@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
|
@@ -3,10 +3,10 @@ import { uuidv7 } from "../engine/session/uuid.js";
|
|
|
3
3
|
import { boundInputHashOf, capturedJsonOf } from "./canonical-json.js";
|
|
4
4
|
import { defineTool, errorResult } from "./tools.js";
|
|
5
5
|
import { delimitUntrusted, inlineUntrusted } from "./untrusted-text.js";
|
|
6
|
-
import { toolFace } from "./tool-catalog-entries.js";
|
|
6
|
+
import { engineMountedAs, mountRuleFace, toolFace } from "./tool-catalog-entries.js";
|
|
7
7
|
import { thrownText } from "./thrown-value.js";
|
|
8
|
-
import { heldBy } from "./tool-name-readings.js";
|
|
9
8
|
export const ASK_USER_QUESTION_TOOL_NAME = "AskUserQuestion";
|
|
9
|
+
export const isEngineQuestionFace = engineMountedAs(["ask-user-question"]);
|
|
10
10
|
export function classifyQuestionOutcome(outcome) {
|
|
11
11
|
let unavailable;
|
|
12
12
|
let answers;
|
|
@@ -69,11 +69,10 @@ export function validateAskQuestions(questions) {
|
|
|
69
69
|
}
|
|
70
70
|
return undefined;
|
|
71
71
|
}
|
|
72
|
-
const QUESTION_TOOL_NAMES = new Set([ASK_USER_QUESTION_TOOL_NAME]);
|
|
73
72
|
export function createDurableQuestionPolicy() {
|
|
74
73
|
return {
|
|
75
74
|
check(req) {
|
|
76
|
-
if (!
|
|
75
|
+
if (!isEngineQuestionFace(req.face)) {
|
|
77
76
|
return { action: "allow" };
|
|
78
77
|
}
|
|
79
78
|
return { action: "ask", message: "AskUserQuestion: awaiting a human answer (durable)" };
|
|
@@ -112,6 +111,7 @@ export function createAskUserQuestionTool(onQuestion, source, opts) {
|
|
|
112
111
|
return defineTool({
|
|
113
112
|
name: ASK_USER_QUESTION_TOOL_NAME,
|
|
114
113
|
...toolFace("ask-user-question"),
|
|
114
|
+
ruleFace: mountRuleFace("ask-user-question"),
|
|
115
115
|
description: "Ask the user a structured multiple-choice question when you are genuinely stuck or a decision is " +
|
|
116
116
|
"the user's to make (which approach, which of these). Provide 1-4 questions, each with 2-4 options " +
|
|
117
117
|
"(label + description). Use sparingly — not for anything you can determine yourself from the code or " +
|
|
@@ -256,6 +256,11 @@ export function createAskUserQuestionTool(onQuestion, source, opts) {
|
|
|
256
256
|
const untrustedParts = [];
|
|
257
257
|
const answeredHeaders = new Set();
|
|
258
258
|
const inlineSafe = (s) => inlineUntrusted(String(s), 300);
|
|
259
|
+
const echoLabel = (q, label, safe) => {
|
|
260
|
+
const place = q.options.findIndex((o) => o.label === label);
|
|
261
|
+
return place < 0 ? safe(label) : `[${place + 1}] ${safe(label)}`;
|
|
262
|
+
};
|
|
263
|
+
const asIs = (s) => s;
|
|
259
264
|
const capNote = (s) => (s.length > 4000 ? s.slice(0, 4000) + "…" : s);
|
|
260
265
|
let answers;
|
|
261
266
|
try {
|
|
@@ -290,15 +295,15 @@ export function createAskUserQuestionTool(onQuestion, source, opts) {
|
|
|
290
295
|
chosen = chosen.slice(0, 1);
|
|
291
296
|
}
|
|
292
297
|
if (answeredHeaders.has(q.header)) {
|
|
293
|
-
untrustedParts.push(`[${inlineSafe(q.header)}] duplicate answer (already answered): ${[...chosen, ...offList].join(" ")}`);
|
|
298
|
+
untrustedParts.push(`[${inlineSafe(q.header)}] duplicate answer (already answered): ${[...chosen.map((s) => echoLabel(q, s, asIs)), ...offList].join(" ")}`);
|
|
294
299
|
}
|
|
295
300
|
else {
|
|
296
301
|
answeredHeaders.add(q.header);
|
|
297
|
-
trustedLines.push(`- ${inlineSafe(q.header)}: ${chosen.length > 0 ? chosen.map(inlineSafe).join(", ") : "(no listed option selected)"}`);
|
|
302
|
+
trustedLines.push(`- ${inlineSafe(q.header)}: ${chosen.length > 0 ? chosen.map((s) => echoLabel(q, s, inlineSafe)).join(", ") : "(no listed option selected)"}`);
|
|
298
303
|
if (offList.length > 0)
|
|
299
304
|
untrustedParts.push(`[${inlineSafe(q.header)}] off-list input: ${offList.join("\n")}`);
|
|
300
305
|
if (extra.length > 0)
|
|
301
|
-
untrustedParts.push(`[${inlineSafe(q.header)}] discarded extra selections (single-choice): ${extra.join(", ")}`);
|
|
306
|
+
untrustedParts.push(`[${inlineSafe(q.header)}] discarded extra selections (single-choice): ${extra.map((s) => echoLabel(q, s, asIs)).join(", ")}`);
|
|
302
307
|
}
|
|
303
308
|
if (note)
|
|
304
309
|
untrustedParts.push(`[${inlineSafe(q.header)}] note: ${note}`);
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* is pure.
|
|
29
29
|
*/
|
|
30
30
|
import type { EngineNotice } from "./engine-notice.js";
|
|
31
|
-
import type
|
|
31
|
+
import { type ApprovalRemedy, type AssertAllKeysHandled, type HeadlessApproverSeat } from "./ask-origin.js";
|
|
32
32
|
/** WHY the ask could not be resolved — the closed set (see the module note for each word). */
|
|
33
33
|
export declare const ASK_UNRESOLVABLE_CAUSES: readonly ["approver_unavailable", "no_approver_wired", "mandate_unreconstructible"];
|
|
34
34
|
export type AskUnresolvableCause = (typeof ASK_UNRESOLVABLE_CAUSES)[number];
|
|
@@ -52,6 +52,10 @@ export interface AskUnresolvableFacts {
|
|
|
52
52
|
* for arguments no approval can be bound to, the binding's own sentence, which is that text — the remedy's approver half would
|
|
53
53
|
* not let them run) — carried verbatim, never re-composed here. */
|
|
54
54
|
readonly remedy?: string;
|
|
55
|
+
/** The ways out of that same refusal as data ({@link ApprovalRemedy}) — the approver, and the permission mode where the refusal could be
|
|
56
|
+
* released by one — for a host that chooses which to offer. Rides exactly when {@link remedy} is the headless remedy's sentence
|
|
57
|
+
* (`headlessApprovalRemedy`); a binding's own sentence, which has no way out to offer, carries none. */
|
|
58
|
+
readonly remedies?: readonly ApprovalRemedy[];
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
57
61
|
* Which causes take the caller-side remedy (`headlessApprovalRemedy`, ask-origin.ts), and in which seat's clause — the table IS
|
|
@@ -82,8 +86,9 @@ export declare function askUnresolvableRemedySeat(cause: AskUnresolvableCause):
|
|
|
82
86
|
* an empty session or tool name, or a cause outside the closed set, is refused at the mint with a
|
|
83
87
|
* `TypeError` rather than shaped into a notice that would route nowhere or say nothing.
|
|
84
88
|
*
|
|
85
|
-
* `detail: { sessionId, toolName, toolCallId, cause, parkLaneExisted, remedy? }` — `remedy` rides the causes that say nobody
|
|
86
|
-
* could be asked ({@link askUnresolvableRemedySeat}: the sentence the refusal's tool text carries)
|
|
89
|
+
* `detail: { sessionId, toolName, toolCallId, cause, parkLaneExisted, remedy?, remedies? }` — `remedy` rides the causes that say nobody
|
|
90
|
+
* could be asked ({@link askUnresolvableRemedySeat}: the sentence the refusal's tool text carries) and `remedies` beside it, the same
|
|
91
|
+
* way out as data ({@link ApprovalRemedy}); `sessionId` is lifted onto the typed key by {@link import("./engine-notice.js").deliverEngineNotice}, the one throat.
|
|
87
92
|
*/
|
|
88
93
|
export declare function askUnresolvableNotice(facts: AskUnresolvableFacts): EngineNotice;
|
|
89
94
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { APPROVAL_REMEDY_KINDS, readApprovalRemedy } from "./ask-origin.js";
|
|
1
2
|
export const ASK_UNRESOLVABLE_CAUSES = Object.freeze(["approver_unavailable", "no_approver_wired", "mandate_unreconstructible"]);
|
|
2
3
|
Object.freeze(ASK_UNRESOLVABLE_CAUSES);
|
|
3
4
|
const ASK_UNRESOLVABLE_CAUSE_SET = new Set(ASK_UNRESOLVABLE_CAUSES);
|
|
@@ -18,7 +19,7 @@ export function askUnresolvableRemedySeat(cause) {
|
|
|
18
19
|
return CAUSE_REMEDY_SEAT[cause];
|
|
19
20
|
}
|
|
20
21
|
export function askUnresolvableNotice(facts) {
|
|
21
|
-
const { sessionId, toolName, toolCallId, cause, parkLaneExisted, remedy } = facts;
|
|
22
|
+
const { sessionId, toolName, toolCallId, cause, parkLaneExisted, remedy, remedies } = facts;
|
|
22
23
|
if (typeof sessionId !== "string" || sessionId.length === 0) {
|
|
23
24
|
throw new TypeError("delegation.ask_unresolvable: sessionId is required — a user-audience notice with no session routes nowhere");
|
|
24
25
|
}
|
|
@@ -31,12 +32,25 @@ export function askUnresolvableNotice(facts) {
|
|
|
31
32
|
if (!isAskUnresolvableCause(cause)) {
|
|
32
33
|
throw new TypeError(`delegation.ask_unresolvable: cause ${JSON.stringify(cause)} is not one of ${ASK_UNRESOLVABLE_CAUSES.join("/")}`);
|
|
33
34
|
}
|
|
35
|
+
let remedyList;
|
|
36
|
+
if (remedies !== undefined) {
|
|
37
|
+
if (typeof remedy !== "string" || remedy.length === 0 || !Array.isArray(remedies) || remedies.length === 0) {
|
|
38
|
+
throw new TypeError("delegation.ask_unresolvable: remedies are a non-empty list of ways out riding beside the remedy sentence they restate");
|
|
39
|
+
}
|
|
40
|
+
remedyList = [];
|
|
41
|
+
for (let i = 0; i < remedies.length; i++) {
|
|
42
|
+
const read = Object.hasOwn(remedies, i) ? readApprovalRemedy(remedies[i]) : undefined;
|
|
43
|
+
if (read === undefined)
|
|
44
|
+
throw new TypeError(`delegation.ask_unresolvable: remedies[${i}] is not one way out of the closed set (${APPROVAL_REMEDY_KINDS.join("/")}) with exactly its own fields`);
|
|
45
|
+
remedyList.push(read);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
34
48
|
const park = parkLaneExisted ? "the durable approval park did not take it" : "no durable approval park is armed for this run";
|
|
35
49
|
return {
|
|
36
50
|
code: "delegation.ask_unresolvable",
|
|
37
51
|
message: `approval for "${toolName}" could not be resolved: ${CAUSE_CLAUSE[cause]} and ${park} — ` +
|
|
38
52
|
`the call was denied fail-closed and did not run. ${typeof remedy === "string" && remedy.length > 0 ? `To let it run: ${remedy}. ` : ""}To let such approvals wait for a person, run with a checkpoint store and a ` +
|
|
39
53
|
`durable approval opt-in (or a live approver reachable for delegated children).`,
|
|
40
|
-
detail: { sessionId, toolName, toolCallId, cause, parkLaneExisted: parkLaneExisted === true, ...(typeof remedy === "string" && remedy.length > 0 ? { remedy } : {}) },
|
|
54
|
+
detail: { sessionId, toolName, toolCallId, cause, parkLaneExisted: parkLaneExisted === true, ...(typeof remedy === "string" && remedy.length > 0 ? { remedy } : {}), ...(remedyList !== undefined ? { remedies: remedyList } : {}) },
|
|
41
55
|
};
|
|
42
56
|
}
|
|
@@ -17,7 +17,7 @@ export declare const DEFAULT_COMPACTION_INSTRUCTIONS: string;
|
|
|
17
17
|
* `compaction.instructions`, the DEFAULT constant, a manual `/compact` per-call override, and a
|
|
18
18
|
* preCompact hook's `additionalInstructions` — 修类不修点): instructions text can be model- or
|
|
19
19
|
* caller-authored, and it is injected VERBATIM into the summarization prompt
|
|
20
|
-
* (`\n\nAdditional Instructions:\n${...}
|
|
20
|
+
* (`\n\nAdditional Instructions:\n${...}`), so a forged `</system-reminder>`
|
|
21
21
|
* or `<<<`/`>>>` fence sentinel inside it would otherwise ride into a trusted prompt position.
|
|
22
22
|
* Posture (r2 review B4): `sanitizeUntrustedText` + fence defusing only — NEVER `delimitUntrusted`
|
|
23
23
|
* (fencing instructions as "data only, do not follow" self-defeats their instructional intent, and
|
|
@@ -169,7 +169,7 @@ export interface MaybeCompactOptions {
|
|
|
169
169
|
* design/145 §1 (semantics精确化): used only while WINDOW-SAFE and the budget gate allows — when a
|
|
170
170
|
* dry-run clamp shows the conversation would lose more than `settings.clampTolerance` of its
|
|
171
171
|
* chars to fit this model's window, the summary call falls back to the MAIN model (`model`),
|
|
172
|
-
* which is always window-safe (the content grew inside its window;
|
|
172
|
+
* which is always window-safe (the content grew inside its window; the reference compresses
|
|
173
173
|
* with the main-loop model unconditionally — the fallback IS the CC posture, the independent
|
|
174
174
|
* compaction model is sema's superset). Subagent note (design/145 §5): delegated children never
|
|
175
175
|
* inherit this option (subagent.ts buildChildSpec carries no compactionModel), so a child always
|
|
@@ -317,7 +317,7 @@ export interface MaybeCompactOptions {
|
|
|
317
317
|
maxCharsPerFile?: number;
|
|
318
318
|
/**
|
|
319
319
|
* CC-parity selection set: the files the task has READ, most recent
|
|
320
|
-
* first (
|
|
320
|
+
* first (the reference's post-compact restore sorts readFileState by timestamp — the read set is wider
|
|
321
321
|
* than the modified set and includes reference files the model consulted). When provided and
|
|
322
322
|
* non-empty it WINS over `modifiedFilesByRecency`; absent/empty falls back to the modified set
|
|
323
323
|
* (the pre-2026-07-03 behavior, and the right answer for callers with no read tracking).
|
|
@@ -419,6 +419,9 @@ export interface MaybeCompactOptions {
|
|
|
419
419
|
* context may have lost an engine frame the run still needs, and every reader of the new baseline
|
|
420
420
|
* (the next model request first) must see it restated. */
|
|
421
421
|
postureRestate?: () => Promise<void>;
|
|
422
|
+
/** The advisor tool's instructions' post-compaction restatement on a leg that mounts the tool (the runner's
|
|
423
|
+
* `compactionRestateOptions`): runs right after `postureRestate`, under the same belt, for the same reason. */
|
|
424
|
+
advisorRestate?: () => Promise<void>;
|
|
422
425
|
/**
|
|
423
426
|
* Fixed per-request prompt overhead (system prompt + tool schemas, in tokens), applied ONLY in the
|
|
424
427
|
* anchor-less regime (design/64 §26.7, search [91] fourth candidate): when no assistant in the
|
|
@@ -458,7 +461,7 @@ export interface MaybeCompactOptions {
|
|
|
458
461
|
* (`reused`) and feeds it back via this option; core treats `summaryProvider` as if absent for that one
|
|
459
462
|
* boundary when `consecutiveProviderReuse >= maxConsecutiveProviderReuse`. Default `3`, a
|
|
460
463
|
* SEMA choice — the earlier "(CC parity)" label was unsupported and is withdrawn (anchoring
|
|
461
|
-
* re-check 2026-08-23:
|
|
464
|
+
* re-check 2026-08-23: the reference has no external summary provider and no reuse concept at all;
|
|
462
465
|
* its three 3s are the PTL retry cap `b$d`, the consecutive-compaction-failure breaker `C$d` and
|
|
463
466
|
* the rapid-refill trip `Q3u`, none of them this). 3 is picked for the same reason those are: a
|
|
464
467
|
* small bound on how long a degraded path may keep answering before the real one is forced.
|
|
@@ -801,8 +804,8 @@ export declare function countSummarizedCrossSessionMessages(branch: ReadonlyArra
|
|
|
801
804
|
* SEMA-ONLY DEFENSE, not a CC port — but the ORIGINAL justification for that label was wrong
|
|
802
805
|
* on both of its premises, and the corrected pair still supports it. (a) "CC's full compact
|
|
803
806
|
* keeps tail 0 and monotonically shrinks" describes the `GNo` branch, which a LOCAL threshold
|
|
804
|
-
* compaction never reaches (
|
|
805
|
-
* pipeline, which preserves the last group verbatim
|
|
807
|
+
* compaction never reaches (the reference routes local passes to the reactive
|
|
808
|
+
* pipeline, which preserves the last group verbatim); the reference's
|
|
806
809
|
* default posture therefore has a keep-tail, exactly as ours does. (b) "CC has no
|
|
807
810
|
* request-layer trim" holds only for the MAIN conversation request: CC does own a
|
|
808
811
|
* keep-the-newest-groups-that-fit primitive (`UPb` :645223), whose only caller is the
|
|
@@ -819,7 +822,7 @@ export declare function nextTrimForceBackoff(prev: boolean, comp: {
|
|
|
819
822
|
freedTokens?: number;
|
|
820
823
|
naturalTrigger?: boolean;
|
|
821
824
|
}, trimForced?: boolean): boolean;
|
|
822
|
-
/** design/119 S3 (
|
|
825
|
+
/** design/119 S3 (rapid_refill_breaker): mutable per-task refill tracking state. */
|
|
823
826
|
export interface RapidRefillState {
|
|
824
827
|
lastCompactionTurn: number;
|
|
825
828
|
count: number;
|
|
@@ -827,7 +830,7 @@ export interface RapidRefillState {
|
|
|
827
830
|
/** Fresh tracking state (no compaction seen yet). */
|
|
828
831
|
export declare function createRapidRefillState(): RapidRefillState;
|
|
829
832
|
/**
|
|
830
|
-
* design/119 S3 (
|
|
833
|
+
* design/119 S3 (rapid_refill_breaker): record that a compaction just
|
|
831
834
|
* happened at `turn` and report whether the thrash breaker should TRIP. A compaction landing within
|
|
832
835
|
* `minGapTurns` of the previous one is a "rapid refill"; `tripAt` consecutive rapid refills = the
|
|
833
836
|
* context is dominated by incompressible content and further compaction only burns summary calls.
|
|
@@ -504,9 +504,11 @@ export async function maybeCompact(opts) {
|
|
|
504
504
|
catch {
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
|
-
|
|
507
|
+
for (const restate of [opts.postureRestate, opts.advisorRestate]) {
|
|
508
|
+
if (restate === undefined)
|
|
509
|
+
continue;
|
|
508
510
|
try {
|
|
509
|
-
await
|
|
511
|
+
await restate();
|
|
510
512
|
}
|
|
511
513
|
catch {
|
|
512
514
|
}
|
|
@@ -18,7 +18,7 @@ export declare const AUTO_MODE_ARMING_RECIPE_VERSION = 2;
|
|
|
18
18
|
export interface AutoModeArmingRecipe {
|
|
19
19
|
/** {@link AUTO_MODE_ARMING_RECIPE_VERSION}. An unknown version is refused, never partially read. */
|
|
20
20
|
v: number;
|
|
21
|
-
/** `buildAutoModePrompt` rule overrides for the four paired sections (omitted =
|
|
21
|
+
/** `buildAutoModePrompt` rule overrides for the four paired sections (omitted = the defaults). */
|
|
22
22
|
rules?: AutoModeRules;
|
|
23
23
|
/** Settings-plane deny rules rendered into `<settings_deny_rules>`. */
|
|
24
24
|
settingsDenyRules?: readonly string[];
|
|
@@ -37,7 +37,7 @@ export interface AutoModeArmingRecipe {
|
|
|
37
37
|
/** Classify round-trip cap, ms. */
|
|
38
38
|
timeoutMs?: number;
|
|
39
39
|
/**
|
|
40
|
-
* The classifier DENIAL-LIMIT bounds (`RunnerDeps.autoMode.denialLimit
|
|
40
|
+
* The classifier DENIAL-LIMIT bounds (`RunnerDeps.autoMode.denialLimit`):
|
|
41
41
|
* how many blocks the ancestor's classifier was allowed before a person had to look, and the window the
|
|
42
42
|
* fallback ask ran under. A KNOB triple, not prompt body — every member is orderable, so the fold takes
|
|
43
43
|
* the strictest of the two sides rather than refusing on a difference.
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* `RunnerDeps.autoMode.timeoutMs` is omitted. Sized for a self-hosted gateway, not a cloud API: a
|
|
4
4
|
* thinking-by-default gateway answers a classification in 5–165 s (Qwen 3.8 p50 11–24 s, kimi and GLM p50
|
|
5
5
|
* ~10 s), and queueing plus prefill of 2–5 min is a normal wait on such a gateway (`docs/TIMEOUTS.md`). 180 s
|
|
6
|
-
* clears the slowest classification observed with margin;
|
|
6
|
+
* clears the slowest classification observed with margin; the reference's per-attempt base is 60 s (
|
|
7
7
|
* stretched to 120 s with prompt size). Worst-case walk = this × rungs (2) = 360 s. Where the leg has an
|
|
8
8
|
* approval seat a rung that runs out of time costs a question to a person, not a refusal (see the gate's
|
|
9
9
|
* classifier station).
|
|
10
10
|
*/
|
|
11
11
|
export declare const AUTO_MODE_DEFAULT_TIMEOUT_MS = 180000;
|
|
12
12
|
/**
|
|
13
|
-
* The classifier call's transient retry budget — the reference implementation's short ladder
|
|
13
|
+
* The classifier call's transient retry budget — the reference implementation's short ladder: a
|
|
14
14
|
* provider error (an HTTP 5xx, a dropped connection) is retried this many times inside the rung's budget, then the rung
|
|
15
15
|
* reports `unavailable` / `error`. Where the leg has an approval seat that question goes to a person, so a long ladder
|
|
16
16
|
* would only make the person wait out the rung's budget and hear "timed out" for a failure that was not one.
|
|
@@ -52,8 +52,8 @@ export declare const AUTO_MODE_CLASSIFIER_MAX_TOKENS = 256;
|
|
|
52
52
|
* which on a default-on gateway is a think). The seat pays for the least the wire can grade plus the verdict,
|
|
53
53
|
* never for an open-ended budget.
|
|
54
54
|
*
|
|
55
|
-
* 2048 is anchored twice:
|
|
56
|
-
* its `rejects_disabled_thinking` family
|
|
55
|
+
* 2048 is anchored twice: the reference adds exactly this many tokens to the verdict cap for a model in
|
|
56
|
+
* its `rejects_disabled_thinking` family; and it is 2 × `MIN_THINKING_TOKENS` (1024), so
|
|
57
57
|
* on the anthropic BUDGET path a HARD cap of 256 + 2048 clears the cap-wins skip (`budgetCapSkipsThinking`)
|
|
58
58
|
* and hosts a legal `low` budget (`1024 ≤ budget_tokens < max_tokens`) without the brain having to raise a
|
|
59
59
|
* cap it refuses to raise. Live 2026-09-15: deepseek's default think fits it ~90–100% of the time; the tail
|
|
@@ -62,8 +62,8 @@ export declare const AUTO_MODE_CLASSIFIER_MAX_TOKENS = 256;
|
|
|
62
62
|
*/
|
|
63
63
|
export declare const AUTO_MODE_CLASSIFIER_LOW_REASONING_BUDGET_TOKENS = 2048;
|
|
64
64
|
/**
|
|
65
|
-
* The RE-ASK seat's allowance — the room a rung gets ONCE after its first attempt produced no verdict:
|
|
66
|
-
*
|
|
65
|
+
* The RE-ASK seat's allowance — the room a rung gets ONCE after its first attempt produced no verdict: the reference's
|
|
66
|
+
* stage-2 classifier cap (`max_tokens: 8192 + bn`). Live 2026-09-15 the thinking tail that overruns
|
|
67
67
|
* 2048 (deepseek 1–2 of 20, some past 4096; Qwen up to 6k) sits under it. One re-ask, never a loop.
|
|
68
68
|
*/
|
|
69
69
|
export declare const AUTO_MODE_CLASSIFIER_THINK_BUDGET_TOKENS = 8192;
|
|
@@ -78,14 +78,14 @@ export declare const AUTO_MODE_CLASSIFIER_CONTRACT_BROKEN_AFTER = 2;
|
|
|
78
78
|
* recipe canonicalizer needs its VALUE and must not load the assembly face (and its SHA-locked assets)
|
|
79
79
|
* to get it; `auto-mode-prompt.js` re-exports it, so the public name and its module face are unchanged. */
|
|
80
80
|
export declare const AUTO_MODE_DEFAULTS_SENTINEL = "$defaults";
|
|
81
|
-
/**
|
|
81
|
+
/** The classifier DENIAL LIMITS applied when
|
|
82
82
|
* `RunnerDeps.autoMode.denialLimit` omits a bound. Count-then-judge: the block that reaches a bound is
|
|
83
83
|
* itself the one that falls back to a person (the 3rd consecutive block asks; the 20th total asks). */
|
|
84
84
|
export declare const AUTO_MODE_DENIAL_LIMIT_DEFAULTS: Readonly<{
|
|
85
85
|
maxConsecutive: number;
|
|
86
86
|
maxTotal: number;
|
|
87
87
|
}>;
|
|
88
|
-
/**
|
|
88
|
+
/** The fallback ask's auto-deny window (ms) when `autoDenyAfterMs` is omitted.
|
|
89
89
|
* `0` disarms the window (the ask waits on the approver alone — the upstream original "fall back to
|
|
90
90
|
* prompting" shape). */
|
|
91
91
|
export declare const AUTO_MODE_DENIAL_AUTO_DENY_DEFAULT_MS = 120000;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/** The auto-mode classifier SYSTEM prompt shell (
|
|
2
|
-
* principle 7 at its
|
|
1
|
+
/** The auto-mode classifier SYSTEM prompt shell (`auto_mode_system_prompt`, with consent-bar
|
|
2
|
+
* principle 7 at its later text — see the header note).
|
|
3
3
|
* Contains two assembly placeholders consumed by `buildAutoModePrompt`: `<permissions_template>`
|
|
4
4
|
* (replaced by the permissions document) and `<cross_session_messages_rule>` (replaced with "" —
|
|
5
5
|
* the 206/207 default). */
|
|
6
6
|
export declare const AUTO_MODE_BASE_PROMPT: string;
|
|
7
|
-
/** The external permissions document (
|
|
7
|
+
/** The external permissions document (`permissions_external`). Four PAIRED placeholder
|
|
8
8
|
* tags wrap the DEFAULT rule sets (environment / hard deny / soft deny / allow) and one UNPAIRED tag
|
|
9
9
|
* (`<settings_deny_rules>`) marks the settings-plane deny injection point — all consumed by
|
|
10
10
|
* `buildAutoModePrompt` with the CC-exact merge semantics (user rules REPLACE the defaults; the
|
|
@@ -7,7 +7,7 @@ import type { Message } from "../internal/llm.js";
|
|
|
7
7
|
export { AUTO_MODE_DEFAULTS_SENTINEL } from "./auto-mode-defaults.js";
|
|
8
8
|
/** Deployment-authored rule overrides for the four paired sections of the permissions document.
|
|
9
9
|
* Each entry is ONE rule (rendered as a `- ` bullet); omit a field (or pass an empty array) to keep
|
|
10
|
-
* the
|
|
10
|
+
* the default rules for that section. */
|
|
11
11
|
export interface AutoModeRules {
|
|
12
12
|
allow?: readonly string[];
|
|
13
13
|
softDeny?: readonly string[];
|
package/dist/core/auto-mode.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare function isAutoModeUnavailableCause(v: unknown): v is AutoModeUna
|
|
|
16
16
|
* HOW a reply failed to carry a verdict — the closed set behind `parse_error.form`. `missing` = the reader found
|
|
17
17
|
* NO answer (empty text, prose, an answer only inside a thinking block); `conflict` = it found TWO distinct
|
|
18
18
|
* `<block>` answers (raw or thinking-stripped). The split decides who gets a SECOND ATTEMPT at the same
|
|
19
|
-
* question, on both seats that offer one: a missing answer is asked for again (
|
|
19
|
+
* question, on both seats that offer one: a missing answer is asked for again (the reference re-asks an
|
|
20
20
|
* unparseable reply) and handed on to the next candidate ({@link rungDidNotRule}); a conflict gets neither —
|
|
21
21
|
* it carries a `yes`, and any second attempt that answered `no` would erase it. One rule, two seats: whatever
|
|
22
22
|
* a re-ask may not overwrite, a later rung may not overwrite either. Not on any wire face; the trace frame and
|
|
@@ -157,7 +157,7 @@ export declare function autoModeRoundNotAsked(reason: unknown): Error & {
|
|
|
157
157
|
*/
|
|
158
158
|
export declare function rungDidNotRule(v: AutoModeVerdict): AutoModeFallbackCause | undefined;
|
|
159
159
|
/**
|
|
160
|
-
* The model-facing deny text for an `unavailable` verdict —
|
|
160
|
+
* The model-facing deny text for an `unavailable` verdict — with the parenthetical
|
|
161
161
|
* spells for the causes this engine distinguishes (a wall-clock / connection timeout reads " (timed out)";
|
|
162
162
|
* an unknown kind reads nothing). The subject is the classifier itself rather than a model id: without a
|
|
163
163
|
* candidate ladder the decider cannot vouch for a name. One writer for every deny site. ROOT CAUSE, when
|
|
@@ -173,8 +173,8 @@ export declare function classifierUnavailableDenyMessage(toolName: string, cause
|
|
|
173
173
|
*/
|
|
174
174
|
export declare function classifierNoRulingAskMessage(askText: string, cause: AutoModeFallbackCause): string;
|
|
175
175
|
/**
|
|
176
|
-
* The model-facing deny text for a `parse_error` verdict —
|
|
177
|
-
* this action and is blocking it for safety"
|
|
176
|
+
* The model-facing deny text for a `parse_error` verdict — stem ("Auto mode could not evaluate
|
|
177
|
+
* this action and is blocking it for safety"): the classifier answered, but not with a verdict,
|
|
178
178
|
* and auto mode blocks what it could not evaluate. With a candidate ladder wired the tail NAMES the model whose
|
|
179
179
|
* reply carried no verdict (`attribution.modelUsed`) — a declared departure from upstream, whose card names no
|
|
180
180
|
* model: the person reading this card is the one who can change the catalog, and on a single-model deployment
|
|
@@ -183,8 +183,8 @@ export declare function classifierNoRulingAskMessage(askText: string, cause: Aut
|
|
|
183
183
|
*/
|
|
184
184
|
export declare function classifierParseFailureDenyMessage(attribution?: AutoModeClassifierRound): string;
|
|
185
185
|
/**
|
|
186
|
-
* Parse the classifier's output contract — the
|
|
187
|
-
* reason reader
|
|
186
|
+
* Parse the classifier's output contract — the verdict reader (with its thinking strip and its
|
|
187
|
+
* reason reader), plus ONE arm of sema's own:
|
|
188
188
|
* blocked: `<block>yes</block><category>Rule Name</category><reason>[Rule Name] …</reason>`
|
|
189
189
|
* allowed: `<block>no</block>`
|
|
190
190
|
*
|
|
@@ -212,7 +212,7 @@ export declare function classifierParseFailureDenyMessage(attribution?: AutoMode
|
|
|
212
212
|
* line from the tool name in that case. Downgrading a stated block to `parse_error` would lose the
|
|
213
213
|
* classifier's explicit verdict on the exact calls it flagged.
|
|
214
214
|
*
|
|
215
|
-
* `parse_error` is fail-closed: the gate handles it as a BLOCK (
|
|
215
|
+
* `parse_error` is fail-closed: the gate handles it as a BLOCK (the reference's own outcome for a reply with no
|
|
216
216
|
* verdict) that the denial limit counts like any other — never a silent allow, and never a question handed
|
|
217
217
|
* to a person on the classifier's behalf.
|
|
218
218
|
*/
|
|
@@ -340,8 +340,15 @@ export interface DenialLimitCounts {
|
|
|
340
340
|
/** Total blocks this run INCLUDING the one that tripped the bound (read before the total-bound reset). */
|
|
341
341
|
readonly total: number;
|
|
342
342
|
/** Which bound tripped. */
|
|
343
|
-
readonly limit:
|
|
343
|
+
readonly limit: DenialLimitBound;
|
|
344
344
|
}
|
|
345
|
+
/** The two denial bounds, spelled once: {@link DenialLimitBound} is derived from this tuple, and every reader of a
|
|
346
|
+
* stored or foreign fallback member judges its `limit` word through {@link isDenialLimitBound}. */
|
|
347
|
+
export declare const DENIAL_LIMIT_BOUNDS: readonly ["consecutive", "total"];
|
|
348
|
+
/** Which denial bound tripped: `consecutive` blocks in a row, or the run's `total`. */
|
|
349
|
+
export type DenialLimitBound = (typeof DENIAL_LIMIT_BOUNDS)[number];
|
|
350
|
+
/** Whether a value is one of {@link DENIAL_LIMIT_BOUNDS} — the screen a reader applies to a stored `limit` word. */
|
|
351
|
+
export declare function isDenialLimitBound(v: unknown): v is DenialLimitBound;
|
|
345
352
|
/**
|
|
346
353
|
* The DECISION-layer member of a denial-limit fallback ask (`PermissionResult` ask arm): the counts
|
|
347
354
|
* that tripped the bound, and NOTHING about a window. A window is a fact of the ask's ROUTE — a live
|
|
@@ -386,7 +393,8 @@ export type DenialLimitFallbackFace = UnarmedDenialLimitFallback | DenialLimitFa
|
|
|
386
393
|
* finite non-negative window), nothing else carried. A deployment-written row (a checkpoint store is a
|
|
387
394
|
* host's) can hold any shape; the faces that echo it (the inbox summary) read through here, so a bad
|
|
388
395
|
* shape reads as ABSENT rather than reaching a consumer as a malformed card. Not a parser of intent —
|
|
389
|
-
* `"3"` is not 3.
|
|
396
|
+
* `"3"` is not 3. The value is a plain record (no member comes from a prototype it was given); each member is read once,
|
|
397
|
+
* in declaration order, and the answer is the values judged.
|
|
390
398
|
*/
|
|
391
399
|
export declare function readDenialLimitFallback(v: unknown): DenialLimitFallback | undefined;
|
|
392
400
|
/** The window-less route's member, spelled in ONE place: every station that hands a fallback somewhere
|
package/dist/core/auto-mode.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AUTO_MODE_DEFAULT_TIMEOUT_MS, AUTO_MODE_DENIAL_AUTO_DENY_DEFAULT_MS, AUTO_MODE_DENIAL_LIMIT_DEFAULTS } from "./auto-mode-defaults.js";
|
|
2
2
|
import { thrownIs } from "./thrown-value.js";
|
|
3
3
|
import { describeRejectedValue } from "./tool-search-setting.js";
|
|
4
|
+
import { isPlainRecord } from "./mods/kernel/receive.js";
|
|
4
5
|
export const AUTO_MODE_UNAVAILABLE_CAUSES = Object.freeze(["error", "timeout"]);
|
|
5
6
|
const AUTO_MODE_UNAVAILABLE_CAUSE_SET = new Set(AUTO_MODE_UNAVAILABLE_CAUSES);
|
|
6
7
|
export function isAutoModeUnavailableCause(v) {
|
|
@@ -312,16 +313,18 @@ class AutoModeTimeout extends Error {
|
|
|
312
313
|
}
|
|
313
314
|
}
|
|
314
315
|
const isAutoModeTimeout = (e) => thrownIs(e, AutoModeTimeout);
|
|
316
|
+
export const DENIAL_LIMIT_BOUNDS = Object.freeze(["consecutive", "total"]);
|
|
317
|
+
export function isDenialLimitBound(v) {
|
|
318
|
+
return DENIAL_LIMIT_BOUNDS.some((bound) => v === bound);
|
|
319
|
+
}
|
|
315
320
|
export function readDenialLimitFallback(v) {
|
|
316
|
-
if (
|
|
321
|
+
if (!isPlainRecord(v))
|
|
317
322
|
return undefined;
|
|
318
|
-
const o = v;
|
|
319
323
|
const count = (x) => typeof x === "number" && Number.isFinite(x) && x >= 0;
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (o["limit"] !== "consecutive" && o["limit"] !== "total")
|
|
324
|
+
const [consecutive, total, limit, autoDenyAfterMs] = [v["consecutive"], v["total"], v["limit"], v["autoDenyAfterMs"]];
|
|
325
|
+
if (!count(consecutive) || !count(total) || !count(autoDenyAfterMs) || !isDenialLimitBound(limit))
|
|
323
326
|
return undefined;
|
|
324
|
-
return { consecutive
|
|
327
|
+
return { consecutive, total, limit, autoDenyAfterMs };
|
|
325
328
|
}
|
|
326
329
|
export function unarmedWindow(fallback) {
|
|
327
330
|
return { ...countsOf(fallback), autoDenyAfterMs: 0 };
|
|
@@ -10,7 +10,7 @@ export interface BackgroundAgentUsage {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* One durable background-agent execution row. Field discipline (design/151 §3.1, HIGH-4): revival
|
|
13
|
-
* re-hydration data is LOOKUP KEYS ONLY (`agentType`/`model`/`name` — the
|
|
13
|
+
* re-hydration data is LOOKUP KEYS ONLY (`agentType`/`model`/`name` — the reference's
|
|
14
14
|
* `.meta.json` sidecar shape) — never a serialized spec and never closures; a tier-3 revival rebuilds
|
|
15
15
|
* the spec the same way a fresh named-teammate spawn would (roster/agent definition + the reviver's
|
|
16
16
|
* deployment assembly).
|
|
@@ -252,8 +252,8 @@ export declare function canAccessAgentRecord(record: Pick<BackgroundAgentRecord,
|
|
|
252
252
|
/** The stale-running reap flip's attribution, written to BOTH `summary` (legacy
|
|
253
253
|
* slot, kept for any out-of-repo reader) and `error` (the field {@link canAccessAgentRecord}-gated
|
|
254
254
|
* durable serving actually renders). One exported constant so the two store implementations (in-memory
|
|
255
|
-
* here, file twin) can never drift apart (RB-74/RB-111 family). Wording carries
|
|
256
|
-
* facts
|
|
255
|
+
* here, file twin) can never drift apart (RB-74/RB-111 family). Wording carries the reference's three
|
|
256
|
+
* facts: what happened (host process gone mid-run), the consequence (in-process state
|
|
257
257
|
* lost), and the action (check the worktree/output for partial work before assuming the task landed). */
|
|
258
258
|
export declare const STALE_RUNNING_REAP_ATTRIBUTION = "the host process was interrupted while this agent was running \u2014 its in-process state was lost. Check its worktree / output file for partial work before assuming the task landed (stale running row reaped).";
|
|
259
259
|
/**
|
|
@@ -50,7 +50,7 @@ import { type ReceiptFault } from "./mods/kernel/receive.js";
|
|
|
50
50
|
* non-JSON values move. That is safe by construction for the persisted ones: the hash is opaque and
|
|
51
51
|
* server-minted, a resume compares the persisted string and never re-serializes.
|
|
52
52
|
*/
|
|
53
|
-
export declare function canonicalize(value: unknown): string;
|
|
53
|
+
export declare function canonicalize(value: unknown, standsAt?: number): string;
|
|
54
54
|
/** What {@link canonicalize} returns when even its top level cannot be encoded — a reader that must never accept a
|
|
55
55
|
* constant (the checkpoint row digest) refuses on it. */
|
|
56
56
|
export declare const UNCANONICALIZABLE = "<uncanonicalizable>";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { types } from "node:util";
|
|
3
3
|
import { describeFault, receive } from "./mods/kernel/receive.js";
|
|
4
|
-
export function canonicalize(value) {
|
|
4
|
+
export function canonicalize(value, standsAt = 0) {
|
|
5
5
|
try {
|
|
6
|
-
return encode(value);
|
|
6
|
+
return encode(value, standsAt);
|
|
7
7
|
}
|
|
8
8
|
catch {
|
|
9
9
|
return UNCANONICALIZABLE;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A checkpoint row's generation and the judges of a resolve's expectation over it (the generation, the claim holder). Every
|
|
3
|
+
* backend, the resume's claim and a host that compares two reads of one row read the generation here, so "an absent `rev`
|
|
4
|
+
* reads as 0" is written once.
|
|
5
|
+
* A leaf: it types against `checkpoint-store.ts` (type only), so the store module can call it without a load-order cycle.
|
|
6
|
+
*/
|
|
7
|
+
import type { Checkpoint, CheckpointStore, ResolveExpectation } from "./checkpoint-store.js";
|
|
8
|
+
/**
|
|
9
|
+
* THE generation of a checkpoint row: its monotonic {@link Checkpoint.rev}, where an absent `rev` (a row
|
|
10
|
+
* minted before the field existed, never mutated) reads as `0`. This is the one place that rule is
|
|
11
|
+
* written — the CAS predicate under it, the loss answer, both backends' resolve / reopen bump, and the
|
|
12
|
+
* resume's expectation all read the generation through it, and so should a backend or a host that
|
|
13
|
+
* compares two reads of one row (`checkpointRevOf(again) === checkpointRevOf(row)` ⇒ no resolve / reopen
|
|
14
|
+
* landed between them).
|
|
15
|
+
*/
|
|
16
|
+
export declare function checkpointRevOf(cp: Pick<Checkpoint, "rev">): number;
|
|
17
|
+
/**
|
|
18
|
+
* REF-A4 — THE optimistic-concurrency half of `resolve`'s CAS predicate (design/80 D-1), shared by every
|
|
19
|
+
* backend. The caller validated its reopen-by-reason guard against a `get()` snapshot; if a concurrent
|
|
20
|
+
* resolve/reopen cycle moved the monotonic `rev` in the get→resolve window, that validation is stale ⇒
|
|
21
|
+
* lose the CAS (fail-closed), forcing a re-get + re-validate. Keyed on `rev`, NOT on `reopenReason` — a
|
|
22
|
+
* 2-valued enum can ABA back to a prior value while the winner changed (round-2 BLOCKER fix). An absent
|
|
23
|
+
* expectation opts out of the guard entirely.
|
|
24
|
+
*/
|
|
25
|
+
export declare function checkpointOccMatches(cp: Checkpoint, expect?: ResolveExpectation): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The deployment's judge of a claim holder, handed to an in-tree store (`holderIsCurrent`): `true` while the grant `holder` names is
|
|
28
|
+
* the current one, `false` once it is not. Exactly `true` is current; any answer that is not a boolean — a promise from an async judge
|
|
29
|
+
* included — is refused loudly ({@link checkpointHolderMatches}), never read by its truthiness and never as a lost grant.
|
|
30
|
+
* SYNCHRONOUS — the store calls it inside its atomic step, right before the commit, so the judgement and the flip
|
|
31
|
+
* are one step with respect to code in THIS process. That closes the race only when the deployment's claim transfers happen in this
|
|
32
|
+
* process and synchronously (an in-process claim table); a claim another process can transfer needs a store whose CAS and the claim
|
|
33
|
+
* table share one transaction (a SQL backend's WHERE).
|
|
34
|
+
*/
|
|
35
|
+
export type HolderJudge = (holder: string) => boolean;
|
|
36
|
+
/**
|
|
37
|
+
* THE holder half of the same predicate ({@link ResolveExpectation.holder}), shared by every backend that judges holders through a
|
|
38
|
+
* function: no holder ⇒ nothing to judge; a holder ⇒ the store's judge answers whether that grant is still the current one. A store
|
|
39
|
+
* with no judge loses a holder-bearing CAS — it never ignores a precondition it was handed. Called inside the store's atomic step,
|
|
40
|
+
* right before the commit; a judge that throws makes the CAS throw with the row untouched. The judge's answer is current only when it
|
|
41
|
+
* is exactly `true`; an answer that is not a boolean throws `config.invalid_checkpoint_store` (the row untouched): a wiring error is
|
|
42
|
+
* named as one, not passed as a grant (by truthiness) nor reported as a superseded holder (by refusal).
|
|
43
|
+
*/
|
|
44
|
+
export declare function checkpointHolderMatches(expect: ResolveExpectation | undefined, holderIsCurrent: HolderJudge | undefined): boolean;
|
|
45
|
+
/** `RunInternals.holder` when present: a non-empty string (the deployment's credential for one claim grant). A provided value that
|
|
46
|
+
* is empty or not a string names no grant and is refused at the door (`config.invalid_argument`), never carried into a CAS where a
|
|
47
|
+
* judge would read it as a grant that lost. The value itself is never printed — only its kind. */
|
|
48
|
+
export declare function assertHolderValue(holder: unknown): void;
|
|
49
|
+
/** The store-seat refusal of a claim holder the seat's store cannot judge: a run handed {@link ResolveExpectation.holder} (through
|
|
50
|
+
* `RunInternals.holder`) whose store does not declare `fence = { holder: true }`. The store seat's door and code
|
|
51
|
+
* (`config.invalid_checkpoint_store`, as for a store without the execution declaration); no store (a disarmed run) has nothing to
|
|
52
|
+
* judge. The holder's value is never named. */
|
|
53
|
+
export declare function assertCheckpointStoreJudgesHolder(seat: "TaskSpec.checkpointStore" | "RunnerDeps.checkpointStore", store: CheckpointStore | undefined, holder: string | undefined): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function checkpointRevOf(cp) {
|
|
2
|
+
return cp.rev ?? 0;
|
|
3
|
+
}
|
|
4
|
+
export function checkpointOccMatches(cp, expect) {
|
|
5
|
+
return expect === undefined || checkpointRevOf(cp) === expect.rev;
|
|
6
|
+
}
|
|
7
|
+
export function checkpointHolderMatches(expect, holderIsCurrent) {
|
|
8
|
+
if (expect?.holder === undefined)
|
|
9
|
+
return true;
|
|
10
|
+
if (holderIsCurrent === undefined)
|
|
11
|
+
return false;
|
|
12
|
+
const answer = holderIsCurrent(expect.holder);
|
|
13
|
+
if (typeof answer !== "boolean") {
|
|
14
|
+
const kind = answer === null ? "null" : typeof answer === "object" ? "an object (an async judge answers a promise)" : `a ${typeof answer}`;
|
|
15
|
+
const e = new Error(`the checkpoint store's \`holderIsCurrent\` judge must answer \`true\` or \`false\` synchronously (it answered ${kind}) — any other answer is a wiring error, not a judgement; the resolve did not run and the row is untouched. Make the judge a synchronous read of the claim table.`);
|
|
16
|
+
e.code = "config.invalid_checkpoint_store";
|
|
17
|
+
throw e;
|
|
18
|
+
}
|
|
19
|
+
return answer === true;
|
|
20
|
+
}
|
|
21
|
+
export function assertHolderValue(holder) {
|
|
22
|
+
if (holder === undefined || (typeof holder === "string" && holder !== ""))
|
|
23
|
+
return;
|
|
24
|
+
const kind = holder === "" ? "an empty string" : holder === null ? "null" : `a ${typeof holder}`;
|
|
25
|
+
const e = new Error(`RunInternals.holder must be a non-empty string when present (got ${kind}) — it is the deployment's credential for the claim grant the run acts under; omit it for a run that acts under none.`);
|
|
26
|
+
e.code = "config.invalid_argument";
|
|
27
|
+
throw e;
|
|
28
|
+
}
|
|
29
|
+
export function assertCheckpointStoreJudgesHolder(seat, store, holder) {
|
|
30
|
+
if (holder === undefined || store === undefined || store.fence?.holder === true)
|
|
31
|
+
return;
|
|
32
|
+
const e = new Error(`${seat}: the run carries a claim holder, but the wired CheckpointStore does not declare \`fence = { holder: true }\` — a store that does not judge the holder in its resolve would ignore it, and the fence would hold nothing. Wire a store that judges holders (the in-tree stores take \`holderIsCurrent\`) or stop passing one.`);
|
|
33
|
+
e.code = "config.invalid_checkpoint_store";
|
|
34
|
+
throw e;
|
|
35
|
+
}
|