@xopcai/xopc 0.0.217 → 0.0.219

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 (329) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-D6trMTyZ.js → activity-store-slG02hSm.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CAQdFrcu.js → agent-avatar-dicebear-DZ6ETNIk.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-DxaIH0Ep.js +68 -0
  6. package/dist/gateway/static/root/assets/{api-B9pZAyMB.js → api-Tz57QxiN.js} +1 -1
  7. package/dist/gateway/static/root/assets/app-management-settings-panel-DdR1L4LR.js +1 -0
  8. package/dist/gateway/static/root/assets/appearance-settings-wYbwqmee.js +1 -0
  9. package/dist/gateway/static/root/assets/apps-page-CyWr6KyO.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-BF0q7N24.js → archive-plugin-DKXa160O.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-D1qmjGDo.js → attachment-load-CzwA9g2y.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-Ccu4yRFa.js → automations-page-DwAXyWAY.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-workspace-CL7ieYIt.js +6 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-DooqxEZz.js → binary-plugins-DoQ_DnT7.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-Dqg9kvb9.js → block-editor-Bj_Uxxng.js} +47 -47
  16. package/dist/gateway/static/root/assets/browser-settings-page-BYa_FNC1.js +8 -0
  17. package/dist/gateway/static/root/assets/{browser-workflow-inputs-CsIh8ySc.js → browser-workflow-inputs-D4roXE6r.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-workflows-page-BXQFxT0p.js → browser-workflows-page-CleKTAKD.js} +2 -2
  19. package/dist/gateway/static/root/assets/capabilities-settings-panel-DYG37N0k.js +7 -0
  20. package/dist/gateway/static/root/assets/{capability-presets-api-BX9U0FRh.js → capability-presets-api-wtEN6Ss6.js} +1 -1
  21. package/dist/gateway/static/root/assets/capability-presets-settings-panel-C0Q4dFq-.js +3 -0
  22. package/dist/gateway/static/root/assets/{channel-recipient-api-CUBTQ0Bz.js → channel-recipient-api-DhuS2RJ3.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-settings-CpO6Xg0n.js +1 -0
  24. package/dist/gateway/static/root/assets/channels-status-swr-CXhPeiNj.js +1 -0
  25. package/dist/gateway/static/root/assets/chat-terminal-dock-ClQMDe2n.js +36 -0
  26. package/dist/gateway/static/root/assets/connectors-page-BvyiPdKU.js +2 -0
  27. package/dist/gateway/static/root/assets/{cron-expression-XzPZhzVM.js → cron-expression-4DvCFs-v.js} +1 -1
  28. package/dist/gateway/static/root/assets/date-picker-B6FSjt4Z.js +1 -0
  29. package/dist/gateway/static/root/assets/dependency-picker-Za18eMp1.js +1 -0
  30. package/dist/gateway/static/root/assets/{desktop-pet-DZjW-7Tw.js → desktop-pet-DUUf3yyJ.js} +1 -1
  31. package/dist/gateway/static/root/assets/desktop-pet-settings-Dwx3GfB8.js +1 -0
  32. package/dist/gateway/static/root/assets/directory-picker-path-field-C6dfTCsl.js +1 -0
  33. package/dist/gateway/static/root/assets/ellipsis-0k4rZLoy.js +1 -0
  34. package/dist/gateway/static/root/assets/{extension-debug-page-D7APnE3n.js → extension-debug-page-Cordpg4X.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-BhV5hz70.js → extension-page-Dw0dGyMl.js} +1 -1
  36. package/dist/gateway/static/root/assets/extension-settings-page-B2pUMaXm.js +1 -0
  37. package/dist/gateway/static/root/assets/eye-CABVeTq0.js +1 -0
  38. package/dist/gateway/static/root/assets/eye-off-DEAzt3g1.js +1 -0
  39. package/dist/gateway/static/root/assets/file-code-corner-byQA1VfD.js +1 -0
  40. package/dist/gateway/static/root/assets/form-field-width-DJw_jULe.js +1 -0
  41. package/dist/gateway/static/root/assets/gateway-config-api-DAZUOEQh.js +1 -0
  42. package/dist/gateway/static/root/assets/{gateway-config-swr-BTH9HVUk.js → gateway-config-swr-BIqRg-zo.js} +1 -1
  43. package/dist/gateway/static/root/assets/gateway-settings-ik2f-pmV.js +1 -0
  44. package/dist/gateway/static/root/assets/{gateway-startup-retry-DAEk_tnd.js → gateway-startup-retry-BFjWYOCS.js} +1 -1
  45. package/dist/gateway/static/root/assets/heartbeat-settings-BE81XJ8F.js +1 -0
  46. package/dist/gateway/static/root/assets/home-page-BTWXJu_m.js +1 -0
  47. package/dist/gateway/static/root/assets/{image-generation-api-HqcQrSed.js → image-generation-api-HXAWlgm6.js} +1 -1
  48. package/dist/gateway/static/root/assets/index-B6gWYy08.js +108 -0
  49. package/dist/gateway/static/root/assets/index-CDkuz_YC.css +2 -0
  50. package/dist/gateway/static/root/assets/interaction-BmQogeqz.js +1 -0
  51. package/dist/gateway/static/root/assets/is-masked-secret-DOkL5b_X.js +1 -0
  52. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BG6lShzn.js → keyboard-shortcuts-settings-ROqQ_Xlo.js} +1 -1
  53. package/dist/gateway/static/root/assets/local-app-workbench-page-Dcaf190G.js +2 -0
  54. package/dist/gateway/static/root/assets/{local-apps-page-vaz8ewe2.js → local-apps-page-Be79cyMG.js} +1 -1
  55. package/dist/gateway/static/root/assets/{locale-store-De8wYkd7.js → locale-store-DfK-Hofd.js} +1 -1
  56. package/dist/gateway/static/root/assets/logs-page-C2pjbXno.js +2 -0
  57. package/dist/gateway/static/root/assets/{management-settings-tqTGCHt0.js → management-settings-CRspx0oY.js} +1 -1
  58. package/dist/gateway/static/root/assets/{markdown-split-BGx8Aao0.js → markdown-split-G3PTpGw3.js} +1 -1
  59. package/dist/gateway/static/root/assets/{markdown-view-ybRARsPs.js → markdown-view-D4FPJZ91.js} +1 -1
  60. package/dist/gateway/static/root/assets/{media-plugins-xbM-SSP5.js → media-plugins-DT0P7j7u.js} +1 -1
  61. package/dist/gateway/static/root/assets/messages-B701TEZ5.js +3 -0
  62. package/dist/gateway/static/root/assets/{notes-api-D9CCwyWK.js → notes-api-q7HjYO07.js} +1 -1
  63. package/dist/gateway/static/root/assets/{notes-page-CMNBbg6g.js → notes-page-Cgl2h7AR.js} +1 -1
  64. package/dist/gateway/static/root/assets/notes-workbench-DFMQYyGJ.js +4 -0
  65. package/dist/gateway/static/root/assets/page-tabs-BaEQMYm_.js +1 -0
  66. package/dist/gateway/static/root/assets/preview-open-alternatives-CsNVTKC0.js +1 -0
  67. package/dist/gateway/static/root/assets/{product-open-page-CZdzgPZW.js → product-open-page-ComKLO4D.js} +1 -1
  68. package/dist/gateway/static/root/assets/project-detail-page-DUFmQscH.js +1 -0
  69. package/dist/gateway/static/root/assets/projects-page-CTWxt3dv.js +1 -0
  70. package/dist/gateway/static/root/assets/{registry-api-DYmKEwiG.js → registry-api-BBoJ7khF.js} +1 -1
  71. package/dist/gateway/static/root/assets/remote-access-hub-qmG-3qjj.js +1 -0
  72. package/dist/gateway/static/root/assets/rotate-cw-LIg3Am9S.js +1 -0
  73. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DQ12tLCL.js → runtime-tools-settings-panel-CXHQc53b.js} +2 -2
  74. package/dist/gateway/static/root/assets/{schema-form-DNCDIkqC.js → schema-form-3jTDF2lJ.js} +1 -1
  75. package/dist/gateway/static/root/assets/search-DA7gz22f.js +1 -0
  76. package/dist/gateway/static/root/assets/sessions-page-D_We4_MV.js +1 -0
  77. package/dist/gateway/static/root/assets/settings-advanced-gate-B_QhPgU0.js +1 -0
  78. package/dist/gateway/static/root/assets/settings-form-section-CUDozALU.js +1 -0
  79. package/dist/gateway/static/root/assets/{settings-loading-skeleton-xgo41cfo.js → settings-loading-skeleton-H3ZH6a6l.js} +1 -1
  80. package/dist/gateway/static/root/assets/{settings-page-8astk_1U.js → settings-page-tx29z21o.js} +1 -1
  81. package/dist/gateway/static/root/assets/setup-status-panel-VunfXpTX.js +1 -0
  82. package/dist/gateway/static/root/assets/{share-preview-page-BBZV4AGy.js → share-preview-page-MyThymEx.js} +1 -1
  83. package/dist/gateway/static/root/assets/shares-settings-DkZvY1cr.js +1 -0
  84. package/dist/gateway/static/root/assets/skill-reload-api-DVDOh1iY.js +1 -0
  85. package/dist/gateway/static/root/assets/skills-page-BOOyMnno.js +2 -0
  86. package/dist/gateway/static/root/assets/{skills-page.utils-HmoDhJVh.js → skills-page.utils-Bl5Yv3Cx.js} +1 -1
  87. package/dist/gateway/static/root/assets/system-settings-panel-DwQ3O1ta.js +1 -0
  88. package/dist/gateway/static/root/assets/tab-completion-input-D64VNmiA.js +1 -0
  89. package/dist/gateway/static/root/assets/tab-completion-input.utils-BP3NH_du.js +1 -0
  90. package/dist/gateway/static/root/assets/task-detail-page-BwOyrADL.js +1 -0
  91. package/dist/gateway/static/root/assets/{theme-store-STx6jo38.js → theme-store-Br4BtK4x.js} +1 -1
  92. package/dist/gateway/static/root/assets/typed-models-lib-q5-Vfqd8.js +1 -0
  93. package/dist/gateway/static/root/assets/{use-autosave-CqFVx92z.js → use-autosave-DRS3RwS9.js} +1 -1
  94. package/dist/gateway/static/root/assets/user-context-page-ClV2r3Cr.js +1 -0
  95. package/dist/gateway/static/root/assets/{voice-api-key-field-pYDiKKMo.js → voice-api-key-field-CGTE5156.js} +1 -1
  96. package/dist/gateway/static/root/assets/{work-discovery-overlay-LJLw9zf0.js → work-discovery-overlay-CW-HKD7h.js} +1 -1
  97. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-D0WhQ3kI.js → workflow-run-setup-panel-Dtr9fDC8.js} +2 -2
  98. package/dist/gateway/static/root/assets/workflows-page-CDOyNgZf.js +5 -0
  99. package/dist/gateway/static/root/index.html +20 -11
  100. package/dist/package.js +1 -1
  101. package/dist/packages/gateway-contract/src/new-session.js +99 -0
  102. package/dist/packages/gateway-contract/src/tasks.js +5 -0
  103. package/dist/packages/gateway-contract/src/user-message-display.js +55 -0
  104. package/dist/src/agent/agent-manager.js +3 -2
  105. package/dist/src/agent/background-review/prompts.d.ts +1 -1
  106. package/dist/src/agent/background-review/prompts.js +6 -3
  107. package/dist/src/agent/background-review/run-background-review.js +144 -16
  108. package/dist/src/agent/inbound/turn-dispatcher.d.ts +3 -1
  109. package/dist/src/agent/inbound/turn-dispatcher.js +2 -1
  110. package/dist/src/agent/memory/context/types.d.ts +1 -1
  111. package/dist/src/agent/memory/create-memory-manager.js +1 -1
  112. package/dist/src/agent/memory/manager.d.ts +2 -1
  113. package/dist/src/agent/memory/manager.js +2 -6
  114. package/dist/src/agent/memory/understanding/service.d.ts +1 -0
  115. package/dist/src/agent/memory/understanding/service.js +179 -36
  116. package/dist/src/agent/memory/understanding/types.d.ts +6 -0
  117. package/dist/src/agent/messaging/command-handler.d.ts +2 -0
  118. package/dist/src/agent/messaging/command-handler.js +3 -1
  119. package/dist/src/agent/service/direct-turn-helpers.d.ts +3 -0
  120. package/dist/src/agent/service/direct-turn-helpers.js +13 -3
  121. package/dist/src/agent/service/process-direct-streaming.d.ts +2 -1
  122. package/dist/src/agent/service/process-direct-streaming.js +12 -11
  123. package/dist/src/agent/session/session-config-service.d.ts +1 -0
  124. package/dist/src/agent/session/session-config-service.js +11 -0
  125. package/dist/src/agent/session/session-inspector.d.ts +1 -0
  126. package/dist/src/agent/session/session-inspector.js +1 -0
  127. package/dist/src/agent/source-context/budget.d.ts +3 -0
  128. package/dist/src/agent/source-context/budget.js +21 -0
  129. package/dist/src/agent/source-context/index.js +3 -3
  130. package/dist/src/agent/source-context/injector.d.ts +2 -2
  131. package/dist/src/agent/source-context/injector.js +19 -9
  132. package/dist/src/agent/source-context/types.d.ts +16 -0
  133. package/dist/src/agent/source-context/types.js +25 -1
  134. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  135. package/dist/src/agent/tool-manuals/xopc-use.js +19 -2
  136. package/dist/src/agent/tools/xopc-use-tool.js +62 -2
  137. package/dist/src/agent-runtime/index.js +1 -1
  138. package/dist/src/agent-runtime/runtime-profile.js +1 -1
  139. package/dist/src/browser/backend-from-config.d.ts +8 -0
  140. package/dist/src/browser/backend-from-config.js +16 -1
  141. package/dist/src/browser/providers/browser-ext-install.d.ts +3 -2
  142. package/dist/src/browser/providers/browser-ext-install.js +4 -2
  143. package/dist/src/chat-commands/builtins/review.js +11 -2
  144. package/dist/src/chat-commands/builtins/understanding.js +11 -4
  145. package/dist/src/chat-commands/types.d.ts +4 -0
  146. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  147. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  148. package/dist/src/cli/commands/extension.js +1 -1
  149. package/dist/src/config/agent-profile.js +1 -1
  150. package/dist/src/config/models-json.d.ts +20 -20
  151. package/dist/src/connectors/connected-source-ingestion.js +21 -4
  152. package/dist/src/connectors/connected-source-normalizers.js +51 -4
  153. package/dist/src/connectors/connected-source-understanding.d.ts +20 -0
  154. package/dist/src/connectors/connected-source-understanding.js +180 -0
  155. package/dist/src/connectors/content-enrichment.d.ts +1 -0
  156. package/dist/src/connectors/content-enrichment.js +11 -7
  157. package/dist/src/connectors/learning-coordinator.js +112 -15
  158. package/dist/src/connectors/learning-recipes.js +2 -2
  159. package/dist/src/document-understanding/extract.d.ts +1 -1
  160. package/dist/src/document-understanding/extract.js +54 -1
  161. package/dist/src/extensions/update.js +1 -1
  162. package/dist/src/gateway/agents-admin.js +1 -1
  163. package/dist/src/gateway/chat-stream/mapper.js +18 -0
  164. package/dist/src/gateway/heartbeat/service.js +1 -1
  165. package/dist/src/gateway/hono/routes/agent-stream.js +12 -2
  166. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  167. package/dist/src/gateway/hono/routes/commands-skills.js +1 -0
  168. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +46 -2
  169. package/dist/src/gateway/hono/routes/session-input-handler.js +23 -3
  170. package/dist/src/gateway/hono/routes/sessions.js +17 -20
  171. package/dist/src/gateway/hono/routes/tasks.js +25 -0
  172. package/dist/src/gateway/hono/routes/understanding-sources.d.ts +9 -0
  173. package/dist/src/gateway/hono/routes/understanding-sources.js +138 -24
  174. package/dist/src/gateway/hono/routes/you.js +71 -4
  175. package/dist/src/gateway/rate-limit/buckets.d.ts +1 -1
  176. package/dist/src/gateway/rate-limit/buckets.js +2 -2
  177. package/dist/src/gateway/service/agent-runner.d.ts +7 -2
  178. package/dist/src/gateway/service/agent-runner.js +21 -1
  179. package/dist/src/gateway/service/config-coordinator.js +1 -1
  180. package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -0
  181. package/dist/src/gateway/service/run-gateway-agent.js +2 -1
  182. package/dist/src/gateway/service/session-input-coordinator.d.ts +8 -2
  183. package/dist/src/gateway/service/session-input-coordinator.js +62 -3
  184. package/dist/src/gateway/service/sessions-api.d.ts +1 -0
  185. package/dist/src/gateway/service.d.ts +3 -2
  186. package/dist/src/gateway/service.js +16 -6
  187. package/dist/src/gateway/user-turn-input.d.ts +2 -0
  188. package/dist/src/gateway/xopc-cloud-capability-setup.d.ts +3 -2
  189. package/dist/src/gateway/xopc-cloud-capability-setup.js +16 -3
  190. package/dist/src/heartbeat/index.js +1 -1
  191. package/dist/src/infra/update-runner.js +1 -1
  192. package/dist/src/knowledge/connected-understanding-pipeline.d.ts +1 -1
  193. package/dist/src/knowledge/connected-understanding-pipeline.js +4 -2
  194. package/dist/src/retrieval/queryProfile.d.ts +1 -0
  195. package/dist/src/retrieval/queryProfile.js +9 -1
  196. package/dist/src/session/client-history.d.ts +11 -0
  197. package/dist/src/session/client-history.js +24 -2
  198. package/dist/src/session/config-types.d.ts +1 -1
  199. package/dist/src/session/session-title.js +2 -3
  200. package/dist/src/session/store.js +1 -0
  201. package/dist/src/session/transcript-outline.js +5 -2
  202. package/dist/src/session/types.d.ts +1 -0
  203. package/dist/src/session/user-message-display.d.ts +4 -0
  204. package/dist/src/session/user-message-display.js +22 -0
  205. package/dist/src/storage/sqlite/context-extraction-repository.d.ts +57 -0
  206. package/dist/src/storage/sqlite/context-extraction-repository.js +119 -0
  207. package/dist/src/storage/sqlite/context-relation-repository.d.ts +50 -0
  208. package/dist/src/storage/sqlite/context-relation-repository.js +97 -0
  209. package/dist/src/storage/sqlite/index.d.ts +4 -2
  210. package/dist/src/storage/sqlite/index.js +5 -3
  211. package/dist/src/storage/sqlite/migrations/126_focus_context_governance.sql +72 -0
  212. package/dist/src/storage/sqlite/migrations/127_context_object_origin.sql +36 -0
  213. package/dist/src/storage/sqlite/migrations/128_context_extraction.sql +73 -0
  214. package/dist/src/storage/sqlite/migrations/129_focus_versions.sql +51 -0
  215. package/dist/src/storage/sqlite/migrations/130_context_evidence_provenance.sql +18 -0
  216. package/dist/src/storage/sqlite/migrations/131_session_input_contexts.sql +2 -0
  217. package/dist/src/storage/sqlite/migrations/132_transcript_source_context_metadata.sql +34 -0
  218. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  219. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  220. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  221. package/dist/src/storage/sqlite/schema.js +1 -1
  222. package/dist/src/storage/sqlite/session-input-repository.d.ts +8 -0
  223. package/dist/src/storage/sqlite/session-input-repository.js +19 -7
  224. package/dist/src/storage/sqlite/session-turn-replace-repository.d.ts +3 -0
  225. package/dist/src/storage/sqlite/session-turn-replace-repository.js +3 -2
  226. package/dist/src/storage/sqlite/transcript-repository.js +29 -3
  227. package/dist/src/storage/sqlite/user-context-repository.d.ts +4 -1
  228. package/dist/src/storage/sqlite/user-context-repository.js +65 -29
  229. package/dist/src/tasks/index.d.ts +1 -0
  230. package/dist/src/tasks/index.js +2 -1
  231. package/dist/src/tasks/task-deletion-service.d.ts +21 -0
  232. package/dist/src/tasks/task-deletion-service.js +35 -0
  233. package/dist/src/tasks/task-repository.js +22 -1
  234. package/dist/src/tui/backends/embedded-backend.js +5 -3
  235. package/dist/src/tui/backends/gateway-realtime-backend.js +5 -3
  236. package/dist/src/tui/chat-history.js +2 -1
  237. package/dist/src/tui/tui-agent-events.js +4 -2
  238. package/dist/src/tui/tui-commands.d.ts +1 -0
  239. package/dist/src/tui/tui-commands.js +8 -3
  240. package/dist/src/tui/tui-empty-session-cleanup.d.ts +0 -1
  241. package/dist/src/tui/tui-empty-session-cleanup.js +1 -11
  242. package/dist/src/tui/tui-new-session-preferences.d.ts +10 -0
  243. package/dist/src/tui/tui-new-session-preferences.js +32 -0
  244. package/dist/src/tui/tui-session-actions.d.ts +1 -0
  245. package/dist/src/tui/tui-session-actions.js +2 -1
  246. package/dist/src/tui/tui-settings.d.ts +2 -0
  247. package/dist/src/tui/tui-settings.js +4 -1
  248. package/dist/src/tui/tui-types.d.ts +1 -0
  249. package/dist/src/tui/tui.js +57 -4
  250. package/dist/src/tunnel/frpc-process.js +3 -0
  251. package/dist/src/tunnel/tunnel-service.d.ts +2 -0
  252. package/dist/src/tunnel/tunnel-service.js +40 -28
  253. package/dist/src/user-context/context-objects.d.ts +17 -0
  254. package/dist/src/user-context/context-objects.js +99 -0
  255. package/dist/src/user-context/domain.d.ts +13 -1
  256. package/dist/src/user-context/evaluation/harness.d.ts +13 -0
  257. package/dist/src/user-context/evaluation/harness.js +31 -0
  258. package/dist/src/user-context/extraction/registry.d.ts +26 -0
  259. package/dist/src/user-context/extraction/registry.js +113 -0
  260. package/dist/src/user-context/extraction/repair.d.ts +19 -0
  261. package/dist/src/user-context/extraction/repair.js +68 -0
  262. package/dist/src/user-context/planner.js +214 -57
  263. package/dist/src/user-context/retriever.js +69 -9
  264. package/dist/src/user-context/sources/catalog.js +9 -2
  265. package/dist/src/user-context/sources/index.js +2 -2
  266. package/dist/src/user-context/sources/local-source-contract.d.ts +1 -1
  267. package/dist/src/user-context/sources/local-source-contract.js +1 -0
  268. package/dist/src/user-context/sources/processing-policy.d.ts +2 -0
  269. package/dist/src/user-context/sources/processing-policy.js +7 -0
  270. package/dist/src/user-context/sources/repository.d.ts +23 -4
  271. package/dist/src/user-context/sources/repository.js +122 -12
  272. package/dist/src/user-context/sources/types.d.ts +10 -1
  273. package/dist/src/user-context/understanding-writing.d.ts +1 -0
  274. package/dist/src/user-context/understanding-writing.js +4 -0
  275. package/dist/src/user-context/understanding.js +1 -1
  276. package/dist/src/work-discovery/analyzer.d.ts +6 -0
  277. package/dist/src/work-discovery/analyzer.js +181 -57
  278. package/dist/src/work-discovery/index.js +1 -1
  279. package/dist/src/work-discovery/probe.js +20 -0
  280. package/dist/src/work-discovery/service.d.ts +9 -0
  281. package/dist/src/work-discovery/service.js +39 -11
  282. package/dist/src/work-discovery/source-repository.js +1 -1
  283. package/dist/src/work-discovery/types.d.ts +5 -0
  284. package/package.json +3 -3
  285. package/dist/gateway/static/root/assets/agents-C6q_vDzP.js +0 -68
  286. package/dist/gateway/static/root/assets/app-management-settings-panel-DRsTwFbF.js +0 -1
  287. package/dist/gateway/static/root/assets/appearance-settings-B99NaPTf.js +0 -1
  288. package/dist/gateway/static/root/assets/apps-page-Dx66anqa.js +0 -1
  289. package/dist/gateway/static/root/assets/automations-workspace-CHbA8d-P.js +0 -6
  290. package/dist/gateway/static/root/assets/browser-settings-page-CpRc-9Jy.js +0 -8
  291. package/dist/gateway/static/root/assets/capabilities-settings-panel-C89FGECN.js +0 -7
  292. package/dist/gateway/static/root/assets/capability-presets-settings-panel-XT6WEz9E.js +0 -3
  293. package/dist/gateway/static/root/assets/channels-settings-DhKk1oNT.js +0 -1
  294. package/dist/gateway/static/root/assets/channels-status-swr-CiwOOoVL.js +0 -1
  295. package/dist/gateway/static/root/assets/chat-terminal-dock-CTbkTsc2.js +0 -36
  296. package/dist/gateway/static/root/assets/connectors-page-BDn3HTzX.js +0 -2
  297. package/dist/gateway/static/root/assets/date-picker-BmZjs4Bq.js +0 -1
  298. package/dist/gateway/static/root/assets/dependency-picker-ndtb88_T.js +0 -1
  299. package/dist/gateway/static/root/assets/desktop-pet-settings-C7BLs783.js +0 -1
  300. package/dist/gateway/static/root/assets/directory-picker-path-field-BWiap88p.js +0 -1
  301. package/dist/gateway/static/root/assets/extension-settings-page-BhbcGuiJ.js +0 -1
  302. package/dist/gateway/static/root/assets/gateway-config-api-CUt9bIpL.js +0 -1
  303. package/dist/gateway/static/root/assets/gateway-settings-RafSECLG.js +0 -1
  304. package/dist/gateway/static/root/assets/heartbeat-settings-CwVPlPLB.js +0 -1
  305. package/dist/gateway/static/root/assets/home-page-CbdBcCwC.js +0 -1
  306. package/dist/gateway/static/root/assets/index-AbNnQyKk.css +0 -2
  307. package/dist/gateway/static/root/assets/index-CMLkr37Y.js +0 -108
  308. package/dist/gateway/static/root/assets/local-app-workbench-page-DdaPtQ5M.js +0 -2
  309. package/dist/gateway/static/root/assets/logs-page-CjxMHTQO.js +0 -2
  310. package/dist/gateway/static/root/assets/messages-VI9m1xJl.js +0 -3
  311. package/dist/gateway/static/root/assets/notes-workbench-V9C-8vSn.js +0 -4
  312. package/dist/gateway/static/root/assets/page-tabs-e99j9S9K.js +0 -1
  313. package/dist/gateway/static/root/assets/preview-open-alternatives-DW9MDOva.js +0 -1
  314. package/dist/gateway/static/root/assets/project-detail-page-DHmAUggu.js +0 -1
  315. package/dist/gateway/static/root/assets/projects-page-D0EiN69Y.js +0 -1
  316. package/dist/gateway/static/root/assets/remote-access-hub-BuAVFk2O.js +0 -1
  317. package/dist/gateway/static/root/assets/sessions-page-hzlTfgOl.js +0 -1
  318. package/dist/gateway/static/root/assets/settings-advanced-gate-BlCoA_9h.js +0 -1
  319. package/dist/gateway/static/root/assets/settings-form-section-z0JH53Fu.js +0 -1
  320. package/dist/gateway/static/root/assets/setup-status-panel-fZQfoJAk.js +0 -1
  321. package/dist/gateway/static/root/assets/shares-settings-B5dPMq3Y.js +0 -1
  322. package/dist/gateway/static/root/assets/skill-reload-api-i1PGf1V2.js +0 -1
  323. package/dist/gateway/static/root/assets/skills-page-BSN2VaqR.js +0 -2
  324. package/dist/gateway/static/root/assets/system-settings-panel-CSibO8vj.js +0 -1
  325. package/dist/gateway/static/root/assets/tab-completion-input-B-VsxKhC.js +0 -1
  326. package/dist/gateway/static/root/assets/task-detail-page-HCKZ11E8.js +0 -1
  327. package/dist/gateway/static/root/assets/typed-models-lib-zrYg51t3.js +0 -1
  328. package/dist/gateway/static/root/assets/user-context-page-CqG56cDS.js +0 -1
  329. package/dist/gateway/static/root/assets/workflows-page-DQAJzV5w.js +0 -5
