@sema-agent/core 5.20.0 → 5.21.1
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/CHANGELOG.md +19 -0
- package/dist/agents/agent-definition.d.ts +7 -0
- package/dist/agents/agent-transcript-tool.d.ts +30 -0
- package/dist/agents/builtin-agents.d.ts +60 -0
- package/dist/agents/cascade.d.ts +107 -0
- package/dist/agents/cumulative-stats.d.ts +56 -0
- package/dist/agents/observer.d.ts +162 -0
- package/dist/agents/peer-admission.d.ts +95 -0
- package/dist/agents/repair-loop.d.ts +226 -0
- package/dist/agents/retain-ledger.d.ts +141 -0
- package/dist/agents/roster-store.d.ts +105 -0
- package/dist/agents/send-message-tool.d.ts +92 -0
- package/dist/agents/session-util.d.ts +5 -0
- package/dist/agents/subagent-steps.d.ts +66 -0
- package/dist/agents/subagent.d.ts +600 -0
- package/dist/agents/suspend-guard.d.ts +29 -0
- package/dist/agents/teacher.d.ts +75 -0
- package/dist/agents/team.d.ts +120 -1
- package/dist/agents/tool-filter.d.ts +34 -0
- package/dist/agents/verify.d.ts +198 -0
- package/dist/bench/metrics.d.ts +455 -0
- package/dist/brain/anthropic.d.ts +30 -0
- package/dist/brain/circuit-breaker.d.ts +33 -0
- package/dist/brain/context-overflow.d.ts +60 -3
- package/dist/brain/degrading.d.ts +67 -0
- package/dist/brain/errors.d.ts +42 -0
- package/dist/brain/failover.d.ts +15 -0
- package/dist/brain/media-degrade.d.ts +39 -0
- package/dist/brain/model-presets.d.ts +31 -0
- package/dist/brain/open-responses.d.ts +19 -0
- package/dist/brain/openai.d.ts +46 -0
- package/dist/brain/reasoning.d.ts +106 -1
- package/dist/brain/repetition.d.ts +83 -0
- package/dist/brain/request-params.d.ts +56 -0
- package/dist/brain/retry.d.ts +46 -0
- package/dist/brain/routing.d.ts +12 -0
- package/dist/brain/status-sink.d.ts +30 -1
- package/dist/brain/stream-engine.d.ts +147 -0
- package/dist/brain/stream-shared.d.ts +34 -0
- package/dist/brain/terminal-cause.d.ts +31 -0
- package/dist/brain/timeout.d.ts +107 -0
- package/dist/brain/tool-call-id.d.ts +20 -0
- package/dist/brain/tool-call-repair.d.ts +13 -0
- package/dist/config/catalog.d.ts +47 -0
- package/dist/config/defaults.d.ts +33 -0
- package/dist/core/a2a-task-state.d.ts +53 -0
- package/dist/core/a2a.d.ts +51 -0
- package/dist/core/arg-summary.d.ts +62 -0
- package/dist/core/ask-question.d.ts +272 -2
- package/dist/core/auto-compaction.d.ts +467 -0
- package/dist/core/auto-compaction.js +20 -6
- package/dist/core/auto-mode-prompt-assets.d.ts +8 -0
- package/dist/core/auto-mode-prompt.d.ts +27 -0
- package/dist/core/auto-mode.d.ts +54 -3
- package/dist/core/auto-promote.d.ts +100 -0
- package/dist/core/background-agent-store.d.ts +292 -0
- package/dist/core/background-shell.d.ts +110 -0
- package/dist/core/cache-break-detector.d.ts +34 -0
- package/dist/core/canonical-json.d.ts +57 -0
- package/dist/core/checkpoint-store.d.ts +1574 -16
- package/dist/core/compliance.d.ts +30 -0
- package/dist/core/consolidate-scope.d.ts +75 -0
- package/dist/core/context-edit.d.ts +99 -0
- package/dist/core/context-guard.d.ts +46 -0
- package/dist/core/exec-gate.d.ts +44 -0
- package/dist/core/exec-output-tail.d.ts +61 -0
- package/dist/core/file-snapshot-store.d.ts +104 -0
- package/dist/core/fs-write-gate-policy.d.ts +36 -0
- package/dist/core/git-worktree-env.d.ts +31 -0
- package/dist/core/governance-codes.d.ts +19 -0
- package/dist/core/hooks.d.ts +608 -1
- package/dist/core/human-input-projection.d.ts +37 -0
- package/dist/core/human-input-projection.js +13 -0
- package/dist/core/image-downsample.d.ts +74 -0
- package/dist/core/locked-config.d.ts +37 -0
- package/dist/core/lsp-diagnostics.d.ts +77 -0
- package/dist/core/lsp-protocol.d.ts +29 -0
- package/dist/core/lsp-session.d.ts +60 -1
- package/dist/core/lsp.d.ts +150 -1
- package/dist/core/mailbox-store.d.ts +57 -0
- package/dist/core/mcp.d.ts +381 -0
- package/dist/core/media-byte-cap.d.ts +21 -0
- package/dist/core/memory-admission.d.ts +71 -0
- package/dist/core/memory-engine/content-origin.d.ts +64 -0
- package/dist/core/memory-engine/data-plane.d.ts +43 -0
- package/dist/core/memory-engine/dual-root.d.ts +24 -0
- package/dist/core/memory-engine/engine.d.ts +230 -0
- package/dist/core/memory-engine/engine.js +103 -35
- package/dist/core/memory-engine/file-backend.d.ts +155 -0
- package/dist/core/memory-engine/frontmatter.d.ts +16 -0
- package/dist/core/memory-engine/layout.d.ts +217 -0
- package/dist/core/memory-engine/memory-backend-contract.d.ts +12 -0
- package/dist/core/memory-engine/migrate.d.ts +9 -0
- package/dist/core/memory-engine/scan.d.ts +12 -0
- package/dist/core/memory-engine/scope-contract.d.ts +61 -1
- package/dist/core/memory-engine/sync-client.d.ts +87 -0
- package/dist/core/memory-engine/sync.d.ts +60 -0
- package/dist/core/memory-engine/tools.d.ts +41 -0
- package/dist/core/memory-engine/types.d.ts +188 -0
- package/dist/core/memory-recall.d.ts +141 -0
- package/dist/core/memory-vector.d.ts +20 -0
- package/dist/core/memory.d.ts +458 -0
- package/dist/core/message-utils.d.ts +6 -0
- package/dist/core/oracle-isolation.d.ts +69 -0
- package/dist/core/permission-rule-consent.d.ts +138 -0
- package/dist/core/permission-rule-model.d.ts +122 -0
- package/dist/core/permission-rule-store.d.ts +119 -3
- package/dist/core/permission-rules.d.ts +87 -1
- package/dist/core/present-plan-tool.d.ts +20 -0
- package/dist/core/pricing.d.ts +26 -0
- package/dist/core/property-harness.d.ts +86 -0
- package/dist/core/protocol-naming.d.ts +38 -0
- package/dist/core/protocol-table.d.ts +61 -0
- package/dist/core/push-queue.d.ts +1 -0
- package/dist/core/remote-env.d.ts +383 -1
- package/dist/core/retention-policy.d.ts +33 -0
- package/dist/core/retention.d.ts +51 -0
- package/dist/core/roles.d.ts +59 -0
- package/dist/core/runner/active-skill-scope.d.ts +34 -0
- package/dist/core/runner/assemble-result.d.ts +134 -0
- package/dist/core/runner/compaction-call-options.d.ts +97 -1
- package/dist/core/runner/grounding-signal.d.ts +10 -0
- package/dist/core/runner/image.d.ts +17 -0
- package/dist/core/runner/image.js +29 -15
- package/dist/core/runner/memory-consolidation.d.ts +60 -0
- package/dist/core/runner/prepare-memory.d.ts +59 -0
- package/dist/core/runner/prepare-task.d.ts +1011 -2
- package/dist/core/runner/prepare-task.js +12 -11
- package/dist/core/runner/prompt-suggestions.d.ts +7 -0
- package/dist/core/runner/runtask.d.ts +304 -3
- package/dist/core/runner/session-file-state-replay.d.ts +49 -0
- package/dist/core/runner/session-rule-policy.d.ts +58 -0
- package/dist/core/runner/strict-output-schema.d.ts +18 -3
- package/dist/core/runner/synthetic-tools.d.ts +113 -0
- package/dist/core/runner/teardown-bounded.d.ts +34 -0
- package/dist/core/runner/tool-disclosure.d.ts +227 -0
- package/dist/core/runner/tool-output-projection.d.ts +6 -0
- package/dist/core/runner/turn-attachments.d.ts +634 -0
- package/dist/core/runner/usage-accounting.d.ts +32 -0
- package/dist/core/runtime.d.ts +9 -0
- package/dist/core/safe-notify.d.ts +64 -0
- package/dist/core/safety-axis-vocab.d.ts +23 -0
- package/dist/core/safety-merge-corpus.d.ts +37 -0
- package/dist/core/scheduler.d.ts +121 -0
- package/dist/core/secret-env.d.ts +32 -0
- package/dist/core/select-model.d.ts +15 -0
- package/dist/core/sensitive-path-policy.d.ts +42 -0
- package/dist/core/session-policy-store.d.ts +94 -0
- package/dist/core/session-reconcile.d.ts +80 -0
- package/dist/core/session-store.d.ts +85 -0
- package/dist/core/session.d.ts +153 -0
- package/dist/core/shared-memory/contract.d.ts +22 -0
- package/dist/core/shared-memory/normalize.d.ts +123 -2
- package/dist/core/shared-memory/tools.d.ts +14 -0
- package/dist/core/shared-memory/types.d.ts +105 -0
- package/dist/core/shutdown-debug.d.ts +6 -0
- package/dist/core/side-query.d.ts +38 -0
- package/dist/core/side-query.js +6 -1
- package/dist/core/skill-tool-specifier.d.ts +72 -0
- package/dist/core/skills-directory.d.ts +100 -1
- package/dist/core/spec-contract.d.ts +89 -0
- package/dist/core/store-contracts/background-agent-store-contract.d.ts +31 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +26 -0
- package/dist/core/store-contracts/contract-harness.d.ts +20 -0
- package/dist/core/store-contracts/contract-kit-version.d.ts +27 -0
- package/dist/core/store-contracts/file-snapshot-store-contract.d.ts +8 -0
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +42 -0
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +13 -0
- package/dist/core/strategy-store.d.ts +37 -0
- package/dist/core/stub-env.d.ts +7 -0
- package/dist/core/surrogate-safe-slice.d.ts +35 -0
- package/dist/core/task-notification.d.ts +202 -0
- package/dist/core/task-outcome.d.ts +53 -0
- package/dist/core/task-registry-agent.d.ts +337 -1
- package/dist/core/task-registry-monitor.d.ts +12 -0
- package/dist/core/task-registry-shared.d.ts +540 -0
- package/dist/core/task-registry.d.ts +343 -0
- package/dist/core/task-registry.js +13 -2
- package/dist/core/task-tool-shape.d.ts +44 -0
- package/dist/core/tighten-task-spec.d.ts +21 -0
- package/dist/core/tool-detach.d.ts +21 -0
- package/dist/core/tool-errors.d.ts +131 -0
- package/dist/core/tool-errors.js +4 -0
- package/dist/core/tool-name-aliases.d.ts +27 -0
- package/dist/core/tool-policy.d.ts +555 -0
- package/dist/core/tool-result-budget.d.ts +32 -0
- package/dist/core/tool-result-store.d.ts +174 -1
- package/dist/core/tools.d.ts +45 -0
- package/dist/core/trace.d.ts +323 -0
- package/dist/core/types.d.ts +3859 -2
- package/dist/core/untrusted-egress.d.ts +8 -0
- package/dist/core/untrusted-text.d.ts +156 -0
- package/dist/core/usage-window-store.d.ts +95 -0
- package/dist/core/version.d.ts +1 -0
- package/dist/core/warm-resume.d.ts +17 -0
- package/dist/core/wiring-manifest.d.ts +169 -0
- package/dist/core/with-retry.d.ts +24 -0
- package/dist/core/workflow-journal-store.d.ts +160 -0
- package/dist/core/workflow-run-store-contract.d.ts +25 -0
- package/dist/core/workflow-run-store.d.ts +119 -0
- package/dist/engine/compaction/compaction.d.ts +256 -1
- package/dist/engine/compaction/utils.d.ts +94 -0
- package/dist/engine/execution-env/kill-tree.d.ts +29 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +94 -0
- package/dist/engine/harness/agent-harness.d.ts +116 -0
- package/dist/engine/harness/agent-harness.js +3 -14
- package/dist/engine/harness/messages.d.ts +15 -0
- package/dist/engine/harness/types.d.ts +464 -2
- package/dist/engine/llm/diagnostics.d.ts +4 -0
- package/dist/engine/llm/event-stream.d.ts +3 -0
- package/dist/engine/llm/index.d.ts +7 -0
- package/dist/engine/llm/types.d.ts +500 -3
- package/dist/engine/llm/validation.d.ts +3 -0
- package/dist/engine/loop/agent-loop.d.ts +87 -2
- package/dist/engine/loop/runtime-deps.d.ts +7 -0
- package/dist/engine/loop/types.d.ts +424 -0
- package/dist/engine/lsp/frame-decoder.d.ts +13 -0
- package/dist/engine/lsp/node-lsp-manager.d.ts +107 -0
- package/dist/engine/lsp/stdio-lsp-transport.d.ts +7 -0
- package/dist/engine/session/import-validate.d.ts +27 -0
- package/dist/engine/session/log-digest.d.ts +93 -0
- package/dist/engine/session/memory-repo.d.ts +6 -0
- package/dist/engine/session/memory-storage.d.ts +2 -0
- package/dist/engine/session/session.d.ts +75 -0
- package/dist/engine/session/storage-base.d.ts +8 -0
- package/dist/fixtures/index.d.ts +36 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.js +0 -1
- package/dist/internal/harness-types.d.ts +6 -0
- package/dist/internal/harness.d.ts +11 -0
- package/dist/internal/llm.d.ts +6 -0
- package/dist/orchestration/builtin-workflows.d.ts +53 -0
- package/dist/orchestration/dev-vm-script-runner.d.ts +19 -0
- package/dist/orchestration/goal.d.ts +57 -0
- package/dist/orchestration/goal.js +3 -0
- package/dist/orchestration/run-spec.d.ts +42 -0
- package/dist/orchestration/run-workflow-tool.d.ts +169 -0
- package/dist/orchestration/workflow-governance.d.ts +61 -0
- package/dist/orchestration/workflow-meta.d.ts +28 -0
- package/dist/orchestration/workflow-observe.d.ts +60 -0
- package/dist/orchestration/workflow-primitives.d.ts +23 -1
- package/dist/orchestration/workflow-sandbox-conformance.d.ts +38 -0
- package/dist/orchestration/workflow-script-runner.d.ts +88 -0
- package/dist/orchestration/workflow-script-store.d.ts +98 -0
- package/dist/orchestration/workflow-size-guideline.d.ts +67 -0
- package/dist/orchestration/workflow-types.d.ts +169 -2
- package/dist/orchestration/workflow.d.ts +358 -0
- package/dist/prompt-assembly/artifact-store.d.ts +33 -0
- package/dist/prompt-assembly/artifact.d.ts +25 -0
- package/dist/prompt-assembly/assemble.d.ts +20 -0
- package/dist/prompt-assembly/composer.d.ts +29 -0
- package/dist/prompt-assembly/epoch.d.ts +55 -1
- package/dist/prompt-assembly/event-registry.d.ts +35 -0
- package/dist/prompt-assembly/explain.d.ts +12 -0
- package/dist/prompt-assembly/tool-catalog.d.ts +38 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +40 -0
- package/dist/prompt-assembly/types.d.ts +115 -0
- package/dist/prompts/coordinator.d.ts +27 -0
- package/dist/prompts/default.d.ts +539 -0
- package/dist/prompts/simple-sections.d.ts +45 -0
- package/dist/prompts/supervisor.d.ts +66 -0
- package/dist/scenarios/env.d.ts +28 -0
- package/dist/scenarios/full-body.d.ts +50 -0
- package/dist/scenarios/scenario-registry.d.ts +60 -0
- package/dist/scenarios/teacher-quickstart.d.ts +27 -0
- package/dist/server/http.d.ts +17 -0
- package/dist/stores/cc/lockfile.d.ts +6 -0
- package/dist/stores/cc/mailbox-store.d.ts +8 -0
- package/dist/stores/cc/roster-adapter.d.ts +4 -0
- package/dist/stores/cc/sidecar-transcript.d.ts +66 -0
- package/dist/stores/file/background-agent-store.d.ts +24 -0
- package/dist/stores/file/checkpoint-store.d.ts +38 -0
- package/dist/stores/file/file-snapshot-store.d.ts +25 -0
- package/dist/stores/file/fs-atomic.d.ts +155 -0
- package/dist/stores/file/index.d.ts +89 -0
- package/dist/stores/file/mailbox-store.d.ts +36 -0
- package/dist/stores/file/memory-store.d.ts +82 -0
- package/dist/stores/file/permission-rule-store.d.ts +79 -0
- package/dist/stores/file/session-policy-store.d.ts +28 -0
- package/dist/stores/file/session-store.d.ts +40 -0
- package/dist/stores/file/shared-ledger.d.ts +83 -0
- package/dist/stores/file/tool-result-store.d.ts +11 -0
- package/dist/stores/file/usage-window-store.d.ts +18 -0
- package/dist/stores/file/workflow-journal-store.d.ts +100 -0
- package/dist/stores/file/workflow-run-store.d.ts +11 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +282 -0
- package/dist/tools/fs/encoding.d.ts +60 -0
- package/dist/tools/fs/fs-bash.d.ts +133 -0
- package/dist/tools/fs/fs-pdf.d.ts +28 -0
- package/dist/tools/fs/fs-search-tools.d.ts +5 -0
- package/dist/tools/fs/fs-search-tools.js +0 -1
- package/dist/tools/fs/fs-shared.d.ts +360 -0
- package/dist/tools/fs/fs-write.d.ts +16 -0
- package/dist/tools/fs/gh-rate-limit.d.ts +22 -0
- package/dist/tools/fs/index.d.ts +79 -0
- package/dist/tools/fs/notebook.d.ts +56 -0
- package/dist/tools/fs/pdf.d.ts +70 -0
- package/dist/tools/fs/pdf.js +8 -2
- package/dist/tools/fs/repo-map.d.ts +10 -0
- package/dist/tools/fs/safety.d.ts +376 -0
- package/dist/tools/fs/search.d.ts +131 -0
- package/dist/tools/loop-tick.d.ts +24 -0
- package/dist/tools/monitor.d.ts +55 -0
- package/dist/tools/scheduler-tools.d.ts +51 -0
- package/dist/tools/sql-adapters.d.ts +18 -0
- package/dist/tools/sql.d.ts +25 -0
- package/dist/tools/task-list.d.ts +77 -0
- package/dist/tools/todo.d.ts +8 -0
- package/dist/tools/web.d.ts +184 -0
- package/dist/tools/worktree.d.ts +81 -0
- package/package.json +2 -2
- package/dist/tools/gitea-issue.d.ts +0 -13
- package/dist/tools/gitea-issue.js +0 -75
|
@@ -9,20 +9,87 @@ import { SubagentRetainLedger } from "./retain-ledger.js";
|
|
|
9
9
|
import { type PeerSelfRef } from "./peer-admission.js";
|
|
10
10
|
export type { SubagentStep, SubagentEditedFile } from "./subagent-steps.js";
|
|
11
11
|
export declare function notifyResultField(result: string | undefined): string | undefined;
|
|
12
|
+
/** What {@link layeredReviewSample} produced: the text actually sent, plus the honest read/total counts. */
|
|
12
13
|
interface ReviewSample {
|
|
13
14
|
text: string;
|
|
14
15
|
readChars: number;
|
|
15
16
|
totalChars: number;
|
|
17
|
+
/** False ⇒ `text` IS the whole field (short enough to fit the budget); true ⇒ windows + gap markers. */
|
|
16
18
|
sampled: boolean;
|
|
19
|
+
/** How many gap markers THIS sampler emitted — the count a reader can hold the text against. */
|
|
17
20
|
gaps: number;
|
|
18
21
|
}
|
|
22
|
+
/** Layered head/middle/tail sample of `text` under `budget`, with each skipped span marked in band so the
|
|
23
|
+
* reader can see that the material is discontinuous. Exported for tests (window determinism). */
|
|
19
24
|
export declare function layeredReviewSample(text: string, budget?: number, windows?: number): ReviewSample;
|
|
25
|
+
/**
|
|
26
|
+
* 🔴 design/77 §3 / §7 — skill→subagent manifest-scope PROPAGATION (fail-closed). Given the parent task's
|
|
27
|
+
* live skill-manifest snapshot (from `ctx.activeSkillScope()`), build the inherited-scope frames to thread
|
|
28
|
+
* into a spawned child via the trusted {@link RunInternals.inheritedManifestScope} channel, so the child's
|
|
29
|
+
* tool gate inherits the parent skill's deny-narrowing (a child of a manifested skill is at most as capable
|
|
30
|
+
* as the manifest — MONOTONIC).
|
|
31
|
+
*
|
|
32
|
+
* - Parent has NO active manifest (empty/absent snapshot) → return `undefined` (no inheritance; the child
|
|
33
|
+
* behaves exactly as today, backward-compatible).
|
|
34
|
+
* - Parent HAS active manifest frames → return them verbatim (the child seeds them as the LIFO base; its
|
|
35
|
+
* own skill loads can only intersect/narrow further).
|
|
36
|
+
* - Fail-closed: the snapshot is non-empty but its shape is not a recognizable frame array (a future/older
|
|
37
|
+
* Runner, a tampered accessor) → return a SINGLE DENY-ALL `unresolved` frame, so the child runs under a
|
|
38
|
+
* deny-all inherited scope rather than UNMANIFESTED. The safe path is the default.
|
|
39
|
+
*/
|
|
20
40
|
export declare function inheritedManifestScopeFor(snapshot: readonly unknown[] | undefined): RunInternals["inheritedManifestScope"];
|
|
41
|
+
/** Default model-facing name of the delegation tool (CC 2.1.187 `Agent`; legacy alias `Task`). */
|
|
21
42
|
export declare const DEFAULT_SUBAGENT_TOOL_NAME = "Agent";
|
|
43
|
+
/**
|
|
44
|
+
* extraTools 快审 S4 — per-root-spawn-tree cap on `extraTools` factory evaluations. The factory runs
|
|
45
|
+
* once per spawn at EVERY level (the nested delegation tool threads it down), so an unbounded tree is
|
|
46
|
+
* depth × breadth × turns factory calls. 拍值理由: the default maxDepth is 3 (RB-292; it was 5 when this
|
|
47
|
+
* budget was set, so the cap only ever got roomier relative to the tree) and legitimate trees stay
|
|
48
|
+
* well under a few dozen spawns — 64 is comfortable headroom above any real workload while capping the
|
|
49
|
+
* amplification at a constant. Exceeding it degrades THAT spawn to zero injected tools (the child still
|
|
50
|
+
* runs) with the same generic-note + host-sink disclosure as a factory failure (S3 posture).
|
|
51
|
+
*/
|
|
22
52
|
export declare const EXTRA_TOOLS_MAX_FACTORY_CALLS_PER_TREE = 64;
|
|
53
|
+
/** RB-292 — default delegation nesting depth. CC 2.1.220 `bee()` @272064 falls back to `aHu = 3`
|
|
54
|
+
* @272076; the previous value 5 was CC 2.1.201's `Y4t` and is a stale anchor. Semantics (off-by-one)
|
|
55
|
+
* are pinned on {@link SubagentToolOptions.maxDepth}. */
|
|
23
56
|
export declare const DEFAULT_SUBAGENT_MAX_DEPTH = 3;
|
|
57
|
+
/**
|
|
58
|
+
* extraTools 快审 S3 — the FIXED model-facing disclosure for a failed factory evaluation. Deliberately
|
|
59
|
+
* generic: the original error (a registry/config fault) can carry paths/hostnames/credentials, and this
|
|
60
|
+
* note reaches the model face AND the persisted transcript. The raw error goes to
|
|
61
|
+
* {@link SubagentToolOptions.onExtraToolsError} only.
|
|
62
|
+
*/
|
|
24
63
|
export declare const EXTRA_TOOLS_FAILED_NOTE = "note: extraTools evaluation failed \u2014 the injected tool set was skipped for this spawn.";
|
|
64
|
+
/** extraTools 快审 S4 — the fixed model-facing disclosure for a budget-exhausted (skipped) evaluation. */
|
|
25
65
|
export declare const EXTRA_TOOLS_BUDGET_NOTE = "note: extraTools evaluation was skipped \u2014 this spawn tree exhausted its factory-call budget (64); no dynamic tools were injected for this spawn.";
|
|
66
|
+
/**
|
|
67
|
+
* CC206-B 欠账 — the Agent completed card's structured `toolStats` (CC 206:541193-541201 `sfd` schema:
|
|
68
|
+
* seven counters, `.optional()`; counting logic 206:540431-540491 `_my`). CC derives the counts from the
|
|
69
|
+
* child's transcript (assistant `tool_use` blocks) and FOLDS nested delegations' toolStats in via each
|
|
70
|
+
* user message's `toolUseResult.toolStats`; sema counts on the shared forward-event sink instead — the
|
|
71
|
+
* sink re-threads DESCENDANT events too (grandchildren bubble through, see subagent-steps.ts header), so
|
|
72
|
+
* the cumulative semantics match without a fold step. Delegation calls themselves are excluded from every
|
|
73
|
+
* bucket (CC excludes `gi`=Agent and `yU`=Task, 206:540453-540455). `linesAdded`/`linesRemoved` mirror CC
|
|
74
|
+
* `i3r` (206:399357-399375): LINE COUNTS OF THE EDIT ARGUMENTS (new/old_string, Write content, NotebookEdit
|
|
75
|
+
* new_source) — not a real diff; honest to CC's own approximation.
|
|
76
|
+
*
|
|
77
|
+
* RB-303 — ANCHOR REFRESHED to CC 2.1.220 (schema @409081-409090, counting `U2_` @408252-408312).
|
|
78
|
+
* The seven counters below are byte-for-byte the same seven, and the counting rules are unchanged
|
|
79
|
+
* (Agent/Task excluded; nested folds via each user message's `toolUseResult.toolStats`). Two 220
|
|
80
|
+
* facts the 206 anchor predates:
|
|
81
|
+
* • 220 declares an EIGHTH, optional field: `frameCount`. It counts calls to CC's Artifact tool
|
|
82
|
+
* (`F2_ = ARTIFACT_TOOL_NAME` @409045) with `input.action !== "list"`, and it is the one counter
|
|
83
|
+
* that also joins the "did this child do anything at all" sum (@408306-408312). sema has no
|
|
84
|
+
* Artifact tool, so there is no call to count: the field is deliberately NOT added (an
|
|
85
|
+
* always-absent counter is noise on every consumer). Registered as a divergence candidate — if a
|
|
86
|
+
* deployment ever mounts an artifact-shaped tool, this is where it lands.
|
|
87
|
+
* • 220's Agent result carries `modelsUsed` (ordered distinct models, emitted only when length > 1
|
|
88
|
+
* @408398) and `resolvedModel` (@466120-466127) beside toolStats. sema reports the resolved model
|
|
89
|
+
* through `TaskResult.model` and has no mid-run swap history on the delegation card. Also
|
|
90
|
+
* registered rather than added: the swap list needs a per-turn model ledger sema does not keep,
|
|
91
|
+
* and inventing a one-element array would be a face without a mechanism.
|
|
92
|
+
*/
|
|
26
93
|
export interface SubagentToolStats {
|
|
27
94
|
readCount: number;
|
|
28
95
|
searchCount: number;
|
|
@@ -32,18 +99,102 @@ export interface SubagentToolStats {
|
|
|
32
99
|
linesRemoved: number;
|
|
33
100
|
otherToolCount: number;
|
|
34
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* design/135 §0 (Fork 收编) — the BUILT-IN `subagent_type` value that routes an `Agent` call to the fork
|
|
104
|
+
* execution path (CC-exact abstraction shape: fork lives in `Agent.subagent_type`'s value domain, not in a
|
|
105
|
+
* separate tool). Always present in the `subagent_type` enum — with or without `spec.agents` — UNLESS the
|
|
106
|
+
* deployment defines its own agent named "fork" (the definition wins; noted in the tool description).
|
|
107
|
+
*/
|
|
35
108
|
export declare const FORK_SUBAGENT_TYPE = "fork";
|
|
109
|
+
/**
|
|
110
|
+
* The BUILT-IN "general-purpose" `subagent_type` alias (CC 2.1.207 parity — 锚 pretty.js:459482 `oje`:
|
|
111
|
+
* CC's agent registry always contains a built-in `general-purpose` definition with `tools: ["*"]`, and an
|
|
112
|
+
* OMITTED `subagent_type` defaults to it, :492377 `t ?? oje.agentType`). CC-ecosystem prompts/skills
|
|
113
|
+
* therefore hardcode `subagent_type: "general-purpose"` freely. sema's equivalent of that built-in is the
|
|
114
|
+
* plain clean-context delegation (full tool pool, SUBAGENT_PROMPT persona) — so the literal FOLDS to the
|
|
115
|
+
* omitted-type path instead of bouncing as an unknown type. A deployment (or builtin) agent definition of
|
|
116
|
+
* the SAME NAME wins and disables the fold (fork-shadowing precedent, CC merge order: later sources
|
|
117
|
+
* override the built-in entry).
|
|
118
|
+
*/
|
|
36
119
|
export declare const GENERAL_PURPOSE_SUBAGENT_TYPE = "general-purpose";
|
|
120
|
+
/**
|
|
121
|
+
* design/136 §6 盲点① (1.256) + §2.1.a (BREAKING batch) — the fork-GOVERNANCE predicate for the
|
|
122
|
+
* `Agent(subagent_type:"fork")` route (the ONLY fork face since the standalone `Fork` tool was retired,
|
|
123
|
+
* design/136 §2.1: the capability moved wholesale into `Agent.subagent_type`'s value domain — CC-exact shape).
|
|
124
|
+
*
|
|
125
|
+
* `TaskSpec.enableFork` is opt-OUT (design/136 §2.1.a default flip, matching CC — fork is available by
|
|
126
|
+
* default, bounded only by the durable session capability): only an EXPLICIT `enableFork:false` denies
|
|
127
|
+
* (`denied:"task"`); `runtimeCaps.allowFork:false` denies per-principal (`denied:"principal"` —
|
|
128
|
+
* tighten-only, mirrors allowWorkflows). Undefined on both axes ⇒ governance does not object; the
|
|
129
|
+
* capability three-checks in the execute path (insideFork / sessionId / hasSessionFork) still apply.
|
|
130
|
+
*
|
|
131
|
+
* prepare-task computes this once per run and threads it to the Agent tool as `ctx.forkAccess`
|
|
132
|
+
* (Runner-held, never a model argument). A denial is HONEST (`fork.disabled` result), never a silent
|
|
133
|
+
* downgrade to a clean delegation. A directly-constructed `createSubagentTool` outside a Runner has no
|
|
134
|
+
* `ctx.forkAccess` ⇒ capability checks only.
|
|
135
|
+
*/
|
|
37
136
|
export declare function forkGovernanceDenial(enableFork: boolean | undefined, allowFork: boolean | undefined): "task" | "principal" | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* design/135 — the trusted per-call worktree-isolation lane for the Agent tool (CC `isolation: "worktree"`).
|
|
139
|
+
* `mint` creates a detached git worktree under the task root via {@link addWorktree} (throws when the root is
|
|
140
|
+
* not a git repository — the caller surfaces the honest error text); `finish` implements CC's "auto-cleaned
|
|
141
|
+
* if unchanged": the worktree is removed when the child left `git status` clean, and KEPT (returning "kept")
|
|
142
|
+
* when the child made changes, so the parent can inspect/merge before removing it. Runner-filled onto
|
|
143
|
+
* {@link import("../core/types.js").ToolExecuteContext.worktreeIsolation}; never a model argument.
|
|
144
|
+
*/
|
|
38
145
|
export interface SubagentWorktreeIsolation {
|
|
146
|
+
/** Create a detached worktree for a child. Throws when the base root is not a git repository. */
|
|
39
147
|
mint(childId: string): Promise<{
|
|
40
148
|
worktreeDir: string;
|
|
41
149
|
}>;
|
|
150
|
+
/** CC "auto-cleaned if unchanged": remove the worktree when clean, keep it when the child made changes. */
|
|
42
151
|
finish(worktreeDir: string): Promise<"pruned" | "kept">;
|
|
43
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Build the {@link SubagentWorktreeIsolation} helper over a base env + repo root. Called by `prepare-task`
|
|
155
|
+
* (closure over the run's ExecutionEnv/taskRootPath — trusted, mirrors the scheduler/fork mounts). The
|
|
156
|
+
* worktree-rooted env handed to {@link addWorktree} is a thin prototype view over the base env with `destroy`
|
|
157
|
+
* MASKED (an own `destroy: undefined`), so tearing the worktree down can never cascade into destroying the
|
|
158
|
+
* parent's own (possibly factory-owned) env.
|
|
159
|
+
*/
|
|
44
160
|
export declare function createSubagentWorktreeHelper(baseEnv: ExecutionEnv, repoRoot: string): SubagentWorktreeIsolation;
|
|
161
|
+
/** Cap for the inline-defused worker-controlled report metadata lines (blocked_reason / error). Matches the
|
|
162
|
+
* ask-question.ts inline-value convention (300) — a one-line operator-facing reason, not a bulk payload. */
|
|
45
163
|
export declare const REPORT_FIELD_MAX = 300;
|
|
164
|
+
/** The machine-readable failure class stamped on a FAILED sub-agent report (sema form — see below). */
|
|
46
165
|
export type SubagentErrorKind = "rate_limit" | "overloaded" | "timeout" | "network" | "logic" | "governance";
|
|
166
|
+
/**
|
|
167
|
+
* RB-302 — ATTRIBUTION CORRECTED (taxonomy and behavior unchanged; this is a SEMA form, not CC
|
|
168
|
+
* parity). The old header called this "CC 2.1.201 parity (追平批 α 项5)". Re-verified against the CC
|
|
169
|
+
* 2.1.220 corpus, three things are true and none of them support that claim:
|
|
170
|
+
* • CC's `errorKind` lives on an ERROR CLASS (`AgentApiErrorTerminationError` @409103-409110), not
|
|
171
|
+
* on the delegation's report card — the Agent result schema (@409040-409090: usage / toolStats /
|
|
172
|
+
* modelsUsed / resolvedModel) has no `error_kind` field at all;
|
|
173
|
+
* • its DOMAIN is three values, `{rate_limit, overloaded, server_error}` (`G2_` @409113) — no
|
|
174
|
+
* `timeout`, no `network`, no `logic`;
|
|
175
|
+
* • its USE is not a retry signal. It gates PARTIAL-OUTPUT HANDBACK (`V2_` @408558-408570): when the
|
|
176
|
+
* kind is in that set and the child produced text before dying, CC returns the salvaged history
|
|
177
|
+
* with the cutoff note "Everything below is PARTIAL output recovered from the agent before it was
|
|
178
|
+
* cut off. The agent did NOT finish its task — treat these results as incomplete."
|
|
179
|
+
* sema's pair is a different mechanism answering a different question (re-delegate or not), derived
|
|
180
|
+
* from sema's OWN errorCode taxonomy. It is kept as-is: it serves a real parent-side decision, and
|
|
181
|
+
* changing the domain now would break every consumer for a parity that was never there.
|
|
182
|
+
*
|
|
183
|
+
* Residual (registered, not done here): CC's partial-output handback has no sema equivalent on this
|
|
184
|
+
* lane — sema's `salvagedOutput` covers two other terminals only. And `authentication_failed`-style
|
|
185
|
+
* auth faults still fold into `logic`, which is correct for "don't retry" but coarse for a caller
|
|
186
|
+
* that wants to re-auth and retry.
|
|
187
|
+
*
|
|
188
|
+
* Classification (unchanged) — a FAILED child run into a coarse `error_kind` +
|
|
189
|
+
* `retryable` pair so the PARENT model (and an orchestrating deployment) can react correctly without
|
|
190
|
+
* string-matching the report: a `rate_limit`/`overloaded`/`timeout`/`network` failure is transient
|
|
191
|
+
* (re-delegating the same subtask may succeed); a `logic` failure is not (auth/invalid_request/budget/
|
|
192
|
+
* output.* — re-delegating unchanged just burns tokens). Derived from the EXISTING taxonomy: the
|
|
193
|
+
* child's `TaskResult.errorCode` (assemble-result's priority chain — brain `[code]` prefixes lifted
|
|
194
|
+
* via `extractErrorCode`, `limits.max_walltime_exceeded`, `budget.*`, …) plus a message sniff for the two classes our
|
|
195
|
+
* BrainError codes fold together ("server" covers overloaded_error/529 AND plain 5xx; "network"
|
|
196
|
+
* covers both timeouts and resets). Returns undefined for a non-failed child (no error to classify).
|
|
197
|
+
*/
|
|
47
198
|
export declare function classifySubagentError(child: {
|
|
48
199
|
status: string;
|
|
49
200
|
errorCode?: string;
|
|
@@ -52,6 +203,61 @@ export declare function classifySubagentError(child: {
|
|
|
52
203
|
errorKind: SubagentErrorKind;
|
|
53
204
|
retryable: boolean;
|
|
54
205
|
} | undefined;
|
|
206
|
+
/**
|
|
207
|
+
* structured-card audit 2026-08-05, item D — the Agent family's **completed** `tool_end.structured`
|
|
208
|
+
* card, assembled from an EXPLICIT field whitelist over the child `TaskResult`.
|
|
209
|
+
*
|
|
210
|
+
* ### What was broken
|
|
211
|
+
* `TaskEvent.tool_end.structured`'s 双面契约 (core/types.ts) states that a host MUST render a
|
|
212
|
+
* delegation's landing report from `structured` and MUST NOT scrape the model-facing text. The
|
|
213
|
+
* `async_launched` receipt honored it (`type:"agent"`, on the allowlist); the **completed** delivery
|
|
214
|
+
* did not: its `details` was `{...child}` — a bare `TaskResult` spread with no `type` key at all — so
|
|
215
|
+
* `structuredFrom`'s allowlist dropped it every time. The one card the contract names by name was the
|
|
216
|
+
* one card that could never arrive, and the only way to get the child's report was the thing the
|
|
217
|
+
* contract forbids.
|
|
218
|
+
*
|
|
219
|
+
* ### Reconciling with "never leak the whole child TaskResult"
|
|
220
|
+
* tool-output-projection.ts's own header calls the subagent `details` its example of what must NOT
|
|
221
|
+
* reach the public stream. That statement is about the SPREAD, and it stays true: what rides here is a
|
|
222
|
+
* fixed, enumerated, host-facing field set — not the child result object. The distinction is
|
|
223
|
+
* load-bearing rather than stylistic, because `TaskResult` carries fields that must never leave the
|
|
224
|
+
* process:
|
|
225
|
+
*
|
|
226
|
+
* - **`checkpointToken`** — the resume CAPABILITY ("never log it or put it in a URL", per its own
|
|
227
|
+
* JSDoc). A durable pause is short-circuited into `durablePauseDelegationReport` well before this
|
|
228
|
+
* point, but that is NOT what keeps the token off the wire: a child whose orchestrator mapped an
|
|
229
|
+
* unexpected `suspended` down to `failed` (`errorCode:"unexpected.suspended"`) reaches this function
|
|
230
|
+
* carrying one. Under a spread, registering the completed card would have published it.
|
|
231
|
+
* - **`checkpointGate`** — the token's other half (who must approve what); useless without the token
|
|
232
|
+
* and part of the same capability story.
|
|
233
|
+
*
|
|
234
|
+
* Everything admitted below is already on the MODEL face of the same tool result (status, result text,
|
|
235
|
+
* failure attribution, run totals, the transcript id) or was already an additive key on the previous
|
|
236
|
+
* `details` object (`resolvedModel` / `toolStats` / `worktreePath`, CC207-B/206-B). So this widens the
|
|
237
|
+
* WIRE by exactly the fields a host needs to render the report, and widens what anyone can read by
|
|
238
|
+
* nothing at all. New `TaskResult` fields do NOT join automatically — that is the point of the
|
|
239
|
+
* whitelist: admitting one is a deliberate edit here, reviewed against this boundary.
|
|
240
|
+
*
|
|
241
|
+
* ### What this whitelist actually governs (wider than "the wire")
|
|
242
|
+
* `details` is the tool result's structured face, so this set is ALSO what the in-process consumers
|
|
243
|
+
* see: the parent's `afterToolCall` hook, the persisted tool-result message in the parent transcript,
|
|
244
|
+
* and anything reading `toolResult.details` — not only `tool_end.structured`. Omitting a field here
|
|
245
|
+
* therefore withholds it from every one of them, which is why the omission of a machine-actionable
|
|
246
|
+
* field (2026-08-04: `retryAfterMs`, the wait hint paired with `errorCode:"usage.window_exhausted"`,
|
|
247
|
+
* and `degraded`, the reduced-quality fact) is a real loss rather than a cosmetic one. The capability
|
|
248
|
+
* fields (`checkpointToken` / `checkpointGate`) stay excluded on exactly the same reading — the
|
|
249
|
+
* whitelist's reach is the reason their exclusion is worth anything.
|
|
250
|
+
*
|
|
251
|
+
* The card keeps `type:"agent"` (rather than minting a second word): CC models the Agent tool's output
|
|
252
|
+
* as one union discriminated by `status`, and both sema cards already carry `status` —
|
|
253
|
+
* `"async_launched"` for the receipt, the child's terminal status here. A consumer branches on it.
|
|
254
|
+
*
|
|
255
|
+
* Exported at MODULE level (not from the package index, same as `classifySubagentError`) so the leak
|
|
256
|
+
* boundary can be pinned directly against a child result carrying a token — the `unexpected.suspended`
|
|
257
|
+
* shape is reachable in production (a child running its own team/verify orchestration) but expensive to
|
|
258
|
+
* stage end-to-end, and a pin that only ever sees an ordinary completed child cannot tell this
|
|
259
|
+
* whitelist apart from a spread.
|
|
260
|
+
*/
|
|
55
261
|
export declare function completedAgentCard(child: {
|
|
56
262
|
taskId: string;
|
|
57
263
|
sessionId: string;
|
|
@@ -74,20 +280,84 @@ export declare function completedAgentCard(child: {
|
|
|
74
280
|
} | undefined;
|
|
75
281
|
worktreePath?: string;
|
|
76
282
|
toolStats?: SubagentToolStats;
|
|
283
|
+
/** Ruled 2026-08-05 (tier-fallback discriminator): the caller REQUESTED a model word that did not
|
|
284
|
+
* bind (no roster / not on the roster) and the child ran on its inherited default instead. The
|
|
285
|
+
* fallback behavior itself is unchanged and deliberate; this makes it machine-visible on the
|
|
286
|
+
* delegation face (closed set, single member today). Absent = the requested word (or no word)
|
|
287
|
+
* bound normally. */
|
|
77
288
|
modelFallback?: "inherit_no_tier_binding";
|
|
289
|
+
/** RB-201 FO-3 — the handback review's warning line, when a completed child's work was flagged.
|
|
290
|
+
* It rides as its OWN key rather than being folded into `result`, because `result` is contracted
|
|
291
|
+
* to be the child's final assistant text verbatim: a structured consumer diffing or re-delivering
|
|
292
|
+
* it must not receive an engine-authored sentence inside that field. Absent when nothing was
|
|
293
|
+
* flagged (or no review was armed), so a consumer must not read presence as a verdict source for
|
|
294
|
+
* anything else. */
|
|
78
295
|
handbackWarning?: string;
|
|
79
296
|
}): Record<string, unknown>;
|
|
297
|
+
/**
|
|
298
|
+
* ruled 2026-08-04 — the DELEGATION-REPORT vocabulary for a child that durably paused at an approval
|
|
299
|
+
* gate. Distinct from the orchestrator-facing `unexpected.suspended` / `unexpected.needs_review`
|
|
300
|
+
* TaskResult codes (`suspend-guard.ts`, unchanged): those say "an orchestrator got a status it does not
|
|
301
|
+
* handle"; these say what actually happened to THIS delegation. The report used to speak the
|
|
302
|
+
* `unexpected.*` pair plus "treat this delegation as failed", which is a false statement about a run
|
|
303
|
+
* that is alive, holds a checkpoint, and is waiting for a human.
|
|
304
|
+
*/
|
|
80
305
|
export declare const SUBAGENT_SUSPENDED_AWAITING_APPROVAL = "suspended.awaiting_approval";
|
|
306
|
+
/** {@link SUBAGENT_SUSPENDED_AWAITING_APPROVAL}'s twin for a `needs_review` pause (plan review / dry run). */
|
|
81
307
|
export declare const SUBAGENT_SUSPENDED_NEEDS_REVIEW = "suspended.needs_review";
|
|
308
|
+
/** ruled 2026-08-04 — a background child that paused durably but could NOT be parked, and whose
|
|
309
|
+
* checkpoint was therefore expired under the no-orphans rule: nothing is pending approval anywhere. */
|
|
82
310
|
export declare const SUBAGENT_SUSPENDED_CHECKPOINT_EXPIRED = "suspended.checkpoint_expired";
|
|
311
|
+
/**
|
|
312
|
+
* Subagent steer verb (2026-07-03) — the handle emitted to `RunInternals.onSubagentSpawn`
|
|
313
|
+
* when a deployment opts into steerable sub-agents. Mirrors {@link WorkflowAgentHandle}: `steer`
|
|
314
|
+
* injects fenced operator guidance into the RUNNING child and returns a correlation marker; it
|
|
315
|
+
* rejects with `steering.not_running` once the child ends. The handle never reaches the model.
|
|
316
|
+
*/
|
|
83
317
|
export interface SubagentSteerHandle {
|
|
318
|
+
/** The child run's unified task id (`spec.taskId ?? sessionId` fallback resolves post-start, so this
|
|
319
|
+
* is the SPAWN-time identity: the parent's tool call id — stable, unique per delegation). */
|
|
84
320
|
parentToolCallId: string;
|
|
321
|
+
/** The child's display name (taskName / agent-type), when one was threaded. */
|
|
85
322
|
agentName?: string;
|
|
323
|
+
/** Inject fenced operator guidance into the running child; resolves to the correlation marker. */
|
|
86
324
|
steer: (content: string) => Promise<string>;
|
|
325
|
+
/** Resolves when the child settles (the tool's own await — exposed so a registry can auto-evict). */
|
|
87
326
|
settled: Promise<void>;
|
|
327
|
+
/**
|
|
328
|
+
* design/122 D1 — the retained child session id; present ONLY when the parent run enabled
|
|
329
|
+
* {@link import("../core/types.js").TaskSpec.retainSubagentSessions} AND this child was actually
|
|
330
|
+
* retained. ⚠️ Control-plane only (codex-B6): this is a continuation CAPABILITY — never expose it to
|
|
331
|
+
* clients; target children by the opaque `parentToolCallId` instead (codex-m3).
|
|
332
|
+
*/
|
|
88
333
|
childSessionId?: string;
|
|
334
|
+
/**
|
|
335
|
+
* design/122 D2 — REVIVE the settled child with a new operator prompt (CC `dfe` resumeAgentBackground
|
|
336
|
+
* parity): the SAME session gains a fenced follow-up user turn and the child continues in the
|
|
337
|
+
* background from its full prior context. ALWAYS ASYNC (even when the original spawn was a synchronous
|
|
338
|
+
* delegation) — the caller is the operator/shell, not the parent model; the parent run's state is
|
|
339
|
+
* untouched and completion is announced ONLY through the deployment-level background-notify sink
|
|
340
|
+
* (never the parent-model `ctx.onTaskNotification` lane — r1-M5). Resolves to the correlation marker
|
|
341
|
+
* (same contract as {@link steer}). Rejections carry an `Error.code`: `steering.still_running` (the
|
|
342
|
+
* child — or a prior resume — is still in flight), `resume.retain_off` (the parent run did not retain
|
|
343
|
+
* this child), `resume.evicted` (TTL/max/parent-end evicted the retained session), `resume.cap`
|
|
344
|
+
* (per-child resume cap reached), `resume.session_not_found` (the session vanished from the store, or
|
|
345
|
+
* is empty — the r1-m1 create-on-miss dark door). `handle.settled` keeps FIRST-RUN semantics (D4
|
|
346
|
+
* ruling); each resume re-emits a FRESH handle (same `parentToolCallId`) to the spawn sink, whose own
|
|
347
|
+
* `settled` tracks the revived run — a registry keeps the newest handle per id.
|
|
348
|
+
*/
|
|
89
349
|
resume?: (content: string) => Promise<string>;
|
|
90
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* design/122 D2 — build the `resume` verb for one delegation (closure over the ledger + delegation runner —
|
|
353
|
+
* NEVER the parent tool ctx / spec builder, r1-m5). Validation order: TTL sweep (MAJOR-1) → disposed?
|
|
354
|
+
* (MAJOR-3) → retained/evicted? → still running? → cap → SYNCHRONOUS claim (MAJOR-2: `running = true`
|
|
355
|
+
* before any await; rolled back on pre-launch failure) → session exists AND non-empty (r1-m1).
|
|
356
|
+
* Then: fenced revive prompt (unpredictable marker) →
|
|
357
|
+
* `runTaskStream` on the FROZEN spawn snapshot + `requireExistingSession` (spec is tighten-only: the caller
|
|
358
|
+
* contributes ONLY `content`) → ledger `activeRun` bookkeeping → completion via the deployment-level
|
|
359
|
+
* background-notify sink ONLY (no sink ⇒ silent; NEVER the parent-model notification lane — r1-M5).
|
|
360
|
+
*/
|
|
91
361
|
export declare function createSubagentResume(deps: {
|
|
92
362
|
ledger: SubagentRetainLedger | undefined;
|
|
93
363
|
parentToolCallId: string;
|
|
@@ -96,28 +366,78 @@ export declare function createSubagentResume(deps: {
|
|
|
96
366
|
priority?: "now" | "next" | "later";
|
|
97
367
|
}) => void;
|
|
98
368
|
sink?: (handle: SubagentSteerHandle) => void;
|
|
369
|
+
/** 1.284 C1 — the child gate's liveness source for RESUME cycles (design/144 §1.2: the 207 semantics
|
|
370
|
+
* apply to EVERY stop cycle, spawn and resume alike). Absent ⇒ honest ungated degradation (no
|
|
371
|
+
* registry to count against — the pre-C1 immediate send). */
|
|
99
372
|
registry?: import("../core/task-registry.js").TaskRegistry;
|
|
373
|
+
/** design/147 S1a (codex F1) — the RESUMING caller's live injection entry: overrides the retained
|
|
374
|
+
* snapshot's spawn-turn `parentNotify` (that lane is torn down with its turn — uplinks through it
|
|
375
|
+
* would PARK instead of reaching the currently active parent turn, behind a success receipt). */
|
|
100
376
|
currentParentNotify?: (n: TaskNotificationPayload, opts?: {
|
|
101
377
|
priority?: "now" | "next" | "later";
|
|
102
378
|
}) => void;
|
|
379
|
+
/** The RESUMING caller's live content-ask face (its trusted `ToolExecuteContext.onQuestion`), same
|
|
380
|
+
* reasoning as `currentParentNotify` one line up: the retained snapshot deliberately carries NO
|
|
381
|
+
* question face (the spawn turn's is stripped at freeze time — a per-request lane is torn down with
|
|
382
|
+
* its turn), so the human who can answer is the one attached to THIS turn. Absent ⇒ the resumed child
|
|
383
|
+
* has no live face and its `AskUserQuestion` mount falls back to the automatic criterion's other legs
|
|
384
|
+
* — never a call into a closed surface. */
|
|
103
385
|
currentOnQuestion?: import("../core/ask-question.js").OnQuestion;
|
|
386
|
+
/** The RESUMING caller's own tighten-only CLAMPS (its trusted `ToolExecuteContext` seats), folded ON TOP
|
|
387
|
+
* of the frozen snapshot so a wake can only ever narrow the child. Without this the snapshot alone
|
|
388
|
+
* decides: a child spawned by a write-capable, interactive, long-lived run could be woken BY a
|
|
389
|
+
* read-only / hard-headless / one-shot run and still act with the spawn turn's capabilities — the
|
|
390
|
+
* resumer driving actions it could not perform itself. The fold is a union of restrictions (either
|
|
391
|
+
* side saying "restricted" wins), never a relaxation: a snapshot clamp is not lifted by a resumer
|
|
392
|
+
* that lacks it. Absent ⇒ the snapshot governs alone (prior behavior). */
|
|
104
393
|
currentClamps?: {
|
|
105
394
|
handsReadOnly?: true;
|
|
106
395
|
interactiveTools?: false;
|
|
107
396
|
oneShot?: true;
|
|
108
397
|
};
|
|
398
|
+
/** The RESUMING caller's own handback-review seat (its trusted `ToolExecuteContext.autoModeReview`),
|
|
399
|
+
* same turn-bound reasoning as `currentOnQuestion` above: a resumed cycle is a completion like any
|
|
400
|
+
* other — its work reaches the durable row and the completion notification — and the decider that can
|
|
401
|
+
* review it belongs to the run doing the waking, not to the frozen spawn snapshot. Absent ⇒ the
|
|
402
|
+
* resumed cycle's output is carried through unreviewed (honest degradation: a caller with no review
|
|
403
|
+
* armed had none to apply). */
|
|
109
404
|
currentAutoModeReview?: {
|
|
110
405
|
decider: import("../core/auto-mode.js").AutoModeDecider;
|
|
111
406
|
};
|
|
407
|
+
/** design/176 — present iff this resume is PEER-DRIVEN (the SendMessage carrier): the resume
|
|
408
|
+
* prompt takes the peer-resume trust frame (teammate header + fence label + the per-message
|
|
409
|
+
* discipline block — never the operator-authority wording), and the woken cycle's inbound peer
|
|
410
|
+
* chain seeds from this value (a FRESH ref per cycle — never a mutation of the spawn ref).
|
|
411
|
+
* Absent = operator resume, byte-for-byte the pre-176 prompt. */
|
|
112
412
|
peerOrigin?: {
|
|
113
413
|
hopChain: string[];
|
|
114
414
|
};
|
|
415
|
+
/** design/176 — the WAKER's peer-identity ref, PAIR-MINTED with {@link currentParentNotify}: the
|
|
416
|
+
* replaced uplink callback points at the waking conversation, so the admission identity the
|
|
417
|
+
* woken child's "main" sends are judged against must travel with the same binding. */
|
|
115
418
|
currentParentPeerRef?: PeerSelfRef;
|
|
419
|
+
/** S2b RB-27② — the settled background-agent ROW this resume revives (SendMessage's completed
|
|
420
|
+
* branch supplies it). With registry+taskId present, the resume cycle re-enters the registry
|
|
421
|
+
* lifecycle: row flips running, a FRESH injector attaches (cycle-stamped), and this cycle's
|
|
422
|
+
* settle re-terminalizes the row — so a mid-resume SendMessage gets real running delivery
|
|
423
|
+
* instead of the still_running refusal. Absent (steer-handle resume path) ⇒ prior behavior. */
|
|
116
424
|
taskId?: string;
|
|
425
|
+
/** S2b RB-27② — the resuming caller's resolved registry access (pairs with taskId). */
|
|
117
426
|
taskAccess?: import("../core/task-registry.js").TaskAccess;
|
|
427
|
+
/** [1358] the process-level background-child observer (ctx.onBackgroundChildEvent, Runner-filled).
|
|
428
|
+
* When present TOGETHER with a revived registry row (taskId + successful revive), the resume cycle
|
|
429
|
+
* re-emits the SAME spawn→tick→terminal event family as a first spawn — a fleet view's row revives
|
|
430
|
+
* on the spawn frame (server treats spawn-after-tombstone as row revival). The spawn frame is
|
|
431
|
+
* emitted after `reviveBackgroundAgent` succeeds and BEFORE the stream starts (spawn precedes every
|
|
432
|
+
* tick — the observer's tombstone-period tick rejection depends on that order). No revived row ⇒
|
|
433
|
+
* no frames (the steer-handle resume path has no a*-domain row to project). */
|
|
118
434
|
bgSink?: (event: import("../core/types.js").BackgroundChildEvent) => void;
|
|
435
|
+
/** [1358] row lifetime class echoed onto the revive frames (mirrors the registry row). */
|
|
119
436
|
sessionScoped?: boolean;
|
|
437
|
+
/** [1358] the row's display description, echoed onto the revive spawn frame (resume-marked). */
|
|
120
438
|
rowDescription?: string;
|
|
439
|
+
/** [1358]/codex 1351 F3 — the row's original observer metadata, reproduced on the revive frames so
|
|
440
|
+
* a consumer rebuilding a tombstoned row gets its TYPE/name/ancestry back (never a blank row). */
|
|
121
441
|
rowName?: string;
|
|
122
442
|
rowAgentType?: string;
|
|
123
443
|
rowOwner?: string;
|
|
@@ -125,71 +445,351 @@ export declare function createSubagentResume(deps: {
|
|
|
125
445
|
rowParentTaskId?: string;
|
|
126
446
|
rowParentSessionId?: string;
|
|
127
447
|
rowRootSessionId?: string;
|
|
448
|
+
/** RB-478 — the row's original spawn instant (AccessibleTaskRow.createdAt): the revive spawn
|
|
449
|
+
* frame's `startedAt` anchors the ROW's birth, never the wake call. */
|
|
128
450
|
rowSpawnedAt?: number;
|
|
451
|
+
/** RB-473 batch 2b — bounded disclosure when a deployment sink throws inside this resume closure's
|
|
452
|
+
* isolation scope (first failure per site; later ones counted only). */
|
|
129
453
|
onNotifyError?: (failure: import("../core/safe-notify.js").SafeNotifyFailure) => void;
|
|
130
454
|
}): (content: string) => Promise<string>;
|
|
455
|
+
/**
|
|
456
|
+
* Options for {@link createSubagentTool}.
|
|
457
|
+
*
|
|
458
|
+
* Hot-update contract: the agent roster (`agents`/`builtinAgents`, including the shadow determination —
|
|
459
|
+
* which deployment definition wins over a built-in of the same name) is a SNAPSHOT taken at
|
|
460
|
+
* `createSubagentTool({...})` time: it is validated, baked into the tool's parameter enum/description,
|
|
461
|
+
* and never re-read. A deployment that hot-reloads its agents directory (or otherwise mutates the
|
|
462
|
+
* catalog) after mounting must REBUILD the ToolSpec — call `createSubagentTool` again with the fresh
|
|
463
|
+
* roster and serve the new tool — for the change to take effect; already-running tasks keep the roster
|
|
464
|
+
* they were prepared with.
|
|
465
|
+
*/
|
|
131
466
|
export interface SubagentToolOptions {
|
|
467
|
+
/** Runner used to execute child tasks. */
|
|
132
468
|
runner: Runner;
|
|
469
|
+
/**
|
|
470
|
+
* design/115 P3 — background sub-agents (CC `run_in_background`). When set, the tool exposes the
|
|
471
|
+
* `run_in_background` parameter: the call returns an `a*` task_id immediately, the child runs
|
|
472
|
+
* asynchronously, and completion fires ONE task-notification ("later" priority — CC posture: an agent
|
|
473
|
+
* completion doesn't derail active work). Poll/stop via TaskOutput/TaskStop. Absent ⇒ synchronous only.
|
|
474
|
+
*/
|
|
133
475
|
background?: {
|
|
134
476
|
registry: import("../core/task-registry.js").TaskRegistry;
|
|
477
|
+
/** β 批 A-2 (BREAKING 1.365.0): REQUIRED — the registry is default-deny on both axes, so a
|
|
478
|
+
* background registration without a declared owner would be unreachable by every caller. */
|
|
135
479
|
owner: string;
|
|
480
|
+
/** β 批 A-2 (BREAKING 1.365.0): REQUIRED — `"default"` is the single-tenant spelling (explicit,
|
|
481
|
+
* matching the engine chain's `principal ?? "default"`), never implied by omission. */
|
|
136
482
|
scope: string;
|
|
137
483
|
notify?: (n: import("../core/task-notification.js").TaskNotificationPayload, opts?: {
|
|
138
484
|
priority?: "now" | "next" | "later";
|
|
139
485
|
}) => void;
|
|
486
|
+
/** design/151 S1a: the durable execution-row ledger. Present ⇒ every background registration
|
|
487
|
+
* writes a durable row (restart-surviving TaskOutput reads; the S1b lifecycle flip keys off the
|
|
488
|
+
* same wiring). Absent ⇒ pre-151 in-memory-only lifecycle, unchanged. */
|
|
140
489
|
agentStore?: import("../core/background-agent-store.js").BackgroundAgentStore;
|
|
490
|
+
/**
|
|
491
|
+
* design/153 §7.3 — the durable-approval checkpoint store, for the PARK lane's compensation and
|
|
492
|
+
* arbitration (expire on a lost park CAS — the no-orphans posture; the in-process TaskStop
|
|
493
|
+
* arbitration closure). MUST be the SAME instance as `RunnerDeps.checkpointStore` (the child's
|
|
494
|
+
* suspend mints its checkpoint there; a different instance could not see the token — the F-6
|
|
495
|
+
* dual-wiring hazard, documented symptom: parks succeed but stops/reconciliation read "missing").
|
|
496
|
+
* Absent ⇒ a durably-suspending bg child keeps the pre-153 lifecycle (settled `failed` with
|
|
497
|
+
* `unexpected.suspended`), byte-for-byte.
|
|
498
|
+
*/
|
|
141
499
|
checkpointStore?: import("../core/checkpoint-store.js").CheckpointStore;
|
|
500
|
+
/**
|
|
501
|
+
* design/153 §7.3 (r4 F-09) — the CAPABILITY protocol that attests the child's transcript
|
|
502
|
+
* session is durable before a park commits (replaces any config-boolean form: a wrong `true`
|
|
503
|
+
* would re-mint the stranded-park class this whole design closes). Called park-side with the
|
|
504
|
+
* child's session id; resolving means "this session is now readable via the durable session
|
|
505
|
+
* store from ANY process" (a transient-tier deployment migrates it here — the server's
|
|
506
|
+
* park-前-迁移 hook; an all-durable deployment wires a no-op resolve). A REJECTION (or absence)
|
|
507
|
+
* vetoes the park: the child settles failed exactly as pre-153, and the already-minted
|
|
508
|
+
* checkpoint is expired (no orphans). Never called for sync children or non-suspending runs.
|
|
509
|
+
*
|
|
510
|
+
* ⚠️ Implementation obligation (blackboard [1593]/[1594], field-proven): "migrates it here"
|
|
511
|
+
* means ACTIVELY PROMOTE — a check-only implementation that merely LOOKS UP the host durable
|
|
512
|
+
* store rejects every child whose session lives in a split/transient tier (a subRunner's
|
|
513
|
+
* private TTL store), and the veto fires on EVERY park: the checkpoint expires within
|
|
514
|
+
* milliseconds of minting and the redemption window never exists. The hook must cover the
|
|
515
|
+
* store the child session ACTUALLY lives in — copy the session tree into the durable store,
|
|
516
|
+
* then re-verify, and only then resolve.
|
|
517
|
+
*/
|
|
142
518
|
ensureChildSessionDurable?: (sessionId: string) => Promise<void>;
|
|
143
519
|
};
|
|
520
|
+
/** Model the child runs on. If omitted, the child resolves the `subagent` role (→ `default`). */
|
|
144
521
|
model?: ModelRef;
|
|
522
|
+
/**
|
|
523
|
+
* Declarative sub-agents the model can pick from (design/38 1B). When set, the tool exposes an `agent`
|
|
524
|
+
* parameter (enum of these names) and the chosen definition's config builds the child task — its
|
|
525
|
+
* `allowTools`/`denyTools` REPLACE the tool-level ones, `model` omitted = inherit the caller's model.
|
|
526
|
+
* design/141 件A: when OMITTED, defaults to the runner's deployment catalog (`RunnerDeps.agents`) —
|
|
527
|
+
* one Runner, one registry across the Agent-tool and workflow lanes. Pass explicitly to narrow.
|
|
528
|
+
*/
|
|
145
529
|
agents?: AgentDefinition[];
|
|
530
|
+
/**
|
|
531
|
+
* F1 (CC 2.1.198 parity): offer the BUILT-IN read-only `Explore`/`Plan` agent types (CC `HCe`
|
|
532
|
+
* registry, GA default-on — pretty.js:487221-487240 + iAt :487127). Default `true` (CC posture);
|
|
533
|
+
* `false` removes them (the config-driven analog of CC's `CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS`).
|
|
534
|
+
* A deployment definition named "Explore"/"Plan" SHADOWS the built-in of the same name (definition
|
|
535
|
+
* wins — fork-shadowing precedent).
|
|
536
|
+
*/
|
|
146
537
|
builtinAgents?: boolean;
|
|
538
|
+
/** Model catalog, used ONLY to validate an agent's string `model` ref at assembly time (fail-fast). */
|
|
147
539
|
models?: Record<string, Model>;
|
|
540
|
+
/** Tools available to the child (a deliberately narrowed subset). */
|
|
148
541
|
tools?: ToolSpec[];
|
|
542
|
+
/**
|
|
543
|
+
* Tool-level allowlist (design/38 1A), used when NO `agent` is selected (a selected agent definition's
|
|
544
|
+
* own `allowTools`/`denyTools` REPLACE these). When set, the child sees only these tools from `tools`
|
|
545
|
+
* (`["*"]` = all). Omit for the whole `tools` pool. Allowlist is the security-recommended shape.
|
|
546
|
+
* NOTE: this filters only the WORK tools — the nested delegation tool is governed by `maxDepth`, not
|
|
547
|
+
* allow/deny. To deny the child any further delegation, set `maxDepth: 1` (not a `denyTools` entry).
|
|
548
|
+
*/
|
|
149
549
|
allowTools?: string[];
|
|
550
|
+
/** Tool-level denylist (design/38 1A), used when no `agent` is selected: names removed (a deny wins). */
|
|
150
551
|
denyTools?: string[];
|
|
552
|
+
/** System prompt / persona for the child. Default (1.259.0, CC 198 parity): the LEAN
|
|
553
|
+
* {@link SUBAGENT_PROMPT} (agent persona + return contract), NOT the full default constitution role
|
|
554
|
+
* base — pass `DEFAULT_SYSTEM_PROMPT` here explicitly to restore the pre-1.259 behavior. */
|
|
151
555
|
systemPrompt?: string;
|
|
556
|
+
/** Tool name exposed to the parent. Default "Agent". */
|
|
152
557
|
name?: string;
|
|
558
|
+
/** What the child is for (shown to the parent in the tool description). */
|
|
153
559
|
purpose?: string;
|
|
560
|
+
/** Child run limits — forwarded verbatim onto each child's `TaskSpec.limits` (design/164 shape). */
|
|
154
561
|
limits?: TaskLimits;
|
|
562
|
+
/**
|
|
563
|
+
* Max nesting depth of delegation. A child at depth `d` only receives a delegation tool when
|
|
564
|
+
* `d + 1 < maxDepth`, so it cannot recurse past the limit.
|
|
565
|
+
*
|
|
566
|
+
* Default 3 (RB-292) — CC 2.1.220 parity: `bee()` @272064 returns `CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH`
|
|
567
|
+
* when set, else a remote-config value, else the constant `aHu = 3` @272076. The old default of 5 was
|
|
568
|
+
* anchored on CC 2.1.201's `Y4t` and upstream has since moved; 5 is a stale anchor, not a sema choice.
|
|
569
|
+
* sema exposes the override as THIS option rather than an env var (deployments configure the tool, not
|
|
570
|
+
* the process), so the env/remote-config half of `bee()` has no sema counterpart to keep in sync.
|
|
571
|
+
*
|
|
572
|
+
* Semantics pin (off-by-one checked): with the default, the main agent + children at depths 1-2 all
|
|
573
|
+
* carry a delegation tool, the depth-3 child is the STRUCTURAL leaf (no delegation tool mounted —
|
|
574
|
+
* sema's structural de-tooling, not a runtime throw), so "default behavior = CC default behavior":
|
|
575
|
+
* 3 delegation levels under main are reachable and a 4th is impossible by construction.
|
|
576
|
+
*/
|
|
155
577
|
maxDepth?: number;
|
|
578
|
+
/**
|
|
579
|
+
* Failure-evidence retain (default ON). A non-completed SYNC child (failed / timeout / blocked) used
|
|
580
|
+
* to have its session released as eagerly as a successful one — for a tool-heavy child whose terminal
|
|
581
|
+
* text is empty, that destroyed the only copy of its intermediate conclusions with zero retrieval
|
|
582
|
+
* path. With this on, a non-completed sync child SKIPS the eager release and its session is briefly
|
|
583
|
+
* retained (ledger-backed when available, timer-backed fallback; ~15 min), and the failure report
|
|
584
|
+
* carries the transcript handle + a retention hint. `false` restores unconditional eager release.
|
|
585
|
+
* Completed children are unaffected (still released eagerly).
|
|
586
|
+
*/
|
|
156
587
|
retainFailedSessions?: boolean;
|
|
588
|
+
/**
|
|
589
|
+
* Observer-failure sink: called when an ARMED observer pairing dies (spawn/delivery failure, or an
|
|
590
|
+
* unresponsive observer at the settle drain). Best-effort observability — a throwing sink is
|
|
591
|
+
* swallowed. Regardless of this sink, the observed child's final report carries an
|
|
592
|
+
* `observer: failed (…)` line so the degrade is never silent.
|
|
593
|
+
*/
|
|
157
594
|
onObserverError?: (err: unknown, info: {
|
|
158
595
|
observedAgent?: string;
|
|
159
596
|
observerAgent?: string;
|
|
160
597
|
site?: string;
|
|
161
598
|
}) => void;
|
|
599
|
+
/**
|
|
600
|
+
* Dynamic tool-injection seam — evaluated ONCE PER SPAWN, with THIS delegation
|
|
601
|
+
* call's parent coordinates, to produce tool instances that cannot sit in the mount-time static
|
|
602
|
+
* `tools` pool (the deployment case: per-task tools issued by a task-env registry — the static pool
|
|
603
|
+
* is fixed at `createSubagentTool({...})` time, before any task exists). The products are MERGED
|
|
604
|
+
* INTO the `tools` pool and then flow through the EXACT SAME `resolveToolSubset` whitelist as the
|
|
605
|
+
* static tools — an agent definition's `allowTools`/`denyTools` (or the tool-level ones when no
|
|
606
|
+
* agent is selected) govern them verbatim: an explicit allowlist must NAME an injected tool for the
|
|
607
|
+
* child to see it; `"*"`/absent allowlist = all. Nested delegation threads the SAME factory down
|
|
608
|
+
* (`createSubagentToolNode(opts, depth+1)` carries it), so a grandchild spawn re-evaluates it — per-spawn,
|
|
609
|
+
* at every level; each child gets its own instances bound to its own spawn moment ([797]: the
|
|
610
|
+
* server-side factory is execute-time late-bound, so per-spawn evaluation is the confirmed shape).
|
|
611
|
+
* A THROWING/rejecting factory degrades THAT spawn to zero injected tools (the child still runs)
|
|
612
|
+
* with a FIXED generic `note:` disclosure on the report/async card (same lane as the model-override
|
|
613
|
+
* notes; the ORIGINAL error goes to {@link onExtraToolsError} only — 快审 S3). On a NAME COLLISION
|
|
614
|
+
* with the static pool the STATIC tool wins and the injected entry is skipped — mount-time
|
|
615
|
+
* configuration outranks runtime injection; the reserved surface covers the static tools' declared
|
|
616
|
+
* `aliases` too (快审 S2). Factory evaluations are capped per root spawn tree
|
|
617
|
+
* ({@link EXTRA_TOOLS_MAX_FACTORY_CALLS_PER_TREE} — 快审 S4). Absent ⇒ byte-identical prior behavior.
|
|
618
|
+
*
|
|
619
|
+
* ⚠️ NOT a supported SPAWN seam (parent effective-policy inheritance): an injected tool that itself
|
|
620
|
+
* calls `opts.runner.runTask(...)` internally is a SELF-MADE spawn OUTSIDE the delegation chain — it
|
|
621
|
+
* does not (and will not) thread `RunInternals.inheritedGate`, so such a child does NOT inherit the
|
|
622
|
+
* parent's evaluated policy chain. The supported spawn paths are the delegation tool itself, the
|
|
623
|
+
* workflow `agent()`/`agentStream()` legs, and the `run_workflow` tool. The backstop for a self-made
|
|
624
|
+
* spawn is the child task's OWN gate (deps/spec policy + its own session rules) — inheritance is a
|
|
625
|
+
* tightening layer on the supported paths, never the only line of defense.
|
|
626
|
+
*/
|
|
162
627
|
extraTools?: (ctx: SubagentSpawnContext) => ToolSpec[] | Promise<ToolSpec[]>;
|
|
628
|
+
/**
|
|
629
|
+
* extraTools 快审 S3 — host-side sink for the ORIGINAL `extraTools` factory error (and the S4
|
|
630
|
+
* budget-exceeded signal). The model-facing report deliberately carries only the fixed
|
|
631
|
+
* {@link EXTRA_TOOLS_FAILED_NOTE}: a registry/config error can embed paths/hostnames/credentials, and
|
|
632
|
+
* the report lands in the model context AND the persisted transcript (four disclosure faces). Sink
|
|
633
|
+
* choice rationale: this file's existing deployment-facing failure-sink posture is
|
|
634
|
+
* {@link onObserverError} (best-effort, swallow-guarded, opts-level) — this mirrors it rather than
|
|
635
|
+
* inventing a new trace channel. A throwing sink is swallowed; absent ⇒ the original error is dropped
|
|
636
|
+
* after the generic disclosure.
|
|
637
|
+
*/
|
|
163
638
|
onExtraToolsError?: (err: unknown, info: {
|
|
164
639
|
toolCallId: string;
|
|
165
640
|
agentType?: string;
|
|
166
641
|
depth: number;
|
|
167
642
|
}) => void;
|
|
168
643
|
}
|
|
644
|
+
/**
|
|
645
|
+
* Read-only parent-spawn coordinates handed to {@link SubagentToolOptions.extraTools}. Deliberately a
|
|
646
|
+
* NARROW projection of what the delegation tool's own `ToolExecuteContext` already carries (no new
|
|
647
|
+
* information channel; the trusted sinks — retain ledger, worktree lane, notification sinks — stay
|
|
648
|
+
* out of the factory's reach).
|
|
649
|
+
*/
|
|
169
650
|
export interface SubagentSpawnContext {
|
|
651
|
+
/** THIS delegation tool-call's id — the spawn moment's stable coordinate. */
|
|
170
652
|
toolCallId: string;
|
|
653
|
+
/** The PARENT run's stable taskId (`spec.taskId ?? sessionId`, Runner-filled). Absent outside a Runner. */
|
|
171
654
|
parentTaskId?: string;
|
|
655
|
+
/** The PARENT run's session id (Runner-filled). Absent outside a Runner. */
|
|
172
656
|
parentSessionId?: string;
|
|
657
|
+
/** The parent task's authenticated end-user principal (design/62), inherited read-only. */
|
|
173
658
|
principal?: string;
|
|
659
|
+
/** The chosen subagent type for THIS spawn (agent-definition name, or "fork"); absent for a plain delegation. */
|
|
174
660
|
agentType?: string;
|
|
661
|
+
/** Delegation depth of the SPAWNING tool (0 = the main agent's Agent tool; a grandchild spawn sees 1, …). */
|
|
175
662
|
depth: number;
|
|
176
663
|
}
|
|
664
|
+
/**
|
|
665
|
+
* "general-purpose" alias fold (CC 2.1.207 parity — see {@link GENERAL_PURPOSE_SUBAGENT_TYPE}): rewrite
|
|
666
|
+
* `subagent_type: "general-purpose"` to the OMITTED form so it takes the plain clean-context delegation
|
|
667
|
+
* path (sema's built-in general-purpose equivalent: full tool pool + SUBAGENT_PROMPT persona). Wired both
|
|
668
|
+
* as the tool's `prepareArguments` pre-validation shim (the declared `subagent_type` enum lists only
|
|
669
|
+
* DEFINED agent names, so the literal must rewrite BEFORE the schema check) AND inside execute (direct
|
|
670
|
+
* ToolSpec.execute callers). Idempotent; identity when `shadowed` (a deployment/builtin definition of the
|
|
671
|
+
* same name wins — the literal then resolves as a normal agent lookup, never this fold). This is a LIVE
|
|
672
|
+
* cross-vocabulary mapping, not a compatibility arm (RB-479-A③ retired the Fork `{directive}` adapter
|
|
673
|
+
* that used to share this wiring).
|
|
674
|
+
*/
|
|
675
|
+
/**
|
|
676
|
+
* RB-293 — subagent_type fold, CC 2.1.220 `ulr` @317317 verbatim:
|
|
677
|
+
* `e.normalize("NFKC").toLowerCase().replace(/[\p{White_Space}\p{Pd}_]+/gu, "")`.
|
|
678
|
+
*
|
|
679
|
+
* Deliberately lossy and deliberately NOT a resolver: it exists only to decide whether two spellings
|
|
680
|
+
* denote the same roster entry AFTER an exact match has already failed. `\p{Pd}` is the dash punctuation
|
|
681
|
+
* class (so an en-dash paste folds like a hyphen), `\p{White_Space}` covers NBSP and friends, and NFKC
|
|
682
|
+
* folds fullwidth/compatibility forms — the three ways a name gets mangled between a listing line and a
|
|
683
|
+
* tool call. Note it can map DISTINCT roster names onto one key ("code-review" / "code_review"), which
|
|
684
|
+
* is exactly why the caller must treat a multi-hit as ambiguous rather than picking a winner.
|
|
685
|
+
*/
|
|
177
686
|
export declare function normalizeSubagentType(value: string): string;
|
|
687
|
+
/**
|
|
688
|
+
* A system-prompt note you can append to the PARENT task so the model knows delegation exists.
|
|
689
|
+
* (The tool description below is the primary "explicit instruction"; this is an optional reinforcement.)
|
|
690
|
+
*/
|
|
178
691
|
export declare const SUBAGENT_SYSTEM_NOTE: string;
|
|
692
|
+
/**
|
|
693
|
+
* G4 (CC 2.1.198 parity — 锚 pretty.js:225024 `Z4t` fork-boilerplate): the MESSAGE-LAYER instruction
|
|
694
|
+
* frame prepended to a fork child's directive. 198 keeps the fork's SYSTEM prompt byte-identical to the
|
|
695
|
+
* parent (prompt-cache) and carries the fork behavior contract in the messages instead — same posture
|
|
696
|
+
* here: this frame wraps the `prompt` (the child's objective/user turn) and never touches systemPrompt.
|
|
697
|
+
* 198-faithful verbatim (2026-07-10 realignment): the no-spawn line is now the full 198 text — the tool
|
|
698
|
+
* name matches (198 `is`="Agent" = our DEFAULT_SUBAGENT_TOOL_NAME) and our tool card carries its own
|
|
699
|
+
* fork guidance (:939) for the referent. An earlier adaptation dropped the "default to forking" clause
|
|
700
|
+
* as CC-specific; a live identity-confusion incident (a fork reading the parent's delegation record as
|
|
701
|
+
* "someone else is on it" and stopping) showed the parent/fork disambiguation clause is load-bearing —
|
|
702
|
+
* keep the anchor whole. (NOT the 88-era frame — 88's "STOP. READ THIS
|
|
703
|
+
* FIRST… Scope:/Result/Key files" format was rewritten shorter and softer in 198; parity follows 198.)
|
|
704
|
+
* Frame TAIL = the literal directive prefix `Your directive: ` (198 `ZDt`, pretty.js:35621; the Z4t
|
|
705
|
+
* assembly is `…</fork-boilerplate>\n\n${ZDt}${directive}`, :225038, and 198 strips the SAME prefix on
|
|
706
|
+
* read-back, :415673). 1.259.0 合车复审修①: an earlier transcription invented a `<directive-prefix>`
|
|
707
|
+
* tag here — that tag does not exist in 198; the anchor is the plain-text prefix.
|
|
708
|
+
*/
|
|
179
709
|
export declare const FORK_DIRECTIVE_FRAME = "<fork-boilerplate>\nYou are a worker fork. The transcript above is the parent's history \u2014 inherited reference, not your situation. You are NOT a continuation of that agent. Execute ONE directive, then stop.\n\nHard rules:\n- Do NOT spawn subagents with the Agent tool. The \"default to forking\" guidance is for the parent; you ARE the fork, execute directly.\n- One shot: report once and stop. No follow-up questions, no proposed next steps, no waiting for the user.\n\nGuidelines (your directive may override any of these):\n- Stay in scope. Other forks may be handling adjacent work; if you spot something outside your directive, note it in a sentence and move on.\n- Open with one line restating your task, so the parent can spot scope drift at a glance.\n- Be concise \u2014 as short as the answer allows, no shorter. Plain text, no preamble, no meta-commentary.\n- If you committed changes, list the paths and commit hashes in your report.\n</fork-boilerplate>\n\nYour directive: ";
|
|
710
|
+
/**
|
|
711
|
+
* RB-295 (CC 2.1.220 `Kus` @273133 — verbatim modulo the two interpolations): the path-translation note
|
|
712
|
+
* a FORK gets when it also runs under `isolation: "worktree"`. Upstream pushes it as its own message
|
|
713
|
+
* appended AFTER the fork's directive messages (@466667: `if (L && Le) de.push(zr({content: Kus(…)}))`)
|
|
714
|
+
* — it exists precisely because a fork INHERITS the parent's transcript, and every absolute path in that
|
|
715
|
+
* transcript points at the parent's working copy while the fork's tools now resolve inside the worktree.
|
|
716
|
+
* A non-fork worktree child has no inherited paths and gets no note, exactly as upstream.
|
|
717
|
+
*
|
|
718
|
+
* `parentCwd` is unknown on mounts that never threaded a parent working root; the sentence then names
|
|
719
|
+
* the relationship instead of a path (the translation instruction is what carries the value, not the
|
|
720
|
+
* literal directory), which is the only place this diverges from the anchor.
|
|
721
|
+
*/
|
|
180
722
|
export declare function forkWorktreeTranslationNote(parentCwd: string | undefined, worktreeDir: string): string;
|
|
723
|
+
/**
|
|
724
|
+
* RB-291 — the `async_launched` tool-result card, rebuilt from the CC 2.1.220 anchor (@467305-467320)
|
|
725
|
+
* and shared by both background lanes (Agent bg + fork bg) so the two copies cannot drift apart again.
|
|
726
|
+
* Three drifts were repaired against the anchor:
|
|
727
|
+
* ① the closing instruction had inverted the anchor's meaning — sema said "end your response. Do not
|
|
728
|
+
* generate any other text", CC says "continue other work or respond to the user in the meantime".
|
|
729
|
+
* CC parks the model on the RESULTS (do not report/assume/predict), never on the turn itself; the
|
|
730
|
+
* old text told a model with unrelated work queued to stop working, which is a real capability loss;
|
|
731
|
+
* ② the internal-ID guard was absent — CC brackets both the whole result ("internal metadata — never
|
|
732
|
+
* quote or paste any part of it … into a user-facing reply") and the id line itself;
|
|
733
|
+
* ③ the SendMessage continuation pointer was absent — CC teaches the exact follow-up call, with the
|
|
734
|
+
* summary shape, right on the card.
|
|
735
|
+
* Registered sema-side deltas that STAY: the id is the unified `task_id` (CC: `agentId`); sema has no
|
|
736
|
+
* agent output file, so the anchor's no-outputFile variant is the one reproduced; `notify: false` is
|
|
737
|
+
* sema's honest degrade arm (CC always has a notification lane); the caller's `notes` are sema's own
|
|
738
|
+
* per-call truths (model override, injected tools, worktree, task- vs session-scoped lifetime).
|
|
739
|
+
*/
|
|
181
740
|
export declare function asyncLaunchedReceipt(p: {
|
|
182
741
|
taskId: string;
|
|
742
|
+
/** The lane's own "what is running" opener — the Agent lane and the fork lane say different things. */
|
|
183
743
|
workingLine: string;
|
|
744
|
+
/** Whether a real notification sink is wired (codex R4: the receipt speaks the RUNTIME sink truth). */
|
|
184
745
|
notify: boolean;
|
|
746
|
+
/**
|
|
747
|
+
* RB-220 — mirrors {@link import("../core/types.js").ToolExecuteContext.oneShot}: this run has no
|
|
748
|
+
* later turn for an async background notification to land in (a headless `-p` process exits once
|
|
749
|
+
* the turn ends). Checked AHEAD of `notify` below — a one-shot submission is wrong to promise a
|
|
750
|
+
* notification regardless of whether a notify sink happens to be wired, the same failure form
|
|
751
|
+
* `run_workflow`'s launch note was fixed for (RB-215/run-workflow-tool.ts): a model that follows
|
|
752
|
+
* "end your turn and wait" advice in a one-shot process loses the result — the process exits with
|
|
753
|
+
* nothing left alive to receive it. Default undefined ⇒ byte-compat (pre-RB-220 wording).
|
|
754
|
+
*/
|
|
185
755
|
oneShot?: boolean;
|
|
756
|
+
/** Per-call honest notes, rendered one per line between the status line and the closing instruction. */
|
|
186
757
|
notes?: (string | undefined)[];
|
|
187
758
|
}): string;
|
|
759
|
+
/**
|
|
760
|
+
* Build a tool that lets a parent task delegate a subtask to an **isolated** sub-agent run.
|
|
761
|
+
*
|
|
762
|
+
* The child runs synchronously in a fresh session (isolated context) with a narrowed tool set and
|
|
763
|
+
* its own model, and returns a structured, machine-readable handoff (status / result / blockedReason / stats).
|
|
764
|
+
*/
|
|
188
765
|
export declare function createSubagentTool(opts: SubagentToolOptions): ToolSpec;
|
|
766
|
+
/**
|
|
767
|
+
* Render an agent definition's tool boundary for the roster listing line tail — CC `gHm` semantics
|
|
768
|
+
* (pretty.js:453014-453027): explicit allowlist ⇒ the list (minus denies; empty ⇒ "None"); only denies ⇒
|
|
769
|
+
* "All tools except …"; neither ⇒ "All tools". sema delta: `allowTools: ["*"]` is the documented
|
|
770
|
+
* allow-everything sentinel (AgentDefinition.allowTools) — treated as NO allowlist, not a literal list.
|
|
771
|
+
*
|
|
772
|
+
* [901] deliberate: this renders the AUTHORED list raw — upstream's listing does too (gHm reads the
|
|
773
|
+
* definition; the unknown-item split happens later, at spawn, in its resolveAgentTools). It is the
|
|
774
|
+
* DECLARED boundary, NOT the effective child roster: an unknown entry may appear here while the
|
|
775
|
+
* spawn-time filter (resolveToolSubset — the authority) drops it, and an alias-form divergence can
|
|
776
|
+
* show a name the deny leg removes at spawn (allow:["HttpGet"] + deny:["Fetch"] over a Fetch/HttpGet
|
|
777
|
+
* aliased tool displays HttpGet yet mounts nothing). Rendering a mount-time "resolved" face instead
|
|
778
|
+
* would both diverge from the anchor and lie the other way (per-spawn extraTools products are not
|
|
779
|
+
* knowable here).
|
|
780
|
+
*/
|
|
189
781
|
export declare function agentToolsNote(def: {
|
|
190
782
|
allowTools?: string[];
|
|
191
783
|
denyTools?: string[];
|
|
192
784
|
}): string;
|
|
785
|
+
/**
|
|
786
|
+
* F4 (CC 2.1.198 `tIl` selection half — 锚 pretty.js:453029 `(t && e.whenToUseLean) || e.whenToUse`,
|
|
787
|
+
* `t = yg(mainLoopModel)` :479504): pick the roster guidance text for one agent definition. CC keys
|
|
788
|
+
* `lean` on its simple-system-prompt model predicate; sema runs the CC lean-prompt arm wholesale
|
|
789
|
+
* (provider-neutral engine, web.ts lean-card precedent), so every call site passes the default
|
|
790
|
+
* `lean = true` — a definition WITH `whenToUseLean` shows the lean text (exactly what modern CC main
|
|
791
|
+
* models see), one without is unchanged. Empty-string lean falls back like CC (`||`, not `??`).
|
|
792
|
+
*/
|
|
193
793
|
export declare function agentWhenToUseText(def: {
|
|
194
794
|
whenToUse?: string;
|
|
195
795
|
whenToUseLean?: string;
|