@sema-agent/core 7.48.0 → 7.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +457 -0
- package/README.md +2 -2
- package/dist/agents/cascade.d.ts +2 -5
- package/dist/agents/child-failure.d.ts +20 -0
- package/dist/agents/child-failure.js +28 -0
- package/dist/agents/cross-session-ref.d.ts +11 -3
- package/dist/agents/cross-session-ref.js +6 -0
- package/dist/agents/cumulative-stats.d.ts +12 -15
- package/dist/agents/cumulative-stats.js +1 -1
- package/dist/agents/extra-tool-names.js +1 -1
- package/dist/agents/inherited-tool-pool.d.ts +17 -13
- package/dist/agents/inherited-tool-pool.js +4 -3
- package/dist/agents/peer-session-drain.d.ts +3 -2
- package/dist/agents/peer-session-drain.js +5 -4
- package/dist/agents/send-message-tool.js +2 -9
- package/dist/agents/subagent.d.ts +10 -29
- package/dist/agents/subagent.js +65 -53
- package/dist/agents/suspend-guard.d.ts +1 -1
- package/dist/agents/tool-filter.d.ts +76 -65
- package/dist/agents/tool-filter.js +122 -92
- package/dist/agents/verify.d.ts +4 -7
- package/dist/agents/verify.js +6 -7
- package/dist/bench/metrics.d.ts +1 -2
- package/dist/brain/anthropic.js +133 -79
- package/dist/brain/errors.d.ts +53 -6
- package/dist/brain/errors.js +22 -2
- package/dist/brain/input-too-long.d.ts +40 -19
- package/dist/brain/input-too-long.js +3 -16
- package/dist/brain/open-responses.js +19 -10
- package/dist/brain/openai.js +123 -32
- package/dist/brain/provider-dialect.d.ts +214 -0
- package/dist/brain/provider-dialect.js +186 -0
- package/dist/brain/request-params.d.ts +27 -8
- package/dist/brain/request-params.js +7 -12
- package/dist/brain/request-route.d.ts +84 -0
- package/dist/brain/request-route.js +41 -0
- package/dist/brain/retry.d.ts +8 -0
- package/dist/brain/retry.js +10 -4
- package/dist/brain/route-adjudicator.d.ts +7 -0
- package/dist/brain/route-adjudicator.js +5 -1
- package/dist/brain/status-sink.d.ts +20 -0
- package/dist/brain/status-sink.js +11 -0
- package/dist/brain/stream-engine.d.ts +52 -1
- package/dist/brain/stream-engine.js +81 -24
- package/dist/brain/stream-shared.d.ts +57 -11
- package/dist/brain/stream-shared.js +28 -2
- package/dist/core/a2a.d.ts +1 -0
- package/dist/core/agent-config-dir.js +3 -2
- package/dist/core/allow-entry.d.ts +21 -12
- package/dist/core/allow-entry.js +38 -31
- package/dist/core/arg-summary.d.ts +21 -28
- package/dist/core/arg-summary.js +235 -88
- package/dist/core/ask-origin.d.ts +42 -24
- package/dist/core/ask-origin.js +18 -13
- package/dist/core/auto-mode-prompt-assets.d.ts +2 -2
- package/dist/core/auto-mode-prompt-assets.js +1 -1
- package/dist/core/auto-mode-prompt.d.ts +11 -1
- package/dist/core/auto-mode-prompt.js +13 -10
- package/dist/core/auto-mode-rebuild.d.ts +7 -0
- package/dist/core/auto-mode-rebuild.js +4 -1
- package/dist/core/canonical-json.d.ts +3 -0
- package/dist/core/canonical-json.js +2 -1
- package/dist/core/checkpoint-requirements.d.ts +892 -0
- package/dist/core/checkpoint-requirements.js +333 -0
- package/dist/core/checkpoint-store.d.ts +94 -65
- package/dist/core/checkpoint-store.js +14 -26
- package/dist/core/child-clamp-seats.d.ts +228 -69
- package/dist/core/child-clamp-seats.js +211 -17
- package/dist/core/classifier-unavailable-arm.d.ts +5 -1
- package/dist/core/classifier-unavailable-arm.js +3 -3
- package/dist/core/compliance.d.ts +3 -0
- package/dist/core/compliance.js +9 -4
- package/dist/core/credential-vocabulary.d.ts +140 -0
- package/dist/core/credential-vocabulary.js +131 -0
- package/dist/core/decision-receipt.js +1 -1
- package/dist/core/effective-path-target.d.ts +73 -16
- package/dist/core/effective-path-target.js +63 -33
- package/dist/core/engine-notice.d.ts +43 -11
- package/dist/core/file-history-store.js +2 -2
- package/dist/core/fs-write-gate-policy.d.ts +4 -0
- package/dist/core/fs-write-gate-policy.js +22 -5
- package/dist/core/gate-bounded-await.d.ts +28 -13
- package/dist/core/gate-bounded-await.js +41 -4
- package/dist/core/gate-fold.d.ts +1 -1
- package/dist/core/gate-fold.js +24 -25
- package/dist/core/gate-lanes.js +16 -15
- package/dist/core/gate-outcome.d.ts +20 -5
- package/dist/core/gate-outcome.js +5 -0
- package/dist/core/governance-codes.d.ts +11 -4
- package/dist/core/governance-codes.js +14 -3
- package/dist/core/hooks.d.ts +21 -0
- package/dist/core/locked-config.d.ts +8 -0
- package/dist/core/locked-config.js +14 -2
- package/dist/core/lsp.js +3 -5
- package/dist/core/mailbox-store.d.ts +3 -4
- package/dist/core/mcp-connection-pool.d.ts +75 -0
- package/dist/core/mcp-connection-pool.js +128 -0
- package/dist/core/mcp-failure.d.ts +2 -1
- package/dist/core/mcp-failure.js +13 -2
- package/dist/core/mcp.d.ts +4 -0
- package/dist/core/mcp.js +70 -43
- package/dist/core/memory-engine/content-origin.js +2 -14
- package/dist/core/memory-engine/engine.d.ts +32 -22
- package/dist/core/memory-engine/engine.js +103 -55
- package/dist/core/memory-engine/file-backend.d.ts +13 -30
- package/dist/core/memory-engine/file-backend.js +37 -252
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/index.js +1 -1
- package/dist/core/memory-engine/layout.d.ts +139 -9
- package/dist/core/memory-engine/layout.js +350 -7
- package/dist/core/memory-engine/scope-contract.d.ts +10 -0
- package/dist/core/memory-engine/scope-contract.js +8 -0
- package/dist/core/memory-engine/session-incarnation.d.ts +14 -4
- package/dist/core/memory-engine/session-incarnation.js +5 -2
- package/dist/core/memory-engine/types.d.ts +10 -1
- package/dist/core/memory.js +5 -17
- package/dist/core/model-seat.d.ts +4 -4
- package/dist/core/model-seat.js +1 -1
- package/dist/core/mounted-mcp.d.ts +57 -0
- package/dist/core/mounted-mcp.js +19 -0
- package/dist/core/namespaced-rule-name.d.ts +29 -0
- package/dist/core/namespaced-rule-name.js +52 -0
- package/dist/core/park-selfcheck.d.ts +1 -1
- package/dist/core/park-selfcheck.js +16 -6
- package/dist/core/path-guard-rows.d.ts +99 -0
- package/dist/core/path-guard-rows.js +45 -0
- package/dist/core/path-identity.d.ts +22 -16
- package/dist/core/path-identity.js +10 -10
- package/dist/core/path-rule-binding.d.ts +2 -1
- package/dist/core/path-rule-binding.js +3 -1
- package/dist/core/pause-registry.d.ts +16 -2
- package/dist/core/pause-registry.js +6 -0
- package/dist/core/permission-rule-consent.js +0 -7
- package/dist/core/permission-rule-model.d.ts +68 -24
- package/dist/core/permission-rule-model.js +105 -24
- package/dist/core/permission-rule-store.js +2 -2
- package/dist/core/permission-rules.d.ts +3 -30
- package/dist/core/permission-rules.js +4 -54
- package/dist/core/read-root-candidate.d.ts +1 -3
- package/dist/core/read-root-candidate.js +4 -15
- package/dist/core/real-approval.d.ts +4 -3
- package/dist/core/retired-keys.d.ts +13 -0
- package/dist/core/retired-keys.js +14 -0
- package/dist/core/roles.d.ts +2 -3
- package/dist/core/roles.js +15 -6
- package/dist/core/runner/assemble-result.d.ts +0 -7
- package/dist/core/runner/assemble-result.js +19 -31
- package/dist/core/runner/caller-roster.d.ts +78 -0
- package/dist/core/runner/caller-roster.js +219 -0
- package/dist/core/runner/checkpoint-scope.d.ts +16 -16
- package/dist/core/runner/checkpoint-scope.js +2 -2
- package/dist/core/runner/child-tree.js +2 -2
- package/dist/core/runner/contracts.d.ts +68 -35
- package/dist/core/runner/decide-continuation.d.ts +51 -3
- package/dist/core/runner/decide-continuation.js +76 -21
- package/dist/core/runner/denial-limit-arms.d.ts +17 -5
- package/dist/core/runner/denial-limit-arms.js +11 -9
- package/dist/core/runner/extra-body-dropped-seat.d.ts +8 -0
- package/dist/core/runner/extra-body-dropped-seat.js +22 -0
- package/dist/core/runner/finish-reason-seat.d.ts +9 -0
- package/dist/core/runner/finish-reason-seat.js +40 -0
- package/dist/core/runner/gate-exit.d.ts +44 -32
- package/dist/core/runner/gate-exit.js +112 -25
- package/dist/core/runner/inherited-ask-grants.js +6 -4
- package/dist/core/runner/mcp-redial.d.ts +3 -3
- package/dist/core/runner/mcp-redial.js +3 -4
- package/dist/core/runner/permission-rule-lanes.d.ts +1 -2
- package/dist/core/runner/permission-rule-lanes.js +5 -4
- package/dist/core/runner/prepare-artifact.d.ts +4 -0
- package/dist/core/runner/prepare-artifact.js +2 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +2 -0
- package/dist/core/runner/prepare-ask-lane.js +12 -6
- package/dist/core/runner/prepare-boundary-parks.d.ts +5 -8
- package/dist/core/runner/prepare-boundary-parks.js +4 -7
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +11 -15
- package/dist/core/runner/prepare-caps-and-workflow.js +19 -27
- package/dist/core/runner/prepare-config-doors.d.ts +9 -9
- package/dist/core/runner/prepare-config-doors.js +10 -5
- package/dist/core/runner/prepare-defer-classify.d.ts +2 -2
- package/dist/core/runner/prepare-defer-classify.js +5 -3
- package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
- package/dist/core/runner/prepare-delegation-surface.js +3 -3
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -4
- package/dist/core/runner/prepare-gate-stations.js +9 -7
- package/dist/core/runner/prepare-hands-readface.d.ts +7 -7
- package/dist/core/runner/prepare-hands-readface.js +7 -7
- package/dist/core/runner/prepare-inherited-gate.d.ts +7 -6
- package/dist/core/runner/prepare-inherited-gate.js +14 -15
- package/dist/core/runner/prepare-listings.d.ts +7 -24
- package/dist/core/runner/prepare-listings.js +4 -5
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -0
- package/dist/core/runner/prepare-memory-engine-session.js +4 -3
- package/dist/core/runner/prepare-memory.d.ts +6 -0
- package/dist/core/runner/prepare-memory.js +13 -13
- package/dist/core/runner/prepare-offload-wrappers.d.ts +5 -0
- package/dist/core/runner/prepare-offload-wrappers.js +3 -3
- package/dist/core/runner/prepare-park-ask.d.ts +7 -8
- package/dist/core/runner/prepare-park-ask.js +17 -10
- package/dist/core/runner/prepare-policy-chain.js +24 -44
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +3 -4
- package/dist/core/runner/prepare-protocol-tools.d.ts +9 -3
- package/dist/core/runner/prepare-protocol-tools.js +3 -4
- package/dist/core/runner/prepare-run-refs.d.ts +3 -0
- package/dist/core/runner/prepare-run-refs.js +2 -1
- package/dist/core/runner/prepare-safety-scan.d.ts +4 -8
- package/dist/core/runner/prepare-safety-scan.js +1 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +7 -1
- package/dist/core/runner/prepare-suspend-saga.js +28 -12
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +67 -56
- package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -10
- package/dist/core/runner/prepare-wiring-manifest.js +5 -8
- package/dist/core/runner/resume-apply.js +7 -14
- package/dist/core/runner/resume-checkpoint-screen.js +11 -4
- package/dist/core/runner/resume-internals-and-config.js +2 -2
- package/dist/core/runner/resume-policy-outcome.js +5 -32
- package/dist/core/runner/resume-review-outcome.js +4 -1
- package/dist/core/runner/retired-runner-deps.d.ts +6 -0
- package/dist/core/runner/retired-runner-deps.js +10 -1
- package/dist/core/runner/run-brain-sinks.d.ts +4 -0
- package/dist/core/runner/run-brain-sinks.js +5 -2
- package/dist/core/runner/run-harness-handlers.js +29 -36
- package/dist/core/runner/run-leg.d.ts +0 -2
- package/dist/core/runner/run-leg.js +32 -33
- package/dist/core/runner/run-terminal-adoption.js +4 -3
- package/dist/core/runner/runtask.js +8 -8
- package/dist/core/runner/session-rule-policy.js +5 -5
- package/dist/core/runner/stream-settle-backstop.js +7 -4
- package/dist/core/runner/sub-agent-deny-lists.d.ts +51 -12
- package/dist/core/runner/sub-agent-deny-lists.js +111 -80
- package/dist/core/runner/terminal-account.d.ts +48 -0
- package/dist/core/runner/terminal-account.js +186 -0
- package/dist/core/runner/tool-end-body.d.ts +54 -17
- package/dist/core/runner/tool-end-body.js +27 -2
- package/dist/core/runner/tool-face-overlay.d.ts +3 -1
- package/dist/core/runner/tool-face-overlay.js +6 -4
- package/dist/core/runner/tool-occurrence.d.ts +106 -0
- package/dist/core/runner/tool-occurrence.js +123 -0
- package/dist/core/runner/tool-progress-lane.d.ts +16 -8
- package/dist/core/runner/tool-progress-lane.js +25 -34
- package/dist/core/runner/tool-turn-repair-seat.d.ts +28 -4
- package/dist/core/runner/tool-turn-repair-seat.js +36 -13
- package/dist/core/runner/turn-attachments.d.ts +1 -1
- package/dist/core/runner/write-protection-station.d.ts +21 -9
- package/dist/core/runner/write-protection-station.js +20 -17
- package/dist/core/runner-deps.d.ts +12 -22
- package/dist/core/secret-env.d.ts +16 -5
- package/dist/core/secret-env.js +23 -63
- package/dist/core/sensitive-path-policy.d.ts +19 -18
- package/dist/core/sensitive-path-policy.js +73 -49
- package/dist/core/session-reconcile.d.ts +3 -0
- package/dist/core/session-reconcile.js +5 -4
- package/dist/core/session-store.d.ts +5 -0
- package/dist/core/session-store.js +12 -0
- package/dist/core/session.d.ts +13 -0
- package/dist/core/shared-memory/normalize.d.ts +17 -4
- package/dist/core/shared-memory/normalize.js +7 -7
- package/dist/core/shell-lexer.js +5 -4
- package/dist/core/shell-wrapper-projection.js +1 -1
- package/dist/core/skill-grant.js +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +13 -0
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +7 -14
- package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +27 -0
- package/dist/core/store-contracts/session-store-incarnation-contract.js +92 -0
- package/dist/core/stub-env.d.ts +2 -0
- package/dist/core/stub-env.js +1 -0
- package/dist/core/synthetic-read-verdict.js +2 -2
- package/dist/core/task-event.d.ts +59 -5
- package/dist/core/task-result.d.ts +1 -1
- package/dist/core/task-spec.d.ts +42 -9
- package/dist/core/terminal-cause.d.ts +94 -11
- package/dist/core/tighten-task-spec.d.ts +5 -4
- package/dist/core/tighten-task-spec.js +20 -25
- package/dist/core/tool-catalog-entries.d.ts +5 -7
- package/dist/core/tool-catalog-entries.js +14 -15
- package/dist/core/tool-face.d.ts +47 -0
- package/dist/core/tool-face.js +5 -0
- package/dist/core/tool-model-gate.d.ts +5 -5
- package/dist/core/tool-name-aliases.d.ts +26 -2
- package/dist/core/tool-name-aliases.js +13 -0
- package/dist/core/tool-name-list.d.ts +30 -0
- package/dist/core/tool-name-list.js +55 -0
- package/dist/core/tool-name-readings.d.ts +1 -9
- package/dist/core/tool-name-readings.js +1 -3
- package/dist/core/tool-policy.d.ts +195 -85
- package/dist/core/tool-policy.js +165 -380
- package/dist/core/tool-registry.d.ts +44 -1
- package/dist/core/tool-registry.js +26 -0
- package/dist/core/tool-roster.d.ts +19 -1
- package/dist/core/tool-roster.js +21 -2
- package/dist/core/tool-spec-members.d.ts +45 -0
- package/dist/core/tool-spec-members.js +169 -0
- package/dist/core/tool-spec.d.ts +46 -8
- package/dist/core/tools.d.ts +6 -2
- package/dist/core/tools.js +8 -4
- package/dist/core/untrusted-egress.js +29 -26
- package/dist/core/untrusted-text.d.ts +13 -10
- package/dist/core/untrusted-text.js +6 -44
- package/dist/core/workflow-journal-store.d.ts +4 -1
- package/dist/core/write-protect.d.ts +65 -29
- package/dist/core/write-protect.js +235 -177
- package/dist/engine/compaction/compaction.d.ts +2 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +5 -23
- package/dist/engine/execution-env/node-execution-env.js +16 -38
- package/dist/engine/execution-env/symlink-chain.d.ts +23 -0
- package/dist/engine/execution-env/symlink-chain.js +32 -0
- package/dist/engine/harness/types.d.ts +7 -0
- package/dist/engine/llm/tool-turns.d.ts +3 -0
- package/dist/engine/llm/tool-turns.js +1 -0
- package/dist/engine/llm/types.d.ts +59 -23
- package/dist/engine/loop/agent-loop.js +16 -2
- package/dist/engine/session/memory-repo.js +11 -3
- package/dist/engine/session/repo-utils.d.ts +8 -0
- package/dist/engine/session/repo-utils.js +13 -0
- package/dist/index.d.ts +20 -23
- package/dist/index.js +17 -20
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/governance-baseline-validity.js +1 -1
- package/dist/orchestration/run-spec.js +3 -3
- package/dist/orchestration/run-workflow-tool.d.ts +16 -35
- package/dist/orchestration/run-workflow-tool.js +38 -78
- package/dist/orchestration/workflow-governance.d.ts +21 -25
- package/dist/orchestration/workflow-governance.js +38 -78
- package/dist/orchestration/workflow-primitives.d.ts +7 -22
- package/dist/orchestration/workflow-primitives.js +5 -12
- package/dist/orchestration/workflow-types.d.ts +1 -1
- package/dist/orchestration/workflow.d.ts +61 -11
- package/dist/orchestration/workflow.js +189 -117
- package/dist/scenarios/full-body.d.ts +1 -1
- package/dist/shell/lex.d.ts +0 -21
- package/dist/shell/lex.js +250 -68
- package/dist/shell/shell-words.d.ts +35 -0
- package/dist/shell/shell-words.js +65 -0
- package/dist/stores/file/checkpoint-store.d.ts +5 -5
- package/dist/stores/file/checkpoint-store.js +5 -2
- package/dist/stores/file/index.d.ts +0 -8
- package/dist/stores/file/index.js +0 -12
- package/dist/stores/file/session-store.d.ts +3 -0
- package/dist/stores/file/session-store.js +44 -19
- package/dist/tools/artifact/artifact-tool.js +2 -0
- package/dist/tools/fs/bash-program-position.d.ts +12 -4
- package/dist/tools/fs/bash-program-position.js +32 -9
- package/dist/tools/fs/bash-readonly-classifier.d.ts +1 -1
- package/dist/tools/fs/bash-readonly-classifier.js +8 -7
- package/dist/tools/fs/containment-face.d.ts +4 -0
- package/dist/tools/fs/containment-face.js +3 -0
- package/dist/tools/fs/fs-shared.d.ts +10 -0
- package/dist/tools/fs/fs-shared.js +18 -0
- package/dist/tools/fs/fs-write.js +4 -2
- package/dist/tools/fs/index.d.ts +1 -1
- package/dist/tools/fs/program-read-model.d.ts +46 -20
- package/dist/tools/fs/program-read-model.js +50 -20
- package/dist/tools/fs/program-read-model.rows.d.ts +0 -14
- package/dist/tools/fs/program-read-model.rows.js +16 -15
- package/dist/tools/fs/read-deny-home.d.ts +33 -47
- package/dist/tools/fs/read-deny-home.js +35 -49
- package/dist/tools/fs/read-deny.d.ts +23 -22
- package/dist/tools/fs/read-deny.js +114 -89
- package/dist/tools/fs/removal-targets.d.ts +56 -23
- package/dist/tools/fs/removal-targets.js +65 -87
- package/dist/tools/fs/safety.d.ts +29 -22
- package/dist/tools/fs/safety.js +17 -11
- package/dist/tools/fs/search.js +10 -8
- package/dist/tools/fs/shell-read-argv.js +1 -1
- package/dist/tools/fs/shell-read-bindings.d.ts +169 -37
- package/dist/tools/fs/shell-read-bindings.js +324 -86
- package/dist/tools/fs/shell-read-builtins.d.ts +35 -0
- package/dist/tools/fs/shell-read-builtins.js +43 -0
- package/dist/tools/fs/shell-read-check.d.ts +15 -1
- package/dist/tools/fs/shell-read-check.js +67 -43
- package/dist/tools/fs/shell-read-establish.js +6 -6
- package/dist/tools/fs/shell-read-functions.d.ts +22 -0
- package/dist/tools/fs/shell-read-functions.js +29 -0
- package/dist/tools/fs/shell-read-judge.d.ts +51 -18
- package/dist/tools/fs/shell-read-judge.js +40 -4
- package/dist/tools/fs/shell-read-plan.d.ts +12 -6
- package/dist/tools/fs/shell-read-plan.js +118 -113
- package/dist/tools/fs/shell-read-start.d.ts +29 -6
- package/dist/tools/fs/shell-read-start.js +16 -9
- package/dist/tools/fs/shell-read-word.js +4 -0
- package/dist/tools/fs/shell-read-workdir.d.ts +156 -0
- package/dist/tools/fs/shell-read-workdir.js +281 -0
- package/dist/tools/fs/shell-read-write-targets.d.ts +5 -2
- package/dist/tools/fs/shell-read-write-targets.js +14 -5
- package/dist/tools/fs/shell-reentry-text.d.ts +4 -6
- package/dist/tools/fs/shell-reentry-text.js +3 -11
- package/dist/tools/task-list.d.ts +1 -2
- package/dist/tools/web.js +1 -1
- package/package.json +4 -1
- package/test/export-surface.snapshot.json +107 -143
- package/wire-changes/core@7.49.0.json +4765 -0
- package/dist/agents/teacher.d.ts +0 -159
- package/dist/agents/teacher.js +0 -577
- package/dist/agents/team.d.ts +0 -226
- package/dist/agents/team.js +0 -257
- package/dist/core/strategy-store.d.ts +0 -238
- package/dist/core/strategy-store.js +0 -253
- package/dist/orchestration/builtin-workflows.d.ts +0 -133
- package/dist/orchestration/builtin-workflows.js +0 -159
- package/dist/scenarios/env.d.ts +0 -40
- package/dist/scenarios/env.js +0 -39
- package/dist/scenarios/scenario-registry.d.ts +0 -110
- package/dist/scenarios/scenario-registry.js +0 -140
- package/dist/scenarios/teacher-quickstart.d.ts +0 -40
- package/dist/scenarios/teacher-quickstart.js +0 -12
- package/dist/stores/cc/lockfile.d.ts +0 -10
- package/dist/stores/cc/lockfile.js +0 -98
- package/dist/stores/cc/mailbox-store.d.ts +0 -20
- package/dist/stores/cc/mailbox-store.js +0 -255
- package/dist/stores/cc/roster-adapter.d.ts +0 -12
- package/dist/stores/cc/roster-adapter.js +0 -117
- package/dist/stores/cc/sidecar-transcript.d.ts +0 -97
- package/dist/stores/cc/sidecar-transcript.js +0 -264
- package/dist/stores/cc/task-list-store.d.ts +0 -2
- package/dist/stores/cc/task-list-store.js +0 -125
- package/dist/stores/file/strategy-store.d.ts +0 -97
- package/dist/stores/file/strategy-store.js +0 -341
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isAskOrigin } from "../ask-origin.js";
|
|
2
|
+
import { isLiveQuestionFace, markBoundOnlyQuestionFace } from "../ask-question.js";
|
|
2
3
|
import { boundInputHashOf } from "../canonical-json.js";
|
|
3
4
|
import { CheckpointError } from "../checkpoint-store.js";
|
|
5
|
+
import { decidersNote, isHostDecider, settlementOfHostDecision } from "../gate-outcome.js";
|
|
4
6
|
import { formatHookFeedback } from "../hooks.js";
|
|
7
|
+
import { facetOf, isGateKind, isQuestionGate } from "../pause-registry.js";
|
|
8
|
+
import { humanRefusalSentence, policyCannotAnswer, screenApproverAttribution } from "../tool-policy.js";
|
|
9
|
+
import { mintGateOutcome } from "./gate-exit.js";
|
|
5
10
|
import { delimitUntrusted, REVIEWER_NOTE_MAX_BODY } from "../untrusted-text.js";
|
|
6
|
-
import {
|
|
11
|
+
import { engineCardOf } from "../tool-roster.js";
|
|
7
12
|
export function resumeDecisionWasNegative(resume) {
|
|
8
13
|
const o = resume.outcome;
|
|
9
14
|
return o.decision === "reject" || o.decision === "deny";
|
|
@@ -50,9 +55,7 @@ export function sameWinner(incoming, persisted) {
|
|
|
50
55
|
(persisted.reason === undefined || incoming.reason === persisted.reason));
|
|
51
56
|
}
|
|
52
57
|
export function pendingContentAskCallId(cp) {
|
|
53
|
-
return cp.pendingAction.kind === "tool_approval" &&
|
|
54
|
-
? cp.pendingAction.toolCallId
|
|
55
|
-
: undefined;
|
|
58
|
+
return cp.pendingAction.kind === "tool_approval" && engineCardOf(cp.pendingAction) === "question" ? cp.pendingAction.toolCallId : undefined;
|
|
56
59
|
}
|
|
57
60
|
export function answerFaceForRedeemedCall(answer, redeemedCallId, base, redeemedQuestionsHash) {
|
|
58
61
|
let consumed = false;
|
|
@@ -70,6 +73,54 @@ export function answerFaceForRedeemedCall(answer, redeemedCallId, base, redeemed
|
|
|
70
73
|
export function describeSuppliedValue(value) {
|
|
71
74
|
return typeof value === "string" ? value : value === null ? "null" : typeof value;
|
|
72
75
|
}
|
|
76
|
+
export const SUPPLIED_RECORD_KEY = ["gateOutcome", "the settlement record is minted by core from the host's decision facts and the row's origin, never supplied"];
|
|
77
|
+
export function refuseSuppliedKeys(decide, keys) {
|
|
78
|
+
for (const [key, why] of keys) {
|
|
79
|
+
if (Reflect.get(decide, key) !== undefined) {
|
|
80
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `resume carries \`${key}\` — ${why}; refusing pre-CAS, the checkpoint stays pending`, { field: "hostDecision" });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export function captureHostDecision(cp, raw, lane, verdict) {
|
|
85
|
+
if (typeof raw !== "object" || raw === null) {
|
|
86
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `resume carries no hostDecision — a ${lane} decide names who decided it ({ decidedBy: "person" | "sla_timeout" | "policy", approver? }); refusing pre-CAS, the checkpoint stays pending`, { field: "hostDecision" });
|
|
87
|
+
}
|
|
88
|
+
const decidedBy = raw.decidedBy;
|
|
89
|
+
if (!isHostDecider(decidedBy)) {
|
|
90
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `resume hostDecision.decidedBy "${describeSuppliedValue(decidedBy)}" is outside the closed set — it is exactly "person", "sla_timeout" or "policy"; refusing pre-CAS, the checkpoint stays pending`, { field: "hostDecision" });
|
|
91
|
+
}
|
|
92
|
+
const gateIsQuestion = isGateKind(cp.gate.kind) && isQuestionGate(cp.gate);
|
|
93
|
+
if (decidedBy === "sla_timeout" && !(isGateKind(cp.gate.kind) && facetOf(cp.gate) === "A")) {
|
|
94
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `resume hostDecision.decidedBy "sla_timeout" names the host's SLA sweep, which resolves approval rows only — this ${gateIsQuestion ? "question" : `"${String(cp.gate.kind)}"`} row's deadline is an abandonment TTL (expired, never resolved); refusing pre-CAS, the checkpoint stays pending`, { field: "hostDecision" });
|
|
95
|
+
}
|
|
96
|
+
const cannotAllow = !verdict.allows
|
|
97
|
+
? undefined
|
|
98
|
+
: decidedBy === "sla_timeout"
|
|
99
|
+
? ` — that word names a wait that ended with nobody answering, and it cannot approve an action that EXECUTES (an allow is decided by "person" or "policy")`
|
|
100
|
+
: policyCannotAnswer(cp, decidedBy)
|
|
101
|
+
? ` on a row that requires real approval — a policy's answer is not a person's, and this row demands a person (decide it as "person", or refuse it as "policy")`
|
|
102
|
+
: undefined;
|
|
103
|
+
if (cannotAllow !== undefined)
|
|
104
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `resume carries decision "${verdict.word}" decided by "${decidedBy}"${cannotAllow}; refusing pre-CAS, the checkpoint stays pending`, { field: "hostDecision" });
|
|
105
|
+
const attribution = screenApproverAttribution(raw.approver);
|
|
106
|
+
if (attribution.defect !== undefined) {
|
|
107
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `resume carries an approver attribution this engine refuses: ${attribution.defect}; refusing pre-CAS, the checkpoint stays pending`, { field: "approver" });
|
|
108
|
+
}
|
|
109
|
+
return { decidedBy, ...(attribution.approver !== undefined ? { approver: attribution.approver } : {}) };
|
|
110
|
+
}
|
|
111
|
+
export function parkedOriginOf(cp) {
|
|
112
|
+
if (cp.pendingAction.kind === "tool_approval")
|
|
113
|
+
return isAskOrigin(cp.pendingAction.origin) ? cp.pendingAction.origin : undefined;
|
|
114
|
+
return cp.pendingAction.kind === "plan_review" ? "plan_review" : undefined;
|
|
115
|
+
}
|
|
116
|
+
export function mintDecideRecord(cp, facts, verdict) {
|
|
117
|
+
const origin = parkedOriginOf(cp);
|
|
118
|
+
if (origin === undefined) {
|
|
119
|
+
throw new CheckpointError("checkpoint.unsupported_version", "this checkpoint's pending approval carries no origin word (a row minted before the ask's origin was persisted on the park) — its settlement cannot be recorded; the checkpoint stays pending", { reason: "origin_missing" });
|
|
120
|
+
}
|
|
121
|
+
const settlement = settlementOfHostDecision(facts, verdict.allowed ? "allowed" : "refused", verdict.note);
|
|
122
|
+
return mintGateOutcome({ ...(verdict.allowed ? {} : { deniedBy: "ask_resolution" }), settled: { settlement, origin } });
|
|
123
|
+
}
|
|
73
124
|
export function assertOutcomeText(value, field) {
|
|
74
125
|
if (value !== undefined && typeof value !== "string") {
|
|
75
126
|
throw new CheckpointError("checkpoint.invalid_outcome", `resume \`${field}\` is not a plain string (got ${typeof value}) — a decide's text payload is an operator's plain data, not a live object; refusing pre-CAS, the checkpoint stays pending`);
|
|
@@ -82,7 +133,7 @@ function reorientClause(fullShellReachable) {
|
|
|
82
133
|
return `Before continuing, ${source} to confirm what is already done, then continue the remaining work. ` +
|
|
83
134
|
"Do NOT restart the task or re-run work that is already committed.";
|
|
84
135
|
}
|
|
85
|
-
export function resumeContinuation(resume, mark, fullShellReachable) {
|
|
136
|
+
export function resumeContinuation(resume, mark, fullShellReachable, delegatedChild) {
|
|
86
137
|
if (resume.outcome.gate === "wake") {
|
|
87
138
|
return formatHookFeedback(`You were WOKEN from a parked pause by an operator. ${reorientClause(fullShellReachable)}`, mark);
|
|
88
139
|
}
|
|
@@ -96,36 +147,40 @@ export function resumeContinuation(resume, mark, fullShellReachable) {
|
|
|
96
147
|
return formatHookFeedback(`You were resumed after a dry-run review. ${verdict}. ${reorientClause(fullShellReachable)}`, mark);
|
|
97
148
|
}
|
|
98
149
|
if (resume.outcome.gate === "plan_review") {
|
|
150
|
+
const byWhom = resume.outcome.hostDecision.decidedBy === "policy" ? " by this deployment's own policy, not by a person" : "";
|
|
99
151
|
if (resume.outcome.decision === "approve") {
|
|
100
|
-
return formatHookFeedback(
|
|
152
|
+
return formatHookFeedback(`Your proposed PLAN was REVIEWED and APPROVED${byWhom}. Proceed with that plan now — begin executing it. ` +
|
|
101
153
|
"This is a RESUMED task; do NOT re-plan or restart from scratch, just carry out the approved plan.", mark);
|
|
102
154
|
}
|
|
103
155
|
if (resume.outcome.decision === "edit") {
|
|
104
156
|
if (!resume.outcome.editedPlan) {
|
|
105
|
-
return formatHookFeedback(
|
|
157
|
+
return formatHookFeedback(`Your proposed PLAN was REVIEWED and EDITED${byWhom}, but no revised plan text was supplied — proceed with your ` +
|
|
106
158
|
"ORIGINAL plan as-is, begin executing it now. This is a RESUMED task; do NOT re-plan or restart from scratch.", mark);
|
|
107
159
|
}
|
|
108
|
-
return formatHookFeedback(
|
|
160
|
+
return formatHookFeedback(`Your proposed PLAN was REVIEWED and EDITED${byWhom || " by a human reviewer"}. Proceed with the REVISED plan below ` +
|
|
109
161
|
"(it supersedes your earlier plan); begin executing it now. This is a RESUMED task; do NOT re-plan " +
|
|
110
162
|
"or restart from scratch, just carry out the revised plan.\n\nThe REVISED plan to follow is:\n" +
|
|
111
163
|
delimitUntrusted("revised plan", resume.outcome.editedPlan), mark);
|
|
112
164
|
}
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
"NOT execute the rejected plan
|
|
165
|
+
const { reason } = resume.outcome;
|
|
166
|
+
const policyNote = decidersNote(reason);
|
|
167
|
+
return formatHookFeedback(resume.outcome.hostDecision.decidedBy === "person"
|
|
168
|
+
? `${humanRefusalSentence("plan", reason, delegatedChild)} This is a RESUMED task; do NOT execute the rejected plan.`
|
|
169
|
+
: `Your proposed PLAN was REVIEWED and REJECTED${byWhom}; it was NOT executed.${policyNote === undefined ? "" : ` Reviewer note: ${delimitUntrusted("reviewer note", policyNote, REVIEWER_NOTE_MAX_BODY)}`} ` +
|
|
170
|
+
"This is a RESUMED task — re-plan from the current state; do NOT execute the rejected plan.", mark);
|
|
117
171
|
}
|
|
118
172
|
const { pendingAction } = resume.cp;
|
|
119
173
|
if (pendingAction.kind !== "tool_approval") {
|
|
120
174
|
return formatHookFeedback("This is a RESUMED task — continue from where you left off without restarting or re-running prior work.", mark);
|
|
121
175
|
}
|
|
122
|
-
const
|
|
176
|
+
const { decision, hostDecision } = resume.outcome;
|
|
177
|
+
const resumed = "This is a RESUMED task — every step before this point is already done and its results are in the conversation above. Do NOT restart the task or re-run any tool you already ran";
|
|
178
|
+
const carryOn = "; continue from this exact point, building on the existing results, and finish the remaining work.";
|
|
179
|
+
if (decision === "deny" && hostDecision.decidedBy === "person") {
|
|
180
|
+
return formatHookFeedback(`${humanRefusalSentence("tool use", resume.outcome.reason, delegatedChild)} ${resumed}${delegatedChild ? carryOn : "."}`, mark);
|
|
181
|
+
}
|
|
182
|
+
const decided = decision === "allow"
|
|
123
183
|
? "was APPROVED and has now been executed — its result is in the tool results above"
|
|
124
|
-
:
|
|
125
|
-
|
|
126
|
-
: `was DENIED${resume.outcome.reason ? `: ${delimitUntrusted("reviewer note", resume.outcome.reason, REVIEWER_NOTE_MAX_BODY)}` : ""}`;
|
|
127
|
-
return formatHookFeedback(`The pending tool call "${pendingAction.toolName}" ${decided}. ` +
|
|
128
|
-
`This is a RESUMED task — every step before this point is already done and its results are in the ` +
|
|
129
|
-
`conversation above. Do NOT restart the task or re-run any tool you already ran; continue from this ` +
|
|
130
|
-
`exact point, building on the existing results, and finish the remaining work.`, mark);
|
|
184
|
+
: `was DENIED ${hostDecision.decidedBy === "policy" ? "by this deployment's own policy" : "because its approval window elapsed with no answer"}, not by a person — the refusal and its reason are in the tool results above`;
|
|
185
|
+
return formatHookFeedback(`The pending tool call "${pendingAction.toolName}" ${decided}. ${resumed}${carryOn}`, mark);
|
|
131
186
|
}
|
|
@@ -2,6 +2,7 @@ import { type AutoModeDecider, type AutoModeDenialLimitOptions, type AutoModeDen
|
|
|
2
2
|
import { type AutoModeArmingRecipe } from "../auto-mode-arming.js";
|
|
3
3
|
import { type ClassifierUnavailableSeat } from "../classifier-unavailable-arm.js";
|
|
4
4
|
import { type PermissionResult, type ResolvedAsk, type ToolCallRequest } from "../tool-policy.js";
|
|
5
|
+
import { type Settlement } from "../gate-outcome.js";
|
|
5
6
|
import { type EngineNotice } from "../types.js";
|
|
6
7
|
import { type AskClass, type AskClassFacts, type AskClassification, type AskOrigin, type AskOriginFacts } from "../ask-origin.js";
|
|
7
8
|
import type { Prepared, StopForDenialLimit } from "./contracts.js";
|
|
@@ -220,12 +221,23 @@ type ResolveJudgment<A extends InheritedAsk> = Extract<InheritedClassifierJudgme
|
|
|
220
221
|
export declare function inheritedFallbackJudgment<A extends InheritedAsk>(ask: A, fallback: UnarmedDenialLimitFallback, latestBlockedAction: string, facts: AskClassFacts): ResolveJudgment<A>;
|
|
221
222
|
/** One resolution of an inherited ask at its frozen approver (the three arms): a no-ruling card its POLICY refused counts
|
|
222
223
|
* ({@link settleNoRulingAsk}); at the bound the call is resolved again there as the fallback. Returns the judgment it answered. */
|
|
223
|
-
export declare function resolveInheritedAsk<A extends InheritedAsk
|
|
224
|
-
|
|
224
|
+
export declare function resolveInheritedAsk<A extends InheritedAsk>(judged: ResolveJudgment<A>, resolveWith: (j: ResolveJudgment<A>) => Promise<ResolvedAsk>, tracker: AutoModeDenialTracker | undefined, call: {
|
|
225
|
+
toolCallId: string;
|
|
226
|
+
toolName: string;
|
|
227
|
+
}, facts: AskClassFacts): Promise<{
|
|
228
|
+
resolved: ResolvedAsk;
|
|
225
229
|
judged: ResolveJudgment<A>;
|
|
226
230
|
}>;
|
|
227
|
-
/** The resolver's answer as the settlement reads it. */
|
|
228
|
-
export type FallbackResolution =
|
|
231
|
+
/** The resolver's answer as the settlement reads it: its action, the settlement its engine record names for the call, the routing marker. */
|
|
232
|
+
export type FallbackResolution = {
|
|
233
|
+
action: ResolvedAsk["action"];
|
|
234
|
+
settlement?: Settlement;
|
|
235
|
+
approverUnavailable?: true;
|
|
236
|
+
};
|
|
237
|
+
export declare const fallbackResolutionOf: (r: ResolvedAsk, call: {
|
|
238
|
+
toolCallId: string;
|
|
239
|
+
toolName: string;
|
|
240
|
+
}) => FallbackResolution;
|
|
229
241
|
/** A deny nobody JUDGED, at a wrapper arm — read off the one table over the settlement words
|
|
230
242
|
* ({@link SETTLEMENT_NOBODY_JUDGED}) rather than listed here, so a word added to the set answers this
|
|
231
243
|
* question by getting a row and not by falling out of a disjunction. `approver_unavailable` is NOT
|
|
@@ -245,7 +257,7 @@ export declare function settleDenialLimitFallback(opts: {
|
|
|
245
257
|
fallback: UnarmedDenialLimitFallback | undefined;
|
|
246
258
|
mintedHere: boolean;
|
|
247
259
|
tracker: AutoModeDenialTracker | undefined;
|
|
248
|
-
resolved:
|
|
260
|
+
resolved: ResolvedAsk;
|
|
249
261
|
headless: (r: FallbackResolution) => boolean;
|
|
250
262
|
stop: StopForDenialLimit;
|
|
251
263
|
toolName: string;
|
|
@@ -2,7 +2,7 @@ import { markTightenMessage } from "../safety-axis-vocab.js";
|
|
|
2
2
|
import { classifierParseFailureDenyMessage, createAutoModeDenialTracker, denialLimitFallbackMessage, denialLimitSentence, isAutoModeFallbackCause, rungDidNotRule, unarmedWindow } from "../auto-mode.js";
|
|
3
3
|
import { sanitizeAutoModeArmingRecipe, tightenDenialLimit } from "../auto-mode-arming.js";
|
|
4
4
|
import { classifierNoRulingArm, settleNoRulingAsk } from "../classifier-unavailable-arm.js";
|
|
5
|
-
import {
|
|
5
|
+
import { attest, attestationOf } from "../tool-policy.js";
|
|
6
6
|
import { SETTLEMENT_NOBODY_JUDGED } from "../gate-outcome.js";
|
|
7
7
|
import { deliverEngineNotice } from "../types.js";
|
|
8
8
|
import { inlineUntrusted } from "../untrusted-text.js";
|
|
@@ -88,7 +88,7 @@ export async function judgeInheritedClassifier(opts) {
|
|
|
88
88
|
const { autoMode, req } = opts;
|
|
89
89
|
const facts = opts.facts ?? INHERITED_STATION_FACTS, m = facts.mandateMarks;
|
|
90
90
|
const frames = [...(m.egress === true ? [markTightenMessage(req.toolName, "egress")] : []), ...(m.irreversibility === "always" ? [markTightenMessage(req.toolName, "irreversible")] : [])];
|
|
91
|
-
const ask = (frames.length > 0 ?
|
|
91
|
+
const ask = (frames.length > 0 ? { ...opts.ask, message: [opts.ask.message ?? inheritedAskFallbackMessage(req.toolName), ...frames].join(" — ") } : opts.ask);
|
|
92
92
|
const origin = askOriginOf(ask, facts);
|
|
93
93
|
const classification = classifyAsk(ask, facts);
|
|
94
94
|
const classifierStandsDown = () => {
|
|
@@ -103,7 +103,7 @@ export async function judgeInheritedClassifier(opts) {
|
|
|
103
103
|
.catch(() => ({ kind: "unavailable", cause: "error" }));
|
|
104
104
|
if (verdict.kind === "allow" && classifierStandsDown())
|
|
105
105
|
return { kind: "resolve", ask, fallback: ask.denialLimitFallback, mintedHere: false, origin, classification };
|
|
106
|
-
const attributed = (d) => (verdict.classifier !== undefined ?
|
|
106
|
+
const attributed = (d) => (verdict.classifier !== undefined ? attest(d, req, { classifierRound: verdict.classifier }) : d);
|
|
107
107
|
if (verdict.kind === "allow") {
|
|
108
108
|
autoMode.denialTracking?.recordAllow();
|
|
109
109
|
return { kind: "allow", result: attributed({ action: "allow", decisionReason: "classifier", ...(opts.allowRewrite !== undefined ? { updatedInput: opts.allowRewrite } : {}) }) };
|
|
@@ -123,23 +123,24 @@ export async function judgeInheritedClassifier(opts) {
|
|
|
123
123
|
message: verdict.kind === "block" ? `auto-mode classifier blocked ${opts.subject} at an inherited ancestor layer${reason ? `: ${reason}` : category ? `: [${category}]` : ""}` : `${reason} (${opts.subject}, at an inherited ancestor layer)`,
|
|
124
124
|
decisionReason: "classifier",
|
|
125
125
|
};
|
|
126
|
-
return { kind: "deny", result: attributed(verdict.kind === "parse_error" ?
|
|
126
|
+
return { kind: "deny", result: attributed(verdict.kind === "parse_error" ? attest(denied, req, { classifierCause: "parse_error" }) : denied) };
|
|
127
127
|
}
|
|
128
128
|
return inheritedFallbackJudgment(ask, tracked.fallback, reason || category || req.toolName, facts);
|
|
129
129
|
}
|
|
130
130
|
export function inheritedFallbackJudgment(ask, fallback, latestBlockedAction, facts) {
|
|
131
131
|
const { classifierNoRuling: _why, ...standing } = ask;
|
|
132
|
-
const minted =
|
|
132
|
+
const minted = { ...standing, message: denialLimitFallbackMessage(fallback, latestBlockedAction), decisionReason: "classifier", requiresRealApproval: true, denialLimitFallback: fallback };
|
|
133
133
|
return { kind: "resolve", ask: minted, fallback, mintedHere: true, origin: askOriginOf(minted, facts), classification: classifyAsk(minted, facts) };
|
|
134
134
|
}
|
|
135
|
-
export async function resolveInheritedAsk(judged, resolveWith, tracker,
|
|
135
|
+
export async function resolveInheritedAsk(judged, resolveWith, tracker, call, facts) {
|
|
136
136
|
const resolved = await resolveWith(judged);
|
|
137
|
-
const refallback = settleNoRulingAsk({ ask: judged.ask, mintedHere: judged.noRulingHere === true, resolved, tracker });
|
|
137
|
+
const refallback = settleNoRulingAsk({ ask: judged.ask, mintedHere: judged.noRulingHere === true, resolved: fallbackResolutionOf(resolved, call), tracker });
|
|
138
138
|
if (refallback === undefined)
|
|
139
139
|
return { resolved, judged };
|
|
140
|
-
const again = inheritedFallbackJudgment(judged.ask, refallback, toolName, facts);
|
|
140
|
+
const again = inheritedFallbackJudgment(judged.ask, refallback, call.toolName, facts);
|
|
141
141
|
return { resolved: await resolveWith(again), judged: again };
|
|
142
142
|
}
|
|
143
|
+
export const fallbackResolutionOf = (r, call) => ({ action: r.action, settlement: attestationOf(r, call)?.settlement, ...(r.approverUnavailable === true ? { approverUnavailable: true } : {}) });
|
|
143
144
|
export function headlessDenyAtFold(r) {
|
|
144
145
|
return r.settlement !== undefined && SETTLEMENT_NOBODY_JUDGED[r.settlement.kind];
|
|
145
146
|
}
|
|
@@ -147,9 +148,10 @@ export function headlessDenyAtRecheck(r) {
|
|
|
147
148
|
return headlessDenyAtFold(r) || r.settlement?.kind === "approver_unavailable" || r.approverUnavailable === true;
|
|
148
149
|
}
|
|
149
150
|
export function settleDenialLimitFallback(opts) {
|
|
150
|
-
const { fallback
|
|
151
|
+
const { fallback } = opts;
|
|
151
152
|
if (fallback === undefined)
|
|
152
153
|
return;
|
|
154
|
+
const resolved = fallbackResolutionOf(opts.resolved, opts);
|
|
153
155
|
if (resolved.action === "allow") {
|
|
154
156
|
if (opts.mintedHere)
|
|
155
157
|
opts.tracker?.recordAllow();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EngineNotice } from "../engine-notice.js";
|
|
2
|
+
/** Where the announcement goes and whom it is attributed to — the same triple as the sibling `route.*` seats. */
|
|
3
|
+
export interface ExtraBodyDroppedSeatInput {
|
|
4
|
+
onNotice: ((notice: EngineNotice) => void) | undefined;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
runId: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function createExtraBodyDroppedScope({ onNotice, sessionId, runId }: ExtraBodyDroppedSeatInput): <T>(fn: () => Promise<T>) => Promise<T>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { runWithExtraBodyDropped } from "../../brain/status-sink.js";
|
|
2
|
+
import { deliverEngineNotice } from "../engine-notice.js";
|
|
3
|
+
export function createExtraBodyDroppedScope({ onNotice, sessionId, runId }) {
|
|
4
|
+
const announced = new Set();
|
|
5
|
+
return (fn) => runWithExtraBodyDropped(({ api, modelId, keys }) => {
|
|
6
|
+
if (keys.length === 0)
|
|
7
|
+
return;
|
|
8
|
+
const set = `${api}\u0000${[...keys].sort().join("\u0000")}`;
|
|
9
|
+
if (announced.has(set))
|
|
10
|
+
return;
|
|
11
|
+
announced.add(set);
|
|
12
|
+
const many = keys.length > 1;
|
|
13
|
+
deliverEngineNotice(onNotice, {
|
|
14
|
+
code: "route.extra_body_reserved_dropped",
|
|
15
|
+
message: `The extraBody of a ${api} request sent as "${modelId}" carried ${many ? "keys" : "a key"} the engine sets itself — ` +
|
|
16
|
+
`${keys.map((k) => `"${k}"`).join(", ")} — and ${many ? "they were" : "it was"} dropped: the request went out ` +
|
|
17
|
+
`with the engine's own value${many ? "s" : ""} (or without ${many ? "them" : "it"}, where the engine sends none). Remove ${many ? "them" : "it"} from extraBody; ` +
|
|
18
|
+
`the same drop applies to every request that model spec is used on, and this notice is said once per run for this set of keys.`,
|
|
19
|
+
detail: { keys: [...keys], api, modelId, sessionId, runId },
|
|
20
|
+
});
|
|
21
|
+
}, fn);
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EngineNotice } from "../engine-notice.js";
|
|
2
|
+
export interface FinishReasonSeat {
|
|
3
|
+
/** Observe one assistant message; announce each stream-end fact this leg has not announced yet. */
|
|
4
|
+
observe(message: unknown): void;
|
|
5
|
+
}
|
|
6
|
+
export declare function createFinishReasonSeat(onNotice: ((notice: EngineNotice) => void) | undefined, ids: {
|
|
7
|
+
sessionId: string;
|
|
8
|
+
runId: string;
|
|
9
|
+
}): FinishReasonSeat;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { deliverEngineNotice } from "../engine-notice.js";
|
|
2
|
+
import { readMember } from "../thrown-value.js";
|
|
3
|
+
export function createFinishReasonSeat(onNotice, ids) {
|
|
4
|
+
const announced = new Set();
|
|
5
|
+
const once = (key) => {
|
|
6
|
+
if (announced.has(key))
|
|
7
|
+
return false;
|
|
8
|
+
announced.add(key);
|
|
9
|
+
return true;
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
observe(message) {
|
|
13
|
+
const word = readMember(message, "finishReasonUnknown");
|
|
14
|
+
if (typeof word === "string" && once(`unknown\u0000${word}`)) {
|
|
15
|
+
deliverEngineNotice(onNotice, {
|
|
16
|
+
code: "route.finish_reason_unknown",
|
|
17
|
+
message: `The provider ended a response with "${word}", a finish reason this engine does not read. The turn was kept ` +
|
|
18
|
+
`as the model left it, but the provider may have cut it short — the text above may be incomplete.`,
|
|
19
|
+
detail: { finishReason: word, sessionId: ids.sessionId, runId: ids.runId },
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const late = readMember(message, "streamEndIgnored");
|
|
23
|
+
const statement = readMember(late, "statement");
|
|
24
|
+
const lateWord = readMember(late, "word");
|
|
25
|
+
const frames = readMember(late, "frames");
|
|
26
|
+
if ((statement === "ending" || statement === "error" || statement === "content") &&
|
|
27
|
+
typeof lateWord === "string" &&
|
|
28
|
+
typeof frames === "number" &&
|
|
29
|
+
once(`late\u0000${statement}\u0000${lateWord}`)) {
|
|
30
|
+
const what = statement === "error" ? `an error "${lateWord}"` : statement === "ending" ? `the ending "${lateWord}"` : `${lateWord} content`;
|
|
31
|
+
deliverEngineNotice(onNotice, {
|
|
32
|
+
code: "route.stream_end_ignored",
|
|
33
|
+
message: `After the provider had already ended a response, its stream sent more (first: ${what}; ${frames} frame${frames === 1 ? "" : "s"} in all). ` +
|
|
34
|
+
`The first ending stands; nothing after it was added to the turn.`,
|
|
35
|
+
detail: { statement, word: lateWord, frames, sessionId: ids.sessionId, runId: ids.runId },
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* refused, written once at the refusing site; WHAT was settled, written at the resolution site) and hands
|
|
7
7
|
* them here; the mint assembles the record, runs the invariant screen, and refuses a record the engine
|
|
8
8
|
* composed wrong. Every projection of the outcome (the deny observer's payload, the call's `tool_end`
|
|
9
|
-
* frame, the
|
|
9
|
+
* frame, the call's occurrence record) is the object minted here, never a re-derivation;
|
|
10
10
|
* - the settlement LEDGER of a pass ({@link createSettlementLedger}) — the one rule every attestation read
|
|
11
11
|
* goes through;
|
|
12
12
|
* - the PASS RECORD ({@link GatePass}) — the per-call cells the gate's station groups read and write, and
|
|
@@ -28,10 +28,12 @@ import { type PermissionResult, type ResolvedAsk, type ToolCallRequest } from ".
|
|
|
28
28
|
import type { SafeNotifier } from "../safe-notify.js";
|
|
29
29
|
import type { HookSeatOutcome, PermissionDeniedPayload, PreToolUseResult, ToolGateInput, ToolGateResult } from "../hooks.js";
|
|
30
30
|
/** The ask a gate pass settled, as the gate captured it at its resolution site: the settlement the
|
|
31
|
-
* resolver composed and the origin word the ask carried. Both or neither (invariant I1).
|
|
31
|
+
* resolver composed and the origin word the ask carried. Both or neither (invariant I1). `licensed` is the engine record's
|
|
32
|
+
* digest of the bytes the settlement licensed: the allow exit keeps a settlement only for the bytes that run. */
|
|
32
33
|
export interface SettledAsk {
|
|
33
34
|
settlement: Settlement;
|
|
34
35
|
origin: AskOrigin;
|
|
36
|
+
licensed?: string;
|
|
35
37
|
}
|
|
36
38
|
/** The facts a gate pass hands the mint. `deniedBy` is present exactly when the pass refused; `cause` only
|
|
37
39
|
* beside it, when the refusing round was a classifier round that did not rule (the station's attestation,
|
|
@@ -62,43 +64,42 @@ export declare function mintGateOutcome(facts: GateExitFacts): GateOutcome;
|
|
|
62
64
|
export declare function directDeny(deniedBy: Exclude<DeniedBy, "ask_resolution">): GateOutcome;
|
|
63
65
|
/**
|
|
64
66
|
* The gate's settlement LEDGER for one pass — the one place "which ask did this pass consume" is written,
|
|
65
|
-
* with ONE rule for every
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
67
|
+
* with ONE rule for every read, all through the decision's engine record ({@link attestationOf}):
|
|
68
|
+
* - a record on an adjudication (the approval factory's wait ended inside a policy `check()`; an inherited
|
|
69
|
+
* lane resolved an ancestor's ask) is a settled ask of THIS call — an approval only for the bytes it licensed (an
|
|
70
|
+
* allow that runs other bytes runs unattributed); a deny carrying a REFUSAL record is the
|
|
71
|
+
* ask's own resolution (`ask_resolution`), a deny carrying a person's YES is a later layer's VETO (the yes
|
|
72
|
+
* stays on the settlement, the layer is the disposition — invariant I3), and an allow carrying a refusal
|
|
73
|
+
* record is that refusal (invariant I4: the record says what ended the wait, whatever the decision claims);
|
|
74
|
+
* - a resolution's record counts only when it answers THE ask the gate put to the resolver — its origin word,
|
|
75
|
+
* its class set, the bytes the answer licenses (the record's `inputDigest`); a resolution
|
|
76
|
+
* without such a record settled nothing the engine can attribute: a deny is recorded as the resolver's
|
|
77
|
+
* out-of-contract refusal (`approver_contract`), an allow on a real-approval ask is refused, a plain allow
|
|
78
|
+
* is a posture allow; a resolution still carrying the retired `settlement` member is refused loudly;
|
|
73
79
|
* - the LATEST resolution wins (a re-check refusal replaces the first approval; a re-approval renews it);
|
|
74
80
|
* - a SURVIVING ask supersedes any settlement read off an earlier decision (a tighten minted a new
|
|
75
81
|
* question; whoever resolves it settles it afresh).
|
|
76
|
-
* For a resolver's object the attestation outranks the exposed member; the member is the fallback for a
|
|
77
|
-
* resolver seat that composes without attesting (a hand-built resolver; the ask lane's own intercept
|
|
78
|
-
* deny). TRUST BOUNDARY, stated: `ToolGateInput.resolveAsk` is wired by prepare from the engine's own
|
|
79
|
-
* resolver — a wrapper that spreads a resolved object (dropping the identity-keyed attestation) and
|
|
80
|
-
* REPLACES the member is inside the engine's trust line, not a deployment's; making the member
|
|
81
|
-
* attestation-only is the follow-up that migrates the ask lane's composition and the test resolvers
|
|
82
|
-
* onto an engine-owned mint.
|
|
83
82
|
*/
|
|
84
83
|
export interface SettlementLedger {
|
|
85
84
|
/** The ask this pass consumed, or undefined when no ask was settled (a direct deny, a plain allow). */
|
|
86
85
|
readonly settled: SettledAsk | undefined;
|
|
87
86
|
/** An engine-composed settlement the gate itself minted (the unshown content ask's refusal). */
|
|
88
87
|
set(settled: SettledAsk): void;
|
|
89
|
-
/** Record an ask's resolution
|
|
90
|
-
fromResolved(resolved: ResolvedAsk, asked: PermissionResult,
|
|
91
|
-
/** Read an adjudication's
|
|
92
|
-
* for
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
88
|
+
/** Record an ask's resolution; returns the resolution the gate goes on with (the resolver's, or the engine's refusal). */
|
|
89
|
+
fromResolved(resolved: ResolvedAsk, asked: PermissionResult, req: ToolCallRequest): ResolvedAsk;
|
|
90
|
+
/** Read an adjudication's record; returns the decision the gate goes on with and, for a deny, the refusing layer word
|
|
91
|
+
* (`ask_resolution` for a refusal record, `policy` otherwise — a veto when a yes rides the settlement). */
|
|
92
|
+
fromDecision(decision: PermissionResult): {
|
|
93
|
+
decision: PermissionResult;
|
|
94
|
+
deniedBy?: DeniedBy;
|
|
95
|
+
};
|
|
96
|
+
/** The allow exit: the bytes that RUN are decided — a settlement licensed for other bytes leaves the record (the call runs
|
|
97
|
+
* unattributed). */
|
|
98
|
+
keepForBytes(runs: unknown): void;
|
|
99
|
+
/** A deny's recorded classifier CAUSE for this call (an inherited station's `unavailable` / `parse_error` outcome). */
|
|
98
100
|
causeOf(decision: PermissionResult): ClassifierDenyCause | undefined;
|
|
99
|
-
/**
|
|
100
|
-
*
|
|
101
|
-
* classifier judged the call, or when the ancestor's decider could vouch for no name. */
|
|
101
|
+
/** A decision's recorded CLASSIFICATION for this call — which model an ancestor's frozen classifier asked and which
|
|
102
|
+
* answered, on either arm. */
|
|
102
103
|
classifierRoundOf(decision: PermissionResult): AutoModeClassifierRound | undefined;
|
|
103
104
|
/** A surviving ask supersedes whatever an earlier decision settled. */
|
|
104
105
|
supersede(): void;
|
|
@@ -116,6 +117,15 @@ export declare function createSettlementLedger(call: {
|
|
|
116
117
|
* a non-object primitive passes through as-is (immutable anyway).
|
|
117
118
|
*/
|
|
118
119
|
export declare function cloneObserverInput(input: unknown): unknown;
|
|
120
|
+
/**
|
|
121
|
+
* The input a gate exit decided on, as the call's record keeps it ({@link ToolGateResult.finalInput}): a deep,
|
|
122
|
+
* FROZEN copy — never the live object the tool receives (a tool or a later layer writing into its own arguments
|
|
123
|
+
* must not rewrite what the gate decided), and never writable by a reader; the deny observer gets a writable
|
|
124
|
+
* {@link cloneObserverInput} of it. A graph `structuredClone` refuses (functions, handles) is kept as a shallow
|
|
125
|
+
* copy frozen at its own top level only — its members are the live arguments' own, and freezing those would
|
|
126
|
+
* freeze the call's input under the tool.
|
|
127
|
+
*/
|
|
128
|
+
export declare function frozenInputSnapshot(input: unknown): unknown;
|
|
119
129
|
/**
|
|
120
130
|
* The PreToolUse screening face as the gate's stations see it — the hook machinery of `runToolGate` (the seat
|
|
121
131
|
* runner, the per-call seat bound, the fresh per-screening context, the result screen, the two fail-closed
|
|
@@ -297,9 +307,11 @@ export interface GatePass {
|
|
|
297
307
|
* on BOTH its arms (a write tool's target), and the fold's read station (a shell command's written targets,
|
|
298
308
|
* `ShellReadVerdict.writeProtected`). Reader: the lanes' mandate. */
|
|
299
309
|
writeProtected?: true;
|
|
300
|
-
/** borrowed-mutable — the
|
|
301
|
-
*
|
|
302
|
-
|
|
310
|
+
/** borrowed-mutable — the READING of a written target could not say where it leads on disk (a target a shell command's
|
|
311
|
+
* program writes, placed, whose destination the read station could not resolve): no automatic lane may answer the ask.
|
|
312
|
+
* A fact of the reading, not of a judge. Writer: the fold's read station (`ShellReadVerdict.targetUnresolved`). Reader:
|
|
313
|
+
* the lanes' mandate. */
|
|
314
|
+
targetUnresolved?: true;
|
|
303
315
|
/** borrowed-mutable — the rewrite remembered BEFORE a hook-ask promotion / tighten, re-applied on the
|
|
304
316
|
* approved path (a redaction is not cancelled because a person confirmed). Writer: the fold. Readers: the
|
|
305
317
|
* fold's probe and write-protection judges, the lanes, the allow exit. */
|