@sema-agent/core 7.67.2 → 7.68.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 +1533 -0
- package/README.md +18 -9
- package/README.zh-CN.md +16 -8
- package/dist/agents/agent-definition.d.ts +1 -1
- package/dist/agents/agent-definition.js +4 -1
- package/dist/agents/cascade.d.ts +2 -2
- package/dist/agents/cascade.js +3 -1
- package/dist/agents/cumulative-stats.d.ts +2 -1
- package/dist/agents/cumulative-stats.js +4 -1
- package/dist/agents/list-agents-tool.d.ts +30 -0
- package/dist/agents/list-agents-tool.js +45 -3
- package/dist/agents/peer-admission.d.ts +2 -2
- package/dist/agents/peer-session-drain.d.ts +2 -0
- package/dist/agents/peer-session-drain.js +1 -0
- package/dist/agents/repair-loop.js +3 -1
- package/dist/agents/retain-ledger.d.ts +61 -8
- package/dist/agents/retain-ledger.js +25 -3
- package/dist/agents/roster-store.d.ts +4 -2
- package/dist/agents/send-message-tool.d.ts +1 -1
- package/dist/agents/send-message-tool.js +20 -15
- package/dist/agents/subagent-steps.js +2 -10
- package/dist/agents/subagent.d.ts +3 -0
- package/dist/agents/subagent.js +106 -76
- package/dist/agents/tool-filter.d.ts +20 -11
- package/dist/agents/tool-filter.js +8 -4
- package/dist/agents/verify.d.ts +3 -1
- package/dist/agents/verify.js +2 -0
- package/dist/brain/anthropic.js +4 -4
- package/dist/brain/errors.d.ts +20 -0
- package/dist/brain/errors.js +114 -0
- package/dist/brain/open-responses.js +3 -1
- package/dist/brain/openai.js +3 -1
- package/dist/brain/provider-message.d.ts +5 -3
- package/dist/brain/provider-message.js +35 -8
- package/dist/brain/reasoning-request.d.ts +73 -19
- package/dist/brain/reasoning-request.js +164 -72
- package/dist/brain/reasoning-stamp.d.ts +26 -0
- package/dist/brain/reasoning-stamp.js +10 -0
- package/dist/brain/reasoning.d.ts +95 -162
- package/dist/brain/reasoning.js +31 -86
- package/dist/brain/route-adjudicator.d.ts +9 -7
- package/dist/brain/route-adjudicator.js +12 -10
- package/dist/brain/status-sink.d.ts +19 -64
- package/dist/brain/status-sink.js +5 -21
- package/dist/brain/stream-engine.d.ts +11 -2
- package/dist/brain/stream-engine.js +10 -0
- package/dist/core/a2a.d.ts +17 -5
- package/dist/core/a2a.js +11 -3
- package/dist/core/allow-entry.d.ts +35 -15
- package/dist/core/allow-entry.js +47 -60
- package/dist/core/ask-headline.d.ts +68 -0
- package/dist/core/ask-headline.js +23 -0
- package/dist/core/ask-origin.d.ts +36 -8
- package/dist/core/ask-origin.js +17 -10
- package/dist/core/ask-question.d.ts +34 -7
- package/dist/core/ask-question.js +10 -1
- package/dist/core/ask-unresolvable-notice.d.ts +7 -0
- package/dist/core/ask-unresolvable-notice.js +9 -3
- package/dist/core/auto-strip.d.ts +53 -0
- package/dist/core/auto-strip.js +76 -0
- package/dist/core/background-agent-store.d.ts +45 -5
- package/dist/core/background-agent-store.js +69 -15
- package/dist/core/background-shell.d.ts +2 -2
- package/dist/core/caller-text.js +2 -2
- package/dist/core/canonical-json.d.ts +13 -0
- package/dist/core/canonical-json.js +7 -0
- package/dist/core/checkpoint-features.d.ts +66 -20
- package/dist/core/checkpoint-features.js +12 -1
- package/dist/core/checkpoint-generation.d.ts +1 -1
- package/dist/core/checkpoint-queries.d.ts +1 -1
- package/dist/core/checkpoint-queries.js +4 -1
- package/dist/core/checkpoint-requirements.d.ts +25 -1
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -0
- package/dist/core/checkpoint-row-verdict.js +4 -0
- package/dist/core/checkpoint-store.d.ts +66 -38
- package/dist/core/checkpoint-store.js +15 -6
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +1 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/delegation-frames.d.ts +9 -12
- package/dist/core/delegation-frames.js +9 -8
- package/dist/core/engine-capabilities.d.ts +21 -8
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +147 -34
- package/dist/core/engine-notice.js +27 -16
- package/dist/core/engine-storage-backend.d.ts +2 -1
- package/dist/core/env-budget.js +3 -3
- package/dist/core/env-knob-announce.d.ts +10 -10
- package/dist/core/env-knob-announce.js +3 -6
- package/dist/core/file-history-store.d.ts +29 -4
- package/dist/core/file-history-store.js +13 -0
- package/dist/core/frame-settlement.d.ts +2 -1
- package/dist/core/gate-fold.js +1 -1
- package/dist/core/gate-lanes.js +56 -49
- package/dist/core/governance-codes.d.ts +39 -3
- package/dist/core/governance-codes.js +61 -3
- package/dist/core/hooks.d.ts +29 -11
- package/dist/core/hooks.js +5 -2
- package/dist/core/human-input-projection.js +3 -3
- package/dist/core/input-author.d.ts +17 -3
- package/dist/core/input-author.js +15 -3
- package/dist/core/leg-identity.d.ts +10 -28
- package/dist/core/leg-identity.js +1 -21
- package/dist/core/lsp.d.ts +18 -13
- package/dist/core/lsp.js +30 -22
- package/dist/core/mailbox-store.d.ts +1 -1
- package/dist/core/mailbox-store.js +4 -4
- package/dist/core/mcp-connection-pool.d.ts +93 -4
- package/dist/core/mcp-connection-pool.js +104 -1
- package/dist/core/mcp-failure.d.ts +38 -12
- package/dist/core/mcp-failure.js +9 -13
- package/dist/core/mcp-probe.d.ts +4 -3
- package/dist/core/mcp-server-link.d.ts +4 -2
- package/dist/core/mcp-server-link.js +4 -5
- package/dist/core/mcp-server-spec.d.ts +3 -3
- package/dist/core/mcp-server-unavailable-notice.d.ts +22 -8
- package/dist/core/mcp-server-unavailable-notice.js +18 -4
- package/dist/core/mcp.d.ts +40 -6
- package/dist/core/mcp.js +39 -13
- package/dist/core/memory-engine/content-origin.js +2 -2
- package/dist/core/memory-engine/control-objects.d.ts +2 -4
- package/dist/core/memory-engine/control-objects.js +2 -10
- package/dist/core/memory-engine/delegation-settlement.js +6 -1
- package/dist/core/memory-engine/dual-root.js +3 -0
- package/dist/core/memory-engine/engine.d.ts +6 -4
- package/dist/core/memory-engine/engine.js +32 -29
- package/dist/core/memory-engine/file-backend.d.ts +20 -5
- package/dist/core/memory-engine/file-backend.js +21 -31
- package/dist/core/memory-engine/frontmatter.d.ts +2 -0
- package/dist/core/memory-engine/frontmatter.js +4 -0
- package/dist/core/memory-engine/layout.d.ts +114 -20
- package/dist/core/memory-engine/layout.js +340 -22
- package/dist/core/memory-engine/memory-deployment.d.ts +7 -5
- package/dist/core/memory-engine/mount-failed-notice.d.ts +19 -7
- package/dist/core/memory-engine/mount-failed-notice.js +43 -10
- package/dist/core/memory-engine/sync-client.js +4 -5
- package/dist/core/model-fallbacks.d.ts +5 -1
- package/dist/core/model-fallbacks.js +3 -3
- package/dist/core/model-receipt.d.ts +2 -1
- package/dist/core/model-receipt.js +12 -1
- package/dist/core/mods/kernel/dispatch.d.ts +2 -2
- package/dist/core/mods/kernel/dispatch.js +14 -6
- package/dist/core/mods/kernel/events.d.ts +8 -5
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/index.d.ts +1 -1
- package/dist/core/mods/kernel/registration.d.ts +9 -0
- package/dist/core/mods/package.js +1 -1
- package/dist/core/mods/session-append.d.ts +4 -2
- package/dist/core/mods/session-append.js +3 -0
- package/dist/core/mods/stations.d.ts +7 -11
- package/dist/core/mods/stations.js +4 -7
- package/dist/core/mods/tool-call.d.ts +10 -8
- package/dist/core/mods/tool-call.js +15 -18
- package/dist/core/mounted-mcp.d.ts +0 -4
- package/dist/core/mounted-mcp.js +1 -1
- package/dist/core/park-noun.d.ts +24 -0
- package/dist/core/park-noun.js +21 -0
- package/dist/core/park-resumability.d.ts +60 -0
- package/dist/core/park-resumability.js +30 -0
- package/dist/core/permission-rule-provider.d.ts +24 -2
- package/dist/core/permission-rule-provider.js +11 -8
- package/dist/core/permission-rule-store.d.ts +8 -1
- package/dist/core/permission-rule-store.js +2 -3
- package/dist/core/permission-rules.d.ts +2 -1
- package/dist/core/permission-rules.js +8 -4
- package/dist/core/persisted-rule-arms.d.ts +3 -0
- package/dist/core/persisted-rule-arms.js +2 -1
- package/dist/core/present-plan-tool.d.ts +47 -3
- package/dist/core/present-plan-tool.js +62 -4
- package/dist/core/principal-name.d.ts +1 -1
- package/dist/core/principal-name.js +5 -5
- package/dist/core/process-identity.js +10 -5
- package/dist/core/protocol-http-auth.d.ts +30 -9
- package/dist/core/protocol-http-auth.js +113 -59
- package/dist/core/read-only-shell.js +9 -5
- package/dist/core/redaction-marks.d.ts +4 -26
- package/dist/core/redaction-marks.js +9 -21
- package/dist/core/remote-env.d.ts +43 -16
- package/dist/core/remote-env.js +1 -1
- package/dist/core/request-copy-projection.d.ts +1 -1
- package/dist/core/request-copy-projection.js +40 -50
- package/dist/core/resume-config-judge.js +1 -1
- package/dist/core/resume-startup-cause.d.ts +35 -18
- package/dist/core/resume-startup-cause.js +13 -10
- package/dist/core/retention.d.ts +167 -25
- package/dist/core/retention.js +100 -20
- package/dist/core/roles.d.ts +6 -0
- package/dist/core/roles.js +11 -5
- package/dist/core/rule-lane-reads.d.ts +3 -0
- package/dist/core/rule-lane-reads.js +5 -1
- package/dist/core/rule-store-fault.d.ts +70 -0
- package/dist/core/rule-store-fault.js +102 -0
- package/dist/core/runner/advertised-writable-dirs.js +16 -31
- package/dist/core/runner/announce-once-ledger.d.ts +19 -2
- package/dist/core/runner/announce-once-ledger.js +24 -2
- package/dist/core/runner/assemble-result.d.ts +6 -0
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/auto-strip-notice.d.ts +36 -0
- package/dist/core/runner/auto-strip-notice.js +59 -0
- package/dist/core/runner/branch-window.d.ts +3 -0
- package/dist/core/runner/branch-window.js +37 -0
- package/dist/core/runner/caller-roster.d.ts +8 -3
- package/dist/core/runner/capability-withheld-seat.js +3 -9
- package/dist/core/runner/clock-and-limits.d.ts +22 -1
- package/dist/core/runner/clock-and-limits.js +30 -0
- package/dist/core/runner/contracts.d.ts +58 -35
- package/dist/core/runner/credential-refusal-seat.d.ts +2 -0
- package/dist/core/runner/credential-refusal-seat.js +47 -0
- package/dist/core/runner/cross-boundary-lane.js +6 -4
- package/dist/core/runner/decide-continuation.js +1 -1
- package/dist/core/runner/file-history-restore.d.ts +53 -2
- package/dist/core/runner/file-history-restore.js +29 -10
- package/dist/core/runner/forward-sink.d.ts +14 -1
- package/dist/core/runner/forward-sink.js +14 -12
- package/dist/core/runner/gate-exit.d.ts +8 -7
- package/dist/core/runner/gate-exit.js +13 -13
- package/dist/core/runner/git-status-frame.js +2 -4
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/main-call-account.d.ts +3 -1
- package/dist/core/runner/main-call-account.js +5 -3
- package/dist/core/runner/mcp-redial.d.ts +2 -5
- package/dist/core/runner/mcp-redial.js +2 -2
- package/dist/core/runner/nested-memory-content.d.ts +7 -1
- package/dist/core/runner/nested-memory-content.js +73 -13
- package/dist/core/runner/nested-memory-lane.d.ts +44 -19
- package/dist/core/runner/nested-memory-lane.js +152 -76
- package/dist/core/runner/park-commit.js +3 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +8 -2
- package/dist/core/runner/permission-rule-lanes.js +29 -3
- package/dist/core/runner/person-path-rows.d.ts +3 -11
- package/dist/core/runner/person-path-rows.js +21 -24
- package/dist/core/runner/prepare-acquire-reconcile.js +3 -1
- package/dist/core/runner/prepare-artifact.d.ts +1 -1
- package/dist/core/runner/prepare-artifact.js +20 -14
- package/dist/core/runner/prepare-ask-lane.d.ts +9 -6
- package/dist/core/runner/prepare-ask-lane.js +6 -5
- package/dist/core/runner/prepare-boundary-parks.d.ts +7 -1
- package/dist/core/runner/prepare-boundary-parks.js +27 -24
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +9 -24
- package/dist/core/runner/prepare-config-doors.js +58 -41
- package/dist/core/runner/prepare-context-lane.d.ts +2 -2
- package/dist/core/runner/prepare-context-lane.js +3 -5
- package/dist/core/runner/prepare-defer-classify.d.ts +1 -1
- package/dist/core/runner/prepare-defer-classify.js +1 -1
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +3 -2
- package/dist/core/runner/prepare-file-history.d.ts +62 -26
- package/dist/core/runner/prepare-file-history.js +117 -46
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
- package/dist/core/runner/prepare-gate-stations.js +6 -5
- package/dist/core/runner/prepare-hands-readface.d.ts +9 -4
- package/dist/core/runner/prepare-hands-readface.js +8 -4
- package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
- package/dist/core/runner/prepare-inherited-gate.js +6 -6
- package/dist/core/runner/prepare-listings.d.ts +1 -1
- package/dist/core/runner/prepare-listings.js +1 -1
- package/dist/core/runner/prepare-memory.js +2 -2
- package/dist/core/runner/prepare-offload-wrappers.d.ts +1 -1
- package/dist/core/runner/prepare-offload-wrappers.js +1 -1
- package/dist/core/runner/prepare-park-ask.d.ts +10 -3
- package/dist/core/runner/prepare-park-ask.js +7 -9
- package/dist/core/runner/prepare-policy-chain.d.ts +18 -9
- package/dist/core/runner/prepare-policy-chain.js +18 -13
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +5 -3
- package/dist/core/runner/prepare-prompt-assembly.js +2 -1
- package/dist/core/runner/prepare-prompt-inputs.d.ts +2 -2
- package/dist/core/runner/prepare-prompt-inputs.js +1 -1
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -5
- package/dist/core/runner/prepare-protocol-tools.js +7 -7
- package/dist/core/runner/prepare-question-face.d.ts +4 -2
- package/dist/core/runner/prepare-run-refs.d.ts +7 -2
- package/dist/core/runner/prepare-run-refs.js +8 -7
- package/dist/core/runner/prepare-safety-scan.d.ts +4 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +3 -7
- package/dist/core/runner/prepare-suspend-saga.js +4 -3
- package/dist/core/runner/prepare-task.js +66 -53
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +3 -2
- package/dist/core/runner/prepare-tool-disclosure-mount.js +2 -1
- package/dist/core/runner/prepare-turn-wiring.d.ts +3 -1
- package/dist/core/runner/prepare-turn-wiring.js +1 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +9 -4
- package/dist/core/runner/prepare-wiring-manifest.js +14 -6
- package/dist/core/runner/prepare-workspace-restore.d.ts +4 -4
- package/dist/core/runner/prepare-workspace-restore.js +15 -6
- package/dist/core/runner/remote-env-retry.d.ts +3 -3
- package/dist/core/runner/restore-seat.d.ts +41 -0
- package/dist/core/runner/restore-seat.js +38 -0
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-apply.js +4 -3
- package/dist/core/runner/resume-checkpoint-screen.js +2 -1
- package/dist/core/runner/resume-internals-and-config.js +2 -1
- package/dist/core/runner/resume-preflight.js +2 -1
- package/dist/core/runner/rewind-files.js +22 -6
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +8 -0
- package/dist/core/runner/rule-store-unreadable-notice.js +11 -0
- package/dist/core/runner/run-brain-sinks.d.ts +3 -6
- package/dist/core/runner/run-brain-sinks.js +6 -6
- package/dist/core/runner/run-compaction-machinery.d.ts +2 -2
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +2 -1
- package/dist/core/runner/run-harness-handlers.js +5 -4
- package/dist/core/runner/run-identity-wiring.js +20 -12
- package/dist/core/runner/run-leg.js +31 -72
- package/dist/core/runner/run-notification-lane.d.ts +3 -0
- package/dist/core/runner/run-notification-lane.js +2 -4
- package/dist/core/runner/run-reasoning-seat.d.ts +5 -6
- package/dist/core/runner/run-reasoning-seat.js +13 -18
- package/dist/core/runner/run-settle-and-teardown.js +13 -9
- package/dist/core/runner/run-terminal-adoption.js +4 -8
- package/dist/core/runner/run-turn-boundary.js +6 -3
- package/dist/core/runner/runtask.d.ts +9 -4
- package/dist/core/runner/runtask.js +29 -22
- package/dist/core/runner/session-rule-policy.d.ts +11 -1
- package/dist/core/runner/shell-env-withheld.js +2 -7
- package/dist/core/runner/side-call-account.d.ts +5 -6
- package/dist/core/runner/side-call-account.js +2 -2
- package/dist/core/runner/stream-lifecycle-verbs.d.ts +3 -0
- package/dist/core/runner/stream-lifecycle-verbs.js +5 -3
- package/dist/core/runner/stream-settle-backstop.js +4 -6
- package/dist/core/runner/stream-steer-verb.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +4 -4
- package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -3
- package/dist/core/runner/sub-agent-deny-lists.js +7 -4
- package/dist/core/runner/teardown-bounded.d.ts +7 -0
- package/dist/core/runner/teardown-bounded.js +7 -0
- package/dist/core/runner/terminal-account.js +41 -13
- package/dist/core/runner/terminal-projection.d.ts +1 -5
- package/dist/core/runner/tool-end-body.d.ts +9 -3
- package/dist/core/runner/tool-end-body.js +6 -3
- package/dist/core/runner/tool-output-projection.d.ts +13 -4
- package/dist/core/runner/tool-output-projection.js +10 -14
- package/dist/core/runner/turn-attachments.d.ts +3 -2
- package/dist/core/runner/turn-attachments.js +12 -5
- package/dist/core/runner-deps.d.ts +6 -6
- package/dist/core/runtime-caps.d.ts +2 -1
- package/dist/core/secret-env.d.ts +20 -3
- package/dist/core/secret-env.js +13 -15
- package/dist/core/session-checkout.d.ts +115 -15
- package/dist/core/session-checkout.js +435 -136
- package/dist/core/session-policy-store.js +21 -3
- package/dist/core/session-reconcile.js +1 -0
- package/dist/core/session-store.js +2 -0
- package/dist/core/session.d.ts +11 -1
- package/dist/core/shell-run-candidates.d.ts +1 -0
- package/dist/core/shell-run-candidates.js +1 -1
- package/dist/core/shutdown-debug.d.ts +6 -5
- package/dist/core/shutdown-debug.js +5 -1
- package/dist/core/skill-grant.js +4 -1
- package/dist/core/skills-directory.js +5 -3
- package/dist/core/spec-contract.d.ts +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +2 -7
- package/dist/core/store-contracts/file-history-store-contract.js +26 -2
- package/dist/core/store-contracts/session-deletion-cascade-contract.js +130 -14
- package/dist/core/store-contracts/task-list-store-contract.d.ts +2 -1
- package/dist/core/store-contracts/task-list-store-contract.js +28 -1
- package/dist/core/task-event.d.ts +48 -27
- package/dist/core/task-notification.d.ts +15 -9
- package/dist/core/task-notification.js +12 -0
- package/dist/core/task-registry-agent.d.ts +24 -22
- package/dist/core/task-registry-agent.js +65 -46
- package/dist/core/task-registry-shared.d.ts +17 -5
- package/dist/core/task-registry.d.ts +17 -6
- package/dist/core/task-registry.js +6 -1
- package/dist/core/task-result.d.ts +71 -25
- package/dist/core/task-spec-members.d.ts +0 -1
- package/dist/core/task-spec-members.js +1 -1
- package/dist/core/task-spec.d.ts +60 -52
- package/dist/core/task-stream.d.ts +45 -12
- package/dist/core/terminal-cause.d.ts +45 -8
- package/dist/core/terminal-cause.js +5 -0
- package/dist/core/tool-card-bound.d.ts +32 -0
- package/dist/core/tool-card-bound.js +33 -0
- package/dist/core/tool-catalog-entries.d.ts +9 -0
- package/dist/core/tool-catalog-entries.js +48 -0
- package/dist/core/tool-errors.d.ts +4 -3
- package/dist/core/tool-face.d.ts +3 -3
- package/dist/core/tool-mount-facts.d.ts +3 -2
- package/dist/core/tool-mount-facts.js +1 -1
- package/dist/core/tool-mount-static.js +7 -5
- package/dist/core/tool-policy.d.ts +21 -19
- package/dist/core/tool-policy.js +5 -6
- package/dist/core/tool-registry.d.ts +3 -1
- package/dist/core/tool-registry.js +15 -1
- package/dist/core/tool-result-store.d.ts +9 -3
- package/dist/core/tool-result-store.js +14 -1
- package/dist/core/tool-roster.d.ts +6 -0
- package/dist/core/tool-roster.js +18 -0
- package/dist/core/tool-spec.d.ts +17 -8
- package/dist/core/trace.d.ts +35 -31
- package/dist/core/types.d.ts +2 -2
- package/dist/core/untrusted-egress.d.ts +19 -7
- package/dist/core/untrusted-egress.js +26 -7
- package/dist/core/untrusted-text.d.ts +6 -18
- package/dist/core/untrusted-text.js +11 -4
- package/dist/core/user-attachment.d.ts +9 -6
- package/dist/core/user-attachment.js +12 -10
- package/dist/core/user-row-origin.d.ts +44 -25
- package/dist/core/user-row-origin.js +30 -20
- package/dist/core/wiring-manifest.d.ts +26 -7
- package/dist/core/wiring-manifest.js +14 -11
- package/dist/core/workspace-snapshot.d.ts +3 -1
- package/dist/core/workspace-snapshot.js +1 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +23 -16
- package/dist/engine/execution-env/node-execution-env.js +127 -67
- package/dist/engine/harness/agent-harness.d.ts +4 -5
- package/dist/engine/harness/agent-harness.js +2 -7
- package/dist/engine/harness/types.d.ts +51 -19
- package/dist/engine/harness/types.js +28 -1
- package/dist/engine/llm/types.d.ts +26 -14
- package/dist/engine/llm/types.js +2 -2
- package/dist/engine/loop/agent-loop.d.ts +2 -2
- package/dist/engine/loop/agent-loop.js +51 -275
- package/dist/engine/loop/types.d.ts +0 -18
- package/dist/engine/session/import-validate.d.ts +3 -0
- package/dist/engine/session/import-validate.js +34 -2
- package/dist/engine/session/repo-utils.d.ts +42 -4
- package/dist/engine/session/repo-utils.js +33 -5
- package/dist/engine/session/session.d.ts +41 -14
- package/dist/engine/session/session.js +96 -25
- package/dist/index.d.ts +21 -16
- package/dist/index.js +16 -10
- package/dist/orchestration/run-spec.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +12 -9
- package/dist/orchestration/run-workflow-tool.js +15 -19
- package/dist/orchestration/workflow-governance.js +13 -21
- package/dist/orchestration/workflow-observe.d.ts +4 -3
- package/dist/orchestration/workflow-primitives.d.ts +1 -1
- package/dist/orchestration/workflow-record-artifact.d.ts +14 -0
- package/dist/orchestration/workflow-record-artifact.js +32 -0
- package/dist/orchestration/workflow-script-store.d.ts +9 -0
- package/dist/orchestration/workflow-script-store.js +20 -1
- package/dist/orchestration/workflow-types.d.ts +33 -3
- package/dist/orchestration/workflow.d.ts +24 -14
- package/dist/orchestration/workflow.js +52 -23
- package/dist/prompt-assembly/artifact.js +4 -8
- package/dist/prompt-assembly/catalog/engine.d.ts +263 -0
- package/dist/prompt-assembly/catalog/engine.js +30 -0
- package/dist/prompt-assembly/catalog/index.d.ts +1 -1
- package/dist/prompt-assembly/catalog/index.js +2 -2
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +1 -1
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +29 -0
- package/dist/prompt-assembly/epoch.js +6 -8
- package/dist/prompt-assembly/turn-snapshot.js +8 -9
- package/dist/stores/file/background-agent-store.js +5 -6
- package/dist/stores/file/checkpoint-store.d.ts +0 -4
- package/dist/stores/file/checkpoint-store.js +7 -3
- package/dist/stores/file/file-history-store.d.ts +8 -0
- package/dist/stores/file/file-history-store.js +72 -0
- package/dist/stores/file/fs-atomic.js +17 -12
- package/dist/stores/file/index.js +11 -5
- package/dist/stores/file/mailbox-store.js +13 -4
- package/dist/stores/file/permission-rule-store.js +14 -13
- package/dist/stores/file/shared-ledger.d.ts +4 -0
- package/dist/stores/file/shared-ledger.js +4 -0
- package/dist/stores/file/task-list-store.js +12 -3
- package/dist/stores/file/workflow-run-store.js +1 -0
- package/dist/tools/fs/bash-program-position.d.ts +4 -2
- package/dist/tools/fs/bash-program-position.js +1 -1
- package/dist/tools/fs/bash-readonly-classifier.js +1 -1
- package/dist/tools/fs/bound-open.d.ts +97 -0
- package/dist/tools/fs/bound-open.js +103 -0
- package/dist/tools/fs/containment-face.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.d.ts +7 -1
- package/dist/tools/fs/fs-pdf.js +31 -23
- package/dist/tools/fs/fs-read.d.ts +24 -17
- package/dist/tools/fs/fs-read.js +84 -53
- package/dist/tools/fs/fs-shared.d.ts +14 -12
- package/dist/tools/fs/fs-shared.js +5 -4
- package/dist/tools/fs/fs-write.d.ts +2 -2
- package/dist/tools/fs/fs-write.js +20 -12
- package/dist/tools/fs/index.d.ts +4 -4
- package/dist/tools/fs/index.js +2 -2
- package/dist/tools/fs/notebook.d.ts +1 -1
- package/dist/tools/fs/pdf.d.ts +12 -3
- package/dist/tools/fs/pdf.js +22 -9
- package/dist/tools/fs/read-deny-home.d.ts +3 -2
- package/dist/tools/fs/read-deny-home.js +8 -11
- package/dist/tools/fs/safety.d.ts +3 -2
- package/dist/tools/fs/shell-read-check.js +10 -9
- package/dist/tools/monitor.d.ts +6 -5
- package/dist/tools/task-list.d.ts +16 -6
- package/dist/tools/task-list.js +4 -0
- package/dist/tools/web.d.ts +9 -1
- package/dist/tools/web.js +8 -3
- package/dist/tools/worktree.d.ts +7 -5
- package/dist/tools/worktree.js +4 -3
- package/package.json +4 -3
- package/test/export-surface.snapshot.json +93 -7
- package/wire-changes/core-stores-sql@7.67.3.json +39 -0
- package/wire-changes/core-stores-sql@7.68.0.json +39 -0
- package/wire-changes/core@7.67.3.json +65 -0
- package/wire-changes/core@7.68.0.json +4257 -0
- package/wire-changes/mods-kernel@7.67.3.json +39 -0
- package/wire-changes/mods-kernel@7.68.0.json +129 -0
- package/wire-changes/primitives@7.67.3.json +39 -0
- package/wire-changes/primitives@7.68.0.json +253 -0
- package/wire-changes/wiki-gate@7.67.3.json +39 -0
- package/wire-changes/wiki-gate@7.68.0.json +39 -0
- package/dist/core/runner/credential-origin-seat.d.ts +0 -2
- package/dist/core/runner/credential-origin-seat.js +0 -20
|
@@ -117,22 +117,31 @@ export declare function isToolSelectorLayer(layer: unknown): layer is ToolSelect
|
|
|
117
117
|
*/
|
|
118
118
|
export declare function compileToolSelector(layers: readonly ToolSelectorLayer[], legs?: readonly ToolLegKind[]): ToolSelector;
|
|
119
119
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
120
|
+
* A run's OWN selector layer, built from its two lists as they were read (a leg's own lists are read as written first, so a malformed
|
|
121
|
+
* one refuses whether or not the switch is on) — the one place a run's whole-face switch (`excludeAllTools`) is read: it is the leg's
|
|
122
|
+
* own allowlist naming nothing, whatever `allowTools` says. The leg then keeps exactly
|
|
123
|
+
* what `allowTools: []` keeps (the tools it relies on, as the layers above allow them), and the selector compiled over this layer —
|
|
124
|
+
* the valve, `ToolExecuteContext.toolSelector`, the ceiling every child inherits — answers so everywhere.
|
|
123
125
|
*/
|
|
124
|
-
export declare function
|
|
126
|
+
export declare function ownSelectorLayer(lists: {
|
|
127
|
+
readonly allow: readonly string[] | undefined;
|
|
128
|
+
readonly exclude: readonly string[] | undefined;
|
|
129
|
+
}, spec: {
|
|
125
130
|
readonly excludeAllTools?: true;
|
|
126
|
-
}
|
|
131
|
+
}): ToolSelectorLayer;
|
|
132
|
+
/**
|
|
133
|
+
* What a leg's tool valve leaves mounted — its one reading: what the compiled selector admits (a run's whole-face switch is inside it,
|
|
134
|
+
* {@link ownSelectorLayer}). The valve unmounts by it, and every question prepare asks about the post-valve roster before the valve
|
|
135
|
+
* runs asks it too.
|
|
136
|
+
*/
|
|
137
|
+
export declare function valveLeaves(selector: Pick<ToolSelector, "admits">): (tool: UniverseTool) => boolean;
|
|
127
138
|
/**
|
|
128
139
|
* The valve's reading at the SERVER level — {@link valveLeaves} asked of a whole peer before any of its tools is known: can the valve
|
|
129
|
-
* leave a tool of the peer `prefix` (`mcp__srv__`) at all?
|
|
130
|
-
*
|
|
131
|
-
* reason to dial it or to teach its instructions.
|
|
140
|
+
* leave a tool of the peer `prefix` (`mcp__srv__`) at all? What the compiled selector's lists can reach of the peer
|
|
141
|
+
* ({@link ToolSelector.admitsPeer}; under the whole-face switch nothing — an allowlist naming nothing reaches no peer). A peer answered
|
|
142
|
+
* `false` leaves no tool on the roster, so a run has no reason to dial it or to teach its instructions.
|
|
132
143
|
*/
|
|
133
|
-
export declare function valveLeavesPeer(
|
|
134
|
-
readonly excludeAllTools?: true;
|
|
135
|
-
}, selector: Pick<ToolSelector, "admitsPeer">): (prefix: string) => boolean;
|
|
144
|
+
export declare function valveLeavesPeer(selector: Pick<ToolSelector, "admitsPeer">): (prefix: string) => boolean;
|
|
136
145
|
/** One protocol tool a denylist reaches, and whose list it is: the leg's own (the last layer) or one it inherits (a ceiling layer). */
|
|
137
146
|
export interface DeniedProtocolTool {
|
|
138
147
|
readonly name: string;
|
|
@@ -130,11 +130,15 @@ export function compileToolSelector(layers, legs = []) {
|
|
|
130
130
|
},
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
-
export function
|
|
134
|
-
|
|
133
|
+
export function ownSelectorLayer(lists, spec) {
|
|
134
|
+
const allow = spec.excludeAllTools === true ? Object.freeze([]) : lists.allow;
|
|
135
|
+
return { ...(allow !== undefined ? { allow } : {}), deny: lists.exclude ?? [] };
|
|
135
136
|
}
|
|
136
|
-
export function
|
|
137
|
-
return
|
|
137
|
+
export function valveLeaves(selector) {
|
|
138
|
+
return (tool) => selector.admits(tool);
|
|
139
|
+
}
|
|
140
|
+
export function valveLeavesPeer(selector) {
|
|
141
|
+
return (prefix) => selector.admitsPeer(prefix);
|
|
138
142
|
}
|
|
139
143
|
export function deniedProtocolTools(layers, legs) {
|
|
140
144
|
const denies = layers.map((l) => readDeniedToolList(isToolSelectorLayer(l) ? l.deny : undefined));
|
package/dist/agents/verify.d.ts
CHANGED
|
@@ -71,6 +71,8 @@ export interface VerifyConfig {
|
|
|
71
71
|
* A generic core can't know which of YOUR tools mutate "the project", so if the verifier needs to run a
|
|
72
72
|
* build/test runner, mark that tool `effect: "read"` (it doesn't persist project changes) or pass it here
|
|
73
73
|
* explicitly. Anything `idempotent`/`write` is dropped by default — pass `verifierTools` to widen.
|
|
74
|
+
* Either way they are bounded by the implementation task's tool-face controls, which the verifier's spec carries
|
|
75
|
+
* (`allowTools` / `excludeTools` / `excludeAllTools`): under `excludeAllTools` the verifier mounts none of them, only its verdict tool.
|
|
74
76
|
*/
|
|
75
77
|
verifierTools?: ToolSpec[];
|
|
76
78
|
/** Verify→fix→re-verify rounds (each round = one verification; FAIL between rounds triggers a fix turn). Default 2. */
|
|
@@ -306,7 +308,7 @@ export declare function verifyCompleted(runner: RunnerSelfSeat, result: TaskResu
|
|
|
306
308
|
* FAILURE-ISOLATED, by the same primitive as {@link VerifyConfig.onRound} /
|
|
307
309
|
* {@link VerifyConfig.onVerifierPause}: the fields on this object are invoked by the ENGINE on the
|
|
308
310
|
* run's own path, through a run-scoped safe notifier — a throwing `onActivity` is contained (first
|
|
309
|
-
* failure per site
|
|
311
|
+
* failure per site told as `config.host_sink_failed` on the runner's notice seat, later ones counted) and never faults the leg it
|
|
310
312
|
* fires on. Uncontained, such a throw fails the leg (misclassified `provider.error`) and reports an
|
|
311
313
|
* impl leg incomplete — the MEASURED HAZARD pins hold containment.
|
|
312
314
|
*
|
package/dist/agents/verify.js
CHANGED
|
@@ -160,6 +160,7 @@ async function verifyCompletedPlaced(runner, result, specBase, objective, config
|
|
|
160
160
|
tools: verifierTools,
|
|
161
161
|
handsReadOnly: config.verifierHandsReadOnly ?? true,
|
|
162
162
|
...engineHeadlessLegSeats(),
|
|
163
|
+
...(specBase.checkpointStore !== undefined ? { checkpointStore: specBase.checkpointStore } : {}),
|
|
163
164
|
...childClampSeats({
|
|
164
165
|
...clampSourceOf(specBase),
|
|
165
166
|
readFace: foldedRootsFace ? "roots" : undefined,
|
|
@@ -178,6 +179,7 @@ async function verifyCompletedPlaced(runner, result, specBase, objective, config
|
|
|
178
179
|
...(specBase.excludeTools !== undefined
|
|
179
180
|
? { excludeTools: Array.isArray(specBase.excludeTools) ? [...specBase.excludeTools] : specBase.excludeTools }
|
|
180
181
|
: {}),
|
|
182
|
+
...(specBase.excludeAllTools !== undefined ? { excludeAllTools: specBase.excludeAllTools } : {}),
|
|
181
183
|
...(specBase.deferTools !== undefined
|
|
182
184
|
? { deferTools: Array.isArray(specBase.deferTools) ? [...specBase.deferTools] : specBase.deferTools }
|
|
183
185
|
: {}),
|
package/dist/brain/anthropic.js
CHANGED
|
@@ -5,13 +5,14 @@ import { startsWithInputTooLongAnchor } from "./input-too-long.js";
|
|
|
5
5
|
import { DEGENERATE_MESSAGE, trimDegenerateTail } from "./repetition.js";
|
|
6
6
|
import { NO_WORD, STREAM_TORN_WARNING, createRepetitionPoll, createStreamEndLedger, droppedFramesNote, endingInNoWord, endingWordOf, memberReader, modelOutputInvalidOf, noteResponseModel, nameMissingCause, parseStreamedToolArgs, placeTurnNotes, truncationCauseClause } from "./stream-shared.js";
|
|
7
7
|
import { admitToolCallId, providerResultIds, providerToolCallId, responseToolCallIds } from "./tool-call-id.js";
|
|
8
|
-
import { emitBrainTelemetry
|
|
8
|
+
import { emitBrainTelemetry } from "./status-sink.js";
|
|
9
9
|
import { errorResultMediaNote, IMAGE_OMITTED_NO_VISION, imageWithholdOf, reportImagesWithheld, sendableImages } from "./media-degrade.js";
|
|
10
10
|
import { ANTHROPIC_RESERVED, OUTPUT_CAP_KEYS, applyExtraBody, declaredRequestValues, effectiveOutputCap, headerBagOnce, headerListEntries, lockHeader, mergeHeaders, takeHeaderSpellings } from "./request-params.js";
|
|
11
11
|
import { admitRouteRequest, applyRouteCredentialHeaders, assertServableRequestRoot, brainConfigSnapshot, createBrainRouteJudge, joinRequestUrl, resolveRequestRootOf, resolveRouteCredential } from "./route-adjudicator.js";
|
|
12
12
|
import { requestRouteOf } from "./request-route.js";
|
|
13
13
|
import { NAMES_AS_WRITTEN, judgeInBandError, resolveProviderDialect, endpointToolNames } from "./provider-dialect.js";
|
|
14
14
|
import { applyReasoningToRequest, mergeReasoningHeaders } from "./reasoning-request.js";
|
|
15
|
+
import { requestReasoning } from "./reasoning-stamp.js";
|
|
15
16
|
import { reasoningTokensOf } from "./usage-reasoning.js";
|
|
16
17
|
import { usageOfStatement } from "./usage-reading.js";
|
|
17
18
|
import { runStreamingBrain } from "./stream-engine.js";
|
|
@@ -377,7 +378,7 @@ export function createAnthropicBrain(given = {}) {
|
|
|
377
378
|
body.temperature = options.temperature;
|
|
378
379
|
}
|
|
379
380
|
const hardCap = overrides?.maxOutputTokens !== undefined || options?.maxTokens !== undefined;
|
|
380
|
-
const { body: reasoningBody, headers: reasoningHeaders,
|
|
381
|
+
const { body: reasoningBody, headers: reasoningHeaders, carried, } = applyReasoningToRequest({
|
|
381
382
|
api: "anthropic-messages",
|
|
382
383
|
model,
|
|
383
384
|
level: options?.reasoning,
|
|
@@ -420,14 +421,13 @@ export function createAnthropicBrain(given = {}) {
|
|
|
420
421
|
route: requestRouteOf(routeCredential, rootOrigin),
|
|
421
422
|
outputCapTokens: effectiveOutputCap(wire, OUTPUT_CAP_KEYS.anthropic),
|
|
422
423
|
capDerivedPaths: [...OUTPUT_CAP_KEYS.anthropic, "thinking.budget_tokens"],
|
|
424
|
+
reasoning: requestReasoning(options?.reasoning, carried),
|
|
423
425
|
onCommitted: () => {
|
|
424
426
|
routeAdmission();
|
|
425
427
|
thinkingRequested = builtThinkingRequested;
|
|
426
428
|
sentMaxTokens = builtMaxTokens;
|
|
427
429
|
sentMaxTokensLane = builtMaxTokensLane;
|
|
428
430
|
sentToolNames = builtToolNames;
|
|
429
|
-
if (builtReasoningFacts !== undefined)
|
|
430
|
-
reportReasoningWireFacts(builtReasoningFacts);
|
|
431
431
|
},
|
|
432
432
|
};
|
|
433
433
|
},
|
package/dist/brain/errors.d.ts
CHANGED
|
@@ -148,6 +148,26 @@ export interface FailedBody {
|
|
|
148
148
|
/** What a failed response's body states — its envelope — and only when the body ended ({@link FailedBody}). Every
|
|
149
149
|
* reader of a failed body (the dialect verdict, the echoed word) reads it through here. */
|
|
150
150
|
export declare function statedEnvelope(body: FailedBody | undefined): ReturnType<typeof providerErrorObject>;
|
|
151
|
+
/** The sentence an envelope states and how the endpoint wrote it. */
|
|
152
|
+
export interface StatedSentence {
|
|
153
|
+
/** `error.message`, as {@link statedEnvelope} reads it. */
|
|
154
|
+
readonly sentence: string;
|
|
155
|
+
/** For each code unit of the sentence, the span of the body it was written as (`from[i]` … `to[i]`: the character itself, or the
|
|
156
|
+
* whole escape that stands for it). Absent when the walk below does not place a literal that decodes to the sentence — two
|
|
157
|
+
* readings of one body that disagree, which the reader of the sentence answers by withholding it. */
|
|
158
|
+
readonly written?: {
|
|
159
|
+
readonly from: Int32Array;
|
|
160
|
+
readonly to: Int32Array;
|
|
161
|
+
} | undefined;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The sentence a failed response's envelope states (`error.message` when it is a string, read through {@link statedEnvelope}),
|
|
165
|
+
* with where each of its characters stands in the body as the endpoint wrote it — one read, two products: the value `JSON.parse`
|
|
166
|
+
* gives, and the literal that value came from, found by a walk that reads the body by `JSON.parse`'s rules (the body trimmed as
|
|
167
|
+
* {@link providerErrorObject} trims it, member names decoded, the last of a repeated member) and checked by decoding: a literal
|
|
168
|
+
* that does not decode to the sentence is not its spelling, and the sentence is stated without one.
|
|
169
|
+
*/
|
|
170
|
+
export declare function statedSentence(body: FailedBody | undefined): StatedSentence | undefined;
|
|
151
171
|
/** The envelope's word as the echo seat carries it ({@link readProviderErrorCode}, for an envelope already in hand —
|
|
152
172
|
* an in-band error frame's): carried in the echo shape, else dropped whole and counted once. */
|
|
153
173
|
export declare function carriedProviderWord(err: {
|
package/dist/brain/errors.js
CHANGED
|
@@ -82,6 +82,120 @@ export function readProviderErrorCode(body) {
|
|
|
82
82
|
export function statedEnvelope(body) {
|
|
83
83
|
return body !== undefined && body.endedNormally ? providerErrorObject(body.text) : undefined;
|
|
84
84
|
}
|
|
85
|
+
export function statedSentence(body) {
|
|
86
|
+
const sentence = statedEnvelope(body)?.message;
|
|
87
|
+
if (body === undefined || typeof sentence !== "string")
|
|
88
|
+
return undefined;
|
|
89
|
+
const literal = envelopeMessageLiteral(body.text);
|
|
90
|
+
const units = literal === undefined ? undefined : literalUnits(body.text, literal);
|
|
91
|
+
return units !== undefined && units.text === sentence ? { sentence, written: { from: units.from, to: units.to } } : { sentence };
|
|
92
|
+
}
|
|
93
|
+
const isJsonSpace = (c) => c === " " || c === "\t" || c === "\n" || c === "\r";
|
|
94
|
+
const skipJsonSpace = (t, i) => {
|
|
95
|
+
while (isJsonSpace(t[i]))
|
|
96
|
+
i++;
|
|
97
|
+
return i;
|
|
98
|
+
};
|
|
99
|
+
function jsonStringEnd(t, i) {
|
|
100
|
+
for (let j = i + 1; j < t.length; j++) {
|
|
101
|
+
if (t[j] === "\\")
|
|
102
|
+
j++;
|
|
103
|
+
else if (t[j] === '"')
|
|
104
|
+
return j + 1;
|
|
105
|
+
}
|
|
106
|
+
return -1;
|
|
107
|
+
}
|
|
108
|
+
function jsonValueEnd(t, i) {
|
|
109
|
+
const c = t[i];
|
|
110
|
+
if (c === '"')
|
|
111
|
+
return jsonStringEnd(t, i);
|
|
112
|
+
if (c !== "{" && c !== "[") {
|
|
113
|
+
let j = i;
|
|
114
|
+
while (j < t.length && !isJsonSpace(t[j]) && t[j] !== "," && t[j] !== "}" && t[j] !== "]")
|
|
115
|
+
j++;
|
|
116
|
+
return j > i ? j : -1;
|
|
117
|
+
}
|
|
118
|
+
let depth = 0;
|
|
119
|
+
for (let j = i; j < t.length; j++) {
|
|
120
|
+
const d = t[j];
|
|
121
|
+
if (d === '"') {
|
|
122
|
+
const end = jsonStringEnd(t, j);
|
|
123
|
+
if (end < 0)
|
|
124
|
+
return -1;
|
|
125
|
+
j = end - 1;
|
|
126
|
+
}
|
|
127
|
+
else if (d === "{" || d === "[")
|
|
128
|
+
depth++;
|
|
129
|
+
else if ((d === "}" || d === "]") && --depth === 0)
|
|
130
|
+
return j + 1;
|
|
131
|
+
}
|
|
132
|
+
return -1;
|
|
133
|
+
}
|
|
134
|
+
function jsonMembers(t, i) {
|
|
135
|
+
const members = [];
|
|
136
|
+
let j = skipJsonSpace(t, i + 1);
|
|
137
|
+
if (t[j] === "}")
|
|
138
|
+
return members;
|
|
139
|
+
for (;;) {
|
|
140
|
+
if (t[j] !== '"')
|
|
141
|
+
return undefined;
|
|
142
|
+
const nameEnd = jsonStringEnd(t, j);
|
|
143
|
+
if (nameEnd < 0)
|
|
144
|
+
return undefined;
|
|
145
|
+
const name = literalUnits(t, { start: j, end: nameEnd })?.text;
|
|
146
|
+
j = skipJsonSpace(t, nameEnd);
|
|
147
|
+
if (name === undefined || t[j] !== ":")
|
|
148
|
+
return undefined;
|
|
149
|
+
const start = skipJsonSpace(t, j + 1);
|
|
150
|
+
const end = jsonValueEnd(t, start);
|
|
151
|
+
if (end < 0)
|
|
152
|
+
return undefined;
|
|
153
|
+
members.push({ name, start, end });
|
|
154
|
+
j = skipJsonSpace(t, end);
|
|
155
|
+
if (t[j] === "}")
|
|
156
|
+
return members;
|
|
157
|
+
if (t[j] !== ",")
|
|
158
|
+
return undefined;
|
|
159
|
+
j = skipJsonSpace(t, j + 1);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const lastMember = (members, name) => members?.filter((m) => m.name === name).pop();
|
|
163
|
+
function envelopeMessageLiteral(text) {
|
|
164
|
+
const at = text.length - text.trimStart().length;
|
|
165
|
+
if (text[at] !== "{")
|
|
166
|
+
return undefined;
|
|
167
|
+
const error = lastMember(jsonMembers(text, at), "error");
|
|
168
|
+
if (error === undefined || text[error.start] !== "{")
|
|
169
|
+
return undefined;
|
|
170
|
+
const message = lastMember(jsonMembers(text, error.start), "message");
|
|
171
|
+
return message !== undefined && text[message.start] === '"' ? message : undefined;
|
|
172
|
+
}
|
|
173
|
+
const JSON_SHORT_ESCAPES = Object.freeze({ '"': '"', "\\": "\\", "/": "/", b: "\b", f: "\f", n: "\n", r: "\r", t: "\t" });
|
|
174
|
+
function literalUnits(t, literal) {
|
|
175
|
+
const from = [];
|
|
176
|
+
const to = [];
|
|
177
|
+
let text = "";
|
|
178
|
+
for (let i = literal.start + 1; i < literal.end - 1;) {
|
|
179
|
+
if (t[i] !== "\\") {
|
|
180
|
+
text += t[i];
|
|
181
|
+
from.push(i);
|
|
182
|
+
to.push(i + 1);
|
|
183
|
+
i += 1;
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const escape = t[i + 1] ?? "";
|
|
187
|
+
const hex = t.slice(i + 2, i + 6);
|
|
188
|
+
const unit = escape === "u" && /^[0-9A-Fa-f]{4}$/.test(hex) ? String.fromCharCode(parseInt(hex, 16)) : JSON_SHORT_ESCAPES[escape];
|
|
189
|
+
if (unit === undefined)
|
|
190
|
+
return undefined;
|
|
191
|
+
const width = escape === "u" ? 6 : 2;
|
|
192
|
+
text += unit;
|
|
193
|
+
from.push(i);
|
|
194
|
+
to.push(i + width);
|
|
195
|
+
i += width;
|
|
196
|
+
}
|
|
197
|
+
return { text, from: Int32Array.from(from), to: Int32Array.from(to) };
|
|
198
|
+
}
|
|
85
199
|
export function carriedProviderWord(err) {
|
|
86
200
|
const word = providerErrorWord(err);
|
|
87
201
|
const reading = providerEchoReading(word);
|
|
@@ -12,6 +12,7 @@ import { admitRouteRequest, applyRouteCredentialHeaders, assertServableRequestRo
|
|
|
12
12
|
import { requestRouteOf } from "./request-route.js";
|
|
13
13
|
import { NAMES_AS_WRITTEN, resolveProviderDialect, endpointToolNames } from "./provider-dialect.js";
|
|
14
14
|
import { applyReasoningToRequest } from "./reasoning-request.js";
|
|
15
|
+
import { requestReasoning } from "./reasoning-stamp.js";
|
|
15
16
|
import { runStreamingBrain } from "./stream-engine.js";
|
|
16
17
|
import { refuseRetiredTimeoutKnobs } from "./timeout.js";
|
|
17
18
|
import { resolveFetch } from "./transport.js";
|
|
@@ -274,7 +275,7 @@ export function createOpenResponsesBrain(given = {}) {
|
|
|
274
275
|
builtMaxTokens = undefined;
|
|
275
276
|
builtMaxTokensLane = "unset";
|
|
276
277
|
}
|
|
277
|
-
const { body: reasoningBody, effort } = applyReasoningToRequest({ api: "openai-responses", model, level: options?.reasoning, body });
|
|
278
|
+
const { body: reasoningBody, effort, carried } = applyReasoningToRequest({ api: "openai-responses", model, level: options?.reasoning, body });
|
|
278
279
|
const headers = mergeHeaders(modelHeaders, config.headers, optionsHeaders);
|
|
279
280
|
applyRouteCredentialHeaders(headers, routeCredential);
|
|
280
281
|
const declared = declaredRequestValues([modelHeaders, config.headers, optionsHeaders, headers], [], apiKey);
|
|
@@ -292,6 +293,7 @@ export function createOpenResponsesBrain(given = {}) {
|
|
|
292
293
|
route: requestRouteOf(routeCredential, rootOrigin),
|
|
293
294
|
outputCapTokens: effectiveOutputCap(wire, OUTPUT_CAP_KEYS.responses),
|
|
294
295
|
capDerivedPaths: OUTPUT_CAP_KEYS.responses,
|
|
296
|
+
reasoning: requestReasoning(options?.reasoning, carried),
|
|
295
297
|
onCommitted: () => {
|
|
296
298
|
routeAdmission();
|
|
297
299
|
sentMaxTokens = builtMaxTokens;
|
package/dist/brain/openai.js
CHANGED
|
@@ -14,6 +14,7 @@ import { requestRouteOf } from "./request-route.js";
|
|
|
14
14
|
import { reasoningTokensOf } from "./usage-reasoning.js";
|
|
15
15
|
import { usageOfStatement } from "./usage-reading.js";
|
|
16
16
|
import { applyReasoningToRequest } from "./reasoning-request.js";
|
|
17
|
+
import { requestReasoning } from "./reasoning-stamp.js";
|
|
17
18
|
import { runStreamingBrain } from "./stream-engine.js";
|
|
18
19
|
import { refuseRetiredTimeoutKnobs } from "./timeout.js";
|
|
19
20
|
import { resolveFetch } from "./transport.js";
|
|
@@ -358,7 +359,7 @@ export function createOpenAIBrain(given = {}) {
|
|
|
358
359
|
}
|
|
359
360
|
if (options?.stop)
|
|
360
361
|
body.stop = options.stop;
|
|
361
|
-
const { body: reasoningBody } = applyReasoningToRequest({ api: "openai-completions", model, level: options?.reasoning, body });
|
|
362
|
+
const { body: reasoningBody, carried } = applyReasoningToRequest({ api: "openai-completions", model, level: options?.reasoning, body });
|
|
362
363
|
const headers = mergeHeaders(modelHeaders, config.headers, optionsHeaders);
|
|
363
364
|
applyRouteCredentialHeaders(headers, routeCredential);
|
|
364
365
|
const declaredValues = declaredRequestValues([modelHeaders, config.headers, optionsHeaders, headers], [], apiKey);
|
|
@@ -376,6 +377,7 @@ export function createOpenAIBrain(given = {}) {
|
|
|
376
377
|
route: requestRouteOf(routeCredential, rootOrigin),
|
|
377
378
|
outputCapTokens: effectiveOutputCap(wire, OUTPUT_CAP_KEYS.openai),
|
|
378
379
|
capDerivedPaths: [mtField],
|
|
380
|
+
reasoning: requestReasoning(options?.reasoning, carried),
|
|
379
381
|
onCommitted: () => {
|
|
380
382
|
routeAdmission();
|
|
381
383
|
sentMaxTokens = builtMaxTokens;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type FailedBody } from "./errors.js";
|
|
2
2
|
/** The bound on a carried sentence, in code points (cut after the pass, so a cut leaves no part of a credential the pass withheld). */
|
|
3
3
|
export declare const PROVIDER_MESSAGE_MAX_CHARS = 240;
|
|
4
|
-
/** A sentence through the one pass
|
|
5
|
-
|
|
4
|
+
/** A sentence through the one pass, with `asSent` (parts of it the raw-body reading withholds) taken out too; `undefined` for a
|
|
5
|
+
* value that is not a string, or says nothing once the pass has folded it. */
|
|
6
|
+
export declare function providerMessageOf(sentence: unknown, declared: readonly string[], asSent?: readonly string[]): string | undefined;
|
|
6
7
|
/** The sentence a failed response's envelope states, as the engine carries it; `declared` = the request's declared values. */
|
|
7
8
|
export declare function readProviderMessage(body: FailedBody | undefined, declared: readonly string[]): string | undefined;
|
|
8
|
-
/** A value that crossed a seat the engine did not mint (a host Brain's message or status): the same pass, no declared values
|
|
9
|
+
/** A value that crossed a seat the engine did not mint (a host Brain's message or status): the same pass, no declared values,
|
|
10
|
+
* read as written only (no body comes with it). */
|
|
9
11
|
export declare function admittedProviderMessage(value: unknown): string | undefined;
|
|
@@ -1,18 +1,45 @@
|
|
|
1
|
-
import { remoteWords } from "../core/protocol-http-auth.js";
|
|
1
|
+
import { remoteWords, remoteWordsSpans } from "../core/protocol-http-auth.js";
|
|
2
2
|
import { egressCredentialParts, egressText } from "../core/untrusted-egress.js";
|
|
3
|
-
import { inlineUntrusted } from "../core/untrusted-text.js";
|
|
4
|
-
import {
|
|
3
|
+
import { foldToOneLine, inlineUntrusted } from "../core/untrusted-text.js";
|
|
4
|
+
import { statedSentence } from "./errors.js";
|
|
5
5
|
export const PROVIDER_MESSAGE_MAX_CHARS = 240;
|
|
6
|
-
export function providerMessageOf(sentence, declared) {
|
|
6
|
+
export function providerMessageOf(sentence, declared, asSent = []) {
|
|
7
7
|
if (typeof sentence !== "string")
|
|
8
8
|
return undefined;
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const carried = inlineUntrusted(egressText("human", remoteWords(oneLine(sentence), withheld)), PROVIDER_MESSAGE_MAX_CHARS);
|
|
9
|
+
const parts = [...egressCredentialParts(sentence), ...asSent].map(foldToOneLine);
|
|
10
|
+
const carried = inlineUntrusted(egressText("human", remoteWords(foldToOneLine(sentence), declared, parts)), PROVIDER_MESSAGE_MAX_CHARS);
|
|
12
11
|
return carried === "" ? undefined : carried;
|
|
13
12
|
}
|
|
13
|
+
function firstAbove(a, v) {
|
|
14
|
+
let lo = 0;
|
|
15
|
+
let hi = a.length;
|
|
16
|
+
while (lo < hi) {
|
|
17
|
+
const mid = (lo + hi) >> 1;
|
|
18
|
+
if (a[mid] > v)
|
|
19
|
+
hi = mid;
|
|
20
|
+
else
|
|
21
|
+
lo = mid + 1;
|
|
22
|
+
}
|
|
23
|
+
return lo;
|
|
24
|
+
}
|
|
25
|
+
function partsAsSent(body, stated, declared) {
|
|
26
|
+
if (stated.written === undefined)
|
|
27
|
+
return [stated.sentence];
|
|
28
|
+
const { from, to } = stated.written;
|
|
29
|
+
if (from.length === 0)
|
|
30
|
+
return [];
|
|
31
|
+
const parts = [];
|
|
32
|
+
for (const [start, end] of remoteWordsSpans(body.text, declared)) {
|
|
33
|
+
const first = firstAbove(to, start);
|
|
34
|
+
const last = firstAbove(from, end - 1) - 1;
|
|
35
|
+
if (first <= last)
|
|
36
|
+
parts.push(stated.sentence.slice(first, last + 1));
|
|
37
|
+
}
|
|
38
|
+
return parts;
|
|
39
|
+
}
|
|
14
40
|
export function readProviderMessage(body, declared) {
|
|
15
|
-
|
|
41
|
+
const stated = statedSentence(body);
|
|
42
|
+
return stated === undefined || body === undefined ? undefined : providerMessageOf(stated.sentence, declared, partsAsSent(body, stated, declared));
|
|
16
43
|
}
|
|
17
44
|
export function admittedProviderMessage(value) {
|
|
18
45
|
return providerMessageOf(value, []);
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ThinkingLevel } from "../internal/harness-types.js";
|
|
2
|
+
import { type OffCapabilityModel, type ReasoningEffective, type ReasoningFormat, type ReasoningWireFacts, type ResolvedReasoning } from "./reasoning.js";
|
|
2
3
|
/**
|
|
3
4
|
* THE reasoning WIRE applier — the one place that knows how a requested thinking tier is spelled on each
|
|
4
|
-
* wire family. The three brains (completions, Responses,
|
|
5
|
-
* {@link applyReasoningToRequest}, and a host that sends its own request to one
|
|
6
|
-
* generator, a side query) calls the same function with the same model entry, so the keys
|
|
7
|
-
* are the keys the engine would have put there — nothing is re-spelled per caller.
|
|
5
|
+
* wire family, and the one place that says what the spelled keys mean. The three brains (completions, Responses,
|
|
6
|
+
* Messages) build their requests through {@link applyReasoningToRequest}, and a host that sends its own request to one
|
|
7
|
+
* of those endpoints (a title generator, a side query) calls the same function with the same model entry, so the keys
|
|
8
|
+
* it puts on the wire are the keys the engine would have put there — nothing is re-spelled per caller.
|
|
9
|
+
*
|
|
10
|
+
* The arm that writes a request's thinking keys says, in the same step, what they say about the tier
|
|
11
|
+
* ({@link ReasoningCarriage.said}); the reported resolution ({@link resolveReasoning}, {@link resolutionOf}) and the
|
|
12
|
+
* supported-tier read ({@link reasoningEffortLevelsOf}) are readers of that answer, never a second reading of the model.
|
|
8
13
|
*
|
|
9
14
|
* What is decided elsewhere and only READ here: whether the request carries thinking at all
|
|
10
15
|
* ({@link reasoningRequestCarried}), the tier clamp and the `thinkingLevelMap` translation
|
|
@@ -17,9 +22,8 @@ export type ReasoningSeat = "off" | "low";
|
|
|
17
22
|
* spell off ({@link offSpelling})? Yes ⇒ `"off"`, and the output cap needs room for the answer only. No ⇒ `"low"`:
|
|
18
23
|
* a model whose thinking the wire cannot turn off is asked for the least it can grade, and the cap needs room for that
|
|
19
24
|
* thinking too — `AUTO_MODE_CLASSIFIER_LOW_REASONING_BUDGET_TOKENS` is the allowance the engine's own side requests add.
|
|
20
|
-
* A
|
|
21
|
-
*
|
|
22
|
-
* gateway's default, and a default-on gateway thinks.
|
|
25
|
+
* A completions model that does not hold reasoning and declares no `compat.thinkingFormat` is on the `low` seat as
|
|
26
|
+
* well: its wire carries nothing either way, so the request is the gateway's default, and a default-on gateway thinks.
|
|
23
27
|
*
|
|
24
28
|
* Callers pass the seat as `level` to {@link applyReasoningToRequest}; the classifier's seat tier is this verdict.
|
|
25
29
|
*/
|
|
@@ -49,14 +53,35 @@ export interface ApplyReasoningInput {
|
|
|
49
53
|
*/
|
|
50
54
|
api: string;
|
|
51
55
|
model: ReasoningRequestModel;
|
|
52
|
-
/** The requested tier. `"off"` is spelled where the wire has an off spelling; `undefined`
|
|
53
|
-
*
|
|
56
|
+
/** The requested tier. `"off"` is spelled where the wire has an off spelling; `undefined` writes nothing (the provider's
|
|
57
|
+
* default); a value that is not one of the seven tiers is refused (`config.invalid_argument`). */
|
|
54
58
|
level: string | undefined;
|
|
55
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* The request body so far. Never mutated — the result carries a copy. The thinking members of the request's lane are the
|
|
61
|
+
* applier's to write: a body that already carries one is refused (`config.invalid_argument`, `detail.field` = the member's
|
|
62
|
+
* path), whatever the tier. Every other member is kept, and the applier's members are merged into the objects that hold
|
|
63
|
+
* them (`output_config`, `context_management`, `reasoning`, `chat_template_kwargs`).
|
|
64
|
+
*/
|
|
56
65
|
body: Readonly<Record<string, unknown>>;
|
|
57
66
|
/** Messages family only: a body with no numeric `max_tokens` is refused where the budget needs one. */
|
|
58
67
|
budget?: ReasoningBudgetKnobs;
|
|
59
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* What one request's thinking keys say, answered by the arm that wrote them. `said`:
|
|
71
|
+
* · a tier — the keys name it: the explicit `off` (a disable key, or a deployment-declared off value), or an enabled tier
|
|
72
|
+
* carried by the lane's tier key (the effort value after the clamp; on the Messages budget form with no budget knob, the
|
|
73
|
+
* budget the tier's share sized; where Messages declares `effortLevels`, `output_config.effort` is the tier key and the
|
|
74
|
+
* budget is only a token allowance);
|
|
75
|
+
* · `"on"` — the keys turn thinking on and name no tier (a binary enable key, deepseek / together's enable key with no
|
|
76
|
+
* effort, `thinking:{type:"adaptive"}`, a budget a knob fixed, openrouter's `reasoning` object with no effort in it);
|
|
77
|
+
* · `"provider_default"` — no thinking key was written at all.
|
|
78
|
+
*/
|
|
79
|
+
export interface ReasoningCarriage {
|
|
80
|
+
readonly said: ReasoningEffective;
|
|
81
|
+
/** The dialect or lane the keys are spelled in: the completions dialect name, `"responses"`, or on Messages `"effort"`
|
|
82
|
+
* (the entry declares `effortLevels`) / `"budget"`. */
|
|
83
|
+
readonly format: ReasoningFormat;
|
|
84
|
+
}
|
|
60
85
|
export interface AppliedReasoning {
|
|
61
86
|
/** A copy of the input body with the thinking keys written (and, on Messages, `temperature` dropped when thinking is on). */
|
|
62
87
|
body: Record<string, unknown>;
|
|
@@ -66,27 +91,56 @@ export interface AppliedReasoning {
|
|
|
66
91
|
* interleaved thinking — whichever the model entry declares). `{}` where the wire needs none.
|
|
67
92
|
*/
|
|
68
93
|
headers: Record<string, string>;
|
|
69
|
-
/** The effort value the request carries (completions `reasoning_effort
|
|
94
|
+
/** The effort value the request carries (completions `reasoning_effort` / openrouter `reasoning.effort`, Responses
|
|
95
|
+
* `reasoning.effort`, Messages `output_config.effort`), or `undefined`. */
|
|
70
96
|
effort: string | undefined;
|
|
71
|
-
/**
|
|
72
|
-
|
|
97
|
+
/** What the written keys say about the tier ({@link ReasoningCarriage}). */
|
|
98
|
+
carried: ReasoningCarriage;
|
|
73
99
|
}
|
|
74
100
|
/**
|
|
75
|
-
* Write the thinking keys a requested tier needs onto a request body, in the dialect of the model's wire family,
|
|
76
|
-
* say
|
|
77
|
-
* the result carries the body to send and the headers to fold into the
|
|
101
|
+
* Write the thinking keys a requested tier needs onto a request body, in the dialect of the model's wire family, say which
|
|
102
|
+
* headers the keys need, and say what the keys mean ({@link AppliedReasoning.carried}). A pure function of (api, model entry,
|
|
103
|
+
* level, body): the input body is not mutated, the result carries the body to send and the headers to fold into the
|
|
104
|
+
* request's own.
|
|
78
105
|
*
|
|
79
106
|
* It answers the question a host that builds its own request has — "which keys does THIS model take for THIS tier?" —
|
|
80
107
|
* from the same table the engine's brains read, so a host never keeps a copy of a dialect. Absence is meaningful:
|
|
81
108
|
* an enabling tier on a model that does not hold `reasoning`, `off` where the wire has no spelling for it
|
|
82
|
-
* ({@link offSpelling}), a `level` that is `undefined
|
|
83
|
-
*
|
|
109
|
+
* ({@link offSpelling}), a `level` that is `undefined`, and a tier the wire cannot carry write nothing, and the provider's
|
|
110
|
+
* default governs. Refused (`config.invalid_argument`, `detail.field` = the input): a `level` outside the seven tiers, a
|
|
111
|
+
* completions dialect name outside the closed set, a body that already carries one of the lane's thinking members, and on the
|
|
112
|
+
* Messages budget form a body with no `max_tokens` or a cap / knob that does not read as a finite number.
|
|
84
113
|
*
|
|
85
114
|
* @example
|
|
86
115
|
* const { body, headers } = applyReasoningToRequest({ api: model.api, model, level: "low", body: { model: model.id, max_tokens: 2304, messages } });
|
|
87
116
|
* mergeReasoningHeaders(requestHeaders, headers);
|
|
88
117
|
*/
|
|
89
118
|
export declare function applyReasoningToRequest(input: ApplyReasoningInput): AppliedReasoning;
|
|
119
|
+
/**
|
|
120
|
+
* How a tier resolved on one request: a pure function of the tier the request was built for, what its keys say, and the
|
|
121
|
+
* entry's endpoint label. `effective` is the request's `said`; `graded` = it names one of the six enabled tiers; `clamped` =
|
|
122
|
+
* it differs from `requested`; `dropped` = nothing was written (`provider_default`).
|
|
123
|
+
*/
|
|
124
|
+
export declare function resolutionOf(requested: ThinkingLevel, carried: ReasoningCarriage, endpoint: string): ResolvedReasoning;
|
|
125
|
+
/**
|
|
126
|
+
* Resolve a requested intensity against a model entry before any request exists: the wire applier's own answer for a request
|
|
127
|
+
* of that tier, read through {@link resolutionOf} — so the reported resolution and the keys a request carries cannot disagree.
|
|
128
|
+
* `endpoint` is the entry's `api` label. With {@link ReasoningWireFacts} the request is sized at that cap (a hard cap too small
|
|
129
|
+
* for a legal budget skips thinking on the Messages budget form, and the resolution says so); without, at a soft cap.
|
|
130
|
+
*
|
|
131
|
+
* What it cannot see is what only the brain holds — a budget knob from the brain's construction config (a fixed
|
|
132
|
+
* `thinkingBudgetTokens` turns the tier into `on`); a Runner leg's seat corrects to the answer its first request carried.
|
|
133
|
+
* A `requested` outside the seven tiers is refused (`config.invalid_argument`).
|
|
134
|
+
*/
|
|
135
|
+
export declare function resolveReasoning(requested: ThinkingLevel, model: ReasoningRequestModel, facts?: ReasoningWireFacts): ResolvedReasoning;
|
|
136
|
+
/**
|
|
137
|
+
* #692 C-c — the effort tiers that actually REACH THE WIRE for this model, derived from the wire applier: the enabled tiers
|
|
138
|
+
* `t` for which a request of tier `t` carries an effort value and says `t` (not clamped, not suppressed by a `null`
|
|
139
|
+
* levelmap entry, not a switch-only dialect, not a model that holds no reasoning), in rank order. `undefined` means "this
|
|
140
|
+
* wire clamps no tier set" (a switch-only dialect, the Messages budget form with no `effortLevels`), never "unknown": a host
|
|
141
|
+
* that offers a person the supported tiers reads THIS, per model, instead of a global default it cannot vouch for.
|
|
142
|
+
*/
|
|
143
|
+
export declare function reasoningEffortLevelsOf(model: ReasoningRequestModel): readonly ThinkingLevel[] | undefined;
|
|
90
144
|
/**
|
|
91
145
|
* Fold the header patch {@link applyReasoningToRequest} returned into a request's headers, in place. A beta LIST
|
|
92
146
|
* (`anthropic-beta`) is unioned with whatever the request already sends under that name in any letter case and in any
|