@xopcai/xopc 0.0.218 → 0.0.220

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 (342) 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-DF2dYXG1.js → activity-store-DeKZ36Jy.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Dw9rF5o1.js → agent-avatar-dicebear-D0hZfdkn.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-Bu0NfWuh.js +68 -0
  6. package/dist/gateway/static/root/assets/{api-_H0Bam-t.js → api-yLnYUedB.js} +1 -1
  7. package/dist/gateway/static/root/assets/app-management-settings-panel-C2kZNEHz.js +1 -0
  8. package/dist/gateway/static/root/assets/appearance-settings-DQ7H35sN.js +1 -0
  9. package/dist/gateway/static/root/assets/apps-page-Tty2xaUG.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-DZCOhXch.js → archive-plugin-CBArbTPH.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Bjb0FH2B.js → attachment-load-oc6DRj4G.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-D4N3ZDhu.js → automations-page-CHPEUpz8.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-workspace-9uYkHmdI.js +6 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-uXPt0s47.js → binary-plugins-BRBd0X7_.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-gukkIEro.js → block-editor-ZgM-Z4Qv.js} +47 -47
  16. package/dist/gateway/static/root/assets/browser-settings-page-BT3mEm00.js +8 -0
  17. package/dist/gateway/static/root/assets/{browser-workflow-inputs-DAhdS-XZ.js → browser-workflow-inputs-DxD74a4c.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-workflows-page-LKjYzXS_.js → browser-workflows-page-Dpc7NqZf.js} +2 -2
  19. package/dist/gateway/static/root/assets/capabilities-settings-panel-DHlfRj4M.js +7 -0
  20. package/dist/gateway/static/root/assets/{capability-presets-api-BBUkH833.js → capability-presets-api-B9ID97j6.js} +1 -1
  21. package/dist/gateway/static/root/assets/capability-presets-settings-panel-D2FkREUX.js +3 -0
  22. package/dist/gateway/static/root/assets/{channel-recipient-api-E5mo8M3a.js → channel-recipient-api-DCNn6MWL.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-settings-D4YcKMtf.js +1 -0
  24. package/dist/gateway/static/root/assets/channels-status-swr-B8XWrzKM.js +1 -0
  25. package/dist/gateway/static/root/assets/chat-terminal-dock-MvNpjcUs.js +36 -0
  26. package/dist/gateway/static/root/assets/connectors-page-Bd6K9bDk.js +2 -0
  27. package/dist/gateway/static/root/assets/{cron-expression-BGNuaqvI.js → cron-expression-BSXX9uY0.js} +1 -1
  28. package/dist/gateway/static/root/assets/{date-picker-k7mkklMU.js → date-picker-CiHNkkIS.js} +1 -1
  29. package/dist/gateway/static/root/assets/dependency-picker-DQyh2ZXE.js +1 -0
  30. package/dist/gateway/static/root/assets/{desktop-pet-p9EZyGzV.js → desktop-pet-DnAHU-zA.js} +1 -1
  31. package/dist/gateway/static/root/assets/desktop-pet-settings-DUdhIBBB.js +1 -0
  32. package/dist/gateway/static/root/assets/directory-picker-path-field-B3gFQt8x.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-Cd4BMKm_.js → extension-debug-page-Lq-gRApw.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-CzEGCkOa.js → extension-page-D0ROxJmY.js} +1 -1
  36. package/dist/gateway/static/root/assets/extension-settings-page-B2tS6mFy.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-DJqWfVi6.js +1 -0
  42. package/dist/gateway/static/root/assets/{gateway-config-swr-DNrttVr2.js → gateway-config-swr-CnwF9Vso.js} +1 -1
  43. package/dist/gateway/static/root/assets/gateway-settings-B3thenPX.js +1 -0
  44. package/dist/gateway/static/root/assets/{gateway-startup-retry-B1vD3vRb.js → gateway-startup-retry-DdJJZR8M.js} +1 -1
  45. package/dist/gateway/static/root/assets/heartbeat-settings-C_g-ZGSE.js +1 -0
  46. package/dist/gateway/static/root/assets/home-page-Cgwx66kc.js +1 -0
  47. package/dist/gateway/static/root/assets/{image-generation-api-BTR0Wk_k.js → image-generation-api-Dtt9M5qz.js} +1 -1
  48. package/dist/gateway/static/root/assets/index-Cf0qTkBK.css +2 -0
  49. package/dist/gateway/static/root/assets/index-V9g9-SWT.js +108 -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-CYlS4RGA.js → keyboard-shortcuts-settings-cJqkmQdP.js} +1 -1
  53. package/dist/gateway/static/root/assets/local-app-workbench-page-CmjLMdly.js +2 -0
  54. package/dist/gateway/static/root/assets/{local-apps-page-CNppYVew.js → local-apps-page-BiuP2pkl.js} +1 -1
  55. package/dist/gateway/static/root/assets/{locale-store-gf9Bg2gb.js → locale-store-D3Q2yEAb.js} +1 -1
  56. package/dist/gateway/static/root/assets/logs-page-BTlxGPho.js +2 -0
  57. package/dist/gateway/static/root/assets/{management-settings-IYk9xLgt.js → management-settings-Z1gJUwP_.js} +1 -1
  58. package/dist/gateway/static/root/assets/{markdown-split-D8e6pRMH.js → markdown-split-DuOmpGgE.js} +1 -1
  59. package/dist/gateway/static/root/assets/{markdown-view-D0fiJjBQ.js → markdown-view-WYArkdrc.js} +1 -1
  60. package/dist/gateway/static/root/assets/{media-plugins-CCq6TtEf.js → media-plugins-DKPh3Mud.js} +1 -1
  61. package/dist/gateway/static/root/assets/messages-BQHpB4VI.js +3 -0
  62. package/dist/gateway/static/root/assets/{notes-api-BBtWnlUU.js → notes-api-DMEon7Zv.js} +1 -1
  63. package/dist/gateway/static/root/assets/{notes-page-BKe1xa3U.js → notes-page-BG4gV8WG.js} +1 -1
  64. package/dist/gateway/static/root/assets/notes-workbench-D3LMBO2X.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-DXe5iWI6.js → product-open-page-BjJf4QOB.js} +1 -1
  68. package/dist/gateway/static/root/assets/project-detail-page-C59tYJG-.js +1 -0
  69. package/dist/gateway/static/root/assets/projects-page-Di7W-Fg8.js +1 -0
  70. package/dist/gateway/static/root/assets/{registry-api-xj5gOva_.js → registry-api-DRyvynb5.js} +1 -1
  71. package/dist/gateway/static/root/assets/remote-access-hub-BYOKveWT.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-BJTvmBCA.js → runtime-tools-settings-panel-DC6t_-db.js} +2 -2
  74. package/dist/gateway/static/root/assets/{schema-form-DvGBa_7R.js → schema-form-DSTWtpjp.js} +1 -1
  75. package/dist/gateway/static/root/assets/search-DA7gz22f.js +1 -0
  76. package/dist/gateway/static/root/assets/sessions-page-CJMNQsxK.js +1 -0
  77. package/dist/gateway/static/root/assets/settings-advanced-gate-FJxZw08y.js +1 -0
  78. package/dist/gateway/static/root/assets/settings-form-section-ZzEMNLYS.js +1 -0
  79. package/dist/gateway/static/root/assets/{settings-loading-skeleton-sbef7GTm.js → settings-loading-skeleton-D7-bkbcW.js} +1 -1
  80. package/dist/gateway/static/root/assets/{settings-page-BNGxxXZe.js → settings-page-PaTpLbmi.js} +1 -1
  81. package/dist/gateway/static/root/assets/setup-status-panel-Bnpim6NY.js +1 -0
  82. package/dist/gateway/static/root/assets/{share-preview-page-C1523ij3.js → share-preview-page-Cxcw0ksa.js} +1 -1
  83. package/dist/gateway/static/root/assets/shares-settings-DBqmV7ZY.js +1 -0
  84. package/dist/gateway/static/root/assets/skill-reload-api-UgLQaWoz.js +1 -0
  85. package/dist/gateway/static/root/assets/skills-page-Dby4iAYe.js +2 -0
  86. package/dist/gateway/static/root/assets/{skills-page.utils-Ditgz7Vo.js → skills-page.utils-nlzJ5Y1V.js} +1 -1
  87. package/dist/gateway/static/root/assets/system-settings-panel-vOsgnzDl.js +1 -0
  88. package/dist/gateway/static/root/assets/task-detail-page-CRy8Wl5g.js +1 -0
  89. package/dist/gateway/static/root/assets/{theme-store-DgSjes3O.js → theme-store-CvnEHGyP.js} +1 -1
  90. package/dist/gateway/static/root/assets/typed-models-lib-q5-Vfqd8.js +1 -0
  91. package/dist/gateway/static/root/assets/{use-autosave-Bp_qFZkl.js → use-autosave-BTNZHulv.js} +1 -1
  92. package/dist/gateway/static/root/assets/user-context-page-BT8F4mh5.js +1 -0
  93. package/dist/gateway/static/root/assets/{voice-api-key-field-hbzDfErG.js → voice-api-key-field-DDJ2-3Tx.js} +1 -1
  94. package/dist/gateway/static/root/assets/{work-discovery-overlay-DZVib-04.js → work-discovery-overlay-DV_qiKSD.js} +1 -1
  95. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C2RKay1p.js → workflow-run-setup-panel--AcvRw1w.js} +2 -2
  96. package/dist/gateway/static/root/assets/workflows-page-CwvskVvU.js +5 -0
  97. package/dist/gateway/static/root/index.html +21 -12
  98. package/dist/package.js +1 -1
  99. package/dist/packages/gateway-contract/src/new-session.js +99 -0
  100. package/dist/packages/gateway-contract/src/tasks.js +5 -0
  101. package/dist/packages/gateway-contract/src/user-message-display.js +55 -0
  102. package/dist/src/agent/agent-manager.js +5 -4
  103. package/dist/src/agent/background-review/prompts.d.ts +1 -1
  104. package/dist/src/agent/background-review/prompts.js +2 -2
  105. package/dist/src/agent/background-review/run-background-review.js +144 -16
  106. package/dist/src/agent/embedded/model-runtime.js +1 -1
  107. package/dist/src/agent/embedded/run-for-session.js +1 -1
  108. package/dist/src/agent/image/tool-model-config.js +1 -1
  109. package/dist/src/agent/inbound/turn-dispatcher.d.ts +3 -1
  110. package/dist/src/agent/inbound/turn-dispatcher.js +2 -1
  111. package/dist/src/agent/ipc/inbox.js +1 -1
  112. package/dist/src/agent/memory/context/types.d.ts +1 -1
  113. package/dist/src/agent/memory/manager.d.ts +2 -1
  114. package/dist/src/agent/memory/manager.js +2 -6
  115. package/dist/src/agent/memory/understanding/service.d.ts +1 -0
  116. package/dist/src/agent/memory/understanding/service.js +179 -36
  117. package/dist/src/agent/memory/understanding/types.d.ts +6 -0
  118. package/dist/src/agent/messaging/command-handler.d.ts +2 -0
  119. package/dist/src/agent/messaging/command-handler.js +3 -1
  120. package/dist/src/agent/service/direct-turn-helpers.d.ts +3 -0
  121. package/dist/src/agent/service/direct-turn-helpers.js +13 -3
  122. package/dist/src/agent/service/process-direct-streaming.d.ts +2 -1
  123. package/dist/src/agent/service/process-direct-streaming.js +12 -11
  124. package/dist/src/agent/service.js +2 -2
  125. package/dist/src/agent/session/session-config-service.d.ts +1 -0
  126. package/dist/src/agent/session/session-config-service.js +11 -0
  127. package/dist/src/agent/session/session-inspector.d.ts +1 -0
  128. package/dist/src/agent/session/session-inspector.js +2 -1
  129. package/dist/src/agent/skills/hub-lock.js +1 -1
  130. package/dist/src/agent/source-context/budget.d.ts +3 -0
  131. package/dist/src/agent/source-context/budget.js +21 -0
  132. package/dist/src/agent/source-context/index.js +3 -3
  133. package/dist/src/agent/source-context/injector.d.ts +2 -2
  134. package/dist/src/agent/source-context/injector.js +19 -9
  135. package/dist/src/agent/source-context/types.d.ts +16 -0
  136. package/dist/src/agent/source-context/types.js +25 -1
  137. package/dist/src/agent/tasks/task-judge-service.js +3 -3
  138. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  139. package/dist/src/agent/tool-manuals/xopc-use.js +19 -2
  140. package/dist/src/agent/tools/xopc-use-tool.js +62 -2
  141. package/dist/src/ai-assist/text-assist.js +1 -1
  142. package/dist/src/auth/credentials.js +2 -2
  143. package/dist/src/auth/profiles/store.js +1 -1
  144. package/dist/src/auth/sync-provider-auth.js +2 -2
  145. package/dist/src/browser/backend-from-config.d.ts +8 -0
  146. package/dist/src/browser/backend-from-config.js +16 -1
  147. package/dist/src/browser/providers/browser-ext-install.d.ts +3 -2
  148. package/dist/src/browser/providers/browser-ext-install.js +5 -3
  149. package/dist/src/chat-commands/builtins/review.js +11 -2
  150. package/dist/src/chat-commands/builtins/understanding.js +11 -4
  151. package/dist/src/chat-commands/types.d.ts +4 -0
  152. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  153. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  154. package/dist/src/cli/commands/models.js +1 -1
  155. package/dist/src/config/index.js +4 -4
  156. package/dist/src/config/loader.js +1 -1
  157. package/dist/src/config/models-json.d.ts +20 -20
  158. package/dist/src/config/models-json.js +1 -1
  159. package/dist/src/connectors/connected-source-understanding.d.ts +1 -0
  160. package/dist/src/connectors/connected-source-understanding.js +87 -38
  161. package/dist/src/connectors/learning-coordinator.js +68 -13
  162. package/dist/src/extensions/lockfile.js +1 -1
  163. package/dist/src/gateway/agents-admin.js +1 -1
  164. package/dist/src/gateway/chat-stream/mapper.js +18 -0
  165. package/dist/src/gateway/file-path-classifier.js +1 -1
  166. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  167. package/dist/src/gateway/hono/routes/agent-stream.js +12 -2
  168. package/dist/src/gateway/hono/routes/commands-skills.js +1 -0
  169. package/dist/src/gateway/hono/routes/models.js +1 -1
  170. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +46 -2
  171. package/dist/src/gateway/hono/routes/session-input-handler.js +23 -3
  172. package/dist/src/gateway/hono/routes/sessions.js +17 -20
  173. package/dist/src/gateway/hono/routes/tasks.js +25 -0
  174. package/dist/src/gateway/hono/routes/understanding-sources.d.ts +18 -0
  175. package/dist/src/gateway/hono/routes/understanding-sources.js +165 -36
  176. package/dist/src/gateway/hono/routes/work-discovery.js +13 -3
  177. package/dist/src/gateway/hono/routes/workflows.js +2 -2
  178. package/dist/src/gateway/hono/routes/you.js +71 -4
  179. package/dist/src/gateway/service/agent-runner.d.ts +11 -2
  180. package/dist/src/gateway/service/agent-runner.js +27 -1
  181. package/dist/src/gateway/service/config-coordinator.js +1 -1
  182. package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -0
  183. package/dist/src/gateway/service/run-gateway-agent.js +15 -9
  184. package/dist/src/gateway/service/session-input-coordinator.d.ts +8 -2
  185. package/dist/src/gateway/service/session-input-coordinator.js +62 -3
  186. package/dist/src/gateway/service/sessions-api.d.ts +10 -0
  187. package/dist/src/gateway/service/sessions-api.js +3 -0
  188. package/dist/src/gateway/service.d.ts +3 -2
  189. package/dist/src/gateway/service.js +27 -16
  190. package/dist/src/gateway/user-turn-input.d.ts +2 -0
  191. package/dist/src/gateway/xopc-cloud-capability-setup.d.ts +3 -2
  192. package/dist/src/gateway/xopc-cloud-capability-setup.js +16 -3
  193. package/dist/src/knowledge/connected-knowledge-pipeline.d.ts +6 -0
  194. package/dist/src/knowledge/connected-knowledge-pipeline.js +35 -4
  195. package/dist/src/knowledge/connected-understanding-pipeline.d.ts +1 -1
  196. package/dist/src/knowledge/connected-understanding-pipeline.js +4 -2
  197. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  198. package/dist/src/providers/index.js +2 -2
  199. package/dist/src/providers/model-registry.js +1 -1
  200. package/dist/src/providers/register-runtime-providers.js +1 -1
  201. package/dist/src/retrieval/queryProfile.d.ts +3 -0
  202. package/dist/src/retrieval/queryProfile.js +20 -2
  203. package/dist/src/session/client-history.d.ts +11 -0
  204. package/dist/src/session/client-history.js +24 -2
  205. package/dist/src/session/config-types.d.ts +1 -1
  206. package/dist/src/session/session-title.js +2 -3
  207. package/dist/src/session/store.js +1 -0
  208. package/dist/src/session/transcript-outline.js +5 -2
  209. package/dist/src/session/types.d.ts +1 -0
  210. package/dist/src/session/user-message-display.d.ts +4 -0
  211. package/dist/src/session/user-message-display.js +22 -0
  212. package/dist/src/storage/sqlite/context-extraction-repository.d.ts +57 -0
  213. package/dist/src/storage/sqlite/context-extraction-repository.js +119 -0
  214. package/dist/src/storage/sqlite/context-relation-repository.d.ts +50 -0
  215. package/dist/src/storage/sqlite/context-relation-repository.js +97 -0
  216. package/dist/src/storage/sqlite/index.d.ts +6 -4
  217. package/dist/src/storage/sqlite/index.js +7 -5
  218. package/dist/src/storage/sqlite/knowledge-repository.d.ts +5 -1
  219. package/dist/src/storage/sqlite/knowledge-repository.js +16 -1
  220. package/dist/src/storage/sqlite/memory-records-repository.d.ts +2 -0
  221. package/dist/src/storage/sqlite/memory-records-repository.js +21 -1
  222. package/dist/src/storage/sqlite/migrations/126_focus_context_governance.sql +72 -0
  223. package/dist/src/storage/sqlite/migrations/127_context_object_origin.sql +36 -0
  224. package/dist/src/storage/sqlite/migrations/128_context_extraction.sql +73 -0
  225. package/dist/src/storage/sqlite/migrations/129_focus_versions.sql +51 -0
  226. package/dist/src/storage/sqlite/migrations/130_context_evidence_provenance.sql +18 -0
  227. package/dist/src/storage/sqlite/migrations/131_session_input_contexts.sql +2 -0
  228. package/dist/src/storage/sqlite/migrations/132_transcript_source_context_metadata.sql +34 -0
  229. package/dist/src/storage/sqlite/migrations/133_archive_legacy_work_discovery_profile_facts.sql +11 -0
  230. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  231. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  232. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  233. package/dist/src/storage/sqlite/schema.js +1 -1
  234. package/dist/src/storage/sqlite/session-input-repository.d.ts +8 -0
  235. package/dist/src/storage/sqlite/session-input-repository.js +19 -7
  236. package/dist/src/storage/sqlite/session-repository.js +2 -2
  237. package/dist/src/storage/sqlite/session-turn-replace-repository.d.ts +3 -0
  238. package/dist/src/storage/sqlite/session-turn-replace-repository.js +3 -2
  239. package/dist/src/storage/sqlite/transcript-repository.js +29 -3
  240. package/dist/src/storage/sqlite/user-context-repository.d.ts +4 -1
  241. package/dist/src/storage/sqlite/user-context-repository.js +65 -29
  242. package/dist/src/tasks/home-query-service.d.ts +14 -0
  243. package/dist/src/tasks/home-query-service.js +19 -2
  244. package/dist/src/tasks/index.d.ts +1 -0
  245. package/dist/src/tasks/index.js +2 -1
  246. package/dist/src/tasks/task-deletion-service.d.ts +21 -0
  247. package/dist/src/tasks/task-deletion-service.js +35 -0
  248. package/dist/src/tasks/task-repository.js +22 -1
  249. package/dist/src/tui/backends/embedded-backend.js +5 -3
  250. package/dist/src/tui/backends/gateway-realtime-backend.js +5 -3
  251. package/dist/src/tui/chat-history.js +2 -1
  252. package/dist/src/tui/tui-agent-events.js +4 -2
  253. package/dist/src/tui/tui-commands.d.ts +1 -0
  254. package/dist/src/tui/tui-commands.js +8 -3
  255. package/dist/src/tui/tui-empty-session-cleanup.d.ts +0 -1
  256. package/dist/src/tui/tui-empty-session-cleanup.js +1 -11
  257. package/dist/src/tui/tui-new-session-preferences.d.ts +10 -0
  258. package/dist/src/tui/tui-new-session-preferences.js +32 -0
  259. package/dist/src/tui/tui-session-actions.d.ts +1 -0
  260. package/dist/src/tui/tui-session-actions.js +2 -1
  261. package/dist/src/tui/tui-settings.d.ts +2 -0
  262. package/dist/src/tui/tui-settings.js +4 -1
  263. package/dist/src/tui/tui-startup-resources.js +1 -1
  264. package/dist/src/tui/tui-types.d.ts +1 -0
  265. package/dist/src/tui/tui.js +58 -5
  266. package/dist/src/tunnel/frpc-process.js +3 -0
  267. package/dist/src/tunnel/tunnel-service.d.ts +2 -0
  268. package/dist/src/tunnel/tunnel-service.js +40 -28
  269. package/dist/src/user-context/consolidation.d.ts +1 -0
  270. package/dist/src/user-context/consolidation.js +62 -2
  271. package/dist/src/user-context/context-objects.d.ts +17 -0
  272. package/dist/src/user-context/context-objects.js +99 -0
  273. package/dist/src/user-context/domain.d.ts +13 -1
  274. package/dist/src/user-context/evaluation/harness.d.ts +13 -0
  275. package/dist/src/user-context/evaluation/harness.js +31 -0
  276. package/dist/src/user-context/extraction/registry.d.ts +26 -0
  277. package/dist/src/user-context/extraction/registry.js +113 -0
  278. package/dist/src/user-context/extraction/repair.d.ts +19 -0
  279. package/dist/src/user-context/extraction/repair.js +68 -0
  280. package/dist/src/user-context/focus-lifecycle.d.ts +2 -0
  281. package/dist/src/user-context/focus-lifecycle.js +26 -0
  282. package/dist/src/user-context/planner.js +252 -62
  283. package/dist/src/user-context/retriever.js +69 -9
  284. package/dist/src/user-context/sources/index.js +2 -2
  285. package/dist/src/user-context/sources/processing-policy.d.ts +2 -0
  286. package/dist/src/user-context/sources/processing-policy.js +7 -0
  287. package/dist/src/user-context/sources/repository.d.ts +23 -4
  288. package/dist/src/user-context/sources/repository.js +122 -12
  289. package/dist/src/user-context/sources/types.d.ts +10 -1
  290. package/dist/src/user-context/understanding.js +1 -1
  291. package/dist/src/work-discovery/analyzer.js +6 -4
  292. package/dist/src/work-discovery/index.js +2 -2
  293. package/dist/src/work-discovery/service.d.ts +12 -3
  294. package/dist/src/work-discovery/service.js +183 -86
  295. package/dist/src/work-discovery/source-repository.d.ts +1 -0
  296. package/dist/src/work-discovery/source-repository.js +10 -4
  297. package/dist/src/work-discovery/types.d.ts +2 -1
  298. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  299. package/package.json +3 -3
  300. package/dist/gateway/static/root/assets/agents-Dj86bHkl.js +0 -68
  301. package/dist/gateway/static/root/assets/app-management-settings-panel-D-M6GN-8.js +0 -1
  302. package/dist/gateway/static/root/assets/appearance-settings-XDhmzdIc.js +0 -1
  303. package/dist/gateway/static/root/assets/apps-page-sfO835uz.js +0 -1
  304. package/dist/gateway/static/root/assets/automations-workspace-PptuZgoo.js +0 -6
  305. package/dist/gateway/static/root/assets/browser-settings-page-BoCmzMFV.js +0 -8
  306. package/dist/gateway/static/root/assets/capabilities-settings-panel-DhkJsU8Z.js +0 -7
  307. package/dist/gateway/static/root/assets/capability-presets-settings-panel-Dm7T61fE.js +0 -3
  308. package/dist/gateway/static/root/assets/channels-settings-dG6UFVqt.js +0 -1
  309. package/dist/gateway/static/root/assets/channels-status-swr-DgJxfNyK.js +0 -1
  310. package/dist/gateway/static/root/assets/chat-terminal-dock-CT5yoSMD.js +0 -36
  311. package/dist/gateway/static/root/assets/connectors-page-BC6Ft9SU.js +0 -2
  312. package/dist/gateway/static/root/assets/dependency-picker-DZVSgLXH.js +0 -1
  313. package/dist/gateway/static/root/assets/desktop-pet-settings-Bw4cCFzI.js +0 -1
  314. package/dist/gateway/static/root/assets/directory-picker-path-field-Cbst7IXR.js +0 -1
  315. package/dist/gateway/static/root/assets/extension-settings-page-C1PAKSy2.js +0 -1
  316. package/dist/gateway/static/root/assets/gateway-config-api-Bch9vO6t.js +0 -1
  317. package/dist/gateway/static/root/assets/gateway-settings-DkDxZFGG.js +0 -1
  318. package/dist/gateway/static/root/assets/heartbeat-settings-DXNMxy5b.js +0 -1
  319. package/dist/gateway/static/root/assets/home-page-CYcpVFNT.js +0 -1
  320. package/dist/gateway/static/root/assets/index-Dgb1R07E.css +0 -2
  321. package/dist/gateway/static/root/assets/index-DlOYwVFK.js +0 -108
  322. package/dist/gateway/static/root/assets/local-app-workbench-page-BFrgPwGE.js +0 -2
  323. package/dist/gateway/static/root/assets/logs-page-CPweLw3k.js +0 -2
  324. package/dist/gateway/static/root/assets/messages-B9WQcZ1V.js +0 -3
  325. package/dist/gateway/static/root/assets/notes-workbench-wieRAd1y.js +0 -4
  326. package/dist/gateway/static/root/assets/page-tabs-Bsluqyfb.js +0 -1
  327. package/dist/gateway/static/root/assets/preview-open-alternatives-BrpTWv44.js +0 -1
  328. package/dist/gateway/static/root/assets/project-detail-page-Cww6V7HJ.js +0 -1
  329. package/dist/gateway/static/root/assets/projects-page-D0LKhCCw.js +0 -1
  330. package/dist/gateway/static/root/assets/remote-access-hub-Sf4Pde6Z.js +0 -1
  331. package/dist/gateway/static/root/assets/sessions-page-S5gvgfu5.js +0 -1
  332. package/dist/gateway/static/root/assets/settings-advanced-gate-B3XvdEy8.js +0 -1
  333. package/dist/gateway/static/root/assets/settings-form-section-CiGFtdD8.js +0 -1
  334. package/dist/gateway/static/root/assets/setup-status-panel-CGU_Mxjr.js +0 -1
  335. package/dist/gateway/static/root/assets/shares-settings-k0UQ8WxO.js +0 -1
  336. package/dist/gateway/static/root/assets/skill-reload-api-DQ1GvL1w.js +0 -1
  337. package/dist/gateway/static/root/assets/skills-page-OuHd9GcN.js +0 -2
  338. package/dist/gateway/static/root/assets/system-settings-panel-CERqCsz2.js +0 -1
  339. package/dist/gateway/static/root/assets/task-detail-page-BnRNL2sn.js +0 -1
  340. package/dist/gateway/static/root/assets/typed-models-lib-abEJNkCO.js +0 -1
  341. package/dist/gateway/static/root/assets/user-context-page-Cnkaiky5.js +0 -1
  342. package/dist/gateway/static/root/assets/workflows-page-B_VlcKiK.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 = 133;
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 ?? 133;
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 ?? 133;
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 = 133;
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: 133,
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,5 +1,5 @@
1
1
  import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
