@xopcai/xopc 0.0.302 → 0.0.306

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 (364) hide show
  1. package/README.md +4 -4
  2. package/README.zh-CN.md +4 -4
  3. package/dist/browser-ext/dist/assets/{auth-B_9ZuGDx.js → auth-C3yV1y_l.js} +67 -22
  4. package/dist/browser-ext/dist/background.js +4 -4
  5. package/dist/browser-ext/dist/sidepanel.html +1 -1
  6. package/dist/browser-ext/dist/sidepanel.js +3 -3
  7. package/dist/browser-ext/manifest.json +1 -1
  8. package/dist/extensions/feishu/xopc.extension.json +0 -3
  9. package/dist/extensions/telegram/xopc.extension.json +1 -4
  10. package/dist/extensions/weixin/xopc.extension.json +0 -3
  11. package/dist/gateway/static/root/assets/{activity-store-DCi5rh4e.js → activity-store-DLtim-_I.js} +1 -1
  12. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-C0zP6W2B.js → agent-avatar-dicebear-iQXtiilH.js} +1 -1
  13. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CxOv4ivK.js +1 -0
  14. package/dist/gateway/static/root/assets/agents-DzKx7z3k.js +1 -0
  15. package/dist/gateway/static/root/assets/{api-CAV9PN9i.js → api-DfSU0-lD.js} +1 -1
  16. package/dist/gateway/static/root/assets/api-gpHh07OL.js +1 -0
  17. package/dist/gateway/static/root/assets/app-management-settings-panel-BpYFKz7B.js +1 -0
  18. package/dist/gateway/static/root/assets/{appearance-settings-ZFjV_opr.js → appearance-settings-BQfR5vrq.js} +1 -1
  19. package/dist/gateway/static/root/assets/apps-page-BceB7JHZ.js +1 -0
  20. package/dist/gateway/static/root/assets/{archive-plugin-MaKWrpgC.js → archive-plugin-BxOvZ-ZX.js} +1 -1
  21. package/dist/gateway/static/root/assets/{attachment-load-IfqbP2BN.js → attachment-load-B0FzTMAJ.js} +1 -1
  22. package/dist/gateway/static/root/assets/{automations-page-CeI2NGSO.js → automations-page-BpXuPaPg.js} +1 -1
  23. package/dist/gateway/static/root/assets/automations-workspace-Cn_p8zY_.js +6 -0
  24. package/dist/gateway/static/root/assets/{binary-plugins-jvQ6FaBZ.js → binary-plugins-BP7wfpqy.js} +1 -1
  25. package/dist/gateway/static/root/assets/{block-editor-D4ZIVQbk.css → block-editor-BdOTO0Yo.css} +1 -1
  26. package/dist/gateway/static/root/assets/{block-editor-B7U3qlB3.js → block-editor-oMLvdnOQ.js} +3 -3
  27. package/dist/gateway/static/root/assets/{browser-automation-inputs-BGT0xoTv.js → browser-automation-inputs-DTxSZ00u.js} +1 -1
  28. package/dist/gateway/static/root/assets/{browser-automations-page-DvLAwoiQ.js → browser-automations-page-IbJnwEY4.js} +2 -2
  29. package/dist/gateway/static/root/assets/browser-settings-page-CCUO3G23.js +3 -0
  30. package/dist/gateway/static/root/assets/button-CS04eWY9.js +1 -0
  31. package/dist/gateway/static/root/assets/capabilities-settings-panel-BjMb5H2_.js +8 -0
  32. package/dist/gateway/static/root/assets/channels-settings-P22-_i13.js +1 -0
  33. package/dist/gateway/static/root/assets/{channels-status-swr-C_icwbWj.js → channels-status-swr-D2AmAoty.js} +1 -1
  34. package/dist/gateway/static/root/assets/{chat-terminal-dock-BtL71IOs.js → chat-terminal-dock-B-yI3Mi1.js} +2 -2
  35. package/dist/gateway/static/root/assets/{computer-settings-page-Bu6ZJtmS.js → computer-settings-page-CWx_jnng.js} +1 -1
  36. package/dist/gateway/static/root/assets/connectors-page-BLgPORmH.js +2 -0
  37. package/dist/gateway/static/root/assets/cron-expression-DMRRL4Zg.js +2 -0
  38. package/dist/gateway/static/root/assets/date-picker-BSwL0e6E.js +1 -0
  39. package/dist/gateway/static/root/assets/{dependency-picker-BNugauiZ.js → dependency-picker-BQTspLzC.js} +1 -1
  40. package/dist/gateway/static/root/assets/{desktop-pet-DTy_3-OY.js → desktop-pet-C3lFxDF6.js} +1 -1
  41. package/dist/gateway/static/root/assets/desktop-pet-settings-Y8pjpXFE.js +1 -0
  42. package/dist/gateway/static/root/assets/device-pairing-wizard-DM4_GMzo.js +1 -0
  43. package/dist/gateway/static/root/assets/{extension-debug-page-C3F7RiGW.js → extension-debug-page-CVGiGVcR.js} +1 -1
  44. package/dist/gateway/static/root/assets/{extension-page-C0jhcCT_.js → extension-page-g3JtCP_y.js} +1 -1
  45. package/dist/gateway/static/root/assets/{extension-settings-page-CNvJQkrr.js → extension-settings-page-CjpoKV1f.js} +1 -1
  46. package/dist/gateway/static/root/assets/{gateway-config-swr-D5AM8cyQ.js → gateway-config-swr-BSvXXpKM.js} +1 -1
  47. package/dist/gateway/static/root/assets/gateway-realtime-BDCpS7U1.js +1 -0
  48. package/dist/gateway/static/root/assets/gateway-realtime-store-BGmP1obI.js +1 -0
  49. package/dist/gateway/static/root/assets/gateway-settings-CYG9WCZn.js +1 -0
  50. package/dist/gateway/static/root/assets/{gateway-startup-retry-CSJWdnFs.js → gateway-startup-retry-Caf8g3sC.js} +1 -1
  51. package/dist/gateway/static/root/assets/{heartbeat-settings-Cd1VJsHe.js → heartbeat-settings-Cl834-SS.js} +1 -1
  52. package/dist/gateway/static/root/assets/home-page-CB_XVtIM.js +1 -0
  53. package/dist/gateway/static/root/assets/{image-generation-api-BNh604hw.js → image-generation-api-BwEWBUVC.js} +1 -1
  54. package/dist/gateway/static/root/assets/imports-page-CoMlgSIA.js +1 -0
  55. package/dist/gateway/static/root/assets/index-CI37dTAn.css +1 -0
  56. package/dist/gateway/static/root/assets/index-Do9MltC4.js +79 -0
  57. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-CNq5D4pe.js +1 -0
  58. package/dist/gateway/static/root/assets/local-app-workbench-page-BxQlEje6.js +2 -0
  59. package/dist/gateway/static/root/assets/{local-apps-page-DyrFxW3G.js → local-apps-page-DQnRA598.js} +1 -1
  60. package/dist/gateway/static/root/assets/{locale-store-DLK05Y1a.js → locale-store-D16nmbaN.js} +1 -1
  61. package/dist/gateway/static/root/assets/logs-page-CT5GrcMs.js +2 -0
  62. package/dist/gateway/static/root/assets/management-settings-DKcO5fQ-.js +1 -0
  63. package/dist/gateway/static/root/assets/{markdown-view-B8maDRWh.js → markdown-view-DCp4BlZP.js} +2 -2
  64. package/dist/gateway/static/root/assets/{media-plugins-5DakFba_.js → media-plugins-Cy64sn_C.js} +1 -1
  65. package/dist/gateway/static/root/assets/messages-C-9oo69N.js +3 -0
  66. package/dist/gateway/static/root/assets/note-detail-panel-5dc3LKTL.js +5 -0
  67. package/dist/gateway/static/root/assets/notes-page-AbwxgXuG.js +8 -0
  68. package/dist/gateway/static/root/assets/{page-tabs-DzJpglJJ.js → page-tabs-CgEoHSVT.js} +1 -1
  69. package/dist/gateway/static/root/assets/{popover-select-DldSX8GX.js → popover-select-9i-ZtHXL.js} +1 -1
  70. package/dist/gateway/static/root/assets/{preview-open-alternatives-Dj6LJsuQ.js → preview-open-alternatives-Ck2uKTbf.js} +1 -1
  71. package/dist/gateway/static/root/assets/{proactive-page-CwudBdrQ.js → proactive-page-Dr1mCJhZ.js} +1 -1
  72. package/dist/gateway/static/root/assets/{product-open-page-CujZXOea.js → product-open-page-DbZvJ5GE.js} +1 -1
  73. package/dist/gateway/static/root/assets/project-detail-page-DnE1zI1c.js +1 -0
  74. package/dist/gateway/static/root/assets/projects-page-BD0nLYxk.js +1 -0
  75. package/dist/gateway/static/root/assets/{registry-api-BMFL4vis.js → registry-api-DcQdwpPu.js} +1 -1
  76. package/dist/gateway/static/root/assets/remote-access-hub-TYuE6A3S.js +1 -0
  77. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DV554qyN.js → runtime-tools-settings-panel-CPwdgWKo.js} +2 -2
  78. package/dist/gateway/static/root/assets/{schema-form-Bh2Er67B.js → schema-form-8psK4cFO.js} +1 -1
  79. package/dist/gateway/static/root/assets/sessions-page-BcWDQQFX.js +1 -0
  80. package/dist/gateway/static/root/assets/settings-advanced-gate-DzGQX6Hq.js +1 -0
  81. package/dist/gateway/static/root/assets/{settings-form-section-BsdM7P1d.js → settings-form-section-D_Gsz5rl.js} +1 -1
  82. package/dist/gateway/static/root/assets/{settings-page-3yEAqoME.js → settings-page-C_Tj_mkZ.js} +1 -1
  83. package/dist/gateway/static/root/assets/setup-status-panel-CE2X89qN.js +1 -0
  84. package/dist/gateway/static/root/assets/share-preview-page-B_M_oPsT.js +2 -0
  85. package/dist/gateway/static/root/assets/shares-settings-BL4H9Iym.js +1 -0
  86. package/dist/gateway/static/root/assets/skill-reload-api-WMKIgUOp.js +1 -0
  87. package/dist/gateway/static/root/assets/skills-page-DYgwzl5B.js +2 -0
  88. package/dist/gateway/static/root/assets/{skills-page.utils-dHBD7YqU.js → skills-page.utils-Cuh6s2HM.js} +1 -1
  89. package/dist/gateway/static/root/assets/{system-settings-panel-lItR5Kah.js → system-settings-panel-aassGyNb.js} +1 -1
  90. package/dist/gateway/static/root/assets/task-detail-page-BjeRslap.js +1 -0
  91. package/dist/gateway/static/root/assets/theme-store-RUBQBsFP.js +1 -0
  92. package/dist/gateway/static/root/assets/tunnel-api-DJYcPWIV.js +1 -0
  93. package/dist/gateway/static/root/assets/{use-autosave-DO50_g_S.js → use-autosave-QGYG7oMZ.js} +1 -1
  94. package/dist/gateway/static/root/assets/user-model-page-PrRsd4go.js +2 -0
  95. package/dist/gateway/static/root/assets/{voice-api-key-field-k7tWLXzM.js → voice-api-key-field-D1s0gIRW.js} +1 -1
  96. package/dist/gateway/static/root/assets/{voice-config-api-bZqN8-UF.js → voice-config-api-D2goEn5e.js} +1 -1
  97. package/dist/gateway/static/root/assets/{work-discovery-overlay-BHI6gO_u.js → work-discovery-overlay-DkFW9aJ6.js} +1 -1
  98. package/dist/gateway/static/root/assets/workflow-run-setup-panel-BYToUPUY.js +3 -0
  99. package/dist/gateway/static/root/assets/workflows-page-Z8iZe9YP.js +6 -0
  100. package/dist/gateway/static/root/index.html +14 -12
  101. package/dist/package.js +1 -1
  102. package/dist/packages/gateway-contract/src/device-pairing.js +100 -7
  103. package/dist/packages/gateway-contract/src/gateway-scopes.js +53 -0
  104. package/dist/packages/gateway-contract/src/index.js +2 -0
  105. package/dist/packages/realtime-client/src/index.js +14 -2
  106. package/dist/packages/realtime-protocol/src/index.js +18 -14
  107. package/dist/src/agent/agent-instance-gateway.d.ts +2 -0
  108. package/dist/src/agent/agent-manager.d.ts +2 -0
  109. package/dist/src/agent/agent-manager.js +40 -12
  110. package/dist/src/agent/agent-scope.d.ts +4 -1
  111. package/dist/src/agent/agent-scope.js +19 -3
  112. package/dist/src/agent/commands/command-isolation.js +11 -9
  113. package/dist/src/agent/commands/command-registry.js +18 -33
  114. package/dist/src/agent/context/audit.js +12 -2
  115. package/dist/src/agent/context/coordinator.d.ts +13 -3
  116. package/dist/src/agent/context/coordinator.js +27 -11
  117. package/dist/src/agent/context/execution-context.js +42 -22
  118. package/dist/src/agent/context/execution-context.types.d.ts +4 -2
  119. package/dist/src/agent/context/execution-scope.d.ts +2 -2
  120. package/dist/src/agent/context/execution-scope.js +1 -1
  121. package/dist/src/agent/context/project-context.d.ts +2 -2
  122. package/dist/src/agent/context/project-context.js +3 -3
  123. package/dist/src/agent/embedded/run-for-session.d.ts +1 -0
  124. package/dist/src/agent/embedded/run-for-session.js +7 -1
  125. package/dist/src/agent/inbound/attachment-pipeline.d.ts +2 -0
  126. package/dist/src/agent/inbound/attachment-pipeline.js +3 -3
  127. package/dist/src/agent/inbound/inbound-loop.js +1 -0
  128. package/dist/src/agent/inbound/turn-dispatcher.js +3 -3
  129. package/dist/src/agent/mcp/mcp-stdio-transport.js +5 -2
  130. package/dist/src/agent/memory/compaction-promotion.js +7 -2
  131. package/dist/src/agent/memory/create-memory-manager.js +1 -0
  132. package/dist/src/agent/memory/manager.d.ts +6 -0
  133. package/dist/src/agent/memory/manager.js +74 -39
  134. package/dist/src/agent/memory/runtime.d.ts +3 -3
  135. package/dist/src/agent/memory/runtime.js +11 -4
  136. package/dist/src/agent/orchestration/agent-orchestrator.js +4 -1
  137. package/dist/src/agent/prompt/cache-boundary.d.ts +2 -0
  138. package/dist/src/agent/prompt/cache-boundary.js +10 -1
  139. package/dist/src/agent/service/build-direct-message-content.d.ts +1 -0
  140. package/dist/src/agent/service/build-direct-message-content.js +2 -1
  141. package/dist/src/agent/service/direct-turn-helpers.js +3 -2
  142. package/dist/src/agent/service/process-direct-streaming.d.ts +3 -1
  143. package/dist/src/agent/service/process-direct-streaming.js +3 -2
  144. package/dist/src/agent/service/webchat-tts.d.ts +0 -4
  145. package/dist/src/agent/service/webchat-tts.js +20 -19
  146. package/dist/src/agent/tools/factory.js +3 -3
  147. package/dist/src/agent/tools/knowledge-memory-tool.d.ts +2 -2
  148. package/dist/src/agent/tools/knowledge-memory-tool.js +7 -7
  149. package/dist/src/browser/native-messaging-host.js +2 -2
  150. package/dist/src/channels/attachments/voice-stt-webchat.d.ts +3 -0
  151. package/dist/src/channels/attachments/voice-stt-webchat.js +22 -9
  152. package/dist/src/cli/commands/agent.js +2 -0
  153. package/dist/src/cli/commands/config.js +8 -9
  154. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  155. package/dist/src/cli/commands/extension-marketplace.js +69 -44
  156. package/dist/src/cli/commands/extension-pack.js +0 -2
  157. package/dist/src/cli/commands/extension.js +4 -25
  158. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  159. package/dist/src/cli/commands/onboard/gateway.js +2 -1
  160. package/dist/src/cli/commands/update.js +1 -1
  161. package/dist/src/cli/utils/init-workspace-core.js +5 -2
  162. package/dist/src/config/index.js +2 -2
  163. package/dist/src/config/loader.d.ts +1 -0
  164. package/dist/src/config/loader.js +14 -1
  165. package/dist/src/config/schema.d.ts +10 -3
  166. package/dist/src/config/schema.js +10 -2
  167. package/dist/src/execution-environments/local-worktree-manager.js +17 -15
  168. package/dist/src/execution-environments/store.js +4 -2
  169. package/dist/src/execution-environments/types.d.ts +3 -0
  170. package/dist/src/execution-environments/types.js +2 -1
  171. package/dist/src/execution-environments/worktree-safety.d.ts +8 -0
  172. package/dist/src/execution-environments/worktree-safety.js +43 -0
  173. package/dist/src/extensions/activation-planner.d.ts +1 -1
  174. package/dist/src/extensions/activation-planner.js +1 -1
  175. package/dist/src/extensions/api-version.d.ts +4 -0
  176. package/dist/src/extensions/api-version.js +15 -0
  177. package/dist/src/extensions/api.d.ts +3 -9
  178. package/dist/src/extensions/api.js +26 -32
  179. package/dist/src/extensions/config-validation.d.ts +8 -0
  180. package/dist/src/extensions/config-validation.js +25 -0
  181. package/dist/src/extensions/extension-registry-impl.d.ts +20 -9
  182. package/dist/src/extensions/extension-registry-impl.js +79 -11
  183. package/dist/src/extensions/hooks.d.ts +1 -1
  184. package/dist/src/extensions/index.d.ts +2 -1
  185. package/dist/src/extensions/install-transaction.d.ts +2 -0
  186. package/dist/src/extensions/install-transaction.js +32 -21
  187. package/dist/src/extensions/install.js +18 -1
  188. package/dist/src/extensions/loader.d.ts +5 -5
  189. package/dist/src/extensions/loader.js +109 -47
  190. package/dist/src/extensions/lockfile.d.ts +3 -5
  191. package/dist/src/extensions/lockfile.js +41 -14
  192. package/dist/src/extensions/normalize-manifest.js +6 -60
  193. package/dist/src/extensions/sdk/index.d.ts +3 -2
  194. package/dist/src/extensions/sdk/index.js +2 -2
  195. package/dist/src/extensions/sdk/testing.js +0 -4
  196. package/dist/src/extensions/security.js +5 -7
  197. package/dist/src/extensions/types/core.d.ts +0 -5
  198. package/dist/src/extensions/types/index.d.ts +1 -1
  199. package/dist/src/extensions/types/manifest.d.ts +1 -25
  200. package/dist/src/extensions/types/providers.d.ts +1 -1
  201. package/dist/src/extensions/types/registration.d.ts +0 -12
  202. package/dist/src/extensions/update.js +71 -30
  203. package/dist/src/gateway/heartbeat/service.js +2 -2
  204. package/dist/src/gateway/hono/lib/config-payload.d.ts +3 -1
  205. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +47 -10
  206. package/dist/src/gateway/hono/routes/devices.js +10 -7
  207. package/dist/src/gateway/hono/routes/endpoint-compatibility.js +6 -0
  208. package/dist/src/gateway/hono/routes/extension-gateway.js +0 -33
  209. package/dist/src/gateway/hono/routes/imports.js +1 -1
  210. package/dist/src/gateway/hono/routes/lazy-bundles.js +0 -1
  211. package/dist/src/gateway/hono/routes/local-apps.js +1 -1
  212. package/dist/src/gateway/hono/routes/realtime.js +30 -8
  213. package/dist/src/gateway/hono/routes/update.js +2 -2
  214. package/dist/src/gateway/hono/routes/user-model.js +25 -6
  215. package/dist/src/gateway/index.js +5 -2
  216. package/dist/src/gateway/lock.d.ts +2 -0
  217. package/dist/src/gateway/lock.js +31 -14
  218. package/dist/src/gateway/run-loop.js +3 -2
  219. package/dist/src/gateway/security/gateway-scopes.d.ts +2 -5
  220. package/dist/src/gateway/security/gateway-scopes.js +3 -45
  221. package/dist/src/gateway/security/index.js +2 -1
  222. package/dist/src/gateway/service/config-coordinator.js +1 -1
  223. package/dist/src/gateway/service.js +11 -7
  224. package/dist/src/heartbeat/index.js +1 -1
  225. package/dist/src/imports/importService.d.ts +1 -1
  226. package/dist/src/imports/inventory.js +16 -2
  227. package/dist/src/imports/productImport.js +5 -5
  228. package/dist/src/imports/types.d.ts +3 -3
  229. package/dist/src/infra/exec.d.ts +2 -2
  230. package/dist/src/infra/exec.js +32 -27
  231. package/dist/src/infra/gateway-processes.js +1 -1
  232. package/dist/src/infra/run-command.js +15 -50
  233. package/dist/src/infra/update-restart.js +1 -1
  234. package/dist/src/infra/update-runner.js +2 -2
  235. package/dist/src/infra/update-startup.js +1 -1
  236. package/dist/src/knowledge/connected-knowledge-pipeline.js +13 -3
  237. package/dist/src/knowledge-memory/domain.d.ts +17 -1
  238. package/dist/src/knowledge-memory/index.js +2 -2
  239. package/dist/src/knowledge-memory/repository.d.ts +26 -4
  240. package/dist/src/knowledge-memory/repository.js +171 -36
  241. package/dist/src/mcp/channel-bridge.js +7 -3
  242. package/dist/src/media-understanding/registry.js +6 -1
  243. package/dist/src/migrations/knowledge-memory-read-policy-config.d.ts +2 -0
  244. package/dist/src/migrations/knowledge-memory-read-policy-config.js +48 -0
  245. package/dist/src/migrations/runner.js +2 -1
  246. package/dist/src/process/bounded-output.d.ts +10 -0
  247. package/dist/src/process/bounded-output.js +41 -0
  248. package/dist/src/process/kill-tree.d.ts +6 -17
  249. package/dist/src/process/kill-tree.js +43 -75
  250. package/dist/src/process/process-spec.d.ts +39 -0
  251. package/dist/src/process/process-spec.js +13 -0
  252. package/dist/src/process/run-process.d.ts +4 -0
  253. package/dist/src/process/run-process.js +97 -0
  254. package/dist/src/providers/plugin-registry.d.ts +1 -1
  255. package/dist/src/providers/plugin-registry.js +6 -0
  256. package/dist/src/realtime/runtime.js +3 -1
  257. package/dist/src/session/store.js +1 -1
  258. package/dist/src/storage/sqlite/device-pairing-approval.js +1 -1
  259. package/dist/src/storage/sqlite/index.d.ts +1 -1
  260. package/dist/src/storage/sqlite/index.js +2 -2
  261. package/dist/src/storage/sqlite/migrations/180_execution_environment_ownership.sql +7 -0
  262. package/dist/src/storage/sqlite/migrations/181_knowledge_item_status_events.sql +12 -0
  263. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  264. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  265. package/dist/src/storage/sqlite/schema.js +1 -1
  266. package/dist/src/storage/sqlite/schema.sql +13 -0
  267. package/dist/src/storage/sqlite/transcript-repository.d.ts +4 -0
  268. package/dist/src/storage/sqlite/transcript-repository.js +36 -1
  269. package/dist/src/tui/backends/embedded-backend.d.ts +24 -8
  270. package/dist/src/tui/backends/embedded-backend.js +114 -10
  271. package/dist/src/tui/backends/gateway-realtime-backend.d.ts +18 -0
  272. package/dist/src/tui/backends/gateway-realtime-backend.js +32 -5
  273. package/dist/src/tui/components/assistant-message.d.ts +4 -1
  274. package/dist/src/tui/components/assistant-message.js +10 -2
  275. package/dist/src/tui/components/cell-render-mode.d.ts +4 -0
  276. package/dist/src/tui/components/cell-render-mode.js +1 -0
  277. package/dist/src/tui/components/chat-log.d.ts +17 -4
  278. package/dist/src/tui/components/chat-log.js +68 -50
  279. package/dist/src/tui/components/custom-editor.d.ts +2 -2
  280. package/dist/src/tui/components/custom-editor.js +5 -1
  281. package/dist/src/tui/components/pending-input-preview.d.ts +9 -0
  282. package/dist/src/tui/components/pending-input-preview.js +33 -0
  283. package/dist/src/tui/components/semantic-cell.d.ts +17 -0
  284. package/dist/src/tui/components/semantic-cell.js +29 -0
  285. package/dist/src/tui/components/tool-execution.d.ts +5 -1
  286. package/dist/src/tui/components/tool-execution.js +33 -10
  287. package/dist/src/tui/components/transcript-overlay.d.ts +29 -0
  288. package/dist/src/tui/components/transcript-overlay.js +114 -0
  289. package/dist/src/tui/components/tui-bottom-bar.js +3 -1
  290. package/dist/src/tui/components/user-message.d.ts +5 -1
  291. package/dist/src/tui/components/user-message.js +12 -1
  292. package/dist/src/tui/extension-host/load-extensions.d.ts +1 -1
  293. package/dist/src/tui/extension-host/runtime-context.js +2 -1
  294. package/dist/src/tui/extension-host/runtime.d.ts +1 -1
  295. package/dist/src/tui/format-tui-hotkeys.js +8 -1
  296. package/dist/src/tui/tui-agent-events.js +31 -0
  297. package/dist/src/tui/tui-backend.d.ts +23 -11
  298. package/dist/src/tui/tui-backend.js +1 -9
  299. package/dist/src/tui/tui-chat-input-state.d.ts +25 -0
  300. package/dist/src/tui/tui-chat-input-state.js +36 -0
  301. package/dist/src/tui/tui-command-formatters.js +2 -1
  302. package/dist/src/tui/tui-commands.js +1 -1
  303. package/dist/src/tui/tui-types.d.ts +2 -1
  304. package/dist/src/tui/tui-types.js +2 -1
  305. package/dist/src/tui/tui.js +122 -30
  306. package/dist/src/tui/xopc-tui-keybindings.d.ts +23 -3
  307. package/dist/src/tui/xopc-tui-keybindings.js +22 -2
  308. package/dist/src/user-context/access-policy.d.ts +2 -2
  309. package/dist/src/user-context/access-policy.js +10 -2
  310. package/dist/src/user-context/config.d.ts +23 -6
  311. package/dist/src/user-context/config.js +54 -7
  312. package/dist/src/voice/platform-streams.js +11 -1
  313. package/dist/src/voice/realtime/omniEngine.js +13 -1
  314. package/dist/src/voice/realtime/runtime.js +2 -1
  315. package/dist/src/voice/tts/audio.js +1 -1
  316. package/dist/src/voice/tts/speech-registry.js +6 -1
  317. package/package.json +9 -7
  318. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-D0ITeUFb.js +0 -1
  319. package/dist/gateway/static/root/assets/agents-DcfWhk2S.js +0 -1
  320. package/dist/gateway/static/root/assets/api-fPapljyb.js +0 -1
  321. package/dist/gateway/static/root/assets/app-management-settings-panel-U3yDRzKF.js +0 -1
  322. package/dist/gateway/static/root/assets/apps-page-FgMHY1Pr.js +0 -1
  323. package/dist/gateway/static/root/assets/automations-workspace-DxaiBwrD.js +0 -6
  324. package/dist/gateway/static/root/assets/browser-settings-page-CHrfg3BX.js +0 -3
  325. package/dist/gateway/static/root/assets/button-CGlRPNzi.js +0 -1
  326. package/dist/gateway/static/root/assets/capabilities-settings-panel-DpYDPk_o.js +0 -8
  327. package/dist/gateway/static/root/assets/channels-settings-DMq-NBUQ.js +0 -1
  328. package/dist/gateway/static/root/assets/connectors-page-LsEiI9L5.js +0 -2
  329. package/dist/gateway/static/root/assets/cron-expression-B25FHn4w.js +0 -2
  330. package/dist/gateway/static/root/assets/date-picker-CzVHO7z9.js +0 -1
  331. package/dist/gateway/static/root/assets/desktop-pet-settings-CXfnejTb.js +0 -1
  332. package/dist/gateway/static/root/assets/device-pairing-wizard-CxKwfncn.js +0 -1
  333. package/dist/gateway/static/root/assets/gateway-settings-CQTcIvlZ.js +0 -1
  334. package/dist/gateway/static/root/assets/home-page-B_uyfCGq.js +0 -1
  335. package/dist/gateway/static/root/assets/imports-page-DXNfRmk9.js +0 -1
  336. package/dist/gateway/static/root/assets/index-BAqVpc1H.css +0 -1
  337. package/dist/gateway/static/root/assets/index-hlU8MUEz.js +0 -79
  338. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-CgW5_XVP.js +0 -1
  339. package/dist/gateway/static/root/assets/local-app-workbench-page-C4h3qDRL.js +0 -2
  340. package/dist/gateway/static/root/assets/logs-page-Goy_QHfL.js +0 -2
  341. package/dist/gateway/static/root/assets/management-settings-DgQyGEpR.js +0 -1
  342. package/dist/gateway/static/root/assets/messages-C9h8SImu.js +0 -3
  343. package/dist/gateway/static/root/assets/note-detail-panel-lcZby9NY.js +0 -5
  344. package/dist/gateway/static/root/assets/notes-page-CDGPPI-W.js +0 -8
  345. package/dist/gateway/static/root/assets/project-detail-page-CyAf_sK-.js +0 -1
  346. package/dist/gateway/static/root/assets/projects-page-BW5m_HhZ.js +0 -1
  347. package/dist/gateway/static/root/assets/remote-access-hub-B4JgwB0s.js +0 -1
  348. package/dist/gateway/static/root/assets/sessions-page-D5SmvlQ1.js +0 -1
  349. package/dist/gateway/static/root/assets/settings-advanced-gate-DDALROy_.js +0 -1
  350. package/dist/gateway/static/root/assets/setup-status-panel-BOHNZ-S3.js +0 -1
  351. package/dist/gateway/static/root/assets/share-preview-page-wV056nz2.js +0 -2
  352. package/dist/gateway/static/root/assets/shares-settings-io4NzfJL.js +0 -1
  353. package/dist/gateway/static/root/assets/skill-reload-api-CERFaxLj.js +0 -1
  354. package/dist/gateway/static/root/assets/skills-page-CtwUqvsE.js +0 -2
  355. package/dist/gateway/static/root/assets/task-detail-page-CCKc67a-.js +0 -1
  356. package/dist/gateway/static/root/assets/theme-store-KfFEGMlp.js +0 -1
  357. package/dist/gateway/static/root/assets/tunnel-api-DPyLgmWw.js +0 -1
  358. package/dist/gateway/static/root/assets/user-model-page-CcnGgH1n.js +0 -2
  359. package/dist/gateway/static/root/assets/workflow-run-setup-panel-jEMtNIG8.js +0 -3
  360. package/dist/gateway/static/root/assets/workflows-page-CX4bcAD-.js +0 -6
  361. package/dist/src/extensions/when-context.d.ts +0 -6
  362. package/dist/src/extensions/when-context.js +0 -26
  363. package/dist/src/extensions/when-expression.d.ts +0 -11
  364. package/dist/src/extensions/when-expression.js +0 -213
