@geminixiang/mikan 1.0.0-beta.44 → 1.0.0-beta.46

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 (422) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +12 -19
  3. package/dist/adapter.d.ts +1 -1
  4. package/dist/adapter.d.ts.map +1 -1
  5. package/dist/adapter.js.map +1 -1
  6. package/dist/adapters/discord/bot.d.ts +3 -1
  7. package/dist/adapters/discord/bot.d.ts.map +1 -1
  8. package/dist/adapters/discord/bot.js +143 -141
  9. package/dist/adapters/discord/bot.js.map +1 -1
  10. package/dist/adapters/discord/context.d.ts +2 -8
  11. package/dist/adapters/discord/context.d.ts.map +1 -1
  12. package/dist/adapters/discord/context.js +1 -1
  13. package/dist/adapters/discord/context.js.map +1 -1
  14. package/dist/adapters/discord/format.d.ts.map +1 -1
  15. package/dist/adapters/discord/format.js +2 -4
  16. package/dist/adapters/discord/format.js.map +1 -1
  17. package/dist/adapters/github/bot.d.ts.map +1 -1
  18. package/dist/adapters/github/bot.js +1 -4
  19. package/dist/adapters/github/bot.js.map +1 -1
  20. package/dist/adapters/github/context.d.ts +2 -9
  21. package/dist/adapters/github/context.d.ts.map +1 -1
  22. package/dist/adapters/github/context.js.map +1 -1
  23. package/dist/adapters/github/github-ops.d.ts +4 -17
  24. package/dist/adapters/github/github-ops.d.ts.map +1 -1
  25. package/dist/adapters/github/github-ops.js +17 -86
  26. package/dist/adapters/github/github-ops.js.map +1 -1
  27. package/dist/adapters/github/tool-pack.d.ts.map +1 -1
  28. package/dist/adapters/github/tool-pack.js +0 -1
  29. package/dist/adapters/github/tool-pack.js.map +1 -1
  30. package/dist/adapters/github/tools/checks.d.ts +0 -1
  31. package/dist/adapters/github/tools/checks.d.ts.map +1 -1
  32. package/dist/adapters/github/tools/checks.js +3 -22
  33. package/dist/adapters/github/tools/checks.js.map +1 -1
  34. package/dist/adapters/github/types.d.ts +0 -33
  35. package/dist/adapters/github/types.d.ts.map +1 -1
  36. package/dist/adapters/github/types.js.map +1 -1
  37. package/dist/adapters/progressive-renderer.d.ts.map +1 -1
  38. package/dist/adapters/progressive-renderer.js +311 -318
  39. package/dist/adapters/progressive-renderer.js.map +1 -1
  40. package/dist/adapters/slack/blocks.d.ts.map +1 -1
  41. package/dist/adapters/slack/blocks.js +1 -4
  42. package/dist/adapters/slack/blocks.js.map +1 -1
  43. package/dist/adapters/slack/bot.d.ts +12 -0
  44. package/dist/adapters/slack/bot.d.ts.map +1 -1
  45. package/dist/adapters/slack/bot.js +158 -178
  46. package/dist/adapters/slack/bot.js.map +1 -1
  47. package/dist/adapters/slack/context.d.ts +2 -8
  48. package/dist/adapters/slack/context.d.ts.map +1 -1
  49. package/dist/adapters/slack/context.js +1 -1
  50. package/dist/adapters/slack/context.js.map +1 -1
  51. package/dist/adapters/slack/response-lifecycle.d.ts.map +1 -1
  52. package/dist/adapters/slack/response-lifecycle.js +135 -123
  53. package/dist/adapters/slack/response-lifecycle.js.map +1 -1
  54. package/dist/adapters/slack/stream-limits.d.ts +1 -1
  55. package/dist/adapters/slack/stream-limits.js +1 -1
  56. package/dist/adapters/slack/stream-limits.js.map +1 -1
  57. package/dist/adapters/slack/types.d.ts +4 -0
  58. package/dist/adapters/slack/types.d.ts.map +1 -1
  59. package/dist/adapters/slack/types.js.map +1 -1
  60. package/dist/adapters/telegram/context.d.ts +2 -8
  61. package/dist/adapters/telegram/context.d.ts.map +1 -1
  62. package/dist/adapters/telegram/context.js +1 -2
  63. package/dist/adapters/telegram/context.js.map +1 -1
  64. package/dist/adapters/types.d.ts +11 -5
  65. package/dist/adapters/types.d.ts.map +1 -1
  66. package/dist/adapters/types.js.map +1 -1
  67. package/dist/agent/catalog.d.ts +6 -18
  68. package/dist/agent/catalog.d.ts.map +1 -1
  69. package/dist/agent/catalog.js +19 -155
  70. package/dist/agent/catalog.js.map +1 -1
  71. package/dist/agent/execution.d.ts +0 -7
  72. package/dist/agent/execution.d.ts.map +1 -1
  73. package/dist/agent/execution.js +23 -21
  74. package/dist/agent/execution.js.map +1 -1
  75. package/dist/agent/presenter.d.ts +7 -9
  76. package/dist/agent/presenter.d.ts.map +1 -1
  77. package/dist/agent/presenter.js +355 -357
  78. package/dist/agent/presenter.js.map +1 -1
  79. package/dist/agent/prompt.d.ts +5 -12
  80. package/dist/agent/prompt.d.ts.map +1 -1
  81. package/dist/agent/prompt.js +56 -81
  82. package/dist/agent/prompt.js.map +1 -1
  83. package/dist/agent/runner.d.ts +0 -7
  84. package/dist/agent/runner.d.ts.map +1 -1
  85. package/dist/agent/runner.js +255 -308
  86. package/dist/agent/runner.js.map +1 -1
  87. package/dist/agent/types.d.ts +21 -17
  88. package/dist/agent/types.d.ts.map +1 -1
  89. package/dist/agent/types.js +0 -1
  90. package/dist/agent/types.js.map +1 -1
  91. package/dist/cli/boot.d.ts.map +1 -1
  92. package/dist/cli/boot.js +7 -10
  93. package/dist/cli/boot.js.map +1 -1
  94. package/dist/cli/onboard.d.ts +10 -0
  95. package/dist/cli/onboard.d.ts.map +1 -0
  96. package/dist/cli/onboard.js +237 -0
  97. package/dist/cli/onboard.js.map +1 -0
  98. package/dist/cli/types.d.ts +8 -3
  99. package/dist/cli/types.d.ts.map +1 -1
  100. package/dist/cli/types.js.map +1 -1
  101. package/dist/commands/auto-reply.d.ts.map +1 -1
  102. package/dist/commands/auto-reply.js +5 -12
  103. package/dist/commands/auto-reply.js.map +1 -1
  104. package/dist/commands/manifest.d.ts.map +1 -1
  105. package/dist/commands/manifest.js +9 -16
  106. package/dist/commands/manifest.js.map +1 -1
  107. package/dist/commands/new.d.ts.map +1 -1
  108. package/dist/commands/new.js +15 -10
  109. package/dist/commands/new.js.map +1 -1
  110. package/dist/commands/registry.d.ts.map +1 -1
  111. package/dist/commands/registry.js +0 -2
  112. package/dist/commands/registry.js.map +1 -1
  113. package/dist/commands/sandbox.d.ts.map +1 -1
  114. package/dist/commands/sandbox.js +89 -70
  115. package/dist/commands/sandbox.js.map +1 -1
  116. package/dist/commands/session-view.js +9 -2
  117. package/dist/commands/session-view.js.map +1 -1
  118. package/dist/commands/types.d.ts +4 -3
  119. package/dist/commands/types.d.ts.map +1 -1
  120. package/dist/commands/types.js.map +1 -1
  121. package/dist/config.d.ts +13 -17
  122. package/dist/config.d.ts.map +1 -1
  123. package/dist/config.js +39 -37
  124. package/dist/config.js.map +1 -1
  125. package/dist/dream/index.d.ts +20 -0
  126. package/dist/dream/index.d.ts.map +1 -0
  127. package/dist/dream/index.js +253 -0
  128. package/dist/dream/index.js.map +1 -0
  129. package/dist/dream/types.d.ts +30 -0
  130. package/dist/dream/types.d.ts.map +1 -0
  131. package/dist/dream/types.js.map +1 -0
  132. package/dist/env-manifest.d.ts.map +1 -1
  133. package/dist/env-manifest.js +2 -34
  134. package/dist/env-manifest.js.map +1 -1
  135. package/dist/execution-resolver.d.ts +9 -2
  136. package/dist/execution-resolver.d.ts.map +1 -1
  137. package/dist/execution-resolver.js +26 -27
  138. package/dist/execution-resolver.js.map +1 -1
  139. package/dist/harness/event-format.d.ts +1 -2
  140. package/dist/harness/event-format.d.ts.map +1 -1
  141. package/dist/harness/event-format.js +9 -15
  142. package/dist/harness/event-format.js.map +1 -1
  143. package/dist/harness/index.d.ts +1 -7
  144. package/dist/harness/index.d.ts.map +1 -1
  145. package/dist/harness/index.js +0 -4
  146. package/dist/harness/index.js.map +1 -1
  147. package/dist/harness/models.d.ts.map +1 -1
  148. package/dist/harness/models.js +15 -35
  149. package/dist/harness/models.js.map +1 -1
  150. package/dist/harness/runner.d.ts +7 -16
  151. package/dist/harness/runner.d.ts.map +1 -1
  152. package/dist/harness/runner.js +13 -131
  153. package/dist/harness/runner.js.map +1 -1
  154. package/dist/harness/session-store.d.ts +1 -1
  155. package/dist/harness/session-store.d.ts.map +1 -1
  156. package/dist/harness/session-store.js +1 -1
  157. package/dist/harness/session-store.js.map +1 -1
  158. package/dist/harness/subagent-runner.d.ts +2 -2
  159. package/dist/harness/subagent-runner.d.ts.map +1 -1
  160. package/dist/harness/subagent-runner.js +157 -162
  161. package/dist/harness/subagent-runner.js.map +1 -1
  162. package/dist/harness/types.d.ts +1 -13
  163. package/dist/harness/types.d.ts.map +1 -1
  164. package/dist/harness/types.js.map +1 -1
  165. package/dist/index.d.ts +3 -9
  166. package/dist/index.d.ts.map +1 -1
  167. package/dist/index.js +1 -5
  168. package/dist/index.js.map +1 -1
  169. package/dist/main.js +31 -212
  170. package/dist/main.js.map +1 -1
  171. package/dist/mcp/catalog.d.ts +5 -0
  172. package/dist/mcp/catalog.d.ts.map +1 -0
  173. package/dist/mcp/catalog.js +135 -0
  174. package/dist/mcp/catalog.js.map +1 -0
  175. package/dist/mcp/loader.d.ts.map +1 -1
  176. package/dist/mcp/loader.js +3 -6
  177. package/dist/mcp/loader.js.map +1 -1
  178. package/dist/mcp/types.d.ts +22 -0
  179. package/dist/mcp/types.d.ts.map +1 -1
  180. package/dist/mcp/types.js.map +1 -1
  181. package/dist/office/index.d.ts +136 -8
  182. package/dist/office/index.d.ts.map +1 -1
  183. package/dist/office/index.js +1050 -9
  184. package/dist/office/index.js.map +1 -1
  185. package/dist/office/types.d.ts +19 -1
  186. package/dist/office/types.d.ts.map +1 -1
  187. package/dist/office/types.js.map +1 -1
  188. package/dist/packages/index.d.ts +168 -5
  189. package/dist/packages/index.d.ts.map +1 -1
  190. package/dist/packages/index.js +749 -5
  191. package/dist/packages/index.js.map +1 -1
  192. package/dist/packages/types.d.ts +1 -5
  193. package/dist/packages/types.d.ts.map +1 -1
  194. package/dist/packages/types.js.map +1 -1
  195. package/dist/provisioner.d.ts +2 -9
  196. package/dist/provisioner.d.ts.map +1 -1
  197. package/dist/provisioner.js +3 -12
  198. package/dist/provisioner.js.map +1 -1
  199. package/dist/runtime/conversation-runtime.d.ts.map +1 -1
  200. package/dist/runtime/conversation-runtime.js +117 -380
  201. package/dist/runtime/conversation-runtime.js.map +1 -1
  202. package/dist/runtime/session-lifecycle.d.ts +32 -18
  203. package/dist/runtime/session-lifecycle.d.ts.map +1 -1
  204. package/dist/runtime/session-lifecycle.js +159 -46
  205. package/dist/runtime/session-lifecycle.js.map +1 -1
  206. package/dist/runtime/types.d.ts +4 -26
  207. package/dist/runtime/types.d.ts.map +1 -1
  208. package/dist/runtime/types.js.map +1 -1
  209. package/dist/sandbox/cloudflare.d.ts.map +1 -1
  210. package/dist/sandbox/cloudflare.js +2 -3
  211. package/dist/sandbox/cloudflare.js.map +1 -1
  212. package/dist/sandbox/container.d.ts +0 -1
  213. package/dist/sandbox/container.d.ts.map +1 -1
  214. package/dist/sandbox/container.js +2 -3
  215. package/dist/sandbox/container.js.map +1 -1
  216. package/dist/sandbox/host.d.ts.map +1 -1
  217. package/dist/sandbox/host.js +4 -2
  218. package/dist/sandbox/host.js.map +1 -1
  219. package/dist/sandbox/identity.d.ts +10 -19
  220. package/dist/sandbox/identity.d.ts.map +1 -1
  221. package/dist/sandbox/identity.js +8 -8
  222. package/dist/sandbox/identity.js.map +1 -1
  223. package/dist/sandbox/index.d.ts +7 -10
  224. package/dist/sandbox/index.d.ts.map +1 -1
  225. package/dist/sandbox/index.js +45 -16
  226. package/dist/sandbox/index.js.map +1 -1
  227. package/dist/sandbox/types.d.ts +13 -45
  228. package/dist/sandbox/types.d.ts.map +1 -1
  229. package/dist/sandbox/types.js.map +1 -1
  230. package/dist/sandbox/utils.d.ts +5 -0
  231. package/dist/sandbox/utils.d.ts.map +1 -1
  232. package/dist/sandbox/utils.js +10 -0
  233. package/dist/sandbox/utils.js.map +1 -1
  234. package/dist/sessions/chat-history-sync.d.ts +1 -3
  235. package/dist/sessions/chat-history-sync.d.ts.map +1 -1
  236. package/dist/sessions/chat-history-sync.js +58 -11
  237. package/dist/sessions/chat-history-sync.js.map +1 -1
  238. package/dist/sessions/migrate-v3.d.ts +2 -5
  239. package/dist/sessions/migrate-v3.d.ts.map +1 -1
  240. package/dist/sessions/migrate-v3.js +34 -4
  241. package/dist/sessions/migrate-v3.js.map +1 -1
  242. package/dist/sessions/store.d.ts +5 -6
  243. package/dist/sessions/store.d.ts.map +1 -1
  244. package/dist/sessions/store.js +62 -2
  245. package/dist/sessions/store.js.map +1 -1
  246. package/dist/sessions/types.d.ts +9 -0
  247. package/dist/sessions/types.d.ts.map +1 -1
  248. package/dist/sessions/types.js.map +1 -1
  249. package/dist/tools/bash.d.ts.map +1 -1
  250. package/dist/tools/bash.js +2 -10
  251. package/dist/tools/bash.js.map +1 -1
  252. package/dist/tools/read.js +2 -2
  253. package/dist/tools/read.js.map +1 -1
  254. package/dist/tools/sandbox.d.ts.map +1 -1
  255. package/dist/tools/sandbox.js +2 -3
  256. package/dist/tools/sandbox.js.map +1 -1
  257. package/dist/tools/subagent.d.ts +1 -1
  258. package/dist/tools/subagent.js.map +1 -1
  259. package/dist/types.d.ts +38 -127
  260. package/dist/types.d.ts.map +1 -1
  261. package/dist/types.js.map +1 -1
  262. package/dist/vault/index.d.ts +9 -2
  263. package/dist/vault/index.d.ts.map +1 -1
  264. package/dist/vault/index.js +29 -5
  265. package/dist/vault/index.js.map +1 -1
  266. package/dist/web/admin/portal.d.ts +12 -1
  267. package/dist/web/admin/portal.d.ts.map +1 -1
  268. package/dist/web/admin/portal.js +437 -422
  269. package/dist/web/admin/portal.js.map +1 -1
  270. package/dist/web/admin/types.d.ts +2 -2
  271. package/dist/web/admin/types.d.ts.map +1 -1
  272. package/dist/web/admin/types.js.map +1 -1
  273. package/dist/web/login/portal.d.ts +7 -1
  274. package/dist/web/login/portal.d.ts.map +1 -1
  275. package/dist/web/login/portal.js +143 -78
  276. package/dist/web/login/portal.js.map +1 -1
  277. package/dist/web/portal-shell.d.ts +1 -0
  278. package/dist/web/portal-shell.d.ts.map +1 -1
  279. package/dist/web/portal-shell.js +12 -1
  280. package/dist/web/portal-shell.js.map +1 -1
  281. package/dist/web/server.d.ts +3 -3
  282. package/dist/web/server.d.ts.map +1 -1
  283. package/dist/web/server.js.map +1 -1
  284. package/dist/web/session-view/portal.d.ts +8 -1
  285. package/dist/web/session-view/portal.d.ts.map +1 -1
  286. package/dist/web/session-view/portal.js +609 -132
  287. package/dist/web/session-view/portal.js.map +1 -1
  288. package/dist/web/session-view/types.d.ts +8 -0
  289. package/dist/web/session-view/types.d.ts.map +1 -1
  290. package/dist/web/session-view/types.js.map +1 -1
  291. package/dist/workspace-projection/index.d.ts +14 -2
  292. package/dist/workspace-projection/index.d.ts.map +1 -1
  293. package/dist/workspace-projection/index.js +102 -14
  294. package/dist/workspace-projection/index.js.map +1 -1
  295. package/dist/workspace-projection/types.d.ts +14 -1
  296. package/dist/workspace-projection/types.d.ts.map +1 -1
  297. package/dist/workspace-projection/types.js.map +1 -1
  298. package/package.json +3 -5
  299. package/dist/adapters/github/cloudbuild.d.ts +0 -19
  300. package/dist/adapters/github/cloudbuild.d.ts.map +0 -1
  301. package/dist/adapters/github/cloudbuild.js +0 -71
  302. package/dist/adapters/github/cloudbuild.js.map +0 -1
  303. package/dist/adapters/github/gcp-auth.d.ts +0 -28
  304. package/dist/adapters/github/gcp-auth.d.ts.map +0 -1
  305. package/dist/adapters/github/gcp-auth.js +0 -196
  306. package/dist/adapters/github/gcp-auth.js.map +0 -1
  307. package/dist/agent/index.d.ts +0 -9
  308. package/dist/agent/index.d.ts.map +0 -1
  309. package/dist/agent/index.js +0 -8
  310. package/dist/agent/index.js.map +0 -1
  311. package/dist/cli/ext-dev.d.ts +0 -2
  312. package/dist/cli/ext-dev.d.ts.map +0 -1
  313. package/dist/cli/ext-dev.js +0 -188
  314. package/dist/cli/ext-dev.js.map +0 -1
  315. package/dist/cli/ext.d.ts +0 -2
  316. package/dist/cli/ext.d.ts.map +0 -1
  317. package/dist/cli/ext.js +0 -324
  318. package/dist/cli/ext.js.map +0 -1
  319. package/dist/commands/extensions.d.ts +0 -26
  320. package/dist/commands/extensions.d.ts.map +0 -1
  321. package/dist/commands/extensions.js +0 -103
  322. package/dist/commands/extensions.js.map +0 -1
  323. package/dist/extension-schedules.d.ts +0 -31
  324. package/dist/extension-schedules.d.ts.map +0 -1
  325. package/dist/extension-schedules.js +0 -229
  326. package/dist/extension-schedules.js.map +0 -1
  327. package/dist/harness/auth.d.ts +0 -17
  328. package/dist/harness/auth.d.ts.map +0 -1
  329. package/dist/harness/auth.js +0 -92
  330. package/dist/harness/auth.js.map +0 -1
  331. package/dist/harness/extensions/loader.d.ts +0 -40
  332. package/dist/harness/extensions/loader.d.ts.map +0 -1
  333. package/dist/harness/extensions/loader.js +0 -723
  334. package/dist/harness/extensions/loader.js.map +0 -1
  335. package/dist/harness/extensions/registry.d.ts +0 -155
  336. package/dist/harness/extensions/registry.d.ts.map +0 -1
  337. package/dist/harness/extensions/registry.js +0 -420
  338. package/dist/harness/extensions/registry.js.map +0 -1
  339. package/dist/harness/extensions/types.d.ts +0 -665
  340. package/dist/harness/extensions/types.d.ts.map +0 -1
  341. package/dist/harness/extensions/types.js.map +0 -1
  342. package/dist/office/address.d.ts +0 -31
  343. package/dist/office/address.d.ts.map +0 -1
  344. package/dist/office/address.js +0 -113
  345. package/dist/office/address.js.map +0 -1
  346. package/dist/office/layout.d.ts +0 -27
  347. package/dist/office/layout.d.ts.map +0 -1
  348. package/dist/office/layout.js +0 -97
  349. package/dist/office/layout.js.map +0 -1
  350. package/dist/office/migration.d.ts +0 -44
  351. package/dist/office/migration.d.ts.map +0 -1
  352. package/dist/office/migration.js +0 -255
  353. package/dist/office/migration.js.map +0 -1
  354. package/dist/office/registry.d.ts +0 -75
  355. package/dist/office/registry.d.ts.map +0 -1
  356. package/dist/office/registry.js +0 -646
  357. package/dist/office/registry.js.map +0 -1
  358. package/dist/packages/admin.d.ts +0 -17
  359. package/dist/packages/admin.d.ts.map +0 -1
  360. package/dist/packages/admin.js +0 -98
  361. package/dist/packages/admin.js.map +0 -1
  362. package/dist/packages/inspect.d.ts +0 -11
  363. package/dist/packages/inspect.d.ts.map +0 -1
  364. package/dist/packages/inspect.js +0 -98
  365. package/dist/packages/inspect.js.map +0 -1
  366. package/dist/packages/materialize.d.ts +0 -40
  367. package/dist/packages/materialize.d.ts.map +0 -1
  368. package/dist/packages/materialize.js +0 -297
  369. package/dist/packages/materialize.js.map +0 -1
  370. package/dist/packages/resolve.d.ts +0 -25
  371. package/dist/packages/resolve.d.ts.map +0 -1
  372. package/dist/packages/resolve.js +0 -208
  373. package/dist/packages/resolve.js.map +0 -1
  374. package/dist/packages/source.d.ts +0 -39
  375. package/dist/packages/source.d.ts.map +0 -1
  376. package/dist/packages/source.js +0 -189
  377. package/dist/packages/source.js.map +0 -1
  378. package/dist/sandbox/errors.d.ts +0 -6
  379. package/dist/sandbox/errors.d.ts.map +0 -1
  380. package/dist/sandbox/errors.js +0 -11
  381. package/dist/sandbox/errors.js.map +0 -1
  382. package/dist/sandbox/firecracker.d.ts +0 -18
  383. package/dist/sandbox/firecracker.d.ts.map +0 -1
  384. package/dist/sandbox/firecracker.js +0 -223
  385. package/dist/sandbox/firecracker.js.map +0 -1
  386. package/dist/sandbox/gondolin.d.ts +0 -57
  387. package/dist/sandbox/gondolin.d.ts.map +0 -1
  388. package/dist/sandbox/gondolin.js +0 -764
  389. package/dist/sandbox/gondolin.js.map +0 -1
  390. package/dist/sandbox/image.d.ts +0 -3
  391. package/dist/sandbox/image.d.ts.map +0 -1
  392. package/dist/sandbox/image.js +0 -29
  393. package/dist/sandbox/image.js.map +0 -1
  394. package/dist/sessions/conversation-log.d.ts +0 -9
  395. package/dist/sessions/conversation-log.d.ts.map +0 -1
  396. package/dist/sessions/conversation-log.js +0 -50
  397. package/dist/sessions/conversation-log.js.map +0 -1
  398. package/dist/sessions/rotation.d.ts +0 -2
  399. package/dist/sessions/rotation.d.ts.map +0 -1
  400. package/dist/sessions/rotation.js +0 -41
  401. package/dist/sessions/rotation.js.map +0 -1
  402. package/dist/vault/disabled.d.ts +0 -9
  403. package/dist/vault/disabled.d.ts.map +0 -1
  404. package/dist/vault/disabled.js +0 -25
  405. package/dist/vault/disabled.js.map +0 -1
  406. package/dist/web/admin/store.d.ts +0 -13
  407. package/dist/web/admin/store.d.ts.map +0 -1
  408. package/dist/web/admin/store.js +0 -14
  409. package/dist/web/admin/store.js.map +0 -1
  410. package/dist/web/login/store.d.ts +0 -8
  411. package/dist/web/login/store.d.ts.map +0 -1
  412. package/dist/web/login/store.js +0 -15
  413. package/dist/web/login/store.js.map +0 -1
  414. package/dist/web/session-view/service.d.ts +0 -6
  415. package/dist/web/session-view/service.d.ts.map +0 -1
  416. package/dist/web/session-view/service.js +0 -517
  417. package/dist/web/session-view/service.js.map +0 -1
  418. package/dist/web/session-view/store.d.ts +0 -8
  419. package/dist/web/session-view/store.d.ts.map +0 -1
  420. package/dist/web/session-view/store.js +0 -15
  421. package/dist/web/session-view/store.js.map +0 -1
  422. /package/dist/{harness/extensions → dream}/types.js +0 -0
