@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
@@ -1,5 +1,5 @@
1
1
  import { summarizeUnderstandingFeedback } from "../storage/sqlite/user-context-quality-repository.js";
2
- import { listUnderstandings, searchActiveUnderstandings } from "../storage/sqlite/user-context-repository.js";
2
+ import { listUnderstandingEvidence, listUnderstandings, searchActiveUnderstandings } from "../storage/sqlite/user-context-repository.js";
3
3
  import { normalizeRetrievalText, retrievalLexicalSimilarity } from "../retrieval/textFeatures.js";
4
4
  import { buildRetrievalQueryProfile } from "../retrieval/queryProfile.js";
5
5
  import "../storage/sqlite/index.js";
@@ -12,9 +12,62 @@ function authorityBonus(item) {
12
12
  }
13
13
  function baseline(item) {
14
14
  if (item.kind === "boundary" && item.explicitness === "explicit") return .8;
15
- if (item.kind === "preference" && item.explicitness === "explicit") return .35;
15
+ if (item.kind === "preference" && item.explicitness === "explicit") return .12;
16
16
  return 0;
17
17
  }
18
+ function temporalAdjustment(item, hints, now) {
19
+ if (!hints.length) return 0;
20
+ let score = 0;
21
+ if (hints.includes("historical")) score += item.validTo !== void 0 || item.status === "archived" || item.status === "stale" ? .14 : -.6;
22
+ if (hints.includes("current")) {
23
+ if (item.kind === "current_state" || item.validFrom !== void 0 || item.validTo !== void 0) {
24
+ const validNow = (item.validFrom === void 0 || item.validFrom <= now) && (item.validTo === void 0 || item.validTo > now);
25
+ score += validNow ? .08 : -.15;
26
+ if (item.kind === "current_state") score += .06;
27
+ }
28
+ }
29
+ if (hints.includes("recent")) score += now - item.updatedAt <= 2160 * 60 * 6e4 ? .08 : -.04;
30
+ if (hints.includes("future")) {
31
+ if ((item.validFrom ?? 0) > now || item.kind === "long_term_goal") score += .1;
32
+ }
33
+ return score;
34
+ }
35
+ function sourceBucket(item) {
36
+ if (item.explicitness === "explicit") return "user";
37
+ const evidence = listUnderstandingEvidence(item.id)[0];
38
+ if (!evidence) return `unknown:${item.id}`;
39
+ if (evidence.sourceInstanceId) return `${evidence.sourceType}:${evidence.sourceInstanceId}`;
40
+ return `${evidence.sourceType}:${evidence.sourceRef.split(":entry:")[0]}`;
41
+ }
42
+ function diversify(results, limit) {
43
+ const remaining = [...results];
44
+ const selected = [];
45
+ const sourceCounts = /* @__PURE__ */ new Map();
46
+ const sourceBuckets = new Map(results.map((result) => [result.understanding.id, sourceBucket(result.understanding)]));
47
+ while (remaining.length && selected.length < limit) {
48
+ let bestIndex = 0;
49
+ let bestScore = Number.NEGATIVE_INFINITY;
50
+ for (const [index, candidate] of remaining.entries()) {
51
+ const redundancy = selected.reduce((maximum, chosen) => Math.max(maximum, retrievalLexicalSimilarity(candidate.understanding.statement, chosen.understanding.statement)), 0);
52
+ const bucket = sourceBuckets.get(candidate.understanding.id);
53
+ const sourcePenalty = candidate.understanding.explicitness === "explicit" ? 0 : (sourceCounts.get(bucket) ?? 0) * .04;
54
+ const adjusted = candidate.score - redundancy * .18 - sourcePenalty;
55
+ if (adjusted > bestScore) {
56
+ bestScore = adjusted;
57
+ bestIndex = index;
58
+ }
59
+ }
60
+ const candidate = remaining.splice(bestIndex, 1)[0];
61
+ const bucket = sourceBuckets.get(candidate.understanding.id);
62
+ sourceCounts.set(bucket, (sourceCounts.get(bucket) ?? 0) + 1);
63
+ selected.push({
64
+ ...candidate,
65
+ score: Math.max(0, bestScore),
66
+ reasons: bestScore < candidate.score ? [...candidate.reasons, "diversified"] : candidate.reasons
67
+ });
68
+ }
69
+ return selected;
70
+ }
18
71
  function feedbackAdjustment(summary) {
19
72
  if (!summary || summary.total < 3) return 0;
20
73
  const helpfulRate = (summary.helpful + 1) / (summary.total + 2);
@@ -30,35 +83,42 @@ var UserUnderstandingRetriever = class {
30
83
  });
