@sema-agent/core 7.54.1 → 7.56.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 +950 -0
- package/dist/agents/agent-transcript-tool.js +2 -1
- package/dist/agents/builtin-agents.d.ts +12 -14
- package/dist/agents/cascade.js +1 -1
- package/dist/agents/cc-peer-directory.d.ts +36 -0
- package/dist/agents/cc-peer-directory.js +139 -0
- package/dist/agents/cc-peer-wire.d.ts +105 -0
- package/dist/agents/cc-peer-wire.js +98 -0
- package/dist/agents/cc-uds-peer-channel.d.ts +40 -0
- package/dist/agents/cc-uds-peer-channel.js +457 -0
- package/dist/agents/child-model-seat.d.ts +0 -11
- package/dist/agents/child-model-seat.js +0 -3
- package/dist/agents/cross-session-envelope.d.ts +4 -1
- package/dist/agents/cross-session-envelope.js +8 -1
- package/dist/agents/cross-session-judge.d.ts +2 -2
- package/dist/agents/list-agents-tool.d.ts +3 -1
- package/dist/agents/list-agents-tool.js +9 -8
- package/dist/agents/observer.d.ts +4 -5
- package/dist/agents/observer.js +2 -1
- package/dist/agents/peer-admission.d.ts +6 -0
- package/dist/agents/peer-admission.js +4 -1
- package/dist/agents/peer-directory.d.ts +65 -13
- package/dist/agents/peer-directory.js +90 -25
- package/dist/agents/peer-notices.d.ts +1 -1
- package/dist/agents/peer-session-drain.d.ts +3 -1
- package/dist/agents/peer-session-drain.js +3 -2
- package/dist/agents/read-inbox-tool.js +2 -1
- package/dist/agents/repair-loop.js +2 -2
- package/dist/agents/retain-ledger.d.ts +1 -1
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/send-message-tool.d.ts +10 -0
- package/dist/agents/send-message-tool.js +37 -8
- package/dist/agents/subagent.d.ts +39 -82
- package/dist/agents/subagent.js +109 -106
- package/dist/agents/tool-filter.d.ts +31 -46
- package/dist/agents/tool-filter.js +13 -33
- package/dist/agents/verify.d.ts +6 -5
- package/dist/agents/verify.js +3 -3
- package/dist/brain/anthropic.js +43 -81
- package/dist/brain/errors.d.ts +15 -0
- package/dist/brain/errors.js +10 -0
- package/dist/brain/media-degrade.d.ts +18 -7
- package/dist/brain/media-degrade.js +13 -2
- package/dist/brain/model-capability.d.ts +37 -0
- package/dist/brain/model-capability.js +34 -0
- package/dist/brain/model-presets.d.ts +6 -12
- package/dist/brain/model-presets.js +1 -6
- package/dist/brain/open-responses.js +27 -35
- package/dist/brain/openai.js +30 -98
- package/dist/brain/provider-dialect.d.ts +39 -3
- package/dist/brain/provider-dialect.js +28 -0
- package/dist/brain/reasoning-request.d.ts +96 -0
- package/dist/brain/reasoning-request.js +174 -0
- package/dist/brain/reasoning.d.ts +12 -12
- package/dist/brain/reasoning.js +4 -3
- package/dist/brain/request-params.d.ts +62 -9
- package/dist/brain/request-params.js +42 -7
- package/dist/brain/retry.d.ts +1 -1
- package/dist/brain/route-adjudicator.d.ts +15 -0
- package/dist/brain/route-adjudicator.js +15 -0
- package/dist/brain/status-sink.d.ts +20 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/brain/stream-engine.js +6 -5
- package/dist/brain/stream-shared.d.ts +1 -1
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +19 -13
- package/dist/core/advisor-verdict.d.ts +120 -0
- package/dist/core/advisor-verdict.js +92 -0
- package/dist/core/agent-definition.d.ts +17 -8
- package/dist/core/allow-entry.d.ts +69 -36
- package/dist/core/allow-entry.js +81 -52
- package/dist/core/allow-rule-shadow.d.ts +10 -3
- package/dist/core/approval-object.d.ts +2 -1
- package/dist/core/approval-object.js +6 -6
- package/dist/core/ask-origin.d.ts +127 -29
- package/dist/core/ask-origin.js +87 -25
- package/dist/core/ask-question.d.ts +51 -8
- package/dist/core/ask-question.js +12 -7
- package/dist/core/ask-unresolvable-notice.d.ts +8 -3
- package/dist/core/ask-unresolvable-notice.js +16 -2
- package/dist/core/auto-compaction.d.ts +11 -8
- package/dist/core/auto-compaction.js +4 -2
- package/dist/core/auto-mode-arming.d.ts +2 -2
- package/dist/core/auto-mode-defaults.d.ts +8 -8
- package/dist/core/auto-mode-prompt-assets.d.ts +3 -3
- package/dist/core/auto-mode-prompt.d.ts +1 -1
- package/dist/core/auto-mode.d.ts +17 -9
- package/dist/core/auto-mode.js +9 -6
- package/dist/core/background-agent-store.d.ts +3 -3
- package/dist/core/canonical-json.d.ts +1 -1
- package/dist/core/canonical-json.js +2 -2
- package/dist/core/checkpoint-generation.d.ts +53 -0
- package/dist/core/checkpoint-generation.js +35 -0
- package/dist/core/checkpoint-queries.d.ts +180 -0
- package/dist/core/checkpoint-queries.js +272 -0
- package/dist/core/checkpoint-requirements.d.ts +19 -4
- package/dist/core/checkpoint-requirements.js +8 -14
- package/dist/core/checkpoint-store.d.ts +165 -72
- package/dist/core/checkpoint-store.js +79 -82
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +3 -16
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/context-edit.d.ts +6 -7
- package/dist/core/cross-boundary-taint.d.ts +11 -4
- package/dist/core/cross-boundary-taint.js +3 -3
- package/dist/core/decision-receipt.d.ts +37 -3
- package/dist/core/decision-receipt.js +19 -19
- package/dist/core/delegation-not-started.d.ts +6 -0
- package/dist/core/delegation-not-started.js +17 -0
- package/dist/core/effective-path-target.d.ts +1 -1
- package/dist/core/engine-attestation.d.ts +93 -0
- package/dist/core/engine-attestation.js +70 -0
- package/dist/core/engine-capabilities.d.ts +4 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +45 -12
- package/dist/core/exec-output-tail.d.ts +1 -1
- package/dist/core/file-history-retention.d.ts +1 -1
- package/dist/core/file-history-store.d.ts +147 -21
- package/dist/core/file-history-store.js +58 -32
- package/dist/core/gate-fold.d.ts +1 -1
- package/dist/core/gate-fold.js +24 -11
- package/dist/core/gate-lanes.js +81 -68
- package/dist/core/gate-outcome.d.ts +40 -6
- package/dist/core/gate-outcome.js +56 -0
- package/dist/core/governance-codes.d.ts +17 -3
- package/dist/core/governance-codes.js +16 -0
- package/dist/core/hands-band.d.ts +1 -1
- package/dist/core/hooks.d.ts +21 -20
- package/dist/core/hooks.js +3 -1
- package/dist/core/host-floor.d.ts +128 -0
- package/dist/core/host-floor.js +206 -0
- package/dist/core/host-target.d.ts +84 -0
- package/dist/core/host-target.js +92 -0
- package/dist/core/image-downsample.d.ts +1 -1
- package/dist/core/lsp-diagnostics.d.ts +4 -4
- package/dist/core/lsp.d.ts +3 -3
- package/dist/core/mailbox-store.d.ts +4 -0
- package/dist/core/mcp-connection-pool.d.ts +18 -2
- package/dist/core/mcp-connection-pool.js +53 -6
- package/dist/core/mcp-failure.d.ts +23 -4
- package/dist/core/mcp-failure.js +26 -11
- package/dist/core/mcp-listing-drift.d.ts +10 -0
- package/dist/core/mcp-listing-drift.js +6 -0
- package/dist/core/mcp-server-link.d.ts +173 -0
- package/dist/core/mcp-server-link.js +127 -0
- package/dist/core/mcp-server-spec.d.ts +4 -2
- package/dist/core/mcp-session-end.d.ts +26 -0
- package/dist/core/mcp-session-end.js +29 -0
- package/dist/core/mcp-startup-request.d.ts +17 -0
- package/dist/core/mcp-startup-request.js +17 -0
- package/dist/core/mcp.d.ts +17 -13
- package/dist/core/mcp.js +240 -189
- package/dist/core/media-byte-cap.d.ts +1 -1
- package/dist/core/memory-engine/delegation-settlement.js +15 -24
- package/dist/core/memory-engine/engine.d.ts +9 -9
- package/dist/core/memory-engine/engine.js +4 -4
- package/dist/core/memory-engine/layout.d.ts +60 -8
- package/dist/core/memory-engine/layout.js +65 -6
- package/dist/core/memory-engine/provenance-wording.d.ts +1 -1
- package/dist/core/memory-engine/tools.js +4 -1
- package/dist/core/mode-policy.d.ts +1 -1
- package/dist/core/model-seat.d.ts +10 -3
- package/dist/core/mods/classic-events.d.ts +67 -0
- package/dist/core/mods/classic-events.js +1 -0
- package/dist/core/mods/dollar.d.ts +13 -0
- package/dist/core/mods/extension-call.d.ts +31 -0
- package/dist/core/mods/extension-call.js +43 -0
- package/dist/core/mods/kernel/dispatch.d.ts +20 -3
- package/dist/core/mods/kernel/dispatch.js +140 -69
- package/dist/core/mods/kernel/events.d.ts +47 -11
- package/dist/core/mods/kernel/events.js +66 -42
- package/dist/core/mods/kernel/index.d.ts +4 -4
- package/dist/core/mods/kernel/index.js +2 -2
- package/dist/core/mods/kernel/receive.d.ts +39 -5
- package/dist/core/mods/kernel/receive.js +290 -17
- package/dist/core/mods/kernel/registration.d.ts +33 -2
- package/dist/core/mods/kernel/registration.js +6 -7
- package/dist/core/mods/kernel/site-rules.d.ts +44 -16
- package/dist/core/mods/kernel/site-rules.js +24 -42
- package/dist/core/mods/spec-seats.d.ts +69 -0
- package/dist/core/mods/spec-seats.js +114 -0
- package/dist/core/mods/stations.d.ts +28 -8
- package/dist/core/mods/stations.js +29 -13
- package/dist/core/mods/tool-call.d.ts +79 -0
- package/dist/core/mods/tool-call.js +152 -0
- package/dist/core/namespaced-rule-name.d.ts +44 -24
- package/dist/core/namespaced-rule-name.js +50 -43
- package/dist/core/output-style.d.ts +1 -1
- package/dist/core/param-rule-reach.d.ts +15 -0
- package/dist/core/param-rule-reach.js +30 -0
- package/dist/core/parent-spec-seat.d.ts +13 -1
- package/dist/core/parent-spec-seat.js +6 -0
- package/dist/core/park-selfcheck.js +1 -0
- package/dist/core/pause-registry.d.ts +16 -5
- package/dist/core/pause-registry.js +6 -2
- package/dist/core/peer-channel.d.ts +70 -0
- package/dist/core/peer-channel.js +1 -0
- package/dist/core/permission-rule-consent.d.ts +30 -5
- package/dist/core/permission-rule-consent.js +147 -50
- package/dist/core/permission-rule-model.d.ts +245 -65
- package/dist/core/permission-rule-model.js +421 -107
- package/dist/core/permission-rule-org.d.ts +6 -2
- package/dist/core/permission-rule-org.js +7 -3
- package/dist/core/permission-rule-provider.d.ts +6 -2
- package/dist/core/permission-rule-provider.js +41 -11
- package/dist/core/permission-rule-store.d.ts +22 -26
- package/dist/core/permission-rule-store.js +12 -6
- package/dist/core/permission-rule-sync.d.ts +11 -2
- package/dist/core/permission-rule-sync.js +11 -3
- package/dist/core/permission-rule-syntax.d.ts +5 -4
- package/dist/core/permission-rule-syntax.js +2 -2
- package/dist/core/permission-rules.d.ts +53 -15
- package/dist/core/permission-rules.js +125 -100
- package/dist/core/persisted-rule-arms.d.ts +6 -4
- package/dist/core/persisted-rule-arms.js +10 -12
- package/dist/core/present-plan-tool.js +3 -1
- package/dist/core/principal-name.d.ts +20 -0
- package/dist/core/principal-name.js +22 -0
- package/dist/core/prompt-section-seat.js +4 -6
- package/dist/core/protocol-http-auth.d.ts +26 -5
- package/dist/core/protocol-http-auth.js +137 -4
- package/dist/core/protocol-naming.d.ts +2 -2
- package/dist/core/read-only-shell-table.d.ts +1 -1
- package/dist/core/read-only-shell.d.ts +1 -1
- package/dist/core/retired-keys.d.ts +16 -0
- package/dist/core/retired-keys.js +16 -4
- package/dist/core/rewrite-rejudge.d.ts +60 -0
- package/dist/core/rewrite-rejudge.js +36 -0
- package/dist/core/roles.d.ts +34 -3
- package/dist/core/roles.js +66 -53
- package/dist/core/rule-lane-reads.d.ts +20 -15
- package/dist/core/rule-lane-reads.js +45 -17
- package/dist/core/rule-offer-read.d.ts +53 -0
- package/dist/core/rule-offer-read.js +146 -0
- package/dist/core/rule-owner.d.ts +46 -0
- package/dist/core/rule-owner.js +29 -0
- package/dist/core/runner/advisor-instructions.d.ts +70 -0
- package/dist/core/runner/advisor-instructions.js +61 -0
- package/dist/core/runner/advisor-tool.d.ts +33 -0
- package/dist/core/runner/advisor-tool.js +112 -0
- package/dist/core/runner/announce-once-ledger.d.ts +18 -26
- package/dist/core/runner/announce-once-ledger.js +19 -46
- package/dist/core/runner/approval-feedback.js +6 -3
- package/dist/core/runner/assemble-result.d.ts +2 -1
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/call-hook-stations.d.ts +3 -2
- package/dist/core/runner/caller-roster.d.ts +21 -2
- package/dist/core/runner/caller-roster.js +38 -0
- package/dist/core/runner/capability-withheld-seat.d.ts +5 -0
- package/dist/core/runner/capability-withheld-seat.js +24 -0
- package/dist/core/runner/classifier-ladder.d.ts +33 -13
- package/dist/core/runner/classifier-ladder.js +15 -14
- package/dist/core/runner/compaction-restate.d.ts +10 -6
- package/dist/core/runner/compaction-restate.js +9 -3
- package/dist/core/runner/construction-doors.js +3 -0
- package/dist/core/runner/contracts.d.ts +40 -33
- package/dist/core/runner/conversation-segment.d.ts +28 -0
- package/dist/core/runner/conversation-segment.js +42 -0
- package/dist/core/runner/cross-boundary-lane.d.ts +21 -16
- package/dist/core/runner/cross-boundary-lane.js +58 -34
- package/dist/core/runner/decide-continuation.d.ts +7 -4
- package/dist/core/runner/decide-continuation.js +2 -2
- package/dist/core/runner/denial-limit-arms.d.ts +4 -4
- package/dist/core/runner/denial-limit-arms.js +1 -1
- package/dist/core/runner/derived-route-fallback.d.ts +24 -24
- package/dist/core/runner/derived-route-fallback.js +9 -7
- package/dist/core/runner/file-history-request.d.ts +18 -0
- package/dist/core/runner/file-history-request.js +21 -13
- package/dist/core/runner/file-history-restore.d.ts +45 -0
- package/dist/core/runner/file-history-restore.js +46 -0
- package/dist/core/runner/gate-exit.d.ts +9 -3
- package/dist/core/runner/gate-exit.js +11 -5
- package/dist/core/runner/image.d.ts +7 -17
- package/dist/core/runner/image.js +9 -60
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +6 -6
- package/dist/core/runner/permission-rule-lanes.js +38 -15
- package/dist/core/runner/person-path-rows.d.ts +12 -9
- package/dist/core/runner/person-path-rows.js +19 -8
- package/dist/core/runner/prepare-advisor.d.ts +63 -0
- package/dist/core/runner/prepare-advisor.js +77 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +2 -2
- package/dist/core/runner/prepare-ask-lane.js +5 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -6
- package/dist/core/runner/prepare-caps-and-workflow.js +5 -4
- package/dist/core/runner/prepare-config-doors.d.ts +31 -38
- package/dist/core/runner/prepare-config-doors.js +57 -34
- package/dist/core/runner/prepare-defer-classify.d.ts +4 -3
- package/dist/core/runner/prepare-defer-classify.js +7 -8
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +1 -1
- package/dist/core/runner/prepare-file-history.d.ts +48 -8
- package/dist/core/runner/prepare-file-history.js +41 -73
- package/dist/core/runner/prepare-gate-stations.d.ts +2 -5
- package/dist/core/runner/prepare-gate-stations.js +12 -8
- package/dist/core/runner/prepare-hands-readface.d.ts +2 -8
- package/dist/core/runner/prepare-hands-readface.js +15 -14
- package/dist/core/runner/prepare-inherited-gate.d.ts +11 -7
- package/dist/core/runner/prepare-inherited-gate.js +8 -6
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-park-ask.js +12 -12
- package/dist/core/runner/prepare-policy-chain.d.ts +7 -4
- package/dist/core/runner/prepare-policy-chain.js +68 -81
- package/dist/core/runner/prepare-project-context.d.ts +5 -2
- package/dist/core/runner/prepare-project-context.js +6 -3
- package/dist/core/runner/prepare-prompt-assembly.d.ts +5 -7
- package/dist/core/runner/prepare-prompt-assembly.js +10 -8
- package/dist/core/runner/prepare-prompt-inputs.d.ts +11 -9
- package/dist/core/runner/prepare-prompt-inputs.js +4 -6
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +5 -4
- package/dist/core/runner/prepare-safety-scan.d.ts +9 -12
- package/dist/core/runner/prepare-safety-scan.js +8 -23
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +5 -6
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +41 -35
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +7 -4
- package/dist/core/runner/prepare-tool-disclosure-mount.js +24 -18
- package/dist/core/runner/prepare-turn-wiring.d.ts +0 -4
- package/dist/core/runner/prepare-turn-wiring.js +2 -7
- package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -4
- package/dist/core/runner/prepare-wiring-manifest.js +3 -3
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-apply.js +11 -12
- package/dist/core/runner/resume-checkpoint-screen.js +3 -0
- package/dist/core/runner/resume-claim.d.ts +4 -2
- package/dist/core/runner/resume-claim.js +15 -8
- package/dist/core/runner/resume-policy-outcome.js +1 -1
- package/dist/core/runner/retired-runner-deps.js +2 -1
- package/dist/core/runner/rewind-files.d.ts +15 -0
- package/dist/core/runner/rewind-files.js +132 -0
- package/dist/core/runner/run-attachment-seats.js +2 -2
- package/dist/core/runner/run-brain-sinks.d.ts +4 -1
- package/dist/core/runner/run-brain-sinks.js +4 -2
- package/dist/core/runner/run-compaction-machinery.d.ts +1 -1
- package/dist/core/runner/run-compaction-machinery.js +2 -12
- package/dist/core/runner/run-git-lane.d.ts +1 -0
- package/dist/core/runner/run-harness-handlers.js +14 -7
- package/dist/core/runner/run-leg.d.ts +1 -1
- package/dist/core/runner/run-leg.js +43 -18
- package/dist/core/runner/run-settle-and-teardown.js +3 -2
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/run-turn-boundary.d.ts +1 -0
- package/dist/core/runner/run-turn-boundary.js +15 -22
- package/dist/core/runner/runtask.d.ts +3 -0
- package/dist/core/runner/runtask.js +8 -9
- package/dist/core/runner/session-read-file-states.d.ts +15 -0
- package/dist/core/runner/session-read-file-states.js +28 -0
- package/dist/core/runner/session-rule-policy.d.ts +22 -21
- package/dist/core/runner/session-rule-policy.js +17 -31
- package/dist/core/runner/shell-env-withheld.d.ts +33 -0
- package/dist/core/runner/shell-env-withheld.js +51 -0
- package/dist/core/runner/side-call-account.d.ts +32 -8
- package/dist/core/runner/side-call-account.js +23 -1
- package/dist/core/runner/skills-seat.js +6 -2
- package/dist/core/runner/stream-settle-backstop.js +1 -1
- package/dist/core/runner/strict-output-schema.d.ts +1 -1
- package/dist/core/runner/sub-agent-deny-lists.js +4 -6
- package/dist/core/runner/synthetic-tools.d.ts +16 -13
- package/dist/core/runner/synthetic-tools.js +8 -3
- package/dist/core/runner/tool-disclosure.d.ts +10 -12
- package/dist/core/runner/tool-disclosure.js +3 -4
- package/dist/core/runner/tool-end-body.d.ts +1 -1
- package/dist/core/runner/tool-end-body.js +10 -9
- package/dist/core/runner/tool-face-overlay.d.ts +2 -1
- package/dist/core/runner/tool-face-overlay.js +17 -1
- package/dist/core/runner/tool-not-executed.d.ts +5 -0
- package/dist/core/runner/tool-not-executed.js +11 -0
- package/dist/core/runner/tool-occurrence.d.ts +8 -0
- package/dist/core/runner/tool-occurrence.js +7 -0
- package/dist/core/runner/tool-progress-lane.d.ts +2 -2
- package/dist/core/runner/tool-turn-repair-seat.d.ts +3 -2
- package/dist/core/runner/turn-attachments.d.ts +91 -80
- package/dist/core/runner/turn-attachments.js +62 -37
- package/dist/core/runner-deps.d.ts +42 -42
- package/dist/core/runtime-caps.d.ts +4 -4
- package/dist/core/safety-axis-vocab.d.ts +6 -4
- package/dist/core/safety-axis-vocab.js +6 -5
- package/dist/core/safety-merge-corpus.js +26 -2
- package/dist/core/same-plain-value.d.ts +40 -0
- package/dist/core/same-plain-value.js +49 -0
- package/dist/core/scheduler.d.ts +1 -1
- package/dist/core/secret-env.d.ts +26 -3
- package/dist/core/secret-env.js +44 -8
- package/dist/core/select-model.js +3 -3
- package/dist/core/sensitive-path-policy.d.ts +1 -1
- package/dist/core/sensitive-path-policy.js +1 -1
- package/dist/core/session-policy-store.d.ts +102 -35
- package/dist/core/session-policy-store.js +210 -48
- package/dist/core/session-reconcile.d.ts +2 -2
- package/dist/core/session-store.d.ts +106 -37
- package/dist/core/session-store.js +165 -91
- package/dist/core/session.d.ts +101 -57
- package/dist/core/session.js +53 -0
- package/dist/core/shared-memory/tools.js +3 -1
- package/dist/core/shared-memory/types.d.ts +1 -1
- package/dist/core/shell-read-silence.d.ts +11 -12
- package/dist/core/shell-read-silence.js +9 -5
- package/dist/core/shell-run-candidates.js +3 -1
- package/dist/core/shell-wrapper-projection.js +1 -1
- package/dist/core/shell-wrapper-table.d.ts +14 -7
- package/dist/core/shell-wrapper-table.js +5 -4
- package/dist/core/side-query.d.ts +10 -0
- package/dist/core/side-query.js +15 -1
- package/dist/core/skill-grant.d.ts +7 -2
- package/dist/core/skill-grant.js +5 -0
- package/dist/core/skills-directory.js +6 -2
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +11 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +168 -3
- package/dist/core/store-contracts/file-history-store-contract.js +74 -4
- package/dist/core/store-contracts/peer-directory-contract.d.ts +7 -2
- package/dist/core/store-contracts/peer-directory-contract.js +14 -2
- package/dist/core/store-contracts/session-policy-store-contract.d.ts +7 -0
- package/dist/core/store-contracts/session-policy-store-contract.js +130 -0
- package/dist/core/store-contracts/session-repo-contract.js +176 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +6 -8
- package/dist/core/store-contracts/session-store-contract.js +361 -51
- package/dist/core/store-contracts/workflow-journal-store-contract.js +26 -1
- package/dist/core/stub-env.d.ts +2 -0
- package/dist/core/stub-env.js +1 -0
- package/dist/core/surrogate-safe-slice.d.ts +3 -3
- package/dist/core/synthetic-read-verdict.js +3 -3
- package/dist/core/task-event.d.ts +42 -8
- package/dist/core/task-notification.d.ts +19 -15
- package/dist/core/task-registry-agent.d.ts +4 -4
- package/dist/core/task-registry-shared.d.ts +4 -4
- package/dist/core/task-registry-shared.js +1 -0
- package/dist/core/task-registry.d.ts +13 -4
- package/dist/core/task-registry.js +14 -2
- package/dist/core/task-result.d.ts +21 -3
- package/dist/core/task-spec.d.ts +69 -64
- package/dist/core/task-stream.d.ts +6 -6
- package/dist/core/task-tool-shape.d.ts +4 -4
- package/dist/core/tighten-task-spec.d.ts +1 -1
- package/dist/core/tighten-task-spec.js +2 -1
- package/dist/core/tool-catalog-entries.d.ts +36 -2
- package/dist/core/tool-catalog-entries.js +69 -43
- package/dist/core/tool-check-reading.d.ts +11 -0
- package/dist/core/tool-check-reading.js +11 -6
- package/dist/core/tool-conformance.js +1 -0
- package/dist/core/tool-errors.d.ts +2 -2
- package/dist/core/tool-face-reader.js +5 -3
- package/dist/core/tool-face.d.ts +21 -2
- package/dist/core/tool-face.js +1 -1
- package/dist/core/tool-model-gate.d.ts +5 -5
- package/dist/core/tool-name-aliases.d.ts +29 -8
- package/dist/core/tool-name-aliases.js +22 -4
- package/dist/core/tool-name-readings.d.ts +10 -43
- package/dist/core/tool-name-readings.js +2 -11
- package/dist/core/tool-policy.d.ts +85 -196
- package/dist/core/tool-policy.js +150 -175
- package/dist/core/tool-registry.d.ts +14 -7
- package/dist/core/tool-registry.js +17 -7
- package/dist/core/tool-result-store.js +5 -1
- package/dist/core/tool-roster.d.ts +57 -33
- package/dist/core/tool-roster.js +56 -68
- package/dist/core/tool-spec-members.js +8 -3
- package/dist/core/tool-spec.d.ts +53 -31
- package/dist/core/tools.js +51 -10
- package/dist/core/trace.d.ts +6 -2
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +1 -1
- package/dist/core/untrusted-text.d.ts +1 -1
- package/dist/core/user-attachment.d.ts +8 -1
- package/dist/core/user-attachment.js +64 -4
- package/dist/core/warm-resume.d.ts +1 -1
- package/dist/core/wiring-manifest.d.ts +58 -0
- package/dist/core/wiring-manifest.js +14 -5
- package/dist/core/workflow-journal-store.d.ts +62 -0
- package/dist/core/workflow-journal-store.js +78 -2
- package/dist/core/workflow-run-store.d.ts +6 -0
- package/dist/core/workflow-run-store.js +2 -0
- package/dist/engine/compaction/compaction.d.ts +9 -9
- package/dist/engine/compaction/compaction.js +3 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +26 -8
- package/dist/engine/execution-env/node-execution-env.js +54 -24
- package/dist/engine/harness/agent-harness.d.ts +39 -9
- package/dist/engine/harness/agent-harness.js +87 -33
- package/dist/engine/harness/types.d.ts +58 -9
- package/dist/engine/harness/types.js +12 -1
- package/dist/engine/llm/types.d.ts +36 -19
- package/dist/engine/llm/validation.d.ts +4 -1
- package/dist/engine/llm/validation.js +13 -1
- package/dist/engine/loop/agent-loop.d.ts +23 -1
- package/dist/engine/loop/agent-loop.js +26 -34
- package/dist/engine/loop/types.d.ts +31 -19
- package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
- package/dist/engine/session/memory-repo.d.ts +18 -12
- package/dist/engine/session/memory-repo.js +24 -9
- package/dist/engine/session/parent-chain-guard.d.ts +3 -2
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/repo-utils.d.ts +32 -3
- package/dist/engine/session/repo-utils.js +50 -5
- package/dist/index.d.ts +47 -23
- package/dist/index.js +35 -17
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +3 -3
- package/dist/internal/harness.js +2 -2
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/goal.js +2 -2
- package/dist/orchestration/run-workflow-tool.d.ts +8 -6
- package/dist/orchestration/run-workflow-tool.js +10 -6
- package/dist/orchestration/workflow-size-guideline.d.ts +4 -4
- package/dist/orchestration/workflow-types.d.ts +18 -0
- package/dist/orchestration/workflow-types.js +6 -0
- package/dist/orchestration/workflow.d.ts +5 -13
- package/dist/orchestration/workflow.js +57 -49
- package/dist/prompt-assembly/artifact.d.ts +2 -2
- package/dist/prompt-assembly/artifact.js +5 -3
- package/dist/prompt-assembly/assemble.d.ts +3 -2
- package/dist/prompt-assembly/assemble.js +1 -1
- package/dist/prompt-assembly/catalog/schema.d.ts +43 -12
- package/dist/prompt-assembly/catalog/schema.js +34 -2
- package/dist/prompt-assembly/catalog/sections.js +0 -1
- package/dist/prompt-assembly/composer.d.ts +3 -1
- package/dist/prompt-assembly/composer.js +1 -1
- package/dist/prompt-assembly/event-registry.js +2 -0
- package/dist/prompt-assembly/overlay.js +3 -3
- package/dist/prompt-assembly/renderers.d.ts +1 -1
- package/dist/prompt-assembly/renderers.js +0 -3
- package/dist/prompt-assembly/role-base.d.ts +15 -0
- package/dist/prompt-assembly/role-base.js +9 -0
- package/dist/prompt-assembly/select.d.ts +39 -14
- package/dist/prompt-assembly/select.js +47 -16
- package/dist/prompt-assembly/sugar.d.ts +17 -11
- package/dist/prompt-assembly/sugar.js +8 -3
- package/dist/prompt-assembly/tool-catalog.d.ts +39 -2
- package/dist/prompt-assembly/tool-catalog.js +117 -4
- package/dist/prompt-assembly/turn-snapshot.d.ts +4 -10
- package/dist/prompt-assembly/turn-snapshot.js +0 -3
- package/dist/prompt-assembly/types.d.ts +0 -7
- package/dist/prompts/default.d.ts +14 -14
- package/dist/scenarios/full-body.d.ts +15 -15
- package/dist/scenarios/full-body.js +4 -3
- package/dist/shell/lex.js +10 -1
- package/dist/stores/file/adoption/adopt.d.ts +4 -3
- package/dist/stores/file/adoption/adopt.js +27 -33
- package/dist/stores/file/adoption/marker.d.ts +6 -13
- package/dist/stores/file/adoption/marker.js +9 -17
- package/dist/stores/file/checkpoint-store.d.ts +24 -0
- package/dist/stores/file/checkpoint-store.js +45 -7
- package/dist/stores/file/file-history-store.d.ts +20 -19
- package/dist/stores/file/file-history-store.js +157 -141
- package/dist/stores/file/fs-atomic.d.ts +15 -0
- package/dist/stores/file/fs-atomic.js +89 -14
- package/dist/stores/file/index.d.ts +1 -1
- package/dist/stores/file/index.js +2 -1
- package/dist/stores/file/mailbox-store.d.ts +3 -0
- package/dist/stores/file/mailbox-store.js +3 -1
- package/dist/stores/file/permission-rule-adopt.d.ts +1 -1
- package/dist/stores/file/permission-rule-adopt.js +18 -18
- package/dist/stores/file/permission-rule-store.d.ts +18 -2
- package/dist/stores/file/permission-rule-store.js +31 -18
- package/dist/stores/file/session-policy-store.d.ts +3 -3
- package/dist/stores/file/session-store.d.ts +54 -16
- package/dist/stores/file/session-store.js +114 -85
- package/dist/stores/file/workflow-journal-store.d.ts +10 -4
- package/dist/stores/file/workflow-journal-store.js +28 -13
- package/dist/tools/artifact/artifact-text.d.ts +1 -1
- package/dist/tools/artifact/artifact-tool.js +5 -3
- package/dist/tools/fs/bash-program-position.d.ts +19 -2
- package/dist/tools/fs/bash-program-position.js +56 -9
- package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -3
- package/dist/tools/fs/fs-bash.d.ts +2 -2
- package/dist/tools/fs/fs-bash.js +8 -6
- package/dist/tools/fs/fs-glob.d.ts +86 -0
- package/dist/tools/fs/fs-glob.js +226 -0
- package/dist/tools/fs/fs-read.js +14 -14
- package/dist/tools/fs/fs-search-tools.js +7 -7
- package/dist/tools/fs/fs-shared.d.ts +8 -8
- package/dist/tools/fs/gh-rate-limit.d.ts +1 -1
- package/dist/tools/fs/notebook.d.ts +2 -2
- package/dist/tools/fs/pattern-kill-guard.d.ts +22 -0
- package/dist/tools/fs/pattern-kill-guard.js +397 -0
- package/dist/tools/fs/pdf.d.ts +9 -6
- package/dist/tools/fs/pdf.js +3 -3
- package/dist/tools/fs/program-read-model.d.ts +57 -7
- package/dist/tools/fs/program-read-model.js +11 -1
- package/dist/tools/fs/program-read-model.rows.js +78 -21
- package/dist/tools/fs/read-deny-home.js +3 -2
- package/dist/tools/fs/read-deny.d.ts +29 -7
- package/dist/tools/fs/read-deny.js +63 -22
- package/dist/tools/fs/removal-targets.d.ts +18 -8
- package/dist/tools/fs/removal-targets.js +47 -20
- package/dist/tools/fs/safety.d.ts +9 -9
- package/dist/tools/fs/search.d.ts +16 -6
- package/dist/tools/fs/search.js +20 -26
- package/dist/tools/fs/shell-read-argv.js +89 -12
- package/dist/tools/fs/shell-read-bindings.d.ts +31 -0
- package/dist/tools/fs/shell-read-bindings.js +41 -0
- package/dist/tools/fs/shell-read-check.js +12 -20
- package/dist/tools/fs/shell-read-environment.d.ts +5 -1
- package/dist/tools/fs/shell-read-environment.js +3 -2
- package/dist/tools/fs/shell-read-establish.d.ts +15 -0
- package/dist/tools/fs/shell-read-establish.js +19 -20
- package/dist/tools/fs/shell-read-judge.d.ts +4 -0
- package/dist/tools/fs/shell-read-judge.js +5 -2
- package/dist/tools/fs/shell-read-plan.js +24 -16
- package/dist/tools/fs/shell-read-start.d.ts +6 -1
- package/dist/tools/fs/shell-read-write-targets.d.ts +5 -1
- package/dist/tools/fs/shell-read-write-targets.js +2 -3
- package/dist/tools/fs/shell-reentry-text.d.ts +9 -0
- package/dist/tools/fs/shell-reentry-text.js +40 -2
- package/dist/tools/loop-tick.d.ts +2 -2
- package/dist/tools/scheduler-tools.js +5 -1
- package/dist/tools/task-list.d.ts +7 -7
- package/dist/tools/task-list.js +5 -1
- package/dist/tools/todo.js +65 -64
- package/dist/tools/web.d.ts +20 -15
- package/dist/tools/web.js +55 -69
- package/dist/tools/worktree.d.ts +3 -3
- package/dist/tools/worktree.js +3 -1
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +5894 -5638
- package/wire-changes/core@7.55.0.json +3318 -0
- package/wire-changes/core@7.56.0.json +3891 -0
- package/wire-changes/mods-kernel@7.56.0.json +303 -0
- package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +0 -39
- package/dist/core/store-contracts/session-store-incarnation-contract.js +0 -95
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isPlainRecord } from "./mods/kernel/receive.js";
|
|
2
|
+
import { principalNameOf } from "./principal-name.js";
|
|
3
|
+
export const RULE_OWNER_KINDS = Object.freeze(["principal", "local-owner"]);
|
|
4
|
+
export function sameRuleOwner(a, b) {
|
|
5
|
+
return a.kind === "principal" ? b.kind === "principal" && a.principal === b.principal : b.kind === "local-owner";
|
|
6
|
+
}
|
|
7
|
+
export function readRuleOwner(raw) {
|
|
8
|
+
if (!isPlainRecord(raw))
|
|
9
|
+
return undefined;
|
|
10
|
+
const kind = raw.kind;
|
|
11
|
+
const word = RULE_OWNER_KINDS.find((k) => k === kind);
|
|
12
|
+
if (word === undefined)
|
|
13
|
+
return undefined;
|
|
14
|
+
switch (word) {
|
|
15
|
+
case "local-owner":
|
|
16
|
+
return { kind: "local-owner" };
|
|
17
|
+
case "principal": {
|
|
18
|
+
const principal = principalNameOf(raw.principal);
|
|
19
|
+
return principal === undefined ? undefined : { kind: "principal", principal };
|
|
20
|
+
}
|
|
21
|
+
default: {
|
|
22
|
+
const unhandled = word;
|
|
23
|
+
return unhandled;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function ruleOwnerText(owner) {
|
|
28
|
+
return owner.kind === "principal" ? `principal "${owner.principal}"` : "the local owner";
|
|
29
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The advisor tool's instructions to the model — the reference's text, verbatim — its two short forms (a re-attach after a
|
|
3
|
+
* withdrawal, and the withdrawal), the one transition that says which a leg owes, and the leg's seat for them. The frame is
|
|
4
|
+
* the `advisor_tool` attachment kind: it rides a fresh leg's first request, and a compaction inside a leg that mounts the
|
|
5
|
+
* tool restates the full text right after it lands. Model lane only: no `steering_injected` echo.
|
|
6
|
+
*/
|
|
7
|
+
import type { AnnouncedAdvisorState, AnnouncedListingSnapshotInput } from "../../internal/harness.js";
|
|
8
|
+
import type { PostureFrameRef } from "../auto-mode-directive.js";
|
|
9
|
+
import type { StoredSession } from "../session.js";
|
|
10
|
+
import type { FrameReceiptLedger } from "./contracts.js";
|
|
11
|
+
export declare const ADVISOR_TOOL_INSTRUCTIONS = "# Advisor Tool\n\nYou have access to an `advisor` tool backed by a stronger reviewer model. It takes NO parameters -- when you call advisor(), your entire conversation history is automatically forwarded. They see the task, every tool call you've made, every result you've seen.\n\nCall advisor BEFORE substantive work -- before writing, before committing to an interpretation, before building on an assumption. If the task requires orientation first (finding files, fetching a source, seeing what's there), do that, then call advisor. Orientation is not substantive work. Writing, editing, and declaring an answer are.\n\nAlso call advisor:\n- When you believe the task is complete. BEFORE this call, make your deliverable durable: write the file, save the result, commit the change. The advisor call takes time; if the session ends during it, a durable result persists and an unwritten one doesn't.\n- When stuck -- errors recurring, approach not converging, results that don't fit.\n- When considering a change of approach.\n\nOn tasks longer than a few steps, call advisor at least once before committing to an approach and once before declaring done. On short reactive tasks where the next action is dictated by tool output you just read, you don't need to keep calling -- the advisor adds most of its value on the first call, before the approach crystallizes.\n\nGive the advice serious weight. If you follow a step and it fails empirically, or you have primary-source evidence that contradicts a specific claim (the file says X, the paper states Y), adapt. A passing self-test is not evidence the advice is wrong -- it's evidence your test doesn't check what the advice is checking.\n\nIf you've already retrieved data pointing one way and the advisor points another: don't silently switch. Surface the conflict in one more advisor call -- \"I found X, you suggest Y, which constraint breaks the tie?\" The advisor saw your evidence but may have underweighted it; a reconcile call is cheaper than committing to the wrong branch.";
|
|
12
|
+
export declare const ADVISOR_TOOL_ABBREVIATED = "The advisor tool is available; the advisor instructions announced earlier apply.";
|
|
13
|
+
export declare const ADVISOR_TOOL_REMOVED = "The advisor tool is no longer available; disregard the earlier advisor instructions.";
|
|
14
|
+
/** What the model has been told about the advisor in the conversation's current segment (since the latest compaction): the session record's own word. */
|
|
15
|
+
export type AdvisorInstructionState = AnnouncedAdvisorState["state"];
|
|
16
|
+
/**
|
|
17
|
+
* The advisor instructions a leg owes, from what the model was told and whether the tool is mounted now: nothing told and
|
|
18
|
+
* mounted ⇒ the full text; told and not mounted ⇒ the withdrawal; withdrawn and mounted again ⇒ the short re-attach; every
|
|
19
|
+
* other pair owes nothing. `state` is what the model has been told once the frame is delivered.
|
|
20
|
+
*/
|
|
21
|
+
export declare function advisorInstructionFrame(told: AdvisorInstructionState | undefined, mounted: boolean): {
|
|
22
|
+
body: string;
|
|
23
|
+
state: AdvisorInstructionState;
|
|
24
|
+
} | undefined;
|
|
25
|
+
/** A leg's advisor-instructions seat: the frame its first request owes, the segment that was judged in, whether the tool is mounted. */
|
|
26
|
+
export interface AdvisorInstructionSeat {
|
|
27
|
+
owed?: {
|
|
28
|
+
readonly body: string;
|
|
29
|
+
readonly state: AdvisorInstructionState;
|
|
30
|
+
};
|
|
31
|
+
readonly segment: string | null;
|
|
32
|
+
readonly mounted: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** The owed frame as one engine-marked reminder — what a fresh leg's first message and a resumed leg's continuation both
|
|
35
|
+
* carry — or `undefined` when nothing is owed. */
|
|
36
|
+
export declare function advisorFrameText(prepared: {
|
|
37
|
+
readonly advisorInstruction?: AdvisorInstructionSeat;
|
|
38
|
+
readonly reminderMark: string;
|
|
39
|
+
}): string | undefined;
|
|
40
|
+
/** Register the owed frame's receipt on the message that carries it (`text`, the exact first text block): its commit
|
|
41
|
+
* records what the model was told only once that message is in the transcript. Nothing owed ⇒ nothing registered. */
|
|
42
|
+
export declare function registerAdvisorReceipt(prepared: {
|
|
43
|
+
readonly advisorInstruction?: AdvisorInstructionSeat;
|
|
44
|
+
readonly announcedListingsRef: AnnouncedListingSnapshotInput;
|
|
45
|
+
readonly frameReceipts: FrameReceiptLedger;
|
|
46
|
+
}, text: string): void;
|
|
47
|
+
/** The owed frame was delivered (its carrying message is in the transcript): what the model was told is recorded for the
|
|
48
|
+
* segment it was told in, and the snapshot write is parked like every listing commit's. */
|
|
49
|
+
export declare function settleAdvisorInstruction(prepared: {
|
|
50
|
+
readonly advisorInstruction?: AdvisorInstructionSeat;
|
|
51
|
+
readonly announcedListingsRef: AnnouncedListingSnapshotInput;
|
|
52
|
+
readonly frameReceipts: {
|
|
53
|
+
listingSnapshotOwed: boolean;
|
|
54
|
+
};
|
|
55
|
+
}): void;
|
|
56
|
+
/**
|
|
57
|
+
* A compaction landed on a leg that mounts the advisor: the full instructions it summarized away are appended to the
|
|
58
|
+
* transcript as one engine-minted message, before any reader of the new baseline — the posture's compaction rule, halt
|
|
59
|
+
* included (no engine message enters the transcript ahead of a person's next words). The record is left as it was: it names
|
|
60
|
+
* the segment before this compaction, so the next leg tells the model again (a duplicate, never a gap). Never throws.
|
|
61
|
+
*/
|
|
62
|
+
export declare function appendAdvisorRestate(prepared: {
|
|
63
|
+
readonly advisorInstruction?: AdvisorInstructionSeat;
|
|
64
|
+
readonly reminderMark: string;
|
|
65
|
+
readonly session: Pick<StoredSession, "appendMessage">;
|
|
66
|
+
readonly batchHaltRef: {
|
|
67
|
+
readonly current?: unknown;
|
|
68
|
+
};
|
|
69
|
+
readonly postureFrameRef: Pick<PostureFrameRef, "report">;
|
|
70
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { mintSystemReminder } from "../reminder-mint.js";
|
|
2
|
+
import { thrownText } from "../thrown-value.js";
|
|
3
|
+
export const ADVISOR_TOOL_INSTRUCTIONS = `# Advisor Tool
|
|
4
|
+
|
|
5
|
+
You have access to an \`advisor\` tool backed by a stronger reviewer model. It takes NO parameters -- when you call advisor(), your entire conversation history is automatically forwarded. They see the task, every tool call you've made, every result you've seen.
|
|
6
|
+
|
|
7
|
+
Call advisor BEFORE substantive work -- before writing, before committing to an interpretation, before building on an assumption. If the task requires orientation first (finding files, fetching a source, seeing what's there), do that, then call advisor. Orientation is not substantive work. Writing, editing, and declaring an answer are.
|
|
8
|
+
|
|
9
|
+
Also call advisor:
|
|
10
|
+
- When you believe the task is complete. BEFORE this call, make your deliverable durable: write the file, save the result, commit the change. The advisor call takes time; if the session ends during it, a durable result persists and an unwritten one doesn't.
|
|
11
|
+
- When stuck -- errors recurring, approach not converging, results that don't fit.
|
|
12
|
+
- When considering a change of approach.
|
|
13
|
+
|
|
14
|
+
On tasks longer than a few steps, call advisor at least once before committing to an approach and once before declaring done. On short reactive tasks where the next action is dictated by tool output you just read, you don't need to keep calling -- the advisor adds most of its value on the first call, before the approach crystallizes.
|
|
15
|
+
|
|
16
|
+
Give the advice serious weight. If you follow a step and it fails empirically, or you have primary-source evidence that contradicts a specific claim (the file says X, the paper states Y), adapt. A passing self-test is not evidence the advice is wrong -- it's evidence your test doesn't check what the advice is checking.
|
|
17
|
+
|
|
18
|
+
If you've already retrieved data pointing one way and the advisor points another: don't silently switch. Surface the conflict in one more advisor call -- "I found X, you suggest Y, which constraint breaks the tie?" The advisor saw your evidence but may have underweighted it; a reconcile call is cheaper than committing to the wrong branch.`;
|
|
19
|
+
export const ADVISOR_TOOL_ABBREVIATED = "The advisor tool is available; the advisor instructions announced earlier apply.";
|
|
20
|
+
export const ADVISOR_TOOL_REMOVED = "The advisor tool is no longer available; disregard the earlier advisor instructions.";
|
|
21
|
+
export function advisorInstructionFrame(told, mounted) {
|
|
22
|
+
if (mounted && told === undefined)
|
|
23
|
+
return { body: ADVISOR_TOOL_INSTRUCTIONS, state: "announced" };
|
|
24
|
+
if (mounted && told === "withdrawn")
|
|
25
|
+
return { body: ADVISOR_TOOL_ABBREVIATED, state: "announced" };
|
|
26
|
+
if (!mounted && told === "announced")
|
|
27
|
+
return { body: ADVISOR_TOOL_REMOVED, state: "withdrawn" };
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
export function advisorFrameText(prepared) {
|
|
31
|
+
const owed = prepared.advisorInstruction?.owed;
|
|
32
|
+
return owed === undefined ? undefined : mintSystemReminder(owed.body, prepared.reminderMark);
|
|
33
|
+
}
|
|
34
|
+
export function registerAdvisorReceipt(prepared, text) {
|
|
35
|
+
if (prepared.advisorInstruction?.owed !== undefined)
|
|
36
|
+
prepared.frameReceipts.pending.push({ source: "advisor_tool", text, commit: () => settleAdvisorInstruction(prepared) });
|
|
37
|
+
}
|
|
38
|
+
export function settleAdvisorInstruction(prepared) {
|
|
39
|
+
const seat = prepared.advisorInstruction;
|
|
40
|
+
const owed = seat?.owed;
|
|
41
|
+
if (seat === undefined || owed === undefined)
|
|
42
|
+
return;
|
|
43
|
+
seat.owed = undefined;
|
|
44
|
+
prepared.announcedListingsRef.advisor = { state: owed.state, segment: seat.segment };
|
|
45
|
+
prepared.frameReceipts.listingSnapshotOwed = true;
|
|
46
|
+
}
|
|
47
|
+
export async function appendAdvisorRestate(prepared) {
|
|
48
|
+
if (prepared.advisorInstruction?.mounted !== true || prepared.batchHaltRef.current !== undefined)
|
|
49
|
+
return;
|
|
50
|
+
const text = mintSystemReminder(ADVISOR_TOOL_INSTRUCTIONS, prepared.reminderMark);
|
|
51
|
+
try {
|
|
52
|
+
await prepared.session.appendMessage({ role: "user", content: [{ type: "text", text }], timestamp: Date.now(), engineMinted: true });
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
try {
|
|
56
|
+
prepared.postureFrameRef.report?.(new Error(`the advisor instructions could not be restated after compaction (the next leg states them): ${thrownText(err)}`));
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AgentTool, SessionTreeEntry } from "../../internal/harness-types.js";
|
|
2
|
+
import type { Model } from "../../internal/llm.js";
|
|
3
|
+
import { type AdvisorFailure, type AdvisorOutcome } from "../advisor-verdict.js";
|
|
4
|
+
import type { CompactionForkContext } from "../auto-compaction.js";
|
|
5
|
+
import { type SideQueryResult } from "../side-query.js";
|
|
6
|
+
import type { Brain, TaskSpec } from "../types.js";
|
|
7
|
+
/** The advisor's own system prompt (the agent's system prompt follows it, marked as context). */
|
|
8
|
+
export declare const ADVISOR_SYSTEM_PROMPT = "You are the advisor: a stronger reviewer model consulted by an agent in the middle of its task. Above is the agent's conversation as it stood in the agent's last request \u2014 its task, every tool call it made and every result it saw \u2014 ending at the point where it asked for advice.\n\nReply in plain text only. Do not call tools: any tool call you make is discarded and counts as no answer. Be concrete and short: name the decision the agent is facing, say what you would do and why, point at the specific evidence in the conversation that supports it, and flag anything the agent has assumed without checking. If the agent asked before declaring the task done, review the deliverable against the task as stated and list what is missing or wrong. If something you need is not in the conversation, say what is missing and what the agent should check first \u2014 that is still guidance.";
|
|
9
|
+
/** The closing result the projection ends on: the asking call is answered, so both wire protocols take the list. */
|
|
10
|
+
export declare const ADVISOR_HANDOFF = "You are the advisor now. Review everything above and reply with your guidance.";
|
|
11
|
+
/** Everything one leg's advisor needs: the advisor model, the lane's accounted brain, and the leg's own readers. */
|
|
12
|
+
export interface AdvisorSeat {
|
|
13
|
+
readonly model: Model;
|
|
14
|
+
readonly brain: Brain;
|
|
15
|
+
/** The request the main lane last sent on this leg (the engine-level context, before provider serialization). */
|
|
16
|
+
readonly lastSentRequest: () => CompactionForkContext | undefined;
|
|
17
|
+
readonly readBranch: () => Promise<ReadonlyArray<SessionTreeEntry>>;
|
|
18
|
+
readonly getApiKeyAndHeaders: TaskSpec["getApiKeyAndHeaders"];
|
|
19
|
+
/** Marks the run's totals a lower bound: a thrown request spent an amount nobody learned. */
|
|
20
|
+
readonly markUsageUnknown: () => void;
|
|
21
|
+
}
|
|
22
|
+
/** The `tool_end.structured` card of one advisor call. */
|
|
23
|
+
export interface AdvisorCard extends AdvisorFailure {
|
|
24
|
+
readonly type: "advisor";
|
|
25
|
+
readonly outcome: AdvisorOutcome;
|
|
26
|
+
readonly model: string;
|
|
27
|
+
readonly servedModel?: string;
|
|
28
|
+
readonly stopReason?: string;
|
|
29
|
+
readonly hold?: true;
|
|
30
|
+
readonly usage?: SideQueryResult["usage"];
|
|
31
|
+
}
|
|
32
|
+
/** The leg's `advisor` tool over its seat; its label is the advisor model's id (it rides `tool_start` / `tool_end`). */
|
|
33
|
+
export declare function createAdvisorTool(seat: AdvisorSeat): AgentTool;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { stripErrorCodePrefix, thrownBrainFailure } from "../../brain/errors.js";
|
|
3
|
+
import { ADVISOR_TOOL_NAME, advisorFailureHolds, advisorHoldOf } from "../advisor-verdict.js";
|
|
4
|
+
import { runSideQuery } from "../side-query.js";
|
|
5
|
+
import { thrownText } from "../thrown-value.js";
|
|
6
|
+
import { defineTool } from "../tools.js";
|
|
7
|
+
import { mountRuleFace, toolFace } from "../tool-catalog-entries.js";
|
|
8
|
+
import { egressText } from "../untrusted-egress.js";
|
|
9
|
+
const ADVISOR_MESSAGE_MAX_CHARS = 2_000;
|
|
10
|
+
export const ADVISOR_SYSTEM_PROMPT = `You are the advisor: a stronger reviewer model consulted by an agent in the middle of its task. Above is the agent's conversation as it stood in the agent's last request — its task, every tool call it made and every result it saw — ending at the point where it asked for advice.
|
|
11
|
+
|
|
12
|
+
Reply in plain text only. Do not call tools: any tool call you make is discarded and counts as no answer. Be concrete and short: name the decision the agent is facing, say what you would do and why, point at the specific evidence in the conversation that supports it, and flag anything the agent has assumed without checking. If the agent asked before declaring the task done, review the deliverable against the task as stated and list what is missing or wrong. If something you need is not in the conversation, say what is missing and what the agent should check first — that is still guidance.`;
|
|
13
|
+
export const ADVISOR_HANDOFF = "You are the advisor now. Review everything above and reply with your guidance.";
|
|
14
|
+
const AGENT_INSTRUCTIONS_HEADER = "# The agent's instructions (context for you; they bind the agent, not you)";
|
|
15
|
+
const HOLD_SENTENCE = "The advisor is off for this conversation until it is compacted; do not call it again before then.";
|
|
16
|
+
function unavailable(model, failure, message, hold, extra = {}) {
|
|
17
|
+
const cause = failure.errorKind ?? failure.code ?? failure.stopReason;
|
|
18
|
+
const bounded = message !== undefined && message.trim() !== "" ? egressText("same-principal", message).slice(0, ADVISOR_MESSAGE_MAX_CHARS) : undefined;
|
|
19
|
+
const text = [`Advisor unavailable${cause !== undefined ? ` (${cause})` : ""}.`, ...(bounded !== undefined ? [bounded] : []), ...(hold ? [HOLD_SENTENCE] : [])].join(" ");
|
|
20
|
+
const card = {
|
|
21
|
+
type: "advisor",
|
|
22
|
+
outcome: "unavailable",
|
|
23
|
+
model: model.id,
|
|
24
|
+
...extra,
|
|
25
|
+
...(failure.stopReason !== undefined ? { stopReason: failure.stopReason } : {}),
|
|
26
|
+
...(failure.code !== undefined ? { code: failure.code } : {}),
|
|
27
|
+
...(failure.errorKind !== undefined ? { errorKind: failure.errorKind } : {}),
|
|
28
|
+
...(hold ? { hold: true } : {}),
|
|
29
|
+
};
|
|
30
|
+
return { text, card };
|
|
31
|
+
}
|
|
32
|
+
function askingTurn(branch, toolCallId) {
|
|
33
|
+
for (let i = branch.length - 1; i >= 0; i--) {
|
|
34
|
+
const e = branch[i];
|
|
35
|
+
if (e.type !== "message" || e.message.role !== "assistant")
|
|
36
|
+
continue;
|
|
37
|
+
const m = e.message;
|
|
38
|
+
if (!m.content.some((c) => c.type === "toolCall" && c.id === toolCallId))
|
|
39
|
+
continue;
|
|
40
|
+
return { ...m, content: m.content.filter((c) => c.type !== "toolCall" || c.id === toolCallId) };
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
function projection(sent, turn, toolCallId) {
|
|
45
|
+
const close = { role: "toolResult", toolCallId, toolName: ADVISOR_TOOL_NAME, content: [{ type: "text", text: ADVISOR_HANDOFF }], isError: false };
|
|
46
|
+
return [...sent.messages, turn, close];
|
|
47
|
+
}
|
|
48
|
+
function systemPromptOf(sent) {
|
|
49
|
+
const sentSystemText = sent.systemPrompt ?? sent.systemBlocks?.map((b) => b.text).join("") ?? "";
|
|
50
|
+
return sentSystemText === "" ? ADVISOR_SYSTEM_PROMPT : `${ADVISOR_SYSTEM_PROMPT}\n\n${AGENT_INSTRUCTIONS_HEADER}\n${sentSystemText}`;
|
|
51
|
+
}
|
|
52
|
+
function outcomeOf(model, r) {
|
|
53
|
+
const served = r.servedModel !== model.id ? { servedModel: r.servedModel } : {};
|
|
54
|
+
const base = { type: "advisor", model: model.id, ...served, stopReason: r.stopReason, usage: r.usage };
|
|
55
|
+
if ((r.stopReason === "stop" || r.stopReason === "length") && r.text.trim() !== "")
|
|
56
|
+
return { text: r.text, card: { ...base, outcome: "reviewed" } };
|
|
57
|
+
if (r.stopReason === "error" && r.errorCode === "refusal") {
|
|
58
|
+
const reason = r.errorMessage !== undefined ? stripErrorCodePrefix(r.errorMessage).trim() : "";
|
|
59
|
+
const bounded = reason !== "" ? egressText("same-principal", reason).slice(0, ADVISOR_MESSAGE_MAX_CHARS) : "";
|
|
60
|
+
return { text: `Advisor declined to advise on this request.${bounded !== "" ? ` Reason: ${bounded}` : ""}`, card: { ...base, outcome: "declined" } };
|
|
61
|
+
}
|
|
62
|
+
const failure = { ...(r.errorCode !== undefined ? { code: r.errorCode } : {}), ...(r.errorKind !== undefined ? { errorKind: r.errorKind } : {}), ...(r.inputTooLongRuledOut === true ? { inputTooLongRuledOut: true } : {}) };
|
|
63
|
+
const message = r.stopReason === "toolUse" ? "the advisor model answered with a tool call instead of guidance" : r.stopReason === "error" || r.stopReason === "aborted" ? (r.errorMessage !== undefined ? stripErrorCodePrefix(r.errorMessage) : undefined) : "the advisor model returned no guidance";
|
|
64
|
+
return unavailable(model, { ...failure, stopReason: r.stopReason }, message, advisorFailureHolds(failure), { ...served, usage: r.usage });
|
|
65
|
+
}
|
|
66
|
+
async function consult(seat, toolCallId, signal) {
|
|
67
|
+
const model = seat.model;
|
|
68
|
+
let branch;
|
|
69
|
+
try {
|
|
70
|
+
branch = await seat.readBranch();
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return unavailable(model, {}, "the advisor's availability for this conversation could not be read; try again later", false);
|
|
74
|
+
}
|
|
75
|
+
const held = advisorHoldOf(branch);
|
|
76
|
+
if (held !== undefined)
|
|
77
|
+
return unavailable(model, held, undefined, true);
|
|
78
|
+
const sent = seat.lastSentRequest();
|
|
79
|
+
if (sent === undefined)
|
|
80
|
+
return unavailable(model, {}, "no request has been sent to the model on this resumed run yet; call advisor again", false);
|
|
81
|
+
const turn = askingTurn(branch, toolCallId) ?? { role: "assistant", content: [{ type: "toolCall", id: toolCallId, name: ADVISOR_TOOL_NAME, arguments: {} }] };
|
|
82
|
+
try {
|
|
83
|
+
const r = await runSideQuery({
|
|
84
|
+
model,
|
|
85
|
+
systemPrompt: systemPromptOf(sent),
|
|
86
|
+
messages: projection(sent, turn, toolCallId),
|
|
87
|
+
...(sent.tools !== undefined && sent.tools.length > 0 ? { tools: sent.tools.map((t) => ({ name: t.name, description: t.description, parameters: t.parameters })) } : {}),
|
|
88
|
+
...(signal !== undefined ? { signal } : {}),
|
|
89
|
+
...(seat.getApiKeyAndHeaders !== undefined ? { getApiKeyAndHeaders: seat.getApiKeyAndHeaders } : {}),
|
|
90
|
+
}, { brain: seat.brain });
|
|
91
|
+
return outcomeOf(model, r);
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
seat.markUsageUnknown();
|
|
95
|
+
const failure = thrownBrainFailure(e);
|
|
96
|
+
return unavailable(model, { ...failure, stopReason: "error" }, stripErrorCodePrefix(thrownText(e)), advisorFailureHolds(failure));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export function createAdvisorTool(seat) {
|
|
100
|
+
return defineTool({
|
|
101
|
+
name: ADVISOR_TOOL_NAME,
|
|
102
|
+
...toolFace("advisor"),
|
|
103
|
+
ruleFace: mountRuleFace("advisor"),
|
|
104
|
+
label: seat.model.id,
|
|
105
|
+
description: "Consult the advisor: a stronger reviewer model reads this conversation and returns guidance. Takes no parameters.",
|
|
106
|
+
parameters: Type.Object({}),
|
|
107
|
+
execute: async (_args, ctx) => {
|
|
108
|
+
const { text, card } = await consult(seat, ctx.toolCallId, ctx.signal);
|
|
109
|
+
return { content: text, details: card, isError: card.outcome === "unavailable" };
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AnnouncedListingSnapshot, AnnouncedListingSnapshotInput, AnnouncedMcpFailure } from "../../internal/harness.js";
|
|
2
|
-
import type {
|
|
3
|
-
import type { AnnounceOnceSink, DateAnchorRead } from "./contracts.js";
|
|
2
|
+
import type { AnnounceOnceSink } from "./contracts.js";
|
|
4
3
|
import type { McpDroppedTool, McpServerStatus } from "../mcp.js";
|
|
5
4
|
import type { RunnerDeps } from "../types.js";
|
|
6
5
|
/** Upper bound on the advisory-digest arm kept in the record (oldest dropped past it). A digest is
|
|
@@ -69,6 +68,20 @@ export declare function flushOwedAnnouncedSnapshot(prepared: {
|
|
|
69
68
|
announcedListingsRef: AnnouncedListingSnapshotInput;
|
|
70
69
|
session: Pick<AnnounceOnceSession, "appendAnnouncedListing">;
|
|
71
70
|
}): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* The one commit of a delivered `mcp_unavailable` frame — the receipt of the message that carried it (a leg's first request), run
|
|
73
|
+
* inside the `message_end` walk: the delivered pairs leave the pending list and join the session's told-failure record, whose
|
|
74
|
+
* snapshot write is parked for the next serialization point. The next prepare on the session announces only what the record lacks.
|
|
75
|
+
*/
|
|
76
|
+
export declare function settleMcpUnavailable(prepared: {
|
|
77
|
+
readonly mcpUnavailable?: {
|
|
78
|
+
pending: AnnouncedMcpFailure[];
|
|
79
|
+
};
|
|
80
|
+
readonly announcedListingsRef: AnnouncedListingSnapshotInput;
|
|
81
|
+
readonly frameReceipts: {
|
|
82
|
+
listingSnapshotOwed: boolean;
|
|
83
|
+
};
|
|
84
|
+
}, delivered: ReadonlyArray<AnnouncedMcpFailure>): void;
|
|
72
85
|
/** The run-local ledger — see the module header for the two commit disciplines it serves. */
|
|
73
86
|
export interface AnnounceOnceLedger {
|
|
74
87
|
/** The nearest announced snapshot on the branch as read at prepare (undefined = pre-entry
|
|
@@ -85,6 +98,9 @@ export interface AnnounceOnceLedger {
|
|
|
85
98
|
* the record is dropped; a new one is forwarded to `deps.onError` and recorded. With no sink wired
|
|
86
99
|
* nothing is recorded either — "announced" means delivered. Same signature as `RunnerDeps.onError`. */
|
|
87
100
|
onError: NonNullable<RunnerDeps["onError"]>;
|
|
101
|
+
/** The record's one dedupe verb, for any announcement of a session fact: `deliver` runs unless `digest` is already in the
|
|
102
|
+
* record, and the digest is recorded once it ran ({@link onError} is this verb over the operator sink). */
|
|
103
|
+
oncePerSession(digest: string, deliver: () => void): void;
|
|
88
104
|
/** The operator-lane sink for a DEPLOYMENT fact (see {@link AnnounceOnceSink.onErrorOncePerRunner}): the same
|
|
89
105
|
* `(code, message)` digest, judged against what THIS RUNNER's sink has already been told rather than against
|
|
90
106
|
* the session's record. Writes no digest into the record and owes the transcript nothing. */
|
|
@@ -127,28 +143,4 @@ export declare function loadAnnounceOnceLedger(session: AnnounceOnceSession, che
|
|
|
127
143
|
* present-only arms, copied; `undefined` when nothing was announced on any face (the resume seed
|
|
128
144
|
* then falls to the lower rungs — unchanged contract). */
|
|
129
145
|
export declare function serializeAnnouncedListings(ref: AnnouncedListingSnapshotInput): AnnouncedListingSnapshot | undefined;
|
|
130
|
-
/** The custom-entry kind that carries the session's date anchor (engine-owned; never model-visible). */
|
|
131
|
-
export declare const DATE_ANCHOR_CUSTOM_TYPE = "engine:date-anchor";
|
|
132
|
-
/**
|
|
133
|
-
* Read the session's date anchor off the active branch: the nearest anchor entry NEWER than the nearest
|
|
134
|
-
* compaction, honored only when it was written for that same segment. An anchor written by a leg whose
|
|
135
|
-
* prefix predates a compaction that landed in between therefore reads as absent — the one rule that makes a
|
|
136
|
-
* compaction re-anchor the date. An unreadable branch returns undefined (the leg renders today, writes nothing).
|
|
137
|
-
*/
|
|
138
|
-
export declare function readDateAnchor(session: {
|
|
139
|
-
getBranch(): Promise<ReadonlyArray<SessionTreeEntry>>;
|
|
140
|
-
}): Promise<DateAnchorRead | undefined>;
|
|
141
|
-
/**
|
|
142
|
-
* The anchor write a leg owes when it settles, or undefined: owed when prepare found no anchor for the segment
|
|
143
|
-
* (the leg rendered today) or the model has since been told a newer date; never after an unreadable branch.
|
|
144
|
-
* Best-effort — a lost write costs one re-rendered prefix or one repeated reminder next leg, never a wrong date.
|
|
145
|
-
*/
|
|
146
|
-
export declare function owedDateAnchor(session: {
|
|
147
|
-
appendCustomEntry(customType: string, data?: unknown): Promise<string>;
|
|
148
|
-
}, seat: {
|
|
149
|
-
legDate: string;
|
|
150
|
-
anchor: DateAnchorRead | undefined;
|
|
151
|
-
} | undefined, state: {
|
|
152
|
-
announcedDate: string;
|
|
153
|
-
} | undefined): (() => Promise<void>) | undefined;
|
|
154
146
|
export {};
|
|
@@ -47,30 +47,37 @@ export async function flushOwedAnnouncedSnapshot(prepared) {
|
|
|
47
47
|
return;
|
|
48
48
|
await prepared.session.appendAnnouncedListing(prepared.announcedListingsRef).catch(() => undefined);
|
|
49
49
|
}
|
|
50
|
+
export function settleMcpUnavailable(prepared, delivered) {
|
|
51
|
+
prepared.mcpUnavailable?.pending.splice(0, delivered.length);
|
|
52
|
+
prepared.announcedListingsRef.mcpFailed = [...(prepared.announcedListingsRef.mcpFailed ?? []), ...delivered];
|
|
53
|
+
prepared.frameReceipts.listingSnapshotOwed = true;
|
|
54
|
+
}
|
|
50
55
|
export async function loadAnnounceOnceLedger(session, checkpointMirror, onError) {
|
|
51
56
|
let recovered = true;
|
|
52
57
|
const entry = await session.getAnnouncedListing().catch(() => {
|
|
53
58
|
recovered = false;
|
|
54
59
|
return undefined;
|
|
55
60
|
});
|
|
56
|
-
const seed = checkpointMirror?.mcpFailed !== undefined || checkpointMirror?.advisories !== undefined ? checkpointMirror : entry;
|
|
61
|
+
const seed = checkpointMirror?.mcpFailed !== undefined || checkpointMirror?.advisories !== undefined || checkpointMirror?.advisor !== undefined ? checkpointMirror : entry;
|
|
57
62
|
const listingSrc = checkpointMirror?.agents !== undefined || checkpointMirror?.skills !== undefined || checkpointMirror?.models !== undefined ? checkpointMirror : entry;
|
|
58
63
|
let mcpFailed = (seed?.mcpFailed ?? []).map((f) => ({ ...f }));
|
|
59
64
|
const advisories = new Set(seed?.advisories ?? []);
|
|
60
65
|
let dirty = false;
|
|
66
|
+
const oncePerSession = (digest, deliver) => {
|
|
67
|
+
if (advisories.has(digest))
|
|
68
|
+
return;
|
|
69
|
+
deliver();
|
|
70
|
+
advisories.add(digest);
|
|
71
|
+
dirty = true;
|
|
72
|
+
};
|
|
61
73
|
return {
|
|
62
74
|
entry,
|
|
63
75
|
recovered,
|
|
64
76
|
onError: (err, ctx) => {
|
|
65
|
-
if (onError
|
|
66
|
-
|
|
67
|
-
const digest = warningDigest(err);
|
|
68
|
-
if (advisories.has(digest))
|
|
69
|
-
return;
|
|
70
|
-
onError(err, ctx);
|
|
71
|
-
advisories.add(digest);
|
|
72
|
-
dirty = true;
|
|
77
|
+
if (onError !== undefined)
|
|
78
|
+
oncePerSession(warningDigest(err), () => onError(err, ctx));
|
|
73
79
|
},
|
|
80
|
+
oncePerSession,
|
|
74
81
|
onErrorOncePerRunner: (err, ctx) => {
|
|
75
82
|
if (onError === undefined)
|
|
76
83
|
return;
|
|
@@ -106,6 +113,7 @@ export async function loadAnnounceOnceLedger(session, checkpointMirror, onError)
|
|
|
106
113
|
...(listingSrc?.models !== undefined ? { models: [...listingSrc.models] } : {}),
|
|
107
114
|
...(mcpFailed.length > 0 ? { mcpFailed: mcpFailed.map((f) => ({ ...f })) } : {}),
|
|
108
115
|
...(advisories.size > 0 ? { advisories: withAnnounceDigests(undefined, [...advisories]) } : {}),
|
|
116
|
+
...(seed?.advisor !== undefined ? { advisor: { ...seed.advisor } } : {}),
|
|
109
117
|
}),
|
|
110
118
|
settle: async (s, ref) => {
|
|
111
119
|
if (advisories.size > 0)
|
|
@@ -119,6 +127,7 @@ export async function loadAnnounceOnceLedger(session, checkpointMirror, onError)
|
|
|
119
127
|
...(ref.models !== undefined ? { models: ref.models } : {}),
|
|
120
128
|
...(ref.mcpFailed !== undefined && ref.mcpFailed.length > 0 ? { mcpFailed: ref.mcpFailed } : {}),
|
|
121
129
|
...(ref.advisories !== undefined && ref.advisories.length > 0 ? { advisories: ref.advisories } : {}),
|
|
130
|
+
...(ref.advisor !== undefined ? { advisor: ref.advisor } : {}),
|
|
122
131
|
})
|
|
123
132
|
.catch(() => undefined);
|
|
124
133
|
},
|
|
@@ -131,43 +140,7 @@ export function serializeAnnouncedListings(ref) {
|
|
|
131
140
|
...(ref.models !== undefined ? { models: [...ref.models] } : {}),
|
|
132
141
|
...(ref.mcpFailed !== undefined ? { mcpFailed: ref.mcpFailed.map((f) => ({ ...f })) } : {}),
|
|
133
142
|
...(ref.advisories !== undefined ? { advisories: [...ref.advisories] } : {}),
|
|
143
|
+
...(ref.advisor !== undefined ? { advisor: { ...ref.advisor } } : {}),
|
|
134
144
|
};
|
|
135
145
|
return Object.keys(out).length > 0 ? out : undefined;
|
|
136
146
|
}
|
|
137
|
-
export const DATE_ANCHOR_CUSTOM_TYPE = "engine:date-anchor";
|
|
138
|
-
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
139
|
-
function normalizeDateAnchor(v) {
|
|
140
|
-
if (typeof v !== "object" || v === null)
|
|
141
|
-
return undefined;
|
|
142
|
-
const { prefixDate, announcedDate, segment } = v;
|
|
143
|
-
if (typeof prefixDate !== "string" || !ISO_DATE.test(prefixDate) || typeof announcedDate !== "string" || !ISO_DATE.test(announcedDate))
|
|
144
|
-
return undefined;
|
|
145
|
-
if (segment !== null && (typeof segment !== "string" || segment.length > 200))
|
|
146
|
-
return undefined;
|
|
147
|
-
return { prefixDate, announcedDate, segment };
|
|
148
|
-
}
|
|
149
|
-
export async function readDateAnchor(session) {
|
|
150
|
-
let branch;
|
|
151
|
-
try {
|
|
152
|
-
branch = await session.getBranch();
|
|
153
|
-
}
|
|
154
|
-
catch {
|
|
155
|
-
return undefined;
|
|
156
|
-
}
|
|
157
|
-
let found;
|
|
158
|
-
let i = branch.length - 1;
|
|
159
|
-
for (; i >= 0 && branch[i].type !== "compaction"; i--) {
|
|
160
|
-
const e = branch[i];
|
|
161
|
-
if (found === undefined && e.type === "custom" && e.customType === DATE_ANCHOR_CUSTOM_TYPE)
|
|
162
|
-
found = normalizeDateAnchor(e.data);
|
|
163
|
-
}
|
|
164
|
-
const segment = i >= 0 ? branch[i].id : null;
|
|
165
|
-
return { current: found !== undefined && found.segment === segment ? { prefixDate: found.prefixDate, announcedDate: found.announcedDate } : undefined, segment };
|
|
166
|
-
}
|
|
167
|
-
export function owedDateAnchor(session, seat, state) {
|
|
168
|
-
const read = seat?.anchor;
|
|
169
|
-
if (read === undefined || state === undefined || read.current?.announcedDate === state.announcedDate)
|
|
170
|
-
return undefined;
|
|
171
|
-
const data = { prefixDate: seat.legDate, announcedDate: state.announcedDate, segment: read.segment };
|
|
172
|
-
return () => session.appendCustomEntry(DATE_ANCHOR_CUSTOM_TYPE, data).then(() => undefined, () => undefined);
|
|
173
|
-
}
|
|
@@ -9,16 +9,19 @@ export function refuseUnfitFeedback(twin) {
|
|
|
9
9
|
if (words === undefined)
|
|
10
10
|
return;
|
|
11
11
|
if (twin.decision !== "allow") {
|
|
12
|
-
throw
|
|
12
|
+
throw feedbackRefusal("resume carried `feedback` on a `deny` — feedback is the approving person's words on an `allow` (a denial's words are `reason`); refusing rather than dropping it silently, the checkpoint stays pending");
|
|
13
13
|
}
|
|
14
14
|
const byPerson = twin.hostDecision.decidedBy === "person";
|
|
15
15
|
if (!byPerson) {
|
|
16
|
-
throw
|
|
16
|
+
throw feedbackRefusal(`resume carried \`feedback\` on a decide made by "${twin.hostDecision.decidedBy}" — feedback is delivered to the model as the user's own words, which only a person's decide can be; refusing rather than attributing a machine's text to the user, the checkpoint stays pending`);
|
|
17
17
|
}
|
|
18
18
|
if (sanitizeUntrustedText(words) !== words) {
|
|
19
|
-
throw
|
|
19
|
+
throw feedbackRefusal(sentinelTagRefusal("resume allow feedback"));
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
function feedbackRefusal(message) {
|
|
23
|
+
return new CheckpointError("checkpoint.invalid_outcome", message, { field: "feedback" });
|
|
24
|
+
}
|
|
22
25
|
export function approvalWordsOf(outcome) {
|
|
23
26
|
return outcome.gate === "policy_ask" && outcome.decision === "allow" ? writtenFeedback(outcome.feedback) : undefined;
|
|
24
27
|
}
|
|
@@ -67,7 +67,7 @@ export interface Stats {
|
|
|
67
67
|
* (so it can't be re-derived from `costMicroUsd` alone). The {@link costBreakdown.compactionMicroUsd}
|
|
68
68
|
* source. Run-loop internal — not a public `TaskResult.stats` field. */
|
|
69
69
|
compactionMicroUsd?: number;
|
|
70
|
-
/** The permission classifier's
|
|
70
|
+
/** The permission classifier's, a mod's and the advisor tool's model-call cost (micro-USD), accumulated by `recordSideCallUsage`. Folded
|
|
71
71
|
* into `costMicroUsd` like compaction, but it STAYS inside {@link costBreakdown.llmRootMicroUsd} (an "of which" line,
|
|
72
72
|
* not a partition member). Absent until a call is booked. Run-loop internal — the public figure is
|
|
73
73
|
* `costBreakdown.sideCallMicroUsd`. */
|
|
@@ -148,6 +148,7 @@ export interface ResultFlags {
|
|
|
148
148
|
* ended for its own reason first) leaves this empty: the original terminal stands and the seat is
|
|
149
149
|
* NOT signed (the settle lane mints `task.halt_unconsumed` for it). */
|
|
150
150
|
haltConsumption?: HaltConsumption;
|
|
151
|
+
answerEntryIds?: readonly string[];
|
|
151
152
|
/** Call ids of answered-but-never-collected questions, echoed on
|
|
152
153
|
* `TaskResult.strandedHumanAnswers`. Pure pass-through; empty/absent ⇒ the field is omitted. The
|
|
153
154
|
* optional `onError` alert is NOT the disclosure — this mandatory result face is. */
|
|
@@ -178,5 +178,5 @@ export function assembleResult(spec, sessionId, final, stats, flags) {
|
|
|
178
178
|
if (flags.unpricedSpend)
|
|
179
179
|
delete publicStats.costMicroUsd;
|
|
180
180
|
const stampHaltedByUser = haltConsumed(flags.haltConsumption);
|
|
181
|
-
return { taskId, ...(flags.runId !== undefined ? { runId: flags.runId } : {}), sessionId, terminal, ...(flags.model !== undefined ? { model: flags.model } : {}), ...(responseModel !== undefined ? { responseModel } : {}), result: result.trim(), salvagedOutput, ...(apiFailure !== undefined ? { apiFailure } : {}), ...(retryAfterMs !== undefined ? { retryAfterMs } : {}), ...(flags.rewindNotes !== undefined && flags.rewindNotes.length > 0 ? { rewindNotes: flags.rewindNotes } : {}), ...(flags.editedFiles !== undefined && flags.editedFiles.length > 0 ? { editedFiles: flags.editedFiles } : {}), ...(flags.haltedOnUserRejection === true ? { haltedOnUserRejection: true } : {}), ...(stampHaltedByUser ? { haltedByUser: true } : {}), ...(flags.remoteEnvFailures !== undefined && flags.remoteEnvFailures.length > 0 ? { remoteEnvFailures: [...flags.remoteEnvFailures] } : {}), ...(flags.strandedHumanAnswers !== undefined && flags.strandedHumanAnswers.length > 0 ? { strandedHumanAnswers: flags.strandedHumanAnswers } : {}), ...(flags.effectiveReadFace !== undefined ? { effectiveReadFace: flags.effectiveReadFace } : {}), ...(flags.effectiveWriteFace !== undefined ? { effectiveWriteFace: flags.effectiveWriteFace } : {}), ...(flags.effectiveReadDenyPatterns !== undefined && flags.effectiveReadDenyPatterns.length > 0 ? { effectiveReadDenyPatterns: flags.effectiveReadDenyPatterns } : {}), ...(flags.effectiveMemoryScopes !== undefined ? { effectiveMemoryScopes: flags.effectiveMemoryScopes } : {}), ...(flags.effectiveReasoning !== undefined ? { effectiveReasoning: flags.effectiveReasoning } : {}), ...(flags.compaction !== undefined ? { compaction: flags.compaction } : {}), stats: publicStats };
|
|
181
|
+
return { taskId, ...(flags.runId !== undefined ? { runId: flags.runId } : {}), sessionId, terminal, ...(flags.model !== undefined ? { model: flags.model } : {}), ...(responseModel !== undefined ? { responseModel } : {}), result: result.trim(), ...(flags.answerEntryIds !== undefined ? { resultEntryIds: [...flags.answerEntryIds] } : {}), salvagedOutput, ...(apiFailure !== undefined ? { apiFailure } : {}), ...(retryAfterMs !== undefined ? { retryAfterMs } : {}), ...(flags.rewindNotes !== undefined && flags.rewindNotes.length > 0 ? { rewindNotes: flags.rewindNotes } : {}), ...(flags.editedFiles !== undefined && flags.editedFiles.length > 0 ? { editedFiles: flags.editedFiles } : {}), ...(flags.haltedOnUserRejection === true ? { haltedOnUserRejection: true } : {}), ...(stampHaltedByUser ? { haltedByUser: true } : {}), ...(flags.remoteEnvFailures !== undefined && flags.remoteEnvFailures.length > 0 ? { remoteEnvFailures: [...flags.remoteEnvFailures] } : {}), ...(flags.strandedHumanAnswers !== undefined && flags.strandedHumanAnswers.length > 0 ? { strandedHumanAnswers: flags.strandedHumanAnswers } : {}), ...(flags.effectiveReadFace !== undefined ? { effectiveReadFace: flags.effectiveReadFace } : {}), ...(flags.effectiveWriteFace !== undefined ? { effectiveWriteFace: flags.effectiveWriteFace } : {}), ...(flags.effectiveReadDenyPatterns !== undefined && flags.effectiveReadDenyPatterns.length > 0 ? { effectiveReadDenyPatterns: flags.effectiveReadDenyPatterns } : {}), ...(flags.effectiveMemoryScopes !== undefined ? { effectiveMemoryScopes: flags.effectiveMemoryScopes } : {}), ...(flags.effectiveReasoning !== undefined ? { effectiveReasoning: flags.effectiveReasoning } : {}), ...(flags.compaction !== undefined ? { compaction: flags.compaction } : {}), stats: publicStats };
|
|
182
182
|
}
|
|
@@ -89,8 +89,9 @@ export interface ApprovedCallScreenInput {
|
|
|
89
89
|
* the call (the decide is the upper bound; the screen can only narrow): a deny, a failed or cancelled screening, or a
|
|
90
90
|
* refused answer refuses the call in the live gate's own sentences; an ask is the question the decide already answered —
|
|
91
91
|
* unless it demands a person and the decide was the deployment's policy (the one predicate every resume station holds a
|
|
92
|
-
* decide against); a rewrite
|
|
93
|
-
*
|
|
92
|
+
* decide against); a rewrite comes back as the args — what executes when the decide carried no edit, a refusal of the edit
|
|
93
|
+
* when it did (a person's bytes are the ceiling, rewrite-rejudge.ts); context rides the result. Undefined when no handler hangs
|
|
94
|
+
* on `classic.PreToolUse`.
|
|
94
95
|
*/
|
|
95
96
|
export declare function createApprovedCallScreen(input: ApprovedCallScreenInput): ApprovedCallScreen | undefined;
|
|
96
97
|
/**
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* (string and symbol keys — what the mount's spread carries) plus every ToolSpec member name read through an ordinary
|
|
13
13
|
* property read (how the phases read a declaration — non-enumerable, inherited or Proxy-answered included), each read once;
|
|
14
14
|
* every declaration value is deep-copied and frozen by the one copier. A primitive is immutable and stays as read. A
|
|
15
|
-
* read that throws refuses the run at the snapshot
|
|
15
|
+
* read that throws refuses the run at the snapshot, and so does an entry that carries a retired ToolSpec member under any
|
|
16
|
+
* reading of the key ({@link refuseRetiredMember}: the entry is asked once, before any face is minted). Whether the ToolSpec arm can build the entry ({@link specArmCanConstruct})
|
|
16
17
|
* is asked of the entry once, there, and recorded on its face ({@link specArmCanBuild}); the mount refuses an entry it
|
|
17
18
|
* cannot build from that record, so an `execute` that grows on the caller's object later is never read. The mount calls a
|
|
18
19
|
* spec face's `execute` with the caller's own object as `this` ({@link callerEntryOrigin}). A `defineTool` product's face is
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
import type { AgentTool } from "../../internal/harness.js";
|
|
33
34
|
import type { TaskSpec } from "../types.js";
|
|
34
35
|
import type { ToolSpec } from "../tool-spec.js";
|
|
36
|
+
import type { ToolDeclarationCode } from "../governance-codes.js";
|
|
35
37
|
import { type ToolCtxEnricher } from "../tools.js";
|
|
36
38
|
declare const ROSTER_FACE: unique symbol;
|
|
37
39
|
/** A roster entry as the snapshot minted it. The brand is private to this module and {@link rosterFaceOf} is the only
|
|
@@ -56,10 +58,27 @@ export declare function callerEntryOrigin(entry: object): object;
|
|
|
56
58
|
/** Can the mount's ToolSpec arm build this roster entry? Only the verdict recorded at the snapshot answers: an object that
|
|
57
59
|
* is no face of this snapshot, a primitive, a product's face, is not built from. */
|
|
58
60
|
export declare function specArmCanBuild(entry: RosterFace): boolean;
|
|
61
|
+
/** A roster entry claiming an engine contract its catalog did not mint for it — the id written by hand, on a spec or on a product — refused where the
|
|
62
|
+
* declaration enters. */
|
|
63
|
+
export declare function callerEngineContractProblem(face: RosterFace): {
|
|
64
|
+
code: ToolDeclarationCode;
|
|
65
|
+
message: string;
|
|
66
|
+
} | undefined;
|
|
67
|
+
/** The retired-key door for one roster entry, asked of the LIVE entry once, before any member is copied: the key is present
|
|
68
|
+
* iff ordinary property lookup answers a defined value ({@link retiredKeyOf} — an own enumerable member, a non-enumerable
|
|
69
|
+
* one, a prototype's getter, a Proxy's trap alike), and a present one refuses the run by name with the sentence and code
|
|
70
|
+
* the factory gives the same key on a `defineTool` spec (`config.deps_retired_key`). A lookup that throws is an entry whose
|
|
71
|
+
* members cannot be read, refused as such. No face is ever minted from an entry that carries a retired member, so no later
|
|
72
|
+
* phase has a key table of its own to consult for one. Every live object that is about to become a face meets it first:
|
|
73
|
+
* {@link rosterFaceOf} asks it of each entry, and the per-task agents rebuild asks it of the object `withAgents` returned
|
|
74
|
+
* before the stamp copy-back spreads that object (a spread drops a prototype's and a non-enumerable member). A value that
|
|
75
|
+
* is no object holds no member. */
|
|
76
|
+
export declare function refuseRetiredMember(entry: unknown, index: number): void;
|
|
59
77
|
/** One entry of the roster, and the ONLY place a {@link RosterFace} is minted. Every object entry (a function included) becomes a frozen face, so no entry the snapshot holds is a
|
|
60
78
|
* live object: a primitive is immutable and stays as read; a `defineTool` product's face names the product for its sealed
|
|
61
79
|
* rebind; an entry the ToolSpec arm cannot build gets a face too, and the mount refuses it from the verdict recorded here —
|
|
62
|
-
* an `execute` or a mark that grows on the caller's object afterwards is never read.
|
|
80
|
+
* an `execute` or a mark that grows on the caller's object afterwards is never read. An entry carrying a retired member is
|
|
81
|
+
* refused first ({@link refuseRetiredMember}). A read that throws refuses the run. */
|
|
63
82
|
export declare function rosterFaceOf(t: unknown, index: number): RosterFace;
|
|
64
83
|
/** The mount's arm for a roster entry that is the face of a `defineTool` product: the exact product object is rebound to
|
|
65
84
|
* the run's ctx through the factory's sealed seat, compared with its face ({@link refuseProductDrift}), and the tool the
|