@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
|
@@ -1,91 +1,141 @@
|
|
|
1
1
|
import { headerListEntries, lockHeader, takeHeaderSpellings } from "./request-params.js";
|
|
2
|
-
import {
|
|
2
|
+
import { describeRejectedValue } from "../core/tool-search-setting.js";
|
|
3
|
+
import { MIN_THINKING_TOKENS, RESPONSES_APIS, THINKING_LEVELS, budgetCapSkipsThinking, completionsFormatOf, declaredEffortLevels, declaredOffSpelling, judgeThinkingLevel, mintEffortWireValue, offSpelling, reasoningBudgetShare, reasoningRequestCarried, resolveEffort, sanitizeEffortLevels, } from "./reasoning.js";
|
|
3
4
|
export function lowestReasoningSeat(model) {
|
|
4
5
|
return offSpelling(model).spelled ? "off" : "low";
|
|
5
6
|
}
|
|
6
7
|
const BETA_EFFORT = "effort-2025-11-24";
|
|
7
8
|
const BETA_CONTEXT_MANAGEMENT = "context-management-2025-06-27";
|
|
8
9
|
const BETA_INTERLEAVED_THINKING = "interleaved-thinking-2025-05-14";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const CAP_BLIND = MIN_THINKING_TOKENS * 2;
|
|
11
|
+
function saidOf(tier, wrote) {
|
|
12
|
+
if (wrote.tierKey)
|
|
13
|
+
return tier;
|
|
14
|
+
if (wrote.switched)
|
|
15
|
+
return tier === "off" ? "off" : "on";
|
|
16
|
+
return "provider_default";
|
|
17
|
+
}
|
|
18
|
+
function refuseInput(field, sentence) {
|
|
19
|
+
const e = new Error(`applyReasoningToRequest: ${sentence}`);
|
|
20
|
+
e.code = "config.invalid_argument";
|
|
21
|
+
e.detail = { field };
|
|
22
|
+
throw e;
|
|
23
|
+
}
|
|
24
|
+
function refuseBody(field, why, value) {
|
|
25
|
+
return refuseInput(field, `${field} ${why} (got ${describeRejectedValue(value)})`);
|
|
12
26
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
27
|
+
const isPlainObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
28
|
+
function mergeInto(body, key, members) {
|
|
29
|
+
const held = body[key];
|
|
30
|
+
if (held !== undefined && !isPlainObject(held))
|
|
31
|
+
refuseBody(`body.${key}`, "must be an object when present (the thinking keys are written into it)", held);
|
|
32
|
+
body[key] = { ...(held ?? {}), ...members };
|
|
33
|
+
}
|
|
34
|
+
const isThinkingEdit = (edit) => isPlainObject(edit) && typeof edit.type === "string" && edit.type.startsWith("clear_thinking_");
|
|
35
|
+
const OWNED_MEMBERS = {
|
|
36
|
+
completions: ["reasoning_effort", "thinking", "reasoning", "enable_thinking", "chat_template_kwargs.enable_thinking"],
|
|
37
|
+
responses: ["reasoning.effort"],
|
|
38
|
+
messages: ["thinking", "output_config.effort", "context_management.edits"],
|
|
39
|
+
};
|
|
40
|
+
function refuseOwnedMembers(lane, body) {
|
|
41
|
+
for (const path of OWNED_MEMBERS[lane]) {
|
|
42
|
+
const [head, member] = path.split(".");
|
|
43
|
+
const outer = body[head];
|
|
44
|
+
let value = outer;
|
|
45
|
+
if (member !== undefined)
|
|
46
|
+
value = isPlainObject(outer) ? outer[member] : undefined;
|
|
47
|
+
if (path === "context_management.edits")
|
|
48
|
+
value = Array.isArray(value) ? value.find(isThinkingEdit) : undefined;
|
|
49
|
+
if (value !== undefined)
|
|
50
|
+
refuseBody(`body.${path}`, "is written by the applier from the requested tier and may not be supplied in the body", value);
|
|
51
|
+
}
|
|
16
52
|
}
|
|
53
|
+
const wroteNothing = { effort: undefined, switched: false };
|
|
17
54
|
function withEffort(body, effort, supportsEffort) {
|
|
18
55
|
if (!supportsEffort || effort === undefined)
|
|
19
|
-
return
|
|
56
|
+
return wroteNothing;
|
|
20
57
|
body.reasoning_effort = effort;
|
|
21
|
-
return effort;
|
|
58
|
+
return { effort, switched: false };
|
|
59
|
+
}
|
|
60
|
+
function switchedWith(body, key, members) {
|
|
61
|
+
mergeInto(body, key, members);
|
|
62
|
+
return { effort: undefined, switched: true };
|
|
63
|
+
}
|
|
64
|
+
function putSwitch(body, key, value) {
|
|
65
|
+
body[key] = value;
|
|
66
|
+
return { effort: undefined, switched: true };
|
|
22
67
|
}
|
|
23
68
|
const COMPLETIONS_DIALECT = {
|
|
24
69
|
openai: {
|
|
25
70
|
off: (body, model) => {
|
|
26
71
|
const spelling = declaredOffSpelling(model);
|
|
27
|
-
return spelling === undefined ?
|
|
72
|
+
return spelling === undefined ? wroteNothing : withEffort(body, spelling, true);
|
|
28
73
|
},
|
|
29
74
|
on: withEffort,
|
|
30
75
|
},
|
|
31
76
|
openrouter: {
|
|
32
|
-
off: (body) =>
|
|
77
|
+
off: (body) => putSwitch(body, "reasoning", { enabled: false }),
|
|
33
78
|
on: (body, effort) => {
|
|
34
|
-
|
|
35
|
-
return effort;
|
|
79
|
+
putSwitch(body, "reasoning", effort === undefined ? {} : { effort });
|
|
80
|
+
return { effort, switched: true };
|
|
36
81
|
},
|
|
37
82
|
},
|
|
38
83
|
deepseek: {
|
|
39
|
-
off: (body) =>
|
|
84
|
+
off: (body) => putSwitch(body, "thinking", { type: "disabled" }),
|
|
40
85
|
on: (body, effort, supportsEffort) => {
|
|
41
|
-
|
|
42
|
-
return withEffort(body, effort, supportsEffort);
|
|
86
|
+
putSwitch(body, "thinking", { type: "enabled" });
|
|
87
|
+
return { effort: withEffort(body, effort, supportsEffort).effort, switched: true };
|
|
43
88
|
},
|
|
44
89
|
},
|
|
45
90
|
together: {
|
|
46
|
-
off: (body) =>
|
|
91
|
+
off: (body) => putSwitch(body, "reasoning", { enabled: false }),
|
|
47
92
|
on: (body, effort, supportsEffort) => {
|
|
48
|
-
|
|
49
|
-
return withEffort(body, effort, supportsEffort);
|
|
93
|
+
putSwitch(body, "reasoning", { enabled: true });
|
|
94
|
+
return { effort: withEffort(body, effort, supportsEffort).effort, switched: true };
|
|
50
95
|
},
|
|
51
96
|
},
|
|
52
|
-
qwen: { off: (body) =>
|
|
53
|
-
zai: { off: (body) =>
|
|
54
|
-
"qwen-chat-template": {
|
|
97
|
+
qwen: { off: (body) => putSwitch(body, "enable_thinking", false), on: (body) => putSwitch(body, "enable_thinking", true) },
|
|
98
|
+
zai: { off: (body) => putSwitch(body, "enable_thinking", false), on: (body) => putSwitch(body, "enable_thinking", true) },
|
|
99
|
+
"qwen-chat-template": {
|
|
100
|
+
off: (body) => switchedWith(body, "chat_template_kwargs", { enable_thinking: false }),
|
|
101
|
+
on: (body) => switchedWith(body, "chat_template_kwargs", { enable_thinking: true }),
|
|
102
|
+
},
|
|
55
103
|
};
|
|
56
|
-
function
|
|
104
|
+
function applyCompletions(input, level, body) {
|
|
105
|
+
const { model } = input;
|
|
106
|
+
const compat = (model.compat ?? {});
|
|
57
107
|
const format = completionsFormatOf(compat);
|
|
58
|
-
|
|
108
|
+
const dialect = COMPLETIONS_DIALECT[format];
|
|
109
|
+
let tier = "off";
|
|
110
|
+
let wrote = wroteNothing;
|
|
111
|
+
if (level === "off") {
|
|
112
|
+
if (offSpelling(model, input.api).spelled)
|
|
113
|
+
wrote = dialect.off(body, model);
|
|
114
|
+
}
|
|
115
|
+
else if (reasoningRequestCarried(model, level)) {
|
|
116
|
+
const mint = mintEffortWireValue(level, model, compat.reasoningEffortLevels);
|
|
117
|
+
tier = mint.resolution.effective;
|
|
118
|
+
wrote = dialect.on(body, mint.wireValue, compat.supportsReasoningEffort ?? true);
|
|
119
|
+
}
|
|
120
|
+
const said = saidOf(tier, { tierKey: wrote.effort !== undefined, switched: wrote.switched });
|
|
121
|
+
return { body, headers: {}, effort: wrote.effort, carried: { said, format } };
|
|
59
122
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const { model, level } = input;
|
|
123
|
+
function applyResponses(input, level, body) {
|
|
124
|
+
const { model } = input;
|
|
63
125
|
const compat = (model.compat ?? {});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const { model, level } = input;
|
|
75
|
-
const effort = responsesEffort(model, level, input.api);
|
|
126
|
+
let tier = "off";
|
|
127
|
+
let effort;
|
|
128
|
+
if (level === "off") {
|
|
129
|
+
effort = offSpelling(model, input.api).spelled ? declaredOffSpelling(model) : undefined;
|
|
130
|
+
}
|
|
131
|
+
else if (compat.supportsReasoningEffort !== false && reasoningRequestCarried(model, level)) {
|
|
132
|
+
const mint = mintEffortWireValue(level, model, compat.reasoningEffortLevels);
|
|
133
|
+
tier = mint.resolution.effective;
|
|
134
|
+
effort = mint.wireValue;
|
|
135
|
+
}
|
|
76
136
|
if (effort !== undefined)
|
|
77
|
-
body
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
function responsesEffort(model, level, api) {
|
|
81
|
-
if (level === "off")
|
|
82
|
-
return offSpelling(model, api).spelled ? declaredOffSpelling(model) : undefined;
|
|
83
|
-
const compat = (model.compat ?? {});
|
|
84
|
-
if (compat.supportsReasoningEffort === false)
|
|
85
|
-
return undefined;
|
|
86
|
-
if (!reasoningRequestCarried(model, level))
|
|
87
|
-
return undefined;
|
|
88
|
-
return mintEffortWireValue(level, model, compat.reasoningEffortLevels).wireValue;
|
|
137
|
+
mergeInto(body, "reasoning", { effort });
|
|
138
|
+
return { body, headers: {}, effort, carried: { said: saidOf(tier, { tierKey: effort !== undefined, switched: false }), format: "responses" } };
|
|
89
139
|
}
|
|
90
140
|
function thinkingBudget(maxTokens, share, fixed, hardCap) {
|
|
91
141
|
const max = hardCap ? maxTokens : Math.max(maxTokens, MIN_THINKING_TOKENS * 2);
|
|
@@ -93,37 +143,37 @@ function thinkingBudget(maxTokens, share, fixed, hardCap) {
|
|
|
93
143
|
const budget = Math.min(Math.max(MIN_THINKING_TOKENS, want), max - 1);
|
|
94
144
|
return { max, budget };
|
|
95
145
|
}
|
|
96
|
-
function applyMessages(input, body) {
|
|
97
|
-
const { model
|
|
146
|
+
function applyMessages(input, level, body) {
|
|
147
|
+
const { model } = input;
|
|
98
148
|
const compat = (model.compat ?? {});
|
|
99
|
-
|
|
149
|
+
const declaredEffort = declaredEffortLevels(compat.effortLevels);
|
|
150
|
+
let tier = "off";
|
|
100
151
|
let thinkingOn = false;
|
|
152
|
+
let budgetIsTier = false;
|
|
101
153
|
if (reasoningRequestCarried(model, level)) {
|
|
154
|
+
tier = level;
|
|
102
155
|
if (compat.thinkingMode === "adaptive") {
|
|
103
156
|
body.thinking = { type: "adaptive" };
|
|
104
157
|
thinkingOn = true;
|
|
105
158
|
}
|
|
106
159
|
else {
|
|
107
160
|
if (body.max_tokens === undefined || body.max_tokens === null) {
|
|
108
|
-
|
|
161
|
+
refuseInput("body.max_tokens", "the Messages budget form needs a body.max_tokens (it sizes the thinking budget)");
|
|
109
162
|
}
|
|
110
163
|
const maxTokens = body.max_tokens;
|
|
111
164
|
const hardCap = input.budget?.capIsHard ?? true;
|
|
112
|
-
|
|
113
|
-
if (budgetCapSkipsThinking(wireFacts.outputCapTokens, wireFacts.hardOutputCap)) {
|
|
114
|
-
delete body.thinking;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
165
|
+
if (!budgetCapSkipsThinking(maxTokens, hardCap)) {
|
|
117
166
|
const share = input.budget?.share ?? reasoningBudgetShare(level);
|
|
118
167
|
const { max, budget } = thinkingBudget(maxTokens, share, input.budget?.tokens, hardCap);
|
|
119
168
|
if (!Number.isFinite(Number(max)) || !Number.isFinite(budget)) {
|
|
120
169
|
const shown = (value) => (typeof value === "string" ? JSON.stringify(value) : String(value));
|
|
121
|
-
|
|
170
|
+
refuseInput(!Number.isFinite(Number(max)) ? "body.max_tokens" : input.budget?.tokens !== undefined ? "budget.tokens" : "budget.share", `the Messages budget form cannot size a thinking budget from body.max_tokens ${shown(body.max_tokens)}, ` +
|
|
122
171
|
`budget.share ${shown(share)}, budget.tokens ${shown(input.budget?.tokens)} (cap ${shown(max)}, budget ${shown(budget)}); each must read as a finite number`);
|
|
123
172
|
}
|
|
124
173
|
body.max_tokens = max;
|
|
125
174
|
body.thinking = { type: "enabled", budget_tokens: budget };
|
|
126
175
|
thinkingOn = true;
|
|
176
|
+
budgetIsTier = input.budget?.share === undefined && input.budget?.tokens === undefined;
|
|
127
177
|
}
|
|
128
178
|
}
|
|
129
179
|
if (thinkingOn)
|
|
@@ -134,28 +184,70 @@ function applyMessages(input, body) {
|
|
|
134
184
|
}
|
|
135
185
|
const betas = [];
|
|
136
186
|
let effort;
|
|
137
|
-
const declaredEffort = declaredEffortLevels(compat.effortLevels);
|
|
138
187
|
if (declaredEffort !== undefined && reasoningRequestCarried(model, level)) {
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
188
|
+
const tiers = [...new Set(sanitizeEffortLevels(declaredEffort).map((t) => (t === "minimal" ? "low" : t)))];
|
|
189
|
+
tier = resolveEffort(level, tiers).effective;
|
|
190
|
+
effort = tier;
|
|
191
|
+
mergeInto(body, "output_config", { effort });
|
|
142
192
|
betas.push(BETA_EFFORT);
|
|
143
193
|
}
|
|
144
194
|
if (compat.contextManagement && thinkingOn) {
|
|
145
|
-
body.context_management
|
|
195
|
+
const held = body.context_management;
|
|
196
|
+
const edits = isPlainObject(held) ? held.edits : undefined;
|
|
197
|
+
if (edits !== undefined && !Array.isArray(edits))
|
|
198
|
+
refuseBody("body.context_management.edits", "must be an array when present (the thinking edit is written into it)", edits);
|
|
199
|
+
mergeInto(body, "context_management", { edits: [{ type: "clear_thinking_20251015", keep: "all" }, ...(edits ?? [])] });
|
|
146
200
|
betas.push(BETA_CONTEXT_MANAGEMENT);
|
|
147
201
|
}
|
|
148
202
|
if (compat.interleavedThinking)
|
|
149
203
|
betas.push(BETA_INTERLEAVED_THINKING);
|
|
150
|
-
|
|
204
|
+
const said = saidOf(tier, { tierKey: effort !== undefined || budgetIsTier, switched: body.thinking !== undefined });
|
|
205
|
+
return { body, headers: betas.length > 0 ? { "anthropic-beta": betas.join(",") } : {}, effort, carried: { said, format: declaredEffort !== undefined ? "effort" : "budget" } };
|
|
151
206
|
}
|
|
152
207
|
export function applyReasoningToRequest(input) {
|
|
208
|
+
const level = judgeThinkingLevel(input.level, "applyReasoningToRequest.level");
|
|
209
|
+
const lane = input.api === "anthropic-messages" ? "messages" : RESPONSES_APIS.has(input.api) ? "responses" : "completions";
|
|
210
|
+
refuseOwnedMembers(lane, input.body);
|
|
153
211
|
const body = { ...input.body };
|
|
154
|
-
if (
|
|
155
|
-
return applyMessages(input, body);
|
|
156
|
-
if (
|
|
157
|
-
return applyResponses(input, body);
|
|
158
|
-
return applyCompletions(input, body);
|
|
212
|
+
if (lane === "messages")
|
|
213
|
+
return applyMessages(input, level, body);
|
|
214
|
+
if (lane === "responses")
|
|
215
|
+
return applyResponses(input, level, body);
|
|
216
|
+
return applyCompletions(input, level, body);
|
|
217
|
+
}
|
|
218
|
+
export function resolutionOf(requested, carried, endpoint) {
|
|
219
|
+
const effective = carried.said;
|
|
220
|
+
return {
|
|
221
|
+
requested,
|
|
222
|
+
effective,
|
|
223
|
+
graded: effective !== "off" && THINKING_LEVELS.includes(effective),
|
|
224
|
+
clamped: effective !== requested,
|
|
225
|
+
format: carried.format,
|
|
226
|
+
endpoint,
|
|
227
|
+
...(effective === "provider_default" ? { dropped: true } : {}),
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
export function resolveReasoning(requested, model, facts) {
|
|
231
|
+
judgeThinkingLevel(requested, "resolveReasoning.requested");
|
|
232
|
+
const api = model.api ?? "unknown";
|
|
233
|
+
const { carried } = applyReasoningToRequest({
|
|
234
|
+
api,
|
|
235
|
+
model,
|
|
236
|
+
level: requested,
|
|
237
|
+
body: { max_tokens: facts?.outputCapTokens ?? CAP_BLIND },
|
|
238
|
+
budget: { capIsHard: facts?.hardOutputCap ?? false },
|
|
239
|
+
});
|
|
240
|
+
return resolutionOf(requested, carried, api);
|
|
241
|
+
}
|
|
242
|
+
export function reasoningEffortLevelsOf(model) {
|
|
243
|
+
const api = model.api ?? "unknown";
|
|
244
|
+
const honored = THINKING_LEVELS.filter((t) => {
|
|
245
|
+
if (t === "off")
|
|
246
|
+
return false;
|
|
247
|
+
const applied = applyReasoningToRequest({ api, model, level: t, body: { max_tokens: CAP_BLIND }, budget: { capIsHard: false } });
|
|
248
|
+
return applied.effort !== undefined && applied.carried.said === t;
|
|
249
|
+
});
|
|
250
|
+
return honored.length > 0 ? honored : undefined;
|
|
159
251
|
}
|
|
160
252
|
export function mergeReasoningHeaders(headers, patch) {
|
|
161
253
|
for (const [name, value] of Object.entries(patch)) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ThinkingLevel } from "../internal/harness-types.js";
|
|
2
|
+
import type { AssistantMessage, Model } from "../internal/llm.js";
|
|
3
|
+
import type { ReasoningCarriage } from "./reasoning-request.js";
|
|
4
|
+
/**
|
|
5
|
+
* What one request carried for its tier, as its builder hands it to the stream engine (`SSERequest.reasoning`): the tier the
|
|
6
|
+
* request was built for and what its thinking keys say. A request built with no tier carries none — there is nothing to
|
|
7
|
+
* resolve, so the type has no absent tier.
|
|
8
|
+
*/
|
|
9
|
+
export interface RequestReasoning {
|
|
10
|
+
readonly level: ThinkingLevel;
|
|
11
|
+
readonly carried: ReasoningCarriage;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The reasoning stamp on a request's terminal message: the {@link RequestReasoning} of the request the engine committed to
|
|
15
|
+
* send, and the `Model` object the engine was handed for it. A reader judges whose request it was by that object, never by an
|
|
16
|
+
* id (two catalog entries may share a wire id).
|
|
17
|
+
*/
|
|
18
|
+
export interface ReasoningStamp extends RequestReasoning {
|
|
19
|
+
readonly model: Model;
|
|
20
|
+
}
|
|
21
|
+
/** The request's reasoning, when the request was built with a tier; `undefined` when it was built with none. */
|
|
22
|
+
export declare function requestReasoning(level: ThinkingLevel | undefined, carried: ReasoningCarriage): RequestReasoning | undefined;
|
|
23
|
+
/** Stamp a terminal message with the reasoning of the request that produced it (the stream engine's one stamping point). */
|
|
24
|
+
export declare function stampReasoning(message: AssistantMessage, stamp: ReasoningStamp): void;
|
|
25
|
+
/** The reasoning stamp a message carries, if any: only a terminal message the stream engine produced, as that very object. */
|
|
26
|
+
export declare function reasoningStampOf(message: unknown): ReasoningStamp | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const stamps = new WeakMap();
|
|
2
|
+
export function requestReasoning(level, carried) {
|
|
3
|
+
return level === undefined ? undefined : { level, carried };
|
|
4
|
+
}
|
|
5
|
+
export function stampReasoning(message, stamp) {
|
|
6
|
+
stamps.set(message, stamp);
|
|
7
|
+
}
|
|
8
|
+
export function reasoningStampOf(message) {
|
|
9
|
+
return typeof message === "object" && message !== null ? stamps.get(message) : undefined;
|
|
10
|
+
}
|