@sema-agent/core 7.57.0 → 7.59.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 +1161 -0
- package/README.md +6 -4
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +5 -3
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/send-message-tool.js +21 -12
- package/dist/agents/subagent-steps.js +2 -4
- package/dist/agents/subagent.js +33 -34
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +89 -22
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +62 -5
- package/dist/brain/timeout.js +93 -6
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +23 -10
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/allow-entry.d.ts +20 -7
- package/dist/core/allow-entry.js +18 -9
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/ask-origin.d.ts +21 -2
- package/dist/core/ask-origin.js +5 -1
- package/dist/core/auto-compaction.d.ts +4 -0
- package/dist/core/auto-compaction.js +2 -2
- package/dist/core/auto-mode-directive.d.ts +29 -5
- package/dist/core/auto-mode-directive.js +38 -8
- package/dist/core/background-agent-store.d.ts +16 -3
- package/dist/core/checkpoint-requirements.d.ts +19 -1
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-store.d.ts +85 -23
- package/dist/core/checkpoint-store.js +31 -9
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/compliance.js +1 -1
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +99 -9
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/fs-write-gate-policy.d.ts +4 -2
- package/dist/core/fs-write-gate-policy.js +7 -3
- package/dist/core/gate-fold.js +7 -4
- package/dist/core/gate-lanes.js +19 -6
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/git-worktree-env.d.ts +53 -11
- package/dist/core/git-worktree-env.js +96 -12
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +13 -0
- package/dist/core/hooks.d.ts +35 -4
- package/dist/core/hooks.js +17 -11
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/image-admission.d.ts +6 -5
- package/dist/core/image-admission.js +18 -14
- package/dist/core/locked-config.d.ts +20 -3
- package/dist/core/locked-config.js +40 -3
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-call-meta.d.ts +66 -0
- package/dist/core/mcp-call-meta.js +103 -0
- package/dist/core/mcp-connection-pool.d.ts +3 -1
- package/dist/core/mcp-connection-pool.js +3 -1
- package/dist/core/mcp-failure.d.ts +117 -15
- package/dist/core/mcp-failure.js +71 -3
- package/dist/core/mcp-probe.d.ts +4 -0
- package/dist/core/mcp-probe.js +1 -1
- package/dist/core/mcp-server-link.d.ts +27 -3
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp-server-spec.d.ts +46 -18
- package/dist/core/mcp-server-spec.js +1 -18
- package/dist/core/mcp.d.ts +16 -20
- package/dist/core/mcp.js +112 -55
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/scope-contract.d.ts +45 -4
- package/dist/core/memory-engine/scope-contract.js +80 -11
- package/dist/core/memory-engine/sync-client.d.ts +9 -1
- package/dist/core/memory-engine/sync-client.js +31 -8
- package/dist/core/memory-engine/sync.d.ts +5 -0
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mode-policy.d.ts +8 -5
- package/dist/core/mode-policy.js +5 -4
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/host.js +1 -1
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +12 -9
- package/dist/core/mods/kernel/events.d.ts +6 -1
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/registration.d.ts +9 -1
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/kernel/site-rules.d.ts +3 -0
- package/dist/core/mods/kernel/site-rules.js +10 -0
- package/dist/core/mods/package.d.ts +23 -0
- package/dist/core/mods/package.js +118 -0
- package/dist/core/mods/stations.d.ts +33 -12
- package/dist/core/mods/stations.js +45 -11
- package/dist/core/mods/tool-call.d.ts +5 -1
- package/dist/core/mods/tool-call.js +13 -4
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +6 -0
- package/dist/core/path-guard-rows.d.ts +20 -0
- package/dist/core/path-guard-rows.js +11 -0
- package/dist/core/peer-seat.d.ts +248 -0
- package/dist/core/peer-seat.js +439 -0
- package/dist/core/permission-rule-consent.js +10 -4
- package/dist/core/permission-rule-model.d.ts +16 -0
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/present-plan-tool.d.ts +20 -3
- package/dist/core/present-plan-tool.js +48 -4
- package/dist/core/protocol-http-auth.d.ts +40 -29
- package/dist/core/protocol-http-auth.js +30 -32
- package/dist/core/redaction-marks.d.ts +16 -0
- package/dist/core/redaction-marks.js +16 -0
- package/dist/core/redaction-passes.js +8 -9
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/retention.d.ts +41 -15
- package/dist/core/retention.js +59 -12
- package/dist/core/rewrite-rejudge.d.ts +38 -0
- package/dist/core/rewrite-rejudge.js +42 -2
- package/dist/core/roles.d.ts +34 -2
- package/dist/core/roles.js +43 -4
- package/dist/core/run-origin.d.ts +40 -0
- package/dist/core/run-origin.js +37 -0
- package/dist/core/runner/advertised-writable-dirs.d.ts +57 -38
- package/dist/core/runner/advertised-writable-dirs.js +126 -0
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/call-hook-stations.js +2 -2
- package/dist/core/runner/compaction-restate.d.ts +15 -6
- package/dist/core/runner/compaction-restate.js +28 -2
- package/dist/core/runner/contracts.d.ts +33 -21
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/gate-exit.d.ts +30 -8
- package/dist/core/runner/gate-exit.js +15 -8
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.js +3 -3
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +3 -1
- package/dist/core/runner/prepare-config-doors.d.ts +8 -5
- package/dist/core/runner/prepare-config-doors.js +14 -10
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +8 -0
- package/dist/core/runner/prepare-delegation-surface.js +16 -18
- package/dist/core/runner/prepare-gate-stations.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +11 -3
- package/dist/core/runner/prepare-hands-readface.js +9 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
- package/dist/core/runner/prepare-inherited-gate.js +14 -27
- package/dist/core/runner/prepare-memory.d.ts +3 -0
- package/dist/core/runner/prepare-memory.js +26 -37
- package/dist/core/runner/prepare-park-ask.d.ts +1 -1
- package/dist/core/runner/prepare-park-ask.js +2 -1
- package/dist/core/runner/prepare-policy-chain.d.ts +7 -7
- package/dist/core/runner/prepare-policy-chain.js +18 -15
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
- package/dist/core/runner/prepare-prompt-inputs.js +8 -19
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +11 -3
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +2 -1
- package/dist/core/runner/prepare-task.js +28 -13
- package/dist/core/runner/prepare-wiring-manifest.d.ts +2 -1
- package/dist/core/runner/prepare-wiring-manifest.js +4 -3
- package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
- package/dist/core/runner/prepare-workspace-restore.js +4 -4
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +5 -3
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-checkpoint-screen.js +2 -0
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-brain-sinks.js +2 -0
- package/dist/core/runner/run-harness-handlers.d.ts +3 -4
- package/dist/core/runner/run-harness-handlers.js +1 -8
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +6 -4
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +42 -29
- package/dist/core/runner/run-notification-lane.js +3 -0
- package/dist/core/runner/run-stop-and-final-verify.js +2 -2
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +77 -70
- package/dist/core/runner/runtask.d.ts +1 -1
- package/dist/core/runner/runtask.js +2 -2
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +10 -0
- package/dist/core/runner/terminal-account.js +3 -3
- package/dist/core/runner/tool-end-body.js +2 -1
- package/dist/core/runner/tool-occurrence.d.ts +5 -2
- package/dist/core/runner/tool-occurrence.js +4 -3
- package/dist/core/runner/turn-attachments.d.ts +26 -22
- package/dist/core/runner/turn-attachments.js +24 -26
- package/dist/core/runner/write-protection-station.d.ts +8 -2
- package/dist/core/runner/write-protection-station.js +2 -0
- package/dist/core/runner-deps.d.ts +3 -3
- package/dist/core/secret-env.d.ts +32 -2
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +9 -10
- package/dist/core/session-log-transfer.d.ts +24 -0
- package/dist/core/session-log-transfer.js +166 -0
- package/dist/core/session-policy-store.d.ts +3 -1
- package/dist/core/session-policy-store.js +13 -9
- package/dist/core/session-store.d.ts +86 -24
- package/dist/core/session-store.js +162 -24
- package/dist/core/session.d.ts +92 -1
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +8 -5
- package/dist/core/skill-grant.js +6 -6
- package/dist/core/steer-replay.d.ts +4 -2
- package/dist/core/steer-replay.js +2 -1
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +20 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/store-contracts/session-repo-contract.js +112 -5
- package/dist/core/store-contracts/session-store-contract.d.ts +4 -1
- package/dist/core/store-contracts/session-store-contract.js +236 -2
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +92 -8
- package/dist/core/task-notification.js +16 -10
- package/dist/core/task-registry-agent.js +1 -0
- package/dist/core/task-registry-shared.d.ts +7 -1
- package/dist/core/task-spec.d.ts +49 -1
- package/dist/core/task-stream.d.ts +2 -1
- package/dist/core/terminal-cause.d.ts +11 -1
- package/dist/core/tool-catalog-entries.js +1 -0
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-policy.d.ts +16 -0
- package/dist/core/tool-result-store.d.ts +17 -10
- package/dist/core/tool-result-store.js +3 -1
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +3 -1
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-egress.d.ts +0 -2
- package/dist/core/untrusted-egress.js +10 -14
- package/dist/core/user-attachment.js +1 -1
- package/dist/core/wiring-manifest.d.ts +18 -6
- package/dist/core/wiring-manifest.js +4 -3
- package/dist/core/workspace-snapshot.d.ts +44 -0
- package/dist/core/workspace-snapshot.js +34 -0
- package/dist/core/write-protect.d.ts +43 -3
- package/dist/core/write-protect.js +43 -16
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/node-execution-env.js +24 -23
- package/dist/engine/execution-env/symlink-chain.d.ts +7 -5
- package/dist/engine/harness/agent-harness.d.ts +30 -2
- package/dist/engine/harness/agent-harness.js +43 -12
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +56 -7
- package/dist/engine/harness/types.js +5 -1
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +30 -10
- package/dist/engine/llm/types.js +1 -1
- package/dist/engine/loop/agent-loop.d.ts +8 -0
- package/dist/engine/loop/agent-loop.js +52 -15
- package/dist/engine/loop/types.d.ts +3 -1
- package/dist/engine/session/import-validate.js +3 -0
- package/dist/engine/session/memory-repo.d.ts +17 -9
- package/dist/engine/session/memory-repo.js +44 -34
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/repo-utils.d.ts +22 -4
- package/dist/engine/session/repo-utils.js +49 -1
- package/dist/engine/session/storage-base.d.ts +10 -1
- package/dist/engine/session/storage-base.js +11 -22
- package/dist/index.d.ts +29 -16
- package/dist/index.js +21 -11
- package/dist/internal/harness-types.d.ts +2 -2
- package/dist/internal/harness.d.ts +3 -2
- package/dist/internal/harness.js +2 -2
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.js +739 -489
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/index.d.ts +4 -1
- package/dist/stores/file/index.js +4 -1
- package/dist/stores/file/mailbox-store.js +6 -10
- package/dist/stores/file/session-store.d.ts +15 -8
- package/dist/stores/file/session-store.js +28 -13
- package/dist/tools/fs/fs-bash.d.ts +6 -0
- package/dist/tools/fs/fs-bash.js +6 -3
- package/dist/tools/fs/fs-write.d.ts +6 -3
- package/dist/tools/fs/fs-write.js +8 -7
- package/dist/tools/fs/index.d.ts +3 -0
- package/dist/tools/fs/index.js +7 -3
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +19 -0
- package/dist/tools/fs/read-floor.js +23 -0
- package/dist/tools/fs/safety.js +40 -8
- package/dist/tools/fs/search.js +6 -24
- package/dist/tools/fs/shell-read-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +61 -16
- package/dist/tools/fs/shell-read-establish.js +2 -1
- package/dist/tools/fs/shell-read-identity.js +1 -1
- package/dist/tools/fs/shell-read-judge.d.ts +26 -9
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +2 -0
- package/dist/tools/worktree.d.ts +42 -15
- package/dist/tools/worktree.js +60 -32
- package/package.json +5 -2
- package/test/export-surface.snapshot.json +149 -1
- package/wire-changes/core-stores-sql@7.58.0.json +29 -0
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core@7.58.0.json +2188 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/mods-kernel@7.58.0.json +81 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/primitives@7.58.0.json +29 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
- package/dist/primitives/credential-ref.d.ts +0 -89
- package/dist/primitives/credential-ref.js +0 -125
- package/dist/primitives/index.d.ts +0 -2
- package/dist/primitives/index.js +0 -1
package/README.md
CHANGED
|
@@ -22,7 +22,8 @@ const res = await runner.runTask({ objective: "...", model: "main" });
|
|
|
22
22
|
and for the Anthropic Messages API. Routing, failover, and model roles are configuration.
|
|
23
23
|
- **Stateless by design.** A task carries its full configuration (model, prompt, tools, MCP,
|
|
24
24
|
skills, limits) and returns a `TaskResult`. Persistence — sessions, checkpoints, long-term
|
|
25
|
-
memory, workflow journals — lives behind storage interfaces
|
|
25
|
+
memory, workflow journals — lives behind storage interfaces. Core ships in-memory and file-backed
|
|
26
|
+
implementations; a database store is your deployment's to write and prove with the published contract kits.
|
|
26
27
|
|
|
27
28
|
**It is not:**
|
|
28
29
|
|
|
@@ -39,10 +40,10 @@ const res = await runner.runTask({ objective: "...", model: "main" });
|
|
|
39
40
|
behavior of Claude Code's tool contract, continuously verified against live probes.
|
|
40
41
|
- **Durable checkpoints and human-in-the-loop.** Tasks can suspend on approval gates, budget
|
|
41
42
|
limits, or explicit checkpoints and resume later — on another process or machine — via a
|
|
42
|
-
pluggable `CheckpointStore` (in-memory
|
|
43
|
+
pluggable `CheckpointStore` (in-memory and file-backed here; a database one is yours). Task statuses are explicit:
|
|
43
44
|
`completed | blocked | failed | timeout | suspended | needs_review`.
|
|
44
45
|
- **Memory engine.** Scoped long-term memory with a pluggable `MemoryBackend`
|
|
45
|
-
(file-backed
|
|
46
|
+
(file-backed here; a database backend is yours), plus automatic in-context compaction that keeps long runs inside the
|
|
46
47
|
model's context window without losing the thread.
|
|
47
48
|
- **Multi-agent.** Sub-agent delegation, deterministic `runWorkflow`
|
|
48
49
|
orchestration with durable journals, and opt-in observer agents that monitor and steer a run.
|
|
@@ -50,7 +51,8 @@ const res = await runner.runTask({ objective: "...", model: "main" });
|
|
|
50
51
|
tool lifecycle, progress, diagnostics), ready to pipe into SSE via `createTaskServer`.
|
|
51
52
|
- **Security model built in.** Tool policies with allow/ask/deny semantics, per-principal
|
|
52
53
|
authorization, shell gating, and durable approval suspension — not bolted on.
|
|
53
|
-
- **Small and honest.**
|
|
54
|
+
- **Small and honest.** Four runtime dependencies (`typebox`, `@modelcontextprotocol/sdk`, `undici`, and the sibling package
|
|
55
|
+
`@sema-agent/primitives`, installed with it at the same version).
|
|
54
56
|
A deterministic vitest suite of 5,400+ tests runs fully offline (`npm test`), including a real
|
|
55
57
|
stdio MCP server.
|
|
56
58
|
- **Source-available.** BUSL-1.1: free for personal, educational, research, and non-commercial
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
import { lstat, readdir, readFile } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import { normalizePeerName } from "./cross-session-ref.js";
|
|
5
4
|
import { inheritedHostEnv } from "../core/secret-env.js";
|
|
6
5
|
import { CC_PEER_ROW_FILE_RE } from "./cc-peer-wire.js";
|
|
7
|
-
import { judgePeerRecordFile,
|
|
6
|
+
import { judgePeerRecordFile, PEER_SESSION_RECORD_SCHEMA_VERSION, peerRowFault, readPeerSessionRecord, vetPeerRegistryDirectory, } from "./peer-directory.js";
|
|
8
7
|
export const CC_UNNAMED_SESSION_NAME = "(unnamed session)";
|
|
9
8
|
export function ccProcessStartToken(pid) {
|
|
10
9
|
if (process.platform === "win32" || !Number.isInteger(pid) || pid <= 0)
|
|
@@ -32,7 +31,7 @@ export class CcPeerDirectoryError extends Error {
|
|
|
32
31
|
code;
|
|
33
32
|
path;
|
|
34
33
|
constructor(code, path) {
|
|
35
|
-
super(`the reference agent's session registry is not a directory this engine can trust (${code}: ${path})
|
|
34
|
+
super(`the reference agent's session registry is not a directory this engine can trust (${code}: ${path})`);
|
|
36
35
|
this.name = "CcPeerDirectoryError";
|
|
37
36
|
this.code = code;
|
|
38
37
|
this.path = path;
|
|
@@ -87,11 +86,11 @@ export function createCcPeerDirectory(opts) {
|
|
|
87
86
|
}
|
|
88
87
|
const finite = (v) => (typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : undefined);
|
|
89
88
|
const startedAt = finite(r["startedAt"]) ?? 0;
|
|
90
|
-
const name = typeof r["name"] === "string"
|
|
89
|
+
const name = typeof r["name"] === "string" ? r["name"] : CC_UNNAMED_SESSION_NAME;
|
|
91
90
|
const features = Array.isArray(r["peerFeatures"]) ? r["peerFeatures"].filter((f) => typeof f === "string" && FEATURE_RE.test(f)).slice(0, MAX_FEATURES) : undefined;
|
|
92
91
|
const tempo = r["tempo"];
|
|
93
|
-
const agent = typeof r["agent"] === "string"
|
|
94
|
-
const
|
|
92
|
+
const agent = typeof r["agent"] === "string" ? r["agent"] : undefined;
|
|
93
|
+
const raw = {
|
|
95
94
|
schemaVersion: PEER_SESSION_RECORD_SCHEMA_VERSION,
|
|
96
95
|
sessionId: r["sessionId"],
|
|
97
96
|
scope,
|
|
@@ -108,9 +107,10 @@ export function createCcPeerDirectory(opts) {
|
|
|
108
107
|
...(features !== undefined ? { peerFeatures: features } : {}),
|
|
109
108
|
sockPath,
|
|
110
109
|
where: "this_machine",
|
|
111
|
-
}
|
|
110
|
+
};
|
|
111
|
+
const read = readPeerSessionRecord(raw);
|
|
112
112
|
if (!read.ok)
|
|
113
|
-
|
|
113
|
+
throw peerRowFault(raw, read);
|
|
114
114
|
return read.record;
|
|
115
115
|
};
|
|
116
116
|
return {
|
|
@@ -7,9 +7,11 @@ export declare function runnerRoleMap(runner: unknown): ModelRoles | undefined;
|
|
|
7
7
|
* own: a string ref other than the literal `"default"`, a `Model` object, or a `{ model | select }` config
|
|
8
8
|
* whose `model` is not that literal. The word `"default"` is how a deployment spells "no subagent tier of my
|
|
9
9
|
* own — same as the main model" (a catalog key of that name is the boot default), so it reads as NOT stated;
|
|
10
|
-
* a role entry carrying only a `thinking` / `systemPrompt` preset states no model either.
|
|
10
|
+
* a role entry carrying only a `thinking` / `systemPrompt` preset states no model either. A word the catalog does not hold states none
|
|
11
|
+
* either — the seat is read as the same seat without that word (`unheldSeatWord`, the roles family's one test): a `select` beside it still
|
|
12
|
+
* states the tier, otherwise the children run on the parent's model; the engine says so once per conversation (`model.role_defaulted`).
|
|
11
13
|
*/
|
|
12
|
-
export declare function deploymentStatesSubagentModel(roles: ModelRoles | undefined): boolean;
|
|
14
|
+
export declare function deploymentStatesSubagentModel(roles: ModelRoles | undefined, models: Record<string, Model> | undefined): boolean;
|
|
13
15
|
/**
|
|
14
16
|
* Did the deployment STATE a thinking level for its subagents — and which? The `thinking` member of an
|
|
15
17
|
* object-form `roles.subagent` entry; a string ref, a `Model` object or an entry without the member states
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveModel, resolveTaskModel } from "../core/roles.js";
|
|
1
|
+
import { resolveModel, resolveTaskModel, unheldSeatWord } from "../core/roles.js";
|
|
2
2
|
export function runnerRoleMap(runner) {
|
|
3
3
|
try {
|
|
4
4
|
return runner?.agentCatalog?.roles;
|
|
@@ -7,10 +7,12 @@ export function runnerRoleMap(runner) {
|
|
|
7
7
|
return undefined;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
export function deploymentStatesSubagentModel(roles) {
|
|
10
|
+
export function deploymentStatesSubagentModel(roles, models) {
|
|
11
11
|
const s = roles?.subagent;
|
|
12
12
|
if (s == null)
|
|
13
13
|
return false;
|
|
14
|
+
if (unheldSeatWord(s, models) !== undefined)
|
|
15
|
+
return typeof s !== "string" && s.select !== undefined;
|
|
14
16
|
if (typeof s === "string")
|
|
15
17
|
return s !== "default";
|
|
16
18
|
if ("id" in s && "api" in s)
|
|
@@ -36,7 +38,7 @@ export function childThinkingSeat(explicit, deploymentStated, parent) {
|
|
|
36
38
|
return level !== undefined ? { thinking: level } : {};
|
|
37
39
|
}
|
|
38
40
|
export function deploymentSubagentTierModel(deps) {
|
|
39
|
-
if (deps === undefined || !deploymentStatesSubagentModel(deps.roles))
|
|
41
|
+
if (deps === undefined || !deploymentStatesSubagentModel(deps.roles, deps.models))
|
|
40
42
|
return undefined;
|
|
41
43
|
const resolved = resolveTaskModel({ modelRole: "subagent" }, deps);
|
|
42
44
|
return { model: resolved.model, ...(inheritableRef(resolved.modelRef, resolved.model, deps.models) !== undefined ? { modelRef: resolved.modelRef } : {}) };
|
|
@@ -185,6 +185,15 @@ export interface PeerDirectory {
|
|
|
185
185
|
* faults the WHOLE listing (thrown, so each consumer's fault arm speaks), never a partial set — refs are minted and
|
|
186
186
|
* names resolved over the full set, and dropping one row would change both. */
|
|
187
187
|
export declare function listPeerDirectory(dir: PeerDirectory, access: PeerDirectoryAccess): Promise<PeerSessionRecord[]>;
|
|
188
|
+
/**
|
|
189
|
+
* THE fault of a row the reader refuses: what the directory did wrong, in one sentence — the consequence is each reader's own
|
|
190
|
+
* line (the listing says what it lists, a send's refusal frame says it was not sent), so a sentence is not written twice. Raised by
|
|
191
|
+
* {@link listPeerDirectory} for a host's rows and by the reference registry's directory for a row it read the same way.
|
|
192
|
+
*/
|
|
193
|
+
export declare function peerRowFault(raw: unknown, read: {
|
|
194
|
+
reason: PeerSessionRecordRefusal;
|
|
195
|
+
field?: string;
|
|
196
|
+
}): Error;
|
|
188
197
|
export interface PeerSessionCandidate {
|
|
189
198
|
record: PeerSessionRecord;
|
|
190
199
|
/** The listing-minted ref (6..12 hex) of this row — stable across the live/dead filter because it is
|
|
@@ -177,10 +177,14 @@ export async function listPeerDirectory(dir, access) {
|
|
|
177
177
|
const read = readPeerSessionRecord(raw);
|
|
178
178
|
if (read.ok)
|
|
179
179
|
return read.record;
|
|
180
|
-
|
|
181
|
-
throw new Error(`the directory listed a row this engine cannot read (${id}: ${read.reason}${read.field !== undefined ? `: ${read.field}` : ""}); no peer row is used until its host fixes it`);
|
|
180
|
+
throw peerRowFault(raw, read);
|
|
182
181
|
});
|
|
183
182
|
}
|
|
183
|
+
export function peerRowFault(raw, read) {
|
|
184
|
+
const sessionId = raw?.sessionId;
|
|
185
|
+
const id = typeof sessionId === "string" ? inlineUntrusted(sessionId, 80) : "(no session id)";
|
|
186
|
+
return new Error(`the directory listed a row this engine cannot read (${id}: ${read.reason}${read.field !== undefined ? `: ${read.field}` : ""})`);
|
|
187
|
+
}
|
|
184
188
|
export function mintPeerSessionCandidates(records, self) {
|
|
185
189
|
const entries = records.map((record) => ({ kind: "session", id: record.sessionId.toLowerCase(), record }));
|
|
186
190
|
const selfEntry = self !== undefined && !records.some((r) => r.sessionId.toLowerCase() === self.sessionId.toLowerCase()) ? { kind: "session", id: self.sessionId.toLowerCase() } : undefined;
|
|
@@ -3,6 +3,7 @@ import { isNotificationInjectionOutcome } from "../core/task-notification.js";
|
|
|
3
3
|
import { defineTool } from "../core/tools.js";
|
|
4
4
|
import { normalizeAgentName, chosenAgentName, DURABLE_AGENT_HANDLE_RE, DURABLE_AGENT_HEARTBEAT_MS } from "../core/task-registry.js";
|
|
5
5
|
import { announceTranscriptIntegrityGapOnce, canAccessAgentRecord, clearRevivedRowTerminalPayload } from "../core/background-agent-store.js";
|
|
6
|
+
import { readClampFloor } from "../core/child-clamp-seats.js";
|
|
6
7
|
import { uuidv7 } from "../internal/harness.js";
|
|
7
8
|
import { MAILBOX_TOMBSTONED_RECIPIENT_CODE, mailboxCrossProcessMountVerdict } from "../core/mailbox-store.js";
|
|
8
9
|
import { peerSendVerdictSeverity } from "./cross-session-judge.js";
|
|
@@ -152,7 +153,7 @@ export function createSendMessageTool(opts) {
|
|
|
152
153
|
}
|
|
153
154
|
return {
|
|
154
155
|
content: `Message not sent: "${inlineUntrusted(to, 120)}" now resolves to a different agent than it did earlier in ` +
|
|
155
|
-
`this run — this name previously resolved to ${pinned.id.slice(0, 64)}, which it no longer reaches
|
|
156
|
+
`this run — this name previously resolved to ${pinned.id.slice(0, 64)}, which it no longer reaches.\n` +
|
|
156
157
|
`It now resolves to ${targetId.slice(0, 64)}. To message that agent, re-send with its task_id: ` +
|
|
157
158
|
`{"to": "${targetId.slice(0, 64)}", …}. To reach the earlier agent, use its task_id ` +
|
|
158
159
|
`${pinned.id.slice(0, 64)} from its spawn result.`,
|
|
@@ -389,11 +390,11 @@ export function createSendMessageTool(opts) {
|
|
|
389
390
|
};
|
|
390
391
|
const deliverOverSocket = async (record, peerLabel, modeClass) => {
|
|
391
392
|
if (notifyWhenIdle)
|
|
392
|
-
return peerRefusal("peer_send.invalid_target", `notify_when_idle is only supported for peer sessions that drain this host's mailbox store, and ${peerLabel} is reached over its socket
|
|
393
|
+
return peerRefusal("peer_send.invalid_target", `notify_when_idle is only supported for peer sessions that drain this host's mailbox store, and ${peerLabel} is reached over its socket.`);
|
|
393
394
|
if (opts.peerChannel === undefined)
|
|
394
|
-
return peerRefusal("peer_send.not_reachable", `${peerLabel} does not drain this host's mailbox store (a Claude Code session, or a session of this engine on another store), so a message parked here would never be read, and no socket channel is wired here to reach it (RunnerDeps.peerChannel)
|
|
395
|
+
return peerRefusal("peer_send.not_reachable", `${peerLabel} does not drain this host's mailbox store (a Claude Code session, or a session of this engine on another store), so a message parked here would never be read, and no socket channel is wired here to reach it (RunnerDeps.peerChannel).`);
|
|
395
396
|
if (record.liveness !== "live")
|
|
396
|
-
return peerRefusal("peer_send.not_reachable", `${peerLabel} is reached only over its socket and is not running; nothing holds a message for it while it is down
|
|
397
|
+
return peerRefusal("peer_send.not_reachable", `${peerLabel} is reached only over its socket and is not running; nothing holds a message for it while it is down.`);
|
|
397
398
|
const recipientKey = peerAxisToken(peerScope, "s", record.sessionId);
|
|
398
399
|
const sendVerdict = judgePeerAdmission(peerScope, recipientKey, { senderKey, body: message, prospectiveChain, ownTokens: [recipientKey] }, admissionConfig, undefined, "send");
|
|
399
400
|
if (!sendVerdict.ok)
|
|
@@ -406,7 +407,7 @@ export function createSendMessageTool(opts) {
|
|
|
406
407
|
hopChain: prospectiveChain,
|
|
407
408
|
});
|
|
408
409
|
if (!verdict.ok)
|
|
409
|
-
return peerRefusal(verdict.code, `${peerLabel} could not be reached over its socket — ${verdict.message}.${verdict.code === "peer_send.send_uncertain" ? " It may have arrived: do not resend the same content blindly." : "
|
|
410
|
+
return peerRefusal(verdict.code, `${peerLabel} could not be reached over its socket — ${verdict.message}.${verdict.code === "peer_send.send_uncertain" ? " It may have arrived: do not resend the same content blindly." : ""}`);
|
|
410
411
|
return {
|
|
411
412
|
content: `Message sent to ${peerLabel} over its socket: it does not drain this host's mailbox store, so nothing is parked here, and the socket answers no acknowledgement — the message was written to its socket once and the connection closed cleanly, which is all this receipt confirms (not that its session took it in, nor that its model read it). Continue with your task; do not resend the same content.`,
|
|
412
413
|
details: { type: "send-message", status: "peer_delivered", to, address: peerSessionBoxHandle(record.sessionId), verdict },
|
|
@@ -415,7 +416,7 @@ export function createSendMessageTool(opts) {
|
|
|
415
416
|
const settlePeerResolution = async (r) => {
|
|
416
417
|
switch (r.status) {
|
|
417
418
|
case "directory_fault":
|
|
418
|
-
return peerRefusal("peer_send.other", `the peer-session directory could not be read (${r.message})
|
|
419
|
+
return peerRefusal("peer_send.other", `the peer-session directory could not be read (${r.message}).`);
|
|
419
420
|
case "not_found":
|
|
420
421
|
return undefined;
|
|
421
422
|
case "self":
|
|
@@ -441,17 +442,17 @@ export function createSendMessageTool(opts) {
|
|
|
441
442
|
};
|
|
442
443
|
if (notifyWhenIdle) {
|
|
443
444
|
if (!peerLane.active) {
|
|
444
|
-
return peerRefusal("peer_send.invalid_target", peerLane.reason !== undefined ? `notify_when_idle is only supported for peer sessions of this engine, and the cross-session lane is unavailable on this mount — ${peerLane.reason}
|
|
445
|
+
return peerRefusal("peer_send.invalid_target", peerLane.reason !== undefined ? `notify_when_idle is only supported for peer sessions of this engine, and the cross-session lane is unavailable on this mount — ${peerLane.reason}.` : `notify_when_idle is only supported for peer sessions of this engine, and cross-session addressing is not mounted here (no peer-session directory).`);
|
|
445
446
|
}
|
|
446
447
|
if (senderIsChild) {
|
|
447
|
-
return peerRefusal("peer_send.invalid_target", "notify_when_idle is only available from the main conversation of this session (not from a subagent or teammate).
|
|
448
|
+
return peerRefusal("peer_send.invalid_target", "notify_when_idle is only available from the main conversation of this session (not from a subagent or teammate).");
|
|
448
449
|
}
|
|
449
450
|
const settled = await settlePeerResolution(await resolvePeerTarget());
|
|
450
|
-
return settled ?? peerRefusal("peer_send.invalid_target", `notify_when_idle is only supported for peer sessions of this engine (not teammates, subagents or agents), and no peer session is registered as "${inlineUntrusted(to, 120)}"
|
|
451
|
+
return settled ?? peerRefusal("peer_send.invalid_target", `notify_when_idle is only supported for peer sessions of this engine (not teammates, subagents or agents), and no peer session is registered as "${inlineUntrusted(to, 120)}".`);
|
|
451
452
|
}
|
|
452
453
|
if (parsePeerSessionAddress(to) !== undefined) {
|
|
453
454
|
if (!peerLane.active) {
|
|
454
|
-
return peerRefusal("peer_send.invalid_target", peerLane.reason !== undefined ? `cross-session addressing is unavailable on this mount — ${peerLane.reason}
|
|
455
|
+
return peerRefusal("peer_send.invalid_target", peerLane.reason !== undefined ? `cross-session addressing is unavailable on this mount — ${peerLane.reason}.` : `cross-session addressing is not mounted here (no peer-session directory), so "${inlineUntrusted(to, 120)}" cannot be delivered.`);
|
|
455
456
|
}
|
|
456
457
|
const settled = await settlePeerResolution(await resolvePeerTarget());
|
|
457
458
|
return settled ?? peerRefusal("peer_send.invalid_target", `no session is registered at "${inlineUntrusted(to, 120)}" — nothing was parked (a message is only ever parked for a session that exists or existed).`);
|
|
@@ -488,7 +489,7 @@ export function createSendMessageTool(opts) {
|
|
|
488
489
|
const content = outcome === "parked_durably"
|
|
489
490
|
? `Message parked durably for main (${mainLabel}): it has no run in progress, so the message was appended to its durable session box and is read at the start of its next run (it survives a restart). Continue with your task; do not wait for a reply.`
|
|
490
491
|
: outcome === "parked"
|
|
491
|
-
? `Message parked in process for main (${mainLabel}): it has no run in progress, so the message waits in this process for its next run — a restart of this process
|
|
492
|
+
? `Message parked in process for main (${mainLabel}): it has no run in progress, so the message waits in this process for its next run — this copy does not survive a restart of this process. Continue with your task; do not wait for a reply.`
|
|
492
493
|
: outcome === "dropped_duplicate"
|
|
493
494
|
? `Message not re-sent to main (${mainLabel}): it already delivered this exact message. Continue with your task; do not resend the same content.`
|
|
494
495
|
: `Message sent to main — queued for ${mainLabel} at its next turn boundary (accepted into its lane, not yet read). If that run finishes before reading it, the message may not survive. Continue with your task; do not wait for a reply.`;
|
|
@@ -580,6 +581,14 @@ export function createSendMessageTool(opts) {
|
|
|
580
581
|
}
|
|
581
582
|
if (row.sessionId === undefined)
|
|
582
583
|
return undefined;
|
|
584
|
+
const floorRead = readClampFloor(row.policyFloor);
|
|
585
|
+
if (!floorRead.ok) {
|
|
586
|
+
return {
|
|
587
|
+
content: `Message not sent: ${whoT3} cannot be revived — ${inlineUntrusted(floorRead.why, 400)}, so the restrictions it ran under cannot be held on a new cycle. Launch a new agent with the needed context instead.`,
|
|
588
|
+
details: { error: "revive.policy_floor_unreadable", code: "revive.policy_floor_unreadable", to },
|
|
589
|
+
isError: true,
|
|
590
|
+
};
|
|
591
|
+
}
|
|
583
592
|
const t3RecipientKey = peerAxisToken(scope, "h", handle);
|
|
584
593
|
const t3Verdict = admitFor(t3RecipientKey, [t3RecipientKey, peerAxisToken(scope, "s", row.sessionId)]);
|
|
585
594
|
if (!t3Verdict.ok)
|
|
@@ -983,7 +992,7 @@ export function createSendMessageTool(opts) {
|
|
|
983
992
|
const stillLive = nowRow !== undefined && (nowRow.status === "running" || nowRow.status === "pending");
|
|
984
993
|
return stillLive
|
|
985
994
|
? {
|
|
986
|
-
content: `Message not sent: ${who} is still starting up (it has not begun reading messages yet)
|
|
995
|
+
content: `Message not sent: ${who} is still starting up (it has not begun reading messages yet). Send again shortly. ${DEDUP_RETRY_NOTE}`,
|
|
987
996
|
details: { error: "settle_race", to },
|
|
988
997
|
isError: true,
|
|
989
998
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { stripMarkedReminderBlocks } from "../core/reminder-mint.js";
|
|
2
2
|
import { renderContentBlock } from "../internal/llm.js";
|
|
3
3
|
import { egressText } from "../core/untrusted-egress.js";
|
|
4
|
+
import { eachRedactionMarkerSpan } from "../core/redaction-marks.js";
|
|
4
5
|
import { isProtectedWrite } from "../core/tool-registry.js";
|
|
5
6
|
import { writeTargetPath } from "../tools/fs/safety.js";
|
|
6
7
|
export const STEP_CAP = 10;
|
|
@@ -10,14 +11,11 @@ function firstLine(s) {
|
|
|
10
11
|
const nl = s.indexOf("\n");
|
|
11
12
|
return nl === -1 ? s : s.slice(0, nl);
|
|
12
13
|
}
|
|
13
|
-
const REDACTION_MARKER_RE = /\[redacted(?:-[a-z]+)?\]/g;
|
|
14
14
|
export function cutAt(line, max) {
|
|
15
15
|
if (line.length <= max)
|
|
16
16
|
return line;
|
|
17
17
|
let at = max;
|
|
18
|
-
for (const
|
|
19
|
-
const start = m.index;
|
|
20
|
-
const end = start + m[0].length;
|
|
18
|
+
for (const [start, end] of eachRedactionMarkerSpan(line)) {
|
|
21
19
|
if (start < at && at < end) {
|
|
22
20
|
at = start;
|
|
23
21
|
break;
|
package/dist/agents/subagent.js
CHANGED
|
@@ -7,7 +7,7 @@ import { resumeRefusalDetailOf, resumeStartupCauseOf } from "../core/resume-star
|
|
|
7
7
|
import { errorCodeOf, thrownFailureOf } from "../core/runner/terminal-account.js";
|
|
8
8
|
import { applyParentSpecSeat, parentSpecSeatOfCtx } from "../core/parent-spec-seat.js";
|
|
9
9
|
import { ADVISOR_FORK_SENTENCE, ADVISOR_TOOL_NAME } from "../core/advisor-verdict.js";
|
|
10
|
-
import { applyClampSeats, assertClampRecord, childClampSeats, clampSeatsOf, clampSourceOf, engineHeadlessLegSeats, foldClampSources, postureUnderClamps } from "../core/child-clamp-seats.js";
|
|
10
|
+
import { applyClampSeats, assertClampRecord, childClampSeats, clampSeatsOf, clampSourceOf, clampsReachNoPerson, clampValuesOf, engineHeadlessLegSeats, foldClampSources, postureUnderClamps, readClampFloor } from "../core/child-clamp-seats.js";
|
|
11
11
|
import { assertNoRetiredKeys } from "../core/retired-keys.js";
|
|
12
12
|
import { stripSpawnTurnQuestionFace } from "../core/ask-question.js";
|
|
13
13
|
import { withDelegationProvenance } from "../core/tool-policy.js";
|
|
@@ -16,7 +16,6 @@ import { notStartedResult } from "../core/delegation-not-started.js";
|
|
|
16
16
|
import { isHighSurrogate, isLowSurrogate } from "../core/surrogate-safe-slice.js";
|
|
17
17
|
import { newDelegationProvenanceAggregate, reduceDelegationAttestation } from "../core/memory-engine/delegation-provenance.js";
|
|
18
18
|
import { registerDelegationLaunch, replayExternalSettlementEffects, settleDelegation } from "../core/memory-engine/delegation-settlement.js";
|
|
19
|
-
import { enqueueMemoryAnnouncement } from "../core/memory-engine/layout.js";
|
|
20
19
|
import { resolveModel, resolveModelDisplayLabel } from "../core/roles.js";
|
|
21
20
|
import { childModelSeat, childThinkingSeat, deploymentStatesSubagentModel, deploymentSubagentThinking, forkModelSeat, inheritedParentModel, runnerRoleMap } from "./child-model-seat.js";
|
|
22
21
|
export { childThinkingSeat, deploymentSubagentThinking, deploymentSubagentTierModel } from "./child-model-seat.js";
|
|
@@ -517,7 +516,7 @@ export function createSubagentResume(deps) {
|
|
|
517
516
|
assertNoRetiredKeys(deps, RETIRED_RESUME_CLAMP_KEYS, "createSubagentResume");
|
|
518
517
|
assertClampRecord(deps.currentClamps, "createSubagentResume currentClamps");
|
|
519
518
|
const notifier = createSafeNotifier(deps.onNotifyError !== undefined ? { onError: deps.onNotifyError } : undefined);
|
|
520
|
-
const
|
|
519
|
+
const resumeAs = (peerOrigin) => async (content) => {
|
|
521
520
|
const ledger = deps.ledger;
|
|
522
521
|
if (!ledger) {
|
|
523
522
|
throw configError("resume unavailable: the parent run did not enable TaskSpec.retainSubagentSessions.", "resume.retain_off");
|
|
@@ -577,7 +576,7 @@ export function createSubagentResume(deps) {
|
|
|
577
576
|
const wakeClamps = foldClampSources(entry.specSnapshot, deps.currentClamps);
|
|
578
577
|
const resumeSpec = applyClampSeats({
|
|
579
578
|
...entry.specSnapshot,
|
|
580
|
-
objective: createResumePrompt(marker, content,
|
|
579
|
+
objective: createResumePrompt(marker, content, peerOrigin !== undefined ? "peer" : "operator"),
|
|
581
580
|
sessionId: entry.childSessionId,
|
|
582
581
|
requireExistingSession: true,
|
|
583
582
|
...(deps.currentOnQuestion !== undefined ? { onQuestion: deps.currentOnQuestion } : {}),
|
|
@@ -653,6 +652,7 @@ export function createSubagentResume(deps) {
|
|
|
653
652
|
}, deps.registry !== undefined && deps.taskId !== undefined ? () => deps.registry.noteBackgroundAgentActivity(deps.taskId) : undefined);
|
|
654
653
|
stream = childRunner.runTaskStream(resumeSpec, undefined, {
|
|
655
654
|
...entry.internalsSnapshot,
|
|
655
|
+
...(peerOrigin === undefined ? { operatorObjective: true } : {}),
|
|
656
656
|
cycleSeq: entry.cycleSeq,
|
|
657
657
|
parentInteractionPosture: postureUnderClamps(entry.internalsSnapshot.parentInteractionPosture, { interactiveTools: resumeSpec.interactiveTools, approvalReach: resumeSpec.approvalReach }),
|
|
658
658
|
...(true
|
|
@@ -683,7 +683,7 @@ export function createSubagentResume(deps) {
|
|
|
683
683
|
...(deps.currentParentNotify !== undefined
|
|
684
684
|
? { parentNotify: deps.currentParentNotify, parentPeerRef: deps.currentParentPeerRef }
|
|
685
685
|
: {}),
|
|
686
|
-
peerInboundChainRef: createPeerInboundChainRef(
|
|
686
|
+
peerInboundChainRef: createPeerInboundChainRef(peerOrigin?.hopChain),
|
|
687
687
|
...(reviveCycle !== undefined
|
|
688
688
|
? {
|
|
689
689
|
onNotifyInjectorReady: (inject) => {
|
|
@@ -718,7 +718,7 @@ export function createSubagentResume(deps) {
|
|
|
718
718
|
settleResolve = r;
|
|
719
719
|
});
|
|
720
720
|
if (deps.sink) {
|
|
721
|
-
notifier.notify(() => deps.sink?.(createSteerHandle(stream, deps.parentToolCallId, entry.agentName, settled, { resume, childSessionId: entry.childSessionId })), "subagent.resume.sink");
|
|
721
|
+
notifier.notify(() => deps.sink?.(createSteerHandle(stream, deps.parentToolCallId, entry.agentName, settled, { resume: operatorResume, childSessionId: entry.childSessionId })), "subagent.resume.sink");
|
|
722
722
|
}
|
|
723
723
|
void (async () => {
|
|
724
724
|
try {
|
|
@@ -867,7 +867,8 @@ export function createSubagentResume(deps) {
|
|
|
867
867
|
})();
|
|
868
868
|
return marker;
|
|
869
869
|
};
|
|
870
|
-
|
|
870
|
+
const operatorResume = resumeAs(undefined);
|
|
871
|
+
return deps.peerOrigin === undefined ? operatorResume : resumeAs(deps.peerOrigin);
|
|
871
872
|
}
|
|
872
873
|
function parkCompletionNotify(deps) {
|
|
873
874
|
const { registry, entry, owner, pendingCount, payload, notify } = deps;
|
|
@@ -1510,6 +1511,16 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1510
1511
|
details: { error: "revive.no_background" },
|
|
1511
1512
|
});
|
|
1512
1513
|
}
|
|
1514
|
+
const revivalFloor = reviveClaim !== undefined ? readClampFloor(reviveClaim.row.policyFloor) : undefined;
|
|
1515
|
+
const floorRefusal = revivalFloor !== undefined && !revivalFloor.ok ? revivalFloor.why : undefined;
|
|
1516
|
+
if (floorRefusal !== undefined && reviveClaim?.parkedResume === undefined) {
|
|
1517
|
+
return notStartedResult({
|
|
1518
|
+
isError: true,
|
|
1519
|
+
content: `Sub-agent not revived: ${inlineUntrusted(floorRefusal, 400)}, so the restrictions it ran under cannot be held on a new cycle. Launch a new agent with the needed context instead.`,
|
|
1520
|
+
details: { error: "revive.policy_floor_unreadable" },
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
const bornFloor = revivalFloor?.ok === true ? revivalFloor.floor : undefined;
|
|
1513
1524
|
const prompt = String(a.prompt ?? "").trim();
|
|
1514
1525
|
if (!prompt) {
|
|
1515
1526
|
return notStartedResult({ isError: true, content: "Sub-agent not started: 'prompt' was empty.", details: { error: "empty prompt" } });
|
|
@@ -1670,7 +1681,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1670
1681
|
const inheritedParent = ctx.modelRef ?? ctx.model;
|
|
1671
1682
|
const explicitModelChain = wantsFork ? [inheritedParentModel(inheritedParent, liveCatalog), opts.model] : [perCallModel, def?.model, opts.model];
|
|
1672
1683
|
let childModel = explicitModelChain.find((c) => c !== undefined);
|
|
1673
|
-
const deploymentStatedSubagentModel = deploymentStatesSubagentModel(runnerRoleMap(opts.runner));
|
|
1684
|
+
const deploymentStatedSubagentModel = deploymentStatesSubagentModel(runnerRoleMap(opts.runner), liveCatalog);
|
|
1674
1685
|
if (reviveClaim !== undefined && typeof childModel === "string") {
|
|
1675
1686
|
const resolvable = (ref) => {
|
|
1676
1687
|
try {
|
|
@@ -1911,7 +1922,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1911
1922
|
queueReport: async (framed) => injectObservedRequest(framed, "observer"),
|
|
1912
1923
|
};
|
|
1913
1924
|
const reportTool = createObserverReportToolSpec(reportOpts);
|
|
1914
|
-
const observerModelPick = () => childModelSeat(undefined, deploymentStatesSubagentModel(runnerRoleMap(opts.runner)), ctx.modelRef ?? ctx.model, runnerModelCatalog(opts.runner));
|
|
1925
|
+
const observerModelPick = () => childModelSeat(undefined, deploymentStatesSubagentModel(runnerRoleMap(opts.runner), runnerModelCatalog(opts.runner)), ctx.modelRef ?? ctx.model, runnerModelCatalog(opts.runner));
|
|
1915
1926
|
const observerSpec = (objectiveText, resume) => applyParentSpecSeat({
|
|
1916
1927
|
sessionId: sid,
|
|
1917
1928
|
...(resume ? { requireExistingSession: true } : {}),
|
|
@@ -2107,6 +2118,8 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2107
2118
|
const liveCaptureFloor = reviveClaim === undefined
|
|
2108
2119
|
? { optedOut: (await ctx.memoryCaptureOptedOut) === true, indeterminate: (await ctx.memoryCaptureIndeterminate) === true }
|
|
2109
2120
|
: undefined;
|
|
2121
|
+
const revivalClamps = bornFloor !== undefined ? clampValuesOf(clampSourceOf(ctx, "clamp"), bornFloor) : undefined;
|
|
2122
|
+
const childPosture = revivalClamps !== undefined && clampsReachNoPerson({ interactiveTools: revivalClamps.interactiveTools, approvalReach: revivalClamps.approvalReach }) ? "headless" : ctx.interactionPosture;
|
|
2110
2123
|
const childInternals = {
|
|
2111
2124
|
...(ctx.toolSelector !== undefined ? { toolCeiling: childCeiling, ...(childListsJudged !== undefined ? { toolListsJudged: childListsJudged } : {}) } : {}),
|
|
2112
2125
|
...(childListsDigest !== undefined ? { ownToolLists: { toolName, ...(def !== undefined ? { definition: def.name } : {}), lists: childListsDigest } } : {}),
|
|
@@ -2130,7 +2143,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2130
2143
|
peerInboundChainRef: createPeerInboundChainRef(reviveClaim?.peerSeed?.hopChain),
|
|
2131
2144
|
...(childDefaultPersona !== undefined ? { defaultSystemPrompt: childDefaultPersona } : {}),
|
|
2132
2145
|
isDelegatedChild: true,
|
|
2133
|
-
...(
|
|
2146
|
+
...(childPosture !== undefined ? { parentInteractionPosture: childPosture } : {}),
|
|
2134
2147
|
...(reviveClaim === undefined
|
|
2135
2148
|
? {
|
|
2136
2149
|
...(liveCaptureFloor?.optedOut === true ? { memoryCaptureFloor: true } : {}),
|
|
@@ -2196,7 +2209,8 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2196
2209
|
...(provenanceAgentName !== undefined ? { agentName: provenanceAgentName } : {}),
|
|
2197
2210
|
})
|
|
2198
2211
|
: undefined;
|
|
2199
|
-
const
|
|
2212
|
+
const underBornFloor = (spec) => (bornFloor === undefined ? spec : applyClampSeats(spec, clampValuesOf(spec, bornFloor)));
|
|
2213
|
+
const buildChildSpec = (signal) => underBornFloor(applyParentSpecSeat({
|
|
2200
2214
|
objective: prompt,
|
|
2201
2215
|
...childSeat,
|
|
2202
2216
|
...childThinking,
|
|
@@ -2220,7 +2234,8 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2220
2234
|
enableBlockedReport: true,
|
|
2221
2235
|
limits: childLimits,
|
|
2222
2236
|
signal,
|
|
2223
|
-
}, parentSpecSeat);
|
|
2237
|
+
}, parentSpecSeat));
|
|
2238
|
+
const spawnPolicyFloor = () => clampSeatsOf(buildChildSpec(undefined));
|
|
2224
2239
|
const tryRetainChild = async (ledger, entryTtlMs, preMintedSessionId, durableProbe, releaseAnchor, internalsExtra) => {
|
|
2225
2240
|
if (!ledger)
|
|
2226
2241
|
return undefined;
|
|
@@ -2500,16 +2515,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2500
2515
|
}
|
|
2501
2516
|
if (!settled) {
|
|
2502
2517
|
const detail = childThrownText(lastErr);
|
|
2503
|
-
|
|
2504
|
-
enqueueMemoryAnnouncement(forkSettlementSeat.controlDir, {
|
|
2505
|
-
kind: "gate",
|
|
2506
|
-
at: Date.now(),
|
|
2507
|
-
items: [`delegation settlement: the terminal observation for a background fork of session ${JSON.stringify(forkSettlementSeat.sessionId)} could NOT be recorded (verdict ${verdict}) — the row stays pending and expires as UNPROVEN at the settlement window (fail-closed floor): ${detail.slice(0, 200)}`],
|
|
2508
|
-
});
|
|
2509
|
-
}
|
|
2510
|
-
catch {
|
|
2511
|
-
console.warn(`[sema] delegation settlement terminal write failed (fork, verdict ${verdict}, session ${forkSettlementSeat.sessionId}): ${detail}`);
|
|
2512
|
-
}
|
|
2518
|
+
console.warn(`[sema] delegation settlement terminal write failed (fork, verdict ${verdict}, session ${forkSettlementSeat.sessionId}): ${detail} — the pending row expires as unproven at the settlement window`);
|
|
2513
2519
|
}
|
|
2514
2520
|
};
|
|
2515
2521
|
let taskId;
|
|
@@ -2528,7 +2534,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2528
2534
|
deliveryChannel: "attaching",
|
|
2529
2535
|
toolUseId: ctx.toolCallId,
|
|
2530
2536
|
...(ctx.crossBoundaryTreeForChildren !== undefined ? { crossBoundaryTree: ctx.crossBoundaryTreeForChildren } : {}),
|
|
2531
|
-
...(bg.agentStore !== undefined ? { store: bg.agentStore } : {}),
|
|
2537
|
+
...(bg.agentStore !== undefined ? { store: bg.agentStore, policyFloor: spawnPolicyFloor() } : {}),
|
|
2532
2538
|
abort,
|
|
2533
2539
|
});
|
|
2534
2540
|
}
|
|
@@ -3008,16 +3014,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3008
3014
|
}
|
|
3009
3015
|
if (!settled) {
|
|
3010
3016
|
const detail = childThrownText(lastErr);
|
|
3011
|
-
|
|
3012
|
-
enqueueMemoryAnnouncement(settlementSeat.controlDir, {
|
|
3013
|
-
kind: "gate",
|
|
3014
|
-
at: Date.now(),
|
|
3015
|
-
items: [`delegation settlement: the terminal observation for a background delegation of session ${JSON.stringify(settlementSeat.sessionId)} could NOT be recorded (verdict ${verdict}) — the row stays pending and expires as UNPROVEN at the settlement window (fail-closed floor): ${detail.slice(0, 200)}`],
|
|
3016
|
-
});
|
|
3017
|
-
}
|
|
3018
|
-
catch {
|
|
3019
|
-
console.warn(`[sema] delegation settlement terminal write failed (verdict ${verdict}, session ${settlementSeat.sessionId}): ${detail} — the pending row expires as unproven at the settlement window`);
|
|
3020
|
-
}
|
|
3017
|
+
console.warn(`[sema] delegation settlement terminal write failed (verdict ${verdict}, session ${settlementSeat.sessionId}): ${detail} — the pending row expires as unproven at the settlement window`);
|
|
3021
3018
|
}
|
|
3022
3019
|
};
|
|
3023
3020
|
let taskId;
|
|
@@ -3071,7 +3068,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3071
3068
|
deliveryChannel: "attaching",
|
|
3072
3069
|
toolUseId: ctx.toolCallId,
|
|
3073
3070
|
...(ctx.crossBoundaryTreeForChildren !== undefined ? { crossBoundaryTree: ctx.crossBoundaryTreeForChildren } : {}),
|
|
3074
|
-
...(bg.agentStore !== undefined ? { store: bg.agentStore } : {}),
|
|
3071
|
+
...(bg.agentStore !== undefined ? { store: bg.agentStore, policyFloor: spawnPolicyFloor() } : {}),
|
|
3075
3072
|
abort,
|
|
3076
3073
|
});
|
|
3077
3074
|
}
|
|
@@ -3299,6 +3296,8 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3299
3296
|
? `parked resume failed — the approval is no longer redeemable: ${msg}`
|
|
3300
3297
|
: `parked resume did not proceed (${disp}): ${msg}`, { cause: e });
|
|
3301
3298
|
};
|
|
3299
|
+
if (floorRefusal !== undefined)
|
|
3300
|
+
return rollbackAndThrow(Object.assign(new Error(`the agent was not resumed: ${inlineUntrusted(floorRefusal, 400)}, so the restrictions it ran under cannot be held on a new cycle`), { code: "revive.policy_floor_unreadable" }));
|
|
3302
3301
|
try {
|
|
3303
3302
|
await opts.runner.sessions.acquire(bgChildSessionId, { requireExisting: true });
|
|
3304
3303
|
if (opts.runner.sessions.forget)
|