@sema-agent/core 7.57.0 → 7.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1161 -0
- package/README.md +6 -4
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +5 -3
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/send-message-tool.js +21 -12
- package/dist/agents/subagent-steps.js +2 -4
- package/dist/agents/subagent.js +33 -34
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +89 -22
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +62 -5
- package/dist/brain/timeout.js +93 -6
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +23 -10
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/allow-entry.d.ts +20 -7
- package/dist/core/allow-entry.js +18 -9
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/ask-origin.d.ts +21 -2
- package/dist/core/ask-origin.js +5 -1
- package/dist/core/auto-compaction.d.ts +4 -0
- package/dist/core/auto-compaction.js +2 -2
- package/dist/core/auto-mode-directive.d.ts +29 -5
- package/dist/core/auto-mode-directive.js +38 -8
- package/dist/core/background-agent-store.d.ts +16 -3
- package/dist/core/checkpoint-requirements.d.ts +19 -1
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-store.d.ts +85 -23
- package/dist/core/checkpoint-store.js +31 -9
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/compliance.js +1 -1
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +99 -9
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/fs-write-gate-policy.d.ts +4 -2
- package/dist/core/fs-write-gate-policy.js +7 -3
- package/dist/core/gate-fold.js +7 -4
- package/dist/core/gate-lanes.js +19 -6
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/git-worktree-env.d.ts +53 -11
- package/dist/core/git-worktree-env.js +96 -12
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +13 -0
- package/dist/core/hooks.d.ts +35 -4
- package/dist/core/hooks.js +17 -11
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/image-admission.d.ts +6 -5
- package/dist/core/image-admission.js +18 -14
- package/dist/core/locked-config.d.ts +20 -3
- package/dist/core/locked-config.js +40 -3
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-call-meta.d.ts +66 -0
- package/dist/core/mcp-call-meta.js +103 -0
- package/dist/core/mcp-connection-pool.d.ts +3 -1
- package/dist/core/mcp-connection-pool.js +3 -1
- package/dist/core/mcp-failure.d.ts +117 -15
- package/dist/core/mcp-failure.js +71 -3
- package/dist/core/mcp-probe.d.ts +4 -0
- package/dist/core/mcp-probe.js +1 -1
- package/dist/core/mcp-server-link.d.ts +27 -3
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp-server-spec.d.ts +46 -18
- package/dist/core/mcp-server-spec.js +1 -18
- package/dist/core/mcp.d.ts +16 -20
- package/dist/core/mcp.js +112 -55
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/scope-contract.d.ts +45 -4
- package/dist/core/memory-engine/scope-contract.js +80 -11
- package/dist/core/memory-engine/sync-client.d.ts +9 -1
- package/dist/core/memory-engine/sync-client.js +31 -8
- package/dist/core/memory-engine/sync.d.ts +5 -0
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mode-policy.d.ts +8 -5
- package/dist/core/mode-policy.js +5 -4
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/host.js +1 -1
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +12 -9
- package/dist/core/mods/kernel/events.d.ts +6 -1
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/registration.d.ts +9 -1
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/kernel/site-rules.d.ts +3 -0
- package/dist/core/mods/kernel/site-rules.js +10 -0
- package/dist/core/mods/package.d.ts +23 -0
- package/dist/core/mods/package.js +118 -0
- package/dist/core/mods/stations.d.ts +33 -12
- package/dist/core/mods/stations.js +45 -11
- package/dist/core/mods/tool-call.d.ts +5 -1
- package/dist/core/mods/tool-call.js +13 -4
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +6 -0
- package/dist/core/path-guard-rows.d.ts +20 -0
- package/dist/core/path-guard-rows.js +11 -0
- package/dist/core/peer-seat.d.ts +248 -0
- package/dist/core/peer-seat.js +439 -0
- package/dist/core/permission-rule-consent.js +10 -4
- package/dist/core/permission-rule-model.d.ts +16 -0
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/present-plan-tool.d.ts +20 -3
- package/dist/core/present-plan-tool.js +48 -4
- package/dist/core/protocol-http-auth.d.ts +40 -29
- package/dist/core/protocol-http-auth.js +30 -32
- package/dist/core/redaction-marks.d.ts +16 -0
- package/dist/core/redaction-marks.js +16 -0
- package/dist/core/redaction-passes.js +8 -9
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/retention.d.ts +41 -15
- package/dist/core/retention.js +59 -12
- package/dist/core/rewrite-rejudge.d.ts +38 -0
- package/dist/core/rewrite-rejudge.js +42 -2
- package/dist/core/roles.d.ts +34 -2
- package/dist/core/roles.js +43 -4
- package/dist/core/run-origin.d.ts +40 -0
- package/dist/core/run-origin.js +37 -0
- package/dist/core/runner/advertised-writable-dirs.d.ts +57 -38
- package/dist/core/runner/advertised-writable-dirs.js +126 -0
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/call-hook-stations.js +2 -2
- package/dist/core/runner/compaction-restate.d.ts +15 -6
- package/dist/core/runner/compaction-restate.js +28 -2
- package/dist/core/runner/contracts.d.ts +33 -21
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/gate-exit.d.ts +30 -8
- package/dist/core/runner/gate-exit.js +15 -8
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.js +3 -3
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +3 -1
- package/dist/core/runner/prepare-config-doors.d.ts +8 -5
- package/dist/core/runner/prepare-config-doors.js +14 -10
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +8 -0
- package/dist/core/runner/prepare-delegation-surface.js +16 -18
- package/dist/core/runner/prepare-gate-stations.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +11 -3
- package/dist/core/runner/prepare-hands-readface.js +9 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
- package/dist/core/runner/prepare-inherited-gate.js +14 -27
- package/dist/core/runner/prepare-memory.d.ts +3 -0
- package/dist/core/runner/prepare-memory.js +26 -37
- package/dist/core/runner/prepare-park-ask.d.ts +1 -1
- package/dist/core/runner/prepare-park-ask.js +2 -1
- package/dist/core/runner/prepare-policy-chain.d.ts +7 -7
- package/dist/core/runner/prepare-policy-chain.js +18 -15
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
- package/dist/core/runner/prepare-prompt-inputs.js +8 -19
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +11 -3
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +2 -1
- package/dist/core/runner/prepare-task.js +28 -13
- package/dist/core/runner/prepare-wiring-manifest.d.ts +2 -1
- package/dist/core/runner/prepare-wiring-manifest.js +4 -3
- package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
- package/dist/core/runner/prepare-workspace-restore.js +4 -4
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +5 -3
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-checkpoint-screen.js +2 -0
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-brain-sinks.js +2 -0
- package/dist/core/runner/run-harness-handlers.d.ts +3 -4
- package/dist/core/runner/run-harness-handlers.js +1 -8
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +6 -4
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +42 -29
- package/dist/core/runner/run-notification-lane.js +3 -0
- package/dist/core/runner/run-stop-and-final-verify.js +2 -2
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +77 -70
- package/dist/core/runner/runtask.d.ts +1 -1
- package/dist/core/runner/runtask.js +2 -2
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +10 -0
- package/dist/core/runner/terminal-account.js +3 -3
- package/dist/core/runner/tool-end-body.js +2 -1
- package/dist/core/runner/tool-occurrence.d.ts +5 -2
- package/dist/core/runner/tool-occurrence.js +4 -3
- package/dist/core/runner/turn-attachments.d.ts +26 -22
- package/dist/core/runner/turn-attachments.js +24 -26
- package/dist/core/runner/write-protection-station.d.ts +8 -2
- package/dist/core/runner/write-protection-station.js +2 -0
- package/dist/core/runner-deps.d.ts +3 -3
- package/dist/core/secret-env.d.ts +32 -2
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +9 -10
- package/dist/core/session-log-transfer.d.ts +24 -0
- package/dist/core/session-log-transfer.js +166 -0
- package/dist/core/session-policy-store.d.ts +3 -1
- package/dist/core/session-policy-store.js +13 -9
- package/dist/core/session-store.d.ts +86 -24
- package/dist/core/session-store.js +162 -24
- package/dist/core/session.d.ts +92 -1
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +8 -5
- package/dist/core/skill-grant.js +6 -6
- package/dist/core/steer-replay.d.ts +4 -2
- package/dist/core/steer-replay.js +2 -1
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +20 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/store-contracts/session-repo-contract.js +112 -5
- package/dist/core/store-contracts/session-store-contract.d.ts +4 -1
- package/dist/core/store-contracts/session-store-contract.js +236 -2
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +92 -8
- package/dist/core/task-notification.js +16 -10
- package/dist/core/task-registry-agent.js +1 -0
- package/dist/core/task-registry-shared.d.ts +7 -1
- package/dist/core/task-spec.d.ts +49 -1
- package/dist/core/task-stream.d.ts +2 -1
- package/dist/core/terminal-cause.d.ts +11 -1
- package/dist/core/tool-catalog-entries.js +1 -0
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-policy.d.ts +16 -0
- package/dist/core/tool-result-store.d.ts +17 -10
- package/dist/core/tool-result-store.js +3 -1
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +3 -1
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-egress.d.ts +0 -2
- package/dist/core/untrusted-egress.js +10 -14
- package/dist/core/user-attachment.js +1 -1
- package/dist/core/wiring-manifest.d.ts +18 -6
- package/dist/core/wiring-manifest.js +4 -3
- package/dist/core/workspace-snapshot.d.ts +44 -0
- package/dist/core/workspace-snapshot.js +34 -0
- package/dist/core/write-protect.d.ts +43 -3
- package/dist/core/write-protect.js +43 -16
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/node-execution-env.js +24 -23
- package/dist/engine/execution-env/symlink-chain.d.ts +7 -5
- package/dist/engine/harness/agent-harness.d.ts +30 -2
- package/dist/engine/harness/agent-harness.js +43 -12
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +56 -7
- package/dist/engine/harness/types.js +5 -1
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +30 -10
- package/dist/engine/llm/types.js +1 -1
- package/dist/engine/loop/agent-loop.d.ts +8 -0
- package/dist/engine/loop/agent-loop.js +52 -15
- package/dist/engine/loop/types.d.ts +3 -1
- package/dist/engine/session/import-validate.js +3 -0
- package/dist/engine/session/memory-repo.d.ts +17 -9
- package/dist/engine/session/memory-repo.js +44 -34
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/repo-utils.d.ts +22 -4
- package/dist/engine/session/repo-utils.js +49 -1
- package/dist/engine/session/storage-base.d.ts +10 -1
- package/dist/engine/session/storage-base.js +11 -22
- package/dist/index.d.ts +29 -16
- package/dist/index.js +21 -11
- package/dist/internal/harness-types.d.ts +2 -2
- package/dist/internal/harness.d.ts +3 -2
- package/dist/internal/harness.js +2 -2
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.js +739 -489
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/index.d.ts +4 -1
- package/dist/stores/file/index.js +4 -1
- package/dist/stores/file/mailbox-store.js +6 -10
- package/dist/stores/file/session-store.d.ts +15 -8
- package/dist/stores/file/session-store.js +28 -13
- package/dist/tools/fs/fs-bash.d.ts +6 -0
- package/dist/tools/fs/fs-bash.js +6 -3
- package/dist/tools/fs/fs-write.d.ts +6 -3
- package/dist/tools/fs/fs-write.js +8 -7
- package/dist/tools/fs/index.d.ts +3 -0
- package/dist/tools/fs/index.js +7 -3
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +19 -0
- package/dist/tools/fs/read-floor.js +23 -0
- package/dist/tools/fs/safety.js +40 -8
- package/dist/tools/fs/search.js +6 -24
- package/dist/tools/fs/shell-read-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +61 -16
- package/dist/tools/fs/shell-read-establish.js +2 -1
- package/dist/tools/fs/shell-read-identity.js +1 -1
- package/dist/tools/fs/shell-read-judge.d.ts +26 -9
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +2 -0
- package/dist/tools/worktree.d.ts +42 -15
- package/dist/tools/worktree.js +60 -32
- package/package.json +5 -2
- package/test/export-surface.snapshot.json +149 -1
- package/wire-changes/core-stores-sql@7.58.0.json +29 -0
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core@7.58.0.json +2188 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/mods-kernel@7.58.0.json +81 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/primitives@7.58.0.json +29 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
- package/dist/primitives/credential-ref.d.ts +0 -89
- package/dist/primitives/credential-ref.js +0 -125
- package/dist/primitives/index.d.ts +0 -2
- package/dist/primitives/index.js +0 -1
|
@@ -4,6 +4,8 @@ import { PROBE_CAUSE_PATH_MAX, PROBE_REASON_MAX, inlineUntrusted, sanitizeUntrus
|
|
|
4
4
|
import { carriesBidiControls } from "./tool-policy.js";
|
|
5
5
|
import { isAutoModeFallbackCause, readDenialLimitFallback } from "./auto-mode.js";
|
|
6
6
|
import { isAskOrigin, isPersistedRuleMandate } from "./ask-origin.js";
|
|
7
|
+
import { isRunOrigin, RUN_ORIGINS } from "./run-origin.js";
|
|
8
|
+
import { describeRejectedValue } from "./tool-search-setting.js";
|
|
7
9
|
import { readBoundBinding } from "./skill-grant-binding.js";
|
|
8
10
|
import { checkpointExecutionRecorded, executionRecordDisposition, ExecutionOutcomeConflictError, } from "./checkpoint-execution-record.js";
|
|
9
11
|
import { checkpointHolderMatches, checkpointOccMatches, checkpointRevOf } from "./checkpoint-generation.js";
|
|
@@ -13,6 +15,7 @@ import { renderUntrustedCommandText, stripFormatCharacters } from "./permission-
|
|
|
13
15
|
import { egressText } from "./untrusted-egress.js";
|
|
14
16
|
import { steerReplayRefusal } from "./steer-replay.js";
|
|
15
17
|
import { isPermissionMode } from "./ask-origin.js";
|
|
18
|
+
import { readRetentionDeclaration } from "./retention.js";
|
|
16
19
|
export function mintCheckpointToken() {
|
|
17
20
|
return randomBytes(16).toString("hex");
|
|
18
21
|
}
|
|
@@ -79,7 +82,7 @@ const BIDI_BACKFILL_MAX_NODES = 512;
|
|
|
79
82
|
export const MAX_PENDING_STEER_CHARS = 16_000;
|
|
80
83
|
export const PENDING_STEER_QUEUE_BYTE_BUDGET_BYTES = 48_000;
|
|
81
84
|
export const MAX_PENDING_STEER_ENTRIES = Math.floor(PENDING_STEER_QUEUE_BYTE_BUDGET_BYTES / MAX_PENDING_STEER_CHARS);
|
|
82
|
-
export const PENDING_STEER_FROZEN_FIELDS = Object.freeze(["text", "trusted", "actor", "seq", "inputId", "priority"]);
|
|
85
|
+
export const PENDING_STEER_FROZEN_FIELDS = Object.freeze(["text", "trusted", "actor", "seq", "inputId", "priority", "runOrigin"]);
|
|
83
86
|
export function isPlainRecord(x) {
|
|
84
87
|
try {
|
|
85
88
|
if (x === null || typeof x !== "object" || Array.isArray(x))
|
|
@@ -272,6 +275,12 @@ export function checkpointIndexFacts(cp) {
|
|
|
272
275
|
hasBidiControls: tool?.hasBidiControls === true ? true : null,
|
|
273
276
|
};
|
|
274
277
|
}
|
|
278
|
+
export function planReviewRequesterOf(pendingAction) {
|
|
279
|
+
if (pendingAction.kind !== "plan_review")
|
|
280
|
+
return undefined;
|
|
281
|
+
const id = pendingAction.requestedByCallId;
|
|
282
|
+
return typeof id === "string" && id !== "" ? id : undefined;
|
|
283
|
+
}
|
|
275
284
|
export function summarizeCheckpoint(cp, disclose) {
|
|
276
285
|
const facts = checkpointIndexFacts(cp);
|
|
277
286
|
const descriptor = facts.riskDescriptor;
|
|
@@ -282,6 +291,7 @@ export function summarizeCheckpoint(cp, disclose) {
|
|
|
282
291
|
}
|
|
283
292
|
const cardReading = parkedApprovalCardOf(cp.gate);
|
|
284
293
|
const tool = cp.pendingAction.kind === "tool_approval" ? cp.pendingAction : undefined;
|
|
294
|
+
const requestedByCallId = planReviewRequesterOf(cp.pendingAction);
|
|
285
295
|
let toolInput;
|
|
286
296
|
if (tool !== undefined) {
|
|
287
297
|
try {
|
|
@@ -310,12 +320,14 @@ export function summarizeCheckpoint(cp, disclose) {
|
|
|
310
320
|
...(cp.sourceTaskId !== undefined ? { sourceTaskId: cp.sourceTaskId } : {}),
|
|
311
321
|
...(cp.principal !== undefined ? { principal: cp.principal } : {}),
|
|
312
322
|
...(facts.toolCallId !== null ? { toolCallId: facts.toolCallId } : {}),
|
|
323
|
+
...(requestedByCallId !== undefined ? { requestedByCallId } : {}),
|
|
313
324
|
...(facts.toolName !== null ? { toolName: facts.toolName } : {}),
|
|
314
325
|
...(cardReading.kind === "card" ? { approvalCard: cardReading.card } : {}),
|
|
315
326
|
...(toolInput !== undefined ? { toolInput } : {}),
|
|
316
327
|
...(cp.state.workspaceHandle !== undefined
|
|
317
328
|
? { restoreMode: cp.state.workspaceHandle.restoreMode === "park_only" ? "park_only" : "snapshot" }
|
|
318
329
|
: {}),
|
|
330
|
+
...((runOrigin) => (isRunOrigin(runOrigin) ? { runOrigin } : {}))(cp.state.runOrigin),
|
|
319
331
|
...(tool?.preview !== undefined ? { preview: tool.preview } : {}),
|
|
320
332
|
...(tool?.previewWithheld === "oversize" || tool?.previewWithheld === "unavailable" ? { previewWithheld: tool.previewWithheld } : {}),
|
|
321
333
|
...(tool?.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
|
|
@@ -335,7 +347,7 @@ export function summarizeCheckpoint(cp, disclose) {
|
|
|
335
347
|
...(hasBidi ? { hasBidiControls: true } : {}),
|
|
336
348
|
};
|
|
337
349
|
}
|
|
338
|
-
export const CHECKPOINT_CONFIG_REFUSAL_CODES = Object.freeze(["config.spec_retired_key", "config.output_style_invalid", "config.permission_mode_invalid", "config.shell_gate_value_retired", "config.approval_reach_invalid", "config.user_invoked_skill_unknown", "config.skill_deny_unreadable", "config.user_attachment_invalid", "config.tool_face_control", "config.deps_retired_key", "config.peer_presence_invalid", "config.tool_model_gate_invalid", "config.microcompact_invalid", "config.prompt_selector_invalid", "resume_at.conflicts_resume", "resume_at.mode_without_target", "config.read_face_invalid", "config.write_face_invalid", "config.invalid_argument", "config.tool_face_invalid", "config.memory_delegation_evidence", "config.memory_provenance", "config.memory_capture_policy", "config.cross_boundary_posture", "config.advisor_tool_invalid", "config.advisor_model_invalid", "config.auto_consolidation", "config.unknown_role", "config.tool_materialize_invalid", "config.memory_persistence_invalid", "config.tool_materialize_unreachable", "config.locked_registry", "config.locked_key", "config.mcp_content_class", "config.skill_listing_budget_invalid", "config.limit_unknown_key", "config.limit_invalid", "config.attachment_invalid", "config.usage_window_invalid", "config.brain_call_guardrail_invalid", "config.retention_policy", "config.retention_capability", "config.invalid_checkpoint_store", "config.skill_base_dir_invalid", "config.host_floor_invalid"]);
|
|
350
|
+
export const CHECKPOINT_CONFIG_REFUSAL_CODES = Object.freeze(["config.spec_retired_key", "config.output_style_invalid", "config.permission_mode_invalid", "config.shell_gate_value_retired", "config.approval_reach_invalid", "config.run_origin_invalid", "config.user_invoked_skill_unknown", "config.skill_deny_unreadable", "config.user_attachment_invalid", "config.tool_face_control", "config.deps_retired_key", "config.peer_presence_invalid", "config.tool_model_gate_invalid", "config.microcompact_invalid", "config.prompt_selector_invalid", "resume_at.conflicts_resume", "resume_at.mode_without_target", "config.read_face_invalid", "config.write_face_invalid", "config.invalid_argument", "config.tool_face_invalid", "config.memory_delegation_evidence", "config.memory_provenance", "config.memory_capture_policy", "config.cross_boundary_posture", "config.advisor_tool_invalid", "config.advisor_model_invalid", "config.auto_consolidation", "config.unknown_role", "config.tool_materialize_invalid", "config.memory_persistence_invalid", "config.tool_materialize_unreachable", "config.locked_registry", "config.locked_key", "config.mcp_content_class", "config.skill_listing_budget_invalid", "config.limit_unknown_key", "config.limit_invalid", "config.attachment_invalid", "config.usage_window_invalid", "config.brain_call_guardrail_invalid", "config.retention_policy", "config.retention_capability", "config.invalid_checkpoint_store", "config.skill_base_dir_invalid", "config.host_floor_invalid", "config.credential_in_declaration", "config.credential_ref_invalid", "config.peer_seat_missing"]);
|
|
339
351
|
export const isCheckpointConfigRefusalCode = (word) => CHECKPOINT_CONFIG_REFUSAL_CODES.some((w) => w === word);
|
|
340
352
|
export class CheckpointError extends Error {
|
|
341
353
|
code;
|
|
@@ -450,6 +462,7 @@ export function validatePendingSteer(steer) {
|
|
|
450
462
|
const actor = steer.actor;
|
|
451
463
|
const inputId = steer.inputId;
|
|
452
464
|
const priority = steer.priority;
|
|
465
|
+
const runOrigin = steer.runOrigin;
|
|
453
466
|
if (typeof text !== "string") {
|
|
454
467
|
throw new CheckpointError("steering.invalid_content", "steering text must be a string");
|
|
455
468
|
}
|
|
@@ -462,6 +475,9 @@ export function validatePendingSteer(steer) {
|
|
|
462
475
|
if (priority !== undefined && priority !== "now" && priority !== "next" && priority !== "later") {
|
|
463
476
|
throw new CheckpointError("steering.invalid_content", `steering priority "${typeof priority === "string" ? priority : priority === null ? "null" : typeof priority}" is outside the injection-priority domain ("now", "next", "later")`);
|
|
464
477
|
}
|
|
478
|
+
if (runOrigin !== undefined && !isRunOrigin(runOrigin)) {
|
|
479
|
+
throw new CheckpointError("steering.invalid_content", `steering runOrigin ${describeRejectedValue(runOrigin)} is not a run origin (${RUN_ORIGINS.map((w) => JSON.stringify(w)).join(" | ")}) — omit it when the deployment's scheduler did not hand this input`);
|
|
480
|
+
}
|
|
465
481
|
const actorTwin = actor === undefined ? undefined : captureActorAssertion(actor);
|
|
466
482
|
if (inputId !== undefined && (inputId === "" || inputId.length > MAX_STEER_INPUT_ID_CHARS)) {
|
|
467
483
|
throw new CheckpointError("steering.invalid_content", `steering inputId must be a non-empty string of at most ${MAX_STEER_INPUT_ID_CHARS} characters`);
|
|
@@ -481,6 +497,7 @@ export function validatePendingSteer(steer) {
|
|
|
481
497
|
...(actorTwin !== undefined ? { actor: actorTwin } : {}),
|
|
482
498
|
inputId: inputId ?? uuidv7(),
|
|
483
499
|
...(priority !== undefined ? { priority: priority } : {}),
|
|
500
|
+
...(runOrigin !== undefined ? { runOrigin } : {}),
|
|
484
501
|
};
|
|
485
502
|
}
|
|
486
503
|
export const MAX_ACTOR_FIELD_CHARS = 256;
|
|
@@ -527,15 +544,19 @@ export function readPendingSteerQueue(state) {
|
|
|
527
544
|
}
|
|
528
545
|
return [...(state.pendingSteerQueue ?? [])].sort((a, b) => a.seq - b.seq);
|
|
529
546
|
}
|
|
547
|
+
export function judgeParkedSteerRepeat(queue, entry) {
|
|
548
|
+
const collision = queue.find((e) => e.inputId === entry.inputId);
|
|
549
|
+
if (collision === undefined)
|
|
550
|
+
return undefined;
|
|
551
|
+
const refusal = steerReplayRefusal(collision, entry, { seat: "parked", inputId: entry.inputId });
|
|
552
|
+
if (refusal !== undefined)
|
|
553
|
+
throw new CheckpointError("steering.duplicate_input_id", refusal.message, refusal.detail);
|
|
554
|
+
return collision;
|
|
555
|
+
}
|
|
530
556
|
export function appendPendingSteer(state, entry) {
|
|
531
557
|
const current = readPendingSteerQueue(state);
|
|
532
|
-
|
|
533
|
-
if (collision !== undefined) {
|
|
534
|
-
const refusal = steerReplayRefusal(collision, entry, { seat: "parked", inputId: entry.inputId });
|
|
535
|
-
if (refusal !== undefined)
|
|
536
|
-
throw new CheckpointError("steering.duplicate_input_id", refusal.message, refusal.detail);
|
|
558
|
+
if (judgeParkedSteerRepeat(current, entry) !== undefined)
|
|
537
559
|
return current;
|
|
538
|
-
}
|
|
539
560
|
const nextSeq = current.reduce((max, e) => Math.max(max, e.seq), 0) + 1;
|
|
540
561
|
const next = [...current, { ...entry, seq: nextSeq }];
|
|
541
562
|
const totalEntries = next.length;
|
|
@@ -554,7 +575,7 @@ export function checkpointRowMatches(cp, scope, status) {
|
|
|
554
575
|
return cp !== undefined && cp.scope === scope && cp.status === status;
|
|
555
576
|
}
|
|
556
577
|
export class InMemoryCheckpointStore {
|
|
557
|
-
retention
|
|
578
|
+
retention;
|
|
558
579
|
durability = "process-local";
|
|
559
580
|
fidelity = "structured-clone";
|
|
560
581
|
execution = { outcome: true };
|
|
@@ -563,6 +584,7 @@ export class InMemoryCheckpointStore {
|
|
|
563
584
|
disclose;
|
|
564
585
|
holderIsCurrent;
|
|
565
586
|
constructor(opts = {}) {
|
|
587
|
+
this.retention = readRetentionDeclaration("InMemoryCheckpointStore.retention", opts.retention);
|
|
566
588
|
this.disclose = opts.disclose;
|
|
567
589
|
this.holderIsCurrent = opts.holderIsCurrent;
|
|
568
590
|
if (opts.holderIsCurrent !== undefined)
|
|
@@ -125,6 +125,12 @@ export declare const CLAMP_SET: Readonly<{
|
|
|
125
125
|
readonly script: true;
|
|
126
126
|
readonly carrier: "specSeat";
|
|
127
127
|
}>;
|
|
128
|
+
classifyAllShell: Readonly<{
|
|
129
|
+
readonly law: "restricting";
|
|
130
|
+
readonly value: true;
|
|
131
|
+
readonly script: true;
|
|
132
|
+
readonly carrier: "specSeat";
|
|
133
|
+
}>;
|
|
128
134
|
fileHistory: Readonly<{
|
|
129
135
|
readonly law: "restricting";
|
|
130
136
|
readonly value: "disabled";
|
|
@@ -257,6 +263,23 @@ export declare function clampRecordError(message: string): Error & {
|
|
|
257
263
|
* whose value is `undefined` carries nothing and is read as absent (the retired-key door's presence rule).
|
|
258
264
|
*/
|
|
259
265
|
export declare function assertClampRecord(record: unknown, owner: string, carrier?: ClampCarrier, extra?: readonly string[]): void;
|
|
266
|
+
/**
|
|
267
|
+
* Read a STATED floor — the clamp values a durable record says its run was born under — back under the table's law, or say
|
|
268
|
+
* why it cannot be read. A floor is the table's own value shape ({@link ClampValues}) and nothing looser: every key a row,
|
|
269
|
+
* a restricting row's value exactly its restricting value (a field row: exactly `{ <field>: <value> }`), an add-only row a
|
|
270
|
+
* non-empty list whose every entry its row's entry law accepts. `{}` is a floor (nothing was clamped); ABSENT is not — a
|
|
271
|
+
* record that states no floor cannot say what a revival under it would widen, and a key this build's table does not have
|
|
272
|
+
* (a newer writer's row) is refused rather than ignored, because ignoring it drops a restriction.
|
|
273
|
+
* The floor is judged and projected from ONE plain-data copy (`structuredClone`): a value that is not plain data refuses, and
|
|
274
|
+
* nothing an accessor answers on a second read can differ from what was judged.
|
|
275
|
+
*/
|
|
276
|
+
export declare function readClampFloor(floor: unknown): {
|
|
277
|
+
ok: true;
|
|
278
|
+
floor: ClampValues;
|
|
279
|
+
} | {
|
|
280
|
+
ok: false;
|
|
281
|
+
why: string;
|
|
282
|
+
};
|
|
260
283
|
/** The restricting values of every row that ANY of `records` carries — the clamp seat a waker hands a revival. */
|
|
261
284
|
export declare function clampValuesOf(...records: ReadonlyArray<object | undefined>): ClampValues;
|
|
262
285
|
/**
|
|
@@ -286,6 +309,12 @@ export declare const CHILD_CLAMP_SEATS_NOT_CARRIED: Readonly<Record<string, stri
|
|
|
286
309
|
* shape it misses leaves the real constructor invisible while a namesake answers for it.
|
|
287
310
|
*/
|
|
288
311
|
export declare const ENGINE_CHILD_SPEC_CONSTRUCTORS: readonly ["src/agents/subagent.ts#buildChildSpec", "src/agents/subagent.ts#observerSpec", "src/agents/subagent.ts#resumeSpec", "src/agents/verify.ts#verifierSpec", "src/agents/verify.ts#fixLegSpec", "src/orchestration/workflow-primitives.ts#workflowChildClamps"];
|
|
312
|
+
/** Do these clamps leave nobody on the leg to ask — the hard-headless clamp (`interactiveTools: false`) or the declaration
|
|
313
|
+
* that nobody can be asked (`approvalReach: "none"`)? The one reading {@link postureUnderClamps} and a revival's posture read. */
|
|
314
|
+
export declare function clampsReachNoPerson(clamps: {
|
|
315
|
+
readonly interactiveTools: boolean | undefined;
|
|
316
|
+
readonly approvalReach: TaskSpec["approvalReach"] | undefined;
|
|
317
|
+
}): boolean;
|
|
289
318
|
/**
|
|
290
319
|
* The interaction posture a leg keeps under the clamps it inherited: `"interactive"` promises a person on the leg, and a
|
|
291
320
|
* leg that inherited the hard-headless clamp (`interactiveTools: false`) or the declaration that nobody can be asked
|
|
@@ -86,6 +86,7 @@ export const CLAMP_SET = Object.freeze({
|
|
|
86
86
|
complianceAdditionalDenies: Object.freeze({ law: "addOnly", identity: complianceIdentity, entry: complianceCapabilityProblem, script: COMPLIANCE_SCRIPT_LAW, deploymentLayer: "compliancePostureResolver", carrier: "clamp" }),
|
|
87
87
|
oneShot: Object.freeze({ law: "restricting", value: true, script: true, carrier: "specSeat" }),
|
|
88
88
|
memoryPersistenceCapable: Object.freeze({ law: "restricting", value: false, script: true, carrier: "specSeat" }),
|
|
89
|
+
classifyAllShell: Object.freeze({ law: "restricting", value: true, script: true, carrier: "specSeat" }),
|
|
89
90
|
fileHistory: Object.freeze({ law: "restricting", value: "disabled", script: false, carrier: "specSeat" }),
|
|
90
91
|
projectMemory: Object.freeze({ law: "restricting", value: "disabled", script: false, carrier: "specSeat" }),
|
|
91
92
|
promptForm: Object.freeze({ law: "restricting", value: "minimal", script: false, carrier: "specSeat" }),
|
|
@@ -239,6 +240,57 @@ export function assertClampRecord(record, owner, carrier, extra = []) {
|
|
|
239
240
|
throw clampRecordError(`${owner} names ${unknown.map((k) => JSON.stringify(k)).join(", ")}, which the clamp table does not carry there — the legal seats are ${legal.join(", ")}. Refused rather than ignored: a seat nobody reads would read to the caller as wired.`);
|
|
240
241
|
}
|
|
241
242
|
}
|
|
243
|
+
export function readClampFloor(floor) {
|
|
244
|
+
if (floor === undefined)
|
|
245
|
+
return { ok: false, why: "the record states no policy floor (written before records carried one, or by a store that does not keep it)" };
|
|
246
|
+
let copy;
|
|
247
|
+
try {
|
|
248
|
+
copy = structuredClone(floor);
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
return { ok: false, why: "the record's policy floor is not plain data" };
|
|
252
|
+
}
|
|
253
|
+
const proto = typeof copy === "object" && copy !== null ? Object.getPrototypeOf(copy) : undefined;
|
|
254
|
+
if (copy === null || typeof copy !== "object" || Array.isArray(copy) || (proto !== Object.prototype && proto !== null)) {
|
|
255
|
+
return { ok: false, why: `the record's policy floor is not a record of clamp seats (got ${copy === null ? "null" : Array.isArray(copy) ? "an array" : typeof copy})` };
|
|
256
|
+
}
|
|
257
|
+
const stated = copy;
|
|
258
|
+
for (const [key, v] of Object.entries(stated)) {
|
|
259
|
+
if (v === undefined)
|
|
260
|
+
continue;
|
|
261
|
+
const row = CLAMP_SEATS.includes(key) ? CLAMP_SET[key] : undefined;
|
|
262
|
+
if (row === undefined)
|
|
263
|
+
return { ok: false, why: `the record's policy floor names ${describeStated(key)}, which this build's clamp table does not have` };
|
|
264
|
+
const seat = key;
|
|
265
|
+
if (row.law === "restricting") {
|
|
266
|
+
const field = fieldOf(row);
|
|
267
|
+
const exact = field === undefined ? v === row.value : typeof v === "object" && v !== null && !Array.isArray(v) && Object.keys(v).length === 1 && cellOf(row, v) === row.value;
|
|
268
|
+
if (!exact)
|
|
269
|
+
return { ok: false, why: `the record's policy floor states ${clampCellPath(seat)} as ${describeStated(v)}, which is not its restricting value ${describeStated(row.value)}` };
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (!Array.isArray(v) || v.length === 0)
|
|
273
|
+
return { ok: false, why: `the record's policy floor states ${seat} as ${Array.isArray(v) ? "an empty list" : describeStated(v)} — a floor's add-only seat is a non-empty list` };
|
|
274
|
+
const entries = v;
|
|
275
|
+
for (const e of entries) {
|
|
276
|
+
const problem = row.entry(e, `policyFloor.${seat}`);
|
|
277
|
+
if (problem !== undefined)
|
|
278
|
+
return { ok: false, why: problem };
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return { ok: true, floor: clampSeatsOf(stated) };
|
|
282
|
+
}
|
|
283
|
+
function describeStated(v) {
|
|
284
|
+
try {
|
|
285
|
+
const s = JSON.stringify(v);
|
|
286
|
+
if (s === undefined)
|
|
287
|
+
return typeof v;
|
|
288
|
+
return s.length > 80 ? `${s.slice(0, 77)}...` : s;
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
return typeof v;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
242
294
|
export function clampValuesOf(...records) {
|
|
243
295
|
return clampSeatsOf(foldClampSources(...records));
|
|
244
296
|
}
|
|
@@ -263,8 +315,11 @@ export const ENGINE_CHILD_SPEC_CONSTRUCTORS = Object.freeze([
|
|
|
263
315
|
"src/agents/verify.ts#fixLegSpec",
|
|
264
316
|
"src/orchestration/workflow-primitives.ts#workflowChildClamps",
|
|
265
317
|
]);
|
|
318
|
+
export function clampsReachNoPerson(clamps) {
|
|
319
|
+
return clamps.interactiveTools === false || clamps.approvalReach === "none";
|
|
320
|
+
}
|
|
266
321
|
export function postureUnderClamps(posture, clamps) {
|
|
267
|
-
return posture === "interactive" && (clamps
|
|
322
|
+
return posture === "interactive" && clampsReachNoPerson(clamps) ? "headless" : posture;
|
|
268
323
|
}
|
|
269
324
|
export function engineHeadlessLegSeats() {
|
|
270
325
|
return { interactiveTools: false, approvalReach: "none", interactionPosture: "headless" };
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
export type ComplianceProfile = "hipaa" | "zdr";
|
|
3
3
|
/** Closed capability set the ENGINE can veto end-to-end (see the module header for the entry-point
|
|
4
4
|
* map — a capability is admitted here only with its full interception story). */
|
|
5
|
-
export type ComplianceCapability = "mcp_servers" | "workflows" | "web_fetch" | "org_memory_mount";
|
|
5
|
+
export type ComplianceCapability = "mcp_servers" | "workflows" | "web_fetch" | "org_memory_mount" | "a2a_peers";
|
|
6
6
|
/** Every member of {@link ComplianceCapability} — the fail-closed "deny everything managed" set used
|
|
7
7
|
* when the posture resolver itself fails. `satisfies` keeps it in lockstep with the union. */
|
|
8
|
-
export declare const COMPLIANCE_CAPABILITIES: readonly ["mcp_servers", "workflows", "web_fetch", "org_memory_mount"];
|
|
8
|
+
export declare const COMPLIANCE_CAPABILITIES: readonly ["mcp_servers", "workflows", "web_fetch", "org_memory_mount", "a2a_peers"];
|
|
9
9
|
/**
|
|
10
10
|
* A principal's resolved compliance posture, supplied by the trusted deployment resolver. The
|
|
11
11
|
* effective deny set is `BUILTIN_COMPLIANCE_DENIES[profile] ∪ additionalDenies` — supply can only
|
package/dist/core/compliance.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describeRejectedValue } from "./tool-search-setting.js";
|
|
2
|
-
export const COMPLIANCE_CAPABILITIES = Object.freeze(["mcp_servers", "workflows", "web_fetch", "org_memory_mount"]);
|
|
2
|
+
export const COMPLIANCE_CAPABILITIES = Object.freeze(["mcp_servers", "workflows", "web_fetch", "org_memory_mount", "a2a_peers"]);
|
|
3
3
|
export const BUILTIN_COMPLIANCE_DENIES = {
|
|
4
4
|
hipaa: ["web_fetch", "org_memory_mount"],
|
|
5
5
|
zdr: ["org_memory_mount"],
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
import { canonicalizeTarget, type PathFamily, type PathIdentity, type Win32NamespaceRefusal } from "../tools/fs/safety.js";
|
|
49
49
|
import type { TargetViews } from "./path-guard-rows.js";
|
|
50
50
|
import type { ExecutionEnv } from "../internal/harness-types.js";
|
|
51
|
-
import type { ToolCallPathTarget } from "./tool-face.js";
|
|
51
|
+
import type { ToolCallPathTarget, ToolPathAbsence, ToolPathBase } from "./tool-face.js";
|
|
52
52
|
import { type ToolCallLike } from "./tool-registry.js";
|
|
53
53
|
/** The bases of ONE CALL a target resolves against: the task root, and the live tracked working directory
|
|
54
54
|
* (absent when no tracker moved or the caller keeps none). Facts of the call, never of the tool. The
|
|
@@ -64,6 +64,12 @@ export interface ToolPathBases {
|
|
|
64
64
|
* slot names nothing this reader can locate.
|
|
65
65
|
*/
|
|
66
66
|
export declare function pathTargetBaseOf(pt: Pick<ToolCallPathTarget, "base"> | undefined, bases: ToolPathBases): string | undefined;
|
|
67
|
+
/** A declared slot's resolution with its silences read: the base its relative spellings resolve against and what an empty slot
|
|
68
|
+
* reads — `cwd` and `none` for a declaration that states neither. The ONE place a declaration's silence becomes a resolution. */
|
|
69
|
+
export declare function pathTargetResolutionOf(pt: Pick<ToolCallPathTarget, "base" | "absent">): {
|
|
70
|
+
readonly base: ToolPathBase;
|
|
71
|
+
readonly absent: ToolPathAbsence;
|
|
72
|
+
};
|
|
67
73
|
/**
|
|
68
74
|
* design/116 批④ #8 — decompose an ABSOLUTE glob pattern into a base
|
|
69
75
|
* directory + relative pattern: cut at the last separator before the first glob metachar (`* ? [ {`); a
|
|
@@ -271,7 +277,7 @@ export declare function carryArgsReadFrom(original: unknown, copy: unknown): voi
|
|
|
271
277
|
* face). Every seat that rewrites a request's arguments and hands it on (a composition's rewrite cascade, a re-judgment of
|
|
272
278
|
* the final or an edited form) goes through here, so the next layer never judges a request its reading does not describe
|
|
273
279
|
* nor arguments the tool would run differently. `signal` is the CURRENT call's: a reading never carries one call's
|
|
274
|
-
* cancellation into another's.
|
|
280
|
+
* cancellation into another's. The request's grant-binding words follow the new args the same way ({@link withArgsBinding}).
|
|
275
281
|
*/
|
|
276
282
|
export declare function withArgsReading<R extends {
|
|
277
283
|
readonly args: unknown;
|
|
@@ -4,8 +4,12 @@ import { symlinkChainHops } from "./path-identity.js";
|
|
|
4
4
|
import { DEFAULT_GATE_AWAIT_TIMEOUT_MS, withGateTimeout } from "./gate-bounded-await.js";
|
|
5
5
|
import { thrownText } from "./thrown-value.js";
|
|
6
6
|
import { canonicalize } from "./canonical-json.js";
|
|
7
|
+
import { withArgsBinding } from "./skill-grant-binding.js";
|
|
7
8
|
export function pathTargetBaseOf(pt, bases) {
|
|
8
|
-
return (pt
|
|
9
|
+
return pathTargetResolutionOf(pt ?? {}).base === "root" ? bases.root : (bases.cwd ?? bases.root);
|
|
10
|
+
}
|
|
11
|
+
export function pathTargetResolutionOf(pt) {
|
|
12
|
+
return { base: pt.base ?? "cwd", absent: pt.absent ?? "none" };
|
|
9
13
|
}
|
|
10
14
|
export function splitAbsoluteGlobPattern(pattern, tree) {
|
|
11
15
|
const family = tree ?? familyFor("own", pattern);
|
|
@@ -44,7 +48,7 @@ export function effectivePathSpellingOf(call, pt, bases) {
|
|
|
44
48
|
const spelled = pathTargetValue(call.args, pt);
|
|
45
49
|
if (spelled !== undefined)
|
|
46
50
|
return { spelled, base: declaredBase };
|
|
47
|
-
if ((pt.absent
|
|
51
|
+
if (pathTargetResolutionOf(pt).absent === "none")
|
|
48
52
|
return undefined;
|
|
49
53
|
if (pt.patternParam !== undefined) {
|
|
50
54
|
const pattern = pathTargetValue(call.args, { param: pt.patternParam });
|
|
@@ -175,7 +179,8 @@ export async function withArgsReading(req, args, signal) {
|
|
|
175
179
|
const read = argsAsTheToolReads(req, args);
|
|
176
180
|
const reading = callTargetReadingOf(req);
|
|
177
181
|
const reread = reading === undefined ? undefined : REREAD.get(reading);
|
|
178
|
-
|
|
182
|
+
const moved = withArgsBinding(req, read);
|
|
183
|
+
return reread === undefined ? moved : { ...moved, targetReading: await reread(read, signal) };
|
|
179
184
|
}
|
|
180
185
|
function viewFrom(v) {
|
|
181
186
|
if (v.lexical === undefined)
|
|
@@ -72,7 +72,7 @@ export interface EngineNotice {
|
|
|
72
72
|
* - `"mods.registration_refused"` — an extension registration was not mounted: a registration admitted before it
|
|
73
73
|
* answered `{ refuse }` on `plugin.register`, or failed while judging it (fail-closed). The run goes on without it.
|
|
74
74
|
* Audience `user` (the seat is in `detail`). Once per refused registration per run. `detail: { name, seat, tier,
|
|
75
|
-
* refusedBy, reason, sessionId }` (`seat` ∈ `deployment` / `task`).
|
|
75
|
+
* provenance?, refusedBy, reason, sessionId }` (`seat` ∈ `deployment` / `task`; `provenance` as the host gave it, absent when none).
|
|
76
76
|
* - `"skills.listing_truncated"` — the `<skills>` disclosure block did not fit its byte budget, so
|
|
77
77
|
* at least one skill is listed without its description (`nameOnly`) or, in the pathological case,
|
|
78
78
|
* not listed at all (`dropped`); the `Skill` tool still serves every one of them. Audience
|
|
@@ -167,6 +167,17 @@ export interface EngineNotice {
|
|
|
167
167
|
* DOWN, which only the operator can act on. Dedup unit: once per ATTEMPT — never folded per run,
|
|
168
168
|
* because two attempts on one server are two different answers and folding the second would hide
|
|
169
169
|
* the one that says the server is still down.
|
|
170
|
+
* - `"mcp.authorization_required"` — an MCP server the user must authorize before it serves them:
|
|
171
|
+
* the leg's dial failed `unauthorized`, or a request was refused so and that refusal is its answer
|
|
172
|
+
* (a repeat-safe call refused 401 and sent once more on a renewed credential announces only if that
|
|
173
|
+
* send is refused too). The SAME fact as the failure record's `authorization`
|
|
174
|
+
* (`McpAuthorization`). `detail: { server, reason, authorizeUrl?, principal?, sessionId, runId }` —
|
|
175
|
+
* `reason` is `rejected` (401) / `scope` (403 insufficient_scope) / `none` (the seat holds no
|
|
176
|
+
* authorization for this user), `authorizeUrl` the seat's own (never the endpoint's
|
|
177
|
+
* `resource_metadata`, which rides the record only). `"user"` audience: nobody but the user can
|
|
178
|
+
* authorize; `sessionId` REQUIRED at the mint. Dedup unit: once per (leg, server) — a resume is a new
|
|
179
|
+
* leg and may announce again. A deployment that waits for the authorization keys on this notice; the
|
|
180
|
+
* leg itself does not park on it.
|
|
170
181
|
* - `"mcp.injection_dropped"` (L-167) — an entry of the user's own request-lane MCP injection
|
|
171
182
|
* was NOT mounted for the leg. The HOST owns the drop sites and supplies the facts; CORE composes
|
|
172
183
|
* the notice ({@link import("./mcp-injection-drop.js").mcpInjectionDroppedNotice}, the one mint).
|
|
@@ -278,7 +289,8 @@ export interface EngineNotice {
|
|
|
278
289
|
* - `"route.credential_origin_mismatch"` (key↔URL pairing, `src/brain/route-adjudicator.ts`; announced by
|
|
279
290
|
* `src/core/runner/credential-origin-seat.ts`) — a request was REFUSED, nothing sent, because the per-model
|
|
280
291
|
* credential it would carry is bound to another origin: the law binds a per-model credential to the origin
|
|
281
|
-
* (scheme + host + port) of the first request sent carrying it
|
|
292
|
+
* (scheme + host + port) of the first request sent carrying it (or the one the host rebinds it to,
|
|
293
|
+
* `route.credential_rebound`), so an entry whose `baseUrl` moved to another
|
|
282
294
|
* host while its credential stayed the same is refused (same-origin path moves are not). The request's own
|
|
283
295
|
* failure carries the same code (`[invalid_request] route.credential_origin_mismatch: …`). Minted only for a
|
|
284
296
|
* request the gate refused (`routeRefusalError`): a pre-flight or read-face judgment reports nothing, and a derived
|
|
@@ -286,6 +298,14 @@ export interface EngineNotice {
|
|
|
286
298
|
* failed hears why; the operator hears it through the sink. `detail: { modelId, boundOrigin, requestOrigin,
|
|
287
299
|
* sessionId, runId }` — the two origins in display spelling, never a credential or a digest of one. Once per
|
|
288
300
|
* run per (modelId, boundOrigin, requestOrigin).
|
|
301
|
+
* - `"route.credential_rebound"` (`rebindCredentialOrigin`, `src/brain/route-adjudicator.ts`) — the HOST moved a
|
|
302
|
+
* per-model credential's binding, explicitly: every secret the credential carries is now bound to the origin the
|
|
303
|
+
* named entry sends to, and a request carrying it anywhere else (another entry still on the old host included) is
|
|
304
|
+
* refused. Minted by the verb's own call, outside any run, through the `onNotice` the host hands it (else the
|
|
305
|
+
* throat's `console.warn` arm); once per call that changed the table, never for one that found every secret already
|
|
306
|
+
* there. Audience `operator`. `detail: { modelId, origin, previous, occurrenceId }` — `origin` and each `previous`
|
|
307
|
+
* origin in display spelling, never a credential or a digest of one; `occurrenceId` is minted at delivery (the
|
|
308
|
+
* call has no run and no session to key it by, as `config.models_swapped`).
|
|
289
309
|
* - `"route.response_model_mismatch"` — the provider answered a turn naming a model that is NOT the id
|
|
290
310
|
* the request was sent with (an alias, a pool or a gateway-side substitution looks exactly like this),
|
|
291
311
|
* so it is advisory, never a refusal: the engine keeps asking for the catalog's id and reports the
|
|
@@ -304,7 +324,8 @@ export interface EngineNotice {
|
|
|
304
324
|
* or `"duplicate"` (a renamed later call); `rawLength` present for the two shape reasons only; never the raw
|
|
305
325
|
* bytes. Absent ⇒ no call of the run was folded.
|
|
306
326
|
* - `"route.finish_reason_unknown"` (#1457) — the provider ended a response with a stream-end word (an
|
|
307
|
-
* OpenAI-family `finish_reason`) the brain does not read
|
|
327
|
+
* OpenAI-family `finish_reason`) the brain does not read, or (#1529, either wire) with an ending seat holding no word
|
|
328
|
+
* at all (a number, `true`, an object — `?`). The turn is kept — its text and the stop its content
|
|
308
329
|
* implies — and the word rides `AssistantMessage.finishReasonUnknown` (and, when the run completes on that turn,
|
|
309
330
|
* `terminal.detail`); the notice is what keeps the keep from being a silent clean stop. ONCE PER LEG PER WORD.
|
|
310
331
|
* Audience `user` (the person reading the answer judges whether it is whole); `detail: { finishReason,
|
|
@@ -332,6 +353,15 @@ export interface EngineNotice {
|
|
|
332
353
|
* drop arm (`TaskResult.effectiveReasoning.dropped`) is that fact's face. ONCE PER SESSION PER (model, capability)
|
|
333
354
|
* (the session's announced record); one report per request also becomes the operator trace `vision.placeholder`.
|
|
334
355
|
* Audience `user`; `detail: { model, capability: "image", status: "declared_off", sessionId, runId }`.
|
|
356
|
+
* - `"model.role_defaulted"` (#2571; `src/core/runner/role-seat-defaulted.ts`) — a role seat of the merged deployment and task
|
|
357
|
+
* maps names a model word the catalog does not hold, so the roles family reads it as an UNSET seat (the tier default and the
|
|
358
|
+
* fallback chain follow; a `subagent` seat's children run on the parent's model) and the run goes on, where it used to be
|
|
359
|
+
* refused at every prepare. Never minted for `default` (the main model's seat: an unknown word there is still refused,
|
|
360
|
+
* `config.unknown_role` / `unknown_model_ref`) nor `classifier` (its own stand-in and its own line, `classifier.role_defaulted`).
|
|
361
|
+
* Named once per SESSION per (seat, word), whether or not a read of this leg reaches the seat; root legs only. Audience
|
|
362
|
+
* `operator`; `detail: { seat, role, model, reason: "unknown_model_ref", fallback, sessionId, runId? }` — `seat` the
|
|
363
|
+
* `roles.<role>` the refusal would have named, `model` the word written there (bounded at 80), `fallback` the roles the seat's
|
|
364
|
+
* chain would reach, nearest first.
|
|
335
365
|
* - `"context.tool_turn_repaired"` (#1224) — a provider request was built from a transcript that breaks the
|
|
336
366
|
* tool-turn law, and the request view restored it (`engine/llm/tool-turns.ts`; the transcript is never
|
|
337
367
|
* rewritten): a block after an assistant's tool calls moved ahead of them (`trailing_text`), a result recorded
|
|
@@ -345,6 +375,13 @@ export interface EngineNotice {
|
|
|
345
375
|
* the run proceeds on the repaired request. Audience `operator`; `detail: { repairs: [{ form, toolCallIds }],
|
|
346
376
|
* sessionId, runId }`. ONCE PER RUN PER (form, calls) — the same broken turn is repaired on every request of
|
|
347
377
|
* the run and announced on the first. Absent ⇒ every request of the run already had the structure.
|
|
378
|
+
* - `"context.image_removed"` (#2874) — the provider refused a request because an image in it could not be processed
|
|
379
|
+
* (the failed turn's `errorKind: "image_unprocessable"`), so the request view removed the images of the newest
|
|
380
|
+
* message still carrying any, each replaced by `[image N removed: rejected by provider: image_unprocessable]`
|
|
381
|
+
* (`engine/llm/rejected-images.ts`); the turn was re-sent without them and every later request of the session
|
|
382
|
+
* reads the same removal. The transcript keeps the images. Audience `user`; `detail: { images, sessionId, runId }`
|
|
383
|
+
* — `images` how many were removed from that message. ONCE PER RUN PER REFUSAL; a refusal recorded before the run
|
|
384
|
+
* began is not announced again.
|
|
348
385
|
* - `"task.tool_turn_incomplete"` (#1230) — the person's line for a tool turn the model was handed incomplete, beside
|
|
349
386
|
* the note the model itself reads. `detail.cause` (closed `TOOL_TURN_INCOMPLETE_CAUSES`): `truncated` — calls whose
|
|
350
387
|
* arguments were cut before they parsed, dropped (they did not run); `unnamed` — calls that arrived with no tool
|
|
@@ -527,7 +564,12 @@ export interface EngineNotice {
|
|
|
527
564
|
* (a returned row does not carry them: its next decide is fresh); when the pause tried to carry them forward and the parked-steer
|
|
528
565
|
* carrier refused, the row also names the store's refusal as `detail.carry` (`steering.invalid_content` | `steering.queue_full`) and
|
|
529
566
|
* its sentence says so (`cause` stays `leg_end`: the leg ended with them owed — the closed set has no carrier words);
|
|
530
|
-
* `detail: { <countKey>, cause, kind?, carry?, taskId?, sessionId?, runId? }` (
|
|
567
|
+
* `detail: { <countKey>, cause, inputIds?, kind?, carry?, taskId?, sessionId?, runId? }` (`inputIds` — on the `leg_end` rows of the two
|
|
568
|
+
* families: the id of EACH input the count stands for, in the order the run would have served them (queue order: an
|
|
569
|
+
* `immediate`-tier input leads the ones accepted before it), the same key value the live `human_input` frame
|
|
570
|
+
* carries as `inputId` and a parked entry as `inputId`; present only when the ids name exactly the counted inputs — a lane
|
|
571
|
+
* where any counted input carried none reports its count alone, never a partial list — and never on an `approval_feedback` row,
|
|
572
|
+
* whose words are no input; the `crashed` arm is the serving layer's and does not carry it) (the `code` and the `countKey` of each family are the
|
|
531
573
|
* table {@link USER_INPUT_UNDRAINED_FAMILIES}, keyed by the lane the input was queued on — `injectionLaneOf` — and the
|
|
532
574
|
* minter writes exactly those; `cause` on both rows, closed `USER_INPUT_UNDRAINED_CAUSES`: `"leg_end"` — this engine's arm, the
|
|
533
575
|
* leg ended with it still owed; `"crashed"` — minted by the SERVING LAYER, not this engine, before the
|
|
@@ -1051,21 +1093,23 @@ export declare function deliverEngineNotice(onNotice: ((notice: EngineNotice) =>
|
|
|
1051
1093
|
* ({@link settleOwedUserInput}). */
|
|
1052
1094
|
export interface OwedUserInputAccount {
|
|
1053
1095
|
/** The harness's at-agent_end snapshot, held because the tail still had something to say about it. */
|
|
1054
|
-
readonly held:
|
|
1055
|
-
|
|
1056
|
-
followUp: number;
|
|
1057
|
-
} | undefined;
|
|
1058
|
-
/** What a durable park's migration carried onto the new checkpoint, by family. */
|
|
1096
|
+
readonly held: HeldUserInputs | undefined;
|
|
1097
|
+
/** What a durable park's migration carried onto the new checkpoint, by family (`inputIds`: which inputs they were). */
|
|
1059
1098
|
readonly migrated: {
|
|
1060
1099
|
steer: number;
|
|
1061
1100
|
followUp: number;
|
|
1101
|
+
inputIds?: OwedInputIds;
|
|
1062
1102
|
};
|
|
1063
1103
|
/** The resumed leg's undelivered continuation frames, and how many of them the migration carried. */
|
|
1064
1104
|
readonly continuation: {
|
|
1105
|
+
/** `inputId`: the frame's own correlation key (a parked entry always carries one). */
|
|
1065
1106
|
frames: ReadonlyArray<{
|
|
1066
1107
|
seq?: number;
|
|
1108
|
+
inputId?: string;
|
|
1067
1109
|
}>;
|
|
1068
1110
|
carried: number;
|
|
1111
|
+
/** The `inputId`s of the frames counted in `carried`, when the migration recorded them. */
|
|
1112
|
+
carriedInputIds?: ReadonlyArray<string>;
|
|
1069
1113
|
/** The approving person's words (a `policy_ask` allow's `feedback`), counted APART from `frames`: owed, and how many the migration carried.
|
|
1070
1114
|
* They are on no row of their own, and a returned row (the compensation reopened it) does not carry them either — its next decide is a
|
|
1071
1115
|
* fresh one the host may re-supply them on — so, unlike the caller's own frames, they are not announced when the row came back (the row is
|
|
@@ -1078,6 +1122,28 @@ export interface OwedUserInputAccount {
|
|
|
1078
1122
|
};
|
|
1079
1123
|
};
|
|
1080
1124
|
}
|
|
1125
|
+
/** The ids of person inputs, per lane — each the `inputId` the input was accepted under (the same key value on the live
|
|
1126
|
+
* `human_input` frame and on a parked entry). */
|
|
1127
|
+
export interface OwedInputIds {
|
|
1128
|
+
readonly steer: ReadonlyArray<string>;
|
|
1129
|
+
readonly followUp: ReadonlyArray<string>;
|
|
1130
|
+
}
|
|
1131
|
+
/** The harness's at-agent_end count of person inputs still queued, per lane, with the ids of the ones that carried a park
|
|
1132
|
+
* record (a list shorter than its count names only some of them). */
|
|
1133
|
+
export interface HeldUserInputs {
|
|
1134
|
+
steer: number;
|
|
1135
|
+
followUp: number;
|
|
1136
|
+
inputIds?: OwedInputIds;
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* The ids of the person inputs a harness-side park-record list stands for: the `inputId` each record carries (the record is
|
|
1140
|
+
* the steer verb's own `PendingSteerInput`, opaque to the harness). Total — a record without a string id contributes none, so
|
|
1141
|
+
* its lane's list falls short of the count and {@link undrainedUserInputNotices} then leaves that lane's count without a list.
|
|
1142
|
+
*/
|
|
1143
|
+
export declare function parkedInputIdsOf(records: {
|
|
1144
|
+
readonly steer: ReadonlyArray<unknown>;
|
|
1145
|
+
readonly followUp: ReadonlyArray<unknown>;
|
|
1146
|
+
}): OwedInputIds;
|
|
1081
1147
|
/**
|
|
1082
1148
|
* What this leg still OWES a person, one count per family — the input to {@link undrainedUserInputNotices}.
|
|
1083
1149
|
* TWO lanes accept caller input and either can be holding some when a run ends: the harness's live queue
|
|
@@ -1103,6 +1169,26 @@ export declare function owedUserInputCounts(held: {
|
|
|
1103
1169
|
steer: number;
|
|
1104
1170
|
followUp: number;
|
|
1105
1171
|
};
|
|
1172
|
+
/**
|
|
1173
|
+
* WHICH inputs {@link owedUserInputCounts} counts — the same two lanes and the same rule, read as ids: the live queue's ids
|
|
1174
|
+
* less the ones the park migrated, plus the continuation frames the reopen did not bring back and the migration did not
|
|
1175
|
+
* carry (steer lane). The counts stay the authority: {@link undrainedUserInputNotices} puts a lane's list on its notice only
|
|
1176
|
+
* where the list names exactly that many inputs, so an input with no id, or a migration that recorded none, leaves that
|
|
1177
|
+
* lane's count without a list rather than with a wrong one.
|
|
1178
|
+
*/
|
|
1179
|
+
export declare function owedUserInputIds(held: HeldUserInputs | undefined, migrated: {
|
|
1180
|
+
steer: number;
|
|
1181
|
+
followUp: number;
|
|
1182
|
+
inputIds?: OwedInputIds;
|
|
1183
|
+
}, continuation: {
|
|
1184
|
+
frames: ReadonlyArray<{
|
|
1185
|
+
seq?: number;
|
|
1186
|
+
inputId?: string;
|
|
1187
|
+
}>;
|
|
1188
|
+
carried: number;
|
|
1189
|
+
carriedInputIds?: ReadonlyArray<string>;
|
|
1190
|
+
rowReturned: boolean;
|
|
1191
|
+
}): OwedInputIds;
|
|
1106
1192
|
/** Close the account — the ONE settlement point, called AFTER the reopen compensation with what that
|
|
1107
1193
|
* compensation actually did. Ordering is the whole rule: the counts are arithmetic, and the only fact they
|
|
1108
1194
|
* cannot be computed without is one the lane before this one does not have yet. EXACTLY ONCE per account,
|
|
@@ -1177,6 +1263,10 @@ export declare function parentLegIds(internals: {
|
|
|
1177
1263
|
export declare function undrainedUserInputNotices(counts: {
|
|
1178
1264
|
steer: number;
|
|
1179
1265
|
followUp: number;
|
|
1266
|
+
inputIds?: {
|
|
1267
|
+
steer?: ReadonlyArray<string>;
|
|
1268
|
+
followUp?: ReadonlyArray<string>;
|
|
1269
|
+
};
|
|
1180
1270
|
approvalFeedback?: number;
|
|
1181
1271
|
approvalCarry?: ApprovalCarryRefusal;
|
|
1182
1272
|
}, taskId?: string, sessionId?: string, runId?: string, parent?: ParentLegIds): EngineNotice[];
|
|
@@ -37,6 +37,10 @@ export function deliverEngineNotice(onNotice, notice) {
|
|
|
37
37
|
}
|
|
38
38
|
console.warn(notice.message);
|
|
39
39
|
}
|
|
40
|
+
export function parkedInputIdsOf(records) {
|
|
41
|
+
const ids = (lane) => lane.flatMap((r) => (typeof r === "object" && r !== null && typeof r.inputId === "string" ? [r.inputId] : []));
|
|
42
|
+
return { steer: ids(records.steer), followUp: ids(records.followUp) };
|
|
43
|
+
}
|
|
40
44
|
export function owedUserInputCounts(held, migrated, continuation) {
|
|
41
45
|
const owedContinuation = (continuation.rowReturned ? continuation.frames.filter((f) => f.seq === undefined).length : continuation.frames.length) - continuation.carried;
|
|
42
46
|
return {
|
|
@@ -44,16 +48,25 @@ export function owedUserInputCounts(held, migrated, continuation) {
|
|
|
44
48
|
followUp: Math.max(0, (held?.followUp ?? 0) - migrated.followUp),
|
|
45
49
|
};
|
|
46
50
|
}
|
|
51
|
+
export function owedUserInputIds(held, migrated, continuation) {
|
|
52
|
+
const gone = (lane) => new Set(migrated.inputIds?.[lane] ?? []);
|
|
53
|
+
const live = (lane) => (held?.inputIds?.[lane] ?? []).filter((id) => !gone(lane).has(id));
|
|
54
|
+
const carried = new Set(continuation.carriedInputIds ?? []);
|
|
55
|
+
const frames = (continuation.rowReturned ? continuation.frames.filter((f) => f.seq === undefined) : continuation.frames).filter((f) => !(typeof f.inputId === "string" && carried.has(f.inputId)));
|
|
56
|
+
const continuationIds = frames.flatMap((f) => (typeof f.inputId === "string" ? [f.inputId] : []));
|
|
57
|
+
return { steer: [...continuationIds, ...live("steer")], followUp: live("followUp") };
|
|
58
|
+
}
|
|
47
59
|
export function settleOwedUserInput(account, rowReturned, ids, onNotice) {
|
|
48
60
|
if (SETTLED_OWED_ACCOUNTS.has(account))
|
|
49
61
|
return;
|
|
50
62
|
SETTLED_OWED_ACCOUNTS.add(account);
|
|
51
63
|
try {
|
|
52
64
|
const owed = owedUserInputCounts(account.held, account.migrated, { ...account.continuation, rowReturned });
|
|
65
|
+
const inputIds = owedUserInputIds(account.held, account.migrated, { ...account.continuation, rowReturned });
|
|
53
66
|
const approval = account.continuation.approval;
|
|
54
67
|
const approvalFeedback = approval === undefined || rowReturned ? 0 : Math.max(0, approval.owed - approval.carried);
|
|
55
68
|
const approvalCarry = approvalFeedback > 0 ? approval?.refusal : undefined;
|
|
56
|
-
for (const notice of undrainedUserInputNotices({ ...owed, ...(approvalFeedback > 0 ? { approvalFeedback } : {}), ...(approvalCarry !== undefined ? { approvalCarry } : {}) }, ids.taskId, ids.sessionId, ids.runId, ids.parent))
|
|
69
|
+
for (const notice of undrainedUserInputNotices({ ...owed, inputIds, ...(approvalFeedback > 0 ? { approvalFeedback } : {}), ...(approvalCarry !== undefined ? { approvalCarry } : {}) }, ids.taskId, ids.sessionId, ids.runId, ids.parent))
|
|
57
70
|
deliverEngineNotice(onNotice, notice);
|
|
58
71
|
}
|
|
59
72
|
catch {
|
|
@@ -86,12 +99,13 @@ export function undrainedUserInputNotices(counts, taskId, sessionId, runId, pare
|
|
|
86
99
|
const own = [];
|
|
87
100
|
const copies = [];
|
|
88
101
|
const cause = "leg_end";
|
|
102
|
+
const inputIdsOf = (ids, counted) => (ids !== undefined && ids.length === counted ? { inputIds: [...ids] } : {});
|
|
89
103
|
if (counts.steer > 0) {
|
|
90
104
|
const message = `${counts.steer} user steer(s) ${tail}`;
|
|
91
105
|
const count = { [USER_INPUT_UNDRAINED_FAMILIES.steer.countKey]: counts.steer, cause };
|
|
92
|
-
own.push({ code: STEER_UNDRAINED, message, detail: { ...count, ...tid, ...sid, ...rid } });
|
|
106
|
+
own.push({ code: STEER_UNDRAINED, message, detail: { ...count, ...inputIdsOf(counts.inputIds?.steer, counts.steer), ...tid, ...sid, ...rid } });
|
|
93
107
|
if (toParent)
|
|
94
|
-
copies.push({ code: STEER_UNDRAINED, message: `${message}${copyTail}`, detail: { ...count, ...ptid, sessionId: parentSession, childSessionId: sessionId } });
|
|
108
|
+
copies.push({ code: STEER_UNDRAINED, message: `${message}${copyTail}`, detail: { ...count, ...inputIdsOf(counts.inputIds?.steer, counts.steer), ...ptid, sessionId: parentSession, childSessionId: sessionId } });
|
|
95
109
|
}
|
|
96
110
|
const approvalFeedback = counts.approvalFeedback ?? 0;
|
|
97
111
|
if (approvalFeedback > 0) {
|
|
@@ -109,9 +123,9 @@ export function undrainedUserInputNotices(counts, taskId, sessionId, runId, pare
|
|
|
109
123
|
if (counts.followUp > 0) {
|
|
110
124
|
const message = `${counts.followUp} user follow-up(s) ${tail}`;
|
|
111
125
|
const count = { [USER_INPUT_UNDRAINED_FAMILIES.followUp.countKey]: counts.followUp, cause };
|
|
112
|
-
own.push({ code: FOLLOWUP_UNDRAINED, message, detail: { ...count, ...tid, ...sid, ...rid } });
|
|
126
|
+
own.push({ code: FOLLOWUP_UNDRAINED, message, detail: { ...count, ...inputIdsOf(counts.inputIds?.followUp, counts.followUp), ...tid, ...sid, ...rid } });
|
|
113
127
|
if (toParent)
|
|
114
|
-
copies.push({ code: FOLLOWUP_UNDRAINED, message: `${message}${copyTail}`, detail: { ...count, ...ptid, sessionId: parentSession, childSessionId: sessionId } });
|
|
128
|
+
copies.push({ code: FOLLOWUP_UNDRAINED, message: `${message}${copyTail}`, detail: { ...count, ...inputIdsOf(counts.inputIds?.followUp, counts.followUp), ...ptid, sessionId: parentSession, childSessionId: sessionId } });
|
|
115
129
|
}
|
|
116
130
|
return [...own, ...copies];
|
|
117
131
|
}
|