@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
|
@@ -2,20 +2,42 @@ import { type TSchema } from "typebox";
|
|
|
2
2
|
import type { AgentTool } from "../../internal/harness-types.js";
|
|
3
3
|
import type { SkillManifest } from "../types.js";
|
|
4
4
|
import type { ActiveSkillScope } from "./active-skill-scope.js";
|
|
5
|
+
/** Reserved name of the injected structured-output tool (CC 2.1.187 `StructuredOutput`; batch-A rename — old
|
|
6
|
+
* "submit_output" is canonicalized for pre-rename durable state). */
|
|
5
7
|
export declare const OUTPUT_TOOL_NAME = "StructuredOutput";
|
|
8
|
+
/** Reserved name of the injected blocked-report signal tool (design/108 PascalCase: `report_blocked`→`ReportBlocked`). */
|
|
6
9
|
export declare const REPORT_BLOCKED_TOOL_NAME = "ReportBlocked";
|
|
10
|
+
/** Name of the injected code-review findings echo tool (CC 2.1.207 parity — 锚 pretty.js:361412 `BCe`). */
|
|
7
11
|
export declare const REPORT_FINDINGS_TOOL_NAME = "ReportFindings";
|
|
12
|
+
/** Default `submit_output` retries (council OS3); total attempts = retries + 1. Overridable via `TaskSpec.outputRetries`. */
|
|
8
13
|
export declare const OUTPUT_DEFAULT_RETRIES = 2;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the per-task cap on *consecutive failed* `submit_output` attempts. The task fails with
|
|
16
|
+
* `output.invalid` when the failure streak EXCEEDS this value, so total attempts = cap + 1
|
|
17
|
+
* (default 2 → 3 attempts; `outputRetries: 0` → cap 0 → fail on the first invalid submit). Illegal
|
|
18
|
+
* values (NaN/Infinity/negative) fall back to the default; fractional values floor down.
|
|
19
|
+
*/
|
|
9
20
|
export declare function resolveOutputRetries(outputRetries?: number): number;
|
|
10
21
|
export interface BlockedRef {
|
|
11
22
|
reason?: string;
|
|
12
23
|
}
|
|
24
|
+
/** Captures the validated object a `submit_output` call submitted (structured output, 1.41). `set` is
|
|
25
|
+
* flipped so we can tell "model submitted {}" from "never called". Mirrors `BlockedRef`. */
|
|
13
26
|
export interface OutputRef {
|
|
14
27
|
value?: unknown;
|
|
15
28
|
set?: boolean;
|
|
16
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* @param strictSchema CC 2.1.205 parity (strict-output-schema.ts): the STRICT derivation of `schema` when
|
|
32
|
+
* it converted (`additionalProperties:false` stamped, subset-validated). It becomes the tool's
|
|
33
|
+
* `parameters` — both the model-visible wire schema (CC sends it as `strictInputJSONSchema`) and the
|
|
34
|
+
* validation schema (the strict form only TIGHTENS the caller's schema, so anything it accepts is valid
|
|
35
|
+
* under the original — CC's Ajv-against-original validation agrees on every accepted submission).
|
|
36
|
+
* Absent (fallback / legacy callers) → the caller's schema is served as-is, the pre-205 behavior.
|
|
37
|
+
*/
|
|
17
38
|
export declare function createOutputTool(ref: OutputRef, schema: TSchema, strictSchema?: TSchema): AgentTool;
|
|
18
39
|
export declare function createReportBlockedTool(ref: BlockedRef): AgentTool;
|
|
40
|
+
/** One reported finding (the CC 207 wire shape — see {@link createReportFindingsTool}). */
|
|
19
41
|
export interface ReportedFinding {
|
|
20
42
|
file: string;
|
|
21
43
|
line?: number;
|
|
@@ -25,33 +47,124 @@ export interface ReportedFinding {
|
|
|
25
47
|
verdict?: "CONFIRMED" | "PLAUSIBLE";
|
|
26
48
|
outcome?: "fixed" | "skipped" | "no_change_needed";
|
|
27
49
|
}
|
|
50
|
+
/** Build the injected `ReportFindings` echo tool (CC 2.1.207 parity — description verbatim from 锚
|
|
51
|
+
* pretty.js:361413; `effect: "read"` mirrors CC `isReadOnly()`/`isConcurrencySafe()` → parallel-safe). */
|
|
28
52
|
export declare function createReportFindingsTool(): AgentTool;
|
|
53
|
+
/** Reserved name of the injected skill-loading tool (present only when `spec.skills` is non-empty). */
|
|
29
54
|
export declare const SKILL_TOOL_NAME = "Skill";
|
|
55
|
+
/** Per-skill LOAD gate on `SkillSpec.content` (CC 2.1.207 parity: CC's only size door at invoke
|
|
56
|
+
* time is a 1MB file-load gate — an over-limit skill is REJECTED WHOLE, never truncated; the
|
|
57
|
+
* invoked body itself enters context untruncated). Sema skills are spec-supplied content, so the
|
|
58
|
+
* equivalent gate sits at spec assembly (prepare-task): an oversized skill is excluded from both
|
|
59
|
+
* the disclosure block and the tool, with an operator-visible config error. The compaction-time
|
|
60
|
+
* retention caps live in the engine's compaction module — a different door, deliberately. */
|
|
30
61
|
export declare const SKILL_CONTENT_MAX_CHARS: number;
|
|
62
|
+
/** Total listing-block cap in UTF-8 BYTES — [c209-C] R2 C4①: the old 8000-CHAR cap measured a
|
|
63
|
+
* different coordinate than the bundle's `ATTACHMENT_BYTE_CAP` (8192 UTF-8 bytes) and counted only
|
|
64
|
+
* the description lines (fence framing + name-only tail rode free), so a near-cap frame could
|
|
65
|
+
* exceed the bundle cap, get clip-mangled every boundary, never pass the intact-survival commit
|
|
66
|
+
* predicate, and REPLAY FOREVER. The cap is now enforced byte-exact over the WHOLE rendered block
|
|
67
|
+
* (fences, headers, markers, joiners included), so `buildSkillsBlock` output always fits the
|
|
68
|
+
* bundle cap solo and an intact commit is always reachable. MUST stay ≤ ATTACHMENT_BYTE_CAP
|
|
69
|
+
* (turn-attachments.ts; not imported here — that module imports this one — pinned by test instead). */
|
|
31
70
|
export declare const SKILLS_BLOCK_MAX_BYTES = 8000;
|
|
71
|
+
/** Total per-invoke cap for a skill's inlined attachments (`SkillSpec.files`) — an ATTACHMENT-face
|
|
72
|
+
* budget, distinct from the (gone) body truncation door: the body itself is delivered untruncated
|
|
73
|
+
* at invoke time (CC parity), while attachments are reference material riding along — bounded and
|
|
74
|
+
* truncation-disclosed. */
|
|
32
75
|
export declare const SKILL_ATTACHMENTS_MAX_CHARS = 50000;
|
|
76
|
+
/** Per-attachment cap on the PATH rendered in its `###` header — a single pathological path must not
|
|
77
|
+
* eat the attachments budget on its own. Overflow is truncated with an ellipsis. */
|
|
33
78
|
export declare const SKILL_ATTACHMENT_PATH_MAX_CHARS = 512;
|
|
34
79
|
interface SkillLike {
|
|
35
80
|
name: string;
|
|
36
81
|
description: string;
|
|
37
82
|
content: string;
|
|
83
|
+
/** Optional Gate-3 runtime capability manifest (design/77 §3) — carried through so a successful
|
|
84
|
+
* `skill` load can push its scope frame. Skills without one stay unscoped (backward-compatible). */
|
|
38
85
|
manifest?: SkillManifest;
|
|
86
|
+
/** Optional attachments (SkillSpec.files): disclosed as paths in the block, delivered inline on
|
|
87
|
+
* invoke under {@link SKILL_ATTACHMENTS_MAX_CHARS}. Same caller-trusted contract as `content`
|
|
88
|
+
* (see the module note above) — core never writes them to disk (deployment's half). */
|
|
39
89
|
files?: Array<{
|
|
40
90
|
path: string;
|
|
41
91
|
content: string;
|
|
42
92
|
}>;
|
|
43
93
|
}
|
|
94
|
+
/** [c209-C] The metadata slice of a skill the LISTING faces consume (disclosure block + the
|
|
95
|
+
* skills_listing turn attachment): name, description, attachment paths — never the body. The
|
|
96
|
+
* Prepared seam projects `SkillSpec`s down to this shape so the run loop's announce lane holds no
|
|
97
|
+
* skill content. `SkillLike` is structurally assignable (its `files` entries simply carry an extra
|
|
98
|
+
* `content` the listing renderers never read). */
|
|
44
99
|
export interface SkillListingEntry {
|
|
45
100
|
name: string;
|
|
46
101
|
description: string;
|
|
47
102
|
files?: Array<{
|
|
48
103
|
path: string;
|
|
49
104
|
}>;
|
|
105
|
+
/** RB-316 — the skill's rank in the DEPLOYMENT'S DECLARATION order (`TaskSpec.skills`, first-wins
|
|
106
|
+
* dedupe applied, 0 = declared first). Lower = higher priority. Used ONLY to decide which skills keep
|
|
107
|
+
* their descriptions when the block overflows its byte budget ({@link buildSkillsBlock} tier B); the
|
|
108
|
+
* DISPLAY order stays name-sorted, so adding this never moves a line.
|
|
109
|
+
*
|
|
110
|
+
* Why declaration order: CC 220's `sbs` (@317547) takes a priority function and is called with
|
|
111
|
+
* `uNt(name)` (@608552 → @402383) = usage count decayed by recency of last use, and additionally
|
|
112
|
+
* pins every `bundled` skill's description unconditionally. Core has NEITHER axis — no cross-session
|
|
113
|
+
* skill-usage store, and no bundled/user distinction (every skill arrives through the same
|
|
114
|
+
* caller-supplied `TaskSpec.skills`). Declaration order is the one priority statement the deployment
|
|
115
|
+
* can actually make here, and it is the same statement 220's bundled-pin encodes ("these matter most,
|
|
116
|
+
* keep their descriptions"). Absent ⇒ the entry's array index is used, i.e. the pre-RB-316 behavior. */
|
|
50
117
|
declaredRank?: number;
|
|
51
118
|
}
|
|
119
|
+
/** Dedupe by name (first occurrence wins) and sort by name — one deterministic list shared by the
|
|
120
|
+
* disclosure block and the tool, so what the prompt promises is exactly what the tool serves. */
|
|
52
121
|
export declare function normalizeSkills(skills: SkillLike[] | undefined): SkillLike[];
|
|
122
|
+
/** [c209-C] The skills listing's lead line — single-sourced so the run loop's durable-resume
|
|
123
|
+
* transcript probe (MED-3② skills arm, runtask) matches EXACTLY what the initial frame carries
|
|
124
|
+
* (probing the bare `<skills>` fence would be more collision-prone in model-quoted text). */
|
|
53
125
|
export declare const SKILLS_LISTING_PROBE_HEADER = "The following skills are available for this task.";
|
|
126
|
+
/** [c209-C] One skill's disclosure line — `- name: description[(files 尾缀)]` with the per-skill
|
|
127
|
+
* description cap. Single-sourced so the skills_listing DELTA frame (turn-attachments) renders adds
|
|
128
|
+
* with byte-identical line shape to the initial `<skills>` block. */
|
|
54
129
|
export declare function skillListingLine(s: SkillListingEntry): string;
|
|
130
|
+
/** Render the `<skills>` disclosure block (metadata only — bodies stay behind the tool).
|
|
131
|
+
* [c209-C] REVERSAL: no longer composed into the stable system prompt — this is now the RENDERER for
|
|
132
|
+
* the `skills_listing` initial frame (first-user-turn reminder / boundary re-announce), so the
|
|
133
|
+
* cached prefix carries zero skill bytes (design/C §2.3; CC 209 classic ships the same listing as a
|
|
134
|
+
* first-turn reminder; Q6: 8KB cap ≈ CC's observed 5.9KB listing).
|
|
135
|
+
*
|
|
136
|
+
* [c209-C] R2 C4① — the cap is BYTE-EXACT over the whole rendered block (see
|
|
137
|
+
* {@link SKILLS_BLOCK_MAX_BYTES}): three honesty tiers, each chosen with the LATER tiers' fixed
|
|
138
|
+
* overhead (cap marker / name-only tail / overflow count line) already reserved so the final
|
|
139
|
+
* render can never blow the budget it was sized against —
|
|
140
|
+
* A. everything fits → every skill gets its full `- name: description` line (byte-identical to
|
|
141
|
+
* the pre-C4 render for every block that was legal under the old cap);
|
|
142
|
+
* B. RB-316 (CC 220 `sbs` @317547-317586) — reserve the cap marker + EVERY skill's name-only line
|
|
143
|
+
* first, then spend the remaining slack on descriptions in PRIORITY order
|
|
144
|
+
* ({@link SkillListingEntry.declaredRank}), admitting each description whose incremental cost
|
|
145
|
+
* still fits and skipping (not stopping at) the ones that do not. Every skill stays listed;
|
|
146
|
+
* the ones that lose their description are the low-priority ones, not the alphabetically late
|
|
147
|
+
* ones. This replaces the pre-RB-316 "longest full-line PREFIX" cut, which had two defects the
|
|
148
|
+
* anchor does not: the surviving set was decided by name sort order (a skill named `zip-deploy`
|
|
149
|
+
* lost its description to `aardvark-lint` for no reason connected to either skill), and one
|
|
150
|
+
* oversized description truncated the block at itself instead of being skipped over;
|
|
151
|
+
* C. even all-name-only overflows (pathological name census) → list what fits and close with an
|
|
152
|
+
* honest `(… +N more skills …)` count line — the tool still serves all of them. */
|
|
55
153
|
export declare function buildSkillsBlock(skills: ReadonlyArray<SkillListingEntry>): string | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* The injected `skill` tool: returns a skill's full body as a tool result.
|
|
156
|
+
*
|
|
157
|
+
* When a {@link ActiveSkillScope} is supplied (design/77 §3 Gate-3) and the loaded skill carries a
|
|
158
|
+
* `manifest`, a successful load PUSHES a scope frame onto the per-task LIFO stack, so the rest of the
|
|
159
|
+
* invocation is deny-narrowed to the manifest's tools/paths. Nested loads (a skill whose body loads
|
|
160
|
+
* another skill) STACK and compose MONOTONICALLY as the INTERSECTION of every active frame's
|
|
161
|
+
* `allowTools` — a child can only narrow further, never re-grant. Frames are popped at task end (and
|
|
162
|
+
* the test/lifecycle may pop explicitly via `scope.pop()` to model a skill frame closing). Skills with
|
|
163
|
+
* NO manifest push nothing (unscoped, backward-compatible).
|
|
164
|
+
*
|
|
165
|
+
* v1 lifetime is heuristic (design/77 §3 residual): the model controls its own turns, so push-on-load
|
|
166
|
+
* is the trigger and the worst case (a frame never popped) is simply continued narrowing — never a
|
|
167
|
+
* widening, so it stays safe-by-construction.
|
|
168
|
+
*/
|
|
56
169
|
export declare function createSkillTool(skills: SkillLike[], scope?: ActiveSkillScope): AgentTool;
|
|
57
170
|
export {};
|
|
@@ -1,7 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RB-470 (blackboard [2310], the D4 never-settle class) — bounded await for BEST-EFFORT teardown /
|
|
3
|
+
* cleanup legs on a run's settle path.
|
|
4
|
+
*
|
|
5
|
+
* The defect class: `resume()`/`runTask` settle only when the run body returns, and the body's tail
|
|
6
|
+
* (after the event queue closed) plus the prepare-throw cleanup path both awaited external entities
|
|
7
|
+
* (adapter `destroy()`, MCP client close, registry rows minted by EARLIER runs, session-store
|
|
8
|
+
* `forget`) with no bound. Every one of those sites already caught THROWS ("best-effort … must not
|
|
9
|
+
* mask the original error") — but a promise that never settles is not a throw, and one wedged
|
|
10
|
+
* adapter turned into: for-await done, `result()` never settles (②型, process alive), or — when the
|
|
11
|
+
* wedge happened before the queue closed — a zero-handle pure-logic hang (the 2.12.0 exit-13 shape).
|
|
12
|
+
* The session lock releases in the run IIFE's finally, so one wedged run also poisoned every later
|
|
13
|
+
* same-session resume.
|
|
14
|
+
*
|
|
15
|
+
* The remedy is the same doctrine as the workflow journal drain (batch-4 F2): a best-effort leg gets
|
|
16
|
+
* a BOUNDED terminal await — generous, disclosed on timeout, never silent (§C1), and the settle path
|
|
17
|
+
* proceeds. The abandoned leg keeps running (nothing can cancel a wedged promise); the incident
|
|
18
|
+
* report says exactly that, so a leaked env/process is attributable instead of anonymous.
|
|
19
|
+
*
|
|
20
|
+
* Timer discipline (RB-447, with-retry.ts same doctrine): the race timer is deliberately NOT
|
|
21
|
+
* unref'd — the caller awaits this in FOREGROUND control flow, and an unref'd timer lets an
|
|
22
|
+
* otherwise-empty event loop exit mid-wait, which un-settles the very await this module exists to
|
|
23
|
+
* bound. The timer is itself bounded, and cleared the moment the leg settles.
|
|
24
|
+
*/
|
|
25
|
+
/** Generous ceiling for one teardown leg — cleanup that has not settled after this long is wedged,
|
|
26
|
+
* not slow (the legs are process kills, fd closes, store forgets; none is legitimately minutes). */
|
|
1
27
|
export declare const TEARDOWN_LEG_MAX_MS = 15000;
|
|
28
|
+
/** Test hook (fs-atomic TxnLockTimings precedent): shrink the budget so wedge pins need no real 15s. */
|
|
2
29
|
export declare function setTeardownLegBudgetForTests(ms: number | undefined): void;
|
|
30
|
+
/** The typed timeout incident — `leg` names the site so a leak is attributable from the report alone. */
|
|
3
31
|
export declare class TeardownLegTimeoutError extends Error {
|
|
4
32
|
readonly leg: string;
|
|
5
33
|
constructor(leg: string, budgetMs: number);
|
|
6
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Run one best-effort teardown leg with the bound above. NEVER throws: a throw OR a timeout is
|
|
37
|
+
* routed to `report` (wire it to `deps.onError` where available) and the caller proceeds —
|
|
38
|
+
* exactly the contract every wrapped site already claimed in prose, now including the never-settle
|
|
39
|
+
* arm it could not previously keep.
|
|
40
|
+
*/
|
|
7
41
|
export declare function settleTeardownLeg(leg: () => Promise<unknown> | unknown, label: string, report?: (err: Error) => void): Promise<void>;
|
|
@@ -3,61 +3,288 @@ import type { AgentMessage, AgentTool, AgentToolResult, AgentToolUpdateCallback,
|
|
|
3
3
|
import type { Model } from "../../internal/llm.js";
|
|
4
4
|
import type { ToolSpec } from "../types.js";
|
|
5
5
|
import type { ToolFingerprintInput } from "../cache-break-detector.js";
|
|
6
|
+
/**
|
|
7
|
+
* Deferred-tool dynamic disclosure (design/36). A deployment with hundreds of tools / several MCP
|
|
8
|
+
* servers can't inline every full JSON Schema into every request — turn-1 cache-creation tokens
|
|
9
|
+
* explode and any tool-description drift breaks the prefix cache. Instead, deferred tools ship as
|
|
10
|
+
* lightweight placeholders ({name, one-line hint, empty params}); a resident `tool_search` lets the
|
|
11
|
+
* model activate them by name or keyword, at which point core MATERIALIZES their full schema into the
|
|
12
|
+
* next request's tools[] (client-side, provider-agnostic — no Anthropic `tool_reference` beta) and
|
|
13
|
+
* announces them via the search's own result content (tail of the log; the cache prefix is untouched).
|
|
14
|
+
*
|
|
15
|
+
* This module is pure tool/registry logic: prepare-task owns the harness wiring and supplies a
|
|
16
|
+
* `rematerialize` callback (which calls `harness.setTools` + refreshes the design/31 fingerprint).
|
|
17
|
+
*/
|
|
6
18
|
export declare const TOOL_SEARCH_NAME = "ToolSearch";
|
|
19
|
+
/** Default keyword-search result cap (design/116 W1-2 = CC ToolSearchTool.ts:28-32 `max_results` default 5). */
|
|
7
20
|
export declare const TOOL_SEARCH_DEFAULT_MAX_RESULTS = 5;
|
|
21
|
+
/**
|
|
22
|
+
* design/168 — how many times in a row ONE placeholder may answer the IDENTICAL invalid-arguments
|
|
23
|
+
* shape before the lane declares the loop unproductive and stops re-teaching. Three, because the
|
|
24
|
+
* corrective round is worth paying for twice (the first rejection hands over the schema; a second
|
|
25
|
+
* covers a model that needed the restatement) and a third identical failure is evidence that the
|
|
26
|
+
* schema was never what was missing.
|
|
27
|
+
*/
|
|
8
28
|
export declare const DEFERRED_NO_PROGRESS_LIMIT = 3;
|
|
29
|
+
/**
|
|
30
|
+
* The stable machine code the no-progress terminal carries on its tool-result `details.noProgress`
|
|
31
|
+
* (and verbatim in its model-facing text, so a transcript reader and a log reader see one string).
|
|
32
|
+
* Names the CONDITION, not the blame: the caller and the tool's declaration cannot be reconciled on
|
|
33
|
+
* this route — the classic producer is a constrained decoder bound to the placeholder's empty
|
|
34
|
+
* advertised schema.
|
|
35
|
+
*/
|
|
9
36
|
export declare const DEFERRED_SCHEMA_INCOMPATIBLE_CODE = "tool.deferred_schema_incompatible";
|
|
37
|
+
/** A deferred tool as the search ranks it: stable name + the one-line hint + full description for scoring. */
|
|
10
38
|
export interface DeferredToolInfo {
|
|
11
39
|
name: string;
|
|
12
40
|
hint: string;
|
|
13
41
|
description: string;
|
|
14
42
|
}
|
|
43
|
+
/** First line of a description, trimmed to a single short hint for a placeholder / announcement. */
|
|
15
44
|
export declare function deferHint(description: string, max?: number): string;
|
|
45
|
+
/**
|
|
46
|
+
* Neutralize a tool name before it appears in ANY model-facing text (design/36 minor #5). A tool name is
|
|
47
|
+
* externally influenced — an untrusted MCP server can return one containing newlines (to inject a fake
|
|
48
|
+
* `<system-reminder>`/instruction line), backticks/quotes (to corrupt the JSON or markdown the model is
|
|
49
|
+
* told to emit), or angle brackets (to break a delimiter). Strip control chars, CR/LF, `` ` ``, `"`, `<`, `>`.
|
|
50
|
+
* For a normal name (`[A-Za-z0-9_.-]`, incl. MCP `server__tool`) this is a no-op.
|
|
51
|
+
*
|
|
52
|
+
* MUST wrap a tool name at EVERY site where it reaches the model — placeholder text, the search tool's
|
|
53
|
+
* announcement, anywhere. A bare interpolation is a prompt-injection hole (council BUG, design/36).
|
|
54
|
+
*/
|
|
16
55
|
export declare function safeName(name: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Decide which tool names are deferred. THIS CONTRACT IS THE SINGLE AUTHORITY on the default-mode
|
|
58
|
+
* source list (TaskSpec/RunnerDeps JSDoc points here), so every arm the body implements is named:
|
|
59
|
+
* deterministic by default = explicit `ToolSpec.defer === true`, plus every REMOTE-PROTOCOL tool name
|
|
60
|
+
* (MCP servers AND A2A peers — most numerous / most drift-prone), plus `deferNames`, i.e. the
|
|
61
|
+
* already-mounted wire names from `TaskSpec.deferTools` and from BUILT-INS that declare their own
|
|
62
|
+
* `defer` (a built-in ToolSpec never reaches `specs`, so its declared deferral has to arrive here as a
|
|
63
|
+
* mounted name — this is why the shared-memory pair defaults to deferred). With `deferMode: "auto"`, ADDITIONALLY
|
|
64
|
+
* defer the remaining user tools when their combined inlined schema would exceed ~10% of the model's
|
|
65
|
+
* context window — an explicit opt-in (council minor #6), because an implicit threshold makes the same
|
|
66
|
+
* TaskSpec yield different tools[] across models/contexts. Explicit `defer` always wins — except
|
|
67
|
+
* against an alwaysLoad pin (RB-400-a), which exempts a name from every deferral source.
|
|
68
|
+
*/
|
|
17
69
|
export declare function classifyDeferred(opts: {
|
|
18
70
|
specs: ReadonlyArray<ToolSpec>;
|
|
71
|
+
/** Every namespaced tool a remote protocol materialized for this task (MCP servers AND A2A peers —
|
|
72
|
+
* the caller unions them). The constant-defer arm is about the SHAPE of a remote roster (many tools,
|
|
73
|
+
* schemas the deployment does not control, drift between tasks), which is the same for every protocol
|
|
74
|
+
* in the table: naming one protocol here left the next one inlined by omission, with nobody deciding
|
|
75
|
+
* that. Only an alwaysLoad pin exempts a name. */
|
|
19
76
|
protocolToolNames: ReadonlyArray<string>;
|
|
20
77
|
fullTools: ReadonlyArray<ToolFingerprintInput>;
|
|
21
78
|
deferMode?: "auto";
|
|
22
79
|
model: Model;
|
|
80
|
+
/** [1044]② TaskSpec.deferTools — defer ALREADY-MOUNTED tools by wire name (built-ins included;
|
|
81
|
+
* `ToolSpec.defer` only reaches caller specs). Caller pre-filters to mounted names. */
|
|
23
82
|
deferNames?: ReadonlyArray<string>;
|
|
83
|
+
/** RB-400-a — inline-pin names (`TaskSpec.alwaysLoadTools` + the MCP tools whose server declared
|
|
84
|
+
* `_meta["anthropic/alwaysLoad"]`, caller-collected; A2A has no such per-skill declaration, so the
|
|
85
|
+
* task-level list is a peer's only inline-keep channel): exempt from EVERY deferral source below.
|
|
86
|
+
* `ToolSpec.alwaysLoad` rides the specs directly and needs no entry here. */
|
|
24
87
|
alwaysLoadNames?: ReadonlyArray<string>;
|
|
25
88
|
}): Set<string>;
|
|
89
|
+
/** Build the registry the search ranks over (deferred tools only — non-deferred are already visible). */
|
|
26
90
|
export declare function buildDeferredRegistry(deferred: ReadonlySet<string>, tools: ReadonlyArray<{
|
|
27
91
|
name: string;
|
|
28
92
|
description: string;
|
|
29
93
|
}>): Map<string, DeferredToolInfo>;
|
|
94
|
+
/**
|
|
95
|
+
* RB-403 — the direct-call lane a placeholder may carry. The upstream defer gate is SHAPE
|
|
96
|
+
* validation, not activation state: a call whose arguments validate against the REAL tool's
|
|
97
|
+
* declared schema runs the real tool directly (activation is only about whether the model has
|
|
98
|
+
* been SHOWN the schema, never an execution gate). Governance cannot be laundered through this
|
|
99
|
+
* lane: policy/effect/irreversibility gates key on the tool NAME maps built from the real
|
|
100
|
+
* declarations, and the engine's approval pipeline runs before any execute — the placeholder
|
|
101
|
+
* object on the harness list plays no part in adjudication.
|
|
102
|
+
*/
|
|
30
103
|
export interface PlaceholderDirectCall {
|
|
104
|
+
/**
|
|
105
|
+
* RB-414 — resolve the real tool AT CALL TIME, never from a prepare-time snapshot. The mounted
|
|
106
|
+
* roster is a LIVE array: an MCP refresh splices a server's name domain out and pushes freshly
|
|
107
|
+
* materialized tool objects back in, so a Map captured when the placeholder was built would hand
|
|
108
|
+
* this lane the WITHDRAWN object (stale schema shape gate, stale transport client) long after the
|
|
109
|
+
* roster moved on. Returns `undefined` when the name no longer resolves — a withdrawn name has no
|
|
110
|
+
* direct lane, and the caller falls back to the teaching rejection.
|
|
111
|
+
*/
|
|
31
112
|
resolveReal: () => PlaceholderDirectTarget | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* RB-415① — the scheduling declaration this placeholder carries while it stands in for the real
|
|
115
|
+
* tool. Mirrors the REAL tool's own `executionMode` (see the mirror rationale in
|
|
116
|
+
* {@link createPlaceholderTool}); absent ⇒ the engine's fail-closed default, exactly as it would
|
|
117
|
+
* be for the real tool once activated.
|
|
118
|
+
*/
|
|
32
119
|
executionMode?: ToolExecutionMode;
|
|
120
|
+
/**
|
|
121
|
+
* design/168 — does THIS name sit on the static face right now, i.e. will it never be swapped for
|
|
122
|
+
* the real tool's declaration? The lane's model-facing rejection text reads it to say where the
|
|
123
|
+
* schema it hands back actually lives (this result only, versus this result AND every later
|
|
124
|
+
* request's tools block). Absent ⇒ the swap posture.
|
|
125
|
+
*
|
|
126
|
+
* A FUNCTION, evaluated per call, for the same reason `resolveReal` is (RB-414): the answer is not
|
|
127
|
+
* a prepare-time constant. The run-wide strategy is, but the per-tool exemption on top of it reads
|
|
128
|
+
* the LIVE roster — an MCP refresh can replace a tool with a declaration that no longer fits the
|
|
129
|
+
* result-text carrier (or one that now does), and a boolean captured when the placeholder was built
|
|
130
|
+
* would then describe the wrong carrier.
|
|
131
|
+
*/
|
|
33
132
|
staticFace?: () => boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Activation side effects (active-set add + rematerialize + boundary delta announcement).
|
|
135
|
+
* Idempotent; awaited BEFORE the invoke so the next boundary already shows the full schema.
|
|
136
|
+
* RB-415② — MUST be atomic: a thrown rematerialize has to leave the active set as it found it.
|
|
137
|
+
*
|
|
138
|
+
* RB-431 — returns the announcement text this activation has to CARRY, or `undefined` when it has
|
|
139
|
+
* none (already active, or nothing rides on this name). The ToolSearch lane announces on its own
|
|
140
|
+
* result content; a direct call makes no ToolSearch call at all, so a face whose only carrier is
|
|
141
|
+
* that result — today the agent-type roster of a deferred delegation tool — had no way to reach
|
|
142
|
+
* the model on this leg. The text is appended to THIS call's result (see
|
|
143
|
+
* {@link createPlaceholderTool}), the same channel discipline: tail of the log, cache prefix
|
|
144
|
+
* untouched, emitted only after the rematerialize succeeded.
|
|
145
|
+
*/
|
|
34
146
|
activate: () => Promise<string | undefined>;
|
|
35
147
|
}
|
|
148
|
+
/** The live view of the real tool behind a placeholder, resolved per call (see {@link PlaceholderDirectCall.resolveReal}). */
|
|
36
149
|
export interface PlaceholderDirectTarget {
|
|
150
|
+
/** The REAL tool's declared parameter schema — the shape gate for a direct call. */
|
|
37
151
|
parameters: TSchema;
|
|
152
|
+
/** Invoke the real tool; the result passes through VERBATIM (structured details intact).
|
|
153
|
+
* RB-416 — `onUpdate` is part of the contract: the engine hands every execute a progress sink,
|
|
154
|
+
* and dropping it here silently mutes streaming progress (MCP `notifications/progress`) for any
|
|
155
|
+
* tool reached through this lane, while the SAME tool streams normally once activated. */
|
|
38
156
|
invoke: (toolCallId: string, params: unknown, signal?: AbortSignal, onUpdate?: AgentToolUpdateCallback<unknown>) => Promise<AgentToolResult<unknown>>;
|
|
39
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* design/168 — can the STATIC face carry this declaration at all? Static's only in-context schema
|
|
160
|
+
* carrier is result TEXT, so a declaration that cannot be serialized, or that the model-facing error
|
|
161
|
+
* bound would truncate into non-JSON, has no carrier there. Such a tool is exempted per-tool from the
|
|
162
|
+
* static face (it materializes into the tools block on activation, the swap way) rather than being
|
|
163
|
+
* announced as callable with a schema the model never actually receives. `undefined` (a name the live
|
|
164
|
+
* roster no longer resolves) is not renderable either.
|
|
165
|
+
*/
|
|
40
166
|
export declare function staticSchemaRenderable(schema: TSchema | undefined): boolean;
|
|
167
|
+
/** A placeholder AgentTool for a deferred tool: visible name + hint, empty params. Without `direct`,
|
|
168
|
+
* every call is the teaching rejection; with it, a schema-valid call runs the real tool (RB-403). */
|
|
41
169
|
export declare function createPlaceholderTool(info: DeferredToolInfo, direct?: PlaceholderDirectCall): AgentTool;
|
|
170
|
+
/** Keyword score of a query against a deferred tool: name hits weigh more than description/hint hits. */
|
|
42
171
|
export declare function scoreToolMatch(query: string, info: DeferredToolInfo): number;
|
|
172
|
+
/** The argument shapes `tool_search` accepts (design/116 W1-2, CC-canonical): `query` (+ optional
|
|
173
|
+
* `max_results`). RB-482 #5 (ruled 2026-08-03): the pre-design/116 `select` ARRAY arm is retired —
|
|
174
|
+
* durable-replay compat was already sacrificed by the RB-476-A ruling (replay resolution included);
|
|
175
|
+
* the CC-canonical `select:A,B,C` string prefix inside `query` is the live selection form. */
|
|
43
176
|
export interface ToolSearchArgs {
|
|
44
177
|
query?: string;
|
|
45
178
|
max_results?: number;
|
|
46
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Resolve a tool_search request to deferred-tool names (design/116 W1-2, CC ToolSearchTool.ts form).
|
|
182
|
+
* Query forms, checked in order:
|
|
183
|
+
* ① `select:A,B,C` prefix (case-insensitive prefix, CC ToolSearchTool.ts:363) — comma-split EXACT
|
|
184
|
+
* name activation against the registry's names; misses are reported in `missing` (never silently
|
|
185
|
+
* eaten) and the result is NOT truncated by `max_results` (explicit selection gets everything).
|
|
186
|
+
* ② bare tool name (case-insensitive equality, CC:199-204) — selects that tool directly; handles
|
|
187
|
+
* models sending a name instead of the select: prefix (seen from subagents/post-compaction).
|
|
188
|
+
* ③ keyword search — scored matches capped at `max_results` (CC default 5).
|
|
189
|
+
* RB-482 #5: the pre-design/116 `select` ARRAY arm is retired (see {@link ToolSearchArgs}) — a stale
|
|
190
|
+
* replayed array argument now resolves like an empty query (nothing matched, honestly).
|
|
191
|
+
*/
|
|
47
192
|
export declare function resolveToolSearchDetailed(args: ToolSearchArgs, registry: ReadonlyMap<string, DeferredToolInfo>): {
|
|
48
193
|
matched: string[];
|
|
49
194
|
missing: string[];
|
|
50
195
|
};
|
|
196
|
+
/** Names-only view of {@link resolveToolSearchDetailed} — the deterministic replay core used by
|
|
197
|
+
* {@link extractDiscoveredToolNames} (and kept as the stable exported signature). */
|
|
51
198
|
export declare function resolveToolSearch(args: ToolSearchArgs, registry: ReadonlyMap<string, DeferredToolInfo>): string[];
|
|
199
|
+
/**
|
|
200
|
+
* Stateless recompute of the activated-tool set from the message log (design/36 §2.3). The in-process
|
|
201
|
+
* `active` Set is the primary source within one process, but a RESUMED session (new process) starts with
|
|
202
|
+
* an empty Set — without this, previously-activated tools would revert to placeholders. Two carriers,
|
|
203
|
+
* both deterministic and both replayed here:
|
|
204
|
+
*
|
|
205
|
+
* ① every prior `tool_search` call's arguments, re-resolved through `resolveToolSearch` — unless that
|
|
206
|
+
* call's OWN result carries the error flag (RB-450 S4: a denied/blocked search never reached execute
|
|
207
|
+
* and staged nothing; a call with no result at all keeps the historic credit);
|
|
208
|
+
* ② RB-431 — a SUCCESSFUL call on a deferred name, which is an activation in its own right: the
|
|
209
|
+
* RB-403 direct lane runs `activate()` BEFORE it invokes the real tool, so a result that came back
|
|
210
|
+
* without an error flag can only have come from a call that passed the shape gate and activated.
|
|
211
|
+
* No new carrier had to be minted for this: the toolCall part and its result are already in the
|
|
212
|
+
* transcript. Before this arm, a direct activation left NO trace at all — the next leg reverted the
|
|
213
|
+
* tool to a placeholder (losing one turn's schema) and, for the roster-bearing delegation tool, kept
|
|
214
|
+
* its listing face deferred so the boundary producer stayed silent as well.
|
|
215
|
+
*
|
|
216
|
+
* ② is deliberately keyed on the ERROR FLAG rather than on re-running the shape gate: the error flag is
|
|
217
|
+
* the only signal that distinguishes "the lane ran" from "the call never reached it". Every non-execution
|
|
218
|
+
* outcome the engine can produce for a placeholder call — the teaching rejection (a throw), a policy
|
|
219
|
+
* denial or hook block, an abort, invalid arguments — is flagged as an error, and none of them activated
|
|
220
|
+
* anything. It is an UNDER-approximation in one direction only: an activation whose real tool then failed
|
|
221
|
+
* (or threw) is not counted, so that name reverts to a placeholder and the model re-activates on demand —
|
|
222
|
+
* self-healing, exactly like the design/116 keyword-cap note below, never a widening. The shape-INVALID
|
|
223
|
+
* direct call (ruled 2026-08-03) activates too and is flagged as an error, so it lands in that same
|
|
224
|
+
* under-approximated class by construction: within the process the in-memory `active` set carries it, and
|
|
225
|
+
* a replay that loses it costs the corrected call — which succeeds, and is itself carrier ②. The one way to
|
|
226
|
+
* forge a positive is a deployment `tool_result` hook that rewrites a rejection's error flag to false,
|
|
227
|
+
* which is the deployment editing its own transcript.
|
|
228
|
+
*
|
|
229
|
+
* design/116 W1-2 note: pre-116 checkpoints whose KEYWORD queries activated up to 25 tools re-derive at
|
|
230
|
+
* the new default cap (5) — the extra tools revert to placeholders, which is self-healing (the model
|
|
231
|
+
* re-activates on demand), never a widening. Exact-name and `select:`-prefix activations replay unchanged.
|
|
232
|
+
*
|
|
233
|
+
* The retired `{select:[…]}` ARRAY no longer replays: it resolves to nothing here, so those names revert
|
|
234
|
+
* to placeholders on the same self-healing path. This is the READ half of a deliberate split — the write
|
|
235
|
+
* lane (`createToolSearchTool.execute`) REFUSES the dead key loudly, because there a message can still
|
|
236
|
+
* change what the caller does; here it cannot, and erroring would only turn an old transcript into a
|
|
237
|
+
* resume that cannot start. Recompute is total: no shape of persisted arguments makes it throw.
|
|
238
|
+
*/
|
|
52
239
|
export declare function extractDiscoveredToolNames(messages: ReadonlyArray<AgentMessage>, registry: ReadonlyMap<string, DeferredToolInfo>): string[];
|
|
240
|
+
/**
|
|
241
|
+
* Build the resident `tool_search` tool. On a search that NEWLY activates deferred tools it (1) adds them
|
|
242
|
+
* to the monotonic `active` Set, (2) calls `rematerialize` (prepare-task swaps placeholders→full schema
|
|
243
|
+
* via `harness.setTools` and refreshes the design/31 fingerprint), and (3) returns the "now available"
|
|
244
|
+
* announcement as its OWN result content — the delta lands at the tail of the log, never in the cache prefix.
|
|
245
|
+
*/
|
|
53
246
|
export declare function createToolSearchTool(opts: {
|
|
54
247
|
registry: ReadonlyMap<string, DeferredToolInfo>;
|
|
55
248
|
active: Set<string>;
|
|
56
249
|
rematerialize: (active: ReadonlySet<string>) => Promise<void>;
|
|
250
|
+
/** RB-28 terminal fix — listing ride-along on the design/36 channel: when an activation newly
|
|
251
|
+
* materializes a listing-bearing tool (the deferred delegation tool whose description points at an
|
|
252
|
+
* agent-types listing that the deferred leg's boundary producer never ships), the caller returns
|
|
253
|
+
* the listing text here and it rides THIS search's own result content — tail of the log, cache
|
|
254
|
+
* prefix untouched, same channel the activation announcement already uses. */
|
|
57
255
|
listingRide?: (newlyActivated: readonly string[]) => string | undefined;
|
|
256
|
+
/** [1413]②b (TOOLS-PERFECT): the names callable DIRECTLY right now (mounted non-deferred + activated),
|
|
257
|
+
* computed at call time (setTools swaps mutate the surface). Lets the miss note tell the model
|
|
258
|
+
* "Workflow is already available — call it" instead of a generic not-found that reads as absence
|
|
259
|
+
* (observed: the model treated the miss as unavailability and only recovered by guessing). */
|
|
58
260
|
mountedNames?: () => ReadonlySet<string>;
|
|
261
|
+
/** DD-5 — whether the placeholders on this task carry the RB-403 direct-call lane
|
|
262
|
+
* (`TaskSpec.deferSelfResolve` not disabled). Selects which of the two teaching postures below is
|
|
263
|
+
* true for this task; defaults to the direct-lane posture, matching the spec field's own default. */
|
|
59
264
|
directCallEnabled?: boolean;
|
|
265
|
+
/** RB-450 S3 — run this tool's activation critical section on the CALLER's serializer instead of a
|
|
266
|
+
* private one. The `active` set and `rematerialize` are shared with the RB-403 direct-call lane,
|
|
267
|
+
* which activates from a placeholder's own execute; both lanes must queue on ONE section or a
|
|
268
|
+
* concurrent batch lets the direct lane stage a name while this section is still pending (and
|
|
269
|
+
* vice versa, so a rollback here cannot be observed as "already active" there). Absent ⇒ a private
|
|
270
|
+
* chain, which still gives the standalone factory its own same-instance guarantee. */
|
|
271
|
+
/**
|
|
272
|
+
* Is this deferred name still on the LIVE roster? The registry is a prepare-time snapshot, but the
|
|
273
|
+
* roster is not: an MCP refresh splices a server's name domain out, and a name that was deferred at
|
|
274
|
+
* prepare can be gone. Without this test an exact `select:` still resolves through the stale
|
|
275
|
+
* registry, the activation section adds the name to `active`, the rematerialize "succeeds" while
|
|
276
|
+
* mounting nothing, and the result announces a tool that does not exist — an uncallable name the
|
|
277
|
+
* model has been told is now available. Absent ⇒ every registry name is assumed live (the standalone
|
|
278
|
+
* factory has no roster to consult), which is the prior behavior.
|
|
279
|
+
*/
|
|
60
280
|
isMounted?: (name: string) => boolean;
|
|
61
281
|
serializeActivation?: <T>(section: () => Promise<T>) => Promise<T>;
|
|
282
|
+
/** design/168 "static" materialization (ruled 2026-08-05): resolve a deferred name's REAL declared
|
|
283
|
+
* parameter schema, read from the live roster at call time. Presence switches this face to the
|
|
284
|
+
* static posture: activation never swaps the placeholder in the tools block, so the result text
|
|
285
|
+
* BELOW is the schema's only in-context carrier — each matched tool's schema is inlined into the
|
|
286
|
+
* result (newly-activated AND already-active alike, so a post-compaction re-select recovers it),
|
|
287
|
+
* and every "full schemas are loaded" claim about the tools block is dropped as false. Absent ⇒
|
|
288
|
+
* the swap posture (activation rewrites the tools block; prior wording, unchanged). */
|
|
62
289
|
staticSchemaFor?: (name: string) => TSchema | undefined;
|
|
63
290
|
}): AgentTool;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/157 B15 一期 (R4 相位抽取) — the `tool_end` output/structured projection, verbatim from
|
|
3
|
+
* `runtask.ts`'s runLocked R4 phase. Pure functions over the harness `AgentToolResult`: zero closure
|
|
4
|
+
* state, zero runtask coupling — the ONLY module-level input is the size cap below. Event-sequence
|
|
5
|
+
* snapshot pin (recorded before/after the move, byte-equal) guards the projection semantics.
|
|
6
|
+
*/
|
|
1
7
|
export declare const toolOutputFrom: (result: unknown) => {
|
|
2
8
|
output: unknown;
|
|
3
9
|
truncated: boolean;
|