@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
@@ -0,0 +1,119 @@
1
+ import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
2
+ import "../../user-context/domain.js";
3
+ import { randomUUID } from "node:crypto";
4
+ //#region src/storage/sqlite/context-extraction-repository.ts
5
+ function runFromRow(row) {
6
+ return {
7
+ id: row.extraction_run_id,
8
+ principalId: row.principal_id,
9
+ sourceRef: row.source_ref,
10
+ extractorId: row.extractor_id,
11
+ extractorVersion: row.extractor_version,
12
+ processingPolicy: row.processing_policy,
13
+ destination: row.destination,
14
+ inputHash: row.input_hash,
15
+ status: row.status,
16
+ ...row.error_code ? { errorCode: row.error_code } : {},
17
+ startedAt: row.started_at,
18
+ ...row.completed_at == null ? {} : { completedAt: row.completed_at }
19
+ };
20
+ }
21
+ function outputFromRow(row) {
22
+ return {
23
+ id: row.output_id,
24
+ runId: row.extraction_run_id,
25
+ ordinal: row.ordinal,
26
+ candidateKey: row.candidate_key,
27
+ ...row.object_type ? { objectType: row.object_type } : {},
28
+ ...row.object_id ? { objectId: row.object_id } : {},
29
+ ...row.version_id ? { versionId: row.version_id } : {},
30
+ outcome: row.outcome,
31
+ createdAt: row.created_at
32
+ };
33
+ }
34
+ function claimContextExtractionRun(input) {
35
+ const principalId = input.principalId ?? "local-owner";
36
+ const now = input.nowMs ?? Date.now();
37
+ return runSqliteWriteTransaction((db) => {
38
+ const existing = db.prepare(`SELECT * FROM context_extraction_runs
39
+ WHERE principal_id = ? AND source_ref = ? AND extractor_id = ? AND extractor_version = ?`).get(principalId, input.sourceRef, input.extractorId, input.extractorVersion);
40
+ if (existing) {
41
+ if (existing.input_hash !== input.inputHash) throw new Error("Extraction source changed without a new source reference");
42
+ if (existing.status !== "failed") return {
43
+ run: runFromRow(existing),
44
+ shouldExecute: false
45
+ };
46
+ db.prepare(`UPDATE context_extraction_runs
47
+ SET status = 'running', error_code = NULL, started_at = ?, completed_at = NULL
48
+ WHERE extraction_run_id = ?`).run(now, existing.extraction_run_id);
49
+ return {
50
+ run: runFromRow(db.prepare("SELECT * FROM context_extraction_runs WHERE extraction_run_id = ?").get(existing.extraction_run_id)),
51
+ shouldExecute: true
52
+ };
53
+ }
54
+ const id = randomUUID();
55
+ db.prepare(`INSERT INTO context_extraction_runs (
56
+ extraction_run_id, principal_id, source_ref, extractor_id, extractor_version,
57
+ processing_policy, destination, input_hash, status, started_at
58
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 'running', ?)`).run(id, principalId, input.sourceRef, input.extractorId, input.extractorVersion, input.processingPolicy, input.destination, input.inputHash, now);
59
+ return {
60
+ run: runFromRow(db.prepare("SELECT * FROM context_extraction_runs WHERE extraction_run_id = ?").get(id)),
61
+ shouldExecute: true
62
+ };
63
+ });
64
+ }
65
+ function finishContextExtractionRun(input) {
66
+ const now = input.nowMs ?? Date.now();
67
+ return runSqliteWriteTransaction((db) => {
68
+ if (!db.prepare(`UPDATE context_extraction_runs SET status = ?, error_code = ?, completed_at = ?
69
+ WHERE extraction_run_id = ?`).run(input.status, input.errorCode ?? null, now, input.runId).changes) return null;
70
+ db.prepare("DELETE FROM context_extraction_outputs WHERE extraction_run_id = ?").run(input.runId);
71
+ const insert = db.prepare(`INSERT INTO context_extraction_outputs (
72
+ output_id, extraction_run_id, ordinal, candidate_key, object_type, object_id,
73
+ version_id, outcome, created_at
74
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`);
75
+ for (const [ordinal, output] of (input.outputs ?? []).entries()) insert.run(randomUUID(), input.runId, ordinal, output.candidateKey, output.objectType ?? null, output.objectId ?? null, output.versionId ?? null, output.outcome, now);
76
+ return runFromRow(db.prepare("SELECT * FROM context_extraction_runs WHERE extraction_run_id = ?").get(input.runId));
77
+ });
78
+ }
79
+ function listContextExtractionRuns(filter = {}) {
80
+ const clauses = [];
81
+ const values = [];
82
+ if (filter.sourceRef) {
83
+ clauses.push("source_ref = ?");
84
+ values.push(filter.sourceRef);
85
+ }
86
+ if (filter.extractorId) {
87
+ clauses.push("extractor_id = ?");
88
+ values.push(filter.extractorId);
89
+ }
90
+ if (filter.extractorVersion) {
91
+ clauses.push("extractor_version = ?");
92
+ values.push(filter.extractorVersion);
93
+ }
94
+ if (filter.status) {
95
+ clauses.push("status = ?");
96
+ values.push(filter.status);
97
+ }
98
+ values.push(Math.max(1, Math.min(500, filter.limit ?? 100)));
99
+ return getSqliteDatabase().prepare(`SELECT * FROM context_extraction_runs
100
+ ${clauses.length ? `WHERE ${clauses.join(" AND ")}` : ""} ORDER BY started_at DESC LIMIT ?`).all(...values).map(runFromRow);
101
+ }
102
+ function getContextExtractionRun(id) {
103
+ const row = getSqliteDatabase().prepare("SELECT * FROM context_extraction_runs WHERE extraction_run_id = ?").get(id);
104
+ return row ? runFromRow(row) : null;
105
+ }
106
+ function listContextExtractionOutputs(runId) {
107
+ return getSqliteDatabase().prepare(`SELECT * FROM context_extraction_outputs
108
+ WHERE extraction_run_id = ? ORDER BY ordinal`).all(runId).map(outputFromRow);
109
+ }
110
+ function hasIndependentExtractionOutput(runIds, objectType, objectId) {
111
+ if (!runIds.length) return false;
112
+ const placeholders = runIds.map(() => "?").join(", ");
113
+ return Boolean(getSqliteDatabase().prepare(`SELECT 1 FROM context_extraction_outputs o
114
+ JOIN context_extraction_runs r ON r.extraction_run_id = o.extraction_run_id
115
+ WHERE o.extraction_run_id NOT IN (${placeholders}) AND o.object_type = ? AND o.object_id = ?
116
+ AND r.status = 'completed' LIMIT 1`).get(...runIds, objectType, objectId));
117
+ }
118
+ //#endregion
119
+ export { claimContextExtractionRun, finishContextExtractionRun, getContextExtractionRun, hasIndependentExtractionOutput, listContextExtractionOutputs, listContextExtractionRuns };
@@ -0,0 +1,50 @@
1
+ import type { ContextObjectType } from './context-extraction-repository.js';
2
+ export type ContextObjectRelation = {
3
+ id: string;
4
+ subjectType: ContextObjectType;
5
+ subjectId: string;
6
+ subjectVersionId?: string;
7
+ predicate: 'supersedes' | 'supports' | 'contradicts' | 'related_to';
8
+ objectType: ContextObjectType;
9
+ objectId: string;
10
+ objectVersionId?: string;
11
+ factual: boolean;
12
+ extractionRunId?: string;
13
+ createdAt: number;
14
+ };
15
+ export type ContextTemporalAssertion = {
16
+ id: string;
17
+ objectType: 'focus' | 'understanding';
18
+ objectId: string;
19
+ objectVersionId?: string;
20
+ assertionType: 'current_state' | 'routine' | 'relationship' | 'project_status';
21
+ value: Record<string, unknown>;
22
+ confidence: number;
23
+ validFrom?: number;
24
+ validTo?: number;
25
+ status: 'candidate' | 'active' | 'closed' | 'rejected';
26
+ extractionRunId?: string;
27
+ createdAt: number;
28
+ updatedAt: number;
29
+ };
30
+ export declare function linkContextObjects(input: Omit<ContextObjectRelation, 'id' | 'createdAt'> & {
31
+ nowMs?: number;
32
+ }): ContextObjectRelation;
33
+ export declare function listContextObjectRelations(input?: {
34
+ objectType?: ContextObjectType;
35
+ objectId?: string;
36
+ extractionRunId?: string;
37
+ }): ContextObjectRelation[];
38
+ export declare function createTemporalAssertion(input: Omit<ContextTemporalAssertion, 'id' | 'createdAt' | 'updatedAt'> & {
39
+ nowMs?: number;
40
+ }): ContextTemporalAssertion;
41
+ export declare function closeTemporalAssertions(input: {
42
+ objectType: ContextTemporalAssertion['objectType'];
43
+ objectId: string;
44
+ validTo?: number;
45
+ }): number;
46
+ export declare function listTemporalAssertions(input?: {
47
+ objectType?: ContextTemporalAssertion['objectType'];
48
+ objectId?: string;
49
+ status?: ContextTemporalAssertion['status'];
50
+ }): ContextTemporalAssertion[];
@@ -0,0 +1,97 @@
1
+ import { getSqliteDatabase } from "./transaction.js";
2
+ import { randomUUID } from "node:crypto";
3
+ //#region src/storage/sqlite/context-relation-repository.ts
4
+ function relationFromRow(row) {
5
+ return {
6
+ id: row.relation_id,
7
+ subjectType: row.subject_type,
8
+ subjectId: row.subject_id,
9
+ ...row.subject_version_id ? { subjectVersionId: row.subject_version_id } : {},
10
+ predicate: row.predicate,
11
+ objectType: row.object_type,
12
+ objectId: row.object_id,
13
+ ...row.object_version_id ? { objectVersionId: row.object_version_id } : {},
14
+ factual: row.factual === 1,
15
+ ...row.extraction_run_id ? { extractionRunId: row.extraction_run_id } : {},
16
+ createdAt: row.created_at
17
+ };
18
+ }
19
+ function assertionFromRow(row) {
20
+ return {
21
+ id: row.assertion_id,
22
+ objectType: row.object_type,
23
+ objectId: row.object_id,
24
+ ...row.object_version_id ? { objectVersionId: row.object_version_id } : {},
25
+ assertionType: row.assertion_type,
26
+ value: JSON.parse(row.value_json),
27
+ confidence: row.confidence,
28
+ ...row.valid_from == null ? {} : { validFrom: row.valid_from },
29
+ ...row.valid_to == null ? {} : { validTo: row.valid_to },
30
+ status: row.status,
31
+ ...row.extraction_run_id ? { extractionRunId: row.extraction_run_id } : {},
32
+ createdAt: row.created_at,
33
+ updatedAt: row.updated_at
34
+ };
35
+ }
36
+ function linkContextObjects(input) {
37
+ const now = input.nowMs ?? Date.now();
38
+ const factual = input.predicate !== "related_to";
39
+ getSqliteDatabase().prepare(`INSERT INTO context_object_relations (
40
+ relation_id, subject_type, subject_id, subject_version_id, predicate,
41
+ object_type, object_id, object_version_id, factual, extraction_run_id, created_at
42
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
43
+ ON CONFLICT DO UPDATE SET factual = excluded.factual, extraction_run_id = excluded.extraction_run_id`).run(randomUUID(), input.subjectType, input.subjectId, input.subjectVersionId ?? null, input.predicate, input.objectType, input.objectId, input.objectVersionId ?? null, factual ? 1 : 0, input.extractionRunId ?? null, now);
44
+ return relationFromRow(getSqliteDatabase().prepare(`SELECT * FROM context_object_relations
45
+ WHERE subject_type = ? AND subject_id = ? AND COALESCE(subject_version_id, '') = COALESCE(?, '')
46
+ AND predicate = ? AND object_type = ? AND object_id = ?
47
+ AND COALESCE(object_version_id, '') = COALESCE(?, '')`).get(input.subjectType, input.subjectId, input.subjectVersionId ?? null, input.predicate, input.objectType, input.objectId, input.objectVersionId ?? null));
48
+ }
49
+ function listContextObjectRelations(input = {}) {
50
+ const clauses = [];
51
+ const values = [];
52
+ if (input.objectType && input.objectId) {
53
+ clauses.push("((subject_type = ? AND subject_id = ?) OR (object_type = ? AND object_id = ?))");
54
+ values.push(input.objectType, input.objectId, input.objectType, input.objectId);
55
+ }
56
+ if (input.extractionRunId) {
57
+ clauses.push("extraction_run_id = ?");
58
+ values.push(input.extractionRunId);
59
+ }
60
+ return getSqliteDatabase().prepare(`SELECT * FROM context_object_relations
61
+ ${clauses.length ? `WHERE ${clauses.join(" AND ")}` : ""} ORDER BY created_at DESC`).all(...values).map(relationFromRow);
62
+ }
63
+ function createTemporalAssertion(input) {
64
+ const now = input.nowMs ?? Date.now();
65
+ const id = randomUUID();
66
+ getSqliteDatabase().prepare(`INSERT INTO context_temporal_assertions (
67
+ assertion_id, object_type, object_id, object_version_id, assertion_type, value_json,
68
+ confidence, valid_from, valid_to, status, extraction_run_id, created_at, updated_at
69
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(id, input.objectType, input.objectId, input.objectVersionId ?? null, input.assertionType, JSON.stringify(input.value), input.confidence, input.validFrom ?? null, input.validTo ?? null, input.status, input.extractionRunId ?? null, now, now);
70
+ return assertionFromRow(getSqliteDatabase().prepare("SELECT * FROM context_temporal_assertions WHERE assertion_id = ?").get(id));
71
+ }
72
+ function closeTemporalAssertions(input) {
73
+ const now = input.validTo ?? Date.now();
74
+ return Number(getSqliteDatabase().prepare(`UPDATE context_temporal_assertions
75
+ SET status = 'closed', valid_to = COALESCE(valid_to, ?), updated_at = ?
76
+ WHERE object_type = ? AND object_id = ? AND status = 'active'`).run(now, now, input.objectType, input.objectId).changes);
77
+ }
78
+ function listTemporalAssertions(input = {}) {
79
+ const clauses = [];
80
+ const values = [];
81
+ if (input.objectType) {
82
+ clauses.push("object_type = ?");
83
+ values.push(input.objectType);
84
+ }
85
+ if (input.objectId) {
86
+ clauses.push("object_id = ?");
87
+ values.push(input.objectId);
88
+ }
89
+ if (input.status) {
90
+ clauses.push("status = ?");
91
+ values.push(input.status);
92
+ }
93
+ return getSqliteDatabase().prepare(`SELECT * FROM context_temporal_assertions
94
+ ${clauses.length ? `WHERE ${clauses.join(" AND ")}` : ""} ORDER BY created_at DESC`).all(...values).map(assertionFromRow);
95
+ }
96
+ //#endregion
97
+ export { closeTemporalAssertions, createTemporalAssertion, linkContextObjects, listContextObjectRelations, listTemporalAssertions };
@@ -5,10 +5,12 @@ export { DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, } from './m
5
5
  export { discoverSqlMigrations, listRegisteredMigrationTargets } from './migrations/discover.js';
6
6
  export { closeXopcDatabase, getXopcDatabase, isXopcDatabaseOpen, openXopcDatabase, requireXopcDatabase, resetXopcDatabaseSingletonForTest, type OpenXopcDatabaseOptions, type XopcDatabase, } from './connection.js';
7
7
  export { getSqliteDatabase, runSqliteWriteTransaction } from './transaction.js';
8
+ export { claimContextExtractionRun, finishContextExtractionRun, getContextExtractionRun, hasIndependentExtractionOutput, listContextExtractionOutputs, listContextExtractionRuns, type ContextExtractionOutput, type ContextExtractionRun, type ContextExtractionStatus, type ContextObjectType, } from './context-extraction-repository.js';
9
+ export { closeTemporalAssertions, createTemporalAssertion, linkContextObjects, listContextObjectRelations, listTemporalAssertions, type ContextObjectRelation, type ContextTemporalAssertion, } from './context-relation-repository.js';
8
10
  export { finishContextConsolidationRun, getContextConsolidationRun, listContextConsolidationDecisions, listContextConsolidationRuns, recordContextConsolidationDecision, startContextConsolidationRun, type ContextConsolidationDecision, type ContextConsolidationRun, } from './context-consolidation-repository.js';
9
11
  export { summarizeUnderstandingFeedback, summarizeUserUnderstandingQuality, type UnderstandingFeedbackSummary, type UserUnderstandingQualityMetrics, } from './user-context-quality-repository.js';
10
- export { createCollaborationRule, createContextEvidence, createUnderstanding, consumeContextConsent, deleteCollaborationRule, deleteUnderstanding, decideContextConsent, ensureContextConsent, getCollaborationRule, getTurnPersonalization, getUnderstanding, getUserProfile, hasContextConsent, isUnderstandingSuppressed, listCollaborationRules, listUnderstandingEvidence, listUnderstandings, linkUnderstandingEvidence, recordContextFeedback, recordContextRun, rejectUnderstanding, reviseCollaborationRule, reviseUnderstanding, searchActiveUnderstandings, setCollaborationRuleStatus, setUnderstandingStatus, updateUserProfile, type CreateUnderstandingInput, } from './user-context-repository.js';
11
- export { cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputState, insertSessionInput, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus, type SessionInput, type SessionInputDelivery, type SessionInputState, type SessionInputStatus, } from './session-input-repository.js';
12
+ export { createCollaborationRule, createContextEvidence, createUnderstanding, closeUnderstandingValidity, consumeContextConsent, deleteCollaborationRule, deleteUnderstanding, decideContextConsent, ensureContextConsent, getCollaborationRule, getTurnPersonalization, getUnderstanding, getUserProfile, hasContextConsent, isUnderstandingSuppressed, listCollaborationRules, listUnderstandingEvidence, listUnderstandings, linkUnderstandingEvidence, recordContextFeedback, recordContextRun, rejectUnderstanding, reviseCollaborationRule, reviseUnderstanding, searchActiveUnderstandings, setCollaborationRuleStatus, setUnderstandingStatus, updateUserProfile, type CreateUnderstandingInput, } from './user-context-repository.js';
13
+ export { cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputState, getSessionInputById, insertSessionInput, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus, type SessionInput, type SessionInputDelivery, type SessionInputState, type SessionInputStatus, } from './session-input-repository.js';
12
14
  export { replaceLatestSessionTurnAndQueueInput, validateLatestSessionTurnTarget, type ReplaceLatestSessionTurnInput, type ReplaceLatestSessionTurnResult, } from './session-turn-replace-repository.js';
13
15
  export { acknowledgeHomeAttention, isHomeAttentionAcknowledged, type HomeAttentionSubjectKind, } from './home-attention-repository.js';
14
16
  export { claimNextConnectorLearningJob, enqueueConnectorLearningJob, listConnectorLearningJobs, recoverStaleConnectorLearningJobs, setConnectorLearningPaused, updateConnectorLearningJob, type ConnectorLearningJob, type ConnectorLearningMode, type ConnectorLearningPhase, type ConnectorLearningStatus, } from './connector-learning-repository.js';
@@ -6,10 +6,12 @@ import { XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_SCHEMA_VERSION, applyPendingMi
6
6
  import { ensureXopcDatabaseSchema } from "./schema.js";
7
7
  import { closeXopcDatabase, getXopcDatabase, isXopcDatabaseOpen, openXopcDatabase, requireXopcDatabase, resetXopcDatabaseSingletonForTest } from "./connection.js";
8
8
  import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
9
+ import { claimContextExtractionRun, finishContextExtractionRun, getContextExtractionRun, hasIndependentExtractionOutput, listContextExtractionOutputs, listContextExtractionRuns } from "./context-extraction-repository.js";
10
+ import { closeTemporalAssertions, createTemporalAssertion, linkContextObjects, listContextObjectRelations, listTemporalAssertions } from "./context-relation-repository.js";
9
11
  import { finishContextConsolidationRun, getContextConsolidationRun, listContextConsolidationDecisions, listContextConsolidationRuns, recordContextConsolidationDecision, startContextConsolidationRun } from "./context-consolidation-repository.js";
10
12
  import { summarizeUnderstandingFeedback, summarizeUserUnderstandingQuality } from "./user-context-quality-repository.js";
11
- import { 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 } from "./user-context-repository.js";
12
- import { cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputState, insertSessionInput, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus } from "./session-input-repository.js";
13
+ import { 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 } from "./user-context-repository.js";
14
+ import { cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputById, getSessionInputState, insertSessionInput, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus } from "./session-input-repository.js";
13
15
  import { buildDefaultSessionMetadata } from "./session-metadata.js";
14
16
  import { buildGlobalSessionStats, classifyStoredRow, estimateTokensFromMessages, extractFtsContent, metadataToSessionInsert, sessionConfigRowToConfig, sessionRowToMetadata, transcriptEntryRowToStoredRow } from "./row-mappers.js";
15
17
  import { replaceLatestSessionTurnAndQueueInput, validateLatestSessionTurnTarget } from "./session-turn-replace-repository.js";
@@ -33,4 +35,4 @@ import { appendConnectorExecutionAudit, claimConnectorWebhookDelivery, completeC
33
35
  import { getConnectorAccount, listConnectorAccounts, reconcileConnectorAccount, refreshConnectorAccountCurrent } from "./connector-account-repository.js";
34
36
  import { getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, listConnectorSyncPolicies, upsertConnectorSyncPolicy } from "./connector-sync-policy-repository.js";
35
37
  import { getUserTrustPolicy, setUserTrustPolicy } from "./user-trust-repository.js";
36
- export { COMPOSER_INPUT_HISTORY_LIMIT, DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, SCHEMA_META_SCHEMA_VERSION_KEY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, acknowledgeHomeAttention, appendCompactionBoundaryIfUnchanged, appendComposerInputHistory, appendConnectorExecutionAudit, appendMemorySignal, appendMemoryTraceEvent, appendTranscriptEntry, applyPendingMigrations, attachMemoryEvidence, bindEndpointPrincipal, buildDefaultSessionMetadata, buildGlobalSessionStats, buildRelationshipPrompt, cancelQueuedSessionInput, claimConnectorWebhookDelivery, claimKnowledgeSourceItems, claimNextConnectorLearningJob, claimNextSessionInput, classifyStoredRow, clearComposerInputHistory, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, consumeConnectorApproval, consumeContextConsent, createCollaborationRule, createConnectorApproval, createContextEvidence, createEndpointPrincipal, createObjectLinkRecord, createUnderstanding, decideConnectorApproval, decideContextConsent, deleteCollaborationRule, deleteConnectorConnection, deleteConnectorInstallation, deleteMemoryEvidenceForRecord, deleteMemoryRecord, deleteNoteAgentContextRecord, deleteNoteRecord, deleteObjectLinkRecord, deleteSessionConfig, deleteSessionRecord, deleteUnderstanding, discoverSqlMigrations, enqueueConnectorLearningJob, ensureContextConsent, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findSessionInput, findSessionKeyBySessionId, finishContextConsolidationRun, finishEndpointToolInvocationAudit, finishKnowledgeSyncRun, finishSessionInputRun, getActivityEventRecord, getCachedConnectorCatalogEntry, getCollaborationRule, getConnectorAccount, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, getContextConsolidationRun, getCurrentSessionId, getEndpointPrincipal, getGlobalSessionStats, getInteractionState, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getMemoryProviderState, getMemoryRecord, getMemoryTurnFeedback, getNoteAgentContextRecord, getNoteRecord, getRelationshipSettings, getSessionConfig, getSessionInputState, getSessionMetadata, getSessionPersistedLevels, getSessionTaskPlan, getSqliteDatabase, getTurnPersonalization, getUnderstanding, getUserProfile, getUserTrustPolicy, getXopcDatabase, hasContextConsent, hasSessionConfig, hasUnresolvedMemoryConflict, incrementSessionStatsOnAppend, insertSessionInput, inspectSchemaMigrationStatus, isHomeAttentionAcknowledged, isProactiveSupportAllowed, isUnderstandingSuppressed, isXopcDatabaseOpen, linkUnderstandingEvidence, listActivityRecords, listCachedConnectorCatalogEntries, listCollaborationRules, listCompactionBoundaries, listComposerInputHistory, listConnectorAccounts, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listConnectorLearningJobs, listConnectorSyncPolicies, listContextConsolidationDecisions, listContextConsolidationRuns, listEndpointPrincipals, listEndpointToolInvocationAudits, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listMemoryEvidence, listMemoryRecords, listMemorySignals, listMemoryTraceEvents, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, listUnderstandingEvidence, listUnderstandings, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, markMemoryRecordsConflicted, metadataToSessionInsert, mutateQueuedSessionInput, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, pruneBoundedKnowledgeSourceItems, readSchemaVersion, readSchemaVersionForTest, reconcileConnectorAccount, recordActivityEvent, recordContextConsolidationDecision, recordContextFeedback, recordContextRun, recoverSessionInputState, recoverStaleConnectorLearningJobs, refreshConnectorAccountCurrent, rejectUnderstanding, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceLatestSessionTurnAndQueueInput, replaceTranscriptRows, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreBeforeCompactionBoundary, reviseCollaborationRule, reviseUnderstanding, revokeEndpointPrincipal, runSqliteWriteTransaction, searchActiveUnderstandings, searchMemoryRecords, searchSessionTranscript, sessionConfigRowToConfig, sessionRowToMetadata, setCollaborationRuleStatus, setConnectorLearningPaused, setInteractionState, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setMemoryProviderState, setMemoryRecordStatus, setMemoryTurnFeedback, setSessionConfig, setSessionInputStatus, setSessionTaskPlan, setUnderstandingStatus, setUserTrustPolicy, startContextConsolidationRun, startEndpointToolInvocationAudit, startKnowledgeSyncRun, summarizeMemoryRecallFeedback, summarizeUnderstandingFeedback, summarizeUserUnderstandingQuality, touchEndpointPrincipal, transcriptEntryRowToStoredRow, updateConnectorLearningJob, updateInteractionStateFromMessage, updateRelationshipSettings, updateSessionConfig, updateSessionStats, updateUserProfile, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertConnectorSyncPolicy, upsertKnowledgeSourceItems, upsertMemoryRecord, upsertNoteAgentContextRecord, upsertNoteRecord, validateLatestSessionTurnTarget };
38
+ export { COMPOSER_INPUT_HISTORY_LIMIT, DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, SCHEMA_META_SCHEMA_VERSION_KEY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, acknowledgeHomeAttention, appendCompactionBoundaryIfUnchanged, appendComposerInputHistory, appendConnectorExecutionAudit, appendMemorySignal, appendMemoryTraceEvent, appendTranscriptEntry, applyPendingMigrations, attachMemoryEvidence, bindEndpointPrincipal, buildDefaultSessionMetadata, buildGlobalSessionStats, buildRelationshipPrompt, cancelQueuedSessionInput, claimConnectorWebhookDelivery, claimContextExtractionRun, claimKnowledgeSourceItems, claimNextConnectorLearningJob, claimNextSessionInput, classifyStoredRow, clearComposerInputHistory, closeTemporalAssertions, closeUnderstandingValidity, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, consumeConnectorApproval, consumeContextConsent, createCollaborationRule, createConnectorApproval, createContextEvidence, createEndpointPrincipal, createObjectLinkRecord, createTemporalAssertion, createUnderstanding, decideConnectorApproval, decideContextConsent, deleteCollaborationRule, deleteConnectorConnection, deleteConnectorInstallation, deleteMemoryEvidenceForRecord, deleteMemoryRecord, deleteNoteAgentContextRecord, deleteNoteRecord, deleteObjectLinkRecord, deleteSessionConfig, deleteSessionRecord, deleteUnderstanding, discoverSqlMigrations, enqueueConnectorLearningJob, ensureContextConsent, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findSessionInput, findSessionKeyBySessionId, finishContextConsolidationRun, finishContextExtractionRun, finishEndpointToolInvocationAudit, finishKnowledgeSyncRun, finishSessionInputRun, getActivityEventRecord, getCachedConnectorCatalogEntry, getCollaborationRule, getConnectorAccount, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, getContextConsolidationRun, getContextExtractionRun, getCurrentSessionId, getEndpointPrincipal, getGlobalSessionStats, getInteractionState, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getMemoryProviderState, getMemoryRecord, getMemoryTurnFeedback, getNoteAgentContextRecord, getNoteRecord, getRelationshipSettings, getSessionConfig, getSessionInputById, getSessionInputState, getSessionMetadata, getSessionPersistedLevels, getSessionTaskPlan, getSqliteDatabase, getTurnPersonalization, getUnderstanding, getUserProfile, getUserTrustPolicy, getXopcDatabase, hasContextConsent, hasIndependentExtractionOutput, hasSessionConfig, hasUnresolvedMemoryConflict, incrementSessionStatsOnAppend, insertSessionInput, inspectSchemaMigrationStatus, isHomeAttentionAcknowledged, isProactiveSupportAllowed, isUnderstandingSuppressed, isXopcDatabaseOpen, linkContextObjects, linkUnderstandingEvidence, listActivityRecords, listCachedConnectorCatalogEntries, listCollaborationRules, listCompactionBoundaries, listComposerInputHistory, listConnectorAccounts, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listConnectorLearningJobs, listConnectorSyncPolicies, listContextConsolidationDecisions, listContextConsolidationRuns, listContextExtractionOutputs, listContextExtractionRuns, listContextObjectRelations, listEndpointPrincipals, listEndpointToolInvocationAudits, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listMemoryEvidence, listMemoryRecords, listMemorySignals, listMemoryTraceEvents, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, listTemporalAssertions, listUnderstandingEvidence, listUnderstandings, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, markMemoryRecordsConflicted, metadataToSessionInsert, mutateQueuedSessionInput, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, pruneBoundedKnowledgeSourceItems, readSchemaVersion, readSchemaVersionForTest, reconcileConnectorAccount, recordActivityEvent, recordContextConsolidationDecision, recordContextFeedback, recordContextRun, recoverSessionInputState, recoverStaleConnectorLearningJobs, refreshConnectorAccountCurrent, rejectUnderstanding, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceLatestSessionTurnAndQueueInput, replaceTranscriptRows, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreBeforeCompactionBoundary, reviseCollaborationRule, reviseUnderstanding, revokeEndpointPrincipal, runSqliteWriteTransaction, searchActiveUnderstandings, searchMemoryRecords, searchSessionTranscript, sessionConfigRowToConfig, sessionRowToMetadata, setCollaborationRuleStatus, setConnectorLearningPaused, setInteractionState, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setMemoryProviderState, setMemoryRecordStatus, setMemoryTurnFeedback, setSessionConfig, setSessionInputStatus, setSessionTaskPlan, setUnderstandingStatus, setUserTrustPolicy, startContextConsolidationRun, startEndpointToolInvocationAudit, startKnowledgeSyncRun, summarizeMemoryRecallFeedback, summarizeUnderstandingFeedback, summarizeUserUnderstandingQuality, touchEndpointPrincipal, transcriptEntryRowToStoredRow, updateConnectorLearningJob, updateInteractionStateFromMessage, updateRelationshipSettings, updateSessionConfig, updateSessionStats, updateUserProfile, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertConnectorSyncPolicy, upsertKnowledgeSourceItems, upsertMemoryRecord, upsertNoteAgentContextRecord, upsertNoteRecord, validateLatestSessionTurnTarget };
@@ -0,0 +1,72 @@
1
+ UPDATE understanding_source_grants
2
+ SET processing_policy = 'local_only'
3
+ WHERE adapter_id = 'local-work-folders'
4
+ OR source_key LIKE 'understanding-source:%';
5
+
6
+ CREATE TABLE user_focuses_v126 (
7
+ focus_id TEXT PRIMARY KEY,
8
+ principal_id TEXT NOT NULL DEFAULT 'local-owner',
9
+ canonical_key TEXT NOT NULL UNIQUE,
10
+ title TEXT NOT NULL,
11
+ summary TEXT NOT NULL,
12
+ horizon TEXT NOT NULL CHECK (horizon IN ('current', 'ongoing', 'long_term')),
13
+ status TEXT NOT NULL CHECK (status IN ('candidate', 'active', 'paused', 'completed', 'rejected')),
14
+ confidence REAL NOT NULL CHECK (confidence >= 0 AND confidence <= 1),
15
+ scope_type TEXT NOT NULL CHECK (scope_type IN ('global', 'workspace', 'project', 'session')),
16
+ scope_id TEXT,
17
+ explicitness TEXT NOT NULL CHECK (explicitness IN ('explicit', 'observed', 'inferred')),
18
+ sensitivity TEXT NOT NULL CHECK (sensitivity IN ('normal', 'personal', 'secret', 'regulated')),
19
+ disclosure_policy TEXT NOT NULL CHECK (disclosure_policy IN ('silent', 'referenceable', 'ask_before_reference')),
20
+ valid_from INTEGER,
21
+ valid_to INTEGER,
22
+ review_at INTEGER,
23
+ evidence_refs_json TEXT NOT NULL DEFAULT '[]',
24
+ source_run_id TEXT,
25
+ created_at INTEGER NOT NULL,
26
+ updated_at INTEGER NOT NULL,
27
+ FOREIGN KEY (source_run_id) REFERENCES understanding_source_runs(run_id) ON DELETE SET NULL,
28
+ CHECK ((scope_type = 'global' AND scope_id IS NULL) OR (scope_type <> 'global' AND scope_id IS NOT NULL))
29
+ );
30
+
31
+ INSERT INTO user_focuses_v126 (
32
+ focus_id, principal_id, canonical_key, title, summary, horizon, status, confidence,
33
+ scope_type, scope_id, explicitness, sensitivity, disclosure_policy,
34
+ evidence_refs_json, source_run_id, created_at, updated_at
35
+ )
36
+ SELECT
37
+ focus_id, 'local-owner', canonical_key, title, summary, horizon, status, confidence,
38
+ CASE WHEN project_id IS NULL THEN 'global' ELSE 'project' END,
39
+ project_id,
40
+ CASE WHEN status = 'candidate' THEN 'inferred' ELSE 'explicit' END,
41
+ 'normal', 'referenceable', evidence_refs_json, source_run_id, created_at, updated_at
42
+ FROM user_focuses;
43
+
44
+ DROP TABLE user_focuses;
45
+ ALTER TABLE user_focuses_v126 RENAME TO user_focuses;
46
+
47
+ CREATE INDEX idx_user_focuses_status
48
+ ON user_focuses(principal_id, status, horizon, updated_at DESC);
49
+ CREATE INDEX idx_user_focuses_scope
50
+ ON user_focuses(principal_id, scope_type, scope_id, status);
51
+
52
+ CREATE TABLE context_run_items_v126 (
53
+ context_run_id TEXT NOT NULL REFERENCES context_runs(context_run_id) ON DELETE CASCADE,
54
+ object_type TEXT NOT NULL CHECK (object_type IN ('profile', 'rule', 'focus', 'understanding')),
55
+ object_id TEXT NOT NULL,
56
+ version_id TEXT,
57
+ decision TEXT NOT NULL CHECK (decision IN (
58
+ 'selected', 'irrelevant', 'expired', 'scope_mismatch', 'sensitive',
59
+ 'needs_consent', 'budget_exceeded', 'conflicted', 'disabled'
60
+ )),
61
+ reason TEXT NOT NULL,
62
+ content_snapshot TEXT NOT NULL,
63
+ source_label TEXT NOT NULL,
64
+ rank INTEGER,
65
+ score REAL,
66
+ injected_chars INTEGER NOT NULL DEFAULT 0,
67
+ PRIMARY KEY (context_run_id, object_type, object_id)
68
+ );
69
+
70
+ INSERT INTO context_run_items_v126 SELECT * FROM context_run_items;
71
+ DROP TABLE context_run_items;
72
+ ALTER TABLE context_run_items_v126 RENAME TO context_run_items;
@@ -0,0 +1,36 @@
1
+ ALTER TABLE context_run_items ADD COLUMN origin TEXT NOT NULL DEFAULT 'inferred'
2
+ CHECK (origin IN ('told_by_user', 'observed', 'inferred', 'connected_source'));
3
+
4
+ UPDATE context_run_items SET origin = 'told_by_user' WHERE object_type IN ('profile', 'rule');
5
+ UPDATE context_run_items SET origin = 'told_by_user'
6
+ WHERE object_type = 'understanding' AND source_label = 'You told xopc';
7
+ UPDATE context_run_items SET origin = 'observed'
8
+ WHERE object_type = 'understanding' AND source_label = 'Observed across prior work';
9
+
10
+ CREATE TABLE session_config_next (
11
+ session_key TEXT PRIMARY KEY,
12
+ thinking_level TEXT,
13
+ reasoning_level TEXT,
14
+ verbose_level TEXT,
15
+ elevated_mode TEXT,
16
+ model_override TEXT,
17
+ provider_override TEXT,
18
+ working_directory_override TEXT,
19
+ response_language TEXT,
20
+ user_context_mode TEXT CHECK (user_context_mode IN ('enabled', 'off', 'temporary')),
21
+ updated_at INTEGER NOT NULL,
22
+ FOREIGN KEY (session_key) REFERENCES sessions(session_key) ON DELETE CASCADE
23
+ );
24
+
25
+ INSERT INTO session_config_next (
26
+ session_key, thinking_level, reasoning_level, verbose_level, elevated_mode,
27
+ model_override, provider_override, working_directory_override, response_language,
28
+ user_context_mode, updated_at
29
+ )
30
+ SELECT session_key, thinking_level, reasoning_level, verbose_level, elevated_mode,
31
+ model_override, provider_override, working_directory_override, response_language,
32
+ user_context_mode, updated_at
33
+ FROM session_config;
34
+
35
+ DROP TABLE session_config;
36
+ ALTER TABLE session_config_next RENAME TO session_config;
@@ -0,0 +1,73 @@
1
+ CREATE TABLE context_extraction_runs (
2
+ extraction_run_id TEXT PRIMARY KEY,
3
+ principal_id TEXT NOT NULL,
4
+ source_ref TEXT NOT NULL,
5
+ extractor_id TEXT NOT NULL,
6
+ extractor_version TEXT NOT NULL,
7
+ processing_policy TEXT NOT NULL CHECK (processing_policy IN ('local_only', 'remote_allowed')),
8
+ destination TEXT NOT NULL CHECK (destination IN ('deterministic', 'local_model', 'remote_model')),
9
+ input_hash TEXT NOT NULL,
10
+ status TEXT NOT NULL CHECK (status IN ('running', 'completed', 'skipped', 'failed')),
11
+ error_code TEXT,
12
+ started_at INTEGER NOT NULL,
13
+ completed_at INTEGER,
14
+ UNIQUE (principal_id, source_ref, extractor_id, extractor_version)
15
+ );
16
+
17
+ CREATE INDEX idx_context_extraction_runs_lookup
18
+ ON context_extraction_runs(extractor_id, status, started_at DESC);
19
+
20
+ CREATE TABLE context_extraction_outputs (
21
+ output_id TEXT PRIMARY KEY,
22
+ extraction_run_id TEXT NOT NULL REFERENCES context_extraction_runs(extraction_run_id) ON DELETE CASCADE,
23
+ ordinal INTEGER NOT NULL,
24
+ candidate_key TEXT NOT NULL,
25
+ object_type TEXT CHECK (object_type IN ('profile', 'rule', 'focus', 'understanding')),
26
+ object_id TEXT,
27
+ version_id TEXT,
28
+ outcome TEXT NOT NULL CHECK (outcome IN ('created', 'deduplicated', 'rejected')),
29
+ created_at INTEGER NOT NULL,
30
+ UNIQUE (extraction_run_id, ordinal)
31
+ );
32
+
33
+ CREATE INDEX idx_context_extraction_outputs_object
34
+ ON context_extraction_outputs(object_type, object_id);
35
+
36
+ CREATE TABLE context_object_relations (
37
+ relation_id TEXT PRIMARY KEY,
38
+ subject_type TEXT NOT NULL CHECK (subject_type IN ('profile', 'rule', 'focus', 'understanding')),
39
+ subject_id TEXT NOT NULL,
40
+ subject_version_id TEXT,
41
+ predicate TEXT NOT NULL CHECK (predicate IN ('supersedes', 'supports', 'contradicts', 'related_to')),
42
+ object_type TEXT NOT NULL CHECK (object_type IN ('profile', 'rule', 'focus', 'understanding')),
43
+ object_id TEXT NOT NULL,
44
+ object_version_id TEXT,
45
+ factual INTEGER NOT NULL DEFAULT 1 CHECK (factual IN (0, 1)),
46
+ extraction_run_id TEXT REFERENCES context_extraction_runs(extraction_run_id) ON DELETE SET NULL,
47
+ created_at INTEGER NOT NULL
48
+ );
49
+
50
+ CREATE UNIQUE INDEX idx_context_object_relations_unique
51
+ ON context_object_relations(
52
+ subject_type, subject_id, COALESCE(subject_version_id, ''), predicate,
53
+ object_type, object_id, COALESCE(object_version_id, '')
54
+ );
55
+
56
+ CREATE TABLE context_temporal_assertions (
57
+ assertion_id TEXT PRIMARY KEY,
58
+ object_type TEXT NOT NULL CHECK (object_type IN ('focus', 'understanding')),
59
+ object_id TEXT NOT NULL,
60
+ object_version_id TEXT,
61
+ assertion_type TEXT NOT NULL CHECK (assertion_type IN ('current_state', 'routine', 'relationship', 'project_status')),
62
+ value_json TEXT NOT NULL,
63
+ confidence REAL NOT NULL CHECK (confidence >= 0 AND confidence <= 1),
64
+ valid_from INTEGER,
65
+ valid_to INTEGER,
66
+ status TEXT NOT NULL CHECK (status IN ('candidate', 'active', 'closed', 'rejected')),
67
+ extraction_run_id TEXT REFERENCES context_extraction_runs(extraction_run_id) ON DELETE SET NULL,
68
+ created_at INTEGER NOT NULL,
69
+ updated_at INTEGER NOT NULL
70
+ );
71
+
72
+ CREATE INDEX idx_context_temporal_assertions_active
73
+ ON context_temporal_assertions(object_type, object_id, assertion_type, status);
@@ -0,0 +1,51 @@
1
+ ALTER TABLE user_focuses ADD COLUMN current_version_id TEXT;
2
+
3
+ CREATE TABLE user_focus_versions (
4
+ version_id TEXT PRIMARY KEY,
5
+ focus_id TEXT NOT NULL REFERENCES user_focuses(focus_id) ON DELETE CASCADE,
6
+ title TEXT NOT NULL,
7
+ summary TEXT NOT NULL,
8
+ snapshot_json TEXT NOT NULL,
9
+ created_by TEXT NOT NULL CHECK (created_by IN ('user', 'runtime', 'connector')),
10
+ change_reason TEXT NOT NULL,
11
+ created_at INTEGER NOT NULL
12
+ );
13
+
14
+ INSERT INTO user_focus_versions (
15
+ version_id, focus_id, title, summary, snapshot_json, created_by, change_reason, created_at
16
+ )
17
+ SELECT
18
+ lower(hex(randomblob(16))), focus_id, title, summary,
19
+ json_object(
20
+ 'horizon', horizon, 'status', status, 'confidence', confidence,
21
+ 'scopeType', scope_type, 'scopeId', scope_id, 'explicitness', explicitness,
22
+ 'sensitivity', sensitivity, 'disclosurePolicy', disclosure_policy,
23
+ 'validFrom', valid_from, 'validTo', valid_to, 'reviewAt', review_at,
24
+ 'evidenceRefs', json(evidence_refs_json)
25
+ ),
26
+ CASE WHEN explicitness = 'explicit' THEN 'user' ELSE 'runtime' END,
27
+ 'Migrated existing focus', created_at
28
+ FROM user_focuses;
29
+
30
+ UPDATE user_focuses
31
+ SET current_version_id = (
32
+ SELECT version_id FROM user_focus_versions v WHERE v.focus_id = user_focuses.focus_id LIMIT 1
33
+ );
34
+
35
+ CREATE INDEX idx_user_focus_versions_focus
36
+ ON user_focus_versions(focus_id, created_at DESC);
37
+
38
+ CREATE TABLE user_focus_evidence_links (
39
+ version_id TEXT NOT NULL REFERENCES user_focus_versions(version_id) ON DELETE CASCADE,
40
+ evidence_id TEXT NOT NULL REFERENCES context_evidence(evidence_id) ON DELETE CASCADE,
41
+ relation TEXT NOT NULL CHECK (relation IN ('supports', 'contradicts', 'supersedes')),
42
+ confidence REAL NOT NULL CHECK (confidence >= 0 AND confidence <= 1),
43
+ PRIMARY KEY (version_id, evidence_id, relation)
44
+ );
45
+
46
+ INSERT OR IGNORE INTO user_focus_evidence_links (version_id, evidence_id, relation, confidence)
47
+ SELECT f.current_version_id, e.evidence_id, 'supports', f.confidence
48
+ FROM user_focuses f
49
+ JOIN json_each(f.evidence_refs_json) refs
50
+ JOIN context_evidence e ON e.source_ref = refs.value
51
+ WHERE f.current_version_id IS NOT NULL;
@@ -0,0 +1,18 @@
1
+ ALTER TABLE context_evidence ADD COLUMN source_run_id TEXT;
2
+ ALTER TABLE context_evidence ADD COLUMN source_item_id TEXT;
3
+ ALTER TABLE context_evidence ADD COLUMN session_id TEXT;
4
+ ALTER TABLE context_evidence ADD COLUMN turn_id TEXT;
5
+ ALTER TABLE context_evidence ADD COLUMN message_id TEXT;
6
+ ALTER TABLE context_evidence ADD COLUMN content_hash TEXT;
7
+ ALTER TABLE context_evidence ADD COLUMN retention_policy TEXT;
8
+ ALTER TABLE context_evidence ADD COLUMN processing_policy TEXT;
9
+ ALTER TABLE context_evidence ADD COLUMN extractor_id TEXT;
10
+ ALTER TABLE context_evidence ADD COLUMN extractor_version TEXT;
11
+ ALTER TABLE context_evidence ADD COLUMN ingested_at INTEGER;
12
+
13
+ UPDATE context_evidence SET ingested_at = created_at WHERE ingested_at IS NULL;
14
+
15
+ CREATE INDEX idx_context_evidence_run
16
+ ON context_evidence(source_run_id, observed_at DESC);
17
+ CREATE INDEX idx_context_evidence_message
18
+ ON context_evidence(session_id, turn_id, message_id);
@@ -0,0 +1,2 @@
1
+ ALTER TABLE session_inputs ADD COLUMN context_refs_json TEXT;
2
+ ALTER TABLE session_inputs ADD COLUMN context_snapshots_json TEXT;
@@ -0,0 +1,34 @@
1
+ UPDATE transcript_entries AS entry
2
+ SET payload_json = json_set(
3
+ entry.payload_json,
4
+ '$.metadata.sourceContexts',
5
+ json((
6
+ SELECT input.context_refs_json
7
+ FROM session_inputs AS input
8
+ JOIN transcripts AS transcript
9
+ ON transcript.session_id = entry.session_id
10
+ AND transcript.session_key = input.session_key
11
+ WHERE input.run_id = json_extract(entry.payload_json, '$.turnId')
12
+ AND input.context_refs_json IS NOT NULL
13
+ AND json_valid(input.context_refs_json)
14
+ AND json_type(input.context_refs_json) = 'array'
15
+ LIMIT 1
16
+ ))
17
+ )
18
+ WHERE entry.role = 'user'
19
+ AND json_type(entry.payload_json, '$.metadata.sourceContexts') IS NULL
20
+ AND (
21
+ json_type(entry.payload_json, '$.metadata') IS NULL
22
+ OR json_type(entry.payload_json, '$.metadata') = 'object'
23
+ )
24
+ AND EXISTS (
25
+ SELECT 1
26
+ FROM session_inputs AS input
27
+ JOIN transcripts AS transcript
28
+ ON transcript.session_id = entry.session_id
29
+ AND transcript.session_key = input.session_key
30
+ WHERE input.run_id = json_extract(entry.payload_json, '$.turnId')
31
+ AND input.context_refs_json IS NOT NULL
32
+ AND json_valid(input.context_refs_json)
33
+ AND json_type(input.context_refs_json) = 'array'
34
+ );
@@ -3,7 +3,7 @@ import type { ApplyMigrationsOptions } from './types.js';
3
3
  /** Baseline schema version applied from schema.sql on first open. */
4
4
  export declare const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
5
5
  /** Latest schema version this release supports (increment when adding migrations). */
6
- export declare const XOPC_DB_SCHEMA_VERSION = 125;
6
+ export declare const XOPC_DB_SCHEMA_VERSION = 132;
7
7
  export declare function resolveMigrationsDir(override?: string): string;
8
8
  /**
9
9
  * Apply sequential SQL migrations from (currentVersion + 1) through targetVersion.