@sema-agent/core 7.58.0 → 7.60.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 +1340 -0
- package/README.md +6 -4
- package/dist/agents/agent-definition.d.ts +7 -0
- package/dist/agents/agent-definition.js +12 -0
- package/dist/agents/agent-transcript-tool.d.ts +2 -1
- package/dist/agents/agent-transcript-tool.js +3 -1
- 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 +9 -4
- package/dist/agents/cumulative-stats.js +0 -1
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +22 -0
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/retain-ledger.d.ts +11 -1
- package/dist/agents/retain-ledger.js +13 -2
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/roster-store.js +3 -1
- package/dist/agents/send-message-tool.d.ts +8 -19
- package/dist/agents/send-message-tool.js +32 -50
- package/dist/agents/subagent.d.ts +51 -17
- package/dist/agents/subagent.js +150 -112
- package/dist/agents/tool-filter.d.ts +1 -3
- package/dist/agents/tool-filter.js +4 -12
- package/dist/bench/metrics.d.ts +3 -5
- package/dist/bench/metrics.js +0 -1
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/degrading.js +3 -1
- 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 +90 -22
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/status-sink.d.ts +7 -1
- package/dist/brain/status-sink.js +6 -0
- 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 +65 -6
- package/dist/brain/timeout.js +111 -11
- package/dist/core/a2a.d.ts +15 -5
- package/dist/core/a2a.js +34 -19
- 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/agent-definition.d.ts +20 -0
- package/dist/core/allow-entry.d.ts +20 -6
- package/dist/core/allow-entry.js +17 -7
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/artifact-host.d.ts +0 -2
- package/dist/core/artifact-host.js +0 -1
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/auto-mode-defaults.d.ts +8 -0
- package/dist/core/auto-mode-defaults.js +1 -0
- package/dist/core/auto-mode-rebuild.d.ts +2 -1
- package/dist/core/auto-mode.d.ts +39 -4
- package/dist/core/auto-mode.js +63 -12
- package/dist/core/background-agent-store.d.ts +26 -4
- package/dist/core/background-agent-store.js +3 -2
- package/dist/core/background-shell.d.ts +12 -1
- package/dist/core/background-shell.js +12 -0
- package/dist/core/checkpoint-requirements.d.ts +13 -1
- package/dist/core/checkpoint-requirements.js +3 -1
- package/dist/core/checkpoint-store.d.ts +66 -25
- package/dist/core/checkpoint-store.js +22 -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 +3 -3
- package/dist/core/compliance.js +1 -1
- package/dist/core/credential-echo.d.ts +52 -0
- package/dist/core/credential-echo.js +65 -0
- package/dist/core/credential-vocabulary.d.ts +13 -3
- package/dist/core/credential-vocabulary.js +12 -4
- package/dist/core/cross-boundary-taint.d.ts +4 -5
- 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 +156 -23
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/frame-settlement.d.ts +5 -0
- package/dist/core/frame-settlement.js +4 -0
- package/dist/core/gate-fold.js +8 -6
- package/dist/core/gate-lanes.js +47 -12
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/governance-codes.d.ts +17 -1
- package/dist/core/governance-codes.js +25 -0
- package/dist/core/hands-band-screen.js +0 -1
- package/dist/core/hands-band.d.ts +0 -3
- package/dist/core/hooks.d.ts +70 -59
- package/dist/core/hooks.js +125 -80
- package/dist/core/image-admission.d.ts +106 -52
- package/dist/core/image-admission.js +184 -56
- package/dist/core/image-downsample.d.ts +36 -69
- package/dist/core/image-downsample.js +111 -73
- package/dist/core/integer-option.d.ts +21 -0
- package/dist/core/integer-option.js +13 -0
- package/dist/core/locked-config.d.ts +59 -5
- package/dist/core/locked-config.js +82 -50
- 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 +2 -2
- package/dist/core/mcp-call-meta.js +9 -10
- package/dist/core/mcp-failure.d.ts +122 -20
- package/dist/core/mcp-failure.js +73 -5
- package/dist/core/mcp-host-seat.d.ts +92 -0
- package/dist/core/mcp-host-seat.js +131 -0
- package/dist/core/mcp-probe.d.ts +7 -2
- package/dist/core/mcp-probe.js +7 -2
- package/dist/core/mcp-server-link.d.ts +22 -1
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp-server-spec.d.ts +38 -9
- package/dist/core/mcp-server-spec.js +55 -21
- package/dist/core/mcp.d.ts +27 -12
- package/dist/core/mcp.js +105 -76
- package/dist/core/memory-admission.d.ts +23 -6
- package/dist/core/memory-admission.js +19 -9
- 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/content-origin.d.ts +13 -0
- package/dist/core/memory-engine/content-origin.js +21 -3
- 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 +3 -2
- package/dist/core/memory-engine/index.js +2 -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 +13 -3
- package/dist/core/memory-engine/scope-contract.js +2 -2
- package/dist/core/memory-engine/sync-client.d.ts +51 -9
- package/dist/core/memory-engine/sync-client.js +107 -13
- package/dist/core/memory-engine/sync-report.d.ts +103 -0
- package/dist/core/memory-engine/sync-report.js +119 -0
- package/dist/core/memory-engine/sync.d.ts +8 -1
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mode-policy.d.ts +9 -1
- package/dist/core/mode-policy.js +11 -1
- package/dist/core/model-receipt.d.ts +39 -0
- package/dist/core/model-receipt.js +139 -0
- package/dist/core/mods/agent-stations.d.ts +65 -0
- package/dist/core/mods/agent-stations.js +105 -0
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +6 -5
- package/dist/core/mods/kernel/events.d.ts +11 -4
- package/dist/core/mods/kernel/events.js +11 -7
- package/dist/core/mods/kernel/receive.d.ts +5 -0
- package/dist/core/mods/kernel/receive.js +10 -0
- package/dist/core/mods/kernel/registration.d.ts +4 -0
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/lifecycle-stations.d.ts +41 -0
- package/dist/core/mods/lifecycle-stations.js +35 -0
- package/dist/core/mods/stations.d.ts +73 -60
- package/dist/core/mods/stations.js +64 -40
- package/dist/core/mods/tool-call.d.ts +10 -4
- package/dist/core/mods/tool-call.js +28 -12
- package/dist/core/mounted-mcp.d.ts +5 -0
- package/dist/core/mounted-mcp.js +2 -2
- package/dist/core/namespaced-rule-name.d.ts +7 -1
- package/dist/core/namespaced-rule-name.js +13 -2
- package/dist/core/oracle-isolation.js +1 -1
- package/dist/core/own-property-receipt.d.ts +3 -0
- package/dist/core/own-property-receipt.js +3 -0
- 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 +14 -8
- package/dist/core/peer-seat.d.ts +133 -16
- package/dist/core/peer-seat.js +319 -42
- package/dist/core/permission-rule-consent.d.ts +0 -21
- package/dist/core/permission-rule-consent.js +11 -6
- package/dist/core/permission-rule-model.d.ts +20 -2
- package/dist/core/permission-rule-model.js +8 -7
- package/dist/core/present-plan-tool.d.ts +11 -3
- package/dist/core/present-plan-tool.js +2 -2
- package/dist/core/protocol-http-auth.d.ts +14 -2
- package/dist/core/protocol-http-auth.js +16 -7
- package/dist/core/read-face-seats.d.ts +7 -5
- package/dist/core/read-face-seats.js +4 -1
- package/dist/core/redaction-marks.d.ts +4 -3
- package/dist/core/redaction-marks.js +2 -2
- package/dist/core/remote-env.d.ts +146 -98
- package/dist/core/remote-env.js +113 -14
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/retention.js +37 -12
- package/dist/core/retired-keys.d.ts +6 -1
- package/dist/core/retired-keys.js +4 -1
- package/dist/core/rewrite-rejudge.d.ts +13 -5
- package/dist/core/rewrite-rejudge.js +9 -5
- package/dist/core/roles.d.ts +69 -3
- package/dist/core/roles.js +167 -80
- package/dist/core/rule-owner.d.ts +3 -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/assemble-result.d.ts +0 -5
- package/dist/core/runner/assemble-result.js +0 -1
- package/dist/core/runner/call-hook-stations.d.ts +17 -10
- package/dist/core/runner/call-hook-stations.js +23 -12
- package/dist/core/runner/child-tree.d.ts +7 -8
- package/dist/core/runner/child-tree.js +6 -6
- package/dist/core/runner/classifier-ladder.d.ts +10 -2
- package/dist/core/runner/classifier-ladder.js +39 -8
- package/dist/core/runner/construction-doors.js +5 -0
- package/dist/core/runner/contracts.d.ts +82 -57
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
- package/dist/core/runner/cross-boundary-lane.js +11 -2
- 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/env-capability-census.d.ts +15 -20
- package/dist/core/runner/env-capability-census.js +25 -34
- package/dist/core/runner/file-history-request.d.ts +2 -2
- package/dist/core/runner/file-history-request.js +0 -8
- package/dist/core/runner/gate-exit.d.ts +87 -11
- package/dist/core/runner/gate-exit.js +30 -8
- package/dist/core/runner/git-status-frame.d.ts +5 -2
- package/dist/core/runner/git-status-frame.js +3 -4
- 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/image.d.ts +7 -2
- package/dist/core/runner/image.js +14 -8
- package/dist/core/runner/inline-image.d.ts +10 -8
- package/dist/core/runner/inline-image.js +11 -9
- package/dist/core/runner/memory-consolidation-driver.js +5 -5
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/permission-rule-lanes.js +1 -1
- 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.d.ts +2 -2
- package/dist/core/runner/prepare-boundary-parks.js +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -1
- package/dist/core/runner/prepare-config-doors.js +16 -9
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +9 -3
- package/dist/core/runner/prepare-delegation-surface.js +5 -4
- package/dist/core/runner/prepare-file-history.d.ts +10 -12
- package/dist/core/runner/prepare-file-history.js +3 -12
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
- package/dist/core/runner/prepare-gate-stations.js +4 -3
- package/dist/core/runner/prepare-hands-readface.d.ts +7 -1
- package/dist/core/runner/prepare-hands-readface.js +19 -6
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -7
- package/dist/core/runner/prepare-inherited-gate.js +22 -31
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.d.ts +2 -2
- package/dist/core/runner/prepare-memory.js +12 -19
- package/dist/core/runner/prepare-park-ask.d.ts +4 -6
- package/dist/core/runner/prepare-park-ask.js +5 -9
- package/dist/core/runner/prepare-policy-chain.d.ts +8 -7
- package/dist/core/runner/prepare-policy-chain.js +136 -121
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +10 -7
- package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -2
- package/dist/core/runner/prepare-prompt-inputs.js +10 -20
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
- package/dist/core/runner/prepare-protocol-tools.js +17 -2
- 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 +0 -2
- package/dist/core/runner/prepare-suspend-saga.js +5 -7
- package/dist/core/runner/prepare-task.js +44 -28
- package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
- package/dist/core/runner/prepare-turn-wiring.js +7 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -4
- package/dist/core/runner/prepare-wiring-manifest.js +34 -19
- package/dist/core/runner/prepare-workspace-restore.js +3 -3
- 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 +4 -2
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-checkpoint-screen.js +4 -4
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/retired-runner-deps.js +4 -1
- 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-attachment-seats.js +3 -3
- package/dist/core/runner/run-brain-sinks.js +3 -0
- package/dist/core/runner/run-git-lane.d.ts +3 -1
- package/dist/core/runner/run-git-lane.js +1 -1
- package/dist/core/runner/run-harness-handlers.d.ts +3 -1
- package/dist/core/runner/run-harness-handlers.js +3 -1
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +6 -5
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +63 -56
- package/dist/core/runner/run-notification-lane.d.ts +3 -1
- package/dist/core/runner/run-notification-lane.js +16 -10
- package/dist/core/runner/run-settle-and-teardown.js +5 -1
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +14 -6
- 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 +89 -77
- package/dist/core/runner/runtask.d.ts +8 -5
- package/dist/core/runner/runtask.js +21 -13
- 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/skills-seat.js +2 -2
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +20 -7
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/tool-disclosure.js +0 -2
- package/dist/core/runner/tool-end-body.js +2 -2
- package/dist/core/runner/tool-face-overlay.d.ts +1 -1
- package/dist/core/runner/tool-face-overlay.js +26 -19
- package/dist/core/runner/tool-occurrence.d.ts +1 -1
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
- package/dist/core/runner/tool-result-media-seat.js +17 -1
- package/dist/core/runner/turn-attachments.d.ts +29 -27
- package/dist/core/runner/turn-attachments.js +27 -42
- package/dist/core/runner-deps.d.ts +32 -19
- package/dist/core/secret-env.d.ts +35 -4
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +3 -3
- package/dist/core/session-policy-store.d.ts +12 -3
- package/dist/core/session-policy-store.js +29 -10
- package/dist/core/session-store.d.ts +5 -7
- package/dist/core/session-store.js +50 -11
- 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 +17 -5
- package/dist/core/skill-grant.js +24 -6
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
- package/dist/core/stub-env.d.ts +5 -5
- package/dist/core/stub-env.js +11 -1
- package/dist/core/swappable-deps.d.ts +17 -43
- package/dist/core/swappable-deps.js +15 -5
- package/dist/core/synthetic-read-verdict.d.ts +1 -1
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +50 -10
- package/dist/core/task-notification.d.ts +88 -5
- package/dist/core/task-notification.js +146 -17
- package/dist/core/task-registry-agent.d.ts +18 -12
- package/dist/core/task-registry-agent.js +19 -6
- package/dist/core/task-registry-monitor.d.ts +7 -0
- package/dist/core/task-registry-monitor.js +28 -1
- package/dist/core/task-registry-shared.d.ts +43 -3
- package/dist/core/task-registry-shared.js +21 -7
- package/dist/core/task-registry-workflow.js +1 -1
- package/dist/core/task-registry.d.ts +50 -35
- package/dist/core/task-registry.js +64 -23
- package/dist/core/task-result.d.ts +3 -12
- package/dist/core/task-spec.d.ts +15 -7
- package/dist/core/task-stream.d.ts +1 -1
- package/dist/core/terminal-cause.d.ts +10 -0
- package/dist/core/tool-catalog-entries.js +1 -1
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-face-reader.d.ts +7 -6
- package/dist/core/tool-face-reader.js +4 -3
- package/dist/core/tool-name-aliases.d.ts +19 -0
- package/dist/core/tool-name-aliases.js +54 -2
- package/dist/core/tool-policy.d.ts +21 -4
- package/dist/core/tool-policy.js +1 -1
- package/dist/core/tool-registry.d.ts +5 -5
- package/dist/core/tool-registry.js +2 -2
- package/dist/core/tool-result-store.d.ts +88 -5
- package/dist/core/tool-result-store.js +51 -12
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +23 -5
- package/dist/core/trace.d.ts +0 -1
- package/dist/core/types.d.ts +5 -5
- package/dist/core/types.js +2 -2
- package/dist/core/untrusted-text.js +1 -1
- package/dist/core/user-attachment.d.ts +10 -5
- package/dist/core/user-attachment.js +15 -7
- package/dist/core/wiring-manifest.d.ts +6 -3
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +11 -5
- package/dist/engine/execution-env/node-execution-env.js +21 -13
- package/dist/engine/harness/agent-harness.d.ts +26 -3
- package/dist/engine/harness/agent-harness.js +49 -16
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +119 -28
- 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 +18 -7
- package/dist/engine/loop/agent-loop.d.ts +20 -12
- package/dist/engine/loop/agent-loop.js +205 -36
- package/dist/engine/loop/types.d.ts +12 -3
- package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
- package/dist/engine/lsp/node-lsp-manager.js +32 -13
- 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/storage-base.js +4 -21
- package/dist/index.d.ts +35 -21
- package/dist/index.js +26 -17
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -0
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/run-workflow-tool.d.ts +9 -3
- package/dist/orchestration/run-workflow-tool.js +59 -29
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-governance.js +2 -1
- 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.d.ts +4 -0
- package/dist/orchestration/workflow.js +762 -491
- package/dist/prompts/default.d.ts +1 -10
- package/dist/prompts/default.js +0 -2
- 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/background-agent-store.d.ts +1 -1
- package/dist/stores/file/background-agent-store.js +3 -1
- package/dist/stores/file/checkpoint-store.d.ts +127 -2
- package/dist/stores/file/checkpoint-store.js +19 -14
- package/dist/stores/file/file-history-store.d.ts +1 -1
- package/dist/stores/file/file-history-store.js +3 -1
- package/dist/stores/file/index.d.ts +4 -3
- package/dist/stores/file/index.js +17 -8
- package/dist/stores/file/mailbox-store.d.ts +1 -1
- package/dist/stores/file/mailbox-store.js +9 -11
- package/dist/stores/file/memory-store.d.ts +1 -1
- package/dist/stores/file/memory-store.js +3 -1
- package/dist/stores/file/session-policy-store.d.ts +1 -1
- package/dist/stores/file/session-policy-store.js +3 -1
- package/dist/stores/file/session-store.d.ts +1 -1
- package/dist/stores/file/session-store.js +3 -1
- package/dist/stores/file/shared-ledger.d.ts +26 -0
- package/dist/stores/file/shared-ledger.js +38 -9
- package/dist/stores/file/tool-result-store.d.ts +20 -2
- package/dist/stores/file/tool-result-store.js +74 -6
- package/dist/stores/file/usage-window-store.d.ts +1 -1
- package/dist/stores/file/usage-window-store.js +3 -1
- package/dist/stores/file/workflow-journal-store.d.ts +1 -11
- package/dist/stores/file/workflow-journal-store.js +3 -2
- package/dist/tools/fs/containment-face.d.ts +5 -0
- package/dist/tools/fs/encoding.d.ts +13 -4
- package/dist/tools/fs/encoding.js +17 -2
- package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
- package/dist/tools/fs/fs-bash-background-text.js +1 -0
- package/dist/tools/fs/fs-bash.d.ts +14 -4
- package/dist/tools/fs/fs-bash.js +29 -35
- package/dist/tools/fs/fs-pdf.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.js +26 -21
- package/dist/tools/fs/fs-read.d.ts +5 -4
- package/dist/tools/fs/fs-read.js +35 -18
- package/dist/tools/fs/fs-search-tools.js +4 -1
- package/dist/tools/fs/fs-shared.d.ts +11 -13
- package/dist/tools/fs/fs-shared.js +11 -7
- package/dist/tools/fs/fs-write.js +5 -5
- package/dist/tools/fs/index.d.ts +14 -8
- package/dist/tools/fs/index.js +13 -5
- 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 +62 -0
- package/dist/tools/fs/read-floor.js +58 -0
- package/dist/tools/fs/removal-targets.d.ts +9 -4
- package/dist/tools/fs/removal-targets.js +17 -9
- package/dist/tools/fs/search.d.ts +3 -3
- package/dist/tools/fs/search.js +4 -4
- package/dist/tools/fs/shell-read-check.d.ts +1 -1
- package/dist/tools/fs/shell-read-check.js +2 -1
- package/dist/tools/fs/shell-read-judge.d.ts +16 -8
- 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 +9 -4
- package/dist/tools/monitor.js +17 -8
- package/dist/tools/scheduler-tools.js +42 -4
- package/dist/tools/web.d.ts +0 -10
- package/dist/tools/web.js +1 -4
- package/package.json +5 -2
- package/test/export-surface.snapshot.json +161 -21
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core-stores-sql@7.60.0.json +30 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/core@7.60.0.json +3274 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/mods-kernel@7.60.0.json +62 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
- package/wire-changes/primitives@7.60.0.json +30 -0
package/dist/brain/openai.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {} from "../internal/llm.js";
|
|
2
2
|
import { repairTextToolCalls } from "./tool-call-repair.js";
|
|
3
3
|
import { DEGENERATE_MESSAGE, trimDegenerateTail } from "./repetition.js";
|
|
4
|
-
import { STREAM_TORN_WARNING, createRepetitionPoll, createStreamEndLedger, echoFoldedWord, modelOutputInvalidOf, noteResponseModel, nameMissingCause, parseStreamedToolArgs, placeTurnNotes, truncationCauseClause } from "./stream-shared.js";
|
|
4
|
+
import { NO_WORD, STREAM_TORN_WARNING, createRepetitionPoll, createStreamEndLedger, droppedFramesNote, echoFoldedWord, endingWordOf, memberReader, modelOutputInvalidOf, noteResponseModel, nameMissingCause, parseStreamedToolArgs, placeTurnNotes, truncationCauseClause } from "./stream-shared.js";
|
|
5
5
|
import { admitToolCallId, providerResultIds, providerToolCallId, responseToolCallIds } from "./tool-call-id.js";
|
|
6
6
|
import { emitBrainTelemetry } from "./status-sink.js";
|
|
7
7
|
import { errorResultMediaNote, IMAGE_OMITTED_NO_VISION, imageWithholdOf, imagesOmittedNoVisionNote, reportImagesWithheld, sendableImages } from "./media-degrade.js";
|
|
@@ -192,17 +192,7 @@ const FINISH_REASON_READINGS = Object.freeze({
|
|
|
192
192
|
aborted: { kind: "provider_cut", code: "server" },
|
|
193
193
|
network_error: { kind: "provider_cut", code: "network" },
|
|
194
194
|
});
|
|
195
|
-
function
|
|
196
|
-
return typeof raw === "object" && raw !== null && !Array.isArray(raw) ? raw : undefined;
|
|
197
|
-
}
|
|
198
|
-
function finishWordOf(raw) {
|
|
199
|
-
if (!raw)
|
|
200
|
-
return null;
|
|
201
|
-
return typeof raw === "string" ? raw : "?";
|
|
202
|
-
}
|
|
203
|
-
function lateContentKind(delta) {
|
|
204
|
-
if (delta === undefined)
|
|
205
|
-
return undefined;
|
|
195
|
+
function offeredOf(delta) {
|
|
206
196
|
const calls = delta.tool_calls;
|
|
207
197
|
if (calls !== undefined && calls !== null && !(Array.isArray(calls) && calls.length === 0))
|
|
208
198
|
return "tool_calls";
|
|
@@ -214,6 +204,57 @@ function lateContentKind(delta) {
|
|
|
214
204
|
return "reasoning";
|
|
215
205
|
return undefined;
|
|
216
206
|
}
|
|
207
|
+
const present = (o) => Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined));
|
|
208
|
+
function readUsage(seat, u) {
|
|
209
|
+
const details = seat.object(u.prompt_tokens_details);
|
|
210
|
+
return present({
|
|
211
|
+
prompt_tokens: seat.count(u.prompt_tokens),
|
|
212
|
+
completion_tokens: seat.count(u.completion_tokens),
|
|
213
|
+
total_tokens: seat.count(u.total_tokens),
|
|
214
|
+
prompt_tokens_details: details === undefined ? undefined : present({ cached_tokens: seat.count(details.cached_tokens) }),
|
|
215
|
+
prompt_cache_hit_tokens: seat.count(u.prompt_cache_hit_tokens),
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function readChunk(raw) {
|
|
219
|
+
const frame = memberReader();
|
|
220
|
+
const callStream = memberReader();
|
|
221
|
+
const usageSeat = memberReader();
|
|
222
|
+
const chunk = typeof raw === "object" && raw !== null && !Array.isArray(raw) ? raw : undefined;
|
|
223
|
+
if (chunk === undefined)
|
|
224
|
+
return { model: undefined, usageUnreadable: false, callsUnreadable: false, outOfShape: true };
|
|
225
|
+
const error = frame.object(chunk.error);
|
|
226
|
+
const usageObject = usageSeat.object(chunk.usage);
|
|
227
|
+
const choices = callStream.array(chunk.choices);
|
|
228
|
+
const first = choices === undefined ? undefined : callStream.object(choices[0]);
|
|
229
|
+
let choice;
|
|
230
|
+
if (first !== undefined) {
|
|
231
|
+
const delta = callStream.object(first.delta);
|
|
232
|
+
const calls = callStream.array(delta?.tool_calls)?.flatMap((element) => {
|
|
233
|
+
const tc = callStream.object(element);
|
|
234
|
+
if (tc === undefined)
|
|
235
|
+
return [];
|
|
236
|
+
const fn = callStream.object(tc.function);
|
|
237
|
+
return [present({ index: callStream.count(tc.index), id: callStream.word(tc.id), name: callStream.word(fn?.name), arguments: callStream.word(fn?.arguments) })];
|
|
238
|
+
});
|
|
239
|
+
choice = present({
|
|
240
|
+
finish: endingWordOf(first.finish_reason),
|
|
241
|
+
offered: delta === undefined ? undefined : offeredOf(delta),
|
|
242
|
+
reasoning: frame.word(delta?.reasoning) || frame.word(delta?.reasoning_content) || undefined,
|
|
243
|
+
content: frame.word(delta?.content),
|
|
244
|
+
refusal: frame.word(delta?.refusal),
|
|
245
|
+
calls,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
return present({
|
|
249
|
+
error,
|
|
250
|
+
model: chunk.model,
|
|
251
|
+
usage: usageObject === undefined ? undefined : readUsage(usageSeat, usageObject),
|
|
252
|
+
usageUnreadable: usageSeat.outOfShape,
|
|
253
|
+
choice,
|
|
254
|
+
callsUnreadable: callStream.outOfShape,
|
|
255
|
+
outOfShape: frame.outOfShape || callStream.outOfShape,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
217
258
|
function readFinishReason(reason) {
|
|
218
259
|
if (reason == null)
|
|
219
260
|
return undefined;
|
|
@@ -322,7 +363,7 @@ export function createOpenAIBrain(given = {}) {
|
|
|
322
363
|
applyRouteCredentialHeaders(headers, routeCredential);
|
|
323
364
|
const declaredValues = declaredRequestValues([modelHeaders, config.headers, optionsHeaders, headers], [], apiKey);
|
|
324
365
|
lockHeader(headers, "content-type", "application/json");
|
|
325
|
-
if (apiKey)
|
|
366
|
+
if (apiKey !== undefined)
|
|
326
367
|
lockHeader(headers, OPENAI_KEY_HEADER, `Bearer ${apiKey}`);
|
|
327
368
|
const { body: wire, dropped: extraBodyDropped } = applyExtraBody(reasoningBody, model, OPENAI_RESERVED);
|
|
328
369
|
return {
|
|
@@ -364,8 +405,14 @@ export function createOpenAIBrain(given = {}) {
|
|
|
364
405
|
const afterEnd = createStreamEndLedger(ctrl.providerWords);
|
|
365
406
|
const terminalFrameSeen = () => finishReason != null || inBandError !== undefined;
|
|
366
407
|
let usageRaw;
|
|
408
|
+
let usageUnreadable = false;
|
|
409
|
+
let callsUnreadable = false;
|
|
367
410
|
let malformedFrames = 0;
|
|
368
411
|
let malformedSample;
|
|
412
|
+
const dropFrame = (data) => {
|
|
413
|
+
malformedFrames++;
|
|
414
|
+
malformedSample ??= ctrl.providerWords(data).slice(0, 160);
|
|
415
|
+
};
|
|
369
416
|
const thinkingBlock = { type: "thinking", thinking: "" };
|
|
370
417
|
const textBlock = { type: "text", text: "" };
|
|
371
418
|
const pushReasoningDelta = (delta) => {
|
|
@@ -443,58 +490,60 @@ export function createOpenAIBrain(given = {}) {
|
|
|
443
490
|
const data = line.slice(5).trim();
|
|
444
491
|
if (!data || data === "[DONE]")
|
|
445
492
|
return;
|
|
446
|
-
let
|
|
493
|
+
let parsed;
|
|
447
494
|
try {
|
|
448
|
-
|
|
495
|
+
parsed = JSON.parse(data);
|
|
449
496
|
}
|
|
450
497
|
catch {
|
|
451
|
-
|
|
452
|
-
malformedSample ??= ctrl.providerWords(data).slice(0, 160);
|
|
498
|
+
dropFrame(data);
|
|
453
499
|
return;
|
|
454
500
|
}
|
|
455
|
-
const
|
|
456
|
-
if (
|
|
501
|
+
const chunk = readChunk(parsed);
|
|
502
|
+
if (chunk.error !== undefined) {
|
|
457
503
|
if (terminalFrameSeen()) {
|
|
458
|
-
afterEnd.note("error", providerErrorWord(
|
|
504
|
+
afterEnd.note("error", providerErrorWord(chunk.error) ?? "?");
|
|
459
505
|
return;
|
|
460
506
|
}
|
|
461
|
-
inBandError = inBandProviderError(ctrl.dialect,
|
|
507
|
+
inBandError = inBandProviderError(ctrl.dialect, chunk.error, "gateway", ctrl.providerWords);
|
|
462
508
|
ctrl.cancel();
|
|
463
509
|
return;
|
|
464
510
|
}
|
|
465
|
-
if (chunk.usage)
|
|
511
|
+
if (chunk.usage !== undefined)
|
|
466
512
|
usageRaw = chunk.usage;
|
|
513
|
+
if (chunk.usageUnreadable)
|
|
514
|
+
usageUnreadable = true;
|
|
467
515
|
noteResponseModel(partial, chunk.model, model.id);
|
|
468
|
-
const choice = chunk.
|
|
469
|
-
if (!choice)
|
|
470
|
-
return;
|
|
471
|
-
const finishWord = finishWordOf(choice.finish_reason);
|
|
516
|
+
const choice = chunk.choice;
|
|
472
517
|
if (terminalFrameSeen()) {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
518
|
+
if (choice !== undefined && choice.finish !== null && choice.finish !== finishReason)
|
|
519
|
+
afterEnd.note("ending", choice.finish);
|
|
520
|
+
else if (choice?.offered !== undefined)
|
|
521
|
+
afterEnd.note("content", choice.offered);
|
|
522
|
+
else if (chunk.outOfShape)
|
|
523
|
+
afterEnd.note("content", NO_WORD);
|
|
478
524
|
return;
|
|
479
525
|
}
|
|
480
|
-
if (
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
526
|
+
if (chunk.outOfShape)
|
|
527
|
+
dropFrame(data);
|
|
528
|
+
if (chunk.callsUnreadable)
|
|
529
|
+
callsUnreadable = true;
|
|
530
|
+
if (choice === undefined)
|
|
531
|
+
return;
|
|
532
|
+
if (choice.finish !== null)
|
|
533
|
+
finishReason = choice.finish;
|
|
534
|
+
if (choice.reasoning !== undefined)
|
|
535
|
+
pushReasoningDelta(choice.reasoning);
|
|
536
|
+
if (choice.refusal) {
|
|
488
537
|
ctrl.sawContentToken();
|
|
489
|
-
accumRefusal +=
|
|
538
|
+
accumRefusal += choice.refusal;
|
|
490
539
|
}
|
|
491
|
-
if (
|
|
492
|
-
pushTextDelta(
|
|
493
|
-
if (
|
|
540
|
+
if (choice.content !== undefined)
|
|
541
|
+
pushTextDelta(choice.content);
|
|
542
|
+
if (choice.calls !== undefined) {
|
|
494
543
|
ctrl.sawContentToken();
|
|
495
|
-
for (const tc of
|
|
544
|
+
for (const tc of choice.calls) {
|
|
496
545
|
const idx = tc.index ?? (tc.id ? toolAccum.size : Math.max(0, toolAccum.size - 1));
|
|
497
|
-
if (!toolAccum.has(idx)) {
|
|
546
|
+
if (!toolAccum.has(idx) && !callsUnreadable) {
|
|
498
547
|
for (const [prevIdx, prevAcc] of [...toolAccum.entries()].sort((a, b) => a[0] - b[0])) {
|
|
499
548
|
if (prevIdx >= idx || prevAcc.closedTc)
|
|
500
549
|
continue;
|
|
@@ -509,10 +558,10 @@ export function createOpenAIBrain(given = {}) {
|
|
|
509
558
|
const acc = toolAccum.get(idx) ?? { id: "", name: "", args: "" };
|
|
510
559
|
if (tc.id)
|
|
511
560
|
acc.id = tc.id;
|
|
512
|
-
if (tc.
|
|
513
|
-
acc.name = sentToolNames.called(tc.
|
|
514
|
-
if (tc.
|
|
515
|
-
acc.args += tc.
|
|
561
|
+
if (tc.name)
|
|
562
|
+
acc.name = sentToolNames.called(tc.name);
|
|
563
|
+
if (tc.arguments && !acc.closedTc)
|
|
564
|
+
acc.args += tc.arguments;
|
|
516
565
|
toolAccum.set(idx, acc);
|
|
517
566
|
}
|
|
518
567
|
}
|
|
@@ -542,7 +591,7 @@ export function createOpenAIBrain(given = {}) {
|
|
|
542
591
|
(nameMissingCause(!endedCut) === "truncated" ? malformed : unnamed).push(`id="${ctrl.providerWords(acc.id || "?")}"(${ctrl.providerWords(acc.args).slice(0, 200)})`);
|
|
543
592
|
continue;
|
|
544
593
|
}
|
|
545
|
-
const tc = closeToolCallAccum(acc, responseIds, !endedCut);
|
|
594
|
+
const tc = callsUnreadable && !acc.closedTc ? undefined : closeToolCallAccum(acc, responseIds, !endedCut);
|
|
546
595
|
if (tc) {
|
|
547
596
|
toolCalls.push(tc);
|
|
548
597
|
finalContent.push(tc);
|
|
@@ -593,11 +642,12 @@ export function createOpenAIBrain(given = {}) {
|
|
|
593
642
|
notes.push({ cause: "unnamed", count: unnamed.length, text: `\n[note: ${unnamed.length} tool call(s) arrived with no tool name and were dropped — re-issue them next turn with an explicit tool name: ${unnamed.join("; ")}]` });
|
|
594
643
|
}
|
|
595
644
|
if (malformedFrames > 0) {
|
|
596
|
-
notes.push({ cause: "bad_frame", count: malformedFrames, text:
|
|
645
|
+
notes.push({ cause: "bad_frame", count: malformedFrames, text: droppedFramesNote(malformedFrames, malformedSample) });
|
|
597
646
|
}
|
|
598
647
|
placeTurnNotes(partial, finalContent, notes);
|
|
648
|
+
const usageMissing = usageRaw === undefined || usageUnreadable;
|
|
599
649
|
if (inBandError !== undefined) {
|
|
600
|
-
ctrl.keepOutput({ content: finalContent, usage: computeUsage(model, usageRaw), ...(
|
|
650
|
+
ctrl.keepOutput({ content: finalContent, usage: computeUsage(model, usageRaw), ...(usageMissing ? { usageMissing: true } : {}) });
|
|
601
651
|
throw inBandError;
|
|
602
652
|
}
|
|
603
653
|
const truncatedEmpty = finishReason === "length" && noUsableContent && !toolError;
|
|
@@ -660,7 +710,7 @@ export function createOpenAIBrain(given = {}) {
|
|
|
660
710
|
content: finalContent.length > 0 ? finalContent : [{ type: "text", text: "" }],
|
|
661
711
|
stopReason: errored ? "error" : mapFinishReason(finishReason, toolCalls.length > 0),
|
|
662
712
|
usage: computeUsage(model, usageRaw),
|
|
663
|
-
...(
|
|
713
|
+
...(usageMissing ? { usageMissing: true } : {}),
|
|
664
714
|
timestamp: Date.now(),
|
|
665
715
|
...(errorMessageOut ? { errorMessage: errorMessageOut } : {}),
|
|
666
716
|
...(errorKind ? { errorKind } : {}),
|
|
@@ -126,6 +126,13 @@ export declare function startsWithInputTooLongAnchor(diagnostic: string): boolea
|
|
|
126
126
|
* terminal marks the latter `errorBodyIncomplete`, so no seat reads its prose either).
|
|
127
127
|
*/
|
|
128
128
|
export type InputTooLongVerdict = "yes" | "no" | "unknown";
|
|
129
|
+
/**
|
|
130
|
+
* "An image in this request could not be processed", matched anywhere in `error.message` (providers state it behind a
|
|
131
|
+
* locator: "messages.3.content.1.image.source.base64: Could not process image"). A match types the turn
|
|
132
|
+
* `image_unprocessable` and costs the newest carrier's images, disclosed — never a request parameter. Members: the
|
|
133
|
+
* reference's image phrases less "exceeds api limit" (it names no image), and DeepSeek's "unsupported image".
|
|
134
|
+
*/
|
|
135
|
+
export declare const IMAGE_UNPROCESSABLE_RE: RegExp;
|
|
129
136
|
/** One row of the failure column. A row with no `status` applies to every status. */
|
|
130
137
|
export interface FailureRow {
|
|
131
138
|
readonly status?: readonly number[];
|
|
@@ -136,6 +143,8 @@ export interface FailureRow {
|
|
|
136
143
|
readonly condition: ProviderCondition;
|
|
137
144
|
/** This row's statement IS the context-limit refusal. */
|
|
138
145
|
readonly inputTooLong?: true;
|
|
146
|
+
/** This row's statement is the provider refusing an image in the request (`errorKind: "image_unprocessable"`). */
|
|
147
|
+
readonly imageUnprocessable?: true;
|
|
139
148
|
}
|
|
140
149
|
/** Where a dialect applies: the wire families it was evidenced for, its host suffixes, an optional path prefix. */
|
|
141
150
|
export interface DialectKey {
|
|
@@ -215,6 +224,8 @@ export interface ProviderVerdict {
|
|
|
215
224
|
/** When the condition is `quota_exhausted` and the provider stated when it lifts: wall-clock epoch ms. */
|
|
216
225
|
readonly resetAtMs?: number;
|
|
217
226
|
readonly inputTooLong: InputTooLongVerdict;
|
|
227
|
+
/** The row the failure read off states an image in the request could not be processed. */
|
|
228
|
+
readonly imageUnprocessable: boolean;
|
|
218
229
|
}
|
|
219
230
|
type HeaderBag = {
|
|
220
231
|
get?: (name: string) => string | null;
|
|
@@ -21,6 +21,7 @@ export function startsWithInputTooLongAnchor(diagnostic) {
|
|
|
21
21
|
return INPUT_TOO_LONG_ANCHORED_RE.test(diagnostic.trimStart());
|
|
22
22
|
}
|
|
23
23
|
const INPUT_TOO_LONG_STATUSES = new Set([400, 413, 422]);
|
|
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;
|
|
24
25
|
const OPENAI_CHAT = "openai-completions";
|
|
25
26
|
const OPENAI_RESPONSES = "openai-responses";
|
|
26
27
|
const ANTHROPIC = "anthropic-messages";
|
|
@@ -107,6 +108,7 @@ export const GENERIC_FAILURES = Object.freeze([
|
|
|
107
108
|
{ status: [400, 422], word: ["context_length_exceeded"], condition: "stop_other", inputTooLong: true },
|
|
108
109
|
{ status: [400, 422], sentence: INPUT_TOO_LONG_ANCHORED_RE, condition: "stop_other", inputTooLong: true },
|
|
109
110
|
{ status: [413], condition: "stop_other", inputTooLong: true },
|
|
111
|
+
{ status: [400, 422], sentence: IMAGE_UNPROCESSABLE_RE, condition: "stop_other", imageUnprocessable: true },
|
|
110
112
|
]);
|
|
111
113
|
export function isTransientStatus(status) {
|
|
112
114
|
return status >= 500 || status === 408 || status === 409;
|
|
@@ -178,7 +180,7 @@ function verdictOf(dialect, status, stated, enveloped) {
|
|
|
178
180
|
const condition = row?.condition ?? (status === undefined || status === 429 || isTransientStatus(status) ? "unknown" : "stop_other");
|
|
179
181
|
const source = row !== undefined && (row.word !== undefined || row.sentence !== undefined) ? "provider_code" : "status";
|
|
180
182
|
const inputTooLong = status !== undefined && !INPUT_TOO_LONG_STATUSES.has(status) ? "no" : row?.inputTooLong === true ? "yes" : enveloped ? "no" : "unknown";
|
|
181
|
-
return { condition, source, inputTooLong };
|
|
183
|
+
return { condition, source, inputTooLong, imageUnprocessable: row?.imageUnprocessable === true };
|
|
182
184
|
}
|
|
183
185
|
const UNIFIED_QUOTA_HEADERS = [
|
|
184
186
|
"anthropic-ratelimit-unified-representative-claim",
|
|
@@ -193,7 +195,7 @@ export function judgeHttpFailure(args) {
|
|
|
193
195
|
const { dialect, status, headers, body } = args;
|
|
194
196
|
if (status === 429 && UNIFIED_QUOTA_HEADERS.some((h) => headerPresent(headers, h))) {
|
|
195
197
|
const resetAtMs = readUnifiedResetEpochMs(headers);
|
|
196
|
-
return { condition: "quota_exhausted", source: "unified_header", ...(resetAtMs !== undefined ? { resetAtMs } : {}), inputTooLong: "no" };
|
|
198
|
+
return { condition: "quota_exhausted", source: "unified_header", ...(resetAtMs !== undefined ? { resetAtMs } : {}), inputTooLong: "no", imageUnprocessable: false };
|
|
197
199
|
}
|
|
198
200
|
const envelope = statedEnvelope(body);
|
|
199
201
|
return verdictOf(dialect, status, statementOf(envelope), envelope !== undefined);
|
|
@@ -208,6 +210,7 @@ export function inBandProviderError(dialect, envelope, label, providerWords) {
|
|
|
208
210
|
return new BrainError(PROVIDER_CONDITION_TRAITS[v.condition].inBandCode, `${label} stream error ${providerWords(`(${word ?? "unknown"}): ${sentence}`)}`, undefined, {
|
|
209
211
|
apiError: true,
|
|
210
212
|
...(v.inputTooLong === "yes" ? { inputTooLong: true } : v.inputTooLong === "no" ? { inputTooLongRuledOut: true } : {}),
|
|
213
|
+
...(v.imageUnprocessable ? { imageUnprocessable: true } : {}),
|
|
211
214
|
...(word !== undefined ? { providerCode: word } : {}),
|
|
212
215
|
verdict: { condition: v.condition, source: v.source },
|
|
213
216
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { capabilityHeld } from "./model-capability.js";
|
|
2
2
|
import { headerListEntries, lockHeader, takeHeaderSpellings } from "./request-params.js";
|
|
3
|
-
import { MIN_THINKING_TOKENS, RESPONSES_APIS, budgetCapSkipsThinking, declaredEffortLevels, declaredOffSpelling, mintEffortWireValue, reasoningBudgetShare, reasoningRequestCarried, resolveEffort, thinkingOffSpelled, } from "./reasoning.js";
|
|
3
|
+
import { MIN_THINKING_TOKENS, RESPONSES_APIS, budgetCapSkipsThinking, completionsFormatOf, declaredEffortLevels, declaredOffSpelling, mintEffortWireValue, reasoningBudgetShare, reasoningRequestCarried, resolveEffort, thinkingOffSpelled, } from "./reasoning.js";
|
|
4
4
|
export function lowestReasoningSeat(model) {
|
|
5
5
|
return thinkingOffSpelled(model) ? "off" : "low";
|
|
6
6
|
}
|
|
@@ -54,14 +54,15 @@ const COMPLETIONS_DIALECT = {
|
|
|
54
54
|
zai: { off: (body) => put(body, "enable_thinking", false), on: (body) => put(body, "enable_thinking", true) },
|
|
55
55
|
"qwen-chat-template": { off: (body) => withTemplateKwarg(body, false), on: (body) => withTemplateKwarg(body, true) },
|
|
56
56
|
};
|
|
57
|
-
function completionsDialectOf(
|
|
58
|
-
|
|
57
|
+
function completionsDialectOf(compat) {
|
|
58
|
+
const format = completionsFormatOf(compat);
|
|
59
|
+
return format === undefined ? undefined : COMPLETIONS_DIALECT[format];
|
|
59
60
|
}
|
|
60
61
|
const bodyOnly = (body, effort) => ({ body, headers: {}, effort, wireFacts: undefined });
|
|
61
62
|
function applyCompletions(input, body) {
|
|
62
63
|
const { model, level } = input;
|
|
63
64
|
const compat = (model.compat ?? {});
|
|
64
|
-
const dialect = completionsDialectOf(compat
|
|
65
|
+
const dialect = completionsDialectOf(compat);
|
|
65
66
|
if (capabilityHeld(model, "reasoning") && level === "off")
|
|
66
67
|
return bodyOnly(body, dialect?.off(body, model));
|
|
67
68
|
if (!reasoningRequestCarried(model, level))
|
|
@@ -63,6 +63,17 @@ export type ReasoningFormat = "openai" | "openrouter" | "deepseek" | "together"
|
|
|
63
63
|
* top-level `reasoning_effort` the `"openai"` tag names. #325 review r3: before this member the
|
|
64
64
|
* resolver fell through to the completions default and labeled Responses resolutions `"openai"`. */
|
|
65
65
|
| "responses";
|
|
66
|
+
/** The chat-completions dialect names — `compat.thinkingFormat` on a completions-family model. */
|
|
67
|
+
export type CompletionsThinkingFormat = Exclude<ReasoningFormat, "budget" | "effort" | "responses">;
|
|
68
|
+
/**
|
|
69
|
+
* The dialect a completions-family model's `compat` names: the declared `thinkingFormat` when it is a string in the closed set
|
|
70
|
+
* of {@link COMPLETIONS_OFF_SPELLING}, `"openai"` when none is declared, and `undefined` when what is declared names no dialect
|
|
71
|
+
* (a string outside the set, or a value that is not a string — an array or an object is not read as its string form). A model
|
|
72
|
+
* with no dialect carries no thinking key of either kind on the wire.
|
|
73
|
+
*/
|
|
74
|
+
export declare function completionsFormatOf(compat: {
|
|
75
|
+
thinkingFormat?: unknown;
|
|
76
|
+
}): CompletionsThinkingFormat | undefined;
|
|
66
77
|
/**
|
|
67
78
|
* The Open Responses API family — every `Api` value `createOpenResponsesBrain` serves (design/163).
|
|
68
79
|
* The SINGLE family discriminant: request-params.ts (reserved-key set selection) and
|
|
@@ -133,6 +144,14 @@ export declare function declaredOffSpelling(model: OffCapabilityModel): string |
|
|
|
133
144
|
* may size a request by what it SENT, never by what it hopes a gateway does when told nothing. What this
|
|
134
145
|
* table cannot see is a gateway that IGNORES the key it was sent — the classifier's re-ask on a no-verdict
|
|
135
146
|
* reply is the seat that learns that from the reply.
|
|
147
|
+
*
|
|
148
|
+
* THE answer to "can this model's thinking be turned off", for every reader: the engine's seats, and a host that serves a model
|
|
149
|
+
* listing (the Claude Code catalog row calls it `supportsThinkingOff`; a host wraps this answer under that name, beside `reasoning`
|
|
150
|
+
* — `reasoning: true` with this `false` is a model that cannot be turned off). It is DERIVED from the wire table — the API
|
|
151
|
+
* family, `compat` and `thinkingLevelMap.off` of the entry, and its `reasoning` declaration — so the catalog row grows no key for
|
|
152
|
+
* it, the way {@link reasoningEffortLevelsOf} derives the supported tiers: a second, declared copy could only disagree with the
|
|
153
|
+
* wire. A completions model whose `compat.thinkingFormat` names no dialect ({@link completionsFormatOf}) carries no key on the
|
|
154
|
+
* wire, so it answers `false`.
|
|
136
155
|
*/
|
|
137
156
|
export declare function thinkingOffSpelled(model: OffCapabilityModel): boolean;
|
|
138
157
|
/**
|
package/dist/brain/reasoning.js
CHANGED
|
@@ -19,6 +19,19 @@ export function rankOf(level) {
|
|
|
19
19
|
}
|
|
20
20
|
export const DEFAULT_EFFORT_LEVELS = ["minimal", "low", "medium", "high"];
|
|
21
21
|
const BINARY_FORMATS = new Set(["qwen", "zai", "qwen-chat-template"]);
|
|
22
|
+
const COMPLETIONS_OFF_SPELLING = {
|
|
23
|
+
openai: "declared",
|
|
24
|
+
openrouter: "always",
|
|
25
|
+
deepseek: "always",
|
|
26
|
+
together: "always",
|
|
27
|
+
zai: "always",
|
|
28
|
+
qwen: "always",
|
|
29
|
+
"qwen-chat-template": "always",
|
|
30
|
+
};
|
|
31
|
+
export function completionsFormatOf(compat) {
|
|
32
|
+
const declared = compat.thinkingFormat ?? "openai";
|
|
33
|
+
return typeof declared === "string" && Object.prototype.hasOwnProperty.call(COMPLETIONS_OFF_SPELLING, declared) ? declared : undefined;
|
|
34
|
+
}
|
|
22
35
|
export const RESPONSES_APIS = new Set(["openai-responses", "azure-openai-responses", "openai-chatgpt-responses"]);
|
|
23
36
|
export const MIN_THINKING_TOKENS = 1024;
|
|
24
37
|
export function budgetCapSkipsThinking(outputCapTokens, hardCap) {
|
|
@@ -39,8 +52,10 @@ export function thinkingOffSpelled(model) {
|
|
|
39
52
|
return compat.thinkingMode !== "adaptive";
|
|
40
53
|
if (model.api !== undefined && RESPONSES_APIS.has(model.api))
|
|
41
54
|
return declaredOffSpelling(model) !== undefined;
|
|
42
|
-
const format = compat
|
|
43
|
-
|
|
55
|
+
const format = completionsFormatOf(compat);
|
|
56
|
+
if (format === undefined)
|
|
57
|
+
return false;
|
|
58
|
+
return COMPLETIONS_OFF_SPELLING[format] === "declared" ? declaredOffSpelling(model) !== undefined : true;
|
|
44
59
|
}
|
|
45
60
|
export function declaredEffortLevels(v) {
|
|
46
61
|
return Array.isArray(v) && v.length > 0 ? v : undefined;
|
|
@@ -53,7 +53,10 @@ export interface RequestRoute {
|
|
|
53
53
|
root: RequestRootOrigin;
|
|
54
54
|
}
|
|
55
55
|
/** The route of a request carrying `credential`, rooted at the knob `root` names — the one mint of a
|
|
56
|
-
* {@link RequestRoute}. Reads the credential's SHAPE only; its key value never leaves this function.
|
|
56
|
+
* {@link RequestRoute}. Reads the credential's SHAPE only; its key value never leaves this function. The route states
|
|
57
|
+
* what the request CARRIED: a credential that carries nothing — the keyless door, a blank key ({@link keyCarriedBy})
|
|
58
|
+
* or a bag of blank credential headers at whatever rank — is the `"absent"` route, so a refusal never reads as one of
|
|
59
|
+
* a credential that was not sent. */
|
|
57
60
|
export declare function requestRouteOf(credential: RouteCredential, root: RequestRootOrigin): RequestRoute;
|
|
58
61
|
/** One row of {@link ROUTE_CREDENTIAL_PAIRING}. */
|
|
59
62
|
export interface RouteCredentialPairingRow {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { readMember } from "../core/thrown-value.js";
|
|
2
|
+
import { keyCarriedBy } from "./route-adjudicator.js";
|
|
2
3
|
export const ROUTE_CREDENTIAL_SOURCES = Object.freeze(["per-model", "deployment-config", "absent"]);
|
|
3
4
|
export const ROUTE_CARRIERS = Object.freeze(["apiKey", "header"]);
|
|
4
5
|
export const ROUTE_CARRIER_BAGS = Object.freeze(["options", "model", "config"]);
|
|
5
6
|
export const REQUEST_ROOT_ORIGINS = Object.freeze(["model", "deployment", "lane-default"]);
|
|
6
7
|
export function requestRouteOf(credential, root) {
|
|
7
|
-
const carrier = credential.apiKey !== undefined ? "apiKey" : credential.headersBorne === true ? "header" : undefined;
|
|
8
|
+
const carrier = keyCarriedBy(credential.apiKey) !== undefined ? "apiKey" : credential.headersBorne === true ? "header" : undefined;
|
|
9
|
+
if (carrier === undefined)
|
|
10
|
+
return { credentialSource: "absent", root };
|
|
8
11
|
return {
|
|
9
12
|
credentialSource: credential.source,
|
|
10
13
|
...(carrier !== undefined ? { carrier } : {}),
|