@sema-agent/core 7.60.0 → 7.62.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 +917 -0
- package/README.md +2 -2
- package/dist/agents/agent-transcript-tool.d.ts +2 -2
- package/dist/agents/agent-transcript-tool.js +1 -1
- package/dist/agents/cascade.d.ts +71 -12
- package/dist/agents/cascade.js +61 -21
- package/dist/agents/composition-allowance.d.ts +53 -0
- package/dist/agents/composition-allowance.js +49 -0
- package/dist/agents/composition-placement.d.ts +29 -0
- package/dist/agents/composition-placement.js +24 -0
- package/dist/agents/cumulative-stats.d.ts +4 -0
- package/dist/agents/cumulative-stats.js +3 -0
- package/dist/agents/inherited-tool-pool.d.ts +5 -3
- package/dist/agents/inherited-tool-pool.js +2 -2
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/peer-held-queue.d.ts +27 -4
- package/dist/agents/peer-held-queue.js +81 -36
- package/dist/agents/peer-notice-route.d.ts +1 -1
- package/dist/agents/peer-notice-route.js +4 -3
- package/dist/agents/peer-notices.d.ts +4 -4
- package/dist/agents/peer-notices.js +8 -4
- package/dist/agents/peer-session-drain.d.ts +8 -1
- package/dist/agents/peer-session-drain.js +49 -10
- package/dist/agents/repair-loop.js +16 -6
- package/dist/agents/retain-ledger.js +3 -1
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/roster-store.js +7 -4
- package/dist/agents/send-message-tool.d.ts +8 -10
- package/dist/agents/send-message-tool.js +43 -23
- package/dist/agents/subagent-completion-gate.d.ts +35 -0
- package/dist/agents/subagent-completion-gate.js +62 -0
- package/dist/agents/subagent-steps.d.ts +7 -6
- package/dist/agents/subagent.d.ts +36 -41
- package/dist/agents/subagent.js +245 -200
- package/dist/agents/suspend-guard.d.ts +47 -16
- package/dist/agents/suspend-guard.js +13 -4
- package/dist/agents/verify.d.ts +41 -14
- package/dist/agents/verify.js +41 -30
- package/dist/brain/anthropic.js +1 -0
- package/dist/brain/errors.d.ts +7 -1
- package/dist/brain/errors.js +6 -0
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +1 -0
- package/dist/brain/openai.js +1 -0
- package/dist/brain/provider-dialect.d.ts +10 -0
- package/dist/brain/provider-dialect.js +13 -2
- package/dist/brain/stream-engine.d.ts +3 -0
- package/dist/brain/stream-engine.js +4 -0
- package/dist/core/agent-state.d.ts +1 -1
- package/dist/core/allow-entry.d.ts +59 -23
- package/dist/core/allow-entry.js +131 -38
- package/dist/core/ask-origin.d.ts +79 -0
- package/dist/core/ask-origin.js +76 -0
- package/dist/core/ask-question.d.ts +19 -13
- package/dist/core/ask-question.js +8 -2
- package/dist/core/auto-compaction.d.ts +2 -0
- package/dist/core/auto-compaction.js +2 -1
- package/dist/core/auto-mode.js +3 -5
- package/dist/core/background-agent-store.d.ts +7 -5
- package/dist/core/background-agent-store.js +12 -11
- package/dist/core/checkpoint-features.d.ts +722 -0
- package/dist/core/checkpoint-features.js +98 -0
- package/dist/core/checkpoint-requirements.d.ts +33 -5
- package/dist/core/checkpoint-requirements.js +18 -5
- package/dist/core/checkpoint-row-verdict.d.ts +99 -0
- package/dist/core/checkpoint-row-verdict.js +225 -0
- package/dist/core/checkpoint-store.d.ts +107 -738
- package/dist/core/checkpoint-store.js +45 -143
- package/dist/core/child-clamp-seats.d.ts +3 -2
- package/dist/core/child-clamp-seats.js +4 -3
- package/dist/core/closest-name.d.ts +13 -0
- package/dist/core/closest-name.js +35 -0
- package/dist/core/context-settings.js +3 -5
- package/dist/core/cross-boundary-taint.d.ts +1 -1
- package/dist/core/decision-receipt.d.ts +14 -1
- package/dist/core/decision-receipt.js +6 -3
- package/dist/core/delegation-frames.d.ts +13 -9
- package/dist/core/effective-path-target.js +2 -3
- package/dist/core/engine-attestation.d.ts +11 -1
- package/dist/core/engine-attestation.js +2 -0
- package/dist/core/engine-notice.d.ts +68 -21
- package/dist/core/engine-notice.js +9 -2
- package/dist/core/file-history-retention.d.ts +8 -0
- package/dist/core/file-history-retention.js +14 -11
- package/dist/core/file-history-store.d.ts +31 -1
- package/dist/core/file-history-store.js +31 -2
- package/dist/core/frame-settlement.d.ts +10 -0
- package/dist/core/frame-settlement.js +6 -1
- package/dist/core/fs-write-gate-policy.d.ts +3 -3
- package/dist/core/fs-write-gate-policy.js +8 -7
- package/dist/core/gate-fold.js +4 -3
- package/dist/core/gate-lanes.js +7 -4
- package/dist/core/gate-outcome.d.ts +40 -1
- package/dist/core/gate-outcome.js +10 -0
- package/dist/core/git-worktree-env.d.ts +7 -3
- package/dist/core/git-worktree-env.js +16 -13
- package/dist/core/governance-codes.d.ts +14 -4
- package/dist/core/governance-codes.js +19 -4
- package/dist/core/hooks.d.ts +25 -4
- package/dist/core/hooks.js +11 -4
- package/dist/core/host-floor.js +3 -5
- 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 +47 -7
- package/dist/core/image-admission.js +35 -4
- package/dist/core/input-author.d.ts +36 -0
- package/dist/core/input-author.js +39 -0
- package/dist/core/leg-identity.d.ts +62 -0
- package/dist/core/leg-identity.js +18 -0
- package/dist/core/locked-config.d.ts +4 -3
- package/dist/core/locked-config.js +5 -3
- package/dist/core/lsp.d.ts +5 -3
- package/dist/core/lsp.js +3 -2
- package/dist/core/mailbox-store.d.ts +85 -10
- package/dist/core/mailbox-store.js +31 -10
- package/dist/core/mcp-connection-pool.d.ts +6 -20
- package/dist/core/mcp-connection-pool.js +10 -28
- package/dist/core/mcp-failure.d.ts +76 -15
- package/dist/core/mcp-failure.js +60 -33
- package/dist/core/mcp-host-seat.d.ts +92 -53
- package/dist/core/mcp-host-seat.js +225 -46
- package/dist/core/mcp-probe.js +2 -2
- package/dist/core/mcp-server-link.d.ts +18 -6
- package/dist/core/mcp-server-link.js +19 -4
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/mcp-session-end.d.ts +1 -2
- package/dist/core/mcp-session-end.js +1 -1
- package/dist/core/mcp.d.ts +6 -49
- package/dist/core/mcp.js +115 -111
- package/dist/core/media-byte-cap.d.ts +21 -46
- package/dist/core/media-byte-cap.js +55 -55
- package/dist/core/member-group.d.ts +7 -0
- package/dist/core/member-group.js +35 -0
- package/dist/core/memory-engine/consolidation-driver.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.js +7 -1
- package/dist/core/memory-engine/dual-root.d.ts +31 -0
- package/dist/core/memory-engine/dual-root.js +59 -11
- package/dist/core/memory-engine/engine.js +27 -24
- package/dist/core/memory-engine/file-backend.d.ts +13 -0
- package/dist/core/memory-engine/file-backend.js +35 -15
- package/dist/core/memory-engine/layout.d.ts +3 -0
- package/dist/core/memory-engine/layout.js +13 -3
- package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
- package/dist/core/memory-engine/memory-deployment.js +182 -0
- package/dist/core/memory-engine/sync-client.d.ts +39 -18
- package/dist/core/memory-engine/sync-client.js +72 -14
- package/dist/core/memory-engine/sync-report.d.ts +7 -4
- package/dist/core/memory-engine/sync.d.ts +9 -1
- package/dist/core/memory-vector.d.ts +1 -1
- package/dist/core/memory.d.ts +10 -10
- package/dist/core/mode-policy.d.ts +8 -8
- package/dist/core/mode-policy.js +8 -6
- package/dist/core/mods/agent-stations.d.ts +39 -4
- package/dist/core/mods/agent-stations.js +59 -10
- package/dist/core/mods/classic-events.d.ts +9 -1
- package/dist/core/mods/dollar.d.ts +94 -1
- package/dist/core/mods/dollar.js +13 -1
- package/dist/core/mods/extension-call.d.ts +15 -1
- package/dist/core/mods/extension-call.js +7 -2
- package/dist/core/mods/kernel/dispatch.d.ts +4 -3
- package/dist/core/mods/kernel/dispatch.js +4 -4
- package/dist/core/mods/kernel/events.d.ts +14 -3
- package/dist/core/mods/kernel/events.js +18 -15
- package/dist/core/mods/kernel/registration.d.ts +3 -0
- package/dist/core/mods/kernel/registration.js +5 -0
- package/dist/core/mods/kernel/site-rules.d.ts +6 -3
- package/dist/core/mods/kernel/site-rules.js +10 -2
- package/dist/core/mods/lifecycle-stations.d.ts +36 -4
- package/dist/core/mods/lifecycle-stations.js +44 -9
- package/dist/core/mods/session-append.d.ts +118 -0
- package/dist/core/mods/session-append.js +318 -0
- package/dist/core/mods/session-compact.d.ts +48 -0
- package/dist/core/mods/session-compact.js +194 -0
- package/dist/core/mods/session-receive.d.ts +93 -0
- package/dist/core/mods/session-receive.js +138 -0
- package/dist/core/mods/session-send.d.ts +72 -0
- package/dist/core/mods/session-send.js +88 -0
- package/dist/core/mods/stations.d.ts +88 -21
- package/dist/core/mods/stations.js +149 -11
- package/dist/core/mods/tool-call.d.ts +2 -0
- package/dist/core/mods/tool-call.js +4 -4
- package/dist/core/output-style.js +3 -4
- package/dist/core/own-property-receipt.d.ts +68 -2
- package/dist/core/own-property-receipt.js +45 -2
- package/dist/core/park-selfcheck.js +4 -2
- package/dist/core/path-identity.d.ts +11 -0
- package/dist/core/path-identity.js +4 -0
- package/dist/core/path-rule-binding.d.ts +3 -1
- package/dist/core/path-rule-binding.js +3 -1
- package/dist/core/peer-seat.d.ts +3 -3
- package/dist/core/peer-seat.js +20 -8
- package/dist/core/permission-rule-consent.d.ts +21 -5
- package/dist/core/permission-rule-consent.js +21 -1
- package/dist/core/permission-rule-model.d.ts +34 -11
- package/dist/core/permission-rule-model.js +47 -10
- package/dist/core/permission-rule-org.d.ts +1 -1
- package/dist/core/permission-rule-provider.js +4 -1
- package/dist/core/permission-rules.d.ts +4 -0
- package/dist/core/permission-rules.js +11 -16
- package/dist/core/read-root-candidate.js +1 -1
- package/dist/core/remote-env.d.ts +74 -26
- package/dist/core/remote-env.js +20 -0
- package/dist/core/resume-startup-cause.d.ts +5 -4
- package/dist/core/retention-policy.d.ts +24 -23
- package/dist/core/retention-policy.js +36 -2
- package/dist/core/retention.d.ts +4 -1
- package/dist/core/retired-keys.d.ts +4 -4
- package/dist/core/row-admission.d.ts +10 -0
- package/dist/core/row-admission.js +5 -0
- package/dist/core/runner/advisor-instructions.d.ts +2 -1
- package/dist/core/runner/advisor-instructions.js +2 -1
- package/dist/core/runner/announce-once-ledger.d.ts +4 -4
- package/dist/core/runner/assemble-result.d.ts +13 -3
- package/dist/core/runner/assemble-result.js +12 -7
- package/dist/core/runner/caller-roster.d.ts +12 -9
- package/dist/core/runner/caller-roster.js +5 -2
- package/dist/core/runner/checkpoint-scope.d.ts +16 -1
- package/dist/core/runner/checkpoint-scope.js +21 -0
- package/dist/core/runner/compact-session.js +18 -3
- package/dist/core/runner/compaction-call-options.d.ts +1 -1
- package/dist/core/runner/compaction-restate.d.ts +2 -2
- package/dist/core/runner/compaction-restate.js +4 -3
- package/dist/core/runner/construction-doors.d.ts +2 -2
- package/dist/core/runner/construction-doors.js +2 -2
- package/dist/core/runner/contracts.d.ts +116 -34
- package/dist/core/runner/cross-boundary-lane.d.ts +1 -1
- package/dist/core/runner/decide-continuation.d.ts +4 -2
- package/dist/core/runner/decide-continuation.js +7 -4
- package/dist/core/runner/delegation-owner.d.ts +43 -0
- package/dist/core/runner/delegation-owner.js +59 -0
- package/dist/core/runner/denial-limit-arms.d.ts +15 -21
- package/dist/core/runner/denial-limit-arms.js +17 -10
- package/dist/core/runner/expire-settle.d.ts +44 -0
- package/dist/core/runner/expire-settle.js +55 -0
- package/dist/core/runner/git-status-frame.d.ts +3 -3
- package/dist/core/runner/git-status-frame.js +2 -1
- package/dist/core/runner/halt-attribution.d.ts +2 -1
- package/dist/core/runner/halt-attribution.js +2 -1
- package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
- package/dist/core/runner/lineage-reroot-view.js +108 -0
- package/dist/core/runner/local-claims.d.ts +17 -0
- package/dist/core/runner/local-claims.js +18 -0
- package/dist/core/runner/media-removed-seat.d.ts +46 -0
- package/dist/core/runner/media-removed-seat.js +88 -0
- package/dist/core/runner/park-commit.d.ts +2 -2
- package/dist/core/runner/permission-rule-lanes.d.ts +7 -2
- package/dist/core/runner/permission-rule-lanes.js +28 -9
- package/dist/core/runner/person-path-rows.d.ts +15 -0
- package/dist/core/runner/person-path-rows.js +27 -4
- package/dist/core/runner/placement-fence.d.ts +26 -0
- package/dist/core/runner/placement-fence.js +38 -0
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
- package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
- package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
- package/dist/core/runner/prepare-ask-lane.js +4 -4
- package/dist/core/runner/prepare-boundary-parks.d.ts +4 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -1
- package/dist/core/runner/prepare-config-doors.d.ts +6 -6
- package/dist/core/runner/prepare-config-doors.js +19 -21
- package/dist/core/runner/prepare-context-lane.d.ts +6 -2
- package/dist/core/runner/prepare-context-lane.js +13 -13
- package/dist/core/runner/prepare-delegation-surface.d.ts +9 -9
- package/dist/core/runner/prepare-delegation-surface.js +4 -5
- package/dist/core/runner/prepare-execution-env.d.ts +5 -2
- package/dist/core/runner/prepare-execution-env.js +7 -4
- package/dist/core/runner/prepare-gate-stations.d.ts +19 -14
- package/dist/core/runner/prepare-gate-stations.js +6 -4
- package/dist/core/runner/prepare-hands-readface.d.ts +6 -6
- package/dist/core/runner/prepare-hands-readface.js +32 -11
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -0
- package/dist/core/runner/prepare-inherited-gate.js +10 -3
- package/dist/core/runner/prepare-lsp.d.ts +3 -0
- package/dist/core/runner/prepare-lsp.js +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +5 -2
- package/dist/core/runner/prepare-park-ask.js +4 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +10 -21
- package/dist/core/runner/prepare-policy-chain.js +16 -25
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -4
- package/dist/core/runner/prepare-prompt-inputs.js +3 -2
- package/dist/core/runner/prepare-question-face.d.ts +6 -4
- package/dist/core/runner/prepare-question-face.js +2 -2
- package/dist/core/runner/prepare-run-refs.d.ts +3 -0
- package/dist/core/runner/prepare-run-refs.js +2 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +11 -7
- package/dist/core/runner/prepare-suspend-saga.js +17 -7
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +61 -30
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
- package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -0
- package/dist/core/runner/prepare-wiring-manifest.js +2 -1
- package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
- package/dist/core/runner/prepare-workspace-restore.js +10 -6
- package/dist/core/runner/read-root-grant.d.ts +1 -1
- package/dist/core/runner/read-root-grant.js +2 -1
- package/dist/core/runner/resume-admission.d.ts +8 -6
- package/dist/core/runner/resume-admission.js +23 -6
- package/dist/core/runner/resume-apply.d.ts +4 -0
- package/dist/core/runner/resume-apply.js +14 -5
- package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
- package/dist/core/runner/resume-checkpoint-screen.js +4 -84
- package/dist/core/runner/resume-claim.d.ts +8 -3
- package/dist/core/runner/resume-claim.js +28 -12
- package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
- package/dist/core/runner/resume-internals-and-config.js +10 -1
- package/dist/core/runner/resume-preflight.d.ts +3 -2
- package/dist/core/runner/resume-preflight.js +13 -26
- package/dist/core/runner/retired-runner-deps.js +2 -0
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +6 -2
- package/dist/core/runner/run-harness-handlers.d.ts +2 -0
- package/dist/core/runner/run-harness-handlers.js +5 -4
- package/dist/core/runner/run-identity-wiring.d.ts +2 -2
- package/dist/core/runner/run-identity-wiring.js +14 -5
- package/dist/core/runner/run-leg.d.ts +3 -3
- package/dist/core/runner/run-leg.js +64 -36
- package/dist/core/runner/run-notification-lane.js +20 -2
- package/dist/core/runner/run-recovery-lanes.js +3 -2
- package/dist/core/runner/run-settle-and-teardown.js +12 -9
- package/dist/core/runner/run-stop-and-final-verify.js +2 -1
- package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.js +26 -17
- package/dist/core/runner/run-turn-boundary.js +34 -18
- package/dist/core/runner/runtask.d.ts +18 -3
- package/dist/core/runner/runtask.js +33 -17
- package/dist/core/runner/session-rule-policy.d.ts +1 -1
- package/dist/core/runner/session-rule-policy.js +6 -1
- package/dist/core/runner/shell-env-withheld.d.ts +1 -1
- package/dist/core/runner/steering-preview.d.ts +9 -0
- package/dist/core/runner/steering-preview.js +5 -0
- package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
- package/dist/core/runner/stream-halt-verbs.js +4 -3
- package/dist/core/runner/stream-reap.d.ts +7 -6
- package/dist/core/runner/stream-reap.js +13 -16
- package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
- package/dist/core/runner/stream-settle-backstop.js +5 -3
- package/dist/core/runner/stream-steer-verb.d.ts +5 -2
- package/dist/core/runner/stream-steer-verb.js +16 -7
- package/dist/core/runner/terminal-account.d.ts +11 -1
- package/dist/core/runner/terminal-account.js +20 -0
- package/dist/core/runner/terminal-projection.d.ts +8 -2
- package/dist/core/runner/terminal-projection.js +2 -2
- package/dist/core/runner/tool-disclosure.d.ts +3 -0
- package/dist/core/runner/tool-disclosure.js +5 -2
- package/dist/core/runner/tool-end-body.d.ts +3 -3
- package/dist/core/runner/tool-end-body.js +1 -1
- package/dist/core/runner/tool-face-overlay.js +2 -0
- package/dist/core/runner/tool-output-projection.d.ts +3 -3
- package/dist/core/runner/tool-output-projection.js +7 -6
- package/dist/core/runner/tool-table-view.d.ts +56 -0
- package/dist/core/runner/tool-table-view.js +51 -0
- package/dist/core/runner/turn-attachments.d.ts +8 -2
- package/dist/core/runner/turn-attachments.js +2 -2
- package/dist/core/runner/void-verifier-pause.d.ts +33 -0
- package/dist/core/runner/void-verifier-pause.js +41 -0
- package/dist/core/runner-deps.d.ts +26 -27
- package/dist/core/secret-env.d.ts +19 -16
- package/dist/core/secret-env.js +45 -27
- package/dist/core/session-log-transfer.js +9 -10
- package/dist/core/session-policy-store.d.ts +1 -1
- package/dist/core/session-policy-store.js +5 -2
- package/dist/core/session-reconcile.d.ts +3 -2
- package/dist/core/session-reconcile.js +7 -4
- package/dist/core/session-store.d.ts +3 -1
- package/dist/core/session-store.js +10 -8
- package/dist/core/session.d.ts +16 -5
- package/dist/core/shell-confinement.d.ts +37 -0
- package/dist/core/shell-confinement.js +56 -0
- package/dist/core/skill-grant.js +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +8 -2
- package/dist/core/store-contracts/checkpoint-store-contract.js +83 -2
- package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
- package/dist/core/store-contracts/file-history-store-contract.js +25 -1
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
- package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
- package/dist/core/store-contracts/session-store-contract.js +22 -8
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +30 -0
- package/dist/core/task-event.d.ts +24 -9
- package/dist/core/task-limits.d.ts +5 -0
- package/dist/core/task-notification.d.ts +89 -12
- package/dist/core/task-notification.js +89 -14
- package/dist/core/task-registry-agent.d.ts +32 -50
- package/dist/core/task-registry-agent.js +36 -56
- package/dist/core/task-registry-monitor.d.ts +1 -1
- package/dist/core/task-registry-monitor.js +15 -60
- package/dist/core/task-registry-shared.d.ts +22 -112
- package/dist/core/task-registry-shared.js +3 -41
- package/dist/core/task-registry-workflow.js +5 -21
- package/dist/core/task-registry.d.ts +32 -62
- package/dist/core/task-registry.js +30 -110
- package/dist/core/task-result.d.ts +29 -12
- package/dist/core/task-spec-members.d.ts +39 -0
- package/dist/core/task-spec-members.js +92 -0
- package/dist/core/task-spec.d.ts +11 -11
- package/dist/core/task-tool-shape.d.ts +7 -57
- package/dist/core/task-tool-shape.js +7 -66
- package/dist/core/terminal-cause.d.ts +36 -6
- package/dist/core/terminal-cause.js +1 -0
- package/dist/core/tool-catalog-entries.js +2 -5
- package/dist/core/tool-check-reading.js +16 -10
- package/dist/core/tool-conformance.js +1 -2
- package/dist/core/tool-errors.d.ts +6 -3
- package/dist/core/tool-errors.js +2 -0
- package/dist/core/tool-face-reader.js +3 -2
- package/dist/core/tool-face.d.ts +8 -5
- package/dist/core/tool-face.js +1 -1
- package/dist/core/tool-name-aliases.d.ts +5 -29
- package/dist/core/tool-name-aliases.js +9 -5
- package/dist/core/tool-name-readings.d.ts +14 -3
- package/dist/core/tool-name-readings.js +2 -0
- package/dist/core/tool-policy.d.ts +109 -18
- package/dist/core/tool-policy.js +84 -14
- package/dist/core/tool-result-store.d.ts +23 -0
- package/dist/core/tool-result-store.js +3 -2
- package/dist/core/tool-roster.d.ts +4 -4
- package/dist/core/tool-spec.d.ts +23 -6
- package/dist/core/trace.d.ts +18 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/core/types.js +1 -1
- package/dist/core/user-attachment.js +26 -21
- package/dist/core/workflow-journal-store.d.ts +1 -1
- package/dist/core/workflow-run-store.d.ts +2 -0
- package/dist/core/workflow-run-store.js +6 -5
- package/dist/core/workflow-settled-run.d.ts +5 -0
- package/dist/core/workflow-settled-run.js +7 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +37 -9
- package/dist/engine/execution-env/node-execution-env.js +221 -22
- package/dist/engine/harness/agent-harness.d.ts +65 -18
- package/dist/engine/harness/agent-harness.js +90 -23
- package/dist/engine/harness/messages.d.ts +4 -3
- package/dist/engine/harness/messages.js +2 -2
- package/dist/engine/harness/types.d.ts +52 -7
- package/dist/engine/llm/media-removed.d.ts +14 -0
- package/dist/engine/llm/media-removed.js +9 -0
- package/dist/engine/llm/rejected-images.d.ts +35 -25
- package/dist/engine/llm/rejected-images.js +59 -10
- package/dist/engine/llm/types.d.ts +24 -3
- package/dist/engine/llm/types.js +7 -3
- package/dist/engine/loop/agent-loop.d.ts +6 -1
- package/dist/engine/loop/agent-loop.js +20 -11
- package/dist/engine/loop/types.d.ts +12 -3
- package/dist/engine/session/import-validate.js +7 -0
- package/dist/engine/session/parent-chain-guard.d.ts +3 -3
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/path-to-root.d.ts +18 -3
- package/dist/engine/session/path-to-root.js +15 -1
- package/dist/engine/session/repo-utils.d.ts +12 -1
- package/dist/engine/session/repo-utils.js +41 -0
- package/dist/engine/session/session.js +1 -1
- package/dist/engine/session/storage-base.d.ts +20 -0
- package/dist/engine/session/storage-base.js +28 -9
- package/dist/fixtures/index.d.ts +7 -5
- package/dist/fixtures/index.js +5 -3
- package/dist/index.d.ts +29 -18
- package/dist/index.js +19 -11
- package/dist/internal/harness-types.d.ts +2 -0
- package/dist/internal/harness.d.ts +4 -3
- package/dist/internal/harness.js +3 -2
- package/dist/internal/llm.d.ts +2 -1
- package/dist/internal/llm.js +1 -0
- package/dist/orchestration/goal.d.ts +6 -2
- package/dist/orchestration/goal.js +6 -3
- package/dist/orchestration/run-workflow-tool.d.ts +14 -17
- package/dist/orchestration/run-workflow-tool.js +43 -50
- package/dist/orchestration/workflow-types.d.ts +2 -2
- package/dist/orchestration/workflow.d.ts +7 -0
- package/dist/orchestration/workflow.js +10 -12
- package/dist/stores/file/background-agent-store.js +18 -15
- package/dist/stores/file/checkpoint-store.d.ts +2 -0
- package/dist/stores/file/checkpoint-store.js +13 -9
- package/dist/stores/file/file-history-store.js +3 -2
- package/dist/stores/file/fs-atomic.d.ts +0 -22
- package/dist/stores/file/fs-atomic.js +0 -17
- package/dist/stores/file/index.d.ts +7 -12
- package/dist/stores/file/index.js +25 -12
- package/dist/stores/file/ledger-tuning.d.ts +23 -0
- package/dist/stores/file/ledger-tuning.js +21 -0
- package/dist/stores/file/mailbox-store.js +42 -22
- package/dist/stores/file/memory-store.js +3 -2
- package/dist/stores/file/permission-rule-adopt.js +24 -21
- package/dist/stores/file/permission-rule-store.js +6 -3
- package/dist/stores/file/session-policy-store.js +3 -2
- package/dist/stores/file/session-store.d.ts +26 -7
- package/dist/stores/file/session-store.js +59 -35
- package/dist/stores/file/tool-result-store.d.ts +11 -0
- package/dist/stores/file/tool-result-store.js +57 -3
- package/dist/stores/file/usage-window-store.js +3 -2
- package/dist/stores/file/workflow-journal-store.d.ts +0 -2
- package/dist/stores/file/workflow-journal-store.js +3 -18
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/stores/file/workflow-run-store.js +15 -10
- package/dist/tools/fs/bash-program-position.d.ts +3 -2
- package/dist/tools/fs/bash-program-position.js +7 -7
- package/dist/tools/fs/dead-cwd.d.ts +5 -5
- package/dist/tools/fs/dead-cwd.js +4 -11
- package/dist/tools/fs/fs-bash-background-text.d.ts +6 -0
- package/dist/tools/fs/fs-bash-background-text.js +6 -0
- package/dist/tools/fs/fs-bash.d.ts +3 -18
- package/dist/tools/fs/fs-bash.js +37 -124
- package/dist/tools/fs/fs-pdf.js +8 -6
- package/dist/tools/fs/fs-read.js +2 -2
- package/dist/tools/fs/fs-shared.d.ts +28 -3
- package/dist/tools/fs/fs-shared.js +15 -0
- package/dist/tools/fs/index.d.ts +1 -1
- package/dist/tools/fs/index.js +4 -14
- package/dist/tools/fs/pdf.d.ts +4 -4
- package/dist/tools/fs/pdf.js +6 -6
- package/dist/tools/fs/read-deny-home.js +8 -1
- package/dist/tools/fs/read-deny.d.ts +26 -2
- package/dist/tools/fs/read-deny.js +9 -2
- package/dist/tools/fs/read-floor.d.ts +13 -5
- package/dist/tools/fs/read-floor.js +206 -2
- package/dist/tools/fs/removal-targets.js +2 -2
- package/dist/tools/fs/search.d.ts +3 -2
- package/dist/tools/fs/search.js +6 -6
- package/dist/tools/fs/shell-read-argv.d.ts +4 -2
- package/dist/tools/fs/shell-read-argv.js +14 -3
- package/dist/tools/fs/shell-read-bindings.d.ts +18 -2
- package/dist/tools/fs/shell-read-bindings.js +148 -68
- package/dist/tools/fs/shell-read-check.js +20 -4
- package/dist/tools/fs/shell-read-establish.js +25 -9
- package/dist/tools/fs/shell-read-functions.js +2 -2
- package/dist/tools/fs/shell-read-identity.d.ts +3 -1
- package/dist/tools/fs/shell-read-identity.js +4 -2
- package/dist/tools/fs/shell-read-judge.d.ts +7 -1
- package/dist/tools/fs/shell-read-judge.js +1 -1
- package/dist/tools/fs/shell-read-object-path.d.ts +59 -0
- package/dist/tools/fs/shell-read-object-path.js +119 -0
- package/dist/tools/fs/shell-read-plan.d.ts +8 -0
- package/dist/tools/fs/shell-read-plan.js +47 -30
- package/dist/tools/fs/shell-read-start.d.ts +66 -13
- package/dist/tools/fs/shell-read-start.js +89 -17
- package/dist/tools/fs/shell-read-workdir.d.ts +29 -8
- package/dist/tools/fs/shell-read-workdir.js +31 -8
- package/dist/tools/monitor.d.ts +8 -7
- package/dist/tools/monitor.js +12 -10
- package/dist/tools/worktree.d.ts +5 -1
- package/dist/tools/worktree.js +20 -17
- package/package.json +6 -3
- package/test/export-surface.snapshot.json +112 -42
- package/wire-changes/core-stores-sql@7.61.0.json +480 -0
- package/wire-changes/core-stores-sql@7.62.0.json +30 -0
- package/wire-changes/core@7.61.0.json +4405 -0
- package/wire-changes/core@7.62.0.json +2181 -0
- package/wire-changes/mods-kernel@7.61.0.json +65 -0
- package/wire-changes/mods-kernel@7.62.0.json +42 -0
- package/wire-changes/primitives@7.61.0.json +30 -0
- package/wire-changes/primitives@7.62.0.json +30 -0
- package/dist/core/consolidate-scope.d.ts +0 -93
- package/dist/core/consolidate-scope.js +0 -98
- package/dist/core/runner/image-removed-seat.d.ts +0 -12
- package/dist/core/runner/image-removed-seat.js +0 -19
- package/dist/core/runner/memory-consolidation.d.ts +0 -109
- package/dist/core/runner/memory-consolidation.js +0 -251
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import type { PausedCause, TaskResult, TerminalCause } from "../core/types.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* run their work as *nested* `runTask`s, and none of them can drive a resume from the inside. If a nested
|
|
6
|
-
* task pauses on a durable gate, the orchestrator must **fail fast** — not silently treat it as an
|
|
7
|
-
* ordinary failure (which would escalate/re-run side effects) and not release its pinned session (which
|
|
8
|
-
* would orphan the checkpoint). It maps `paused → failed` with the code `"unexpected.suspended"` (an
|
|
9
|
-
* approval / resource pause) or `"unexpected.needs_review"` (a review pause) and **carries the pause's own
|
|
10
|
-
* cause on the failed terminal's `nestedPause` seat** so the top-level caller can still resume.
|
|
3
|
+
* The **nested durable-pause boundary** — the one place that says which orchestrators map a pause they meet and how a host
|
|
4
|
+
* continues it; the other places that mention it point here.
|
|
11
5
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
6
|
+
* An orchestrator that runs its work as *nested* `runTask`s cannot answer a durable gate (an approval, a resource slice, a platform
|
|
7
|
+
* park, a dry-run or plan review) from the inside. The cascade (`runCascade` / `resumeCascade`) and the verification gate
|
|
8
|
+
* (`runWithVerification` / `resumeWithVerification`) therefore **stop** at such a pause — no escalation or re-run (side effects), and
|
|
9
|
+
* no release of the pinned session (the checkpoint still references it) — and hand it back through {@link mapNestedSuspend}: a
|
|
10
|
+
* `failed` terminal with the code `"unexpected.suspended"` (an approval / resource / platform pause) or `"unexpected.needs_review"`
|
|
11
|
+
* (a review pause), **the pause's own cause on the failed terminal's `nestedPause` seat**, and a sentence that names the entry that
|
|
12
|
+
* continues it. That entry is the orchestrator's own: `resumeCascade` for a cascade, `resumeWithVerification` for a verification
|
|
13
|
+
* gate. Once the pause is decided, the host calls it with `nestedPause.token` and the decision.
|
|
14
|
+
*
|
|
15
|
+
* The other orchestrators do not map: the repair loop hands the paused terminal back as is, a workflow parks the run, and a
|
|
16
|
+
* subagent reports `suspended.awaiting_approval`.
|
|
17
|
+
*
|
|
18
|
+
* The structural prevention is upstream — an orchestrator should run nested tasks under a **non-durable** approval policy (e.g. the
|
|
19
|
+
* verifier already forces `handsReadOnly` + headless auto-deny) so a suspension cannot arise. This mapping is the defense-in-depth:
|
|
20
|
+
* a deployment that wires durable suspend into a nested orchestrator gets a surfaced pause, not silent errors.
|
|
16
21
|
*/
|
|
17
22
|
export declare const UNEXPECTED_SUSPENDED = "unexpected.suspended";
|
|
18
23
|
/** design/80 D-B: the review durable-pause family (dry-run `needs_review` AND `plan_review`) hits the SAME
|
|
@@ -22,9 +27,9 @@ export declare const UNEXPECTED_NEEDS_REVIEW = "unexpected.needs_review";
|
|
|
22
27
|
/**
|
|
23
28
|
* design/80 D-B: the durable-pause hard boundary covers EVERY `paused` cause — an approval gate, a resource
|
|
24
29
|
* slice, a dry-run review, a `plan_review` plan-gate. All of them persist a checkpoint + PIN their session,
|
|
25
|
-
* and
|
|
26
|
-
* pinned session (releasing it orphans the checkpoint). A type guard, so the caller reads the
|
|
27
|
-
* off the narrowed cause.
|
|
30
|
+
* and the decision that resumes them comes from outside the orchestrator — so it must surface the pause and
|
|
31
|
+
* NOT release the pinned session (releasing it orphans the checkpoint). A type guard, so the caller reads the
|
|
32
|
+
* token/gate off the narrowed cause.
|
|
28
33
|
*/
|
|
29
34
|
export declare function isDurablePause(terminal: TerminalCause): terminal is PausedCause;
|
|
30
35
|
/** A result whose terminal is known to be a pause — what {@link isDurablePause} narrows a result's
|
|
@@ -32,15 +37,41 @@ export declare function isDurablePause(terminal: TerminalCause): terminal is Pau
|
|
|
32
37
|
export type PausedResult = TaskResult & {
|
|
33
38
|
terminal: PausedCause;
|
|
34
39
|
};
|
|
40
|
+
/** A resumed leg that ended before its approved action started — read off the row's outcome the leg states
|
|
41
|
+
* (`failed.unstartedRow`), never off its code (that still names what ended the leg) or its sentence. Its checkpoint is
|
|
42
|
+
* pending again, or the store declined, or its state is unprovable: in none of them was the approved work done, so an
|
|
43
|
+
* orchestrator stops there as at a durable pause — no re-run, no escalation, no session release. */
|
|
44
|
+
export declare function resumeNeverStarted(result: TaskResult): boolean;
|
|
35
45
|
/**
|
|
36
46
|
* Which family a pause belongs to — its gate kind's registry row: `"suspended"` (an approval gate, a
|
|
37
47
|
* resource slice, a platform park) or `"needs_review"` (a dry-run or plan review). The same row the
|
|
38
48
|
* status word is projected from; read here by the orchestrators that name the family in their own faces.
|
|
39
49
|
*/
|
|
40
50
|
export declare function pauseFamily(t: PausedCause): "suspended" | "needs_review";
|
|
51
|
+
/**
|
|
52
|
+
* The entry that continues what {@link mapNestedSuspend} hands back, as the orchestrator that calls it names it. The entry is the
|
|
53
|
+
* caller's to give — the mint does not look at who is calling — and a union, so a new mapper has to name its own to compile.
|
|
54
|
+
*/
|
|
55
|
+
export interface NestedResumeEntry {
|
|
56
|
+
/** The orchestrator's resume entry, by its exported name. */
|
|
57
|
+
readonly door: "resumeCascade" | "resumeWithVerification";
|
|
58
|
+
/**
|
|
59
|
+
* Only for an entry that takes the parked leg: where the host gets it. `"card"` — the parked card records it
|
|
60
|
+
* (`CheckpointState.compositionLeg`); `"caller"` — the leg was dispatched with none (the task spec named no session and no leg was
|
|
61
|
+
* handed in), so the card records none and the host supplies the leg itself. Absent — the entry takes no leg.
|
|
62
|
+
*/
|
|
63
|
+
readonly legFrom?: "card" | "caller";
|
|
64
|
+
}
|
|
41
65
|
/**
|
|
42
66
|
* If `result` durably paused, return it mapped to a `failed` result whose terminal carries the pause on
|
|
43
67
|
* `nestedPause`; otherwise return it unchanged. The orchestrator should also **stop** (not escalate/re-run)
|
|
44
68
|
* and **not release** the session when this maps a pause — the checkpoint still references that session.
|
|
69
|
+
*
|
|
70
|
+
* `resume` names the entry that continues the pause; the sentence of the failed terminal is one template with that entry (and, for
|
|
71
|
+
* an entry that takes the parked leg, where the host gets the leg) as its slots.
|
|
72
|
+
*
|
|
73
|
+
* The mapped result keeps the parked leg's `sessionId` — the parked row's own `Checkpoint.sessionId`. A composition's legs do
|
|
74
|
+
* not run in the caller's session, so a host links the row to its run by the row's `CheckpointState.compositionLeg`, never by
|
|
75
|
+
* assuming the row sits in the session it submitted.
|
|
45
76
|
*/
|
|
46
|
-
export declare function mapNestedSuspend(result: TaskResult): TaskResult;
|
|
77
|
+
export declare function mapNestedSuspend(result: TaskResult, resume: NestedResumeEntry): TaskResult;
|
|
@@ -4,19 +4,28 @@ export const UNEXPECTED_NEEDS_REVIEW = "unexpected.needs_review";
|
|
|
4
4
|
export function isDurablePause(terminal) {
|
|
5
5
|
return terminal.kind === "paused";
|
|
6
6
|
}
|
|
7
|
+
export function resumeNeverStarted(result) {
|
|
8
|
+
const t = result.terminal;
|
|
9
|
+
return t.kind === "failed" && t.unstartedRow !== undefined;
|
|
10
|
+
}
|
|
7
11
|
export function pauseFamily(t) {
|
|
8
12
|
return PAUSE_REGISTRY[t.gate.kind].taskStatus;
|
|
9
13
|
}
|
|
10
|
-
|
|
14
|
+
const LEG_CLAUSE = {
|
|
15
|
+
card: ", and the leg its parked card records (CheckpointState.compositionLeg)",
|
|
16
|
+
caller: ", and the parked leg — this run's card records none because the task spec named no session, so you supply it yourself",
|
|
17
|
+
};
|
|
18
|
+
export function mapNestedSuspend(result, resume) {
|
|
11
19
|
const t = result.terminal;
|
|
12
20
|
if (!isDurablePause(t)) {
|
|
13
21
|
return result;
|
|
14
22
|
}
|
|
15
23
|
const word = pauseFamily(t);
|
|
16
24
|
const code = word === "needs_review" ? UNEXPECTED_NEEDS_REVIEW : UNEXPECTED_SUSPENDED;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
const legClause = resume.legFrom === undefined ? "" : LEG_CLAUSE[resume.legFrom];
|
|
26
|
+
const message = `a nested task durably paused ("${word}") on a HITL gate and the orchestrator stopped there, keeping the parked leg's session: ` +
|
|
27
|
+
`once the pause is decided, continue it with ${resume.door}, handing it this pause's token (nestedPause.token) and the decision${legClause}; ` +
|
|
28
|
+
"or run the orchestrated task under a non-durable policy so it auto-adjudicates instead of pausing.";
|
|
20
29
|
return {
|
|
21
30
|
...result,
|
|
22
31
|
terminal: { kind: "failed", code, message, nestedPause: t },
|
package/dist/agents/verify.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Type, type Static } from "typebox";
|
|
|
2
2
|
import type { ResumeTaskConfig, RunInternals, RunnerSelfSeat } from "../core/runner/contracts.js";
|
|
3
3
|
import type { CheckpointGate, CheckpointToken, ResumeOutcome } from "../core/checkpoint-store.js";
|
|
4
4
|
import type { ModelRef, TaskResult, TaskSpec, TaskStatus, ToolSpec } from "../core/types.js";
|
|
5
|
+
import { type AllowanceExhausted } from "./composition-allowance.js";
|
|
5
6
|
/**
|
|
6
7
|
* Verification gate (developer mode, design/28 §4). An **independent falsification-style verifier** runs after
|
|
7
8
|
* an implementation task and tries to BREAK it — read-only, evidence-required, returning a structured
|
|
@@ -118,9 +119,10 @@ export interface VerifyConfig {
|
|
|
118
119
|
/**
|
|
119
120
|
* HRD-AGO-3 — fired when the VERIFIER's own run durably paused (`suspended`/`needs_review`), carrying the
|
|
120
121
|
* resume capability for the checkpoint it minted. The pause is ALWAYS reported on
|
|
121
|
-
* {@link VerificationOutcome.verifierPause} as well
|
|
122
|
-
* checkpoint lifecycle can act at once
|
|
123
|
-
*
|
|
122
|
+
* {@link VerificationOutcome.verifierPause} as well — this callback hands the same members, plus the iteration number; it
|
|
123
|
+
* exists so a deployment that owns the checkpoint lifecycle can act at once instead of waiting for the reaper:
|
|
124
|
+
* decide the card (`runner.resume` with the token), or void it with `Runner.voidVerifierPause(token)`, which
|
|
125
|
+
* expires the card and unpins the verifier session. A throwing handler cannot strand the gate (it is swallowed, like `onRound`).
|
|
124
126
|
*
|
|
125
127
|
* ⚠️ `checkpointToken` is the resume CAPABILITY — never log it or put it in a URL (types.ts §6).
|
|
126
128
|
*/
|
|
@@ -130,6 +132,7 @@ export interface VerifyConfig {
|
|
|
130
132
|
sessionId: string;
|
|
131
133
|
checkpointToken?: CheckpointToken;
|
|
132
134
|
checkpointGate?: CheckpointGate;
|
|
135
|
+
checkpointId?: string;
|
|
133
136
|
}) => void;
|
|
134
137
|
}
|
|
135
138
|
/**
|
|
@@ -147,8 +150,8 @@ export interface VerifyConfig {
|
|
|
147
150
|
* - `"opted_out"` — verification was explicitly disabled (`runDeveloperTask({ verify: false })`); not gated by design.
|
|
148
151
|
* - `"verifier_paused"` (HRD-AGO-3) — the VERIFIER's own run durably paused (suspended/needs_review) and minted
|
|
149
152
|
* a checkpoint of its own. DISJOINT from `"suspended"` (which is about the IMPLEMENTATION): the work IS done,
|
|
150
|
-
* it simply was not gated, and there is an outstanding verifier checkpoint the caller must decide or
|
|
151
|
-
* see {@link VerificationOutcome.verifierPause} for the token. Previously reported as `"no_verdict"`, which
|
|
153
|
+
* it simply was not gated, and there is an outstanding verifier checkpoint the caller must decide or void
|
|
154
|
+
* (`Runner.voidVerifierPause`) — see {@link VerificationOutcome.verifierPause} for the token. Previously reported as `"no_verdict"`, which
|
|
152
155
|
* reads like a broken verifier and hid the fact that a live checkpoint was left pinned.
|
|
153
156
|
*/
|
|
154
157
|
export type UnverifiedReason = "suspended" | "needs_review" | "no_verdict" | "opted_out" | "impl_incomplete" | "could_not_verify" | "verifier_paused";
|
|
@@ -184,12 +187,25 @@ export interface VerificationOutcome {
|
|
|
184
187
|
* (undefined) when no verifier ran (e.g. an impl that suspended/was opted out before verification).
|
|
185
188
|
*/
|
|
186
189
|
verifierCost?: number;
|
|
190
|
+
/**
|
|
191
|
+
* Set when the loop stopped before a fix leg because the TASK's own ceilings had nothing left on an axis. The task's
|
|
192
|
+
* `limits` (or, on a task that opted into resource suspension, its `resourceSuspend` totals) bound the implementation
|
|
193
|
+
* side as one task — every fix leg runs on what the implementation legs before it left — so the loop returns the current
|
|
194
|
+
* FAIL with its findings, at the same exit as {@link VerifyConfig.costCeilingMicroUsd}, and names the axis and what was
|
|
195
|
+
* left (`0`; absent when the spend could not be known). Absent on every other stop.
|
|
196
|
+
*/
|
|
197
|
+
allowanceExhausted?: AllowanceExhausted;
|
|
187
198
|
/**
|
|
188
199
|
* HRD-AGO-3 — set iff `unverifiedReason === "verifier_paused"`: the VERIFIER's own durable pause. The
|
|
189
200
|
* verifier's session stays PINNED by its checkpoint (releasing it here would orphan the checkpoint), so the
|
|
190
|
-
* pause is handed back instead of being swallowed
|
|
191
|
-
*
|
|
192
|
-
*
|
|
201
|
+
* pause is handed back instead of being swallowed. Its card records the leg it is
|
|
202
|
+
* (`CheckpointState.compositionLeg`, entry `verify`: the iteration and the implementation's session), so a host
|
|
203
|
+
* tells it from a card its own run's resume reaches. Settle it with this token, either way unpinning the
|
|
204
|
+
* verifier session: `runner.resume` decides it (the resumed run's terminal unpins), and
|
|
205
|
+
* `Runner.voidVerifierPause(token)` voids it — the card ends `expired`, exactly as an expiry leaves it, and the
|
|
206
|
+
* session is unpinned (not released: its transcript stays the session store's to evict). Without it the token
|
|
207
|
+
* died inside the gate and the checkpoint + pinned session survived only until the deadline reaper collected
|
|
208
|
+
* them, with nothing in the result saying so.
|
|
193
209
|
*
|
|
194
210
|
* ⚠️ `checkpointToken` is the resume CAPABILITY — never log it or put it in a URL (types.ts §6).
|
|
195
211
|
*/
|
|
@@ -202,6 +218,9 @@ export interface VerificationOutcome {
|
|
|
202
218
|
checkpointToken?: CheckpointToken;
|
|
203
219
|
/** What the verifier's checkpoint is waiting on (which resume outcome it takes). */
|
|
204
220
|
checkpointGate?: CheckpointGate;
|
|
221
|
+
/** The card's NON-SECRET stable identity (`Checkpoint.checkpointId`, the pause's own `checkpointId`) — the key a host
|
|
222
|
+
* may log or render where the token must not travel. Present whenever the pause minted a card that carries one. */
|
|
223
|
+
checkpointId?: string;
|
|
205
224
|
};
|
|
206
225
|
}
|
|
207
226
|
export interface VerificationResult extends TaskResult {
|
|
@@ -241,7 +260,7 @@ export declare function verifyCompleted(runner: RunnerSelfSeat, result: TaskResu
|
|
|
241
260
|
/**
|
|
242
261
|
* The TRUSTED, run-scoped internals channel — the same object `Runner.runTask` takes as its second
|
|
243
262
|
* argument — forwarded to EVERY leg this gate drives under the composition forward contract
|
|
244
|
-
* (identity, with the
|
|
263
|
+
* (identity, with the placement and continuation-author exceptions stated where the shape is named in
|
|
245
264
|
* `src/index.ts`): each round's verifier run and each fix continuation, plus (from
|
|
246
265
|
* {@link runWithVerification} / {@link resumeWithVerification} / {@link runDeveloperTask}) the
|
|
247
266
|
* implementation leg. This doc is the contract for the family; the siblings point here.
|
|
@@ -289,11 +308,19 @@ export declare function verifyCompleted(runner: RunnerSelfSeat, result: TaskResu
|
|
|
289
308
|
* (`refuseUnhonorableInternals`) carries the reasoning, the re-check rule, and what a mid-gate
|
|
290
309
|
* refusal does and does not undo.
|
|
291
310
|
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
* gate's
|
|
296
|
-
*
|
|
311
|
+
* The design/380 O1② PLACEMENT delta, either way (present or absent): the verifier and fix legs land
|
|
312
|
+
* where the implementation leg landed — a fresh shallow copy carrying `placementRoot` = the fixed point
|
|
313
|
+
* that leg's result reports (`TaskResult.placementRoot`) unless the caller's object already resolves
|
|
314
|
+
* there (`placementRoot`, else `rootSessionId`: the gate's fixed point; a result that reports none mints
|
|
315
|
+
* none), and — on the entries that
|
|
316
|
+
* dispatch the implementation leg themselves ({@link runWithVerification}, {@link resumeWithVerification},
|
|
317
|
+
* which hand it a shallow copy whose `onWorkspaceResolved` first records the target its env reported,
|
|
318
|
+
* then calls the caller's own sink) — `placementTarget` = that leg's target when it reported one (a
|
|
319
|
+
* verifier or fix leg minted on another device is refused `config.placement_not_honored`). This entry
|
|
320
|
+
* did not dispatch the implementation, so its legs carry whatever `placementTarget` the caller's object
|
|
321
|
+
* does. The verifier and fix objectives are the gate's words, so each of those legs also carries
|
|
322
|
+
* `objectiveAuthor: "engine"` — always a fresh copy (absent ⇒ exactly the gains). Every other field
|
|
323
|
+
* still rides by the same reference.
|
|
297
324
|
*/
|
|
298
325
|
internals?: RunInternals): Promise<VerificationResult>;
|
|
299
326
|
/**
|
package/dist/agents/verify.js
CHANGED
|
@@ -6,6 +6,9 @@ import { mapNestedSuspend, isDurablePause, pauseFamily } from "./suspend-guard.j
|
|
|
6
6
|
import { delimitUntrusted, sanitizeUntrustedText } from "../core/untrusted-text.js";
|
|
7
7
|
import { createSafeNotifier } from "../core/safe-notify.js";
|
|
8
8
|
import { createCumulativeStatsTracker } from "./cumulative-stats.js";
|
|
9
|
+
import { compositionPlacement } from "./composition-placement.js";
|
|
10
|
+
import { laterLegAllowance } from "./composition-allowance.js";
|
|
11
|
+
import { recipeContinuationLeg } from "../core/input-author.js";
|
|
9
12
|
export const VERIFICATION_PROMPT = `You are a verification specialist. Your job is NOT to confirm the implementation works — it is to try to BREAK it.
|
|
10
13
|
|
|
11
14
|
You have two documented failure patterns. First, verification avoidance: faced with a check, you find reasons not to run it — you read code, narrate what you would test, declare "PASS," and move on. Second, being seduced by the first 80%: a polished result or a passing test suite makes you inclined to pass it, not noticing the edge that crashes, the state that vanishes, the bad input that is unhandled. The first 80% is the easy part. Your entire value is in finding the last 20%.
|
|
@@ -81,13 +84,14 @@ function refuseUnhonorableInternals(internals, phase) {
|
|
|
81
84
|
`implementation leg keeps whatever it did (a consumed checkpoint stays consumed, its session stays the caller's to reclaim).`));
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
|
-
function withLegIdentity(internals, leg) {
|
|
87
|
+
function withLegIdentity(internals, leg, caller) {
|
|
85
88
|
if (internals?.onWiringManifest === undefined)
|
|
86
89
|
return internals;
|
|
87
90
|
const identity = Object.freeze({ ...leg });
|
|
88
|
-
return { ...internals, onWiringManifest: (manifest) => internals.onWiringManifest?.(manifest, identity) };
|
|
91
|
+
return { ...internals, onWiringManifest: (manifest) => (caller ?? internals).onWiringManifest?.(manifest, identity) };
|
|
89
92
|
}
|
|
90
93
|
const IMPL_LEG = { kind: "impl", round: 0 };
|
|
94
|
+
const GATE_RESUME_ENTRY = { door: "resumeWithVerification" };
|
|
91
95
|
function fixObjective(findings) {
|
|
92
96
|
const list = findings.length
|
|
93
97
|
? findings.map((f) => `- ${sanitizeUntrustedText(f)}`).join("\n")
|
|
@@ -109,6 +113,9 @@ function verifierObjective(originalObjective, impl, evidence) {
|
|
|
109
113
|
return parts.join("\n\n");
|
|
110
114
|
}
|
|
111
115
|
export async function verifyCompleted(runner, result, specBase, objective, config, internals) {
|
|
116
|
+
return verifyCompletedPlaced(runner, result, specBase, objective, config, internals, compositionPlacement(internals));
|
|
117
|
+
}
|
|
118
|
+
async function verifyCompletedPlaced(runner, result, specBase, objective, config, internals, placement) {
|
|
112
119
|
refuseUnhonorableInternals(internals, "door");
|
|
113
120
|
if (result.terminal.kind !== "completed") {
|
|
114
121
|
return { ...result, verification: { verdict: "unverified", unverifiedReason: "impl_incomplete", rounds: 0, findings: [] } };
|
|
@@ -138,9 +145,11 @@ export async function verifyCompleted(runner, result, specBase, objective, confi
|
|
|
138
145
|
};
|
|
139
146
|
const evidenceMode = config.evidence != null && config.evidence.trim() !== "";
|
|
140
147
|
const verifierPrompt = config.verifierPrompt ?? (evidenceMode ? STATIC_VERIFICATION_PROMPT : VERIFICATION_PROMPT);
|
|
141
|
-
const legInternals = () =>
|
|
142
|
-
|
|
143
|
-
|
|
148
|
+
const legInternals = () => recipeContinuationLeg(placement.laterLeg(result));
|
|
149
|
+
const verifierLegInternals = (round) => {
|
|
150
|
+
const { compositionLeg: _notThisLeg, ...leg } = legInternals();
|
|
151
|
+
return result.sessionId === "" ? leg : { ...leg, compositionLeg: { entry: "verify", leg: round, hostSessionId: result.sessionId } };
|
|
152
|
+
};
|
|
144
153
|
const runVerifier = async (impl, round) => {
|
|
145
154
|
refuseUnhonorableInternals(internals, "before_leg");
|
|
146
155
|
const roundEvidence = round === 1 ? config.evidence : undefined;
|
|
@@ -182,7 +191,7 @@ export async function verifyCompleted(runner, result, specBase, objective, confi
|
|
|
182
191
|
...(specBase.promptLean !== undefined ? { promptLean: specBase.promptLean } : {}),
|
|
183
192
|
signal: specBase.signal,
|
|
184
193
|
};
|
|
185
|
-
const v = await runner.runTask(verifierSpec, withLegIdentity(
|
|
194
|
+
const v = await runner.runTask(verifierSpec, withLegIdentity(verifierLegInternals(round), { kind: "verifier", round }, internals));
|
|
186
195
|
try {
|
|
187
196
|
const cost = (v.stats.costMicroUsd ?? 0) + (v.stats.nested?.costMicroUsd ?? 0);
|
|
188
197
|
return { verdict: v.structuredOutput, cost, ...(isDurablePause(v.terminal) ? { paused: { ...v, terminal: v.terminal } } : {}) };
|
|
@@ -211,27 +220,22 @@ export async function verifyCompleted(runner, result, specBase, objective, confi
|
|
|
211
220
|
spend += v.cost;
|
|
212
221
|
verifierSpend += v.cost;
|
|
213
222
|
if (v.paused) {
|
|
214
|
-
const
|
|
223
|
+
const verifierPause = {
|
|
224
|
+
status: pauseFamily(v.paused.terminal),
|
|
225
|
+
sessionId: v.paused.sessionId,
|
|
226
|
+
checkpointToken: v.paused.terminal.token,
|
|
227
|
+
checkpointGate: v.paused.terminal.gate,
|
|
228
|
+
...(v.paused.terminal.checkpointId !== undefined ? { checkpointId: v.paused.terminal.checkpointId } : {}),
|
|
229
|
+
};
|
|
215
230
|
outcome = {
|
|
216
231
|
verdict: "unverified",
|
|
217
232
|
unverifiedReason: "verifier_paused",
|
|
218
233
|
rounds: round,
|
|
219
234
|
findings: [],
|
|
220
235
|
verifierCost: verifierSpend,
|
|
221
|
-
verifierPause
|
|
222
|
-
status: pauseFamily(paused.terminal),
|
|
223
|
-
sessionId: paused.sessionId,
|
|
224
|
-
checkpointToken: paused.terminal.token,
|
|
225
|
-
checkpointGate: paused.terminal.gate,
|
|
226
|
-
},
|
|
236
|
+
verifierPause,
|
|
227
237
|
};
|
|
228
|
-
notifier.notify(() => config.onVerifierPause?.({
|
|
229
|
-
round,
|
|
230
|
-
status: pauseFamily(paused.terminal),
|
|
231
|
-
sessionId: paused.sessionId,
|
|
232
|
-
checkpointToken: paused.terminal.token,
|
|
233
|
-
checkpointGate: paused.terminal.gate,
|
|
234
|
-
}), VERIFY_ON_VERIFIER_PAUSE_SITE);
|
|
238
|
+
notifier.notify(() => config.onVerifierPause?.({ round, ...verifierPause }), VERIFY_ON_VERIFIER_PAUSE_SITE);
|
|
235
239
|
notifier.notify(() => config.onRound?.({ round, verdict: outcome.verdict, findings: outcome.findings }), VERIFY_ON_ROUND_SITE);
|
|
236
240
|
break;
|
|
237
241
|
}
|
|
@@ -255,9 +259,14 @@ export async function verifyCompleted(runner, result, specBase, objective, confi
|
|
|
255
259
|
break;
|
|
256
260
|
if (config.costCeilingMicroUsd != null && spend >= config.costCeilingMicroUsd)
|
|
257
261
|
break;
|
|
262
|
+
const allowance = laterLegAllowance(specBase, implAccount.spend());
|
|
263
|
+
if (allowance.exhausted !== undefined) {
|
|
264
|
+
outcome = { ...outcome, allowanceExhausted: allowance.exhausted };
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
258
267
|
refuseUnhonorableInternals(internals, "before_leg");
|
|
259
268
|
const fixLegSpec = {
|
|
260
|
-
...
|
|
269
|
+
...allowance.spec,
|
|
261
270
|
sessionId: current.sessionId,
|
|
262
271
|
objective: fixObjective(outcome.findings),
|
|
263
272
|
...childClampSeats({
|
|
@@ -267,11 +276,11 @@ export async function verifyCompleted(runner, result, specBase, objective, confi
|
|
|
267
276
|
readDenyPatterns: foldedReadDeny,
|
|
268
277
|
}),
|
|
269
278
|
};
|
|
270
|
-
current = await runner.runTask(fixLegSpec, withLegIdentity(legInternals(), { kind: "fix", round }));
|
|
279
|
+
current = await runner.runTask(fixLegSpec, withLegIdentity(legInternals(), { kind: "fix", round }, internals));
|
|
271
280
|
spend += (current.stats.costMicroUsd ?? 0) + (current.stats.nested?.costMicroUsd ?? 0);
|
|
272
281
|
implAccount.add(current.stats);
|
|
273
282
|
if (isDurablePause(current.terminal)) {
|
|
274
|
-
return { ...mapNestedSuspend(carryFrozenPosture(withImplAccount(current))), verification: outcome };
|
|
283
|
+
return { ...mapNestedSuspend(carryFrozenPosture(withImplAccount(current)), GATE_RESUME_ENTRY), verification: outcome };
|
|
275
284
|
}
|
|
276
285
|
if (current.terminal.kind !== "completed")
|
|
277
286
|
break;
|
|
@@ -280,26 +289,28 @@ export async function verifyCompleted(runner, result, specBase, objective, confi
|
|
|
280
289
|
}
|
|
281
290
|
export async function runWithVerification(runner, implSpec, config = {}, internals) {
|
|
282
291
|
refuseUnhonorableInternals(internals, "door");
|
|
283
|
-
const
|
|
292
|
+
const placement = compositionPlacement(internals);
|
|
293
|
+
const result = await runner.runTask(implSpec, withLegIdentity(placement.firstLeg, IMPL_LEG, internals));
|
|
284
294
|
if (isDurablePause(result.terminal)) {
|
|
285
|
-
return { ...mapNestedSuspend(result), verification: { verdict: "unverified", unverifiedReason: pauseFamily(result.terminal), rounds: 0, findings: [] } };
|
|
295
|
+
return { ...mapNestedSuspend(result, GATE_RESUME_ENTRY), verification: { verdict: "unverified", unverifiedReason: pauseFamily(result.terminal), rounds: 0, findings: [] } };
|
|
286
296
|
}
|
|
287
297
|
refuseUnhonorableInternals(internals, "before_leg");
|
|
288
|
-
return
|
|
298
|
+
return verifyCompletedPlaced(runner, result, implSpec, implSpec.objective, config, internals, placement);
|
|
289
299
|
}
|
|
290
300
|
export async function resumeWithVerification(runner, token, outcome, taskConfig, objective, config = {}, internals) {
|
|
291
301
|
refuseUnhonorableInternals(internals, "door");
|
|
292
|
-
const
|
|
302
|
+
const placement = compositionPlacement(internals);
|
|
303
|
+
const result = await runner.resume(token, outcome, taskConfig, withLegIdentity(placement.firstLeg, IMPL_LEG, internals));
|
|
293
304
|
if (isDurablePause(result.terminal)) {
|
|
294
|
-
return { ...mapNestedSuspend(result), verification: { verdict: "unverified", unverifiedReason: pauseFamily(result.terminal), rounds: 0, findings: [] } };
|
|
305
|
+
return { ...mapNestedSuspend(result, GATE_RESUME_ENTRY), verification: { verdict: "unverified", unverifiedReason: pauseFamily(result.terminal), rounds: 0, findings: [] } };
|
|
295
306
|
}
|
|
296
307
|
refuseUnhonorableInternals(internals, "before_leg");
|
|
297
|
-
return
|
|
308
|
+
return verifyCompletedPlaced(runner, result, taskConfig, objective, config, internals, placement);
|
|
298
309
|
}
|
|
299
310
|
export async function runDeveloperTask(runner, spec, config = {}, internals) {
|
|
300
311
|
const implSpec = namesRoleBase(spec) ? spec : { ...spec, promptRole: "code" };
|
|
301
312
|
if (config.verify === false) {
|
|
302
|
-
const result = await runner.runTask(implSpec, withLegIdentity(internals, IMPL_LEG));
|
|
313
|
+
const result = await runner.runTask(implSpec, withLegIdentity(internals, IMPL_LEG, internals));
|
|
303
314
|
return { ...result, verification: { verdict: "unverified", unverifiedReason: "opted_out", rounds: 0, findings: [] } };
|
|
304
315
|
}
|
|
305
316
|
return runWithVerification(runner, implSpec, config, internals);
|
package/dist/brain/anthropic.js
CHANGED
|
@@ -410,6 +410,7 @@ export function createAnthropicBrain(given = {}) {
|
|
|
410
410
|
headers,
|
|
411
411
|
declared,
|
|
412
412
|
body: JSON.stringify(wire),
|
|
413
|
+
...((context.tools?.length ?? 0) > 0 ? { toolNames: context.tools.map((t) => t.name) } : {}),
|
|
413
414
|
extraBodyDropped,
|
|
414
415
|
route: requestRouteOf(routeCredential, rootOrigin),
|
|
415
416
|
outputCapTokens: effectiveOutputCap(wire, OUTPUT_CAP_KEYS.anthropic),
|
package/dist/brain/errors.d.ts
CHANGED
|
@@ -85,6 +85,9 @@ export declare class BrainError extends Error {
|
|
|
85
85
|
* dialect table's image row, `provider-dialect.ts`). Lifted onto `AssistantMessage.errorKind: "image_unprocessable"`
|
|
86
86
|
* at the terminal-shell mint. Never inferred from `detail` prose after construction. */
|
|
87
87
|
readonly imageUnprocessable?: true;
|
|
88
|
+
/** The tool whose input schema the provider stated it refused, located by the dialect table's tool-schema rows; lifted onto
|
|
89
|
+
* `AssistantMessage.errorKind: "tool_schema_refused"` with `refusedTool` at the terminal-shell mint. */
|
|
90
|
+
readonly toolSchemaRefused?: string;
|
|
88
91
|
constructor(code: BrainErrorCode, detail: string, status?: number, opts?: {
|
|
89
92
|
inputTooLong?: boolean;
|
|
90
93
|
inputTooLongRuledOut?: boolean;
|
|
@@ -97,6 +100,7 @@ export declare class BrainError extends Error {
|
|
|
97
100
|
};
|
|
98
101
|
errorBodyIncomplete?: boolean;
|
|
99
102
|
imageUnprocessable?: boolean;
|
|
103
|
+
toolSchemaRefused?: string;
|
|
100
104
|
});
|
|
101
105
|
}
|
|
102
106
|
/** The provider's diagnostic object out of a JSON error body, or undefined when the body establishes no provenance
|
|
@@ -266,7 +270,9 @@ export declare function brainErrorCodeOf(e: unknown): BrainErrorCode | undefined
|
|
|
266
270
|
* brain code. */
|
|
267
271
|
export interface ThrownBrainFailure {
|
|
268
272
|
readonly code?: BrainErrorCode;
|
|
269
|
-
readonly errorKind?: "input_too_long" | "image_unprocessable";
|
|
273
|
+
readonly errorKind?: "input_too_long" | "image_unprocessable" | "tool_schema_refused";
|
|
274
|
+
/** With `tool_schema_refused`: the tool whose input schema the provider refused. */
|
|
275
|
+
readonly refusedTool?: string;
|
|
270
276
|
readonly inputTooLongRuledOut?: true;
|
|
271
277
|
}
|
|
272
278
|
/**
|
package/dist/brain/errors.js
CHANGED
|
@@ -24,6 +24,7 @@ export class BrainError extends Error {
|
|
|
24
24
|
providerResetAtMs;
|
|
25
25
|
errorBodyIncomplete;
|
|
26
26
|
imageUnprocessable;
|
|
27
|
+
toolSchemaRefused;
|
|
27
28
|
constructor(code, detail, status, opts) {
|
|
28
29
|
super(`[${code}] ${detail}`);
|
|
29
30
|
this.name = "BrainError";
|
|
@@ -47,6 +48,8 @@ export class BrainError extends Error {
|
|
|
47
48
|
this.errorBodyIncomplete = true;
|
|
48
49
|
if (opts?.imageUnprocessable === true)
|
|
49
50
|
this.imageUnprocessable = true;
|
|
51
|
+
if (typeof opts?.toolSchemaRefused === "string")
|
|
52
|
+
this.toolSchemaRefused = opts.toolSchemaRefused;
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
export function providerErrorObject(body) {
|
|
@@ -259,6 +262,9 @@ export function thrownBrainFailure(e) {
|
|
|
259
262
|
const ruledOut = readMember(e, "inputTooLongRuledOut") === true;
|
|
260
263
|
if (readMember(e, "imageUnprocessable") === true)
|
|
261
264
|
return { code, errorKind: "image_unprocessable", ...(ruledOut ? { inputTooLongRuledOut: true } : {}) };
|
|
265
|
+
const refusedTool = readMember(e, "toolSchemaRefused");
|
|
266
|
+
if (typeof refusedTool === "string")
|
|
267
|
+
return { code, errorKind: "tool_schema_refused", refusedTool, ...(ruledOut ? { inputTooLongRuledOut: true } : {}) };
|
|
262
268
|
if (ruledOut)
|
|
263
269
|
return { code, inputTooLongRuledOut: true };
|
|
264
270
|
return { code };
|
package/dist/brain/failover.js
CHANGED
|
@@ -42,7 +42,8 @@ export function createFailoverBrain(brains) {
|
|
|
42
42
|
options?.signal?.aborted !== true &&
|
|
43
43
|
!sawContent &&
|
|
44
44
|
message.errorKind !== "length_empty" &&
|
|
45
|
-
message.errorKind !== "image_unprocessable"
|
|
45
|
+
message.errorKind !== "image_unprocessable" &&
|
|
46
|
+
message.errorKind !== "tool_schema_refused";
|
|
46
47
|
if (cleanUpfrontFailure && !isLast) {
|
|
47
48
|
lastFailedCode = extractErrorCode(message.errorMessage);
|
|
48
49
|
continue;
|
|
@@ -291,6 +291,7 @@ export function createOpenResponsesBrain(given = {}) {
|
|
|
291
291
|
headers,
|
|
292
292
|
declared,
|
|
293
293
|
body: JSON.stringify(wire),
|
|
294
|
+
...((context.tools?.length ?? 0) > 0 ? { toolNames: context.tools.map((t) => t.name) } : {}),
|
|
294
295
|
extraBodyDropped,
|
|
295
296
|
route: requestRouteOf(routeCredential, rootOrigin),
|
|
296
297
|
outputCapTokens: effectiveOutputCap(wire, OUTPUT_CAP_KEYS.responses),
|
package/dist/brain/openai.js
CHANGED
|
@@ -371,6 +371,7 @@ export function createOpenAIBrain(given = {}) {
|
|
|
371
371
|
headers,
|
|
372
372
|
declared: declaredValues,
|
|
373
373
|
body: JSON.stringify(wire),
|
|
374
|
+
...((context.tools?.length ?? 0) > 0 ? { toolNames: context.tools.map((t) => t.name) } : {}),
|
|
374
375
|
extraBodyDropped,
|
|
375
376
|
route: requestRouteOf(routeCredential, rootOrigin),
|
|
376
377
|
outputCapTokens: effectiveOutputCap(wire, OUTPUT_CAP_KEYS.openai),
|
|
@@ -133,6 +133,10 @@ export type InputTooLongVerdict = "yes" | "no" | "unknown";
|
|
|
133
133
|
* reference's image phrases less "exceeds api limit" (it names no image), and DeepSeek's "unsupported image".
|
|
134
134
|
*/
|
|
135
135
|
export declare const IMAGE_UNPROCESSABLE_RE: RegExp;
|
|
136
|
+
/** "The provider refused the input schema of the tool at this position of the request's tool list", located in `error.message`
|
|
137
|
+
* (`tools.3.custom.input_schema: …` — the reference's own pattern, `X4e` (cli309.js:264190)) or in the envelope's `param`
|
|
138
|
+
* (`tools[3].function.parameters`, the OpenAI-family form, read by its documented shape). */
|
|
139
|
+
export declare const TOOL_INPUT_SCHEMA_SENTENCE_RE: RegExp;
|
|
136
140
|
/** One row of the failure column. A row with no `status` applies to every status. */
|
|
137
141
|
export interface FailureRow {
|
|
138
142
|
readonly status?: readonly number[];
|
|
@@ -145,6 +149,9 @@ export interface FailureRow {
|
|
|
145
149
|
readonly inputTooLong?: true;
|
|
146
150
|
/** This row's statement is the provider refusing an image in the request (`errorKind: "image_unprocessable"`). */
|
|
147
151
|
readonly imageUnprocessable?: true;
|
|
152
|
+
/** This row's statement is the provider refusing one tool's input schema (`errorKind: "tool_schema_refused"`), at the
|
|
153
|
+
* position the envelope locates ({@link ProviderVerdict.toolSchemaAt}). */
|
|
154
|
+
readonly toolSchemaRefused?: true;
|
|
148
155
|
}
|
|
149
156
|
/** Where a dialect applies: the wire families it was evidenced for, its host suffixes, an optional path prefix. */
|
|
150
157
|
export interface DialectKey {
|
|
@@ -226,6 +233,9 @@ export interface ProviderVerdict {
|
|
|
226
233
|
readonly inputTooLong: InputTooLongVerdict;
|
|
227
234
|
/** The row the failure read off states an image in the request could not be processed. */
|
|
228
235
|
readonly imageUnprocessable: boolean;
|
|
236
|
+
/** The row the failure read off states the provider refused one tool's input schema, and the envelope located it: the
|
|
237
|
+
* tool's position in the request's tool list. Absent when no row says so, or the envelope locates no position. */
|
|
238
|
+
readonly toolSchemaAt?: number;
|
|
229
239
|
}
|
|
230
240
|
type HeaderBag = {
|
|
231
241
|
get?: (name: string) => string | null;
|
|
@@ -22,6 +22,8 @@ export function startsWithInputTooLongAnchor(diagnostic) {
|
|
|
22
22
|
}
|
|
23
23
|
const INPUT_TOO_LONG_STATUSES = new Set([400, 413, 422]);
|
|
24
24
|
export const IMAGE_UNPROCESSABLE_RE = /could not process image|image exceeds|image dimensions exceed|image does not match the provided media type|image cannot be empty|images exceed the api limit|unable to resize image|unable to compress image|image file is empty|unsupported image/i;
|
|
25
|
+
export const TOOL_INPUT_SCHEMA_SENTENCE_RE = /\btools\.(\d+)\.(?:custom\.)?input_schema\b/;
|
|
26
|
+
const TOOL_INPUT_SCHEMA_PARAM_RE = /^tools\[(\d+)\](?:\.function)?\.parameters$/;
|
|
25
27
|
const OPENAI_CHAT = "openai-completions";
|
|
26
28
|
const OPENAI_RESPONSES = "openai-responses";
|
|
27
29
|
const ANTHROPIC = "anthropic-messages";
|
|
@@ -109,6 +111,8 @@ export const GENERIC_FAILURES = Object.freeze([
|
|
|
109
111
|
{ status: [400, 422], sentence: INPUT_TOO_LONG_ANCHORED_RE, condition: "stop_other", inputTooLong: true },
|
|
110
112
|
{ status: [413], condition: "stop_other", inputTooLong: true },
|
|
111
113
|
{ status: [400, 422], sentence: IMAGE_UNPROCESSABLE_RE, condition: "stop_other", imageUnprocessable: true },
|
|
114
|
+
{ status: [400], sentence: TOOL_INPUT_SCHEMA_SENTENCE_RE, condition: "stop_other", toolSchemaRefused: true },
|
|
115
|
+
{ status: [400], word: ["invalid_function_parameters"], condition: "stop_other", toolSchemaRefused: true },
|
|
112
116
|
]);
|
|
113
117
|
export function isTransientStatus(status) {
|
|
114
118
|
return status >= 500 || status === 408 || status === 409;
|
|
@@ -155,7 +159,13 @@ function statementOf(err) {
|
|
|
155
159
|
return undefined;
|
|
156
160
|
const word = providerErrorWord(err);
|
|
157
161
|
const sentence = typeof err.message === "string" ? err.message.trimStart() : undefined;
|
|
158
|
-
|
|
162
|
+
const param = typeof err.param === "string" ? err.param : undefined;
|
|
163
|
+
return { ...(word !== undefined ? { word } : {}), ...(sentence !== undefined ? { sentence } : {}), ...(param !== undefined ? { param } : {}) };
|
|
164
|
+
}
|
|
165
|
+
function refusedToolSchemaPosition(stated) {
|
|
166
|
+
const at = (stated?.param !== undefined ? TOOL_INPUT_SCHEMA_PARAM_RE.exec(stated.param) : null)?.[1] ?? (stated?.sentence !== undefined ? TOOL_INPUT_SCHEMA_SENTENCE_RE.exec(stated.sentence) : null)?.[1];
|
|
167
|
+
const n = at !== undefined ? Number(at) : Number.NaN;
|
|
168
|
+
return Number.isSafeInteger(n) ? n : undefined;
|
|
159
169
|
}
|
|
160
170
|
function bestRow(rows, status, stated) {
|
|
161
171
|
let best;
|
|
@@ -180,7 +190,8 @@ function verdictOf(dialect, status, stated, enveloped) {
|
|
|
180
190
|
const condition = row?.condition ?? (status === undefined || status === 429 || isTransientStatus(status) ? "unknown" : "stop_other");
|
|
181
191
|
const source = row !== undefined && (row.word !== undefined || row.sentence !== undefined) ? "provider_code" : "status";
|
|
182
192
|
const inputTooLong = status !== undefined && !INPUT_TOO_LONG_STATUSES.has(status) ? "no" : row?.inputTooLong === true ? "yes" : enveloped ? "no" : "unknown";
|
|
183
|
-
|
|
193
|
+
const toolSchemaAt = row?.toolSchemaRefused === true ? refusedToolSchemaPosition(stated) : undefined;
|
|
194
|
+
return { condition, source, inputTooLong, imageUnprocessable: row?.imageUnprocessable === true, ...(toolSchemaAt !== undefined ? { toolSchemaAt } : {}) };
|
|
184
195
|
}
|
|
185
196
|
const UNIFIED_QUOTA_HEADERS = [
|
|
186
197
|
"anthropic-ratelimit-unified-representative-claim",
|
|
@@ -116,6 +116,9 @@ export interface SSERequest {
|
|
|
116
116
|
*/
|
|
117
117
|
declared: readonly string[];
|
|
118
118
|
body: string;
|
|
119
|
+
/** The engine name of each tool the body's tool list carries, in its order: a tool-schema refusal located by position
|
|
120
|
+
* ({@link ProviderVerdict.toolSchemaAt}) names the tool at it (`BrainError.toolSchemaRefused`). Absent = no tool list. */
|
|
121
|
+
toolNames?: readonly string[];
|
|
119
122
|
/**
|
|
120
123
|
* The per-request output cap this request ACTUALLY carries on the wire, when the adapter sets one
|
|
121
124
|
* (the adapters disagree on the body key, so the engine cannot read it off `body`). Absent means
|
|
@@ -337,6 +337,8 @@ export function runStreamingBrain(args) {
|
|
|
337
337
|
if (failure.code !== undefined) {
|
|
338
338
|
if (failure.errorKind !== undefined)
|
|
339
339
|
errorMsg.errorKind = failure.errorKind;
|
|
340
|
+
if (failure.refusedTool !== undefined)
|
|
341
|
+
errorMsg.refusedTool = failure.refusedTool;
|
|
340
342
|
if (failure.inputTooLongRuledOut === true)
|
|
341
343
|
errorMsg.inputTooLongRuledOut = true;
|
|
342
344
|
if (readMember(err, "errorBodyIncomplete") === true)
|
|
@@ -692,10 +694,12 @@ export function runStreamingBrain(args) {
|
|
|
692
694
|
const status = r?.status ?? 0;
|
|
693
695
|
const itl = terminalVerdict?.inputTooLong ?? "no";
|
|
694
696
|
const providerCode = refusedTheRequest(status) ? readProviderErrorCode(errorBody) : undefined;
|
|
697
|
+
const refusedTool = terminalVerdict?.toolSchemaAt !== undefined ? req.toolNames?.[terminalVerdict.toolSchemaAt] : undefined;
|
|
695
698
|
throw new BrainError(classifyHttp(status), `${httpLabel} HTTP ${status || "ERR"}: ${detail.slice(0, 500)}${overflowDeclineNote}`, status, {
|
|
696
699
|
apiError: true,
|
|
697
700
|
...(itl === "yes" ? { inputTooLong: true } : itl === "no" ? { inputTooLongRuledOut: true } : {}),
|
|
698
701
|
...(terminalVerdict?.imageUnprocessable === true ? { imageUnprocessable: true } : {}),
|
|
702
|
+
...(refusedTool !== undefined ? { toolSchemaRefused: refusedTool } : {}),
|
|
699
703
|
...(providerCode !== undefined ? { providerCode } : {}),
|
|
700
704
|
...(terminalVerdict !== undefined ? { verdict: { condition: terminalVerdict.condition, source: terminalVerdict.source, ...(terminalVerdict.resetAtMs !== undefined ? { resetAtMs: terminalVerdict.resetAtMs } : {}) } } : {}),
|
|
701
705
|
...(errorBody !== undefined && !errorBody.endedNormally ? { errorBodyIncomplete: true } : {}),
|