@sema-agent/core 5.19.0 → 5.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +102 -4
- 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/roster-store.js +3 -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/circuit-breaker.js +14 -3
- 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 +108 -0
- package/dist/brain/timeout.js +11 -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 +293 -0
- package/dist/core/background-agent-store.js +5 -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 +609 -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/mailbox-store.js +2 -0
- package/dist/core/mcp.d.ts +385 -0
- package/dist/core/mcp.js +58 -11
- 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 +40 -0
- package/dist/core/retention-policy.js +21 -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 +51 -14
- package/dist/core/runner/prompt-suggestions.d.ts +7 -0
- package/dist/core/runner/runtask.d.ts +304 -3
- package/dist/core/runner/runtask.js +17 -2
- 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-agent.js +2 -0
- 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-policy.js +3 -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/core/workflow-run-store.js +2 -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 +17 -2
- package/dist/index.js +1 -2
- 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-spec.js +4 -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/orchestration/workflow.js +13 -2
- 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/background-agent-store.js +2 -1
- 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/mailbox-store.js +2 -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/stores/file/workflow-run-store.js +2 -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-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/web.js +32 -5
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,98 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.21.0 — 2026-08-09
|
|
4
|
+
|
|
5
|
+
### BREAKING
|
|
6
|
+
|
|
7
|
+
- **`createGiteaIssueTool` / `GiteaIssueToolOptions` removed** (historical deletion). A single-vendor
|
|
8
|
+
HTTP integration from this repo's own early self-hosted era — the engine is the wrong layer for it.
|
|
9
|
+
A deployment that wants issue-filing mounts its own ToolSpec (~30 lines against its forge's API) or
|
|
10
|
+
an MCP server; nothing else in the engine referenced it.
|
|
11
|
+
|
|
12
|
+
## 5.20.0 — 2026-08-08
|
|
13
|
+
|
|
14
|
+
### BREAKING
|
|
15
|
+
|
|
16
|
+
Configuration hygiene sweep. A malformed numeric knob used to be accepted and then quietly do
|
|
17
|
+
something — usually the OPPOSITE of what it was set to. Every seam below now either refuses the
|
|
18
|
+
value at its resolution point or clamps it and says so. Well-formed values in the documented range
|
|
19
|
+
are untouched everywhere; the break is that values which used to be accepted-then-misbehave are
|
|
20
|
+
now rejected, so a deployment carrying one gets a loud failure at wiring time instead of a
|
|
21
|
+
mysterious runtime.
|
|
22
|
+
|
|
23
|
+
- **MCP millisecond env knobs** (`MCP_TOOL_TIMEOUT`, `MCP_TOOL_TIMEOUT_TOTAL`,
|
|
24
|
+
`MCP_IDLE_TIMEOUT_STDIO`, `MCP_IDLE_TIMEOUT_HTTP`, `MCP_TIMEOUT`) share one parser, which was
|
|
25
|
+
`parseInt`-based: `1e9` meant 1ms, `30s` meant 30ms, and `100_000_000` — the way this repo writes
|
|
26
|
+
the default constant it invites you to copy — meant 100ms. Past 2^31-1 the host timer truncated
|
|
27
|
+
the delay and fired at once, so widening a watchdog to "basically off" made it abort every call,
|
|
28
|
+
while the failure text quoted the requested number back. The parser now reads plain digits,
|
|
29
|
+
scientific notation and digit grouping, refuses anything else, and clamps into
|
|
30
|
+
**[1000, 2147483647] ms**, warning once on stderr with the knob name, the raw text and the value
|
|
31
|
+
actually in force. Timeout frames quote the resolved value. `MAX_MCP_OUTPUT_TOKENS` moves onto the
|
|
32
|
+
same grammar (its `1e5` used to mean a 4-char budget), keeping upstream's unbounded range.
|
|
33
|
+
Upgrade note (the widening side of this fix): on 5.19.0 and earlier, `1e9` / `1_800_000` — both
|
|
34
|
+
legal upstream spellings — silently took effect as **1ms**. After upgrading they take effect at
|
|
35
|
+
face value, so a deployment that wrote one of these will see the knob jump from 1ms to the
|
|
36
|
+
number it always said.
|
|
37
|
+
- **Millisecond knobs that arm a host timer** are refused above 2147483647ms (~24.8 days), where
|
|
38
|
+
the timer truncates and fires immediately: the stall watchdogs (`connectTimeoutMs`,
|
|
39
|
+
`firstTokenTimeoutMs`, `idleTimeoutMs`), `brainCallGuardrailMs`, `runWorkflow`'s `totalTimeoutMs`
|
|
40
|
+
/ `stallMs` / `throttleBackoffMs`, and `createApprovalPolicy`'s `approvalTimeoutMs` — the last of
|
|
41
|
+
which would otherwise have denied every request instantly, fail-closed and silent. Each already
|
|
42
|
+
documents `0` / `false` / omission as "off". `limits.maxWalltimeMs` is the exception and keeps
|
|
43
|
+
its promise of no ceiling: the hard-abort timer now waits in representable chunks.
|
|
44
|
+
- **Retention policies** (`BackgroundAgentStore.reap`, `MailboxStore.reap`, `WorkflowRunStore.reap`,
|
|
45
|
+
`reapDurableAgents`, both roster stores' constructors) refuse a non-finite or negative bound with
|
|
46
|
+
`config.retention_policy_invalid`. `keep` is consumed as `slice(Math.max(0, keep))`, where NaN
|
|
47
|
+
collapses to `slice(0)` and deleted EVERY terminal row in the scope; the roster's `maxAgeMs` made
|
|
48
|
+
every durable address read as expired. Absent fields keep their "this arm is not applied" meaning.
|
|
49
|
+
Operational note: this is a refusal, not a sanitize — a deployment with a malformed retention knob
|
|
50
|
+
will see every reap throw (rows accumulate) until the knob is corrected. Fix the knob before
|
|
51
|
+
upgrading; nothing is auto-repaired on your behalf.
|
|
52
|
+
- **Web and circuit-breaker knobs**: `timeoutMs` on WebFetch / WebSearch / the Searxng backend fed a
|
|
53
|
+
bare `setTimeout`, where NaN and Infinity both become 1ms — a budget written as "no limit" aborted
|
|
54
|
+
every request on arrival and reported "timed out after NaNms". `maxResults` fed `slice(0, max)`,
|
|
55
|
+
so a NaN or 0 cap emptied every search from a backend that answered. The circuit breaker's
|
|
56
|
+
`failureThreshold` / `cooldownMs` / `halfOpenProbes` had no validation at all, and `failures >= NaN`
|
|
57
|
+
is false forever — an unevaluable threshold left the breaker permanently open-loop. All are now
|
|
58
|
+
resolved at assembly time (`config.web_timeout_invalid`,
|
|
59
|
+
`config.web_search_max_results_invalid`, `config.circuit_breaker_invalid`). `probeSearchBackend`
|
|
60
|
+
keeps its documented never-throws contract: a malformed budget comes back as `{ ok: false, error }`.
|
|
61
|
+
|
|
62
|
+
### Added
|
|
63
|
+
|
|
64
|
+
- **`Hooks.preToolUseObservational`** — a deployment declares that its PreToolUse face is a pure
|
|
65
|
+
OBSERVER (a tracer, an audit sink) and never judges. 5.19.0's delegation fold keys on PRESENCE,
|
|
66
|
+
which cannot tell a tracer from a screener: a deployment that flipped on a default-OFF diagnostic
|
|
67
|
+
hook thereby added an opaque constraint to every delegated child, and a child that durably parked
|
|
68
|
+
recorded that count on its row — where an approval redeemed by a leg that cannot re-supply the
|
|
69
|
+
live screening closure has no recovery path. With the declaration the face contributes **no
|
|
70
|
+
chain entry**, so `parentConstraintCount` counts only constraints that actually judge; without it,
|
|
71
|
+
5.19.0 behavior is unchanged. The callback still runs in the installing task's own gate, on every
|
|
72
|
+
call, with the same crash posture (a throw is still the fail-closed deny) — only the inherited
|
|
73
|
+
constraint goes away. A declared-observational face that returns something anyway has that return
|
|
74
|
+
**refused, not obeyed**: the call proceeds as if the face had no opinion (this covers
|
|
75
|
+
`additionalContext` too) and `onError` is told (`phase:"hook"`, classification
|
|
76
|
+
`observational-hook-verdict-ignored`), so the declaration cannot become a quiet way to keep a
|
|
77
|
+
screening face's verdicts while shedding the delegation constraint they belong to. A declared face
|
|
78
|
+
is also handed a **detached copy of the arguments** (best-effort, same helper and same limits as the
|
|
79
|
+
other observe-only payloads): the gate reads a rewrite off reference identity, so an in-place edit
|
|
80
|
+
would be a second channel outliving the dropped return. Two further consequences of "it does not
|
|
81
|
+
judge": a declared face no longer collapses an ancestor's screening entry that names the same
|
|
82
|
+
callback (the descendant no longer honors it, so the ancestor's constraint is folded instead), and it
|
|
83
|
+
no longer counts as an effect-aware gate for the loud ungated-write-surface warning.
|
|
84
|
+
- **`createPreToolUseConstraintPolicy` is now a public export**, and a durable park under an inherited
|
|
85
|
+
screening constraint says so at PARK time. A checkpoint records only how many opaque constraints its
|
|
86
|
+
leg ran under; the resume must hand the same chain back. Every entry kind except one is a policy the
|
|
87
|
+
deployment authored — the screening entry 5.19.0 added is engine-minted, so a hook-wired tree's
|
|
88
|
+
parked children were redeemable only in the process that spawned them (same-Runner resumes are
|
|
89
|
+
auto-re-supplied from the in-memory registry and were never affected). The mint is now exported, so a
|
|
90
|
+
fresh Runner can rebuild the entry — same callback, same installed env — and hand the full chain to
|
|
91
|
+
`resumeStream(..., internals)`; the recorded-count check is unchanged, so a short or mismatched chain
|
|
92
|
+
is still refused pre-CAS. And the park itself now announces the requirement once per task on
|
|
93
|
+
`onError` (`phase:"degraded"`, classification `screening-constraint-in-durable-chain`), naming the
|
|
94
|
+
recorded count and the ways out, instead of leaving it to be discovered at a redemption that fails.
|
|
95
|
+
|
|
3
96
|
## 5.19.0 — 2026-08-10
|
|
4
97
|
|
|
5
98
|
> Three bundles, each pre-verified two-way by the evaluation line against the 5.18.1 artifact
|
|
@@ -14,10 +107,15 @@
|
|
|
14
107
|
four-axis dedup so a deps-level hook is consulted once per call at any depth). A screening
|
|
15
108
|
`ask` resolves at the installing task's frozen approver; a hook-wired parent with no approver
|
|
16
109
|
denies its children's screened calls fail-closed.
|
|
17
|
-
**Operational**: `parentConstraintCount` gains a
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
110
|
+
**Operational (corrected per downstream measurement)**: `parentConstraintCount` gains a
|
|
111
|
+
screening entry for hook-wired trees. Pre-5.19.0 rows (including hook-wired parents) recorded
|
|
112
|
+
the old count and rebuild legs that supply it keep matching — upgrade and rollback are clean
|
|
113
|
+
for EXISTING pending checkpoints. The unrecoverable case is a checkpoint **minted on 5.19.0**
|
|
114
|
+
by a hook-wired parent and redeemed by a rebuild leg that cannot re-supply the live screening
|
|
115
|
+
entry (cross-replica redemption): it fails pre-CAS with `resume.parent_constraint_mismatch`
|
|
116
|
+
and stays pending, with no recovery path (the count is written at park time; disabling the
|
|
117
|
+
hook afterwards does not change it). Same-replica resumes via `resumeStream(..., internals)`
|
|
118
|
+
are unaffected. A delegated child of a hook-wired parent also sets
|
|
21
119
|
`requiresParentConstraint`, so its durable resume must re-supply the chain via
|
|
22
120
|
`resumeStream(..., internals)`.
|
|
23
121
|
- **Write guards judge the call's live cwd** (P1, host-lane proven bypass). A resident shell's
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import type { AgentDefinition } from "../core/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Validate + freeze a declarative sub-agent definition (design/38 1B). A thin, fail-fast factory: it
|
|
4
|
+
* checks the only hard requirement (a non-empty `name`) and returns a shallow-frozen copy so a stored
|
|
5
|
+
* definition can't be mutated out from under the registry. Registry-level checks (name uniqueness,
|
|
6
|
+
* collision with reserved/tool names, model-ref resolution) happen when the set is handed to
|
|
7
|
+
* {@link createSubagentTool}, where the tool name + model catalog are available.
|
|
8
|
+
*/
|
|
2
9
|
export declare function defineAgent(def: AgentDefinition): AgentDefinition;
|
|
@@ -1,15 +1,45 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
import type { Runner } from "../core/runner/runtask.js";
|
|
3
|
+
/** Model-facing name of the child-transcript read tool (residual lane C). */
|
|
3
4
|
export declare const AGENT_TRANSCRIPT_TOOL_NAME = "AgentTranscript";
|
|
4
5
|
export interface AgentTranscriptToolOptions {
|
|
6
|
+
/** Runner whose `sessions` store holds the child's persisted history. */
|
|
5
7
|
runner: Runner;
|
|
8
|
+
/** The unified registry the background Agent lane registered its a* handles in (scopes reads to lineage). */
|
|
6
9
|
registry: import("../core/task-registry.js").TaskRegistry;
|
|
10
|
+
/** design/151 S1b: the durable ledger — when the live row/retain entry is gone (restart, terminal GC,
|
|
11
|
+
* retain off), the row's `sessionId` still anchors the PRESERVED transcript session (the S1b
|
|
12
|
+
* lifecycle flip skipped its release). Reads go through `runner.sessions` — a split-store child
|
|
13
|
+
* (caller-mounted Agent tool with its own runner) is honestly unreadable here after a restart. */
|
|
7
14
|
agentStore?: import("../core/background-agent-store.js").BackgroundAgentStore;
|
|
15
|
+
/** Access identity (mirrors SendMessage/TaskOutput — the mount fills these). */
|
|
8
16
|
owner?: string;
|
|
9
17
|
scope?: string;
|
|
10
18
|
sessionId?: string;
|
|
19
|
+
/**
|
|
20
|
+
* RB-409 seat, wired by RB-448 — the mount's per-call ctx builder, forwarded to {@link defineTool}
|
|
21
|
+
* (see {@link import("../core/tools.js").ToolCtxEnricher}). This tool is a `defineTool` PRODUCT, so
|
|
22
|
+
* without it the body sees exactly `{toolCallId, signal}` and `ctx.subagentRetain` below is always
|
|
23
|
+
* undefined — the run-scoped retain ledger has NO other channel (its own doc calls itself "threaded
|
|
24
|
+
* to delegation tools as the TRUSTED ctx.subagentRetain"), so the ordinary retained child this tool
|
|
25
|
+
* advertises reading was structurally unreachable and every such call fell through to the durable
|
|
26
|
+
* lane and then to "not retained". Same seat, same builder and same rationale as the SendMessage
|
|
27
|
+
* twin (RB-409 fixed it there and left this sibling — extracted from the same source file in
|
|
28
|
+
* design/157 A7 — behind). Absent ⇒ unchanged behavior: the `opts` axes alone supply the identity.
|
|
29
|
+
*/
|
|
11
30
|
enrichCtx?: import("../core/tools.js").ToolCtxEnricher;
|
|
12
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Residual observability (lane C) — build the MODEL-VISIBLE **AgentTranscript** tool: read the last N tool steps of a
|
|
34
|
+
* previously spawned background agent ON DEMAND (a PULL face — it does NOT inflate the parent's context
|
|
35
|
+
* the way an injected residual would). `id` is the a* task_id the Agent tool returned. This is the
|
|
36
|
+
* complement to the stop-time residual (which the notification already carries): use it to look deeper
|
|
37
|
+
* into a child's tail when the residual isn't enough.
|
|
38
|
+
*
|
|
39
|
+
* Safety: reads are bounded to the parent's OWN lineage — the same non-leaking registry access scope as
|
|
40
|
+
* SendMessage/TaskOutput (an unknown or out-of-scope id reads identically to "not found"). Only a
|
|
41
|
+
* RETAINED child's session survives to be read; a throwaway child returns an honest "not retained".
|
|
42
|
+
*/
|
|
13
43
|
export declare function createAgentTranscriptTool(opts: AgentTranscriptToolOptions): import("../internal/harness-types.js").AgentTool<Type.TObject<{
|
|
14
44
|
id: Type.TString;
|
|
15
45
|
lastN: Type.TOptional<Type.TInteger>;
|
|
@@ -1,8 +1,68 @@
|
|
|
1
1
|
import type { AgentDefinition } from "../core/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* F1 (design/135 批次3 / PARITY-SPOT-AGENT-TYPES-2026-07-10) — the CC 2.1.198 BUILT-IN `Explore` and
|
|
4
|
+
* `Plan` agent types, ported to sema's AgentDefinition roster shape.
|
|
5
|
+
*
|
|
6
|
+
* 198 锚 (亲核 2026-07-10, drift 调研: 198→204→206 逐字零漂移):
|
|
7
|
+
* - Explore definition `qme` — pretty.js:409186-409198 (`agentType:"Explore"`, whenToUse=nbm,
|
|
8
|
+
* whenToUseLean=rbm, `disallowedTools:[is,NR,s0,xa,Ic,FR]` = Agent/Artifact/ExitPlanMode/Edit/Write/
|
|
9
|
+
* NotebookEdit, `model:"inherit"`, `omitClaudeMd:!0`, getSystemPrompt=tbm).
|
|
10
|
+
* - Explore whenToUse `nbm` / whenToUseLean `rbm` — pretty.js:409173-409174 (verbatim below).
|
|
11
|
+
* - Explore system prompt `tbm()` — pretty.js:409122-409160 (verbatim below, unix+Glob/Grep arm).
|
|
12
|
+
* - Plan definition `Xor` — pretty.js:486943-486953 (`agentType:"Plan"`, single whenToUse, same six
|
|
13
|
+
* disallowedTools, `tools: qme.tools` = undefined, `model:"inherit"`, `omitClaudeMd:!0`).
|
|
14
|
+
* - Plan system prompt `kBm()` — pretty.js:486874-486930 (verbatim below, unix arm).
|
|
15
|
+
* - Registry `HCe` — pretty.js:487221-487240: Explore+Plan ship behind `iAt()` (487127-487131:
|
|
16
|
+
* env kill-switch `CLAUDE_CODE_DISABLE_EXPLORE_PLAN_AGENTS` + `tengu_slate_ibis` gate DEFAULT ON)
|
|
17
|
+
* ⇒ GA default-on in 198 (and byte-stable through 204/206 — CC-DRIFT-198-206-AGENT-TYPES 锚 1-7).
|
|
18
|
+
* SDK entrypoints ship them too (only `claude-code-guide` is non-SDK); the SDK-form opt-out is
|
|
19
|
+
* `CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS` (487221) → sema's deployment-config analog is
|
|
20
|
+
* `SubagentToolOptions.builtinAgents: false` (config-driven, not env-driven).
|
|
21
|
+
*
|
|
22
|
+
* sema adaptations (deliberate, each recorded):
|
|
23
|
+
* - De-branding (prompt-sovereignty / SUBAGENT_PROMPT precedent): CC's persona first sentences name the
|
|
24
|
+
* product ("… for Claude Code, Anthropic's official CLI for Claude." / "… for Claude Code.") — sema
|
|
25
|
+
* stays provider-neutral, the brand clause is dropped; every other byte is CC-verbatim.
|
|
26
|
+
* - Platform arm: CC's `tbm`/`kBm` interpolate per-platform tool guidance (unix Bash vs PowerShell) and
|
|
27
|
+
* a bash-only search mode (`ww()`). sema children run in a POSIX ExecutionEnv with first-party
|
|
28
|
+
* Glob/Grep/Read/Bash under CC-identical names — the unix + Glob/Grep arm is baked verbatim
|
|
29
|
+
* (Mu="Glob" :149761, Jc="Grep" :224202, Ls="Read", Lo="Bash").
|
|
30
|
+
* - `model:"inherit"` — sema shape: `model` omitted on an AgentDefinition = inherit the caller's current
|
|
31
|
+
* model (identical semantics). CC's Explore firstParty opus UPGRADE (`GAe`, 409162-409171: built-in
|
|
32
|
+
* Explore may upshift to opus on first-party subscriptions) is a CC-subscription ladder concern —
|
|
33
|
+
* NOT ported (sema is provider-neutral; inherit is the base arm both sides share).
|
|
34
|
+
* - `omitClaudeMd:!0` (422063: drops the CLAUDE.md user-context layer for these types) — NOT ported this
|
|
35
|
+
* round: sema's project-context layer is assembled in prepare-task (design/113 C4), a concurrent-batch
|
|
36
|
+
* conflict domain at port time. Recorded as the F7 residual; the deployment `loadProjectMemory` seam
|
|
37
|
+
* already receives `isSubagent`/`agentName` and can trim today.
|
|
38
|
+
* - `disallowedTools` → `denyTools` (sema name), with the DELEGATION-tool entry tracking the deployment's
|
|
39
|
+
* actual tool name (default "Agent" = CC-verbatim). "Artifact"/"ExitPlanMode" have first-party sema
|
|
40
|
+
* referents only partially (present_plan canonicalizes to ExitPlanMode; Artifact has none) — a deny of
|
|
41
|
+
* an unmounted name is a documented no-op (tool-filter), kept for CC listing-tail byte parity.
|
|
42
|
+
*/
|
|
43
|
+
/** CC 198 `nbm` (pretty.js:409173) — Explore `whenToUse`, verbatim. */
|
|
2
44
|
export declare const EXPLORE_WHEN_TO_USE = "Fast read-only search agent for locating code. Use it to find files by pattern (eg. \"src/components/**/*.tsx\"), grep for symbols or keywords (eg. \"API endpoints\"), or answer \"where is X defined / which files reference Y.\" Do NOT use it for code review, design-doc auditing, cross-file consistency checks, or open-ended analysis \u2014 it reads excerpts rather than whole files and will miss content past its read window. When calling, specify search breadth: \"quick\" for a single targeted lookup, \"medium\" for moderate exploration, or \"very thorough\" to search across multiple locations and naming conventions.";
|
|
45
|
+
/** CC 198 `rbm` (pretty.js:409174) — Explore `whenToUseLean`, verbatim. */
|
|
3
46
|
export declare const EXPLORE_WHEN_TO_USE_LEAN = "Read-only search agent for broad fan-out searches \u2014 when answering means sweeping many files, directories, or naming conventions and you only need the conclusion, not the file dumps. It reads excerpts rather than whole files, so it locates code; it doesn't review or audit it. Specify search breadth: \"medium\" for moderate exploration, \"very thorough\" for multiple locations and naming conventions.";
|
|
47
|
+
/** CC 198 Plan `whenToUse` (pretty.js:486945), verbatim (Plan has no lean variant in 198). */
|
|
4
48
|
export declare const PLAN_WHEN_TO_USE = "Software architect agent for designing implementation plans. Use this when you need to plan the implementation strategy for a task. Returns step-by-step plans, identifies critical files, and considers architectural trade-offs.";
|
|
49
|
+
/** CC 198 `tbm()` (pretty.js:409122-409160) — Explore persona, unix+Glob/Grep arm, first sentence de-branded. */
|
|
5
50
|
export declare const EXPLORE_SYSTEM_PROMPT = "You are a file search specialist. You excel at thoroughly navigating and exploring codebases.\n\n=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===\nThis is a READ-ONLY exploration task. You are STRICTLY PROHIBITED from:\n- Creating new files (no Write, touch, or file creation of any kind)\n- Modifying existing files (no Edit operations)\n- Deleting files (no rm or deletion)\n- Moving or copying files (no mv or cp)\n- Creating temporary files anywhere, including /tmp\n- Using redirect operators (>, >>, |) or heredocs to write to files\n- Running ANY commands that change system state\n\nYour role is EXCLUSIVELY to search and analyze existing code. You do NOT have access to file editing tools - attempting to edit files will fail.\n\nYour strengths:\n- Rapidly finding files using glob patterns\n- Searching code and text with powerful regex patterns\n- Reading and analyzing file contents\n\nGuidelines:\n- Use Glob for broad file pattern matching\n- Use Grep for searching file contents with regex\n- Use Read when you know the specific file path you need to read\n- Use Bash ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)\n- NEVER use Bash for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification\n- Adapt your search approach based on the thoroughness level specified by the caller\n- Communicate your final report directly as a regular message - do NOT attempt to create files\n\nNOTE: You are meant to be a fast agent that returns output as quickly as possible. In order to achieve this you must:\n- Make efficient use of the tools that you have at your disposal: be smart about how you search for files and implementations\n- Wherever possible you should try to spawn multiple parallel tool calls for grepping and reading files\n\nComplete the user's search request efficiently and report your findings clearly.";
|
|
51
|
+
/** CC 198 `kBm()` (pretty.js:486874-486930) — Plan persona, unix arm, first sentence de-branded. */
|
|
6
52
|
export declare const PLAN_SYSTEM_PROMPT = "You are a software architect and planning specialist. Your role is to explore the codebase and design implementation plans.\n\n=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===\nThis is a READ-ONLY planning task. You are STRICTLY PROHIBITED from:\n- Creating new files (no Write, touch, or file creation of any kind)\n- Modifying existing files (no Edit operations)\n- Deleting files (no rm or deletion)\n- Moving or copying files (no mv or cp)\n- Creating temporary files anywhere, including /tmp\n- Using redirect operators (>, >>, |) or heredocs to write to files\n- Running ANY commands that change system state\n\nYour role is EXCLUSIVELY to explore the codebase and design implementation plans. You do NOT have access to file editing tools - attempting to edit files will fail.\n\nYou will be provided with a set of requirements and optionally a perspective on how to approach the design process.\n\n## Your Process\n\n1. **Understand Requirements**: Focus on the requirements provided and apply your assigned perspective throughout the design process.\n\n2. **Explore Thoroughly**:\n - Read any files provided to you in the initial prompt\n - Find existing patterns and conventions using Glob, Grep, and Read\n - Understand the current architecture\n - Identify similar features as reference\n - Trace through relevant code paths\n - Use Bash ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)\n - NEVER use Bash for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification\n\n3. **Design Solution**:\n - Create implementation approach based on your assigned perspective\n - Consider trade-offs and architectural decisions\n - Follow existing patterns where appropriate\n\n4. **Detail the Plan**:\n - Provide step-by-step implementation strategy\n - Identify dependencies and sequencing\n - Anticipate potential challenges\n\n## Required Output\n\nEnd your response with:\n\n### Critical Files for Implementation\nList 3-5 files most critical for implementing this plan:\n- path/to/file1.ts\n- path/to/file2.ts\n- path/to/file3.ts\n\nREMEMBER: You can ONLY explore and plan. You CANNOT and MUST NOT write, edit, or modify any files. You do NOT have access to file editing tools.";
|
|
53
|
+
/**
|
|
54
|
+
* CC 198 `disallowedTools:[is,NR,s0,xa,Ic,FR]` (pretty.js:409189 Explore / :486948 Plan) — the six-tool
|
|
55
|
+
* deny set shared by both read-only built-ins, constants resolved 亲核: is="Agent"(147382),
|
|
56
|
+
* NR="Artifact"(143265), s0="ExitPlanMode"(149770), xa="Edit"(143358), Ic="Write"(143375),
|
|
57
|
+
* NotebookEdit FR(143373). The delegation-tool entry is parameterized on the deployment's actual tool
|
|
58
|
+
* name (default = "Agent", CC-verbatim).
|
|
59
|
+
*/
|
|
7
60
|
export declare const BUILTIN_READONLY_DENY_TOOLS: (delegationToolName?: string) => string[];
|
|
61
|
+
/**
|
|
62
|
+
* Build the built-in agent definitions offered by {@link import("./subagent.js").createSubagentTool}
|
|
63
|
+
* (CC `HCe` registry analog, SDK arm: Explore + Plan; general-purpose is sema's OMITTED-`subagent_type`
|
|
64
|
+
* fallback and fork lives in the `subagent_type` value domain — neither needs a definition here).
|
|
65
|
+
* A deployment definition of the same name SHADOWS a built-in (fork-shadowing precedent), and
|
|
66
|
+
* `builtinAgents: false` removes them wholesale (CC `CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS` form).
|
|
67
|
+
*/
|
|
8
68
|
export declare function builtinAgentDefinitions(delegationToolName?: string): AgentDefinition[];
|
package/dist/agents/cascade.d.ts
CHANGED
|
@@ -1,24 +1,98 @@
|
|
|
1
1
|
import type { Runner } from "../core/runner/runtask.js";
|
|
2
2
|
import type { ModelRef, TaskResult, TaskSpec } from "../core/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Quality-gate cascade (design/27). Run the SAME task across a ladder of models (cheapest → strongest);
|
|
5
|
+
* after each rung a caller-supplied **decidable gate** judges "good enough" — pass = keep it, fail =
|
|
6
|
+
* escalate to the next rung. Classic FrugalGPT cascade, as a thin function over `runner.runTask`
|
|
7
|
+
* (no Runner-core changes).
|
|
8
|
+
*
|
|
9
|
+
* APPLICABILITY: cascade only helps when the gate is **decidable** (a schema check, a verifier model, a
|
|
10
|
+
* concrete assertion). Open-ended "completeness" tasks (find every bug, writing quality) have no oracle —
|
|
11
|
+
* the gate keeps passing the first plausible cheap answer and escalation idles. Those want breadth /
|
|
12
|
+
* adversarial debate (a `team`), not a depth ladder.
|
|
13
|
+
*
|
|
14
|
+
* Cost note (design/27 §2): each rung is an independent COLD `runTask` — every escalation repays the
|
|
15
|
+
* full input cost. Cascade wins when (a) the cheap rung usually passes and (b) the prompt isn't so large
|
|
16
|
+
* that the restart tax dominates. It is NOT always cheaper than running the strongest model directly.
|
|
17
|
+
*
|
|
18
|
+
* Boundary vs teacher mode: teacher injects advice and continues the SAME session (recovery); cascade
|
|
19
|
+
* does independent re-runs on a model ladder (breadth). Orthogonal, not merged.
|
|
20
|
+
*/
|
|
21
|
+
/** A gate's verdict: a bare boolean, or `{ pass, diagnostics }` to attach reasoning to `attempts[]`. */
|
|
3
22
|
export type GateVerdict = boolean | {
|
|
4
23
|
pass: boolean;
|
|
5
24
|
diagnostics?: string;
|
|
6
25
|
};
|
|
7
26
|
export interface CascadeRung {
|
|
27
|
+
/** The model this rung runs on. */
|
|
8
28
|
model: ModelRef;
|
|
29
|
+
/** Optional per-rung overrides (default: inherit the task's). */
|
|
9
30
|
overrides?: Partial<Pick<TaskSpec, "limits" | "systemPrompt">>;
|
|
10
31
|
}
|
|
11
32
|
export interface CascadeConfig {
|
|
33
|
+
/** RB-473 — disclosure channel for CONTAINED host-callback failures in this scope (the RB-463
|
|
34
|
+
* isolation primitive's bounded first-failure per site). Absent ⇒ failures are counted only. */
|
|
12
35
|
onNotifyError?: (failure: import("../core/safe-notify.js").SafeNotifyFailure) => void;
|
|
36
|
+
/** Model ladder, cheapest → strongest. ≥1 rung; the last rung is the fallback (returned even if it doesn't pass). */
|
|
13
37
|
ladder: CascadeRung[];
|
|
38
|
+
/**
|
|
39
|
+
* Quality gate: given a rung's result, return whether it is good enough (true/`{pass:true}` = keep,
|
|
40
|
+
* false = escalate). Default: `status === "completed"` — and, if `spec.outputSchema` is set, also
|
|
41
|
+
* requires a valid `structuredOutput` (so a schema auto-gives "only keep a rung that actually produced
|
|
42
|
+
* valid structured output"; a prose-only completion escalates). The gate can be a pure check (structured
|
|
43
|
+
* output / fields), a verifier model, semantic agreement, etc. **A throw is treated as "did not pass"**
|
|
44
|
+
* (fail-open to escalate) and recorded as `attempts[].gateError` — so a broken gate can't strand the run,
|
|
45
|
+
* but a verifier-gate's own failure is still visible. The gate must be decidable (see APPLICABILITY).
|
|
46
|
+
*
|
|
47
|
+
* HRD-AGO-10 — a positive verdict is CONJOINED with the rung's status: it counts as a pass only when
|
|
48
|
+
* `result.status === "completed"`, unless {@link CascadeConfig.acceptPartial} is set. A status-blind gate
|
|
49
|
+
* ("the text is non-empty", "the JSON parses") could otherwise keep a blocked/failed/timeout rung, which made
|
|
50
|
+
* `cascadeOutcome: "passed"` disagree with the `status` the same object carries. A verdict rejected on those
|
|
51
|
+
* grounds is recorded as `passed: false` + {@link CascadeAttempt.statusRejected}, and the cascade escalates.
|
|
52
|
+
*
|
|
53
|
+
* @warning unredacted — the gate receives the UNREDACTED `TaskResult` (model output, structured output,
|
|
54
|
+
* stats); this is prose advisory, not an enforced boundary (design/54 §3.5, [46] DESIGN1). If your gate
|
|
55
|
+
* forwards output to an external service, ensure it has no sensitive data or sanitize first.
|
|
56
|
+
*/
|
|
14
57
|
gate?: (result: TaskResult, rung: {
|
|
15
58
|
index: number;
|
|
16
59
|
model: ModelRef;
|
|
17
60
|
}) => GateVerdict | Promise<GateVerdict>;
|
|
61
|
+
/**
|
|
62
|
+
* HRD-AGO-10 — the explicit opt-out from the require-completed conjunction above. Two states, no middle:
|
|
63
|
+
* - **omitted / `false` (default)** — a {@link gate} pass counts only on a `completed` rung. Unfinished work
|
|
64
|
+
* is escalated, so `cascadeOutcome: "passed"` always implies the returned rung actually finished.
|
|
65
|
+
* - **`true`** — the gate's verdict alone decides, so a deliberately partial answer can be kept (a blocked
|
|
66
|
+
* rung whose partial output IS the deliverable, a timeout whose streamed prefix is good enough). The
|
|
67
|
+
* returned `status` still reports the truth — this only says the gate is allowed to accept it.
|
|
68
|
+
*
|
|
69
|
+
* Ignored by the default gate, which requires `completed` in either case.
|
|
70
|
+
*/
|
|
18
71
|
acceptPartial?: boolean;
|
|
72
|
+
/** Max escalations (rungs run ≤ maxEscalations + 1). Default = `ladder.length - 1` (the whole ladder). */
|
|
19
73
|
maxEscalations?: number;
|
|
74
|
+
/** Stop escalating once cumulative cost reaches this; return the current best. Optional. */
|
|
20
75
|
costCeilingMicroUsd?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Overall wall-clock ceiling for the whole cascade (per-rung time is `spec.limits.timeout`). Optional.
|
|
78
|
+
*
|
|
79
|
+
* HRD-AGO-7 — this is a REAL deadline over the run, not just a gate on starting the next rung: each rung is
|
|
80
|
+
* dispatched with an `AbortSignal` that fires at `start + totalTimeoutMs` (combined with the caller's own
|
|
81
|
+
* `spec.signal` when there is one), so a rung already in flight when the budget runs out is ABORTED. What
|
|
82
|
+
* "aborted" buys is bounded by the workload's cooperation with cancellation — the brain request is cancelled
|
|
83
|
+
* and a tool that honors its `ToolExecuteContext.signal` stops at once, but a tool that ignores its signal
|
|
84
|
+
* still runs to its own completion (the run then assembles as failed the moment it returns). Cleanup on a
|
|
85
|
+
* cut: the rung's result is NOT gated (truncated work must never pass), its session IS released (nothing
|
|
86
|
+
* pins it — a durable pause is handled earlier and returns instead), the attempt is recorded with
|
|
87
|
+
* `timedOut: true`, and the ladder stops (`cascadeOutcome: "exhausted"`) rather than escalating past a
|
|
88
|
+
* deadline that has already passed.
|
|
89
|
+
*
|
|
90
|
+
* A budget already spent AT ENTRY (`0`, negative, or a caller that measured elapsed time itself) dispatches
|
|
91
|
+
* NOTHING and returns the cascade's own terminal: `status: "failed"`, `errorCode:
|
|
92
|
+
* "cascade.budget_exhausted"`, empty `attempts`, `finalRung: -1`.
|
|
93
|
+
*/
|
|
21
94
|
totalTimeoutMs?: number;
|
|
95
|
+
/** Per-rung callback (observability). */
|
|
22
96
|
onRung?: (info: {
|
|
23
97
|
index: number;
|
|
24
98
|
model: ModelRef;
|
|
@@ -30,20 +104,53 @@ export interface CascadeAttempt {
|
|
|
30
104
|
index: number;
|
|
31
105
|
model: ModelRef;
|
|
32
106
|
passed: boolean;
|
|
107
|
+
/** This rung's OWN+nested spend. ABSENT when the rung ran unpriced (RB-368 knownness, codex batch-4
|
|
108
|
+
* F4) — a fabricated 0 here both misreported the attempt and let escalation ride under a finite
|
|
109
|
+
* ceiling the engine could not actually enforce. */
|
|
33
110
|
costMicroUsd?: number;
|
|
34
111
|
status: TaskResult["status"];
|
|
112
|
+
/** The rung's own failure code (e.g. "auth") if its `runTask` failed — distinct from "gate rejected it". */
|
|
35
113
|
errorCode?: string;
|
|
114
|
+
/** Set when the gate THREW (vs returned false) — surfaces a broken verifier-gate (expired key, etc.). */
|
|
36
115
|
gateError?: string;
|
|
116
|
+
/** HRD-AGO-7: this rung was CUT IN FLIGHT by {@link CascadeConfig.totalTimeoutMs}. Its result is truncated
|
|
117
|
+
* work, so it was never handed to the gate (`passed` is always false) and the ladder stopped here. */
|
|
37
118
|
timedOut?: true;
|
|
119
|
+
/** HRD-AGO-7: the CALLER's own `spec.signal` aborted during this rung (distinct from the cascade deadline).
|
|
120
|
+
* Same handling — no gate, no escalation onto an already-aborted signal. */
|
|
38
121
|
cancelled?: true;
|
|
122
|
+
/** HRD-AGO-10: the gate returned a PASS but the rung had not `completed`, so the verdict did not count
|
|
123
|
+
* (`passed: false`, escalate). Set only in the default require-completed mode — never with
|
|
124
|
+
* {@link CascadeConfig.acceptPartial}. */
|
|
39
125
|
statusRejected?: true;
|
|
126
|
+
/** Optional reasoning the gate attached to its verdict. */
|
|
40
127
|
diagnostics?: string;
|
|
41
128
|
}
|
|
42
129
|
export interface CascadeRunResult extends TaskResult {
|
|
130
|
+
/**
|
|
131
|
+
* The cascade's conclusion, **distinct from the inherited `status`**: `"passed"` = some rung passed the
|
|
132
|
+
* gate; `"exhausted"` = ladder/guards ran out with no rung passing (the last rung's result is returned,
|
|
133
|
+
* and its `status` may still be "completed" — judge the cascade by `cascadeOutcome`, not `status`).
|
|
134
|
+
*/
|
|
43
135
|
cascadeOutcome: "passed" | "exhausted";
|
|
136
|
+
/** F4: present when a finite `costCeilingMicroUsd` was configured but some rung's spend was unpriced —
|
|
137
|
+
* the ceiling could not be enforced over unknown cost, so the ladder STOPPED escalating (fail-closed)
|
|
138
|
+
* instead of riding an unbindable budget. Judge spend by the absent cost fields, not by 0. */
|
|
44
139
|
costCeilingUnenforceable?: true;
|
|
140
|
+
/** True if the returned result came from a rung after the first (i.e. an escalation happened). */
|
|
45
141
|
escalated: boolean;
|
|
142
|
+
/** Which rung (0-based) produced the returned result — or `-1` when NO rung was dispatched (an already
|
|
143
|
+
* spent {@link CascadeConfig.totalTimeoutMs}); `attempts` is then empty and the result is the cascade's
|
|
144
|
+
* own synthetic `cascade.budget_exhausted` terminal, not a rung's. */
|
|
46
145
|
finalRung: number;
|
|
146
|
+
/** Per-rung audit detail (cost, pass/fail, why). Each attempt's `costMicroUsd` includes that rung's nested
|
|
147
|
+
* (delegated) cost; the top-level `stats.costMicroUsd` is the sum of the rungs' OWN cost (nested totals live
|
|
148
|
+
* in `stats.nested.costMicroUsd`), so it is NOT the plain sum of `attempts[].costMicroUsd`. */
|
|
47
149
|
attempts: CascadeAttempt[];
|
|
48
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Side-effect note: `runCascade` runs the task up to N times. If your tools have non-idempotent effects
|
|
153
|
+
* (`effect: "write"`), those execute once PER rung — ensure idempotency, or gate before the side effect
|
|
154
|
+
* (e.g. a structured-output gate). `TaskSpec` never guaranteed idempotency; cascade makes it explicit.
|
|
155
|
+
*/
|
|
49
156
|
export declare function runCascade(runner: Runner, spec: TaskSpec, config: CascadeConfig): Promise<CascadeRunResult>;
|
|
@@ -1,29 +1,85 @@
|
|
|
1
1
|
import type { TaskResult } from "../core/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Shared CUMULATIVE-STATS constructor for the multi-leg agent compositions (cascade rungs, repair-loop
|
|
4
|
+
* attempts, teacher student attempts). All three run `runner.runTask` MORE THAN ONCE and must report the
|
|
5
|
+
* OPERATION's totals, not the last leg's.
|
|
6
|
+
*
|
|
7
|
+
* The invariant this exists to hold in ONE place: **every field the accumulator tracks is OVERRIDDEN over
|
|
8
|
+
* the base stats**. A field left un-overridden silently leaks the LAST leg's value dressed up as a
|
|
9
|
+
* cumulative total (the cascade R1-m5 / R3 trap; repair-loop shipped exactly that hole on `humanReview`).
|
|
10
|
+
* Three independent copies of this literal is how that hole survived in one copy while the other two were
|
|
11
|
+
* fixed — hence one constructor, three call sites.
|
|
12
|
+
*
|
|
13
|
+
* OWN and NESTED stay DISJOINT (the cascade R-5 / teacher A-7 convention): a consumer adds
|
|
14
|
+
* `stats.X + stats.nested.X` for the true total; nested cost is never folded into `costMicroUsd`.
|
|
15
|
+
*/
|
|
16
|
+
/** Cumulative delegated-subagent (nested) totals, summed across every leg. */
|
|
2
17
|
export interface CumulativeNestedTotals {
|
|
3
18
|
tokens: number;
|
|
4
19
|
turns: number;
|
|
5
20
|
tasks: number;
|
|
6
21
|
costMicroUsd: number;
|
|
7
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Cumulative human-review (design/91 C2 axis) burden, summed across every leg. `gates` is the ordered
|
|
25
|
+
* concatenation of each leg's gate entries — the element shape is the canonical one published on
|
|
26
|
+
* {@link TaskResult}, so a leg's entry passes through with `toolName`/`toolArg` intact.
|
|
27
|
+
*/
|
|
8
28
|
export interface CumulativeHumanReviewTotals {
|
|
9
29
|
count: number;
|
|
10
30
|
totalWaitMs: number;
|
|
11
31
|
gates: NonNullable<TaskResult["stats"]["humanReview"]>["gates"];
|
|
12
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* The running totals a multi-leg composition accumulates. Every field is REQUIRED: an optional field here
|
|
35
|
+
* would re-open the exact "forgot to override one" hole this module exists to close — a caller that has
|
|
36
|
+
* nothing to report passes zeros.
|
|
37
|
+
*/
|
|
13
38
|
export interface CumulativeStatsAccumulator {
|
|
14
39
|
tokens: number;
|
|
15
40
|
turns: number;
|
|
16
41
|
promptTokens: number;
|
|
42
|
+
/** RB-457-a: the cache-INCLUSIVE input total — its own leg, no longer derivable from `promptTokens` (the
|
|
43
|
+
* cache-MISS sum). Also the cache-hit-rate denominator. */
|
|
17
44
|
totalInputTokens: number;
|
|
18
45
|
cachedTokens: number;
|
|
19
46
|
outputTokens: number;
|
|
20
47
|
cacheWriteTokens: number;
|
|
21
48
|
cacheWriteTokensLong: number;
|
|
49
|
+
/**
|
|
50
|
+
* Cumulative own LLM cost (micro-USD) EXACTLY as the caller wants it published. Callers differ on the
|
|
51
|
+
* zero case on purpose and this constructor does not adjudicate: cascade/repair-loop publish a plain `0`
|
|
52
|
+
* (a run happened, it cost nothing measurable), teacher collapses `0` to `undefined` (the RB-368
|
|
53
|
+
* "unpriced spend is absent, not free" posture). Unifying the two is a BEHAVIOR change, not a refactor.
|
|
54
|
+
*
|
|
55
|
+
* Ignored entirely when {@link anyLegUnpriced} is set — see there.
|
|
56
|
+
*/
|
|
22
57
|
costMicroUsd: number | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* TRUE when ANY contributing leg published no `costMicroUsd`, i.e. it ran on a model with neither a
|
|
60
|
+
* `RunnerDeps.pricing` entry nor a `Model.cost` declaration (`stats.costMicroUsd` is contractually
|
|
61
|
+
* ABSENT there — types.ts / RB-368 [2076]).
|
|
62
|
+
*
|
|
63
|
+
* Accumulating such a leg as `?? 0` publishes a total that is not one: the operation's real cost is
|
|
64
|
+
* unknown, and reporting the priced legs' partial sum makes "no price table" indistinguishable from
|
|
65
|
+
* "declared free" — the exact conflation the single-leg face refuses. So the knownness travels with the
|
|
66
|
+
* money: when this is set, `costMicroUsd` AND `costBreakdown` are both omitted from the cumulative
|
|
67
|
+
* stats, matching what a single unpriced `runTask` already reports. Token/turn totals are unaffected
|
|
68
|
+
* (they are knowable regardless of pricing).
|
|
69
|
+
*/
|
|
23
70
|
anyLegUnpriced: boolean;
|
|
71
|
+
/** Cumulative root-agent LLM cost for the `costBreakdown` taxonomy. */
|
|
24
72
|
llmRootMicroUsd: number;
|
|
73
|
+
/** Cumulative within-task compaction LLM cost for the `costBreakdown` taxonomy. */
|
|
25
74
|
compactionMicroUsd: number;
|
|
26
75
|
nested: CumulativeNestedTotals;
|
|
27
76
|
humanReview: CumulativeHumanReviewTotals;
|
|
28
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Build the cumulative stats over a base (the FINAL leg's stats — it carries the non-accumulated fields
|
|
80
|
+
* such as `model`) with every accumulated field overridden.
|
|
81
|
+
*
|
|
82
|
+
* `cacheHitRate` is RE-DERIVED from the cumulative cached/total-input totals rather than spread from the
|
|
83
|
+
* base: a ratio is not additive, so the last leg's rate is never the operation's rate.
|
|
84
|
+
*/
|
|
29
85
|
export declare function buildCumulativeStats(base: TaskResult["stats"], acc: CumulativeStatsAccumulator): TaskResult["stats"];
|