@pentoshi/clai 4.11.7 → 4.11.8
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 -38
- package/dist/agent/reliability-policy.js +0 -39
- 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 +32 -0
- package/dist/agent/turn/loop/request-assembly.js +97 -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 +169 -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 +664 -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 +38 -0
- package/dist/agent/turn/loop/state.js +29 -0
- package/dist/agent/turn/loop/state.js.map +1 -0
- package/dist/agent/turn/loop/stream-failure.d.ts +55 -0
- package/dist/agent/turn/loop/stream-failure.js +149 -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 +25 -0
- package/dist/agent/turn/setup/turn-messages.js +38 -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 +0 -1
- 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 +10 -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 +0 -14
- 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 +8 -47
- package/dist/app/controllers/session-controller.js.map +1 -1
- package/dist/app/controllers/session-naming.d.ts +0 -4
- package/dist/app/controllers/session-naming.js +0 -4
- 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 +0 -14
- 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 +0 -5
- package/dist/llm/model-families.js +0 -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 +6 -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 +0 -16
- 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 +2 -1
- package/dist/llm/responses-request.js +7 -2
- 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 +212 -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 +335 -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 +85 -0
- package/dist/store/config/endpoints.js +298 -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 +62 -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 +25 -0
- package/dist/store/history/sqlite-backend.js +209 -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-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 +67 -112
- 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 +10 -27
- 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 +0 -12
- package/dist/tui-v2/components/jobs/jobs-panel.js +0 -34
- 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 +0 -14
- package/dist/tui-v2/components/overlay/overlay-host.js +0 -2
- 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 +0 -7
- package/dist/tui-v2/components/plan/plan-view.js +0 -20
- 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 +0 -12
- package/dist/tui-v2/components/queue/queue-panel.js +2 -4
- package/dist/tui-v2/components/queue/queue-panel.js.map +1 -1
- package/dist/tui-v2/components/status/status-line.d.ts +0 -17
- package/dist/tui-v2/components/status/status-line.js +0 -10
- 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 +0 -12
- package/dist/tui-v2/components/toast/toast-host.js +1 -29
- 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 +0 -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-view.d.ts +0 -9
- package/dist/tui-v2/components/transcript/transcript-view.js +4 -67
- 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 +0 -20
- package/dist/tui-v2/composer/composer-editor.js +0 -61
- 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/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/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 +6 -694
- 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 +184 -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-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-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 +0 -8
- package/dist/ui-core/state/transcript-window.js +0 -8
- 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
|
@@ -1,763 +1,16 @@
|
|
|
1
1
|
import { isCompactionMemoryMessage } from "./context-manager.js";
|
|
2
2
|
import { projectToolHistory } from "./tool-history.js";
|
|
3
|
+
import { isDurableInjectedBlock } from "./durable-blocks.js";
|
|
3
4
|
import { isResponderResultLedgerMessage } from "./responder-context.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
inString = !inString;
|
|
13
|
-
result += char;
|
|
14
|
-
}
|
|
15
|
-
else if (inString) {
|
|
16
|
-
if (char === "\n") {
|
|
17
|
-
result += "\\n";
|
|
18
|
-
}
|
|
19
|
-
else if (char === "\r") {
|
|
20
|
-
result += "\\r";
|
|
21
|
-
}
|
|
22
|
-
else if (char === "\t") {
|
|
23
|
-
result += "\\t";
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
result += char;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
if (char === "," && i + 1 < raw.length) {
|
|
31
|
-
let nextNonWs = "";
|
|
32
|
-
for (let j = i + 1; j < raw.length; j++) {
|
|
33
|
-
if (!/\s/.test(raw[j])) {
|
|
34
|
-
nextNonWs = raw[j];
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (nextNonWs === "}" || nextNonWs === "]") {
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
result += char;
|
|
43
|
-
}
|
|
44
|
-
if (char === "\\" && inString) {
|
|
45
|
-
escaped = !escaped;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
escaped = false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Last-resort lenient repair for tool-call JSON that strict JSON.parse
|
|
55
|
-
* rejected. Models frequently emit "almost JSON": smart/curly quotes from a
|
|
56
|
-
* copy-paste, Python-style True/False/None literals, or an object that is
|
|
57
|
-
* wholly single-quoted. We only apply these transforms when a strict parse
|
|
58
|
-
* has already failed, so well-formed JSON is never touched.
|
|
59
|
-
*/
|
|
60
|
-
function repairMixedQuotes(text) {
|
|
61
|
-
let inString = false;
|
|
62
|
-
let escaped = false;
|
|
63
|
-
let out = "";
|
|
64
|
-
for (let i = 0; i < text.length; i += 1) {
|
|
65
|
-
const ch = text[i];
|
|
66
|
-
if (inString === "double") {
|
|
67
|
-
if (escaped) {
|
|
68
|
-
out += ch;
|
|
69
|
-
escaped = false;
|
|
70
|
-
}
|
|
71
|
-
else if (ch === "\\") {
|
|
72
|
-
out += ch;
|
|
73
|
-
escaped = true;
|
|
74
|
-
}
|
|
75
|
-
else if (ch === '"') {
|
|
76
|
-
out += ch;
|
|
77
|
-
inString = false;
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
out += ch;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
else if (inString === "single") {
|
|
84
|
-
if (escaped) {
|
|
85
|
-
if (ch === "'") {
|
|
86
|
-
out += "'";
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
out += "\\" + ch;
|
|
90
|
-
}
|
|
91
|
-
escaped = false;
|
|
92
|
-
}
|
|
93
|
-
else if (ch === "\\") {
|
|
94
|
-
escaped = true;
|
|
95
|
-
}
|
|
96
|
-
else if (ch === "'") {
|
|
97
|
-
out += '"';
|
|
98
|
-
inString = false;
|
|
99
|
-
}
|
|
100
|
-
else if (ch === '"') {
|
|
101
|
-
out += '\\"';
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
out += ch;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
if (ch === '"') {
|
|
109
|
-
out += ch;
|
|
110
|
-
inString = "double";
|
|
111
|
-
}
|
|
112
|
-
else if (ch === "'") {
|
|
113
|
-
out += '"';
|
|
114
|
-
inString = "single";
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
out += ch;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return out;
|
|
122
|
-
}
|
|
123
|
-
function lenientJsonParse(text) {
|
|
124
|
-
const candidates = [];
|
|
125
|
-
// 1. Normalize unicode/smart quotes to ASCII quotes.
|
|
126
|
-
const deSmart = text
|
|
127
|
-
.replace(/[\u201C\u201D\u201E\u2033]/g, '"')
|
|
128
|
-
.replace(/[\u2018\u2019\u201A\u2032]/g, "'");
|
|
129
|
-
candidates.push(deSmart);
|
|
130
|
-
// 2. Python/JS literals → JSON literals (outside of double-quoted strings).
|
|
131
|
-
candidates.push(replaceOutsideStrings(deSmart));
|
|
132
|
-
// 3. Mixed quotes repair (convert '...' strings to "..." strings)
|
|
133
|
-
const mixedRepaired = repairMixedQuotes(deSmart);
|
|
134
|
-
candidates.push(mixedRepaired);
|
|
135
|
-
candidates.push(replaceOutsideStrings(mixedRepaired));
|
|
136
|
-
// 4. Single-quoted object → double-quoted (only when there are no double
|
|
137
|
-
// quotes already, so we don't corrupt strings that contain apostrophes).
|
|
138
|
-
if (!deSmart.includes('"') && deSmart.includes("'")) {
|
|
139
|
-
candidates.push(deSmart.replace(/'/g, '"'));
|
|
140
|
-
}
|
|
141
|
-
for (const candidate of candidates) {
|
|
142
|
-
try {
|
|
143
|
-
return JSON.parse(preprocessJson(candidate).trim());
|
|
144
|
-
}
|
|
145
|
-
catch {
|
|
146
|
-
// try the next repair
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return undefined;
|
|
150
|
-
}
|
|
151
|
-
/** Replace bare Python/JS literals (True/False/None/NaN) with JSON equivalents,
|
|
152
|
-
* skipping anything inside a double-quoted string. */
|
|
153
|
-
function replaceOutsideStrings(text) {
|
|
154
|
-
let inString = false;
|
|
155
|
-
let escaped = false;
|
|
156
|
-
let out = "";
|
|
157
|
-
let i = 0;
|
|
158
|
-
while (i < text.length) {
|
|
159
|
-
const ch = text[i];
|
|
160
|
-
if (inString) {
|
|
161
|
-
out += ch;
|
|
162
|
-
if (escaped)
|
|
163
|
-
escaped = false;
|
|
164
|
-
else if (ch === "\\")
|
|
165
|
-
escaped = true;
|
|
166
|
-
else if (ch === '"')
|
|
167
|
-
inString = false;
|
|
168
|
-
i += 1;
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
if (ch === '"') {
|
|
172
|
-
inString = true;
|
|
173
|
-
out += ch;
|
|
174
|
-
i += 1;
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
const rest = text.slice(i);
|
|
178
|
-
const m = /^(True|False|None|NaN|undefined)\b/.exec(rest);
|
|
179
|
-
if (m) {
|
|
180
|
-
const word = m[1];
|
|
181
|
-
out +=
|
|
182
|
-
word === "True"
|
|
183
|
-
? "true"
|
|
184
|
-
: word === "False"
|
|
185
|
-
? "false"
|
|
186
|
-
: word === "NaN"
|
|
187
|
-
? "0"
|
|
188
|
-
: "null"; // None / undefined
|
|
189
|
-
i += word.length;
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
out += ch;
|
|
193
|
-
i += 1;
|
|
194
|
-
}
|
|
195
|
-
return out;
|
|
196
|
-
}
|
|
197
|
-
function tryParseCall(raw) {
|
|
198
|
-
let parsed;
|
|
199
|
-
try {
|
|
200
|
-
parsed = JSON.parse(preprocessJson(raw).trim());
|
|
201
|
-
}
|
|
202
|
-
catch {
|
|
203
|
-
// Strict parse failed — try lenient repairs before giving up so a model
|
|
204
|
-
// that emits smart quotes / single quotes / Python literals still works.
|
|
205
|
-
const repaired = lenientJsonParse(raw.trim());
|
|
206
|
-
if (repaired && typeof repaired === "object" && !Array.isArray(repaired)) {
|
|
207
|
-
parsed = repaired;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
if (!parsed)
|
|
211
|
-
return undefined;
|
|
212
|
-
const anyParsed = parsed;
|
|
213
|
-
// Accept name under several keys models commonly use.
|
|
214
|
-
const nameRaw = typeof parsed.name === "string"
|
|
215
|
-
? parsed.name
|
|
216
|
-
: typeof anyParsed.tool_name === "string"
|
|
217
|
-
? anyParsed.tool_name
|
|
218
|
-
: undefined;
|
|
219
|
-
if (typeof nameRaw === "string" && nameRaw.length > 0) {
|
|
220
|
-
// Strip a leading "functions." namespace some models add.
|
|
221
|
-
const name = nameRaw.replace(/^functions\./, "");
|
|
222
|
-
// Many OpenAI/Hermes/Qwen-trained models emit {"name","arguments"}
|
|
223
|
-
// (or "parameters"/"input") instead of {"name","args"} — accept any.
|
|
224
|
-
const argsSrc = pickObject(parsed.args) ??
|
|
225
|
-
pickObject(parsed.arguments) ??
|
|
226
|
-
pickObject(anyParsed.parameters) ??
|
|
227
|
-
pickObject(anyParsed.input);
|
|
228
|
-
if (argsSrc) {
|
|
229
|
-
return { name, args: argsSrc };
|
|
230
|
-
}
|
|
231
|
-
// Allow an empty args object explicitly written as {} or null (common for
|
|
232
|
-
// sysinfo), but do NOT invent args for objects that merely happen to
|
|
233
|
-
// contain a "name" key (e.g. {"name":"shell.exec"} with no command).
|
|
234
|
-
if (parsed.args === null || parsed.arguments === null) {
|
|
235
|
-
return { name, args: {} };
|
|
236
|
-
}
|
|
237
|
-
// Flattened form: the args are emitted as SIBLINGS of `name` rather than
|
|
238
|
-
// nested (e.g. {"name":"web.fetch","url":"…","responseMode":"raw"}). Treat
|
|
239
|
-
// the non-reserved keys as args, but only when at least one is a known
|
|
240
|
-
// tool-arg key so plain data objects carrying a `name` are not misread.
|
|
241
|
-
const flat = {};
|
|
242
|
-
for (const key of Object.keys(anyParsed)) {
|
|
243
|
-
if (!FLATTENED_RESERVED_KEYS.has(key))
|
|
244
|
-
flat[key] = anyParsed[key];
|
|
245
|
-
}
|
|
246
|
-
const flatKeys = Object.keys(flat);
|
|
247
|
-
if (flatKeys.length > 0 && flatKeys.some((k) => TOOL_ARG_KEYS.has(k))) {
|
|
248
|
-
return { name, args: flat };
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return undefined;
|
|
252
|
-
}
|
|
253
|
-
// Keys that name the tool or wrap its arguments — excluded when recovering a
|
|
254
|
-
// flattened tool call whose args sit alongside `name`.
|
|
255
|
-
const FLATTENED_RESERVED_KEYS = new Set([
|
|
256
|
-
"name",
|
|
257
|
-
"tool_name",
|
|
258
|
-
"args",
|
|
259
|
-
"arguments",
|
|
260
|
-
"parameters",
|
|
261
|
-
"input",
|
|
262
|
-
]);
|
|
263
|
-
function pickObject(value) {
|
|
264
|
-
return value && typeof value === "object" && !Array.isArray(value)
|
|
265
|
-
? value
|
|
266
|
-
: undefined;
|
|
267
|
-
}
|
|
268
|
-
// Kimi K2 / Moonshot models on NVIDIA NIM emit tool calls using a
|
|
269
|
-
// sentinel-token format that looks like:
|
|
270
|
-
// <|tool_calls_section_begin|>
|
|
271
|
-
// <|tool_call_begin|>functions.shell.exec:0<|tool_call_argument_begin|>
|
|
272
|
-
// {"command":"ls"}
|
|
273
|
-
// <|tool_call_end|>
|
|
274
|
-
// <|tool_calls_section_end|>
|
|
275
|
-
// The `functions.` prefix is optional, the trailing `:N` index is optional,
|
|
276
|
-
// and the surrounding section markers may be absent on truncated streams.
|
|
277
|
-
const KIMI_TOOL_CALL_RE = /<\|tool_call_begin\|>\s*(?:functions\.)?([A-Za-z][\w.]*?)(?::\d+)?\s*<\|tool_call_argument_begin\|>\s*(\{[\s\S]*?\})\s*<\|tool_call_end\|>/i;
|
|
278
|
-
function parseKimiToolCall(text) {
|
|
279
|
-
const match = text.match(KIMI_TOOL_CALL_RE);
|
|
280
|
-
if (!match)
|
|
281
|
-
return undefined;
|
|
282
|
-
const name = match[1];
|
|
283
|
-
return tryParseCall(JSON.stringify({ name, args: tryJson(match[2]) ?? {} }));
|
|
284
|
-
}
|
|
285
|
-
const DEEPSEEK_TOOL_CALL_RE = /<[||]+tool[_▁]call[_▁]begin[||]+>\s*(?:[A-Za-z]+\s*)?<[||]+tool[_▁]sep[||]+>\s*(?:functions\.)?([A-Za-z][\w.]*?)(?::\d+)?\s*(?:\n|\s)*(?:```(?:json)?\s*)?(\{[\s\S]*?\})\s*(?:```)?\s*(?:<[||]+tool[_▁]call[_▁]end[||]+>|$)/i;
|
|
286
|
-
function parseDeepseekToolCall(text) {
|
|
287
|
-
const match = text.match(DEEPSEEK_TOOL_CALL_RE);
|
|
288
|
-
if (!match)
|
|
289
|
-
return undefined;
|
|
290
|
-
return tryParseCall(JSON.stringify({ name: match[1], args: tryJson(match[2]) ?? {} }));
|
|
291
|
-
}
|
|
292
|
-
const DSML_INVOKE_OPEN_RE = /<[||]+DSML[||]+invoke\b([^>]*)>/gi;
|
|
293
|
-
const DSML_PARAMETER_OPEN_RE = /<[||]+DSML[||]+parameter\b([^>]*)>/gi;
|
|
294
|
-
const DSML_INVOKE_END_RES = [
|
|
295
|
-
/<\/[||]+DSML[||]+invoke>/i,
|
|
296
|
-
/<[||]+DSML[||]+invoke\b/i,
|
|
297
|
-
/<\/[||]+DSML[||]+tool_calls>/i,
|
|
298
|
-
];
|
|
299
|
-
const DSML_PARAMETER_END_RES = [
|
|
300
|
-
/<\/[||]+DSML[||]+parameter>/i,
|
|
301
|
-
/<[||]+DSML[||]+parameter\b/i,
|
|
302
|
-
/<\/[||]+DSML[||]+invoke>/i,
|
|
303
|
-
/<\/[||]+DSML[||]+tool_calls>/i,
|
|
304
|
-
];
|
|
305
|
-
function boundDsmlBlock(after, boundaries) {
|
|
306
|
-
let end = -1;
|
|
307
|
-
for (const re of boundaries) {
|
|
308
|
-
const match = re.exec(after);
|
|
309
|
-
if (match && (end < 0 || match.index < end))
|
|
310
|
-
end = match.index;
|
|
311
|
-
}
|
|
312
|
-
return end < 0
|
|
313
|
-
? { body: after, terminated: false }
|
|
314
|
-
: { body: after.slice(0, end), terminated: true };
|
|
315
|
-
}
|
|
316
|
-
function dsmlAttribute(attrs, name) {
|
|
317
|
-
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
318
|
-
const match = new RegExp(`(?:^|\\s)${escaped}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`, "i").exec(attrs);
|
|
319
|
-
return match?.[1] ?? match?.[2];
|
|
320
|
-
}
|
|
321
|
-
function decodeDsmlCodePoint(raw, radix, original) {
|
|
322
|
-
const value = Number.parseInt(raw, radix);
|
|
323
|
-
return Number.isInteger(value) && value >= 0 && value <= 0x10ffff
|
|
324
|
-
? String.fromCodePoint(value)
|
|
325
|
-
: original;
|
|
326
|
-
}
|
|
327
|
-
function decodeDsmlText(value) {
|
|
328
|
-
return value
|
|
329
|
-
.replace(/&#x([0-9a-f]+);/gi, (original, hex) => decodeDsmlCodePoint(hex, 16, original))
|
|
330
|
-
.replace(/&#(\d+);/g, (original, decimal) => decodeDsmlCodePoint(decimal, 10, original))
|
|
331
|
-
.replace(/"/gi, '"')
|
|
332
|
-
.replace(/'/gi, "'")
|
|
333
|
-
.replace(/</gi, "<")
|
|
334
|
-
.replace(/>/gi, ">")
|
|
335
|
-
.replace(/&/gi, "&");
|
|
336
|
-
}
|
|
337
|
-
function dsmlParameterValue(attrs, raw) {
|
|
338
|
-
const value = decodeDsmlText(raw.trim());
|
|
339
|
-
if (/\bstring\s*=\s*["']true["']/i.test(attrs))
|
|
340
|
-
return value;
|
|
341
|
-
if (/\bboolean\s*=\s*["']true["']/i.test(attrs))
|
|
342
|
-
return value.toLowerCase() === "true";
|
|
343
|
-
if (/\bnumber\s*=\s*["']true["']/i.test(attrs)) {
|
|
344
|
-
const number = Number(value);
|
|
345
|
-
return Number.isFinite(number) ? number : value;
|
|
346
|
-
}
|
|
347
|
-
const parsed = lenientJsonParse(value);
|
|
348
|
-
return parsed === undefined ? value : parsed;
|
|
349
|
-
}
|
|
350
|
-
function parseAllDsmlToolCalls(text) {
|
|
351
|
-
const found = [];
|
|
352
|
-
const invokeRe = new RegExp(DSML_INVOKE_OPEN_RE.source, "gi");
|
|
353
|
-
let invoke;
|
|
354
|
-
while ((invoke = invokeRe.exec(text)) !== null) {
|
|
355
|
-
const name = dsmlAttribute(invoke[1] ?? "", "name")?.replace(/^functions\./, "").trim();
|
|
356
|
-
const body = boundDsmlBlock(text.slice(invoke.index + invoke[0].length), DSML_INVOKE_END_RES);
|
|
357
|
-
if (!name || !body.terminated)
|
|
358
|
-
continue;
|
|
359
|
-
const args = {};
|
|
360
|
-
const parameterRe = new RegExp(DSML_PARAMETER_OPEN_RE.source, "gi");
|
|
361
|
-
let parameter;
|
|
362
|
-
let truncated = false;
|
|
363
|
-
while ((parameter = parameterRe.exec(body.body)) !== null) {
|
|
364
|
-
const parameterName = dsmlAttribute(parameter[1] ?? "", "name")?.trim();
|
|
365
|
-
const value = boundDsmlBlock(body.body.slice(parameter.index + parameter[0].length), DSML_PARAMETER_END_RES);
|
|
366
|
-
if (!value.terminated) {
|
|
367
|
-
truncated = true;
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
if (!parameterName)
|
|
371
|
-
continue;
|
|
372
|
-
args[parameterName] = dsmlParameterValue(parameter[1] ?? "", value.body);
|
|
373
|
-
}
|
|
374
|
-
if (truncated)
|
|
375
|
-
continue;
|
|
376
|
-
found.push({ index: invoke.index, call: { name, args } });
|
|
377
|
-
}
|
|
378
|
-
return found;
|
|
379
|
-
}
|
|
380
|
-
function parseDsmlToolCall(text) {
|
|
381
|
-
return parseAllDsmlToolCalls(text)[0]?.call;
|
|
382
|
-
}
|
|
383
|
-
const OPEN_SEP_OPEN_RE = /<[||]+open[||]+>?([A-Za-z][\w-]*)\b/gi;
|
|
384
|
-
const OPEN_SEP_SEP_RE = /<[||]+sep[||]+>/gi;
|
|
385
|
-
function scanOpenSepElement(text, from) {
|
|
386
|
-
OPEN_SEP_OPEN_RE.lastIndex = from;
|
|
387
|
-
const open = OPEN_SEP_OPEN_RE.exec(text);
|
|
388
|
-
if (!open)
|
|
389
|
-
return undefined;
|
|
390
|
-
const tag = open[1];
|
|
391
|
-
const afterOpen = open.index + open[0].length;
|
|
392
|
-
OPEN_SEP_SEP_RE.lastIndex = afterOpen;
|
|
393
|
-
const sep = OPEN_SEP_SEP_RE.exec(text);
|
|
394
|
-
if (!sep)
|
|
395
|
-
return undefined;
|
|
396
|
-
const attrs = text.slice(afterOpen, sep.index);
|
|
397
|
-
const closeRe = new RegExp(`<[||]+close[||]+>?${tag.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*>?`, "i");
|
|
398
|
-
const close = closeRe.exec(text.slice(sep.index + sep[0].length));
|
|
399
|
-
const bodyEnd = close
|
|
400
|
-
? sep.index + sep[0].length + close.index
|
|
401
|
-
: text.length;
|
|
402
|
-
return {
|
|
403
|
-
tag,
|
|
404
|
-
attrs,
|
|
405
|
-
body: text.slice(sep.index + sep[0].length, bodyEnd),
|
|
406
|
-
end: close ? bodyEnd + close[0].length : text.length,
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
function openSepValue(attrs, raw) {
|
|
410
|
-
const value = decodeDsmlText(raw.trim());
|
|
411
|
-
const type = dsmlAttribute(attrs, "type")?.toLowerCase();
|
|
412
|
-
if (type === "number") {
|
|
413
|
-
const n = Number(value);
|
|
414
|
-
return Number.isFinite(n) ? n : value;
|
|
415
|
-
}
|
|
416
|
-
if (type === "boolean" || type === "bool")
|
|
417
|
-
return value.toLowerCase() === "true";
|
|
418
|
-
if (type === "string")
|
|
419
|
-
return value;
|
|
420
|
-
const parsed = lenientJsonParse(value);
|
|
421
|
-
return parsed === undefined ? value : parsed;
|
|
422
|
-
}
|
|
423
|
-
function parseAllOpenSepToolCalls(text) {
|
|
424
|
-
const found = [];
|
|
425
|
-
if (!/<[||]+open[||]+/i.test(text))
|
|
426
|
-
return found;
|
|
427
|
-
let cursor = 0;
|
|
428
|
-
while (cursor < text.length) {
|
|
429
|
-
const openIdx = text.slice(cursor).search(OPEN_SEP_OPEN_RE);
|
|
430
|
-
if (openIdx < 0)
|
|
431
|
-
break;
|
|
432
|
-
const element = scanOpenSepElement(text, cursor + openIdx);
|
|
433
|
-
if (!element) {
|
|
434
|
-
cursor = cursor + openIdx + 1;
|
|
435
|
-
continue;
|
|
436
|
-
}
|
|
437
|
-
if (element.tag !== "call") {
|
|
438
|
-
cursor = cursor + openIdx + 1;
|
|
439
|
-
continue;
|
|
440
|
-
}
|
|
441
|
-
{
|
|
442
|
-
const rawName = dsmlAttribute(element.attrs, "tool") ?? dsmlAttribute(element.attrs, "name");
|
|
443
|
-
const name = rawName?.replace(/^functions\./, "").trim();
|
|
444
|
-
if (name) {
|
|
445
|
-
const args = {};
|
|
446
|
-
let inner = 0;
|
|
447
|
-
while (inner < element.body.length) {
|
|
448
|
-
const nextOpen = element.body.slice(inner).search(OPEN_SEP_OPEN_RE);
|
|
449
|
-
if (nextOpen < 0)
|
|
450
|
-
break;
|
|
451
|
-
const arg = scanOpenSepElement(element.body, inner + nextOpen);
|
|
452
|
-
if (!arg)
|
|
453
|
-
break;
|
|
454
|
-
if (arg.tag === "argument") {
|
|
455
|
-
const key = dsmlAttribute(arg.attrs, "key") ?? dsmlAttribute(arg.attrs, "name");
|
|
456
|
-
if (key)
|
|
457
|
-
args[key] = openSepValue(arg.attrs, arg.body);
|
|
458
|
-
}
|
|
459
|
-
inner = arg.end;
|
|
460
|
-
}
|
|
461
|
-
found.push({ index: cursor + openIdx, call: { name, args } });
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
cursor = element.end > cursor + openIdx ? element.end : cursor + openIdx + 1;
|
|
465
|
-
}
|
|
466
|
-
return found;
|
|
467
|
-
}
|
|
468
|
-
function parseOpenSepToolCall(text) {
|
|
469
|
-
return parseAllOpenSepToolCalls(text)[0]?.call;
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* GLM / Tencent / some OpenAI-compat gateways emit:
|
|
473
|
-
* <tool_calls:6124c78e>
|
|
474
|
-
* <tool_call:6124c78e>web.search
|
|
475
|
-
* {"query":"…"}
|
|
476
|
-
* </tool_call:6124c78e>
|
|
477
|
-
* </tool_calls:6124c78e>
|
|
478
|
-
* Closing tags and the outer wrapper are optional on truncated streams.
|
|
479
|
-
* Name may sit on the same line as the opener or the next line; args are a
|
|
480
|
-
* balanced JSON object (bare args, not necessarily {"name","args"} wrapper).
|
|
481
|
-
*/
|
|
482
|
-
const ID_TOOL_CALL_RE = /<tool_call:([A-Za-z0-9_-]+)>\s*([\w.-]+)\s*/gi;
|
|
483
|
-
/**
|
|
484
|
-
* Boundaries that end one id-tagged block. Argument JSON must be found before
|
|
485
|
-
* the first of these, so a block whose own JSON is missing or truncated can
|
|
486
|
-
* Never adopt the arguments of a LATER block: a `fs.delete` opener
|
|
487
|
-
* must not pair with the next call's `{"path":...}`.
|
|
488
|
-
*/
|
|
489
|
-
const ID_BLOCK_BOUNDARY_RES = [
|
|
490
|
-
/<\/tool_call\b/i,
|
|
491
|
-
/<\/tool_calls\b/i,
|
|
492
|
-
/<tool_call:/i,
|
|
493
|
-
/<tool_call>/i,
|
|
494
|
-
/<tool_calls:/i,
|
|
495
|
-
/<\|tool_call_begin\|>/i,
|
|
496
|
-
/<\|tool_calls_section_end\|>/i,
|
|
497
|
-
];
|
|
498
|
-
function boundIdTaggedBlock(after) {
|
|
499
|
-
let end = -1;
|
|
500
|
-
for (const re of ID_BLOCK_BOUNDARY_RES) {
|
|
501
|
-
const match = re.exec(after);
|
|
502
|
-
if (match && (end < 0 || match.index < end))
|
|
503
|
-
end = match.index;
|
|
504
|
-
}
|
|
505
|
-
return end < 0
|
|
506
|
-
? { body: after, terminated: false }
|
|
507
|
-
: { body: after.slice(0, end), terminated: true };
|
|
508
|
-
}
|
|
509
|
-
function parseIdTaggedToolCall(text) {
|
|
510
|
-
const match = /<tool_call:([A-Za-z0-9_-]+)>\s*([\w.-]+)\s*/i.exec(text);
|
|
511
|
-
if (!match)
|
|
512
|
-
return undefined;
|
|
513
|
-
const name = match[2];
|
|
514
|
-
const block = boundIdTaggedBlock(text.slice(match.index + match[0].length));
|
|
515
|
-
const json = extractBalancedJson(block.body);
|
|
516
|
-
if (json) {
|
|
517
|
-
const parsed = tryJson(json);
|
|
518
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
519
|
-
const obj = parsed;
|
|
520
|
-
// Full {"name","args"} form inside the block.
|
|
521
|
-
if (typeof obj.name === "string" && obj.args && typeof obj.args === "object") {
|
|
522
|
-
return tryParseCall(json);
|
|
523
|
-
}
|
|
524
|
-
// Bare args object: {"query":"…"}
|
|
525
|
-
return { name, args: obj };
|
|
526
|
-
}
|
|
527
|
-
return undefined;
|
|
528
|
-
}
|
|
529
|
-
// An unbalanced/undecodable `{` inside this block means the arguments are
|
|
530
|
-
// truncated. Never fall through to an empty-args call — that would run a
|
|
531
|
-
// mutating tool with a different meaning than the model intended.
|
|
532
|
-
if (block.body.includes("{"))
|
|
533
|
-
return undefined;
|
|
534
|
-
// Still-open block: the argument JSON (or the rest of the tool name) has not
|
|
535
|
-
// streamed in yet. Reporting an empty-args call here is what froze live tool
|
|
536
|
-
// cards with a blank input, and a half-arrived name would be assembled into
|
|
537
|
-
// a shell command. Only a closed block is a real zero-argument call.
|
|
538
|
-
if (!block.terminated)
|
|
539
|
-
return undefined;
|
|
540
|
-
return { name, args: {} };
|
|
541
|
-
}
|
|
542
|
-
function parseAllIdTaggedToolCalls(text) {
|
|
543
|
-
const found = [];
|
|
544
|
-
const re = new RegExp(ID_TOOL_CALL_RE.source, "gi");
|
|
545
|
-
let m;
|
|
546
|
-
while ((m = re.exec(text)) !== null) {
|
|
547
|
-
const slice = text.slice(m.index);
|
|
548
|
-
const call = parseIdTaggedToolCall(slice);
|
|
549
|
-
if (call)
|
|
550
|
-
found.push({ index: m.index, call });
|
|
551
|
-
}
|
|
552
|
-
return found;
|
|
553
|
-
}
|
|
554
|
-
// Recognized XML-ish tool-call wrappers some models emit (with or without a
|
|
555
|
-
// matching close tag). Used so we can recover a call even when the model
|
|
556
|
-
// forgot the closing tag, while plain prose never matches.
|
|
557
|
-
const XML_BLOCK_OPENERS = /<tool_call>|<function_calls>|<invoke>|<ant:invoke>/i;
|
|
558
|
-
/**
|
|
559
|
-
* Scan `text` starting at the index of the first `{`, returning the balanced
|
|
560
|
-
* JSON substring (respecting strings) or undefined if braces never balance.
|
|
561
|
-
* Lets us recover a tool-call JSON object the model emitted without a closing
|
|
562
|
-
* wrapper tag, where a non-greedy regex would stop at the first inner brace.
|
|
563
|
-
*/
|
|
564
|
-
function extractBalancedJson(text) {
|
|
565
|
-
const start = text.indexOf("{");
|
|
566
|
-
if (start < 0)
|
|
567
|
-
return undefined;
|
|
568
|
-
let depth = 0;
|
|
569
|
-
let inString = false;
|
|
570
|
-
let escaped = false;
|
|
571
|
-
for (let i = start; i < text.length; i += 1) {
|
|
572
|
-
const ch = text[i];
|
|
573
|
-
if (escaped) {
|
|
574
|
-
escaped = false;
|
|
575
|
-
continue;
|
|
576
|
-
}
|
|
577
|
-
if (ch === "\\") {
|
|
578
|
-
escaped = true;
|
|
579
|
-
continue;
|
|
580
|
-
}
|
|
581
|
-
if (ch === '"') {
|
|
582
|
-
inString = !inString;
|
|
583
|
-
continue;
|
|
584
|
-
}
|
|
585
|
-
if (inString)
|
|
586
|
-
continue;
|
|
587
|
-
if (ch === "{")
|
|
588
|
-
depth += 1;
|
|
589
|
-
else if (ch === "}") {
|
|
590
|
-
depth -= 1;
|
|
591
|
-
if (depth === 0)
|
|
592
|
-
return text.slice(start, i + 1);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
return undefined;
|
|
596
|
-
}
|
|
597
|
-
function parseXmlToolCall(text) {
|
|
598
|
-
// Pattern 1d (GLM arg_key / arg_value format):
|
|
599
|
-
// <tool_call>tool.name<arg_key>key</arg_key><arg_value>value</arg_value></tool_call>
|
|
600
|
-
const glmMatch = text.match(/<tool_call>\s*([\w.-]+)\s*([\s\S]*?)(?:<\/tool_call>|$)/i);
|
|
601
|
-
if (glmMatch && glmMatch[1] !== undefined && glmMatch[2] !== undefined) {
|
|
602
|
-
const toolName = glmMatch[1];
|
|
603
|
-
const rest = glmMatch[2].trim();
|
|
604
|
-
if (rest.includes("<arg_key>") && rest.includes("<arg_value>")) {
|
|
605
|
-
const args = {};
|
|
606
|
-
const keyValRegex = /<arg_key>([\s\S]*?)<\/arg_key>\s*<arg_value>([\s\S]*?)<\/arg_value>/gi;
|
|
607
|
-
let match;
|
|
608
|
-
let hasArgs = false;
|
|
609
|
-
while ((match = keyValRegex.exec(rest)) !== null) {
|
|
610
|
-
const key = match[1];
|
|
611
|
-
const rawVal = match[2];
|
|
612
|
-
if (key === undefined || rawVal === undefined)
|
|
613
|
-
continue;
|
|
614
|
-
const keyTrimmed = key.trim();
|
|
615
|
-
const rawValTrimmed = rawVal.trim();
|
|
616
|
-
let val = rawValTrimmed;
|
|
617
|
-
try {
|
|
618
|
-
val = JSON.parse(preprocessJson(rawValTrimmed));
|
|
619
|
-
}
|
|
620
|
-
catch {
|
|
621
|
-
// Keep as string
|
|
622
|
-
}
|
|
623
|
-
args[keyTrimmed] = val;
|
|
624
|
-
hasArgs = true;
|
|
625
|
-
}
|
|
626
|
-
if (hasArgs) {
|
|
627
|
-
return { name: toolName, args };
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
else if (rest === "") {
|
|
631
|
-
return { name: toolName, args: {} };
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
// Pattern 1 (name + args/arguments/parameters JSON):
|
|
635
|
-
// <tool_call>
|
|
636
|
-
// <name>tool.name</name>
|
|
637
|
-
// <args>{...}</args> (or <arguments> / <parameters>)
|
|
638
|
-
// <tool_call>
|
|
639
|
-
const xmlNameArgs = text.match(/<tool_call>[\s\S]*?<name>\s*([\w.]+?)\s*<\/name>\s*<(?:args|arguments|parameters)>\s*(\{[\s\S]*?\})\s*<\/(?:args|arguments|parameters)>[\s\S]*?<\/tool_call>/i);
|
|
640
|
-
if (xmlNameArgs?.[1] && xmlNameArgs?.[2]) {
|
|
641
|
-
try {
|
|
642
|
-
const args = JSON.parse(preprocessJson(xmlNameArgs[2]));
|
|
643
|
-
return {
|
|
644
|
-
name: xmlNameArgs[1],
|
|
645
|
-
args: args,
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
catch { }
|
|
649
|
-
}
|
|
650
|
-
// Pattern 1b (MiMo alternative):
|
|
651
|
-
// <tool_call>
|
|
652
|
-
// <tool_name>tool.name</tool_name>
|
|
653
|
-
// <parameters>{...}</parameters> (or <arguments> / <args>)
|
|
654
|
-
// <tool_call>
|
|
655
|
-
const xmlToolNameParams = text.match(/<tool_call>[\s\S]*?<tool_name>\s*([\w.]+?)\s*<\/tool_name>\s*<(?:parameters|arguments|args)>\s*(\{[\s\S]*?\})\s*<\/(?:parameters|arguments|args)>[\s\S]*?<\/tool_call>/i);
|
|
656
|
-
if (xmlToolNameParams?.[1] && xmlToolNameParams?.[2]) {
|
|
657
|
-
try {
|
|
658
|
-
const args = JSON.parse(preprocessJson(xmlToolNameParams[2]));
|
|
659
|
-
return {
|
|
660
|
-
name: xmlToolNameParams[1],
|
|
661
|
-
args: args,
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
catch { }
|
|
665
|
-
}
|
|
666
|
-
// Pattern 1c (MiMo function/parameter format), with or WITHOUT a
|
|
667
|
-
// surrounding <tool_call> wrapper (some models emit the bare function block):
|
|
668
|
-
// <function=tool.name>
|
|
669
|
-
// <parameter=name>value</parameter>
|
|
670
|
-
// </function>
|
|
671
|
-
const xmlFunctionBlock = text.match(/<function=([\w.]+?)>([\s\S]*?)<\/function>/i);
|
|
672
|
-
if (xmlFunctionBlock?.[1] && xmlFunctionBlock?.[2]) {
|
|
673
|
-
const name = xmlFunctionBlock[1];
|
|
674
|
-
const inner = xmlFunctionBlock[2];
|
|
675
|
-
const args = {};
|
|
676
|
-
const paramRegex = /<parameter=([\w.]+?)>([\s\S]*?)<\/parameter>/gi;
|
|
677
|
-
let paramMatch;
|
|
678
|
-
while ((paramMatch = paramRegex.exec(inner)) !== null) {
|
|
679
|
-
const paramName = paramMatch[1];
|
|
680
|
-
const paramValueStr = paramMatch[2].trim();
|
|
681
|
-
let paramValue = paramValueStr;
|
|
682
|
-
try {
|
|
683
|
-
if (/^(?:\[|\{|true|false|null|\d+(\.\d+)?$)/i.test(paramValueStr)) {
|
|
684
|
-
paramValue = JSON.parse(preprocessJson(paramValueStr));
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
catch { }
|
|
688
|
-
args[paramName] = paramValue;
|
|
689
|
-
}
|
|
690
|
-
return { name, args };
|
|
691
|
-
}
|
|
692
|
-
// Pattern 2: JSON object inside a recognized wrapper (closed). The wrapper
|
|
693
|
-
// may be the tool_call sentinel, <function_calls>, or <invoke>/<ant:invoke>.
|
|
694
|
-
// Backtracking off the closing tag handles nested {} in the args.
|
|
695
|
-
const wrappers = [
|
|
696
|
-
"<tool_call>",
|
|
697
|
-
"<function_calls>",
|
|
698
|
-
"<invoke>",
|
|
699
|
-
"<ant:invoke>",
|
|
700
|
-
];
|
|
701
|
-
for (const open of wrappers) {
|
|
702
|
-
const close = open === "<function_calls>"
|
|
703
|
-
? "</function_calls>"
|
|
704
|
-
: open === "<invoke>"
|
|
705
|
-
? "</invoke>"
|
|
706
|
-
: open === "<ant:invoke>"
|
|
707
|
-
? "</ant:invoke>"
|
|
708
|
-
: "</tool_call>";
|
|
709
|
-
const re = new RegExp(open.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") +
|
|
710
|
-
"[\\s\\S]*?(?:<tool>)?\\s*(\\{[\\s\\S]*?\\})\\s*" +
|
|
711
|
-
close.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "i");
|
|
712
|
-
const match = text.match(re);
|
|
713
|
-
if (match?.[1]) {
|
|
714
|
-
const call = tryParseCall(match[1]);
|
|
715
|
-
if (call)
|
|
716
|
-
return call;
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
// Pattern 3: a recognized opener is present but there is no matching close
|
|
720
|
-
// (model forgot it, or the stream was cut). Use a balanced brace scan from
|
|
721
|
-
// the first `{` after the opener so nested args survive, then try to parse.
|
|
722
|
-
const openerMatch = XML_BLOCK_OPENERS.exec(text);
|
|
723
|
-
if (openerMatch) {
|
|
724
|
-
const after = text.slice(openerMatch.index + openerMatch[0].length);
|
|
725
|
-
const json = extractBalancedJson(after);
|
|
726
|
-
if (json) {
|
|
727
|
-
const call = tryParseCall(json);
|
|
728
|
-
if (call)
|
|
729
|
-
return call;
|
|
730
|
-
}
|
|
731
|
-
// Also try the <name>...</name><arguments>{...}</arguments> tag shape
|
|
732
|
-
// without a closing wrapper (Hermes/Qwen often omit it).
|
|
733
|
-
const tagShape = after.match(/<name>\s*([\w.]+?)\s*<\/name>\s*<(?:args|arguments|parameters)>\s*(\{[\s\S]*?\})\s*<\/(?:args|arguments|parameters)>/i);
|
|
734
|
-
if (tagShape?.[1] && tagShape?.[2]) {
|
|
735
|
-
try {
|
|
736
|
-
const args = JSON.parse(preprocessJson(tagShape[2]));
|
|
737
|
-
return { name: tagShape[1], args: args };
|
|
738
|
-
}
|
|
739
|
-
catch { }
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
return undefined;
|
|
743
|
-
}
|
|
744
|
-
function tryJson(raw) {
|
|
745
|
-
try {
|
|
746
|
-
const preprocessed = preprocessJson(raw);
|
|
747
|
-
const parsed = JSON.parse(preprocessed);
|
|
748
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
749
|
-
return parsed;
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
catch {
|
|
753
|
-
// ignore
|
|
754
|
-
}
|
|
755
|
-
return undefined;
|
|
756
|
-
}
|
|
5
|
+
import { preprocessJson } from "./parser/xml-protocol.js";
|
|
6
|
+
import { salvageTruncatedWrite } from "./parser/salvage.js";
|
|
7
|
+
export { isMutatingToolName, looksLikeTruncatedToolCall, parseAllToolCalls, parseToolCall, sameToolCall } from "./parser/parse-entry.js";
|
|
8
|
+
export { inferToolFromArgs, recognizeBareToolJson } from "./parser/bare-recognition.js";
|
|
9
|
+
export { formatFsReadLineRange, formatToolArgs } from "./parser/arg-formatting.js";
|
|
10
|
+
export { collapseRepeatedText } from "./parser/repetition.js";
|
|
11
|
+
export { salvageTruncatedWrite };
|
|
12
|
+
export { preprocessJson };
|
|
757
13
|
const STRAY_DSML_TAG_RE = /<\/?[||]+DSML[||]+[A-Za-z0-9_]*\b[^>]*>/gi;
|
|
758
|
-
/** Strip any leftover Kimi/Moonshot sentinel tokens from final answers
|
|
759
|
-
* so a model that mixes prose and tool-call markers never bleeds raw
|
|
760
|
-
* `<|tool_call_begin|>` strings to the terminal. */
|
|
761
14
|
export function stripSentinelTokens(text) {
|
|
762
15
|
return text
|
|
763
16
|
.replace(/<\|tool_calls_section_begin\|>[\s\S]*?<\|tool_calls_section_end\|>/gi, "")
|
|
@@ -768,7 +21,6 @@ export function stripSentinelTokens(text) {
|
|
|
768
21
|
.replace(/<[||]+tool[_▁]calls[_▁]begin[||]+>[\s\S]*?(?:<[||]+tool[_▁]calls[_▁]end[||]+>|$)/gi, "")
|
|
769
22
|
.replace(/<[||]+tool[_▁]call[_▁]begin[||]+>[\s\S]*?(?:<[||]+tool[_▁]call[_▁]end[||]+>|$)/gi, "")
|
|
770
23
|
.replace(/<[||]+tool[_▁](?:calls?[_▁](?:begin|end)|sep)[||]+>/gi, "")
|
|
771
|
-
// GLM/Tencent id-tagged blocks (and bare openers left after a partial strip).
|
|
772
24
|
.replace(/<tool_calls:[A-Za-z0-9_-]+>[\s\S]*?(?:<\/tool_calls:[A-Za-z0-9_-]+>|$)/gi, "")
|
|
773
25
|
.replace(/<tool_call:[A-Za-z0-9_-]+>[\s\S]*?(?:<\/tool_call:[A-Za-z0-9_-]+>|$)/gi, "")
|
|
774
26
|
.replace(/<\/?tool_calls?:[A-Za-z0-9_-]+>/gi, "")
|
|
@@ -781,635 +33,20 @@ export function stripSentinelTokens(text) {
|
|
|
781
33
|
.replace(/<[||]+sep[||]+>/gi, "")
|
|
782
34
|
.trim();
|
|
783
35
|
}
|
|
784
|
-
export function parseToolCall(text, options = {}) {
|
|
785
|
-
// 1. ```tool ... ``` (standard format)
|
|
786
|
-
const fenced = text.match(/```tool\s*\n?([\s\S]*?)```/i);
|
|
787
|
-
if (fenced?.[1]) {
|
|
788
|
-
const call = tryParseCall(fenced[1]);
|
|
789
|
-
if (call)
|
|
790
|
-
return call;
|
|
791
|
-
}
|
|
792
|
-
// 2. <tool_call>...</tool_call> (XML formats)
|
|
793
|
-
const xmlCall = parseXmlToolCall(text);
|
|
794
|
-
if (xmlCall)
|
|
795
|
-
return xmlCall;
|
|
796
|
-
// 2b. <tool_call:id>name\n{args} (GLM / Tencent / some gateways)
|
|
797
|
-
const idTagged = parseIdTaggedToolCall(text);
|
|
798
|
-
if (idTagged)
|
|
799
|
-
return idTagged;
|
|
800
|
-
const dsml = parseDsmlToolCall(text);
|
|
801
|
-
if (dsml)
|
|
802
|
-
return dsml;
|
|
803
|
-
const openSep = parseOpenSepToolCall(text);
|
|
804
|
-
if (openSep)
|
|
805
|
-
return openSep;
|
|
806
|
-
// 3. Kimi/Moonshot sentinel format (used by kimi-k2 family on NIM).
|
|
807
|
-
const kimi = parseKimiToolCall(text);
|
|
808
|
-
if (kimi)
|
|
809
|
-
return kimi;
|
|
810
|
-
const deepseek = parseDeepseekToolCall(text);
|
|
811
|
-
if (deepseek)
|
|
812
|
-
return deepseek;
|
|
813
|
-
// In strict mode, stop here. Headings, generic fenced blocks, and trailing
|
|
814
|
-
// JSON are too easy to accidentally trigger when the model is showing a
|
|
815
|
-
// worked example.
|
|
816
|
-
if (options.strict)
|
|
817
|
-
return undefined;
|
|
818
|
-
// 4. ### tool / ## tool / # tool heading + JSON
|
|
819
|
-
const heading = text.match(/#{1,3}\s*tool\s*\n\s*(\{[\s\S]*\})/i);
|
|
820
|
-
if (heading?.[1]) {
|
|
821
|
-
const call = tryParseCall(heading[1]);
|
|
822
|
-
if (call)
|
|
823
|
-
return call;
|
|
824
|
-
}
|
|
825
|
-
// 5. **tool** heading + JSON
|
|
826
|
-
const bold = text.match(/\*\*tool\*\*\s*\n\s*(\{[\s\S]*\})/i);
|
|
827
|
-
if (bold?.[1]) {
|
|
828
|
-
const call = tryParseCall(bold[1]);
|
|
829
|
-
if (call)
|
|
830
|
-
return call;
|
|
831
|
-
}
|
|
832
|
-
// 6. Any fenced block (```json, ```, etc.) containing name+args
|
|
833
|
-
const anyFenced = text.match(/```\w*\s*\n?([\s\S]*?)```/);
|
|
834
|
-
if (anyFenced?.[1]) {
|
|
835
|
-
const call = tryParseCall(anyFenced[1]);
|
|
836
|
-
if (call)
|
|
837
|
-
return call;
|
|
838
|
-
}
|
|
839
|
-
// 7. Trailing JSON object with "name" and "args"
|
|
840
|
-
const trailingJson = text.match(/(\{"name"\s*:\s*"[^"]+"\s*,\s*"args"\s*:\s*\{[\s\S]*?\}\s*\})\s*$/);
|
|
841
|
-
if (trailingJson?.[1]) {
|
|
842
|
-
const call = tryParseCall(trailingJson[1]);
|
|
843
|
-
if (call)
|
|
844
|
-
return call;
|
|
845
|
-
}
|
|
846
|
-
return undefined;
|
|
847
|
-
}
|
|
848
|
-
// Argument keys that the built-in tools accept. Used to recognize when a
|
|
849
|
-
// model emitted a bare args object (e.g. {"path":"file.pdf"}) — intending a
|
|
850
|
-
// tool call but forgetting the {"name","args"} wrapper and the ```tool fence.
|
|
851
|
-
const TOOL_ARG_KEYS = new Set([
|
|
852
|
-
"command",
|
|
853
|
-
"path",
|
|
854
|
-
"paths",
|
|
855
|
-
"url",
|
|
856
|
-
"query",
|
|
857
|
-
"target",
|
|
858
|
-
"pattern",
|
|
859
|
-
"tool",
|
|
860
|
-
"tools",
|
|
861
|
-
"files",
|
|
862
|
-
"content",
|
|
863
|
-
"calls",
|
|
864
|
-
"record",
|
|
865
|
-
"ports",
|
|
866
|
-
"profile",
|
|
867
|
-
"id",
|
|
868
|
-
"lang",
|
|
869
|
-
"dpi",
|
|
870
|
-
"psm",
|
|
871
|
-
"recursive",
|
|
872
|
-
"oldText",
|
|
873
|
-
"newText",
|
|
874
|
-
"expectedReplacements",
|
|
875
|
-
"goal",
|
|
876
|
-
"tasks",
|
|
877
|
-
"taskId",
|
|
878
|
-
"notificationId",
|
|
879
|
-
"jobId",
|
|
880
|
-
"state",
|
|
881
|
-
"method",
|
|
882
|
-
"body",
|
|
883
|
-
"headers",
|
|
884
|
-
"maxBytes",
|
|
885
|
-
"maxResults",
|
|
886
|
-
"cwd",
|
|
887
|
-
"name",
|
|
888
|
-
"concurrency",
|
|
889
|
-
"on_fail",
|
|
890
|
-
"onFail",
|
|
891
|
-
"fail_policy",
|
|
892
|
-
"failPolicy",
|
|
893
|
-
"id",
|
|
894
|
-
"cancel_on_fail",
|
|
895
|
-
"cancelOnFail",
|
|
896
|
-
// Extra optional keys that commonly ride along with a bare args object so
|
|
897
|
-
// it is still recognized (and its tool inferred) instead of leaking to the
|
|
898
|
-
// screen — e.g. shell.exec with {"command":"…","timeoutMs":300000}.
|
|
899
|
-
"timeoutMs",
|
|
900
|
-
"flags",
|
|
901
|
-
"iOwnThis",
|
|
902
|
-
"own",
|
|
903
|
-
"note",
|
|
904
|
-
"kind",
|
|
905
|
-
"detail",
|
|
906
|
-
"maxEntries",
|
|
907
|
-
"checkBinary",
|
|
908
|
-
"scanType",
|
|
909
|
-
"whois",
|
|
910
|
-
"dns",
|
|
911
|
-
"nmap",
|
|
912
|
-
"bytes",
|
|
913
|
-
"responseMode",
|
|
914
|
-
"includeHeaders",
|
|
915
|
-
"includeTls",
|
|
916
|
-
"includeTiming",
|
|
917
|
-
"includeRedirectChain",
|
|
918
|
-
"redactSensitive",
|
|
919
|
-
]);
|
|
920
|
-
/**
|
|
921
|
-
* When a model emits a bare args object with no {"name", "args"} wrapper and
|
|
922
|
-
* no ```tool fence, infer which tool it MEANT from the argument keys so we
|
|
923
|
-
* can run it directly instead of nudging the model to re-emit (the user
|
|
924
|
-
* should not have to type "run"). Only unambiguous key signatures map to a
|
|
925
|
-
* tool; genuinely ambiguous shapes (a lone `path` could be fs.read / fs.list
|
|
926
|
-
* / pdf.read / image.ocr; a lone `target` could be whois / dns / scan) return
|
|
927
|
-
* undefined so the caller falls back to a re-emit nudge. Inferred calls still
|
|
928
|
-
* pass through the normal safety classifier + confirmation, so inference can
|
|
929
|
-
* never bypass a confirm/block gate.
|
|
930
|
-
*/
|
|
931
|
-
export function inferToolFromArgs(obj) {
|
|
932
|
-
const has = (key) => Object.prototype.hasOwnProperty.call(obj, key);
|
|
933
|
-
// `command` is deliberately NOT inferred: a fenced JSON object containing a
|
|
934
|
-
// "command" key routinely appears in material the model quotes from a
|
|
935
|
-
// README, web page, or config sample. Inferring shell.exec from it turns
|
|
936
|
-
// fetched content into an execution path, so the caller nudges for an
|
|
937
|
-
// explicit re-emit instead.
|
|
938
|
-
if (has("command") || has("cmd"))
|
|
939
|
-
return undefined;
|
|
940
|
-
if (has("files"))
|
|
941
|
-
return "fs.writeMany";
|
|
942
|
-
if (has("calls"))
|
|
943
|
-
return "tool.batch";
|
|
944
|
-
if (has("startLine") && has("endLine") && has("path"))
|
|
945
|
-
return "fs.replaceLines";
|
|
946
|
-
if (has("oldText") || has("newText"))
|
|
947
|
-
return "fs.edit";
|
|
948
|
-
if (has("position") && has("content") && has("path"))
|
|
949
|
-
return "fs.append";
|
|
950
|
-
if (has("content") && has("path"))
|
|
951
|
-
return "fs.write";
|
|
952
|
-
if (has("pattern"))
|
|
953
|
-
return "fs.search";
|
|
954
|
-
if (has("query"))
|
|
955
|
-
return "web.search";
|
|
956
|
-
if (has("tools"))
|
|
957
|
-
return "tool.check";
|
|
958
|
-
if (has("goal") && has("tasks"))
|
|
959
|
-
return "plan.create";
|
|
960
|
-
if (has("notificationId") || has("jobId"))
|
|
961
|
-
return "job.read";
|
|
962
|
-
if (has("taskId") &&
|
|
963
|
-
(has("position") || has("beforeTaskId") || has("afterTaskId")))
|
|
964
|
-
return "task.move";
|
|
965
|
-
if (has("taskId") || has("state"))
|
|
966
|
-
return "task.update";
|
|
967
|
-
if (has("tool"))
|
|
968
|
-
return "pkg.install";
|
|
969
|
-
if (has("record") && has("target"))
|
|
970
|
-
return "dns.lookup";
|
|
971
|
-
if (has("ports") && has("target"))
|
|
972
|
-
return "net.scan";
|
|
973
|
-
if (has("url")) {
|
|
974
|
-
// A url with an explicit method/body is a raw HTTP request (http.fetch);
|
|
975
|
-
// a lone url is a content read (web.fetch).
|
|
976
|
-
return has("method") || has("body") ? "http.fetch" : "web.fetch";
|
|
977
|
-
}
|
|
978
|
-
return undefined;
|
|
979
|
-
}
|
|
980
|
-
/**
|
|
981
|
-
* Strip a single wrapping ```json / ``` fence (if any) and return the inner
|
|
982
|
-
* text trimmed. Leaves un-fenced text unchanged.
|
|
983
|
-
*/
|
|
984
|
-
function stripLoneFence(text) {
|
|
985
|
-
const fenced = text.trim().match(/^```[a-zA-Z]*\s*\n?([\s\S]*?)\n?```$/);
|
|
986
|
-
return (fenced?.[1] ?? text).trim();
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
* Try to recover a bare-args tool call from a single candidate text snippet.
|
|
990
|
-
* Returns the recognized result or undefined if the text isn't a recoverable
|
|
991
|
-
* tool call. Used by both the whole-text path and the embedded-fence path.
|
|
992
|
-
*/
|
|
993
|
-
function tryRecognizeBareArgs(inner) {
|
|
994
|
-
const trimmed = inner.trim();
|
|
995
|
-
if (!trimmed.startsWith("{") || !trimmed.endsWith("}"))
|
|
996
|
-
return undefined;
|
|
997
|
-
let parsed;
|
|
998
|
-
try {
|
|
999
|
-
parsed = JSON.parse(trimmed);
|
|
1000
|
-
}
|
|
1001
|
-
catch {
|
|
1002
|
-
return undefined;
|
|
1003
|
-
}
|
|
1004
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1005
|
-
return undefined;
|
|
1006
|
-
}
|
|
1007
|
-
const obj = parsed;
|
|
1008
|
-
// Complete {name, args} call the earlier matchers didn't catch.
|
|
1009
|
-
const direct = tryParseCall(trimmed);
|
|
1010
|
-
if (direct)
|
|
1011
|
-
return { call: direct };
|
|
1012
|
-
// Bare args object: every key is a known tool-arg key.
|
|
1013
|
-
const keys = Object.keys(obj);
|
|
1014
|
-
if (keys.length === 0 || keys.length > 6)
|
|
1015
|
-
return undefined;
|
|
1016
|
-
const allKnown = keys.every((key) => TOOL_ARG_KEYS.has(key));
|
|
1017
|
-
if (!allKnown)
|
|
1018
|
-
return undefined;
|
|
1019
|
-
const inferred = inferToolFromArgs(obj);
|
|
1020
|
-
if (inferred) {
|
|
1021
|
-
return { call: { name: inferred, args: obj } };
|
|
1022
|
-
}
|
|
1023
|
-
return { argsOnly: true };
|
|
1024
|
-
}
|
|
1025
|
-
/**
|
|
1026
|
-
* When a model means to call a tool but emits ONLY a bare JSON object —
|
|
1027
|
-
* either a proper {"name","args"} that the strict matchers missed, or a bare
|
|
1028
|
-
* args object like {"path":"file.pdf"} with the wrapper/fence dropped — this
|
|
1029
|
-
* recognizes it. Returns:
|
|
1030
|
-
* - { call } when the object is a complete {name, args} tool call, or
|
|
1031
|
-
* - { argsOnly: true } when it looks like a bare args object (so the caller
|
|
1032
|
-
* can nudge the model to re-emit a properly named, fenced tool call).
|
|
1033
|
-
* Returns undefined for anything that is plainly a normal prose/JSON answer.
|
|
1034
|
-
*
|
|
1035
|
-
* Also handles the case where a model emits prose followed by a non-`tool`
|
|
1036
|
-
* fenced code block (e.g. ```web\n{"url":"..."}\n```) that contains a bare
|
|
1037
|
-
* args object — the fence is scanned even when it's not the sole content.
|
|
1038
|
-
*/
|
|
1039
|
-
export function recognizeBareToolJson(text) {
|
|
1040
|
-
// Primary path: the whole (de-fenced) text is a bare JSON object
|
|
1041
|
-
const inner = stripLoneFence(text);
|
|
1042
|
-
const primary = tryRecognizeBareArgs(inner);
|
|
1043
|
-
if (primary)
|
|
1044
|
-
return primary;
|
|
1045
|
-
// Secondary path: scan for a fenced block that is the model's OWN trailing
|
|
1046
|
-
// content (the last fence in the message, with nothing but whitespace after
|
|
1047
|
-
// it). Quoted material in the middle of an answer is never treated as a
|
|
1048
|
-
// call, which keeps fetched README/web content out of the execution path.
|
|
1049
|
-
// We skip ```tool fences — those are handled by parseToolCall already.
|
|
1050
|
-
const embeddedFenceRe = /```([a-zA-Z]*)\s*\n?([\s\S]*?)```/g;
|
|
1051
|
-
let m;
|
|
1052
|
-
let lastFence;
|
|
1053
|
-
while ((m = embeddedFenceRe.exec(text)) !== null) {
|
|
1054
|
-
lastFence = {
|
|
1055
|
-
lang: m[1] ?? "",
|
|
1056
|
-
body: (m[2] ?? "").trim(),
|
|
1057
|
-
end: m.index + m[0].length,
|
|
1058
|
-
};
|
|
1059
|
-
}
|
|
1060
|
-
if (lastFence && text.slice(lastFence.end).trim() === "") {
|
|
1061
|
-
const lang = lastFence.lang.toLowerCase();
|
|
1062
|
-
if (lang !== "tool") {
|
|
1063
|
-
const body = lastFence.body;
|
|
1064
|
-
if (body.startsWith("{") && body.endsWith("}")) {
|
|
1065
|
-
const result = tryRecognizeBareArgs(body);
|
|
1066
|
-
if (result)
|
|
1067
|
-
return result;
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
return undefined;
|
|
1072
|
-
}
|
|
1073
|
-
/**
|
|
1074
|
-
* Detect an opened-but-unparseable tool call. This happens when the model's
|
|
1075
|
-
* output is truncated by the token limit mid-JSON: we see the ```tool fence
|
|
1076
|
-
* (or a bare {"name":"...","args" prefix) open, but parseToolCall returns
|
|
1077
|
-
* undefined because the JSON never closed. Without this, the broken block
|
|
1078
|
-
* leaks to the screen as a "final answer" and the requested action (e.g. a
|
|
1079
|
-
* multi-file fs.writeMany scaffold) silently never runs.
|
|
1080
|
-
*/
|
|
1081
|
-
export function looksLikeTruncatedToolCall(text) {
|
|
1082
|
-
// An opened ```tool fence with no closing fence.
|
|
1083
|
-
const openFence = /```tool\s*\n?/i.test(text);
|
|
1084
|
-
const closeFence = /```tool[\s\S]*?```/i.test(text);
|
|
1085
|
-
if (openFence && !closeFence)
|
|
1086
|
-
return true;
|
|
1087
|
-
// A tool-call JSON object that started but whose braces never balanced.
|
|
1088
|
-
const jsonStart = text.search(/\{\s*"name"\s*:\s*"[A-Za-z][\w.]*"\s*,\s*"args"/);
|
|
1089
|
-
if (jsonStart >= 0) {
|
|
1090
|
-
const slice = text.slice(jsonStart);
|
|
1091
|
-
let depth = 0;
|
|
1092
|
-
let inString = false;
|
|
1093
|
-
let escaped = false;
|
|
1094
|
-
let balanced = false;
|
|
1095
|
-
for (const ch of slice) {
|
|
1096
|
-
if (escaped) {
|
|
1097
|
-
escaped = false;
|
|
1098
|
-
continue;
|
|
1099
|
-
}
|
|
1100
|
-
if (ch === "\\") {
|
|
1101
|
-
escaped = true;
|
|
1102
|
-
continue;
|
|
1103
|
-
}
|
|
1104
|
-
if (ch === '"')
|
|
1105
|
-
inString = !inString;
|
|
1106
|
-
if (inString)
|
|
1107
|
-
continue;
|
|
1108
|
-
if (ch === "{")
|
|
1109
|
-
depth += 1;
|
|
1110
|
-
else if (ch === "}") {
|
|
1111
|
-
depth -= 1;
|
|
1112
|
-
if (depth === 0) {
|
|
1113
|
-
balanced = true;
|
|
1114
|
-
break;
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
if (!balanced)
|
|
1119
|
-
return true;
|
|
1120
|
-
}
|
|
1121
|
-
// An id-tagged block (GLM / Kimi-style wire) left open. Its arguments are
|
|
1122
|
-
// only trusted once the block closes, so a cut stream must retry rather than
|
|
1123
|
-
// leak the opener as prose. Later openers win: earlier blocks that closed
|
|
1124
|
-
// were already parsed and returned by parseAllToolCalls.
|
|
1125
|
-
const idOpeners = [...text.matchAll(/<tool_call:[A-Za-z0-9_-]+>/gi)];
|
|
1126
|
-
const lastOpener = idOpeners[idOpeners.length - 1];
|
|
1127
|
-
if (lastOpener?.index !== undefined) {
|
|
1128
|
-
const after = text.slice(lastOpener.index + lastOpener[0].length);
|
|
1129
|
-
if (!/<\/tool_call\b/i.test(after))
|
|
1130
|
-
return true;
|
|
1131
|
-
}
|
|
1132
|
-
return false;
|
|
1133
|
-
}
|
|
1134
|
-
/**
|
|
1135
|
-
* Attempt to extract usable content from a truncated fs.write / fs.append
|
|
1136
|
-
* tool call. When the model's output is cut off mid-JSON, the tool call fails
|
|
1137
|
-
* to parse — but typically a large chunk of the intended file content is
|
|
1138
|
-
* already present in the raw text. This function extracts:
|
|
1139
|
-
* - operation: which mutation the model actually asked for
|
|
1140
|
-
* - path: the target file path
|
|
1141
|
-
* - content: the partial file content (up to the truncation point)
|
|
1142
|
-
* - lastLine: the last complete line (for telling the model where to resume)
|
|
1143
|
-
* - expectedPriorBytes: the append precondition when the model supplied one
|
|
1144
|
-
*
|
|
1145
|
-
* Returns undefined when the text does not look like an unambiguous single
|
|
1146
|
-
* write/append call. `fs.writeMany` is never salvaged: a truncated multi-file
|
|
1147
|
-
* payload cannot be attributed to one file safely.
|
|
1148
|
-
*/
|
|
1149
|
-
/**
|
|
1150
|
-
* Single-pass JSON string unescape for salvaged (possibly truncated) content.
|
|
1151
|
-
* Order matters: a chained `.replace` sequence turns the escaped Windows path
|
|
1152
|
-
* `C:\\new` into `C:` + newline + `ew`. Unknown escapes are kept verbatim, and
|
|
1153
|
-
* a trailing incomplete escape is dropped.
|
|
1154
|
-
*/
|
|
1155
|
-
function unescapeJsonStringPrefix(raw) {
|
|
1156
|
-
let out = "";
|
|
1157
|
-
for (let i = 0; i < raw.length; i += 1) {
|
|
1158
|
-
const ch = raw[i];
|
|
1159
|
-
if (ch !== "\\") {
|
|
1160
|
-
out += ch;
|
|
1161
|
-
continue;
|
|
1162
|
-
}
|
|
1163
|
-
const next = raw[i + 1];
|
|
1164
|
-
if (next === undefined)
|
|
1165
|
-
break;
|
|
1166
|
-
switch (next) {
|
|
1167
|
-
case "n":
|
|
1168
|
-
out += "\n";
|
|
1169
|
-
i += 1;
|
|
1170
|
-
break;
|
|
1171
|
-
case "r":
|
|
1172
|
-
out += "\r";
|
|
1173
|
-
i += 1;
|
|
1174
|
-
break;
|
|
1175
|
-
case "t":
|
|
1176
|
-
out += "\t";
|
|
1177
|
-
i += 1;
|
|
1178
|
-
break;
|
|
1179
|
-
case "b":
|
|
1180
|
-
out += "\b";
|
|
1181
|
-
i += 1;
|
|
1182
|
-
break;
|
|
1183
|
-
case "f":
|
|
1184
|
-
out += "\f";
|
|
1185
|
-
i += 1;
|
|
1186
|
-
break;
|
|
1187
|
-
case '"':
|
|
1188
|
-
out += '"';
|
|
1189
|
-
i += 1;
|
|
1190
|
-
break;
|
|
1191
|
-
case "/":
|
|
1192
|
-
out += "/";
|
|
1193
|
-
i += 1;
|
|
1194
|
-
break;
|
|
1195
|
-
case "\\":
|
|
1196
|
-
out += "\\";
|
|
1197
|
-
i += 1;
|
|
1198
|
-
break;
|
|
1199
|
-
case "u": {
|
|
1200
|
-
const hex = raw.slice(i + 2, i + 6);
|
|
1201
|
-
if (/^[0-9a-fA-F]{4}$/.test(hex)) {
|
|
1202
|
-
out += String.fromCharCode(Number.parseInt(hex, 16));
|
|
1203
|
-
i += 5;
|
|
1204
|
-
}
|
|
1205
|
-
else {
|
|
1206
|
-
// Truncated \uXXXX at the cut point — drop it.
|
|
1207
|
-
i = raw.length;
|
|
1208
|
-
}
|
|
1209
|
-
break;
|
|
1210
|
-
}
|
|
1211
|
-
default:
|
|
1212
|
-
out += `\\${next}`;
|
|
1213
|
-
i += 1;
|
|
1214
|
-
break;
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
return out;
|
|
1218
|
-
}
|
|
1219
|
-
export function salvageTruncatedWrite(text) {
|
|
1220
|
-
// Match fs.write or fs.append: {"name":"fs.write","args":{"path":"...","content":"...
|
|
1221
|
-
// Also handle "fs.append" and cases where content comes before path.
|
|
1222
|
-
const toolNameMatch = text.match(/\{\s*"name"\s*:\s*"fs\.(write|append)"\s*,\s*"args"\s*:\s*\{/);
|
|
1223
|
-
if (toolNameMatch) {
|
|
1224
|
-
const operation = toolNameMatch[1] === "append" ? "append" : "write";
|
|
1225
|
-
const argsStart = text.indexOf(toolNameMatch[0]) + toolNameMatch[0].length;
|
|
1226
|
-
const afterArgs = text.slice(argsStart);
|
|
1227
|
-
// Extract path value
|
|
1228
|
-
const pathMatch = afterArgs.match(/"path"\s*:\s*"([^"]+)"/);
|
|
1229
|
-
if (!pathMatch?.[1])
|
|
1230
|
-
return undefined;
|
|
1231
|
-
const path = pathMatch[1];
|
|
1232
|
-
const priorMatch = afterArgs.match(/"expectedPriorBytes"\s*:\s*(\d{1,15})(?!\d)/);
|
|
1233
|
-
const expectedPriorBytes = priorMatch?.[1]
|
|
1234
|
-
? Number(priorMatch[1])
|
|
1235
|
-
: undefined;
|
|
1236
|
-
// Find where "content":" starts and extract everything after its opening quote
|
|
1237
|
-
const contentKeyMatch = afterArgs.match(/"content"\s*:\s*"/);
|
|
1238
|
-
if (!contentKeyMatch)
|
|
1239
|
-
return undefined;
|
|
1240
|
-
const contentStart = argsStart + afterArgs.indexOf(contentKeyMatch[0]) + contentKeyMatch[0].length;
|
|
1241
|
-
let raw = text.slice(contentStart);
|
|
1242
|
-
// The content is JSON-encoded (escaped). Unescape in one pass so a
|
|
1243
|
-
// literal backslash sequence is not re-interpreted.
|
|
1244
|
-
raw = raw.replace(/\\?$/, "");
|
|
1245
|
-
try {
|
|
1246
|
-
const unescaped = unescapeJsonStringPrefix(raw);
|
|
1247
|
-
// Trim to the last complete line
|
|
1248
|
-
const lastNewline = unescaped.lastIndexOf("\n");
|
|
1249
|
-
const content = lastNewline > 0 ? unescaped.slice(0, lastNewline + 1) : unescaped;
|
|
1250
|
-
if (content.trim().length < 50)
|
|
1251
|
-
return undefined; // Too little to salvage
|
|
1252
|
-
const lines = content.trimEnd().split("\n");
|
|
1253
|
-
const lastLine = lines[lines.length - 1]?.trim().slice(0, 80) ?? "(unknown)";
|
|
1254
|
-
return { operation, path, content, lastLine, expectedPriorBytes };
|
|
1255
|
-
}
|
|
1256
|
-
catch {
|
|
1257
|
-
return undefined;
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
// fs.writeMany is intentionally NOT salvaged: a truncated multi-file payload
|
|
1261
|
-
// is ambiguous about which files were meant to be written, and guessing the
|
|
1262
|
-
// first entry can silently overwrite a different file than intended.
|
|
1263
|
-
return undefined;
|
|
1264
|
-
}
|
|
1265
36
|
const NATIVE_WRITE_TOOLS = new Set(["fs.write", "fs.append"]);
|
|
1266
|
-
/**
|
|
1267
|
-
* Salvage partial file content from a native tool call's raw argument JSON
|
|
1268
|
-
* (streaming cut off / finish_reason length / _parseError). Reuses the
|
|
1269
|
-
* text-path salvage by reconstructing a minimal {"name","args"} shape.
|
|
1270
|
-
*/
|
|
1271
37
|
export function salvageTruncatedWriteFromNative(name, rawArguments) {
|
|
1272
38
|
if (!NATIVE_WRITE_TOOLS.has(name) || !rawArguments?.trim())
|
|
1273
39
|
return undefined;
|
|
1274
40
|
const raw = rawArguments.trim();
|
|
1275
|
-
// raw is usually the args object JSON only; wrap for salvageTruncatedWrite.
|
|
1276
41
|
const synthetic = raw.includes(`"name"`)
|
|
1277
42
|
? raw
|
|
1278
43
|
: `{"name":${JSON.stringify(name)},"args":${raw.startsWith("{") ? raw : `{}`}`;
|
|
1279
44
|
return salvageTruncatedWrite(synthetic);
|
|
1280
45
|
}
|
|
1281
|
-
/**
|
|
1282
|
-
* Count the number of ```tool fenced blocks in a message. Models sometimes
|
|
1283
|
-
* emit MULTIPLE tool calls in one response (e.g. fs.writeMany + npm install +
|
|
1284
|
-
* npm run dev). Only the FIRST is parsed and executed; the rest are silently
|
|
1285
|
-
* dropped and leak to the screen as code fences, while the model believes it
|
|
1286
|
-
* ran all of them — a major cause of "everything is done" fabrications. We
|
|
1287
|
-
* detect this so the runner can run the first and explicitly tell the model
|
|
1288
|
-
* the others did NOT run and must be re-sent one at a time.
|
|
1289
|
-
*/
|
|
1290
46
|
export function countToolFences(text) {
|
|
1291
47
|
const matches = text.match(/```tool\s*\n[\s\S]*?```/gi);
|
|
1292
48
|
return matches ? matches.length : 0;
|
|
1293
49
|
}
|
|
1294
|
-
/**
|
|
1295
|
-
* Parse every explicitly-delimited tool call in a message (```tool fences,
|
|
1296
|
-
* <tool_call> XML, Kimi sentinel blocks), in document order, so the runner
|
|
1297
|
-
* can execute a batch emitted in one turn instead of only the first call.
|
|
1298
|
-
*/
|
|
1299
|
-
export function parseAllToolCalls(text) {
|
|
1300
|
-
const found = [];
|
|
1301
|
-
let m;
|
|
1302
|
-
const fenceRe = /```tool\s*\n?([\s\S]*?)```/gi;
|
|
1303
|
-
while ((m = fenceRe.exec(text)) !== null) {
|
|
1304
|
-
const call = tryParseCall(m[1] ?? "");
|
|
1305
|
-
if (call)
|
|
1306
|
-
found.push({ index: m.index, call });
|
|
1307
|
-
}
|
|
1308
|
-
const xmlRe = /<tool_call>([\s\S]*?)<\/tool_call>/gi;
|
|
1309
|
-
while ((m = xmlRe.exec(text)) !== null) {
|
|
1310
|
-
const call = parseXmlToolCall(m[0]);
|
|
1311
|
-
if (call)
|
|
1312
|
-
found.push({ index: m.index, call });
|
|
1313
|
-
}
|
|
1314
|
-
for (const entry of parseAllIdTaggedToolCalls(text)) {
|
|
1315
|
-
found.push(entry);
|
|
1316
|
-
}
|
|
1317
|
-
for (const entry of parseAllDsmlToolCalls(text)) {
|
|
1318
|
-
found.push(entry);
|
|
1319
|
-
}
|
|
1320
|
-
for (const entry of parseAllOpenSepToolCalls(text)) {
|
|
1321
|
-
found.push(entry);
|
|
1322
|
-
}
|
|
1323
|
-
const kimiRe = new RegExp(KIMI_TOOL_CALL_RE.source, "gi");
|
|
1324
|
-
while ((m = kimiRe.exec(text)) !== null) {
|
|
1325
|
-
const call = tryParseCall(JSON.stringify({ name: m[1], args: tryJson(m[2] ?? "{}") ?? {} }));
|
|
1326
|
-
if (call)
|
|
1327
|
-
found.push({ index: m.index, call });
|
|
1328
|
-
}
|
|
1329
|
-
const deepseekRe = new RegExp(DEEPSEEK_TOOL_CALL_RE.source, "gi");
|
|
1330
|
-
while ((m = deepseekRe.exec(text)) !== null) {
|
|
1331
|
-
const call = tryParseCall(JSON.stringify({ name: m[1], args: tryJson(m[2] ?? "{}") ?? {} }));
|
|
1332
|
-
if (call)
|
|
1333
|
-
found.push({ index: m.index, call });
|
|
1334
|
-
}
|
|
1335
|
-
// Bare <function=name>…</function> blocks (no <tool_call> wrapper) — some
|
|
1336
|
-
// models emit one or several of these. Route each through parseXmlToolCall
|
|
1337
|
-
// so the <parameter=…> args are decoded. Skip any that overlap a
|
|
1338
|
-
// <tool_call> block already captured above (avoid double-counting).
|
|
1339
|
-
const fnRe = /<function=[\w.]+?>[\s\S]*?<\/function>/gi;
|
|
1340
|
-
while ((m = fnRe.exec(text)) !== null) {
|
|
1341
|
-
const alreadyCaptured = found.some((f) => m.index >= f.index && m.index < f.index + 12);
|
|
1342
|
-
const overlapsToolCall = /<tool_call>/i.test(text.slice(Math.max(0, m.index - 24), m.index));
|
|
1343
|
-
if (alreadyCaptured || overlapsToolCall)
|
|
1344
|
-
continue;
|
|
1345
|
-
const call = parseXmlToolCall(m[0]);
|
|
1346
|
-
if (call)
|
|
1347
|
-
found.push({ index: m.index, call });
|
|
1348
|
-
}
|
|
1349
|
-
found.sort((a, b) => a.index - b.index);
|
|
1350
|
-
const deduped = [];
|
|
1351
|
-
for (const entry of found) {
|
|
1352
|
-
const mutating = isMutatingToolName(entry.call.name);
|
|
1353
|
-
if (deduped.some((d) => sameToolCall(d.call, entry.call) &&
|
|
1354
|
-
(mutating || Math.abs(d.index - entry.index) < 64))) {
|
|
1355
|
-
continue;
|
|
1356
|
-
}
|
|
1357
|
-
deduped.push(entry);
|
|
1358
|
-
}
|
|
1359
|
-
const MAX_PER_TOOL = 5;
|
|
1360
|
-
const toolCounts = new Map();
|
|
1361
|
-
const capped = [];
|
|
1362
|
-
for (const entry of deduped) {
|
|
1363
|
-
const count = toolCounts.get(entry.call.name) ?? 0;
|
|
1364
|
-
if (count >= MAX_PER_TOOL)
|
|
1365
|
-
continue;
|
|
1366
|
-
toolCounts.set(entry.call.name, count + 1);
|
|
1367
|
-
capped.push(entry.call);
|
|
1368
|
-
}
|
|
1369
|
-
return capped;
|
|
1370
|
-
}
|
|
1371
|
-
/**
|
|
1372
|
-
* Tools whose duplicate execution changes state (files, packages, processes,
|
|
1373
|
-
* remote resources). Duplicate identical calls to these are collapsed across
|
|
1374
|
-
* a whole message rather than only within a 64-character window.
|
|
1375
|
-
*/
|
|
1376
|
-
const MUTATING_TOOL_NAMES = new Set([
|
|
1377
|
-
"fs.write",
|
|
1378
|
-
"fs.writeMany",
|
|
1379
|
-
"fs.append",
|
|
1380
|
-
"fs.edit",
|
|
1381
|
-
"fs.replaceLines",
|
|
1382
|
-
"fs.delete",
|
|
1383
|
-
"shell.exec",
|
|
1384
|
-
"shell.start",
|
|
1385
|
-
"shell.stop",
|
|
1386
|
-
"pkg.install",
|
|
1387
|
-
"http.fetch",
|
|
1388
|
-
"tool.batch",
|
|
1389
|
-
]);
|
|
1390
|
-
export function isMutatingToolName(name) {
|
|
1391
|
-
return MUTATING_TOOL_NAMES.has(name.trim());
|
|
1392
|
-
}
|
|
1393
|
-
/** Structural equality for two tool calls (name + canonical args JSON). */
|
|
1394
|
-
export function sameToolCall(a, b) {
|
|
1395
|
-
if (a.name !== b.name)
|
|
1396
|
-
return false;
|
|
1397
|
-
try {
|
|
1398
|
-
return JSON.stringify(a.args) === JSON.stringify(b.args);
|
|
1399
|
-
}
|
|
1400
|
-
catch {
|
|
1401
|
-
return false;
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
/**
|
|
1405
|
-
* Partition a batch of tool calls (in document order) into execution groups.
|
|
1406
|
-
* A run of consecutive parallel-safe calls forms one group to be run
|
|
1407
|
-
* concurrently (bounded by maxGroupSize); every non-parallel-safe call is its
|
|
1408
|
-
* own single-element group, i.e. a sequential barrier. Because plan updates
|
|
1409
|
-
* and side-effecting tools are never parallel-safe, they always split the
|
|
1410
|
-
* batch — which keeps parallelism scoped within a single task and prevents
|
|
1411
|
-
* plan-state races and overlapping writes.
|
|
1412
|
-
*/
|
|
1413
50
|
export function groupToolCallsForExecution(calls, isParallelSafe, maxGroupSize = 4) {
|
|
1414
51
|
const groups = [];
|
|
1415
52
|
let cursor = 0;
|
|
@@ -1429,21 +66,11 @@ export function groupToolCallsForExecution(calls, isParallelSafe, maxGroupSize =
|
|
|
1429
66
|
}
|
|
1430
67
|
return groups;
|
|
1431
68
|
}
|
|
1432
|
-
/**
|
|
1433
|
-
* Build the conversation to hand back to the caller at turn end. Strips system
|
|
1434
|
-
* prompts (they're re-added each turn) but keeps the user turn plus every
|
|
1435
|
-
* assistant tool-call and tool result, then appends the final answer if it
|
|
1436
|
-
* isn't already the last message. Persisting this is what lets a resumed
|
|
1437
|
-
* session give the model back what it actually did — commands, outputs, and
|
|
1438
|
-
* results — instead of only its prose answers.
|
|
1439
|
-
*/
|
|
1440
69
|
export function buildTurnHistory(messages, answer) {
|
|
1441
|
-
// Drop system messages (the main prompt, plan context, and reflections are
|
|
1442
|
-
// all re-injected each turn) EXCEPT compacted session memory, which is the
|
|
1443
|
-
// only record of summarized older turns and must survive a resume.
|
|
1444
70
|
const convo = messages.filter((m) => m.role !== "system" ||
|
|
1445
71
|
isCompactionMemoryMessage(m) ||
|
|
1446
|
-
isResponderResultLedgerMessage(m)
|
|
72
|
+
isResponderResultLedgerMessage(m) ||
|
|
73
|
+
isDurableInjectedBlock(m));
|
|
1447
74
|
const last = convo[convo.length - 1];
|
|
1448
75
|
if (answer &&
|
|
1449
76
|
!(last && last.role === "assistant" && last.content === answer)) {
|
|
@@ -1451,98 +78,10 @@ export function buildTurnHistory(messages, answer) {
|
|
|
1451
78
|
}
|
|
1452
79
|
return projectToolHistory(convo).messages;
|
|
1453
80
|
}
|
|
1454
|
-
/** Lines where repetition is meaningful syntax/content and must stay byte-exact. */
|
|
1455
|
-
function isRepetitionSensitiveMarkdownLine(line) {
|
|
1456
|
-
if (/^(?: {4}|\t)/.test(line))
|
|
1457
|
-
return true;
|
|
1458
|
-
if (line.includes("`"))
|
|
1459
|
-
return true;
|
|
1460
|
-
if ((line.match(/\|/g)?.length ?? 0) >= 2)
|
|
1461
|
-
return true;
|
|
1462
|
-
if (/!?\[[^\]]*\](?:\([^)]*\)|\[[^\]]*\])/.test(line))
|
|
1463
|
-
return true;
|
|
1464
|
-
if (/^\s{0,3}(?:#{1,6}(?:\s|$)|>\s?|[-+*]\s+|\d+[.)]\s+)/.test(line)) {
|
|
1465
|
-
return true;
|
|
1466
|
-
}
|
|
1467
|
-
return /^\s{0,3}(?:(?:-\s*){3,}|(?:_\s*){3,}|(?:\*\s*){3,}|=+)\s*$/.test(line);
|
|
1468
|
-
}
|
|
1469
|
-
function collapseRepeatedProse(text) {
|
|
1470
|
-
return text.replace(/(.{3,80}?)\1{6,}/gs, (match, unit) => {
|
|
1471
|
-
// Punctuation runs are commonly Markdown separators/rules even when a
|
|
1472
|
-
// caller gives us an incomplete fragment without its surrounding line.
|
|
1473
|
-
if (!/[\p{L}\p{N}]/u.test(unit))
|
|
1474
|
-
return match;
|
|
1475
|
-
return `${unit.repeat(3)} …[repeated ~${Math.round(match.length / Math.max(1, unit.length))}× — collapsed]`;
|
|
1476
|
-
});
|
|
1477
|
-
}
|
|
1478
|
-
/**
|
|
1479
|
-
* Collapse pathological repetition before a message is stored in history.
|
|
1480
|
-
* Some models degenerate into emitting the same short phrase hundreds of
|
|
1481
|
-
* times ("We need to wait.We need to wait.…"), which otherwise bloats the
|
|
1482
|
-
* context window and wastes tokens on every subsequent turn. We keep a few
|
|
1483
|
-
* copies and note the collapse so the meaning is preserved without the bulk.
|
|
1484
|
-
*
|
|
1485
|
-
* Markdown tables, rules, lists, links, and code must remain exact: this runs
|
|
1486
|
-
* before Markdown parsing, so changing one delimiter makes the renderer fall
|
|
1487
|
-
* back to raw pipes. Plain prose spans can still include repeated newlines and
|
|
1488
|
-
* therefore retain the original protection against multi-line degeneration.
|
|
1489
|
-
*/
|
|
1490
|
-
export function collapseRepeatedText(text) {
|
|
1491
|
-
if (!text || text.length < 1500)
|
|
1492
|
-
return text;
|
|
1493
|
-
try {
|
|
1494
|
-
const pieces = text.split(/(\r\n|\n|\r)/);
|
|
1495
|
-
let output = "";
|
|
1496
|
-
let prose = "";
|
|
1497
|
-
let fence;
|
|
1498
|
-
const flushProse = () => {
|
|
1499
|
-
if (!prose)
|
|
1500
|
-
return;
|
|
1501
|
-
output += collapseRepeatedProse(prose);
|
|
1502
|
-
prose = "";
|
|
1503
|
-
};
|
|
1504
|
-
for (let index = 0; index < pieces.length; index += 2) {
|
|
1505
|
-
const line = pieces[index] ?? "";
|
|
1506
|
-
const newline = pieces[index + 1] ?? "";
|
|
1507
|
-
const fenceMatch = /^\s{0,3}(`{3,}|~{3,})/.exec(line);
|
|
1508
|
-
const protectedLine = fence !== undefined ||
|
|
1509
|
-
fenceMatch !== null ||
|
|
1510
|
-
isRepetitionSensitiveMarkdownLine(line);
|
|
1511
|
-
if (protectedLine) {
|
|
1512
|
-
flushProse();
|
|
1513
|
-
output += line + newline;
|
|
1514
|
-
}
|
|
1515
|
-
else {
|
|
1516
|
-
prose += line + newline;
|
|
1517
|
-
}
|
|
1518
|
-
if (fenceMatch) {
|
|
1519
|
-
const token = fenceMatch[1];
|
|
1520
|
-
if (!fence) {
|
|
1521
|
-
fence = { marker: token[0], length: token.length };
|
|
1522
|
-
}
|
|
1523
|
-
else {
|
|
1524
|
-
const rest = line.slice(fenceMatch[0].length);
|
|
1525
|
-
if (token[0] === fence.marker &&
|
|
1526
|
-
token.length >= fence.length &&
|
|
1527
|
-
rest.trim() === "") {
|
|
1528
|
-
fence = undefined;
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
flushProse();
|
|
1534
|
-
return output;
|
|
1535
|
-
}
|
|
1536
|
-
catch {
|
|
1537
|
-
return text;
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
/** Extract the text before the tool call block for display purposes */
|
|
1541
81
|
export function textBeforeToolCall(text) {
|
|
1542
82
|
const patterns = [
|
|
1543
83
|
/```tool\s*\n?[\s\S]*$/i,
|
|
1544
84
|
/<tool_call>[\s\S]*$/i,
|
|
1545
|
-
// GLM/Tencent id-tagged tool blocks — never show raw XML as ◆ Response.
|
|
1546
85
|
/<tool_calls:[A-Za-z0-9_-]+>[\s\S]*$/i,
|
|
1547
86
|
/<tool_call:[A-Za-z0-9_-]+>[\s\S]*$/i,
|
|
1548
87
|
/<[||]+DSML[||]+tool_calls\b[\s\S]*$/i,
|
|
@@ -1550,8 +89,6 @@ export function textBeforeToolCall(text) {
|
|
|
1550
89
|
/<[||]+DSML[||]+parameter\b[\s\S]*$/i,
|
|
1551
90
|
/<[||]+open[||]+>?tools\b[\s\S]*$/i,
|
|
1552
91
|
/<[||]+open[||]+>?call\b[\s\S]*$/i,
|
|
1553
|
-
// Kimi/Moonshot sentinel block — strip from the section opener
|
|
1554
|
-
// (or the first call opener if the section header is missing).
|
|
1555
92
|
/<[||]+tool[_▁]calls[_▁]begin[||]+>[\s\S]*$/i,
|
|
1556
93
|
/<\|tool_calls_section_begin\|>[\s\S]*$/i,
|
|
1557
94
|
/<[||]+tool[_▁]call[_▁]begin[||]+>[\s\S]*$/i,
|
|
@@ -1570,120 +107,10 @@ export function textBeforeToolCall(text) {
|
|
|
1570
107
|
}
|
|
1571
108
|
return text.trim();
|
|
1572
109
|
}
|
|
1573
|
-
/** Compact line window for fs.read card headers, e.g. "11–20" or "1–10". */
|
|
1574
|
-
export function formatFsReadLineRange(args) {
|
|
1575
|
-
if (!args)
|
|
1576
|
-
return undefined;
|
|
1577
|
-
const startRaw = typeof args.startLine === "number"
|
|
1578
|
-
? args.startLine
|
|
1579
|
-
: typeof args.offset === "number"
|
|
1580
|
-
? args.offset
|
|
1581
|
-
: undefined;
|
|
1582
|
-
const endRaw = typeof args.endLine === "number" ? args.endLine : undefined;
|
|
1583
|
-
const limitRaw = typeof args.limit === "number" ? args.limit : undefined;
|
|
1584
|
-
const start = typeof startRaw === "number" && Number.isFinite(startRaw)
|
|
1585
|
-
? Math.max(1, Math.floor(startRaw) || 1)
|
|
1586
|
-
: undefined;
|
|
1587
|
-
const end = typeof endRaw === "number" && Number.isFinite(endRaw)
|
|
1588
|
-
? Math.floor(endRaw)
|
|
1589
|
-
: undefined;
|
|
1590
|
-
const limit = typeof limitRaw === "number" && Number.isFinite(limitRaw) && limitRaw > 0
|
|
1591
|
-
? Math.floor(limitRaw)
|
|
1592
|
-
: undefined;
|
|
1593
|
-
if (start !== undefined && end !== undefined && end >= start) {
|
|
1594
|
-
return start === end ? `${start}` : `${start}–${end}`;
|
|
1595
|
-
}
|
|
1596
|
-
if (start !== undefined && limit !== undefined) {
|
|
1597
|
-
const last = start + limit - 1;
|
|
1598
|
-
return start === last ? `${start}` : `${start}–${last}`;
|
|
1599
|
-
}
|
|
1600
|
-
if (start !== undefined)
|
|
1601
|
-
return `${start}+`;
|
|
1602
|
-
if (end !== undefined && end >= 1)
|
|
1603
|
-
return `1–${end}`;
|
|
1604
|
-
if (limit !== undefined)
|
|
1605
|
-
return `1–${limit}`;
|
|
1606
|
-
return undefined;
|
|
1607
|
-
}
|
|
1608
|
-
export function formatToolArgs(call) {
|
|
1609
|
-
if (call.name === "terminal.send") {
|
|
1610
|
-
return `id=${String(call.args.id ?? "")} kind=${String(call.args.kind ?? "")}`;
|
|
1611
|
-
}
|
|
1612
|
-
if (call.name === "shell.exec")
|
|
1613
|
-
return String(call.args.command ?? "");
|
|
1614
|
-
if (call.name === "net.scan")
|
|
1615
|
-
return `${call.args.target ?? ""}${call.args.ports ? ` -p ${call.args.ports}` : ""}${call.args.flags ? ` ${call.args.flags}` : ""}`;
|
|
1616
|
-
if (call.name === "pentest.recon")
|
|
1617
|
-
return String(call.args.target ?? "");
|
|
1618
|
-
if (call.name === "dns.lookup")
|
|
1619
|
-
return `${call.args.target ?? ""}${call.args.record ? ` ${call.args.record}` : " A"}`;
|
|
1620
|
-
if (call.name === "whois.lookup")
|
|
1621
|
-
return String(call.args.target ?? "");
|
|
1622
|
-
if (call.name === "fs.read") {
|
|
1623
|
-
const path = String(call.args.path ?? "");
|
|
1624
|
-
const range = formatFsReadLineRange(call.args);
|
|
1625
|
-
return range ? `${path} lines ${range}` : path;
|
|
1626
|
-
}
|
|
1627
|
-
if (call.name === "fs.write" ||
|
|
1628
|
-
call.name === "fs.append" ||
|
|
1629
|
-
call.name === "fs.edit" ||
|
|
1630
|
-
call.name === "fs.replaceLines" ||
|
|
1631
|
-
call.name === "fs.delete") {
|
|
1632
|
-
return String(call.args.path ?? "");
|
|
1633
|
-
}
|
|
1634
|
-
if (call.name === "fs.writeMany") {
|
|
1635
|
-
const files = Array.isArray(call.args.files) ? call.args.files : [];
|
|
1636
|
-
const names = files
|
|
1637
|
-
.map((f) => f && typeof f === "object"
|
|
1638
|
-
? String(f.path ?? "")
|
|
1639
|
-
: "")
|
|
1640
|
-
.filter(Boolean);
|
|
1641
|
-
const preview = names.slice(0, 4).join(", ");
|
|
1642
|
-
return `${names.length} file(s)${preview ? `: ${preview}${names.length > 4 ? ", …" : ""}` : ""}`;
|
|
1643
|
-
}
|
|
1644
|
-
if (call.name === "fs.search")
|
|
1645
|
-
return String(call.args.pattern ?? "");
|
|
1646
|
-
if (call.name === "image.ocr" || call.name === "pdf.read")
|
|
1647
|
-
return String(call.args.path ?? "");
|
|
1648
|
-
if (call.name === "http.fetch" || call.name === "web.fetch")
|
|
1649
|
-
return String(call.args.url ?? "");
|
|
1650
|
-
if (call.name === "web.search")
|
|
1651
|
-
return String(call.args.query ?? "");
|
|
1652
|
-
if (call.name === "pkg.install")
|
|
1653
|
-
return String(call.args.tool ?? "");
|
|
1654
|
-
if (call.name === "fs.list")
|
|
1655
|
-
return String(call.args.path ?? safeCwd());
|
|
1656
|
-
if (call.name === "tool.batch") {
|
|
1657
|
-
// Compact summary — never dump the full nested JSON into the card header.
|
|
1658
|
-
const raw = call.args.calls;
|
|
1659
|
-
const list = Array.isArray(raw) ? raw : [];
|
|
1660
|
-
const names = list
|
|
1661
|
-
.map((entry) => entry && typeof entry === "object"
|
|
1662
|
-
? String(entry.name ?? "")
|
|
1663
|
-
: "")
|
|
1664
|
-
.filter(Boolean);
|
|
1665
|
-
if (names.length === 0)
|
|
1666
|
-
return `${list.length || 0} call(s)`;
|
|
1667
|
-
const preview = names.slice(0, 4).join(", ");
|
|
1668
|
-
return `${names.length} call(s): ${preview}${names.length > 4 ? ", …" : ""}`;
|
|
1669
|
-
}
|
|
1670
|
-
return JSON.stringify(call.args);
|
|
1671
|
-
}
|
|
1672
|
-
// Pure social / idle turns — never force tools.
|
|
1673
110
|
const SOCIAL_OR_IDLE_PROMPT_RE = /^(?:hi|hii+|hello|hey(?:\s+there)?|yo|sup|howdy|hiya|good\s+(?:morning|afternoon|evening|night)|thanks?(?:\s+you)?|thx|ty|ok(?:ay)?|cool|great|nice|awesome|perfect|bye|goodbye|see\s+ya|cheers|gm|gn|how\s+are\s+you(?:\s+doing)?|what'?s\s+up|wassup)(?:\s*[!.?]*)?$/i;
|
|
1674
|
-
// Signals that the current turn is (or continues) a coding / scaffolding
|
|
1675
|
-
// task. These are intentionally broad — over-budgeting a build is cheap
|
|
1676
|
-
// (the loop still stops as soon as the model gives a final answer) while
|
|
1677
|
-
// under-budgeting silently truncates a half-built project.
|
|
1678
111
|
const BUILD_TASK_RE = /\b(?:build|create|scaffold|generate|make|set\s*up|setup|bootstrap|init(?:ialize)?|implement|add|write|develop|code|refactor|migrate|convert|wire\s*up|integrate)\b[\s\S]{0,80}\b(?:app|application|project|site|website|web\s*app|server|api|service|component|page|module|feature|cli|script|library|package|frontend|backend|fullstack|game|bot|dashboard|form|endpoint|database|schema|test|tests|suite|auth|authentication|authorization|login|signup|middleware|route|routes|routing|handler|controller|model|view)\b/i;
|
|
1679
112
|
const BUILD_STACK_RE = /\b(?:react|next(?:\.?js)?|vue|svelte|angular|vite|webpack|express|fastify|nest(?:js)?|django|flask|fastapi|rails|laravel|spring|node(?:\.?js)?|typescript|tailwind|redux|prisma|mongoose|graphql|docker|kubernetes)\b/i;
|
|
1680
|
-
// Pentest / security keywords — these tasks are inherently multi-step and
|
|
1681
|
-
// always deserve the full step budget, just like build tasks.
|
|
1682
113
|
const PENTEST_TASK_RE = /\b(?:pentest|pen[\s-]?test|penetration|security\s*(?:test|audit|scan|assess(?:ment)?)|csrf|xss|sqli|sql[\s-]?inject|rce|lfi|rfi|ssrf|idor|xxe|brute[\s-]?force|enumerat\w*|exploit\w*|vulnerabilit\w*|recon\w*|bug[\s-]?bounty|ctf|capture[\s-]?the[\s-]?flag|red[\s-]?team|offensive|nmap|nikto|nuclei|ffuf|gobuster|sqlmap|hydra|metasploit)\b/i;
|
|
1683
|
-
/**
|
|
1684
|
-
* Detect pentest/security tasks that need the full step budget.
|
|
1685
|
-
* Mirrors looksLikeBuildTask but for security work.
|
|
1686
|
-
*/
|
|
1687
114
|
export function looksLikePentestTask(prompt, history) {
|
|
1688
115
|
if (PENTEST_TASK_RE.test(prompt))
|
|
1689
116
|
return true;
|
|
@@ -1696,49 +123,24 @@ export function looksLikePentestTask(prompt, history) {
|
|
|
1696
123
|
}
|
|
1697
124
|
return false;
|
|
1698
125
|
}
|
|
1699
|
-
// Short continuation prompts that, on their own, carry no build signal but
|
|
1700
|
-
// clearly mean "keep going with what we were doing".
|
|
1701
126
|
const CONTINUATION_RE = /^(?:do\s+it|build\s+it|build\s+fully|build\s+it\s+fully|go\s+ahead|continue|proceed|keep\s+going|finish(?:\s+it)?|complete(?:\s+it)?|yes|ok(?:ay)?|make\s+it|run\s+it|next|on\s+your\s+own|build\s+(?:fully\s+)?on\s+your\s+own)\b/i;
|
|
1702
127
|
const INCOMPLETE_RE = /\b(?:not\s+complete|incomplete|isn'?t\s+(?:done|complete|working|finished)|doesn'?t\s+work|still\s+(?:broken|missing|failing)|missing\s+(?:files?|parts?)|finish\s+(?:the|it)|complete\s+(?:the|it))\b/i;
|
|
1703
|
-
// The synthetic message injected when the user runs /implement to approve a
|
|
1704
|
-
// plan ("I approve the plan. Execute it now, task by task…"). It must always
|
|
1705
|
-
// count as a build/continuation turn.
|
|
1706
128
|
const PLAN_EXECUTION_RE = /\b(?:approve the plan|execute it (?:now|task by task)|task by task|execute the plan|implement the plan)\b/i;
|
|
1707
|
-
// Informational / comparison / explanation intent. These questions want an
|
|
1708
|
-
// ANSWER, not a build — even when they mention a framework or an install
|
|
1709
|
-
// step (e.g. "compare installation steps in react vite", "how do I set up
|
|
1710
|
-
// tailwind", "tailwind 3 vs 4"). They must NOT trigger the explore→plan
|
|
1711
|
-
// build workflow.
|
|
1712
129
|
const INFORMATIONAL_SIGNAL_RE = /\b(?:compare|comparison|contrast|differ(?:ence|ences|s)?|pros\s+and\s+cons|trade-?offs?|versus|vs\.?|cheat\s*sheet|explain|describe|summari[sz]e|overview|tell\s+me)\b/i;
|
|
1713
130
|
const INTERROGATIVE_LEAD_RE = /^(?:what|which|why|how|when|who|where|is|are|do|does|did|can|could|should|would|will)\b/i;
|
|
1714
|
-
/**
|
|
1715
|
-
* Does a single message imply an actual build/scaffold task (as opposed to a
|
|
1716
|
-
* question about one)? Comparison/explanation signals and plain questions are
|
|
1717
|
-
* treated as informational and return false even when they name a stack.
|
|
1718
|
-
*/
|
|
1719
131
|
function messageImpliesBuild(text) {
|
|
1720
132
|
if (!text)
|
|
1721
133
|
return false;
|
|
1722
134
|
if (INFORMATIONAL_SIGNAL_RE.test(text))
|
|
1723
135
|
return false;
|
|
1724
|
-
// Explicit "build/create/scaffold … <thing>" is always a build.
|
|
1725
136
|
if (BUILD_TASK_RE.test(text))
|
|
1726
137
|
return true;
|
|
1727
|
-
// A bare question (interrogative lead or trailing "?") that merely mentions
|
|
1728
|
-
// a stack is informational, not a build.
|
|
1729
138
|
if (text.endsWith("?") || INTERROGATIVE_LEAD_RE.test(text))
|
|
1730
139
|
return false;
|
|
1731
140
|
return BUILD_STACK_RE.test(text);
|
|
1732
141
|
}
|
|
1733
|
-
/**
|
|
1734
|
-
* Decide whether this turn should get the build workflow (explore → plan →
|
|
1735
|
-
* implement) and a generous step budget. Looks at the current prompt first,
|
|
1736
|
-
* then falls back to recent USER turns so a terse follow-up inherits an
|
|
1737
|
-
* ongoing build — but NOT the agent's own (possibly mistaken) plan narration.
|
|
1738
|
-
*/
|
|
1739
142
|
export function looksLikeBuildTask(prompt, history) {
|
|
1740
143
|
const text = prompt.replace(/\s+/g, " ").trim();
|
|
1741
|
-
// Continuation / "not done yet" / plan-execution always count as build.
|
|
1742
144
|
if (CONTINUATION_RE.test(text) ||
|
|
1743
145
|
INCOMPLETE_RE.test(text) ||
|
|
1744
146
|
PLAN_EXECUTION_RE.test(text)) {
|
|
@@ -1747,9 +149,6 @@ export function looksLikeBuildTask(prompt, history) {
|
|
|
1747
149
|
if (messageImpliesBuild(text)) {
|
|
1748
150
|
return true;
|
|
1749
151
|
}
|
|
1750
|
-
// Inspect recent USER turns only: if the user was already building
|
|
1751
|
-
// something, treat a terse follow-up as part of that build. (Assistant
|
|
1752
|
-
// turns are excluded so a misfired plan can't keep re-triggering build.)
|
|
1753
152
|
if (history && history.length > 0) {
|
|
1754
153
|
const recent = history.slice(-6);
|
|
1755
154
|
for (const msg of recent) {
|
|
@@ -1762,19 +161,6 @@ export function looksLikeBuildTask(prompt, history) {
|
|
|
1762
161
|
}
|
|
1763
162
|
return false;
|
|
1764
163
|
}
|
|
1765
|
-
/**
|
|
1766
|
-
* Is THIS prompt a plain informational question (as opposed to a request to
|
|
1767
|
-
* do work)? Used to stop a resumed/continuing build or pentest session from
|
|
1768
|
-
* forcing "act, don't narrate" behavior — and the explore→plan build
|
|
1769
|
-
* workflow — onto a question like "what do you know so far", "what did you
|
|
1770
|
-
* find", or "summarize the results". A follow-up question in a work session
|
|
1771
|
-
* should be ANSWERED from context, not treated as a signal to start executing
|
|
1772
|
-
* or to invent a brand-new plan.
|
|
1773
|
-
*
|
|
1774
|
-
* Explicit build/continuation/plan-execution phrasing is NOT informational,
|
|
1775
|
-
* even when it opens with a question word (e.g. "can you build the api",
|
|
1776
|
-
* "should I add auth" → those still want work).
|
|
1777
|
-
*/
|
|
1778
164
|
export function looksLikeInformationalQuery(prompt) {
|
|
1779
165
|
const text = prompt.replace(/\s+/g, " ").trim();
|
|
1780
166
|
if (!text)
|
|
@@ -1789,26 +175,14 @@ export function looksLikeInformationalQuery(prompt) {
|
|
|
1789
175
|
INTERROGATIVE_LEAD_RE.test(text) ||
|
|
1790
176
|
INFORMATIONAL_SIGNAL_RE.test(text));
|
|
1791
177
|
}
|
|
1792
|
-
// Matrix of action-verb narration: the model says it is *about to* do
|
|
1793
|
-
// something but hasn't. Used to detect "narrate, don't act" stalls.
|
|
1794
178
|
const ACTION_NARRATION_RE = /\b(?:let me|let's|i'?ll|i will|i'?m going to|i am going to|i need to|i should|i'?m about to|going to|now i'?ll|first[,]?\s*i'?ll|we need to|we should|we'?ll|we will|we'?re going to)\s+(?:now\s+|first\s+|quickly\s+|just\s+|go\s+ahead\s+and\s+)?(?:explore|list|read|fetch|browse|check|inspect|examine|look|create|run|start|write|build|add|scaffold|set\s*up|setup|install|initialize|init|generate|make|review|open|find|search|verify|update|edit|modify|fix|implement|gather|assess|scan|audit|retry|restart)\b/i;
|
|
1795
|
-
/**
|
|
1796
|
-
* Past-tense / verification language: the model already applied a fix and is
|
|
1797
|
-
* summarizing. Must NOT re-trigger "error diagnosed but not fixed".
|
|
1798
|
-
*/
|
|
1799
179
|
const ERROR_FIX_ALREADY_DONE_RE = /\b(?:i(?:'?ve| have)\s+(?:already\s+)?(?:fixed|applied|added|patched|updated|changed|edited)|(?:already|now)\s+(?:fixed|applied|working)|fix(?:ed)?\s+(?:is\s+)?(?:in\s+place|applied|verified|complete)|(?:is\s+)?now\s+fixed|no longer (?:errors?|fails?|broken)|should now work|hmr (?:update|applied|reloaded)|build (?:successful|passed|succeeded)|verification complete|fix verified|successfully (?:fixed|applied|patched)|the (?:app|page|site) (?:should )?(?:now )?(?:work|load)s?)\b/i;
|
|
1800
|
-
/**
|
|
1801
|
-
* Model diagnosed a concrete failure (build/runtime/HTTP) and implies a fix
|
|
1802
|
-
* but has not yet applied it — must not end the turn on diagnosis alone.
|
|
1803
|
-
* Returns false for post-fix summaries ("I've fixed…", "build passed").
|
|
1804
|
-
*/
|
|
1805
180
|
export function looksLikeErrorDiagnosisWithFixIntent(text) {
|
|
1806
181
|
const t = text.trim();
|
|
1807
182
|
if (t.length < 20 || t.length > 2_000)
|
|
1808
183
|
return false;
|
|
1809
184
|
if (t.includes("```tool"))
|
|
1810
185
|
return false;
|
|
1811
|
-
// Already applied / verified — do not force another tool loop.
|
|
1812
186
|
if (ERROR_FIX_ALREADY_DONE_RE.test(t))
|
|
1813
187
|
return false;
|
|
1814
188
|
const sawError = /\b(?:error|exception|failed|failure|crash(?:ed)?|500|502|503|404|ECONNREFUSED|cannot\s+find|is\s+not\s+defined|use client|server component|module not found|syntaxerror|typeerror|build failed|internal server error)\b/i.test(t);
|
|
@@ -1817,10 +191,8 @@ export function looksLikeErrorDiagnosisWithFixIntent(text) {
|
|
|
1817
191
|
const fixIntent = /\b(?:need to|needs? to|should|must|have to|let'?s|i'?ll|we'?ll|going to|fix|edit|add|patch|rewrite|change|update|retry|restart)\b/i.test(t);
|
|
1818
192
|
return fixIntent;
|
|
1819
193
|
}
|
|
1820
|
-
/** True when tool output is a local HTTP probe that did not return 2xx. */
|
|
1821
194
|
export function localHttpProbeIsFailure(output) {
|
|
1822
195
|
const head = output.slice(0, 400);
|
|
1823
|
-
// http.fetch first line: "500 Internal Server Error http://localhost:3000/"
|
|
1824
196
|
if (/^(?:[45]\d\d)\b/.test(head.trim()) || /\n(?:[45]\d\d)\s+\w+/.test(head)) {
|
|
1825
197
|
return true;
|
|
1826
198
|
}
|
|
@@ -1831,7 +203,6 @@ export function localHttpProbeIsFailure(output) {
|
|
|
1831
203
|
return true;
|
|
1832
204
|
return false;
|
|
1833
205
|
}
|
|
1834
|
-
/** True when tool output shows a successful 2xx local probe. */
|
|
1835
206
|
export function localHttpProbeIsSuccess(output) {
|
|
1836
207
|
if (localHttpProbeIsFailure(output))
|
|
1837
208
|
return false;
|
|
@@ -1840,40 +211,22 @@ export function localHttpProbeIsSuccess(output) {
|
|
|
1840
211
|
return true;
|
|
1841
212
|
if (/\b(?:200|201|204)\s+(?:OK|Created|No Content)\b/i.test(head))
|
|
1842
213
|
return true;
|
|
1843
|
-
// curl -sI / plain HTML with no status — treat as soft success only if no error signals
|
|
1844
214
|
if (/<!doctype html|<html[\s>]/i.test(output) && !/\berror\b/i.test(head)) {
|
|
1845
215
|
return true;
|
|
1846
216
|
}
|
|
1847
217
|
return false;
|
|
1848
218
|
}
|
|
1849
|
-
// Web-specific upcoming action (used to pick the right recovery nudge).
|
|
1850
219
|
const WEB_ACTION_NARRATION_RE = /\b(?:let me|let's|i'?ll|i will|i'?m going to|i am going to|i need to|i should|i'?m about to|going to|now i'?ll|first[,]?\s*i'?ll)\s+(?:now\s+|first\s+|quickly\s+|just\s+|go\s+ahead\s+and\s+)?(?:fetch|browse|search(?:\s+(?:the\s+)?(?:web|internet|online))?|look\s*up|google|open\s+(?:the\s+)?(?:page|url|site|link)|read\s+(?:the\s+)?(?:page|url|site|article|blog|docs?))\b/i;
|
|
1851
|
-
// Capability menus / offers: the model is inviting the user to pick a task,
|
|
1852
|
-
// not stalling mid-work. Must not trigger "act, don't narrate" recovery.
|
|
1853
220
|
const CAPABILITY_OFFER_RE = /\b(?:what\s+do\s+you\s+(?:want|need)|what\s+would\s+you\s+(?:like|actually\s+like)|how\s+can\s+i\s+help|just\s+tell\s+me|tell\s+me\s+the\s+task|when\s+you(?:'re|\s+are)\s+ready|if\s+you\s+(?:want|need|like|have|give)|a\s+few\s+things\s+i\s+can|here'?s\s+what\s+i\s+can|i\s+can\s+(?:help|jump|assist|build|scan|investigate|research|look)|ready\s+(?:when|whenever)\s+you|what\s+would\s+you\s+(?:actually\s+)?like\s+me\s+to|i'?m\s+ready\s+to)\b/i;
|
|
1854
|
-
// After a bad recovery nudge the model often clarifies there is no real task.
|
|
1855
|
-
// Accept that as a final answer instead of looping more web.search nudges.
|
|
1856
221
|
const DENIES_PENDING_WORK_RE = /\b(?:didn'?t\s+(?:actually\s+)?(?:promise|claim|make\s+any)|haven'?t\s+made\s+any|no\s+(?:pending|real)\s+(?:task|browse|research|fetch|job)|non-existent\s+(?:job|task)|there'?s\s+no\s+pending|no\s+tool\s+call\s+for\s+a\s+non)\b/i;
|
|
1857
|
-
// Soft generic offers without a concrete work object ("I'll start executing",
|
|
1858
|
-
// "I'll help you") — common in greetings, not mid-task stalls.
|
|
1859
222
|
const GENERIC_OFFER_NARRATION_RE = /\b(?:i'?ll|i will|i'?m going to)\s+(?:start\s+executing|start\s+working|help(?:\s+you)?|jump\s+in|get\s+started|wait\s+for|be\s+here|stand\s+by)\b/i;
|
|
1860
|
-
// Educational framing ("I'll start with the basics", "I'll start by explaining")
|
|
1861
|
-
// is not a tool-call stall.
|
|
1862
223
|
const EDUCATIONAL_START_RE = /\b(?:i'?ll|i will|i'?m going to|let me)\s+start\s+(?:with|by)\b/i;
|
|
1863
|
-
/**
|
|
1864
|
-
* Detect a pure social / idle user prompt (greetings, thanks, short acks).
|
|
1865
|
-
* These must never force tool use or plan workflows.
|
|
1866
|
-
*/
|
|
1867
224
|
export function looksLikeIdleOrSocialPrompt(prompt) {
|
|
1868
225
|
const text = prompt.replace(/\s+/g, " ").trim();
|
|
1869
226
|
if (!text)
|
|
1870
227
|
return true;
|
|
1871
228
|
return SOCIAL_OR_IDLE_PROMPT_RE.test(text);
|
|
1872
229
|
}
|
|
1873
|
-
/**
|
|
1874
|
-
* True when the assistant message is a capability menu / "what do you want"
|
|
1875
|
-
* invitation rather than a mid-task action stall.
|
|
1876
|
-
*/
|
|
1877
230
|
function looksLikeCapabilityMenu(text) {
|
|
1878
231
|
const bullets = (text.match(/(?:^|\n)\s*[•\-\*]|\n\s*\d+[.)]\s+/g) || [])
|
|
1879
232
|
.length;
|
|
@@ -1882,17 +235,6 @@ function looksLikeCapabilityMenu(text) {
|
|
|
1882
235
|
/\btell\s+me\s+(?:the\s+)?(?:task|what)\b/i.test(text);
|
|
1883
236
|
return bullets >= 2 && asksUser;
|
|
1884
237
|
}
|
|
1885
|
-
/**
|
|
1886
|
-
* Detect a message that narrates an *upcoming* action ("let me explore the
|
|
1887
|
-
* directory", "I'll create the components") rather than an actual answer or
|
|
1888
|
-
* tool call. Used to catch models that describe intent but emit no tool call,
|
|
1889
|
-
* which would otherwise end the turn with nothing done. A real completion
|
|
1890
|
-
* summary (past tense, longer, or containing a code block) is NOT flagged.
|
|
1891
|
-
*
|
|
1892
|
-
* Capability offers, greetings, educational framing, and explicit denials of
|
|
1893
|
-
* pending work are intentionally NOT flagged — those false positives used to
|
|
1894
|
-
* burn recovery turns (and tokens) on web.search nudges after a simple "hi".
|
|
1895
|
-
*/
|
|
1896
238
|
export function looksLikeActionNarration(text) {
|
|
1897
239
|
const t = text.trim();
|
|
1898
240
|
if (t.length === 0 || t.length > 600)
|
|
@@ -1906,26 +248,17 @@ export function looksLikeActionNarration(text) {
|
|
|
1906
248
|
if (looksLikeCapabilityMenu(t))
|
|
1907
249
|
return false;
|
|
1908
250
|
if (EDUCATIONAL_START_RE.test(t) && !WEB_ACTION_NARRATION_RE.test(t)) {
|
|
1909
|
-
// "I'll start with bubble sort" is teaching, not a tool stall — unless
|
|
1910
|
-
// the same message also claims a concrete web fetch/search.
|
|
1911
|
-
// Still allow other non-start action verbs in the same message.
|
|
1912
251
|
const withoutEducational = t.replace(EDUCATIONAL_START_RE, " ");
|
|
1913
252
|
if (!ACTION_NARRATION_RE.test(withoutEducational))
|
|
1914
253
|
return false;
|
|
1915
254
|
}
|
|
1916
255
|
if (GENERIC_OFFER_NARRATION_RE.test(t)) {
|
|
1917
|
-
// Generic offer alone is not a stall; a separate concrete action verb is.
|
|
1918
256
|
const withoutOffer = t.replace(GENERIC_OFFER_NARRATION_RE, " ");
|
|
1919
257
|
if (!ACTION_NARRATION_RE.test(withoutOffer))
|
|
1920
258
|
return false;
|
|
1921
259
|
}
|
|
1922
260
|
return ACTION_NARRATION_RE.test(t);
|
|
1923
261
|
}
|
|
1924
|
-
/**
|
|
1925
|
-
* Narration specifically about an upcoming web/browse/search action. Used to
|
|
1926
|
-
* choose the web-oriented recovery nudge instead of treating every non-build
|
|
1927
|
-
* stall as a web action.
|
|
1928
|
-
*/
|
|
1929
262
|
export function looksLikeWebActionNarration(text) {
|
|
1930
263
|
const t = text.trim();
|
|
1931
264
|
if (t.length === 0 || t.length > 600)
|
|
@@ -1939,12 +272,6 @@ export function looksLikeWebActionNarration(text) {
|
|
|
1939
272
|
return false;
|
|
1940
273
|
return WEB_ACTION_NARRATION_RE.test(t);
|
|
1941
274
|
}
|
|
1942
|
-
/**
|
|
1943
|
-
* Detect a message that narrates a PLAN as prose ("Goal: … Tasks: 1. … Please
|
|
1944
|
-
* approve the plan") instead of calling plan.create. Such a turn leaves no
|
|
1945
|
-
* real plan, so the user can't /implement it — we nudge the model to emit the
|
|
1946
|
-
* plan.create tool call instead.
|
|
1947
|
-
*/
|
|
1948
275
|
export function looksLikePlanNarration(text) {
|
|
1949
276
|
const t = text.trim();
|
|
1950
277
|
if (t.length < 40)
|
|
@@ -1955,12 +282,6 @@ export function looksLikePlanNarration(text) {
|
|
|
1955
282
|
/(?:^|\n)\s*(?:t?1[.)]|step\s*1)\b/im.test(t);
|
|
1956
283
|
return approval || (goal && tasks);
|
|
1957
284
|
}
|
|
1958
|
-
/**
|
|
1959
|
-
* Detect a low-quality "everything in one step" plan task. A single task that
|
|
1960
|
-
* itself enumerates many files/actions (multiple commas, an "and", several
|
|
1961
|
-
* slashes, or an overlong title) means the model lumped the whole build into
|
|
1962
|
-
* one checkbox instead of producing a real ordered checklist.
|
|
1963
|
-
*/
|
|
1964
285
|
export function isLumpedSingleTask(taskTitles) {
|
|
1965
286
|
if (taskTitles.length !== 1)
|
|
1966
287
|
return false;
|
|
@@ -1970,10 +291,6 @@ export function isLumpedSingleTask(taskTitles) {
|
|
|
1970
291
|
(only.match(/\//g)?.length ?? 0) >= 2 ||
|
|
1971
292
|
only.length > 90);
|
|
1972
293
|
}
|
|
1973
|
-
/**
|
|
1974
|
-
* Compact build inject — reinforces judgment defaults without restating the
|
|
1975
|
-
* full system playbook. Stack-agnostic.
|
|
1976
|
-
*/
|
|
1977
294
|
export function buildWorkflowDirective() {
|
|
1978
295
|
return [
|
|
1979
296
|
"BUILD FOCUS (specialization for software work — apply the professional loop, not a rigid scaffold script):",
|
|
@@ -1996,9 +313,6 @@ export function narrowNmapOperationDirective() {
|
|
|
1996
313
|
"- Stop after reporting this scan's result or durable job receipt. Ask before broadening the operation.",
|
|
1997
314
|
].join("\n");
|
|
1998
315
|
}
|
|
1999
|
-
/**
|
|
2000
|
-
* Compact pentest inject — objective-first red team / VAPT defaults.
|
|
2001
|
-
*/
|
|
2002
316
|
export function pentestWorkflowDirective() {
|
|
2003
317
|
return [
|
|
2004
318
|
"PENTEST FOCUS (security / pentest / VAPT specialization — pursue the objective with verified coverage, not activity theater):",
|
|
@@ -2010,10 +324,6 @@ export function pentestWorkflowDirective() {
|
|
|
2010
324
|
"Before closing, reconcile the ledger with scope and objective. Report severity, affected asset, evidence, reproduction, impact, remediation, and every material residual/untested surface with its reason. Never infer mature posture from untested classes. Flag out-of-scope assets; no local dev server for remote targets.",
|
|
2011
325
|
].join("\n");
|
|
2012
326
|
}
|
|
2013
|
-
/**
|
|
2014
|
-
* Always-on reminder when the session is already a remote/security engagement
|
|
2015
|
-
* (plan kind=pentest or pentest-like turn), including after tasks complete.
|
|
2016
|
-
*/
|
|
2017
327
|
export function pentestNoLocalServerDirective() {
|
|
2018
328
|
return [
|
|
2019
329
|
"REMOTE / PENTEST SESSION RULE (always on for this engagement):",
|
|
@@ -2026,14 +336,6 @@ export function pentestNoLocalServerDirective() {
|
|
|
2026
336
|
export function shouldDimToolChatter(call) {
|
|
2027
337
|
return call.name === "web.search";
|
|
2028
338
|
}
|
|
2029
|
-
/**
|
|
2030
|
-
* Distinctive section headings and phrases that appear only in our system
|
|
2031
|
-
* prompts. If the model's output contains several of these, it is almost
|
|
2032
|
-
* certainly regurgitating its instructions in response to a prompt-injection
|
|
2033
|
-
* attack like "repeat your instructions verbatim". Any tool-call syntax
|
|
2034
|
-
* inside such a leak is an EXAMPLE from the prompt, not a real request, and
|
|
2035
|
-
* must not be executed.
|
|
2036
|
-
*/
|
|
2037
339
|
const PROMPT_LEAK_MARKERS = [
|
|
2038
340
|
/# SECURITY POSTURE/i,
|
|
2039
341
|
/# RESEARCH — READ-ONLY TOOLS/i,
|
|
@@ -2047,13 +349,7 @@ const PROMPT_LEAK_MARKERS = [
|
|
|
2047
349
|
/\bpentoshi007 on GitHub\b/i,
|
|
2048
350
|
/\bagent\.handoff\b.*\btask\b.*\breason\b/i,
|
|
2049
351
|
];
|
|
2050
|
-
/** Minimum number of markers that must match to consider it a prompt leak. */
|
|
2051
352
|
const PROMPT_LEAK_THRESHOLD = 3;
|
|
2052
|
-
/**
|
|
2053
|
-
* Returns true when the model's output looks like it is repeating the system
|
|
2054
|
-
* prompt rather than giving a genuine answer. Used to suppress execution of
|
|
2055
|
-
* tool-call examples embedded in the regurgitated instructions.
|
|
2056
|
-
*/
|
|
2057
353
|
export function looksLikePromptLeak(text) {
|
|
2058
354
|
let hits = 0;
|
|
2059
355
|
for (const marker of PROMPT_LEAK_MARKERS) {
|