@nodetool-ai/cli 0.7.0-rc.23 → 0.8.2

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 (535) hide show
  1. package/README.md +82 -0
  2. package/dist/.nodetool-build-stamp +1 -0
  3. package/dist/ExecutionTree.d.ts +2 -1
  4. package/dist/ExecutionTree.d.ts.map +1 -1
  5. package/dist/ExecutionTree.js +1 -1
  6. package/dist/ExecutionTree.js.map +1 -1
  7. package/dist/affected/affected.d.ts +45 -0
  8. package/dist/affected/affected.d.ts.map +1 -0
  9. package/dist/affected/affected.js +160 -0
  10. package/dist/affected/affected.js.map +1 -0
  11. package/dist/agent-toolbelt.d.ts +15 -0
  12. package/dist/agent-toolbelt.d.ts.map +1 -0
  13. package/dist/agent-toolbelt.js +28 -0
  14. package/dist/agent-toolbelt.js.map +1 -0
  15. package/dist/api-client.d.ts +12 -0
  16. package/dist/api-client.d.ts.map +1 -0
  17. package/dist/api-client.js +21 -0
  18. package/dist/api-client.js.map +1 -0
  19. package/dist/app-build/bundle.d.ts +15 -0
  20. package/dist/app-build/bundle.d.ts.map +1 -0
  21. package/dist/app-build/bundle.js +45 -0
  22. package/dist/app-build/bundle.js.map +1 -0
  23. package/dist/app-build/watch.d.ts +13 -0
  24. package/dist/app-build/watch.d.ts.map +1 -0
  25. package/dist/app-build/watch.js +25 -0
  26. package/dist/app-build/watch.js.map +1 -0
  27. package/dist/app-debug/app-target.d.ts +14 -0
  28. package/dist/app-debug/app-target.d.ts.map +1 -0
  29. package/dist/app-debug/app-target.js +120 -0
  30. package/dist/app-debug/app-target.js.map +1 -0
  31. package/dist/app-debug/harness.d.ts +29 -0
  32. package/dist/app-debug/harness.d.ts.map +1 -0
  33. package/dist/app-debug/harness.js +116 -0
  34. package/dist/app-debug/harness.js.map +1 -0
  35. package/dist/app-debug/index.d.ts +12 -0
  36. package/dist/app-debug/index.d.ts.map +1 -0
  37. package/dist/app-debug/index.js +9 -0
  38. package/dist/app-debug/index.js.map +1 -0
  39. package/dist/app.d.ts +38 -48
  40. package/dist/app.d.ts.map +1 -1
  41. package/dist/app.js +980 -677
  42. package/dist/app.js.map +1 -1
  43. package/dist/bash-tool.d.ts +13 -0
  44. package/dist/bash-tool.d.ts.map +1 -0
  45. package/dist/bash-tool.js +85 -0
  46. package/dist/bash-tool.js.map +1 -0
  47. package/dist/chat-codeact.d.ts +93 -0
  48. package/dist/chat-codeact.d.ts.map +1 -0
  49. package/dist/chat-codeact.js +179 -0
  50. package/dist/chat-codeact.js.map +1 -0
  51. package/dist/chat-context.d.ts +18 -0
  52. package/dist/chat-context.d.ts.map +1 -0
  53. package/dist/chat-context.js +32 -0
  54. package/dist/chat-context.js.map +1 -0
  55. package/dist/chat-media.d.ts +3 -0
  56. package/dist/chat-media.d.ts.map +1 -0
  57. package/dist/chat-media.js +46 -0
  58. package/dist/chat-media.js.map +1 -0
  59. package/dist/chat-prompts.d.ts +20 -0
  60. package/dist/chat-prompts.d.ts.map +1 -0
  61. package/dist/chat-prompts.js +42 -0
  62. package/dist/chat-prompts.js.map +1 -0
  63. package/dist/chat-sessions.d.ts +25 -0
  64. package/dist/chat-sessions.d.ts.map +1 -0
  65. package/dist/chat-sessions.js +153 -0
  66. package/dist/chat-sessions.js.map +1 -0
  67. package/dist/command-errors.d.ts +10 -0
  68. package/dist/command-errors.d.ts.map +1 -0
  69. package/dist/command-errors.js +15 -0
  70. package/dist/command-errors.js.map +1 -0
  71. package/dist/commands/__tests__/jtbd.test.d.ts +2 -0
  72. package/dist/commands/__tests__/jtbd.test.d.ts.map +1 -0
  73. package/dist/commands/__tests__/jtbd.test.js +120 -0
  74. package/dist/commands/__tests__/jtbd.test.js.map +1 -0
  75. package/dist/commands/__tests__/timeline-render-audio.test.d.ts +2 -0
  76. package/dist/commands/__tests__/timeline-render-audio.test.d.ts.map +1 -0
  77. package/dist/commands/__tests__/timeline-render-audio.test.js +53 -0
  78. package/dist/commands/__tests__/timeline-render-audio.test.js.map +1 -0
  79. package/dist/commands/__tests__/timeline-render-completeness.test.d.ts +2 -0
  80. package/dist/commands/__tests__/timeline-render-completeness.test.d.ts.map +1 -0
  81. package/dist/commands/__tests__/timeline-render-completeness.test.js +117 -0
  82. package/dist/commands/__tests__/timeline-render-completeness.test.js.map +1 -0
  83. package/dist/commands/__tests__/timeline-render.test.d.ts +2 -0
  84. package/dist/commands/__tests__/timeline-render.test.d.ts.map +1 -0
  85. package/dist/commands/__tests__/timeline-render.test.js +115 -0
  86. package/dist/commands/__tests__/timeline-render.test.js.map +1 -0
  87. package/dist/commands/__tests__/timeline-score.test.d.ts +2 -0
  88. package/dist/commands/__tests__/timeline-score.test.d.ts.map +1 -0
  89. package/dist/commands/__tests__/timeline-score.test.js +100 -0
  90. package/dist/commands/__tests__/timeline-score.test.js.map +1 -0
  91. package/dist/commands/affected.d.ts +9 -0
  92. package/dist/commands/affected.d.ts.map +1 -0
  93. package/dist/commands/affected.js +122 -0
  94. package/dist/commands/affected.js.map +1 -0
  95. package/dist/commands/agent.d.ts +26 -4
  96. package/dist/commands/agent.d.ts.map +1 -1
  97. package/dist/commands/agent.js +328 -306
  98. package/dist/commands/agent.js.map +1 -1
  99. package/dist/commands/app.d.ts +3 -0
  100. package/dist/commands/app.d.ts.map +1 -0
  101. package/dist/commands/app.js +405 -0
  102. package/dist/commands/app.js.map +1 -0
  103. package/dist/commands/apps.d.ts +15 -0
  104. package/dist/commands/apps.d.ts.map +1 -0
  105. package/dist/commands/apps.js +180 -0
  106. package/dist/commands/apps.js.map +1 -0
  107. package/dist/commands/auth.d.ts +12 -0
  108. package/dist/commands/auth.d.ts.map +1 -0
  109. package/dist/commands/auth.js +154 -0
  110. package/dist/commands/auth.js.map +1 -0
  111. package/dist/commands/collections.d.ts +10 -0
  112. package/dist/commands/collections.d.ts.map +1 -0
  113. package/dist/commands/collections.js +257 -0
  114. package/dist/commands/collections.js.map +1 -0
  115. package/dist/commands/costs.d.ts +15 -0
  116. package/dist/commands/costs.d.ts.map +1 -0
  117. package/dist/commands/costs.js +201 -0
  118. package/dist/commands/costs.js.map +1 -0
  119. package/dist/commands/db.d.ts +3 -0
  120. package/dist/commands/db.d.ts.map +1 -0
  121. package/dist/commands/db.js +176 -0
  122. package/dist/commands/db.js.map +1 -0
  123. package/dist/commands/debug-summary-output.d.ts +22 -0
  124. package/dist/commands/debug-summary-output.d.ts.map +1 -0
  125. package/dist/commands/debug-summary-output.js +28 -0
  126. package/dist/commands/debug-summary-output.js.map +1 -0
  127. package/dist/commands/debug.d.ts +13 -0
  128. package/dist/commands/debug.d.ts.map +1 -0
  129. package/dist/commands/debug.js +138 -0
  130. package/dist/commands/debug.js.map +1 -0
  131. package/dist/commands/deploy-helpers.d.ts +49 -18
  132. package/dist/commands/deploy-helpers.d.ts.map +1 -1
  133. package/dist/commands/deploy-helpers.js +10 -276
  134. package/dist/commands/deploy-helpers.js.map +1 -1
  135. package/dist/commands/deploy.d.ts +0 -1
  136. package/dist/commands/deploy.d.ts.map +1 -1
  137. package/dist/commands/deploy.js +21 -217
  138. package/dist/commands/deploy.js.map +1 -1
  139. package/dist/commands/errors.d.ts +11 -0
  140. package/dist/commands/errors.d.ts.map +1 -0
  141. package/dist/commands/errors.js +177 -0
  142. package/dist/commands/errors.js.map +1 -0
  143. package/dist/commands/eval.d.ts +152 -0
  144. package/dist/commands/eval.d.ts.map +1 -0
  145. package/dist/commands/eval.js +690 -0
  146. package/dist/commands/eval.js.map +1 -0
  147. package/dist/commands/extension.d.ts +12 -0
  148. package/dist/commands/extension.d.ts.map +1 -0
  149. package/dist/commands/extension.js +30 -0
  150. package/dist/commands/extension.js.map +1 -0
  151. package/dist/commands/game-benchmark.d.ts +34 -0
  152. package/dist/commands/game-benchmark.d.ts.map +1 -0
  153. package/dist/commands/game-benchmark.js +95 -0
  154. package/dist/commands/game-benchmark.js.map +1 -0
  155. package/dist/commands/game-smoke.d.ts +3 -0
  156. package/dist/commands/game-smoke.d.ts.map +1 -0
  157. package/dist/commands/game-smoke.js +23 -0
  158. package/dist/commands/game-smoke.js.map +1 -0
  159. package/dist/commands/game.d.ts +4 -0
  160. package/dist/commands/game.d.ts.map +1 -0
  161. package/dist/commands/game.js +624 -0
  162. package/dist/commands/game.js.map +1 -0
  163. package/dist/commands/generate.d.ts +17 -0
  164. package/dist/commands/generate.d.ts.map +1 -0
  165. package/dist/commands/generate.js +324 -0
  166. package/dist/commands/generate.js.map +1 -0
  167. package/dist/commands/generations.d.ts +17 -0
  168. package/dist/commands/generations.d.ts.map +1 -0
  169. package/dist/commands/generations.js +408 -0
  170. package/dist/commands/generations.js.map +1 -0
  171. package/dist/commands/harness.d.ts +69 -0
  172. package/dist/commands/harness.d.ts.map +1 -0
  173. package/dist/commands/harness.js +575 -0
  174. package/dist/commands/harness.js.map +1 -0
  175. package/dist/commands/js-script-validation-output.d.ts +7 -0
  176. package/dist/commands/js-script-validation-output.d.ts.map +1 -0
  177. package/dist/commands/js-script-validation-output.js +5 -0
  178. package/dist/commands/js-script-validation-output.js.map +1 -0
  179. package/dist/commands/js-script-versions.d.ts +53 -0
  180. package/dist/commands/js-script-versions.d.ts.map +1 -0
  181. package/dist/commands/js-script-versions.js +89 -0
  182. package/dist/commands/js-script-versions.js.map +1 -0
  183. package/dist/commands/js-script.d.ts +29 -0
  184. package/dist/commands/js-script.d.ts.map +1 -0
  185. package/dist/commands/js-script.js +211 -0
  186. package/dist/commands/js-script.js.map +1 -0
  187. package/dist/commands/jtbd.d.ts +38 -0
  188. package/dist/commands/jtbd.d.ts.map +1 -0
  189. package/dist/commands/jtbd.js +261 -0
  190. package/dist/commands/jtbd.js.map +1 -0
  191. package/dist/commands/local-db.d.ts +16 -0
  192. package/dist/commands/local-db.d.ts.map +1 -0
  193. package/dist/commands/local-db.js +33 -0
  194. package/dist/commands/local-db.js.map +1 -0
  195. package/dist/commands/mcp.d.ts +21 -0
  196. package/dist/commands/mcp.d.ts.map +1 -0
  197. package/dist/commands/mcp.js +164 -0
  198. package/dist/commands/mcp.js.map +1 -0
  199. package/dist/commands/migrate-code-inputs.d.ts +24 -0
  200. package/dist/commands/migrate-code-inputs.d.ts.map +1 -0
  201. package/dist/commands/migrate-code-inputs.js +120 -0
  202. package/dist/commands/migrate-code-inputs.js.map +1 -0
  203. package/dist/commands/models-hf.js +4 -4
  204. package/dist/commands/models-hf.js.map +1 -1
  205. package/dist/commands/models-recommended.d.ts.map +1 -1
  206. package/dist/commands/models-recommended.js +16 -24
  207. package/dist/commands/models-recommended.js.map +1 -1
  208. package/dist/commands/node.d.ts +10 -0
  209. package/dist/commands/node.d.ts.map +1 -0
  210. package/dist/commands/node.js +72 -0
  211. package/dist/commands/node.js.map +1 -0
  212. package/dist/commands/output.d.ts +24 -0
  213. package/dist/commands/output.d.ts.map +1 -0
  214. package/dist/commands/output.js +132 -0
  215. package/dist/commands/output.js.map +1 -0
  216. package/dist/commands/package-helpers.d.ts +1 -7
  217. package/dist/commands/package-helpers.d.ts.map +1 -1
  218. package/dist/commands/package-helpers.js +3 -26
  219. package/dist/commands/package-helpers.js.map +1 -1
  220. package/dist/commands/package.d.ts.map +1 -1
  221. package/dist/commands/package.js +14 -14
  222. package/dist/commands/package.js.map +1 -1
  223. package/dist/commands/packs.d.ts +13 -0
  224. package/dist/commands/packs.d.ts.map +1 -0
  225. package/dist/commands/packs.js +60 -0
  226. package/dist/commands/packs.js.map +1 -0
  227. package/dist/commands/reliability.d.ts +14 -0
  228. package/dist/commands/reliability.d.ts.map +1 -0
  229. package/dist/commands/reliability.js +80 -0
  230. package/dist/commands/reliability.js.map +1 -0
  231. package/dist/commands/resource-read.d.ts +28 -0
  232. package/dist/commands/resource-read.d.ts.map +1 -0
  233. package/dist/commands/resource-read.js +316 -0
  234. package/dist/commands/resource-read.js.map +1 -0
  235. package/dist/commands/runs.d.ts +7 -0
  236. package/dist/commands/runs.d.ts.map +1 -0
  237. package/dist/commands/runs.js +302 -0
  238. package/dist/commands/runs.js.map +1 -0
  239. package/dist/commands/sketch-validation-output.d.ts +7 -0
  240. package/dist/commands/sketch-validation-output.d.ts.map +1 -0
  241. package/dist/commands/sketch-validation-output.js +5 -0
  242. package/dist/commands/sketch-validation-output.js.map +1 -0
  243. package/dist/commands/sketch-versions.d.ts +66 -0
  244. package/dist/commands/sketch-versions.d.ts.map +1 -0
  245. package/dist/commands/sketch-versions.js +108 -0
  246. package/dist/commands/sketch-versions.js.map +1 -0
  247. package/dist/commands/sketch.d.ts +21 -0
  248. package/dist/commands/sketch.d.ts.map +1 -0
  249. package/dist/commands/sketch.js +101 -0
  250. package/dist/commands/sketch.js.map +1 -0
  251. package/dist/commands/storage.d.ts +24 -0
  252. package/dist/commands/storage.d.ts.map +1 -0
  253. package/dist/commands/storage.js +112 -0
  254. package/dist/commands/storage.js.map +1 -0
  255. package/dist/commands/telegram.d.ts +11 -0
  256. package/dist/commands/telegram.d.ts.map +1 -0
  257. package/dist/commands/telegram.js +66 -0
  258. package/dist/commands/telegram.js.map +1 -0
  259. package/dist/commands/timeline-render.d.ts +85 -0
  260. package/dist/commands/timeline-render.d.ts.map +1 -0
  261. package/dist/commands/timeline-render.js +474 -0
  262. package/dist/commands/timeline-render.js.map +1 -0
  263. package/dist/commands/timeline-score.d.ts +16 -0
  264. package/dist/commands/timeline-score.d.ts.map +1 -0
  265. package/dist/commands/timeline-score.js +89 -0
  266. package/dist/commands/timeline-score.js.map +1 -0
  267. package/dist/commands/timeline-validation-output.d.ts +7 -0
  268. package/dist/commands/timeline-validation-output.d.ts.map +1 -0
  269. package/dist/commands/timeline-validation-output.js +9 -0
  270. package/dist/commands/timeline-validation-output.js.map +1 -0
  271. package/dist/commands/timeline-versions.d.ts +72 -0
  272. package/dist/commands/timeline-versions.d.ts.map +1 -0
  273. package/dist/commands/timeline-versions.js +108 -0
  274. package/dist/commands/timeline-versions.js.map +1 -0
  275. package/dist/commands/timeline.d.ts +22 -0
  276. package/dist/commands/timeline.d.ts.map +1 -0
  277. package/dist/commands/timeline.js +105 -0
  278. package/dist/commands/timeline.js.map +1 -0
  279. package/dist/commands/validate.d.ts +22 -0
  280. package/dist/commands/validate.d.ts.map +1 -0
  281. package/dist/commands/validate.js +127 -0
  282. package/dist/commands/validate.js.map +1 -0
  283. package/dist/commands/validation-output.d.ts +25 -0
  284. package/dist/commands/validation-output.d.ts.map +1 -0
  285. package/dist/commands/validation-output.js +29 -0
  286. package/dist/commands/validation-output.js.map +1 -0
  287. package/dist/commands/version-commands.d.ts +94 -0
  288. package/dist/commands/version-commands.d.ts.map +1 -0
  289. package/dist/commands/version-commands.js +227 -0
  290. package/dist/commands/version-commands.js.map +1 -0
  291. package/dist/commands/worker-models.d.ts +13 -0
  292. package/dist/commands/worker-models.d.ts.map +1 -0
  293. package/dist/commands/worker-models.js +207 -0
  294. package/dist/commands/worker-models.js.map +1 -0
  295. package/dist/commands/worker.d.ts +23 -0
  296. package/dist/commands/worker.d.ts.map +1 -0
  297. package/dist/commands/worker.js +374 -0
  298. package/dist/commands/worker.js.map +1 -0
  299. package/dist/debug/browser-runner.d.ts +21 -0
  300. package/dist/debug/browser-runner.d.ts.map +1 -0
  301. package/dist/debug/browser-runner.js +196 -0
  302. package/dist/debug/browser-runner.js.map +1 -0
  303. package/dist/debug/collector.d.ts +9 -0
  304. package/dist/debug/collector.d.ts.map +1 -0
  305. package/dist/debug/collector.js +9 -0
  306. package/dist/debug/collector.js.map +1 -0
  307. package/dist/debug/diff.d.ts +48 -0
  308. package/dist/debug/diff.d.ts.map +1 -0
  309. package/dist/debug/diff.js +68 -0
  310. package/dist/debug/diff.js.map +1 -0
  311. package/dist/debug/harness.d.ts +11 -0
  312. package/dist/debug/harness.d.ts.map +1 -0
  313. package/dist/debug/harness.js +103 -0
  314. package/dist/debug/harness.js.map +1 -0
  315. package/dist/debug/index.d.ts +17 -0
  316. package/dist/debug/index.d.ts.map +1 -0
  317. package/dist/debug/index.js +16 -0
  318. package/dist/debug/index.js.map +1 -0
  319. package/dist/debug/markdown.d.ts +3 -0
  320. package/dist/debug/markdown.d.ts.map +1 -0
  321. package/dist/debug/markdown.js +127 -0
  322. package/dist/debug/markdown.js.map +1 -0
  323. package/dist/debug/server-runner.d.ts +24 -0
  324. package/dist/debug/server-runner.d.ts.map +1 -0
  325. package/dist/debug/server-runner.js +197 -0
  326. package/dist/debug/server-runner.js.map +1 -0
  327. package/dist/debug/target.d.ts +34 -0
  328. package/dist/debug/target.d.ts.map +1 -0
  329. package/dist/debug/target.js +104 -0
  330. package/dist/debug/target.js.map +1 -0
  331. package/dist/debug/trace.d.ts +30 -0
  332. package/dist/debug/trace.d.ts.map +1 -0
  333. package/dist/debug/trace.js +87 -0
  334. package/dist/debug/trace.js.map +1 -0
  335. package/dist/debug/types.d.ts +82 -0
  336. package/dist/debug/types.d.ts.map +1 -0
  337. package/dist/debug/types.js +13 -0
  338. package/dist/debug/types.js.map +1 -0
  339. package/dist/debug/verdict.d.ts +3 -0
  340. package/dist/debug/verdict.d.ts.map +1 -0
  341. package/dist/debug/verdict.js +78 -0
  342. package/dist/debug/verdict.js.map +1 -0
  343. package/dist/debug/watch.d.ts +23 -0
  344. package/dist/debug/watch.d.ts.map +1 -0
  345. package/dist/debug/watch.js +68 -0
  346. package/dist/debug/watch.js.map +1 -0
  347. package/dist/diagnose.d.ts +139 -0
  348. package/dist/diagnose.d.ts.map +1 -0
  349. package/dist/diagnose.js +418 -0
  350. package/dist/diagnose.js.map +1 -0
  351. package/dist/evals/graph-runner.d.ts +8 -0
  352. package/dist/evals/graph-runner.d.ts.map +1 -0
  353. package/dist/evals/graph-runner.js +136 -0
  354. package/dist/evals/graph-runner.js.map +1 -0
  355. package/dist/harness/capability-coverage.d.ts +161 -0
  356. package/dist/harness/capability-coverage.d.ts.map +1 -0
  357. package/dist/harness/capability-coverage.js +266 -0
  358. package/dist/harness/capability-coverage.js.map +1 -0
  359. package/dist/harness/capability-table.d.ts +17 -0
  360. package/dist/harness/capability-table.d.ts.map +1 -0
  361. package/dist/harness/capability-table.js +3844 -0
  362. package/dist/harness/capability-table.js.map +1 -0
  363. package/dist/harness/changed-files.d.ts +20 -0
  364. package/dist/harness/changed-files.d.ts.map +1 -0
  365. package/dist/harness/changed-files.js +90 -0
  366. package/dist/harness/changed-files.js.map +1 -0
  367. package/dist/harness/declared-capabilities.d.ts +12 -0
  368. package/dist/harness/declared-capabilities.d.ts.map +1 -0
  369. package/dist/harness/declared-capabilities.js +21 -0
  370. package/dist/harness/declared-capabilities.js.map +1 -0
  371. package/dist/harness/registry.d.ts +190 -0
  372. package/dist/harness/registry.d.ts.map +1 -0
  373. package/dist/harness/registry.js +2034 -0
  374. package/dist/harness/registry.js.map +1 -0
  375. package/dist/index.js +122 -131
  376. package/dist/index.js.map +1 -1
  377. package/dist/interaction-script.d.ts +40 -0
  378. package/dist/interaction-script.d.ts.map +1 -0
  379. package/dist/interaction-script.js +96 -0
  380. package/dist/interaction-script.js.map +1 -0
  381. package/dist/js-script-debug/harness.d.ts +124 -0
  382. package/dist/js-script-debug/harness.d.ts.map +1 -0
  383. package/dist/js-script-debug/harness.js +230 -0
  384. package/dist/js-script-debug/harness.js.map +1 -0
  385. package/dist/js-script-debug/index.d.ts +9 -0
  386. package/dist/js-script-debug/index.d.ts.map +1 -0
  387. package/dist/js-script-debug/index.js +9 -0
  388. package/dist/js-script-debug/index.js.map +1 -0
  389. package/dist/js-script-debug/interactions.d.ts +19 -0
  390. package/dist/js-script-debug/interactions.d.ts.map +1 -0
  391. package/dist/js-script-debug/interactions.js +17 -0
  392. package/dist/js-script-debug/interactions.js.map +1 -0
  393. package/dist/js-script-debug/target.d.ts +20 -0
  394. package/dist/js-script-debug/target.d.ts.map +1 -0
  395. package/dist/js-script-debug/target.js +78 -0
  396. package/dist/js-script-debug/target.js.map +1 -0
  397. package/dist/local-model-interfaces.d.ts +20 -0
  398. package/dist/local-model-interfaces.d.ts.map +1 -0
  399. package/dist/local-model-interfaces.js +41 -0
  400. package/dist/local-model-interfaces.js.map +1 -0
  401. package/dist/local-secrets.d.ts +3 -0
  402. package/dist/local-secrets.d.ts.map +1 -0
  403. package/dist/local-secrets.js +16 -0
  404. package/dist/local-secrets.js.map +1 -0
  405. package/dist/markdown.d.ts.map +1 -1
  406. package/dist/markdown.js +7 -2
  407. package/dist/markdown.js.map +1 -1
  408. package/dist/node/run-node.d.ts +28 -0
  409. package/dist/node/run-node.d.ts.map +1 -0
  410. package/dist/node/run-node.js +76 -0
  411. package/dist/node/run-node.js.map +1 -0
  412. package/dist/node-registry.d.ts +27 -0
  413. package/dist/node-registry.d.ts.map +1 -0
  414. package/dist/node-registry.js +33 -0
  415. package/dist/node-registry.js.map +1 -0
  416. package/dist/nodetool-main.d.ts +15 -0
  417. package/dist/nodetool-main.d.ts.map +1 -0
  418. package/dist/nodetool-main.js +1368 -0
  419. package/dist/nodetool-main.js.map +1 -0
  420. package/dist/nodetool.d.ts +0 -13
  421. package/dist/nodetool.d.ts.map +1 -1
  422. package/dist/nodetool.js +17 -1147
  423. package/dist/nodetool.js.map +1 -1
  424. package/dist/numeric-options.d.ts +22 -0
  425. package/dist/numeric-options.d.ts.map +1 -0
  426. package/dist/numeric-options.js +45 -0
  427. package/dist/numeric-options.js.map +1 -0
  428. package/dist/permission-gate.d.ts +55 -0
  429. package/dist/permission-gate.d.ts.map +1 -0
  430. package/dist/permission-gate.js +118 -0
  431. package/dist/permission-gate.js.map +1 -0
  432. package/dist/predicates.d.ts +6 -0
  433. package/dist/predicates.d.ts.map +1 -0
  434. package/dist/predicates.js +6 -0
  435. package/dist/predicates.js.map +1 -0
  436. package/dist/providers.d.ts +73 -10
  437. package/dist/providers.d.ts.map +1 -1
  438. package/dist/providers.js +339 -97
  439. package/dist/providers.js.map +1 -1
  440. package/dist/readline-input.d.ts +13 -19
  441. package/dist/readline-input.d.ts.map +1 -1
  442. package/dist/readline-input.js +201 -190
  443. package/dist/readline-input.js.map +1 -1
  444. package/dist/run-budget.d.ts +40 -0
  445. package/dist/run-budget.d.ts.map +1 -0
  446. package/dist/run-budget.js +119 -0
  447. package/dist/run-budget.js.map +1 -0
  448. package/dist/run-dsl-supervised.d.ts +11 -0
  449. package/dist/run-dsl-supervised.d.ts.map +1 -0
  450. package/dist/run-dsl-supervised.js +82 -0
  451. package/dist/run-dsl-supervised.js.map +1 -0
  452. package/dist/run-dsl.d.ts +29 -0
  453. package/dist/run-dsl.d.ts.map +1 -1
  454. package/dist/run-dsl.js +44 -10
  455. package/dist/run-dsl.js.map +1 -1
  456. package/dist/run-json.d.ts +24 -0
  457. package/dist/run-json.d.ts.map +1 -0
  458. package/dist/run-json.js +132 -0
  459. package/dist/run-json.js.map +1 -0
  460. package/dist/sandbox-catalog.d.ts +24 -0
  461. package/dist/sandbox-catalog.d.ts.map +1 -0
  462. package/dist/sandbox-catalog.js +78 -0
  463. package/dist/sandbox-catalog.js.map +1 -0
  464. package/dist/settings.d.ts +11 -10
  465. package/dist/settings.d.ts.map +1 -1
  466. package/dist/settings.js +71 -13
  467. package/dist/settings.js.map +1 -1
  468. package/dist/sketch-debug/harness.d.ts +87 -0
  469. package/dist/sketch-debug/harness.d.ts.map +1 -0
  470. package/dist/sketch-debug/harness.js +145 -0
  471. package/dist/sketch-debug/harness.js.map +1 -0
  472. package/dist/sketch-debug/index.d.ts +9 -0
  473. package/dist/sketch-debug/index.d.ts.map +1 -0
  474. package/dist/sketch-debug/index.js +9 -0
  475. package/dist/sketch-debug/index.js.map +1 -0
  476. package/dist/sketch-debug/interactions.d.ts +19 -0
  477. package/dist/sketch-debug/interactions.d.ts.map +1 -0
  478. package/dist/sketch-debug/interactions.js +17 -0
  479. package/dist/sketch-debug/interactions.js.map +1 -0
  480. package/dist/sketch-debug/target.d.ts +48 -0
  481. package/dist/sketch-debug/target.d.ts.map +1 -0
  482. package/dist/sketch-debug/target.js +138 -0
  483. package/dist/sketch-debug/target.js.map +1 -0
  484. package/dist/stdin.d.ts +18 -19
  485. package/dist/stdin.d.ts.map +1 -1
  486. package/dist/stdin.js +160 -157
  487. package/dist/stdin.js.map +1 -1
  488. package/dist/supervisor.d.ts +97 -0
  489. package/dist/supervisor.d.ts.map +1 -0
  490. package/dist/supervisor.js +194 -0
  491. package/dist/supervisor.js.map +1 -0
  492. package/dist/terminal-clipboard.d.ts +3 -0
  493. package/dist/terminal-clipboard.d.ts.map +1 -0
  494. package/dist/terminal-clipboard.js +24 -0
  495. package/dist/terminal-clipboard.js.map +1 -0
  496. package/dist/terminal-mouse.d.ts +24 -0
  497. package/dist/terminal-mouse.d.ts.map +1 -0
  498. package/dist/terminal-mouse.js +84 -0
  499. package/dist/terminal-mouse.js.map +1 -0
  500. package/dist/terminal-screen.d.ts +41 -0
  501. package/dist/terminal-screen.d.ts.map +1 -0
  502. package/dist/terminal-screen.js +228 -0
  503. package/dist/terminal-screen.js.map +1 -0
  504. package/dist/timeline-debug/harness.d.ts +79 -0
  505. package/dist/timeline-debug/harness.d.ts.map +1 -0
  506. package/dist/timeline-debug/harness.js +122 -0
  507. package/dist/timeline-debug/harness.js.map +1 -0
  508. package/dist/timeline-debug/index.d.ts +9 -0
  509. package/dist/timeline-debug/index.d.ts.map +1 -0
  510. package/dist/timeline-debug/index.js +9 -0
  511. package/dist/timeline-debug/index.js.map +1 -0
  512. package/dist/timeline-debug/interactions.d.ts +19 -0
  513. package/dist/timeline-debug/interactions.d.ts.map +1 -0
  514. package/dist/timeline-debug/interactions.js +17 -0
  515. package/dist/timeline-debug/interactions.js.map +1 -0
  516. package/dist/timeline-debug/target.d.ts +34 -0
  517. package/dist/timeline-debug/target.d.ts.map +1 -0
  518. package/dist/timeline-debug/target.js +132 -0
  519. package/dist/timeline-debug/target.js.map +1 -0
  520. package/dist/tool-format.d.ts +54 -0
  521. package/dist/tool-format.d.ts.map +1 -0
  522. package/dist/tool-format.js +360 -0
  523. package/dist/tool-format.js.map +1 -0
  524. package/dist/useExecutionState.d.ts.map +1 -1
  525. package/dist/useExecutionState.js +8 -4
  526. package/dist/useExecutionState.js.map +1 -1
  527. package/dist/validate/index.d.ts +28 -0
  528. package/dist/validate/index.d.ts.map +1 -0
  529. package/dist/validate/index.js +51 -0
  530. package/dist/validate/index.js.map +1 -0
  531. package/dist/websocket-client.d.ts +78 -15
  532. package/dist/websocket-client.d.ts.map +1 -1
  533. package/dist/websocket-client.js +497 -171
  534. package/dist/websocket-client.js.map +1 -1
  535. package/package.json +65 -31
