|
|
@@ -1,7 +1,5 @@
|
|
|
/**
|
|
|
- * Subagent seam vocabulary: the request/result/capability types a
|
|
|
- * {@link SubagentProvider} consumes and produces. No runtime code — types
|
|
|
- * only, per the package convention.
|
|
|
+ * Request, result, and capability contracts for {@link SubagentProvider}.
|
|
|
*
|
|
|
* @module @deepseek-ai/dsh-subagent/types
|
|
|
*/
|
|
|
@@ -17,7 +15,7 @@ export type SubagentRunId = Branded<'SubagentRunId'>
|
|
|
|
|
|
/**
|
|
|
* Brand a string as a {@link SubagentRunId}.
|
|
|
- * @param id - the raw id string (the service mints UUIDs; tests may pass fixtures).
|
|
|
+ * @param id - the raw run id.
|
|
|
* @returns the same string, branded.
|
|
|
*/
|
|
|
export function SubagentRunId(id: string): SubagentRunId {
|
|
|
@@ -30,16 +28,13 @@ export function SubagentRunId(id: string): SubagentRunId {
|
|
|
* is rejected with a typed error rather than accepted-then-ignored (the "fail loud, no silent
|
|
|
* degradation" rule). These static flags cover features needed before a run exists; runtime
|
|
|
* capabilities such as steering and resume are optional {@link SubagentRun} methods whose presence
|
|
|
- * is the capability.
|
|
|
+ * is the capability. Each flag corresponds one-to-one to a {@link SubagentStartRequest} option:
|
|
|
+ * `depthLimit` to `maxDepth`; the other names match.
|
|
|
*/
|
|
|
export interface SubagentCapabilities {
|
|
|
- /** Honor {@link SubagentStartRequest.outputSchema} (structured final output). */
|
|
|
readonly outputSchema: boolean
|
|
|
- /** Enforce {@link SubagentStartRequest.maxDepth} (recursion cap). */
|
|
|
readonly depthLimit: boolean
|
|
|
- /** Enforce {@link SubagentStartRequest.toolFilter} (child tool scoping). */
|
|
|
readonly toolFilter: boolean
|
|
|
- /** Honor {@link SubagentStartRequest.persona} (a per-child persona). */
|
|
|
readonly persona: boolean
|
|
|
}
|
|
|
|
|
|
@@ -50,16 +45,12 @@ export interface SubagentCapabilities {
|
|
|
* passes it to {@link SubagentProvider.start}.
|
|
|
*/
|
|
|
export interface SubagentStartRequest {
|
|
|
- /** The task/prompt for the child agent (a user message in the child session). */
|
|
|
+ /** Content delivered as the child's user message. */
|
|
|
readonly prompt: ContentBlock[]
|
|
|
/**
|
|
|
- * The spawning ("parent") agent — the one whose tool call started this
|
|
|
- * subagent. REQUIRED: in-process backends read `parent.session.header` for
|
|
|
- * the working directory, the `parentSession` lineage to stamp on the child,
|
|
|
- * and the parent's delegation depth. The out-of-process backend (ACP) reads
|
|
|
- * exactly one field — the session header's cwd, the child's workspace when
|
|
|
- * no deployment `cwd` override is configured; nothing else crosses the
|
|
|
- * process boundary.
|
|
|
+ * The spawning agent. In-process providers derive workspace, lineage, and
|
|
|
+ * delegation depth from its durable session state. ACP reads only its cwd,
|
|
|
+ * and only when no deployment `cwd` override is configured.
|
|
|
*/
|
|
|
readonly parent: Agent
|
|
|
/**
|
|
|
@@ -70,7 +61,6 @@ export interface SubagentStartRequest {
|
|
|
* afterward.
|
|
|
*/
|
|
|
readonly signal: AbortSignal
|
|
|
- /** Per-child agent options (model and plugin-defined extension fields). */
|
|
|
readonly agentOptions?: AgentOptions
|
|
|
/**
|
|
|
* Object-rooted JSON Schema within `assertObjectJsonSchema`'s enforced subset. Start rejects
|
|
|
@@ -112,9 +102,9 @@ export interface SubagentStartRequest {
|
|
|
export interface SubagentStopReasonMap {
|
|
|
/** The child finished its turn normally. */
|
|
|
completed: 'completed'
|
|
|
- /** The run was cancelled by its request signal or by disposal. */
|
|
|
+ /** Cancelled through the request signal or disposal. */
|
|
|
aborted: 'aborted'
|
|
|
- /** The child failed (model error, transport error). */
|
|
|
+ /** Model or transport failure. */
|
|
|
error: 'error'
|
|
|
/** The child hit its token ceiling before finishing. */
|
|
|
'max-tokens': 'max-tokens'
|
|
|
@@ -170,9 +160,8 @@ export interface SubagentRun {
|
|
|
*/
|
|
|
readonly result: Promise<SubagentResult>
|
|
|
/**
|
|
|
- * Cancel remaining work, reach child quiescence, and release the run's
|
|
|
- * resources (in-process: dispose the owned agent and remove its session;
|
|
|
- * ACP: kill and reap the subprocess). Idempotent.
|
|
|
+ * Cancel remaining work, reach child quiescence, and release resources.
|
|
|
+ * Idempotent.
|
|
|
*/
|
|
|
dispose(): Promise<void>
|
|
|
/**
|
|
|
@@ -188,12 +177,9 @@ export interface SubagentRun {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * A subagent backend: one transport for running a child agent (in-process
|
|
|
- * spawn/fork, ACP to another process, …). Implementations register under a
|
|
|
- * unique name via {@link SubagentService.registerProvider}; multiple providers
|
|
|
- * coexist in one context (unlike the single-implementation bash seam). The
|
|
|
- * Providers are trusted same-process implementations; callers treat their
|
|
|
- * descriptors and returned values as borrowed immutable data.
|
|
|
+ * One registered transport for running child agents. Providers are trusted
|
|
|
+ * same-process implementations; callers treat descriptors and returned values
|
|
|
+ * as borrowed immutable data.
|
|
|
*/
|
|
|
export interface SubagentProvider {
|
|
|
/** Unique registry name (e.g. `spawn`, `fork`, `acp`). */
|