@dsh-cc/subagent-task 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.i18n.yaml +6 -0
- package/README.md +214 -0
- package/README.zh.md +100 -0
- package/lib/background-start.d.ts +207 -0
- package/lib/background-start.d.ts.map +1 -0
- package/lib/background-start.js +354 -0
- package/lib/background-start.js.map +1 -0
- package/lib/catalog.d.ts +99 -0
- package/lib/catalog.d.ts.map +1 -0
- package/lib/catalog.js +197 -0
- package/lib/catalog.js.map +1 -0
- package/lib/epoch-collector.d.ts +126 -0
- package/lib/epoch-collector.d.ts.map +1 -0
- package/lib/epoch-collector.js +243 -0
- package/lib/epoch-collector.js.map +1 -0
- package/lib/index.d.ts +62 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +143 -0
- package/lib/index.js.map +1 -0
- package/lib/preload-tools.d.ts +66 -0
- package/lib/preload-tools.d.ts.map +1 -0
- package/lib/preload-tools.js +101 -0
- package/lib/preload-tools.js.map +1 -0
- package/lib/registry.d.ts +49 -0
- package/lib/registry.d.ts.map +1 -0
- package/lib/registry.js +66 -0
- package/lib/registry.js.map +1 -0
- package/lib/resume-capture.d.ts +107 -0
- package/lib/resume-capture.d.ts.map +1 -0
- package/lib/resume-capture.js +232 -0
- package/lib/resume-capture.js.map +1 -0
- package/lib/sanitize-filter.d.ts +27 -0
- package/lib/sanitize-filter.d.ts.map +1 -0
- package/lib/sanitize-filter.js +95 -0
- package/lib/sanitize-filter.js.map +1 -0
- package/lib/strip-instructions.d.ts +47 -0
- package/lib/strip-instructions.d.ts.map +1 -0
- package/lib/strip-instructions.js +77 -0
- package/lib/strip-instructions.js.map +1 -0
- package/lib/suppress-settled.d.ts +45 -0
- package/lib/suppress-settled.d.ts.map +1 -0
- package/lib/suppress-settled.js +80 -0
- package/lib/suppress-settled.js.map +1 -0
- package/lib/tool.d.ts +49 -0
- package/lib/tool.d.ts.map +1 -0
- package/lib/tool.js +247 -0
- package/lib/tool.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Task tool's background/collect start mechanics: env kill-switch parsing,
|
|
3
|
+
* the §3.6 capacity guard, capability probes, request preparation (pin
|
|
4
|
+
* preallocation), and the two dispatch paths — `startBackground` (durable
|
|
5
|
+
* continuable child, returns immediately) and `collectForeground` (inline
|
|
6
|
+
* first-epoch collection through the epoch collector, promotable via Ctrl+B).
|
|
7
|
+
*
|
|
8
|
+
* Pure mechanics shared by the tool definition in `./tool.ts`; no behavior
|
|
9
|
+
* here beyond what `tool.ts` already performed — this module is a structural
|
|
10
|
+
* split of that file.
|
|
11
|
+
*
|
|
12
|
+
* @module @dsh-cc/subagent-task/background-start
|
|
13
|
+
*/
|
|
14
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
15
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
16
|
+
import type { AgentDefinition, ToolRestriction } from '@dsh-cc/claude-code-agents';
|
|
17
|
+
import type { DetailedRoute, ModelRoutes } from '@dsh-cc/model-aliases';
|
|
18
|
+
import { SpawnPinCapture } from './resume-capture.ts';
|
|
19
|
+
/** Fresh-child provider: no parent conversation (CC Task default). */
|
|
20
|
+
export declare const PROVIDER_SPAWN = "spawn";
|
|
21
|
+
/**
|
|
22
|
+
* Per-parent admission limit for continuable children (UX plan §3.6): no
|
|
23
|
+
* upstream resident-children cap exists, so the Task tool refuses a new
|
|
24
|
+
* continuable start when the parent already has this many live children —
|
|
25
|
+
* counted directly as `listChildren` entries with `activity: 'running'`.
|
|
26
|
+
* A safety valve, not a scheduling policy.
|
|
27
|
+
*/
|
|
28
|
+
export declare const MAX_LIVE_CONTINUABLE_CHILDREN = 25;
|
|
29
|
+
/**
|
|
30
|
+
* The env kill switch (UX plan §3.4): a non-empty value other than
|
|
31
|
+
* case-insensitive `0`/`false` disables backgrounding-by-default.
|
|
32
|
+
*/
|
|
33
|
+
export declare const CLAUDE_CODE_DISABLE_BACKGROUND_TASKS = "CLAUDE_CODE_DISABLE_BACKGROUND_TASKS";
|
|
34
|
+
/** A structural subset of the subagents seam the tool dispatches through. */
|
|
35
|
+
export interface ContinuableStart {
|
|
36
|
+
childId: string;
|
|
37
|
+
messageId: string;
|
|
38
|
+
}
|
|
39
|
+
export interface SubagentsLike {
|
|
40
|
+
start(name: string, request: {
|
|
41
|
+
label?: string;
|
|
42
|
+
prompt: readonly {
|
|
43
|
+
type: 'text';
|
|
44
|
+
text: string;
|
|
45
|
+
}[];
|
|
46
|
+
parent: Agent;
|
|
47
|
+
signal: AbortSignal;
|
|
48
|
+
agentOptions?: Record<string, string>;
|
|
49
|
+
toolFilter?: ToolRestriction;
|
|
50
|
+
maxDepth?: number;
|
|
51
|
+
persona?: string;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
result: Promise<{
|
|
54
|
+
stopReason: string;
|
|
55
|
+
output?: readonly {
|
|
56
|
+
type: string;
|
|
57
|
+
text?: string;
|
|
58
|
+
}[];
|
|
59
|
+
}>;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Duck-typed continuable-creation entry (harness `ctx.subagents.startContinuable`):
|
|
63
|
+
* establishes a durable child that accepts follow-up turns by its `childId`.
|
|
64
|
+
* A seam without it cannot serve background dispatch.
|
|
65
|
+
*/
|
|
66
|
+
startContinuable?(spec: {
|
|
67
|
+
provider: string;
|
|
68
|
+
label: string;
|
|
69
|
+
/** Caller-reserved durable id (becomes the child's session id). */
|
|
70
|
+
childId?: string;
|
|
71
|
+
request: {
|
|
72
|
+
prompt: readonly {
|
|
73
|
+
type: 'text';
|
|
74
|
+
text: string;
|
|
75
|
+
}[];
|
|
76
|
+
parent: Agent;
|
|
77
|
+
agentOptions?: Record<string, string>;
|
|
78
|
+
toolFilter?: ToolRestriction;
|
|
79
|
+
maxDepth?: number;
|
|
80
|
+
persona?: string;
|
|
81
|
+
};
|
|
82
|
+
signal: AbortSignal;
|
|
83
|
+
}): Promise<ContinuableStart>;
|
|
84
|
+
getProvider(name: string): unknown;
|
|
85
|
+
list(): string[];
|
|
86
|
+
/**
|
|
87
|
+
* Duck-typed interrupt (harness `ctx.subagents.interrupt`): cancels a live
|
|
88
|
+
* child's current turn; admission is synchronous and an absent/settled
|
|
89
|
+
* target is an accepted no-op. Used by the epoch collector's abort path.
|
|
90
|
+
* Absent → abort degrades to a prompt resolve without interrupting.
|
|
91
|
+
*/
|
|
92
|
+
interrupt?(childId: string, authority: {
|
|
93
|
+
kind: 'ancestor';
|
|
94
|
+
agent: Agent;
|
|
95
|
+
}): void;
|
|
96
|
+
/**
|
|
97
|
+
* Duck-typed `listChildren` (harness `ctx.subagents.listChildren`): the
|
|
98
|
+
* durable children of one parent session with a store-snapshot `activity`.
|
|
99
|
+
* Used by the §3.6 capacity guard. Absent → the guard degrades open.
|
|
100
|
+
*/
|
|
101
|
+
listChildren?(parentSessionId: string, signal?: AbortSignal): Promise<{
|
|
102
|
+
kind: string;
|
|
103
|
+
activity?: string;
|
|
104
|
+
}[]>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The background request shape: everything `startContinuable` forwards except
|
|
108
|
+
* the provider/label envelope and the signal, which live at the spec level.
|
|
109
|
+
*/
|
|
110
|
+
export type BackgroundRequest = {
|
|
111
|
+
label: string;
|
|
112
|
+
prompt: readonly {
|
|
113
|
+
type: 'text';
|
|
114
|
+
text: string;
|
|
115
|
+
}[];
|
|
116
|
+
parent: Agent;
|
|
117
|
+
signal: AbortSignal;
|
|
118
|
+
maxDepth?: number;
|
|
119
|
+
persona?: string;
|
|
120
|
+
agentOptions?: Record<string, string>;
|
|
121
|
+
toolFilter?: ToolRestriction;
|
|
122
|
+
/**
|
|
123
|
+
* Caller-reserved durable child id — preallocated by the capture flow so
|
|
124
|
+
* the pin can be written before the child exists (plan §4.5 step 1).
|
|
125
|
+
*/
|
|
126
|
+
childId?: string;
|
|
127
|
+
/** Capture-only metadata (never forwarded to the seam): definition. */
|
|
128
|
+
captureDefinition?: AgentDefinition;
|
|
129
|
+
/** Capture-only metadata: the atomic model-selector resolution. */
|
|
130
|
+
captureSelector?: DetailedRoute;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Parse `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` (UX plan §3.4): a non-empty
|
|
134
|
+
* value other than a case-insensitive `0`/`false` disables the kill switch's
|
|
135
|
+
* targets (backgrounding-by-default pins and, from Slice 3, promotion).
|
|
136
|
+
* Explicit `run_in_background` arguments stay honored both ways — declared
|
|
137
|
+
* as a partial-parity deviation because upstream's exact precedence is
|
|
138
|
+
* unverified.
|
|
139
|
+
* @param env - the environment to read; defaults to `process.env`.
|
|
140
|
+
*/
|
|
141
|
+
export declare function backgroundTasksDisabled(env?: Record<string, string | undefined>): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Precedence for the background decision: explicit `run_in_background` always wins
|
|
144
|
+
* (true and false alike), otherwise the definition's `background: true` pin applies,
|
|
145
|
+
* otherwise foreground. A `true`-string pin cannot reach this check — the agents
|
|
146
|
+
* parser rejects a non-boolean `background` at load time. With the
|
|
147
|
+
* `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` kill switch armed, the pin path is
|
|
148
|
+
* disabled (omissions collect in foreground); explicit arguments still win.
|
|
149
|
+
*/
|
|
150
|
+
export declare function wantsBackground(args: {
|
|
151
|
+
run_in_background?: boolean;
|
|
152
|
+
}, definition: {
|
|
153
|
+
background?: boolean;
|
|
154
|
+
} | undefined, disabled: boolean): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Thread the preallocated childId and the capture metadata into a background
|
|
157
|
+
* request. Without capture (no `resumePins` config) the request is returned
|
|
158
|
+
* unchanged — zero behavior difference.
|
|
159
|
+
*/
|
|
160
|
+
export declare function preparedBackground(request: BackgroundRequest, capture: SpawnPinCapture | undefined, definition?: AgentDefinition, routes?: ModelRoutes): BackgroundRequest;
|
|
161
|
+
/**
|
|
162
|
+
* The §3.6 capacity guard (both `startBackground` and the collect path):
|
|
163
|
+
* refuse a new continuable child when the parent already has
|
|
164
|
+
* {@link MAX_LIVE_CONTINUABLE_CHILDREN} live children — counted directly as
|
|
165
|
+
* `listChildren` entries with `activity: 'running'`. Degrades open when the
|
|
166
|
+
* seam lacks `listChildren` or the listing fails: a safety valve must never
|
|
167
|
+
* block starts on its own infrastructure trouble.
|
|
168
|
+
*/
|
|
169
|
+
export declare function assertLiveCapacity(seam: SubagentsLike, parent: Agent, signal: AbortSignal): Promise<void>;
|
|
170
|
+
/** Capability checks shared by `startBackground` and the collect path. */
|
|
171
|
+
export declare function assertContinuableCapable(seam: SubagentsLike): void;
|
|
172
|
+
/**
|
|
173
|
+
* Dispatch a FOREGROUND non-fork call by collecting the child's first epoch
|
|
174
|
+
* inline through the epoch collector (`docs/plans/2026-09-10-epoch-collector-dsh-cc.md`).
|
|
175
|
+
* Performs the same pin preallocation, pre-start pin write, and
|
|
176
|
+
* tombstone-on-throw as `startBackground` — a foreground-launched child is
|
|
177
|
+
* pinnable/resumable exactly like a background one. The child's settlement
|
|
178
|
+
* notice is suppressed (pop-once) because the epoch is consumed here.
|
|
179
|
+
*/
|
|
180
|
+
export declare function collectForeground(ctx: Context, seam: SubagentsLike, request: BackgroundRequest, capture: SpawnPinCapture | undefined, exec: {
|
|
181
|
+
agent?: Agent;
|
|
182
|
+
signal: AbortSignal;
|
|
183
|
+
token?: unknown;
|
|
184
|
+
}): Promise<{
|
|
185
|
+
text: string;
|
|
186
|
+
status: 'completed';
|
|
187
|
+
} | {
|
|
188
|
+
text: string;
|
|
189
|
+
status: 'async_launched';
|
|
190
|
+
agentId: string;
|
|
191
|
+
backgroundedByUser: true;
|
|
192
|
+
}>;
|
|
193
|
+
/**
|
|
194
|
+
* Dispatch a background call as a durable continuable child on the `spawn`
|
|
195
|
+
* provider. The definition folding (persona, sanitized toolFilter,
|
|
196
|
+
* alias-resolved agentOptions, maxDepth) happened before this call — cold
|
|
197
|
+
* resume never re-captures the parent's policy, so the creation input must
|
|
198
|
+
* already be final. Resolves once the child accepted its initial prompt.
|
|
199
|
+
* Capability gaps (seam without `startContinuable`, provider without
|
|
200
|
+
* `prepareContinuable`) surface as actionable tool errors naming the cause.
|
|
201
|
+
*/
|
|
202
|
+
export declare function startBackground(seam: SubagentsLike, request: BackgroundRequest, capture?: SpawnPinCapture): Promise<{
|
|
203
|
+
text: string;
|
|
204
|
+
status: 'async_launched';
|
|
205
|
+
agentId: string;
|
|
206
|
+
}>;
|
|
207
|
+
//# sourceMappingURL=background-start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background-start.d.ts","sourceRoot":"","sources":["../src/background-start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAElF,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEvE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,sEAAsE;AACtE,eAAO,MAAM,cAAc,UAAU,CAAA;AAErC;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,KAAK,CAAA;AAE/C;;;GAGG;AACH,eAAO,MAAM,oCAAoC,yCAAyC,CAAA;AAE1F,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,MAAM,EAAE,SAAS;YAAE,IAAI,EAAE,MAAM,CAAC;Y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2
|
+
* The Task tool's background/collect start mechanics: env kill-switch parsing,
|
|
3
|
+
* the §3.6 capacity guard, capability probes, request preparation (pin
|
|
4
|
+
* preallocation), and the two dispatch paths — `startBackground` (durable
|
|
5
|
+
* continuable child, returns immediately) and `collectForeground` (inline
|
|
6
|
+
* first-epoch collection through the epoch collector, promotable via Ctrl+B).
|
|
7
|
+
*
|
|
8
|
+
* Pure mechanics shared by the tool definition in `./tool.ts`; no behavior
|
|
9
|
+
* here beyond what `tool.ts` already performed — this module is a structural
|
|
10
|
+
* split of that file.
|
|
11
|
+
*
|
|
12
|
+
* @module @dsh-cc/subagent-task/background-start
|
|
13
|
+
*/
|
|
14
|
+
import { randomUUID } from 'node:crypto';
|
|
15
|
+
import { cwdOf } from '@dsh-cc/memory';
|
|
16
|
+
import { collectFirstEpoch } from "./epoch-collector.js";
|
|
17
|
+
import { SpawnPinCapture } from "./resume-capture.js";
|
|
18
|
+
/** Fresh-child provider: no parent conversation (CC Task default). */
|
|
19
|
+
export const PROVIDER_SPAWN = 'spawn';
|
|
20
|
+
/**
|
|
21
|
+
* Per-parent admission limit for continuable children (UX plan §3.6): no
|
|
22
|
+
* upstream resident-children cap exists, so the Task tool refuses a new
|
|
23
|
+
* continuable start when the parent already has this many live children —
|
|
24
|
+
* counted directly as `listChildren` entries with `activity: 'running'`.
|
|
25
|
+
* A safety valve, not a scheduling policy.
|
|
26
|
+
*/
|
|
27
|
+
export const MAX_LIVE_CONTINUABLE_CHILDREN = 25;
|
|
28
|
+
/**
|
|
29
|
+
* The env kill switch (UX plan §3.4): a non-empty value other than
|
|
30
|
+
* case-insensitive `0`/`false` disables backgrounding-by-default.
|
|
31
|
+
*/
|
|
32
|
+
export const CLAUDE_CODE_DISABLE_BACKGROUND_TASKS = 'CLAUDE_CODE_DISABLE_BACKGROUND_TASKS';
|
|
33
|
+
/**
|
|
34
|
+
* Parse `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` (UX plan §3.4): a non-empty
|
|
35
|
+
* value other than a case-insensitive `0`/`false` disables the kill switch's
|
|
36
|
+
* targets (backgrounding-by-default pins and, from Slice 3, promotion).
|
|
37
|
+
* Explicit `run_in_background` arguments stay honored both ways — declared
|
|
38
|
+
* as a partial-parity deviation because upstream's exact precedence is
|
|
39
|
+
* unverified.
|
|
40
|
+
* @param env - the environment to read; defaults to `process.env`.
|
|
41
|
+
*/
|
|
42
|
+
export function backgroundTasksDisabled(env = process.env) {
|
|
43
|
+
const raw = env[CLAUDE_CODE_DISABLE_BACKGROUND_TASKS];
|
|
44
|
+
if (raw === undefined || raw === '')
|
|
45
|
+
return false;
|
|
46
|
+
const lower = raw.toLowerCase();
|
|
47
|
+
return lower !== '0' && lower !== 'false';
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Precedence for the background decision: explicit `run_in_background` always wins
|
|
51
|
+
* (true and false alike), otherwise the definition's `background: true` pin applies,
|
|
52
|
+
* otherwise foreground. A `true`-string pin cannot reach this check — the agents
|
|
53
|
+
* parser rejects a non-boolean `background` at load time. With the
|
|
54
|
+
* `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` kill switch armed, the pin path is
|
|
55
|
+
* disabled (omissions collect in foreground); explicit arguments still win.
|
|
56
|
+
*/
|
|
57
|
+
export function wantsBackground(args, definition, disabled) {
|
|
58
|
+
if (args.run_in_background === true)
|
|
59
|
+
return true;
|
|
60
|
+
if (args.run_in_background === false)
|
|
61
|
+
return false;
|
|
62
|
+
if (disabled)
|
|
63
|
+
return false;
|
|
64
|
+
return definition?.background === true;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Thread the preallocated childId and the capture metadata into a background
|
|
68
|
+
* request. Without capture (no `resumePins` config) the request is returned
|
|
69
|
+
* unchanged — zero behavior difference.
|
|
70
|
+
*/
|
|
71
|
+
export function preparedBackground(request, capture, definition, routes) {
|
|
72
|
+
if (capture === undefined)
|
|
73
|
+
return request;
|
|
74
|
+
return {
|
|
75
|
+
...request,
|
|
76
|
+
childId: capture.preallocateChildId(),
|
|
77
|
+
...(definition !== undefined ? { captureDefinition: definition } : {}),
|
|
78
|
+
captureSelector: routes !== undefined
|
|
79
|
+
? routes.resolveDetailed(definition?.model)
|
|
80
|
+
: SpawnPinCapture.inheritSelector(definition?.model),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The §3.6 capacity guard (both `startBackground` and the collect path):
|
|
85
|
+
* refuse a new continuable child when the parent already has
|
|
86
|
+
* {@link MAX_LIVE_CONTINUABLE_CHILDREN} live children — counted directly as
|
|
87
|
+
* `listChildren` entries with `activity: 'running'`. Degrades open when the
|
|
88
|
+
* seam lacks `listChildren` or the listing fails: a safety valve must never
|
|
89
|
+
* block starts on its own infrastructure trouble.
|
|
90
|
+
*/
|
|
91
|
+
export async function assertLiveCapacity(seam, parent, signal) {
|
|
92
|
+
if (typeof seam.listChildren !== 'function')
|
|
93
|
+
return;
|
|
94
|
+
let children;
|
|
95
|
+
try {
|
|
96
|
+
children = await seam.listChildren(parent.id, signal);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const live = children.filter(child => child.kind === 'child' && child.activity === 'running').length;
|
|
102
|
+
if (live >= MAX_LIVE_CONTINUABLE_CHILDREN) {
|
|
103
|
+
throw new Error(`parent has ${MAX_LIVE_CONTINUABLE_CHILDREN} live subagents; /agents stop <id> to `
|
|
104
|
+
+ 'release one, or let children settle');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/** Capability checks shared by `startBackground` and the collect path. */
|
|
108
|
+
export function assertContinuableCapable(seam) {
|
|
109
|
+
if (typeof seam.startContinuable !== 'function') {
|
|
110
|
+
throw new Error('background subagents are unavailable: the subagents seam does not expose '
|
|
111
|
+
+ 'startContinuable. Background subagents require a subagent service with the '
|
|
112
|
+
+ 'continuable-creation capability (prepareContinuable on the provider) and a '
|
|
113
|
+
+ 'session-persistence backend; run this Task in the foreground instead.');
|
|
114
|
+
}
|
|
115
|
+
const provider = seam.getProvider(PROVIDER_SPAWN);
|
|
116
|
+
if (provider !== undefined && provider !== null && provider.prepareContinuable === undefined) {
|
|
117
|
+
throw new Error(`background subagents are unavailable: provider "${PROVIDER_SPAWN}" does not support `
|
|
118
|
+
+ 'continuable children (UNSUPPORTED_CAPABILITY: no prepareContinuable). Background '
|
|
119
|
+
+ 'subagents require a provider that implements the continuable-creation capability '
|
|
120
|
+
+ 'and a session-persistence backend; run this Task in the foreground instead.');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Per-reason failure copy for the collect path (UX plan §4 Slice 3 item 2):
|
|
125
|
+
* mirrors `settle`'s contract — `completed` becomes the tool result, every
|
|
126
|
+
* other stop reason throws with a reason-specific, actionable message.
|
|
127
|
+
*/
|
|
128
|
+
function stopReasonMessage(childId, stopReason) {
|
|
129
|
+
switch (stopReason) {
|
|
130
|
+
case 'error':
|
|
131
|
+
return `subagent ${childId} run failed: the child hit a model or transport failure (stopReason "error").`;
|
|
132
|
+
case 'max-tokens':
|
|
133
|
+
return `subagent ${childId} stopped with reason "max-tokens": the child hit its token ceiling before finishing.`;
|
|
134
|
+
case 'refusal':
|
|
135
|
+
return `subagent ${childId} stopped with reason "refusal": the child declined the task.`;
|
|
136
|
+
case 'aborted':
|
|
137
|
+
return `subagent ${childId} was interrupted (stopReason "aborted"); it may still be resumed — /agents for status.`;
|
|
138
|
+
default:
|
|
139
|
+
return `subagent ${childId} stopped with reason "${stopReason}".`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The user-promotion result (Ctrl+B, UX plan §3.4): the foreground wait is
|
|
144
|
+
* released to background — the model sees the SAME contract as an explicit
|
|
145
|
+
* `run_in_background: true` launch, with `backgroundedByUser: true` marking
|
|
146
|
+
* the promotion. The child's report/finish notice arrives later as a wake
|
|
147
|
+
* (its suppression mark was removed by `promote()` — exactly-once delivery).
|
|
148
|
+
*/
|
|
149
|
+
function promotedResult(childId, captureWarning) {
|
|
150
|
+
return {
|
|
151
|
+
text: `Background subagent started (agentId: ${childId}). The user moved the foreground wait `
|
|
152
|
+
+ 'to the background while it ran (status async_launched, backgroundedByUser: true); treat '
|
|
153
|
+
+ 'this exactly like a background launch — the result arrives as a later waking message, '
|
|
154
|
+
+ 'so do not compose on an inline result. '
|
|
155
|
+
+ 'Control it by that id: `list_agents` for status, `send_message` to continue the same '
|
|
156
|
+
+ 'conversation, `interrupt_agent` to stop its current turn.'
|
|
157
|
+
+ (captureWarning !== undefined
|
|
158
|
+
? `\nresume pin capture failed: ${captureWarning}; this child will resume with legacy semantics`
|
|
159
|
+
: ''),
|
|
160
|
+
status: 'async_launched',
|
|
161
|
+
agentId: childId,
|
|
162
|
+
backgroundedByUser: true,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Project the collect path's epoch outcome onto the tool output shape
|
|
167
|
+
* (`settle`'s contract): `completed` → the closing message's text blocks;
|
|
168
|
+
* any other stop reason — including the abort path's prompt-synthetic
|
|
169
|
+
* `aborted` — throws with per-reason copy.
|
|
170
|
+
*/
|
|
171
|
+
function outcomeToResult(childId, outcome, captureWarning) {
|
|
172
|
+
// A promoted outcome never reaches here (the collect caller returns the
|
|
173
|
+
// async_launched result first); defensively it is an unexpected terminal.
|
|
174
|
+
if (outcome.kind !== 'epoch' || outcome.stopReason !== 'completed') {
|
|
175
|
+
throw new Error(stopReasonMessage(childId, outcome.kind === 'epoch' ? outcome.stopReason : outcome.kind));
|
|
176
|
+
}
|
|
177
|
+
const text = (outcome.output ?? [])
|
|
178
|
+
.filter(block => block.type === 'text')
|
|
179
|
+
.map(block => block.text ?? '')
|
|
180
|
+
.join('');
|
|
181
|
+
return {
|
|
182
|
+
text: text
|
|
183
|
+
+ (captureWarning !== undefined
|
|
184
|
+
? `\nresume pin capture failed: ${captureWarning}; this child will resume with legacy semantics`
|
|
185
|
+
: ''),
|
|
186
|
+
status: 'completed',
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Dispatch a FOREGROUND non-fork call by collecting the child's first epoch
|
|
191
|
+
* inline through the epoch collector (`docs/plans/2026-09-10-epoch-collector-dsh-cc.md`).
|
|
192
|
+
* Performs the same pin preallocation, pre-start pin write, and
|
|
193
|
+
* tombstone-on-throw as `startBackground` — a foreground-launched child is
|
|
194
|
+
* pinnable/resumable exactly like a background one. The child's settlement
|
|
195
|
+
* notice is suppressed (pop-once) because the epoch is consumed here.
|
|
196
|
+
*/
|
|
197
|
+
export async function collectForeground(ctx, seam, request, capture, exec) {
|
|
198
|
+
const agent = exec.agent;
|
|
199
|
+
if (agent === undefined) {
|
|
200
|
+
throw new Error('subagent_fork requires a calling agent (exec.agent was undefined)');
|
|
201
|
+
}
|
|
202
|
+
await assertLiveCapacity(seam, agent, exec.signal);
|
|
203
|
+
assertContinuableCapable(seam);
|
|
204
|
+
const { label, prompt, parent, signal, childId, captureDefinition, captureSelector, ...rest } = request;
|
|
205
|
+
// The watch map keys on the durable child id, so the collect path ALWAYS
|
|
206
|
+
// preallocates one — via the capture flow when pins are armed, otherwise a
|
|
207
|
+
// fresh id (the child's session id, exactly as the harness would mint it).
|
|
208
|
+
const durableChildId = childId ?? randomUUID();
|
|
209
|
+
// §4.5 step 2 (parity with startBackground): the pin is written BEFORE the
|
|
210
|
+
// creation call; capture trouble becomes an explicit captureWarning line.
|
|
211
|
+
let captureWarning;
|
|
212
|
+
if (capture !== undefined && childId !== undefined && captureSelector !== undefined) {
|
|
213
|
+
captureWarning = await capture.write({
|
|
214
|
+
parentSessionId: parent.id,
|
|
215
|
+
label,
|
|
216
|
+
childId,
|
|
217
|
+
definition: captureDefinition,
|
|
218
|
+
selector: captureSelector,
|
|
219
|
+
parentRoute: parent.options,
|
|
220
|
+
toolFilter: 'toolFilter' in rest ? rest.toolFilter : undefined,
|
|
221
|
+
cwd: cwdOf(parent),
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
let startFailed = false;
|
|
225
|
+
try {
|
|
226
|
+
const outcome = await collectFirstEpoch({
|
|
227
|
+
bus: ctx,
|
|
228
|
+
childId: durableChildId,
|
|
229
|
+
agent,
|
|
230
|
+
signal,
|
|
231
|
+
subagents: seam,
|
|
232
|
+
// The promotion-registry key (§6): parent session + this call's
|
|
233
|
+
// registry token, so the TUI busy-branch Ctrl+B can find (and promote
|
|
234
|
+
// or abort) every armed foreground collect of this session.
|
|
235
|
+
parentSessionId: agent.id,
|
|
236
|
+
toolCallToken: exec.token !== undefined ? String(exec.token) : randomUUID(),
|
|
237
|
+
start: async () => {
|
|
238
|
+
try {
|
|
239
|
+
await seam.startContinuable({
|
|
240
|
+
provider: PROVIDER_SPAWN,
|
|
241
|
+
label,
|
|
242
|
+
childId: durableChildId,
|
|
243
|
+
request: {
|
|
244
|
+
prompt,
|
|
245
|
+
parent,
|
|
246
|
+
...('persona' in rest ? { persona: rest.persona } : {}),
|
|
247
|
+
...('toolFilter' in rest ? { toolFilter: rest.toolFilter } : {}),
|
|
248
|
+
...('agentOptions' in rest ? { agentOptions: rest.agentOptions } : {}),
|
|
249
|
+
...('maxDepth' in rest ? { maxDepth: rest.maxDepth } : {}),
|
|
250
|
+
},
|
|
251
|
+
signal,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
startFailed = true;
|
|
256
|
+
throw error;
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
if (outcome.kind === 'promoted')
|
|
261
|
+
return promotedResult(durableChildId, captureWarning);
|
|
262
|
+
return outcomeToResult(durableChildId, outcome, captureWarning);
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
// §4.5 step 4 (parity with startBackground): a start that rolled back the
|
|
266
|
+
// creation must not leave the pin behind — tombstone, then rethrow. A
|
|
267
|
+
// non-`completed` epoch terminal or an abort keeps the child (it is
|
|
268
|
+
// resumable), so no tombstone on those.
|
|
269
|
+
if (startFailed && capture !== undefined && childId !== undefined)
|
|
270
|
+
await capture.tombstone(childId);
|
|
271
|
+
const message = error.message ?? String(error);
|
|
272
|
+
if (startFailed
|
|
273
|
+
&& (message.includes('UNSUPPORTED_CAPABILITY') || message.includes('does not support continuable'))) {
|
|
274
|
+
throw new Error(`background subagents are unavailable: ${message}. Background subagents require a `
|
|
275
|
+
+ 'provider that implements the continuable-creation capability (prepareContinuable) '
|
|
276
|
+
+ 'and a session-persistence backend; run this Task in the foreground instead.');
|
|
277
|
+
}
|
|
278
|
+
throw error;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Dispatch a background call as a durable continuable child on the `spawn`
|
|
283
|
+
* provider. The definition folding (persona, sanitized toolFilter,
|
|
284
|
+
* alias-resolved agentOptions, maxDepth) happened before this call — cold
|
|
285
|
+
* resume never re-captures the parent's policy, so the creation input must
|
|
286
|
+
* already be final. Resolves once the child accepted its initial prompt.
|
|
287
|
+
* Capability gaps (seam without `startContinuable`, provider without
|
|
288
|
+
* `prepareContinuable`) surface as actionable tool errors naming the cause.
|
|
289
|
+
*/
|
|
290
|
+
export async function startBackground(seam, request, capture) {
|
|
291
|
+
assertContinuableCapable(seam);
|
|
292
|
+
const { label, prompt, parent, signal, childId, captureDefinition, captureSelector, ...rest } = request;
|
|
293
|
+
// §3.6 capacity guard: refuse before any pin write or creation call.
|
|
294
|
+
await assertLiveCapacity(seam, parent, signal);
|
|
295
|
+
// §4.5 step 2: the pin is written BEFORE the creation call (crash
|
|
296
|
+
// consistency). A failed capture keeps the spawn alive but must never be
|
|
297
|
+
// silent: the returned reason becomes an explicit captureWarning line in
|
|
298
|
+
// the tool result ("this child will resume with legacy semantics").
|
|
299
|
+
let captureWarning;
|
|
300
|
+
if (capture !== undefined && childId !== undefined && captureSelector !== undefined) {
|
|
301
|
+
captureWarning = await capture.write({
|
|
302
|
+
parentSessionId: parent.id,
|
|
303
|
+
label,
|
|
304
|
+
childId,
|
|
305
|
+
definition: captureDefinition,
|
|
306
|
+
selector: captureSelector,
|
|
307
|
+
parentRoute: parent.options,
|
|
308
|
+
toolFilter: 'toolFilter' in rest ? rest.toolFilter : undefined,
|
|
309
|
+
cwd: cwdOf(parent),
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
let started;
|
|
313
|
+
try {
|
|
314
|
+
started = await seam.startContinuable({
|
|
315
|
+
provider: PROVIDER_SPAWN,
|
|
316
|
+
label,
|
|
317
|
+
...(childId !== undefined ? { childId } : {}),
|
|
318
|
+
request: {
|
|
319
|
+
prompt,
|
|
320
|
+
parent,
|
|
321
|
+
...('persona' in rest ? { persona: rest.persona } : {}),
|
|
322
|
+
...('toolFilter' in rest ? { toolFilter: rest.toolFilter } : {}),
|
|
323
|
+
...('agentOptions' in rest ? { agentOptions: rest.agentOptions } : {}),
|
|
324
|
+
...('maxDepth' in rest ? { maxDepth: rest.maxDepth } : {}),
|
|
325
|
+
},
|
|
326
|
+
signal,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
// §4.5 step 4: the creation rolled back fully (no child id), so the pin
|
|
331
|
+
// must not survive it — tombstone, then rethrow the error unchanged.
|
|
332
|
+
if (capture !== undefined && childId !== undefined)
|
|
333
|
+
await capture.tombstone(childId);
|
|
334
|
+
const message = error.message ?? String(error);
|
|
335
|
+
if (message.includes('UNSUPPORTED_CAPABILITY') || message.includes('does not support continuable')) {
|
|
336
|
+
throw new Error(`background subagents are unavailable: ${message}. Background subagents require a `
|
|
337
|
+
+ 'provider that implements the continuable-creation capability (prepareContinuable) '
|
|
338
|
+
+ 'and a session-persistence backend; run this Task in the foreground instead.');
|
|
339
|
+
}
|
|
340
|
+
throw error;
|
|
341
|
+
}
|
|
342
|
+
return {
|
|
343
|
+
text: `Background subagent started (agentId: ${started.childId}). It is running in the `
|
|
344
|
+
+ 'background; its report or finish notice will arrive as a waking message. Control it '
|
|
345
|
+
+ 'by that id: `list_agents` for status, `send_message` to continue the same '
|
|
346
|
+
+ 'conversation, `interrupt_agent` to stop its current turn.'
|
|
347
|
+
+ (captureWarning !== undefined
|
|
348
|
+
? `\nresume pin capture failed: ${captureWarning}; this child will resume with legacy semantics`
|
|
349
|
+
: ''),
|
|
350
|
+
status: 'async_launched',
|
|
351
|
+
agentId: started.childId,
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
//# sourceMappingURL=background-start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background-start.js","sourceRoot":"","sources":["../src/background-start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAIxC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEtC,OAAO,EAAE,iBAAiB,EAAyC,MAAM,sBAAsB,CAAA;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,sEAAsE;AACtE,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAA;AAErC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAA;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,sCAAsC,CAAA;AAyF1F;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAA0C,OAAO,CAAC,GAAG;IAErD,MAAM,GAAG,GAAG,GAAG,CAAC,oCAAoC,CAAC,CAAA;IACrD,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,KAAK,CAAA;IACjD,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAA;IAC/B,OAAO,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,OAAO,CAAA;AAC3C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAqC,EACrC,UAAgD,EAChD,QAAi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