31
84
  if (!profile.normalized) return [];
32
85
  const maxCandidates = Math.max(1, Math.min(200, Math.floor(params.maxCandidates)));
33
- const fts = searchActiveUnderstandings(profile.normalized, Math.max(50, maxCandidates));
86
+ const fts = searchActiveUnderstandings(profile.expanded, Math.max(50, maxCandidates));
34
87
  const ftsScores = new Map(fts.map((result) => [result.understanding.id, result.score]));
35
88
  const recentLimit = Math.max(200, Math.min(500, maxCandidates * 5));
36
- const recent = listUnderstandings(["active"]).slice(0, recentLimit);
89
+ const recent = listUnderstandings([...profile.timeHints.includes("historical") ? [
90
+ "active",
91
+ "archived",
92
+ "stale"
93
+ ] : ["active"]]).slice(0, recentLimit);
37
94
  const candidates = /* @__PURE__ */ new Map();
38
95
  for (const result of fts) candidates.set(result.understanding.id, result.understanding);
39
96
  for (const item of recent) candidates.set(item.id, item);
40
97
  const feedback = new Map(summarizeUnderstandingFeedback([...candidates.keys()]).map((summary) => [summary.understandingId, summary]));
41
- return [...candidates.values()].map((item) => {
42
- const lexical = retrievalLexicalSimilarity(profile.normalized, item.statement);
98
+ const now = Date.now();
99
+ return diversify([...candidates.values()].map((item) => {
100
+ const lexical = Math.max(retrievalLexicalSimilarity(profile.normalized, item.statement), retrievalLexicalSimilarity(profile.expanded, item.statement));
43
101
  const ftsScore = ftsScores.get(item.id) ?? 0;
44
102
  const textScore = Math.max(lexical, ftsScore);
45
103
  const kindMatched = profile.intentKinds.includes(item.kind);
46
104
  const normalizedStatement = normalizeRetrievalText(item.statement);
47
105
  const identifierMatched = profile.identifiers.some((identifier) => normalizedStatement.includes(identifier));
48
106
  const feedbackScore = feedbackAdjustment(feedback.get(item.id));
107
+ const kindAdjustment = profile.intentKinds.length > 0 && !kindMatched && profile.timeHints.length === 0 ? -.35 : 0;
49
108
  return {
50
109
  understanding: item,
51
- score: Math.min(1, Math.max(0, Math.max(baseline(item), textScore * .7 + lexical * .1 + item.confidence * .1 + authorityBonus(item) + (kindMatched ? .08 : 0) + (identifierMatched ? .12 : 0) + (matchesUserContextScope(item.scope, params) && item.scope.type !== "global" ? .05 : 0)) + feedbackScore)),
110
+ score: Math.min(1, Math.max(0, Math.max(baseline(item), textScore * .7 + lexical * .1 + item.confidence * .1 + authorityBonus(item) + (kindMatched ? .08 : 0) + kindAdjustment + (identifierMatched ? .12 : 0) + temporalAdjustment(item, profile.timeHints, now) + (matchesUserContextScope(item.scope, params) && item.scope.type !== "global" ? .05 : 0)) + feedbackScore)),
52
111
  reasons: [
53
112
  ftsScore > 0 ? "fts" : "",
54
113
  lexical > 0 ? "lexical" : "",
55
114
  identifierMatched ? "identifier" : "",
56
115
  kindMatched ? "kind" : "",
57
116
  item.explicitness === "explicit" ? "explicit" : "",
58
- feedbackScore !== 0 ? "feedback" : ""
117
+ feedbackScore !== 0 ? "feedback" : "",
118
+ temporalAdjustment(item, profile.timeHints, now) !== 0 ? "temporal" : ""
59
119
  ].filter(Boolean)
60
120
  };
61
- }).sort((left, right) => Number(matchesUserContextScope(right.understanding.scope, params)) - Number(matchesUserContextScope(left.understanding.scope, params)) || right.score - left.score || right.understanding.updatedAt - left.understanding.updatedAt).slice(0, maxCandidates);
121
+ }).sort((left, right) => Number(matchesUserContextScope(right.understanding.scope, params)) - Number(matchesUserContextScope(left.understanding.scope, params)) || right.score - left.score || right.understanding.updatedAt - left.understanding.updatedAt), maxCandidates);
62
122
  }
63
123
  };
64
124
  //#endregion
