@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.
Files changed (49) hide show
  1. package/LICENSE +201 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +214 -0
  4. package/README.zh.md +100 -0
  5. package/lib/background-start.d.ts +207 -0
  6. package/lib/background-start.d.ts.map +1 -0
  7. package/lib/background-start.js +354 -0
  8. package/lib/background-start.js.map +1 -0
  9. package/lib/catalog.d.ts +99 -0
  10. package/lib/catalog.d.ts.map +1 -0
  11. package/lib/catalog.js +197 -0
  12. package/lib/catalog.js.map +1 -0
  13. package/lib/epoch-collector.d.ts +126 -0
  14. package/lib/epoch-collector.d.ts.map +1 -0
  15. package/lib/epoch-collector.js +243 -0
  16. package/lib/epoch-collector.js.map +1 -0
  17. package/lib/index.d.ts +62 -0
  18. package/lib/index.d.ts.map +1 -0
  19. package/lib/index.js +143 -0
  20. package/lib/index.js.map +1 -0
  21. package/lib/preload-tools.d.ts +66 -0
  22. package/lib/preload-tools.d.ts.map +1 -0
  23. package/lib/preload-tools.js +101 -0
  24. package/lib/preload-tools.js.map +1 -0
  25. package/lib/registry.d.ts +49 -0
  26. package/lib/registry.d.ts.map +1 -0
  27. package/lib/registry.js +66 -0
  28. package/lib/registry.js.map +1 -0
  29. package/lib/resume-capture.d.ts +107 -0
  30. package/lib/resume-capture.d.ts.map +1 -0
  31. package/lib/resume-capture.js +232 -0
  32. package/lib/resume-capture.js.map +1 -0
  33. package/lib/sanitize-filter.d.ts +27 -0
  34. package/lib/sanitize-filter.d.ts.map +1 -0
  35. package/lib/sanitize-filter.js +95 -0
  36. package/lib/sanitize-filter.js.map +1 -0
  37. package/lib/strip-instructions.d.ts +47 -0
  38. package/lib/strip-instructions.d.ts.map +1 -0
  39. package/lib/strip-instructions.js +77 -0
  40. package/lib/strip-instructions.js.map +1 -0
  41. package/lib/suppress-settled.d.ts +45 -0
  42. package/lib/suppress-settled.d.ts.map +1 -0
  43. package/lib/suppress-settled.js +80 -0
  44. package/lib/suppress-settled.js.map +1 -0
  45. package/lib/tool.d.ts +49 -0
  46. package/lib/tool.d.ts.map +1 -0
  47. package/lib/tool.js +247 -0
  48. package/lib/tool.js.map +1 -0
  49. package/package.json +78 -0
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Workspace-instruction strip for delegated Task children: a waterfall
3
+ * listener that drops harness `agent-instructions` messages (the CLAUDE.md
4
+ * / AGENTS.md baseline) so named children keep their own agent-file persona
5
+ * instead of also loading the parent's workspace instructions.
6
+ *
7
+ * @module @dsh-cc/subagent-task/strip-instructions
8
+ */
9
+ import type { Context } from '@deepseek-ai/cordis';
10
+ import type { Agent } from '@deepseek-ai/dsh-agent';
11
+ /**
12
+ * Whether an agent is a delegated Task child (`delegationDepth > 0`).
13
+ * Fails closed: a throw from reading the depth treats the agent as a child.
14
+ * @param agent - the agent to classify.
15
+ */
16
+ export declare function isDelegated(agent: Agent): boolean;
17
+ /**
18
+ * Whether a message was injected by the harness `agent-instructions`
19
+ * plugin (workspace CLAUDE.md / AGENTS.md baseline). Duck-typed on
20
+ * `source.kind` so the strip never imports the plugin.
21
+ * @param message - a candidate message with an optional source.
22
+ */
23
+ export declare function isAgentInstructions(message: {
24
+ source?: {
25
+ kind?: string;
26
+ };
27
+ }): boolean;
28
+ /**
29
+ * Mount the `agent/pre-step` listener. After letting the harness
30
+ * `agent-instructions` plugin inject, delegated children lose every
31
+ * `agent-instructions` message both from the enter batch and from the
32
+ * pending inbox; top-level agents pass through untouched.
33
+ *
34
+ * Registered with `prepend`: the cordis waterfall dispatches listeners
35
+ * outermost-first in registration order, and the cc preset mounts
36
+ * `agent-instructions` rows BEFORE `cc-subagent-task`, so an appended
37
+ * strip would sit INSIDE the injector — the injector splices the
38
+ * baseline into the enter batch during unwind, after the inner strip
39
+ * already ran, and the strip would never see it. Prepending keeps the
40
+ * strip outermost so its post-`next()` filter sees the injector's
41
+ * output. (Same mechanism `tool-append-order` documents for
42
+ * `system-prompt/assemble`.)
43
+ * @param ctx - the plug context.
44
+ * @returns an unmount callback.
45
+ */
46
+ export declare function mountStripWorkspaceInstructions(ctx: Context): () => void;
47
+ //# sourceMappingURL=strip-instructions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strip-instructions.d.ts","sourceRoot":"","sources":["../src/strip-instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAmB,MAAM,wBAAwB,CAAA;AAGpE;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAMjD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAAG,OAAO,CAEpF;AAiBD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,IAAI,CAQxE"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Workspace-instruction strip for delegated Task children: a waterfall
3
+ * listener that drops harness `agent-instructions` messages (the CLAUDE.md
4
+ * / AGENTS.md baseline) so named children keep their own agent-file persona
5
+ * instead of also loading the parent's workspace instructions.
6
+ *
7
+ * @module @dsh-cc/subagent-task/strip-instructions
8
+ */
9
+ import { delegationDepthOf } from '@deepseek-ai/dsh-subagent';
10
+ /**
11
+ * Whether an agent is a delegated Task child (`delegationDepth > 0`).
12
+ * Fails closed: a throw from reading the depth treats the agent as a child.
13
+ * @param agent - the agent to classify.
14
+ */
15
+ export function isDelegated(agent) {
16
+ try {
17
+ return delegationDepthOf(agent) !== 0;
18
+ }
19
+ catch {
20
+ return true;
21
+ }
22
+ }
23
+ /**
24
+ * Whether a message was injected by the harness `agent-instructions`
25
+ * plugin (workspace CLAUDE.md / AGENTS.md baseline). Duck-typed on
26
+ * `source.kind` so the strip never imports the plugin.
27
+ * @param message - a candidate message with an optional source.
28
+ */
29
+ export function isAgentInstructions(message) {
30
+ return message.source?.kind === 'agent-instructions';
31
+ }
32
+ /**
33
+ * Remove every pending `agent-instructions` message from the inbox's
34
+ * next-step queue. Copies the queue before iterating because `remove`
35
+ * mutates it. A missing inbox (duck-typed test agents) is a no-op.
36
+ * @param agent - the agent whose inbox is drained.
37
+ */
38
+ function drainInbox(agent) {
39
+ const inbox = agent.inbox;
40
+ if (inbox === undefined)
41
+ return;
42
+ for (const message of [...inbox.nextStep]) {
43
+ if (!isAgentInstructions(message))
44
+ continue;
45
+ inbox.remove(message.id);
46
+ }
47
+ }
48
+ /**
49
+ * Mount the `agent/pre-step` listener. After letting the harness
50
+ * `agent-instructions` plugin inject, delegated children lose every
51
+ * `agent-instructions` message both from the enter batch and from the
52
+ * pending inbox; top-level agents pass through untouched.
53
+ *
54
+ * Registered with `prepend`: the cordis waterfall dispatches listeners
55
+ * outermost-first in registration order, and the cc preset mounts
56
+ * `agent-instructions` rows BEFORE `cc-subagent-task`, so an appended
57
+ * strip would sit INSIDE the injector — the injector splices the
58
+ * baseline into the enter batch during unwind, after the inner strip
59
+ * already ran, and the strip would never see it. Prepending keeps the
60
+ * strip outermost so its post-`next()` filter sees the injector's
61
+ * output. (Same mechanism `tool-append-order` documents for
62
+ * `system-prompt/assemble`.)
63
+ * @param ctx - the plug context.
64
+ * @returns an unmount callback.
65
+ */
66
+ export function mountStripWorkspaceInstructions(ctx) {
67
+ return ctx.on('agent/pre-step', async ({ agent }, next) => {
68
+ const decision = await next();
69
+ if (!isDelegated(agent))
70
+ return decision;
71
+ drainInbox(agent);
72
+ if (decision.kind !== 'enter')
73
+ return decision;
74
+ return { kind: 'enter', messages: decision.messages.filter(msg => !isAgentInstructions(msg)) };
75
+ }, { prepend: true });
76
+ }
77
+ //# sourceMappingURL=strip-instructions.js.map
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AAO,QAAQ,CAAA;QAC9C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,EAAE,CAAA;IAChG,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;AACvB,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Duplicate-notice suppression for inline-collected subagent epochs
3
+ * (`docs/plans/2026-09-10-epoch-collector-dsh-cc.md` §5): a pre-step
4
+ * waterfall listener that DROPs pending `subagent-settled` messages whose
5
+ * `senderSessionId` is in the pop-once "collected" set, so a collected
6
+ * epoch's settlement account lives only in the tool result and never also
7
+ * wakes the parent. A promoted child is simply removed from the set — its
8
+ * notice flows normally.
9
+ *
10
+ * Registration mirrors `mountStripWorkspaceInstructions` (same file's
11
+ * `prepend` ordering rationale): the cc preset mounts `agent-instructions`
12
+ * rows BEFORE `cc-subagent-task`, and waterfall listeners dispatch
13
+ * outermost-first in registration order, so the strip is prepended to stay
14
+ * outermost. This listener is prepended too, which places it outermost of
15
+ * the two — harmless: the two filters are independent (one drops
16
+ * `agent-instructions`, the other `subagent-settled`).
17
+ *
18
+ * Unlike the strip, this listener is NOT scoped by `isDelegated`: the
19
+ * `subagent-settled` notice arrives in the PARENT's inbox, and the parent is
20
+ * typically a top-level agent. The filter is safe to apply to every agent —
21
+ * it only drops `subagent-settled` messages whose sender is in the collected
22
+ * set, and pop-once semantics make double consultation impossible.
23
+ *
24
+ * @module @dsh-cc/subagent-task/suppress-settled
25
+ */
26
+ import type { Context } from '@deepseek-ai/cordis';
27
+ /**
28
+ * Whether a message is a harness settlement notice. Duck-typed on
29
+ * `source.kind` so the filter never imports the continuation plugin.
30
+ * @param message - a candidate message with an optional source.
31
+ */
32
+ export declare function isSubagentSettledNotice(message: {
33
+ source?: {
34
+ kind?: string;
35
+ senderSessionId?: string;
36
+ };
37
+ }): boolean;
38
+ /**
39
+ * Mount the `agent/pre-step` suppression listener. See the module doc for
40
+ * the ordering and scoping rationale.
41
+ * @param ctx - the plug context.
42
+ * @returns an unmount callback.
43
+ */
44
+ export declare function mountSettledNoticeSuppression(ctx: Context): () => void;
45
+ //# sourceMappingURL=suppress-settled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suppress-settled.d.ts","sourceRoot":"","sources":["../src/suppress-settled.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAOlD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAC/C,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CACrD,GAAG,OAAO,CAEV;AA0BD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,IAAI,CActE"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Duplicate-notice suppression for inline-collected subagent epochs
3
+ * (`docs/plans/2026-09-10-epoch-collector-dsh-cc.md` §5): a pre-step
4
+ * waterfall listener that DROPs pending `subagent-settled` messages whose
5
+ * `senderSessionId` is in the pop-once "collected" set, so a collected
6
+ * epoch's settlement account lives only in the tool result and never also
7
+ * wakes the parent. A promoted child is simply removed from the set — its
8
+ * notice flows normally.
9
+ *
10
+ * Registration mirrors `mountStripWorkspaceInstructions` (same file's
11
+ * `prepend` ordering rationale): the cc preset mounts `agent-instructions`
12
+ * rows BEFORE `cc-subagent-task`, and waterfall listeners dispatch
13
+ * outermost-first in registration order, so the strip is prepended to stay
14
+ * outermost. This listener is prepended too, which places it outermost of
15
+ * the two — harmless: the two filters are independent (one drops
16
+ * `agent-instructions`, the other `subagent-settled`).
17
+ *
18
+ * Unlike the strip, this listener is NOT scoped by `isDelegated`: the
19
+ * `subagent-settled` notice arrives in the PARENT's inbox, and the parent is
20
+ * typically a top-level agent. The filter is safe to apply to every agent —
21
+ * it only drops `subagent-settled` messages whose sender is in the collected
22
+ * set, and pop-once semantics make double consultation impossible.
23
+ *
24
+ * @module @dsh-cc/subagent-task/suppress-settled
25
+ */
26
+ import { isCollectedForSuppression, releaseCollectedForSuppression, } from "./epoch-collector.js";
27
+ /**
28
+ * Whether a message is a harness settlement notice. Duck-typed on
29
+ * `source.kind` so the filter never imports the continuation plugin.
30
+ * @param message - a candidate message with an optional source.
31
+ */
32
+ export function isSubagentSettledNotice(message) {
33
+ return message.source?.kind === 'subagent-settled';
34
+ }
35
+ /** Whether a settled notice's sender is currently marked collected. */
36
+ function isMarked(message) {
37
+ const sender = message.source?.senderSessionId;
38
+ return sender !== undefined && isCollectedForSuppression(String(sender));
39
+ }
40
+ /**
41
+ * Remove every pending settlement notice of a collected child from the
42
+ * inbox's next-step queue, popping the collected entry. Copies the queue
43
+ * before iterating because `remove` mutates it. A missing inbox
44
+ * (duck-typed test agents) is a no-op.
45
+ */
46
+ function drainInbox(agent) {
47
+ const inbox = agent.inbox;
48
+ if (inbox === undefined || inbox.nextStep === undefined)
49
+ return;
50
+ for (const message of [...inbox.nextStep]) {
51
+ if (!isSubagentSettledNotice(message) || !isMarked(message))
52
+ continue;
53
+ releaseCollectedForSuppression(String(message.source?.senderSessionId));
54
+ inbox.remove(message.id);
55
+ }
56
+ }
57
+ /**
58
+ * Mount the `agent/pre-step` suppression listener. See the module doc for
59
+ * the ordering and scoping rationale.
60
+ * @param ctx - the plug context.
61
+ * @returns an unmount callback.
62
+ */
63
+ export function mountSettledNoticeSuppression(ctx) {
64
+ return ctx.on('agent/pre-step', async ({ agent }, next) => {
65
+ const decision = await next();
66
+ drainInbox(agent);
67
+ if (decision.kind !== 'enter')
68
+ return decision;
69
+ return {
70
+ kind: 'enter',
71
+ messages: decision.messages.filter(msg => {
72
+ if (!isSubagentSettledNotice(msg) || !isMarked(msg))
73
+ return true;
74
+ releaseCollectedForSuppression(String(msg.source?.senderSessionId));
75
+ return false;
76
+ }),
77
+ };
78
+ }, { prepend: true });
79
+ }
80
+ //# sourceMappingURL=suppress-settled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suppress-settled.js","sourceRoot":"","sources":["../src/suppress-settled.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,OAAO,EACL,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,sBAAsB,CAAA;AAE7B;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAEvC;IACC,OAAQ,OAAO,CAAC,MAAwC,EAAE,IAAI,KAAK,kBAAkB,CAAA;AACvF,CAAC;AAED,uEAAuE;AACvE,SAAS,QAAQ,CAAC,OAAiE;IACjF,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,eAAe,CAAA;IAC9C,OAAO,MAAM,KAAK,SAAS,IAAI,yBAAyB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;AAC1E,CAAC;AAED;;;;;GAKG;AACH,SAAS,UAAU,CAAC,KAAY;IAC9B,MAAM,KAAK,GAAG,KAAK,CAAC,KAEP,CAAA;IACb,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAM;IAC/D,KAAK,MAAM,OAAO,IAAI,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1C,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,SAAQ;QACrE,8BAA8B,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAA;QACvE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAC1B,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAAC,GAAY;IACxD,OAAO,GAAG,CAAC,EAAE,CAAC,gBAAgB,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAA4B,EAAE;QAClF,MAAM,QAAQ,GAAG,MAAM,IAAI,EAAE,CAAA;QAC7B,UAAU,CAAC,KAAK,CAAC,CAAA;QACjB,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO;YAAE,OAAO,QAAQ,CAAA;QAC9C,OAAO;YACL,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;gBACvC,IAAI,CAAC,uBAAuB,CAAC,GAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAY,CAAC;oBAAE,OAAO,IAAI,CAAA;gBAClF,8BAA8B,CAAC,MAAM,CAAE,GAAG,CAAC,MAAmD,EAAE,eAAe,CAAC,CAAC,CAAA;gBACjH,OAAO,KAAK,CAAA;YACd,CAAC,CAAC;SACH,CAAA;IACH,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;AACvB,CAAC"}
package/lib/tool.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The CC-compatible Task tool: `subagent_type` dispatch over the per-workspace
3
+ * `.claude/agents` definitions discovered by the AgentRegistry.
4
+ *
5
+ * The internal tool name is `subagent_fork` so the CC display-name mapping
6
+ * (Task) and permission/hook rows keyed on it keep working. The harness rows
7
+ * `tool-subagent` and `tool-subagent-fork` are disabled in the cc preset in
8
+ * favour of this definition — see `packages/preset/cc/agent.cordis.yml`.
9
+ *
10
+ * Dispatch rules:
11
+ * - `subagent_type` omitted (or the `general-purpose` sentinel) → a fresh
12
+ * spawn of the caller, no definition participation, no parent history.
13
+ * - `subagent_type` equal to the `fork` sentinel → a conversation-inheriting
14
+ * fork of the caller (CC `subagent_type: "fork"`). The sentinel wins over a
15
+ * workspace file of the same name; `.claude/agents/fork.md` is unreachable.
16
+ * - A type matching a definition under the session cwd → spawn with the
17
+ * definition's system prompt delivered as the child `persona`, the model's
18
+ * task text as the first user message, a routes-resolved `agentOptions`
19
+ * override, and the definition's tool restriction (sanitized of tool names
20
+ * this composition no longer registers).
21
+ * - Any other type → an error result listing the available types.
22
+ *
23
+ * The seam's capability contract (`assertCapabilities`) is honoured
24
+ * transitively: spawn and fork both support persona/toolFilter/depthLimit, so
25
+ * every field this tool forwards is legal.
26
+ *
27
+ * The background/collect start mechanics (env kill-switch parsing, capacity
28
+ * guard, pin preallocation, `startBackground`/`collectForeground`) live in
29
+ * `./background-start.ts`; the public policy names are re-exported here to
30
+ * keep the module's public surface unchanged.
31
+ *
32
+ * @module @dsh-cc/subagent-task/tool
33
+ */
34
+ import type { Context } from '@deepseek-ai/cordis';
35
+ import type { AgentRegistry } from './registry.ts';
36
+ import { SpawnPinCapture } from './resume-capture.ts';
37
+ export { MAX_LIVE_CONTINUABLE_CHILDREN, CLAUDE_CODE_DISABLE_BACKGROUND_TASKS, backgroundTasksDisabled, } from './background-start.ts';
38
+ /** The registered tool name (the CC display mapping surfaces it as `Task`). */
39
+ export declare const TASK_TOOL = "subagent_fork";
40
+ /**
41
+ * Register the Task tool.
42
+ * @param ctx - the plug context.
43
+ * @param registry - the per-workspace definition cache.
44
+ * @param capture - the spawn-time resume-pin capture; undefined (the default,
45
+ * no `resumePins` plugin config) writes no pins and runs no preflight.
46
+ * @returns the registration disposer, or undefined when the tools seam is absent.
47
+ */
48
+ export declare function registerTaskTool(ctx: Context, registry: AgentRegistry, capture?: SpawnPinCapture): (() => void) | undefined;
49
+ //# sourceMappingURL=tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAMlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAYrD,OAAO,EACL,6BAA6B,EAC7B,oCAAoC,EACpC,uBAAuB,GACxB,MAAM,uBAAuB,CAAA;AAE9B,+EAA+E;AAC/E,eAAO,MAAM,SAAS,kBAAkB,CAAA;AA8CxC;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,eAAe,GACxB,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAkL1B"}
package/lib/tool.js ADDED
@@ -0,0 +1,247 @@
1
+ /**
2
+ * The CC-compatible Task tool: `subagent_type` dispatch over the per-workspace
3
+ * `.claude/agents` definitions discovered by the AgentRegistry.
4
+ *
5
+ * The internal tool name is `subagent_fork` so the CC display-name mapping
6
+ * (Task) and permission/hook rows keyed on it keep working. The harness rows
7
+ * `tool-subagent` and `tool-subagent-fork` are disabled in the cc preset in
8
+ * favour of this definition — see `packages/preset/cc/agent.cordis.yml`.
9
+ *
10
+ * Dispatch rules:
11
+ * - `subagent_type` omitted (or the `general-purpose` sentinel) → a fresh
12
+ * spawn of the caller, no definition participation, no parent history.
13
+ * - `subagent_type` equal to the `fork` sentinel → a conversation-inheriting
14
+ * fork of the caller (CC `subagent_type: "fork"`). The sentinel wins over a
15
+ * workspace file of the same name; `.claude/agents/fork.md` is unreachable.
16
+ * - A type matching a definition under the session cwd → spawn with the
17
+ * definition's system prompt delivered as the child `persona`, the model's
18
+ * task text as the first user message, a routes-resolved `agentOptions`
19
+ * override, and the definition's tool restriction (sanitized of tool names
20
+ * this composition no longer registers).
21
+ * - Any other type → an error result listing the available types.
22
+ *
23
+ * The seam's capability contract (`assertCapabilities`) is honoured
24
+ * transitively: spawn and fork both support persona/toolFilter/depthLimit, so
25
+ * every field this tool forwards is legal.
26
+ *
27
+ * The background/collect start mechanics (env kill-switch parsing, capacity
28
+ * guard, pin preallocation, `startBackground`/`collectForeground`) live in
29
+ * `./background-start.ts`; the public policy names are re-exported here to
30
+ * keep the module's public surface unchanged.
31
+ *
32
+ * @module @dsh-cc/subagent-task/tool
33
+ */
34
+ import { defineTool } from '@dsh-cc/tools';
35
+ import { cwdOf } from '@dsh-cc/memory';
36
+ import { toAgentOptions } from '@dsh-cc/model-aliases';
37
+ import { preloadDeferredFilterTools, renderPreloadLines } from "./preload-tools.js";
38
+ import { sanitizeToolFilter } from "./sanitize-filter.js";
39
+ import { backgroundTasksDisabled, collectForeground, preparedBackground, startBackground, wantsBackground, } from "./background-start.js";
40
+ export { MAX_LIVE_CONTINUABLE_CHILDREN, CLAUDE_CODE_DISABLE_BACKGROUND_TASKS, backgroundTasksDisabled, } from "./background-start.js";
41
+ /** The registered tool name (the CC display mapping surfaces it as `Task`). */
42
+ export const TASK_TOOL = 'subagent_fork';
43
+ /** The sentinel a model uses to ask for a plain spawn with no definition. */
44
+ const GENERAL_PURPOSE = 'general-purpose';
45
+ /** The sentinel a model uses to inherit the parent's completed-turn prefix. */
46
+ const FORK_SENTINEL = 'fork';
47
+ /** The default delegation-depth cap for a Task child (matches the harness default). */
48
+ const DEFAULT_MAX_DEPTH = 3;
49
+ /** The upstream harness issue that keeps fork children one-shot. */
50
+ const FORK_BACKGROUND_ISSUE = 'deepseek-harness#2124';
51
+ /**
52
+ * Tool names this composition keeps restrictable without registering a
53
+ * visible definition. The cc preset disables the two harness subagent tool
54
+ * rows (`subagent` + `subagent_fork`) in favour of this tool, so the CC
55
+ * frontmatter `Task` translation `['subagent', 'subagent_fork']` must stay in
56
+ * the restrictable universe even though `subagent` is only reserved (not
57
+ * registered — one visible Task is enough). `workflow` is the deferred row's
58
+ * name for the same reason.
59
+ *
60
+ * `subagent_fork` itself needs no reservation: `registerTaskTool` registers
61
+ * the visible definition below, and `restrict()` accepts registered names.
62
+ * Filter sanitization reads the live `ctx.tools.view().restrictableNames` set,
63
+ * so these reservations (plus every registered row and every mounted MCP tool)
64
+ * are exactly the names a subagent toolFilter may carry.
65
+ */
66
+ const RESERVED_TOOL_NAMES = ['subagent', 'workflow'];
67
+ /**
68
+ * Register the Task tool.
69
+ * @param ctx - the plug context.
70
+ * @param registry - the per-workspace definition cache.
71
+ * @param capture - the spawn-time resume-pin capture; undefined (the default,
72
+ * no `resumePins` plugin config) writes no pins and runs no preflight.
73
+ * @returns the registration disposer, or undefined when the tools seam is absent.
74
+ */
75
+ export function registerTaskTool(ctx, registry, capture) {
76
+ const tools = ctx.get('tools');
77
+ if (tools === undefined)
78
+ return undefined;
79
+ // Keep the disabled harness `subagent` row's name restrictable (the CC
80
+ // frontmatter `Task` translates to both `subagent` and `subagent_fork`), and
81
+ // `workflow` for the deferred workflow row.
82
+ for (const name of RESERVED_TOOL_NAMES)
83
+ tools.reserve(name);
84
+ return tools.register(defineTool({
85
+ name: TASK_TOOL,
86
+ description: 'Delegate a well-scoped task to a subagent. The child starts with a fresh conversation: '
87
+ + 'write a self-contained prompt (paths, constraints, what to return). Pass `subagent_type` '
88
+ + 'to run a named agent from the session workspace (`.claude/agents`) — see the "Available '
89
+ + 'subagents" section of the system prompt for the current list. Omit `subagent_type` (or '
90
+ + 'use "general-purpose") for a plain spawn that inherits your tools but not your history. '
91
+ + 'Pass `subagent_type: "fork"` to inherit completed parent turns (and the prompt cache, '
92
+ + 'when the child stays on the same model). The child runs to completion and returns its '
93
+ + 'final text. Unknown types fail with the available list. '
94
+ + 'Omit `run_in_background` (foreground) when this turn\u2019s answer to the human depends on '
95
+ + 'the child: the call blocks until the child finishes and returns its final text. Pass '
96
+ + '`run_in_background: true` when the human can keep talking while the child works: the call '
97
+ + 'returns promptly once the child has accepted its first turn (with its `agentId`), and you '
98
+ + 'are told when it finishes via a waking message; synthesize on the wake, do not poll. '
99
+ + 'A definition with `background: true` backgrounds on omit; pass `run_in_background: false` '
100
+ + 'when this turn needs that child\u2019s result \u2014 explicit true/false always win over the pin. '
101
+ + 'Continue a background child later with `send_message` addressed to its id; inspect it with '
102
+ + '`list_agents` and stop its current turn with `interrupt_agent`. '
103
+ + 'A foreground wait may be user-promoted to background while it runs: if a tool result '
104
+ + 'carries `status: \'async_launched\'` with `backgroundedByUser: true`, treat it exactly '
105
+ + 'like a background launch — the result arrives as a later wake; do not poll. '
106
+ + 'Note: `fork` cannot run in the background (upstream harness issue #2124).',
107
+ parameters: {
108
+ subagent_type: {
109
+ type: 'string',
110
+ description: 'Named agent from `.claude/agents`, or the sentinels "general-purpose" (fresh spawn) '
111
+ + 'and "fork" (inherit completed parent turns). "fork" is reserved and wins over a '
112
+ + 'workspace file of the same name.',
113
+ },
114
+ description: {
115
+ type: 'string',
116
+ required: true,
117
+ description: 'A short (3-5 word) task label, for display.',
118
+ },
119
+ prompt: {
120
+ type: 'string',
121
+ required: true,
122
+ description: 'The task text delivered to the child as its first user message.',
123
+ },
124
+ run_in_background: {
125
+ type: 'boolean',
126
+ description: 'Explicit true starts a durable background child (returns its agentId; the report or '
127
+ + 'finish notice arrives as a waking message) and explicit false forces foreground \u2014 '
128
+ + 'both win over a definition pin. Omitted: background when the definition pins '
129
+ + '`background: true`, foreground otherwise.',
130
+ },
131
+ },
132
+ output: {
133
+ schema: {
134
+ type: 'object',
135
+ additionalProperties: false,
136
+ properties: {
137
+ text: { type: 'string', required: true },
138
+ status: { type: 'string', enum: ['completed', 'async_launched'] },
139
+ agentId: { type: 'string' },
140
+ backgroundedByUser: { type: 'boolean' },
141
+ },
142
+ },
143
+ render: (_args, value) => [
144
+ { type: 'text', text: value.text },
145
+ ],
146
+ },
147
+ isConcurrencySafe: () => true,
148
+ async execute(args, exec) {
149
+ const agent = exec.agent;
150
+ if (agent === undefined) {
151
+ throw new Error('subagent_fork requires a calling agent (exec.agent was undefined)');
152
+ }
153
+ const seam = ctx.get('subagents');
154
+ if (seam === undefined)
155
+ throw new Error('subagent_fork unavailable: no subagents seam');
156
+ const type = args.subagent_type?.trim();
157
+ const base = {
158
+ label: args.description,
159
+ prompt: [{ type: 'text', text: args.prompt }],
160
+ parent: agent,
161
+ signal: exec.signal,
162
+ maxDepth: DEFAULT_MAX_DEPTH,
163
+ };
164
+ const disabled = backgroundTasksDisabled();
165
+ if (type === undefined || type.length === 0 || type === GENERAL_PURPOSE) {
166
+ if (wantsBackground(args, undefined, disabled)) {
167
+ return startBackground(seam, preparedBackground(base, capture), capture);
168
+ }
169
+ return collectForeground(ctx, seam, preparedBackground(base, capture), capture, exec);
170
+ }
171
+ if (type === FORK_SENTINEL) {
172
+ // Rejected BEFORE any seam call: fork children are one-shot until the
173
+ // upstream harness continuable-fork prefix-reuse issue lands.
174
+ if (wantsBackground(args, undefined, disabled)) {
175
+ throw new Error('subagent_type "fork" cannot run in the background: fork children are one-shot '
176
+ + `until upstream harness issue ${FORK_BACKGROUND_ISSUE} resolves. Workaround: use a `
177
+ + 'plain background spawn instead (omit subagent_type, or name a definition) with '
178
+ + 'run_in_background: true.');
179
+ }
180
+ const run = await seam.start(FORK_SENTINEL, base);
181
+ return settle(run);
182
+ }
183
+ const root = cwdOf(agent);
184
+ const definition = await registry.resolve(root, type);
185
+ if (definition === undefined) {
186
+ const available = (await registry.list(root)).map(def => def.agentType).join(', ');
187
+ throw new Error(`unknown subagent_type "${type}"`
188
+ + (available.length > 0 ? `; available in this workspace: ${available}` : '; this workspace defines no agents'));
189
+ }
190
+ const routes = ctx.get('ccModelRoutes');
191
+ const agentOptions = toAgentOptions(routes?.resolve(definition.model));
192
+ // LIVE known set, read at execute time so MCP tools mounted or deferred
193
+ // after this plugin's apply (including hash-suffixed public names) are
194
+ // all restrictable candidates for the child's filter. Pass the calling
195
+ // agent: MCP tools live on the standing-scope layer, which the global
196
+ // view (no scope) does not include.
197
+ const knownNames = tools.view?.(agent).restrictableNames ?? new Set();
198
+ const toolFilter = definition.toolRestriction !== undefined
199
+ ? sanitizeToolFilter(definition.toolRestriction, message => ctx.logger.warn(message), knownNames)
200
+ : undefined;
201
+ // Spawn-time pre-activation (named definitions only): explicit deferred
202
+ // MCP names in the raw `tools:` allow-list are activated through the
203
+ // duck-typed toolSearch seam BEFORE the child starts, on BOTH dispatch
204
+ // paths. Activation is process-global — every admitting agent's schema
205
+ // grows after the spawn.
206
+ const preloadText = renderPreloadLines(preloadDeferredFilterTools({
207
+ raw: definition.toolRestriction,
208
+ sanitized: toolFilter,
209
+ toolSearch: ctx.get('toolSearch'),
210
+ agent,
211
+ tools,
212
+ warn: message => ctx.logger.warn(message),
213
+ }));
214
+ const folded = {
215
+ ...base,
216
+ persona: definition.systemPrompt,
217
+ ...(toolFilter !== undefined ? { toolFilter } : {}),
218
+ ...(agentOptions !== undefined ? { agentOptions } : {}),
219
+ };
220
+ if (wantsBackground(args, definition, disabled)) {
221
+ const result = await startBackground(seam, preparedBackground(folded, capture, definition, routes), capture);
222
+ return preloadText === '' ? result : { ...result, text: `${result.text}\n${preloadText}` };
223
+ }
224
+ const result = await collectForeground(ctx, seam, preparedBackground(folded, capture, definition, routes), capture, exec);
225
+ return preloadText === '' ? result : { ...result, text: `${result.text}\n${preloadText}` };
226
+ },
227
+ }));
228
+ }
229
+ /** Await a run's terminal result and project it onto the tool output shape. */
230
+ async function settle(run) {
231
+ let result;
232
+ try {
233
+ result = await run.result;
234
+ }
235
+ catch (error) {
236
+ throw new Error(`subagent run failed: ${error.message}`);
237
+ }
238
+ if (result.stopReason !== 'completed') {
239
+ throw new Error(`subagent run stopped with reason "${result.stopReason}"`);
240
+ }
241
+ const text = (result.output ?? [])
242
+ .filter(block => block.type === 'text')
243
+ .map(block => block.text ?? '')
244
+ .join('');
245
+ return { text, status: 'completed' };
246
+ }
247
+ //# sourceMappingURL=tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.js","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC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