@code-yeongyu/senpi 2026.7.25-2 → 2026.7.26

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 (463) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +1 -1
  3. package/dist/cli/args.d.ts +4 -16
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +9 -25
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/grok-neo-gate.d.ts +12 -0
  8. package/dist/cli/grok-neo-gate.d.ts.map +1 -0
  9. package/dist/cli/grok-neo-gate.js +18 -0
  10. package/dist/cli/grok-neo-gate.js.map +1 -0
  11. package/dist/cli-main.js +4 -0
  12. package/dist/cli-main.js.map +1 -1
  13. package/dist/cli.js +2 -0
  14. package/dist/cli.js.map +1 -1
  15. package/dist/core/agent-session-runtime.d.ts +2 -0
  16. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  17. package/dist/core/agent-session-runtime.js +33 -8
  18. package/dist/core/agent-session-runtime.js.map +1 -1
  19. package/dist/core/agent-session.d.ts +9 -3
  20. package/dist/core/agent-session.d.ts.map +1 -1
  21. package/dist/core/agent-session.js +179 -57
  22. package/dist/core/agent-session.js.map +1 -1
  23. package/dist/core/auth-providers.d.ts +2 -2
  24. package/dist/core/auth-providers.js +2 -2
  25. package/dist/core/auth-providers.js.map +1 -1
  26. package/dist/core/extensions/builtin/bash-timeout/timeout.d.ts.map +1 -1
  27. package/dist/core/extensions/builtin/bash-timeout/timeout.js +3 -2
  28. package/dist/core/extensions/builtin/bash-timeout/timeout.js.map +1 -1
  29. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  30. package/dist/core/extensions/builtin/compaction/index.js +30 -2
  31. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  32. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  33. package/dist/core/extensions/builtin/compaction/speculative.js +28 -0
  34. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  35. package/dist/core/extensions/builtin/goal/command-registration.js +2 -2
  36. package/dist/core/extensions/builtin/goal/command-registration.js.map +1 -1
  37. package/dist/core/extensions/builtin/goal/format.d.ts +1 -1
  38. package/dist/core/extensions/builtin/goal/format.d.ts.map +1 -1
  39. package/dist/core/extensions/builtin/goal/format.js +9 -2
  40. package/dist/core/extensions/builtin/goal/format.js.map +1 -1
  41. package/dist/core/extensions/builtin/goal/index.d.ts.map +1 -1
  42. package/dist/core/extensions/builtin/goal/index.js +38 -23
  43. package/dist/core/extensions/builtin/goal/index.js.map +1 -1
  44. package/dist/core/extensions/builtin/goal/lifecycle-helpers.d.ts +6 -0
  45. package/dist/core/extensions/builtin/goal/lifecycle-helpers.d.ts.map +1 -0
  46. package/dist/core/extensions/builtin/goal/lifecycle-helpers.js +19 -0
  47. package/dist/core/extensions/builtin/goal/lifecycle-helpers.js.map +1 -0
  48. package/dist/core/extensions/builtin/goal/persistence.d.ts +6 -0
  49. package/dist/core/extensions/builtin/goal/persistence.d.ts.map +1 -0
  50. package/dist/core/extensions/builtin/goal/persistence.js +141 -0
  51. package/dist/core/extensions/builtin/goal/persistence.js.map +1 -0
  52. package/dist/core/extensions/builtin/goal/store.d.ts +7 -3
  53. package/dist/core/extensions/builtin/goal/store.d.ts.map +1 -1
  54. package/dist/core/extensions/builtin/goal/store.js +66 -181
  55. package/dist/core/extensions/builtin/goal/store.js.map +1 -1
  56. package/dist/core/extensions/builtin/goal/tool-registration.d.ts +1 -0
  57. package/dist/core/extensions/builtin/goal/tool-registration.d.ts.map +1 -1
  58. package/dist/core/extensions/builtin/goal/tool-registration.js +26 -15
  59. package/dist/core/extensions/builtin/goal/tool-registration.js.map +1 -1
  60. package/dist/core/extensions/builtin/goal/transitions.d.ts +3 -0
  61. package/dist/core/extensions/builtin/goal/transitions.d.ts.map +1 -0
  62. package/dist/core/extensions/builtin/goal/transitions.js +45 -0
  63. package/dist/core/extensions/builtin/goal/transitions.js.map +1 -0
  64. package/dist/core/extensions/builtin/goal/types.d.ts +10 -4
  65. package/dist/core/extensions/builtin/goal/types.d.ts.map +1 -1
  66. package/dist/core/extensions/builtin/goal/types.js +2 -2
  67. package/dist/core/extensions/builtin/goal/types.js.map +1 -1
  68. package/dist/core/extensions/builtin/goal/ui.d.ts.map +1 -1
  69. package/dist/core/extensions/builtin/goal/ui.js +2 -0
  70. package/dist/core/extensions/builtin/goal/ui.js.map +1 -1
  71. package/dist/core/extensions/builtin/goal/validation.d.ts +8 -1
  72. package/dist/core/extensions/builtin/goal/validation.d.ts.map +1 -1
  73. package/dist/core/extensions/builtin/goal/validation.js +24 -12
  74. package/dist/core/extensions/builtin/goal/validation.js.map +1 -1
  75. package/dist/core/extensions/builtin/index.d.ts.map +1 -1
  76. package/dist/core/extensions/builtin/index.js +0 -2
  77. package/dist/core/extensions/builtin/index.js.map +1 -1
  78. package/dist/core/extensions/builtin/mcp/index.d.ts.map +1 -1
  79. package/dist/core/extensions/builtin/mcp/index.js +8 -5
  80. package/dist/core/extensions/builtin/mcp/index.js.map +1 -1
  81. package/dist/core/extensions/builtin/permission-system/parsers.d.ts.map +1 -1
  82. package/dist/core/extensions/builtin/permission-system/parsers.js +1 -0
  83. package/dist/core/extensions/builtin/permission-system/parsers.js.map +1 -1
  84. package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
  85. package/dist/core/extensions/builtin/terminal/extension.js +32 -0
  86. package/dist/core/extensions/builtin/terminal/extension.js.map +1 -1
  87. package/dist/core/extensions/builtin/terminal/index.d.ts +1 -1
  88. package/dist/core/extensions/builtin/terminal/index.d.ts.map +1 -1
  89. package/dist/core/extensions/builtin/terminal/index.js +1 -1
  90. package/dist/core/extensions/builtin/terminal/index.js.map +1 -1
  91. package/dist/core/extensions/builtin/terminal/monitor-notify.d.ts +29 -0
  92. package/dist/core/extensions/builtin/terminal/monitor-notify.d.ts.map +1 -0
  93. package/dist/core/extensions/builtin/terminal/monitor-notify.js +185 -0
  94. package/dist/core/extensions/builtin/terminal/monitor-notify.js.map +1 -0
  95. package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts +35 -0
  96. package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts.map +1 -0
  97. package/dist/core/extensions/builtin/terminal/monitor-registry.js +98 -0
  98. package/dist/core/extensions/builtin/terminal/monitor-registry.js.map +1 -0
  99. package/dist/core/extensions/builtin/terminal/notify.d.ts +9 -0
  100. package/dist/core/extensions/builtin/terminal/notify.d.ts.map +1 -1
  101. package/dist/core/extensions/builtin/terminal/notify.js +30 -14
  102. package/dist/core/extensions/builtin/terminal/notify.js.map +1 -1
  103. package/dist/core/extensions/builtin/terminal/prompt.d.ts +1 -1
  104. package/dist/core/extensions/builtin/terminal/prompt.d.ts.map +1 -1
  105. package/dist/core/extensions/builtin/terminal/prompt.js +13 -5
  106. package/dist/core/extensions/builtin/terminal/prompt.js.map +1 -1
  107. package/dist/core/extensions/builtin/terminal/runtime-session.d.ts +3 -12
  108. package/dist/core/extensions/builtin/terminal/runtime-session.d.ts.map +1 -1
  109. package/dist/core/extensions/builtin/terminal/runtime-session.js +4 -59
  110. package/dist/core/extensions/builtin/terminal/runtime-session.js.map +1 -1
  111. package/dist/core/extensions/builtin/terminal/settings.d.ts +8 -0
  112. package/dist/core/extensions/builtin/terminal/settings.d.ts.map +1 -1
  113. package/dist/core/extensions/builtin/terminal/settings.js +16 -2
  114. package/dist/core/extensions/builtin/terminal/settings.js.map +1 -1
  115. package/dist/core/extensions/builtin/terminal/shared.d.ts +2 -2
  116. package/dist/core/extensions/builtin/terminal/shared.d.ts.map +1 -1
  117. package/dist/core/extensions/builtin/terminal/shared.js +2 -1
  118. package/dist/core/extensions/builtin/terminal/shared.js.map +1 -1
  119. package/dist/core/extensions/builtin/terminal/tools/bash-output.d.ts +10 -4
  120. package/dist/core/extensions/builtin/terminal/tools/bash-output.d.ts.map +1 -1
  121. package/dist/core/extensions/builtin/terminal/tools/bash-output.js +17 -96
  122. package/dist/core/extensions/builtin/terminal/tools/bash-output.js.map +1 -1
  123. package/dist/core/extensions/builtin/terminal/tools/context.d.ts +7 -0
  124. package/dist/core/extensions/builtin/terminal/tools/context.d.ts.map +1 -1
  125. package/dist/core/extensions/builtin/terminal/tools/context.js.map +1 -1
  126. package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts +41 -0
  127. package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts.map +1 -0
  128. package/dist/core/extensions/builtin/terminal/tools/monitor.js +97 -0
  129. package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -0
  130. package/dist/core/extensions/builtin/terminal/tools/render.d.ts +3 -0
  131. package/dist/core/extensions/builtin/terminal/tools/render.d.ts.map +1 -1
  132. package/dist/core/extensions/builtin/terminal/tools/render.js +5 -2
  133. package/dist/core/extensions/builtin/terminal/tools/render.js.map +1 -1
  134. package/dist/core/extensions/builtin/todotools/fuzzy-match.d.ts +19 -0
  135. package/dist/core/extensions/builtin/todotools/fuzzy-match.d.ts.map +1 -0
  136. package/dist/core/extensions/builtin/todotools/fuzzy-match.js +70 -0
  137. package/dist/core/extensions/builtin/todotools/fuzzy-match.js.map +1 -0
  138. package/dist/core/extensions/builtin/todotools/normalize.d.ts +8 -0
  139. package/dist/core/extensions/builtin/todotools/normalize.d.ts.map +1 -0
  140. package/dist/core/extensions/builtin/todotools/normalize.js +174 -0
  141. package/dist/core/extensions/builtin/todotools/normalize.js.map +1 -0
  142. package/dist/core/extensions/builtin/todotools/prompt.d.ts +2 -2
  143. package/dist/core/extensions/builtin/todotools/prompt.d.ts.map +1 -1
  144. package/dist/core/extensions/builtin/todotools/prompt.js +4 -2
  145. package/dist/core/extensions/builtin/todotools/prompt.js.map +1 -1
  146. package/dist/core/extensions/builtin/todotools/state.d.ts +9 -8
  147. package/dist/core/extensions/builtin/todotools/state.d.ts.map +1 -1
  148. package/dist/core/extensions/builtin/todotools/state.js +99 -48
  149. package/dist/core/extensions/builtin/todotools/state.js.map +1 -1
  150. package/dist/core/extensions/builtin/todotools/tools/todo.d.ts +1 -1
  151. package/dist/core/extensions/builtin/todotools/tools/todo.d.ts.map +1 -1
  152. package/dist/core/extensions/builtin/todotools/tools/todo.js +65 -38
  153. package/dist/core/extensions/builtin/todotools/tools/todo.js.map +1 -1
  154. package/dist/core/extensions/loader.d.ts.map +1 -1
  155. package/dist/core/extensions/loader.js +12 -0
  156. package/dist/core/extensions/loader.js.map +1 -1
  157. package/dist/core/extensions/runner.d.ts +5 -0
  158. package/dist/core/extensions/runner.d.ts.map +1 -1
  159. package/dist/core/extensions/runner.js +12 -1
  160. package/dist/core/extensions/runner.js.map +1 -1
  161. package/dist/core/extensions/types.d.ts +23 -1
  162. package/dist/core/extensions/types.d.ts.map +1 -1
  163. package/dist/core/extensions/types.js.map +1 -1
  164. package/dist/core/keybindings.d.ts +0 -5
  165. package/dist/core/keybindings.d.ts.map +1 -1
  166. package/dist/core/keybindings.js +0 -2
  167. package/dist/core/keybindings.js.map +1 -1
  168. package/dist/core/messages.d.ts +32 -0
  169. package/dist/core/messages.d.ts.map +1 -1
  170. package/dist/core/messages.js +91 -0
  171. package/dist/core/messages.js.map +1 -1
  172. package/dist/core/model-resolver.d.ts +9 -1
  173. package/dist/core/model-resolver.d.ts.map +1 -1
  174. package/dist/core/model-resolver.js.map +1 -1
  175. package/dist/core/model-runtime.d.ts +2 -0
  176. package/dist/core/model-runtime.d.ts.map +1 -1
  177. package/dist/core/model-runtime.js +4 -3
  178. package/dist/core/model-runtime.js.map +1 -1
  179. package/dist/core/resource-loader.d.ts +9 -0
  180. package/dist/core/resource-loader.d.ts.map +1 -1
  181. package/dist/core/resource-loader.js +10 -2
  182. package/dist/core/resource-loader.js.map +1 -1
  183. package/dist/core/retry-fallback/cooldown.d.ts.map +1 -1
  184. package/dist/core/retry-fallback/cooldown.js +5 -0
  185. package/dist/core/retry-fallback/cooldown.js.map +1 -1
  186. package/dist/core/sdk.d.ts.map +1 -1
  187. package/dist/core/sdk.js +11 -35
  188. package/dist/core/sdk.js.map +1 -1
  189. package/dist/core/settings-manager.d.ts +5 -16
  190. package/dist/core/settings-manager.d.ts.map +1 -1
  191. package/dist/core/settings-manager.js +0 -13
  192. package/dist/core/settings-manager.js.map +1 -1
  193. package/dist/core/slash-commands.d.ts.map +1 -1
  194. package/dist/core/slash-commands.js +1 -0
  195. package/dist/core/slash-commands.js.map +1 -1
  196. package/dist/core/timings.d.ts +7 -2
  197. package/dist/core/timings.d.ts.map +1 -1
  198. package/dist/core/timings.js +11 -0
  199. package/dist/core/timings.js.map +1 -1
  200. package/dist/inspector-policy.d.ts +22 -0
  201. package/dist/inspector-policy.d.ts.map +1 -0
  202. package/dist/inspector-policy.js +84 -0
  203. package/dist/inspector-policy.js.map +1 -0
  204. package/dist/main.d.ts +6 -0
  205. package/dist/main.d.ts.map +1 -1
  206. package/dist/main.js +20 -23
  207. package/dist/main.js.map +1 -1
  208. package/dist/modes/app-server/runtime.d.ts.map +1 -1
  209. package/dist/modes/app-server/runtime.js +1 -0
  210. package/dist/modes/app-server/runtime.js.map +1 -1
  211. package/dist/modes/app-server/threads/goal-handlers.js +4 -2
  212. package/dist/modes/app-server/threads/goal-handlers.js.map +1 -1
  213. package/dist/modes/app-server/threads/goal-wire.d.ts.map +1 -1
  214. package/dist/modes/app-server/threads/goal-wire.js +1 -0
  215. package/dist/modes/app-server/threads/goal-wire.js.map +1 -1
  216. package/dist/modes/app-server/threads/handlers.d.ts +1 -0
  217. package/dist/modes/app-server/threads/handlers.d.ts.map +1 -1
  218. package/dist/modes/app-server/threads/handlers.js +2 -0
  219. package/dist/modes/app-server/threads/handlers.js.map +1 -1
  220. package/dist/modes/app-server/threads/turn-runtime.d.ts +1 -0
  221. package/dist/modes/app-server/threads/turn-runtime.d.ts.map +1 -1
  222. package/dist/modes/app-server/threads/turn-runtime.js.map +1 -1
  223. package/dist/modes/app-server/threads/turns.d.ts.map +1 -1
  224. package/dist/modes/app-server/threads/turns.js +47 -3
  225. package/dist/modes/app-server/threads/turns.js.map +1 -1
  226. package/dist/modes/interactive/components/status-indicator.d.ts +1 -0
  227. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  228. package/dist/modes/interactive/components/status-indicator.js +29 -4
  229. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  230. package/dist/modes/interactive/components/tool-execution.d.ts +5 -1
  231. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  232. package/dist/modes/interactive/components/tool-execution.js +43 -17
  233. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  234. package/dist/modes/interactive/grok/chrome-tokens.d.ts +22 -0
  235. package/dist/modes/interactive/grok/chrome-tokens.d.ts.map +1 -0
  236. package/dist/modes/interactive/grok/chrome-tokens.js +27 -0
  237. package/dist/modes/interactive/grok/chrome-tokens.js.map +1 -0
  238. package/dist/modes/interactive/grok/chrome.d.ts +51 -0
  239. package/dist/modes/interactive/grok/chrome.d.ts.map +1 -0
  240. package/dist/modes/interactive/grok/chrome.js +105 -0
  241. package/dist/modes/interactive/grok/chrome.js.map +1 -0
  242. package/dist/modes/interactive/grok/footer.d.ts +14 -0
  243. package/dist/modes/interactive/grok/footer.d.ts.map +1 -0
  244. package/dist/modes/interactive/grok/footer.js +27 -0
  245. package/dist/modes/interactive/grok/footer.js.map +1 -0
  246. package/dist/modes/interactive/grok/input-card.d.ts +9 -0
  247. package/dist/modes/interactive/grok/input-card.d.ts.map +1 -0
  248. package/dist/modes/interactive/grok/input-card.js +30 -0
  249. package/dist/modes/interactive/grok/input-card.js.map +1 -0
  250. package/dist/modes/interactive/grok/palette.d.ts +145 -0
  251. package/dist/modes/interactive/grok/palette.d.ts.map +1 -0
  252. package/dist/modes/interactive/grok/palette.js +92 -0
  253. package/dist/modes/interactive/grok/palette.js.map +1 -0
  254. package/dist/modes/interactive/grok/tool-row.d.ts +17 -0
  255. package/dist/modes/interactive/grok/tool-row.d.ts.map +1 -0
  256. package/dist/modes/interactive/grok/tool-row.js +26 -0
  257. package/dist/modes/interactive/grok/tool-row.js.map +1 -0
  258. package/dist/modes/interactive/grok/welcome-card.d.ts +10 -0
  259. package/dist/modes/interactive/grok/welcome-card.d.ts.map +1 -0
  260. package/dist/modes/interactive/grok/welcome-card.js +30 -0
  261. package/dist/modes/interactive/grok/welcome-card.js.map +1 -0
  262. package/dist/modes/interactive/interactive-mode.d.ts +5 -0
  263. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  264. package/dist/modes/interactive/interactive-mode.js +108 -52
  265. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  266. package/dist/modes/interactive/theme/grok-day.json +77 -0
  267. package/dist/modes/interactive/theme/grok-night.json +93 -0
  268. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  269. package/dist/modes/interactive/theme/theme.js +4 -0
  270. package/dist/modes/interactive/theme/theme.js.map +1 -1
  271. package/dist/modes/rpc/connection-handler.d.ts +3 -3
  272. package/dist/modes/rpc/connection-handler.js +6 -6
  273. package/dist/modes/rpc/connection-handler.js.map +1 -1
  274. package/dist/modes/rpc/custom-capability.d.ts +6 -7
  275. package/dist/modes/rpc/custom-capability.d.ts.map +1 -1
  276. package/dist/modes/rpc/custom-capability.js +6 -7
  277. package/dist/modes/rpc/custom-capability.js.map +1 -1
  278. package/dist/modes/rpc/rpc-mode.d.ts +2 -2
  279. package/dist/modes/rpc/rpc-mode.js +5 -5
  280. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  281. package/dist/senpi +2 -0
  282. package/docs/docs.json +4 -0
  283. package/docs/environment-variables.md +1 -0
  284. package/docs/grok-neo.md +77 -0
  285. package/docs/keybindings.md +0 -1
  286. package/docs/settings.md +3 -3
  287. package/docs/terminal-tools.md +6 -3
  288. package/docs/usage.md +1 -1
  289. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +35 -0
  290. package/node_modules/@code-yeongyu/senpi-codemode/README.md +39 -19
  291. package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
  292. package/node_modules/@code-yeongyu/senpi-codemode/src/bridge/http-server.ts +6 -1
  293. package/node_modules/@code-yeongyu/senpi-codemode/src/bridges/output-bridge.ts +0 -1
  294. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/eval-notifier.ts +40 -0
  295. package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +46 -66
  296. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/context-manager.ts +5 -2
  297. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/kernel-contract.ts +2 -0
  298. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/kernel.ts +19 -4
  299. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/prelude.py +7 -0
  300. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-kernel.ts +8 -5
  301. package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +23 -5
  302. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-manager.ts +322 -0
  303. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +253 -18
  304. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/interrupt-note.ts +58 -0
  305. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/render.ts +28 -6
  306. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/status-events.ts +20 -0
  307. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/types.ts +65 -22
  308. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  309. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +4 -41
  310. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  311. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +3 -0
  312. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
  313. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +2 -0
  314. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
  315. package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.d.ts +10 -0
  316. package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.d.ts.map +1 -0
  317. package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.js +38 -0
  318. package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.js.map +1 -0
  319. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +5 -0
  320. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
  321. package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
  322. package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  323. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  324. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +135 -16
  325. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  326. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +1 -1
  327. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
  328. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  329. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -4
  330. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
  331. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts.map +1 -1
  332. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +4 -3
  333. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js.map +1 -1
  334. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +2 -2
  335. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  336. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts +1 -0
  337. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
  338. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +67 -31
  339. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
  340. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +1 -1
  341. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  342. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  343. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  344. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
  345. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +10 -0
  346. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
  347. package/node_modules/@earendil-works/pi-ai/dist/utils/stop-details.d.ts +1 -1
  348. package/node_modules/@earendil-works/pi-ai/dist/utils/stop-details.d.ts.map +1 -1
  349. package/node_modules/@earendil-works/pi-ai/dist/utils/stop-details.js +7 -3
  350. package/node_modules/@earendil-works/pi-ai/dist/utils/stop-details.js.map +1 -1
  351. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-call-id.d.ts +9 -0
  352. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-call-id.d.ts.map +1 -0
  353. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-call-id.js +16 -0
  354. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-call-id.js.map +1 -0
  355. package/node_modules/@earendil-works/pi-ai/package.json +1 -1
  356. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  357. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +1 -0
  358. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +1 -1
  359. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +35 -3
  360. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +1 -1
  361. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +6 -0
  362. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
  363. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
  364. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +32 -0
  365. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts.map +1 -1
  366. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +15 -7
  367. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js.map +1 -1
  368. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +1 -1
  369. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  370. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
  371. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  372. package/package.json +8 -8
  373. package/dist/cli/neo/build-argv.d.ts +0 -19
  374. package/dist/cli/neo/build-argv.d.ts.map +0 -1
  375. package/dist/cli/neo/build-argv.js +0 -84
  376. package/dist/cli/neo/build-argv.js.map +0 -1
  377. package/dist/cli/neo/daemon-launch.d.ts +0 -25
  378. package/dist/cli/neo/daemon-launch.d.ts.map +0 -1
  379. package/dist/cli/neo/daemon-launch.js +0 -97
  380. package/dist/cli/neo/daemon-launch.js.map +0 -1
  381. package/dist/cli/neo/gate.d.ts +0 -15
  382. package/dist/cli/neo/gate.d.ts.map +0 -1
  383. package/dist/cli/neo/gate.js +0 -21
  384. package/dist/cli/neo/gate.js.map +0 -1
  385. package/dist/cli/neo/launch.d.ts +0 -24
  386. package/dist/cli/neo/launch.d.ts.map +0 -1
  387. package/dist/cli/neo/launch.js +0 -66
  388. package/dist/cli/neo/launch.js.map +0 -1
  389. package/dist/cli/neo/platform.d.ts +0 -38
  390. package/dist/cli/neo/platform.d.ts.map +0 -1
  391. package/dist/cli/neo/platform.js +0 -54
  392. package/dist/cli/neo/platform.js.map +0 -1
  393. package/dist/cli/neo/resolve-binary.d.ts +0 -39
  394. package/dist/cli/neo/resolve-binary.d.ts.map +0 -1
  395. package/dist/cli/neo/resolve-binary.js +0 -66
  396. package/dist/cli/neo/resolve-binary.js.map +0 -1
  397. package/dist/core/extensions/builtin/session-observer/index.d.ts +0 -5
  398. package/dist/core/extensions/builtin/session-observer/index.d.ts.map +0 -1
  399. package/dist/core/extensions/builtin/session-observer/index.js +0 -36
  400. package/dist/core/extensions/builtin/session-observer/index.js.map +0 -1
  401. package/dist/core/extensions/builtin/session-observer/loader.d.ts +0 -3
  402. package/dist/core/extensions/builtin/session-observer/loader.d.ts.map +0 -1
  403. package/dist/core/extensions/builtin/session-observer/loader.js +0 -20
  404. package/dist/core/extensions/builtin/session-observer/loader.js.map +0 -1
  405. package/dist/core/extensions/builtin/session-observer/overlay-format.d.ts +0 -7
  406. package/dist/core/extensions/builtin/session-observer/overlay-format.d.ts.map +0 -1
  407. package/dist/core/extensions/builtin/session-observer/overlay-format.js +0 -30
  408. package/dist/core/extensions/builtin/session-observer/overlay-format.js.map +0 -1
  409. package/dist/core/extensions/builtin/session-observer/overlay.d.ts +0 -51
  410. package/dist/core/extensions/builtin/session-observer/overlay.d.ts.map +0 -1
  411. package/dist/core/extensions/builtin/session-observer/overlay.js +0 -229
  412. package/dist/core/extensions/builtin/session-observer/overlay.js.map +0 -1
  413. package/dist/core/extensions/builtin/session-observer/scanner.d.ts +0 -10
  414. package/dist/core/extensions/builtin/session-observer/scanner.d.ts.map +0 -1
  415. package/dist/core/extensions/builtin/session-observer/scanner.js +0 -142
  416. package/dist/core/extensions/builtin/session-observer/scanner.js.map +0 -1
  417. package/dist/core/extensions/builtin/session-observer/text.d.ts +0 -7
  418. package/dist/core/extensions/builtin/session-observer/text.d.ts.map +0 -1
  419. package/dist/core/extensions/builtin/session-observer/text.js +0 -37
  420. package/dist/core/extensions/builtin/session-observer/text.js.map +0 -1
  421. package/dist/core/extensions/builtin/session-observer/transcript-entries.d.ts +0 -7
  422. package/dist/core/extensions/builtin/session-observer/transcript-entries.d.ts.map +0 -1
  423. package/dist/core/extensions/builtin/session-observer/transcript-entries.js +0 -71
  424. package/dist/core/extensions/builtin/session-observer/transcript-entries.js.map +0 -1
  425. package/dist/core/extensions/builtin/session-observer/transcript-format.d.ts +0 -11
  426. package/dist/core/extensions/builtin/session-observer/transcript-format.d.ts.map +0 -1
  427. package/dist/core/extensions/builtin/session-observer/transcript-format.js +0 -65
  428. package/dist/core/extensions/builtin/session-observer/transcript-format.js.map +0 -1
  429. package/dist/core/extensions/builtin/session-observer/transcript.d.ts +0 -4
  430. package/dist/core/extensions/builtin/session-observer/transcript.d.ts.map +0 -1
  431. package/dist/core/extensions/builtin/session-observer/transcript.js +0 -81
  432. package/dist/core/extensions/builtin/session-observer/transcript.js.map +0 -1
  433. package/dist/core/extensions/builtin/session-observer/types.d.ts +0 -33
  434. package/dist/core/extensions/builtin/session-observer/types.d.ts.map +0 -1
  435. package/dist/core/extensions/builtin/session-observer/types.js +0 -2
  436. package/dist/core/extensions/builtin/session-observer/types.js.map +0 -1
  437. package/dist/modes/rpc/neo-daemon-child-worker.d.ts +0 -29
  438. package/dist/modes/rpc/neo-daemon-child-worker.d.ts.map +0 -1
  439. package/dist/modes/rpc/neo-daemon-child-worker.js +0 -95
  440. package/dist/modes/rpc/neo-daemon-child-worker.js.map +0 -1
  441. package/dist/modes/rpc/neo-daemon-mode.d.ts +0 -110
  442. package/dist/modes/rpc/neo-daemon-mode.d.ts.map +0 -1
  443. package/dist/modes/rpc/neo-daemon-mode.js +0 -267
  444. package/dist/modes/rpc/neo-daemon-mode.js.map +0 -1
  445. package/dist/modes/rpc/neo-daemon-protocol.d.ts +0 -50
  446. package/dist/modes/rpc/neo-daemon-protocol.d.ts.map +0 -1
  447. package/dist/modes/rpc/neo-daemon-protocol.js +0 -66
  448. package/dist/modes/rpc/neo-daemon-protocol.js.map +0 -1
  449. package/dist/modes/rpc/neo-daemon-registry.d.ts +0 -98
  450. package/dist/modes/rpc/neo-daemon-registry.d.ts.map +0 -1
  451. package/dist/modes/rpc/neo-daemon-registry.js +0 -209
  452. package/dist/modes/rpc/neo-daemon-registry.js.map +0 -1
  453. package/dist/modes/rpc/neo-runtime-options-argv.d.ts +0 -17
  454. package/dist/modes/rpc/neo-runtime-options-argv.d.ts.map +0 -1
  455. package/dist/modes/rpc/neo-runtime-options-argv.js +0 -79
  456. package/dist/modes/rpc/neo-runtime-options-argv.js.map +0 -1
  457. package/dist/modes/rpc/neo-runtime-options.d.ts +0 -84
  458. package/dist/modes/rpc/neo-runtime-options.d.ts.map +0 -1
  459. package/dist/modes/rpc/neo-runtime-options.js +0 -92
  460. package/dist/modes/rpc/neo-runtime-options.js.map +0 -1
  461. package/docs/neo.md +0 -111
  462. package/node_modules/@code-yeongyu/senpi-codemode/src/codemode/runtime.ts +0 -258
  463. package/node_modules/@code-yeongyu/senpi-codemode/src/codemode/tools.ts +0 -106