@@ -18,7 +18,7 @@ const COMMON = [
18
18
  category: "recent_documents",
19
19
  platform: "all",
20
20
  displayName: "Recent files",
21
- description: "Read-only metadata for recent documents on Desktop, Documents, and Downloads.",
21
+ description: "Bounded text from recent readable documents on Desktop, Documents, and Downloads.",
22
22
  availability: "available",
23
23
  permission: "not_requested",
24
24
  defaultAccessMode: "once",
@@ -114,6 +114,13 @@ const PLATFORM = {
114
114
  "Recent unlocked notes selected through macOS Automation",
115
115
  true
116
116
  ],
117
+ [
118
+ "apple-mail",
119
+ "mail",
120
+ "Apple Mail",
121
+ "Recent inbox and sent-message content selected through macOS Automation",
122
+ true
123
+ ],
117
124
  [
118
125
  "apple-calendar",
119
126
  "calendar",
@@ -138,7 +145,7 @@ const PLATFORM = {
138
145
  permission: "not_requested",
139
146
  defaultAccessMode: "once",
140
147
  supportedAccessModes: ["once"],
141
- recommended: category !== "notes",
148
+ recommended: category !== "notes" && category !== "mail",
142
149
  sensitive: Boolean(sensitive)
143
150
  })),
