Files
deepseek-harness/packages/computer-use/computer-use/src/index.ts
T
imccyu 5e7206f6c6 refactor(exports): retire obsolete subpaths with compatible brand APIs (#8215)
* refactor(exports): consolidate type entries and remove obsolete subpaths

* fix(exports): preserve constructors while retiring brand subpaths

* fix(exports): retain guide relocation after parent squash
2026-11-11 08:39:14 +00:00

49 lines
1.5 KiB
TypeScript

/**
* Exclusive named registration for the computer-use capability.
* @module @deepseek-ai/dsh-computer-use
*/
import { Context, Service } from '@deepseek-ai/cordis'
import type { ComputerUseProviderName } from './types.ts'
declare module '@deepseek-ai/cordis' {
interface Context {
computerUse: ComputerUseRegistry
}
}
/** Owns one optional provider registration in the shared computer-use service. */
export class ComputerUseRegistry extends Service {
private registration: ComputerUseProviderName | undefined
constructor(ctx: Context) {
super(ctx, 'computerUse')
}
/** Name of the registered provider, including while its resources are closing. */
get providerName(): ComputerUseProviderName | undefined {
return this.registration
}
/**
* Reserve the sole provider slot until the contribution is disposed.
* A second registration fails even when it repeats the current name. Providers
* must stop their tools and await owned work before releasing this registration.
* @param name - provider-owned name used in registration diagnostics.
* @returns the effect disposer for this exact registration.
*/
register(name: ComputerUseProviderName): () => Promise<void> {
if (this.registration !== undefined) {
throw new Error(`computer use provider "${this.registration}" is already registered`)
}
return this.ctx.effect(() => {
this.registration = name
return () => {
this.registration = undefined
}
}, 'computerUse.register()')
}
}
export default ComputerUseRegistry