@@ -4,9 +4,214 @@
4
4
  * and workflow commands (run_job, cancel_job, get_status).
5
5
  */
6
6
  import WebSocket from "ws";
7
+ import { processingMessageSchema } from "@nodetool-ai/protocol";
8
+ import { isNumber, isRecord, isString } from "./predicates.js";
9
+ /** Read `key` as a string, or report it absent when the wire says otherwise. */
10
+ function wireString(frame, key) {
11
+ const value = frame[key];
12
+ return isString(value) ? value : undefined;
13
+ }
14
+ /** Read `key` as a number, or report it absent when the wire says otherwise. */
15
+ function wireNumber(frame, key) {
16
+ const value = frame[key];
17
+ return isNumber(value) ? value : undefined;
18
+ }
19
+ function toolCallArgs(frame) {
20
+ const args = frame["args"];
21
+ return isRecord(args) ? args : {};
22
+ }
23
+ /** Read a `message` frame's `tool_calls`; anything else reads as none. */
24
+ function parseToolCalls(frame) {
25
+ const raw = frame["tool_calls"];
26
+ if (!Array.isArray(raw))
27
+ return [];
28
+ const calls = [];
29
+ for (const entry of raw) {
30
+ if (!isRecord(entry))
31
+ continue;
32
+ const call = entry;
33
+ calls.push({
34
+ id: wireString(call, "id") ?? "",
35
+ name: wireString(call, "name") ?? "",
36
+ args: toolCallArgs(call)
37
+ });
38
+ }
39
+ return calls;
40
+ }
41
+ function parsePlan(value) {
42
+ if (!isRecord(value) ||
43
+ !isString(value["title"]) ||
44
+ !Array.isArray(value["tasks"]))
45
+ return null;
46
+ const tasks = [];
47
+ for (const task of value["tasks"]) {
48
+ if (!isRecord(task) ||
49
+ !isString(task["id"]) ||
50
+ !isString(task["title"]) ||
51
+ !Array.isArray(task["steps"]))
52
+ return null;
53
+ const steps = [];
54
+ for (const step of task["steps"]) {
55
+ if (!isRecord(step) ||
56
+ !isString(step["id"]) ||
57
+ !isString(step["instructions"]))
58
+ return null;
59
+ steps.push({ id: step["id"], instructions: step["instructions"] });
60
+ }
61
+ const dependencies = task["depends_on"];
62
+ tasks.push({
63
+ id: task["id"],
64
+ title: task["title"],
65
+ depends_on: Array.isArray(dependencies)
66
+ ? dependencies.filter(isString)
67
+ : [],
68
+ steps
69
+ });
70
+ }
71
+ return { title: value["title"], tasks };
72
+ }
73
+ function assistantText(content) {
74
+ if (isString(content))
75
+ return content;
76
+ if (!Array.isArray(content))
77
+ return "";
78
+ return content
79
+ .flatMap((block) => isRecord(block) && block["type"] === "text" && isString(block["text"])
80
+ ? [block["text"]]
81
+ : [])
82
+ .join("");
83
+ }
84
+ /**
85
+ * Turn one decoded frame into the domain value it stands for, or null when the
86
+ * client has nothing to do with it. Fields the wire gets wrong read as absent
87
+ * and fall back to the same defaults the generators used to apply inline.
88
+ */
89
+ function parseServerFrame(frame) {
90
+ const type = wireString(frame, "type");
91
+ // A command-level failure has no `type`, only `error`.
92
+ if (type === undefined) {
93
+ const error = wireString(frame, "error");
94
+ return error === undefined ? null : { type: "error", message: error };
95
+ }
96
+ switch (type) {
97
+ case "chunk":
98
+ return {
99
+ type: "chunk",
100
+ content: wireString(frame, "content") ?? "",
101
+ done: frame["done"] === true
102
+ };
103
+ case "message": {
104
+ const role = wireString(frame, "role");
105
+ if (role === "tool") {
106
+ return {
107
+ type: "tool_result",
108
+ toolCallId: wireString(frame, "tool_call_id") ?? "",
109
+ name: wireString(frame, "name") ?? "",
110
+ content: wireString(frame, "content") ?? ""
111
+ };
112
+ }
113
+ if (role === "assistant") {
114
+ return {
115
+ type: "assistant_message",
116
+ toolCalls: parseToolCalls(frame),
117
+ content: frame["content"]
118
+ };
119
+ }
120
+ return null;
121
+ }
122
+ case "tool_call":
123
+ return {
124
+ type: "tool_call",
125
+ id: wireString(frame, "tool_call_id") ?? wireString(frame, "id") ?? "",
126
+ name: wireString(frame, "name") ?? "",
127
+ args: toolCallArgs(frame)
128
+ };
129
+ case "tool_approval_request":
130
+ return {
131
+ type,
132
+ approvalId: wireString(frame, "approval_id") ?? "",
133
+ threadId: wireString(frame, "thread_id") ?? "",
134
+ toolName: wireString(frame, "tool_name") ?? "",
135
+ category: wireString(frame, "category") ?? "",
136
+ message: wireString(frame, "message") ?? "",
137
+ description: wireString(frame, "description") ?? "",
138
+ args: toolCallArgs(frame)
139
+ };
140
+ case "plan_approval_request": {
141
+ const plan = parsePlan(frame["plan"]);
142
+ if (!plan)
143
+ return {
144
+ type: "error",
145
+ message: "The server sent an invalid approval plan."
146
+ };
147
+ return {
148
+ type,
149
+ approvalId: wireString(frame, "approval_id") ?? "",
150
+ threadId: wireString(frame, "thread_id") ?? null,
151
+ plan
152
+ };
153
+ }
154
+ case "secret_request":
155
+ return {
156
+ type,
157
+ approvalId: wireString(frame, "approval_id") ?? "",
158
+ threadId: wireString(frame, "thread_id") ?? "",
159
+ key: wireString(frame, "key") ?? "",
160
+ description: wireString(frame, "description") ?? null,
161
+ reason: wireString(frame, "reason") ?? null,
162
+ helpUrl: wireString(frame, "help_url") ?? null
163
+ };
164
+ case "job_update":
165
+ return {
166
+ type: "job_update",
167
+ status: wireString(frame, "status") ?? "unknown",
168
+ jobId: wireString(frame, "job_id"),
169
+ workflowId: wireString(frame, "workflow_id"),
170
+ error: wireString(frame, "error"),
171
+ result: frame["result"]
172
+ };
173
+ case "node_update":
174
+ return {
175
+ type: "node_update",
176
+ nodeId: wireString(frame, "node_id") ?? "",
177
+ status: wireString(frame, "status") ?? "unknown",
178
+ error: wireString(frame, "error")
179
+ };
180
+ case "output_update":
181
+ return {
182
+ type: "output_update",
183
+ nodeId: wireString(frame, "node_id") ?? "",
184
+ value: frame["value"],
185
+ outputType: wireString(frame, "output_type")
186
+ };
187
+ case "node_progress":
188
+ return {
189
+ type: "node_progress",
190
+ nodeId: wireString(frame, "node_id") ?? "",
191
+ progress: wireNumber(frame, "progress") ?? 0,
192
+ total: wireNumber(frame, "total")
193
+ };
194
+ case "error":
195
+ return {
196
+ type: "error",
197
+ message: wireString(frame, "message") ?? "Unknown error"
198
+ };
199
+ case "inference_done":
200
+ return { type: "inference_done" };
201
+ case "generation_stopped":
202
+ return { type: "generation_stopped" };
203
+ default: {
204
+ const parsed = processingMessageSchema.safeParse(frame);
205
+ return parsed.success
206
+ ? { type: "processing", message: parsed.data }
207
+ : null;
208
+ }
209
+ }
210
+ }
7
211
  export class WebSocketChatClient {
8
212
  wsUrl;
9
213
  ws = null;
214
+ disconnectedMessage = "Not connected to the NodeTool server.";
10
215
  contentQueue = [];
11
216
  contentWaiters = [];
12
217
  constructor(wsUrl) {
@@ -15,94 +220,133 @@ export class WebSocketChatClient {
15
220
  async connect() {
16
221
  return new Promise((resolve, reject) => {
17
222
  const ws = new WebSocket(this.wsUrl);
223
+ this.ws = ws;
224
+ this.disconnectedMessage =
225
+ "Connection to the NodeTool server closed before the response completed.";
226
+ // Guard so the connect promise settles exactly once: the "error" listener
227
+ // stays attached for the socket's lifetime, so without this a post-connect
228
+ // error would call reject() on an already-resolved promise and be silently
229
+ // swallowed (and an unhandled "error" event would otherwise crash Node).
230
+ let settled = false;
18
231
  ws.on("open", () => {
19
- this.ws = ws;
232
+ if (this.ws !== ws) {
233
+ ws.close();
234
+ return;
235
+ }
20
236
  // Switch server to text/JSON mode
21
237
  ws.send(JSON.stringify({ command: "set_mode", data: { mode: "text" } }));
22
- resolve();
238
+ if (!settled) {
239
+ settled = true;
240
+ resolve();
241
+ }
242
+ });
243
+ ws.on("error", (err) => {
244
+ this.disconnectedMessage = `NodeTool connection failed: ${err.message}`;
245
+ if (this.ws === ws)
246
+ this.ws = null;
247
+ if (!settled) {
248
+ settled = true;
249
+ reject(err);
250
+ this.drainWaiters();
251
+ return;
252
+ }
253
+ // Error after a successful connect: tear down and unblock any waiting
254
+ // generators so they terminate instead of hanging forever.
255
+ this.ws = null;
256
+ this.drainWaiters();
23
257
  });
24
- ws.on("error", (err) => reject(err));
25
258
  ws.on("message", (data) => {
26
259
  try {
27
- const msg = JSON.parse(typeof data === "string" ? data : data.toString("utf8"));
28
- this.handleMessage(msg);
260
+ const msg = JSON.parse(isString(data) ? data : data.toString("utf8"));
261
+ if (isRecord(msg))
262
+ this.handleMessage(msg);
29
263
  }
30
264
  catch {
31
265
  // ignore malformed messages
32
266
  }
33
267
  });
34
268
  ws.on("close", () => {
35
- this.ws = null;
36
- // Unblock all pending waiters
37
- for (const waiter of this.contentWaiters)
38
- waiter(null);
39
- this.contentWaiters = [];
269
+ if (this.ws === ws)
270
+ this.ws = null;
271
+ if (!settled) {
272
+ settled = true;
273
+ reject(new Error(this.disconnectedMessage));
274
+ }
275
+ this.drainWaiters();
40
276
  });
41
277
  });
42
278
  }
279
+ /** A dropped connection is a failed response, never a successful completion. */
280
+ drainWaiters() {
281
+ const waiters = this.contentWaiters;
282
+ this.contentWaiters = [];
283
+ for (const waiter of waiters)
284
+ waiter({ type: "error", message: this.disconnectedMessage });
285
+ }
43
286
  handleMessage(msg) {
44
- const type = typeof msg.type === "string" ? msg.type : null;
45
287
  // Auto-respond to server pings
46
- if (type === "ping") {
288
+ if (msg["type"] === "ping") {
47
289
  this.send({ type: "pong", ts: Date.now() / 1000 });
48
290
  return;
49
291
  }
50
- // Treat command-level errors (no type field but has error field) as error content events
51
- if (!type && typeof msg.error === "string") {
52
- const errorEvent = {
53
- type: "error",
54
- message: msg.error
55
- };
56
- const waiter = this.contentWaiters.shift();
57
- if (waiter) {
58
- waiter(errorEvent);
59
- }
60
- else {
61
- this.contentQueue.push(errorEvent);
62
- }
292
+ // Route content events to waiting generators
293
+ const parsed = parseServerFrame(msg);
294
+ if (!parsed)
63
295
  return;
296
+ const processing = processingMessageSchema.safeParse(msg);
297
+ const frame = {
298
+ ...parsed,
299
+ scopeThreadId: wireString(msg, "thread_id"),
300
+ parentToolCallId: wireString(msg, "parent_tool_call_id"),
301
+ ...(processing.success && { processing: processing.data })
302
+ };
303
+ const waiter = this.contentWaiters.shift();
304
+ if (waiter) {
305
+ waiter(frame);
64
306
  }
65
- // Route content events to waiting generators
66
- if (this.isContentEvent(type)) {
67
- const waiter = this.contentWaiters.shift();
68
- if (waiter) {
69
- waiter(msg);
70
- }
71
- else {
72
- this.contentQueue.push(msg);
73
- }
307
+ else {
308
+ this.contentQueue.push(frame);
74
309
  }
75
- // Ignore: system_stats, command acks (no type field), etc.
76
- }
77
- isContentEvent(type) {
78
- return (type === "chunk" ||
79
- type === "message" ||
80
- type === "tool_call" ||
81
- type === "job_update" ||
82
- type === "node_update" ||
83
- type === "output_update" ||
84
- type === "node_progress" ||
85
- type === "error" ||
86
- type === "inference_done" ||
87
- type === "generation_stopped");
88
310
  }
89
311
  send(data) {
90
- if (this.ws && this.ws.readyState === WebSocket.OPEN) {
91
- this.ws.send(JSON.stringify(data));
312
+ if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
313
+ throw new Error(this.disconnectedMessage);
92
314
  }
315
+ this.ws.send(JSON.stringify(data));
93
316
  }
94
- nextContent() {
95
- if (this.contentQueue.length > 0) {
96
- return Promise.resolve(this.contentQueue.shift());
317
+ nextContent(signal) {
318
+ if (signal?.aborted)
319
+ return Promise.resolve(null);
320
+ const queued = this.contentQueue.shift();
321
+ if (queued)
322
+ return Promise.resolve(queued);
323
+ if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
324
+ return Promise.resolve({
325
+ type: "error",
326
+ message: this.disconnectedMessage
327
+ });
97
328
  }
98
329
  return new Promise((resolve) => {
99
- this.contentWaiters.push(resolve);
330
+ const receive = (event) => {
331
+ signal?.removeEventListener("abort", cancel);
332
+ resolve(event);
333
+ };
334
+ const cancel = () => {
335
+ const index = this.contentWaiters.indexOf(receive);
336
+ if (index !== -1)
337
+ this.contentWaiters.splice(index, 1);
338
+ receive(null);
339
+ };
340
+ this.contentWaiters.push(receive);
341
+ signal?.addEventListener("abort", cancel, { once: true });
100
342
  });
101
343
  }
102
344
  /** Stateful chat — messages are saved to DB, thread history is loaded. */
103
- async *chat(content, threadId, model, provider, tools) {
104
- // Drain stale events from previous responses (extra done chunks, final messages, etc.)
105
- // that arrived between the previous chat completing and this one starting.
345
+ async *chat(content, threadId, model, provider, tools, options = {}) {
346
+ if (options.signal?.aborted) {
347
+ yield { type: "done" };
348
+ return;
349
+ }
106
350
  this.contentQueue.length = 0;
107
351
  this.send({
108
352
  command: "chat_message",
@@ -112,75 +356,142 @@ export class WebSocketChatClient {
112
356
  thread_id: threadId,
113
357
  model,
114
358
  provider,
115
- tools: tools ?? []
359
+ tools: tools ?? [],
360
+ ...(options.permissionMode && {
361
+ permission_mode: options.permissionMode
362
+ })
116
363
  }
117
364
  });
118
- while (true) {
119
- const event = await this.nextContent();
120
- if (!event) {
121
- yield { type: "done" };
122
- return;
123
- }
124
- const type = event.type;
125
- if (type === "chunk") {
126
- // Yield content from every chunk — including the done chunk which may carry the last piece
127
- const chunkContent = typeof event.content === "string" ? event.content : "";
128
- if (chunkContent) {
129
- yield { type: "chunk", content: chunkContent };
365
+ const cancel = () => {
366
+ if (this.ws?.readyState === WebSocket.OPEN)
367
+ this.stop(threadId);
368
+ };
369
+ options.signal?.addEventListener("abort", cancel, { once: true });
370
+ let streamedText = "";
371
+ const announcedCalls = new Set();
372
+ const completedCalls = new Set();
373
+ try {
374
+ while (true) {
375
+ const event = await this.nextContent(options.signal);
376
+ if (!event) {
377
+ yield { type: "done" };
378
+ return;
130
379
  }
131
- // Done chunk signals completion — matches Python's {"type": "chunk", "done": true}
132
- if (event.done === true) {
380
+ if (event.scopeThreadId && event.scopeThreadId !== threadId)
381
+ continue;
382
+ if (event.type === "chunk") {
383
+ if (event.processing?.type === "chunk" &&
384
+ (event.processing.thinking ||
385
+ event.parentToolCallId ||
386
+ event.processing.subtask_depth)) {
387
+ yield { type: "processing", message: event.processing };
388
+ continue;
389
+ }
390
+ if (event.content) {
391
+ if (!event.parentToolCallId)
392
+ streamedText += event.content;
393
+ yield { type: "chunk", content: event.content };
394
+ }
395
+ // A delegated loop finishing does not finish its parent turn.
396
+ if (event.done && !event.parentToolCallId) {
397
+ yield { type: "done" };
398
+ return;
399
+ }
400
+ }
401
+ else if (event.type === "assistant_message") {
402
+ if (event.content != null) {
403
+ const fullText = assistantText(event.content);
404
+ const text = fullText.startsWith(streamedText)
405
+ ? fullText.slice(streamedText.length)
406
+ : fullText;
407
+ if (!event.parentToolCallId)
408
+ streamedText = "";
409
+ if (text || Array.isArray(event.content)) {
410
+ yield { type: "assistant_message", content: event.content, text };
411
+ }
412
+ }
413
+ for (const call of event.toolCalls) {
414
+ if (announcedCalls.has(call.id))
415
+ continue;
416
+ announcedCalls.add(call.id);
417
+ yield { type: "tool_call", ...call };
418
+ }
419
+ }
420
+ else if (event.type === "tool_call") {
421
+ yield {
422
+ type: "client_tool_call",
423
+ id: event.id,
424
+ name: event.name,
425
+ args: event.args,
426
+ threadId: event.scopeThreadId ?? threadId
427
+ };
428
+ }
429
+ else if (event.type === "tool_result") {
430
+ if (completedCalls.has(event.toolCallId))
431
+ continue;
432
+ completedCalls.add(event.toolCallId);
433
+ yield {
434
+ type: "tool_result",
435
+ id: event.toolCallId,
436
+ name: event.name,
437
+ content: event.content
438
+ };
439
+ }
440
+ else if (event.type === "output_update") {
441
+ yield {
442
+ type: "output_update",
443
+ node_id: event.nodeId,
444
+ value: event.value,
445
+ output_type: event.outputType
446
+ };
447
+ }
448
+ else if (event.type === "generation_stopped") {
133
449
  yield { type: "done" };
134
450
  return;
135
451
  }
136
- }
137
- else if (type === "message") {
138
- const role = event.role;
139
- if (role === "assistant" && Array.isArray(event.tool_calls)) {
140
- // Assistant decided to call tool(s) — yield each one
141
- for (const tc of event.tool_calls) {
452
+ else if (event.type === "error") {
453
+ yield { type: "error", message: event.message };
454
+ return;
455
+ }
456
+ else if (event.type === "tool_approval_request" ||
457
+ event.type === "plan_approval_request" ||
458
+ event.type === "secret_request") {
459
+ yield event;
460
+ }
461
+ else if (event.type === "processing") {
462
+ const message = event.message;
463
+ if (message.type === "tool_call_update" &&
464
+ message.tool_call_id &&
465
+ !announcedCalls.has(message.tool_call_id)) {
466
+ announcedCalls.add(message.tool_call_id);
142
467
  yield {
143
468
  type: "tool_call",
144
- id: typeof tc.id === "string" ? tc.id : "",
145
- name: typeof tc.name === "string" ? tc.name : "",
146
- args: (tc.args ?? {})
469
+ id: message.tool_call_id,
470
+ name: message.name,
471
+ args: message.args
147
472
  };
148
473
  }
474
+ else if (message.type === "tool_result_update" &&
475
+ message.tool_call_id &&
476
+ !completedCalls.has(message.tool_call_id)) {
477
+ completedCalls.add(message.tool_call_id);
478
+ yield {
479
+ type: "tool_result",
480
+ id: message.tool_call_id,
481
+ name: message.name ?? "",
482
+ content: JSON.stringify(message.result)
483
+ };
484
+ }
485
+ yield { type: "processing", message };
149
486
  }
150
- else if (role === "tool") {
151
- // Tool result — yield for display
152
- yield {
153
- type: "tool_result",
154
- id: typeof event.tool_call_id === "string" ? event.tool_call_id : "",
155
- name: typeof event.name === "string" ? event.name : "",
156
- content: typeof event.content === "string" ? event.content : ""
157
- };
487
+ else if (event.processing) {
488
+ yield { type: "processing", message: event.processing };
158
489
  }
159
- // Final assistant message (no tool_calls) is ignored — content already streamed via chunks
160
- continue;
161
- }
162
- else if (type === "output_update") {
163
- yield {
164
- type: "output_update",
165
- node_id: typeof event.node_id === "string" ? event.node_id : "",
166
- value: event.value,
167
- output_type: typeof event.output_type === "string"
168
- ? event.output_type
169
- : undefined
170
- };
171
- }
172
- else if (type === "job_update" || type === "generation_stopped") {
173
- yield { type: "done" };
174
- return;
175
- }
176
- else if (type === "error") {
177
- yield {
178
- type: "error",
179
- message: typeof event.message === "string" ? event.message : "Unknown error"
180
- };
181
- return;
182
490
  }
183
491
  }
492
+ finally {
493
+ options.signal?.removeEventListener("abort", cancel);
494
+ }
184
495
  }
185
496
  /** Stateless inference — takes full messages array, streams back, no DB. Used by agent mode. */
186
497
  async *inference(messages, model, provider, tools) {
@@ -194,34 +505,30 @@ export class WebSocketChatClient {
194
505
  yield { type: "done" };
195
506
  return;
196
507
  }
197
- const type = event.type;
198
- if (type === "chunk") {
199
- const chunkContent = typeof event.content === "string" ? event.content : "";
200
- if (chunkContent) {
201
- yield { type: "chunk", content: chunkContent };
508
+ if (event.type === "chunk") {
509
+ if (event.content) {
510
+ yield { type: "chunk", content: event.content };
202
511
  }
203
- if (event.done === true) {
512
+ if (event.done) {
204
513
  yield { type: "done" };
205
514
  return;
206
515
  }
207
516
  }
208
- else if (type === "tool_call") {
517
+ else if (event.type === "tool_call") {
209
518
  yield {
210
519
  type: "tool_call",
211
- id: typeof event.id === "string" ? event.id : "",
212
- name: typeof event.name === "string" ? event.name : "",
213
- args: (event.args ?? {})
520
+ id: event.id,
521
+ name: event.name,
522
+ args: event.args
214
523
  };
215
524
  }
216
- else if (type === "inference_done" || type === "generation_stopped") {
525
+ else if (event.type === "inference_done" ||
526
+ event.type === "generation_stopped") {
217
527
  yield { type: "done" };
218
528
  return;
219
529
  }
220
- else if (type === "error") {
221
- yield {
222
- type: "error",
223
- message: typeof event.message === "string" ? event.message : "Unknown error"
224
- };
530
+ else if (event.type === "error") {
531
+ yield { type: "error", message: event.message };
225
532
  return;
226
533
  }
227
534
  }
@@ -252,16 +559,7 @@ export class WebSocketChatClient {
252
559
  });
253
560
  yield* this.consumeJobEvents();
254
561
  }
255
- /** Resume a paused/interrupted job. */
256
- async *resumeJob(jobId, workflowId) {
257
- this.contentQueue.length = 0;
258
- this.send({
259
- command: "resume_job",
260
- data: { job_id: jobId, workflow_id: workflowId }
261
- });
262
- yield* this.consumeJobEvents();
263
- }
264
- /** Shared job event consumer used by runJob, reconnectJob, resumeJob. */
562
+ /** Shared job event consumer used by runJob and reconnectJob. */
265
563
  async *consumeJobEvents() {
266
564
  while (true) {
267
565
  const event = await this.nextContent();
@@ -269,58 +567,49 @@ export class WebSocketChatClient {
269
567
  yield { type: "done" };
270
568
  return;
271
569
  }
272
- const type = event.type;
273
- if (type === "job_update") {
274
- const status = typeof event.status === "string" ? event.status : "unknown";
570
+ if (event.type === "job_update") {
275
571
  yield {
276
572
  type: "job_update",
277
- status,
278
- job_id: typeof event.job_id === "string" ? event.job_id : undefined,
279
- workflow_id: typeof event.workflow_id === "string"
280
- ? event.workflow_id
281
- : undefined,
282
- error: typeof event.error === "string" ? event.error : undefined,
573
+ status: event.status,
574
+ job_id: event.jobId,
575
+ workflow_id: event.workflowId,
576
+ error: event.error,
283
577
  result: event.result
284
578
  };
285
- if (["completed", "failed", "cancelled", "error"].includes(status)) {
579
+ if (["completed", "failed", "cancelled", "error"].includes(event.status)) {
286
580
  yield { type: "done" };
287
581
  return;
288
582
  }
289
583
  }
290
- else if (type === "node_update") {
584
+ else if (event.type === "node_update") {
291
585
  yield {
292
586
  type: "node_update",
293
- node_id: typeof event.node_id === "string" ? event.node_id : "",
294
- status: typeof event.status === "string" ? event.status : "unknown",
295
- error: typeof event.error === "string" ? event.error : undefined
587
+ node_id: event.nodeId,
588
+ status: event.status,
589
+ error: event.error
296
590
  };
297
591
  }
298
- else if (type === "output_update") {
592
+ else if (event.type === "output_update") {
299
593
  yield {
300
594
  type: "output_update",
301
- node_id: typeof event.node_id === "string" ? event.node_id : "",
595
+ node_id: event.nodeId,
302
596
  value: event.value,
303
- output_type: typeof event.output_type === "string"
304
- ? event.output_type
305
- : undefined
597
+ output_type: event.outputType
306
598
  };
307
599
  }
308
- else if (type === "node_progress") {
600
+ else if (event.type === "node_progress") {
309
601
  yield {
310
602
  type: "node_progress",
311
- node_id: typeof event.node_id === "string" ? event.node_id : "",
312
- progress: typeof event.progress === "number" ? event.progress : 0,
313
- total: typeof event.total === "number" ? event.total : undefined
603
+ node_id: event.nodeId,
604
+ progress: event.progress,
605
+ total: event.total
314
606
  };
315
607
  }
316
- else if (type === "error") {
317
- yield {
318
- type: "error",
319
- message: typeof event.message === "string" ? event.message : "Unknown error"
320
- };
608
+ else if (event.type === "error") {
609
+ yield { type: "error", message: event.message };
321
610
  return;
322
611
  }
323
- else if (type === "generation_stopped") {
612
+ else if (event.type === "generation_stopped") {
324
613
  yield { type: "done" };
325
614
  return;
326
615
  }
@@ -338,14 +627,51 @@ export class WebSocketChatClient {
338
627
  stop(threadId) {
339
628
  const data = {};
340
629
  if (threadId)
341
- data["thread_id"] = threadId;
630
+ data.thread_id = threadId;
342
631
  this.send({ command: "stop", data });
343
632
  }
633
+ respondToolApproval(approvalId, decision) {
634
+ this.send({
635
+ type: "tool_approval_response",
636
+ approval_id: approvalId,
637
+ decision
638
+ });
639
+ }
640
+ respondPlanApproval(approvalId, decision, feedback) {
641
+ this.send({
642
+ type: "plan_approval_response",
643
+ approval_id: approvalId,
644
+ decision,
645
+ ...(feedback && { feedback })
646
+ });
647
+ }
648
+ respondSecretRequest(approvalId, status) {
649
+ this.send({
650
+ type: "secret_request_response",
651
+ approval_id: approvalId,
652
+ status
653
+ });
654
+ }
655
+ respondToolResult(id, threadId, result, ok = true) {
656
+ this.send({
657
+ type: "tool_result",
658
+ tool_call_id: id,
659
+ thread_id: threadId,
660
+ result,
661
+ ok
662
+ });
663
+ }
664
+ setPermissionMode(threadId, mode) {
665
+ this.send({
666
+ command: "set_permission_mode",
667
+ data: { thread_id: threadId, permission_mode: mode }
668
+ });
669
+ }
344
670
  disconnect() {
345
- if (this.ws) {
346
- this.ws.close();
347
- this.ws = null;
348
- }
671
+ const ws = this.ws;
672
+ this.ws = null;
673
+ ws?.close();
674
+ this.drainWaiters();
349
675
  }
350
676
  }
351
677
  //# sourceMappingURL=websocket-client.js.map