@@ -25,416 +25,409 @@ export function formatMarkdownToolResult(result) {
25
25
  * rate with it instead of queueing work it cannot deliver.
26
26
  */
27
27
  const DEFAULT_FLUSH_INTERVAL_MS = 1000;
28
- export function createProgressiveRenderer(platform) {
29
- const state = {
30
- responseId: platform.initialResponseId ?? null,
31
- source: "",
32
- working: true,
33
- streamActive: false,
34
- streamUnavailable: false,
35
- streamedSource: "",
36
- pendingChars: 0,
37
- lastFlushAt: 0,
38
- resetDelta: false,
39
- typingInterval: null,
40
- typingFailureWarned: false,
41
- extraIds: [],
42
- continuationIds: [],
43
- };
44
- const sanitize = platform.sanitize ?? ((text) => text);
45
- const reportResponseError = platform.responseErrorContext
46
- ? createChatResponseErrorReporter(() => platform.responseErrorContext(state.responseId))
47
- : (err, operation, extra) => platform.reportError?.(err, operation, extra ?? {}, state.responseId);
48
- const now = Date.now;
49
- const flushIntervalMs = platform.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS;
50
- function stopTyping() {
51
- if (state.typingInterval !== null) {
52
- clearInterval(state.typingInterval);
53
- state.typingInterval = null;
28
+ class ProgressiveRenderer {
29
+ constructor(platform) {
30
+ this.platform = platform;
31
+ this.now = Date.now;
32
+ this.queueTail = Promise.resolve();
33
+ this.state = {
34
+ responseId: platform.initialResponseId ?? null,
35
+ source: "",
36
+ working: true,
37
+ streamActive: false,
38
+ streamUnavailable: false,
39
+ streamedSource: "",
40
+ pendingChars: 0,
41
+ lastFlushAt: 0,
42
+ resetDelta: false,
43
+ typingInterval: null,
44
+ typingFailureWarned: false,
45
+ extraIds: [],
46
+ continuationIds: [],
47
+ };
48
+ this.sanitize = platform.sanitize ?? ((text) => text);
49
+ this.reportResponseError = platform.responseErrorContext
50
+ ? createChatResponseErrorReporter(() => platform.responseErrorContext(this.state.responseId))
51
+ : undefined;
52
+ this.flushIntervalMs = platform.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS;
53
+ this.responder = this.createResponder();
54
+ }
55
+ createResponder() {
56
+ return {
57
+ respond: (text) => this.respond(text),
58
+ appendResponseDelta: this.platform.supportsDeltas || this.platform.stream
59
+ ? (delta) => this.appendDelta(delta)
60
+ : undefined,
61
+ finishResponse: this.platform.supportsDeltas || this.platform.stream
62
+ ? (finalText) => this.finishResponse(finalText)
63
+ : undefined,
64
+ replaceResponse: (text, options) => this.replaceResponse(text, options),
65
+ replaceSubagentProgress: this.platform.formatSubagentProgress
66
+ ? (progress, finalText) => this.replaceSubagentProgress(progress, finalText)
67
+ : undefined,
68
+ respondDiagnostic: (text, options) => this.respondDiagnostic(text, options),
69
+ respondToolResult: (result) => this.respondToolResult(result),
70
+ setTyping: (isTyping) => this.setTyping(isTyping),
71
+ setWorking: (working) => this.setWorking(working),
72
+ uploadFile: (filePath, title) => this.uploadFile(filePath, title),
73
+ ...(this.platform.react ? { react: this.platform.react } : {}),
74
+ deleteResponse: () => this.deleteResponse(),
75
+ };
76
+ }
77
+ stopTyping() {
78
+ if (this.state.typingInterval !== null) {
79
+ clearInterval(this.state.typingInterval);
80
+ this.state.typingInterval = null;
54
81
  }
55
82
  }
56
- function provisional(text, working) {
57
- if (platform.formatProvisional)
58
- return platform.formatProvisional(text, working);
59
- return working && platform.workingIndicator ? text + platform.workingIndicator : text;
83
+ provisional(text, working) {
84
+ if (this.platform.formatProvisional)
85
+ return this.platform.formatProvisional(text, working);
86
+ return working && this.platform.workingIndicator ? text + this.platform.workingIndicator : text;
60
87
  }
61
- function split(text) {
62
- return splitText(text, platform.maxLength, platform.formatContinuation);
88
+ split(text) {
89
+ return splitText(text, this.platform.maxLength, this.platform.formatContinuation);
63
90
  }
64
- async function postOrUpdate(text) {
65
- if (state.responseId !== null) {
66
- await platform.update(state.responseId, text);
91
+ async postOrUpdate(text) {
92
+ if (this.state.responseId !== null) {
93
+ await this.platform.update(this.state.responseId, text);
67
94
  return;
68
95
  }
69
- if (platform.typing?.stopOnSend)
70
- stopTyping();
71
- state.responseId = await platform.post(text);
96
+ if (this.platform.typing?.stopOnSend)
97
+ this.stopTyping();
98
+ this.state.responseId = await this.platform.post(text);
72
99
  }
73
- /**
74
- * Render `text` as a head message plus however many overflow messages it
75
- * needs.
76
- *
77
- * The overflow is *edited* on later redraws, not re-posted. A streaming
78
- * response redraws roughly once a second, and re-posting meant every redraw
79
- * past the length limit dropped another copy of the tail into the channel —
80
- * a single long answer arrived as one correct message followed by six
81
- * partial duplicates of itself.
82
- *
83
- * Reuse is positional: overflow N always lives in the same message, so the
84
- * text a reader has already scrolled past does not move. A platform whose
85
- * `postExtra` reports no id cannot be edited, and falls back to the old
86
- * behaviour rather than losing the content.
87
- */
88
- async function postSplit(text) {
89
- const [head = text, ...tail] = split(text);
90
- await postOrUpdate(head);
100
+ async postSplit(text) {
101
+ const [head = text, ...tail] = this.split(text);
102
+ await this.postOrUpdate(head);
91
103
  for (const [index, part] of tail.entries()) {
92
- const existing = state.continuationIds[index];
104
+ const existing = this.state.continuationIds[index];
93
105
  if (existing !== undefined) {
94
- await platform.update(String(existing), part);
106
+ await this.platform.update(String(existing), part);
95
107
  continue;
96
108
  }
97
- if (platform.typing?.stopOnSend)
98
- stopTyping();
99
- const id = await platform.postExtra(part, state.responseId);
109
+ if (this.platform.typing?.stopOnSend)
110
+ this.stopTyping();
111
+ const id = await this.platform.postExtra(part, this.state.responseId);
100
112
  if (id !== undefined && id !== null)
101
- state.continuationIds[index] = id;
113
+ this.state.continuationIds[index] = id;
102
114
  }
103
115
  }
104
- async function postExtra(text) {
105
- if (platform.typing?.stopOnSend)
106
- stopTyping();
107
- await platform.postExtra(text, state.responseId);
116
+ async postExtra(text) {
117
+ if (this.platform.typing?.stopOnSend)
118
+ this.stopTyping();
119
+ await this.platform.postExtra(text, this.state.responseId);
108
120
  }
109
- async function stopNativeStream() {
110
- if (!state.streamActive || state.responseId === null || !platform.stream)
121
+ async stopNativeStream() {
122
+ if (!this.state.streamActive || this.state.responseId === null || !this.platform.stream)
111
123
  return;
112
- const streamId = state.responseId;
113
- state.streamActive = false;
114
- state.streamedSource = "";
115
- await platform.stream.stop(streamId);
124
+ const streamId = this.state.responseId;
125
+ this.state.streamActive = false;
126
+ this.state.streamedSource = "";
127
+ await this.platform.stream.stop(streamId);
116
128
  }
117
- async function abandonNativeStream() {
118
- if (!platform.stream || state.responseId === null)
129
+ async abandonNativeStream() {
130
+ if (!this.platform.stream || this.state.responseId === null)
119
131
  return;
120
- const streamId = state.responseId;
121
- state.streamActive = false;
122
- state.streamedSource = "";
123
- await platform.stream.stop(streamId).catch(() => undefined);
124
- if (state.responseId === streamId)
125
- state.responseId = null;
132
+ const streamId = this.state.responseId;
133
+ this.state.streamActive = false;
134
+ this.state.streamedSource = "";
135
+ await this.platform.stream.stop(streamId).catch(() => undefined);
136
+ if (this.state.responseId === streamId)
137
+ this.state.responseId = null;
126
138
  }
127
- async function renderRaw(text, operation, options, canonicalText = text) {
139
+ async renderRaw(text, operation, options, canonicalText = text) {
128
140
  try {
129
- await postSplit(text);
141
+ await this.postSplit(text);
130
142
  return canonicalText;
131
143
  }
132
144
  catch (err) {
133
- if (!platform.handleTooLong)
145
+ if (!this.platform.handleTooLong)
134
146
  throw err;
135
- // Only a length rejection may take the truncating path. Treating every
136
- // failure as "too long" turned a transient rate limit into a response
137
- // cut to a few thousand characters under a notice blaming its length,
138
- // and the retry it triggered kept the limit alive.
139
- if (platform.isTooLongError && !platform.isTooLongError(err))
147
+ if (this.platform.isTooLongError && !this.platform.isTooLongError(err))
140
148
  throw err;
141
- const fallback = await platform.handleTooLong(canonicalText, operation, options, state.responseId, postSplit, () => state.responseId);
149
+ const fallback = await this.platform.handleTooLong({
150
+ text: canonicalText,
151
+ operation,
152
+ options,
153
+ responseId: this.state.responseId,
154
+ write: (fallbackText) => this.postSplit(fallbackText),
155
+ getResponseId: () => this.state.responseId,
156
+ });
142
157
  return fallback.text;
143
158
  }
144
159
  }
145
- async function renderDelta(text) {
146
- if (state.working && !text.trim())
160
+ async renderDelta(text) {
161
+ if (this.state.working && !text.trim())
147
162
  return text;
148
- const prepared = platform.prepareSource?.(text, state.working) ?? text;
149
- const stream = platform.stream;
150
- const display = provisional(prepared, state.working);
151
- if (!stream || state.streamUnavailable) {
152
- await renderRaw(display, "render", undefined, prepared);
163
+ const prepared = this.platform.prepareSource?.(text, this.state.working) ?? text;
164
+ const stream = this.platform.stream;
165
+ const display = this.provisional(prepared, this.state.working);
166
+ if (!stream || this.state.streamUnavailable) {
167
+ await this.renderRaw(display, "render", undefined, prepared);
153
168
  return prepared;
154
169
  }
155
- if (state.responseId !== null && !state.streamActive) {
156
- await renderRaw(display, "render", undefined, prepared);
170
+ if (this.state.responseId !== null && !this.state.streamActive) {
171
+ await this.renderRaw(display, "render", undefined, prepared);
157
172
  return prepared;
158
173
  }
159
- if (state.responseId !== null &&
160
- state.streamActive &&
161
- !prepared.startsWith(state.streamedSource)) {
162
- await abandonNativeStream();
163
- await renderRaw(display, "render", undefined, prepared);
174
+ if (this.state.responseId !== null &&
175
+ this.state.streamActive &&
176
+ !prepared.startsWith(this.state.streamedSource)) {
177
+ await this.abandonNativeStream();
178
+ await this.renderRaw(display, "render", undefined, prepared);
164
179
  return prepared;
165
180
  }
166
181
  try {
167
- if (state.responseId !== null) {
168
- const delta = prepared.slice(state.streamedSource.length);
169
- // Below the threshold the delta stays pending: `state.streamedSource`
170
- // does not advance, so the next tick recomputes it from the same base
171
- // and `renderFinal` flushes the remainder before stopping.
182
+ if (this.state.responseId !== null) {
183
+ const delta = prepared.slice(this.state.streamedSource.length);
172
184
  if (delta && delta.length >= (stream.minDeltaChars ?? 0)) {
173
- await stream.append(state.responseId, delta);
174
- state.streamedSource = prepared;
185
+ await stream.append(this.state.responseId, delta);
186
+ this.state.streamedSource = prepared;
175
187
  }
176
188
  return prepared;
177
189
  }
178
- state.responseId = await stream.start(prepared);
179
- state.streamActive = true;
180
- state.streamedSource = prepared;
190
+ this.state.responseId = await stream.start(prepared);
191
+ this.state.streamActive = true;
192
+ this.state.streamedSource = prepared;
181
193
  return prepared;
182
194
  }
183
195
  catch (err) {
184
- state.streamUnavailable = true;
196
+ this.state.streamUnavailable = true;
185
197
  log.logWarning("Native response streaming unavailable; falling back to message updates", err instanceof Error ? err.message : String(err));
186
- await abandonNativeStream();
187
- await renderRaw(display, "render", undefined, prepared);
198
+ await this.abandonNativeStream();
199
+ await this.renderRaw(display, "render", undefined, prepared);
188
200
  return prepared;
189
201
  }
190
202
  }
191
- async function renderFinal(text) {
192
- const stream = platform.stream;
193
- if (stream && state.streamActive && state.responseId !== null) {
203
+ async renderFinal(text) {
204
+ const stream = this.platform.stream;
205
+ if (stream && this.state.streamActive && this.state.responseId !== null) {
194
206
  let streamed = false;
195
207
  try {
196
- if (text.startsWith(state.streamedSource)) {
197
- const delta = text.slice(state.streamedSource.length);
208
+ if (text.startsWith(this.state.streamedSource)) {
209
+ const delta = text.slice(this.state.streamedSource.length);
198
210
  if (delta)
199
- await stream.append(state.responseId, delta);
200
- await stream.stop(state.responseId);
211
+ await stream.append(this.state.responseId, delta);
212
+ await stream.stop(this.state.responseId);
201
213
  streamed = true;
202
214
  }
203
215
  }
204
216
  catch (err) {
205
- state.streamUnavailable = true;
217
+ this.state.streamUnavailable = true;
206
218
  log.logWarning("Native response streaming unavailable; falling back to message updates", err instanceof Error ? err.message : String(err));
207
219
  }
208
- state.streamActive = false;
209
- state.streamedSource = "";
220
+ this.state.streamActive = false;
221
+ this.state.streamedSource = "";
210
222
  if (streamed) {
211
- if (platform.needsCanonicalRender?.(text))
212
- await renderRaw(text, "render");
223
+ if (this.platform.needsCanonicalRender?.(text))
224
+ await this.renderRaw(text, "render");
213
225
  return text;
214
226
  }
215
- await abandonNativeStream();
227
+ await this.abandonNativeStream();
216
228
  }
217
- if (state.responseId !== null || text)
218
- return renderRaw(text, "render");
229
+ if (this.state.responseId !== null || text)
230
+ return this.renderRaw(text, "render");
219
231
  return text;
220
232
  }
221
- async function run(label, operation, work, extra) {
222
- const operationPromise = queueTail.then(work);
233
+ async run(label, operation, work, extra) {
234
+ const operationPromise = this.queueTail.then(work);
223
235
  const handled = operationPromise.catch(async (err) => {
224
236
  const message = err instanceof Error ? err.message : String(err);
225
- log.logWarning(`${platform.label} ${label} error`, message);
226
- reportResponseError(err, operation, extra());
227
- if (platform.notifySendFailure) {
237
+ log.logWarning(`${this.platform.label} ${label} error`, message);
238
+ this.reportResponseError?.(err, operation, extra());
239
+ if (this.platform.notifySendFailure) {
228
240
  try {
229
- await platform.notifySendFailure(message);
241
+ await this.platform.notifySendFailure(message);
230
242
  }
231
243
  catch {
232
244
  // A secondary notification must not poison the response queue.
233
245
  }
234
246
  }
235
247
  });
236
- queueTail = handled.catch(() => undefined);
248
+ this.queueTail = handled.catch(() => undefined);
237
249
  return handled;
238
250
  }
239
- let queueTail = Promise.resolve();
240
- async function appendDelta(delta) {
241
- await run("appendResponseDelta", "respond", async () => {
251
+ async appendDelta(delta) {
252
+ await this.run("appendResponseDelta", "respond", async () => {
242
253
  if (!delta)
243
254
  return;
244
- if (state.resetDelta) {
245
- state.source = "";
246
- state.pendingChars = 0;
247
- state.resetDelta = false;
255
+ if (this.state.resetDelta) {
256
+ this.state.source = "";
257
+ this.state.pendingChars = 0;
258
+ this.state.resetDelta = false;
248
259
  }
249
- const sanitized = sanitize(delta);
250
- state.source += sanitized;
251
- state.pendingChars += sanitized.length;
252
- const elapsed = now() - state.lastFlushAt;
253
- // A character threshold must not bypass the interval. When it did, a
254
- // fast stream redrew every eighty characters — well over a hundred
255
- // edits for a long answer — and the platform started refusing them.
256
- if (state.lastFlushAt === 0 || (elapsed >= flushIntervalMs && state.pendingChars > 0)) {
257
- state.pendingChars = 0;
258
- state.source = await renderDelta(state.source);
259
- // Stamp on completion: a slow or retrying send pushes the next
260
- // redraw out by however long it took, so pressure never compounds.
261
- state.lastFlushAt = now();
260
+ const sanitized = this.sanitize(delta);
261
+ this.state.source += sanitized;
262
+ this.state.pendingChars += sanitized.length;
263
+ const elapsed = this.now() - this.state.lastFlushAt;
264
+ if (this.state.lastFlushAt === 0 ||
265
+ (elapsed >= this.flushIntervalMs && this.state.pendingChars > 0)) {
266
+ this.state.pendingChars = 0;
267
+ this.state.source = await this.renderDelta(this.state.source);
268
+ this.state.lastFlushAt = this.now();
262
269
  }
263
- }, () => ({ textLength: delta.length, accumulatedLength: state.source.length }));
270
+ }, () => ({ textLength: delta.length, accumulatedLength: this.state.source.length }));
264
271
  }
265
- const responder = {
266
- respond: async (text) => {
267
- await run("respond", "respond", async () => {
268
- const sanitized = sanitize(text);
269
- state.source = state.source ? `${state.source}\n${sanitized}` : sanitized;
270
- state.pendingChars = 0;
271
- state.source = await renderDelta(state.source);
272
- if (state.responseId !== null && platform.logIntermediateResponses) {
273
- platform.logBotResponse?.(text, state.responseId);
274
- }
275
- }, () => ({
276
- phase: state.responseId ? "update" : "initial_post",
277
- textLength: text.length,
278
- accumulatedLength: state.source.length,
279
- }));
280
- },
281
- appendResponseDelta: platform.supportsDeltas || platform.stream ? appendDelta : undefined,
282
- finishResponse: platform.supportsDeltas || platform.stream
283
- ? async (finalText) => {
284
- await run("finishResponse", "set_working", async () => {
285
- if (finalText !== undefined)
286
- state.source = sanitize(finalText);
287
- state.resetDelta = false;
288
- state.pendingChars = 0;
289
- stopTyping();
290
- state.working = false;
291
- state.source = await renderFinal(state.source);
292
- if (state.responseId !== null)
293
- platform.logBotResponse?.(state.source, state.responseId);
294
- await platform.onFinish?.(state.source, state.responseId);
295
- }, () => ({ finalTextLength: finalText?.length }));
272
+ async respond(text) {
273
+ await this.run("respond", "respond", async () => {
274
+ const sanitized = this.sanitize(text);
275
+ this.state.source = this.state.source ? `${this.state.source}\n${sanitized}` : sanitized;
276
+ this.state.pendingChars = 0;
277
+ this.state.source = await this.renderDelta(this.state.source);
278
+ if (this.state.responseId !== null && this.platform.logIntermediateResponses) {
279
+ this.platform.logBotResponse?.(text, this.state.responseId);
296
280
  }
297
- : undefined,
298
- replaceResponse: async (text, options) => {
299
- await run("replaceResponse", "replace_response", async () => {
300
- state.source = sanitize(text);
301
- state.pendingChars = 0;
302
- state.resetDelta = true;
303
- if (state.streamActive)
304
- await stopNativeStream();
305
- if (state.working && !state.source.trim())
306
- return;
307
- // Prepare here too, not only on the delta path. This render is the
308
- // last word on the response, so skipping it let the canonical
309
- // replace overwrite prepared text with the raw source — a Discord
310
- // table converted during streaming reverted to literal pipes the
311
- // moment the run finished.
312
- const prepared = platform.prepareSource?.(state.source, state.working) ?? state.source;
313
- state.source = await renderRaw(provisional(prepared, state.working), "replace", options,
314
- // The prepared text is what was sent, so it is also what the
315
- // renderer must remember it sent.
316
- prepared);
317
- }, () => ({
318
- textLength: text.length,
319
- hadExistingResponse: Boolean(state.responseId),
320
- }));
321
- },
322
- replaceSubagentProgress: platform.formatSubagentProgress
323
- ? async (progress, finalText) => {
324
- const dashboard = platform.formatSubagentProgress(progress);
325
- await responder.replaceResponse(finalText ? `${dashboard}\n\n${finalText}` : dashboard);
281
+ }, () => ({
282
+ phase: this.state.responseId ? "update" : "initial_post",
283
+ textLength: text.length,
284
+ accumulatedLength: this.state.source.length,
285
+ }));
286
+ }
287
+ async finishResponse(finalText) {
288
+ await this.run("finishResponse", "set_working", async () => {
289
+ if (finalText !== undefined)
290
+ this.state.source = this.sanitize(finalText);
291
+ this.state.resetDelta = false;
292
+ this.state.pendingChars = 0;
293
+ this.stopTyping();
294
+ this.state.working = false;
295
+ this.state.source = await this.renderFinal(this.state.source);
296
+ if (this.state.responseId !== null) {
297
+ this.platform.logBotResponse?.(this.state.source, this.state.responseId);
326
298
  }
327
- : undefined,
328
- respondDiagnostic: async (text, options = {}) => {
329
- await run("respondDiagnostic", "respond_diagnostic", async () => {
330
- const ids = platform.postDiagnostic
331
- ? await platform.postDiagnostic(text, options, state.responseId)
332
- : await postDefaultDiagnostic(text, options);
333
- state.extraIds.push(...ids);
334
- }, () => ({ textLength: text.length, style: options.style }));
335
- },
336
- respondToolResult: async (result) => {
337
- await responder.respondDiagnostic(platform.formatToolResult(result));
338
- },
339
- setTyping: async (isTyping) => {
340
- await run("setTyping", "set_working", async () => {
341
- if (platform.setTyping) {
342
- await platform.setTyping(isTyping, state.responseId);
343
- return;
344
- }
345
- const typing = platform.typing;
346
- if (!typing)
299
+ await this.platform.onFinish?.(this.state.source, this.state.responseId);
300
+ }, () => ({ finalTextLength: finalText?.length }));
301
+ }
302
+ async replaceResponse(text, options) {
303
+ await this.run("replaceResponse", "replace_response", async () => {
304
+ this.state.source = this.sanitize(text);
305
+ this.state.pendingChars = 0;
306
+ this.state.resetDelta = true;
307
+ if (this.state.streamActive)
308
+ await this.stopNativeStream();
309
+ if (this.state.working && !this.state.source.trim())
310
+ return;
311
+ const prepared = this.platform.prepareSource?.(this.state.source, this.state.working) ?? this.state.source;
312
+ this.state.source = await this.renderRaw(this.provisional(prepared, this.state.working), "replace", options, prepared);
313
+ }, () => ({ textLength: text.length, hadExistingResponse: Boolean(this.state.responseId) }));
314
+ }
315
+ async replaceSubagentProgress(progress, finalText) {
316
+ const dashboard = this.platform.formatSubagentProgress(progress);
317
+ await this.responder.replaceResponse(finalText ? `${dashboard}\n\n${finalText}` : dashboard);
318
+ }
319
+ async respondDiagnostic(text, options = {}) {
320
+ await this.run("respondDiagnostic", "respond_diagnostic", async () => {
321
+ const ids = this.platform.postDiagnostic
322
+ ? await this.platform.postDiagnostic(text, options, this.state.responseId)
323
+ : await this.postDefaultDiagnostic(text, options);
324
+ this.state.extraIds.push(...ids);
325
+ }, () => ({ textLength: text.length, style: options.style }));
326
+ }
327
+ async respondToolResult(result) {
328
+ await this.responder.respondDiagnostic(this.platform.formatToolResult(result));
329
+ }
330
+ async setTyping(isTyping) {
331
+ await this.run("setTyping", "set_working", async () => {
332
+ if (this.platform.setTyping) {
333
+ await this.platform.setTyping(isTyping, this.state.responseId);
334
+ return;
335
+ }
336
+ const typing = this.platform.typing;
337
+ if (!typing)
338
+ return;
339
+ const onTypingError = (err) => {
340
+ if (this.state.typingFailureWarned)
347
341
  return;
348
- const onTypingError = (err) => {
349
- if (state.typingFailureWarned)
350
- return;
351
- state.typingFailureWarned = true;
352
- log.logWarning(`${platform.label} sendTyping failed (further occurrences suppressed for this session)`, err instanceof Error ? err.message : String(err));
353
- };
354
- if (isTyping && state.typingInterval === null) {
342
+ this.state.typingFailureWarned = true;
343
+ log.logWarning(`${this.platform.label} sendTyping failed (further occurrences suppressed for this session)`, err instanceof Error ? err.message : String(err));
344
+ };
345
+ if (isTyping && this.state.typingInterval === null) {
346
+ typing.send().catch(onTypingError);
347
+ this.state.typingInterval = setInterval(() => {
355
348
  typing.send().catch(onTypingError);
356
- state.typingInterval = setInterval(() => {
357
- typing.send().catch(onTypingError);
358
- }, typing.intervalMs);
359
- }
360
- else if (!isTyping) {
361
- stopTyping();
362
- }
363
- }, () => ({ working: isTyping }));
364
- },
365
- setWorking: async (working) => {
366
- await run("setWorking", "set_working", async () => {
367
- state.working = working;
368
- if (!working)
369
- stopTyping();
370
- await platform.onWorkingChanged?.(working, state.responseId);
371
- if (state.responseId === null || (!platform.workingIndicator && !platform.stream))
372
- return;
373
- if (working && !state.source.trim())
374
- return;
375
- if (state.streamActive && !working) {
376
- await stopNativeStream();
377
- return;
378
- }
379
- if (state.responseId !== null) {
380
- state.source = await renderRaw(provisional(state.source, working), "render", undefined, state.source);
381
- }
382
- }, () => ({ working }));
383
- },
384
- uploadFile: async (filePath, title) => {
385
- if (platform.uploadFile) {
386
- await platform.uploadFile(filePath, title);
349
+ }, typing.intervalMs);
350
+ }
351
+ else if (!isTyping) {
352
+ this.stopTyping();
353
+ }
354
+ }, () => ({ working: isTyping }));
355
+ }
356
+ async setWorking(working) {
357
+ await this.run("setWorking", "set_working", async () => {
358
+ this.state.working = working;
359
+ if (!working)
360
+ this.stopTyping();
361
+ await this.platform.onWorkingChanged?.(working, this.state.responseId);
362
+ if (this.state.responseId === null ||
363
+ (!this.platform.workingIndicator && !this.platform.stream)) {
387
364
  return;
388
365
  }
389
- const note = platform.uploadFallbackNote?.(title ?? filePath);
390
- if (note === undefined)
366
+ if (working && !this.state.source.trim())
367
+ return;
368
+ if (this.state.streamActive && !working) {
369
+ await this.stopNativeStream();
391
370
  return;
392
- await run("uploadFile", "respond_diagnostic", () => postExtra(note), () => ({ filePath }));
393
- },
394
- ...(platform.react ? { react: platform.react } : {}),
395
- deleteResponse: async () => {
396
- await run("deleteResponse", "respond", async () => {
397
- stopTyping();
398
- if (state.streamActive)
399
- await stopNativeStream().catch(() => undefined);
400
- for (const id of [...state.extraIds, ...state.continuationIds]) {
401
- try {
402
- await platform.deleteExtra?.(id);
403
- }
404
- catch {
405
- // Deleting diagnostics is best effort.
406
- }
371
+ }
372
+ if (this.state.responseId !== null) {
373
+ this.state.source = await this.renderRaw(this.provisional(this.state.source, working), "render", undefined, this.state.source);
374
+ }
375
+ }, () => ({ working }));
376
+ }
377
+ async uploadFile(filePath, title) {
378
+ if (this.platform.uploadFile) {
379
+ await this.platform.uploadFile(filePath, title);
380
+ return;
381
+ }
382
+ const note = this.platform.uploadFallbackNote?.(title ?? filePath);
383
+ if (note === undefined)
384
+ return;
385
+ await this.run("uploadFile", "respond_diagnostic", () => this.postExtra(note), () => ({ filePath }));
386
+ }
387
+ async deleteResponse() {
388
+ await this.run("deleteResponse", "respond", async () => {
389
+ this.stopTyping();
390
+ if (this.state.streamActive)
391
+ await this.stopNativeStream().catch(() => undefined);
392
+ for (const id of [...this.state.extraIds, ...this.state.continuationIds]) {
393
+ try {
394
+ await this.platform.deleteExtra?.(id);
395
+ }
396
+ catch {
397
+ // Deleting diagnostics is best effort.
407
398
  }
408
- state.extraIds = [];
409
- state.continuationIds = [];
410
- if (state.responseId !== null) {
411
- try {
412
- await platform.delete?.(state.responseId);
413
- }
414
- catch {
415
- // Deleting the main response is best effort.
416
- }
399
+ }
400
+ this.state.extraIds = [];
401
+ this.state.continuationIds = [];
402
+ if (this.state.responseId !== null) {
403
+ try {
404
+ await this.platform.delete?.(this.state.responseId);
417
405
  }
418
- state.responseId = null;
419
- state.source = "";
420
- state.streamUnavailable = false;
421
- state.streamedSource = "";
422
- state.streamActive = false;
423
- state.resetDelta = false;
424
- state.working = true;
425
- }, () => ({}));
426
- },
427
- };
428
- async function postDefaultDiagnostic(text, options) {
429
- const prefix = options.style === "error" ? platform.errorPrefix : "";
406
+ catch {
407
+ // Deleting the main response is best effort.
408
+ }
409
+ }
410
+ this.state.responseId = null;
411
+ this.state.source = "";
412
+ this.state.streamUnavailable = false;
413
+ this.state.streamedSource = "";
414
+ this.state.streamActive = false;
415
+ this.state.resetDelta = false;
416
+ this.state.working = true;
417
+ }, () => ({}));
418
+ }
419
+ async postDefaultDiagnostic(text, options) {
420
+ const prefix = options.style === "error" ? this.platform.errorPrefix : "";
430
421
  const ids = [];
431
- for (const part of split(sanitize(`${prefix}${text}`))) {
432
- const id = await platform.postExtra(part, state.responseId);
422
+ for (const part of this.split(this.sanitize(`${prefix}${text}`))) {
423
+ const id = await this.platform.postExtra(part, this.state.responseId);
433
424
  if (typeof id === "string" || typeof id === "number")
434
425
  ids.push(id);
435
426
  }
436
427
  return ids;
437
428
  }
438
- return { responder };
429
+ }
430
+ export function createProgressiveRenderer(platform) {
431
+ return { responder: new ProgressiveRenderer(platform).responder };
439
432
  }
440
433
  //# sourceMappingURL=progressive-renderer.js.map