@@ -1,4 +1,5 @@
1
1
  import type { TerminalManager } from "../manager.ts";
2
+ import type { MonitorEvent, MonitorRegistry } from "../monitor-registry.ts";
2
3
  import type { TerminalRuntimeSession } from "../runtime-session.ts";
3
4
  /** Shared dependencies handed to every terminal tool factory. */
4
5
  export interface TerminalToolContext {
@@ -17,6 +18,12 @@ export interface TerminalToolContext {
17
18
  readonly getSessionContext?: () => import("../../../types.ts").ExtensionContext | undefined;
18
19
  /** Notified when a background session exits, so the notify layer can wake the agent. */
19
20
  readonly onBackgroundExit?: (id: string, runtime: TerminalRuntimeSession) => void;
21
+ /** Session-scoped monitor state, sharing the terminal manager's bash-id namespace. */
22
+ readonly monitorRegistry?: MonitorRegistry;
23
+ /** Receives filtered monitor line and terminal-summary events. */
24
+ readonly onMonitorEvent?: (event: MonitorEvent) => void;
25
+ /** Resets session-global wake-budget delivery after a monitor was explicitly rearmed. */
26
+ readonly onMonitorRearmed?: (id: string) => void;
20
27
  }
21
28
  /** Minimal tool-result shape returned by the terminal tools. */
22
29
  export interface TerminalToolResult {
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/context.ts"],"names":[],"mappings":"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AC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,UAAU,CACzB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,kBAAkB,CAEpB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAE5D"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/context.ts"],"names":[],"mappings":"AA6BA,MAAM,UAAU,UAAU,CACzB,IAAY,EACZ,KAAgE;IAEhE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAChG,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACvC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACjF,CAAC","sourcesContent":["import type { TerminalManager } from \"../manager.ts\";\nimport type { TerminalRuntimeSession } from \"../runtime-session.ts\";\n\n/** Shared dependencies handed to every terminal tool factory. */\nexport interface TerminalToolContext {\n\treadonly manager: TerminalManager;\n\treadonly cwd: string;\n\t/** Explicit shell path from settings (settings-manager `shellPath`), if any. */\n\treadonly shellPath?: string;\n\treadonly defaultCols: number;\n\treadonly defaultRows: number;\n\t/** Resolve the environment for spawned sessions (mirrors core bash `getShellEnv`). */\n\treadonly getEnv: () => NodeJS.ProcessEnv;\n\t/**\n\t * Current extension session context (set on session_start/model_select), used to\n\t * expose PI_* session metadata to spawned commands like the core bash tool does.\n\t */\n\treadonly getSessionContext?: () => import(\"../../../types.ts\").ExtensionContext | undefined;\n\t/** Notified when a background session exits, so the notify layer can wake the agent. */\n\treadonly onBackgroundExit?: (id: string, runtime: TerminalRuntimeSession) => void;\n}\n\n/** Minimal tool-result shape returned by the terminal tools. */\nexport interface TerminalToolResult {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: Record<string, unknown> | undefined;\n\tisError?: boolean;\n}\n\nexport function textResult(\n\ttext: string,\n\textra?: { details?: Record<string, unknown>; isError?: boolean },\n): TerminalToolResult {\n\treturn { content: [{ type: \"text\", text }], details: extra?.details, isError: extra?.isError };\n}\n\nexport function errorResult(text: string): TerminalToolResult {\n\treturn { content: [{ type: \"text\", text }], details: undefined, isError: true };\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/context.ts"],"names":[],"mappings":"AAoCA,MAAM,UAAU,UAAU,CACzB,IAAY,EACZ,KAAgE;IAEhE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAChG,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACvC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACjF,CAAC","sourcesContent":["import type { TerminalManager } from \"../manager.ts\";\nimport type { MonitorEvent, MonitorRegistry } from \"../monitor-registry.ts\";\nimport type { TerminalRuntimeSession } from \"../runtime-session.ts\";\n\n/** Shared dependencies handed to every terminal tool factory. */\nexport interface TerminalToolContext {\n\treadonly manager: TerminalManager;\n\treadonly cwd: string;\n\t/** Explicit shell path from settings (settings-manager `shellPath`), if any. */\n\treadonly shellPath?: string;\n\treadonly defaultCols: number;\n\treadonly defaultRows: number;\n\t/** Resolve the environment for spawned sessions (mirrors core bash `getShellEnv`). */\n\treadonly getEnv: () => NodeJS.ProcessEnv;\n\t/**\n\t * Current extension session context (set on session_start/model_select), used to\n\t * expose PI_* session metadata to spawned commands like the core bash tool does.\n\t */\n\treadonly getSessionContext?: () => import(\"../../../types.ts\").ExtensionContext | undefined;\n\t/** Notified when a background session exits, so the notify layer can wake the agent. */\n\treadonly onBackgroundExit?: (id: string, runtime: TerminalRuntimeSession) => void;\n\t/** Session-scoped monitor state, sharing the terminal manager's bash-id namespace. */\n\treadonly monitorRegistry?: MonitorRegistry;\n\t/** Receives filtered monitor line and terminal-summary events. */\n\treadonly onMonitorEvent?: (event: MonitorEvent) => void;\n\t/** Resets session-global wake-budget delivery after a monitor was explicitly rearmed. */\n\treadonly onMonitorRearmed?: (id: string) => void;\n}\n\n/** Minimal tool-result shape returned by the terminal tools. */\nexport interface TerminalToolResult {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: Record<string, unknown> | undefined;\n\tisError?: boolean;\n}\n\nexport function textResult(\n\ttext: string,\n\textra?: { details?: Record<string, unknown>; isError?: boolean },\n): TerminalToolResult {\n\treturn { content: [{ type: \"text\", text }], details: extra?.details, isError: extra?.isError };\n}\n\nexport function errorResult(text: string): TerminalToolResult {\n\treturn { content: [{ type: \"text\", text }], details: undefined, isError: true };\n}\n"]}
@@ -0,0 +1,41 @@
1
+ import { type Static, Type } from "typebox";
2
+ import { type TerminalToolContext, type TerminalToolResult } from "./context.ts";
3
+ import { renderMonitorCall } from "./render.ts";
4
+ export declare const DEFAULT_MONITOR_TIMEOUT_MS = 300000;
5
+ export declare const MAX_MONITOR_TIMEOUT_MS = 3600000;
6
+ export declare const monitorSchema: Type.TUnion<[Type.TObject<{
7
+ action: Type.TOptional<Type.TLiteral<"create">>;
8
+ description: Type.TString;
9
+ command: Type.TString;
10
+ filter: Type.TOptional<Type.TString>;
11
+ timeout_ms: Type.TOptional<Type.TNumber>;
12
+ persistent: Type.TOptional<Type.TBoolean>;
13
+ }>, Type.TObject<{
14
+ action: Type.TLiteral<"rearm">;
15
+ bash_id: Type.TString;
16
+ }>]>;
17
+ export type MonitorInput = Static<typeof monitorSchema>;
18
+ /** Build the PTY-backed monitor tool. Monitor handles share TerminalManager's bash_N namespace. */
19
+ export declare function createMonitorTool(ctx: TerminalToolContext): {
20
+ name: string;
21
+ label: string;
22
+ description: string;
23
+ promptSnippet: string;
24
+ promptGuidelines: string[];
25
+ parameters: Type.TUnion<[Type.TObject<{
26
+ action: Type.TOptional<Type.TLiteral<"create">>;
27
+ description: Type.TString;
28
+ command: Type.TString;
29
+ filter: Type.TOptional<Type.TString>;
30
+ timeout_ms: Type.TOptional<Type.TNumber>;
31
+ persistent: Type.TOptional<Type.TBoolean>;
32
+ }>, Type.TObject<{
33
+ action: Type.TLiteral<"rearm">;
34
+ bash_id: Type.TString;
35
+ }>]>;
36
+ renderCall: typeof renderMonitorCall;
37
+ execute(_toolCallId: string, input: MonitorInput, _signal?: AbortSignal, _onUpdate?: undefined, execCtx?: {
38
+ cwd?: string;
39
+ }): Promise<TerminalToolResult>;
40
+ };
41
+ //# sourceMappingURL=monitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EAAe,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAc,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,eAAO,MAAM,0BAA0B,SAAU,CAAC;AAClD,eAAO,MAAM,sBAAsB,UAAY,CAAC;AA4BhD,eAAO,MAAM,aAAa;;;;;;;;;;IAAwD,CAAC;AACnF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AA2CxD,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;yBAoB1C,MAAM,SACZ,YAAY,YACT,WAAW,cACT,SAAS,YACX;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GACxB,OAAO,CAAC,kBAAkB,CAAC;EAY/B"}
@@ -0,0 +1,97 @@
1
+ import { Type } from "typebox";
2
+ import { MonitorRegistry } from "../monitor-registry.js";
3
+ import { DEFAULT_COLS, DEFAULT_ROWS, TERMINAL_MONITOR_TOOL } from "../shared.js";
4
+ import { errorResult, textResult } from "./context.js";
5
+ import { renderMonitorCall } from "./render.js";
6
+ import { spawnCommandSession } from "./spawn.js";
7
+ export const DEFAULT_MONITOR_TIMEOUT_MS = 300_000;
8
+ export const MAX_MONITOR_TIMEOUT_MS = 3_600_000;
9
+ const createMonitorSchema = Type.Object({
10
+ action: Type.Optional(Type.Literal("create")),
11
+ description: Type.String({
12
+ minLength: 1,
13
+ maxLength: 200,
14
+ description: "Short label for the watcher and its decision-relevant events.",
15
+ }),
16
+ command: Type.String({ description: "Shell command to run and watch in a PTY-backed monitor session." }),
17
+ filter: Type.Optional(Type.String({ description: "Only stdout lines matching this regex become monitor events." })),
18
+ timeout_ms: Type.Optional(Type.Number({
19
+ minimum: 1,
20
+ maximum: MAX_MONITOR_TIMEOUT_MS,
21
+ description: "Watcher deadline in milliseconds (default 300000; ignored by persistent monitors).",
22
+ })),
23
+ persistent: Type.Optional(Type.Boolean({ description: "Keep watching until the command exits or kill_bash stops its bash_id." })),
24
+ });
25
+ const rearmMonitorSchema = Type.Object({
26
+ action: Type.Literal("rearm"),
27
+ bash_id: Type.String({ description: "Paused monitor bash_id to resume after a wake-budget pause." }),
28
+ });
29
+ export const monitorSchema = Type.Union([createMonitorSchema, rearmMonitorSchema]);
30
+ function resolveDimension(value, fallback) {
31
+ if (value === undefined || !Number.isFinite(value) || value < 1)
32
+ return fallback;
33
+ return Math.trunc(value);
34
+ }
35
+ function resolveTimeoutMs(value) {
36
+ const timeout = value ?? DEFAULT_MONITOR_TIMEOUT_MS;
37
+ return Math.min(Math.max(Math.trunc(timeout), 1), MAX_MONITOR_TIMEOUT_MS);
38
+ }
39
+ function compileFilter(filter) {
40
+ if (filter === undefined)
41
+ return undefined;
42
+ return new RegExp(filter);
43
+ }
44
+ async function createMonitor(ctx, registry, input, execCtx) {
45
+ let filter;
46
+ try {
47
+ filter = compileFilter(input.filter);
48
+ }
49
+ catch {
50
+ return errorResult(`Invalid monitor filter regex: ${input.filter}`);
51
+ }
52
+ const { id, runtime } = await spawnCommandSession(ctx, {
53
+ command: input.command,
54
+ cols: resolveDimension(undefined, ctx.defaultCols || DEFAULT_COLS),
55
+ rows: resolveDimension(undefined, ctx.defaultRows || DEFAULT_ROWS),
56
+ cwd: execCtx?.cwd,
57
+ ...(input.persistent ? {} : { timeoutMs: resolveTimeoutMs(input.timeout_ms) }),
58
+ });
59
+ registry.register({ id, description: input.description, runtime, filter });
60
+ return textResult(`Monitor started with ID: ${id}`, { details: { bash_id: id, monitor: true } });
61
+ }
62
+ /** Build the PTY-backed monitor tool. Monitor handles share TerminalManager's bash_N namespace. */
63
+ export function createMonitorTool(ctx) {
64
+ let fallbackRegistry;
65
+ const getRegistry = () => {
66
+ const sessionRegistry = ctx.monitorRegistry;
67
+ if (sessionRegistry)
68
+ return sessionRegistry;
69
+ fallbackRegistry ??= new MonitorRegistry((event) => ctx.onMonitorEvent?.(event));
70
+ return fallbackRegistry;
71
+ };
72
+ return {
73
+ name: TERMINAL_MONITOR_TOOL,
74
+ label: "monitor",
75
+ description: "Watch a background shell command and emit decision-relevant stdout-line events. Returns a bash_id immediately; peek with bash_output or stop with kill_bash.",
76
+ promptSnippet: "Watch a long-running command; monitor emits matching stdout lines as events",
77
+ promptGuidelines: [
78
+ "Use monitor only for decision-relevant lines; filter noisy output at the source when possible.",
79
+ ],
80
+ parameters: monitorSchema,
81
+ renderCall: renderMonitorCall,
82
+ async execute(_toolCallId, input, _signal, _onUpdate, execCtx) {
83
+ const registry = getRegistry();
84
+ if (input.action === "rearm") {
85
+ const outcome = registry.rearm(input.bash_id);
86
+ if (outcome === "not_found")
87
+ return errorResult(`No active monitor found with id: ${input.bash_id}`);
88
+ if (outcome === "not_paused")
89
+ return textResult(`Monitor ${input.bash_id} is not paused; no action taken.`);
90
+ ctx.onMonitorRearmed?.(input.bash_id);
91
+ return textResult(`Monitor ${input.bash_id} re-armed.`);
92
+ }
93
+ return createMonitor(ctx, registry, input, execCtx);
94
+ },
95
+ };
96
+ }
97
+ //# sourceMappingURL=monitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,WAAW,EAAqD,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAClD,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEhD,MAAM,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC;IACvC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAA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AAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACtC,OAAO,UAAU,CAAC,WAAW,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;YACzD,CAAC;YACD,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport { MonitorRegistry } from \"../monitor-registry.ts\";\nimport { DEFAULT_COLS, DEFAULT_ROWS, TERMINAL_MONITOR_TOOL } from \"../shared.ts\";\nimport { errorResult, type TerminalToolContext, type TerminalToolResult, textResult } from \"./context.ts\";\nimport { renderMonitorCall } from \"./render.ts\";\nimport { spawnCommandSession } from \"./spawn.ts\";\n\nexport const DEFAULT_MONITOR_TIMEOUT_MS = 300_000;\nexport const MAX_MONITOR_TIMEOUT_MS = 3_600_000;\n\nconst createMonitorSchema = Type.Object({\n\taction: Type.Optional(Type.Literal(\"create\")),\n\tdescription: Type.String({\n\t\tminLength: 1,\n\t\tmaxLength: 200,\n\t\tdescription: \"Short label for the watcher and its decision-relevant events.\",\n\t}),\n\tcommand: Type.String({ description: \"Shell command to run and watch in a PTY-backed monitor session.\" }),\n\tfilter: Type.Optional(Type.String({ description: \"Only stdout lines matching this regex become monitor events.\" })),\n\ttimeout_ms: Type.Optional(\n\t\tType.Number({\n\t\t\tminimum: 1,\n\t\t\tmaximum: MAX_MONITOR_TIMEOUT_MS,\n\t\t\tdescription: \"Watcher deadline in milliseconds (default 300000; ignored by persistent monitors).\",\n\t\t}),\n\t),\n\tpersistent: Type.Optional(\n\t\tType.Boolean({ description: \"Keep watching until the command exits or kill_bash stops its bash_id.\" }),\n\t),\n});\n\nconst rearmMonitorSchema = Type.Object({\n\taction: Type.Literal(\"rearm\"),\n\tbash_id: Type.String({ description: \"Paused monitor bash_id to resume after a wake-budget pause.\" }),\n});\n\nexport const monitorSchema = Type.Union([createMonitorSchema, rearmMonitorSchema]);\nexport type MonitorInput = Static<typeof monitorSchema>;\n\ntype MonitorCreateInput = Static<typeof createMonitorSchema>;\n\nfunction resolveDimension(value: number | undefined, fallback: number): number {\n\tif (value === undefined || !Number.isFinite(value) || value < 1) return fallback;\n\treturn Math.trunc(value);\n}\n\nfunction resolveTimeoutMs(value: number | undefined): number {\n\tconst timeout = value ?? DEFAULT_MONITOR_TIMEOUT_MS;\n\treturn Math.min(Math.max(Math.trunc(timeout), 1), MAX_MONITOR_TIMEOUT_MS);\n}\n\nfunction compileFilter(filter: string | undefined): RegExp | undefined {\n\tif (filter === undefined) return undefined;\n\treturn new RegExp(filter);\n}\n\nasync function createMonitor(\n\tctx: TerminalToolContext,\n\tregistry: MonitorRegistry,\n\tinput: MonitorCreateInput,\n\texecCtx: { cwd?: string } | undefined,\n): Promise<TerminalToolResult> {\n\tlet filter: RegExp | undefined;\n\ttry {\n\t\tfilter = compileFilter(input.filter);\n\t} catch {\n\t\treturn errorResult(`Invalid monitor filter regex: ${input.filter}`);\n\t}\n\n\tconst { id, runtime } = await spawnCommandSession(ctx, {\n\t\tcommand: input.command,\n\t\tcols: resolveDimension(undefined, ctx.defaultCols || DEFAULT_COLS),\n\t\trows: resolveDimension(undefined, ctx.defaultRows || DEFAULT_ROWS),\n\t\tcwd: execCtx?.cwd,\n\t\t...(input.persistent ? {} : { timeoutMs: resolveTimeoutMs(input.timeout_ms) }),\n\t});\n\tregistry.register({ id, description: input.description, runtime, filter });\n\treturn textResult(`Monitor started with ID: ${id}`, { details: { bash_id: id, monitor: true } });\n}\n\n/** Build the PTY-backed monitor tool. Monitor handles share TerminalManager's bash_N namespace. */\nexport function createMonitorTool(ctx: TerminalToolContext) {\n\tlet fallbackRegistry: MonitorRegistry | undefined;\n\tconst getRegistry = (): MonitorRegistry => {\n\t\tconst sessionRegistry = ctx.monitorRegistry;\n\t\tif (sessionRegistry) return sessionRegistry;\n\t\tfallbackRegistry ??= new MonitorRegistry((event) => ctx.onMonitorEvent?.(event));\n\t\treturn fallbackRegistry;\n\t};\n\treturn {\n\t\tname: TERMINAL_MONITOR_TOOL,\n\t\tlabel: \"monitor\",\n\t\tdescription:\n\t\t\t\"Watch a background shell command and emit decision-relevant stdout-line events. Returns a bash_id immediately; peek with bash_output or stop with kill_bash.\",\n\t\tpromptSnippet: \"Watch a long-running command; monitor emits matching stdout lines as events\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use monitor only for decision-relevant lines; filter noisy output at the source when possible.\",\n\t\t],\n\t\tparameters: monitorSchema,\n\t\trenderCall: renderMonitorCall,\n\t\tasync execute(\n\t\t\t_toolCallId: string,\n\t\t\tinput: MonitorInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\t_onUpdate?: undefined,\n\t\t\texecCtx?: { cwd?: string },\n\t\t): Promise<TerminalToolResult> {\n\t\t\tconst registry = getRegistry();\n\t\t\tif (input.action === \"rearm\") {\n\t\t\t\tconst outcome = registry.rearm(input.bash_id);\n\t\t\t\tif (outcome === \"not_found\") return errorResult(`No active monitor found with id: ${input.bash_id}`);\n\t\t\t\tif (outcome === \"not_paused\") return textResult(`Monitor ${input.bash_id} is not paused; no action taken.`);\n\t\t\t\tctx.onMonitorRearmed?.(input.bash_id);\n\t\t\t\treturn textResult(`Monitor ${input.bash_id} re-armed.`);\n\t\t\t}\n\t\t\treturn createMonitor(ctx, registry, input, execCtx);\n\t\t},\n\t};\n}\n"]}
@@ -1,8 +1,10 @@
1
1
  import { Text } from "@earendil-works/pi-tui";