@@ -12,7 +12,7 @@ const log = createLogger("Sqlite:Migrations");
12
12
  /** Baseline schema version applied from schema.sql on first open. */
13
13
  const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
14
14
  /** Latest schema version this release supports (increment when adding migrations). */
15
- const XOPC_DB_SCHEMA_VERSION = 125;
15
+ const XOPC_DB_SCHEMA_VERSION = 132;
16
16
  const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
17
17
  function backupBeforeTaskCutover(db, databasePath) {
18
18
  db.exec("PRAGMA wal_checkpoint(FULL)");
@@ -57,7 +57,7 @@ function applySingleMigration(db, migration) {
57
57
  * Each step runs in its own transaction and updates schema_meta on success.
58
58
  */
59
59
  function applyPendingMigrations(db, options = {}) {
60
- const targetVersion = options.targetVersion ?? 125;
60
+ const targetVersion = options.targetVersion ?? 132;
61
61
  let currentVersion = readSchemaVersion(db);
62
62
  if (currentVersion > targetVersion) throw new DatabaseSchemaTooNewError(currentVersion, targetVersion);
63
63
  if (currentVersion >= targetVersion) return currentVersion;
@@ -94,7 +94,7 @@ function applyPendingMigrations(db, options = {}) {
94
94
  }
95
95
  /** Inspect schema version without mutating the database. */
96
96
  function inspectSchemaMigrationStatus(db, options = {}) {
97
- const appVersion = options.targetVersion ?? 125;
97
+ const appVersion = options.targetVersion ?? 132;
98
98
  const dbVersion = readSchemaVersion(db);
99
99
  if (dbVersion > appVersion) return {
100
100
  dbVersion,
@@ -19,7 +19,7 @@ const log = createLogger('Sqlite:Migrations');
19
19
  export const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
20
20
 
21
21
  /** Latest schema version this release supports (increment when adding migrations). */
22
- export const XOPC_DB_SCHEMA_VERSION = 125;
22
+ export const XOPC_DB_SCHEMA_VERSION = 132;
23
23
 
24
24
  const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
25
25
 
@@ -32,7 +32,7 @@ function ensureXopcDatabaseSchema(db, options = {}) {
32
32
  currentVersion = 11;
33
33
  }
34
34
  applyPendingMigrations(db, {
35
- targetVersion: 125,
35
+ targetVersion: 132,
36
36
  databasePath: options.databasePath
37
37
  });
38
38
  }
@@ -1,4 +1,5 @@
1
1
  import { type TurnOrigin } from '@xopcai/endpoint-tools-protocol';
2
+ import type { AgentSourceContext, SourceContextRefSummary } from '../../agent/source-context/types.js';
2
3
  export type SessionInputDelivery = 'next' | 'steer';
3
4
  export type SessionInputStatus = 'queued' | 'running' | 'injecting' | 'completed' | 'cancelled' | 'failed' | 'interrupted';
4
5
  export type SessionInput = {
@@ -10,6 +11,8 @@ export type SessionInput = {
10
11
  status: SessionInputStatus;
11
12
  content: string;
12
13
  attachments?: unknown[];
14
+ contextRefs?: SourceContextRefSummary[];
15
+ contextSnapshots?: AgentSourceContext[];
13
16
  thinking?: string;
14
17
  origin: TurnOrigin;
15
18
  position: number;
@@ -29,6 +32,7 @@ export type SessionInputState = {
29
32
  };
30
33
  export declare function getSessionInputState(sessionKey: string): SessionInputState;
31
34
  export declare function findSessionInput(sessionKey: string, clientMessageId: string): SessionInput | undefined;
35
+ export declare function getSessionInputById(sessionKey: string, id: string): SessionInput | undefined;
32
36
  export declare function insertSessionInput(input: {
33
37
  id: string;
34
38
  sessionKey: string;
@@ -38,6 +42,8 @@ export declare function insertSessionInput(input: {
38
42
  status: 'queued' | 'injecting';
39
43
  content: string;
40
44
  attachments?: unknown[];
45
+ contextRefs?: SourceContextRefSummary[];
46
+ contextSnapshots?: AgentSourceContext[];
41
47
  thinking?: string;
42
48
  origin: TurnOrigin;
43
49
  targetRunId?: string;
@@ -55,6 +61,8 @@ export declare function mutateQueuedSessionInput(input: {
55
61
  version: number;
56
62
  content?: string;
57
63
  attachments?: unknown[];
64
+ contextRefs?: SourceContextRefSummary[];
65
+ contextSnapshots?: AgentSourceContext[];
58
66
  thinking?: string;
59
67
  position?: number;
60
68
  }): boolean;
@@ -11,6 +11,8 @@ function mapInput(row) {
11
11
  status: row.status,
12
12
  content: row.content,
13
13
  attachments: row.attachments_json ? JSON.parse(row.attachments_json) : void 0,
14
+ contextRefs: row.context_refs_json ? JSON.parse(row.context_refs_json) : void 0,
15
+ contextSnapshots: row.context_snapshots_json ? JSON.parse(row.context_snapshots_json) : void 0,
14
16
  thinking: row.thinking ?? void 0,
15
17
  position: row.position,
16
18
  origin: turnOriginSchema.parse(JSON.parse(row.origin_json)),
@@ -23,7 +25,8 @@ function mapInput(row) {
23
25
  };
24
26
  }
25
27
  const SELECT_INPUTS = `SELECT id, session_key, client_message_id, requested_delivery,
26
- effective_delivery, status, content, attachments_json, thinking, origin_json, position,
28
+ effective_delivery, status, content, attachments_json, context_refs_json, context_snapshots_json,
29
+ thinking, origin_json, position,
27
30
  target_run_id, run_id, version, error, created_at_ms, updated_at_ms
28
31
  FROM session_inputs`;
29
32
  function ensureRuntime(db, sessionKey) {
@@ -47,13 +50,20 @@ function getSessionInputState(sessionKey) {
47
50
  revision: runtime?.revision ?? 0,
48
51
  activeRunId: runtime?.active_run_id ?? void 0,
49
52
  activeInputId: runtime?.active_input_id ?? void 0,
50
- inputs: rows.map(mapInput)
53
+ inputs: rows.map((row) => {
54
+ const { contextSnapshots: _contextSnapshots, ...input } = mapInput(row);
55
+ return input;
56
+ })
51
57
  };
52
58
  }
53
59
  function findSessionInput(sessionKey, clientMessageId) {
54
60
  const row = getSqliteDatabase().prepare(`${SELECT_INPUTS} WHERE session_key = ? AND client_message_id = ?`).get(sessionKey, clientMessageId);
55
61
  return row ? mapInput(row) : void 0;
56
62
  }
63
+ function getSessionInputById(sessionKey, id) {
64
+ const row = getSqliteDatabase().prepare(`${SELECT_INPUTS} WHERE session_key = ? AND id = ?`).get(sessionKey, id);
65
+ return row ? mapInput(row) : void 0;
66
+ }
57
67
  function insertSessionInput(input) {
58
68
  return runSqliteWriteTransaction((db) => {
59
69
  const existing = db.prepare(`${SELECT_INPUTS} WHERE session_key = ? AND client_message_id = ?`).get(input.sessionKey, input.clientMessageId);
@@ -63,8 +73,9 @@ function insertSessionInput(input) {
63
73
  WHERE session_key = ? AND status IN ('queued','running','injecting','interrupted')`).get(input.sessionKey);
64
74
  db.prepare(`INSERT INTO session_inputs(id, session_key, client_message_id,
65
75
  requested_delivery, effective_delivery, status, content, attachments_json,
66
- thinking, origin_json, position, target_run_id, version, created_at_ms, updated_at_ms)
67
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)`).run(input.id, input.sessionKey, input.clientMessageId, input.requestedDelivery, input.effectiveDelivery, input.status, input.content, input.attachments ? JSON.stringify(input.attachments) : null, input.thinking ?? null, JSON.stringify(input.origin), max.value + 1, input.targetRunId ?? null, now, now);
76
+ context_refs_json, context_snapshots_json, thinking, origin_json, position,
77
+ target_run_id, version, created_at_ms, updated_at_ms)
78
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)`).run(input.id, input.sessionKey, input.clientMessageId, input.requestedDelivery, input.effectiveDelivery, input.status, input.content, input.attachments ? JSON.stringify(input.attachments) : null, input.contextRefs ? JSON.stringify(input.contextRefs) : null, input.contextSnapshots ? JSON.stringify(input.contextSnapshots) : null, input.thinking ?? null, JSON.stringify(input.origin), max.value + 1, input.targetRunId ?? null, now, now);
68
79
  bumpRevision(db, input.sessionKey);
69
80
  return mapInput(db.prepare(`${SELECT_INPUTS} WHERE id = ?`).get(input.id));
70
81
  });
@@ -119,8 +130,9 @@ function mutateQueuedSessionInput(input) {
119
130
  ordered.splice(Math.max(0, Math.min(input.position, ordered.length)), 0, row);
120
131
  const stmt = db.prepare(`UPDATE session_inputs SET position = ?, version = version + 1, updated_at_ms = ? WHERE id = ?`);
121
132
  ordered.forEach((item, index) => stmt.run(index + 1, now, item.id));
122
- } else db.prepare(`UPDATE session_inputs SET content = ?, attachments_json = ?, thinking = ?, version = version + 1,
123
- updated_at_ms = ? WHERE id = ?`).run(input.content ?? row.content, input.attachments ? JSON.stringify(input.attachments) : row.attachments_json, input.thinking ?? row.thinking, now, input.id);
133
+ } else db.prepare(`UPDATE session_inputs SET content = ?, attachments_json = ?, context_refs_json = ?,
134
+ context_snapshots_json = ?, thinking = ?, version = version + 1,
135
+ updated_at_ms = ? WHERE id = ?`).run(input.content ?? row.content, input.attachments ? JSON.stringify(input.attachments) : row.attachments_json, input.contextRefs ? JSON.stringify(input.contextRefs) : row.context_refs_json, input.contextSnapshots ? JSON.stringify(input.contextSnapshots) : row.context_snapshots_json, input.thinking ?? row.thinking, now, input.id);
124
136
  bumpRevision(db, input.sessionKey);
125
137
  return true;
126
138
  });
@@ -146,4 +158,4 @@ function recoverSessionInputState() {
146
158
  });
147
159
  }
148
160
  //#endregion
149
- export { cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputState, insertSessionInput, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus };
161
+ export { cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputById, getSessionInputState, insertSessionInput, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus };
@@ -1,11 +1,14 @@
1
1
  import type { AgentMessage } from '@earendil-works/pi-agent-core';
2
2
  import type { TurnOrigin } from '@xopcai/endpoint-tools-protocol';
3
+ import type { AgentSourceContext, SourceContextRefSummary } from '../../agent/source-context/types.js';
3
4
  export type ReplaceLatestSessionTurnInput = {
4
5
  sessionKey: string;
5
6
  targetTurnId: string;
6
7
  clientMessageId: string;
7
8
  content: string;
8
9
  attachments?: unknown[];
10
+ contextRefs?: SourceContextRefSummary[];
11
+ contextSnapshots?: AgentSourceContext[];
9
12
  thinking?: string;
10
13
  origin: TurnOrigin;
11
14
  };
@@ -93,8 +93,9 @@ function replaceLatestSessionTurnAndQueueInput(input) {
93
93
  const inputId = randomUUID();
94
94
  db.prepare(`INSERT INTO session_inputs(id, session_key, client_message_id,
95
95
  requested_delivery, effective_delivery, status, content, attachments_json,
96
- thinking, origin_json, position, target_run_id, version, created_at_ms, updated_at_ms)
97
- VALUES (?, ?, ?, 'next', 'next', 'queued', ?, ?, ?, ?, ?, NULL, 1, ?, ?)`).run(inputId, input.sessionKey, input.clientMessageId, input.content, input.attachments ? JSON.stringify(input.attachments) : null, input.thinking ?? null, JSON.stringify(input.origin), maxPosition.value + 1, now, now);
96
+ context_refs_json, context_snapshots_json, thinking, origin_json, position,
97
+ target_run_id, version, created_at_ms, updated_at_ms)
98
+ VALUES (?, ?, ?, 'next', 'next', 'queued', ?, ?, ?, ?, ?, ?, ?, NULL, 1, ?, ?)`).run(inputId, input.sessionKey, input.clientMessageId, input.content, input.attachments ? JSON.stringify(input.attachments) : null, input.contextRefs ? JSON.stringify(input.contextRefs) : null, input.contextSnapshots ? JSON.stringify(input.contextSnapshots) : null, input.thinking ?? null, JSON.stringify(input.origin), maxPosition.value + 1, now, now);
98
99
  db.prepare(`UPDATE session_input_runtime SET revision = revision + 1, updated_at_ms = ?
99
100
  WHERE session_key = ?`).run(now, input.sessionKey);
100
101
  return {
@@ -33,20 +33,46 @@ function isUserMessageRow(row) {
33
33
  const classified = classifyStoredRow(row);
34
34
  return classified.entryKind === "message" && classified.role === "user";
35
35
  }
36
+ function withSessionInputContextMetadata(db, sessionKey, row) {
37
+ if (!isUserMessageRow(row)) return row;
38
+ const message = row;
39
+ const turnId = typeof message.turnId === "string" ? message.turnId.trim() : "";
40
+ if (!turnId) return row;
41
+ const metadata = message.metadata && typeof message.metadata === "object" && !Array.isArray(message.metadata) ? message.metadata : {};
42
+ if (Array.isArray(metadata.sourceContexts) && metadata.sourceContexts.length > 0) return row;
43
+ const input = db.prepare(`SELECT context_refs_json FROM session_inputs
44
+ WHERE session_key = ? AND run_id = ? AND context_refs_json IS NOT NULL
45
+ LIMIT 1`).get(sessionKey, turnId);
46
+ if (!input) return row;
47
+ try {
48
+ const sourceContexts = JSON.parse(input.context_refs_json);
49
+ if (!Array.isArray(sourceContexts) || sourceContexts.length === 0) return row;
50
+ return {
51
+ ...message,
52
+ metadata: {
53
+ ...metadata,
54
+ sourceContexts
55
+ }
56
+ };
57
+ } catch {
58
+ return row;
59
+ }
60
+ }
36
61
  function appendTranscriptEntry(sessionKey, row, opts) {
37
62
  if (isRuntimeOnlyTranscriptMessage(row)) throw new Error("Runtime-only messages cannot be persisted in a session transcript");
38
63
  return runSqliteWriteTransaction((db) => {
39
64
  const sessionId = opts?.sessionId ?? readCurrentSessionId(db, sessionKey);
40
65
  if (!sessionId) throw new Error(`Session not found: ${sessionKey}`);
66
+ const persistedRow = withSessionInputContextMetadata(db, sessionKey, row);
41
67
  const inserted = insertEntry(db, {
42
68
  sessionId,
43
69
  sessionKey,
44
- row
70
+ row: persistedRow
45
71
  });
46
- if (classifyStoredRow(row).entryKind === "message") {
72
+ if (classifyStoredRow(persistedRow).entryKind === "message") {
47
73
  const tokenDelta = opts?.tokenDelta ?? 0;
48
74
  const now = Date.now();
49
- const hiddenUpdate = isUserMessageRow(row) ? `hidden_from_session_list = 0,` : "";
75
+ const hiddenUpdate = isUserMessageRow(persistedRow) ? `hidden_from_session_list = 0,` : "";
50
76
  db.prepare(`UPDATE sessions SET
51
77
  message_count = message_count + 1,
52
78
  estimated_tokens = estimated_tokens + ?,
@@ -25,6 +25,7 @@ export declare function setUnderstandingStatus(id: string, status: Understanding
25
25
  explicitness: UserUnderstanding['explicitness'];
26
26
  confidence: number;
27
27
  }): UserUnderstanding;
28
+ export declare function closeUnderstandingValidity(id: string, validTo?: number): UserUnderstanding;
28
29
  export declare function rejectUnderstanding(id: string, reason: string): UserUnderstanding;
29
30
  export declare function deleteUnderstanding(id: string): boolean;
30
31
  export declare function isUnderstandingSuppressed(canonicalKey: string, scope: UserContextScope, principalId?: string): boolean;
@@ -34,7 +35,9 @@ export declare function listCollaborationRules(principalId?: string): Collaborat
34
35
  export declare function reviseCollaborationRule(id: string, statement: string): CollaborationRule;
35
36
  export declare function setCollaborationRuleStatus(id: string, status: CollaborationRule['status']): CollaborationRule;
36
37
  export declare function deleteCollaborationRule(id: string): boolean;
37
- export declare function createContextEvidence(input: Omit<ContextEvidence, 'id' | 'createdAt'>, principalId?: string): ContextEvidence;
38
+ export declare function createContextEvidence(input: Omit<ContextEvidence, 'id' | 'ingestedAt' | 'createdAt'> & {
39
+ ingestedAt?: number;
40
+ }, principalId?: string): ContextEvidence;
38
41
  export declare function linkUnderstandingEvidence(versionId: string, evidenceId: string, relation: 'supports' | 'contradicts' | 'supersedes', confidence: number): void;
39
42
  export declare function listUnderstandingEvidence(understandingId: string, relation?: 'supports' | 'contradicts' | 'supersedes'): ContextEvidence[];
40
43
  export declare function recordContextRun(input: {
@@ -2,8 +2,31 @@ import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
2
2
  import { USER_CONTEXT_PRINCIPAL_ID } from "../../user-context/domain.js";
3
3
  import { retrievalQueryAuditValue } from "../../retrieval/audit.js";
4
4
  import { buildFts5SearchQuery, fts5RankToScore } from "./fts.js";
5
- import { randomUUID } from "node:crypto";
5
+ import { createHash, randomUUID } from "node:crypto";
6
6
  //#region src/storage/sqlite/user-context-repository.ts
7
+ function evidenceFromRow(row) {
8
+ return {
9
+ id: row.evidence_id,
10
+ sourceType: row.source_type,
11
+ ...row.source_instance_id ? { sourceInstanceId: row.source_instance_id } : {},
12
+ sourceRef: row.source_ref,
13
+ ...row.source_run_id ? { sourceRunId: row.source_run_id } : {},
14
+ ...row.source_item_id ? { sourceItemId: row.source_item_id } : {},
15
+ ...row.session_id ? { sessionId: row.session_id } : {},
16
+ ...row.turn_id ? { turnId: row.turn_id } : {},
17
+ ...row.message_id ? { messageId: row.message_id } : {},
18
+ ...row.content_hash ? { contentHash: row.content_hash } : {},
19
+ ...row.retention_policy ? { retentionPolicy: row.retention_policy } : {},
20
+ ...row.processing_policy ? { processingPolicy: row.processing_policy } : {},
21
+ ...row.extractor_id ? { extractorId: row.extractor_id } : {},
22
+ ...row.extractor_version ? { extractorVersion: row.extractor_version } : {},
23
+ ...row.redacted_excerpt ? { redactedExcerpt: row.redacted_excerpt } : {},
24
+ trustLevel: row.trust_level,
25
+ observedAt: row.observed_at,
26
+ ingestedAt: row.ingested_at ?? row.created_at,
27
+ createdAt: row.created_at
28
+ };
29
+ }
7
30
  const UNDERSTANDING_SELECT = `
8
31
  SELECT u.*, v.statement, v.payload_json
9
32
  FROM user_understandings u
@@ -182,6 +205,16 @@ function setUnderstandingStatus(id, status, confirmation) {
182
205
  confidence = COALESCE(?, confidence),
183
206
  updated_at = ?
184
207
  WHERE understanding_id = ?`).run(status, confirmation?.explicitness ?? null, confirmation?.confidence ?? null, now, id);
208
+ const assertionStatus = status === "active" ? "active" : status === "archived" ? "closed" : status === "rejected" ? "rejected" : "candidate";
209
+ getSqliteDatabase().prepare(`UPDATE context_temporal_assertions
210
+ SET status = ?, updated_at = ? WHERE object_type = 'understanding' AND object_id = ?`).run(assertionStatus, now, id);
211
+ const result = getUnderstanding(id);
212
+ if (!result) throw new Error(`User understanding not found: ${id}`);
213
+ return result;
214
+ }
215
+ function closeUnderstandingValidity(id, validTo = Date.now()) {
216
+ getSqliteDatabase().prepare(`UPDATE user_understandings SET valid_to = ?, updated_at = ?
217
+ WHERE understanding_id = ?`).run(validTo, validTo, id);
185
218
  const result = getUnderstanding(id);
186
219
  if (!result) throw new Error(`User understanding not found: ${id}`);
187
220
  return result;
@@ -263,25 +296,36 @@ function createContextEvidence(input, principalId = USER_CONTEXT_PRINCIPAL_ID) {
263
296
  const existing = getSqliteDatabase().prepare(`SELECT * FROM context_evidence
264
297
  WHERE principal_id = ? AND source_type = ?
265
298
  AND COALESCE(source_instance_id, '') = COALESCE(?, '') AND source_ref = ?`).get(principalId, input.sourceType, input.sourceInstanceId ?? null, input.sourceRef);
266
- if (existing) return {
267
- id: existing.evidence_id,
268
- sourceType: existing.source_type,
269
- ...existing.source_instance_id ? { sourceInstanceId: existing.source_instance_id } : {},
270
- sourceRef: existing.source_ref,
271
- ...existing.redacted_excerpt ? { redactedExcerpt: existing.redacted_excerpt } : {},
272
- trustLevel: existing.trust_level,
273
- observedAt: existing.observed_at,
274
- createdAt: existing.created_at
275
- };
299
+ const derivedHash = input.contentHash ?? (input.redactedExcerpt ? createHash("sha256").update(input.redactedExcerpt).digest("hex") : void 0);
300
+ if (existing) {
301
+ getSqliteDatabase().prepare(`UPDATE context_evidence SET
302
+ source_run_id = COALESCE(source_run_id, ?), source_item_id = COALESCE(source_item_id, ?),
303
+ session_id = COALESCE(session_id, ?), turn_id = COALESCE(turn_id, ?),
304
+ message_id = COALESCE(message_id, ?), content_hash = COALESCE(content_hash, ?),
305
+ retention_policy = COALESCE(retention_policy, ?),
306
+ processing_policy = CASE
307
+ WHEN processing_policy = 'local_only' OR ? = 'local_only' THEN 'local_only'
308
+ ELSE COALESCE(processing_policy, ?)
309
+ END,
310
+ extractor_id = COALESCE(extractor_id, ?), extractor_version = COALESCE(extractor_version, ?),
311
+ ingested_at = COALESCE(ingested_at, ?)
312
+ WHERE evidence_id = ?`).run(input.sourceRunId ?? null, input.sourceItemId ?? null, input.sessionId ?? null, input.turnId ?? null, input.messageId ?? null, derivedHash ?? null, input.retentionPolicy ?? null, input.processingPolicy ?? null, input.processingPolicy ?? null, input.extractorId ?? null, input.extractorVersion ?? null, input.ingestedAt ?? Date.now(), existing.evidence_id);
313
+ return evidenceFromRow(getSqliteDatabase().prepare("SELECT * FROM context_evidence WHERE evidence_id = ?").get(existing.evidence_id));
314
+ }
315
+ const createdAt = Date.now();
276
316
  const evidence = {
277
317
  ...input,
278
318
  id: randomUUID(),
279
- createdAt: Date.now()
319
+ ...derivedHash ? { contentHash: derivedHash } : {},
320
+ ingestedAt: input.ingestedAt ?? createdAt,
321
+ createdAt
280
322
  };
281
323
  getSqliteDatabase().prepare(`INSERT INTO context_evidence (
282
- evidence_id, principal_id, source_type, source_instance_id, source_ref,
283
- redacted_excerpt, trust_level, observed_at, created_at
284
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(evidence.id, principalId, evidence.sourceType, evidence.sourceInstanceId ?? null, evidence.sourceRef, evidence.redactedExcerpt ?? null, evidence.trustLevel, evidence.observedAt, evidence.createdAt);
324
+ evidence_id, principal_id, source_type, source_instance_id, source_ref, source_run_id,
325
+ source_item_id, session_id, turn_id, message_id, content_hash, retention_policy,
326
+ processing_policy, extractor_id, extractor_version, redacted_excerpt, trust_level,
327
+ observed_at, ingested_at, created_at
328
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(evidence.id, principalId, evidence.sourceType, evidence.sourceInstanceId ?? null, evidence.sourceRef, evidence.sourceRunId ?? null, evidence.sourceItemId ?? null, evidence.sessionId ?? null, evidence.turnId ?? null, evidence.messageId ?? null, evidence.contentHash ?? null, evidence.retentionPolicy ?? null, evidence.processingPolicy ?? null, evidence.extractorId ?? null, evidence.extractorVersion ?? null, evidence.redactedExcerpt ?? null, evidence.trustLevel, evidence.observedAt, evidence.ingestedAt, evidence.createdAt);
285
329
  return evidence;
286
330
  }
287
331
  function linkUnderstandingEvidence(versionId, evidenceId, relation, confidence) {
@@ -295,16 +339,7 @@ function listUnderstandingEvidence(understandingId, relation) {
295
339
  JOIN understanding_evidence_links l ON l.evidence_id = e.evidence_id
296
340
  JOIN user_understanding_versions v ON v.version_id = l.version_id
297
341
  WHERE v.understanding_id = ? AND (? IS NULL OR l.relation = ?)
298
- ORDER BY e.observed_at DESC`).all(understandingId, relation ?? null, relation ?? null).map((row) => ({
299
- id: row.evidence_id,
300
- sourceType: row.source_type,
301
- ...row.source_instance_id ? { sourceInstanceId: row.source_instance_id } : {},
302
- sourceRef: row.source_ref,
303
- ...row.redacted_excerpt ? { redactedExcerpt: row.redacted_excerpt } : {},
304
- trustLevel: row.trust_level,
305
- observedAt: row.observed_at,
306
- createdAt: row.created_at
307
- }));
342
+ ORDER BY e.observed_at DESC`).all(understandingId, relation ?? null, relation ?? null).map(evidenceFromRow);
308
343
  }
309
344
  function recordContextRun(input) {
310
345
  const auditedQuery = retrievalQueryAuditValue(input.query);
@@ -320,9 +355,9 @@ function recordContextRun(input) {
320
355
  ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(runId, input.principalId ?? "local-owner", input.turnId, input.sessionKey, auditedQuery, input.budget, input.durationMs, Date.now());
321
356
  const insert = db.prepare(`INSERT INTO context_run_items (
322
357
  context_run_id, object_type, object_id, version_id, decision, reason, content_snapshot,
323
- source_label, rank, score, injected_chars
324
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);
325
- for (const item of input.items) insert.run(runId, item.objectType, item.objectId, item.versionId ?? null, item.decision, item.reason, item.content, item.sourceLabel, item.rank ?? null, item.score ?? null, item.injectedChars);
358
+ source_label, origin, rank, score, injected_chars
359
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);
360
+ for (const item of input.items) insert.run(runId, item.objectType, item.objectId, item.versionId ?? null, item.decision, item.reason, item.content, item.sourceLabel, item.origin, item.rank ?? null, item.score ?? null, item.injectedChars);
326
361
  });
327
362
  return runId;
328
363
  }
@@ -341,6 +376,7 @@ function getTurnPersonalization(turnId) {
341
376
  reason: row.reason,
342
377
  content: row.content_snapshot,
343
378
  sourceLabel: row.source_label,
379
+ origin: row.origin,
344
380
  ...row.rank === null ? {} : { rank: row.rank },
345
381
  ...row.score === null ? {} : { score: row.score },
346
382
  injectedChars: row.injected_chars
@@ -406,4 +442,4 @@ function decideContextConsent(id, decision) {
406
442
  return Number(result.changes) > 0;
407
443
  }
408
444
  //#endregion
409
- export { consumeContextConsent, createCollaborationRule, createContextEvidence, createUnderstanding, decideContextConsent, deleteCollaborationRule, deleteUnderstanding, ensureContextConsent, getCollaborationRule, getTurnPersonalization, getUnderstanding, getUserProfile, hasContextConsent, isUnderstandingSuppressed, linkUnderstandingEvidence, listCollaborationRules, listUnderstandingEvidence, listUnderstandings, recordContextFeedback, recordContextRun, rejectUnderstanding, reviseCollaborationRule, reviseUnderstanding, searchActiveUnderstandings, setCollaborationRuleStatus, setUnderstandingStatus, updateUserProfile };
445
+ export { closeUnderstandingValidity, consumeContextConsent, createCollaborationRule, createContextEvidence, createUnderstanding, decideContextConsent, deleteCollaborationRule, deleteUnderstanding, ensureContextConsent, getCollaborationRule, getTurnPersonalization, getUnderstanding, getUserProfile, hasContextConsent, isUnderstandingSuppressed, linkUnderstandingEvidence, listCollaborationRules, listUnderstandingEvidence, listUnderstandings, recordContextFeedback, recordContextRun, rejectUnderstanding, reviseCollaborationRule, reviseUnderstanding, searchActiveUnderstandings, setCollaborationRuleStatus, setUnderstandingStatus, updateUserProfile };
@@ -16,6 +16,7 @@ export * from './task-context-repository.js';
16
16
  export * from './task-conversation-repository.js';
17
17
  export * from './task-handoff-service.js';
18
18
  export * from './task-dependency-service.js';
19
+ export * from './task-deletion-service.js';
19
20
  export * from './task-read-model-projector.js';
20
21
  export * from './task-outbox-dispatcher.js';
21
22
  export * from './task-run-dispatcher.js';
@@ -18,7 +18,8 @@ import { ProjectMonitoringService, decideProactiveDisposition, isInQuietHours, n
18
18
  import { ProjectOperatingViewService, summarizeProjectOperatingView } from "./project-operating-view-service.js";
19
19
  import { TaskValueMetricsService } from "./task-value-metrics-service.js";
20
20
  import { TaskHandoffService } from "./task-handoff-service.js";
21
+ import { TaskDeletionService } from "./task-deletion-service.js";
21
22
  import { TaskOutboxDispatcher } from "./task-outbox-dispatcher.js";
22
23
  import { TaskRunDispatcher } from "./task-run-dispatcher.js";
23
24
  import { TaskSignalService } from "./task-signal-service.js";
24
- export { AttentionGovernor, HomeQueryService, ModelTaskContractPlanner, ProjectMonitoringService, ProjectOperatingViewService, TaskApplicationService, TaskContextRepository, TaskConversationConflictError, TaskConversationRepository, TaskDependencyError, TaskDependencyService, TaskHandoffService, TaskOutboxDispatcher, TaskReadModelProjector, TaskRepository, TaskRunCoordinator, TaskRunDispatcher, TaskRunRepository, TaskSignalService, TaskValueMetricsService, TaskWorkflowCoordinator, assembleTaskContext, buildHomeWorkbench, buildTaskExecutionDirective, decideProactiveDisposition, decisionFromTask, defineTaskContract, enqueueTaskChanged, enqueueTaskChangedEvent, getTaskContextManifest, getTaskExecutionBrief, isInQuietHours, nextQuietHoursEnd, parseTaskContractResponse, proactiveDispositionReason, resolveExecutionContext, summarizeProjectOperatingView };
25
+ export { AttentionGovernor, HomeQueryService, ModelTaskContractPlanner, ProjectMonitoringService, ProjectOperatingViewService, TaskApplicationService, TaskContextRepository, TaskConversationConflictError, TaskConversationRepository, TaskDeletionService, TaskDependencyError, TaskDependencyService, TaskHandoffService, TaskOutboxDispatcher, TaskReadModelProjector, TaskRepository, TaskRunCoordinator, TaskRunDispatcher, TaskRunRepository, TaskSignalService, TaskValueMetricsService, TaskWorkflowCoordinator, assembleTaskContext, buildHomeWorkbench, buildTaskExecutionDirective, decideProactiveDisposition, decisionFromTask, defineTaskContract, enqueueTaskChanged, enqueueTaskChangedEvent, getTaskContextManifest, getTaskExecutionBrief, isInQuietHours, nextQuietHoursEnd, parseTaskContractResponse, proactiveDispositionReason, resolveExecutionContext, summarizeProjectOperatingView };
@@ -0,0 +1,21 @@
1
+ import type { Task, TaskRun } from '@xopcai/gateway-contract';
2
+ import { TaskRepository } from './task-repository.js';
3
+ import { TaskRunRepository } from './task-run-repository.js';
4
+ export type TaskDeletionInspection = {
5
+ ok: true;
6
+ task: Task;
7
+ } | {
8
+ ok: false;
9
+ reason: 'not_found';
10
+ } | {
11
+ ok: false;
12
+ reason: 'active_run';
13
+ run: TaskRun;
14
+ };
15
+ export declare class TaskDeletionService {
16
+ private readonly tasks;
17
+ private readonly runs;
18
+ constructor(tasks?: TaskRepository, runs?: TaskRunRepository);
19
+ inspect(taskId: string): TaskDeletionInspection;
20
+ delete(taskId: string): TaskDeletionInspection;
21
+ }
@@ -0,0 +1,35 @@
1
+ import { TaskRepository } from "./task-repository.js";
2
+ import { TaskRunRepository } from "./task-run-repository.js";
3
+ //#region src/tasks/task-deletion-service.ts
4
+ var TaskDeletionService = class {
5
+ constructor(tasks = new TaskRepository(), runs = new TaskRunRepository()) {
6
+ this.tasks = tasks;
7
+ this.runs = runs;
8
+ }
9
+ inspect(taskId) {
10
+ const task = this.tasks.get(taskId);
11
+ if (!task) return {
12
+ ok: false,
13
+ reason: "not_found"
14
+ };
15
+ const run = this.runs.getActiveRoot(taskId);
16
+ return run ? {
17
+ ok: false,
18
+ reason: "active_run",
19
+ run
20
+ } : {
21
+ ok: true,
22
+ task
23
+ };
24
+ }
25
+ delete(taskId) {
26
+ const inspection = this.inspect(taskId);
27
+ if (!inspection.ok) return inspection;
28
+ return this.tasks.delete(taskId) ? inspection : {
29
+ ok: false,
30
+ reason: "not_found"
31
+ };
32
+ }
33
+ };
34
+ //#endregion
35
+ export { TaskDeletionService };
@@ -187,7 +187,28 @@ var TaskRepository = class {
187
187
  });
188
188
  }
189
189
  delete(taskId) {
190
- return getSqliteDatabase().prepare("DELETE FROM tasks WHERE task_id = ?").run(taskId).changes > 0;
190
+ return runSqliteWriteTransaction((db) => {
191
+ const task = db.prepare("SELECT project_id FROM tasks WHERE task_id = ?").get(taskId);
192
+ if (!task) return false;
193
+ const runIds = db.prepare("SELECT run_id FROM task_runs WHERE task_id = ?").all(taskId).map((row) => row.run_id);
194
+ db.prepare(`DELETE FROM context_edges WHERE owner_kind = 'task' AND owner_id = ?`).run(taskId);
195
+ db.prepare(`DELETE FROM command_deduplication WHERE subject_kind = 'task' AND subject_id = ?`).run(taskId);
196
+ db.prepare(`DELETE FROM domain_outbox WHERE subject_kind = 'task' AND subject_id = ?`).run(taskId);
197
+ const deleted = db.prepare("DELETE FROM tasks WHERE task_id = ?").run(taskId).changes > 0;
198
+ db.prepare(`DELETE FROM context_snapshots WHERE owner_kind = 'task' AND owner_id = ?`).run(taskId);
199
+ if (runIds.length > 0) db.prepare(`DELETE FROM context_snapshots
200
+ WHERE owner_kind = 'task_run' AND owner_id IN (SELECT value FROM json_each(?))`).run(JSON.stringify(runIds));
201
+ const deletedAt = Date.now();
202
+ db.prepare(`INSERT INTO domain_outbox (
203
+ event_id, event_type, subject_kind, subject_id, correlation_id,
204
+ payload_json, created_at
205
+ ) VALUES (?, 'task.deleted.v1', 'task', ?, ?, ?, ?)`).run(randomUUID(), taskId, randomUUID(), JSON.stringify({
206
+ taskId,
207
+ ...task.project_id ? { projectId: task.project_id } : {},
208
+ deletedAt
209
+ }), deletedAt);
210
+ return deleted;
211
+ });
191
212
  }
192
213
  insertContract(db, contract) {
193
214
  db.prepare(`INSERT INTO task_contracts (
@@ -15,7 +15,6 @@ import { inferSuggestedProjectDefaultAgentId } from "../../projects/project-agen
15
15
  import "../../projects/index.js";
16
16
  import { setTuiDefaultAgentConfig } from "../../commands/agents.config.js";
17
17
  import { evictEmbeddedSessionRunner } from "../../agent/embedded/session-runner.js";
18
- import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
19
18
  import { buildSessionTimeline } from "../../session/transcript-outline.js";
20
19
  import { transcriptRowsToClientHistory } from "../../session/client-history.js";
21
20
  import { SessionIndex } from "../../session/manager.js";
@@ -24,6 +23,7 @@ import { parseModelRef } from "../../agent/models/selection.js";
24
23
  import { buildReviewContext, resolveGitRoot } from "../../review/review-git.js";
25
24
  import { MessageBus, MessageBusShutdownError } from "../../infra/bus/queue.js";
26
25
  import "../../infra/bus/index.js";
26
+ import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
27
27
  import { getWorkspacePath } from "../../config/workspace-path-helpers.js";
28
28
  import "../../config/index.js";
29
29
  import { buildWorkflowChildTools } from "../../agent/workflow/workflow-child-tools.js";
@@ -579,7 +579,8 @@ var EmbeddedBackend = class {
579
579
  contextWindow: usage.contextWindow,
580
580
  contextUsagePercent: usage.usagePercent,
581
581
  effectiveWorkspacePath: cfg.effectiveWorkspacePath,
582
- workingDirectoryLocked: cfg.workingDirectoryLocked
582
+ workingDirectoryLocked: cfg.workingDirectoryLocked,
583
+ projectId: getSessionMetadata(sessionKey)?.projectId
583
584
  };
584
585
  } catch (err) {
585
586
  const errorMessage = err instanceof Error ? err.message : String(err);
@@ -609,6 +610,7 @@ var EmbeddedBackend = class {
609
610
  }
610
611
  async patchSession(sessionKey, patch) {
611
612
  const agent = await this.ensureAgent();
613
+ const hasProjectPatch = Object.prototype.hasOwnProperty.call(patch, "projectId");
612
614
  const projectId = typeof patch.projectId === "string" ? patch.projectId.trim() : "";
613
615
  const result = await agent.sessionConfig.patch(sessionKey, {
614
616
  model: typeof patch.model === "string" ? patch.model : void 0,
@@ -622,7 +624,7 @@ var EmbeddedBackend = class {
622
624
  await this.sessionIndexReady;
623
625
  await this.sessionIndex?.getStore().resolveTranscriptPath(sessionKey);
624
626
  new ProjectService().attachSession(sessionKey, projectId);
625
- }
627
+ } else if (hasProjectPatch && patch.projectId === null) new ProjectService().detachSession(sessionKey);
626
628
  const hiddenFromSessionList = typeof patch.hiddenFromSessionList === "boolean" ? patch.hiddenFromSessionList : void 0;
627
629
  const customData = patch.customData && typeof patch.customData === "object" && !Array.isArray(patch.customData) ? patch.customData : void 0;
628
630
  if (hiddenFromSessionList !== void 0 || customData !== void 0) {
@@ -1,8 +1,8 @@
1
1
  import { createLogger } from "../../utils/logger/index.js";
2
2
  import { init_logger } from "../../utils/logger.js";
3
- import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
4
3
  import { transcriptRowsToClientHistory } from "../../session/client-history.js";
5
4
  import { parseModelRef } from "../../agent/models/selection.js";
5
+ import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
6
6
  import { gatewayCredentialAuthorization } from "../../gateway/credential.js";
7
7
  import { RealtimeClient } from "../../../packages/realtime-client/src/index.js";
8
8
  import { buildTuiTranscriptTree, transcriptTreeEntryIdToRowNumber } from "../tui-transcript-tree.js";
@@ -422,6 +422,7 @@ var GatewayRealtimeBackend = class {
422
422
  if (session) {
423
423
  if (session.name) out.displayName = session.name;
424
424
  if (session.estimatedTokens != null) out.totalTokens = session.estimatedTokens;
425
+ if (session.projectId?.trim()) out.projectId = session.projectId.trim();
425
426
  }
426
427
  }
427
428
  if (agentCfgRes.ok) {
@@ -645,12 +646,13 @@ var GatewayRealtimeBackend = class {
645
646
  });
646
647
  const json = await res.json().catch(() => ({}));
647
648
  if (!res.ok || json.ok === false) throw new Error(json.error ?? `Session config patch failed (${res.status})`);
649
+ const hasProjectPatch = Object.prototype.hasOwnProperty.call(patch, "projectId");
648
650
  const projectId = typeof patch.projectId === "string" ? patch.projectId.trim() : "";
649
651
  const hiddenFromSessionList = typeof patch.hiddenFromSessionList === "boolean" ? patch.hiddenFromSessionList : void 0;
650
652
  const customData = patch.customData && typeof patch.customData === "object" && !Array.isArray(patch.customData) ? patch.customData : void 0;
651
- if (projectId || hiddenFromSessionList !== void 0 || customData !== void 0) {
653
+ if (hasProjectPatch || hiddenFromSessionList !== void 0 || customData !== void 0) {
652
654
  const metadataPatch = {
653
- ...projectId ? { projectId } : {},
655
+ ...hasProjectPatch ? { projectId: projectId || null } : {},
654
656
  ...hiddenFromSessionList !== void 0 ? { hiddenFromSessionList } : {},
655
657
  ...customData ? { customData } : {}
656
658
  };
@@ -1,3 +1,4 @@
1
+ import { stripRuntimeContextFromUserMessage } from "../session/user-message-display.js";
1
2
  import { createAssistantMessageFromText } from "./components/assistant-message.js";
2
3
  //#region src/tui/chat-history.ts
3
4
  function historyMessageKey(message, index) {
@@ -77,7 +78,7 @@ function appendHistoryToChatLog(chatLog, messages, toolsExpanded, showThinking =
77
78
  return;
78
79
  }
79
80
  if (hm.role === "user") {
80
- chatLog.addUser(historyContentText(hm.content), {
81
+ chatLog.addUser(stripRuntimeContextFromUserMessage(historyContentText(hm.content)), {
81
82
  displayIndex,
82
83
  historyIndex,
83
84
  role: "user"
@@ -1,4 +1,5 @@
1
1
  import { formatAgentRunErrorForDisplay } from "../agent/client-error-format.js";
2
+ import { stripRuntimeContextFromUserContent } from "../session/user-message-display.js";
2
3
  import { createAssistantMessageFromText } from "./components/assistant-message.js";
3
4
  import { markRunEvent, markRunIdleAfterCompletion } from "./tui-run-state.js";
4
5
  //#region src/tui/tui-agent-events.ts
@@ -175,12 +176,13 @@ function dispatchAgentEvent(event, data, state, chatLog, tui, setActivityStatus,
175
176
  break;
176
177
  case "user_message": {
177
178
  const message = p.message;
178
- chatLog.addUser(Array.isArray(message?.content) || typeof message?.content === "string" ? message.content : []);
179
+ const content = Array.isArray(message?.content) || typeof message?.content === "string" ? stripRuntimeContextFromUserContent(message.content) : [];
180
+ chatLog.addUser(content);
179
181
  tui.requestRender();
180
182
  break;
181
183
  }
182
184
  case "user_transcript":
183
- chatLog.addUser(String(p.text ?? ""));
185
+ chatLog.addUser(stripRuntimeContextFromUserContent(String(p.text ?? "")));
184
186
  tui.requestRender();
185
187
  break;
186
188
  case "assistant_message_start": {