@geminilight/mindos 1.1.26 → 1.1.28

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 (352) hide show
  1. package/dist/agent/bridges/index.d.ts +3 -0
  2. package/dist/agent/bridges/index.d.ts.map +1 -0
  3. package/dist/agent/bridges/index.js +3 -0
  4. package/dist/agent/bridges/index.js.map +1 -0
  5. package/dist/agent/bridges/runtime-permission-bridge.d.ts +34 -0
  6. package/dist/agent/bridges/runtime-permission-bridge.d.ts.map +1 -0
  7. package/dist/agent/bridges/runtime-permission-bridge.js +284 -0
  8. package/dist/agent/bridges/runtime-permission-bridge.js.map +1 -0
  9. package/dist/agent/bridges/user-question-bridge.d.ts +90 -0
  10. package/dist/agent/bridges/user-question-bridge.d.ts.map +1 -0
  11. package/dist/agent/bridges/user-question-bridge.js +260 -0
  12. package/dist/agent/bridges/user-question-bridge.js.map +1 -0
  13. package/dist/agent/index.d.ts +6 -7
  14. package/dist/agent/index.d.ts.map +1 -1
  15. package/dist/agent/index.js +6 -7
  16. package/dist/agent/index.js.map +1 -1
  17. package/dist/agent/ledger/index.d.ts +5 -0
  18. package/dist/agent/ledger/index.d.ts.map +1 -0
  19. package/dist/agent/ledger/index.js +5 -0
  20. package/dist/agent/ledger/index.js.map +1 -0
  21. package/dist/agent/ledger/run-cancellation.d.ts +13 -0
  22. package/dist/agent/ledger/run-cancellation.d.ts.map +1 -0
  23. package/dist/agent/ledger/run-cancellation.js +97 -0
  24. package/dist/agent/ledger/run-cancellation.js.map +1 -0
  25. package/dist/agent/ledger/run-ledger-types.d.ts +197 -0
  26. package/dist/agent/ledger/run-ledger-types.d.ts.map +1 -0
  27. package/dist/agent/ledger/run-ledger-types.js +9 -0
  28. package/dist/agent/ledger/run-ledger-types.js.map +1 -0
  29. package/dist/agent/ledger/run-ledger.d.ts +44 -0
  30. package/dist/agent/ledger/run-ledger.d.ts.map +1 -0
  31. package/dist/agent/ledger/run-ledger.js +814 -0
  32. package/dist/agent/ledger/run-ledger.js.map +1 -0
  33. package/dist/agent/ledger/run-timeline-events.d.ts +3 -0
  34. package/dist/agent/ledger/run-timeline-events.d.ts.map +1 -0
  35. package/dist/agent/ledger/run-timeline-events.js +239 -0
  36. package/dist/agent/ledger/run-timeline-events.js.map +1 -0
  37. package/dist/agent/mindos-pi/extension/extension-tools.d.ts +16 -0
  38. package/dist/agent/mindos-pi/extension/extension-tools.d.ts.map +1 -0
  39. package/dist/agent/mindos-pi/extension/extension-tools.js +115 -0
  40. package/dist/agent/mindos-pi/extension/extension-tools.js.map +1 -0
  41. package/dist/agent/mindos-pi/extension/index.d.ts +3 -0
  42. package/dist/agent/mindos-pi/extension/index.d.ts.map +1 -0
  43. package/dist/agent/mindos-pi/extension/index.js +3 -0
  44. package/dist/agent/mindos-pi/extension/index.js.map +1 -0
  45. package/dist/agent/mindos-pi/extension/kb-extension.d.ts +38 -0
  46. package/dist/agent/mindos-pi/extension/kb-extension.d.ts.map +1 -0
  47. package/dist/agent/mindos-pi/extension/kb-extension.js +140 -0
  48. package/dist/agent/mindos-pi/extension/kb-extension.js.map +1 -0
  49. package/dist/agent/mindos-pi/index.d.ts +5 -0
  50. package/dist/agent/mindos-pi/index.d.ts.map +1 -0
  51. package/dist/agent/mindos-pi/index.js +5 -0
  52. package/dist/agent/mindos-pi/index.js.map +1 -0
  53. package/dist/agent/mindos-pi/prompt.d.ts +3 -0
  54. package/dist/agent/mindos-pi/prompt.d.ts.map +1 -0
  55. package/dist/agent/mindos-pi/prompt.js +22 -0
  56. package/dist/agent/mindos-pi/prompt.js.map +1 -0
  57. package/dist/agent/mindos-pi/resource-types.d.ts +27 -0
  58. package/dist/agent/mindos-pi/resource-types.d.ts.map +1 -0
  59. package/dist/agent/mindos-pi/resource-types.js +2 -0
  60. package/dist/agent/mindos-pi/resource-types.js.map +1 -0
  61. package/dist/agent/mindos-pi/runtime.d.ts +10 -0
  62. package/dist/agent/mindos-pi/runtime.d.ts.map +1 -0
  63. package/dist/agent/mindos-pi/runtime.js +31 -0
  64. package/dist/agent/mindos-pi/runtime.js.map +1 -0
  65. package/dist/agent/pi/extension-tools.d.ts +2 -0
  66. package/dist/agent/pi/extension-tools.d.ts.map +1 -0
  67. package/dist/agent/pi/extension-tools.js +2 -0
  68. package/dist/agent/pi/extension-tools.js.map +1 -0
  69. package/dist/agent/pi/index.d.ts +2 -0
  70. package/dist/agent/pi/index.d.ts.map +1 -0
  71. package/dist/agent/pi/index.js +2 -0
  72. package/dist/agent/pi/index.js.map +1 -0
  73. package/dist/agent/pi/resource-types.d.ts +2 -0
  74. package/dist/agent/pi/resource-types.d.ts.map +1 -0
  75. package/dist/agent/pi/resource-types.js +2 -0
  76. package/dist/agent/pi/resource-types.js.map +1 -0
  77. package/dist/agent/pi/runtime.d.ts +2 -0
  78. package/dist/agent/pi/runtime.d.ts.map +1 -0
  79. package/dist/agent/pi/runtime.js +2 -0
  80. package/dist/agent/pi/runtime.js.map +1 -0
  81. package/dist/agent/prompt/context-prompt.d.ts +24 -0
  82. package/dist/agent/prompt/context-prompt.d.ts.map +1 -1
  83. package/dist/agent/prompt/context-prompt.js +15 -38
  84. package/dist/agent/prompt/context-prompt.js.map +1 -1
  85. package/dist/agent/prompt/index.d.ts +1 -1
  86. package/dist/agent/prompt/index.d.ts.map +1 -1
  87. package/dist/agent/prompt/index.js +1 -1
  88. package/dist/agent/prompt/index.js.map +1 -1
  89. package/dist/agent/result-reducer.d.ts +1 -1
  90. package/dist/agent/result-reducer.d.ts.map +1 -1
  91. package/dist/agent/run-cancellation.d.ts +1 -12
  92. package/dist/agent/run-cancellation.d.ts.map +1 -1
  93. package/dist/agent/run-cancellation.js +1 -96
  94. package/dist/agent/run-cancellation.js.map +1 -1
  95. package/dist/agent/run-ledger-types.d.ts +1 -196
  96. package/dist/agent/run-ledger-types.d.ts.map +1 -1
  97. package/dist/agent/run-ledger-types.js +1 -8
  98. package/dist/agent/run-ledger-types.js.map +1 -1
  99. package/dist/agent/run-ledger.d.ts +1 -43
  100. package/dist/agent/run-ledger.d.ts.map +1 -1
  101. package/dist/agent/run-ledger.js +1 -813
  102. package/dist/agent/run-ledger.js.map +1 -1
  103. package/dist/agent/run-timeline-events.d.ts +1 -2
  104. package/dist/agent/run-timeline-events.d.ts.map +1 -1
  105. package/dist/agent/run-timeline-events.js +1 -238
  106. package/dist/agent/run-timeline-events.js.map +1 -1
  107. package/dist/agent/runtime/adapters/index.d.ts +2 -0
  108. package/dist/agent/runtime/adapters/index.d.ts.map +1 -0
  109. package/dist/agent/runtime/adapters/index.js +2 -0
  110. package/dist/agent/runtime/adapters/index.js.map +1 -0
  111. package/dist/agent/runtime/adapters/mindos.d.ts +21 -0
  112. package/dist/agent/runtime/adapters/mindos.d.ts.map +1 -0
  113. package/dist/agent/runtime/adapters/mindos.js +14 -0
  114. package/dist/agent/runtime/adapters/mindos.js.map +1 -0
  115. package/dist/agent/runtime/attachments.d.ts +37 -0
  116. package/dist/agent/runtime/attachments.d.ts.map +1 -0
  117. package/dist/agent/runtime/attachments.js +187 -0
  118. package/dist/agent/runtime/attachments.js.map +1 -0
  119. package/dist/agent/runtime/capabilities.d.ts +10 -0
  120. package/dist/agent/runtime/capabilities.d.ts.map +1 -0
  121. package/dist/agent/runtime/capabilities.js +100 -0
  122. package/dist/agent/runtime/capabilities.js.map +1 -0
  123. package/dist/agent/runtime/child-process.d.ts +21 -0
  124. package/dist/agent/runtime/child-process.d.ts.map +1 -0
  125. package/dist/agent/runtime/child-process.js +29 -0
  126. package/dist/agent/runtime/child-process.js.map +1 -0
  127. package/dist/agent/runtime/claude-code-cli.d.ts +40 -0
  128. package/dist/agent/runtime/claude-code-cli.d.ts.map +1 -0
  129. package/dist/agent/runtime/claude-code-cli.js +288 -0
  130. package/dist/agent/runtime/claude-code-cli.js.map +1 -0
  131. package/dist/agent/runtime/claude-code-sdk.d.ts +62 -0
  132. package/dist/agent/runtime/claude-code-sdk.d.ts.map +1 -0
  133. package/dist/agent/runtime/claude-code-sdk.js +613 -0
  134. package/dist/agent/runtime/claude-code-sdk.js.map +1 -0
  135. package/dist/agent/runtime/codex-app-server.d.ts +172 -0
  136. package/dist/agent/runtime/codex-app-server.d.ts.map +1 -0
  137. package/dist/agent/runtime/codex-app-server.js +700 -0
  138. package/dist/agent/runtime/codex-app-server.js.map +1 -0
  139. package/dist/agent/runtime/codex-env.d.ts +42 -0
  140. package/dist/agent/runtime/codex-env.d.ts.map +1 -0
  141. package/dist/agent/runtime/codex-env.js +290 -0
  142. package/dist/agent/runtime/codex-env.js.map +1 -0
  143. package/dist/agent/runtime/descriptors.d.ts +19 -0
  144. package/dist/agent/runtime/descriptors.d.ts.map +1 -0
  145. package/dist/agent/runtime/descriptors.js +143 -0
  146. package/dist/agent/runtime/descriptors.js.map +1 -0
  147. package/dist/agent/runtime/detection.d.ts +15 -0
  148. package/dist/agent/runtime/detection.d.ts.map +1 -0
  149. package/dist/agent/runtime/detection.js +124 -0
  150. package/dist/agent/runtime/detection.js.map +1 -0
  151. package/dist/agent/runtime/index.d.ts +15 -0
  152. package/dist/agent/runtime/index.d.ts.map +1 -0
  153. package/dist/agent/runtime/index.js +15 -0
  154. package/dist/agent/runtime/index.js.map +1 -0
  155. package/dist/agent/runtime/registry.d.ts +152 -0
  156. package/dist/agent/runtime/registry.d.ts.map +1 -0
  157. package/dist/agent/runtime/registry.js +84 -0
  158. package/dist/agent/runtime/registry.js.map +1 -0
  159. package/dist/agent/runtime/run.d.ts +129 -0
  160. package/dist/agent/runtime/run.d.ts.map +1 -0
  161. package/dist/agent/runtime/run.js +739 -0
  162. package/dist/agent/runtime/run.js.map +1 -0
  163. package/dist/agent/runtime/runtime-env.d.ts +28 -0
  164. package/dist/agent/runtime/runtime-env.d.ts.map +1 -0
  165. package/dist/agent/runtime/runtime-env.js +66 -0
  166. package/dist/agent/runtime/runtime-env.js.map +1 -0
  167. package/dist/agent/runtime/runtime-errors.d.ts +20 -0
  168. package/dist/agent/runtime/runtime-errors.d.ts.map +1 -0
  169. package/dist/agent/runtime/runtime-errors.js +95 -0
  170. package/dist/agent/runtime/runtime-errors.js.map +1 -0
  171. package/dist/agent/runtime-permission-bridge.d.ts +1 -33
  172. package/dist/agent/runtime-permission-bridge.d.ts.map +1 -1
  173. package/dist/agent/runtime-permission-bridge.js +1 -283
  174. package/dist/agent/runtime-permission-bridge.js.map +1 -1
  175. package/dist/agent/selected-skills.d.ts +8 -0
  176. package/dist/agent/selected-skills.d.ts.map +1 -0
  177. package/dist/agent/selected-skills.js +27 -0
  178. package/dist/agent/selected-skills.js.map +1 -0
  179. package/dist/agent/session/index.d.ts +618 -0
  180. package/dist/agent/session/index.d.ts.map +1 -0
  181. package/dist/agent/session/index.js +1330 -0
  182. package/dist/agent/session/index.js.map +1 -0
  183. package/dist/agent/session/redaction.d.ts +3 -0
  184. package/dist/agent/session/redaction.d.ts.map +1 -0
  185. package/dist/agent/session/redaction.js +47 -0
  186. package/dist/agent/session/redaction.js.map +1 -0
  187. package/dist/agent/stream/index.d.ts +3 -0
  188. package/dist/agent/stream/index.d.ts.map +1 -0
  189. package/dist/agent/stream/index.js +3 -0
  190. package/dist/agent/stream/index.js.map +1 -0
  191. package/dist/agent/stream/stream-consumer.d.ts +65 -0
  192. package/dist/agent/stream/stream-consumer.d.ts.map +1 -0
  193. package/dist/agent/stream/stream-consumer.js +664 -0
  194. package/dist/agent/stream/stream-consumer.js.map +1 -0
  195. package/dist/agent/stream/stream-message-types.d.ts +128 -0
  196. package/dist/agent/stream/stream-message-types.d.ts.map +1 -0
  197. package/dist/agent/stream/stream-message-types.js +14 -0
  198. package/dist/agent/stream/stream-message-types.js.map +1 -0
  199. package/dist/agent/stream-consumer.d.ts +1 -64
  200. package/dist/agent/stream-consumer.d.ts.map +1 -1
  201. package/dist/agent/stream-consumer.js +1 -663
  202. package/dist/agent/stream-consumer.js.map +1 -1
  203. package/dist/agent/stream-message-types.d.ts +1 -137
  204. package/dist/agent/stream-message-types.d.ts.map +1 -1
  205. package/dist/agent/stream-message-types.js +1 -13
  206. package/dist/agent/stream-message-types.js.map +1 -1
  207. package/dist/agent/subagent/index.d.ts +3 -0
  208. package/dist/agent/subagent/index.d.ts.map +1 -0
  209. package/dist/agent/subagent/index.js +3 -0
  210. package/dist/agent/subagent/index.js.map +1 -0
  211. package/dist/agent/subagent/subagent-ledger-extension.d.ts +36 -0
  212. package/dist/agent/subagent/subagent-ledger-extension.d.ts.map +1 -0
  213. package/dist/agent/subagent/subagent-ledger-extension.js +572 -0
  214. package/dist/agent/subagent/subagent-ledger-extension.js.map +1 -0
  215. package/dist/agent/subagent/subagent-orchestrator.d.ts +62 -0
  216. package/dist/agent/subagent/subagent-orchestrator.d.ts.map +1 -0
  217. package/dist/agent/subagent/subagent-orchestrator.js +350 -0
  218. package/dist/agent/subagent/subagent-orchestrator.js.map +1 -0
  219. package/dist/agent/subagent-ledger-extension.d.ts +1 -35
  220. package/dist/agent/subagent-ledger-extension.d.ts.map +1 -1
  221. package/dist/agent/subagent-ledger-extension.js +1 -571
  222. package/dist/agent/subagent-ledger-extension.js.map +1 -1
  223. package/dist/agent/subagent-orchestrator.d.ts +1 -61
  224. package/dist/agent/subagent-orchestrator.d.ts.map +1 -1
  225. package/dist/agent/subagent-orchestrator.js +1 -349
  226. package/dist/agent/subagent-orchestrator.js.map +1 -1
  227. package/dist/agent/tool/executable-tool.d.ts +12 -0
  228. package/dist/agent/tool/executable-tool.d.ts.map +1 -0
  229. package/dist/agent/tool/executable-tool.js +2 -0
  230. package/dist/agent/tool/executable-tool.js.map +1 -0
  231. package/dist/agent/tool/index.d.ts +1 -1
  232. package/dist/agent/tool/index.d.ts.map +1 -1
  233. package/dist/agent/tool/index.js +1 -1
  234. package/dist/agent/tool/index.js.map +1 -1
  235. package/dist/agent/tool/kb-extension.d.ts +1 -37
  236. package/dist/agent/tool/kb-extension.d.ts.map +1 -1
  237. package/dist/agent/tool/kb-extension.js +1 -139
  238. package/dist/agent/tool/kb-extension.js.map +1 -1
  239. package/dist/agent/user-question-bridge.d.ts +1 -89
  240. package/dist/agent/user-question-bridge.d.ts.map +1 -1
  241. package/dist/agent/user-question-bridge.js +1 -259
  242. package/dist/agent/user-question-bridge.js.map +1 -1
  243. package/dist/agent-runtime/adapters/index.d.ts +2 -0
  244. package/dist/agent-runtime/adapters/index.d.ts.map +1 -0
  245. package/dist/agent-runtime/adapters/index.js +2 -0
  246. package/dist/agent-runtime/adapters/index.js.map +1 -0
  247. package/dist/agent-runtime/adapters/mindos.d.ts +2 -0
  248. package/dist/agent-runtime/adapters/mindos.d.ts.map +1 -0
  249. package/dist/agent-runtime/adapters/mindos.js +2 -0
  250. package/dist/agent-runtime/adapters/mindos.js.map +1 -0
  251. package/dist/agent-runtime/capabilities.d.ts +1 -9
  252. package/dist/agent-runtime/capabilities.d.ts.map +1 -1
  253. package/dist/agent-runtime/capabilities.js +1 -99
  254. package/dist/agent-runtime/capabilities.js.map +1 -1
  255. package/dist/agent-runtime/child-process.d.ts +1 -20
  256. package/dist/agent-runtime/child-process.d.ts.map +1 -1
  257. package/dist/agent-runtime/child-process.js +1 -28
  258. package/dist/agent-runtime/child-process.js.map +1 -1
  259. package/dist/agent-runtime/claude-code-cli.d.ts +1 -35
  260. package/dist/agent-runtime/claude-code-cli.d.ts.map +1 -1
  261. package/dist/agent-runtime/claude-code-cli.js +1 -287
  262. package/dist/agent-runtime/claude-code-cli.js.map +1 -1
  263. package/dist/agent-runtime/claude-code-sdk.d.ts +1 -40
  264. package/dist/agent-runtime/claude-code-sdk.d.ts.map +1 -1
  265. package/dist/agent-runtime/claude-code-sdk.js +1 -571
  266. package/dist/agent-runtime/claude-code-sdk.js.map +1 -1
  267. package/dist/agent-runtime/codex-app-server.d.ts +1 -157
  268. package/dist/agent-runtime/codex-app-server.d.ts.map +1 -1
  269. package/dist/agent-runtime/codex-app-server.js +1 -665
  270. package/dist/agent-runtime/codex-app-server.js.map +1 -1
  271. package/dist/agent-runtime/codex-env.d.ts +1 -41
  272. package/dist/agent-runtime/codex-env.d.ts.map +1 -1
  273. package/dist/agent-runtime/codex-env.js +1 -289
  274. package/dist/agent-runtime/codex-env.js.map +1 -1
  275. package/dist/agent-runtime/descriptors.d.ts +1 -18
  276. package/dist/agent-runtime/descriptors.d.ts.map +1 -1
  277. package/dist/agent-runtime/descriptors.js +1 -142
  278. package/dist/agent-runtime/descriptors.js.map +1 -1
  279. package/dist/agent-runtime/detection.d.ts +1 -14
  280. package/dist/agent-runtime/detection.d.ts.map +1 -1
  281. package/dist/agent-runtime/detection.js +1 -123
  282. package/dist/agent-runtime/detection.js.map +1 -1
  283. package/dist/agent-runtime/index.d.ts +1 -8
  284. package/dist/agent-runtime/index.d.ts.map +1 -1
  285. package/dist/agent-runtime/index.js +1 -8
  286. package/dist/agent-runtime/index.js.map +1 -1
  287. package/dist/agent-runtime/registry.d.ts +1 -151
  288. package/dist/agent-runtime/registry.d.ts.map +1 -1
  289. package/dist/agent-runtime/registry.js +1 -83
  290. package/dist/agent-runtime/registry.js.map +1 -1
  291. package/dist/agent-runtime/run.d.ts +1 -124
  292. package/dist/agent-runtime/run.d.ts.map +1 -1
  293. package/dist/agent-runtime/run.js +1 -720
  294. package/dist/agent-runtime/run.js.map +1 -1
  295. package/dist/agent-runtime/runtime-env.d.ts +1 -27
  296. package/dist/agent-runtime/runtime-env.d.ts.map +1 -1
  297. package/dist/agent-runtime/runtime-env.js +1 -65
  298. package/dist/agent-runtime/runtime-env.js.map +1 -1
  299. package/dist/agent-runtime/runtime-errors.d.ts +1 -19
  300. package/dist/agent-runtime/runtime-errors.d.ts.map +1 -1
  301. package/dist/agent-runtime/runtime-errors.js +1 -94
  302. package/dist/agent-runtime/runtime-errors.js.map +1 -1
  303. package/dist/agent-runtime.d.ts +1 -1
  304. package/dist/agent-runtime.js +1 -1
  305. package/dist/client.d.ts +8 -4
  306. package/dist/client.d.ts.map +1 -1
  307. package/dist/client.js.map +1 -1
  308. package/dist/foundation/config/schema.d.ts +1 -1
  309. package/dist/server/handlers/agent-runtime-codex.d.ts +1 -1
  310. package/dist/server/handlers/agent-runtime-codex.js +2 -2
  311. package/dist/server/handlers/agent-runtimes.d.ts +3 -3
  312. package/dist/server/handlers/agent-runtimes.js +5 -5
  313. package/dist/server/handlers/ask.d.ts +8 -4
  314. package/dist/server/handlers/ask.d.ts.map +1 -1
  315. package/dist/server/handlers/ask.js +7 -1
  316. package/dist/server/handlers/ask.js.map +1 -1
  317. package/dist/server/handlers/inbox-source.d.ts +1 -1
  318. package/dist/server/handlers/inbox-source.d.ts.map +1 -1
  319. package/dist/server/handlers/inbox-source.js +22 -0
  320. package/dist/server/handlers/inbox-source.js.map +1 -1
  321. package/dist/server/handlers/settings.d.ts +1 -1
  322. package/dist/server/handlers/settings.js +1 -1
  323. package/dist/server/handlers/setup.d.ts +2 -1
  324. package/dist/server/handlers/setup.d.ts.map +1 -1
  325. package/dist/server/handlers/setup.js +1 -0
  326. package/dist/server/handlers/setup.js.map +1 -1
  327. package/dist/server/index.d.ts +1 -1
  328. package/dist/server/index.d.ts.map +1 -1
  329. package/dist/server/index.js +1 -1
  330. package/dist/server/index.js.map +1 -1
  331. package/dist/server/runtime.d.ts +1 -1
  332. package/dist/session/index.d.ts +1 -650
  333. package/dist/session/index.d.ts.map +1 -1
  334. package/dist/session/index.js +1 -1455
  335. package/dist/session/index.js.map +1 -1
  336. package/dist/session/pi-coding-agent-runtime.d.ts +1 -9
  337. package/dist/session/pi-coding-agent-runtime.d.ts.map +1 -1
  338. package/dist/session/pi-coding-agent-runtime.js +1 -30
  339. package/dist/session/pi-coding-agent-runtime.js.map +1 -1
  340. package/dist/session/redaction.d.ts +1 -2
  341. package/dist/session/redaction.d.ts.map +1 -1
  342. package/dist/session/redaction.js +1 -46
  343. package/dist/session/redaction.js.map +1 -1
  344. package/dist/session.d.ts +1 -1
  345. package/dist/session.d.ts.map +1 -1
  346. package/dist/session.js +1 -1
  347. package/dist/session.js.map +1 -1
  348. package/dist/setup/index.d.ts +24 -3
  349. package/dist/setup/index.d.ts.map +1 -1
  350. package/dist/setup/index.js +102 -2
  351. package/dist/setup/index.js.map +1 -1
  352. package/package.json +97 -9