2
2
  import type { AgentToolResult, ToolDefinition } from "../../../types.ts";
3
3
  import type { BashOutputInput, bashOutputSchema } from "./bash-output.ts";
4
+ import type { MonitorInput, monitorSchema } from "./monitor.ts";
4
5
  type BashOutputDetails = Record<string, unknown> | undefined;
5
6
  type BashOutputToolDefinition = ToolDefinition<typeof bashOutputSchema, BashOutputDetails>;
7
+ type MonitorToolDefinition = ToolDefinition<typeof monitorSchema, BashOutputDetails>;
6
8
  type RenderResultOptions = Parameters<NonNullable<BashOutputToolDefinition["renderResult"]>>[1];
7
9
  declare class BashOutputResultComponent {
8
10
  #private;
@@ -11,6 +13,7 @@ declare class BashOutputResultComponent {
11
13
  invalidate(): void;
12
14
  }
13
15
  export declare function renderBashOutputCall(args: BashOutputInput, theme: Parameters<NonNullable<BashOutputToolDefinition["renderCall"]>>[1]): Text;
16
+ export declare function renderMonitorCall(args: MonitorInput, theme: Parameters<NonNullable<MonitorToolDefinition["renderCall"]>>[1]): Text;
14
17
  export declare function renderBashOutputResult(result: AgentToolResult<BashOutputDetails>, options: RenderResultOptions, _theme: Parameters<NonNullable<BashOutputToolDefinition["renderResult"]>>[2], context: Parameters<NonNullable<BashOutputToolDefinition["renderResult"]>>[3]): BashOutputResultComponent;
15
18
  export {};
16
19
  //# sourceMappingURL=render.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE1E,KAAK,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;AAC7D,KAAK,wBAAwB,GAAG,cAAc,CAAC,OAAO,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;AAC3F,KAAK,mBAAmB,GAAG,UAAU,CAAC,WAAW,CAAC,wBAAwB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAIhG,cAAM,yBAAyB;;IAK9B,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAKxF;IAED,MAAM,CAAC,KAAK,EAAE,M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CAAC,CAAC,CAAC;AAIhG,cAAM,yBAAyB;;IAK9B,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAKxF;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAK9B;IAED,UAAU,IAAI,IAAI,CAAG;CACrB;AAED,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,eAAe,EACrB,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,wBAAwB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACvE,IAAI,CAEN;AAED,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACpE,IAAI,CAGN;AAED,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,eAAe,CAAC,iBAAiB,CAAC,EAC1C,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,wBAAwB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC5E,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,wBAAwB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAC3E,yBAAyB,CAK3B"}
@@ -19,8 +19,11 @@ class BashOutputResultComponent {
19
19
  invalidate() { }
20
20
  }
21
21
  export function renderBashOutputCall(args, theme) {
22
- const waitFor = args.wait_for ? ` wait_for:/${args.wait_for}/` : "";
23
- return new Text(theme.fg("toolTitle", theme.bold(`bash_output ${args.bash_id}${waitFor}`)), 0, 0);
22
+ return new Text(theme.fg("toolTitle", theme.bold(`bash_output ${args.bash_id}`)), 0, 0);
23
+ }
24
+ export function renderMonitorCall(args, theme) {
25
+ const label = args.action === "rearm" ? `monitor rearm ${args.bash_id}` : `monitor ${args.description}`;
26
+ return new Text(theme.fg("toolTitle", theme.bold(label)), 0, 0);
24
27
  }
25
28
  export function renderBashOutputResult(result, options, _theme, context) {
26
29
  const component = context.lastComponent ?? new BashOutputResultComponent();
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gEAAgE,CAAC;AAQvG,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAE/B,MAAM,yBAAyB;IAC9B,KAAK,GAAG,EAAE,CAAC;IACX,UAAU,GAAG,KAAK,CAAC;IACnB,SAAS,GAAG,KAAK,CAAC;IAElB,SAAS,CAAC,MAA0C,EAAE,OAA4B;QACjF,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;QACxE,IAAI,CAAC,KAAK,GAAG,KAAK,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,KAAa;QACnB,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtE,OAAO,qBAAqB,CAAC,IAAI,CAAC,KAAK,EAAE,oBAAoB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAC3G,IAAI,CAAC,OAAO,EAAE,CACd,CAAC;IACH,CAAC;IAED,UAAU,KAAU,CAAC;CACrB;AAED,MAAM,UAAU,oBAAoB,CACnC,IAAqB,EACrB,KAAyE;IAEzE,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACpE,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACnG,CAAC;AAED,MAAM,UAAU,sBAAsB,CACrC,MAA0C,EAC1C,OAA4B,EAC5B,MAA4E,EAC5E,OAA6E;IAE7E,MAAM,SAAS,GACb,OAAO,CAAC,aAAuD,IAAI,IAAI,yBAAyB,EAAE,CAAC;IACrG,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { Text } from \"@earendil-works/pi-tui\";\nimport { truncateToVisualLines } from \"../../../../../modes/interactive/components/visual-truncate.ts\";\nimport type { AgentToolResult, ToolDefinition } from \"../../../types.ts\";\nimport type { BashOutputInput, bashOutputSchema } from \"./bash-output.ts\";\n\ntype BashOutputDetails = Record<string, unknown> | undefined;\ntype BashOutputToolDefinition = ToolDefinition<typeof bashOutputSchema, BashOutputDetails>;\ntype RenderResultOptions = Parameters<NonNullable<BashOutputToolDefinition[\"renderResult\"]>>[1];\n\nconst OUTPUT_PREVIEW_LINES = 8;\n\nclass BashOutputResultComponent {\n\t#text = \"\";\n\t#isPartial = false;\n\t#expanded = false;\n\n\tsetResult(result: AgentToolResult<BashOutputDetails>, options: RenderResultOptions): void {\n\t\tconst block = result.content.find((content) => content.type === \"text\");\n\t\tthis.#text = block?.type === \"text\" ? block.text : \"\";\n\t\tthis.#isPartial = options.isPartial;\n\t\tthis.#expanded = options.expanded;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (!this.#isPartial || this.#expanded) return this.#text.split(\"\\n\");\n\t\treturn truncateToVisualLines(this.#text, OUTPUT_PREVIEW_LINES, Math.max(1, width)).visualLines.map((line) =>\n\t\t\tline.trimEnd(),\n\t\t);\n\t}\n\n\tinvalidate(): void {}\n}\n\nexport function renderBashOutputCall(\n\targs: BashOutputInput,\n\ttheme: Parameters<NonNullable<BashOutputToolDefinition[\"renderCall\"]>>[1],\n): Text {\n\tconst waitFor = args.wait_for ? ` wait_for:/${args.wait_for}/` : \"\";\n\treturn new Text(theme.fg(\"toolTitle\", theme.bold(`bash_output ${args.bash_id}${waitFor}`)), 0, 0);\n}\n\nexport function renderBashOutputResult(\n\tresult: AgentToolResult<BashOutputDetails>,\n\toptions: RenderResultOptions,\n\t_theme: Parameters<NonNullable<BashOutputToolDefinition[\"renderResult\"]>>[2],\n\tcontext: Parameters<NonNullable<BashOutputToolDefinition[\"renderResult\"]>>[3],\n): BashOutputResultComponent {\n\tconst component =\n\t\t(context.lastComponent as BashOutputResultComponent | undefined) ?? new BashOutputResultComponent();\n\tcomponent.setResult(result, options);\n\treturn component;\n}\n"]}
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gEAAgE,CAAC;AAUvG,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAE/B,MAAM,yBAAyB;IAC9B,KAAK,GAAG,EAAE,CAAC;IACX,UAAU,GAAG,KAAK,CAAC;IACnB,SAAS,GAAG,KAAK,CAAC;IAElB,SAAS,CAAC,MAA0C,EAAE,OAA4B;QACjF,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAA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EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,sBAAsB,CACrC,MAA0C,EAC1C,OAA4B,EAC5B,MAA4E,EAC5E,OAA6E;IAE7E,MAAM,SAAS,GACb,OAAO,CAAC,aAAuD,IAAI,IAAI,yBAAyB,EAAE,CAAC;IACrG,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { Text } from \"@earendil-works/pi-tui\";\nimport { truncateToVisualLines } from \"../../../../../modes/interactive/components/visual-truncate.ts\";\nimport type { AgentToolResult, ToolDefinition } from \"../../../types.ts\";\nimport type { BashOutputInput, bashOutputSchema } from \"./bash-output.ts\";\nimport type { MonitorInput, monitorSchema } from \"./monitor.ts\";\n\ntype BashOutputDetails = Record<string, unknown> | undefined;\ntype BashOutputToolDefinition = ToolDefinition<typeof bashOutputSchema, BashOutputDetails>;\ntype MonitorToolDefinition = ToolDefinition<typeof monitorSchema, BashOutputDetails>;\ntype RenderResultOptions = Parameters<NonNullable<BashOutputToolDefinition[\"renderResult\"]>>[1];\n\nconst OUTPUT_PREVIEW_LINES = 8;\n\nclass BashOutputResultComponent {\n\t#text = \"\";\n\t#isPartial = false;\n\t#expanded = false;\n\n\tsetResult(result: AgentToolResult<BashOutputDetails>, options: RenderResultOptions): void {\n\t\tconst block = result.content.find((content) => content.type === \"text\");\n\t\tthis.#text = block?.type === \"text\" ? block.text : \"\";\n\t\tthis.#isPartial = options.isPartial;\n\t\tthis.#expanded = options.expanded;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (!this.#isPartial || this.#expanded) return this.#text.split(\"\\n\");\n\t\treturn truncateToVisualLines(this.#text, OUTPUT_PREVIEW_LINES, Math.max(1, width)).visualLines.map((line) =>\n\t\t\tline.trimEnd(),\n\t\t);\n\t}\n\n\tinvalidate(): void {}\n}\n\nexport function renderBashOutputCall(\n\targs: BashOutputInput,\n\ttheme: Parameters<NonNullable<BashOutputToolDefinition[\"renderCall\"]>>[1],\n): Text {\n\treturn new Text(theme.fg(\"toolTitle\", theme.bold(`bash_output ${args.bash_id}`)), 0, 0);\n}\n\nexport function renderMonitorCall(\n\targs: MonitorInput,\n\ttheme: Parameters<NonNullable<MonitorToolDefinition[\"renderCall\"]>>[1],\n): Text {\n\tconst label = args.action === \"rearm\" ? `monitor rearm ${args.bash_id}` : `monitor ${args.description}`;\n\treturn new Text(theme.fg(\"toolTitle\", theme.bold(label)), 0, 0);\n}\n\nexport function renderBashOutputResult(\n\tresult: AgentToolResult<BashOutputDetails>,\n\toptions: RenderResultOptions,\n\t_theme: Parameters<NonNullable<BashOutputToolDefinition[\"renderResult\"]>>[2],\n\tcontext: Parameters<NonNullable<BashOutputToolDefinition[\"renderResult\"]>>[3],\n): BashOutputResultComponent {\n\tconst component =\n\t\t(context.lastComponent as BashOutputResultComponent | undefined) ?? new BashOutputResultComponent();\n\tcomponent.setResult(result, options);\n\treturn component;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import { type TodoItem, type TodoPhase } from "./state.ts";
2
+ type TaskHit = {
3
+ task: TodoItem;
4
+ phase: TodoPhase;
5
+ };
6
+ export type FuzzyTaskResolution = {
7
+ hit?: TaskHit;
8
+ corrected: boolean;
9
+ suggestion?: string;
10
+ };
11
+ export type FuzzyPhaseResolution = {
12
+ hit?: TodoPhase;
13
+ corrected: boolean;
14
+ suggestion?: string;
15
+ };
16
+ export declare function fuzzyResolveTask(phases: readonly TodoPhase[], query: string): FuzzyTaskResolution;
17
+ export declare function fuzzyResolvePhase(phases: readonly TodoPhase[], name: string): FuzzyPhaseResolution;
18
+ export {};
19
+ //# sourceMappingURL=fuzzy-match.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fuzzy-match.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/fuzzy-match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE7E,KAAK,OAAO,GAAG;IACd,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IACjC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAClC,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAmDF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,mBAAmB,CAWjG;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,oBAAoB,CAUlG"}
@@ -0,0 +1,70 @@
1
+ import { sanitizeTodoText } from "./state.js";
2
+ function normalized(text) {
3
+ return sanitizeTodoText(text).toLowerCase();
4
+ }
5
+ function diceCoefficient(left, right) {
6
+ if (left === right)
7
+ return 1;
8
+ if (left.length < 2 || right.length < 2)
9
+ return 0;
10
+ const pairs = new Map();
11
+ for (let index = 0; index < left.length - 1; index += 1) {
12
+ const pair = left.slice(index, index + 2);
13
+ pairs.set(pair, (pairs.get(pair) ?? 0) + 1);
14
+ }
15
+ let overlap = 0;
16
+ for (let index = 0; index < right.length - 1; index += 1) {
17
+ const pair = right.slice(index, index + 2);
18
+ const count = pairs.get(pair) ?? 0;
19
+ if (count > 0) {
20
+ overlap += 1;
21
+ pairs.set(pair, count - 1);
22
+ }
23
+ }
24
+ return (2 * overlap) / (left.length + right.length - 2);
25
+ }
26
+ function suggestionFor(candidates, query, contentOf) {
27
+ const normalizedQuery = normalized(query);
28
+ if (!normalizedQuery)
29
+ return undefined;
30
+ let suggestion;
31
+ let bestScore = 0;
32
+ for (const candidate of candidates) {
33
+ const content = contentOf(candidate);
34
+ const normalizedContent = normalized(content);
35
+ if (!normalizedContent)
36
+ continue;
37
+ const score = normalizedContent.includes(normalizedQuery) || normalizedQuery.includes(normalizedContent)
38
+ ? 1
39
+ : diceCoefficient(normalizedContent, normalizedQuery);
40
+ if (score >= 0.5 && score > bestScore) {
41
+ bestScore = score;
42
+ suggestion = content;
43
+ }
44
+ }
45
+ return suggestion;
46
+ }
47
+ export function fuzzyResolveTask(phases, query) {
48
+ const candidates = phases.flatMap((phase) => phase.tasks.map((task) => ({ task, phase })));
49
+ const exactMatches = candidates.filter(({ task }) => task.content === query);
50
+ if (exactMatches.length === 1)
51
+ return { hit: exactMatches[0], corrected: false };
52
+ const normalizedQuery = normalized(query);
53
+ const normalizedMatches = candidates.filter(({ task }) => normalized(task.content) === normalizedQuery);
54
+ if (normalizedMatches.length === 1)
55
+ return { hit: normalizedMatches[0], corrected: true };
56
+ const suggestion = suggestionFor(candidates, query, ({ task }) => task.content);
57
+ return suggestion ? { corrected: false, suggestion } : { corrected: false };
58
+ }
59
+ export function fuzzyResolvePhase(phases, name) {
60
+ const exactMatches = phases.filter((phase) => phase.name === name);
61
+ if (exactMatches.length === 1)
62
+ return { hit: exactMatches[0], corrected: false };
63
+ const normalizedName = normalized(name);
64
+ const normalizedMatches = phases.filter((phase) => normalized(phase.name) === normalizedName);
65
+ if (normalizedMatches.length === 1)
66
+ return { hit: normalizedMatches[0], corrected: true };
67
+ const suggestion = suggestionFor(phases, name, (phase) => phase.name);
68
+ return suggestion ? { corrected: false, suggestion } : { corrected: false };
69
+ }
70
+ //# sourceMappingURL=fuzzy-match.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fuzzy-match.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/fuzzy-match.ts"],"names":[],"mappings":"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AAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,cAAc,CAAC,CAAC;IAC9F,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAE1F,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtE,OAAO,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAC7E,CAAC","sourcesContent":["import { sanitizeTodoText, type TodoItem, type TodoPhase } from \"./state.ts\";\n\ntype TaskHit = {\n\ttask: TodoItem;\n\tphase: TodoPhase;\n};\n\nexport type FuzzyTaskResolution = {\n\thit?: TaskHit;\n\tcorrected: boolean;\n\tsuggestion?: string;\n};\n\nexport type FuzzyPhaseResolution = {\n\thit?: TodoPhase;\n\tcorrected: boolean;\n\tsuggestion?: string;\n};\n\nfunction normalized(text: string): string {\n\treturn sanitizeTodoText(text).toLowerCase();\n}\n\nfunction diceCoefficient(left: string, right: string): number {\n\tif (left === right) return 1;\n\tif (left.length < 2 || right.length < 2) return 0;\n\tconst pairs = new Map<string, number>();\n\tfor (let index = 0; index < left.length - 1; index += 1) {\n\t\tconst pair = left.slice(index, index + 2);\n\t\tpairs.set(pair, (pairs.get(pair) ?? 0) + 1);\n\t}\n\tlet overlap = 0;\n\tfor (let index = 0; index < right.length - 1; index += 1) {\n\t\tconst pair = right.slice(index, index + 2);\n\t\tconst count = pairs.get(pair) ?? 0;\n\t\tif (count > 0) {\n\t\t\toverlap += 1;\n\t\t\tpairs.set(pair, count - 1);\n\t\t}\n\t}\n\treturn (2 * overlap) / (left.length + right.length - 2);\n}\n\nfunction suggestionFor<T>(\n\tcandidates: readonly T[],\n\tquery: string,\n\tcontentOf: (candidate: T) => string,\n): string | undefined {\n\tconst normalizedQuery = normalized(query);\n\tif (!normalizedQuery) return undefined;\n\tlet suggestion: string | undefined;\n\tlet bestScore = 0;\n\tfor (const candidate of candidates) {\n\t\tconst content = contentOf(candidate);\n\t\tconst normalizedContent = normalized(content);\n\t\tif (!normalizedContent) continue;\n\t\tconst score =\n\t\t\tnormalizedContent.includes(normalizedQuery) || normalizedQuery.includes(normalizedContent)\n\t\t\t\t? 1\n\t\t\t\t: diceCoefficient(normalizedContent, normalizedQuery);\n\t\tif (score >= 0.5 && score > bestScore) {\n\t\t\tbestScore = score;\n\t\t\tsuggestion = content;\n\t\t}\n\t}\n\treturn suggestion;\n}\n\nexport function fuzzyResolveTask(phases: readonly TodoPhase[], query: string): FuzzyTaskResolution {\n\tconst candidates = phases.flatMap((phase) => phase.tasks.map((task) => ({ task, phase })));\n\tconst exactMatches = candidates.filter(({ task }) => task.content === query);\n\tif (exactMatches.length === 1) return { hit: exactMatches[0], corrected: false };\n\n\tconst normalizedQuery = normalized(query);\n\tconst normalizedMatches = candidates.filter(({ task }) => normalized(task.content) === normalizedQuery);\n\tif (normalizedMatches.length === 1) return { hit: normalizedMatches[0], corrected: true };\n\n\tconst suggestion = suggestionFor(candidates, query, ({ task }) => task.content);\n\treturn suggestion ? { corrected: false, suggestion } : { corrected: false };\n}\n\nexport function fuzzyResolvePhase(phases: readonly TodoPhase[], name: string): FuzzyPhaseResolution {\n\tconst exactMatches = phases.filter((phase) => phase.name === name);\n\tif (exactMatches.length === 1) return { hit: exactMatches[0], corrected: false };\n\n\tconst normalizedName = normalized(name);\n\tconst normalizedMatches = phases.filter((phase) => normalized(phase.name) === normalizedName);\n\tif (normalizedMatches.length === 1) return { hit: normalizedMatches[0], corrected: true };\n\n\tconst suggestion = suggestionFor(phases, name, (phase) => phase.name);\n\treturn suggestion ? { corrected: false, suggestion } : { corrected: false };\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { TodoOpEntry, TodoPhase } from "./state.ts";
2
+ export type TodoNormalization = {
3
+ entry?: TodoOpEntry;
4
+ corrections: string[];
5
+ error?: string;
6
+ };
7
+ export declare function normalizeTodoParams(raw: Record<string, unknown>, currentPhases: readonly TodoPhase[]): TodoNormalization;
8
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAiB,SAAS,EAAE,MAAM,YAAY,CAAC;AAExE,MAAM,MAAM,iBAAiB,GAAG;IAC/B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AA6EF,wBAAgB,mBAAmB,CAClC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,aAAa,EAAE,SAAS,SAAS,EAAE,GACjC,iBAAiB,CAsGnB"}
@@ -0,0 +1,174 @@
1
+ const CONFLICTING_SHAPES = 'conflicting shapes. Use {"op":"init","list":[...]} to replace the list or {"op":"append","phase":"<active phase>","items":[...]} to add tasks.';
2
+ function isRecord(value) {
3
+ return typeof value === "object" && value !== null;
4
+ }
5
+ function isOperation(value) {
6
+ switch (value) {
7
+ case "init":
8
+ case "start":
9
+ case "done":
10
+ case "rm":
11
+ case "drop":
12
+ case "append":
13
+ case "view":
14
+ return true;
15
+ default:
16
+ return false;
17
+ }
18
+ }
19
+ function strings(value) {
20
+ if (!Array.isArray(value))
21
+ return undefined;
22
+ const parsed = [];
23
+ for (const item of value) {
24
+ if (typeof item !== "string")
25
+ return undefined;
26
+ parsed.push(item);
27
+ }
28
+ return parsed;
29
+ }
30
+ function list(value) {
31
+ if (!Array.isArray(value))
32
+ return undefined;
33
+ const parsed = [];
34
+ for (const item of value) {
35
+ if (!isRecord(item) || typeof item.phase !== "string")
36
+ return undefined;
37
+ const items = strings(item.items);
38
+ if (!items)
39
+ return undefined;
40
+ parsed.push({ phase: item.phase, items });
41
+ }
42
+ return parsed;
43
+ }
44
+ function nonBlank(value) {
45
+ return typeof value === "string" && value.trim() !== "" ? value : undefined;
46
+ }
47
+ function isBlank(value) {
48
+ return typeof value === "string" && value.trim() === "";
49
+ }
50
+ function error(message) {
51
+ return { corrections: [], error: message };
52
+ }
53
+ function aliasCorrection(alias, inferred) {
54
+ const form = alias === "init" ? '{"op":"init","items":[...]}' : '{"op":"append","phase":"<active phase>","items":[...]}';
55
+ if (inferred) {
56
+ return `[auto-corrected] "op" was missing; interpreted as "${alias}" because "${alias}" was provided as an items alias. Always pass op explicitly: ${form}`;
57
+ }
58
+ return `[auto-corrected] "${alias}" was used as an items alias and folded into "items". Use: ${form}`;
59
+ }
60
+ function inferredCorrection(op, reason, form) {
61
+ return `[auto-corrected] "op" was missing; interpreted as "${op}" because ${reason}. Always pass op explicitly: ${form}`;
62
+ }
63
+ function hasTasks(phases) {
64
+ return phases.some((phase) => phase.tasks.length > 0);
65
+ }
66
+ export function normalizeTodoParams(raw, currentPhases) {
67
+ const rawOp = raw.op;
68
+ if (rawOp === "view")
69
+ return { entry: { op: "view" }, corrections: [] };
70
+ if (rawOp !== undefined && !isOperation(rawOp))
71
+ return error('Invalid "op".');
72
+ const op = isOperation(rawOp) ? rawOp : undefined;
73
+ const task = nonBlank(raw.task);
74
+ const phase = nonBlank(raw.phase);
75
+ if (op === "start" || op === "done" || op === "drop" || op === "rm") {
76
+ if (isBlank(raw.task) && !phase) {
77
+ return error('Blank "task" — pass the exact task text, or omit the field entirely for a bulk operation.');
78
+ }
79
+ if (isBlank(raw.phase) && !task) {
80
+ return error('Blank "phase" — pass the exact phase text, or omit the field entirely for a bulk operation.');
81
+ }
82
+ }
83
+ const rawItems = strings(raw.items);
84
+ const aliases = [];
85
+ for (const name of ["init", "append"]) {
86
+ const items = strings(raw[name]);
87
+ if (items && items.length > 0)
88
+ aliases.push({ name, items });
89
+ }
90
+ if (aliases.length > 1)
91
+ return error(CONFLICTING_SHAPES);
92
+ if (aliases.length === 1 && rawItems && rawItems.length > 0)
93
+ return error(CONFLICTING_SHAPES);
94
+ const alias = aliases[0];
95
+ let effectiveItems = rawItems && rawItems.length > 0 ? rawItems : undefined;
96
+ let candidate;
97
+ const corrections = [];
98
+ if (alias) {
99
+ if (op && op !== alias.name)
100
+ return error(CONFLICTING_SHAPES);
101
+ effectiveItems = alias.items;
102
+ candidate = op ? undefined : alias.name;
103
+ corrections.push(aliasCorrection(alias.name, !op));
104
+ }
105
+ const effectiveList = list(raw.list);
106
+ const hasList = Boolean(effectiveList && effectiveList.length > 0);
107
+ const hasItems = Boolean(effectiveItems && effectiveItems.length > 0);
108
+ if (hasList && hasItems)
109
+ return error(CONFLICTING_SHAPES);
110
+ let effectiveOp = op;
111
+ if (!effectiveOp) {
112
+ if (candidate) {
113
+ effectiveOp = candidate;
114
+ }
115
+ else if (hasList) {
116
+ effectiveOp = "init";
117
+ corrections.push(inferredCorrection("init", '"list" was provided', '{"op":"init","list":[...]}'));
118
+ }
119
+ else if (hasItems && phase) {
120
+ effectiveOp = "append";
121
+ corrections.push(inferredCorrection("append", '"items" and "phase" were provided', '{"op":"append","phase":"<active phase>","items":[...]}'));
122
+ }
123
+ else if (hasItems && !hasTasks(currentPhases)) {
124
+ effectiveOp = "init";
125
+ corrections.push(inferredCorrection("init", '"items" was provided to an empty todo list', '{"op":"init","items":[...]}'));
126
+ }
127
+ else if (hasItems) {
128
+ return error('Missing "op": use {"op":"init","list":[...]} to replace the list, or {"op":"append","phase":"<active phase>","items":[...]} to add tasks.');
129
+ }
130
+ else {
131
+ return error('Missing "op". Example: {"op":"init","list":[{"phase":"Setup","items":["..."]}]}');
132
+ }
133
+ }
134
+ switch (effectiveOp) {
135
+ case "init": {
136
+ if (task || (effectiveList && effectiveList.length === 0 && hasItems))
137
+ return error(CONFLICTING_SHAPES);
138
+ const entry = { op: "init" };
139
+ if (effectiveList)
140
+ entry.list = effectiveList;
141
+ if (effectiveItems)
142
+ entry.items = effectiveItems;
143
+ if (phase)
144
+ entry.phase = phase;
145
+ return { entry, corrections };
146
+ }
147
+ case "start":
148
+ if (phase || hasList || hasItems)
149
+ return error(CONFLICTING_SHAPES);
150
+ return { entry: task ? { op: "start", task } : { op: "start" }, corrections };
151
+ case "done":
152
+ case "drop":
153
+ case "rm": {
154
+ if (hasList || hasItems)
155
+ return error(CONFLICTING_SHAPES);
156
+ const entry = { op: effectiveOp };
157
+ if (task)
158
+ entry.task = task;
159
+ if (phase)
160
+ entry.phase = phase;
161
+ return { entry, corrections };
162
+ }
163
+ case "append":
164
+ if (task || hasList)
165
+ return error(CONFLICTING_SHAPES);
166
+ return {
167
+ entry: { op: "append", ...(phase ? { phase } : {}), ...(effectiveItems ? { items: effectiveItems } : {}) },
168
+ corrections,
169
+ };
170
+ case "view":
171
+ return { entry: { op: "view" }, corrections: [] };
172
+ }
173
+ }
174
+ //# sourceMappingURL=normalize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/normalize.ts"],"names":[],"mappings":"AAUA,MAAM,kBAAkB,GACvB,gJAAgJ,CAAC;AAElJ,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IAClC,QAAQ,KAAK,EAAE,CAAC;QACf,KAAK,MAAM,CAAC;QACZ,KAAK,OAAO,CAAC;QACb,KAAK,MAAM,CAAC;QACZ,KAAK,IAAI,CAAC;QACV,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,MAAM;YACV,OAAO,IAAI,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W,EAAE,CAAC;QAC/E,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM,CAAC;QACZ,KAAK,IAAI,EAAE,CAAC;YACX,IAAI,OAAO,IAAI,QAAQ;gBAAE,OAAO,KAAK,CAAC,kBAAkB,CAAC,CAAC;YAC1D,MAAM,KAAK,GAAgB,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC;YAC/C,IAAI,IAAI;gBAAE,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;YAC5B,IAAI,KAAK;gBAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;YAC/B,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;QAC/B,CAAC;QACD,KAAK,QAAQ;YACZ,IAAI,IAAI,IAAI,OAAO;gBAAE,OAAO,KAAK,CAAC,kBAAkB,CAAC,CAAC;YACtD,OAAO;gBACN,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;gBAC1G,WAAW;aACX,CAAC;QACH,KAAK,MAAM;YACV,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACpD,CAAC;AACF,CAAC","sourcesContent":["import type { TodoOpEntry, TodoOperation, TodoPhase } from \"./state.ts\";\n\nexport type TodoNormalization = {\n\tentry?: TodoOpEntry;\n\tcorrections: string[];\n\terror?: string;\n};\n\ntype Alias = \"init\" | \"append\";\n\nconst CONFLICTING_SHAPES =\n\t'conflicting shapes. Use {\"op\":\"init\",\"list\":[...]} to replace the list or {\"op\":\"append\",\"phase\":\"<active phase>\",\"items\":[...]} to add tasks.';\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction isOperation(value: unknown): value is TodoOperation {\n\tswitch (value) {\n\t\tcase \"init\":\n\t\tcase \"start\":\n\t\tcase \"done\":\n\t\tcase \"rm\":\n\t\tcase \"drop\":\n\t\tcase \"append\":\n\t\tcase \"view\":\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nfunction strings(value: unknown): string[] | undefined {\n\tif (!Array.isArray(value)) return undefined;\n\tconst parsed: string[] = [];\n\tfor (const item of value) {\n\t\tif (typeof item !== \"string\") return undefined;\n\t\tparsed.push(item);\n\t}\n\treturn parsed;\n}\n\nfunction list(value: unknown): TodoOpEntry[\"list\"] | undefined {\n\tif (!Array.isArray(value)) return undefined;\n\tconst parsed: NonNullable<TodoOpEntry[\"list\"]> = [];\n\tfor (const item of value) {\n\t\tif (!isRecord(item) || typeof item.phase !== \"string\") return undefined;\n\t\tconst items = strings(item.items);\n\t\tif (!items) return undefined;\n\t\tparsed.push({ phase: item.phase, items });\n\t}\n\treturn parsed;\n}\n\nfunction nonBlank(value: unknown): string | undefined {\n\treturn typeof value === \"string\" && value.trim() !== \"\" ? value : undefined;\n}\n\nfunction isBlank(value: unknown): boolean {\n\treturn typeof value === \"string\" && value.trim() === \"\";\n}\n\nfunction error(message: string): TodoNormalization {\n\treturn { corrections: [], error: message };\n}\n\nfunction aliasCorrection(alias: Alias, inferred: boolean): string {\n\tconst form =\n\t\talias === \"init\" ? '{\"op\":\"init\",\"items\":[...]}' : '{\"op\":\"append\",\"phase\":\"<active phase>\",\"items\":[...]}';\n\tif (inferred) {\n\t\treturn `[auto-corrected] \"op\" was missing; interpreted as \"${alias}\" because \"${alias}\" was provided as an items alias. Always pass op explicitly: ${form}`;\n\t}\n\treturn `[auto-corrected] \"${alias}\" was used as an items alias and folded into \"items\". Use: ${form}`;\n}\n\nfunction inferredCorrection(op: \"init\" | \"append\", reason: string, form: string): string {\n\treturn `[auto-corrected] \"op\" was missing; interpreted as \"${op}\" because ${reason}. Always pass op explicitly: ${form}`;\n}\n\nfunction hasTasks(phases: readonly TodoPhase[]): boolean {\n\treturn phases.some((phase) => phase.tasks.length > 0);\n}\n\nexport function normalizeTodoParams(\n\traw: Record<string, unknown>,\n\tcurrentPhases: readonly TodoPhase[],\n): TodoNormalization {\n\tconst rawOp = raw.op;\n\tif (rawOp === \"view\") return { entry: { op: \"view\" }, corrections: [] };\n\tif (rawOp !== undefined && !isOperation(rawOp)) return error('Invalid \"op\".');\n\n\tconst op = isOperation(rawOp) ? rawOp : undefined;\n\tconst task = nonBlank(raw.task);\n\tconst phase = nonBlank(raw.phase);\n\tif (op === \"start\" || op === \"done\" || op === \"drop\" || op === \"rm\") {\n\t\tif (isBlank(raw.task) && !phase) {\n\t\t\treturn error('Blank \"task\" — pass the exact task text, or omit the field entirely for a bulk operation.');\n\t\t}\n\t\tif (isBlank(raw.phase) && !task) {\n\t\t\treturn error('Blank \"phase\" — pass the exact phase text, or omit the field entirely for a bulk operation.');\n\t\t}\n\t}\n\n\tconst rawItems = strings(raw.items);\n\tconst aliases: Array<{ name: Alias; items: string[] }> = [];\n\tfor (const name of [\"init\", \"append\"] as const) {\n\t\tconst items = strings(raw[name]);\n\t\tif (items && items.length > 0) aliases.push({ name, items });\n\t}\n\tif (aliases.length > 1) return error(CONFLICTING_SHAPES);\n\tif (aliases.length === 1 && rawItems && rawItems.length > 0) return error(CONFLICTING_SHAPES);\n\n\tconst alias = aliases[0];\n\tlet effectiveItems = rawItems && rawItems.length > 0 ? rawItems : undefined;\n\tlet candidate: Alias | undefined;\n\tconst corrections: string[] = [];\n\tif (alias) {\n\t\tif (op && op !== alias.name) return error(CONFLICTING_SHAPES);\n\t\teffectiveItems = alias.items;\n\t\tcandidate = op ? undefined : alias.name;\n\t\tcorrections.push(aliasCorrection(alias.name, !op));\n\t}\n\n\tconst effectiveList = list(raw.list);\n\tconst hasList = Boolean(effectiveList && effectiveList.length > 0);\n\tconst hasItems = Boolean(effectiveItems && effectiveItems.length > 0);\n\tif (hasList && hasItems) return error(CONFLICTING_SHAPES);\n\n\tlet effectiveOp = op;\n\tif (!effectiveOp) {\n\t\tif (candidate) {\n\t\t\teffectiveOp = candidate;\n\t\t} else if (hasList) {\n\t\t\teffectiveOp = \"init\";\n\t\t\tcorrections.push(inferredCorrection(\"init\", '\"list\" was provided', '{\"op\":\"init\",\"list\":[...]}'));\n\t\t} else if (hasItems && phase) {\n\t\t\teffectiveOp = \"append\";\n\t\t\tcorrections.push(\n\t\t\t\tinferredCorrection(\n\t\t\t\t\t\"append\",\n\t\t\t\t\t'\"items\" and \"phase\" were provided',\n\t\t\t\t\t'{\"op\":\"append\",\"phase\":\"<active phase>\",\"items\":[...]}',\n\t\t\t\t),\n\t\t\t);\n\t\t} else if (hasItems && !hasTasks(currentPhases)) {\n\t\t\teffectiveOp = \"init\";\n\t\t\tcorrections.push(\n\t\t\t\tinferredCorrection(\"init\", '\"items\" was provided to an empty todo list', '{\"op\":\"init\",\"items\":[...]}'),\n\t\t\t);\n\t\t} else if (hasItems) {\n\t\t\treturn error(\n\t\t\t\t'Missing \"op\": use {\"op\":\"init\",\"list\":[...]} to replace the list, or {\"op\":\"append\",\"phase\":\"<active phase>\",\"items\":[...]} to add tasks.',\n\t\t\t);\n\t\t} else {\n\t\t\treturn error('Missing \"op\". Example: {\"op\":\"init\",\"list\":[{\"phase\":\"Setup\",\"items\":[\"...\"]}]}');\n\t\t}\n\t}\n\n\tswitch (effectiveOp) {\n\t\tcase \"init\": {\n\t\t\tif (task || (effectiveList && effectiveList.length === 0 && hasItems)) return error(CONFLICTING_SHAPES);\n\t\t\tconst entry: TodoOpEntry = { op: \"init\" };\n\t\t\tif (effectiveList) entry.list = effectiveList;\n\t\t\tif (effectiveItems) entry.items = effectiveItems;\n\t\t\tif (phase) entry.phase = phase;\n\t\t\treturn { entry, corrections };\n\t\t}\n\t\tcase \"start\":\n\t\t\tif (phase || hasList || hasItems) return error(CONFLICTING_SHAPES);\n\t\t\treturn { entry: task ? { op: \"start\", task } : { op: \"start\" }, corrections };\n\t\tcase \"done\":\n\t\tcase \"drop\":\n\t\tcase \"rm\": {\n\t\t\tif (hasList || hasItems) return error(CONFLICTING_SHAPES);\n\t\t\tconst entry: TodoOpEntry = { op: effectiveOp };\n\t\t\tif (task) entry.task = task;\n\t\t\tif (phase) entry.phase = phase;\n\t\t\treturn { entry, corrections };\n\t\t}\n\t\tcase \"append\":\n\t\t\tif (task || hasList) return error(CONFLICTING_SHAPES);\n\t\t\treturn {\n\t\t\t\tentry: { op: \"append\", ...(phase ? { phase } : {}), ...(effectiveItems ? { items: effectiveItems } : {}) },\n\t\t\t\tcorrections,\n\t\t\t};\n\t\tcase \"view\":\n\t\t\treturn { entry: { op: \"view\" }, corrections: [] };\n\t}\n}\n"]}