@@ -0,0 +1,97 @@
1
+ import { createBoundedOutput } from "./bounded-output.js";
2
+ import { terminateProcess } from "./kill-tree.js";
3
+ import { ProcessExitError } from "./process-spec.js";
4
+ import { spawn } from "node:child_process";
5
+ //#region src/process/run-process.ts
6
+ const DEFAULT_MAX_OUTPUT_BYTES = 1024 * 1024;
7
+ function spawnProcess(spec) {
8
+ spec.signal?.throwIfAborted();
9
+ const detached = spec.detached ?? (spec.terminationPolicy === "tree" && process.platform !== "win32");
10
+ const child = spawn(spec.program, [...spec.args ?? []], {
11
+ cwd: spec.cwd,
12
+ env: spec.env ?? process.env,
13
+ stdio: [
14
+ "pipe",
15
+ "pipe",
16
+ "pipe"
17
+ ],
18
+ detached,
19
+ windowsHide: spec.windowsHide ?? true,
20
+ shell: spec.shell ?? false
21
+ });
22
+ const stdout = createBoundedOutput(spec.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES);
23
+ const stderr = createBoundedOutput(spec.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES);
24
+ let timedOut = false;
25
+ let aborted = false;
26
+ let terminationRequested = false;
27
+ let settled = false;
28
+ let timer;
29
+ const terminate = (reason = "cancelled") => {
30
+ if (settled || terminationRequested) return;
31
+ terminationRequested = true;
32
+ timedOut = reason === "timed_out";
33
+ aborted = reason === "cancelled";
34
+ terminateProcess(child, {
35
+ tree: spec.terminationPolicy === "tree",
36
+ detached
37
+ });
38
+ };
39
+ const abort = () => terminate("cancelled");
40
+ spec.signal?.addEventListener("abort", abort, { once: true });
41
+ if (spec.signal?.aborted) abort();
42
+ if (spec.timeoutMs != null && spec.timeoutMs > 0) {
43
+ timer = setTimeout(() => terminate("timed_out"), spec.timeoutMs);
44
+ timer.unref();
45
+ }
46
+ child.stdout?.on("data", (chunk) => {
47
+ stdout.append(chunk);
48
+ spec.onOutput?.("stdout", chunk);
49
+ });
50
+ child.stderr?.on("data", (chunk) => {
51
+ stderr.append(chunk);
52
+ spec.onOutput?.("stderr", chunk);
53
+ });
54
+ child.stdin?.on("error", (error) => stderr.append(error.message));
55
+ if (spec.input !== void 0) child.stdin?.end(spec.input);
56
+ else if (!spec.keepStdinOpen) child.stdin?.end();
57
+ return {
58
+ child,
59
+ completion: new Promise((resolve) => {
60
+ let spawnError;
61
+ child.once("error", (error) => {
62
+ spawnError = error;
63
+ });
64
+ child.once("close", (exitCode, signal) => {
65
+ if (settled) return;
66
+ settled = true;
67
+ if (timer) clearTimeout(timer);
68
+ spec.signal?.removeEventListener("abort", abort);
69
+ if (spawnError && stderr.snapshot().totalBytes === 0) stderr.append(spawnError.message);
70
+ const out = stdout.snapshot();
71
+ const err = stderr.snapshot();
72
+ resolve({
73
+ exitCode: spawnError ? null : exitCode,
74
+ ...spawnError && spawnError.code ? { spawnErrorCode: spawnError.code } : {},
75
+ signal,
76
+ stdout: out.text,
77
+ stderr: err.text,
78
+ timedOut,
79
+ aborted,
80
+ outputTruncated: out.truncated || err.truncated,
81
+ terminationVerified: !terminationRequested || child.exitCode !== null || child.signalCode !== null
82
+ });
83
+ });
84
+ }),
85
+ terminate
86
+ };
87
+ }
88
+ function runProcess(spec) {
89
+ return spawnProcess(spec).completion;
90
+ }
91
+ async function runProcessChecked(spec) {
92
+ const result = await runProcess(spec);
93
+ if (result.exitCode !== 0) throw new ProcessExitError(spec, result);
94
+ return result;
95
+ }
96
+ //#endregion
97
+ export { runProcess, runProcessChecked, spawnProcess };
@@ -9,7 +9,7 @@ export declare class ProviderPluginRegistry implements ProviderRegistry {
9
9
  /**
10
10
  * Register a new provider
11
11
  */
12
- register(provider: ProviderPlugin): void;
12
+ register(provider: ProviderPlugin): () => void;
13
13
  /**
14
14
  * Get a provider by ID
15
15
  */
@@ -23,8 +23,14 @@ var init_plugin_registry = __esmMin((() => {
23
23
  if (!provider.id) throw new Error("Provider must have an id");
24
24
  if (!provider.name) throw new Error("Provider must have a name");
25
25
  if (!provider.createStream || typeof provider.createStream !== "function") throw new Error("Provider must implement createStream method");
26
+ const previous = this.providers.get(provider.id);
26
27
  this.providers.set(provider.id, provider);
27
28
  log.info(`Registered provider: ${provider.name} (${provider.id})`);
29
+ return () => {
30
+ if (this.providers.get(provider.id) !== provider) return;
31
+ if (previous) this.providers.set(provider.id, previous);
32
+ else this.providers.delete(provider.id);
33
+ };
28
34
  }
29
35
  /**
30
36
  * Get a provider by ID
@@ -2,7 +2,7 @@ import { createLogger } from "../utils/logger/index.js";
2
2
  import { init_logger } from "../utils/logger.js";
3
3
  import { hasGatewayScope } from "../gateway/security/gateway-scopes.js";
4
4
  import { EndpointToolPolicyError } from "../endpoint-tools/policy.js";
5
- import { REALTIME_HEARTBEAT_INTERVAL_MS, REALTIME_HEARTBEAT_TIMEOUT_MS, REALTIME_HELLO_TIMEOUT_MS, REALTIME_MAX_CLIENT_FRAME_BYTES, parseClientRealtimeJsonFrame, parseClientRealtimeMessage } from "../../packages/realtime-protocol/src/index.js";
5
+ import { REALTIME_CAPABILITIES, REALTIME_HEARTBEAT_INTERVAL_MS, REALTIME_HEARTBEAT_TIMEOUT_MS, REALTIME_HELLO_TIMEOUT_MS, REALTIME_MAX_CLIENT_FRAME_BYTES, parseClientRealtimeJsonFrame, parseClientRealtimeMessage } from "../../packages/realtime-protocol/src/index.js";
6
6
  import { createPreauthConnectionBudget } from "../gateway/security/preauth-connection-budget.js";
7
7
  import { RealtimeBroker } from "./broker.js";
8
8
  import { RealtimeTicketStore } from "./tickets.js";
@@ -265,10 +265,12 @@ var RealtimeRuntime = class {
265
265
  }
266
266
  clearTimeout(helloTimer);
267
267
  releaseBudget();
268
+ const negotiatedCapabilities = message.payload.capabilities ? [...new Set(message.payload.capabilities.filter((capability) => REALTIME_CAPABILITIES.includes(capability)))] : void 0;
268
269
  writer.enqueue(serverMessage("realtime.ready", {
269
270
  connectionId,
270
271
  heartbeatIntervalMs: REALTIME_HEARTBEAT_INTERVAL_MS,
271
272
  heartbeatTimeoutMs: REALTIME_HEARTBEAT_TIMEOUT_MS,
273
+ ...message.payload.capabilities ? { negotiatedCapabilities } : {},
272
274
  ...endpointReady ? { endpoint: endpointReady } : {}
273
275
  }), "critical");
274
276
  subscribe(message.payload.subscriptions);
@@ -502,7 +502,7 @@ var SessionStore = class {
502
502
  handover: result.handover,
503
503
  audit: result.audit,
504
504
  sourceEntries: expectedSnapshot.entries,
505
- writePolicy: access.knowledge && this.options.config.userContext.knowledgeMemory.sources.includes("session") ? this.options.config.userContext.knowledgeMemory.writePolicy : "deny"
505
+ writePolicy: access.knowledge && access.knowledgePolicy.scopes.includes("session") && access.knowledgePolicy.contentSources.includes("memory") ? this.options.config.userContext.knowledgeMemory.writePolicy : "deny"
506
506
  });
507
507
  log.info({
508
508
  conversationId: key,
@@ -1,7 +1,7 @@
1
1
  import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "./transaction.js";
2
2
  import { buildDevicePairingProof, devicePairingCompleteSchema, devicePairingDeviceSchema } from "../../../packages/gateway-contract/src/device-pairing.js";
3
+ import { DEFAULT_BROWSER_EXTENSION_SCOPES, DEFAULT_MOBILE_SCOPES } from "../../../packages/gateway-contract/src/gateway-scopes.js";
3
4
  import { init_src } from "../../../packages/gateway-contract/src/index.js";
4
- import { DEFAULT_BROWSER_EXTENSION_SCOPES, DEFAULT_MOBILE_SCOPES } from "../../gateway/security/gateway-scopes.js";
5
5
  import { createDevice, getDevice, registerInitialDeviceRefreshToken, revokeDevice } from "./device-access-repository.js";
6
6
  import { getOrCreateGatewayIdentity } from "./gateway-identity-repository.js";
7
7
  import { browserEnrollmentPublicKeyThumbprint } from "../../browser/enrollment.js";
@@ -29,7 +29,7 @@ export { buildRelationshipPrompt, getRelationshipSettings, isProactiveSupportAll
29
29
  export { buildDefaultSessionMetadata, type SessionMetadataSeed, } from './session-metadata.js';
30
30
  export { buildGlobalSessionStats, classifyStoredRow, estimateTokensFromMessages, extractFtsContent, metadataToSessionInsert, sessionConfigRowToConfig, sessionRowToMetadata, transcriptEntryRowToStoredRow, type SessionConfigRow, type SessionRow, type TranscriptEntryRow, } from './row-mappers.js';
31
31
  export { deleteSessionRecord, ensureSessionRecord, getCurrentTranscriptId, getGlobalSessionStats, findConversationIdByTranscriptId, getSessionPersistedLevels, getSessionMetadata, incrementSessionStatsOnAppend, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord, resolveSessionAgentId, updateSessionStats, } from './session-repository.js';
32
- export { appendCompactionBoundaryIfUnchanged, appendTranscriptEntry, listCompactionBoundaries, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, loadCompactionSourceSnapshot, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript, type CompactionSourceSnapshot, type SessionTranscriptRecallMatch, type TranscriptSourceEntry, } from './transcript-repository.js';
32
+ export { appendCompactionBoundaryIfUnchanged, appendMediaToAssistantTranscriptEntry, appendTranscriptEntry, findLatestAssistantTranscriptEntryId, listCompactionBoundaries, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, loadCompactionSourceSnapshot, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript, type CompactionSourceSnapshot, type SessionTranscriptRecallMatch, type TranscriptSourceEntry, } from './transcript-repository.js';
33
33
  export { deleteNoteRecord, getNoteRecord, listNoteRecords, upsertNoteRecord, } from './notes-repository.js';
34
34
  export { deleteNoteAgentContextRecord, getNoteAgentContextRecord, upsertNoteAgentContextRecord, type NoteAgentContextRecord, } from './note-agent-context-repository.js';
35
35
  export { claimKnowledgeSourceItems, countKnowledgeSourceItems, completeKnowledgeSourceItemSynthesis, deleteKnowledgeSourceItems, finishKnowledgeSyncRun, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, listKnowledgeSourceItems, listKnowledgeSourceChanges, listKnowledgeSyncRuns, pruneBoundedKnowledgeSourceItems, setKnowledgeSourceItemSynthesisStatus, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, startKnowledgeSyncRun, upsertKnowledgeSourceItems, } from './knowledge-repository.js';
@@ -31,7 +31,7 @@ import { getInteractionState, setInteractionState, updateInteractionStateFromMes
31
31
  import { deleteSessionRecord, ensureSessionRecord, findConversationIdByTranscriptId, getCurrentTranscriptId, getGlobalSessionStats, getSessionMetadata, getSessionPersistedLevels, incrementSessionStatsOnAppend, init_session_repository, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord, resolveSessionAgentId, updateSessionStats } from "./session-repository.js";
32
32
  import { getSessionTaskPlan, setSessionTaskPlan } from "./session-task-plan-repository.js";
33
33
  import { buildRelationshipPrompt, getRelationshipSettings, isProactiveSupportAllowed, updateRelationshipSettings } from "./relationship-settings-repository.js";
34
- import { appendCompactionBoundaryIfUnchanged, appendTranscriptEntry, listCompactionBoundaries, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript } from "./transcript-repository.js";
34
+ import { appendCompactionBoundaryIfUnchanged, appendMediaToAssistantTranscriptEntry, appendTranscriptEntry, findLatestAssistantTranscriptEntryId, listCompactionBoundaries, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript } from "./transcript-repository.js";
35
35
  import { deleteNoteRecord, getNoteRecord, listNoteRecords, upsertNoteRecord } from "./notes-repository.js";
36
36
  import { deleteNoteAgentContextRecord, getNoteAgentContextRecord, upsertNoteAgentContextRecord } from "./note-agent-context-repository.js";
37
37
  import { claimKnowledgeSourceItems, completeKnowledgeSourceItemSynthesis, countKnowledgeSourceItems, deleteKnowledgeSourceItems, finishKnowledgeSyncRun, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, pruneBoundedKnowledgeSourceItems, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, startKnowledgeSyncRun, upsertKnowledgeSourceItems } from "./knowledge-repository.js";
@@ -54,4 +54,4 @@ init_session_metadata();
54
54
  init_row_mappers();
55
55
  init_session_repository();
56
56
  //#endregion
57
- export { COMPOSER_INPUT_HISTORY_LIMIT, DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, DatabaseSchemaTooOldError, SCHEMA_META_SCHEMA_VERSION_KEY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, acknowledgeHomeAttention, appendCompactionBoundaryIfUnchanged, appendComposerInputHistory, appendConnectorExecutionAudit, appendTranscriptEntry, applyPendingMigrations, authenticateDeviceAccessToken, bindEndpointPrincipal, buildDefaultSessionMetadata, buildGlobalSessionStats, buildRefreshProofMessage, buildRelationshipPrompt, cancelQueuedSessionInput, claimConnectorWebhookDelivery, claimContextExtractionRun, claimKnowledgeSourceItems, claimNextConnectorLearningJob, claimNextSessionInput, classifyStoredRow, clearComposerInputHistory, clearGatewayIdentityForTest, closeTemporalAssertions, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, consumeClarificationApproval, consumeClarificationResume, consumeConnectorApproval, countKnowledgeSourceItems, createClarificationWait, createCollaborationRule, createConnectorApproval, createContextEvidence, createDevice, createDevicePairingSetup, createEndpointPrincipal, createObjectLinkRecord, createTemporalAssertion, decideConnectorApproval, deleteBrowserTabBinding, deleteBrowserTabBindingsByEndpoint, deleteBrowserTabBindingsByPrincipal, deleteConnectorConnection, deleteConnectorInstallation, deleteEndpointSessionBinding, deleteEndpointSessionBindingsByPrincipal, deleteKnowledgeSourceItems, deleteNoteAgentContextRecord, deleteNoteRecord, deleteObjectLinkRecord, deleteSessionConfig, deleteSessionRecord, discoverSqlMigrations, enqueueConnectorLearningJob, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findConversationIdByTranscriptId, findSessionInput, finishContextExtractionRun, finishEndpointToolInvocationAudit, finishKnowledgeSyncRun, finishSessionInputRun, getActiveClarification, getActivityEventRecord, getBrowserTabBinding, getBrowserTabBindingById, getCachedConnectorCatalogEntry, getClarification, getClarificationResumeInput, getClarificationSnapshot, getCollaborationRule, getConnectorAccount, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, getContextExtractionRun, getCurrentTranscriptId, getDevice, getEndpointPrincipal, getEndpointSessionBinding, getGlobalSessionStats, getInteractionState, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getNoteAgentContextRecord, getNoteRecord, getOrCreateGatewayIdentity, getRelationshipSettings, getSessionConfig, getSessionInputById, getSessionInputState, getSessionMetadata, getSessionPersistedLevels, getSessionTaskPlan, getSqliteDatabase, getUserPeopleIndexState, getUserPerson, getUserTrustPolicy, getXopcDatabase, hasIndependentExtractionOutput, hasSessionConfig, incrementSessionStatsOnAppend, insertSessionInput, inspectSchemaMigrationStatus, isClarificationSuspended, isDevicePairingSetupActive, isHomeAttentionAcknowledged, isProactiveSupportAllowed, isXopcDatabaseOpen, issueDeviceTokenPair, linkContextObjects, listActiveSessionInputRuns, listActivityRecords, listCachedConnectorCatalogEntries, listCollaborationRules, listCompactionBoundaries, listComposerInputHistory, listConnectorAccounts, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listConnectorLearningJobs, listConnectorSyncPolicies, listContextExtractionOutputs, listContextExtractionRuns, listContextObjectRelations, listDevices, listEndpointPrincipals, listEndpointToolInvocationAudits, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, listTemporalAssertions, listUserPeople, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, mergeUserPeople, metadataToSessionInsert, mutateQueuedSessionInput, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, pruneBoundedKnowledgeSourceItems, readSchemaVersion, readSchemaVersionForTest, reconcileConnectorAccount, recordActivityEvent, recoverSessionInputState, recoverStaleConnectorLearningJobs, refreshConnectorAccountCurrent, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceLatestSessionTurnAndQueueInput, replaceTranscriptRows, replaceUserPeopleIndex, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveClarification, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreBeforeCompactionBoundary, revokeDevice, revokeEndpointPrincipal, rotateDeviceRefreshToken, runSqliteWriteTransaction, searchSessionTranscript, sessionConfigRowToConfig, sessionRowToMetadata, setBrowserTabBinding, setCollaborationRuleStatus, setConnectorLearningPaused, setEndpointSessionBinding, setInteractionState, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setSessionConfig, setSessionInputStatus, setSessionTaskPlan, setUserTrustPolicy, signGatewayPayload, startEndpointToolInvocationAudit, startKnowledgeSyncRun, summarizeUserPeople, supersedeActiveClarification, touchEndpointPrincipal, transcriptEntryRowToStoredRow, updateConnectorLearningJob, updateInteractionStateFromMessage, updateRelationshipSettings, updateSessionConfig, updateSessionStats, updateUserPerson, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertConnectorSyncPolicy, upsertKnowledgeSourceItems, upsertNoteAgentContextRecord, upsertNoteRecord, validateLatestSessionTurnTarget };
57
+ export { COMPOSER_INPUT_HISTORY_LIMIT, DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, DatabaseSchemaTooOldError, SCHEMA_META_SCHEMA_VERSION_KEY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, acknowledgeHomeAttention, appendCompactionBoundaryIfUnchanged, appendComposerInputHistory, appendConnectorExecutionAudit, appendMediaToAssistantTranscriptEntry, appendTranscriptEntry, applyPendingMigrations, authenticateDeviceAccessToken, bindEndpointPrincipal, buildDefaultSessionMetadata, buildGlobalSessionStats, buildRefreshProofMessage, buildRelationshipPrompt, cancelQueuedSessionInput, claimConnectorWebhookDelivery, claimContextExtractionRun, claimKnowledgeSourceItems, claimNextConnectorLearningJob, claimNextSessionInput, classifyStoredRow, clearComposerInputHistory, clearGatewayIdentityForTest, closeTemporalAssertions, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, consumeClarificationApproval, consumeClarificationResume, consumeConnectorApproval, countKnowledgeSourceItems, createClarificationWait, createCollaborationRule, createConnectorApproval, createContextEvidence, createDevice, createDevicePairingSetup, createEndpointPrincipal, createObjectLinkRecord, createTemporalAssertion, decideConnectorApproval, deleteBrowserTabBinding, deleteBrowserTabBindingsByEndpoint, deleteBrowserTabBindingsByPrincipal, deleteConnectorConnection, deleteConnectorInstallation, deleteEndpointSessionBinding, deleteEndpointSessionBindingsByPrincipal, deleteKnowledgeSourceItems, deleteNoteAgentContextRecord, deleteNoteRecord, deleteObjectLinkRecord, deleteSessionConfig, deleteSessionRecord, discoverSqlMigrations, enqueueConnectorLearningJob, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findConversationIdByTranscriptId, findLatestAssistantTranscriptEntryId, findSessionInput, finishContextExtractionRun, finishEndpointToolInvocationAudit, finishKnowledgeSyncRun, finishSessionInputRun, getActiveClarification, getActivityEventRecord, getBrowserTabBinding, getBrowserTabBindingById, getCachedConnectorCatalogEntry, getClarification, getClarificationResumeInput, getClarificationSnapshot, getCollaborationRule, getConnectorAccount, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, getContextExtractionRun, getCurrentTranscriptId, getDevice, getEndpointPrincipal, getEndpointSessionBinding, getGlobalSessionStats, getInteractionState, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getNoteAgentContextRecord, getNoteRecord, getOrCreateGatewayIdentity, getRelationshipSettings, getSessionConfig, getSessionInputById, getSessionInputState, getSessionMetadata, getSessionPersistedLevels, getSessionTaskPlan, getSqliteDatabase, getUserPeopleIndexState, getUserPerson, getUserTrustPolicy, getXopcDatabase, hasIndependentExtractionOutput, hasSessionConfig, incrementSessionStatsOnAppend, insertSessionInput, inspectSchemaMigrationStatus, isClarificationSuspended, isDevicePairingSetupActive, isHomeAttentionAcknowledged, isProactiveSupportAllowed, isXopcDatabaseOpen, issueDeviceTokenPair, linkContextObjects, listActiveSessionInputRuns, listActivityRecords, listCachedConnectorCatalogEntries, listCollaborationRules, listCompactionBoundaries, listComposerInputHistory, listConnectorAccounts, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listConnectorLearningJobs, listConnectorSyncPolicies, listContextExtractionOutputs, listContextExtractionRuns, listContextObjectRelations, listDevices, listEndpointPrincipals, listEndpointToolInvocationAudits, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, listTemporalAssertions, listUserPeople, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, mergeUserPeople, metadataToSessionInsert, mutateQueuedSessionInput, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, pruneBoundedKnowledgeSourceItems, readSchemaVersion, readSchemaVersionForTest, reconcileConnectorAccount, recordActivityEvent, recoverSessionInputState, recoverStaleConnectorLearningJobs, refreshConnectorAccountCurrent, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceLatestSessionTurnAndQueueInput, replaceTranscriptRows, replaceUserPeopleIndex, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveClarification, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreBeforeCompactionBoundary, revokeDevice, revokeEndpointPrincipal, rotateDeviceRefreshToken, runSqliteWriteTransaction, searchSessionTranscript, sessionConfigRowToConfig, sessionRowToMetadata, setBrowserTabBinding, setCollaborationRuleStatus, setConnectorLearningPaused, setEndpointSessionBinding, setInteractionState, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setSessionConfig, setSessionInputStatus, setSessionTaskPlan, setUserTrustPolicy, signGatewayPayload, startEndpointToolInvocationAudit, startKnowledgeSyncRun, summarizeUserPeople, supersedeActiveClarification, touchEndpointPrincipal, transcriptEntryRowToStoredRow, updateConnectorLearningJob, updateInteractionStateFromMessage, updateRelationshipSettings, updateSessionConfig, updateSessionStats, updateUserPerson, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertConnectorSyncPolicy, upsertKnowledgeSourceItems, upsertNoteAgentContextRecord, upsertNoteRecord, validateLatestSessionTurnTarget };
@@ -0,0 +1,7 @@
1
+ ALTER TABLE execution_environments
2
+ ADD COLUMN ownership TEXT NOT NULL DEFAULT 'registered'
3
+ CHECK (ownership IN ('registered', 'xopc_created'));
4
+
5
+ UPDATE execution_environments
6
+ SET ownership = 'xopc_created'
7
+ WHERE kind = 'managed_worktree';
@@ -0,0 +1,12 @@
1
+ CREATE TABLE IF NOT EXISTS knowledge_item_status_events (
2
+ event_id TEXT PRIMARY KEY,
3
+ knowledge_id TEXT NOT NULL REFERENCES knowledge_items(knowledge_id) ON DELETE CASCADE,
4
+ from_status TEXT,
5
+ to_status TEXT NOT NULL,
6
+ actor_type TEXT NOT NULL CHECK(actor_type IN ('user', 'agent', 'runtime', 'maintenance', 'migration')),
7
+ reason TEXT NOT NULL,
8
+ created_at INTEGER NOT NULL
9
+ );
10
+
11
+ CREATE INDEX IF NOT EXISTS idx_knowledge_item_status_events_item
12
+ ON knowledge_item_status_events(knowledge_id, created_at DESC);
@@ -3,7 +3,7 @@ import type { ApplyMigrationsOptions } from './types.js';
3
3
  /** Baseline schema version applied from schema.sql on first open. */
4
4
  export declare const XOPC_DB_BASELINE_SCHEMA_VERSION = 165;
5
5
  /** Latest schema version this release supports (increment when adding migrations). */
6
- export declare const XOPC_DB_SCHEMA_VERSION = 179;
6
+ export declare const XOPC_DB_SCHEMA_VERSION = 181;
7
7
  export declare function resolveMigrationsDir(override?: string): string;
8
8
  /**
9
9
  * Apply sequential SQL migrations from (currentVersion + 1) through targetVersion.
@@ -63,7 +63,7 @@ function applySingleMigration(db, migration) {
63
63
  * Each step runs in its own transaction and updates schema_meta on success.
64
64
  */
65
65
  function applyPendingMigrations(db, options = {}) {
66
- const targetVersion = options.targetVersion ?? 179;
66
+ const targetVersion = options.targetVersion ?? 181;
67
67
  let currentVersion = readSchemaVersion(db);
68
68
  if (currentVersion > targetVersion) throw new DatabaseSchemaTooNewError(currentVersion, targetVersion);
69
69
  if (!options.migrationsDir && currentVersion < 165) throw new DatabaseSchemaTooOldError(currentVersion, 165);
@@ -118,7 +118,7 @@ function applyPendingMigrations(db, options = {}) {
118
118
  }
119
119
  /** Inspect schema version without mutating the database. */
120
120
  function inspectSchemaMigrationStatus(db, options = {}) {
121
- const appVersion = options.targetVersion ?? 179;
121
+ const appVersion = options.targetVersion ?? 181;
122
122
  const dbVersion = readSchemaVersion(db);
123
123
  if (dbVersion > appVersion) return {
124
124
  dbVersion,
@@ -157,7 +157,7 @@ var init_runner = __esmMin((() => {
157
157
  init_errors();
158
158
  log = createLogger("Sqlite:Migrations");
159
159
  XOPC_DB_BASELINE_SCHEMA_VERSION = 165;
160
- XOPC_DB_SCHEMA_VERSION = 179;
160
+ XOPC_DB_SCHEMA_VERSION = 181;
161
161
  MODULE_DIR = dirname(fileURLToPath(import.meta.url));
162
162
  }));
163
163
  //#endregion
@@ -33,7 +33,7 @@ function ensureXopcDatabaseSchema(db, options = {}) {
33
33
  currentVersion = 165;
34
34
  }
35
35
  applyPendingMigrations(db, {
36
- targetVersion: 179,
36
+ targetVersion: 181,
37
37
  databasePath: fresh ? void 0 : options.databasePath
38
38
  });
39
39
  }
@@ -2320,6 +2320,19 @@ CREATE VIRTUAL TABLE knowledge_items_fts USING fts5(
2320
2320
  tokenize='unicode61'
2321
2321
  );
2322
2322
 
2323
+ CREATE TABLE knowledge_item_status_events (
2324
+ event_id TEXT PRIMARY KEY,
2325
+ knowledge_id TEXT NOT NULL REFERENCES knowledge_items(knowledge_id) ON DELETE CASCADE,
2326
+ from_status TEXT,
2327
+ to_status TEXT NOT NULL,
2328
+ actor_type TEXT NOT NULL CHECK(actor_type IN ('user', 'agent', 'runtime', 'maintenance', 'migration')),
2329
+ reason TEXT NOT NULL,
2330
+ created_at INTEGER NOT NULL
2331
+ );
2332
+
2333
+ CREATE INDEX idx_knowledge_item_status_events_item
2334
+ ON knowledge_item_status_events(knowledge_id, created_at DESC);
2335
+
2323
2336
  CREATE TABLE memory_maintenance_runs (
2324
2337
  run_id TEXT PRIMARY KEY,
2325
2338
  principal_id TEXT NOT NULL,
@@ -1,4 +1,5 @@
1
1
  import type { AgentMessage } from '@earendil-works/pi-agent-core';
2
+ import type { MediaRef } from '../../media/types.js';
2
3
  import type { CompactionBoundarySummary } from '../../session/types.js';
3
4
  import { type TranscriptStoredRow, type XopcTranscriptCompactionEntry } from '../../session/session-context-for-llm.js';
4
5
  import { type TranscriptEntryRow } from './row-mappers.js';
@@ -34,6 +35,9 @@ export declare function loadTranscriptRowsForSession(conversationId: string): Tr
34
35
  export declare function loadTranscriptHistoryRowsForSession(conversationId: string): TranscriptStoredRow[];
35
36
  export declare function loadTranscriptRows(transcriptId: string): TranscriptStoredRow[];
36
37
  export declare function loadLlmMessagesForSession(conversationId: string): AgentMessage[];
38
+ export declare function findLatestAssistantTranscriptEntryId(conversationId: string): string | null;
39
+ /** Attach generated media to one exact assistant row without rewriting the transcript. */
40
+ export declare function appendMediaToAssistantTranscriptEntry(conversationId: string, entryId: string, media: MediaRef): boolean;
37
41
  export declare function replaceTranscriptRows(conversationId: string, rows: TranscriptStoredRow[]): void;
38
42
  export declare function paginateTranscriptMessages(conversationId: string, options?: {
39
43
  offset?: number;
@@ -218,6 +218,41 @@ function loadLlmMessagesForSession(conversationId) {
218
218
  )
219
219
  ORDER BY seq ASC`).all(transcriptId, transcriptId).map(transcriptEntryRowToStoredRow));
220
220
  }
221
+ function findLatestAssistantTranscriptEntryId(conversationId) {
222
+ const transcriptId = getCurrentTranscriptId(conversationId);
223
+ if (!transcriptId) return null;
224
+ return getSqliteDatabase().prepare(`SELECT entry_id
225
+ FROM transcript_entries
226
+ WHERE transcript_id = ? AND entry_kind = 'message' AND role = 'assistant'
227
+ ORDER BY seq DESC
228
+ LIMIT 1`).get(transcriptId)?.entry_id ?? null;
229
+ }
230
+ /** Attach generated media to one exact assistant row without rewriting the transcript. */
231
+ function appendMediaToAssistantTranscriptEntry(conversationId, entryId, media) {
232
+ if (!entryId.trim() || !media.uri?.trim()) return false;
233
+ return runSqliteWriteTransaction((db) => {
234
+ const transcriptId = readCurrentTranscriptId(db, conversationId);
235
+ if (!transcriptId) return false;
236
+ const row = db.prepare(`SELECT payload_json
237
+ FROM transcript_entries
238
+ WHERE transcript_id = ? AND entry_id = ? AND entry_kind = 'message' AND role = 'assistant'`).get(transcriptId, entryId);
239
+ if (!row) return false;
240
+ let message;
241
+ try {
242
+ message = JSON.parse(row.payload_json);
243
+ } catch {
244
+ return false;
245
+ }
246
+ const existing = Array.isArray(message.media) ? message.media : [];
247
+ if (existing.some((item) => item?.uri === media.uri)) return true;
248
+ const next = {
249
+ ...message,
250
+ media: [...existing, media]
251
+ };
252
+ return db.prepare(`UPDATE transcript_entries SET payload_json = ?
253
+ WHERE transcript_id = ? AND entry_id = ?`).run(JSON.stringify(next), transcriptId, entryId).changes === 1;
254
+ });
255
+ }
221
256
  function replaceTranscriptRows(conversationId, rows) {
222
257
  if (rows.some(isRuntimeOnlyTranscriptMessage)) throw new Error("Runtime-only messages cannot be persisted in a session transcript");
223
258
  runSqliteWriteTransaction((db) => {
@@ -349,4 +384,4 @@ function restoreBeforeCompactionBoundary(conversationId, compactionId) {
349
384
  });
350
385
  }
351
386
  //#endregion
352
- export { appendCompactionBoundaryIfUnchanged, appendTranscriptEntry, listCompactionBoundaries, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript };
387
+ export { appendCompactionBoundaryIfUnchanged, appendMediaToAssistantTranscriptEntry, appendTranscriptEntry, findLatestAssistantTranscriptEntryId, listCompactionBoundaries, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript };
@@ -1,8 +1,8 @@
1
- import type { ExtensionRegistryImpl } from '../../extensions/loader.js';
1
+ import type { ExtensionRegistryImpl } from '../../extensions/extension-registry-impl.js';
2
2
  import { type SessionTimelineItem } from '../../session/transcript-outline.js';
3
3
  import { type Config } from '../../config/schema.js';
4
4
  import type { ExportFormat } from '../../session/types.js';
5
- import type { ChatSendOptions, HistoryMessage, TuiBackend, TuiCompactionResult, TuiComposerHistoryItem, TuiEvent, TuiModelChoice, TuiShareRequest, TuiShareResult, TuiSessionStats, TuiSessionItem, TuiTranscriptTreeEntry, TuiAgentInfo, TuiWorkspaceFileSearchEntry, TuiWorkflowRunStartRequest, TuiWorkflowRunStartResult, TuiStartupProjectResult } from '../tui-backend.js';
5
+ import type { ChatSendOptions, HistoryMessage, TuiBackend, TuiCompactionResult, TuiComposerHistoryItem, TuiEvent, TuiModelChoice, TuiShareRequest, TuiShareResult, TuiSessionStats, TuiSessionItem, TuiTranscriptTreeEntry, TuiAgentInfo, TuiWorkspaceFileSearchEntry, TuiWorkflowRunStartRequest, TuiWorkflowRunStartResult, TuiStartupProjectResult, TuiChatInputState } from '../tui-backend.js';
6
6
  import type { SessionInfo } from '../tui-types.js';
7
7
  interface EmbeddedBackendOptions {
8
8
  config?: Config;
@@ -28,6 +28,7 @@ export declare class EmbeddedBackend implements TuiBackend {
28
28
  private workflowRunService;
29
29
  private running;
30
30
  private chatAbort;
31
+ private readonly chatInputStates;
31
32
  onEvent?: (evt: TuiEvent) => void;
32
33
  onConnected?: () => void;
33
34
  onDisconnected?: (reason: string) => void;
@@ -73,15 +74,30 @@ export declare class EmbeddedBackend implements TuiBackend {
73
74
  }): Promise<{
74
75
  ok: boolean;
75
76
  effectiveDelivery?: 'next' | 'steer';
77
+ state?: TuiChatInputState;
76
78
  }>;
77
- getChatInputState(conversationId: string): Promise<{
79
+ getChatInputState(conversationId: string): Promise<TuiChatInputState>;
80
+ updateChatInput(opts: {
78
81
  conversationId: string;
79
- revision: number;
80
- inputs: {
81
- id: string;
82
- status: string;
83
- }[];
82
+ inputId: string;
83
+ version: number;
84
+ content: string;
85
+ }): Promise<{
86
+ ok: boolean;
87
+ state?: TuiChatInputState;
88
+ }>;
89
+ removeChatInput(opts: {
90
+ conversationId: string;
91
+ inputId: string;
92
+ version: number;
93
+ }): Promise<{
94
+ ok: boolean;
95
+ state?: TuiChatInputState;
84
96
  }>;
97
+ private appendPendingChatInput;
98
+ private consumePendingChatInput;
99
+ private publishChatInputState;
100
+ private replaceEmbeddedQueue;
85
101
  loadHistory(opts: {
86
102
  conversationId: string;
87
103
  limit?: number;
@@ -33,6 +33,7 @@ import { WorkflowSessionBridge } from "../../workflows/service/workflow-session-
33
33
  import { ChatStreamMapper } from "../../gateway/chat-stream/mapper.js";
34
34
  import { getXopcCloudCatalogCoordinator } from "../../providers/xopc-cloud-catalog-coordinator.js";
35
35
  import { fuzzySearchWorkspaceFiles } from "../../gateway/workspace-file-search.js";
36
+ import { commitDeliveredChatInput } from "../tui-chat-input-state.js";
36
37
  import { sessionMetadataToTuiItem } from "../tui-session-format.js";
37
38
  import { buildTuiTranscriptTree, transcriptTreeEntryIdToRowNumber } from "../tui-transcript-tree.js";
38
39
  import { computeTuiSessionStats } from "../tui-session-stats.js";
@@ -54,6 +55,14 @@ function isPathSameOrInside(parentDir, childDir) {
54
55
  const rel = relative(resolve(parentDir), resolve(childDir));
55
56
  return rel === "" || !!rel && !rel.startsWith("..") && !isAbsolute(rel);
56
57
  }
58
+ function deliveredUserMessageText(event) {
59
+ if (event.type !== "message_start" || !event.message || typeof event.message !== "object") return void 0;
60
+ const message = event.message;
61
+ if (message.role !== "user") return void 0;
62
+ if (typeof message.content === "string") return message.content;
63
+ if (!Array.isArray(message.content)) return void 0;
64
+ return message.content.map((block) => block && typeof block === "object" && block.type === "text" ? String(block.text ?? "") : "").join("");
65
+ }
57
66
  /**
58
67
  * TUI backend that runs the agent in-process (no gateway required).
59
68
  *
@@ -71,6 +80,7 @@ var EmbeddedBackend = class {
71
80
  workflowRunService = null;
72
81
  running = false;
73
82
  chatAbort = null;
83
+ chatInputStates = /* @__PURE__ */ new Map();
74
84
  onEvent;
75
85
  onConnected;
76
86
  onDisconnected;
@@ -319,6 +329,7 @@ var EmbeddedBackend = class {
319
329
  source: "embedded"
320
330
  });
321
331
  (async () => {
332
+ let initialUserMessageObserved = false;
322
333
  try {
323
334
  const messageForAgent = opts.message.trimStart().startsWith("/") ? opts.message : prependEnvelopeTimestamp(opts.message);
324
335
  const stream = agent.turnDispatcher.processDirectStreaming(messageForAgent, opts.conversationId, {
@@ -330,6 +341,9 @@ var EmbeddedBackend = class {
330
341
  });
331
342
  for await (const event of stream) {
332
343
  if (signal.aborted) break;
344
+ const deliveredInput = deliveredUserMessageText(event);
345
+ if (deliveredInput !== void 0) if (initialUserMessageObserved) this.consumePendingChatInput(opts.conversationId, deliveredInput);
346
+ else initialUserMessageObserved = true;
333
347
  for (const mapped of mapper.map(event)) this.onEvent?.({
334
348
  event: mapped.type,
335
349
  data: mapped,
@@ -369,10 +383,11 @@ var EmbeddedBackend = class {
369
383
  async submitChatInput(opts) {
370
384
  if (!this.agent) return { ok: false };
371
385
  if (opts.delivery === "steer") {
372
- const ok = await this.agent.turnDispatcher.steerWebchatSession(opts.conversationId, opts.message);
386
+ if (!await this.agent.turnDispatcher.steerWebchatSession(opts.conversationId, opts.message)) return { ok: false };
373
387
  return {
374
- ok,
375
- effectiveDelivery: ok ? "steer" : void 0
388
+ ok: true,
389
+ effectiveDelivery: "steer",
390
+ state: this.appendPendingChatInput(opts.conversationId, opts.message, "steer")
376
391
  };
377
392
  }
378
393
  const { getEmbeddedRunByConversationId } = await import("../../agent/embedded/runs.js");
@@ -381,20 +396,109 @@ var EmbeddedBackend = class {
381
396
  await handle.session.followUp(opts.message);
382
397
  return {
383
398
  ok: true,
384
- effectiveDelivery: "next"
399
+ effectiveDelivery: "next",
400
+ state: this.appendPendingChatInput(opts.conversationId, opts.message, "next")
385
401
  };
386
402
  }
387
403
  async getChatInputState(conversationId) {
388
- const { getEmbeddedRunByConversationId } = await import("../../agent/embedded/runs.js");
389
- const handle = getEmbeddedRunByConversationId(conversationId);
404
+ return this.chatInputStates.get(conversationId) ?? {
405
+ conversationId,
406
+ revision: 0,
407
+ inputs: []
408
+ };
409
+ }
410
+ async updateChatInput(opts) {
411
+ const current = await this.getChatInputState(opts.conversationId);
412
+ const target = current.inputs.find((input) => input.id === opts.inputId);
413
+ if (!target || target.version !== opts.version || target.status !== "queued") return {
414
+ ok: false,
415
+ state: current
416
+ };
417
+ const state = {
418
+ ...current,
419
+ revision: current.revision + 1,
420
+ inputs: current.inputs.map((input) => input.id === target.id ? {
421
+ ...input,
422
+ content: opts.content,
423
+ version: input.version + 1
424
+ } : input)
425
+ };
426
+ if (!await this.replaceEmbeddedQueue(opts.conversationId, state)) return {
427
+ ok: false,
428
+ state: current
429
+ };
430
+ this.publishChatInputState(state);
431
+ return {
432
+ ok: true,
433
+ state
434
+ };
435
+ }
436
+ async removeChatInput(opts) {
437
+ const current = await this.getChatInputState(opts.conversationId);
438
+ const target = current.inputs.find((input) => input.id === opts.inputId);
439
+ if (!target || target.version !== opts.version || target.status !== "queued" && target.status !== "interrupted") return {
440
+ ok: false,
441
+ state: current
442
+ };
443
+ const state = {
444
+ ...current,
445
+ revision: current.revision + 1,
446
+ inputs: current.inputs.filter((input) => input.id !== target.id)
447
+ };
448
+ if (!await this.replaceEmbeddedQueue(opts.conversationId, state)) return {
449
+ ok: false,
450
+ state: current
451
+ };
452
+ this.publishChatInputState(state);
390
453
  return {
454
+ ok: true,
455
+ state
456
+ };
457
+ }
458
+ appendPendingChatInput(conversationId, content, delivery) {
459
+ const current = this.chatInputStates.get(conversationId) ?? {
391
460
  conversationId,
392
461
  revision: 0,
393
- inputs: Array.from({ length: handle?.session.pendingMessageCount ?? 0 }, (_, index) => ({
394
- id: String(index),
395
- status: "queued"
396
- }))
462
+ inputs: []
397
463
  };
464
+ const state = {
465
+ ...current,
466
+ revision: current.revision + 1,
467
+ inputs: [...current.inputs, {
468
+ id: crypto.randomUUID(),
469
+ content,
470
+ requestedDelivery: delivery,
471
+ effectiveDelivery: delivery,
472
+ status: delivery === "steer" ? "injecting" : "queued",
473
+ version: 1,
474
+ position: current.inputs.length
475
+ }]
476
+ };
477
+ this.publishChatInputState(state);
478
+ return state;
479
+ }
480
+ consumePendingChatInput(conversationId, content) {
481
+ const current = this.chatInputStates.get(conversationId);
482
+ if (!current?.inputs.length) return;
483
+ const next = commitDeliveredChatInput(current, content);
484
+ if (next !== current) this.publishChatInputState(next);
485
+ }
486
+ publishChatInputState(state) {
487
+ this.chatInputStates.set(state.conversationId, state);
488
+ this.onEvent?.({
489
+ event: "session.input-state",
490
+ data: state,
491
+ source: "embedded"
492
+ });
493
+ }
494
+ async replaceEmbeddedQueue(conversationId, state) {
495
+ const { getEmbeddedRunByConversationId } = await import("../../agent/embedded/runs.js");
496
+ const handle = getEmbeddedRunByConversationId(conversationId);
497
+ if (!handle) return false;
498
+ handle.session.clearQueue();
499
+ for (const input of state.inputs) if (input.status === "injecting") await handle.session.steer(input.content);
500
+ else await handle.session.followUp(input.content);
501
+ return true;
398
502
  }
399
503
  async loadHistory(opts) {
400
504
  if (!this.agent) return { messages: [] };
@@ -71,8 +71,26 @@ export declare class GatewayRealtimeBackend implements TuiBackend {
71
71
  }): Promise<{
72
72
  ok: boolean;
73
73
  effectiveDelivery?: 'next' | 'steer';
74
+ state?: TuiChatInputState;
74
75
  }>;
75
76
  getChatInputState(conversationId: string): Promise<TuiChatInputState>;
77
+ updateChatInput(opts: {
78
+ conversationId: string;
79
+ inputId: string;
80
+ version: number;
81
+ content: string;
82
+ }): Promise<{
83
+ ok: boolean;
84
+ state?: TuiChatInputState;
85
+ }>;
86
+ removeChatInput(opts: {
87
+ conversationId: string;
88
+ inputId: string;
89
+ version: number;
90
+ }): Promise<{
91
+ ok: boolean;
92
+ state?: TuiChatInputState;
93
+ }>;
76
94
  getStartupResources(conversationId: string): Promise<TuiStartupResources>;
77
95
  loadHistory(opts: {
78
96
  conversationId: string;