2
- import { escapeFts5Query } from "./fts.js";
2
+ import { buildFts5SearchQuery } from "./fts.js";
3
3
  import { buildDefaultSessionMetadata } from "./session-metadata.js";
4
4
  import { buildGlobalSessionStats, metadataToSessionInsert, sessionRowToMetadata } from "./row-mappers.js";
5
5
  import { validateSessionId } from "../../session/session-id.js";
@@ -129,7 +129,7 @@ function listSessionMetadata(query = {}) {
129
129
  let searchKeys = null;
130
130
  if (query.search?.trim()) {
131
131
  const rawSearch = query.search.trim();
132
- const ftsQuery = escapeFts5Query(rawSearch);
132
+ const ftsQuery = buildFts5SearchQuery(rawSearch);
133
133
  const ftsRows = db.prepare(`SELECT DISTINCT session_key FROM transcript_fts WHERE transcript_fts MATCH ? LIMIT 500`).all(ftsQuery);
134
134
  const ftsKeys = new Set(ftsRows.map((r) => r.session_key));
135
135
  const like = `%${rawSearch.toLowerCase()}%`;
@@ -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 };
@@ -30,6 +30,20 @@ interface HomeGatewayPort {
30
30
  readonly automationServiceInstance: AutomationService;
31
31
  readonly projects: ProjectService;
32
32
  readonly proactiveInbox: ProactiveInboxService;
33
+ readonly sessions: {
34
+ listActiveRuns(): Array<{
35
+ sessionKey: string;
36
+ runId: string;
37
+ }>;
38
+ getSession(key: string): Promise<{
39
+ name?: string;
40
+ updatedAt: string;
41
+ lastInteractionAt?: string;
42
+ routing?: {
43
+ agentId?: string;
44
+ };
45
+ } | null>;
46
+ };
33
47
  createWorkflowRunService(): WorkflowRunService;
34
48
  }
35
49
  export declare function decisionFromTask(model: TaskReadModel, projectName?: string, locale?: string): HomeDecision | null;
@@ -294,7 +294,8 @@ var HomeQueryService = class {
294
294
  const workflowRunStore = this.service.createWorkflowRunService().createRunStore(defaultAgent?.id ?? agents.defaultId);
295
295
  const nowMs = Date.now();
296
296
  const tasks = this.#tasks.list({ limit: 60 });
297
- const [workflowRuns, automations, automationRuns, projects, connectorApprovals] = await Promise.all([
297
+ const activeRuns = this.service.sessions.listActiveRuns();
298
+ const [workflowRuns, automations, automationRuns, projects, connectorApprovals, activeRunSessions] = await Promise.all([
298
299
  workflowRunStore.listRunSummaries(20),
299
300
  this.service.automationServiceInstance.list(),
300
301
  this.service.automationServiceInstance.listRuns({ limit: 10 }),
@@ -303,8 +304,23 @@ var HomeQueryService = class {
303
304
  principalId: "local-owner",
304
305
  status: "pending",
305
306
  limit: 100
306
- }))
307
+ })),
308
+ Promise.all(activeRuns.map(async (run) => ({
309
+ ...run,
310
+ session: await this.service.sessions.getSession(run.sessionKey)
311
+ })))
307
312
  ]);
