@pentoshi/clai 4.11.7 → 4.11.9
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/dist/agent/compaction/summary-execution.d.ts +32 -0
- package/dist/agent/compaction/summary-execution.js +407 -0
- package/dist/agent/compaction/summary-execution.js.map +1 -0
- package/dist/agent/compaction-attempt.d.ts +5 -1
- package/dist/agent/compaction-attempt.js +22 -12
- package/dist/agent/compaction-attempt.js.map +1 -1
- package/dist/agent/compaction-executor.d.ts +5 -53
- package/dist/agent/compaction-executor.js +4 -447
- package/dist/agent/compaction-executor.js.map +1 -1
- package/dist/agent/compaction-summary.d.ts +0 -25
- package/dist/agent/compaction-summary.js +0 -20
- package/dist/agent/compaction-summary.js.map +1 -1
- package/dist/agent/confirm-port.d.ts +0 -6
- package/dist/agent/confirm-port.js +0 -11
- package/dist/agent/confirm-port.js.map +1 -1
- package/dist/agent/context/compact-with-summary.d.ts +34 -0
- package/dist/agent/context/compact-with-summary.js +381 -0
- package/dist/agent/context/compact-with-summary.js.map +1 -0
- package/dist/agent/context-breakdown.d.ts +0 -12
- package/dist/agent/context-breakdown.js +0 -16
- package/dist/agent/context-breakdown.js.map +1 -1
- package/dist/agent/context-manager.d.ts +4 -90
- package/dist/agent/context-manager.js +4 -458
- package/dist/agent/context-manager.js.map +1 -1
- package/dist/agent/continue-orient.d.ts +0 -19
- package/dist/agent/continue-orient.js +0 -24
- package/dist/agent/continue-orient.js.map +1 -1
- package/dist/agent/durable-blocks.d.ts +5 -0
- package/dist/agent/durable-blocks.js +16 -0
- package/dist/agent/durable-blocks.js.map +1 -0
- package/dist/agent/durable-envelope.d.ts +0 -2
- package/dist/agent/durable-envelope.js +0 -16
- package/dist/agent/durable-envelope.js.map +1 -1
- package/dist/agent/events.d.ts +6 -17
- package/dist/agent/evidence/task-classification.d.ts +25 -0
- package/dist/agent/evidence/task-classification.js +124 -0
- package/dist/agent/evidence/task-classification.js.map +1 -0
- package/dist/agent/evidence/task-selection.d.ts +29 -0
- package/dist/agent/evidence/task-selection.js +148 -0
- package/dist/agent/evidence/task-selection.js.map +1 -0
- package/dist/agent/evidence/tool-budgets.d.ts +12 -0
- package/dist/agent/evidence/tool-budgets.js +82 -0
- package/dist/agent/evidence/tool-budgets.js.map +1 -0
- package/dist/agent/evidence-governor.d.ts +0 -3
- package/dist/agent/evidence-governor.js.map +1 -1
- package/dist/agent/injected-blocks.d.ts +1 -0
- package/dist/agent/injected-blocks.js +14 -4
- package/dist/agent/injected-blocks.js.map +1 -1
- package/dist/agent/message-slim.js +0 -2
- package/dist/agent/message-slim.js.map +1 -1
- package/dist/agent/outcomes.d.ts +0 -1
- package/dist/agent/outcomes.js +0 -11
- package/dist/agent/outcomes.js.map +1 -1
- package/dist/agent/parser/arg-formatting.d.ts +3 -0
- package/dist/agent/parser/arg-formatting.js +99 -0
- package/dist/agent/parser/arg-formatting.js.map +1 -0
- package/dist/agent/parser/bare-recognition.d.ts +6 -0
- package/dist/agent/parser/bare-recognition.js +106 -0
- package/dist/agent/parser/bare-recognition.js.map +1 -0
- package/dist/agent/parser/parse-entry.d.ts +9 -0
- package/dist/agent/parser/parse-entry.js +198 -0
- package/dist/agent/parser/parse-entry.js.map +1 -0
- package/dist/agent/parser/repetition.d.ts +1 -0
- package/dist/agent/parser/repetition.js +72 -0
- package/dist/agent/parser/repetition.js.map +1 -0
- package/dist/agent/parser/salvage.d.ts +8 -0
- package/dist/agent/parser/salvage.js +100 -0
- package/dist/agent/parser/salvage.js.map +1 -0
- package/dist/agent/parser/vendor-protocols.d.ts +21 -0
- package/dist/agent/parser/vendor-protocols.js +265 -0
- package/dist/agent/parser/vendor-protocols.js.map +1 -0
- package/dist/agent/parser/xml-protocol.d.ts +7 -0
- package/dist/agent/parser/xml-protocol.js +455 -0
- package/dist/agent/parser/xml-protocol.js.map +1 -0
- package/dist/agent/plan/actions/plan-clear.d.ts +4 -0
- package/dist/agent/plan/actions/plan-clear.js +46 -0
- package/dist/agent/plan/actions/plan-clear.js.map +1 -0
- package/dist/agent/plan/actions/plan-create.d.ts +4 -0
- package/dist/agent/plan/actions/plan-create.js +371 -0
- package/dist/agent/plan/actions/plan-create.js.map +1 -0
- package/dist/agent/plan/actions/task-add.d.ts +5 -0
- package/dist/agent/plan/actions/task-add.js +131 -0
- package/dist/agent/plan/actions/task-add.js.map +1 -0
- package/dist/agent/plan/actions/task-move.d.ts +5 -0
- package/dist/agent/plan/actions/task-move.js +72 -0
- package/dist/agent/plan/actions/task-move.js.map +1 -0
- package/dist/agent/plan/context-message.d.ts +2 -0
- package/dist/agent/plan/context-message.js +91 -0
- package/dist/agent/plan/context-message.js.map +1 -0
- package/dist/agent/plan/handle-plan-tool.d.ts +24 -0
- package/dist/agent/plan/handle-plan-tool.js +310 -0
- package/dist/agent/plan/handle-plan-tool.js.map +1 -0
- package/dist/agent/plan/normalization.d.ts +19 -0
- package/dist/agent/plan/normalization.js +175 -0
- package/dist/agent/plan/normalization.js.map +1 -0
- package/dist/agent/plan-implement-compact.d.ts +0 -20
- package/dist/agent/plan-implement-compact.js +0 -21
- package/dist/agent/plan-implement-compact.js.map +1 -1
- package/dist/agent/plan-mode-reminders.d.ts +0 -24
- package/dist/agent/plan-mode-reminders.js +0 -21
- package/dist/agent/plan-mode-reminders.js.map +1 -1
- package/dist/agent/plan-tool.d.ts +5 -60
- package/dist/agent/plan-tool.js +7 -1235
- package/dist/agent/plan-tool.js.map +1 -1
- package/dist/agent/progress-pause-policy.d.ts +0 -1
- package/dist/agent/progress-pause-policy.js +1 -5
- package/dist/agent/progress-pause-policy.js.map +1 -1
- package/dist/agent/progress.d.ts +0 -5
- package/dist/agent/progress.js +0 -14
- package/dist/agent/progress.js.map +1 -1
- package/dist/agent/project-root.d.ts +0 -21
- package/dist/agent/project-root.js +0 -36
- package/dist/agent/project-root.js.map +1 -1
- package/dist/agent/prompt-composer.d.ts +0 -1
- package/dist/agent/prompt-composer.js +0 -2
- package/dist/agent/prompt-composer.js.map +1 -1
- package/dist/agent/reliability-policy.d.ts +0 -41
- package/dist/agent/reliability-policy.js +0 -46
- package/dist/agent/reliability-policy.js.map +1 -1
- package/dist/agent/request-accounting.d.ts +0 -30
- package/dist/agent/request-accounting.js +1 -25
- package/dist/agent/request-accounting.js.map +1 -1
- package/dist/agent/request-budget.d.ts +0 -2
- package/dist/agent/request-budget.js +0 -13
- package/dist/agent/request-budget.js.map +1 -1
- package/dist/agent/responder-context.js +14 -3
- package/dist/agent/responder-context.js.map +1 -1
- package/dist/agent/responder-parent.d.ts +0 -10
- package/dist/agent/responder-parent.js +0 -12
- package/dist/agent/responder-parent.js.map +1 -1
- package/dist/agent/runner.d.ts +0 -30
- package/dist/agent/runner.js +403 -5087
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/scope-context.d.ts +0 -1
- package/dist/agent/scope-context.js +0 -1
- package/dist/agent/scope-context.js.map +1 -1
- package/dist/agent/scratch-write.d.ts +0 -1
- package/dist/agent/scratch-write.js +0 -1
- package/dist/agent/scratch-write.js.map +1 -1
- package/dist/agent/session-policy.d.ts +0 -28
- package/dist/agent/session-policy.js +0 -34
- package/dist/agent/session-policy.js.map +1 -1
- package/dist/agent/session-state.d.ts +0 -38
- package/dist/agent/session-state.js +4 -41
- package/dist/agent/session-state.js.map +1 -1
- package/dist/agent/step-budget.d.ts +0 -4
- package/dist/agent/step-budget.js +0 -4
- package/dist/agent/step-budget.js.map +1 -1
- package/dist/agent/stop-summary.d.ts +0 -5
- package/dist/agent/stop-summary.js +0 -8
- package/dist/agent/stop-summary.js.map +1 -1
- package/dist/agent/stream-recovery.d.ts +1 -54
- package/dist/agent/stream-recovery.js +4 -53
- package/dist/agent/stream-recovery.js.map +1 -1
- package/dist/agent/task-evidence.d.ts +10 -159
- package/dist/agent/task-evidence.js +10 -477
- package/dist/agent/task-evidence.js.map +1 -1
- package/dist/agent/task-plan.d.ts +0 -8
- package/dist/agent/task-plan.js +0 -6
- package/dist/agent/task-plan.js.map +1 -1
- package/dist/agent/task-sync.d.ts +0 -25
- package/dist/agent/task-sync.js +0 -31
- package/dist/agent/task-sync.js.map +1 -1
- package/dist/agent/tool-call-parser.d.ts +10 -205
- package/dist/agent/tool-call-parser.js +11 -1715
- package/dist/agent/tool-call-parser.js.map +1 -1
- package/dist/agent/tool-history.d.ts +1 -57
- package/dist/agent/tool-history.js +1 -68
- package/dist/agent/tool-history.js.map +1 -1
- package/dist/agent/tool-output-formatting.d.ts +0 -18
- package/dist/agent/tool-output-formatting.js +0 -28
- package/dist/agent/tool-output-formatting.js.map +1 -1
- package/dist/agent/turn/automatic-compaction-execution.d.ts +14 -0
- package/dist/agent/turn/automatic-compaction-execution.js +19 -0
- package/dist/agent/turn/automatic-compaction-execution.js.map +1 -0
- package/dist/agent/turn/compaction-admission.d.ts +25 -0
- package/dist/agent/turn/compaction-admission.js +40 -0
- package/dist/agent/turn/compaction-admission.js.map +1 -0
- package/dist/agent/turn/compaction-candidate.d.ts +10 -0
- package/dist/agent/turn/compaction-candidate.js +12 -0
- package/dist/agent/turn/compaction-candidate.js.map +1 -0
- package/dist/agent/turn/compaction-coordinator.d.ts +42 -0
- package/dist/agent/turn/compaction-coordinator.js +169 -0
- package/dist/agent/turn/compaction-coordinator.js.map +1 -0
- package/dist/agent/turn/compaction-durable-envelope.d.ts +24 -0
- package/dist/agent/turn/compaction-durable-envelope.js +54 -0
- package/dist/agent/turn/compaction-durable-envelope.js.map +1 -0
- package/dist/agent/turn/compaction-final-fit.d.ts +10 -0
- package/dist/agent/turn/compaction-final-fit.js +14 -0
- package/dist/agent/turn/compaction-final-fit.js.map +1 -0
- package/dist/agent/turn/compaction-messages.d.ts +6 -0
- package/dist/agent/turn/compaction-messages.js +15 -0
- package/dist/agent/turn/compaction-messages.js.map +1 -0
- package/dist/agent/turn/compaction-replay-selection.d.ts +10 -0
- package/dist/agent/turn/compaction-replay-selection.js +27 -0
- package/dist/agent/turn/compaction-replay-selection.js.map +1 -0
- package/dist/agent/turn/compaction-request-estimator.d.ts +7 -0
- package/dist/agent/turn/compaction-request-estimator.js +13 -0
- package/dist/agent/turn/compaction-request-estimator.js.map +1 -0
- package/dist/agent/turn/compaction-summarizer.d.ts +21 -0
- package/dist/agent/turn/compaction-summarizer.js +41 -0
- package/dist/agent/turn/compaction-summarizer.js.map +1 -0
- package/dist/agent/turn/continuation-overlap.d.ts +1 -0
- package/dist/agent/turn/continuation-overlap.js +35 -0
- package/dist/agent/turn/continuation-overlap.js.map +1 -0
- package/dist/agent/turn/contracts.d.ts +25 -0
- package/dist/agent/turn/contracts.js +2 -0
- package/dist/agent/turn/contracts.js.map +1 -0
- package/dist/agent/turn/event-emitter.d.ts +21 -0
- package/dist/agent/turn/event-emitter.js +116 -0
- package/dist/agent/turn/event-emitter.js.map +1 -0
- package/dist/agent/turn/evidence-flags.d.ts +16 -0
- package/dist/agent/turn/evidence-flags.js +44 -0
- package/dist/agent/turn/evidence-flags.js.map +1 -0
- package/dist/agent/turn/finalizer.d.ts +28 -0
- package/dist/agent/turn/finalizer.js +44 -0
- package/dist/agent/turn/finalizer.js.map +1 -0
- package/dist/agent/turn/history-writer.d.ts +17 -0
- package/dist/agent/turn/history-writer.js +72 -0
- package/dist/agent/turn/history-writer.js.map +1 -0
- package/dist/agent/turn/inserted-text.d.ts +1 -0
- package/dist/agent/turn/inserted-text.js +2 -0
- package/dist/agent/turn/inserted-text.js.map +1 -0
- package/dist/agent/turn/loop/answer-assessment.d.ts +22 -0
- package/dist/agent/turn/loop/answer-assessment.js +30 -0
- package/dist/agent/turn/loop/answer-assessment.js.map +1 -0
- package/dist/agent/turn/loop/answer-path.d.ts +20 -0
- package/dist/agent/turn/loop/answer-path.js +92 -0
- package/dist/agent/turn/loop/answer-path.js.map +1 -0
- package/dist/agent/turn/loop/call-binding.d.ts +17 -0
- package/dist/agent/turn/loop/call-binding.js +42 -0
- package/dist/agent/turn/loop/call-binding.js.map +1 -0
- package/dist/agent/turn/loop/canonicalize-turn-call.d.ts +5 -0
- package/dist/agent/turn/loop/canonicalize-turn-call.js +12 -0
- package/dist/agent/turn/loop/canonicalize-turn-call.js.map +1 -0
- package/dist/agent/turn/loop/completion-interpretation.d.ts +34 -0
- package/dist/agent/turn/loop/completion-interpretation.js +71 -0
- package/dist/agent/turn/loop/completion-interpretation.js.map +1 -0
- package/dist/agent/turn/loop/deps.d.ts +98 -0
- package/dist/agent/turn/loop/deps.js +2 -0
- package/dist/agent/turn/loop/deps.js.map +1 -0
- package/dist/agent/turn/loop/empty-response.d.ts +22 -0
- package/dist/agent/turn/loop/empty-response.js +51 -0
- package/dist/agent/turn/loop/empty-response.js.map +1 -0
- package/dist/agent/turn/loop/final-outcome.d.ts +15 -0
- package/dist/agent/turn/loop/final-outcome.js +49 -0
- package/dist/agent/turn/loop/final-outcome.js.map +1 -0
- package/dist/agent/turn/loop/group-execution.d.ts +14 -0
- package/dist/agent/turn/loop/group-execution.js +44 -0
- package/dist/agent/turn/loop/group-execution.js.map +1 -0
- package/dist/agent/turn/loop/model-only-rounds.d.ts +31 -0
- package/dist/agent/turn/loop/model-only-rounds.js +49 -0
- package/dist/agent/turn/loop/model-only-rounds.js.map +1 -0
- package/dist/agent/turn/loop/native-tool-calls.d.ts +12 -0
- package/dist/agent/turn/loop/native-tool-calls.js +57 -0
- package/dist/agent/turn/loop/native-tool-calls.js.map +1 -0
- package/dist/agent/turn/loop/native-write-salvage.d.ts +18 -0
- package/dist/agent/turn/loop/native-write-salvage.js +92 -0
- package/dist/agent/turn/loop/native-write-salvage.js.map +1 -0
- package/dist/agent/turn/loop/output-budget.d.ts +40 -0
- package/dist/agent/turn/loop/output-budget.js +76 -0
- package/dist/agent/turn/loop/output-budget.js.map +1 -0
- package/dist/agent/turn/loop/plan-call-deferral.d.ts +12 -0
- package/dist/agent/turn/loop/plan-call-deferral.js +32 -0
- package/dist/agent/turn/loop/plan-call-deferral.js.map +1 -0
- package/dist/agent/turn/loop/request-assembly.d.ts +31 -0
- package/dist/agent/turn/loop/request-assembly.js +91 -0
- package/dist/agent/turn/loop/request-assembly.js.map +1 -0
- package/dist/agent/turn/loop/round-closeout.d.ts +56 -0
- package/dist/agent/turn/loop/round-closeout.js +77 -0
- package/dist/agent/turn/loop/round-closeout.js.map +1 -0
- package/dist/agent/turn/loop/round-recorder.d.ts +38 -0
- package/dist/agent/turn/loop/round-recorder.js +71 -0
- package/dist/agent/turn/loop/round-recorder.js.map +1 -0
- package/dist/agent/turn/loop/round-request.d.ts +19 -0
- package/dist/agent/turn/loop/round-request.js +164 -0
- package/dist/agent/turn/loop/round-request.js.map +1 -0
- package/dist/agent/turn/loop/round-state.d.ts +11 -0
- package/dist/agent/turn/loop/round-state.js +11 -0
- package/dist/agent/turn/loop/round-state.js.map +1 -0
- package/dist/agent/turn/loop/run-rounds.d.ts +5 -0
- package/dist/agent/turn/loop/run-rounds.js +661 -0
- package/dist/agent/turn/loop/run-rounds.js.map +1 -0
- package/dist/agent/turn/loop/sequence-suppression.d.ts +54 -0
- package/dist/agent/turn/loop/sequence-suppression.js +112 -0
- package/dist/agent/turn/loop/sequence-suppression.js.map +1 -0
- package/dist/agent/turn/loop/state.d.ts +37 -0
- package/dist/agent/turn/loop/state.js +28 -0
- package/dist/agent/turn/loop/state.js.map +1 -0
- package/dist/agent/turn/loop/stream-failure.d.ts +54 -0
- package/dist/agent/turn/loop/stream-failure.js +146 -0
- package/dist/agent/turn/loop/stream-failure.js.map +1 -0
- package/dist/agent/turn/loop/stream-request.d.ts +16 -0
- package/dist/agent/turn/loop/stream-request.js +21 -0
- package/dist/agent/turn/loop/stream-request.js.map +1 -0
- package/dist/agent/turn/loop/stream-session.d.ts +41 -0
- package/dist/agent/turn/loop/stream-session.js +136 -0
- package/dist/agent/turn/loop/stream-session.js.map +1 -0
- package/dist/agent/turn/loop/tool-call-recovery.d.ts +25 -0
- package/dist/agent/turn/loop/tool-call-recovery.js +162 -0
- package/dist/agent/turn/loop/tool-call-recovery.js.map +1 -0
- package/dist/agent/turn/loop/unrun-calls.d.ts +12 -0
- package/dist/agent/turn/loop/unrun-calls.js +27 -0
- package/dist/agent/turn/loop/unrun-calls.js.map +1 -0
- package/dist/agent/turn/loop/wire-occurrences.d.ts +31 -0
- package/dist/agent/turn/loop/wire-occurrences.js +45 -0
- package/dist/agent/turn/loop/wire-occurrences.js.map +1 -0
- package/dist/agent/turn/mcp-agent-tools.d.ts +17 -0
- package/dist/agent/turn/mcp-agent-tools.js +69 -0
- package/dist/agent/turn/mcp-agent-tools.js.map +1 -0
- package/dist/agent/turn/message-assembly.d.ts +14 -0
- package/dist/agent/turn/message-assembly.js +22 -0
- package/dist/agent/turn/message-assembly.js.map +1 -0
- package/dist/agent/turn/outcome-accounting.d.ts +27 -0
- package/dist/agent/turn/outcome-accounting.js +91 -0
- package/dist/agent/turn/outcome-accounting.js.map +1 -0
- package/dist/agent/turn/plan-mode-gate.d.ts +16 -0
- package/dist/agent/turn/plan-mode-gate.js +36 -0
- package/dist/agent/turn/plan-mode-gate.js.map +1 -0
- package/dist/agent/turn/plan-persistence.d.ts +28 -0
- package/dist/agent/turn/plan-persistence.js +56 -0
- package/dist/agent/turn/plan-persistence.js.map +1 -0
- package/dist/agent/turn/prompt-sections.d.ts +9 -0
- package/dist/agent/turn/prompt-sections.js +67 -0
- package/dist/agent/turn/prompt-sections.js.map +1 -0
- package/dist/agent/turn/responder-claims.d.ts +16 -0
- package/dist/agent/turn/responder-claims.js +37 -0
- package/dist/agent/turn/responder-claims.js.map +1 -0
- package/dist/agent/turn/responder-dependency.d.ts +3 -0
- package/dist/agent/turn/responder-dependency.js +36 -0
- package/dist/agent/turn/responder-dependency.js.map +1 -0
- package/dist/agent/turn/responder-inbox.d.ts +28 -0
- package/dist/agent/turn/responder-inbox.js +57 -0
- package/dist/agent/turn/responder-inbox.js.map +1 -0
- package/dist/agent/turn/responder-job-linkage.d.ts +30 -0
- package/dist/agent/turn/responder-job-linkage.js +124 -0
- package/dist/agent/turn/responder-job-linkage.js.map +1 -0
- package/dist/agent/turn/responder-read-tool.d.ts +26 -0
- package/dist/agent/turn/responder-read-tool.js +83 -0
- package/dist/agent/turn/responder-read-tool.js.map +1 -0
- package/dist/agent/turn/scaffold-outcome.d.ts +7 -0
- package/dist/agent/turn/scaffold-outcome.js +93 -0
- package/dist/agent/turn/scaffold-outcome.js.map +1 -0
- package/dist/agent/turn/scaffold-preflight.d.ts +8 -0
- package/dist/agent/turn/scaffold-preflight.js +31 -0
- package/dist/agent/turn/scaffold-preflight.js.map +1 -0
- package/dist/agent/turn/session-state-projection.d.ts +18 -0
- package/dist/agent/turn/session-state-projection.js +46 -0
- package/dist/agent/turn/session-state-projection.js.map +1 -0
- package/dist/agent/turn/setup/compaction-services.d.ts +55 -0
- package/dist/agent/turn/setup/compaction-services.js +69 -0
- package/dist/agent/turn/setup/compaction-services.js.map +1 -0
- package/dist/agent/turn/setup/evidence-rehydration.d.ts +3 -0
- package/dist/agent/turn/setup/evidence-rehydration.js +22 -0
- package/dist/agent/turn/setup/evidence-rehydration.js.map +1 -0
- package/dist/agent/turn/setup/mcp-agent-ports.d.ts +29 -0
- package/dist/agent/turn/setup/mcp-agent-ports.js +26 -0
- package/dist/agent/turn/setup/mcp-agent-ports.js.map +1 -0
- package/dist/agent/turn/setup/prompt-classification.d.ts +10 -0
- package/dist/agent/turn/setup/prompt-classification.js +18 -0
- package/dist/agent/turn/setup/prompt-classification.js.map +1 -0
- package/dist/agent/turn/setup/responder-wake.d.ts +16 -0
- package/dist/agent/turn/setup/responder-wake.js +18 -0
- package/dist/agent/turn/setup/responder-wake.js.map +1 -0
- package/dist/agent/turn/setup/session-state.d.ts +20 -0
- package/dist/agent/turn/setup/session-state.js +23 -0
- package/dist/agent/turn/setup/session-state.js.map +1 -0
- package/dist/agent/turn/setup/task-gate-setup.d.ts +19 -0
- package/dist/agent/turn/setup/task-gate-setup.js +21 -0
- package/dist/agent/turn/setup/task-gate-setup.js.map +1 -0
- package/dist/agent/turn/setup/turn-budget.d.ts +19 -0
- package/dist/agent/turn/setup/turn-budget.js +34 -0
- package/dist/agent/turn/setup/turn-budget.js.map +1 -0
- package/dist/agent/turn/setup/turn-messages.d.ts +26 -0
- package/dist/agent/turn/setup/turn-messages.js +50 -0
- package/dist/agent/turn/setup/turn-messages.js.map +1 -0
- package/dist/agent/turn/setup/turn-state-machine.d.ts +13 -0
- package/dist/agent/turn/setup/turn-state-machine.js +52 -0
- package/dist/agent/turn/setup/turn-state-machine.js.map +1 -0
- package/dist/agent/turn/system-sections.d.ts +36 -0
- package/dist/agent/turn/system-sections.js +157 -0
- package/dist/agent/turn/system-sections.js.map +1 -0
- package/dist/agent/turn/task-autostart.d.ts +12 -0
- package/dist/agent/turn/task-autostart.js +35 -0
- package/dist/agent/turn/task-autostart.js.map +1 -0
- package/dist/agent/turn/task-batch-guard.d.ts +18 -0
- package/dist/agent/turn/task-batch-guard.js +83 -0
- package/dist/agent/turn/task-batch-guard.js.map +1 -0
- package/dist/agent/turn/task-credit.d.ts +15 -0
- package/dist/agent/turn/task-credit.js +49 -0
- package/dist/agent/turn/task-credit.js.map +1 -0
- package/dist/agent/turn/task-gate.d.ts +13 -0
- package/dist/agent/turn/task-gate.js +34 -0
- package/dist/agent/turn/task-gate.js.map +1 -0
- package/dist/agent/turn/task-update-gate.d.ts +13 -0
- package/dist/agent/turn/task-update-gate.js +40 -0
- package/dist/agent/turn/task-update-gate.js.map +1 -0
- package/dist/agent/turn/task-work-signals.d.ts +3 -0
- package/dist/agent/turn/task-work-signals.js +44 -0
- package/dist/agent/turn/task-work-signals.js.map +1 -0
- package/dist/agent/turn/tool-call-preparation.d.ts +20 -0
- package/dist/agent/turn/tool-call-preparation.js +67 -0
- package/dist/agent/turn/tool-call-preparation.js.map +1 -0
- package/dist/agent/turn/tool-evidence-signals.d.ts +22 -0
- package/dist/agent/turn/tool-evidence-signals.js +101 -0
- package/dist/agent/turn/tool-evidence-signals.js.map +1 -0
- package/dist/agent/turn/tool-execution/authorization.d.ts +32 -0
- package/dist/agent/turn/tool-execution/authorization.js +100 -0
- package/dist/agent/turn/tool-execution/authorization.js.map +1 -0
- package/dist/agent/turn/tool-execution/deps.d.ts +74 -0
- package/dist/agent/turn/tool-execution/deps.js +2 -0
- package/dist/agent/turn/tool-execution/deps.js.map +1 -0
- package/dist/agent/turn/tool-execution/dispatch.d.ts +27 -0
- package/dist/agent/turn/tool-execution/dispatch.js +76 -0
- package/dist/agent/turn/tool-execution/dispatch.js.map +1 -0
- package/dist/agent/turn/tool-execution/engagement-checkpoint.d.ts +7 -0
- package/dist/agent/turn/tool-execution/engagement-checkpoint.js +32 -0
- package/dist/agent/turn/tool-execution/engagement-checkpoint.js.map +1 -0
- package/dist/agent/turn/tool-execution/engagement-gate.d.ts +16 -0
- package/dist/agent/turn/tool-execution/engagement-gate.js +55 -0
- package/dist/agent/turn/tool-execution/engagement-gate.js.map +1 -0
- package/dist/agent/turn/tool-execution/gates.d.ts +21 -0
- package/dist/agent/turn/tool-execution/gates.js +45 -0
- package/dist/agent/turn/tool-execution/gates.js.map +1 -0
- package/dist/agent/turn/tool-execution/guards.d.ts +42 -0
- package/dist/agent/turn/tool-execution/guards.js +62 -0
- package/dist/agent/turn/tool-execution/guards.js.map +1 -0
- package/dist/agent/turn/tool-execution/meta-tools.d.ts +50 -0
- package/dist/agent/turn/tool-execution/meta-tools.js +114 -0
- package/dist/agent/turn/tool-execution/meta-tools.js.map +1 -0
- package/dist/agent/turn/tool-execution/plan-tool-ledger.d.ts +10 -0
- package/dist/agent/turn/tool-execution/plan-tool-ledger.js +50 -0
- package/dist/agent/turn/tool-execution/plan-tool-ledger.js.map +1 -0
- package/dist/agent/turn/tool-execution/result-framing.d.ts +36 -0
- package/dist/agent/turn/tool-execution/result-framing.js +54 -0
- package/dist/agent/turn/tool-execution/result-framing.js.map +1 -0
- package/dist/agent/turn/tool-execution/run-setup.d.ts +29 -0
- package/dist/agent/turn/tool-execution/run-setup.js +64 -0
- package/dist/agent/turn/tool-execution/run-setup.js.map +1 -0
- package/dist/agent/turn/tool-execution/single-tool.d.ts +4 -0
- package/dist/agent/turn/tool-execution/single-tool.js +613 -0
- package/dist/agent/turn/tool-execution/single-tool.js.map +1 -0
- package/dist/agent/turn/tool-execution/state.d.ts +19 -0
- package/dist/agent/turn/tool-execution/state.js +13 -0
- package/dist/agent/turn/tool-execution/state.js.map +1 -0
- package/dist/agent/turn/tool-execution/supervision.d.ts +20 -0
- package/dist/agent/turn/tool-execution/supervision.js +44 -0
- package/dist/agent/turn/tool-execution/supervision.js.map +1 -0
- package/dist/agent/turn/tool-result-recorder.d.ts +26 -0
- package/dist/agent/turn/tool-result-recorder.js +54 -0
- package/dist/agent/turn/tool-result-recorder.js.map +1 -0
- package/dist/agent/turn/tool-routing.d.ts +23 -0
- package/dist/agent/turn/tool-routing.js +58 -0
- package/dist/agent/turn/tool-routing.js.map +1 -0
- package/dist/agent/turn/tool-watchdog.d.ts +22 -0
- package/dist/agent/turn/tool-watchdog.js +135 -0
- package/dist/agent/turn/tool-watchdog.js.map +1 -0
- package/dist/agent/turn/turn-counters.d.ts +9 -0
- package/dist/agent/turn/turn-counters.js +13 -0
- package/dist/agent/turn/turn-counters.js.map +1 -0
- package/dist/agent/turn/workspace-setup.d.ts +29 -0
- package/dist/agent/turn/workspace-setup.js +74 -0
- package/dist/agent/turn/workspace-setup.js.map +1 -0
- package/dist/agent/workspace-orient.d.ts +0 -45
- package/dist/agent/workspace-orient.js +3 -69
- package/dist/agent/workspace-orient.js.map +1 -1
- package/dist/app/adapters/agent-event-adapter.d.ts +0 -1
- package/dist/app/adapters/agent-event-adapter.js +1 -4
- package/dist/app/adapters/agent-event-adapter.js.map +1 -1
- package/dist/app/adapters/current-interactive-sessions-adapter.d.ts +0 -1
- package/dist/app/adapters/current-interactive-sessions-adapter.js +0 -1
- package/dist/app/adapters/current-interactive-sessions-adapter.js.map +1 -1
- package/dist/app/adapters/current-jobs-adapter.d.ts +0 -1
- package/dist/app/adapters/current-jobs-adapter.js +0 -1
- package/dist/app/adapters/current-jobs-adapter.js.map +1 -1
- package/dist/app/adapters/current-store-adapter.d.ts +0 -1
- package/dist/app/adapters/current-store-adapter.js +2 -2
- package/dist/app/adapters/current-store-adapter.js.map +1 -1
- package/dist/app/adapters/quiet-meta-tools.d.ts +0 -11
- package/dist/app/adapters/quiet-meta-tools.js +0 -11
- package/dist/app/adapters/quiet-meta-tools.js.map +1 -1
- package/dist/app/commands/catalog.d.ts +0 -8
- package/dist/app/commands/catalog.js +13 -32
- package/dist/app/commands/catalog.js.map +1 -1
- package/dist/app/commands/command.d.ts +0 -4
- package/dist/app/commands/command.js.map +1 -1
- package/dist/app/commands/registry.d.ts +0 -3
- package/dist/app/commands/registry.js +1 -7
- package/dist/app/commands/registry.js.map +1 -1
- package/dist/app/confirm-prompt-text.d.ts +0 -6
- package/dist/app/confirm-prompt-text.js +0 -6
- package/dist/app/confirm-prompt-text.js.map +1 -1
- package/dist/app/controllers/cancel-all-result.d.ts +0 -5
- package/dist/app/controllers/cancel-all-result.js +0 -5
- package/dist/app/controllers/cancel-all-result.js.map +1 -1
- package/dist/app/controllers/plan-controller.d.ts +0 -6
- package/dist/app/controllers/plan-controller.js +0 -11
- package/dist/app/controllers/plan-controller.js.map +1 -1
- package/dist/app/controllers/session-compact-helper.d.ts +0 -9
- package/dist/app/controllers/session-compact-helper.js +6 -18
- package/dist/app/controllers/session-compact-helper.js.map +1 -1
- package/dist/app/controllers/session-context-usage.d.ts +0 -11
- package/dist/app/controllers/session-context-usage.js +22 -30
- package/dist/app/controllers/session-context-usage.js.map +1 -1
- package/dist/app/controllers/session-controller.d.ts +1 -38
- package/dist/app/controllers/session-controller.js +9 -47
- package/dist/app/controllers/session-controller.js.map +1 -1
- package/dist/app/controllers/session-naming.d.ts +10 -4
- package/dist/app/controllers/session-naming.js +26 -8
- package/dist/app/controllers/session-naming.js.map +1 -1
- package/dist/app/controllers/session-persistence.d.ts +0 -6
- package/dist/app/controllers/session-persistence.js +0 -10
- package/dist/app/controllers/session-persistence.js.map +1 -1
- package/dist/app/controllers/session-responder.js +0 -4
- package/dist/app/controllers/session-responder.js.map +1 -1
- package/dist/app/controllers/session-turn-request.d.ts +0 -1
- package/dist/app/controllers/session-turn-request.js +0 -1
- package/dist/app/controllers/session-turn-request.js.map +1 -1
- package/dist/app/controllers/session-usage-ledger.d.ts +6 -1
- package/dist/app/controllers/session-usage-ledger.js +43 -3
- package/dist/app/controllers/session-usage-ledger.js.map +1 -1
- package/dist/app/controllers/turn-controller.js +2 -6
- package/dist/app/controllers/turn-controller.js.map +1 -1
- package/dist/app/events/app-event.d.ts +1 -11
- package/dist/app/events/app-event.js +0 -1
- package/dist/app/events/app-event.js.map +1 -1
- package/dist/app/events/event-buffer.d.ts +0 -6
- package/dist/app/events/event-buffer.js +0 -6
- package/dist/app/events/event-buffer.js.map +1 -1
- package/dist/app/events/sequencer.d.ts +0 -2
- package/dist/app/events/sequencer.js +0 -1
- package/dist/app/events/sequencer.js.map +1 -1
- package/dist/app/ports/agent-port.d.ts +0 -19
- package/dist/app/ports/interactive-sessions-port.d.ts +0 -13
- package/dist/app/ports/interactive-sessions-port.js +0 -7
- package/dist/app/ports/interactive-sessions-port.js.map +1 -1
- package/dist/app/ports/persistence-port.d.ts +2 -15
- package/dist/app/ports/updates-port.d.ts +0 -5
- package/dist/classic/app/ClassicApp.js +0 -2
- package/dist/classic/app/ClassicApp.js.map +1 -1
- package/dist/classic/app/action-handlers.js +0 -4
- package/dist/classic/app/action-handlers.js.map +1 -1
- package/dist/classic/app/git-branch.js +0 -1
- package/dist/classic/app/git-branch.js.map +1 -1
- package/dist/classic/app/use-feed.d.ts +0 -7
- package/dist/classic/app/use-feed.js +0 -5
- package/dist/classic/app/use-feed.js.map +1 -1
- package/dist/classic/app/wiring-interactions.js +0 -2
- package/dist/classic/app/wiring-interactions.js.map +1 -1
- package/dist/classic/blocks/assistant-lines.d.ts +0 -1
- package/dist/classic/blocks/assistant-lines.js +0 -1
- package/dist/classic/blocks/assistant-lines.js.map +1 -1
- package/dist/classic/blocks/batch-lines.d.ts +0 -1
- package/dist/classic/blocks/batch-lines.js +0 -1
- package/dist/classic/blocks/batch-lines.js.map +1 -1
- package/dist/classic/blocks/block-context.d.ts +0 -7
- package/dist/classic/blocks/block-context.js +0 -1
- package/dist/classic/blocks/block-context.js.map +1 -1
- package/dist/classic/blocks/compacted-lines.d.ts +0 -1
- package/dist/classic/blocks/compacted-lines.js +0 -1
- package/dist/classic/blocks/compacted-lines.js.map +1 -1
- package/dist/classic/blocks/diff-lines.d.ts +0 -3
- package/dist/classic/blocks/diff-lines.js +0 -4
- package/dist/classic/blocks/diff-lines.js.map +1 -1
- package/dist/classic/blocks/intro-lines.d.ts +0 -5
- package/dist/classic/blocks/intro-lines.js +0 -5
- package/dist/classic/blocks/intro-lines.js.map +1 -1
- package/dist/classic/blocks/notice-lines.d.ts +0 -4
- package/dist/classic/blocks/notice-lines.js +0 -6
- package/dist/classic/blocks/notice-lines.js.map +1 -1
- package/dist/classic/blocks/thinking-lines.d.ts +0 -1
- package/dist/classic/blocks/thinking-lines.js +0 -1
- package/dist/classic/blocks/thinking-lines.js.map +1 -1
- package/dist/classic/blocks/tool-lines.d.ts +0 -7
- package/dist/classic/blocks/tool-lines.js +0 -10
- package/dist/classic/blocks/tool-lines.js.map +1 -1
- package/dist/classic/blocks/user-lines.d.ts +0 -1
- package/dist/classic/blocks/user-lines.js +0 -1
- package/dist/classic/blocks/user-lines.js.map +1 -1
- package/dist/classic/bootstrap/osc52-renderer.js +0 -1
- package/dist/classic/bootstrap/osc52-renderer.js.map +1 -1
- package/dist/classic/chrome/Chrome.d.ts +0 -1
- package/dist/classic/chrome/Chrome.js.map +1 -1
- package/dist/classic/chrome/Composer.d.ts +0 -5
- package/dist/classic/chrome/Composer.js +0 -5
- package/dist/classic/chrome/Composer.js.map +1 -1
- package/dist/classic/chrome/composer-controller.js +0 -4
- package/dist/classic/chrome/composer-controller.js.map +1 -1
- package/dist/classic/chrome/composer-frame.d.ts +0 -3
- package/dist/classic/chrome/composer-frame.js +0 -3
- package/dist/classic/chrome/composer-frame.js.map +1 -1
- package/dist/classic/chrome/directory-row.d.ts +0 -7
- package/dist/classic/chrome/directory-row.js +0 -7
- package/dist/classic/chrome/directory-row.js.map +1 -1
- package/dist/classic/chrome/row-budget.d.ts +0 -2
- package/dist/classic/chrome/row-budget.js +0 -8
- package/dist/classic/chrome/row-budget.js.map +1 -1
- package/dist/classic/chrome/status-rows.d.ts +0 -12
- package/dist/classic/chrome/status-rows.js +0 -16
- package/dist/classic/chrome/status-rows.js.map +1 -1
- package/dist/classic/chrome/toast-rows.d.ts +0 -4
- package/dist/classic/chrome/toast-rows.js +0 -9
- package/dist/classic/chrome/toast-rows.js.map +1 -1
- package/dist/classic/feed/Feed.d.ts +0 -5
- package/dist/classic/feed/Feed.js +0 -4
- package/dist/classic/feed/Feed.js.map +1 -1
- package/dist/classic/feed/FeedStatic.d.ts +0 -8
- package/dist/classic/feed/FeedStatic.js +0 -8
- package/dist/classic/feed/FeedStatic.js.map +1 -1
- package/dist/classic/feed/ScrollbarGutter.js +0 -1
- package/dist/classic/feed/ScrollbarGutter.js.map +1 -1
- package/dist/classic/feed/block-height.d.ts +0 -7
- package/dist/classic/feed/block-height.js +0 -7
- package/dist/classic/feed/block-height.js.map +1 -1
- package/dist/classic/feed/commit-ledger.d.ts +0 -12
- package/dist/classic/feed/commit-ledger.js +0 -10
- package/dist/classic/feed/commit-ledger.js.map +1 -1
- package/dist/classic/feed/feed-blocks.d.ts +0 -8
- package/dist/classic/feed/feed-blocks.js +0 -6
- package/dist/classic/feed/feed-blocks.js.map +1 -1
- package/dist/classic/feed/live-tail-policy.d.ts +0 -13
- package/dist/classic/feed/live-tail-policy.js +0 -11
- package/dist/classic/feed/live-tail-policy.js.map +1 -1
- package/dist/classic/feed/scrollbar-rows.d.ts +0 -1
- package/dist/classic/feed/scrollbar-rows.js +0 -1
- package/dist/classic/feed/scrollbar-rows.js.map +1 -1
- package/dist/classic/feed/transcript-window.d.ts +0 -10
- package/dist/classic/feed/transcript-window.js +0 -6
- package/dist/classic/feed/transcript-window.js.map +1 -1
- package/dist/classic/input/input-router.js +0 -2
- package/dist/classic/input/input-router.js.map +1 -1
- package/dist/classic/panels/completion-rows.js +2 -1
- package/dist/classic/panels/completion-rows.js.map +1 -1
- package/dist/classic/panels/keys-panel.d.ts +0 -1
- package/dist/classic/panels/keys-panel.js +0 -1
- package/dist/classic/panels/keys-panel.js.map +1 -1
- package/dist/classic/panels/pager-panel.d.ts +0 -5
- package/dist/classic/panels/pager-panel.js +0 -11
- package/dist/classic/panels/pager-panel.js.map +1 -1
- package/dist/classic/panels/panel-controller.d.ts +0 -2
- package/dist/classic/panels/panel-controller.js +0 -2
- package/dist/classic/panels/panel-controller.js.map +1 -1
- package/dist/classic/panels/panel-frame.js +0 -2
- package/dist/classic/panels/panel-frame.js.map +1 -1
- package/dist/classic/panels/panel-wheel.d.ts +0 -5
- package/dist/classic/panels/panel-wheel.js +0 -5
- package/dist/classic/panels/panel-wheel.js.map +1 -1
- package/dist/classic/panels/secret-panel.d.ts +0 -1
- package/dist/classic/panels/secret-panel.js +0 -1
- package/dist/classic/panels/secret-panel.js.map +1 -1
- package/dist/classic/panels/text-editor-panel.d.ts +0 -1
- package/dist/classic/panels/text-editor-panel.js +0 -1
- package/dist/classic/panels/text-editor-panel.js.map +1 -1
- package/dist/classic/render/ansi-text.d.ts +0 -19
- package/dist/classic/render/ansi-text.js +0 -19
- package/dist/classic/render/ansi-text.js.map +1 -1
- package/dist/classic/render/glyphs.d.ts +0 -4
- package/dist/classic/render/glyphs.js +0 -4
- package/dist/classic/render/glyphs.js.map +1 -1
- package/dist/classic/render/ink-theme.d.ts +0 -10
- package/dist/classic/render/ink-theme.js +0 -6
- package/dist/classic/render/ink-theme.js.map +1 -1
- package/dist/classic/render/measure.d.ts +0 -12
- package/dist/classic/render/measure.js +0 -12
- package/dist/classic/render/measure.js.map +1 -1
- package/dist/classic/render/shell-width.d.ts +0 -8
- package/dist/classic/render/shell-width.js +0 -8
- package/dist/classic/render/shell-width.js.map +1 -1
- package/dist/classic/render/wrap.d.ts +0 -11
- package/dist/classic/render/wrap.js +0 -8
- package/dist/classic/render/wrap.js.map +1 -1
- package/dist/commands/doctor.js +0 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/providers.d.ts +0 -1
- package/dist/commands/providers.js +0 -22
- package/dist/commands/providers.js.map +1 -1
- package/dist/commands/search-providers.d.ts +0 -1
- package/dist/commands/search-providers.js +0 -4
- package/dist/commands/search-providers.js.map +1 -1
- package/dist/commands/update/installers.d.ts +61 -0
- package/dist/commands/update/installers.js +505 -0
- package/dist/commands/update/installers.js.map +1 -0
- package/dist/commands/update-install.d.ts +4 -65
- package/dist/commands/update-install.js +6 -506
- package/dist/commands/update-install.js.map +1 -1
- package/dist/commands/update.d.ts +0 -6
- package/dist/commands/update.js +1 -11
- package/dist/commands/update.js.map +1 -1
- package/dist/index.js +3 -10
- package/dist/index.js.map +1 -1
- package/dist/interactive-session/artifact-writer.d.ts +0 -1
- package/dist/interactive-session/artifact-writer.js +0 -1
- package/dist/interactive-session/artifact-writer.js.map +1 -1
- package/dist/interactive-session/cleanup.d.ts +0 -10
- package/dist/interactive-session/cleanup.js +0 -13
- package/dist/interactive-session/cleanup.js.map +1 -1
- package/dist/interactive-session/config.d.ts +0 -16
- package/dist/interactive-session/config.js +0 -13
- package/dist/interactive-session/config.js.map +1 -1
- package/dist/interactive-session/manager.d.ts +0 -27
- package/dist/interactive-session/manager.js +0 -42
- package/dist/interactive-session/manager.js.map +1 -1
- package/dist/interactive-session/output-store.d.ts +0 -6
- package/dist/interactive-session/output-store.js +0 -5
- package/dist/interactive-session/output-store.js.map +1 -1
- package/dist/interactive-session/output-view.d.ts +0 -4
- package/dist/interactive-session/output-view.js +0 -12
- package/dist/interactive-session/output-view.js.map +1 -1
- package/dist/interactive-session/recovery-journal.d.ts +0 -7
- package/dist/interactive-session/recovery-journal.js +0 -7
- package/dist/interactive-session/recovery-journal.js.map +1 -1
- package/dist/interactive-session/registry.d.ts +0 -25
- package/dist/interactive-session/registry.js +0 -27
- package/dist/interactive-session/registry.js.map +1 -1
- package/dist/interactive-session/runtime.d.ts +0 -30
- package/dist/interactive-session/runtime.js +0 -23
- package/dist/interactive-session/runtime.js.map +1 -1
- package/dist/interactive-session/session-runtime.d.ts +0 -9
- package/dist/interactive-session/session-runtime.js +0 -10
- package/dist/interactive-session/session-runtime.js.map +1 -1
- package/dist/interactive-session/streaming-redactor.d.ts +0 -14
- package/dist/interactive-session/streaming-redactor.js +0 -18
- package/dist/interactive-session/streaming-redactor.js.map +1 -1
- package/dist/interactive-session/telemetry.d.ts +0 -8
- package/dist/interactive-session/telemetry.js +0 -7
- package/dist/interactive-session/telemetry.js.map +1 -1
- package/dist/interactive-session/transport-factory.d.ts +0 -5
- package/dist/interactive-session/transport-factory.js +0 -5
- package/dist/interactive-session/transport-factory.js.map +1 -1
- package/dist/interactive-session/transport-pipe.d.ts +0 -7
- package/dist/interactive-session/transport-pipe.js +0 -14
- package/dist/interactive-session/transport-pipe.js.map +1 -1
- package/dist/interactive-session/transport.d.ts +0 -26
- package/dist/interactive-session/transport.js +0 -20
- package/dist/interactive-session/transport.js.map +1 -1
- package/dist/interactive-session/types.d.ts +0 -19
- package/dist/interactive-session/types.js +0 -22
- package/dist/interactive-session/types.js.map +1 -1
- package/dist/llm/adapters/anthropic-stream-events.d.ts +38 -0
- package/dist/llm/adapters/anthropic-stream-events.js +144 -0
- package/dist/llm/adapters/anthropic-stream-events.js.map +1 -0
- package/dist/llm/adapters/anthropic-tools.d.ts +5 -55
- package/dist/llm/adapters/anthropic-tools.js +6 -208
- package/dist/llm/adapters/anthropic-tools.js.map +1 -1
- package/dist/llm/adapters/anthropic-wire-blocks.d.ts +9 -0
- package/dist/llm/adapters/anthropic-wire-blocks.js +59 -0
- package/dist/llm/adapters/anthropic-wire-blocks.js.map +1 -0
- package/dist/llm/adapters/gemini-tools.d.ts +0 -6
- package/dist/llm/adapters/gemini-tools.js +0 -24
- package/dist/llm/adapters/gemini-tools.js.map +1 -1
- package/dist/llm/adapters/ollama-tools.js +0 -5
- package/dist/llm/adapters/ollama-tools.js.map +1 -1
- package/dist/llm/adapters/openai-tools.d.ts +0 -4
- package/dist/llm/adapters/openai-tools.js +2 -11
- package/dist/llm/adapters/openai-tools.js.map +1 -1
- package/dist/llm/agentrouter.d.ts +0 -9
- package/dist/llm/agentrouter.js +10 -60
- package/dist/llm/agentrouter.js.map +1 -1
- package/dist/llm/anthropic.d.ts +0 -7
- package/dist/llm/anthropic.js +2 -30
- package/dist/llm/anthropic.js.map +1 -1
- package/dist/llm/artifacts/legacy-blocks.d.ts +3 -0
- package/dist/llm/artifacts/legacy-blocks.js +109 -0
- package/dist/llm/artifacts/legacy-blocks.js.map +1 -0
- package/dist/llm/artifacts/replay-selection.d.ts +9 -0
- package/dist/llm/artifacts/replay-selection.js +48 -0
- package/dist/llm/artifacts/replay-selection.js.map +1 -0
- package/dist/llm/aws-mantle.js +2 -4
- package/dist/llm/aws-mantle.js.map +1 -1
- package/dist/llm/bynara.js +2 -0
- package/dist/llm/bynara.js.map +1 -1
- package/dist/llm/cache-affinity.d.ts +1 -0
- package/dist/llm/cache-affinity.js +6 -0
- package/dist/llm/cache-affinity.js.map +1 -1
- package/dist/llm/capabilities.d.ts +7 -36
- package/dist/llm/capabilities.js +11 -502
- package/dist/llm/capabilities.js.map +1 -1
- package/dist/llm/capability/state.d.ts +25 -0
- package/dist/llm/capability/state.js +125 -0
- package/dist/llm/capability/state.js.map +1 -0
- package/dist/llm/capability/tool-dialect.d.ts +3 -0
- package/dist/llm/capability/tool-dialect.js +78 -0
- package/dist/llm/capability/tool-dialect.js.map +1 -0
- package/dist/llm/capability/vision-patterns.d.ts +4 -0
- package/dist/llm/capability/vision-patterns.js +188 -0
- package/dist/llm/capability/vision-patterns.js.map +1 -0
- package/dist/llm/capability/vision-registry.d.ts +20 -0
- package/dist/llm/capability/vision-registry.js +112 -0
- package/dist/llm/capability/vision-registry.js.map +1 -0
- package/dist/llm/context-snapshot.d.ts +0 -18
- package/dist/llm/context-snapshot.js +1 -8
- package/dist/llm/context-snapshot.js.map +1 -1
- package/dist/llm/context-windows.d.ts +0 -6
- package/dist/llm/context-windows.js +0 -30
- package/dist/llm/context-windows.js.map +1 -1
- package/dist/llm/custom-provider-profile.d.ts +4 -23
- package/dist/llm/custom-provider-profile.js +4 -515
- package/dist/llm/custom-provider-profile.js.map +1 -1
- package/dist/llm/custom-providers.d.ts +0 -23
- package/dist/llm/custom-providers.js +2 -27
- package/dist/llm/custom-providers.js.map +1 -1
- package/dist/llm/effort-fallback.d.ts +0 -38
- package/dist/llm/effort-fallback.js +0 -38
- package/dist/llm/effort-fallback.js.map +1 -1
- package/dist/llm/fireworks.js +2 -0
- package/dist/llm/fireworks.js.map +1 -1
- package/dist/llm/free.js +7 -2
- package/dist/llm/free.js.map +1 -1
- package/dist/llm/gemini.d.ts +0 -1
- package/dist/llm/gemini.js +2 -19
- package/dist/llm/gemini.js.map +1 -1
- package/dist/llm/hetzner.js +2 -0
- package/dist/llm/hetzner.js.map +1 -1
- package/dist/llm/http.d.ts +24 -251
- package/dist/llm/http.js +19 -2021
- package/dist/llm/http.js.map +1 -1
- package/dist/llm/key-rotation.d.ts +0 -32
- package/dist/llm/key-rotation.js +6 -37
- package/dist/llm/key-rotation.js.map +1 -1
- package/dist/llm/lightning.d.ts +0 -8
- package/dist/llm/lightning.js +3 -18
- package/dist/llm/lightning.js.map +1 -1
- package/dist/llm/merge-gateway.d.ts +0 -9
- package/dist/llm/merge-gateway.js +2 -44
- package/dist/llm/merge-gateway.js.map +1 -1
- package/dist/llm/modal.js +3 -15
- package/dist/llm/modal.js.map +1 -1
- package/dist/llm/model-families.d.ts +1 -6
- package/dist/llm/model-families.js +2 -5
- package/dist/llm/model-families.js.map +1 -1
- package/dist/llm/model-layers/model-patterns.d.ts +7 -0
- package/dist/llm/model-layers/model-patterns.js +30 -0
- package/dist/llm/model-layers/model-patterns.js.map +1 -0
- package/dist/llm/model-layers/model-rules.d.ts +8 -0
- package/dist/llm/model-layers/model-rules.js +221 -0
- package/dist/llm/model-layers/model-rules.js.map +1 -0
- package/dist/llm/model-layers/nvidia-layer.d.ts +2 -0
- package/dist/llm/model-layers/nvidia-layer.js +135 -0
- package/dist/llm/model-layers/nvidia-layer.js.map +1 -0
- package/dist/llm/nvidia.js +3 -11
- package/dist/llm/nvidia.js.map +1 -1
- package/dist/llm/ollama.js +2 -11
- package/dist/llm/ollama.js.map +1 -1
- package/dist/llm/openai.js +2 -0
- package/dist/llm/openai.js.map +1 -1
- package/dist/llm/openrouter.js +3 -1
- package/dist/llm/openrouter.js.map +1 -1
- package/dist/llm/operation-ledger.d.ts +0 -6
- package/dist/llm/operation-ledger.js +0 -6
- package/dist/llm/operation-ledger.js.map +1 -1
- package/dist/llm/operation-usage.d.ts +2 -0
- package/dist/llm/operation-usage.js +27 -0
- package/dist/llm/operation-usage.js.map +1 -1
- package/dist/llm/orcarouter.d.ts +0 -4
- package/dist/llm/orcarouter.js +3 -26
- package/dist/llm/orcarouter.js.map +1 -1
- package/dist/llm/profile/control-rejections.d.ts +14 -0
- package/dist/llm/profile/control-rejections.js +75 -0
- package/dist/llm/profile/control-rejections.js.map +1 -0
- package/dist/llm/profile/custom-layer.d.ts +3 -0
- package/dist/llm/profile/custom-layer.js +83 -0
- package/dist/llm/profile/custom-layer.js.map +1 -0
- package/dist/llm/profile/layer-merge.d.ts +3 -0
- package/dist/llm/profile/layer-merge.js +185 -0
- package/dist/llm/profile/layer-merge.js.map +1 -0
- package/dist/llm/profile/spec-validation.d.ts +5 -0
- package/dist/llm/profile/spec-validation.js +289 -0
- package/dist/llm/profile/spec-validation.js.map +1 -0
- package/dist/llm/profile/spec-vocabulary.d.ts +21 -0
- package/dist/llm/profile/spec-vocabulary.js +142 -0
- package/dist/llm/profile/spec-vocabulary.js.map +1 -0
- package/dist/llm/provider-identity.d.ts +5 -0
- package/dist/llm/provider-identity.js +130 -0
- package/dist/llm/provider-identity.js.map +1 -0
- package/dist/llm/provider-info-text.d.ts +1 -0
- package/dist/llm/provider-info-text.js +587 -0
- package/dist/llm/provider-info-text.js.map +1 -0
- package/dist/llm/provider-model-layers.d.ts +2 -0
- package/dist/llm/provider-model-layers.js +21 -380
- package/dist/llm/provider-model-layers.js.map +1 -1
- package/dist/llm/provider-profile-layers.js +0 -2
- package/dist/llm/provider-profile-layers.js.map +1 -1
- package/dist/llm/provider-profile.d.ts +10 -12
- package/dist/llm/provider-profile.js +6 -265
- package/dist/llm/provider-profile.js.map +1 -1
- package/dist/llm/provider.d.ts +4 -16
- package/dist/llm/provider.js +6 -760
- package/dist/llm/provider.js.map +1 -1
- package/dist/llm/qwen-cloud.js +2 -4
- package/dist/llm/qwen-cloud.js.map +1 -1
- package/dist/llm/reasoning-artifacts.d.ts +5 -50
- package/dist/llm/reasoning-artifacts.js +11 -198
- package/dist/llm/reasoning-artifacts.js.map +1 -1
- package/dist/llm/reasoning-capability.js +1 -17
- package/dist/llm/reasoning-capability.js.map +1 -1
- package/dist/llm/request-fingerprint.d.ts +0 -4
- package/dist/llm/request-fingerprint.js +0 -4
- package/dist/llm/request-fingerprint.js.map +1 -1
- package/dist/llm/request-plan.d.ts +0 -14
- package/dist/llm/request-plan.js +0 -23
- package/dist/llm/request-plan.js.map +1 -1
- package/dist/llm/responses/item-events.d.ts +3 -0
- package/dist/llm/responses/item-events.js +93 -0
- package/dist/llm/responses/item-events.js.map +1 -0
- package/dist/llm/responses-complete.d.ts +1 -1
- package/dist/llm/responses-complete.js +2 -1
- package/dist/llm/responses-complete.js.map +1 -1
- package/dist/llm/responses-config.js.map +1 -1
- package/dist/llm/responses-http.d.ts +1 -0
- package/dist/llm/responses-http.js +3 -1
- package/dist/llm/responses-http.js.map +1 -1
- package/dist/llm/responses-parse.d.ts +3 -0
- package/dist/llm/responses-parse.js +19 -6
- package/dist/llm/responses-parse.js.map +1 -1
- package/dist/llm/responses-request.d.ts +3 -1
- package/dist/llm/responses-request.js +18 -3
- package/dist/llm/responses-request.js.map +1 -1
- package/dist/llm/responses-shape.d.ts +5 -0
- package/dist/llm/responses-shape.js +16 -0
- package/dist/llm/responses-shape.js.map +1 -0
- package/dist/llm/responses-stream-accumulator.d.ts +1 -1
- package/dist/llm/responses-stream-accumulator.js +8 -9
- package/dist/llm/responses-stream-accumulator.js.map +1 -1
- package/dist/llm/responses-stream-events.d.ts +2 -0
- package/dist/llm/responses-stream-events.js +34 -102
- package/dist/llm/responses-stream-events.js.map +1 -1
- package/dist/llm/responses-stream-watchdog.js.map +1 -1
- package/dist/llm/responses-stream.js +9 -4
- package/dist/llm/responses-stream.js.map +1 -1
- package/dist/llm/router.d.ts +7 -44
- package/dist/llm/router.js +24 -1145
- package/dist/llm/router.js.map +1 -1
- package/dist/llm/routing/attempt-complete.d.ts +3 -0
- package/dist/llm/routing/attempt-complete.js +120 -0
- package/dist/llm/routing/attempt-complete.js.map +1 -0
- package/dist/llm/routing/attempt-request.d.ts +21 -0
- package/dist/llm/routing/attempt-request.js +99 -0
- package/dist/llm/routing/attempt-request.js.map +1 -0
- package/dist/llm/routing/attempt-stream.d.ts +3 -0
- package/dist/llm/routing/attempt-stream.js +256 -0
- package/dist/llm/routing/attempt-stream.js.map +1 -0
- package/dist/llm/routing/error-classification.d.ts +15 -0
- package/dist/llm/routing/error-classification.js +151 -0
- package/dist/llm/routing/error-classification.js.map +1 -0
- package/dist/llm/routing/failure-report.d.ts +22 -0
- package/dist/llm/routing/failure-report.js +128 -0
- package/dist/llm/routing/failure-report.js.map +1 -0
- package/dist/llm/routing/key-rotation.d.ts +21 -0
- package/dist/llm/routing/key-rotation.js +207 -0
- package/dist/llm/routing/key-rotation.js.map +1 -0
- package/dist/llm/routing/provider-selection.d.ts +8 -0
- package/dist/llm/routing/provider-selection.js +119 -0
- package/dist/llm/routing/provider-selection.js.map +1 -0
- package/dist/llm/sampling.d.ts +0 -15
- package/dist/llm/sampling.js +0 -9
- package/dist/llm/sampling.js.map +1 -1
- package/dist/llm/session-affinity.d.ts +2 -0
- package/dist/llm/session-affinity.js +9 -0
- package/dist/llm/session-affinity.js.map +1 -0
- package/dist/llm/stream-progress.d.ts +0 -1
- package/dist/llm/stream-progress.js +0 -15
- package/dist/llm/stream-progress.js.map +1 -1
- package/dist/llm/system-messages.d.ts +0 -22
- package/dist/llm/system-messages.js +6 -22
- package/dist/llm/system-messages.js.map +1 -1
- package/dist/llm/token-estimate-calibration.d.ts +0 -6
- package/dist/llm/token-estimate-calibration.js +0 -26
- package/dist/llm/token-estimate-calibration.js.map +1 -1
- package/dist/llm/token-usage.d.ts +8 -69
- package/dist/llm/token-usage.js +10 -257
- package/dist/llm/token-usage.js.map +1 -1
- package/dist/llm/tokenrouter.d.ts +0 -12
- package/dist/llm/tokenrouter.js +3 -14
- package/dist/llm/tokenrouter.js.map +1 -1
- package/dist/llm/tool-protocol.d.ts +3 -22
- package/dist/llm/tool-protocol.js +20 -155
- package/dist/llm/tool-protocol.js.map +1 -1
- package/dist/llm/tool-wire/argument-repair.d.ts +4 -0
- package/dist/llm/tool-wire/argument-repair.js +174 -0
- package/dist/llm/tool-wire/argument-repair.js.map +1 -0
- package/dist/llm/transport-events.d.ts +12 -0
- package/dist/llm/transport-events.js +29 -0
- package/dist/llm/transport-events.js.map +1 -0
- package/dist/llm/usage/provider-parsers.d.ts +11 -0
- package/dist/llm/usage/provider-parsers.js +220 -0
- package/dist/llm/usage/provider-parsers.js.map +1 -0
- package/dist/llm/wire/abort-race.d.ts +1 -0
- package/dist/llm/wire/abort-race.js +34 -0
- package/dist/llm/wire/abort-race.js.map +1 -0
- package/dist/llm/wire/capability-errors.d.ts +11 -0
- package/dist/llm/wire/capability-errors.js +92 -0
- package/dist/llm/wire/capability-errors.js.map +1 -0
- package/dist/llm/wire/chat-body.d.ts +40 -0
- package/dist/llm/wire/chat-body.js +172 -0
- package/dist/llm/wire/chat-body.js.map +1 -0
- package/dist/llm/wire/model-catalog.d.ts +4 -0
- package/dist/llm/wire/model-catalog.js +34 -0
- package/dist/llm/wire/model-catalog.js.map +1 -0
- package/dist/llm/wire/openai-complete.d.ts +27 -0
- package/dist/llm/wire/openai-complete.js +138 -0
- package/dist/llm/wire/openai-complete.js.map +1 -0
- package/dist/llm/wire/openai-stream.d.ts +36 -0
- package/dist/llm/wire/openai-stream.js +665 -0
- package/dist/llm/wire/openai-stream.js.map +1 -0
- package/dist/llm/wire/reasoning-artifacts.d.ts +45 -0
- package/dist/llm/wire/reasoning-artifacts.js +140 -0
- package/dist/llm/wire/reasoning-artifacts.js.map +1 -0
- package/dist/llm/wire/reasoning-payload.d.ts +9 -0
- package/dist/llm/wire/reasoning-payload.js +226 -0
- package/dist/llm/wire/reasoning-payload.js.map +1 -0
- package/dist/llm/wire/response-errors.d.ts +5 -0
- package/dist/llm/wire/response-errors.js +182 -0
- package/dist/llm/wire/response-errors.js.map +1 -0
- package/dist/llm/wire/responses-first.d.ts +30 -0
- package/dist/llm/wire/responses-first.js +366 -0
- package/dist/llm/wire/responses-first.js.map +1 -0
- package/dist/llm/wire/stream-framing.d.ts +38 -0
- package/dist/llm/wire/stream-framing.js +217 -0
- package/dist/llm/wire/stream-framing.js.map +1 -0
- package/dist/mcp/runtime.d.ts +0 -15
- package/dist/mcp/runtime.js +0 -8
- package/dist/mcp/runtime.js.map +1 -1
- package/dist/modes/ask.d.ts +0 -3
- package/dist/modes/ask.js +0 -22
- package/dist/modes/ask.js.map +1 -1
- package/dist/noninteractive/blocks/tool-blocks.d.ts +35 -0
- package/dist/noninteractive/blocks/tool-blocks.js +206 -0
- package/dist/noninteractive/blocks/tool-blocks.js.map +1 -0
- package/dist/noninteractive/readline-prompts.d.ts +0 -21
- package/dist/noninteractive/readline-prompts.js +0 -31
- package/dist/noninteractive/readline-prompts.js.map +1 -1
- package/dist/noninteractive/stdio-confirm-port.d.ts +0 -9
- package/dist/noninteractive/stdio-confirm-port.js +0 -9
- package/dist/noninteractive/stdio-confirm-port.js.map +1 -1
- package/dist/noninteractive/stream-blocks.d.ts +3 -49
- package/dist/noninteractive/stream-blocks.js +14 -234
- package/dist/noninteractive/stream-blocks.js.map +1 -1
- package/dist/noninteractive/stream-renderer.d.ts +0 -10
- package/dist/noninteractive/stream-renderer.js +0 -10
- package/dist/noninteractive/stream-renderer.js.map +1 -1
- package/dist/noninteractive/stream-spinner.d.ts +0 -8
- package/dist/noninteractive/stream-spinner.js +0 -8
- package/dist/noninteractive/stream-spinner.js.map +1 -1
- package/dist/os/bun-runtime.d.ts +0 -15
- package/dist/os/bun-runtime.js +0 -33
- package/dist/os/bun-runtime.js.map +1 -1
- package/dist/os/command.d.ts +0 -6
- package/dist/os/command.js +0 -13
- package/dist/os/command.js.map +1 -1
- package/dist/os/cwd.d.ts +0 -5
- package/dist/os/cwd.js +0 -6
- package/dist/os/cwd.js.map +1 -1
- package/dist/os/permissions.d.ts +0 -11
- package/dist/os/permissions.js +0 -13
- package/dist/os/permissions.js.map +1 -1
- package/dist/os/process-identity.d.ts +0 -22
- package/dist/os/process-identity.js +0 -23
- package/dist/os/process-identity.js.map +1 -1
- package/dist/os/process-tree.d.ts +0 -7
- package/dist/os/process-tree.js +0 -8
- package/dist/os/process-tree.js.map +1 -1
- package/dist/prompts/index.d.ts +0 -36
- package/dist/prompts/index.js +0 -46
- package/dist/prompts/index.js.map +1 -1
- package/dist/safety/classifier.d.ts +5 -26
- package/dist/safety/classifier.js +5 -573
- package/dist/safety/classifier.js.map +1 -1
- package/dist/safety/engagement-policy.d.ts +0 -13
- package/dist/safety/engagement-policy.js +0 -32
- package/dist/safety/engagement-policy.js.map +1 -1
- package/dist/safety/patterns.d.ts +0 -108
- package/dist/safety/patterns.js +0 -159
- package/dist/safety/patterns.js.map +1 -1
- package/dist/safety/shell-classification.d.ts +19 -0
- package/dist/safety/shell-classification.js +215 -0
- package/dist/safety/shell-classification.js.map +1 -0
- package/dist/safety/tool-classification.d.ts +4 -0
- package/dist/safety/tool-classification.js +260 -0
- package/dist/safety/tool-classification.js.map +1 -0
- package/dist/store/config/endpoints.d.ts +86 -0
- package/dist/store/config/endpoints.js +297 -0
- package/dist/store/config/endpoints.js.map +1 -0
- package/dist/store/config/settings.d.ts +11 -0
- package/dist/store/config/settings.js +52 -0
- package/dist/store/config/settings.js.map +1 -0
- package/dist/store/config.d.ts +6 -169
- package/dist/store/config.js +4 -411
- package/dist/store/config.js.map +1 -1
- package/dist/store/engagement.d.ts +0 -1
- package/dist/store/engagement.js +0 -3
- package/dist/store/engagement.js.map +1 -1
- package/dist/store/history/jsonl-backend.d.ts +7 -0
- package/dist/store/history/jsonl-backend.js +151 -0
- package/dist/store/history/jsonl-backend.js.map +1 -0
- package/dist/store/history/jsonl-lock.d.ts +2 -0
- package/dist/store/history/jsonl-lock.js +100 -0
- package/dist/store/history/jsonl-lock.js.map +1 -0
- package/dist/store/history/lifecycle.d.ts +14 -0
- package/dist/store/history/lifecycle.js +316 -0
- package/dist/store/history/lifecycle.js.map +1 -0
- package/dist/store/history/recovery.d.ts +63 -0
- package/dist/store/history/recovery.js +253 -0
- package/dist/store/history/recovery.js.map +1 -0
- package/dist/store/history/session-queries.d.ts +9 -0
- package/dist/store/history/session-queries.js +142 -0
- package/dist/store/history/session-queries.js.map +1 -0
- package/dist/store/history/sqlite-backend.d.ts +26 -0
- package/dist/store/history/sqlite-backend.js +212 -0
- package/dist/store/history/sqlite-backend.js.map +1 -0
- package/dist/store/history-index.d.ts +0 -5
- package/dist/store/history-index.js +0 -10
- package/dist/store/history-index.js.map +1 -1
- package/dist/store/history.d.ts +12 -97
- package/dist/store/history.js +12 -1214
- package/dist/store/history.js.map +1 -1
- package/dist/store/keys/search-providers.d.ts +33 -0
- package/dist/store/keys/search-providers.js +211 -0
- package/dist/store/keys/search-providers.js.map +1 -0
- package/dist/store/keys/secret-store.d.ts +40 -0
- package/dist/store/keys/secret-store.js +249 -0
- package/dist/store/keys/secret-store.js.map +1 -0
- package/dist/store/keys.d.ts +8 -95
- package/dist/store/keys.js +7 -537
- package/dist/store/keys.js.map +1 -1
- package/dist/store/logs.d.ts +0 -1
- package/dist/store/logs.js +1 -7
- package/dist/store/logs.js.map +1 -1
- package/dist/store/paths.d.ts +0 -12
- package/dist/store/paths.js +0 -12
- package/dist/store/paths.js.map +1 -1
- package/dist/store/plan/jsonl-backend.d.ts +7 -0
- package/dist/store/plan/jsonl-backend.js +115 -0
- package/dist/store/plan/jsonl-backend.js.map +1 -0
- package/dist/store/plan/mutation.d.ts +25 -0
- package/dist/store/plan/mutation.js +270 -0
- package/dist/store/plan/mutation.js.map +1 -0
- package/dist/store/plan/sqlite-backend.d.ts +66 -0
- package/dist/store/plan/sqlite-backend.js +66 -0
- package/dist/store/plan/sqlite-backend.js.map +1 -0
- package/dist/store/plan/task-normalization.d.ts +8 -0
- package/dist/store/plan/task-normalization.js +165 -0
- package/dist/store/plan/task-normalization.js.map +1 -0
- package/dist/store/plan.d.ts +9 -176
- package/dist/store/plan.js +11 -742
- package/dist/store/plan.js.map +1 -1
- package/dist/store/project.js +0 -5
- package/dist/store/project.js.map +1 -1
- package/dist/store/responder-settlement.d.ts +0 -1
- package/dist/store/responder-settlement.js +0 -3
- package/dist/store/responder-settlement.js.map +1 -1
- package/dist/store/scope.d.ts +0 -16
- package/dist/store/scope.js +0 -22
- package/dist/store/scope.js.map +1 -1
- package/dist/store/session-model.d.ts +2 -1
- package/dist/store/session-model.js +27 -1
- package/dist/store/session-model.js.map +1 -1
- package/dist/store/session-workspace.d.ts +0 -51
- package/dist/store/session-workspace.js +0 -57
- package/dist/store/session-workspace.js.map +1 -1
- package/dist/store/task-transitions.d.ts +0 -7
- package/dist/store/task-transitions.js +0 -6
- package/dist/store/task-transitions.js.map +1 -1
- package/dist/tools/batch/batch-parsing.d.ts +11 -0
- package/dist/tools/batch/batch-parsing.js +78 -0
- package/dist/tools/batch/batch-parsing.js.map +1 -0
- package/dist/tools/batch/limits.d.ts +6 -0
- package/dist/tools/batch/limits.js +17 -0
- package/dist/tools/batch/limits.js.map +1 -0
- package/dist/tools/batch/run-batch.d.ts +3 -0
- package/dist/tools/batch/run-batch.js +402 -0
- package/dist/tools/batch/run-batch.js.map +1 -0
- package/dist/tools/batch-fail-policy.d.ts +0 -29
- package/dist/tools/batch-fail-policy.js +0 -31
- package/dist/tools/batch-fail-policy.js.map +1 -1
- package/dist/tools/call-normalization.d.ts +2 -0
- package/dist/tools/call-normalization.js +165 -0
- package/dist/tools/call-normalization.js.map +1 -0
- package/dist/tools/capabilities.d.ts +0 -1
- package/dist/tools/capabilities.js +0 -28
- package/dist/tools/capabilities.js.map +1 -1
- package/dist/tools/command-intent.d.ts +0 -19
- package/dist/tools/command-intent.js +0 -65
- package/dist/tools/command-intent.js.map +1 -1
- package/dist/tools/definitions/aggregate.d.ts +2 -0
- package/dist/tools/definitions/aggregate.js +263 -0
- package/dist/tools/definitions/aggregate.js.map +1 -0
- package/dist/tools/definitions/context-1.d.ts +2 -0
- package/dist/tools/definitions/context-1.js +8 -0
- package/dist/tools/definitions/context-1.js.map +1 -0
- package/dist/tools/definitions/context-2.d.ts +2 -0
- package/dist/tools/definitions/context-2.js +90 -0
- package/dist/tools/definitions/context-2.js.map +1 -0
- package/dist/tools/definitions/define.d.ts +7 -0
- package/dist/tools/definitions/define.js +53 -0
- package/dist/tools/definitions/define.js.map +1 -0
- package/dist/tools/definitions/files.d.ts +2 -0
- package/dist/tools/definitions/files.js +193 -0
- package/dist/tools/definitions/files.js.map +1 -0
- package/dist/tools/definitions/network-1.d.ts +2 -0
- package/dist/tools/definitions/network-1.js +72 -0
- package/dist/tools/definitions/network-1.js.map +1 -0
- package/dist/tools/definitions/network-2.d.ts +2 -0
- package/dist/tools/definitions/network-2.js +22 -0
- package/dist/tools/definitions/network-2.js.map +1 -0
- package/dist/tools/definitions/orchestration.d.ts +2 -0
- package/dist/tools/definitions/orchestration.js +122 -0
- package/dist/tools/definitions/orchestration.js.map +1 -0
- package/dist/tools/definitions/pentest.d.ts +2 -0
- package/dist/tools/definitions/pentest.js +91 -0
- package/dist/tools/definitions/pentest.js.map +1 -0
- package/dist/tools/definitions/selection.d.ts +9 -0
- package/dist/tools/definitions/selection.js +84 -0
- package/dist/tools/definitions/selection.js.map +1 -0
- package/dist/tools/definitions/shell.d.ts +2 -0
- package/dist/tools/definitions/shell.js +83 -0
- package/dist/tools/definitions/shell.js.map +1 -0
- package/dist/tools/definitions/terminal.d.ts +2 -0
- package/dist/tools/definitions/terminal.js +91 -0
- package/dist/tools/definitions/terminal.js.map +1 -0
- package/dist/tools/definitions/web-1.d.ts +2 -0
- package/dist/tools/definitions/web-1.js +68 -0
- package/dist/tools/definitions/web-1.js.map +1 -0
- package/dist/tools/definitions/web-2.d.ts +2 -0
- package/dist/tools/definitions/web-2.js +59 -0
- package/dist/tools/definitions/web-2.js.map +1 -0
- package/dist/tools/definitions.d.ts +3 -16
- package/dist/tools/definitions.js +8 -1238
- package/dist/tools/definitions.js.map +1 -1
- package/dist/tools/diff/line-ops.d.ts +34 -0
- package/dist/tools/diff/line-ops.js +218 -0
- package/dist/tools/diff/line-ops.js.map +1 -0
- package/dist/tools/dns-native.d.ts +0 -5
- package/dist/tools/dns-native.js +0 -16
- package/dist/tools/dns-native.js.map +1 -1
- package/dist/tools/external-tools.d.ts +0 -8
- package/dist/tools/external-tools.js.map +1 -1
- package/dist/tools/file-diff.d.ts +3 -78
- package/dist/tools/file-diff.js +2 -271
- package/dist/tools/file-diff.js.map +1 -1
- package/dist/tools/fs/internals-2.d.ts +1 -0
- package/dist/tools/fs/internals-2.js +6 -0
- package/dist/tools/fs/internals-2.js.map +1 -0
- package/dist/tools/fs/internals.d.ts +4 -0
- package/dist/tools/fs/internals.js +23 -0
- package/dist/tools/fs/internals.js.map +1 -0
- package/dist/tools/fs/mutations.d.ts +17 -0
- package/dist/tools/fs/mutations.js +396 -0
- package/dist/tools/fs/mutations.js.map +1 -0
- package/dist/tools/fs/read-window.d.ts +14 -0
- package/dist/tools/fs/read-window.js +288 -0
- package/dist/tools/fs/read-window.js.map +1 -0
- package/dist/tools/fs/read.d.ts +7 -0
- package/dist/tools/fs/read.js +164 -0
- package/dist/tools/fs/read.js.map +1 -0
- package/dist/tools/fs/search.d.ts +13 -0
- package/dist/tools/fs/search.js +125 -0
- package/dist/tools/fs/search.js.map +1 -0
- package/dist/tools/fs.d.ts +4 -79
- package/dist/tools/fs.js +26 -1115
- package/dist/tools/fs.js.map +1 -1
- package/dist/tools/handlers/args.d.ts +8 -0
- package/dist/tools/handlers/args.js +50 -0
- package/dist/tools/handlers/args.js.map +1 -0
- package/dist/tools/handlers/context-1.d.ts +2 -0
- package/dist/tools/handlers/context-1.js +7 -0
- package/dist/tools/handlers/context-1.js.map +1 -0
- package/dist/tools/handlers/context-2.d.ts +2 -0
- package/dist/tools/handlers/context-2.js +14 -0
- package/dist/tools/handlers/context-2.js.map +1 -0
- package/dist/tools/handlers/files-1.d.ts +2 -0
- package/dist/tools/handlers/files-1.js +51 -0
- package/dist/tools/handlers/files-1.js.map +1 -0
- package/dist/tools/handlers/files-2.d.ts +2 -0
- package/dist/tools/handlers/files-2.js +31 -0
- package/dist/tools/handlers/files-2.js.map +1 -0
- package/dist/tools/handlers/network-1.d.ts +2 -0
- package/dist/tools/handlers/network-1.js +52 -0
- package/dist/tools/handlers/network-1.js.map +1 -0
- package/dist/tools/handlers/network-2.d.ts +2 -0
- package/dist/tools/handlers/network-2.js +32 -0
- package/dist/tools/handlers/network-2.js.map +1 -0
- package/dist/tools/handlers/network-3.d.ts +2 -0
- package/dist/tools/handlers/network-3.js +17 -0
- package/dist/tools/handlers/network-3.js.map +1 -0
- package/dist/tools/handlers/nmap-preparation.d.ts +13 -0
- package/dist/tools/handlers/nmap-preparation.js +66 -0
- package/dist/tools/handlers/nmap-preparation.js.map +1 -0
- package/dist/tools/handlers/orchestration-1.d.ts +2 -0
- package/dist/tools/handlers/orchestration-1.js +7 -0
- package/dist/tools/handlers/orchestration-1.js.map +1 -0
- package/dist/tools/handlers/orchestration-2.d.ts +2 -0
- package/dist/tools/handlers/orchestration-2.js +16 -0
- package/dist/tools/handlers/orchestration-2.js.map +1 -0
- package/dist/tools/handlers/pentest.d.ts +2 -0
- package/dist/tools/handlers/pentest.js +208 -0
- package/dist/tools/handlers/pentest.js.map +1 -0
- package/dist/tools/handlers/responder-job-options.d.ts +3 -0
- package/dist/tools/handlers/responder-job-options.js +16 -0
- package/dist/tools/handlers/responder-job-options.js.map +1 -0
- package/dist/tools/handlers/shell-1.d.ts +2 -0
- package/dist/tools/handlers/shell-1.js +94 -0
- package/dist/tools/handlers/shell-1.js.map +1 -0
- package/dist/tools/handlers/shell-2.d.ts +2 -0
- package/dist/tools/handlers/shell-2.js +49 -0
- package/dist/tools/handlers/shell-2.js.map +1 -0
- package/dist/tools/handlers/shell-3.d.ts +2 -0
- package/dist/tools/handlers/shell-3.js +47 -0
- package/dist/tools/handlers/shell-3.js.map +1 -0
- package/dist/tools/handlers/web.d.ts +2 -0
- package/dist/tools/handlers/web.js +168 -0
- package/dist/tools/handlers/web.js.map +1 -0
- package/dist/tools/http/agents.d.ts +10 -0
- package/dist/tools/http/agents.js +63 -0
- package/dist/tools/http/agents.js.map +1 -0
- package/dist/tools/http/evidence-format.d.ts +37 -0
- package/dist/tools/http/evidence-format.js +181 -0
- package/dist/tools/http/evidence-format.js.map +1 -0
- package/dist/tools/http/fetch.d.ts +31 -0
- package/dist/tools/http/fetch.js +480 -0
- package/dist/tools/http/fetch.js.map +1 -0
- package/dist/tools/http/retry-policy.d.ts +14 -0
- package/dist/tools/http/retry-policy.js +144 -0
- package/dist/tools/http/retry-policy.js.map +1 -0
- package/dist/tools/http.d.ts +1 -45
- package/dist/tools/http.js +1 -920
- package/dist/tools/http.js.map +1 -1
- package/dist/tools/image.d.ts +0 -15
- package/dist/tools/image.js +0 -21
- package/dist/tools/image.js.map +1 -1
- package/dist/tools/interactive-session-tools.d.ts +0 -7
- package/dist/tools/interactive-session-tools.js +0 -13
- package/dist/tools/interactive-session-tools.js.map +1 -1
- package/dist/tools/jobs/helpers.d.ts +6 -0
- package/dist/tools/jobs/helpers.js +63 -0
- package/dist/tools/jobs/helpers.js.map +1 -0
- package/dist/tools/jobs/limits.d.ts +20 -0
- package/dist/tools/jobs/limits.js +21 -0
- package/dist/tools/jobs/limits.js.map +1 -0
- package/dist/tools/jobs/polling-policy.d.ts +11 -0
- package/dist/tools/jobs/polling-policy.js +33 -0
- package/dist/tools/jobs/polling-policy.js.map +1 -0
- package/dist/tools/jobs/process-identity.d.ts +5 -0
- package/dist/tools/jobs/process-identity.js +80 -0
- package/dist/tools/jobs/process-identity.js.map +1 -0
- package/dist/tools/jobs/redacted-writer.d.ts +25 -0
- package/dist/tools/jobs/redacted-writer.js +134 -0
- package/dist/tools/jobs/redacted-writer.js.map +1 -0
- package/dist/tools/jobs/types.d.ts +152 -0
- package/dist/tools/jobs/types.js +2 -0
- package/dist/tools/jobs/types.js.map +1 -0
- package/dist/tools/jobs.d.ts +8 -210
- package/dist/tools/jobs.js +13 -453
- package/dist/tools/jobs.js.map +1 -1
- package/dist/tools/net-ping-sweep.d.ts +0 -8
- package/dist/tools/net-ping-sweep.js +0 -22
- package/dist/tools/net-ping-sweep.js.map +1 -1
- package/dist/tools/network-context.d.ts +0 -4
- package/dist/tools/network-context.js +0 -8
- package/dist/tools/network-context.js.map +1 -1
- package/dist/tools/nmap-runner.d.ts +0 -21
- package/dist/tools/nmap-runner.js +0 -43
- package/dist/tools/nmap-runner.js.map +1 -1
- package/dist/tools/output-selection.d.ts +0 -1
- package/dist/tools/output-selection.js +0 -3
- package/dist/tools/output-selection.js.map +1 -1
- package/dist/tools/package-binary.js +0 -7
- package/dist/tools/package-binary.js.map +1 -1
- package/dist/tools/pdf/read.d.ts +6 -0
- package/dist/tools/pdf/read.js +529 -0
- package/dist/tools/pdf/read.js.map +1 -0
- package/dist/tools/pdf.d.ts +2 -6
- package/dist/tools/pdf.js +1 -528
- package/dist/tools/pdf.js.map +1 -1
- package/dist/tools/pentest-workflows.js +0 -12
- package/dist/tools/pentest-workflows.js.map +1 -1
- package/dist/tools/policies/output-policy.d.ts +0 -17
- package/dist/tools/policies/output-policy.js +0 -18
- package/dist/tools/policies/output-policy.js.map +1 -1
- package/dist/tools/reducers/ffuf.d.ts +0 -5
- package/dist/tools/reducers/ffuf.js +0 -8
- package/dist/tools/reducers/ffuf.js.map +1 -1
- package/dist/tools/reducers/gobuster.js +0 -1
- package/dist/tools/reducers/gobuster.js.map +1 -1
- package/dist/tools/reducers/httpx.js +0 -1
- package/dist/tools/reducers/httpx.js.map +1 -1
- package/dist/tools/reducers/nmap.d.ts +0 -5
- package/dist/tools/reducers/nmap.js +0 -5
- package/dist/tools/reducers/nmap.js.map +1 -1
- package/dist/tools/reducers/nuclei.js +0 -1
- package/dist/tools/reducers/nuclei.js.map +1 -1
- package/dist/tools/reducers/subdomains.d.ts +0 -4
- package/dist/tools/reducers/subdomains.js +0 -4
- package/dist/tools/reducers/subdomains.js.map +1 -1
- package/dist/tools/reducers/types.d.ts +0 -5
- package/dist/tools/registry.d.ts +4 -20
- package/dist/tools/registry.js +36 -1634
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/shell/artifact-name.d.ts +1 -0
- package/dist/tools/shell/artifact-name.js +6 -0
- package/dist/tools/shell/artifact-name.js.map +1 -0
- package/dist/tools/shell/capture.d.ts +31 -0
- package/dist/tools/shell/capture.js +135 -0
- package/dist/tools/shell/capture.js.map +1 -0
- package/dist/tools/shell/exec-attempt.d.ts +10 -0
- package/dist/tools/shell/exec-attempt.js +288 -0
- package/dist/tools/shell/exec-attempt.js.map +1 -0
- package/dist/tools/shell/internals-2.d.ts +16 -0
- package/dist/tools/shell/internals-2.js +48 -0
- package/dist/tools/shell/internals-2.js.map +1 -0
- package/dist/tools/shell/internals.d.ts +10 -0
- package/dist/tools/shell/internals.js +51 -0
- package/dist/tools/shell/internals.js.map +1 -0
- package/dist/tools/shell/spawn-argv.d.ts +17 -0
- package/dist/tools/shell/spawn-argv.js +248 -0
- package/dist/tools/shell/spawn-argv.js.map +1 -0
- package/dist/tools/shell-quoting.d.ts +1 -0
- package/dist/tools/shell-quoting.js +7 -0
- package/dist/tools/shell-quoting.js.map +1 -0
- package/dist/tools/shell.d.ts +4 -82
- package/dist/tools/shell.js +7 -845
- package/dist/tools/shell.js.map +1 -1
- package/dist/tools/sudo-session.d.ts +0 -41
- package/dist/tools/sudo-session.js +0 -44
- package/dist/tools/sudo-session.js.map +1 -1
- package/dist/tools/tool-types.d.ts +0 -7
- package/dist/tools/validate.d.ts +0 -35
- package/dist/tools/validate.js +2 -67
- package/dist/tools/validate.js.map +1 -1
- package/dist/tools/web/audit.d.ts +0 -74
- package/dist/tools/web/audit.js +0 -39
- package/dist/tools/web/audit.js.map +1 -1
- package/dist/tools/web/budget.d.ts +0 -35
- package/dist/tools/web/budget.js +0 -75
- package/dist/tools/web/budget.js.map +1 -1
- package/dist/tools/web/capture.d.ts +0 -106
- package/dist/tools/web/capture.js +0 -148
- package/dist/tools/web/capture.js.map +1 -1
- package/dist/tools/web/decode.d.ts +0 -8
- package/dist/tools/web/decode.js +0 -9
- package/dist/tools/web/decode.js.map +1 -1
- package/dist/tools/web/fetch-core.d.ts +2 -32
- package/dist/tools/web/fetch-core.js +4 -1058
- package/dist/tools/web/fetch-core.js.map +1 -1
- package/dist/tools/web/fetch.d.ts +0 -29
- package/dist/tools/web/fetch.js +0 -46
- package/dist/tools/web/fetch.js.map +1 -1
- package/dist/tools/web/issue-hop.d.ts +57 -0
- package/dist/tools/web/issue-hop.js +396 -0
- package/dist/tools/web/issue-hop.js.map +1 -0
- package/dist/tools/web/providers/brave.d.ts +0 -40
- package/dist/tools/web/providers/brave.js +1 -100
- package/dist/tools/web/providers/brave.js.map +1 -1
- package/dist/tools/web/providers/duckduckgo.d.ts +0 -41
- package/dist/tools/web/providers/duckduckgo.js +0 -104
- package/dist/tools/web/providers/duckduckgo.js.map +1 -1
- package/dist/tools/web/providers/exa.d.ts +0 -43
- package/dist/tools/web/providers/exa.js +1 -102
- package/dist/tools/web/providers/exa.js.map +1 -1
- package/dist/tools/web/providers/provider.d.ts +0 -69
- package/dist/tools/web/providers/provider.js +0 -28
- package/dist/tools/web/providers/provider.js.map +1 -1
- package/dist/tools/web/providers/tavily.d.ts +0 -46
- package/dist/tools/web/providers/tavily.js +1 -111
- package/dist/tools/web/providers/tavily.js.map +1 -1
- package/dist/tools/web/readable.d.ts +0 -62
- package/dist/tools/web/readable.js +1 -132
- package/dist/tools/web/readable.js.map +1 -1
- package/dist/tools/web/redact.d.ts +0 -26
- package/dist/tools/web/redact.js +0 -2
- package/dist/tools/web/redact.js.map +1 -1
- package/dist/tools/web/request-loop.d.ts +38 -0
- package/dist/tools/web/request-loop.js +172 -0
- package/dist/tools/web/request-loop.js.map +1 -0
- package/dist/tools/web/response-body.d.ts +41 -0
- package/dist/tools/web/response-body.js +174 -0
- package/dist/tools/web/response-body.js.map +1 -0
- package/dist/tools/web/search-attempts.d.ts +20 -0
- package/dist/tools/web/search-attempts.js +303 -0
- package/dist/tools/web/search-attempts.js.map +1 -0
- package/dist/tools/web/search.d.ts +0 -33
- package/dist/tools/web/search.js +3 -396
- package/dist/tools/web/search.js.map +1 -1
- package/dist/tools/web/ssrf-guard.d.ts +0 -42
- package/dist/tools/web/ssrf-guard.js +0 -57
- package/dist/tools/web/ssrf-guard.js.map +1 -1
- package/dist/tools/web/types.d.ts +0 -197
- package/dist/tools/web/types.js +0 -41
- package/dist/tools/web/types.js.map +1 -1
- package/dist/tools/web/validate-args.d.ts +11 -0
- package/dist/tools/web/validate-args.js +107 -0
- package/dist/tools/web/validate-args.js.map +1 -0
- package/dist/tools/whois-native.d.ts +0 -4
- package/dist/tools/whois-native.js +0 -6
- package/dist/tools/whois-native.js.map +1 -1
- package/dist/tools/wordlists.js +0 -32
- package/dist/tools/wordlists.js.map +1 -1
- package/dist/tui-v2/app/App.d.ts +0 -10
- package/dist/tui-v2/app/App.js +95 -131
- package/dist/tui-v2/app/App.js.map +1 -1
- package/dist/tui-v2/bootstrap/pager-export.d.ts +0 -8
- package/dist/tui-v2/bootstrap/pager-export.js +0 -11
- package/dist/tui-v2/bootstrap/pager-export.js.map +1 -1
- package/dist/tui-v2/bootstrap/patch-opentui-text.d.ts +0 -5
- package/dist/tui-v2/bootstrap/patch-opentui-text.js +0 -5
- package/dist/tui-v2/bootstrap/patch-opentui-text.js.map +1 -1
- package/dist/tui-v2/bootstrap/resize-repaint.d.ts +16 -20
- package/dist/tui-v2/bootstrap/resize-repaint.js +31 -16
- package/dist/tui-v2/bootstrap/resize-repaint.js.map +1 -1
- package/dist/tui-v2/bootstrap/start-tui-v2.d.ts +0 -7
- package/dist/tui-v2/bootstrap/start-tui-v2.js +39 -38
- package/dist/tui-v2/bootstrap/start-tui-v2.js.map +1 -1
- package/dist/tui-v2/components/completion/completion-menu.d.ts +0 -4
- package/dist/tui-v2/components/completion/completion-menu.js +2 -6
- package/dist/tui-v2/components/completion/completion-menu.js.map +1 -1
- package/dist/tui-v2/components/composer/composer-input-box.d.ts +0 -4
- package/dist/tui-v2/components/composer/composer-input-box.js +1 -10
- package/dist/tui-v2/components/composer/composer-input-box.js.map +1 -1
- package/dist/tui-v2/components/composer/paste-chip.d.ts +0 -7
- package/dist/tui-v2/components/composer/paste-chip.js +0 -7
- package/dist/tui-v2/components/composer/paste-chip.js.map +1 -1
- package/dist/tui-v2/components/jobs/jobs-panel.d.ts +5 -14
- package/dist/tui-v2/components/jobs/jobs-panel.js +8 -37
- package/dist/tui-v2/components/jobs/jobs-panel.js.map +1 -1
- package/dist/tui-v2/components/modal/confirm-modal.d.ts +0 -8
- package/dist/tui-v2/components/modal/confirm-modal.js +0 -4
- package/dist/tui-v2/components/modal/confirm-modal.js.map +1 -1
- package/dist/tui-v2/components/modal/keys-modal.d.ts +0 -11
- package/dist/tui-v2/components/modal/keys-modal.js +0 -24
- package/dist/tui-v2/components/modal/keys-modal.js.map +1 -1
- package/dist/tui-v2/components/modal/prompt-actions-modal.d.ts +0 -6
- package/dist/tui-v2/components/modal/prompt-actions-modal.js +4 -13
- package/dist/tui-v2/components/modal/prompt-actions-modal.js.map +1 -1
- package/dist/tui-v2/components/modal/scope-modal.d.ts +0 -5
- package/dist/tui-v2/components/modal/scope-modal.js +0 -12
- package/dist/tui-v2/components/modal/scope-modal.js.map +1 -1
- package/dist/tui-v2/components/modal/secret-modal.d.ts +0 -8
- package/dist/tui-v2/components/modal/secret-modal.js +0 -17
- package/dist/tui-v2/components/modal/secret-modal.js.map +1 -1
- package/dist/tui-v2/components/modal/text-editor-modal.d.ts +0 -6
- package/dist/tui-v2/components/modal/text-editor-modal.js +0 -6
- package/dist/tui-v2/components/modal/text-editor-modal.js.map +1 -1
- package/dist/tui-v2/components/overlay/overlay-host.d.ts +3 -15
- package/dist/tui-v2/components/overlay/overlay-host.js +6 -3
- package/dist/tui-v2/components/overlay/overlay-host.js.map +1 -1
- package/dist/tui-v2/components/pager/pager-line.d.ts +0 -5
- package/dist/tui-v2/components/pager/pager-line.js +0 -10
- package/dist/tui-v2/components/pager/pager-line.js.map +1 -1
- package/dist/tui-v2/components/pager/pager.d.ts +0 -14
- package/dist/tui-v2/components/pager/pager.js +3 -58
- package/dist/tui-v2/components/pager/pager.js.map +1 -1
- package/dist/tui-v2/components/picker/picker.d.ts +0 -6
- package/dist/tui-v2/components/picker/picker.js +3 -12
- package/dist/tui-v2/components/picker/picker.js.map +1 -1
- package/dist/tui-v2/components/plan/plan-pane-anim.d.ts +0 -25
- package/dist/tui-v2/components/plan/plan-pane-anim.js +0 -23
- package/dist/tui-v2/components/plan/plan-pane-anim.js.map +1 -1
- package/dist/tui-v2/components/plan/plan-view.d.ts +3 -8
- package/dist/tui-v2/components/plan/plan-view.js +5 -22
- package/dist/tui-v2/components/plan/plan-view.js.map +1 -1
- package/dist/tui-v2/components/plan/use-pane-presence.d.ts +0 -9
- package/dist/tui-v2/components/plan/use-pane-presence.js +0 -9
- package/dist/tui-v2/components/plan/use-pane-presence.js.map +1 -1
- package/dist/tui-v2/components/queue/queue-panel.d.ts +3 -13
- package/dist/tui-v2/components/queue/queue-panel.js +8 -5
- package/dist/tui-v2/components/queue/queue-panel.js.map +1 -1
- package/dist/tui-v2/components/status/status-line.d.ts +3 -18
- package/dist/tui-v2/components/status/status-line.js +5 -12
- package/dist/tui-v2/components/status/status-line.js.map +1 -1
- package/dist/tui-v2/components/toast/toast-anim.d.ts +0 -20
- package/dist/tui-v2/components/toast/toast-anim.js +0 -15
- package/dist/tui-v2/components/toast/toast-anim.js.map +1 -1
- package/dist/tui-v2/components/toast/toast-host.d.ts +3 -13
- package/dist/tui-v2/components/toast/toast-host.js +6 -31
- package/dist/tui-v2/components/toast/toast-host.js.map +1 -1
- package/dist/tui-v2/components/transcript/assistant-message.d.ts +0 -11
- package/dist/tui-v2/components/transcript/assistant-message.js +3 -24
- package/dist/tui-v2/components/transcript/assistant-message.js.map +1 -1
- package/dist/tui-v2/components/transcript/compacted-row.d.ts +0 -6
- package/dist/tui-v2/components/transcript/compacted-row.js +2 -6
- package/dist/tui-v2/components/transcript/compacted-row.js.map +1 -1
- package/dist/tui-v2/components/transcript/file-diff-card.d.ts +0 -9
- package/dist/tui-v2/components/transcript/file-diff-card.js +0 -16
- package/dist/tui-v2/components/transcript/file-diff-card.js.map +1 -1
- package/dist/tui-v2/components/transcript/intro-card.d.ts +0 -9
- package/dist/tui-v2/components/transcript/intro-card.js +2 -13
- package/dist/tui-v2/components/transcript/intro-card.js.map +1 -1
- package/dist/tui-v2/components/transcript/linkable-text.d.ts +0 -16
- package/dist/tui-v2/components/transcript/linkable-text.js +0 -11
- package/dist/tui-v2/components/transcript/linkable-text.js.map +1 -1
- package/dist/tui-v2/components/transcript/notice-row.d.ts +0 -7
- package/dist/tui-v2/components/transcript/notice-row.js +2 -18
- package/dist/tui-v2/components/transcript/notice-row.js.map +1 -1
- package/dist/tui-v2/components/transcript/search-bar.d.ts +0 -10
- package/dist/tui-v2/components/transcript/search-bar.js +0 -3
- package/dist/tui-v2/components/transcript/search-bar.js.map +1 -1
- package/dist/tui-v2/components/transcript/selectable-line.d.ts +0 -16
- package/dist/tui-v2/components/transcript/selectable-line.js +0 -9
- package/dist/tui-v2/components/transcript/selectable-line.js.map +1 -1
- package/dist/tui-v2/components/transcript/thinking-block.d.ts +0 -18
- package/dist/tui-v2/components/transcript/thinking-block.js +2 -40
- package/dist/tui-v2/components/transcript/thinking-block.js.map +1 -1
- package/dist/tui-v2/components/transcript/tool-card.d.ts +0 -19
- package/dist/tui-v2/components/transcript/tool-card.js +2 -42
- package/dist/tui-v2/components/transcript/tool-card.js.map +1 -1
- package/dist/tui-v2/components/transcript/transcript-row.d.ts +0 -14
- package/dist/tui-v2/components/transcript/transcript-row.js +2 -13
- package/dist/tui-v2/components/transcript/transcript-row.js.map +1 -1
- package/dist/tui-v2/components/transcript/transcript-scroll-port.d.ts +0 -32
- package/dist/tui-v2/components/transcript/transcript-scroll-port.js +0 -22
- package/dist/tui-v2/components/transcript/transcript-scroll-port.js.map +1 -1
- package/dist/tui-v2/components/transcript/transcript-scrollbar.d.ts +6 -2
- package/dist/tui-v2/components/transcript/transcript-scrollbar.js +15 -4
- package/dist/tui-v2/components/transcript/transcript-scrollbar.js.map +1 -1
- package/dist/tui-v2/components/transcript/transcript-view.d.ts +0 -9
- package/dist/tui-v2/components/transcript/transcript-view.js +9 -104
- package/dist/tui-v2/components/transcript/transcript-view.js.map +1 -1
- package/dist/tui-v2/components/transcript/use-click-without-drag.d.ts +0 -7
- package/dist/tui-v2/components/transcript/use-click-without-drag.js +1 -11
- package/dist/tui-v2/components/transcript/use-click-without-drag.js.map +1 -1
- package/dist/tui-v2/components/transcript/use-native-selection-copy.d.ts +0 -7
- package/dist/tui-v2/components/transcript/use-native-selection-copy.js +0 -9
- package/dist/tui-v2/components/transcript/use-native-selection-copy.js.map +1 -1
- package/dist/tui-v2/components/transcript/use-transcript-selection.d.ts +0 -1
- package/dist/tui-v2/components/transcript/use-transcript-selection.js +0 -14
- package/dist/tui-v2/components/transcript/use-transcript-selection.js.map +1 -1
- package/dist/tui-v2/components/transcript/user-message.d.ts +0 -2
- package/dist/tui-v2/components/transcript/user-message.js +2 -7
- package/dist/tui-v2/components/transcript/user-message.js.map +1 -1
- package/dist/tui-v2/composer/composer-editor.d.ts +3 -21
- package/dist/tui-v2/composer/composer-editor.js +5 -63
- package/dist/tui-v2/composer/composer-editor.js.map +1 -1
- package/dist/tui-v2/composer/composer-wheel.d.ts +0 -17
- package/dist/tui-v2/composer/composer-wheel.js +0 -17
- package/dist/tui-v2/composer/composer-wheel.js.map +1 -1
- package/dist/tui-v2/composer/disable-native-textarea-scroll.d.ts +0 -12
- package/dist/tui-v2/composer/disable-native-textarea-scroll.js +0 -13
- package/dist/tui-v2/composer/disable-native-textarea-scroll.js.map +1 -1
- package/dist/tui-v2/composer/textarea-keybindings.d.ts +0 -19
- package/dist/tui-v2/composer/textarea-keybindings.js +0 -34
- package/dist/tui-v2/composer/textarea-keybindings.js.map +1 -1
- package/dist/tui-v2/composer/use-draft-actions.d.ts +0 -10
- package/dist/tui-v2/composer/use-draft-actions.js +0 -5
- package/dist/tui-v2/composer/use-draft-actions.js.map +1 -1
- package/dist/tui-v2/hooks/terminal-dimensions.d.ts +6 -0
- package/dist/tui-v2/hooks/terminal-dimensions.js +14 -0
- package/dist/tui-v2/hooks/terminal-dimensions.js.map +1 -0
- package/dist/tui-v2/input/chord-from-opentui-key.d.ts +0 -17
- package/dist/tui-v2/input/chord-from-opentui-key.js +0 -17
- package/dist/tui-v2/input/chord-from-opentui-key.js.map +1 -1
- package/dist/tui-v2/perf/render-counters.d.ts +5 -0
- package/dist/tui-v2/perf/render-counters.js +54 -0
- package/dist/tui-v2/perf/render-counters.js.map +1 -0
- package/dist/tui-v2/rendering/ansi-to-styled.d.ts +0 -12
- package/dist/tui-v2/rendering/ansi-to-styled.js +0 -10
- package/dist/tui-v2/rendering/ansi-to-styled.js.map +1 -1
- package/dist/tui-v2/rendering/pager-markdown.d.ts +0 -18
- package/dist/tui-v2/rendering/pager-markdown.js +0 -14
- package/dist/tui-v2/rendering/pager-markdown.js.map +1 -1
- package/dist/types.d.ts +2 -135
- package/dist/types.js +0 -3
- package/dist/types.js.map +1 -1
- package/dist/ui/mentions/expand.d.ts +26 -0
- package/dist/ui/mentions/expand.js +308 -0
- package/dist/ui/mentions/expand.js.map +1 -0
- package/dist/ui/mentions/file-suggestions.d.ts +7 -0
- package/dist/ui/mentions/file-suggestions.js +106 -0
- package/dist/ui/mentions/file-suggestions.js.map +1 -0
- package/dist/ui/mentions.d.ts +6 -70
- package/dist/ui/mentions.js +8 -482
- package/dist/ui/mentions.js.map +1 -1
- package/dist/ui/plan-pane.d.ts +0 -15
- package/dist/ui/plan-pane.js +1 -16
- package/dist/ui/plan-pane.js.map +1 -1
- package/dist/ui/thinking.d.ts +0 -8
- package/dist/ui/thinking.js +0 -13
- package/dist/ui/thinking.js.map +1 -1
- package/dist/ui-core/actions/action-id.d.ts +0 -8
- package/dist/ui-core/actions/action-id.js +0 -25
- package/dist/ui-core/actions/action-id.js.map +1 -1
- package/dist/ui-core/actions/action-router.d.ts +0 -10
- package/dist/ui-core/actions/action-router.js +0 -16
- package/dist/ui-core/actions/action-router.js.map +1 -1
- package/dist/ui-core/actions/cancel-timing.d.ts +0 -3
- package/dist/ui-core/actions/cancel-timing.js +0 -3
- package/dist/ui-core/actions/cancel-timing.js.map +1 -1
- package/dist/ui-core/actions/format-shortcuts.d.ts +0 -9
- package/dist/ui-core/actions/format-shortcuts.js +0 -9
- package/dist/ui-core/actions/format-shortcuts.js.map +1 -1
- package/dist/ui-core/actions/keymap.d.ts +0 -9
- package/dist/ui-core/actions/keymap.js +0 -39
- package/dist/ui-core/actions/keymap.js.map +1 -1
- package/dist/ui-core/actions/mode-cycle.d.ts +0 -2
- package/dist/ui-core/actions/mode-cycle.js +0 -4
- package/dist/ui-core/actions/mode-cycle.js.map +1 -1
- package/dist/ui-core/bootstrap/can-use-tui.d.ts +0 -6
- package/dist/ui-core/bootstrap/can-use-tui.js +0 -9
- package/dist/ui-core/bootstrap/can-use-tui.js.map +1 -1
- package/dist/ui-core/bootstrap/capabilities.d.ts +0 -8
- package/dist/ui-core/bootstrap/capabilities.js +1 -8
- package/dist/ui-core/bootstrap/capabilities.js.map +1 -1
- package/dist/ui-core/bootstrap/composition-root.d.ts +0 -17
- package/dist/ui-core/bootstrap/composition-root.js +30 -19
- package/dist/ui-core/bootstrap/composition-root.js.map +1 -1
- package/dist/ui-core/bootstrap/console-guard.d.ts +0 -15
- package/dist/ui-core/bootstrap/console-guard.js +32 -0
- package/dist/ui-core/bootstrap/console-guard.js.map +1 -1
- package/dist/ui-core/bootstrap/console-suppress.js +2 -7
- package/dist/ui-core/bootstrap/console-suppress.js.map +1 -1
- package/dist/ui-core/bootstrap/exit-epilogue.d.ts +0 -6
- package/dist/ui-core/bootstrap/exit-epilogue.js +0 -5
- package/dist/ui-core/bootstrap/exit-epilogue.js.map +1 -1
- package/dist/ui-core/bootstrap/lifecycle.d.ts +0 -42
- package/dist/ui-core/bootstrap/lifecycle.js +0 -31
- package/dist/ui-core/bootstrap/lifecycle.js.map +1 -1
- package/dist/ui-core/bootstrap/overlay-ports.d.ts +0 -11
- package/dist/ui-core/bootstrap/overlay-ports.js +0 -13
- package/dist/ui-core/bootstrap/overlay-ports.js.map +1 -1
- package/dist/ui-core/bootstrap/session-resume.js +10 -2
- package/dist/ui-core/bootstrap/session-resume.js.map +1 -1
- package/dist/ui-core/bootstrap/theme-mode-cache.js +0 -5
- package/dist/ui-core/bootstrap/theme-mode-cache.js.map +1 -1
- package/dist/ui-core/commands/command-handlers.d.ts +0 -6
- package/dist/ui-core/commands/command-handlers.js +0 -6
- package/dist/ui-core/commands/command-handlers.js.map +1 -1
- package/dist/ui-core/commands/config-commands.d.ts +0 -3
- package/dist/ui-core/commands/config-commands.js +0 -7
- package/dist/ui-core/commands/config-commands.js.map +1 -1
- package/dist/ui-core/commands/key-commands.d.ts +2 -0
- package/dist/ui-core/commands/key-commands.js +79 -213
- package/dist/ui-core/commands/key-commands.js.map +1 -1
- package/dist/ui-core/commands/keys/editors.d.ts +15 -0
- package/dist/ui-core/commands/keys/editors.js +127 -0
- package/dist/ui-core/commands/keys/editors.js.map +1 -0
- package/dist/ui-core/commands/mcp-commands.js +0 -6
- package/dist/ui-core/commands/mcp-commands.js.map +1 -1
- package/dist/ui-core/commands/picker-commands.d.ts +3 -14
- package/dist/ui-core/commands/picker-commands.js +11 -695
- package/dist/ui-core/commands/picker-commands.js.map +1 -1
- package/dist/ui-core/commands/pickers/custom-provider.d.ts +3 -0
- package/dist/ui-core/commands/pickers/custom-provider.js +170 -0
- package/dist/ui-core/commands/pickers/custom-provider.js.map +1 -0
- package/dist/ui-core/commands/pickers/history.d.ts +3 -0
- package/dist/ui-core/commands/pickers/history.js +185 -0
- package/dist/ui-core/commands/pickers/history.js.map +1 -0
- package/dist/ui-core/commands/pickers/output-pager.d.ts +5 -0
- package/dist/ui-core/commands/pickers/output-pager.js +90 -0
- package/dist/ui-core/commands/pickers/output-pager.js.map +1 -0
- package/dist/ui-core/commands/pickers/search-reasoning.d.ts +4 -0
- package/dist/ui-core/commands/pickers/search-reasoning.js +197 -0
- package/dist/ui-core/commands/pickers/search-reasoning.js.map +1 -0
- package/dist/ui-core/commands/session-commands.d.ts +0 -4
- package/dist/ui-core/commands/session-commands.js +23 -17
- package/dist/ui-core/commands/session-commands.js.map +1 -1
- package/dist/ui-core/commands/startup-update.d.ts +0 -6
- package/dist/ui-core/commands/startup-update.js +0 -6
- package/dist/ui-core/commands/startup-update.js.map +1 -1
- package/dist/ui-core/composer/arrow-intent.d.ts +0 -10
- package/dist/ui-core/composer/arrow-intent.js +0 -14
- package/dist/ui-core/composer/arrow-intent.js.map +1 -1
- package/dist/ui-core/composer/completion.d.ts +0 -9
- package/dist/ui-core/composer/completion.js +1 -13
- package/dist/ui-core/composer/completion.js.map +1 -1
- package/dist/ui-core/composer/composer-action-port.d.ts +0 -10
- package/dist/ui-core/composer/composer-action-port.js +0 -10
- package/dist/ui-core/composer/composer-action-port.js.map +1 -1
- package/dist/ui-core/composer/composer-height.d.ts +0 -12
- package/dist/ui-core/composer/composer-height.js +0 -12
- package/dist/ui-core/composer/composer-height.js.map +1 -1
- package/dist/ui-core/composer/composer-wheel.d.ts +0 -17
- package/dist/ui-core/composer/composer-wheel.js +0 -17
- package/dist/ui-core/composer/composer-wheel.js.map +1 -1
- package/dist/ui-core/composer/draft-actions.d.ts +0 -14
- package/dist/ui-core/composer/draft-actions.js +0 -13
- package/dist/ui-core/composer/draft-actions.js.map +1 -1
- package/dist/ui-core/composer/history-nav.d.ts +0 -9
- package/dist/ui-core/composer/history-nav.js +0 -9
- package/dist/ui-core/composer/history-nav.js.map +1 -1
- package/dist/ui-core/composer/input-history.d.ts +0 -1
- package/dist/ui-core/composer/input-history.js +0 -1
- package/dist/ui-core/composer/input-history.js.map +1 -1
- package/dist/ui-core/composer/newline-hint.d.ts +0 -7
- package/dist/ui-core/composer/newline-hint.js +0 -9
- package/dist/ui-core/composer/newline-hint.js.map +1 -1
- package/dist/ui-core/composer/paste-placeholder.d.ts +0 -23
- package/dist/ui-core/composer/paste-placeholder.js +0 -21
- package/dist/ui-core/composer/paste-placeholder.js.map +1 -1
- package/dist/ui-core/composer/prompt-history.d.ts +0 -11
- package/dist/ui-core/composer/prompt-history.js +0 -11
- package/dist/ui-core/composer/prompt-history.js.map +1 -1
- package/dist/ui-core/composer/secret-buffer.d.ts +0 -8
- package/dist/ui-core/composer/secret-buffer.js +0 -8
- package/dist/ui-core/composer/secret-buffer.js.map +1 -1
- package/dist/ui-core/composer/textarea-keybindings.d.ts +0 -15
- package/dist/ui-core/composer/textarea-keybindings.js +0 -30
- package/dist/ui-core/composer/textarea-keybindings.js.map +1 -1
- package/dist/ui-core/controllers/focus-controller.d.ts +0 -11
- package/dist/ui-core/controllers/focus-controller.js +0 -11
- package/dist/ui-core/controllers/focus-controller.js.map +1 -1
- package/dist/ui-core/controllers/interruptible-controller.d.ts +0 -6
- package/dist/ui-core/controllers/interruptible-controller.js +0 -6
- package/dist/ui-core/controllers/interruptible-controller.js.map +1 -1
- package/dist/ui-core/controllers/overlay-controller.d.ts +1 -81
- package/dist/ui-core/controllers/overlay-controller.js +1 -48
- package/dist/ui-core/controllers/overlay-controller.js.map +1 -1
- package/dist/ui-core/controllers/selection-controller.d.ts +0 -9
- package/dist/ui-core/controllers/selection-controller.js +0 -7
- package/dist/ui-core/controllers/selection-controller.js.map +1 -1
- package/dist/ui-core/controllers/toast-controller.d.ts +0 -24
- package/dist/ui-core/controllers/toast-controller.js +0 -15
- package/dist/ui-core/controllers/toast-controller.js.map +1 -1
- package/dist/ui-core/layout/compute-layout.d.ts +0 -19
- package/dist/ui-core/layout/compute-layout.js +0 -32
- package/dist/ui-core/layout/compute-layout.js.map +1 -1
- package/dist/ui-core/motion/ease.d.ts +0 -6
- package/dist/ui-core/motion/ease.js +0 -6
- package/dist/ui-core/motion/ease.js.map +1 -1
- package/dist/ui-core/notify.d.ts +0 -8
- package/dist/ui-core/notify.js +0 -8
- package/dist/ui-core/notify.js.map +1 -1
- package/dist/ui-core/plan/plan-lifecycle.d.ts +0 -27
- package/dist/ui-core/plan/plan-lifecycle.js +0 -45
- package/dist/ui-core/plan/plan-lifecycle.js.map +1 -1
- package/dist/ui-core/ports/clipboard-osc52.d.ts +0 -8
- package/dist/ui-core/ports/clipboard-osc52.js +0 -7
- package/dist/ui-core/ports/clipboard-osc52.js.map +1 -1
- package/dist/ui-core/ports/pager-export-port.js +0 -2
- package/dist/ui-core/ports/pager-export-port.js.map +1 -1
- package/dist/ui-core/ports/renderer-port.d.ts +0 -6
- package/dist/ui-core/react/providers.d.ts +0 -7
- package/dist/ui-core/react/providers.js +0 -7
- package/dist/ui-core/react/providers.js.map +1 -1
- package/dist/ui-core/react/use-has-draft.d.ts +0 -5
- package/dist/ui-core/react/use-has-draft.js +0 -5
- package/dist/ui-core/react/use-has-draft.js.map +1 -1
- package/dist/ui-core/react/use-overlay.d.ts +0 -1
- package/dist/ui-core/react/use-overlay.js +0 -1
- package/dist/ui-core/react/use-overlay.js.map +1 -1
- package/dist/ui-core/react/use-plan.d.ts +0 -1
- package/dist/ui-core/react/use-plan.js +0 -1
- package/dist/ui-core/react/use-plan.js.map +1 -1
- package/dist/ui-core/react/use-toast.d.ts +0 -1
- package/dist/ui-core/react/use-toast.js +0 -3
- package/dist/ui-core/react/use-toast.js.map +1 -1
- package/dist/ui-core/react/use-transcript-meta.d.ts +7 -0
- package/dist/ui-core/react/use-transcript-meta.js +36 -0
- package/dist/ui-core/react/use-transcript-meta.js.map +1 -0
- package/dist/ui-core/react/use-transcript-store.d.ts +0 -7
- package/dist/ui-core/react/use-transcript-store.js +0 -7
- package/dist/ui-core/react/use-transcript-store.js.map +1 -1
- package/dist/ui-core/rendering/artifact-pager-source.d.ts +0 -7
- package/dist/ui-core/rendering/artifact-pager-source.js +0 -3
- package/dist/ui-core/rendering/artifact-pager-source.js.map +1 -1
- package/dist/ui-core/rendering/batch-sections.d.ts +0 -38
- package/dist/ui-core/rendering/batch-sections.js +1 -47
- package/dist/ui-core/rendering/batch-sections.js.map +1 -1
- package/dist/ui-core/rendering/code-block.d.ts +0 -25
- package/dist/ui-core/rendering/code-block.js +0 -47
- package/dist/ui-core/rendering/code-block.js.map +1 -1
- package/dist/ui-core/rendering/context-limit.js +0 -2
- package/dist/ui-core/rendering/context-limit.js.map +1 -1
- package/dist/ui-core/rendering/duration.js +0 -3
- package/dist/ui-core/rendering/duration.js.map +1 -1
- package/dist/ui-core/rendering/exit-summary/table.d.ts +23 -0
- package/dist/ui-core/rendering/exit-summary/table.js +194 -0
- package/dist/ui-core/rendering/exit-summary/table.js.map +1 -0
- package/dist/ui-core/rendering/exit-summary.js +1 -210
- package/dist/ui-core/rendering/exit-summary.js.map +1 -1
- package/dist/ui-core/rendering/file-diff-view.d.ts +0 -27
- package/dist/ui-core/rendering/file-diff-view.js +0 -29
- package/dist/ui-core/rendering/file-diff-view.js.map +1 -1
- package/dist/ui-core/rendering/format-help.d.ts +0 -13
- package/dist/ui-core/rendering/format-help.js +0 -18
- package/dist/ui-core/rendering/format-help.js.map +1 -1
- package/dist/ui-core/rendering/format-keys.js +0 -2
- package/dist/ui-core/rendering/format-keys.js.map +1 -1
- package/dist/ui-core/rendering/format-usage.js +18 -5
- package/dist/ui-core/rendering/format-usage.js.map +1 -1
- package/dist/ui-core/rendering/incremental-strip.js +0 -13
- package/dist/ui-core/rendering/incremental-strip.js.map +1 -1
- package/dist/ui-core/rendering/intro-header.js +0 -1
- package/dist/ui-core/rendering/intro-header.js.map +1 -1
- package/dist/ui-core/rendering/job-tail-source.d.ts +0 -9
- package/dist/ui-core/rendering/job-tail-source.js +0 -9
- package/dist/ui-core/rendering/job-tail-source.js.map +1 -1
- package/dist/ui-core/rendering/link-detector.d.ts +0 -8
- package/dist/ui-core/rendering/link-detector.js +0 -10
- package/dist/ui-core/rendering/link-detector.js.map +1 -1
- package/dist/ui-core/rendering/markdown/tables.d.ts +8 -0
- package/dist/ui-core/rendering/markdown/tables.js +276 -0
- package/dist/ui-core/rendering/markdown/tables.js.map +1 -0
- package/dist/ui-core/rendering/markdown.d.ts +4 -9
- package/dist/ui-core/rendering/markdown.js +224 -593
- package/dist/ui-core/rendering/markdown.js.map +1 -1
- package/dist/ui-core/rendering/open-tool-output.d.ts +0 -30
- package/dist/ui-core/rendering/open-tool-output.js +0 -39
- package/dist/ui-core/rendering/open-tool-output.js.map +1 -1
- package/dist/ui-core/rendering/pager-chrome.d.ts +0 -20
- package/dist/ui-core/rendering/pager-chrome.js +0 -24
- package/dist/ui-core/rendering/pager-chrome.js.map +1 -1
- package/dist/ui-core/rendering/pager-source.d.ts +0 -17
- package/dist/ui-core/rendering/pager-source.js +0 -27
- package/dist/ui-core/rendering/pager-source.js.map +1 -1
- package/dist/ui-core/rendering/pager-text.d.ts +0 -21
- package/dist/ui-core/rendering/pager-text.js +0 -31
- package/dist/ui-core/rendering/pager-text.js.map +1 -1
- package/dist/ui-core/rendering/pager-view-policy.d.ts +0 -24
- package/dist/ui-core/rendering/pager-view-policy.js +0 -31
- package/dist/ui-core/rendering/pager-view-policy.js.map +1 -1
- package/dist/ui-core/rendering/picker-filter.d.ts +0 -11
- package/dist/ui-core/rendering/picker-filter.js +0 -11
- package/dist/ui-core/rendering/picker-filter.js.map +1 -1
- package/dist/ui-core/rendering/plan-view.d.ts +0 -39
- package/dist/ui-core/rendering/plan-view.js +0 -37
- package/dist/ui-core/rendering/plan-view.js.map +1 -1
- package/dist/ui-core/rendering/prompt-preview.d.ts +0 -5
- package/dist/ui-core/rendering/prompt-preview.js +0 -5
- package/dist/ui-core/rendering/prompt-preview.js.map +1 -1
- package/dist/ui-core/rendering/sanitize-display.d.ts +0 -10
- package/dist/ui-core/rendering/sanitize-display.js +0 -14
- package/dist/ui-core/rendering/sanitize-display.js.map +1 -1
- package/dist/ui-core/rendering/status-segments.js +3 -3
- package/dist/ui-core/rendering/status-segments.js.map +1 -1
- package/dist/ui-core/rendering/streaming-markdown.js +0 -11
- package/dist/ui-core/rendering/streaming-markdown.js.map +1 -1
- package/dist/ui-core/rendering/syntax/clike.d.ts +22 -0
- package/dist/ui-core/rendering/syntax/clike.js +168 -0
- package/dist/ui-core/rendering/syntax/clike.js.map +1 -0
- package/dist/ui-core/rendering/syntax/keywords.d.ts +24 -0
- package/dist/ui-core/rendering/syntax/keywords.js +169 -0
- package/dist/ui-core/rendering/syntax/keywords.js.map +1 -0
- package/dist/ui-core/rendering/syntax/language-highlighters.d.ts +18 -0
- package/dist/ui-core/rendering/syntax/language-highlighters.js +538 -0
- package/dist/ui-core/rendering/syntax/language-highlighters.js.map +1 -0
- package/dist/ui-core/rendering/syntax/language-table.d.ts +3 -0
- package/dist/ui-core/rendering/syntax/language-table.js +244 -0
- package/dist/ui-core/rendering/syntax/language-table.js.map +1 -0
- package/dist/ui-core/rendering/syntax-highlight.d.ts +6 -28
- package/dist/ui-core/rendering/syntax-highlight.js +5 -1177
- package/dist/ui-core/rendering/syntax-highlight.js.map +1 -1
- package/dist/ui-core/rendering/text-format.d.ts +0 -3
- package/dist/ui-core/rendering/text-format.js +0 -3
- package/dist/ui-core/rendering/text-format.js.map +1 -1
- package/dist/ui-core/rendering/text-width.d.ts +0 -26
- package/dist/ui-core/rendering/text-width.js +0 -26
- package/dist/ui-core/rendering/text-width.js.map +1 -1
- package/dist/ui-core/rendering/theme.d.ts +0 -65
- package/dist/ui-core/rendering/theme.js +0 -24
- package/dist/ui-core/rendering/theme.js.map +1 -1
- package/dist/ui-core/rendering/thinking-tail.js +0 -3
- package/dist/ui-core/rendering/thinking-tail.js.map +1 -1
- package/dist/ui-core/rendering/tool-presenter.d.ts +0 -41
- package/dist/ui-core/rendering/tool-presenter.js +1 -67
- package/dist/ui-core/rendering/tool-presenter.js.map +1 -1
- package/dist/ui-core/rendering/transcript-semantic.d.ts +0 -8
- package/dist/ui-core/rendering/transcript-semantic.js +0 -13
- package/dist/ui-core/rendering/transcript-semantic.js.map +1 -1
- package/dist/ui-core/rendering/user-message-wrap.d.ts +0 -16
- package/dist/ui-core/rendering/user-message-wrap.js +0 -16
- package/dist/ui-core/rendering/user-message-wrap.js.map +1 -1
- package/dist/ui-core/rendering/wordmark.d.ts +0 -8
- package/dist/ui-core/rendering/wordmark.js +0 -21
- package/dist/ui-core/rendering/wordmark.js.map +1 -1
- package/dist/ui-core/state/hydrate/classic-transcript.d.ts +8 -0
- package/dist/ui-core/state/hydrate/classic-transcript.js +168 -0
- package/dist/ui-core/state/hydrate/classic-transcript.js.map +1 -0
- package/dist/ui-core/state/hydrate/from-messages.d.ts +6 -0
- package/dist/ui-core/state/hydrate/from-messages.js +237 -0
- package/dist/ui-core/state/hydrate/from-messages.js.map +1 -0
- package/dist/ui-core/state/pager-search.d.ts +0 -9
- package/dist/ui-core/state/pager-search.js +1 -8
- package/dist/ui-core/state/pager-search.js.map +1 -1
- package/dist/ui-core/state/semantic-document.d.ts +0 -8
- package/dist/ui-core/state/semantic-document.js +0 -8
- package/dist/ui-core/state/semantic-document.js.map +1 -1
- package/dist/ui-core/state/thinking-copy.d.ts +0 -8
- package/dist/ui-core/state/thinking-copy.js +0 -8
- package/dist/ui-core/state/thinking-copy.js.map +1 -1
- package/dist/ui-core/state/transcript/apply-app-event.d.ts +8 -0
- package/dist/ui-core/state/transcript/apply-app-event.js +406 -0
- package/dist/ui-core/state/transcript/apply-app-event.js.map +1 -0
- package/dist/ui-core/state/transcript/message-lifecycle.d.ts +7 -0
- package/dist/ui-core/state/transcript/message-lifecycle.js +285 -0
- package/dist/ui-core/state/transcript/message-lifecycle.js.map +1 -0
- package/dist/ui-core/state/transcript-compaction.d.ts +0 -19
- package/dist/ui-core/state/transcript-compaction.js +0 -21
- package/dist/ui-core/state/transcript-compaction.js.map +1 -1
- package/dist/ui-core/state/transcript-follow-key.d.ts +2 -0
- package/dist/ui-core/state/transcript-follow-key.js +37 -0
- package/dist/ui-core/state/transcript-follow-key.js.map +1 -0
- package/dist/ui-core/state/transcript-hydrate.d.ts +6 -52
- package/dist/ui-core/state/transcript-hydrate.js +5 -470
- package/dist/ui-core/state/transcript-hydrate.js.map +1 -1
- package/dist/ui-core/state/transcript-reducer.d.ts +1 -15
- package/dist/ui-core/state/transcript-reducer.js +1 -708
- package/dist/ui-core/state/transcript-reducer.js.map +1 -1
- package/dist/ui-core/state/transcript-search.d.ts +0 -8
- package/dist/ui-core/state/transcript-search.js +0 -8
- package/dist/ui-core/state/transcript-search.js.map +1 -1
- package/dist/ui-core/state/transcript-store.d.ts +0 -26
- package/dist/ui-core/state/transcript-store.js +0 -28
- package/dist/ui-core/state/transcript-store.js.map +1 -1
- package/dist/ui-core/state/transcript-types.d.ts +0 -33
- package/dist/ui-core/state/transcript-types.js +0 -17
- package/dist/ui-core/state/transcript-types.js.map +1 -1
- package/dist/ui-core/state/transcript-window.d.ts +1 -9
- package/dist/ui-core/state/transcript-window.js +1 -9
- package/dist/ui-core/state/transcript-window.js.map +1 -1
- package/dist/version.generated.d.ts +2 -2
- package/dist/version.generated.js +2 -2
- package/package.json +19 -2
- package/dist/agent/finalize-gate.d.ts +0 -54
- package/dist/agent/finalize-gate.js +0 -97
- package/dist/agent/finalize-gate.js.map +0 -1
- package/dist/agent/must-continue.d.ts +0 -36
- package/dist/agent/must-continue.js +0 -172
- package/dist/agent/must-continue.js.map +0 -1
package/dist/llm/http.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { readJson } from "./wire/response-errors.js";
|
|
2
|
+
import { DEFAULT_STREAM_IDLE_TIMEOUT_MS, STREAM_STALL_MARKER, THINKING_STREAM_IDLE_TIMEOUT_MS, THINKING_STREAM_INITIAL_IDLE_TIMEOUT_MS, createSseFrameAssembler, } from "./wire/stream-framing.js";
|
|
3
|
+
import { buildReasoningPayload, } from "./wire/reasoning-payload.js";
|
|
4
|
+
import { chatCompletionsBodyFromPlan } from "./wire/chat-body.js";
|
|
5
|
+
import { compatibleArtifactPolicyFor, } from "./wire/reasoning-artifacts.js";
|
|
6
|
+
export { openAiCompatibleStream } from "./wire/openai-stream.js";
|
|
7
|
+
export { openAiCompatibleComplete, openAiCompatiblePing, } from "./wire/openai-complete.js";
|
|
8
|
+
export { catalogEntryVision, ingestModelCatalogEntries, ingestOpenAiModelCatalog, } from "./wire/model-catalog.js";
|
|
9
|
+
export { toCompletionResult } from "./wire/reasoning-artifacts.js";
|
|
10
|
+
export { compatibleArtifactPolicyFor };
|
|
11
|
+
export { buildChatBody, isOpenAiReasoningModel, toOpenAiMessages, } from "./wire/chat-body.js";
|
|
12
|
+
export { chatCompletionsBodyFromPlan };
|
|
13
|
+
export { imageCapableMessages, isImageInputUnsupportedError, isReasoningUnsupportedError, isStreamOptionsUnsupportedError, reasoningRejectionAdvice, stripImagesFromMessages, } from "./wire/capability-errors.js";
|
|
14
|
+
export { buildReasoningPayload };
|
|
15
|
+
export { readStreamLines, streamIdleBudgets } from "./wire/stream-framing.js";
|
|
16
|
+
export { DEFAULT_STREAM_IDLE_TIMEOUT_MS, STREAM_STALL_MARKER, THINKING_STREAM_IDLE_TIMEOUT_MS, THINKING_STREAM_INITIAL_IDLE_TIMEOUT_MS, createSseFrameAssembler, };
|
|
17
|
+
export { MAX_ERROR_BODY_CHARS, MAX_ERROR_BODY_IN_MESSAGE_CHARS, bodyAddsInformation, collapseWhitespace, } from "./wire/response-errors.js";
|
|
18
|
+
export { readJson };
|
|
19
19
|
export class ProviderError extends Error {
|
|
20
20
|
status;
|
|
21
21
|
body;
|
|
@@ -28,2007 +28,5 @@ export class ProviderError extends Error {
|
|
|
28
28
|
this.name = "ProviderError";
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
"prompt_tokens",
|
|
33
|
-
"promptTokens",
|
|
34
|
-
"input_tokens",
|
|
35
|
-
"inputTokens",
|
|
36
|
-
];
|
|
37
|
-
const USAGE_OUTPUT_KEYS = [
|
|
38
|
-
"completion_tokens",
|
|
39
|
-
"completionTokens",
|
|
40
|
-
"output_tokens",
|
|
41
|
-
"outputTokens",
|
|
42
|
-
];
|
|
43
|
-
function isFinalUsageFrame(parsed) {
|
|
44
|
-
if (Array.isArray(parsed.choices) && parsed.choices.length > 0)
|
|
45
|
-
return false;
|
|
46
|
-
const usage = parsed.usage;
|
|
47
|
-
if (!usage || typeof usage !== "object" || Array.isArray(usage))
|
|
48
|
-
return false;
|
|
49
|
-
const raw = usage;
|
|
50
|
-
const reported = (keys) => keys.some((key) => {
|
|
51
|
-
const value = raw[key];
|
|
52
|
-
return typeof value === "number" && Number.isFinite(value);
|
|
53
|
-
});
|
|
54
|
-
return reported(USAGE_INPUT_KEYS) && reported(USAGE_OUTPUT_KEYS);
|
|
55
|
-
}
|
|
56
|
-
function parseRetryAfterHeader(value) {
|
|
57
|
-
if (!value)
|
|
58
|
-
return undefined;
|
|
59
|
-
const seconds = Number.parseFloat(value);
|
|
60
|
-
if (Number.isFinite(seconds) && seconds >= 0)
|
|
61
|
-
return seconds;
|
|
62
|
-
// HTTP-date form: "Wed, 21 Oct 2015 07:28:00 GMT"
|
|
63
|
-
const date = Date.parse(value);
|
|
64
|
-
if (Number.isFinite(date)) {
|
|
65
|
-
const diff = (date - Date.now()) / 1000;
|
|
66
|
-
if (diff > 0)
|
|
67
|
-
return diff;
|
|
68
|
-
}
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
function parseRetryHintFromBody(text) {
|
|
72
|
-
const match = text.match(/try again in\s+([0-9.]+)\s*s/i);
|
|
73
|
-
if (match) {
|
|
74
|
-
const seconds = Number.parseFloat(match[1]);
|
|
75
|
-
if (Number.isFinite(seconds) && seconds >= 0)
|
|
76
|
-
return seconds;
|
|
77
|
-
}
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
function statusCodeHint(status) {
|
|
81
|
-
if (status === 401) {
|
|
82
|
-
return " — check that the API key is valid (run `clai providers` to inspect)";
|
|
83
|
-
}
|
|
84
|
-
if (status === 403) {
|
|
85
|
-
return " — the key was rejected (insufficient permissions, billing, or region restriction)";
|
|
86
|
-
}
|
|
87
|
-
if (status === 404) {
|
|
88
|
-
return " — endpoint or model not found (try `/model list` to see supported names)";
|
|
89
|
-
}
|
|
90
|
-
if (status === 422) {
|
|
91
|
-
return " — the provider rejected the request body (model name or parameter mismatch)";
|
|
92
|
-
}
|
|
93
|
-
if (status === 413) {
|
|
94
|
-
return " — request exceeded the provider input limit; retry with a compact prompt or pick another model";
|
|
95
|
-
}
|
|
96
|
-
if (status >= 500 && status < 600) {
|
|
97
|
-
return " — upstream provider error; try again or switch with `/provider`";
|
|
98
|
-
}
|
|
99
|
-
return "";
|
|
100
|
-
}
|
|
101
|
-
export function catalogEntryVision(entry) {
|
|
102
|
-
return parseCatalogFacts(entry)?.vision;
|
|
103
|
-
}
|
|
104
|
-
export function ingestModelCatalogEntries(provider, entries) {
|
|
105
|
-
const models = [];
|
|
106
|
-
const seen = new Set();
|
|
107
|
-
for (const entry of entries) {
|
|
108
|
-
const facts = parseCatalogFacts(entry);
|
|
109
|
-
if (!facts)
|
|
110
|
-
continue;
|
|
111
|
-
const id = facts.id;
|
|
112
|
-
if (seen.has(id))
|
|
113
|
-
continue;
|
|
114
|
-
seen.add(id);
|
|
115
|
-
const reasoning = facts.reasoning?.supported;
|
|
116
|
-
const reasoningEfforts = catalogEffortList(facts.reasoning?.supportedEfforts);
|
|
117
|
-
models.push({
|
|
118
|
-
id,
|
|
119
|
-
facts,
|
|
120
|
-
...(facts.vision === undefined ? {} : { vision: facts.vision }),
|
|
121
|
-
...(reasoning === undefined ? {} : { reasoning }),
|
|
122
|
-
...(reasoningEfforts === undefined ? {} : { reasoningEfforts }),
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
if (models.length > 0)
|
|
126
|
-
registerModelCatalog(provider, models);
|
|
127
|
-
return models.map((model) => model.id).sort();
|
|
128
|
-
}
|
|
129
|
-
export function ingestOpenAiModelCatalog(provider, payload) {
|
|
130
|
-
return ingestModelCatalogEntries(provider, catalogEntriesFromPayload(payload));
|
|
131
|
-
}
|
|
132
|
-
export async function readJson(response, signal) {
|
|
133
|
-
const text = await readBodyCapped(response, MAX_JSON_RESPONSE_BYTES, signal);
|
|
134
|
-
if (!response.ok) {
|
|
135
|
-
let detail = "";
|
|
136
|
-
let extractedMessage = "";
|
|
137
|
-
try {
|
|
138
|
-
const body = JSON.parse(text);
|
|
139
|
-
const error = body.error;
|
|
140
|
-
let msg = "";
|
|
141
|
-
if (typeof error === "string") {
|
|
142
|
-
msg = error;
|
|
143
|
-
}
|
|
144
|
-
else if (error && typeof error === "object") {
|
|
145
|
-
const errObj = error;
|
|
146
|
-
msg = errObj.message ?? "";
|
|
147
|
-
if (!msg && (errObj.type || errObj.code)) {
|
|
148
|
-
msg = errObj.type ?? errObj.code ?? "";
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (!msg) {
|
|
152
|
-
msg =
|
|
153
|
-
body.message ??
|
|
154
|
-
body.detail ??
|
|
155
|
-
"";
|
|
156
|
-
}
|
|
157
|
-
if (msg) {
|
|
158
|
-
// Detect NVIDIA DEGRADED function errors and enrich the message.
|
|
159
|
-
if (/DEGRADED/i.test(msg)) {
|
|
160
|
-
detail = ` — ${msg} (model is temporarily unavailable on this provider; try a different model with \`/model\`)`;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
detail = ` — ${msg}`;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
extractedMessage = msg;
|
|
167
|
-
}
|
|
168
|
-
catch {
|
|
169
|
-
// Non-JSON body — the raw text is surfaced via the full-response rule
|
|
170
|
-
// below, so nothing is lost here.
|
|
171
|
-
}
|
|
172
|
-
// Show the full error received from the request: the extracted
|
|
173
|
-
// `error.message` alone routinely hides the actionable part of a gateway
|
|
174
|
-
// error (upstream detail, codes, validation fields). Append the complete
|
|
175
|
-
// body whenever it carries anything beyond that extracted message.
|
|
176
|
-
const bodyText = text.slice(0, MAX_ERROR_BODY_CHARS);
|
|
177
|
-
if (bodyAddsInformation(bodyText, extractedMessage)) {
|
|
178
|
-
const shown = collapseWhitespace(bodyText);
|
|
179
|
-
const capped = shown.length > MAX_ERROR_BODY_IN_MESSAGE_CHARS
|
|
180
|
-
? `${shown.slice(0, MAX_ERROR_BODY_IN_MESSAGE_CHARS)}…`
|
|
181
|
-
: shown;
|
|
182
|
-
detail = `${detail} — full response: ${capped}`;
|
|
183
|
-
}
|
|
184
|
-
const retryAfterSeconds = parseRetryAfterHeader(response.headers.get("retry-after")) ??
|
|
185
|
-
parseRetryHintFromBody(text);
|
|
186
|
-
const retryHint = retryAfterSeconds !== undefined
|
|
187
|
-
? ` (retry after ${Math.ceil(retryAfterSeconds)}s)`
|
|
188
|
-
: "";
|
|
189
|
-
const codeHint = statusCodeHint(response.status);
|
|
190
|
-
throw new ProviderError(`Provider request failed with HTTP ${response.status}${retryHint}${detail}${codeHint}`, response.status, bodyText, retryAfterSeconds);
|
|
191
|
-
}
|
|
192
|
-
return JSON.parse(text);
|
|
193
|
-
}
|
|
194
|
-
/** Hard cap on a JSON response body so a misbehaving provider can't OOM us. */
|
|
195
|
-
const MAX_JSON_RESPONSE_BYTES = 4 * 1024 * 1024;
|
|
196
|
-
/** How much of a provider error body we retain on the ProviderError. */
|
|
197
|
-
export const MAX_ERROR_BODY_CHARS = 8_000;
|
|
198
|
-
/** How much of that body is embedded in the user-visible error message. */
|
|
199
|
-
export const MAX_ERROR_BODY_IN_MESSAGE_CHARS = 2_000;
|
|
200
|
-
export function collapseWhitespace(text) {
|
|
201
|
-
return text.replace(/\s+/g, " ").trim();
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* True when the raw response body carries information beyond the message we
|
|
205
|
-
* already extracted from it (extra JSON fields, non-JSON payloads, …). Pure
|
|
206
|
-
* `{"error":{"message": …}}` envelopes are redundant and stay compact.
|
|
207
|
-
*/
|
|
208
|
-
export function bodyAddsInformation(bodyText, extracted) {
|
|
209
|
-
const collapsed = collapseWhitespace(bodyText);
|
|
210
|
-
if (!collapsed)
|
|
211
|
-
return false;
|
|
212
|
-
if (!extracted)
|
|
213
|
-
return true;
|
|
214
|
-
const normalizedExtracted = collapseWhitespace(extracted);
|
|
215
|
-
// The user-facing text already carries the entire body verbatim.
|
|
216
|
-
if (normalizedExtracted.includes(collapsed))
|
|
217
|
-
return false;
|
|
218
|
-
if (!collapsed.includes(normalizedExtracted))
|
|
219
|
-
return true;
|
|
220
|
-
const rest = collapsed
|
|
221
|
-
.replace(normalizedExtracted, " ")
|
|
222
|
-
.replace(/\b(errors?|message|msg|detail|details|type|code|status)\b/gi, " ")
|
|
223
|
-
.replace(/[{}\[\]":,]/g, " ")
|
|
224
|
-
.trim();
|
|
225
|
-
return rest.length > 0;
|
|
226
|
-
}
|
|
227
|
-
async function readBodyCapped(response, maxBytes, signal) {
|
|
228
|
-
const reader = response.body?.getReader();
|
|
229
|
-
if (!reader) {
|
|
230
|
-
if (signal?.aborted) {
|
|
231
|
-
throw signal.reason ?? new Error("Response body read aborted");
|
|
232
|
-
}
|
|
233
|
-
const text = await response.text();
|
|
234
|
-
return text.length > maxBytes ? text.slice(0, maxBytes) : text;
|
|
235
|
-
}
|
|
236
|
-
const decoder = new TextDecoder("utf-8", { fatal: false });
|
|
237
|
-
let collected = "";
|
|
238
|
-
let bytesRead = 0;
|
|
239
|
-
const cancelOnAbort = () => {
|
|
240
|
-
void reader.cancel(signal?.reason).catch(() => undefined);
|
|
241
|
-
};
|
|
242
|
-
signal?.addEventListener("abort", cancelOnAbort, { once: true });
|
|
243
|
-
try {
|
|
244
|
-
while (bytesRead < maxBytes) {
|
|
245
|
-
const { done, value } = signal
|
|
246
|
-
? await readWithAbort(reader, signal)
|
|
247
|
-
: await reader.read();
|
|
248
|
-
if (signal?.aborted) {
|
|
249
|
-
throw signal.reason ?? new Error("Response body read aborted");
|
|
250
|
-
}
|
|
251
|
-
if (done)
|
|
252
|
-
break;
|
|
253
|
-
if (!value)
|
|
254
|
-
continue;
|
|
255
|
-
const remaining = maxBytes - bytesRead;
|
|
256
|
-
if (value.byteLength > remaining) {
|
|
257
|
-
collected += decoder.decode(value.subarray(0, remaining), {
|
|
258
|
-
stream: true,
|
|
259
|
-
});
|
|
260
|
-
bytesRead += remaining;
|
|
261
|
-
try {
|
|
262
|
-
await reader.cancel();
|
|
263
|
-
}
|
|
264
|
-
catch {
|
|
265
|
-
// ignore — we're abandoning the body deliberately
|
|
266
|
-
}
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
269
|
-
collected += decoder.decode(value, { stream: true });
|
|
270
|
-
bytesRead += value.byteLength;
|
|
271
|
-
}
|
|
272
|
-
collected += decoder.decode();
|
|
273
|
-
}
|
|
274
|
-
finally {
|
|
275
|
-
signal?.removeEventListener("abort", cancelOnAbort);
|
|
276
|
-
try {
|
|
277
|
-
reader.releaseLock();
|
|
278
|
-
}
|
|
279
|
-
catch {
|
|
280
|
-
// already released
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
return collected;
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Mid-stream silence budget.
|
|
287
|
-
*
|
|
288
|
-
* This is deliberately generous because "no bytes" does **not** mean "dead
|
|
289
|
-
* socket" on an OpenAI-compatible endpoint. Most self-hosted runtimes (vLLM /
|
|
290
|
-
* SGLang and the tool-call parsers layered on top of them) buffer an entire
|
|
291
|
-
* `tool_calls` delta before emitting it, so a model writing a large file goes
|
|
292
|
-
* completely silent on the wire for as long as the generation takes. A 90s
|
|
293
|
-
* budget aborted those healthy streams at `firstToken + 90s`, reported the
|
|
294
|
-
* abort as a network failure, and burned three identical retries that each
|
|
295
|
-
* re-generated the same prefix before one happened to finish inside the window.
|
|
296
|
-
*/
|
|
297
|
-
export const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 240_000;
|
|
298
|
-
export const THINKING_STREAM_IDLE_TIMEOUT_MS = 900_000;
|
|
299
|
-
export const THINKING_STREAM_INITIAL_IDLE_TIMEOUT_MS = 900_000;
|
|
300
|
-
export function streamIdleBudgets(reasoningEnabled) {
|
|
301
|
-
const idleTimeoutMs = reasoningEnabled
|
|
302
|
-
? THINKING_STREAM_IDLE_TIMEOUT_MS
|
|
303
|
-
: DEFAULT_STREAM_IDLE_TIMEOUT_MS;
|
|
304
|
-
return {
|
|
305
|
-
idleTimeoutMs,
|
|
306
|
-
outputIdleTimeoutMs: Math.round(idleTimeoutMs * 1.5),
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Marker appended to the message of a stall that happened on a **live**
|
|
311
|
-
* connection (bytes/keepalives were still arriving, or output had already
|
|
312
|
-
* started and simply stopped). Such a stall is not a transport failure, so the
|
|
313
|
-
* recovery layer must not classify it as `network` and retry the identical
|
|
314
|
-
* request against the identical route.
|
|
315
|
-
*/
|
|
316
|
-
export const STREAM_STALL_MARKER = "no model output";
|
|
317
|
-
function readWithAbort(reader, signal) {
|
|
318
|
-
if (signal.aborted) {
|
|
319
|
-
return Promise.reject(signal.reason ?? new Error("Stream aborted"));
|
|
320
|
-
}
|
|
321
|
-
return new Promise((resolve, reject) => {
|
|
322
|
-
let settled = false;
|
|
323
|
-
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
324
|
-
const succeed = (value) => {
|
|
325
|
-
if (settled)
|
|
326
|
-
return;
|
|
327
|
-
settled = true;
|
|
328
|
-
cleanup();
|
|
329
|
-
resolve(value);
|
|
330
|
-
};
|
|
331
|
-
const fail = (error) => {
|
|
332
|
-
if (settled)
|
|
333
|
-
return;
|
|
334
|
-
settled = true;
|
|
335
|
-
cleanup();
|
|
336
|
-
reject(error);
|
|
337
|
-
};
|
|
338
|
-
const abort = () => {
|
|
339
|
-
fail(signal.reason ?? new Error("Stream aborted"));
|
|
340
|
-
};
|
|
341
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
342
|
-
try {
|
|
343
|
-
void reader.read().then(succeed, fail);
|
|
344
|
-
}
|
|
345
|
-
catch (error) {
|
|
346
|
-
fail(error);
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
export async function* readStreamLines(response, options = {}) {
|
|
351
|
-
if (!response.body)
|
|
352
|
-
return;
|
|
353
|
-
const idleTimeoutMs = options.idleTimeoutMs ?? DEFAULT_STREAM_IDLE_TIMEOUT_MS;
|
|
354
|
-
const outputIdleTimeoutMs = options.outputIdleTimeoutMs ?? Math.round(idleTimeoutMs * 1.5);
|
|
355
|
-
const trackOutput = typeof options.outputProgress === "function";
|
|
356
|
-
const maxBytes = options.maxBytes ?? 16 * 1024 * 1024;
|
|
357
|
-
const idleController = new AbortController();
|
|
358
|
-
let idleTimer;
|
|
359
|
-
let outputTimer;
|
|
360
|
-
let idleFired = false;
|
|
361
|
-
let firedWatchdog = "transport";
|
|
362
|
-
let lastOutputProgress = trackOutput ? options.outputProgress() : 0;
|
|
363
|
-
const fireStall = (watchdog) => {
|
|
364
|
-
if (idleFired)
|
|
365
|
-
return;
|
|
366
|
-
idleFired = true;
|
|
367
|
-
firedWatchdog = watchdog;
|
|
368
|
-
idleController.abort();
|
|
369
|
-
};
|
|
370
|
-
const clearIdleTimers = () => {
|
|
371
|
-
if (idleTimer)
|
|
372
|
-
clearTimeout(idleTimer);
|
|
373
|
-
if (outputTimer)
|
|
374
|
-
clearTimeout(outputTimer);
|
|
375
|
-
idleTimer = undefined;
|
|
376
|
-
outputTimer = undefined;
|
|
377
|
-
};
|
|
378
|
-
const armOutputTimer = () => {
|
|
379
|
-
if (!trackOutput)
|
|
380
|
-
return;
|
|
381
|
-
if (outputTimer)
|
|
382
|
-
clearTimeout(outputTimer);
|
|
383
|
-
outputTimer = setTimeout(() => fireStall("output"), outputIdleTimeoutMs);
|
|
384
|
-
};
|
|
385
|
-
const resetIdleTimer = () => {
|
|
386
|
-
if (idleTimer)
|
|
387
|
-
clearTimeout(idleTimer);
|
|
388
|
-
idleTimer = setTimeout(() => fireStall("transport"), idleTimeoutMs);
|
|
389
|
-
};
|
|
390
|
-
const noteOutputProgress = () => {
|
|
391
|
-
if (!trackOutput)
|
|
392
|
-
return;
|
|
393
|
-
const current = options.outputProgress();
|
|
394
|
-
if (current <= lastOutputProgress)
|
|
395
|
-
return;
|
|
396
|
-
lastOutputProgress = current;
|
|
397
|
-
armOutputTimer();
|
|
398
|
-
};
|
|
399
|
-
const stallError = () => firedWatchdog === "output"
|
|
400
|
-
? new ProviderError(`Provider stream stalled — ${STREAM_STALL_MARKER} for ${Math.round(outputIdleTimeoutMs / 1000)}s.`)
|
|
401
|
-
: new ProviderError(`Provider stream stalled — no data for ${Math.round(idleTimeoutMs / 1000)}s.`);
|
|
402
|
-
resetIdleTimer();
|
|
403
|
-
armOutputTimer();
|
|
404
|
-
const onCallerAbort = () => idleController.abort(options.signal?.reason);
|
|
405
|
-
options.signal?.addEventListener("abort", onCallerAbort, { once: true });
|
|
406
|
-
// A caller abort must surface as an abort error, not as a clean
|
|
407
|
-
// end-of-stream — otherwise the partial text is returned as a successful
|
|
408
|
-
// completion and enters history as the model's final answer.
|
|
409
|
-
const callerAbortError = () => options.signal?.reason ??
|
|
410
|
-
new DOMException("The operation was aborted.", "AbortError");
|
|
411
|
-
if (options.signal?.aborted) {
|
|
412
|
-
clearIdleTimers();
|
|
413
|
-
throw callerAbortError();
|
|
414
|
-
}
|
|
415
|
-
// If the idle watchdog already fired, bail before starting the loop.
|
|
416
|
-
if (idleController.signal.aborted) {
|
|
417
|
-
clearIdleTimers();
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
const reader = response.body.getReader();
|
|
421
|
-
const decoder = new TextDecoder();
|
|
422
|
-
let buffer = "";
|
|
423
|
-
let bytesRead = 0;
|
|
424
|
-
const cancelReaderOnAbort = () => {
|
|
425
|
-
reader.cancel().catch(() => undefined);
|
|
426
|
-
};
|
|
427
|
-
idleController.signal.addEventListener("abort", cancelReaderOnAbort, {
|
|
428
|
-
once: true,
|
|
429
|
-
});
|
|
430
|
-
try {
|
|
431
|
-
while (true) {
|
|
432
|
-
noteOutputProgress();
|
|
433
|
-
if (idleController.signal.aborted) {
|
|
434
|
-
if (idleFired)
|
|
435
|
-
throw stallError();
|
|
436
|
-
throw callerAbortError();
|
|
437
|
-
}
|
|
438
|
-
let readResult;
|
|
439
|
-
try {
|
|
440
|
-
readResult = await readWithAbort(reader, idleController.signal);
|
|
441
|
-
}
|
|
442
|
-
catch (error) {
|
|
443
|
-
if (idleFired)
|
|
444
|
-
throw stallError();
|
|
445
|
-
throw error;
|
|
446
|
-
}
|
|
447
|
-
const { done, value } = readResult;
|
|
448
|
-
if (done) {
|
|
449
|
-
if (idleFired)
|
|
450
|
-
throw stallError();
|
|
451
|
-
break;
|
|
452
|
-
}
|
|
453
|
-
if (value) {
|
|
454
|
-
bytesRead += value.byteLength;
|
|
455
|
-
if (bytesRead > maxBytes) {
|
|
456
|
-
throw new ProviderError(`Provider stream exceeded ${maxBytes.toLocaleString()} bytes — aborting.`);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
resetIdleTimer();
|
|
460
|
-
options.onActivity?.();
|
|
461
|
-
buffer += decoder.decode(value, { stream: true });
|
|
462
|
-
const lines = buffer.split("\n");
|
|
463
|
-
buffer = lines.pop() ?? "";
|
|
464
|
-
for (const line of lines)
|
|
465
|
-
yield line;
|
|
466
|
-
}
|
|
467
|
-
if (buffer.length > 0)
|
|
468
|
-
yield buffer;
|
|
469
|
-
}
|
|
470
|
-
finally {
|
|
471
|
-
clearIdleTimers();
|
|
472
|
-
options.signal?.removeEventListener("abort", onCallerAbort);
|
|
473
|
-
idleController.signal.removeEventListener("abort", cancelReaderOnAbort);
|
|
474
|
-
void reader.cancel().catch(() => undefined);
|
|
475
|
-
try {
|
|
476
|
-
reader.releaseLock();
|
|
477
|
-
}
|
|
478
|
-
catch {
|
|
479
|
-
// already released
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
const DEFAULT_COMPATIBLE_REASONING_ARTIFACT_POLICY = {
|
|
484
|
-
scope: "all-history",
|
|
485
|
-
persistence: "tool-turn",
|
|
486
|
-
};
|
|
487
|
-
const PRESERVED_FINAL_TURN_ARTIFACT_POLICY = {
|
|
488
|
-
scope: "all-history",
|
|
489
|
-
persistence: "all-turns",
|
|
490
|
-
};
|
|
491
|
-
export function compatibleArtifactPolicyFor(preservation) {
|
|
492
|
-
return preservation === "required"
|
|
493
|
-
? PRESERVED_FINAL_TURN_ARTIFACT_POLICY
|
|
494
|
-
: DEFAULT_COMPATIBLE_REASONING_ARTIFACT_POLICY;
|
|
495
|
-
}
|
|
496
|
-
function artifactRaw(value) {
|
|
497
|
-
if (typeof value === "string")
|
|
498
|
-
return value;
|
|
499
|
-
if (Array.isArray(value))
|
|
500
|
-
return value;
|
|
501
|
-
if (value && typeof value === "object") {
|
|
502
|
-
return value;
|
|
503
|
-
}
|
|
504
|
-
return undefined;
|
|
505
|
-
}
|
|
506
|
-
/**
|
|
507
|
-
* Reads the reasoning text off an OpenAI-compatible `message`/`delta`.
|
|
508
|
-
*
|
|
509
|
-
* Most routes use `reasoning_content` (DeepSeek/vLLM style) or `reasoning`
|
|
510
|
-
* (OpenRouter style). Merge Gateway normalizes every upstream vendor onto a
|
|
511
|
-
* third field, `thinking` (+ `thinking_signature`), on both its
|
|
512
|
-
* chat.completion messages and its chat.completion.chunk deltas — verified live
|
|
513
|
-
* against api-gateway.merge.dev/v1/openai for qwen/qwen3.8-max,
|
|
514
|
-
* zai/glm-5.3-flash and deepseek/deepseek-v4-flash-0731. Without this branch the
|
|
515
|
-
* chain of thought arrives on the wire and is silently dropped, which looks
|
|
516
|
-
* exactly like a model that never reasoned.
|
|
517
|
-
*
|
|
518
|
-
* Only strings are accepted: Anthropic-shaped `thinking` request/response
|
|
519
|
-
* objects (`{type:"disabled"}`, content blocks) must not be treated as text.
|
|
520
|
-
*/
|
|
521
|
-
function openAiReasoningText(channel) {
|
|
522
|
-
const primary = channel?.reasoning_content ?? channel?.reasoning;
|
|
523
|
-
if (typeof primary === "string" && primary)
|
|
524
|
-
return primary;
|
|
525
|
-
const thinking = channel?.thinking;
|
|
526
|
-
return typeof thinking === "string" && thinking ? thinking : undefined;
|
|
527
|
-
}
|
|
528
|
-
function compatibleReasoningArtifacts(input) {
|
|
529
|
-
const policy = input.policy ?? DEFAULT_COMPATIBLE_REASONING_ARTIFACT_POLICY;
|
|
530
|
-
const provenance = createReasoningArtifactProvenance({
|
|
531
|
-
provider: input.providerId,
|
|
532
|
-
model: input.model,
|
|
533
|
-
dialect: "openai-compatible",
|
|
534
|
-
endpoint: input.baseUrl,
|
|
535
|
-
});
|
|
536
|
-
const artifacts = [];
|
|
537
|
-
const primaryToolPosition = input.toolCalls.length > 0 ? 0 : undefined;
|
|
538
|
-
if (input.reasoning?.text) {
|
|
539
|
-
artifacts.push(createReasoningArtifact({
|
|
540
|
-
kind: "plaintext",
|
|
541
|
-
raw: input.reasoning.text,
|
|
542
|
-
displaySummary: input.reasoning.text,
|
|
543
|
-
provenance,
|
|
544
|
-
replay: policy,
|
|
545
|
-
position: {
|
|
546
|
-
sequence: input.reasoning.sequence,
|
|
547
|
-
placement: primaryToolPosition === undefined ? "assistant" : "before-tool-call",
|
|
548
|
-
...(primaryToolPosition === undefined
|
|
549
|
-
? {}
|
|
550
|
-
: { toolCallIndex: primaryToolPosition }),
|
|
551
|
-
},
|
|
552
|
-
}));
|
|
553
|
-
}
|
|
554
|
-
for (const detail of input.details ?? []) {
|
|
555
|
-
const visible = visibleReasoningDetailText(detail.raw);
|
|
556
|
-
artifacts.push(createReasoningArtifact({
|
|
557
|
-
kind: "structured-details",
|
|
558
|
-
raw: detail.raw,
|
|
559
|
-
...(visible ? { displaySummary: visible } : {}),
|
|
560
|
-
provenance,
|
|
561
|
-
replay: policy,
|
|
562
|
-
position: {
|
|
563
|
-
sequence: detail.sequence,
|
|
564
|
-
placement: primaryToolPosition === undefined ? "assistant" : "before-tool-call",
|
|
565
|
-
...(primaryToolPosition === undefined
|
|
566
|
-
? {}
|
|
567
|
-
: { toolCallIndex: primaryToolPosition }),
|
|
568
|
-
},
|
|
569
|
-
}));
|
|
570
|
-
}
|
|
571
|
-
for (const signature of input.thoughtSignatures ?? []) {
|
|
572
|
-
const toolCallIndex = signature.toolCallIndex;
|
|
573
|
-
artifacts.push(createReasoningArtifact({
|
|
574
|
-
kind: "thought-signature",
|
|
575
|
-
raw: signature.raw,
|
|
576
|
-
provenance,
|
|
577
|
-
replay: toolCallIndex === undefined
|
|
578
|
-
? { scope: "none", persistence: "never" }
|
|
579
|
-
: { scope: "tool-turn", persistence: "tool-turn" },
|
|
580
|
-
position: {
|
|
581
|
-
sequence: signature.sequence,
|
|
582
|
-
placement: toolCallIndex === undefined ? "assistant" : "on-tool-call",
|
|
583
|
-
...(toolCallIndex === undefined ? {} : { toolCallIndex }),
|
|
584
|
-
},
|
|
585
|
-
}));
|
|
586
|
-
}
|
|
587
|
-
return artifacts.length ? artifacts : undefined;
|
|
588
|
-
}
|
|
589
|
-
/** Map shared OpenAI-compatible payload → CompletionResult (includes usage). */
|
|
590
|
-
export function toCompletionResult(provider, model, payload) {
|
|
591
|
-
const usage = withReasoningObservation(payload.usage, Boolean(payload.reasoningBlock?.text.trim()) ||
|
|
592
|
-
reasoningArtifactsObserved(payload.reasoningArtifacts));
|
|
593
|
-
return {
|
|
594
|
-
text: payload.text,
|
|
595
|
-
provider,
|
|
596
|
-
model,
|
|
597
|
-
...(payload.toolCalls?.length ? { toolCalls: payload.toolCalls } : {}),
|
|
598
|
-
...(payload.finishReason ? { finishReason: payload.finishReason } : {}),
|
|
599
|
-
...(usage ? { usage } : {}),
|
|
600
|
-
...(payload.reasoningBlock ? { reasoningBlock: payload.reasoningBlock } : {}),
|
|
601
|
-
...(payload.reasoningArtifacts
|
|
602
|
-
? { reasoningArtifacts: payload.reasoningArtifacts }
|
|
603
|
-
: {}),
|
|
604
|
-
};
|
|
605
|
-
}
|
|
606
|
-
/**
|
|
607
|
-
* Reassembles SSE `data:` frames.
|
|
608
|
-
*
|
|
609
|
-
* Per the SSE spec a single event's payload may be split across several `data:`
|
|
610
|
-
* lines that the client must concatenate before parsing; each fragment was
|
|
611
|
-
* previously parsed on its own, failed `JSON.parse`, and was dropped as a
|
|
612
|
-
* malformed keepalive — losing content without a trace.
|
|
613
|
-
*
|
|
614
|
-
* A payload is released as soon as it is syntactically complete, so
|
|
615
|
-
* single-line frames behave exactly as before. A blank line (frame terminator)
|
|
616
|
-
* discards an incomplete remainder, and a runaway fragment is dropped rather
|
|
617
|
-
* than corrupting later frames.
|
|
618
|
-
*/
|
|
619
|
-
export function createSseFrameAssembler(options) {
|
|
620
|
-
const maxBufferedBytes = options?.maxBufferedBytes ?? 1_000_000;
|
|
621
|
-
let buffered = "";
|
|
622
|
-
const complete = (payload) => {
|
|
623
|
-
if (payload === "[DONE]")
|
|
624
|
-
return true;
|
|
625
|
-
try {
|
|
626
|
-
JSON.parse(payload);
|
|
627
|
-
return true;
|
|
628
|
-
}
|
|
629
|
-
catch {
|
|
630
|
-
return false;
|
|
631
|
-
}
|
|
632
|
-
};
|
|
633
|
-
return {
|
|
634
|
-
pushLine(line) {
|
|
635
|
-
const trimmed = line.trim();
|
|
636
|
-
if (trimmed === "") {
|
|
637
|
-
// End of event: an incomplete remainder was malformed.
|
|
638
|
-
buffered = "";
|
|
639
|
-
return undefined;
|
|
640
|
-
}
|
|
641
|
-
if (!trimmed.startsWith("data:"))
|
|
642
|
-
return undefined;
|
|
643
|
-
const chunk = trimmed.slice(5).trim();
|
|
644
|
-
buffered = buffered ? `${buffered}\n${chunk}` : chunk;
|
|
645
|
-
if (complete(buffered)) {
|
|
646
|
-
const payload = buffered;
|
|
647
|
-
buffered = "";
|
|
648
|
-
return payload;
|
|
649
|
-
}
|
|
650
|
-
if (buffered.length > maxBufferedBytes)
|
|
651
|
-
buffered = "";
|
|
652
|
-
return undefined;
|
|
653
|
-
},
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
export function toOpenAiMessages(messages, supportsVision = true, replay) {
|
|
657
|
-
return toOpenAiToolMessages(messages, (message) => {
|
|
658
|
-
if (supportsVision &&
|
|
659
|
-
message.images &&
|
|
660
|
-
message.images.length > 0) {
|
|
661
|
-
const parts = [];
|
|
662
|
-
if (message.content)
|
|
663
|
-
parts.push({ type: "text", text: message.content });
|
|
664
|
-
for (const img of message.images) {
|
|
665
|
-
parts.push({
|
|
666
|
-
type: "image_url",
|
|
667
|
-
image_url: {
|
|
668
|
-
url: `data:${img.mediaType};base64,${img.dataBase64}`,
|
|
669
|
-
detail: "high",
|
|
670
|
-
},
|
|
671
|
-
});
|
|
672
|
-
}
|
|
673
|
-
return parts;
|
|
674
|
-
}
|
|
675
|
-
return message.content;
|
|
676
|
-
}, replay);
|
|
677
|
-
}
|
|
678
|
-
export { classifyBynaraModel, classifyNvidiaModel, } from "./model-families.js";
|
|
679
|
-
function supportsOpenRouterReasoning(model) {
|
|
680
|
-
return /:thinking|deepseek-r1|qwen3|kimi-k2|claude-(?:opus|sonnet|haiku)-4|gpt-5|(?:^|\/)o[134]|grok.*reasoner/i.test(model);
|
|
681
|
-
}
|
|
682
|
-
const MODAL_DEFAULT_EFFORTS = ["low", "high", "max"];
|
|
683
|
-
const MODAL_EFFORT_PREFERENCE = {
|
|
684
|
-
minimal: ["minimal", "low", "medium", "high", "max"],
|
|
685
|
-
low: ["low", "minimal", "medium", "high", "max"],
|
|
686
|
-
medium: ["medium", "high", "low", "max"],
|
|
687
|
-
high: ["high", "max", "medium", "low"],
|
|
688
|
-
xhigh: ["xhigh", "max", "high", "medium", "low"],
|
|
689
|
-
max: ["max", "xhigh", "high", "medium", "low"],
|
|
690
|
-
};
|
|
691
|
-
function pickAdvertisedEffort(effort, advertised) {
|
|
692
|
-
const order = MODAL_EFFORT_PREFERENCE[effort] ?? MODAL_EFFORT_PREFERENCE.medium;
|
|
693
|
-
return (order.find((candidate) => advertised.includes(candidate)) ??
|
|
694
|
-
advertised[advertised.length - 1]);
|
|
695
|
-
}
|
|
696
|
-
export function buildReasoningPayload(reasoning, style, model, providerId, control) {
|
|
697
|
-
if (control) {
|
|
698
|
-
return {
|
|
699
|
-
...emitReasoningControls({
|
|
700
|
-
profile: control.profile,
|
|
701
|
-
preference: reasoning,
|
|
702
|
-
willReplayReasoning: control.willReplayReasoning,
|
|
703
|
-
}),
|
|
704
|
-
};
|
|
705
|
-
}
|
|
706
|
-
if (style === "none")
|
|
707
|
-
return {};
|
|
708
|
-
const enabled = Boolean(reasoning?.enabled);
|
|
709
|
-
const effort = reasoning?.effort ?? "medium";
|
|
710
|
-
// Map expanded effort levels to the classic low/medium/high subset for
|
|
711
|
-
// providers that only understand the smaller set.
|
|
712
|
-
const clampEffort = (e) => {
|
|
713
|
-
if (e === "none" || e === "minimal" || e === "low")
|
|
714
|
-
return "low";
|
|
715
|
-
if (e === "max" || e === "xhigh" || e === "high")
|
|
716
|
-
return "high";
|
|
717
|
-
return "medium";
|
|
718
|
-
};
|
|
719
|
-
switch (style) {
|
|
720
|
-
case "meta": {
|
|
721
|
-
const metaEffort = (e) => {
|
|
722
|
-
if (e === "none" || e === "minimal")
|
|
723
|
-
return "minimal";
|
|
724
|
-
if (e === "max" || e === "xhigh")
|
|
725
|
-
return "xhigh";
|
|
726
|
-
return e;
|
|
727
|
-
};
|
|
728
|
-
if (!enabled)
|
|
729
|
-
return { reasoning_effort: "minimal" };
|
|
730
|
-
return { reasoning_effort: metaEffort(effort) };
|
|
731
|
-
}
|
|
732
|
-
case "openai": {
|
|
733
|
-
if (!enabled) {
|
|
734
|
-
return effort === "none" ? { reasoning_effort: "none" } : {};
|
|
735
|
-
}
|
|
736
|
-
// `reasoning_effort` is the Chat Completions knob. The nested
|
|
737
|
-
// `reasoning` object belongs to the Responses API; strict gateways reject
|
|
738
|
-
// unknown top-level fields with a hard 400.
|
|
739
|
-
return { reasoning_effort: clampEffort(effort) };
|
|
740
|
-
}
|
|
741
|
-
case "bynara": {
|
|
742
|
-
const kind = classifyBynaraModel(model ?? "");
|
|
743
|
-
const noThinking = !enabled || effort === "none" || effort === "minimal";
|
|
744
|
-
switch (kind) {
|
|
745
|
-
case "kimi":
|
|
746
|
-
if (noThinking)
|
|
747
|
-
return { chat_template_kwargs: { thinking: false } };
|
|
748
|
-
if (effort === "high" || effort === "xhigh" || effort === "max") {
|
|
749
|
-
return {
|
|
750
|
-
chat_template_kwargs: { thinking: true },
|
|
751
|
-
reasoning_effort: "high",
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
if (effort === "low") {
|
|
755
|
-
return {
|
|
756
|
-
chat_template_kwargs: { thinking: true },
|
|
757
|
-
reasoning_effort: "low",
|
|
758
|
-
};
|
|
759
|
-
}
|
|
760
|
-
return { chat_template_kwargs: { thinking: true } };
|
|
761
|
-
case "deepseek":
|
|
762
|
-
case "agnes":
|
|
763
|
-
if (noThinking)
|
|
764
|
-
return { reasoning_effort: "none" };
|
|
765
|
-
return { reasoning_effort: clampEffort(effort) };
|
|
766
|
-
case "stepfun":
|
|
767
|
-
if (noThinking)
|
|
768
|
-
return {};
|
|
769
|
-
return { reasoning_effort: clampEffort(effort) };
|
|
770
|
-
case "none":
|
|
771
|
-
return {};
|
|
772
|
-
}
|
|
773
|
-
return {};
|
|
774
|
-
}
|
|
775
|
-
case "agentrouter": {
|
|
776
|
-
// AgentRouter proxies three families, each with a *different* reasoning
|
|
777
|
-
// contract (verified live against agentrouter.org/v1, 2026-07). We send
|
|
778
|
-
// only the standard top-level knob each one honours — no redundant
|
|
779
|
-
// `reasoning` object (none of the routed models read it).
|
|
780
|
-
const m = (model ?? "").toLowerCase();
|
|
781
|
-
const clamped = clampEffort(effort);
|
|
782
|
-
// OpenAI gpt-5.x / o-series: top-level `reasoning_effort`, and it uniquely
|
|
783
|
-
// supports "minimal". These models can't be fully disabled, so "off"
|
|
784
|
-
// degrades to the cheapest "minimal" rather than the medium default.
|
|
785
|
-
if (/(?:^|\/)gpt-5|(?:^|\/)o[134](?:\b|-)/.test(m)) {
|
|
786
|
-
if (!enabled)
|
|
787
|
-
return { reasoning_effort: "minimal" };
|
|
788
|
-
const gptEffort = effort === "none"
|
|
789
|
-
? "minimal"
|
|
790
|
-
: effort === "xhigh" || effort === "max"
|
|
791
|
-
? "high"
|
|
792
|
-
: effort; // minimal | low | medium | high
|
|
793
|
-
return { reasoning_effort: gptEffort };
|
|
794
|
-
}
|
|
795
|
-
// Zhipu GLM thinks by DEFAULT; `reasoning_effort` only modulates depth and
|
|
796
|
-
// cannot turn it off. The one knob that actually disables it on this
|
|
797
|
-
// gateway is `thinking.type=disabled` — so "off" must send that.
|
|
798
|
-
if (/glm/.test(m)) {
|
|
799
|
-
if (!enabled)
|
|
800
|
-
return { thinking: { type: "disabled" } };
|
|
801
|
-
return { reasoning_effort: clamped };
|
|
802
|
-
}
|
|
803
|
-
// Anthropic Claude: `reasoning_effort` enables extended thinking (the
|
|
804
|
-
// gateway maps it to a thinking budget). Thinking is OFF by default, so
|
|
805
|
-
// "off" simply omits the knob. `buildChatBody` floors max_tokens above the
|
|
806
|
-
// budget so enabling it never trips the gateway's budget precondition.
|
|
807
|
-
if (/claude/.test(m)) {
|
|
808
|
-
if (!enabled)
|
|
809
|
-
return {};
|
|
810
|
-
return { reasoning_effort: clamped };
|
|
811
|
-
}
|
|
812
|
-
// Unknown model routed by AgentRouter → plain OpenAI-compatible behavior.
|
|
813
|
-
if (!enabled)
|
|
814
|
-
return {};
|
|
815
|
-
return { reasoning_effort: clamped };
|
|
816
|
-
}
|
|
817
|
-
case "openrouter":
|
|
818
|
-
if (!enabled)
|
|
819
|
-
return {};
|
|
820
|
-
if (!supportsOpenRouterReasoning(model ?? ""))
|
|
821
|
-
return {};
|
|
822
|
-
return { reasoning: { enabled: true, effort: clampEffort(effort) } };
|
|
823
|
-
case "modal": {
|
|
824
|
-
const advertised = providerId !== undefined && model
|
|
825
|
-
? modelReasoningEfforts(providerId, model)
|
|
826
|
-
: undefined;
|
|
827
|
-
if (!advertised &&
|
|
828
|
-
providerId !== undefined &&
|
|
829
|
-
model &&
|
|
830
|
-
!modelSupportsThinking(providerId, model)) {
|
|
831
|
-
return {};
|
|
832
|
-
}
|
|
833
|
-
if (!enabled || effort === "none")
|
|
834
|
-
return { reasoning_effort: "none" };
|
|
835
|
-
return {
|
|
836
|
-
reasoning_effort: pickAdvertisedEffort(effort, advertised ?? MODAL_DEFAULT_EFFORTS),
|
|
837
|
-
};
|
|
838
|
-
}
|
|
839
|
-
case "stepfun":
|
|
840
|
-
// Step 3.5/3.7 Flash enables a <think> block by default on compatible
|
|
841
|
-
// hosts. Omitting an OpenAI reasoning field does not turn that default
|
|
842
|
-
// off, so compaction would still buy hidden reasoning tokens. vLLM's
|
|
843
|
-
// StepFun template honours this explicit per-request switch.
|
|
844
|
-
return { chat_template_kwargs: { enable_thinking: enabled } };
|
|
845
|
-
case "nvidia": {
|
|
846
|
-
const kind = classifyNvidiaModel(model ?? "");
|
|
847
|
-
switch (kind) {
|
|
848
|
-
case "kimi-thinking":
|
|
849
|
-
return {
|
|
850
|
-
chat_template_kwargs: {
|
|
851
|
-
thinking: enabled,
|
|
852
|
-
},
|
|
853
|
-
};
|
|
854
|
-
case "deepseek-v4":
|
|
855
|
-
// NVIDIA's DeepSeek V4 API accepts none/high/max. Map expanded
|
|
856
|
-
// effort levels: none/minimal/low → none; medium/high/xhigh → high.
|
|
857
|
-
return {
|
|
858
|
-
chat_template_kwargs: {
|
|
859
|
-
thinking: enabled,
|
|
860
|
-
reasoning_effort: enabled
|
|
861
|
-
? clampEffort(effort) === "low"
|
|
862
|
-
? "none"
|
|
863
|
-
: "high"
|
|
864
|
-
: "none",
|
|
865
|
-
},
|
|
866
|
-
};
|
|
867
|
-
case "thinking":
|
|
868
|
-
return {
|
|
869
|
-
chat_template_kwargs: {
|
|
870
|
-
thinking: enabled,
|
|
871
|
-
},
|
|
872
|
-
};
|
|
873
|
-
case "nemotron-3": {
|
|
874
|
-
// Nemotron-3 supports both `enable_thinking` and an optional
|
|
875
|
-
// `reasoning_budget` cap. Map expanded effort to budget values.
|
|
876
|
-
if (!enabled) {
|
|
877
|
-
return {
|
|
878
|
-
chat_template_kwargs: { enable_thinking: false },
|
|
879
|
-
};
|
|
880
|
-
}
|
|
881
|
-
const clamped = clampEffort(effort);
|
|
882
|
-
const budget = clamped === "low" ? 4_096 : clamped === "high" ? 16_384 : 8_192;
|
|
883
|
-
return {
|
|
884
|
-
reasoning_budget: budget,
|
|
885
|
-
chat_template_kwargs: { enable_thinking: true },
|
|
886
|
-
};
|
|
887
|
-
}
|
|
888
|
-
case "glm-thinking":
|
|
889
|
-
// GLM-5 / 4.5 expects `clear_thinking:false` alongside
|
|
890
|
-
// `enable_thinking:true` per the NIM docs example.
|
|
891
|
-
return {
|
|
892
|
-
chat_template_kwargs: enabled
|
|
893
|
-
? { enable_thinking: true, clear_thinking: false }
|
|
894
|
-
: { enable_thinking: false },
|
|
895
|
-
};
|
|
896
|
-
case "enable-thinking":
|
|
897
|
-
// Gemma 3/4 only documents `enable_thinking`; do not add
|
|
898
|
-
// `clear_thinking` here since the chat template doesn't accept it.
|
|
899
|
-
return {
|
|
900
|
-
chat_template_kwargs: { enable_thinking: enabled },
|
|
901
|
-
};
|
|
902
|
-
case "effort-only":
|
|
903
|
-
// NVIDIA GPT-OSS accepts only low/medium/high, so a retry cannot
|
|
904
|
-
// fully disable it. Keep it at the lowest supported effort instead
|
|
905
|
-
// of omitting the field and reverting to NVIDIA's medium default.
|
|
906
|
-
if (!enabled && /gpt-oss/i.test(model ?? "")) {
|
|
907
|
-
return { reasoning_effort: "low" };
|
|
908
|
-
}
|
|
909
|
-
if (!enabled && /qwen3|mistral-/i.test(model ?? "")) {
|
|
910
|
-
return { reasoning_effort: "none" };
|
|
911
|
-
}
|
|
912
|
-
return { reasoning_effort: clampEffort(effort) };
|
|
913
|
-
case "none":
|
|
914
|
-
default:
|
|
915
|
-
return {};
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
default:
|
|
919
|
-
return {};
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
/**
|
|
923
|
-
* Detects provider errors that mean the model rejected one of our
|
|
924
|
-
* reasoning/thinking knobs (chat_template_kwargs, enable_thinking,
|
|
925
|
-
* clear_thinking, reasoning_effort, reasoning_budget, thinking). NVIDIA NIM and
|
|
926
|
-
* other OpenAI-compatible gateways return a 400/422 for chat templates that do
|
|
927
|
-
* not accept these fields. When this matches, the router strips the reasoning
|
|
928
|
-
* payload and retries so an unsupported option never fails the whole request.
|
|
929
|
-
*/
|
|
930
|
-
export function isReasoningUnsupportedError(error) {
|
|
931
|
-
if (isMissingReasoningContentError(error))
|
|
932
|
-
return false;
|
|
933
|
-
const status = error && typeof error === "object" && "status" in error
|
|
934
|
-
? Number(error.status)
|
|
935
|
-
: undefined;
|
|
936
|
-
const body = error && typeof error === "object" && "body" in error
|
|
937
|
-
? String(error.body ?? "")
|
|
938
|
-
: "";
|
|
939
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
940
|
-
const hay = `${message}\n${body}`.toLowerCase();
|
|
941
|
-
const mentionsReasoningKnob =
|
|
942
|
-
// `\breasoning\b` catches bodies like "Unrecognized request argument
|
|
943
|
-
// supplied: reasoning" so a bare reasoning-field rejection also degrades.
|
|
944
|
-
/chat_template_kwargs|enable_thinking|clear_thinking|reasoning_effort|reasoning_budget|reasoning_content|\breasoning\b|\bthinking\b/.test(hay);
|
|
945
|
-
if (!mentionsReasoningKnob)
|
|
946
|
-
return false;
|
|
947
|
-
// A 4xx that names a reasoning field is a parameter rejection — strip it.
|
|
948
|
-
if (status === 400 || status === 422)
|
|
949
|
-
return true;
|
|
950
|
-
// Any status: explicit "not supported / unknown / invalid parameter" wording.
|
|
951
|
-
return /not support|unsupported|unknown|unrecognized|not a valid|not allowed|unexpected keyword|does not accept|extra fields not permitted|additional propert|invalid[_ ]?(?:request[_ ]?)?(?:argument|parameter|field)/.test(hay);
|
|
952
|
-
}
|
|
953
|
-
const EFFORT_VOCABULARY = [
|
|
954
|
-
"none",
|
|
955
|
-
"minimal",
|
|
956
|
-
"low",
|
|
957
|
-
"medium",
|
|
958
|
-
"high",
|
|
959
|
-
"xhigh",
|
|
960
|
-
"max",
|
|
961
|
-
];
|
|
962
|
-
export function reasoningRejectionAdvice(error) {
|
|
963
|
-
const body = error && typeof error === "object" && "body" in error
|
|
964
|
-
? String(error.body ?? "")
|
|
965
|
-
: "";
|
|
966
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
967
|
-
const hay = `${message}\n${body}`.toLowerCase();
|
|
968
|
-
const mandatory = /always\s+(?:engages?\s+in|uses?|performs?)\s+(?:thinking|reasoning)|(?:thinking|reasoning)\s+cannot\s+be\s+disabled|cannot\s+be\s+disabled|can(?:no|')t\s+be\s+(?:disabled|turned\s+off)/.test(hay);
|
|
969
|
-
const clause = /(?:please\s+use|must\s+be\s+one\s+of|must\s+be|one\s+of|supported\s+values?(?:\s+are)?|valid\s+values?(?:\s+are)?|allowed\s+values?(?:\s+are)?|use)\s*:?\s*([^.;\n}"]{0,120})/.exec(hay);
|
|
970
|
-
const acceptedEfforts = clause
|
|
971
|
-
? EFFORT_VOCABULARY.filter((effort) => new RegExp(`\\b${effort}\\b`).test(clause[1] ?? ""))
|
|
972
|
-
: [];
|
|
973
|
-
if (!mandatory && acceptedEfforts.length === 0)
|
|
974
|
-
return undefined;
|
|
975
|
-
return { mandatory, acceptedEfforts };
|
|
976
|
-
}
|
|
977
|
-
export function isStreamOptionsUnsupportedError(error) {
|
|
978
|
-
const status = error && typeof error === "object" && "status" in error
|
|
979
|
-
? Number(error.status)
|
|
980
|
-
: undefined;
|
|
981
|
-
if (status !== 400 && status !== 422)
|
|
982
|
-
return false;
|
|
983
|
-
const body = error && typeof error === "object" && "body" in error
|
|
984
|
-
? String(error.body ?? "")
|
|
985
|
-
: "";
|
|
986
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
987
|
-
const hay = `${message}\n${body}`.toLowerCase();
|
|
988
|
-
return (/stream_options|stream options/.test(hay) &&
|
|
989
|
-
/not support|unsupported|unknown|unrecognized|not a valid|not allowed|unexpected keyword|does not accept|extra fields not permitted|additional propert|invalid[_ ]?(?:request[_ ]?)?(?:argument|parameter|field)/.test(hay));
|
|
990
|
-
}
|
|
991
|
-
export function isImageInputUnsupportedError(error) {
|
|
992
|
-
const status = error && typeof error === "object" && "status" in error
|
|
993
|
-
? Number(error.status)
|
|
994
|
-
: undefined;
|
|
995
|
-
const body = error && typeof error === "object" && "body" in error
|
|
996
|
-
? String(error.body ?? "")
|
|
997
|
-
: "";
|
|
998
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
999
|
-
const hay = `${message}\n${body}`.toLowerCase();
|
|
1000
|
-
const mentionsImageInput = /image_url|image url|inlinedata|inline_data|\bimages?\b|multimodal|\bvision\b|media_type|image content|content\[\d+\]|content\.\d+|parts\[\d+\]/.test(hay);
|
|
1001
|
-
if (!mentionsImageInput)
|
|
1002
|
-
return false;
|
|
1003
|
-
if (status !== undefined && status !== 400 && status !== 415 && status !== 422) {
|
|
1004
|
-
return false;
|
|
1005
|
-
}
|
|
1006
|
-
return /not support|unsupported|does not accept|cannot process|invalid[_ ]?(?:request[_ ]?)?(?:argument|parameter|field|type|value)?|unknown|unrecognized|not a valid|not allowed|only text|text[- ]only|expected a string|must be a string|additional propert/.test(hay);
|
|
1007
|
-
}
|
|
1008
|
-
export function stripImagesFromMessages(messages) {
|
|
1009
|
-
return messages.map((message) => {
|
|
1010
|
-
if (!message.images?.length)
|
|
1011
|
-
return message;
|
|
1012
|
-
const { images: _images, ...rest } = message;
|
|
1013
|
-
return rest;
|
|
1014
|
-
});
|
|
1015
|
-
}
|
|
1016
|
-
export function imageCapableMessages(provider, model, messages) {
|
|
1017
|
-
if (modelAcceptsImages(provider, model))
|
|
1018
|
-
return messages;
|
|
1019
|
-
return stripImagesFromMessages(messages);
|
|
1020
|
-
}
|
|
1021
|
-
/**
|
|
1022
|
-
* legacy Chat Completions sampling knobs: `max_tokens` must be
|
|
1023
|
-
* `max_completion_tokens`, and `temperature`/`top_p` must be omitted or left
|
|
1024
|
-
* at their default (non-default values return HTTP 400 "Unsupported
|
|
1025
|
-
* parameter"). Matched by model name (not provider) since OpenAI-compatible
|
|
1026
|
-
* gateways that pass these model IDs through to the real OpenAI API hit the
|
|
1027
|
-
* same restriction.
|
|
1028
|
-
* https://help.openai.com/en/articles/5072518 (Chat Completions section).
|
|
1029
|
-
*/
|
|
1030
|
-
export function isOpenAiReasoningModel(model) {
|
|
1031
|
-
const m = model.toLowerCase();
|
|
1032
|
-
return (/(?:^|\/)gpt-5(?:\.|-|$)/.test(m) ||
|
|
1033
|
-
/(?:^|\/)o[134](?:\.|-|$)/.test(m) ||
|
|
1034
|
-
/muse-spark/.test(m));
|
|
1035
|
-
}
|
|
1036
|
-
const DEFAULT_REASONING_OUTPUT_FLOOR = 16_384;
|
|
1037
|
-
function outputBudgetWithReasoning(requested, options) {
|
|
1038
|
-
const floor = options.control?.profile.reasoning.minOutputTokens ??
|
|
1039
|
-
DEFAULT_REASONING_OUTPUT_FLOOR;
|
|
1040
|
-
const ceiling = modelMaxOutputTokens(options.providerId, options.model, options.outputTokenLimit);
|
|
1041
|
-
const floored = Math.max(requested, floor);
|
|
1042
|
-
return ceiling !== undefined ? Math.min(floored, ceiling) : floored;
|
|
1043
|
-
}
|
|
1044
|
-
function emitChatCompletionsBody(options) {
|
|
1045
|
-
// Skip reasoning knobs entirely for models observed to reject them this
|
|
1046
|
-
// session (see isReasoningUnsupportedError). This is how thinking degrades
|
|
1047
|
-
// gracefully: the request still runs, just without the unsupported option.
|
|
1048
|
-
const capabilityDeniesThinking = options.control === undefined &&
|
|
1049
|
-
options.providerId !== undefined &&
|
|
1050
|
-
Boolean(options.reasoning?.enabled) &&
|
|
1051
|
-
!modelSupportsThinking(options.providerId, options.model);
|
|
1052
|
-
const legacyControlDenied = options.control === undefined &&
|
|
1053
|
-
options.providerId !== undefined &&
|
|
1054
|
-
isReasoningUnsupported(options.providerId, options.model);
|
|
1055
|
-
const reasoning = legacyControlDenied ||
|
|
1056
|
-
capabilityDeniesThinking ||
|
|
1057
|
-
options.control?.suppressed === true
|
|
1058
|
-
? {}
|
|
1059
|
-
: buildReasoningPayload(options.reasoning, options.reasoningStyle ?? "none", options.model, options.providerId, options.control);
|
|
1060
|
-
const reasoningOn = Boolean(options.reasoning?.enabled);
|
|
1061
|
-
// Kimchi exposes this model as `minimax-m3`; NVIDIA uses the longer
|
|
1062
|
-
// `minimaxai/minimax-m3` ID. Both need the larger default output budget.
|
|
1063
|
-
const isMinimaxM3 = /minimax-m3/i.test(options.model);
|
|
1064
|
-
const defaultMaxTokens = isMinimaxM3 ? 8_192 : reasoningOn ? 8_192 : 4_096;
|
|
1065
|
-
// One declarative sampling policy; explicit caller value wins.
|
|
1066
|
-
const sampling = options.resolvedSampling ?? {
|
|
1067
|
-
...resolveSampling({
|
|
1068
|
-
model: options.model,
|
|
1069
|
-
reasoningEnabled: reasoningOn,
|
|
1070
|
-
requestedTemperature: options.temperature,
|
|
1071
|
-
}),
|
|
1072
|
-
};
|
|
1073
|
-
const reasoningModel = isOpenAiReasoningModel(options.model);
|
|
1074
|
-
const emitTemperature = sampling.temperature !== undefined &&
|
|
1075
|
-
(options.resolvedSampling !== undefined || !reasoningModel);
|
|
1076
|
-
// Claude extended thinking via AgentRouter maps reasoning_effort to an
|
|
1077
|
-
// Anthropic `thinking.budget_tokens`, and the gateway (Bedrock) rejects the
|
|
1078
|
-
// request with HTTP 400 unless `max_tokens > budget_tokens`. Some upstream
|
|
1079
|
-
// nodes enforce this intermittently, so whenever Claude reasoning is enabled
|
|
1080
|
-
// we guarantee a ceiling that clears the largest effort budget (32000 was
|
|
1081
|
-
// verified live to succeed while staying within Opus's output cap). This is a
|
|
1082
|
-
// ceiling, not a forced length — Claude still stops at its natural stop.
|
|
1083
|
-
const claudeThinking = reasoningOn &&
|
|
1084
|
-
options.reasoningStyle === "agentrouter" &&
|
|
1085
|
-
/claude/i.test(options.model);
|
|
1086
|
-
const requestedMaxTokens = options.maxTokens ?? defaultMaxTokens;
|
|
1087
|
-
const claudeFloored = claudeThinking
|
|
1088
|
-
? Math.max(requestedMaxTokens, 32_000)
|
|
1089
|
-
: requestedMaxTokens;
|
|
1090
|
-
const effectiveMaxTokens = reasoningOn
|
|
1091
|
-
? outputBudgetWithReasoning(claudeFloored, options)
|
|
1092
|
-
: claudeFloored;
|
|
1093
|
-
const affinityKey = options.providerId === "openrouter" || options.providerId === "fireworks"
|
|
1094
|
-
? cacheAffinityKey(options.providerId, options.model, options.messages)
|
|
1095
|
-
: undefined;
|
|
1096
|
-
const body = {
|
|
1097
|
-
model: options.model,
|
|
1098
|
-
messages: toOpenAiMessages(singleLeadingSystemMessages(options.messages), options.supportsVision, options.replayTarget
|
|
1099
|
-
? {
|
|
1100
|
-
target: options.replayTarget,
|
|
1101
|
-
observe: options.reasoningArtifactReplayObserver,
|
|
1102
|
-
...(options.forceReasoningReplay ? { forceScope: true } : {}),
|
|
1103
|
-
}
|
|
1104
|
-
: undefined),
|
|
1105
|
-
stream: options.stream,
|
|
1106
|
-
...(options.providerId === "openrouter" && affinityKey
|
|
1107
|
-
? { session_id: affinityKey }
|
|
1108
|
-
: {}),
|
|
1109
|
-
...(options.providerId === "fireworks"
|
|
1110
|
-
? {
|
|
1111
|
-
perf_metrics_in_response: true,
|
|
1112
|
-
...(affinityKey
|
|
1113
|
-
? {
|
|
1114
|
-
prompt_cache_key: affinityKey,
|
|
1115
|
-
prompt_cache_isolation_key: affinityKey,
|
|
1116
|
-
}
|
|
1117
|
-
: {}),
|
|
1118
|
-
}
|
|
1119
|
-
: {}),
|
|
1120
|
-
...(reasoningModel
|
|
1121
|
-
? { max_completion_tokens: effectiveMaxTokens }
|
|
1122
|
-
: { max_tokens: effectiveMaxTokens }),
|
|
1123
|
-
// gpt-5.x / o1 / o3 / o4 only accept the default temperature (1) and
|
|
1124
|
-
// reject any explicit value — omit the field entirely rather than send
|
|
1125
|
-
// our 0.2 default and get a 400.
|
|
1126
|
-
...(emitTemperature ? { temperature: sampling.temperature } : {}),
|
|
1127
|
-
...reasoning,
|
|
1128
|
-
...openAiToolBodyFields({
|
|
1129
|
-
tools: options.tools,
|
|
1130
|
-
toolChoice: options.toolChoice,
|
|
1131
|
-
parallelToolCalls: options.parallelToolCalls,
|
|
1132
|
-
}),
|
|
1133
|
-
};
|
|
1134
|
-
if (emitTemperature && sampling.topP !== undefined) {
|
|
1135
|
-
body.top_p = sampling.topP;
|
|
1136
|
-
}
|
|
1137
|
-
// OpenAI + many OpenAI-compatible gateways attach usage on the final SSE
|
|
1138
|
-
// chunk when this is set (non-stream responses always include usage).
|
|
1139
|
-
if (options.stream && options.includeStreamUsage !== false) {
|
|
1140
|
-
body.stream_options = { include_usage: true };
|
|
1141
|
-
}
|
|
1142
|
-
return JSON.stringify(body);
|
|
1143
|
-
}
|
|
1144
|
-
export function buildChatBody(options) {
|
|
1145
|
-
return emitChatCompletionsBody(options);
|
|
1146
|
-
}
|
|
1147
|
-
/**
|
|
1148
|
-
* Serializes a compiled canonical plan onto the Chat Completions wire. Wire
|
|
1149
|
-
* dialect knobs that the plan intentionally does not model (gateway reasoning
|
|
1150
|
-
* style, stream-usage flag, replay observer) stay serializer-side extras.
|
|
1151
|
-
*/
|
|
1152
|
-
export function chatCompletionsBodyFromPlan(plan, extras = {}) {
|
|
1153
|
-
return emitChatCompletionsBody({
|
|
1154
|
-
model: plan.route.model,
|
|
1155
|
-
providerId: plan.route.provider,
|
|
1156
|
-
messages: [...plan.timeline.messages],
|
|
1157
|
-
maxTokens: plan.controls.requestedMaxTokens,
|
|
1158
|
-
temperature: plan.controls.temperature,
|
|
1159
|
-
stream: plan.controls.stream,
|
|
1160
|
-
includeStreamUsage: extras.includeStreamUsage,
|
|
1161
|
-
reasoning: plan.controls.reasoning,
|
|
1162
|
-
reasoningStyle: extras.reasoningStyle,
|
|
1163
|
-
supportsVision: plan.images.visionAccepted,
|
|
1164
|
-
control: {
|
|
1165
|
-
profile: {
|
|
1166
|
-
reasoning: plan.policy.reasoning,
|
|
1167
|
-
capabilities: { acceptedParameters: plan.policy.acceptedParameters },
|
|
1168
|
-
},
|
|
1169
|
-
willReplayReasoning: plan.replay.decisions.some((entry) => entry.decision.action === "replayed"),
|
|
1170
|
-
suppressed: plan.controls.controlSuppression !== undefined,
|
|
1171
|
-
},
|
|
1172
|
-
resolvedSampling: {
|
|
1173
|
-
temperature: plan.controls.temperature,
|
|
1174
|
-
topP: plan.controls.topP,
|
|
1175
|
-
},
|
|
1176
|
-
...(plan.policy.limits.outputTokens !== undefined
|
|
1177
|
-
? { outputTokenLimit: plan.policy.limits.outputTokens }
|
|
1178
|
-
: {}),
|
|
1179
|
-
tools: plan.tools.definitions.length
|
|
1180
|
-
? [...plan.tools.definitions]
|
|
1181
|
-
: undefined,
|
|
1182
|
-
toolChoice: plan.tools.choice,
|
|
1183
|
-
parallelToolCalls: plan.tools.parallelToolCalls,
|
|
1184
|
-
replayTarget: plan.replay.target,
|
|
1185
|
-
reasoningArtifactReplayObserver: extras.reasoningArtifactReplayObserver,
|
|
1186
|
-
...(extras.forceReasoningReplay ? { forceReasoningReplay: true } : {}),
|
|
1187
|
-
});
|
|
1188
|
-
}
|
|
1189
|
-
function sentReasoningEffort(requestBody) {
|
|
1190
|
-
try {
|
|
1191
|
-
const body = JSON.parse(requestBody);
|
|
1192
|
-
if (typeof body.reasoning_effort === "string" && body.reasoning_effort) {
|
|
1193
|
-
return body.reasoning_effort;
|
|
1194
|
-
}
|
|
1195
|
-
const nested = body.reasoning;
|
|
1196
|
-
if (nested && typeof nested === "object" && !Array.isArray(nested)) {
|
|
1197
|
-
const effort = nested.effort;
|
|
1198
|
-
if (typeof effort === "string" && effort)
|
|
1199
|
-
return effort;
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
catch {
|
|
1203
|
-
return undefined;
|
|
1204
|
-
}
|
|
1205
|
-
return undefined;
|
|
1206
|
-
}
|
|
1207
|
-
function privateReasoningNote(provider, requestBody, reasoningTokens) {
|
|
1208
|
-
const effort = sentReasoningEffort(requestBody);
|
|
1209
|
-
const effortText = effort ? ` at ${effort} effort` : "";
|
|
1210
|
-
return `Reasoning is private on ${provider}: the model reasoned${effortText} and used ${reasoningTokens.toLocaleString("en-US")} reasoning tokens, but the API returns no reasoning text to display.`;
|
|
1211
|
-
}
|
|
1212
|
-
export async function openAiCompatibleComplete(options) {
|
|
1213
|
-
const plan = compileRequestPlan({
|
|
1214
|
-
provider: options.providerId,
|
|
1215
|
-
model: options.model,
|
|
1216
|
-
messages: options.messages,
|
|
1217
|
-
stream: false,
|
|
1218
|
-
endpoint: options.baseUrl,
|
|
1219
|
-
reasoning: options.reasoning,
|
|
1220
|
-
tools: options.tools,
|
|
1221
|
-
toolChoice: options.toolChoice,
|
|
1222
|
-
parallelToolCalls: options.parallelToolCalls,
|
|
1223
|
-
temperature: options.temperature,
|
|
1224
|
-
maxTokens: options.maxTokens,
|
|
1225
|
-
});
|
|
1226
|
-
const requestBody = chatCompletionsBodyFromPlan(plan, {
|
|
1227
|
-
reasoningStyle: options.reasoningStyle,
|
|
1228
|
-
reasoningArtifactReplayObserver: options.reasoningArtifactReplayObserver,
|
|
1229
|
-
...(options.forceReasoningReplay ? { forceReasoningReplay: true } : {}),
|
|
1230
|
-
});
|
|
1231
|
-
let response;
|
|
1232
|
-
try {
|
|
1233
|
-
response = await generationFetch(`${options.baseUrl}/chat/completions`, {
|
|
1234
|
-
method: "POST",
|
|
1235
|
-
signal: options.signal ?? null,
|
|
1236
|
-
headers: {
|
|
1237
|
-
"content-type": "application/json",
|
|
1238
|
-
accept: "application/json",
|
|
1239
|
-
...(options.apiKey
|
|
1240
|
-
? { authorization: `Bearer ${options.apiKey}` }
|
|
1241
|
-
: {}),
|
|
1242
|
-
...options.headers,
|
|
1243
|
-
},
|
|
1244
|
-
body: requestBody,
|
|
1245
|
-
verbose: process.env.CLAI_VERBOSE === "true",
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
1248
|
-
catch (error) {
|
|
1249
|
-
if (error instanceof Error && error.name === "AbortError")
|
|
1250
|
-
throw error;
|
|
1251
|
-
if (isOperationPolicyError(error))
|
|
1252
|
-
throw error;
|
|
1253
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
1254
|
-
throw new ProviderError(`${options.provider} request could not be sent (${msg}). Check connectivity to ${options.baseUrl}.`);
|
|
1255
|
-
}
|
|
1256
|
-
let data;
|
|
1257
|
-
try {
|
|
1258
|
-
data = await readJson(response);
|
|
1259
|
-
}
|
|
1260
|
-
catch (error) {
|
|
1261
|
-
if (error instanceof ProviderError) {
|
|
1262
|
-
throw new ProviderError(`${options.provider} (model=${options.model}): ${error.message}`, error.status, error.body, error.retryAfterSeconds);
|
|
1263
|
-
}
|
|
1264
|
-
throw error;
|
|
1265
|
-
}
|
|
1266
|
-
const choice = data.choices?.[0];
|
|
1267
|
-
const message = choice?.message;
|
|
1268
|
-
const toolCalls = parseOpenAiMessageToolCalls(message?.tool_calls);
|
|
1269
|
-
const text = message?.content ?? "";
|
|
1270
|
-
if (!text && toolCalls.length === 0) {
|
|
1271
|
-
throw new ProviderError(`${options.provider} returned no completion text (model=${options.model}). The response was empty — try /effort off, raise max_tokens, or pick another model with /model.`);
|
|
1272
|
-
}
|
|
1273
|
-
// If the API returns reasoning separately, prepend it inside <think>
|
|
1274
|
-
// tags so the existing thinking parser can pick it up uniformly.
|
|
1275
|
-
// Fireworks exposes cache metrics in headers for complete calls and can also
|
|
1276
|
-
// include them in perf_metrics. Other compatible routes use their standard
|
|
1277
|
-
// usage object plus any explicitly configured aliases.
|
|
1278
|
-
const usage = options.providerId === "fireworks"
|
|
1279
|
-
? parseFireworksUsage(data.usage, data.perf_metrics, response.headers)
|
|
1280
|
-
: parseOpenAiUsage(data.usage, options.usageAliases);
|
|
1281
|
-
const reasoning = openAiReasoningText(message);
|
|
1282
|
-
const detailsRaw = artifactRaw(message?.reasoning_details);
|
|
1283
|
-
const thoughtSignature = message?.extra_content?.google?.thought_signature;
|
|
1284
|
-
const reasoningArtifacts = compatibleReasoningArtifacts({
|
|
1285
|
-
providerId: options.providerId,
|
|
1286
|
-
model: options.model,
|
|
1287
|
-
baseUrl: options.baseUrl,
|
|
1288
|
-
toolCalls,
|
|
1289
|
-
policy: options.reasoningArtifactPolicy ??
|
|
1290
|
-
compatibleArtifactPolicyFor(plan.policy.reasoning.finalTurnPreservation),
|
|
1291
|
-
...(typeof reasoning === "string" && reasoning
|
|
1292
|
-
? { reasoning: { text: reasoning, sequence: 0 } }
|
|
1293
|
-
: {}),
|
|
1294
|
-
...(detailsRaw ? { details: [{ raw: detailsRaw, sequence: 1 }] } : {}),
|
|
1295
|
-
...(thoughtSignature
|
|
1296
|
-
? {
|
|
1297
|
-
thoughtSignatures: [
|
|
1298
|
-
{
|
|
1299
|
-
raw: thoughtSignature,
|
|
1300
|
-
sequence: 2,
|
|
1301
|
-
...(toolCalls.length ? { toolCallIndex: 0 } : {}),
|
|
1302
|
-
},
|
|
1303
|
-
],
|
|
1304
|
-
}
|
|
1305
|
-
: {}),
|
|
1306
|
-
});
|
|
1307
|
-
if (typeof reasoning === "string" && reasoning.trim()) {
|
|
1308
|
-
learnModelEmitsReasoning(options.providerId, options.model);
|
|
1309
|
-
}
|
|
1310
|
-
const displayReasoning = typeof reasoning === "string" && reasoning
|
|
1311
|
-
? reasoning
|
|
1312
|
-
: (visibleReasoningDetailText(detailsRaw) ?? "");
|
|
1313
|
-
return {
|
|
1314
|
-
text,
|
|
1315
|
-
...(toolCalls.length ? { toolCalls } : {}),
|
|
1316
|
-
...(choice?.finish_reason
|
|
1317
|
-
? { finishReason: choice.finish_reason }
|
|
1318
|
-
: toolCalls.length
|
|
1319
|
-
? { finishReason: "tool_calls" }
|
|
1320
|
-
: {}),
|
|
1321
|
-
...(usage ? { usage } : {}),
|
|
1322
|
-
...(displayReasoning ? { reasoningBlock: { text: displayReasoning } } : {}),
|
|
1323
|
-
...(reasoningArtifacts ? { reasoningArtifacts } : {}),
|
|
1324
|
-
};
|
|
1325
|
-
}
|
|
1326
|
-
export async function openAiCompatibleStream(options) {
|
|
1327
|
-
// Combine the caller's abort signal with an idle watchdog so a stuck
|
|
1328
|
-
// connection can't wedge the REPL forever. Thinking models get a much
|
|
1329
|
-
// longer first-byte budget and a longer mid-stream silence budget —
|
|
1330
|
-
// the old 30s default aborted healthy Bynara/OpenRouter streams that
|
|
1331
|
-
// were still "thinking" without tokens.
|
|
1332
|
-
const reasoningOn = Boolean(options.reasoning?.enabled);
|
|
1333
|
-
const idleTimeoutMs = options.idleTimeoutMs ??
|
|
1334
|
-
(reasoningOn
|
|
1335
|
-
? THINKING_STREAM_IDLE_TIMEOUT_MS
|
|
1336
|
-
: DEFAULT_STREAM_IDLE_TIMEOUT_MS);
|
|
1337
|
-
const initialIdleTimeoutMs = options.initialIdleTimeoutMs ??
|
|
1338
|
-
(reasoningOn
|
|
1339
|
-
? THINKING_STREAM_INITIAL_IDLE_TIMEOUT_MS
|
|
1340
|
-
: idleTimeoutMs);
|
|
1341
|
-
// "No bytes" and "no output" are different failures and need separate
|
|
1342
|
-
// budgets. The transport watchdog is re-armed by every read, so an SSE
|
|
1343
|
-
// keepalive comment, a `delta:{}` heartbeat, a role-only opening delta, or a
|
|
1344
|
-
// multi-line frame still being assembled all count as proof that the
|
|
1345
|
-
// connection is healthy. The output watchdog is re-armed only by real model
|
|
1346
|
-
// progress, so a stream that keepalives forever without ever producing
|
|
1347
|
-
// anything still fails instead of hanging.
|
|
1348
|
-
const outputIdleTimeoutMs = options.outputIdleTimeoutMs ??
|
|
1349
|
-
Math.round(Math.max(idleTimeoutMs, initialIdleTimeoutMs) * 1.5);
|
|
1350
|
-
const idleController = new AbortController();
|
|
1351
|
-
let transportTimer;
|
|
1352
|
-
let outputTimer;
|
|
1353
|
-
let idleFired = false;
|
|
1354
|
-
let firedWatchdog;
|
|
1355
|
-
/** Budget of whichever watchdog fired, for the error message. */
|
|
1356
|
-
let firedBudgetMs = initialIdleTimeoutMs;
|
|
1357
|
-
/**
|
|
1358
|
-
* Any bytes at all read off the socket, whether or not the frame carried
|
|
1359
|
-
* model output. Separates "the route never answered" (retry the request) from
|
|
1360
|
-
* "the model was working and went quiet" (a retry replays all of that work).
|
|
1361
|
-
*/
|
|
1362
|
-
let sawTransportActivity = false;
|
|
1363
|
-
/** Model-visible progress: content, reasoning, tool-call delta, or usage. */
|
|
1364
|
-
let sawStreamProgress = false;
|
|
1365
|
-
const fireStall = (watchdog, budgetMs) => {
|
|
1366
|
-
// The two timers can expire in the same event-loop turn. Preserve the first
|
|
1367
|
-
// cause so a transport outage is never relabeled by the output watchdog.
|
|
1368
|
-
if (idleFired)
|
|
1369
|
-
return;
|
|
1370
|
-
idleFired = true;
|
|
1371
|
-
firedWatchdog = watchdog;
|
|
1372
|
-
firedBudgetMs = budgetMs;
|
|
1373
|
-
idleController.abort();
|
|
1374
|
-
};
|
|
1375
|
-
const armTransportTimer = (budgetMs) => {
|
|
1376
|
-
if (transportTimer)
|
|
1377
|
-
clearTimeout(transportTimer);
|
|
1378
|
-
transportTimer = setTimeout(() => fireStall("transport", budgetMs), budgetMs);
|
|
1379
|
-
};
|
|
1380
|
-
/** Bytes arrived — the connection is alive; re-arm the mid-stream budget. */
|
|
1381
|
-
const noteTransportActivity = () => {
|
|
1382
|
-
sawTransportActivity = true;
|
|
1383
|
-
armTransportTimer(idleTimeoutMs);
|
|
1384
|
-
};
|
|
1385
|
-
const resetIdleTimer = () => {
|
|
1386
|
-
sawStreamProgress = true;
|
|
1387
|
-
noteTransportActivity();
|
|
1388
|
-
if (outputTimer)
|
|
1389
|
-
clearTimeout(outputTimer);
|
|
1390
|
-
outputTimer = setTimeout(() => fireStall("output", outputIdleTimeoutMs), outputIdleTimeoutMs);
|
|
1391
|
-
};
|
|
1392
|
-
armTransportTimer(initialIdleTimeoutMs);
|
|
1393
|
-
outputTimer = setTimeout(() => fireStall("output", outputIdleTimeoutMs), outputIdleTimeoutMs);
|
|
1394
|
-
const clearIdleTimers = () => {
|
|
1395
|
-
if (transportTimer)
|
|
1396
|
-
clearTimeout(transportTimer);
|
|
1397
|
-
if (outputTimer)
|
|
1398
|
-
clearTimeout(outputTimer);
|
|
1399
|
-
transportTimer = undefined;
|
|
1400
|
-
outputTimer = undefined;
|
|
1401
|
-
};
|
|
1402
|
-
const onCallerAbort = () => idleController.abort(options.signal?.reason);
|
|
1403
|
-
options.signal?.addEventListener("abort", onCallerAbort, { once: true });
|
|
1404
|
-
const plan = compileRequestPlan({
|
|
1405
|
-
provider: options.providerId,
|
|
1406
|
-
model: options.model,
|
|
1407
|
-
messages: options.messages,
|
|
1408
|
-
stream: true,
|
|
1409
|
-
endpoint: options.baseUrl,
|
|
1410
|
-
reasoning: options.reasoning,
|
|
1411
|
-
tools: options.tools,
|
|
1412
|
-
toolChoice: options.toolChoice,
|
|
1413
|
-
parallelToolCalls: options.parallelToolCalls,
|
|
1414
|
-
temperature: options.temperature,
|
|
1415
|
-
maxTokens: options.maxTokens,
|
|
1416
|
-
});
|
|
1417
|
-
const requestBody = chatCompletionsBodyFromPlan(plan, {
|
|
1418
|
-
reasoningStyle: options.reasoningStyle,
|
|
1419
|
-
includeStreamUsage: options.includeStreamUsage,
|
|
1420
|
-
reasoningArtifactReplayObserver: options.reasoningArtifactReplayObserver,
|
|
1421
|
-
...(options.forceReasoningReplay ? { forceReasoningReplay: true } : {}),
|
|
1422
|
-
});
|
|
1423
|
-
let response;
|
|
1424
|
-
try {
|
|
1425
|
-
response = await generationFetch(`${options.baseUrl}/chat/completions`, {
|
|
1426
|
-
method: "POST",
|
|
1427
|
-
signal: idleController.signal,
|
|
1428
|
-
headers: {
|
|
1429
|
-
"content-type": "application/json",
|
|
1430
|
-
accept: "text/event-stream",
|
|
1431
|
-
...(options.apiKey
|
|
1432
|
-
? { authorization: `Bearer ${options.apiKey}` }
|
|
1433
|
-
: {}),
|
|
1434
|
-
...options.headers,
|
|
1435
|
-
},
|
|
1436
|
-
body: requestBody,
|
|
1437
|
-
verbose: process.env.CLAI_VERBOSE === "true",
|
|
1438
|
-
});
|
|
1439
|
-
}
|
|
1440
|
-
catch (error) {
|
|
1441
|
-
clearIdleTimers();
|
|
1442
|
-
options.signal?.removeEventListener("abort", onCallerAbort);
|
|
1443
|
-
if (idleFired) {
|
|
1444
|
-
throw new ProviderError(`${options.provider} request timed out before any response (${Math.round(firedBudgetMs / 1000)}s)`);
|
|
1445
|
-
}
|
|
1446
|
-
throw error;
|
|
1447
|
-
}
|
|
1448
|
-
if (!response.ok) {
|
|
1449
|
-
clearIdleTimers();
|
|
1450
|
-
options.signal?.removeEventListener("abort", onCallerAbort);
|
|
1451
|
-
try {
|
|
1452
|
-
await readJson(response);
|
|
1453
|
-
}
|
|
1454
|
-
catch (error) {
|
|
1455
|
-
if (error instanceof ProviderError) {
|
|
1456
|
-
throw new ProviderError(`${options.provider} (model=${options.model}): ${error.message}`, error.status, error.body, error.retryAfterSeconds);
|
|
1457
|
-
}
|
|
1458
|
-
throw error;
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
if (!response.body) {
|
|
1462
|
-
clearIdleTimers();
|
|
1463
|
-
options.signal?.removeEventListener("abort", onCallerAbort);
|
|
1464
|
-
throw new ProviderError(`${options.provider} returned no stream body`);
|
|
1465
|
-
}
|
|
1466
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
1467
|
-
if (response.status === 202 || /\bapplication\/json\b/i.test(contentType)) {
|
|
1468
|
-
try {
|
|
1469
|
-
const data = await readJson(response, idleController.signal);
|
|
1470
|
-
if (response.status === 202) {
|
|
1471
|
-
const requestId = data.requestId ?? data.id;
|
|
1472
|
-
throw new ProviderError(`${options.provider} returned a pending async response${requestId ? ` (${requestId})` : ""}; streaming did not start.`, response.status, JSON.stringify(data).slice(0, 1_000));
|
|
1473
|
-
}
|
|
1474
|
-
const choice = data.choices?.[0];
|
|
1475
|
-
const message = choice?.message;
|
|
1476
|
-
const toolCalls = parseOpenAiMessageToolCalls(message?.tool_calls);
|
|
1477
|
-
const text = message?.content ?? "";
|
|
1478
|
-
const jsonUsage = options.providerId === "fireworks"
|
|
1479
|
-
? parseFireworksUsage(data.usage, data.perf_metrics, response.headers)
|
|
1480
|
-
: parseOpenAiUsage(data.usage, options.usageAliases);
|
|
1481
|
-
const reasoning = openAiReasoningText(message);
|
|
1482
|
-
const detailsRaw = artifactRaw(message?.reasoning_details);
|
|
1483
|
-
const thoughtSignature = message?.extra_content?.google?.thought_signature;
|
|
1484
|
-
const reasoningArtifacts = compatibleReasoningArtifacts({
|
|
1485
|
-
providerId: options.providerId,
|
|
1486
|
-
model: options.model,
|
|
1487
|
-
baseUrl: options.baseUrl,
|
|
1488
|
-
toolCalls,
|
|
1489
|
-
policy: options.reasoningArtifactPolicy ??
|
|
1490
|
-
compatibleArtifactPolicyFor(plan.policy.reasoning.finalTurnPreservation),
|
|
1491
|
-
...(typeof reasoning === "string" && reasoning
|
|
1492
|
-
? { reasoning: { text: reasoning, sequence: 0 } }
|
|
1493
|
-
: {}),
|
|
1494
|
-
...(detailsRaw ? { details: [{ raw: detailsRaw, sequence: 1 }] } : {}),
|
|
1495
|
-
...(thoughtSignature
|
|
1496
|
-
? {
|
|
1497
|
-
thoughtSignatures: [
|
|
1498
|
-
{
|
|
1499
|
-
raw: thoughtSignature,
|
|
1500
|
-
sequence: 2,
|
|
1501
|
-
...(toolCalls.length ? { toolCallIndex: 0 } : {}),
|
|
1502
|
-
},
|
|
1503
|
-
],
|
|
1504
|
-
}
|
|
1505
|
-
: {}),
|
|
1506
|
-
});
|
|
1507
|
-
if (text.trim() ||
|
|
1508
|
-
toolCalls.length > 0 ||
|
|
1509
|
-
(typeof reasoning === "string" && reasoning.trim())) {
|
|
1510
|
-
emitStreamReasoningArtifacts(options.onStreamEvent, reasoningArtifacts);
|
|
1511
|
-
if (text)
|
|
1512
|
-
options.onToken(text);
|
|
1513
|
-
return {
|
|
1514
|
-
text,
|
|
1515
|
-
...(toolCalls.length ? { toolCalls } : {}),
|
|
1516
|
-
...(choice?.finish_reason
|
|
1517
|
-
? { finishReason: choice.finish_reason }
|
|
1518
|
-
: toolCalls.length
|
|
1519
|
-
? { finishReason: "tool_calls" }
|
|
1520
|
-
: {}),
|
|
1521
|
-
...(jsonUsage ? { usage: jsonUsage } : {}),
|
|
1522
|
-
...(typeof reasoning === "string" && reasoning
|
|
1523
|
-
? { reasoningBlock: { text: reasoning } }
|
|
1524
|
-
: visibleReasoningDetailText(detailsRaw)
|
|
1525
|
-
? {
|
|
1526
|
-
reasoningBlock: {
|
|
1527
|
-
text: visibleReasoningDetailText(detailsRaw),
|
|
1528
|
-
},
|
|
1529
|
-
}
|
|
1530
|
-
: {}),
|
|
1531
|
-
...(reasoningArtifacts ? { reasoningArtifacts } : {}),
|
|
1532
|
-
};
|
|
1533
|
-
}
|
|
1534
|
-
throw new ProviderError(`${options.provider} returned JSON instead of an SSE stream, but no completion text was present.`, response.status, JSON.stringify(data).slice(0, 1_000));
|
|
1535
|
-
}
|
|
1536
|
-
catch (error) {
|
|
1537
|
-
if (idleFired) {
|
|
1538
|
-
const seconds = Math.round(firedBudgetMs / 1000);
|
|
1539
|
-
if (firedWatchdog === "transport" || !sawTransportActivity) {
|
|
1540
|
-
if (!sawTransportActivity) {
|
|
1541
|
-
throw new ProviderError(`${options.provider} request timed out before any response (${seconds}s) — no data arrived on the connection.`);
|
|
1542
|
-
}
|
|
1543
|
-
throw new ProviderError(`${options.provider} stream transport timeout (${seconds}s) — no data arrived on the connection after it had started.`);
|
|
1544
|
-
}
|
|
1545
|
-
throw new ProviderError(`${options.provider} stream stalled — ${STREAM_STALL_MARKER} for ${seconds}s`);
|
|
1546
|
-
}
|
|
1547
|
-
throw error;
|
|
1548
|
-
}
|
|
1549
|
-
finally {
|
|
1550
|
-
clearIdleTimers();
|
|
1551
|
-
options.signal?.removeEventListener("abort", onCallerAbort);
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
const decoder = new TextDecoder();
|
|
1555
|
-
const reader = response.body.getReader();
|
|
1556
|
-
let buffer = "";
|
|
1557
|
-
let full = "";
|
|
1558
|
-
let visible = "";
|
|
1559
|
-
let reasoningSeen = "";
|
|
1560
|
-
let contentWireSeen = "";
|
|
1561
|
-
let reasoningWireSeen = "";
|
|
1562
|
-
let finishReason;
|
|
1563
|
-
let terminalSignal;
|
|
1564
|
-
const terminalPolicy = options.streamTerminal ??
|
|
1565
|
-
(plan.policy.terminal.proofs.length > 0
|
|
1566
|
-
? plan.policy.terminal
|
|
1567
|
-
: CHAT_COMPLETIONS_STREAM_TERMINAL);
|
|
1568
|
-
const emittedByteCounts = () => {
|
|
1569
|
-
let toolArgumentBytes = 0;
|
|
1570
|
-
for (const state of toolCallState.values()) {
|
|
1571
|
-
toolArgumentBytes += state.arguments.length;
|
|
1572
|
-
}
|
|
1573
|
-
return {
|
|
1574
|
-
answerBytes: visible.length,
|
|
1575
|
-
reasoningBytes: reasoningSeen.length,
|
|
1576
|
-
toolArgumentBytes,
|
|
1577
|
-
};
|
|
1578
|
-
};
|
|
1579
|
-
let streamUsage = options.providerId === "fireworks"
|
|
1580
|
-
? parseFireworksUsage(undefined, undefined, response.headers)
|
|
1581
|
-
: undefined;
|
|
1582
|
-
const toolCallState = new Map();
|
|
1583
|
-
let reasoningArtifactSequence;
|
|
1584
|
-
let nextArtifactSequence = 0;
|
|
1585
|
-
let lastToolCallIndex;
|
|
1586
|
-
const structuredDetails = [];
|
|
1587
|
-
const thoughtSignatures = [];
|
|
1588
|
-
const pendingThoughtSignatures = [];
|
|
1589
|
-
const finalReasoningArtifacts = (toolCalls) => {
|
|
1590
|
-
if (pendingThoughtSignatures.length) {
|
|
1591
|
-
const toolCallIndex = toolCalls.length ? 0 : undefined;
|
|
1592
|
-
for (const capture of pendingThoughtSignatures.splice(0)) {
|
|
1593
|
-
thoughtSignatures.push(toolCallIndex === undefined
|
|
1594
|
-
? capture
|
|
1595
|
-
: { ...capture, toolCallIndex });
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
|
-
return compatibleReasoningArtifacts({
|
|
1599
|
-
providerId: options.providerId,
|
|
1600
|
-
model: options.model,
|
|
1601
|
-
baseUrl: options.baseUrl,
|
|
1602
|
-
toolCalls,
|
|
1603
|
-
policy: options.reasoningArtifactPolicy ??
|
|
1604
|
-
compatibleArtifactPolicyFor(plan.policy.reasoning.finalTurnPreservation),
|
|
1605
|
-
...(reasoningSeen
|
|
1606
|
-
? {
|
|
1607
|
-
reasoning: {
|
|
1608
|
-
text: reasoningSeen,
|
|
1609
|
-
sequence: reasoningArtifactSequence ?? 0,
|
|
1610
|
-
},
|
|
1611
|
-
}
|
|
1612
|
-
: {}),
|
|
1613
|
-
...(structuredDetails.length ? { details: structuredDetails } : {}),
|
|
1614
|
-
...(thoughtSignatures.length ? { thoughtSignatures } : {}),
|
|
1615
|
-
});
|
|
1616
|
-
};
|
|
1617
|
-
const displayReasoningText = () => {
|
|
1618
|
-
if (reasoningSeen)
|
|
1619
|
-
return reasoningSeen;
|
|
1620
|
-
return structuredDetails
|
|
1621
|
-
.map((detail) => visibleReasoningDetailText(detail.raw) ?? "")
|
|
1622
|
-
.join("");
|
|
1623
|
-
};
|
|
1624
|
-
const normalizeChannelDelta = (token, seen, snapshotThreshold = 64) => {
|
|
1625
|
-
const extendsSnapshot = token.length > seen.length && token.startsWith(seen);
|
|
1626
|
-
const repeatsEstablishedSnapshot = seen.length >= 64 && token.length === seen.length && token === seen;
|
|
1627
|
-
if (seen.length >= snapshotThreshold &&
|
|
1628
|
-
(extendsSnapshot || repeatsEstablishedSnapshot)) {
|
|
1629
|
-
return { delta: token.slice(seen.length), seen: token };
|
|
1630
|
-
}
|
|
1631
|
-
return { delta: token, seen: seen + token };
|
|
1632
|
-
};
|
|
1633
|
-
const emitPrivateReasoningNote = (hasToolCalls) => {
|
|
1634
|
-
if (reasoningSeen.trim())
|
|
1635
|
-
return;
|
|
1636
|
-
if (!visible.trim() && !hasToolCalls)
|
|
1637
|
-
return;
|
|
1638
|
-
const tokens = streamUsage?.reasoningTokens ?? 0;
|
|
1639
|
-
if (tokens <= 0)
|
|
1640
|
-
return;
|
|
1641
|
-
const note = privateReasoningNote(options.provider, requestBody, tokens);
|
|
1642
|
-
emitStreamReasoningDelta(options.onStreamEvent, note);
|
|
1643
|
-
};
|
|
1644
|
-
/**
|
|
1645
|
-
* Reasoning-echo suppression.
|
|
1646
|
-
*
|
|
1647
|
-
* Some gateways/models stream the chain of thought on `reasoning_content` and
|
|
1648
|
-
* then replay it verbatim at the start of `content` before the real answer
|
|
1649
|
-
* (observed with MiniMax M3 and GLM). Untagged, that replay is
|
|
1650
|
-
* indistinguishable from an answer, so it was rendered as the response — the
|
|
1651
|
-
* user saw the model's reasoning as its reply even with thinking off.
|
|
1652
|
-
*
|
|
1653
|
-
* While the leading `content` still matches reasoning we already received, it
|
|
1654
|
-
* is kept inside the `<think>` region: never a visible answer, still visible
|
|
1655
|
-
* under Ctrl+T, and stripped from history. Only the first
|
|
1656
|
-
* ECHO_CONFIRM_CHARS are held back before deciding, so a normal answer is
|
|
1657
|
-
* emitted with no perceptible delay.
|
|
1658
|
-
*/
|
|
1659
|
-
const ECHO_CONFIRM_CHARS = 64;
|
|
1660
|
-
let echoState = "idle";
|
|
1661
|
-
let echoBuffer = "";
|
|
1662
|
-
let echoPos = 0;
|
|
1663
|
-
const emitVisible = (text) => {
|
|
1664
|
-
if (!text)
|
|
1665
|
-
return;
|
|
1666
|
-
visible += text;
|
|
1667
|
-
full += text;
|
|
1668
|
-
options.onToken(text);
|
|
1669
|
-
};
|
|
1670
|
-
/**
|
|
1671
|
-
* Route replayed text back into the reasoning region. Deliberately does NOT
|
|
1672
|
-
* extend `reasoningSeen`: that string is the comparison baseline, and growing
|
|
1673
|
-
* it with the replay would let the echo match itself past the real reasoning.
|
|
1674
|
-
*/
|
|
1675
|
-
const emitReasoningEcho = (text) => {
|
|
1676
|
-
if (!text)
|
|
1677
|
-
return;
|
|
1678
|
-
emitStreamReasoningDelta(options.onStreamEvent, text);
|
|
1679
|
-
};
|
|
1680
|
-
/** Release a still-undecided hold-back as the answer (stream ended early). */
|
|
1681
|
-
const flushEchoBuffer = () => {
|
|
1682
|
-
if (!echoBuffer)
|
|
1683
|
-
return;
|
|
1684
|
-
const held = echoBuffer;
|
|
1685
|
-
echoBuffer = "";
|
|
1686
|
-
echoState = "done";
|
|
1687
|
-
emitVisible(held);
|
|
1688
|
-
};
|
|
1689
|
-
const handleContentToken = (token) => {
|
|
1690
|
-
if (echoState === "done") {
|
|
1691
|
-
emitVisible(token);
|
|
1692
|
-
return;
|
|
1693
|
-
}
|
|
1694
|
-
if (echoState === "idle") {
|
|
1695
|
-
// A replay is only plausible once a meaningful amount of reasoning came
|
|
1696
|
-
// through the separate channel.
|
|
1697
|
-
if (reasoningSeen.length < ECHO_CONFIRM_CHARS) {
|
|
1698
|
-
echoState = "done";
|
|
1699
|
-
emitVisible(token);
|
|
1700
|
-
return;
|
|
1701
|
-
}
|
|
1702
|
-
echoState = "buffering";
|
|
1703
|
-
}
|
|
1704
|
-
if (echoState === "buffering") {
|
|
1705
|
-
echoBuffer += token;
|
|
1706
|
-
if (reasoningSeen.startsWith(echoBuffer)) {
|
|
1707
|
-
if (echoBuffer.length >= ECHO_CONFIRM_CHARS) {
|
|
1708
|
-
const confirmed = echoBuffer;
|
|
1709
|
-
echoBuffer = "";
|
|
1710
|
-
echoPos = confirmed.length;
|
|
1711
|
-
echoState = "echoing";
|
|
1712
|
-
emitReasoningEcho(confirmed);
|
|
1713
|
-
}
|
|
1714
|
-
return;
|
|
1715
|
-
}
|
|
1716
|
-
flushEchoBuffer();
|
|
1717
|
-
return;
|
|
1718
|
-
}
|
|
1719
|
-
// Confirmed replay: consume the matching run, then hand over the answer.
|
|
1720
|
-
let matched = 0;
|
|
1721
|
-
while (matched < token.length &&
|
|
1722
|
-
reasoningSeen[echoPos + matched] === token[matched]) {
|
|
1723
|
-
matched += 1;
|
|
1724
|
-
}
|
|
1725
|
-
if (matched > 0) {
|
|
1726
|
-
emitReasoningEcho(token.slice(0, matched));
|
|
1727
|
-
echoPos += matched;
|
|
1728
|
-
}
|
|
1729
|
-
if (matched < token.length) {
|
|
1730
|
-
echoState = "done";
|
|
1731
|
-
emitVisible(token.slice(matched));
|
|
1732
|
-
}
|
|
1733
|
-
};
|
|
1734
|
-
const cleanup = () => {
|
|
1735
|
-
clearIdleTimers();
|
|
1736
|
-
options.signal?.removeEventListener("abort", onCallerAbort);
|
|
1737
|
-
idleController.signal.removeEventListener("abort", cancelReaderOnAbort);
|
|
1738
|
-
};
|
|
1739
|
-
const cancelReaderOnAbort = () => {
|
|
1740
|
-
reader.cancel().catch(() => undefined);
|
|
1741
|
-
};
|
|
1742
|
-
idleController.signal.addEventListener("abort", cancelReaderOnAbort, {
|
|
1743
|
-
once: true,
|
|
1744
|
-
});
|
|
1745
|
-
const sseFrames = createSseFrameAssembler();
|
|
1746
|
-
try {
|
|
1747
|
-
while (true) {
|
|
1748
|
-
options.signal?.throwIfAborted();
|
|
1749
|
-
if (idleController.signal.aborted) {
|
|
1750
|
-
throw new Error("Stream aborted");
|
|
1751
|
-
}
|
|
1752
|
-
const { done, value } = await readWithAbort(reader, idleController.signal);
|
|
1753
|
-
options.signal?.throwIfAborted();
|
|
1754
|
-
if (idleController.signal.aborted) {
|
|
1755
|
-
throw new Error("Stream aborted");
|
|
1756
|
-
}
|
|
1757
|
-
if (done)
|
|
1758
|
-
break;
|
|
1759
|
-
// Bytes off the wire re-arm the watchdog before anything is parsed.
|
|
1760
|
-
// Keepalives and empty deltas are proof of a live connection, so they
|
|
1761
|
-
// must not be allowed to age out a stream that is merely quiet.
|
|
1762
|
-
if (value && value.byteLength > 0)
|
|
1763
|
-
noteTransportActivity();
|
|
1764
|
-
buffer += decoder.decode(value, { stream: true });
|
|
1765
|
-
const lines = buffer.split("\n");
|
|
1766
|
-
buffer = lines.pop() ?? "";
|
|
1767
|
-
for (const line of lines) {
|
|
1768
|
-
const payload = sseFrames.pushLine(line);
|
|
1769
|
-
if (payload === undefined)
|
|
1770
|
-
continue;
|
|
1771
|
-
if (payload === "[DONE]") {
|
|
1772
|
-
terminalSignal = "done-sentinel";
|
|
1773
|
-
requireTerminalProof({
|
|
1774
|
-
provider: options.provider,
|
|
1775
|
-
policy: terminalPolicy,
|
|
1776
|
-
signal: terminalSignal,
|
|
1777
|
-
...emittedByteCounts(),
|
|
1778
|
-
});
|
|
1779
|
-
flushEchoBuffer();
|
|
1780
|
-
cleanup();
|
|
1781
|
-
const toolCalls = finalizeOpenAiToolCalls(toolCallState);
|
|
1782
|
-
emitPrivateReasoningNote(toolCalls.length > 0);
|
|
1783
|
-
const reasoningArtifacts = finalReasoningArtifacts(toolCalls);
|
|
1784
|
-
emitStreamReasoningArtifacts(options.onStreamEvent, reasoningArtifacts);
|
|
1785
|
-
if (!visible.trim() && toolCalls.length === 0) {
|
|
1786
|
-
// Thinking models (Kimi/Moonshot via Mantle, etc.) often emit only
|
|
1787
|
-
// reasoning, sometimes with tool sentinels inside <think>. Returning
|
|
1788
|
-
// the full text lets the agent runner recover tool calls from
|
|
1789
|
-
// thinkContent instead of failing the whole stream as an error.
|
|
1790
|
-
if (reasoningSeen.trim()) {
|
|
1791
|
-
return {
|
|
1792
|
-
text: full,
|
|
1793
|
-
...(finishReason ? { finishReason } : { finishReason: "stop" }),
|
|
1794
|
-
...(streamUsage ? { usage: streamUsage } : {}),
|
|
1795
|
-
...(displayReasoningText() ? { reasoningBlock: { text: displayReasoningText() } } : {}),
|
|
1796
|
-
...(reasoningArtifacts ? { reasoningArtifacts } : {}),
|
|
1797
|
-
};
|
|
1798
|
-
}
|
|
1799
|
-
throw new ProviderError(`${options.provider} completed without a visible answer.`);
|
|
1800
|
-
}
|
|
1801
|
-
return {
|
|
1802
|
-
text: full,
|
|
1803
|
-
...(toolCalls.length ? { toolCalls } : {}),
|
|
1804
|
-
...(finishReason
|
|
1805
|
-
? { finishReason }
|
|
1806
|
-
: toolCalls.length
|
|
1807
|
-
? { finishReason: "tool_calls" }
|
|
1808
|
-
: {}),
|
|
1809
|
-
...(streamUsage ? { usage: streamUsage } : {}),
|
|
1810
|
-
...(displayReasoningText() ? { reasoningBlock: { text: displayReasoningText() } } : {}),
|
|
1811
|
-
...(reasoningArtifacts ? { reasoningArtifacts } : {}),
|
|
1812
|
-
};
|
|
1813
|
-
}
|
|
1814
|
-
let parsed;
|
|
1815
|
-
try {
|
|
1816
|
-
// Only JSON.parse is allowed to fail silently here. The
|
|
1817
|
-
// delta handlers below (tool-arg size guard, UI callbacks) used to be
|
|
1818
|
-
// inside this try and had their errors swallowed as "keepalives".
|
|
1819
|
-
parsed = JSON.parse(payload);
|
|
1820
|
-
}
|
|
1821
|
-
catch {
|
|
1822
|
-
// Malformed keepalive / comment line.
|
|
1823
|
-
continue;
|
|
1824
|
-
}
|
|
1825
|
-
// Gateways report mid-stream failures as an error frame; that
|
|
1826
|
-
// used to be dropped, so an upstream overload looked like a complete
|
|
1827
|
-
// (but truncated) answer.
|
|
1828
|
-
if (parsed.error) {
|
|
1829
|
-
const detail = typeof parsed.error === "string"
|
|
1830
|
-
? parsed.error
|
|
1831
|
-
: (parsed.error.message ?? parsed.error.type ?? "unknown error");
|
|
1832
|
-
throw new ProviderError(`${options.provider} stream error: ${detail}`, inBandBadRequestStatus(parsed.error), payload.slice(0, 500));
|
|
1833
|
-
}
|
|
1834
|
-
{
|
|
1835
|
-
const chunkUsage = options.providerId === "fireworks"
|
|
1836
|
-
? parseFireworksUsage(parsed.usage, parsed.perf_metrics, response.headers)
|
|
1837
|
-
: parseOpenAiUsage(parsed.usage, options.usageAliases);
|
|
1838
|
-
if (chunkUsage)
|
|
1839
|
-
streamUsage = chunkUsage;
|
|
1840
|
-
const finalUsageFrame = isFinalUsageFrame(parsed);
|
|
1841
|
-
const choice = parsed.choices?.[0];
|
|
1842
|
-
const delta = choice?.delta;
|
|
1843
|
-
const reasoningToken = openAiReasoningText(delta);
|
|
1844
|
-
const token = delta?.content;
|
|
1845
|
-
const detailRaw = artifactRaw(delta?.reasoning_details);
|
|
1846
|
-
const thoughtSignature = delta?.extra_content?.google?.thought_signature;
|
|
1847
|
-
const artifactSequence = nextArtifactSequence++;
|
|
1848
|
-
const toolProgress = delta?.tool_calls?.some((toolCall) => Boolean(toolCall.id ||
|
|
1849
|
-
toolCall.function?.name ||
|
|
1850
|
-
toolCall.function?.arguments));
|
|
1851
|
-
if (choice?.finish_reason ||
|
|
1852
|
-
chunkUsage ||
|
|
1853
|
-
reasoningToken ||
|
|
1854
|
-
token ||
|
|
1855
|
-
detailRaw ||
|
|
1856
|
-
thoughtSignature ||
|
|
1857
|
-
toolProgress) {
|
|
1858
|
-
resetIdleTimer();
|
|
1859
|
-
}
|
|
1860
|
-
if (terminalSignal === "usage-chunk" &&
|
|
1861
|
-
(token || reasoningToken || toolProgress)) {
|
|
1862
|
-
terminalSignal = undefined;
|
|
1863
|
-
}
|
|
1864
|
-
if (choice?.finish_reason) {
|
|
1865
|
-
finishReason = choice.finish_reason;
|
|
1866
|
-
terminalSignal = "finish-reason";
|
|
1867
|
-
}
|
|
1868
|
-
else if (finalUsageFrame && terminalSignal === undefined) {
|
|
1869
|
-
terminalSignal = "usage-chunk";
|
|
1870
|
-
}
|
|
1871
|
-
if (reasoningToken) {
|
|
1872
|
-
const normalized = normalizeChannelDelta(reasoningToken, reasoningWireSeen, options.providerId === "bynara" ? 1 : 64);
|
|
1873
|
-
reasoningWireSeen = normalized.seen;
|
|
1874
|
-
if (normalized.delta) {
|
|
1875
|
-
reasoningArtifactSequence ??= artifactSequence;
|
|
1876
|
-
if (!reasoningSeen) {
|
|
1877
|
-
learnModelEmitsReasoning(options.providerId, options.model);
|
|
1878
|
-
}
|
|
1879
|
-
reasoningSeen += normalized.delta;
|
|
1880
|
-
emitStreamReasoningDelta(options.onStreamEvent, normalized.delta);
|
|
1881
|
-
}
|
|
1882
|
-
}
|
|
1883
|
-
if (detailRaw) {
|
|
1884
|
-
structuredDetails.push({ raw: detailRaw, sequence: artifactSequence });
|
|
1885
|
-
}
|
|
1886
|
-
if (token) {
|
|
1887
|
-
const normalized = normalizeChannelDelta(token, contentWireSeen);
|
|
1888
|
-
contentWireSeen = normalized.seen;
|
|
1889
|
-
if (normalized.delta)
|
|
1890
|
-
handleContentToken(normalized.delta);
|
|
1891
|
-
}
|
|
1892
|
-
const deltaToolCallIndices = [];
|
|
1893
|
-
if (delta?.tool_calls?.length) {
|
|
1894
|
-
for (const tc of delta.tool_calls) {
|
|
1895
|
-
const accInfo = accumulateOpenAiToolCallDelta(toolCallState, tc);
|
|
1896
|
-
deltaToolCallIndices.push(accInfo.index);
|
|
1897
|
-
lastToolCallIndex = accInfo.index;
|
|
1898
|
-
if (options.onToolCallDelta) {
|
|
1899
|
-
const wire = accInfo.name;
|
|
1900
|
-
const canonical = wire
|
|
1901
|
-
? (fromWireName(wire) ?? wire)
|
|
1902
|
-
: undefined;
|
|
1903
|
-
const largeArgTick = !accInfo.nameBecameKnown &&
|
|
1904
|
-
accInfo.argumentsBytes > 0 &&
|
|
1905
|
-
accInfo.argumentsBytes % 4096 <
|
|
1906
|
-
(typeof tc.function?.arguments === "string"
|
|
1907
|
-
? tc.function.arguments.length
|
|
1908
|
-
: 0);
|
|
1909
|
-
if (accInfo.nameBecameKnown || largeArgTick) {
|
|
1910
|
-
options.onToolCallDelta({
|
|
1911
|
-
index: accInfo.index,
|
|
1912
|
-
...(accInfo.id !== undefined ? { id: accInfo.id } : {}),
|
|
1913
|
-
...(canonical !== undefined ? { name: canonical } : {}),
|
|
1914
|
-
argumentsBytes: accInfo.argumentsBytes,
|
|
1915
|
-
});
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
}
|
|
1919
|
-
}
|
|
1920
|
-
const signatureToolCallIndex = deltaToolCallIndices[0] ?? lastToolCallIndex;
|
|
1921
|
-
if (thoughtSignature) {
|
|
1922
|
-
const capture = {
|
|
1923
|
-
raw: thoughtSignature,
|
|
1924
|
-
sequence: artifactSequence,
|
|
1925
|
-
...(signatureToolCallIndex === undefined
|
|
1926
|
-
? {}
|
|
1927
|
-
: { toolCallIndex: signatureToolCallIndex }),
|
|
1928
|
-
};
|
|
1929
|
-
if (signatureToolCallIndex === undefined) {
|
|
1930
|
-
pendingThoughtSignatures.push(capture);
|
|
1931
|
-
}
|
|
1932
|
-
else {
|
|
1933
|
-
thoughtSignatures.push(capture);
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
if (deltaToolCallIndices.length && pendingThoughtSignatures.length) {
|
|
1937
|
-
const toolCallIndex = deltaToolCallIndices[0];
|
|
1938
|
-
for (const capture of pendingThoughtSignatures.splice(0)) {
|
|
1939
|
-
thoughtSignatures.push({ ...capture, toolCallIndex });
|
|
1940
|
-
}
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1945
|
-
flushEchoBuffer();
|
|
1946
|
-
cleanup();
|
|
1947
|
-
requireTerminalProof({
|
|
1948
|
-
provider: options.provider,
|
|
1949
|
-
policy: terminalPolicy,
|
|
1950
|
-
signal: terminalSignal,
|
|
1951
|
-
...emittedByteCounts(),
|
|
1952
|
-
});
|
|
1953
|
-
const toolCalls = finalizeOpenAiToolCalls(toolCallState);
|
|
1954
|
-
emitPrivateReasoningNote(toolCalls.length > 0);
|
|
1955
|
-
const reasoningArtifacts = finalReasoningArtifacts(toolCalls);
|
|
1956
|
-
emitStreamReasoningArtifacts(options.onStreamEvent, reasoningArtifacts);
|
|
1957
|
-
if (!visible.trim() && toolCalls.length === 0) {
|
|
1958
|
-
// See [DONE] branch — hand thinking-only streams to the runner so it can
|
|
1959
|
-
// salvage sentinel tool blocks (or nudge) instead of hard-failing.
|
|
1960
|
-
if (reasoningSeen.trim()) {
|
|
1961
|
-
return {
|
|
1962
|
-
text: full,
|
|
1963
|
-
...(finishReason ? { finishReason } : { finishReason: "stop" }),
|
|
1964
|
-
...(streamUsage ? { usage: streamUsage } : {}),
|
|
1965
|
-
...(displayReasoningText() ? { reasoningBlock: { text: displayReasoningText() } } : {}),
|
|
1966
|
-
...(reasoningArtifacts ? { reasoningArtifacts } : {}),
|
|
1967
|
-
};
|
|
1968
|
-
}
|
|
1969
|
-
throw new ProviderError(`${options.provider} completed without a visible answer.`);
|
|
1970
|
-
}
|
|
1971
|
-
return {
|
|
1972
|
-
text: full,
|
|
1973
|
-
...(toolCalls.length ? { toolCalls } : {}),
|
|
1974
|
-
...(finishReason
|
|
1975
|
-
? { finishReason }
|
|
1976
|
-
: toolCalls.length
|
|
1977
|
-
? { finishReason: "tool_calls" }
|
|
1978
|
-
: {}),
|
|
1979
|
-
...(streamUsage ? { usage: streamUsage } : {}),
|
|
1980
|
-
...(displayReasoningText() ? { reasoningBlock: { text: displayReasoningText() } } : {}),
|
|
1981
|
-
...(reasoningArtifacts ? { reasoningArtifacts } : {}),
|
|
1982
|
-
};
|
|
1983
|
-
}
|
|
1984
|
-
catch (error) {
|
|
1985
|
-
if (idleFired) {
|
|
1986
|
-
const seconds = Math.round(firedBudgetMs / 1000);
|
|
1987
|
-
// Preserve the actual watchdog source. Any byte proves the route admitted
|
|
1988
|
-
// the request, but a later byte-silence timeout is still a transport
|
|
1989
|
-
// failure; only the output watchdog denotes a live keepalive-only/model
|
|
1990
|
-
// stall and receives STREAM_STALL_MARKER.
|
|
1991
|
-
if (firedWatchdog === "transport" || !sawTransportActivity) {
|
|
1992
|
-
if (!sawTransportActivity) {
|
|
1993
|
-
// Keep the established wording: both the router's transparent-retry
|
|
1994
|
-
// check and classifyStreamFailure key off this phrase to treat a route
|
|
1995
|
-
// that never answered as a retriable transport failure.
|
|
1996
|
-
throw new ProviderError(`${options.provider} request timed out before any response (${seconds}s) — no data arrived on the connection.`);
|
|
1997
|
-
}
|
|
1998
|
-
throw new ProviderError(`${options.provider} stream transport timeout (${seconds}s) — no data arrived on the connection after it had started.`);
|
|
1999
|
-
}
|
|
2000
|
-
throw new ProviderError(`${options.provider} stream stalled — ${STREAM_STALL_MARKER} for ${seconds}s` +
|
|
2001
|
-
(sawStreamProgress
|
|
2002
|
-
? " after it had already started producing output. " +
|
|
2003
|
-
"The connection stayed open, so the model was most likely buffering one very large tool call. " +
|
|
2004
|
-
"Split large writes into smaller sequential calls, or try a smaller model / disable thinking with /effort off."
|
|
2005
|
-
: " — the connection stayed open but the model never produced anything. " +
|
|
2006
|
-
"Try another model, or disable thinking with /effort off."));
|
|
2007
|
-
}
|
|
2008
|
-
throw error;
|
|
2009
|
-
}
|
|
2010
|
-
finally {
|
|
2011
|
-
// The success paths used to return without releasing the body, so
|
|
2012
|
-
// the socket stayed locked until GC — dozens of leaked connections per
|
|
2013
|
-
// long agent turn.
|
|
2014
|
-
cleanup();
|
|
2015
|
-
void reader.cancel().catch(() => undefined);
|
|
2016
|
-
try {
|
|
2017
|
-
reader.releaseLock();
|
|
2018
|
-
}
|
|
2019
|
-
catch {
|
|
2020
|
-
// already released
|
|
2021
|
-
}
|
|
2022
|
-
}
|
|
2023
|
-
}
|
|
2024
|
-
export async function openAiCompatiblePing(baseUrl, apiKey, headers) {
|
|
2025
|
-
const response = await fetch(`${baseUrl}/models`, {
|
|
2026
|
-
headers: {
|
|
2027
|
-
...(apiKey ? { authorization: `Bearer ${apiKey}` } : {}),
|
|
2028
|
-
...headers,
|
|
2029
|
-
},
|
|
2030
|
-
verbose: process.env.CLAI_VERBOSE === "true",
|
|
2031
|
-
});
|
|
2032
|
-
await readJson(response);
|
|
2033
|
-
}
|
|
31
|
+
export { classifyBynaraModel, classifyNvidiaModel } from "./model-families.js";
|
|
2034
32
|
//# sourceMappingURL=http.js.map
|