144
151
  win32: [{
@@ -1,4 +1,4 @@
1
- import { createUnderstandingSourceRun, deleteUserFocus, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocuses, revokeUnderstandingSourceGrant, setUserFocusStatus, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant, upsertUserFocus } from "./repository.js";
1
+ import { createUnderstandingSourceRun, deleteUserFocus, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocusEvidence, listUserFocuses, revokeUnderstandingSourceGrant, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, updateUserFocus, upsertUnderstandingSourceGrant, upsertUserFocus } from "./repository.js";
2
2
  import { clusterUnderstandingSignals, tokenizeUnderstandingSignal } from "./signal-clustering.js";
3
3
  import { listUnderstandingSourceDefinitions } from "./catalog.js";
4
- export { clusterUnderstandingSignals, createUnderstandingSourceRun, deleteUserFocus, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceDefinitions, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocuses, revokeUnderstandingSourceGrant, setUserFocusStatus, tokenizeUnderstandingSignal, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant, upsertUserFocus };
4
+ export { clusterUnderstandingSignals, createUnderstandingSourceRun, deleteUserFocus, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceDefinitions, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocusEvidence, listUserFocuses, revokeUnderstandingSourceGrant, tokenizeUnderstandingSignal, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, updateUserFocus, upsertUnderstandingSourceGrant, upsertUserFocus };
@@ -1,3 +1,3 @@
1
- export declare const LOCAL_UNDERSTANDING_SOURCE_IDS: readonly ["local-recent-files", "chromium-bookmarks", "apple-notes", "apple-calendar", "apple-reminders", "windows-recent-documents", "linux-recent-documents"];
1
+ export declare const LOCAL_UNDERSTANDING_SOURCE_IDS: readonly ["local-recent-files", "chromium-bookmarks", "apple-notes", "apple-mail", "apple-calendar", "apple-reminders", "windows-recent-documents", "linux-recent-documents"];
2
2
  export type LocalUnderstandingSourceId = typeof LOCAL_UNDERSTANDING_SOURCE_IDS[number];
3
3
  export declare function isLocalUnderstandingSourceId(value: string): value is LocalUnderstandingSourceId;
@@ -3,6 +3,7 @@ const LOCAL_UNDERSTANDING_SOURCE_IDS = [
3
3
  "local-recent-files",
4
4
  "chromium-bookmarks",
5
5
  "apple-notes",
6
+ "apple-mail",
6
7
  "apple-calendar",
7
8
  "apple-reminders",
8
9
  "windows-recent-documents",
@@ -0,0 +1,2 @@
1
+ import type { UnderstandingSourceProcessingPolicy } from './types.js';
2
+ export declare function allowsRemoteSourceProcessing(policies: Iterable<UnderstandingSourceProcessingPolicy>): boolean;
@@ -0,0 +1,7 @@
1
+ //#region src/user-context/sources/processing-policy.ts
2
+ function allowsRemoteSourceProcessing(policies) {
3
+ for (const policy of policies) if (policy !== "remote_allowed") return false;
4
+ return true;
5
+ }
6
+ //#endregion
7
+ export { allowsRemoteSourceProcessing };
@@ -1,4 +1,18 @@
1
+ import { type ContextEvidence, type UserContextScope } from '../domain.js';
1
2
  import type { UnderstandingSourceGrant, UnderstandingSourceRun, UserFocus } from './types.js';
3
+ type UserFocusInput = Omit<UserFocus, 'id' | 'versionId' | 'principalId' | 'scope' | 'explicitness' | 'sensitivity' | 'disclosurePolicy' | 'validFrom' | 'validTo' | 'reviewAt' | 'createdAt' | 'updatedAt'> & {
4
+ principalId?: string;
5
+ scope?: UserContextScope;
6
+ explicitness?: UserFocus['explicitness'];
7
+ sensitivity?: UserFocus['sensitivity'];
8
+ disclosurePolicy?: UserFocus['disclosurePolicy'];
9
+ validFrom?: number;
10
+ validTo?: number;
11
+ reviewAt?: number;
12
+ changeReason?: string;
13
+ nowMs?: number;
14
+ };
15
+ export declare function listUserFocusEvidence(focusId: string): ContextEvidence[];
2
16
  export declare function listUnderstandingSourceGrants(options?: {
3
17
  includeRevoked?: boolean;
4
18
  }): UnderstandingSourceGrant[];
@@ -13,6 +27,12 @@ export declare function updateUnderstandingSourceGrantCheckpoint(id: string, inp
13
27
  lastCollectedAt?: number;
14
28
  nowMs?: number;
15
29
  }): UnderstandingSourceGrant | null;
30
+ export declare function updateUnderstandingSourceGrantPolicies(id: string, patch: {
31
+ accessMode?: UnderstandingSourceGrant['accessMode'];
32
+ retentionPolicy?: UnderstandingSourceGrant['retentionPolicy'];
33
+ processingPolicy?: UnderstandingSourceGrant['processingPolicy'];
34
+ nowMs?: number;
35
+ }): UnderstandingSourceGrant | null;
16
36
  export declare function revokeUnderstandingSourceGrant(id: string, nowMs?: number): UnderstandingSourceGrant | null;
17
37
  export declare function createUnderstandingSourceRun(input: {
18
38
  grantId: string;
@@ -33,9 +53,8 @@ export declare function updateUnderstandingSourceRun(id: string, patch: {
33
53
  completed?: boolean;
34
54
  nowMs?: number;
35
55
  }): UnderstandingSourceRun | null;
36
- export declare function upsertUserFocus(input: Omit<UserFocus, 'id' | 'createdAt' | 'updatedAt'> & {
37
- nowMs?: number;
38
- }): UserFocus;
56
+ export declare function upsertUserFocus(input: UserFocusInput): UserFocus;
39
57
  export declare function listUserFocuses(statuses?: UserFocus['status'][]): UserFocus[];
40
- export declare function setUserFocusStatus(id: string, status: UserFocus['status'], nowMs?: number): UserFocus | null;
58
+ export declare function updateUserFocus(id: string, patch: Partial<Pick<UserFocus, 'title' | 'summary' | 'status'>>, nowMs?: number): UserFocus | null;
41
59
  export declare function deleteUserFocus(id: string): boolean;
60
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { getSqliteDatabase, runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
2
+ import "../domain.js";
2
3
  import { randomUUID } from "node:crypto";
3
4
  //#region src/user-context/sources/repository.ts
4
5
  function record(value) {
@@ -53,19 +54,82 @@ function runFromRow(row) {
53
54
  function focusFromRow(row) {
54
55
  return {
55
56
  id: row.focus_id,
57
+ versionId: row.current_version_id,
58
+ principalId: row.principal_id,
56
59
  canonicalKey: row.canonical_key,
57
60
  title: row.title,
58
61
  summary: row.summary,
59
62
  horizon: row.horizon,
60
63
  status: row.status,
61
64
  confidence: row.confidence,
62
- ...row.project_id ? { projectId: row.project_id } : {},
65
+ scope: {
66
+ type: row.scope_type,
67
+ ...row.scope_id ? { id: row.scope_id } : {}
68
+ },
69
+ explicitness: row.explicitness,
70
+ sensitivity: row.sensitivity,
71
+ disclosurePolicy: row.disclosure_policy,
72
+ ...row.valid_from == null ? {} : { validFrom: row.valid_from },
73
+ ...row.valid_to == null ? {} : { validTo: row.valid_to },
74
+ ...row.review_at == null ? {} : { reviewAt: row.review_at },
63
75
  evidenceRefs: strings(row.evidence_refs_json),
64
76
  ...row.source_run_id ? { sourceRunId: row.source_run_id } : {},
65
77
  createdAt: row.created_at,
66
78
  updatedAt: row.updated_at
67
79
  };
68
80
  }
81
+ function focusSnapshot(row) {
82
+ return {
83
+ horizon: row.horizon,
84
+ status: row.status,
85
+ confidence: row.confidence,
86
+ scopeType: row.scope_type,
87
+ scopeId: row.scope_id,
88
+ explicitness: row.explicitness,
89
+ sensitivity: row.sensitivity,
90
+ disclosurePolicy: row.disclosure_policy,
91
+ validFrom: row.valid_from,
92
+ validTo: row.valid_to,
93
+ reviewAt: row.review_at,
94
+ evidenceRefs: strings(row.evidence_refs_json)
95
+ };
96
+ }
97
+ function sameFocusVersion(left, right) {
98
+ return Boolean(left && left.title === right.title && left.summary === right.summary && JSON.stringify(focusSnapshot(left)) === JSON.stringify(focusSnapshot(right)));
99
+ }
100
+ function linkFocusEvidence(versionId, evidenceRefs, confidence) {
101
+ if (!evidenceRefs.length) return;
102
+ const placeholders = evidenceRefs.map(() => "?").join(", ");
103
+ getSqliteDatabase().prepare(`INSERT OR IGNORE INTO user_focus_evidence_links (
104
+ version_id, evidence_id, relation, confidence
105
+ ) SELECT ?, evidence_id, 'supports', ? FROM context_evidence WHERE source_ref IN (${placeholders})`).run(versionId, confidence, ...evidenceRefs);
106
+ }
107
+ function listUserFocusEvidence(focusId) {
108
+ return getSqliteDatabase().prepare(`SELECT DISTINCT e.* FROM context_evidence e
109
+ JOIN user_focus_evidence_links l ON l.evidence_id = e.evidence_id
110
+ JOIN user_focus_versions v ON v.version_id = l.version_id
111
+ WHERE v.focus_id = ? ORDER BY e.observed_at DESC`).all(focusId).map((row) => ({
112
+ id: row.evidence_id,
113
+ sourceType: row.source_type,
114
+ ...row.source_instance_id ? { sourceInstanceId: row.source_instance_id } : {},
115
+ sourceRef: row.source_ref,
116
+ ...row.source_run_id ? { sourceRunId: row.source_run_id } : {},
117
+ ...row.source_item_id ? { sourceItemId: row.source_item_id } : {},
118
+ ...row.session_id ? { sessionId: row.session_id } : {},
119
+ ...row.turn_id ? { turnId: row.turn_id } : {},
120
+ ...row.message_id ? { messageId: row.message_id } : {},
121
+ ...row.content_hash ? { contentHash: row.content_hash } : {},
122
+ ...row.retention_policy ? { retentionPolicy: row.retention_policy } : {},
123
+ ...row.processing_policy ? { processingPolicy: row.processing_policy } : {},
124
+ ...row.extractor_id ? { extractorId: row.extractor_id } : {},
125
+ ...row.extractor_version ? { extractorVersion: row.extractor_version } : {},
126
+ ...row.redacted_excerpt ? { redactedExcerpt: row.redacted_excerpt } : {},
127
+ trustLevel: row.trust_level,
128
+ observedAt: row.observed_at,
129
+ ingestedAt: row.ingested_at ?? row.created_at,
130
+ createdAt: row.created_at
131
+ }));
132
+ }
69
133
  function listUnderstandingSourceGrants(options = {}) {
70
134
  return getSqliteDatabase().prepare(`SELECT * FROM understanding_source_grants ${options.includeRevoked ? "" : "WHERE status = 'active'"} ORDER BY updated_at DESC`).all().map(grantFromRow);
71
135
  }
@@ -85,8 +149,7 @@ function upsertUnderstandingSourceGrant(input) {
85
149
  ) VALUES (?, ?, ?, ?, ?, ?, 'active', ?, ?, ?, ?, ?, ?, ?, ?)
86
150
  ON CONFLICT(source_key) DO UPDATE SET
87
151
  adapter_id = excluded.adapter_id, category = excluded.category, platform = excluded.platform,
88
- display_name = excluded.display_name, status = 'active', access_mode = excluded.access_mode,
89
- retention_policy = excluded.retention_policy, processing_policy = excluded.processing_policy,
152
+ display_name = excluded.display_name, status = 'active',
90
153
  config_json = excluded.config_json, checkpoint_json = excluded.checkpoint_json,
91
154
  last_collected_at = COALESCE(excluded.last_collected_at, understanding_source_grants.last_collected_at),
92
155
  updated_at = excluded.updated_at
@@ -104,6 +167,16 @@ function updateUnderstandingSourceGrantCheckpoint(id, input) {
104
167
  `).run(JSON.stringify(input.checkpoint ?? current.checkpoint), input.lastCollectedAt ?? current.lastCollectedAt ?? null, now, id));
105
168
  return getUnderstandingSourceGrant(id);
106
169
  }
170
+ function updateUnderstandingSourceGrantPolicies(id, patch) {
171
+ const current = getUnderstandingSourceGrant(id);
172
+ if (!current) return null;
173
+ runSqliteWriteTransaction((db) => db.prepare(`
174
+ UPDATE understanding_source_grants
175
+ SET access_mode = ?, retention_policy = ?, processing_policy = ?, updated_at = ?
176
+ WHERE grant_id = ?
177
+ `).run(patch.accessMode ?? current.accessMode, patch.retentionPolicy ?? current.retentionPolicy, patch.processingPolicy ?? current.processingPolicy, patch.nowMs ?? Date.now(), id));
178
+ return getUnderstandingSourceGrant(id);
179
+ }
107
180
  function revokeUnderstandingSourceGrant(id, nowMs = Date.now()) {
108
181
  runSqliteWriteTransaction((db) => db.prepare("UPDATE understanding_source_grants SET status = 'revoked', updated_at = ? WHERE grant_id = ?").run(nowMs, id));
109
182
  return getUnderstandingSourceGrant(id);
@@ -138,11 +211,20 @@ function updateUnderstandingSourceRun(id, patch) {
138
211
  function upsertUserFocus(input) {
139
212
  const id = randomUUID();
140
213
  const now = input.nowMs ?? Date.now();
141
- runSqliteWriteTransaction((db) => db.prepare(`
214
+ const scope = input.scope ?? { type: "global" };
215
+ const explicitness = input.explicitness ?? "inferred";
216
+ const sensitivity = input.sensitivity ?? "normal";
217
+ const disclosurePolicy = input.disclosurePolicy ?? "referenceable";
218
+ const existingRow = getSqliteDatabase().prepare("SELECT * FROM user_focuses WHERE canonical_key = ?").get(input.canonicalKey);
219
+ if (existingRow?.explicitness === "explicit" && explicitness !== "explicit") return focusFromRow(existingRow);
220
+ let currentVersionId = existingRow?.current_version_id;
221
+ runSqliteWriteTransaction((db) => {
222
+ db.prepare(`
142
223
  INSERT INTO user_focuses (
143
- focus_id, canonical_key, title, summary, horizon, status, confidence, project_id,
144
- evidence_refs_json, source_run_id, created_at, updated_at
145
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
224
+ focus_id, principal_id, canonical_key, title, summary, horizon, status, confidence,
225
+ scope_type, scope_id, explicitness, sensitivity, disclosure_policy,
226
+ valid_from, valid_to, review_at, evidence_refs_json, source_run_id, created_at, updated_at
227
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
146
228
  ON CONFLICT(canonical_key) DO UPDATE SET title = excluded.title, summary = excluded.summary,
147
229
  horizon = excluded.horizon,
148
230
  status = CASE
@@ -151,9 +233,23 @@ function upsertUserFocus(input) {
151
233
  ELSE excluded.status
152
234
  END,
153
235
  confidence = excluded.confidence,
154
- project_id = excluded.project_id, evidence_refs_json = excluded.evidence_refs_json,
236
+ scope_type = excluded.scope_type, scope_id = excluded.scope_id,
237
+ explicitness = excluded.explicitness, sensitivity = excluded.sensitivity,
238
+ disclosure_policy = excluded.disclosure_policy, valid_from = excluded.valid_from,
239
+ valid_to = excluded.valid_to, review_at = excluded.review_at,
240
+ evidence_refs_json = excluded.evidence_refs_json,
155
241
  source_run_id = excluded.source_run_id, updated_at = excluded.updated_at
156
- `).run(id, input.canonicalKey, input.title, input.summary, input.horizon, input.status, input.confidence, input.projectId ?? null, JSON.stringify(input.evidenceRefs), input.sourceRunId ?? null, now, now));
242
+ `).run(id, input.principalId ?? "local-owner", input.canonicalKey, input.title, input.summary, input.horizon, input.status, input.confidence, scope.type, scope.id ?? null, explicitness, sensitivity, disclosurePolicy, input.validFrom ?? null, input.validTo ?? null, input.reviewAt ?? null, JSON.stringify(input.evidenceRefs), input.sourceRunId ?? null, now, now);
243
+ const nextRow = db.prepare("SELECT * FROM user_focuses WHERE canonical_key = ?").get(input.canonicalKey);
244
+ if (!sameFocusVersion(existingRow, nextRow)) {
245
+ currentVersionId = randomUUID();
246
+ db.prepare(`INSERT INTO user_focus_versions (
247
+ version_id, focus_id, title, summary, snapshot_json, created_by, change_reason, created_at
248
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(currentVersionId, nextRow.focus_id, nextRow.title, nextRow.summary, JSON.stringify(focusSnapshot(nextRow)), explicitness === "explicit" ? "user" : input.sourceRunId ? "connector" : "runtime", input.changeReason ?? (existingRow ? "Focus updated" : "Focus created"), now);
249
+ db.prepare("UPDATE user_focuses SET current_version_id = ? WHERE focus_id = ?").run(currentVersionId, nextRow.focus_id);
250
+ }
251
+ });
252
+ if (currentVersionId) linkFocusEvidence(currentVersionId, input.evidenceRefs, input.confidence);
157
253
  return focusFromRow(getSqliteDatabase().prepare("SELECT * FROM user_focuses WHERE canonical_key = ?").get(input.canonicalKey));
158
254
  }
159
255
  function listUserFocuses(statuses) {
@@ -161,8 +257,22 @@ function listUserFocuses(statuses) {
161
257
  const placeholders = statuses.map(() => "?").join(", ");
162
258
  return getSqliteDatabase().prepare(`SELECT * FROM user_focuses WHERE status IN (${placeholders}) ORDER BY updated_at DESC`).all(...statuses).map(focusFromRow);
163
259
  }
164
- function setUserFocusStatus(id, status, nowMs = Date.now()) {
165
- runSqliteWriteTransaction((db) => db.prepare("UPDATE user_focuses SET status = ?, updated_at = ? WHERE focus_id = ?").run(status, nowMs, id));
260
+ function updateUserFocus(id, patch, nowMs = Date.now()) {
261
+ const currentRow = getSqliteDatabase().prepare("SELECT * FROM user_focuses WHERE focus_id = ?").get(id);
262
+ if (!currentRow) return null;
263
+ const current = focusFromRow(currentRow);
264
+ if ((patch.title ?? current.title) === current.title && (patch.summary ?? current.summary) === current.summary && (patch.status ?? current.status) === current.status) return current;
265
+ const versionId = randomUUID();
266
+ runSqliteWriteTransaction((db) => {
267
+ db.prepare(`UPDATE user_focuses
268
+ SET title = ?, summary = ?, status = ?, updated_at = ? WHERE focus_id = ?`).run(patch.title ?? current.title, patch.summary ?? current.summary, patch.status ?? current.status, nowMs, id);
269
+ const nextRow = db.prepare("SELECT * FROM user_focuses WHERE focus_id = ?").get(id);
270
+ db.prepare(`INSERT INTO user_focus_versions (
271
+ version_id, focus_id, title, summary, snapshot_json, created_by, change_reason, created_at
272
+ ) VALUES (?, ?, ?, ?, ?, ?, 'Focus updated', ?)`).run(versionId, id, nextRow.title, nextRow.summary, JSON.stringify(focusSnapshot(nextRow)), current.explicitness === "explicit" ? "user" : "runtime", nowMs);
273
+ db.prepare("UPDATE user_focuses SET current_version_id = ? WHERE focus_id = ?").run(versionId, id);
274
+ });
275
+ linkFocusEvidence(versionId, current.evidenceRefs, current.confidence);
166
276
  const row = getSqliteDatabase().prepare("SELECT * FROM user_focuses WHERE focus_id = ?").get(id);
167
277
  return row ? focusFromRow(row) : null;
168
278
  }
@@ -170,4 +280,4 @@ function deleteUserFocus(id) {
170
280
  return Number(getSqliteDatabase().prepare("DELETE FROM user_focuses WHERE focus_id = ?").run(id).changes) > 0;
171
281
  }
172
282
  //#endregion
173
- export { createUnderstandingSourceRun, deleteUserFocus, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocuses, revokeUnderstandingSourceGrant, setUserFocusStatus, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant, upsertUserFocus };
283
+ export { createUnderstandingSourceRun, deleteUserFocus, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocusEvidence, listUserFocuses, revokeUnderstandingSourceGrant, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, updateUserFocus, upsertUnderstandingSourceGrant, upsertUserFocus };
@@ -1,3 +1,4 @@
1
+ import type { UserContextScope, UserUnderstanding } from '../domain.js';
1
2
  export type UnderstandingSourcePlatform = 'darwin' | 'win32' | 'linux' | 'all';
2
3
  export type UnderstandingSourceCategory = 'files' | 'recent_documents' | 'calendar' | 'tasks' | 'notes' | 'mail' | 'messages' | 'code_activity';
3
4
  export type UnderstandingSourceAccessMode = 'once' | 'continuous';
@@ -75,13 +76,21 @@ export interface UnderstandingSourceRun {
75
76
  }
76
77
  export interface UserFocus {
77
78
  id: string;
79
+ versionId: string;
80
+ principalId: string;
78
81
  canonicalKey: string;
79
82
  title: string;
80
83
  summary: string;
81
84
  horizon: 'current' | 'ongoing' | 'long_term';
82
85
  status: 'candidate' | 'active' | 'paused' | 'completed' | 'rejected';
83
86
  confidence: number;
84
- projectId?: string;
87
+ scope: UserContextScope;
88
+ explicitness: UserUnderstanding['explicitness'];
89
+ sensitivity: UserUnderstanding['sensitivity'];
90
+ disclosurePolicy: UserUnderstanding['disclosurePolicy'];
91
+ validFrom?: number;
92
+ validTo?: number;
93
+ reviewAt?: number;
85
94
  evidenceRefs: string[];
86
95
  sourceRunId?: string;
87
96
  createdAt: number;
@@ -0,0 +1 @@
1
+ export declare const USER_FACING_UNDERSTANDING_WRITING_GUIDANCE = "Write each understanding as concise, neutral profile copy that can be shown directly to the person described, not as an internal note about \"the user\". Prefer a subject-omitted predicate or noun phrase. For example, write \u201C\u503E\u5411\u4F7F\u7528 pnpm \u4F5C\u4E3A\u5305\u7BA1\u7406\u5668\u201D or \u201Cxopc \u9879\u76EE\u7684\u6838\u5FC3\u5F00\u53D1\u8005\u201D, not \u201C\u7528\u6237\u503E\u5411\u4E8E\u4F7F\u7528 pnpm\u201D or \u201C\u7528\u6237\u662F xopc \u9879\u76EE\u7684\u5F00\u53D1\u8005\u201D; write \u201CPrefers pnpm as the package manager\u201D or \u201CCore maintainer of xopc\u201D, not \u201CThe user prefers pnpm\u201D or \u201CThe user is a maintainer of xopc\u201D. Do not begin with generic subject labels or pronouns such as \u201C\u7528\u6237\u201D, \u201C\u8BE5\u7528\u6237\u201D, \u201C\u6B64\u7528\u6237\u201D, \u201C\u4F60\u201D, \u201C\u6211\u201D, \u201Cthe user\u201D, \u201Cuser\u201D, \u201Cyou\u201D, or \u201CI\u201D.";
@@ -0,0 +1,4 @@
1
+ //#region src/user-context/understanding-writing.ts
2
+ const USER_FACING_UNDERSTANDING_WRITING_GUIDANCE = `Write each understanding as concise, neutral profile copy that can be shown directly to the person described, not as an internal note about "the user". Prefer a subject-omitted predicate or noun phrase. For example, write “倾向使用 pnpm 作为包管理器” or “xopc 项目的核心开发者”, not “用户倾向于使用 pnpm” or “用户是 xopc 项目的开发者”; write “Prefers pnpm as the package manager” or “Core maintainer of xopc”, not “The user prefers pnpm” or “The user is a maintainer of xopc”. Do not begin with generic subject labels or pronouns such as “用户”, “该用户”, “此用户”, “你”, “我”, “the user”, “user”, “you”, or “I”.`;
3
+ //#endregion
4
+ export { USER_FACING_UNDERSTANDING_WRITING_GUIDANCE };
@@ -8,7 +8,7 @@ function canonicalUnderstandingKey(kind, statement) {
8
8
  function isSameUserContextScope(left, right) {
9
9
  return left.type === right.type && left.id === right.id;
10
10
  }
11
- const NEGATION = /\b(?:do not|don't|never|avoid|without)\b|(?:不要|不用|无需|从不|避免|禁止)/i;
11
+ const NEGATION = /\b(?:do not|don't|not|never|avoid|without)\b|(?:不要|不用|无需|从不|避免|禁止)/i;
12
12
  function withoutNegation(statement) {
13
13
  return statement.replace(NEGATION, "").replace(/\s+/g, " ").trim();
14
14
  }
@@ -10,6 +10,11 @@ export declare function analyzeWorkContext(input: {
10
10
  modelRef: string;
11
11
  result: WorkDiscoveryResult;
12
12
  }>;
13
+ export type UnderstandingSourceAnalysisStatus = {
14
+ sourceId: string;
15
+ status: 'completed' | 'partial' | 'failed';
16
+ error?: string;
17
+ };
13
18
  export declare function analyzeUnderstandingSources(input: {
14
19
  config: Config;
15
20
  items: UnderstandingSourceItem[];
@@ -19,5 +24,6 @@ export declare function analyzeUnderstandingSources(input: {
19
24
  modelRef: string;
20
25
  profileCandidates: WorkDiscoveryProfileCandidate[];
21
26
  workThreadCandidates: WorkUnderstandingThreadCandidate[];
27
+ sourceStatuses: UnderstandingSourceAnalysisStatus[];
22
28
  }>;
23
29
  export declare function workDiscoveryResultMarkdown(result: WorkDiscoveryResult): string;