@sema-agent/core 7.71.1 → 7.73.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 +500 -0
- package/dist/agents/cross-session-ref.d.ts +2 -2
- package/dist/agents/cross-session-ref.js +7 -2
- package/dist/agents/inherited-tool-pool.d.ts +30 -2
- package/dist/agents/inherited-tool-pool.js +53 -7
- package/dist/agents/parked-resume-drive.d.ts +10 -0
- package/dist/agents/parked-resume-drive.js +9 -0
- package/dist/agents/retain-ledger.d.ts +3 -0
- package/dist/agents/send-message-tool.js +7 -2
- package/dist/agents/send-user-message-tool.d.ts +12 -0
- package/dist/agents/send-user-message-tool.js +67 -0
- package/dist/agents/subagent-steps.d.ts +9 -0
- package/dist/agents/subagent-steps.js +38 -0
- package/dist/agents/subagent.d.ts +2 -0
- package/dist/agents/subagent.js +47 -12
- package/dist/agents/verify.js +23 -7
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.js +14 -9
- package/dist/brain/open-responses.js +4 -5
- package/dist/brain/openai.js +30 -23
- package/dist/brain/stream-engine.js +159 -151
- package/dist/core/a2a.d.ts +24 -3
- package/dist/core/a2a.js +27 -8
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/agent-state.d.ts +28 -7
- package/dist/core/agent-state.js +19 -6
- package/dist/core/allow-entry.js +3 -3
- package/dist/core/approval-object.d.ts +7 -3
- package/dist/core/approval-object.js +30 -9
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/checkpoint-features.d.ts +16 -5
- package/dist/core/checkpoint-features.js +35 -6
- package/dist/core/checkpoint-rekey.d.ts +1 -1
- package/dist/core/checkpoint-rekey.js +6 -1
- package/dist/core/checkpoint-requirements.d.ts +23 -3
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -1
- package/dist/core/checkpoint-row-verdict.js +10 -4
- package/dist/core/checkpoint-store.d.ts +24 -2
- package/dist/core/checkpoint-store.js +1 -0
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/effective-path-target.d.ts +19 -0
- package/dist/core/effective-path-target.js +95 -38
- package/dist/core/engine-capabilities.d.ts +5 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +34 -23
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +19 -7
- package/dist/core/entries-not-applied.js +33 -1
- package/dist/core/file-history-store.d.ts +15 -4
- package/dist/core/file-history-store.js +53 -23
- package/dist/core/gate-fold.js +3 -1
- package/dist/core/governance-codes.d.ts +10 -1
- package/dist/core/governance-codes.js +17 -5
- package/dist/core/hooks.d.ts +3 -0
- package/dist/core/hooks.js +1 -0
- package/dist/core/host-instance.d.ts +23 -0
- package/dist/core/host-instance.js +69 -0
- package/dist/core/instruction-preview.d.ts +63 -0
- package/dist/core/instruction-preview.js +406 -0
- package/dist/core/judged-read.d.ts +57 -0
- package/dist/core/judged-read.js +1 -0
- package/dist/core/leg-budget.d.ts +26 -0
- package/dist/core/leg-budget.js +9 -0
- package/dist/core/leg-identity.d.ts +51 -1
- package/dist/core/leg-identity.js +45 -2
- package/dist/core/manager-launch-check.d.ts +48 -0
- package/dist/core/manager-launch-check.js +64 -0
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-host-seat.d.ts +5 -0
- package/dist/core/mcp-host-seat.js +7 -1
- package/dist/core/mcp-injection-drop.d.ts +20 -10
- package/dist/core/mcp-injection-drop.js +9 -3
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/mcp.js +3 -1
- package/dist/core/member-outcome.d.ts +3 -2
- package/dist/core/member-outcome.js +1 -1
- package/dist/core/memory-engine/deletion-record.d.ts +46 -0
- package/dist/core/memory-engine/deletion-record.js +96 -0
- package/dist/core/memory-engine/engine.js +24 -16
- package/dist/core/memory-engine/file-backend.js +7 -5
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/index.js +1 -1
- package/dist/core/memory-engine/layout.js +6 -4
- package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
- package/dist/core/memory-engine/projection-ledger.js +1 -1
- package/dist/core/memory-engine/scope-contract.d.ts +69 -11
- package/dist/core/memory-engine/scope-contract.js +99 -34
- package/dist/core/memory-engine/sync-client.js +26 -6
- package/dist/core/memory-engine/sync.d.ts +20 -2
- package/dist/core/memory-engine/sync.js +18 -17
- package/dist/core/mode-policy.d.ts +21 -6
- package/dist/core/mode-policy.js +15 -6
- package/dist/core/mounted-mcp.d.ts +7 -2
- package/dist/core/mounted-mcp.js +10 -1
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/param-rule-reach.d.ts +8 -3
- package/dist/core/param-rule-reach.js +9 -1
- package/dist/core/parent-spec-seat.d.ts +13 -1
- package/dist/core/parent-spec-seat.js +18 -0
- package/dist/core/peer-registration.d.ts +52 -0
- package/dist/core/peer-registration.js +37 -0
- package/dist/core/peer-seat.d.ts +3 -1
- package/dist/core/peer-seat.js +3 -3
- package/dist/core/peer-task-store.d.ts +365 -0
- package/dist/core/peer-task-store.js +682 -0
- package/dist/core/permission-rule-consent.js +6 -11
- package/dist/core/permission-rule-model.d.ts +27 -0
- package/dist/core/permission-rule-model.js +34 -6
- package/dist/core/permission-rule-provider.d.ts +35 -33
- package/dist/core/permission-rule-provider.js +38 -295
- package/dist/core/permission-rule-store.d.ts +181 -8
- package/dist/core/permission-rule-store.js +420 -17
- package/dist/core/permission-rule-sync.js +15 -1
- package/dist/core/project-seat.d.ts +55 -0
- package/dist/core/project-seat.js +96 -0
- package/dist/core/protocol-http-auth.d.ts +3 -2
- package/dist/core/protocol-http-auth.js +26 -18
- package/dist/core/remote-env.d.ts +4 -4
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/run-ledger-seat.d.ts +66 -0
- package/dist/core/run-ledger-seat.js +70 -0
- package/dist/core/run-ledger.d.ts +332 -0
- package/dist/core/run-ledger.js +550 -0
- package/dist/core/runner/chain-mismatch.d.ts +32 -0
- package/dist/core/runner/chain-mismatch.js +29 -0
- package/dist/core/runner/changes-history.d.ts +1 -0
- package/dist/core/runner/changes-history.js +2 -2
- package/dist/core/runner/checkpoint-scope.d.ts +13 -3
- package/dist/core/runner/checkpoint-scope.js +12 -4
- package/dist/core/runner/construction-doors.js +6 -0
- package/dist/core/runner/contracts.d.ts +22 -3
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/file-history-restore.d.ts +3 -1
- package/dist/core/runner/file-history-restore.js +9 -6
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/loaded-skills.d.ts +2 -0
- package/dist/core/runner/loaded-skills.js +10 -0
- package/dist/core/runner/nested-memory-lane.d.ts +22 -5
- package/dist/core/runner/nested-memory-lane.js +91 -30
- package/dist/core/runner/person-path-rows.d.ts +23 -20
- package/dist/core/runner/person-path-rows.js +82 -18
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +105 -90
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +5 -3
- package/dist/core/runner/prepare-context-lane.js +1 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +6 -0
- package/dist/core/runner/prepare-execution-env.d.ts +3 -3
- package/dist/core/runner/prepare-file-history.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +10 -2
- package/dist/core/runner/prepare-hands-readface.js +36 -22
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -5
- package/dist/core/runner/prepare-inherited-gate.js +14 -6
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -2
- package/dist/core/runner/prepare-memory-engine-session.js +2 -2
- package/dist/core/runner/prepare-memory.js +3 -15
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +3 -7
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -0
- package/dist/core/runner/prepare-protocol-tools.js +2 -2
- package/dist/core/runner/prepare-run-refs.d.ts +1 -1
- package/dist/core/runner/prepare-run-refs.js +3 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
- package/dist/core/runner/prepare-suspend-saga.js +4 -2
- package/dist/core/runner/prepare-task.js +50 -37
- package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -1
- package/dist/core/runner/prepare-wiring-manifest.js +8 -4
- package/dist/core/runner/read-session-changes.js +1 -1
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-checkpoint-screen.d.ts +8 -7
- package/dist/core/runner/resume-checkpoint-screen.js +7 -6
- package/dist/core/runner/resume-review-outcome.d.ts +3 -0
- package/dist/core/runner/resume-review-outcome.js +24 -1
- package/dist/core/runner/rewind-files.js +3 -2
- package/dist/core/runner/run-harness-handlers.js +3 -0
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +9 -2
- package/dist/core/runner/run-notification-lane.js +20 -1
- package/dist/core/runner/run-settle-and-teardown.js +21 -12
- package/dist/core/runner/run-stop-and-final-verify.js +6 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/runtask.d.ts +6 -2
- package/dist/core/runner/runtask.js +21 -9
- package/dist/core/runner/shell-env-withheld.d.ts +3 -2
- package/dist/core/runner/shell-env-withheld.js +1 -2
- package/dist/core/runner/stop-tail-notice.d.ts +10 -2
- package/dist/core/runner/stop-tail-notice.js +9 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +10 -1
- package/dist/core/runner/terminal-account.js +23 -3
- package/dist/core/runner/tool-face-overlay.d.ts +2 -11
- package/dist/core/runner/tool-face-overlay.js +39 -0
- package/dist/core/runner/trim-stretch.js +7 -2
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner-deps.d.ts +13 -10
- package/dist/core/scheduler.d.ts +47 -7
- package/dist/core/scheduler.js +19 -7
- package/dist/core/secret-env.d.ts +60 -37
- package/dist/core/secret-env.js +45 -48
- package/dist/core/sensitive-path-policy.js +14 -7
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +1 -0
- package/dist/core/session-store.d.ts +12 -6
- package/dist/core/session-store.js +26 -6
- package/dist/core/session.d.ts +31 -8
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +17 -0
- package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
- package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/session-store-contract.js +87 -3
- package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
- package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
- package/dist/core/task-event.d.ts +11 -3
- package/dist/core/task-notification.d.ts +97 -10
- package/dist/core/task-notification.js +129 -5
- package/dist/core/task-registry-shared.d.ts +12 -1
- package/dist/core/task-registry-shared.js +3 -1
- package/dist/core/task-registry-workflow.d.ts +1 -1
- package/dist/core/task-registry-workflow.js +9 -1
- package/dist/core/task-registry.d.ts +39 -2
- package/dist/core/task-registry.js +76 -12
- package/dist/core/task-result.d.ts +13 -0
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +11 -3
- package/dist/core/task-spec.d.ts +57 -23
- package/dist/core/tool-catalog-entries.js +4 -0
- package/dist/core/tool-face-reader.js +1 -1
- package/dist/core/tool-face.d.ts +7 -0
- package/dist/core/tool-face.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +5 -3
- package/dist/core/tool-mount-facts.js +4 -3
- package/dist/core/tool-mount-plan.d.ts +7 -3
- package/dist/core/tool-mount-plan.js +11 -5
- package/dist/core/tool-mount-static.d.ts +2 -2
- package/dist/core/tool-mount-static.js +28 -14
- package/dist/core/tool-registry.d.ts +33 -1
- package/dist/core/tool-registry.js +33 -0
- package/dist/core/tool-result-store.d.ts +19 -2
- package/dist/core/tool-result-store.js +51 -2
- package/dist/core/tool-roster.d.ts +16 -0
- package/dist/core/tool-roster.js +6 -0
- package/dist/core/tool-spec.d.ts +13 -4
- package/dist/core/tools.d.ts +6 -0
- package/dist/core/tools.js +1 -1
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +89 -29
- package/dist/core/wiring-manifest.js +44 -4
- package/dist/core/workflow-journal-store.d.ts +53 -10
- package/dist/core/workflow-journal-store.js +27 -4
- package/dist/core/workflow-run-store-contract.js +16 -0
- package/dist/core/workflow-run-store.d.ts +9 -7
- package/dist/core/workflow-run-store.js +4 -1
- package/dist/engine/execution-env/node-execution-env.js +3 -1
- package/dist/engine/harness/messages.d.ts +1 -1
- package/dist/engine/harness/messages.js +2 -1
- package/dist/engine/harness/types.d.ts +24 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +5 -7
- package/dist/engine/loop/types.d.ts +2 -0
- package/dist/engine/lsp/node-lsp-manager.js +2 -1
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +15 -2
- package/dist/engine/session/session.js +35 -5
- package/dist/index.d.ts +27 -12
- package/dist/index.js +20 -8
- package/dist/orchestration/run-workflow-tool.js +40 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
- package/dist/orchestration/workflow-park-adoption.js +47 -12
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +30 -6
- package/dist/orchestration/workflow.js +117 -54
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/stores/file/adoption/marker.d.ts +2 -27
- package/dist/stores/file/adoption/marker.js +12 -0
- package/dist/stores/file/index.d.ts +1 -1
- package/dist/stores/file/index.js +1 -1
- package/dist/stores/file/permission-rule-store.d.ts +3 -1
- package/dist/stores/file/permission-rule-store.js +0 -1
- package/dist/stores/file/workflow-journal-store.d.ts +16 -3
- package/dist/stores/file/workflow-journal-store.js +93 -5
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/tools/artifact/artifact-tool.js +11 -6
- package/dist/tools/fs/file-read-check.d.ts +45 -11
- package/dist/tools/fs/file-read-check.js +200 -57
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- package/dist/tools/fs/judged-reads.d.ts +51 -0
- package/dist/tools/fs/judged-reads.js +68 -0
- package/dist/tools/fs/read-deny-home.d.ts +1 -1
- package/dist/tools/fs/read-deny-home.js +5 -5
- package/dist/tools/fs/read-deny.d.ts +33 -8
- package/dist/tools/fs/read-deny.js +114 -25
- package/dist/tools/fs/safety.d.ts +12 -1
- package/dist/tools/fs/safety.js +16 -3
- package/dist/tools/fs/shell-read-check.d.ts +25 -5
- package/dist/tools/fs/shell-read-check.js +100 -15
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +34 -14
- package/dist/tools/fs/shell-read-judge.d.ts +13 -1
- package/dist/tools/fs/shell-read-judge.js +26 -7
- package/dist/tools/fs/shell-read-plan.d.ts +5 -0
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/dist/tools/scheduler-store-move.d.ts +74 -0
- package/dist/tools/scheduler-store-move.js +103 -0
- package/dist/tools/scheduler-tools.d.ts +43 -29
- package/dist/tools/scheduler-tools.js +161 -118
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +173 -3
- package/wire-changes/answers/core-stores-sql@7.72.0.json +12 -0
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core@7.72.0.json +84 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/mods-kernel@7.72.0.json +7 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/primitives@7.72.0.json +6 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/wiki-gate@7.72.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/core-stores-sql@7.72.0.json +215 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core@7.72.0.json +2426 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/mods-kernel@7.72.0.json +147 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/primitives@7.72.0.json +143 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/wiki-gate@7.72.0.json +145 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
|
@@ -53,8 +53,8 @@ export declare const RESERVED_AGENT_NAMES: readonly string[];
|
|
|
53
53
|
* design/385 §2.2 namespace protection (CC `qd` in spirit): a candidate spawn/session name is refused
|
|
54
54
|
* when its normalized key would shadow an explicit address — a reserved box prefix, a transport
|
|
55
55
|
* scheme (`uds:` / `bridge:` / `did:`), a socket path, an `@`-bearing team form, the `*` broadcast
|
|
56
|
-
* token, one of the {@link RESERVED_AGENT_NAMES} (`reserved_name`) or the shape of an agent id
|
|
57
|
-
* (`agent_id_shape`). Returns the reason, or `undefined` when the name is admissible. Registration-side
|
|
56
|
+
* token, one of the {@link RESERVED_AGENT_NAMES} (`reserved_name`) or the shape of a task handle — an agent id's among them, and every
|
|
57
|
+
* kind the handle table holds (`agent_id_shape`, the word the `a` shape always had). Returns the reason, or `undefined` when the name is admissible. Registration-side
|
|
58
58
|
* check (loud refusal at write time); the resolution ladder ranks explicit addresses first regardless.
|
|
59
59
|
* The spawn face (the Agent tool's `name`) refuses on every reason this returns.
|
|
60
60
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { SEMA_TASK_HANDLE_PREFIXES } from "../core/task-registry-shared.js";
|
|
2
3
|
export const PEER_REF_MIN = 6;
|
|
3
4
|
export const PEER_REF_MAX = 12;
|
|
4
5
|
export const PEER_REF_RE = /^[0-9a-f]{6,12}$/;
|
|
@@ -48,7 +49,11 @@ function isSocketPathSpelling(text) {
|
|
|
48
49
|
return SOCKET_PATH_RE.test(text) || NAMED_PIPE_RE.test(text);
|
|
49
50
|
}
|
|
50
51
|
export const RESERVED_AGENT_NAMES = Object.freeze(["main", "team-lead", "user", "system"]);
|
|
51
|
-
const
|
|
52
|
+
const LABELLED_AGENT_ID_LETTER = SEMA_TASK_HANDLE_PREFIXES.background_agent;
|
|
53
|
+
const TASK_HANDLE_SHAPE_RE = (() => {
|
|
54
|
+
const letters = Object.values(SEMA_TASK_HANDLE_PREFIXES).join("");
|
|
55
|
+
return new RegExp(`^(?:[${letters}]|${LABELLED_AGENT_ID_LETTER}[\\w-]{1,63}-)[0-9a-f]{16}$`);
|
|
56
|
+
})();
|
|
52
57
|
export function reservedPeerNameReason(name) {
|
|
53
58
|
const key = normalizePeerName(name);
|
|
54
59
|
if (key === "")
|
|
@@ -65,7 +70,7 @@ export function reservedPeerNameReason(name) {
|
|
|
65
70
|
return "socket_path";
|
|
66
71
|
if (RESERVED_AGENT_NAMES.includes(key))
|
|
67
72
|
return "reserved_name";
|
|
68
|
-
if (
|
|
73
|
+
if (TASK_HANDLE_SHAPE_RE.test(key))
|
|
69
74
|
return "agent_id_shape";
|
|
70
75
|
return undefined;
|
|
71
76
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AgentDefinition, McpServerSpec, ToolSpec } from "../core/types.js";
|
|
2
2
|
import type { ToolSelector, ToolSelectorLayer } from "../core/tool-face.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type MountedMcp } from "../core/mounted-mcp.js";
|
|
4
4
|
import type { McpHostSeat } from "../core/mcp-host-seat.js";
|
|
5
|
-
import type { InheritedGate, RunInternals } from "../core/runner/contracts.js";
|
|
5
|
+
import type { InheritedGate, RunInternals, RunnerSelfSeat } from "../core/runner/contracts.js";
|
|
6
6
|
/**
|
|
7
7
|
* What a delegated child inherits when its delegation tool has no explicit pool (`SubagentToolOptions.inheritedTools`):
|
|
8
8
|
* the parent surface, narrowed at spawn by two laws, and the parent's MCP declarations. The mint of the parent bound
|
|
@@ -38,6 +38,9 @@ export declare function inheritedMcpDeclarations(mounted: MountedMcp, selector:
|
|
|
38
38
|
* run that spawns it, or, at a wake, the woken leg's own list — whose host-transport entries are inherited ones too, since the definition
|
|
39
39
|
* door refuses a definition that declares one ({@link import("./agent-definition.js").definitionMcpServers}). */
|
|
40
40
|
export declare function inheritedHostSeats(held: ReadonlyMap<string, McpHostSeat> | undefined, servers: ReadonlyArray<McpServerSpec>): Pick<RunInternals, "mcpHostSeats">;
|
|
41
|
+
/** The host-transport servers among `servers` that `held` (a waker's mount seats) has no seat for — each fails its dial on the woken leg
|
|
42
|
+
* (`config.mcp_host_seat_missing`), and the wake's receipt says so. */
|
|
43
|
+
export declare function seatlessHostServers(held: ReadonlyMap<string, McpHostSeat> | undefined, servers: ReadonlyArray<McpServerSpec>): string[];
|
|
41
44
|
/** A child's internals as a retained snapshot keeps them: without the seats that belong to whoever wakes it — the host seats (live objects of
|
|
42
45
|
* the run that held them), the placement fence (the target of the leg that spawned it), the objective's author (who wrote the spawn's
|
|
43
46
|
* prompt) and the activity seat (the spawner's, a closure over its row). Each wake hands the waker's own: its seats
|
|
@@ -48,6 +51,13 @@ export declare function withoutWakerSeats(internals: RunInternals): RunInternals
|
|
|
48
51
|
* chain): without any reading of the `sharedArtifactReads` setting. One rule: every wake is a run of its own and reads the seat
|
|
49
52
|
* again — neither the spawner's old `allow` nor the waker's outlives a setting changed since. Every other member stays as it is. */
|
|
50
53
|
export declare function wakeGate(gate: InheritedGate): InheritedGate;
|
|
54
|
+
/** Merge an agent definition's MCP servers with the lane's servers, returning both the mounted list and any shadowed entries. */
|
|
55
|
+
export declare function mergeDefinitionServers<S extends {
|
|
56
|
+
readonly name: string;
|
|
57
|
+
}>(handed: readonly S[] | undefined, own: readonly S[] | undefined): {
|
|
58
|
+
servers: S[];
|
|
59
|
+
dropped: S[];
|
|
60
|
+
};
|
|
51
61
|
/**
|
|
52
62
|
* The MCP servers a leg spawned as an agent definition is declared ({@link AgentDefinition.mcp}): the servers its lane hands it (the
|
|
53
63
|
* spawning run's it inherits, a workflow child's governed spec's) first, then each of the definition's own whose tool namespace none of
|
|
@@ -58,6 +68,24 @@ export declare function wakeGate(gate: InheritedGate): InheritedGate;
|
|
|
58
68
|
export declare function withDefinitionServers<S extends {
|
|
59
69
|
readonly name: string;
|
|
60
70
|
}>(handed: readonly S[] | undefined, own: readonly S[] | undefined): S[];
|
|
71
|
+
/**
|
|
72
|
+
* Announce shadowed agent-definition MCP entries through `mcpInjectionDroppedNotice`, once per (runner, root session address, agent,
|
|
73
|
+
* server) while that tuple is among the last `MAX_SHADOWED_ANNOUNCEMENTS_PER_RUNNER` announced (one pushed out is said again). The announcement is said on behalf of the spawning tree's leg `leg` and goes where that leg's children's notices go
|
|
74
|
+
* (`noticeAddressOf` over the root anchor `root` the children are handed): to the tree's root, under the runner's admission for that
|
|
75
|
+
* route — an announcement for a root occupant the root no longer holds is discarded and said, never delivered to its later occupant.
|
|
76
|
+
*/
|
|
77
|
+
export declare function announceShadowedDefinitionServers(args: {
|
|
78
|
+
readonly runner: Pick<RunnerSelfSeat, "emitNotice">;
|
|
79
|
+
readonly leg: string | undefined;
|
|
80
|
+
readonly root: {
|
|
81
|
+
readonly rootSessionId?: string;
|
|
82
|
+
readonly rootSessionIncarnation?: string;
|
|
83
|
+
};
|
|
84
|
+
readonly agent: string | undefined;
|
|
85
|
+
readonly dropped: ReadonlyArray<{
|
|
86
|
+
readonly name: string;
|
|
87
|
+
}>;
|
|
88
|
+
}): void;
|
|
61
89
|
/**
|
|
62
90
|
* A definition's own allowed-tools list as its leg's selector reads it: the list it wrote, extended by every tool of each MCP server it
|
|
63
91
|
* declares (`mcp__<server>__*`) — the servers an agent brings are its own whatever its list names, and its denied list still wins over them.
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { hostSeatsAlong } from "../core/mounted-mcp.js";
|
|
1
2
|
import { transportKindOf } from "../core/mcp-server-spec.js";
|
|
3
|
+
import { deliverEngineNotice } from "../core/engine-notice.js";
|
|
4
|
+
import { mcpInjectionDroppedNotice } from "../core/mcp-injection-drop.js";
|
|
5
|
+
import { noticeAddressOf } from "../core/leg-identity.js";
|
|
2
6
|
import { MCP_NAMESPACE, mintNamespacePrefix } from "@sema-agent/primitives";
|
|
3
7
|
import { TASK_CREATE_TOOL_NAME, TASK_GET_TOOL_NAME, TASK_LIST_TOOL_NAME, TASK_UPDATE_TOOL_NAME } from "../core/tool-catalog-entries.js";
|
|
4
8
|
export const TEAM_TASK_LIST_TOOL_NAMES = Object.freeze([TASK_CREATE_TOOL_NAME, TASK_GET_TOOL_NAME, TASK_LIST_TOOL_NAME, TASK_UPDATE_TOOL_NAME]);
|
|
@@ -15,11 +19,12 @@ export function inheritedMcpDeclarations(mounted, selector) {
|
|
|
15
19
|
return mounted.servers.filter((m) => selector.admitsPeer(mintNamespacePrefix(MCP_NAMESPACE, m.server.name))).map((m) => m.server);
|
|
16
20
|
}
|
|
17
21
|
export function inheritedHostSeats(held, servers) {
|
|
18
|
-
const seats = servers
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
const seats = hostSeatsAlong(held, servers);
|
|
23
|
+
return seats !== undefined ? { mcpHostSeats: seats } : {};
|
|
24
|
+
}
|
|
25
|
+
export function seatlessHostServers(held, servers) {
|
|
26
|
+
const seated = hostSeatsAlong(held, servers);
|
|
27
|
+
return servers.filter((s) => transportKindOf(s) === "host" && seated?.has(s.name) !== true).map((s) => s.name);
|
|
23
28
|
}
|
|
24
29
|
export function withoutWakerSeats(internals) {
|
|
25
30
|
const { mcpHostSeats: _live, placementTarget: _spawnersTarget, objectiveAuthor: _spawnAuthor, onSubtreeActivity: _spawnersActivity, ...kept } = internals;
|
|
@@ -31,9 +36,50 @@ export function wakeGate(gate) {
|
|
|
31
36
|
const { sharedArtifactReads: _reading, ...kept } = gate;
|
|
32
37
|
return kept;
|
|
33
38
|
}
|
|
34
|
-
export function
|
|
39
|
+
export function mergeDefinitionServers(handed, own) {
|
|
35
40
|
const held = new Set((handed ?? []).map((s) => mintNamespacePrefix(MCP_NAMESPACE, s.name)));
|
|
36
|
-
|
|
41
|
+
const kept = [];
|
|
42
|
+
const dropped = [];
|
|
43
|
+
for (const s of own ?? []) {
|
|
44
|
+
if (held.has(mintNamespacePrefix(MCP_NAMESPACE, s.name)))
|
|
45
|
+
dropped.push(s);
|
|
46
|
+
else
|
|
47
|
+
kept.push(s);
|
|
48
|
+
}
|
|
49
|
+
return { servers: [...(handed ?? []), ...kept], dropped };
|
|
50
|
+
}
|
|
51
|
+
export function withDefinitionServers(handed, own) {
|
|
52
|
+
return mergeDefinitionServers(handed, own).servers;
|
|
53
|
+
}
|
|
54
|
+
const announcedShadowedServers = new WeakMap();
|
|
55
|
+
const MAX_SHADOWED_ANNOUNCEMENTS_PER_RUNNER = 4_096;
|
|
56
|
+
export function announceShadowedDefinitionServers(args) {
|
|
57
|
+
const { runner, leg, root, agent, dropped } = args;
|
|
58
|
+
if (dropped.length === 0 || typeof leg !== "string" || leg.length === 0 || typeof agent !== "string" || agent.length === 0)
|
|
59
|
+
return;
|
|
60
|
+
const route = noticeAddressOf({ sourceSessionId: leg, isDelegatedChild: true }, root);
|
|
61
|
+
const sessionId = route.address.sessionId;
|
|
62
|
+
let seen = announcedShadowedServers.get(runner);
|
|
63
|
+
if (seen === undefined) {
|
|
64
|
+
seen = new Set();
|
|
65
|
+
announcedShadowedServers.set(runner, seen);
|
|
66
|
+
}
|
|
67
|
+
for (const s of dropped) {
|
|
68
|
+
const key = JSON.stringify([sessionId, root.rootSessionIncarnation ?? null, agent, s.name]);
|
|
69
|
+
if (seen.has(key))
|
|
70
|
+
continue;
|
|
71
|
+
if (seen.size >= MAX_SHADOWED_ANNOUNCEMENTS_PER_RUNNER) {
|
|
72
|
+
const oldest = seen.values().next().value;
|
|
73
|
+
if (oldest !== undefined)
|
|
74
|
+
seen.delete(oldest);
|
|
75
|
+
}
|
|
76
|
+
seen.add(key);
|
|
77
|
+
const notice = mcpInjectionDroppedNotice({ sessionId, server: s.name, reason: "name_already_mounted", agent });
|
|
78
|
+
if (runner.emitNotice !== undefined)
|
|
79
|
+
runner.emitNotice(notice, route);
|
|
80
|
+
else
|
|
81
|
+
deliverEngineNotice(undefined, notice);
|
|
82
|
+
}
|
|
37
83
|
}
|
|
38
84
|
export function definitionAllowTools(def) {
|
|
39
85
|
const written = def.allowTools ?? undefined;
|
|
@@ -24,6 +24,16 @@ export declare function parkedResumeDoor(pr: {
|
|
|
24
24
|
}): ParkedResumeGateReading | {
|
|
25
25
|
readonly refusal: unknown;
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* The root task's facts a drive must hand, or the refusal naming the first it lacks: the root's seat (`parentSpecSeat`, minted with
|
|
29
|
+
* `parentSpecSeatOf` from the root's stored spec — the revived leg's instruction family, language, directories and mods are read from
|
|
30
|
+
* it; the row records only the principal and the sandbox), then the root's current mode (`parkedResume.inheritedGate.permissionMode`
|
|
31
|
+
* — the row froze the mode at the park, and the root may have tightened it since). Asked of every drive, an allow and a deny alike;
|
|
32
|
+
* the drive refuses before the consume and rolls the claim back, as for any other fact it lacks.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parkedResumeUnhanded(seat: unknown, gate: {
|
|
35
|
+
readonly permissionMode?: PermissionMode;
|
|
36
|
+
} | undefined): Error | undefined;
|
|
27
37
|
/** The account of the resume's own rejection `e` when the chain raised it for a deny the resume validated on THIS card
|
|
28
38
|
* (`takeDeniedChainRefusalToken`, the ladder's mark on that one throw, naming the card's token — every code and reason the chain's
|
|
29
39
|
* rungs refuse with), else `undefined`: its code and reason, as the stopped agent's receipt names them (the refusal's own sentence
|
|
@@ -40,6 +40,15 @@ export function parkedResumeDoor(pr) {
|
|
|
40
40
|
return { refusal: e };
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
export function parkedResumeUnhanded(seat, gate) {
|
|
44
|
+
if (seat === undefined) {
|
|
45
|
+
return Object.assign(new Error("the parked agent was not resumed: the drive hands no `parentSpecSeat` — mint it with `parentSpecSeatOf` from the root task's stored spec, so the agent reads its instruction files, language and directories; the approval stays pending"), { code: "config.parent_spec_seat_missing" });
|
|
46
|
+
}
|
|
47
|
+
if (gate?.permissionMode === undefined) {
|
|
48
|
+
return Object.assign(new Error("the parked agent was not resumed: the drive hands no `parkedResume.inheritedGate.permissionMode` — hand the root task's current mode (the row's is the mode at the park); the approval stays pending"), { code: "config.invalid_argument", detail: { field: "inheritedGate" } });
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
43
52
|
export function unresumableChainRefusal(e, token) {
|
|
44
53
|
if (takeDeniedChainRefusalToken(e) !== token)
|
|
45
54
|
return undefined;
|
|
@@ -146,6 +146,9 @@ export interface SubagentRetainEntry {
|
|
|
146
146
|
* runner, so this adds no new retention class.
|
|
147
147
|
*/
|
|
148
148
|
runner?: RunnerSelfSeat;
|
|
149
|
+
/** The run that dispatched the child keeps a member ledger (`ToolExecuteContext.runLedgerBook` at the spawn): every cycle's
|
|
150
|
+
* terminal frame carries the child's actions digest, a woken cycle's as the spawn cycle's. */
|
|
151
|
+
actionsDigest?: true;
|
|
149
152
|
agentName?: string;
|
|
150
153
|
/** fix-C5: PER-ENTRY retain TTL override (ms). A SESSION-scoped ledger is shared by two purposes with
|
|
151
154
|
* different windows (failure-evidence retain = FAILED_SESSION_RETAIN_TTL_MS vs a session-scoped bg
|
|
@@ -20,6 +20,8 @@ import { neutralizePeerBody } from "./cross-session-envelope.js";
|
|
|
20
20
|
import { SubagentRetainLedger, durableRungAdmitsRow, getSessionRetainLedger, liveRetainEntryOf } from "./retain-ledger.js";
|
|
21
21
|
import { createSubagentResume } from "./subagent.js";
|
|
22
22
|
import { childAnswerCode, childFailureOf } from "./child-failure.js";
|
|
23
|
+
import { seatlessHostServers } from "./inherited-tool-pool.js";
|
|
24
|
+
import { hostSeatNotHandedLine } from "../core/mcp-host-seat.js";
|
|
23
25
|
import { appendHopToken, judgePeerAdmission, peerAxisToken, resolvePeerLaneConfig, PEER_MESSAGE_NOTICE, } from "./peer-admission.js";
|
|
24
26
|
import { mountRuleFace, toolFace } from "../core/tool-catalog-entries.js";
|
|
25
27
|
import { thrownText } from "../core/thrown-value.js";
|
|
@@ -1105,6 +1107,7 @@ export function createSendMessageTool(opts) {
|
|
|
1105
1107
|
return admissionRefusal(l3Verdict.reason, who);
|
|
1106
1108
|
assertParentSpecSeatCurrent(ctx.parentSpecSeat);
|
|
1107
1109
|
const chosenRowName = chosenAgentName(targetId, row.name);
|
|
1110
|
+
const wakerSeats = ctx.mountedMcp?.().hostSeats;
|
|
1108
1111
|
const resume = createSubagentResume({
|
|
1109
1112
|
ledger,
|
|
1110
1113
|
parentToolCallId: resumeToolUseId,
|
|
@@ -1132,10 +1135,11 @@ export function createSendMessageTool(opts) {
|
|
|
1132
1135
|
...(opts.taskArtifacts !== undefined ? { currentTaskArtifacts: opts.taskArtifacts } : {}),
|
|
1133
1136
|
...(ctx.onQuestion !== undefined && row.sessionScoped !== true ? { currentOnQuestion: ctx.onQuestion } : {}),
|
|
1134
1137
|
currentClamps: clampValuesOf(ctx, ctx.parentSpecSeat),
|
|
1138
|
+
...(ctx.parentSpecSeat?.project !== undefined ? { currentProject: ctx.parentSpecSeat.project } : {}),
|
|
1135
1139
|
...(ctx.autoModeReview !== undefined ? { currentAutoModeReview: ctx.autoModeReview } : {}),
|
|
1136
1140
|
...(ctx.spendSeat !== undefined ? { currentSpendSeat: ctx.spendSeat } : {}),
|
|
1137
1141
|
continuationTier,
|
|
1138
|
-
currentMcpHostSeats:
|
|
1142
|
+
currentMcpHostSeats: wakerSeats,
|
|
1139
1143
|
currentPlacementTarget: ctx.placementTarget,
|
|
1140
1144
|
});
|
|
1141
1145
|
const fromPrefix = senderIsChild ? `(message from teammate "${senderLabel}")\n` : "";
|
|
@@ -1146,8 +1150,9 @@ export function createSendMessageTool(opts) {
|
|
|
1146
1150
|
if (entryNow !== undefined && (entryNow !== judgedEntry || entryNow.internalsSnapshot.delegationOwner !== judgedSeat))
|
|
1147
1151
|
return notReached();
|
|
1148
1152
|
const marker = await resume(`${fromPrefix}[${safeSummary}] ${safeMessage}`);
|
|
1153
|
+
const seatless = seatlessHostServers(wakerSeats, judgedEntry?.specSnapshot.mcp ?? []);
|
|
1149
1154
|
return {
|
|
1150
|
-
content: continuedReceipt(receiptAgentLabel(to, targetId, row), 0),
|
|
1155
|
+
content: continuedReceipt(receiptAgentLabel(to, targetId, row), 0) + (seatless.length > 0 ? ` ${hostSeatNotHandedLine(seatless)}` : ""),
|
|
1151
1156
|
details: { type: "send-message", status: "resumed", to, task_id: targetId, marker, summary },
|
|
1152
1157
|
};
|
|
1153
1158
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentTool } from "../internal/harness-types.js";
|
|
2
|
+
import type { RunLedger, RunLedgerBook } from "../core/run-ledger.js";
|
|
3
|
+
export declare const SEND_USER_MESSAGE_TOOL_NAME = "SendUserMessage";
|
|
4
|
+
export interface SendUserMessageSeats {
|
|
5
|
+
/** The run's ledger book. */
|
|
6
|
+
readonly book: RunLedgerBook;
|
|
7
|
+
/** Record the ledger snapshot a delivery carries in the run's session log (best effort: a failed write does not refuse the
|
|
8
|
+
* delivery — the snapshot still rides the call's result). */
|
|
9
|
+
readonly record: (ledger: RunLedger) => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
/** Build the report tool over the run's book. */
|
|
12
|
+
export declare function createSendUserMessageTool(seats: SendUserMessageSeats): AgentTool;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { defineTool } from "../core/tools.js";
|
|
3
|
+
import { mountRuleFace, toolFace } from "../core/tool-catalog-entries.js";
|
|
4
|
+
import { egressValue } from "../core/untrusted-egress.js";
|
|
5
|
+
export const SEND_USER_MESSAGE_TOOL_NAME = "SendUserMessage";
|
|
6
|
+
const DELIVERED = "Message delivered to user.";
|
|
7
|
+
const CLAIM = Type.Object({
|
|
8
|
+
about: Type.String({ description: "The task id of the member this conclusion is about, as the ledger lists it." }),
|
|
9
|
+
text: Type.String({ description: "The conclusion, in one or two sentences." }),
|
|
10
|
+
basis: Type.Union([Type.Literal("verified"), Type.Literal("relayed"), Type.Literal("inferred")], {
|
|
11
|
+
description: '"verified": you checked it yourself after that member reported (cite the check) — "relayed": it is what the member said, unchecked — "inferred": your own judgment.',
|
|
12
|
+
}),
|
|
13
|
+
verdict: Type.Optional(Type.Union([Type.Literal("confirms"), Type.Literal("refutes"), Type.Literal("partial")], { description: 'For "verified": whether your check confirms, refutes or partly confirms what the member reported.' })),
|
|
14
|
+
evidence: Type.Optional(Type.Array(Type.String(), { maxItems: 8, description: 'For "verified": the id of each check — a tool call you made after the member reported, or another member\'s task id (a verification worker).' })),
|
|
15
|
+
}, { additionalProperties: false });
|
|
16
|
+
const PARAMETERS = Type.Object({
|
|
17
|
+
message: Type.String({ description: "What the person reads. Markdown is fine." }),
|
|
18
|
+
status: Type.Union([Type.Literal("normal"), Type.Literal("proactive")], {
|
|
19
|
+
description: "'normal' when replying to what they just asked; 'proactive' when you are initiating — a phase finished, a blocker surfaced, a result was overturned, you need a decision. Set it honestly; downstream routing uses it.",
|
|
20
|
+
}),
|
|
21
|
+
report: Type.Optional(Type.Object({
|
|
22
|
+
kind: Type.Optional(Type.Union([Type.Literal("start"), Type.Literal("interim"), Type.Literal("final")])),
|
|
23
|
+
claims: Type.Optional(Type.Array(CLAIM, { maxItems: 32 })),
|
|
24
|
+
decisions: Type.Optional(Type.Array(Type.Object({ question: Type.String(), options: Type.Array(Type.String(), { maxItems: 8 }), recommend: Type.Optional(Type.String()) }, { additionalProperties: false }), { maxItems: 8 })),
|
|
25
|
+
next: Type.Optional(Type.String()),
|
|
26
|
+
}, { additionalProperties: false })),
|
|
27
|
+
}, { additionalProperties: false });
|
|
28
|
+
export function createSendUserMessageTool(seats) {
|
|
29
|
+
return defineTool({
|
|
30
|
+
name: SEND_USER_MESSAGE_TOOL_NAME,
|
|
31
|
+
...toolFace("send-user-message"),
|
|
32
|
+
ruleFace: mountRuleFace("send-user-message"),
|
|
33
|
+
description: "Send a message the person you work for will read. Use it to report — when you start, when a result is overturned, when you are blocked or need a decision, and at the end.\n\n" +
|
|
34
|
+
"`status` labels intent: 'normal' when replying to what they just asked; 'proactive' when you are initiating. Set it honestly; downstream routing uses it.\n\n" +
|
|
35
|
+
"`report.claims` is optional: one entry per conclusion about a member you dispatched (`about` = its task id), each saying what it rests on. " +
|
|
36
|
+
'A "verified" claim must cite evidence made AFTER that member reported — a tool call of your own, or another member that checked it — and state a verdict; ' +
|
|
37
|
+
"a report whose checks do not hold is not delivered and the reason comes back, so check again or mark the claim \"relayed\". " +
|
|
38
|
+
"Beside every message the engine delivers its own ledger of the members — how each ended, what each did, which ones nobody checked — whatever the message says.",
|
|
39
|
+
parameters: PARAMETERS,
|
|
40
|
+
execute: async (args, ctx) => {
|
|
41
|
+
const a = egressValue("same-principal", args);
|
|
42
|
+
const verdict = seats.book.acceptReport({
|
|
43
|
+
status: a.status,
|
|
44
|
+
message: a.message,
|
|
45
|
+
...(a.report !== undefined ? { report: { ...(a.report.kind !== undefined ? { kind: a.report.kind } : {}), ...(a.report.claims !== undefined ? { claims: a.report.claims } : {}) } } : {}),
|
|
46
|
+
...(ctx?.toolCallId !== undefined ? { toolCallId: ctx.toolCallId } : {}),
|
|
47
|
+
});
|
|
48
|
+
if (!verdict.ok) {
|
|
49
|
+
return { content: `Report not sent: ${verdict.why.slice(0, 1200)}`, details: { type: "send-user-message", status: a.status, delivered: false }, isError: true };
|
|
50
|
+
}
|
|
51
|
+
const ledger = seats.book.snapshot({ kind: "report", ...(ctx?.toolCallId !== undefined ? { toolCallId: ctx.toolCallId } : {}) });
|
|
52
|
+
await seats.record(ledger).catch(() => undefined);
|
|
53
|
+
return {
|
|
54
|
+
content: `${DELIVERED}\nLedger: ${ledger.headline}`,
|
|
55
|
+
details: {
|
|
56
|
+
type: "send-user-message",
|
|
57
|
+
status: a.status,
|
|
58
|
+
delivered: true,
|
|
59
|
+
message: a.message,
|
|
60
|
+
...(a.report?.kind !== undefined ? { kind: a.report.kind } : {}),
|
|
61
|
+
...(a.report !== undefined ? { report: a.report } : {}),
|
|
62
|
+
ledger,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* Everything is BOUNDED (step ring ≤ {@link STEP_CAP}, fields truncated): a pathological child cannot balloon the parent's view.
|
|
19
19
|
*/
|
|
20
20
|
import type { TaskEvent } from "../core/types.js";
|
|
21
|
+
import { type SubagentActions } from "../core/actions-digest.js";
|
|
21
22
|
/** One completed tool step in the child's tail — enough for the parent to say "you stopped at X". */
|
|
22
23
|
export interface SubagentStep {
|
|
23
24
|
/** Tool name (or its distinct {@link ToolSpec.label} when set). */
|
|
@@ -49,6 +50,11 @@ export declare class SubagentStepRecorder {
|
|
|
49
50
|
private readonly steps;
|
|
50
51
|
private readonly pending;
|
|
51
52
|
private readonly edits;
|
|
53
|
+
/** The whole-stream counters the actions digest reads (never the ring): calls by tool, and the shell commands. */
|
|
54
|
+
private readonly toolCounts;
|
|
55
|
+
private toolCallTotal;
|
|
56
|
+
private readonly commands;
|
|
57
|
+
private commandsPast;
|
|
52
58
|
private action;
|
|
53
59
|
private actionTool;
|
|
54
60
|
private actionTarget;
|
|
@@ -76,6 +82,9 @@ export declare class SubagentStepRecorder {
|
|
|
76
82
|
recentSteps(): SubagentStep[] | undefined;
|
|
77
83
|
/** Files the child mutated with edit counts; undefined if none. */
|
|
78
84
|
editedFiles(): SubagentEditedFile[] | undefined;
|
|
85
|
+
/** The child's whole-stream actions digest ({@link SubagentActions}) — present even when the child called no tool (a
|
|
86
|
+
* zero digest is the fact a self-report of work is read against). */
|
|
87
|
+
actions(): SubagentActions;
|
|
79
88
|
/** The child's most recent tool intent as one human line ("Bash npm test", "Edit src/x.ts"); undefined if none. */
|
|
80
89
|
currentAction(): string | undefined;
|
|
81
90
|
/** {@link currentAction} pre-formatted into a fleet-view Progress-section
|
|
@@ -3,6 +3,16 @@ import { renderContentBlock } from "../internal/llm.js";
|
|
|
3
3
|
import { cutAt, redactThenCut } from "../core/untrusted-egress.js";
|
|
4
4
|
import { isProtectedWrite } from "../core/tool-registry.js";
|
|
5
5
|
import { writeTargetPath } from "../tools/fs/safety.js";
|
|
6
|
+
import { ACTIONS_COMMANDS_CAP, ACTIONS_TOOLS_CAP } from "../core/actions-digest.js";
|
|
7
|
+
const SHELL_TOOL_NAME = "Bash";
|
|
8
|
+
function shellExitCode(structured, output) {
|
|
9
|
+
const s = structured;
|
|
10
|
+
if (s !== null && typeof s === "object" && typeof s.exitCode === "number" && Number.isInteger(s.exitCode))
|
|
11
|
+
return s.exitCode;
|
|
12
|
+
const text = typeof output === "string" ? output : Array.isArray(output) ? output.map(renderContentBlock).join("\n") : "";
|
|
13
|
+
const m = /^exit code: (-?\d+)/.exec(text);
|
|
14
|
+
return m !== null ? Number(m[1]) : undefined;
|
|
15
|
+
}
|
|
6
16
|
export const STEP_CAP = 10;
|
|
7
17
|
const FIELD_MAX = 80;
|
|
8
18
|
const EDITED_FILES_CAP = 32;
|
|
@@ -55,6 +65,10 @@ export class SubagentStepRecorder {
|
|
|
55
65
|
steps = [];
|
|
56
66
|
pending = new Map();
|
|
57
67
|
edits = new Map();
|
|
68
|
+
toolCounts = new Map();
|
|
69
|
+
toolCallTotal = 0;
|
|
70
|
+
commands = [];
|
|
71
|
+
commandsPast = 0;
|
|
58
72
|
action;
|
|
59
73
|
actionTool;
|
|
60
74
|
actionTarget;
|
|
@@ -71,6 +85,10 @@ export class SubagentStepRecorder {
|
|
|
71
85
|
this.steps.length = 0;
|
|
72
86
|
this.pending.clear();
|
|
73
87
|
this.edits.clear();
|
|
88
|
+
this.toolCounts.clear();
|
|
89
|
+
this.toolCallTotal = 0;
|
|
90
|
+
this.commands.length = 0;
|
|
91
|
+
this.commandsPast = 0;
|
|
74
92
|
this.action = undefined;
|
|
75
93
|
this.actionTool = undefined;
|
|
76
94
|
this.actionTarget = undefined;
|
|
@@ -111,6 +129,16 @@ export class SubagentStepRecorder {
|
|
|
111
129
|
this.steps.push({ tool, target, outcome });
|
|
112
130
|
if (this.steps.length > STEP_CAP)
|
|
113
131
|
this.steps.shift();
|
|
132
|
+
this.toolCallTotal += 1;
|
|
133
|
+
this.toolCounts.set(e.toolName, (this.toolCounts.get(e.toolName) ?? 0) + 1);
|
|
134
|
+
if (e.toolName === SHELL_TOOL_NAME) {
|
|
135
|
+
if (this.commands.length < ACTIONS_COMMANDS_CAP) {
|
|
136
|
+
const exitCode = shellExitCode(e.structured, e.output);
|
|
137
|
+
this.commands.push({ command: target, ...(exitCode !== undefined ? { exitCode } : {}) });
|
|
138
|
+
}
|
|
139
|
+
else
|
|
140
|
+
this.commandsPast += 1;
|
|
141
|
+
}
|
|
114
142
|
const editPath = start?.edit;
|
|
115
143
|
if (editPath !== undefined && !e.isError) {
|
|
116
144
|
if (this.edits.has(editPath))
|
|
@@ -129,6 +157,16 @@ export class SubagentStepRecorder {
|
|
|
129
157
|
editedFiles() {
|
|
130
158
|
return this.edits.size > 0 ? [...this.edits].map(([path, edits]) => ({ path, edits })) : undefined;
|
|
131
159
|
}
|
|
160
|
+
actions() {
|
|
161
|
+
const byTool = [...this.toolCounts].map(([tool, calls]) => ({ tool, calls })).sort((a, b) => b.calls - a.calls).slice(0, ACTIONS_TOOLS_CAP);
|
|
162
|
+
return {
|
|
163
|
+
toolCalls: this.toolCallTotal,
|
|
164
|
+
byTool,
|
|
165
|
+
commands: this.commands.map((c) => ({ ...c })),
|
|
166
|
+
...(this.commandsPast > 0 ? { commandsUnlisted: this.commandsPast } : {}),
|
|
167
|
+
filesEdited: this.editedFiles() ?? [],
|
|
168
|
+
};
|
|
169
|
+
}
|
|
132
170
|
currentAction() {
|
|
133
171
|
return this.action;
|
|
134
172
|
}
|
|
@@ -433,6 +433,8 @@ export declare function createSubagentResume(deps: {
|
|
|
433
433
|
* has no live face and its `AskUserQuestion` mount falls back to the automatic criterion's other legs
|
|
434
434
|
* — never a call into a closed surface. */
|
|
435
435
|
currentOnQuestion?: import("../core/ask-question.js").OnQuestion;
|
|
436
|
+
/** The RESUMING caller's own project seat (`ParentSpecSeat.project`): a woken cycle runs under its WAKER's, as a tier-3 revival does; the spawn snapshot's is not kept (absent ⇒ none). */
|
|
437
|
+
currentProject?: import("../core/project-seat.js").ProjectSeat;
|
|
436
438
|
/** The RESUMING caller's own tighten-only CLAMPS (its trusted `ToolExecuteContext` seats), folded ON TOP
|
|
437
439
|
* of the frozen snapshot so a wake can only ever narrow the child. Without this the snapshot alone
|
|
438
440
|
* decides: a child spawned by a write-capable, interactive, long-lived run could be woken BY a
|