313
+ const runningConversations = activeRunSessions.filter((item) => Boolean(item.session)).map((item) => {
314
+ const session = item.session;
315
+ const updatedAt = Date.parse(session.lastInteractionAt ?? session.updatedAt);
316
+ return {
317
+ sessionKey: item.sessionKey,
318
+ runId: item.runId,
319
+ ...session.name?.trim() ? { title: session.name.trim() } : {},
320
+ ...session.routing?.agentId ? { agentId: session.routing.agentId } : {},
321
+ updatedAt: Number.isFinite(updatedAt) ? updatedAt : nowMs
322
+ };
323
+ }).sort((left, right) => right.updatedAt - left.updatedAt);
308
324
  const activeTasks = tasks.filter((task) => task.phase !== "closed");
309
325
  const projectsById = new Map(projects.items.map((project) => [project.id, project]));
310
326
  const activeWorkflowRuns = workflowRuns.filter((run) => run.status === "queued" || run.status === "running").map(toHomeWorkflowRun);
@@ -395,6 +411,7 @@ var HomeQueryService = class {
395
411
  scheduled: upcomingAutomations,
396
412
  nowMs
397
413
  }),
414
+ runningConversations,
398
415
  decisions,
399
416
  attentionPolicy: governed.policy
400
417
  };
@@ -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 (