@@ -1,664 +1,2 @@
1
- import { parseMindosSseLine } from '../session/index.js';
2
- import { redactSensitiveObject, redactSensitiveText } from './redaction.js';
3
- /** Tools that modify files — trigger files-changed notification on completion */
4
- const FILE_MUTATING_TOOLS = new Set([
5
- 'write_file', 'create_file', 'batch_create_files',
6
- 'append_to_file', 'insert_after_heading', 'update_section',
7
- 'edit_lines', 'delete_file', 'rename_file', 'move_file',
8
- 'append_csv', 'create_space',
9
- ]);
10
- /**
11
- * Extract the file paths a mutating tool touched from its input args.
12
- * Returns undefined when no recognizable path input exists — the
13
- * files-changed event then degrades to "unknown, assume anything changed".
14
- */
15
- function collectMutatedPaths(input) {
16
- if (!isRecord(input))
17
- return undefined;
18
- const paths = [];
19
- const add = (value) => {
20
- if (typeof value === 'string' && value.trim())
21
- paths.push(value);
22
- };
23
- add(input.path);
24
- add(input.from_path);
25
- add(input.to_path);
26
- if (Array.isArray(input.files)) {
27
- for (const file of input.files) {
28
- if (isRecord(file))
29
- add(file.path);
30
- }
31
- }
32
- // rename_file: the new path is the old directory + new_name.
33
- if (typeof input.new_name === 'string' && input.new_name.trim() && typeof input.path === 'string' && input.path.trim()) {
34
- const slash = input.path.lastIndexOf('/');
35
- add((slash >= 0 ? input.path.slice(0, slash + 1) : '') + input.new_name);
36
- }
37
- return paths.length > 0 ? paths : undefined;
38
- }
39
- function parseSseLineAsRecord(line) {
40
- const parsed = parseMindosSseLine(line);
41
- if (parsed)
42
- return parsed;
43
- if (!line.startsWith('data:'))
44
- return null;
45
- const payload = line.slice(5).trim();
46
- if (!payload || payload === '[DONE]')
47
- return null;
48
- try {
49
- const fallback = JSON.parse(payload);
50
- return fallback && typeof fallback === 'object' && !Array.isArray(fallback)
51
- ? fallback
52
- : null;
53
- }
54
- catch {
55
- return null;
56
- }
57
- }
58
- function isRuntimeBindingStatus(value) {
59
- return value === 'active'
60
- || value === 'missing'
61
- || value === 'signed-out'
62
- || value === 'archived'
63
- || value === 'failed';
64
- }
65
- function isRecord(value) {
66
- return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
67
- }
68
- function normalizeUserQuestionAnswers(value) {
69
- if (!Array.isArray(value))
70
- return [];
71
- return value.filter(isRecord).map((answer) => ({
72
- questionIndex: typeof answer.questionIndex === 'number' ? answer.questionIndex : -1,
73
- question: typeof answer.question === 'string' ? redactSensitiveText(answer.question) : '',
74
- kind: answer.kind === 'custom' || answer.kind === 'chat' || answer.kind === 'multi' ? answer.kind : 'option',
75
- answer: typeof answer.answer === 'string' ? redactSensitiveText(answer.answer) : null,
76
- ...(Array.isArray(answer.selected) ? { selected: answer.selected.filter((item) => typeof item === 'string').map(redactSensitiveText) } : {}),
77
- ...(typeof answer.notes === 'string' ? { notes: redactSensitiveText(answer.notes) } : {}),
78
- ...(typeof answer.preview === 'string' ? { preview: redactSensitiveText(answer.preview) } : {}),
79
- }));
80
- }
81
- function normalizeRuntime(value) {
82
- return value === 'mindos' || value === 'acp' || value === 'codex' || value === 'claude'
83
- ? value
84
- : undefined;
85
- }
86
- function normalizeRuntimePermissionIntent(value) {
87
- return value === 'allow' || value === 'deny' || value === 'cancel' ? value : undefined;
88
- }
89
- function normalizeRuntimePermissionScope(value) {
90
- return value === 'once' || value === 'session' || value === 'always' || value === 'turn' ? value : undefined;
91
- }
92
- function normalizeRuntimePermissionRisk(value) {
93
- if (!isRecord(value))
94
- return undefined;
95
- const level = value.level === 'low' || value.level === 'medium' || value.level === 'high' ? value.level : undefined;
96
- const summary = typeof value.summary === 'string' ? redactSensitiveText(value.summary) : undefined;
97
- if (!level || !summary)
98
- return undefined;
99
- return {
100
- level,
101
- summary,
102
- ...(Array.isArray(value.reasons)
103
- ? { reasons: value.reasons.filter((reason) => typeof reason === 'string').map(redactSensitiveText) }
104
- : {}),
105
- };
106
- }
107
- function shortToolName(toolName) {
108
- const parts = toolName.split('__');
109
- return parts[parts.length - 1] || toolName;
110
- }
111
- function isAskUserQuestionToolName(toolName) {
112
- if (!toolName)
113
- return false;
114
- const normalized = shortToolName(toolName).replace(/[-_\s]/g, '').toLowerCase();
115
- return normalized === 'askuserquestion';
116
- }
117
- function isGenericToolCompletionOutput(output) {
118
- return /^Codex item (completed|success|succeeded)$/i.test(output.trim());
119
- }
120
- function extractQuestionPayload(input) {
121
- if (!isRecord(input))
122
- return input;
123
- if (Array.isArray(input.questions))
124
- return input.questions;
125
- if (isRecord(input.input) && Array.isArray(input.input.questions))
126
- return input.input.questions;
127
- if (isRecord(input.params) && Array.isArray(input.params.questions))
128
- return input.params.questions;
129
- if (isRecord(input.arguments) && Array.isArray(input.arguments.questions))
130
- return input.arguments.questions;
131
- return undefined;
132
- }
133
- export async function consumeUIMessageStream(body, onUpdate, signal, options = {}) {
134
- const reader = body.getReader();
135
- const decoder = new TextDecoder();
136
- let buffer = '';
137
- const filesChanged = options.filesChanged;
138
- // Mutable working copies
139
- const parts = [];
140
- const toolCalls = new Map();
141
- let currentTextId = null;
142
- let currentReasoningPart = null;
143
- const startedAt = Date.now();
144
- /**
145
- * Structural sharing: cache the immutable clone of each mutable part and
146
- * reuse it across emissions until the part is mutated again (touch()).
147
- * Unchanged parts keep object identity so memoized children skip re-render.
148
- */
149
- const cloneCache = new Map();
150
- /** Mark a mutable part as changed — its next snapshot gets a fresh clone. */
151
- function touch(part) {
152
- cloneCache.delete(part);
153
- }
154
- function clonePart(p) {
155
- if (p.type === 'text')
156
- return { type: 'text', text: p.text };
157
- if (p.type === 'reasoning')
158
- return { type: 'reasoning', text: p.text };
159
- if (p.type === 'image')
160
- return { ...p };
161
- if (p.type === 'runtime-status')
162
- return { ...p };
163
- if (p.type === 'agent-run-timeline') {
164
- return {
165
- ...p,
166
- runs: p.runs.map(run => ({
167
- ...run,
168
- ...(run.metadata ? { metadata: { ...run.metadata } } : {}),
169
- })),
170
- };
171
- }
172
- // ToolCallPart — shallow copy safe (primitive fields, input is replaced not mutated)
173
- return {
174
- ...p,
175
- ...(p.userQuestion ? {
176
- userQuestion: {
177
- ...p.userQuestion,
178
- questions: p.userQuestion.questions.map(q => ({
179
- ...q,
180
- options: q.options.map(o => ({ ...o })),
181
- })),
182
- ...(p.userQuestion.answers ? { answers: p.userQuestion.answers.map(a => ({ ...a, selected: a.selected ? [...a.selected] : undefined })) } : {}),
183
- },
184
- } : {}),
185
- ...(p.runtimePermission ? {
186
- runtimePermission: {
187
- ...p.runtimePermission,
188
- options: p.runtimePermission.options.map(option => ({ ...option })),
189
- },
190
- } : {}),
191
- };
192
- }
193
- /** Build an immutable Message snapshot from current parts */
194
- function buildMessage() {
195
- const clonedParts = parts.map(p => {
196
- const cached = cloneCache.get(p);
197
- if (cached)
198
- return cached;
199
- const clone = clonePart(p);
200
- cloneCache.set(p, clone);
201
- return clone;
202
- });
203
- const textContent = clonedParts
204
- .filter((p) => p.type === 'text')
205
- .map(p => p.text)
206
- .join('');
207
- return {
208
- role: 'assistant',
209
- content: textContent,
210
- parts: clonedParts,
211
- timestamp: startedAt,
212
- };
213
- }
214
- // ---------------------------------------------------------------------------
215
- // Emit coalescing: streaming runs can deliver hundreds of chunks per second;
216
- // emitting per read batch made rendering O(L²). Leading emit + trailing
217
- // flush within emitCoalesceMs; terminal state always flushes immediately.
218
- const emitCoalesceMs = options.emitCoalesceMs ?? 50;
219
- let lastEmitAt = Number.NEGATIVE_INFINITY;
220
- let trailingTimer = null;
221
- let pendingEmit = false;
222
- let runEnded = false;
223
- function emitNow() {
224
- pendingEmit = false;
225
- lastEmitAt = Date.now();
226
- onUpdate(buildMessage());
227
- }
228
- function scheduleEmit() {
229
- if (emitCoalesceMs <= 0) {
230
- emitNow();
231
- return;
232
- }
233
- if (trailingTimer === null && Date.now() - lastEmitAt >= emitCoalesceMs) {
234
- emitNow(); // leading edge — first chunk renders without delay
235
- return;
236
- }
237
- pendingEmit = true;
238
- if (trailingTimer === null) {
239
- trailingTimer = setTimeout(() => {
240
- trailingTimer = null;
241
- if (!runEnded && pendingEmit)
242
- emitNow();
243
- }, emitCoalesceMs);
244
- }
245
- }
246
- /** Terminal flush — completion/error/abort must never be delayed. */
247
- function flushEmit() {
248
- runEnded = true;
249
- if (trailingTimer !== null) {
250
- clearTimeout(trailingTimer);
251
- trailingTimer = null;
252
- }
253
- if (pendingEmit)
254
- emitNow();
255
- }
256
- /** Get or create the last text part with given ID */
257
- function findOrCreateTextPart(id) {
258
- if (currentTextId === id) {
259
- const last = parts[parts.length - 1];
260
- if (last && last.type === 'text')
261
- return last;
262
- }
263
- const part = { type: 'text', text: '' };
264
- parts.push(part);
265
- currentTextId = id;
266
- return part;
267
- }
268
- /** Get or create a tool call part */
269
- function findOrCreateToolCall(toolCallId, toolName) {
270
- let tc = toolCalls.get(toolCallId);
271
- if (!tc) {
272
- tc = {
273
- type: 'tool-call',
274
- toolCallId,
275
- toolName: toolName ?? 'unknown',
276
- input: undefined,
277
- state: 'pending',
278
- };
279
- toolCalls.set(toolCallId, tc);
280
- parts.push(tc);
281
- currentTextId = null;
282
- }
283
- return tc;
284
- }
285
- function upsertRuntimeStatus(message, runtime) {
286
- const safeMessage = redactSensitiveText(message);
287
- const last = parts[parts.length - 1];
288
- if (last?.type === 'runtime-status' && last.runtime === runtime) {
289
- last.message = safeMessage;
290
- touch(last);
291
- return;
292
- }
293
- parts.push({
294
- type: 'runtime-status',
295
- message: safeMessage,
296
- ...(runtime ? { runtime } : {}),
297
- });
298
- currentTextId = null;
299
- }
300
- function normalizeUserQuestions(value) {
301
- if (!Array.isArray(value))
302
- return [];
303
- return value
304
- .filter((item) => Boolean(item) && typeof item === 'object' && !Array.isArray(item))
305
- .map((question) => ({
306
- question: typeof question.question === 'string' ? redactSensitiveText(question.question) : '',
307
- header: typeof question.header === 'string' ? redactSensitiveText(question.header) : '',
308
- multiSelect: question.multiSelect === true,
309
- options: Array.isArray(question.options)
310
- ? question.options
311
- .filter((option) => Boolean(option) && typeof option === 'object' && !Array.isArray(option))
312
- .map(option => ({
313
- label: typeof option.label === 'string' ? redactSensitiveText(option.label) : '',
314
- description: typeof option.description === 'string' ? redactSensitiveText(option.description) : '',
315
- ...(typeof option.preview === 'string' ? { preview: redactSensitiveText(option.preview) } : {}),
316
- }))
317
- : [],
318
- }));
319
- }
320
- // Cancelling the reader is the only way to interrupt a pending read();
321
- // the aborted check at the top of the loop can't fire while the stream is
322
- // quiet, which left aborted runs awaiting a read that never resolves.
323
- const cancelOnAbort = () => { void reader.cancel().catch(() => { }); };
324
- if (signal?.aborted) {
325
- cancelOnAbort();
326
- }
327
- else {
328
- signal?.addEventListener('abort', cancelOnAbort, { once: true });
329
- }
330
- try {
331
- while (true) {
332
- if (signal?.aborted)
333
- break;
334
- const { done, value } = await reader.read();
335
- if (done && !buffer)
336
- break;
337
- if (!done)
338
- buffer += decoder.decode(value, { stream: true });
339
- // Process complete SSE lines
340
- const lines = done ? [buffer] : buffer.split('\n');
341
- buffer = done ? '' : lines.pop() ?? ''; // keep incomplete last line
342
- let changed = false;
343
- for (const line of lines) {
344
- const trimmed = line.trim();
345
- const eventRecord = parseSseLineAsRecord(trimmed);
346
- if (!eventRecord)
347
- continue;
348
- const type = typeof eventRecord.type === 'string' ? eventRecord.type : '';
349
- switch (type) {
350
- case 'agent_run_context': {
351
- if (typeof eventRecord.rootRunId !== 'string' || !eventRecord.rootRunId)
352
- break;
353
- options.onAgentRunContext?.({
354
- rootRunId: eventRecord.rootRunId,
355
- ...(typeof eventRecord.chatSessionId === 'string' ? { chatSessionId: eventRecord.chatSessionId } : {}),
356
- startedAt: typeof eventRecord.startedAt === 'number' && Number.isFinite(eventRecord.startedAt)
357
- ? eventRecord.startedAt
358
- : Date.now(),
359
- });
360
- break;
361
- }
362
- case 'text_delta': {
363
- // Regular text from assistant
364
- const part = findOrCreateTextPart('text');
365
- part.text += eventRecord.delta ?? '';
366
- touch(part);
367
- changed = true;
368
- break;
369
- }
370
- case 'thinking_delta': {
371
- // Extended thinking (Anthropic)
372
- if (!currentReasoningPart) {
373
- currentReasoningPart = { type: 'reasoning', text: '' };
374
- parts.push(currentReasoningPart);
375
- currentTextId = null;
376
- }
377
- currentReasoningPart.text += eventRecord.delta ?? '';
378
- touch(currentReasoningPart);
379
- changed = true;
380
- break;
381
- }
382
- case 'tool_start': {
383
- // Beginning of tool execution
384
- const toolCallId = eventRecord.toolCallId;
385
- if (!toolCallId)
386
- break;
387
- const toolName = eventRecord.toolName;
388
- const tc = findOrCreateToolCall(toolCallId, toolName);
389
- const safeArgs = redactSensitiveObject(eventRecord.args);
390
- tc.input = safeArgs;
391
- tc.runtime = normalizeRuntime(eventRecord.runtime);
392
- if (isAskUserQuestionToolName(toolName)) {
393
- const questions = normalizeUserQuestions(extractQuestionPayload(safeArgs));
394
- if (questions.length > 0) {
395
- const runId = typeof eventRecord.runId === 'string' ? eventRecord.runId : '';
396
- tc.userQuestion = {
397
- runId,
398
- questions,
399
- status: 'waiting',
400
- readOnly: !runId,
401
- ...(tc.runtime ? { runtime: tc.runtime } : {}),
402
- };
403
- }
404
- }
405
- tc.state = 'running';
406
- touch(tc);
407
- changed = true;
408
- break;
409
- }
410
- case 'tool_delta': {
411
- const toolCallId = eventRecord.toolCallId;
412
- if (!toolCallId)
413
- break;
414
- const toolName = typeof eventRecord.toolName === 'string' ? eventRecord.toolName : undefined;
415
- const tc = findOrCreateToolCall(toolCallId, toolName);
416
- if (toolName && tc.toolName === 'unknown')
417
- tc.toolName = toolName;
418
- tc.runtime = normalizeRuntime(eventRecord.runtime) ?? tc.runtime;
419
- tc.output = `${tc.output ?? ''}${typeof eventRecord.delta === 'string' ? redactSensitiveText(eventRecord.delta) : ''}`;
420
- if (tc.state === 'pending')
421
- tc.state = 'running';
422
- touch(tc);
423
- changed = true;
424
- break;
425
- }
426
- case 'tool_end': {
427
- // Tool execution finished
428
- const toolCallId = eventRecord.toolCallId;
429
- if (!toolCallId)
430
- break;
431
- // Use findOrCreateToolCall so tool_end still works even if tool_start was lost
432
- const tc = findOrCreateToolCall(toolCallId, eventRecord.toolName);
433
- if (typeof eventRecord.toolName === 'string' && eventRecord.toolName && tc.toolName === 'unknown') {
434
- tc.toolName = eventRecord.toolName;
435
- }
436
- tc.runtime = normalizeRuntime(eventRecord.runtime) ?? tc.runtime;
437
- const output = typeof eventRecord.output === 'string' ? redactSensitiveText(eventRecord.output) : '';
438
- const shouldPreserveExistingOutput = Boolean(tc.output &&
439
- !eventRecord.isError &&
440
- (!output || isGenericToolCompletionOutput(output)));
441
- if (!shouldPreserveExistingOutput) {
442
- tc.output = output;
443
- }
444
- tc.state = (eventRecord.isError ? 'error' : 'done');
445
- if (eventRecord.isError && tc.userQuestion?.readOnly) {
446
- tc.userQuestion.status = 'cancelled';
447
- tc.userQuestion.reason = output || 'tool_error';
448
- }
449
- touch(tc);
450
- changed = true;
451
- // Notify when a file-modifying tool completes successfully —
452
- // batched into one files-changed notification per run.
453
- if (!eventRecord.isError && FILE_MUTATING_TOOLS.has(tc.toolName)) {
454
- filesChanged?.queue(collectMutatedPaths(tc.input));
455
- }
456
- break;
457
- }
458
- case 'runtime_permission_request': {
459
- const toolCallId = eventRecord.toolCallId;
460
- const runId = eventRecord.runId;
461
- const requestId = eventRecord.requestId;
462
- const runtime = normalizeRuntime(eventRecord.runtime);
463
- if (!toolCallId || !runId || !requestId || (runtime !== 'codex' && runtime !== 'claude'))
464
- break;
465
- const toolName = typeof eventRecord.toolName === 'string' && eventRecord.toolName ? eventRecord.toolName : 'approval_request';
466
- const tc = findOrCreateToolCall(toolCallId, toolName);
467
- tc.toolName = toolName;
468
- tc.input = redactSensitiveObject(eventRecord.input);
469
- tc.runtime = runtime;
470
- tc.runtimePermission = {
471
- runId,
472
- requestId,
473
- runtime,
474
- status: 'waiting',
475
- options: Array.isArray(eventRecord.options)
476
- ? eventRecord.options
477
- .filter(isRecord)
478
- .map(option => ({
479
- id: typeof option.id === 'string' ? option.id : '',
480
- label: typeof option.label === 'string' ? redactSensitiveText(option.label) : '',
481
- ...(typeof option.description === 'string' ? { description: redactSensitiveText(option.description) } : {}),
482
- ...(normalizeRuntimePermissionIntent(option.intent) ? { intent: normalizeRuntimePermissionIntent(option.intent) } : {}),
483
- ...(normalizeRuntimePermissionScope(option.scope) ? { scope: normalizeRuntimePermissionScope(option.scope) } : {}),
484
- }))
485
- .filter(option => option.id && option.label)
486
- : [],
487
- ...(typeof eventRecord.reason === 'string' ? { reason: redactSensitiveText(eventRecord.reason) } : {}),
488
- ...(typeof eventRecord.action === 'string' ? { action: redactSensitiveText(eventRecord.action) } : {}),
489
- ...(typeof eventRecord.resource === 'string' ? { resource: redactSensitiveText(eventRecord.resource) } : {}),
490
- ...(normalizeRuntimePermissionRisk(eventRecord.risk) ? { risk: normalizeRuntimePermissionRisk(eventRecord.risk) } : {}),
491
- };
492
- tc.state = 'running';
493
- touch(tc);
494
- changed = true;
495
- break;
496
- }
497
- case 'runtime_permission_resolved': {
498
- const toolCallId = eventRecord.toolCallId;
499
- if (!toolCallId)
500
- break;
501
- const tc = findOrCreateToolCall(toolCallId, 'approval_request');
502
- tc.runtime = normalizeRuntime(eventRecord.runtime) ?? tc.runtime;
503
- const decision = typeof eventRecord.decision === 'string' ? eventRecord.decision : '';
504
- const denied = decision === 'decline' || decision === 'deny' || decision === 'denied';
505
- if (tc.runtimePermission) {
506
- tc.runtimePermission.decision = decision;
507
- if (typeof eventRecord.decisionLabel === 'string')
508
- tc.runtimePermission.decisionLabel = redactSensitiveText(eventRecord.decisionLabel);
509
- const decisionIntent = normalizeRuntimePermissionIntent(eventRecord.decisionIntent);
510
- if (decisionIntent)
511
- tc.runtimePermission.decisionIntent = decisionIntent;
512
- const decisionScope = normalizeRuntimePermissionScope(eventRecord.decisionScope);
513
- if (decisionScope)
514
- tc.runtimePermission.decisionScope = decisionScope;
515
- tc.runtimePermission.status = eventRecord.cancelled === true
516
- ? 'cancelled'
517
- : decisionIntent === 'deny' || denied
518
- ? 'denied'
519
- : 'approved';
520
- }
521
- if (eventRecord.cancelled === true || denied) {
522
- tc.state = 'error';
523
- tc.output = decision
524
- ? `Permission decision forwarded: ${decision}`
525
- : 'Permission decision forwarded.';
526
- }
527
- touch(tc);
528
- changed = true;
529
- break;
530
- }
531
- case 'user_question_start': {
532
- const toolCallId = eventRecord.toolCallId;
533
- const runId = eventRecord.runId;
534
- if (!toolCallId || !runId)
535
- break;
536
- const tc = findOrCreateToolCall(toolCallId, 'ask_user_question');
537
- tc.toolName = 'ask_user_question';
538
- tc.userQuestion = {
539
- runId,
540
- questions: normalizeUserQuestions(eventRecord.questions),
541
- status: 'waiting',
542
- };
543
- tc.state = 'running';
544
- touch(tc);
545
- changed = true;
546
- break;
547
- }
548
- case 'user_question_answered': {
549
- const toolCallId = eventRecord.toolCallId;
550
- if (!toolCallId)
551
- break;
552
- const tc = findOrCreateToolCall(toolCallId, 'ask_user_question');
553
- if (tc.userQuestion) {
554
- tc.userQuestion.status = 'submitted';
555
- tc.userQuestion.answers = normalizeUserQuestionAnswers(eventRecord.answers);
556
- }
557
- tc.state = 'done';
558
- touch(tc);
559
- changed = true;
560
- break;
561
- }
562
- case 'user_question_cancelled': {
563
- const toolCallId = eventRecord.toolCallId;
564
- if (!toolCallId)
565
- break;
566
- const tc = findOrCreateToolCall(toolCallId, 'ask_user_question');
567
- if (tc.userQuestion) {
568
- tc.userQuestion.status = 'cancelled';
569
- tc.userQuestion.reason = typeof eventRecord.reason === 'string' ? redactSensitiveText(eventRecord.reason) : undefined;
570
- }
571
- tc.state = 'error';
572
- tc.output = typeof eventRecord.reason === 'string' && eventRecord.reason
573
- ? redactSensitiveText(eventRecord.reason)
574
- : 'Question cancelled.';
575
- touch(tc);
576
- changed = true;
577
- break;
578
- }
579
- case 'runtime_binding': {
580
- const runtime = eventRecord.runtime;
581
- const externalSessionId = eventRecord.externalSessionId;
582
- if ((runtime === 'acp' || runtime === 'codex' || runtime === 'claude') &&
583
- typeof externalSessionId === 'string' &&
584
- externalSessionId) {
585
- options.onRuntimeBinding?.({
586
- runtime,
587
- externalSessionId,
588
- ...(typeof eventRecord.cwd === 'string' ? { cwd: eventRecord.cwd } : {}),
589
- ...(isRuntimeBindingStatus(eventRecord.status) ? { status: eventRecord.status } : {}),
590
- ...(typeof eventRecord.reason === 'string' ? { reason: redactSensitiveText(eventRecord.reason) } : {}),
591
- });
592
- }
593
- break;
594
- }
595
- case 'status': {
596
- if (eventRecord.visible !== true || typeof eventRecord.message !== 'string' || !eventRecord.message.trim()) {
597
- break;
598
- }
599
- upsertRuntimeStatus(eventRecord.message.trim(), normalizeRuntime(eventRecord.runtime));
600
- changed = true;
601
- break;
602
- }
603
- case 'error': {
604
- // Stream error
605
- const message = eventRecord.message;
606
- parts.push({
607
- type: 'text',
608
- text: `\n\n**Stream Error:** ${redactSensitiveText(message)}`,
609
- });
610
- currentTextId = null;
611
- changed = true;
612
- break;
613
- }
614
- case 'done': {
615
- // Stream completed cleanly — usage data is optional
616
- // No state change needed; just marks end of SSE stream
617
- break;
618
- }
619
- default:
620
- // Ignore unknown event types
621
- break;
622
- }
623
- }
624
- // Emit at most once per coalescing window, not per SSE line/batch
625
- if (changed) {
626
- scheduleEmit();
627
- }
628
- if (done)
629
- break;
630
- }
631
- }
632
- finally {
633
- signal?.removeEventListener('abort', cancelOnAbort);
634
- if (signal?.aborted) {
635
- // Release the underlying connection; safe if already cancelled/closed.
636
- try {
637
- await reader.cancel();
638
- }
639
- catch { /* stream already settled */ }
640
- }
641
- reader.releaseLock();
642
- // Terminal state (completion, error, abort) must never be delayed:
643
- // flush any pending coalesced snapshot and the batched files-changed
644
- // notification before the caller observes the run as finished.
645
- flushEmit();
646
- filesChanged?.flush();
647
- }
648
- // Finalize any tool calls still in running/pending state
649
- // (stream ended unexpectedly — abort, network error, step limit)
650
- let finalized = false;
651
- for (const tc of toolCalls.values()) {
652
- if (tc.state === 'running' || tc.state === 'pending') {
653
- tc.state = 'error';
654
- tc.output = tc.output ?? 'Stream ended before tool completed';
655
- touch(tc);
656
- finalized = true;
657
- }
658
- }
659
- if (finalized) {
660
- onUpdate(buildMessage());
661
- }
662
- return buildMessage();
663
- }
1
+ export * from './stream/stream-consumer.js';
664
2
  //# sourceMappingURL=stream-consumer.js.map