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