@xopcai/xopc 0.0.189 → 0.0.190

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 (347) hide show
  1. package/README.md +0 -3
  2. package/README.zh-CN.md +0 -3
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/{activity-store-DTFKTPs8.js → activity-store-DstnJCS5.js} +1 -1
  6. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DqO25Qe5.js → agent-avatar-dicebear-9vAbkroX.js} +1 -1
  7. package/dist/gateway/static/root/assets/agents-D1t4SfMQ.js +68 -0
  8. package/dist/gateway/static/root/assets/{api-DWeXfwVU.js → api-BTL9kayv.js} +1 -1
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-BRpV8PXG.js → app-management-settings-panel-DkFeIdBf.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-3ntKM9nQ.js → appearance-settings-Bxs8Fpaj.js} +1 -1
  11. package/dist/gateway/static/root/assets/apps-page-Cgrgu5OW.js +1 -0
  12. package/dist/gateway/static/root/assets/{archive-plugin-Df7Ycj_7.js → archive-plugin-Ch2RmLCC.js} +1 -1
  13. package/dist/gateway/static/root/assets/{attachment-load-UHgfZYtj.js → attachment-load-BhMQM_Ky.js} +1 -1
  14. package/dist/gateway/static/root/assets/automations-page-CtJxstKh.js +6 -0
  15. package/dist/gateway/static/root/assets/{binary-plugins-BJah99wE.js → binary-plugins-D6CqlymH.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-DNlY5KqF.js → block-editor-ClL6HEg9.js} +48 -48
  17. package/dist/gateway/static/root/assets/browser-settings-page-DW99iDmD.js +8 -0
  18. package/dist/gateway/static/root/assets/{browser-workflow-inputs-vyUfdzAd.js → browser-workflow-inputs-BYy48VhN.js} +1 -1
  19. package/dist/gateway/static/root/assets/{browser-workflows-page-C1cKZjx-.js → browser-workflows-page-zgLibuMH.js} +2 -2
  20. package/dist/gateway/static/root/assets/capabilities-settings-panel-CHUrT9EB.js +7 -0
  21. package/dist/gateway/static/root/assets/capability-presets-api-BB8t4Ja7.js +1 -0
  22. package/dist/gateway/static/root/assets/capability-presets-settings-panel-Cycrv0YV.js +1 -0
  23. package/dist/gateway/static/root/assets/{channel-recipient-api-BGG2kpJB.js → channel-recipient-api-BThDGiO3.js} +1 -1
  24. package/dist/gateway/static/root/assets/channels-settings-V96gPUAU.js +1 -0
  25. package/dist/gateway/static/root/assets/channels-status-swr-Cz7SAAkm.js +1 -0
  26. package/dist/gateway/static/root/assets/connectors-api-DS9ED-EL.js +1 -0
  27. package/dist/gateway/static/root/assets/connectors-page-BhlyQoQI.js +2 -0
  28. package/dist/gateway/static/root/assets/cron-expression-CkgsvhtW.js +2 -0
  29. package/dist/gateway/static/root/assets/{desktop-pet-BUuBEJuP.js → desktop-pet-Cv8rGhYW.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-settings-BGfVIJM3.js → desktop-pet-settings-CIeJdwfV.js} +1 -1
  31. package/dist/gateway/static/root/assets/{directory-picker-path-field-DrQFfHH_.js → directory-picker-path-field-D8jXEiAY.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-debug-page-CEnIFOX-.js → extension-debug-page-CCZ9u6TZ.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-page-CCqHbexs.js → extension-page-CV36ILRG.js} +1 -1
  34. package/dist/gateway/static/root/assets/extension-settings-page-IyQrSILY.js +1 -0
  35. package/dist/gateway/static/root/assets/{gateway-config-api-CgUE2Ii1.js → gateway-config-api-D4_r5iJM.js} +1 -1
  36. package/dist/gateway/static/root/assets/gateway-settings-CYlntpBH.js +1 -0
  37. package/dist/gateway/static/root/assets/{gateway-startup-retry-DxhKNiCF.js → gateway-startup-retry-EO9mKvzE.js} +1 -1
  38. package/dist/gateway/static/root/assets/heartbeat-settings-D4SyWob8.js +1 -0
  39. package/dist/gateway/static/root/assets/home-page-B2Kagoh8.js +3 -0
  40. package/dist/gateway/static/root/assets/{image-generation-api-DCFdc-HD.js → image-generation-api-Bu7PyVSh.js} +1 -1
  41. package/dist/gateway/static/root/assets/index-CYT5DOzr.js +150 -0
  42. package/dist/gateway/static/root/assets/index-D6e3tPL-.css +1 -0
  43. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Bf2VLtXW.js → keyboard-shortcuts-settings-BMhCuVBZ.js} +1 -1
  44. package/dist/gateway/static/root/assets/local-app-workbench-page-BHYbFjqy.js +2 -0
  45. package/dist/gateway/static/root/assets/{local-apps-page-Ca1RuI13.js → local-apps-page-ijIe7_y2.js} +1 -1
  46. package/dist/gateway/static/root/assets/locale-store-deR2zRaE.js +1 -0
  47. package/dist/gateway/static/root/assets/logs-page-IIn8Tess.js +2 -0
  48. package/dist/gateway/static/root/assets/{management-settings-B3Eop1zn.js → management-settings--V_fovKD.js} +1 -1
  49. package/dist/gateway/static/root/assets/{markdown-split-BGOYjgnM.js → markdown-split-Dt9-in6W.js} +1 -1
  50. package/dist/gateway/static/root/assets/{media-plugins-CT0txyM4.js → media-plugins-B3pj_iO0.js} +1 -1
  51. package/dist/gateway/static/root/assets/messages-B4XqB8I6.js +3 -0
  52. package/dist/gateway/static/root/assets/{notes-page-DfKgAe78.js → notes-page-DZ366lIT.js} +1 -1
  53. package/dist/gateway/static/root/assets/notes-workbench-S2sBVOLw.js +4 -0
  54. package/dist/gateway/static/root/assets/{page-tabs-DNrbCgmC.js → page-tabs-C5ge434C.js} +1 -1
  55. package/dist/gateway/static/root/assets/{preview-open-alternatives-BTqViDOR.js → preview-open-alternatives-BFa9DgSV.js} +1 -1
  56. package/dist/gateway/static/root/assets/{product-open-page-C_2L4_Iu.js → product-open-page-Dc9CcWdu.js} +1 -1
  57. package/dist/gateway/static/root/assets/project-detail-page-BilzoCJ7.js +1 -0
  58. package/dist/gateway/static/root/assets/projects-page-BoQUyacP.js +1 -0
  59. package/dist/gateway/static/root/assets/remote-access-hub-DUyUaCRF.js +1 -0
  60. package/dist/gateway/static/root/assets/{schema-form-BFLfkDGG.js → schema-form-B84DckWe.js} +1 -1
  61. package/dist/gateway/static/root/assets/sessions-page-Dzxlq1F0.js +1 -0
  62. package/dist/gateway/static/root/assets/settings-advanced-gate-TzwlZxU6.js +1 -0
  63. package/dist/gateway/static/root/assets/settings-form-section-Dp9itvdy.js +1 -0
  64. package/dist/gateway/static/root/assets/{settings-loading-skeleton-C9a-EbTZ.js → settings-loading-skeleton-CCtlhoy7.js} +1 -1
  65. package/dist/gateway/static/root/assets/{settings-page-DI9qDH5x.js → settings-page-DQmMKf8r.js} +1 -1
  66. package/dist/gateway/static/root/assets/{settings-page-layout-D-LWQdI5.js → settings-page-layout-EQIOJa_L.js} +1 -1
  67. package/dist/gateway/static/root/assets/{setup-status-panel-CJwmPvgs.js → setup-status-panel-Cwi-SPja.js} +1 -1
  68. package/dist/gateway/static/root/assets/{share-preview-page-BKSMG9r5.js → share-preview-page-C4_B2jvf.js} +1 -1
  69. package/dist/gateway/static/root/assets/shares-settings-CkyuGlZK.js +1 -0
  70. package/dist/gateway/static/root/assets/skill-reload-api-BJCePQK5.js +1 -0
  71. package/dist/gateway/static/root/assets/skills-page-BYWLfmJi.js +2 -0
  72. package/dist/gateway/static/root/assets/{skills-page.utils-zsz2HIlZ.js → skills-page.utils-Jhm24i4h.js} +1 -1
  73. package/dist/gateway/static/root/assets/{system-settings-panel-IWNDBI1O.js → system-settings-panel-Dpx2ags2.js} +1 -1
  74. package/dist/gateway/static/root/assets/{task-detail-page-CgtK02kP.js → task-detail-page-DLAdxI6e.js} +1 -1
  75. package/dist/gateway/static/root/assets/{theme-store-BkJe7UDo.js → theme-store-DnBOcGXi.js} +1 -1
  76. package/dist/gateway/static/root/assets/{typed-models-lib-C07LGthO.js → typed-models-lib-DULmTHUB.js} +1 -1
  77. package/dist/gateway/static/root/assets/use-autosave-BrjVk5VH.js +1 -0
  78. package/dist/gateway/static/root/assets/user-context-page-9AAFpGAL.js +1 -0
  79. package/dist/gateway/static/root/assets/{voice-api-key-field-Boue1D46.js → voice-api-key-field-BISTPfq_.js} +1 -1
  80. package/dist/gateway/static/root/assets/{work-discovery-overlay-bbmvCmc8.js → work-discovery-overlay-Wr-uF7VA.js} +1 -1
  81. package/dist/gateway/static/root/assets/work-discovery-page-BWds95sL.js +1 -0
  82. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DlHv-GZC.js → workflow-run-setup-panel-DHqHP8_6.js} +2 -2
  83. package/dist/gateway/static/root/assets/workflows-page-0b4_DFHr.js +11 -0
  84. package/dist/gateway/static/root/index.html +7 -7
  85. package/dist/package.js +1 -1
  86. package/dist/packages/gateway-contract/src/tool-activity.js +0 -36
  87. package/dist/packages/realtime-client/src/index.js +105 -48
  88. package/dist/packages/realtime-protocol/src/index.js +6 -1
  89. package/dist/src/agent/agent-manager.d.ts +0 -1
  90. package/dist/src/agent/agent-manager.js +6 -13
  91. package/dist/src/agent/background-review/coordinator.js +1 -1
  92. package/dist/src/agent/background-review/run-background-review.js +5 -7
  93. package/dist/src/agent/bootstrap/bootstrap-cache.d.ts +0 -1
  94. package/dist/src/agent/bootstrap/bootstrap-cache.js +3 -4
  95. package/dist/src/agent/bootstrap/bootstrap-files.d.ts +0 -4
  96. package/dist/src/agent/bootstrap/bootstrap-files.js +3 -4
  97. package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -4
  98. package/dist/src/agent/bootstrap/load-bootstrap-files.d.ts +0 -1
  99. package/dist/src/agent/bootstrap/load-bootstrap-files.js +1 -14
  100. package/dist/src/agent/bootstrap/types.d.ts +1 -1
  101. package/dist/src/agent/context/workspace-templates/SOUL.md +1 -1
  102. package/dist/src/agent/memory/builtin-provider.d.ts +2 -4
  103. package/dist/src/agent/memory/builtin-provider.js +35 -15
  104. package/dist/src/agent/memory/context/types.d.ts +3 -1
  105. package/dist/src/agent/memory/create-memory-manager.js +2 -0
  106. package/dist/src/agent/memory/index.d.ts +1 -1
  107. package/dist/src/agent/memory/index.js +1 -1
  108. package/dist/src/agent/memory/manager.d.ts +9 -1
  109. package/dist/src/agent/memory/manager.js +39 -9
  110. package/dist/src/agent/memory/memory-config.d.ts +1 -1
  111. package/dist/src/agent/memory/memory-config.js +1 -1
  112. package/dist/src/agent/memory/source-origin.js +0 -2
  113. package/dist/src/agent/memory/types.d.ts +5 -1
  114. package/dist/src/agent/memory/understanding/service.d.ts +10 -10
  115. package/dist/src/agent/memory/understanding/service.js +108 -176
  116. package/dist/src/agent/memory/understanding/types.d.ts +7 -8
  117. package/dist/src/agent/memory/user-context-coordinator.d.ts +2 -1
  118. package/dist/src/agent/memory/user-context-coordinator.js +27 -41
  119. package/dist/src/agent/orchestration/agent-orchestrator.js +4 -7
  120. package/dist/src/agent/prompt/sections/memory-skills.js +4 -4
  121. package/dist/src/agent/prompt/sections/tooling.js +0 -10
  122. package/dist/src/agent/prompt/service-prompt-builder.d.ts +0 -1
  123. package/dist/src/agent/prompt/service-prompt-builder.js +4 -33
  124. package/dist/src/agent/prompt/system-prompt.js +1 -2
  125. package/dist/src/agent/service/direct-turn-helpers.js +1 -1
  126. package/dist/src/agent/service.d.ts +1 -2
  127. package/dist/src/agent/service.js +4 -17
  128. package/dist/src/agent/skills/marketplace/adapters/clawhub/adapter.js +1 -1
  129. package/dist/src/agent/tools/dreaming-tool.d.ts +0 -2
  130. package/dist/src/agent/tools/dreaming-tool.js +13 -38
  131. package/dist/src/agent/tools/factory.d.ts +0 -3
  132. package/dist/src/agent/tools/factory.js +1 -10
  133. package/dist/src/agent/tools/index.d.ts +0 -1
  134. package/dist/src/agent/tools/index.js +1 -2
  135. package/dist/src/agent/tools/memory-tool.js +1 -1
  136. package/dist/src/agent/workspace-runtime/registry.d.ts +3 -5
  137. package/dist/src/agent/workspace-runtime/registry.js +2 -15
  138. package/dist/src/agent-manifest/schema.d.ts +17 -17
  139. package/dist/src/agent-runtime/index.js +1 -1
  140. package/dist/src/agent-runtime/memory-runtime.d.ts +2 -2
  141. package/dist/src/agent-runtime/runtime-profile.js +1 -1
  142. package/dist/src/automations/domain/validation.d.ts +28 -28
  143. package/dist/src/automations/draft/automation-draft-validator.d.ts +3 -3
  144. package/dist/src/chat-commands/builtins/understanding.js +2 -5
  145. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  146. package/dist/src/cli/commands/init.js +3 -22
  147. package/dist/src/cli/templates.js +1 -1
  148. package/dist/src/config/index.js +3 -3
  149. package/dist/src/config/paths.d.ts +0 -5
  150. package/dist/src/config/paths.js +2 -11
  151. package/dist/src/config/schema.d.ts +24 -117
  152. package/dist/src/config/schema.js +9 -39
  153. package/dist/src/connectors/learning-coordinator.js +75 -3
  154. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  155. package/dist/src/gateway/agent-builtin-tools.js +0 -5
  156. package/dist/src/gateway/agents-admin.d.ts +0 -7
  157. package/dist/src/gateway/agents-admin.js +3 -32
  158. package/dist/src/gateway/dreaming-automation-reconciler.d.ts +3 -3
  159. package/dist/src/gateway/dreaming-automation-reconciler.js +48 -88
  160. package/dist/src/gateway/hono/lib/config-payload.d.ts +19 -7
  161. package/dist/src/gateway/hono/lib/config-payload.js +3 -1
  162. package/dist/src/gateway/hono/oauth-async.d.ts +1 -0
  163. package/dist/src/gateway/hono/oauth-async.js +17 -2
  164. package/dist/src/gateway/hono/routes/agents.js +1 -33
  165. package/dist/src/gateway/hono/routes/config-patch/misc.js +17 -1
  166. package/dist/src/gateway/hono/routes/connectors.js +13 -12
  167. package/dist/src/gateway/hono/routes/index.js +2 -2
  168. package/dist/src/gateway/hono/routes/lazy-bundles.js +1 -5
  169. package/dist/src/gateway/hono/routes/status.js +0 -7
  170. package/dist/src/gateway/hono/routes/understanding-sources.d.ts +3 -0
  171. package/dist/src/gateway/hono/routes/understanding-sources.js +203 -0
  172. package/dist/src/gateway/hono/routes/work-discovery.d.ts +2 -0
  173. package/dist/src/gateway/hono/routes/work-discovery.js +3 -134
  174. package/dist/src/gateway/hono/routes/you.d.ts +0 -22
  175. package/dist/src/gateway/hono/routes/you.js +234 -1118
  176. package/dist/src/gateway/service/config-coordinator.d.ts +1 -1
  177. package/dist/src/gateway/service/run-gateway-agent.js +2 -4
  178. package/dist/src/knowledge/connected-knowledge-pipeline.js +1 -1
  179. package/dist/src/knowledge/connected-understanding-pipeline.d.ts +2 -4
  180. package/dist/src/knowledge/connected-understanding-pipeline.js +31 -81
  181. package/dist/src/knowledge/index.js +2 -2
  182. package/dist/src/knowledge/people-graph.d.ts +22 -25
  183. package/dist/src/knowledge/people-graph.js +76 -43
  184. package/dist/src/proactive/execution/context.js +8 -13
  185. package/dist/src/realtime/broker.d.ts +1 -0
  186. package/dist/src/realtime/broker.js +19 -2
  187. package/dist/src/realtime/runtime.js +6 -1
  188. package/dist/src/storage/sqlite/connector-account-repository.js +0 -1
  189. package/dist/src/storage/sqlite/context-consolidation-repository.d.ts +37 -0
  190. package/dist/src/storage/sqlite/context-consolidation-repository.js +64 -0
  191. package/dist/src/storage/sqlite/fts.d.ts +2 -0
  192. package/dist/src/storage/sqlite/fts.js +29 -1
  193. package/dist/src/storage/sqlite/index.d.ts +4 -6
  194. package/dist/src/storage/sqlite/index.js +5 -7
  195. package/dist/src/storage/sqlite/knowledge-repository.d.ts +9 -2
  196. package/dist/src/storage/sqlite/knowledge-repository.js +58 -10
  197. package/dist/src/storage/sqlite/memory-records-repository.d.ts +7 -56
  198. package/dist/src/storage/sqlite/memory-records-repository.js +68 -218
  199. package/dist/src/storage/sqlite/migrations/113_memory_evidence_single_source.sql +54 -0
  200. package/dist/src/storage/sqlite/migrations/114_user_context_domain.sql +193 -0
  201. package/dist/src/storage/sqlite/migrations/115_remove_legacy_user_context.sql +6 -0
  202. package/dist/src/storage/sqlite/migrations/116_structured_context_consolidation.sql +38 -0
  203. package/dist/src/storage/sqlite/migrations/117_unified_understanding_sources.sql +110 -0
  204. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  205. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  206. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  207. package/dist/src/storage/sqlite/schema.js +1 -1
  208. package/dist/src/storage/sqlite/schema.sql +0 -20
  209. package/dist/src/storage/sqlite/user-context-quality-repository.d.ts +34 -0
  210. package/dist/src/storage/sqlite/user-context-quality-repository.js +74 -0
  211. package/dist/src/storage/sqlite/user-context-repository.d.ts +64 -0
  212. package/dist/src/storage/sqlite/user-context-repository.js +383 -0
  213. package/dist/src/tui/tool-summary.js +1 -7
  214. package/dist/src/tui/tui-startup-resources.js +1 -2
  215. package/dist/src/user-context/config.d.ts +17 -210
  216. package/dist/src/user-context/config.js +19 -85
  217. package/dist/src/user-context/consolidation.d.ts +26 -0
  218. package/dist/src/user-context/consolidation.js +115 -0
  219. package/dist/src/user-context/domain.d.ts +75 -0
  220. package/dist/src/user-context/domain.js +4 -0
  221. package/dist/src/user-context/manual-understanding.d.ts +7 -14
  222. package/dist/src/user-context/manual-understanding.js +19 -54
  223. package/dist/src/{agent/memory/context → user-context}/planner.d.ts +5 -6
  224. package/dist/src/user-context/planner.js +311 -0
  225. package/dist/src/user-context/relationship-continuity.d.ts +3 -6
  226. package/dist/src/user-context/relationship-continuity.js +39 -32
  227. package/dist/src/user-context/sources/catalog.d.ts +2 -0
  228. package/dist/src/user-context/sources/catalog.js +149 -0
  229. package/dist/src/user-context/sources/index.d.ts +3 -0
  230. package/dist/src/user-context/sources/index.js +3 -0
  231. package/dist/src/user-context/sources/repository.d.ts +40 -0
  232. package/dist/src/user-context/sources/repository.js +164 -0
  233. package/dist/src/user-context/sources/types.d.ts +83 -0
  234. package/dist/src/work-discovery/analyzer.d.ts +4 -3
  235. package/dist/src/work-discovery/analyzer.js +21 -16
  236. package/dist/src/work-discovery/incremental-repository.js +42 -40
  237. package/dist/src/work-discovery/index.js +3 -3
  238. package/dist/src/work-discovery/service.d.ts +7 -7
  239. package/dist/src/work-discovery/service.js +241 -190
  240. package/dist/src/work-discovery/source-repository.js +42 -53
  241. package/dist/src/work-discovery/types.d.ts +2 -14
  242. package/package.json +3 -8
  243. package/dist/gateway/static/root/assets/agents-BvdqdER9.js +0 -2
  244. package/dist/gateway/static/root/assets/apps-page-nKLsfy6C.js +0 -1
  245. package/dist/gateway/static/root/assets/automations-page-Dh5bdZiN.js +0 -6
  246. package/dist/gateway/static/root/assets/browser-settings-page-CRJ_nAuh.js +0 -8
  247. package/dist/gateway/static/root/assets/capabilities-settings-panel-DeQR5BZt.js +0 -7
  248. package/dist/gateway/static/root/assets/capability-presets-api-D7tkhDMv.js +0 -1
  249. package/dist/gateway/static/root/assets/capability-presets-settings-panel-D7uK3q1p.js +0 -1
  250. package/dist/gateway/static/root/assets/channels-settings-Bw6Dniyq.js +0 -1
  251. package/dist/gateway/static/root/assets/channels-status-swr-BrUTz4uU.js +0 -1
  252. package/dist/gateway/static/root/assets/connector-logo-8YU53RUT.js +0 -1
  253. package/dist/gateway/static/root/assets/connectors-page-k9tMiOL5.js +0 -2
  254. package/dist/gateway/static/root/assets/cron-expression-B3B1eqnr.js +0 -2
  255. package/dist/gateway/static/root/assets/extension-settings-page-DEZw_7zN.js +0 -1
  256. package/dist/gateway/static/root/assets/gateway-settings-Dg8qCiIp.js +0 -1
  257. package/dist/gateway/static/root/assets/heartbeat-settings-27tRzDEo.js +0 -1
  258. package/dist/gateway/static/root/assets/home-page-VA511kMr.js +0 -3
  259. package/dist/gateway/static/root/assets/index-BvR-i-m6.js +0 -216
  260. package/dist/gateway/static/root/assets/index-zybP34zk.css +0 -1
  261. package/dist/gateway/static/root/assets/local-app-workbench-page-CaJq4-wV.js +0 -2
  262. package/dist/gateway/static/root/assets/locale-store-DUW5YE3R.js +0 -1
  263. package/dist/gateway/static/root/assets/logs-page-BLTCg69e.js +0 -2
  264. package/dist/gateway/static/root/assets/messages-CMjnbdbn.js +0 -3
  265. package/dist/gateway/static/root/assets/notes-workbench-Bp1w9UM1.js +0 -4
  266. package/dist/gateway/static/root/assets/project-detail-page-CZmbPDQN.js +0 -1
  267. package/dist/gateway/static/root/assets/projects-page-D5pzqfm5.js +0 -1
  268. package/dist/gateway/static/root/assets/remote-access-hub-CC-XhVGI.js +0 -1
  269. package/dist/gateway/static/root/assets/segmented-styles-BL8oLBEp.js +0 -1
  270. package/dist/gateway/static/root/assets/sessions-page-B2eTLVDV.js +0 -1
  271. package/dist/gateway/static/root/assets/settings-advanced-gate-CRuZ_bl0.js +0 -1
  272. package/dist/gateway/static/root/assets/settings-form-section-C4GXGeA4.js +0 -1
  273. package/dist/gateway/static/root/assets/shares-settings-YzSDS4G_.js +0 -1
  274. package/dist/gateway/static/root/assets/skill-reload-api-CwOo8zZk.js +0 -1
  275. package/dist/gateway/static/root/assets/skills-page-xd1cgSGN.js +0 -2
  276. package/dist/gateway/static/root/assets/time-picker-CstQ___Y.js +0 -1
  277. package/dist/gateway/static/root/assets/use-save-bar-registration-CQYE0l6z.js +0 -1
  278. package/dist/gateway/static/root/assets/user-context-page-BnQAWS_B.js +0 -1
  279. package/dist/gateway/static/root/assets/work-discovery-page-CAszL1y8.js +0 -1
  280. package/dist/gateway/static/root/assets/workflows-page-DxGzo3-x.js +0 -11
  281. package/dist/src/agent/code-intelligence/binary.d.ts +0 -15
  282. package/dist/src/agent/code-intelligence/binary.js +0 -372
  283. package/dist/src/agent/code-intelligence/index.d.ts +0 -4
  284. package/dist/src/agent/code-intelligence/index.js +0 -4
  285. package/dist/src/agent/code-intelligence/runtime.d.ts +0 -34
  286. package/dist/src/agent/code-intelligence/runtime.js +0 -280
  287. package/dist/src/agent/code-intelligence/tool-gating.d.ts +0 -5
  288. package/dist/src/agent/code-intelligence/tool-gating.js +0 -6
  289. package/dist/src/agent/code-intelligence/tools.d.ts +0 -6
  290. package/dist/src/agent/code-intelligence/tools.js +0 -266
  291. package/dist/src/agent/code-intelligence/types.d.ts +0 -22
  292. package/dist/src/agent/memory/context/planner.js +0 -286
  293. package/dist/src/agent/memory/dreaming/config.d.ts +0 -48
  294. package/dist/src/agent/memory/dreaming/config.js +0 -98
  295. package/dist/src/agent/memory/dreaming/constants.d.ts +0 -12
  296. package/dist/src/agent/memory/dreaming/constants.js +0 -18
  297. package/dist/src/agent/memory/dreaming/deep-promotion.d.ts +0 -19
  298. package/dist/src/agent/memory/dreaming/deep-promotion.js +0 -152
  299. package/dist/src/agent/memory/dreaming/light-sweep.d.ts +0 -16
  300. package/dist/src/agent/memory/dreaming/light-sweep.js +0 -115
  301. package/dist/src/agent/memory/dreaming/preview.d.ts +0 -23
  302. package/dist/src/agent/memory/dreaming/preview.js +0 -52
  303. package/dist/src/agent/memory/dreaming/promotion-lifecycle.d.ts +0 -16
  304. package/dist/src/agent/memory/dreaming/promotion-lifecycle.js +0 -44
  305. package/dist/src/agent/memory/dreaming/rem-patterns.d.ts +0 -19
  306. package/dist/src/agent/memory/dreaming/rem-patterns.js +0 -150
  307. package/dist/src/agent/memory/dreaming/runner.d.ts +0 -10
  308. package/dist/src/agent/memory/dreaming/runner.js +0 -78
  309. package/dist/src/agent/memory/dreaming/schedule.d.ts +0 -23
  310. package/dist/src/agent/memory/dreaming/schedule.js +0 -38
  311. package/dist/src/agent/memory/dreaming/scope.d.ts +0 -11
  312. package/dist/src/agent/memory/dreaming/scope.js +0 -33
  313. package/dist/src/agent/memory/dreaming/utils.d.ts +0 -3
  314. package/dist/src/agent/memory/dreaming/utils.js +0 -31
  315. package/dist/src/gateway/hono/routes/memory.d.ts +0 -3
  316. package/dist/src/gateway/hono/routes/memory.js +0 -460
  317. package/dist/src/storage/sqlite/dreaming-repository.d.ts +0 -61
  318. package/dist/src/storage/sqlite/dreaming-repository.js +0 -88
  319. package/dist/src/storage/sqlite/memory-readiness-repository.d.ts +0 -7
  320. package/dist/src/storage/sqlite/memory-readiness-repository.js +0 -30
  321. package/dist/src/storage/sqlite/memory-reference-consent-repository.d.ts +0 -27
  322. package/dist/src/storage/sqlite/memory-reference-consent-repository.js +0 -107
  323. package/dist/src/storage/sqlite/user-claims-repository.d.ts +0 -101
  324. package/dist/src/storage/sqlite/user-claims-repository.js +0 -241
  325. package/dist/src/storage/sqlite/user-profile-setup-repository.d.ts +0 -3
  326. package/dist/src/storage/sqlite/user-profile-setup-repository.js +0 -32
  327. package/dist/src/user-context/actionableInsights.d.ts +0 -14
  328. package/dist/src/user-context/actionableInsights.js +0 -34
  329. package/dist/src/user-context/context-compiler.d.ts +0 -27
  330. package/dist/src/user-context/context-compiler.js +0 -48
  331. package/dist/src/user-context/import.d.ts +0 -12
  332. package/dist/src/user-context/import.js +0 -51
  333. package/dist/src/user-context/memory-episode-evaluator.d.ts +0 -32
  334. package/dist/src/user-context/memory-episode-evaluator.js +0 -35
  335. package/dist/src/user-context/memory-readiness.d.ts +0 -33
  336. package/dist/src/user-context/memory-readiness.js +0 -41
  337. package/dist/src/user-context/memory-use-audit.d.ts +0 -10
  338. package/dist/src/user-context/memory-use-audit.js +0 -26
  339. package/dist/src/user-context/personal-playbook.d.ts +0 -11
  340. package/dist/src/user-context/personal-playbook.js +0 -41
  341. package/dist/src/user-context/profile.d.ts +0 -37
  342. package/dist/src/user-context/profile.js +0 -163
  343. package/dist/src/user-context/projection.d.ts +0 -120
  344. package/dist/src/user-context/projection.js +0 -262
  345. package/dist/src/user-context/source-recommendations.d.ts +0 -13
  346. package/dist/src/user-context/source-recommendations.js +0 -85
  347. /package/dist/src/{agent/code-intelligence → user-context/sources}/types.js +0 -0
@@ -0,0 +1,149 @@
1
+ //#region src/user-context/sources/catalog.ts
2
+ const COMMON = [
3
+ {
4
+ id: "local-work-folders",
5
+ category: "files",
6
+ platform: "all",
7
+ displayName: "Work folders",
8
+ description: "Discover likely work folders and analyze only folders you approve.",
9
+ availability: "available",
10
+ permission: "not_requested",
11
+ defaultAccessMode: "continuous",
12
+ supportedAccessModes: ["once", "continuous"],
13
+ recommended: true,
14
+ sensitive: false
15
+ },
16
+ {
17
+ id: "connector-github",
18
+ category: "code_activity",
19
+ platform: "all",
20
+ displayName: "GitHub",
21
+ description: "Repositories, pull requests, issues, and recent code activity from an account you connect.",
22
+ availability: "available",
23
+ permission: "not_requested",
24
+ defaultAccessMode: "continuous",
25
+ supportedAccessModes: ["once", "continuous"],
26
+ recommended: true,
27
+ sensitive: false
28
+ },
29
+ {
30
+ id: "connector-calendar",
31
+ category: "calendar",
32
+ platform: "all",
33
+ displayName: "Connected calendar",
34
+ description: "Calendar commitments and recurring work rhythms from a connected account.",
35
+ availability: "available",
36
+ permission: "not_requested",
37
+ defaultAccessMode: "continuous",
38
+ supportedAccessModes: ["once", "continuous"],
39
+ recommended: true,
40
+ sensitive: true
41
+ },
42
+ {
43
+ id: "connector-drive",
44
+ category: "files",
45
+ platform: "all",
46
+ displayName: "Cloud documents",
47
+ description: "Selected cloud documents and metadata from a connected workspace.",
48
+ availability: "available",
49
+ permission: "not_requested",
50
+ defaultAccessMode: "continuous",
51
+ supportedAccessModes: ["once", "continuous"],
52
+ recommended: false,
53
+ sensitive: true
54
+ },
55
+ {
56
+ id: "connector-mail",
57
+ category: "mail",
58
+ platform: "all",
59
+ displayName: "Mail",
60
+ description: "Work themes and commitments from explicitly connected mail.",
61
+ availability: "available",
62
+ permission: "not_requested",
63
+ defaultAccessMode: "continuous",
64
+ supportedAccessModes: ["once", "continuous"],
65
+ recommended: false,
66
+ sensitive: true
67
+ },
68
+ {
69
+ id: "connector-messages",
70
+ category: "messages",
71
+ platform: "all",
72
+ displayName: "Messages",
73
+ description: "Work themes from explicitly connected collaboration messages.",
74
+ availability: "available",
75
+ permission: "not_requested",
76
+ defaultAccessMode: "continuous",
77
+ supportedAccessModes: ["once", "continuous"],
78
+ recommended: false,
79
+ sensitive: true
80
+ }
81
+ ];
82
+ const PLATFORM = {
83
+ darwin: [
84
+ [
85
+ "apple-notes",
86
+ "notes",
87
+ "Apple Notes",
88
+ "Recent unlocked notes selected through macOS Automation",
89
+ true
90
+ ],
91
+ [
92
+ "apple-calendar",
93
+ "calendar",
94
+ "Apple Calendar",
95
+ "Recent and upcoming calendar events",
96
+ true
97
+ ],
98
+ [
99
+ "apple-reminders",
100
+ "tasks",
101
+ "Apple Reminders",
102
+ "Open and recently completed reminders",
103
+ true
104
+ ]
105
+ ].map(([id, category, displayName, description, sensitive]) => ({
106
+ id: String(id),
107
+ category,
108
+ platform: "darwin",
109
+ displayName: String(displayName),
110
+ description: String(description),
111
+ availability: "available",
112
+ permission: "not_requested",
113
+ defaultAccessMode: "once",
114
+ supportedAccessModes: ["once"],
115
+ recommended: category !== "notes",
116
+ sensitive: Boolean(sensitive)
117
+ })),
118
+ win32: [{
119
+ id: "windows-recent-documents",
120
+ category: "recent_documents",
121
+ platform: "win32",
122
+ displayName: "Recent documents",
123
+ description: "Metadata for files in Windows Recent Items",
124
+ availability: "available",
125
+ permission: "granted",
126
+ defaultAccessMode: "once",
127
+ supportedAccessModes: ["once"],
128
+ recommended: true,
129
+ sensitive: false
130
+ }],
131
+ linux: [{
132
+ id: "linux-recent-documents",
133
+ category: "recent_documents",
134
+ platform: "linux",
135
+ displayName: "Recent documents",
136
+ description: "Metadata from the freedesktop recent-files list",
137
+ availability: "available",
138
+ permission: "granted",
139
+ defaultAccessMode: "once",
140
+ supportedAccessModes: ["once"],
141
+ recommended: true,
142
+ sensitive: false
143
+ }]
144
+ };
145
+ function listUnderstandingSourceDefinitions(platform = process.platform) {
146
+ return [...COMMON, ...PLATFORM[platform] ?? []];
147
+ }
148
+ //#endregion
149
+ export { listUnderstandingSourceDefinitions };
@@ -0,0 +1,3 @@
1
+ export * from './catalog.js';
2
+ export * from './repository.js';
3
+ export * from './types.js';
@@ -0,0 +1,3 @@
1
+ import { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocuses, revokeUnderstandingSourceGrant, setUserFocusStatus, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant, upsertUserFocus } from "./repository.js";
2
+ import { listUnderstandingSourceDefinitions } from "./catalog.js";
3
+ export { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceDefinitions, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocuses, revokeUnderstandingSourceGrant, setUserFocusStatus, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant, upsertUserFocus };
@@ -0,0 +1,40 @@
1
+ import type { UnderstandingSourceGrant, UnderstandingSourceRun, UserFocus } from './types.js';
2
+ export declare function listUnderstandingSourceGrants(options?: {
3
+ includeRevoked?: boolean;
4
+ }): UnderstandingSourceGrant[];
5
+ export declare function getUnderstandingSourceGrant(id: string): UnderstandingSourceGrant | null;
6
+ export declare function upsertUnderstandingSourceGrant(input: Omit<UnderstandingSourceGrant, 'id' | 'status' | 'checkpoint' | 'lastCollectedAt' | 'createdAt' | 'updatedAt'> & {
7
+ checkpoint?: Record<string, unknown>;
8
+ lastCollectedAt?: number;
9
+ nowMs?: number;
10
+ }): UnderstandingSourceGrant;
11
+ export declare function updateUnderstandingSourceGrantCheckpoint(id: string, input: {
12
+ checkpoint?: Record<string, unknown>;
13
+ lastCollectedAt?: number;
14
+ nowMs?: number;
15
+ }): UnderstandingSourceGrant | null;
16
+ export declare function revokeUnderstandingSourceGrant(id: string, nowMs?: number): UnderstandingSourceGrant | null;
17
+ export declare function createUnderstandingSourceRun(input: {
18
+ grantId: string;
19
+ kind: UnderstandingSourceRun['kind'];
20
+ status?: UnderstandingSourceRun['status'];
21
+ cursorBefore?: string;
22
+ metadata?: Record<string, unknown>;
23
+ nowMs?: number;
24
+ }): UnderstandingSourceRun;
25
+ export declare function getUnderstandingSourceRun(id: string): UnderstandingSourceRun | null;
26
+ export declare function listUnderstandingSourceRuns(grantId: string, limit?: number): UnderstandingSourceRun[];
27
+ export declare function updateUnderstandingSourceRun(id: string, patch: {
28
+ status?: UnderstandingSourceRun['status'];
29
+ cursorAfter?: string;
30
+ itemsSeen?: number;
31
+ metadata?: Record<string, unknown>;
32
+ errorMessage?: string;
33
+ completed?: boolean;
34
+ nowMs?: number;
35
+ }): UnderstandingSourceRun | null;
36
+ export declare function upsertUserFocus(input: Omit<UserFocus, 'id' | 'createdAt' | 'updatedAt'> & {
37
+ nowMs?: number;
38
+ }): UserFocus;
39
+ export declare function listUserFocuses(statuses?: UserFocus['status'][]): UserFocus[];
40
+ export declare function setUserFocusStatus(id: string, status: UserFocus['status'], nowMs?: number): UserFocus | null;
@@ -0,0 +1,164 @@
1
+ import { getSqliteDatabase, runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
2
+ import { randomUUID } from "node:crypto";
3
+ //#region src/user-context/sources/repository.ts
4
+ function record(value) {
5
+ try {
6
+ return JSON.parse(value);
7
+ } catch {
8
+ return {};
9
+ }
10
+ }
11
+ function strings(value) {
12
+ try {
13
+ const parsed = JSON.parse(value);
14
+ return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : [];
15
+ } catch {
16
+ return [];
17
+ }
18
+ }
19
+ function grantFromRow(row) {
20
+ return {
21
+ id: row.grant_id,
22
+ sourceKey: row.source_key,
23
+ adapterId: row.adapter_id,
24
+ category: row.category,
25
+ platform: row.platform,
26
+ displayName: row.display_name,
27
+ status: row.status,
28
+ accessMode: row.access_mode,
29
+ retentionPolicy: row.retention_policy,
30
+ processingPolicy: row.processing_policy,
31
+ config: record(row.config_json),
32
+ checkpoint: record(row.checkpoint_json),
33
+ ...row.last_collected_at == null ? {} : { lastCollectedAt: row.last_collected_at },
34
+ createdAt: row.created_at,
35
+ updatedAt: row.updated_at
36
+ };
37
+ }
38
+ function runFromRow(row) {
39
+ return {
40
+ id: row.run_id,
41
+ grantId: row.grant_id,
42
+ kind: row.kind,
43
+ status: row.status,
44
+ ...row.cursor_before ? { cursorBefore: row.cursor_before } : {},
45
+ ...row.cursor_after ? { cursorAfter: row.cursor_after } : {},
46
+ itemsSeen: row.items_seen,
47
+ metadata: record(row.metadata_json),
48
+ ...row.error_message ? { errorMessage: row.error_message } : {},
49
+ startedAt: row.started_at,
50
+ ...row.completed_at == null ? {} : { completedAt: row.completed_at }
51
+ };
52
+ }
53
+ function focusFromRow(row) {
54
+ return {
55
+ id: row.focus_id,
56
+ canonicalKey: row.canonical_key,
57
+ title: row.title,
58
+ summary: row.summary,
59
+ horizon: row.horizon,
60
+ status: row.status,
61
+ confidence: row.confidence,
62
+ ...row.project_id ? { projectId: row.project_id } : {},
63
+ evidenceRefs: strings(row.evidence_refs_json),
64
+ ...row.source_run_id ? { sourceRunId: row.source_run_id } : {},
65
+ createdAt: row.created_at,
66
+ updatedAt: row.updated_at
67
+ };
68
+ }
69
+ function listUnderstandingSourceGrants(options = {}) {
70
+ return getSqliteDatabase().prepare(`SELECT * FROM understanding_source_grants ${options.includeRevoked ? "" : "WHERE status = 'active'"} ORDER BY updated_at DESC`).all().map(grantFromRow);
71
+ }
72
+ function getUnderstandingSourceGrant(id) {
73
+ const row = getSqliteDatabase().prepare("SELECT * FROM understanding_source_grants WHERE grant_id = ?").get(id);
74
+ return row ? grantFromRow(row) : null;
75
+ }
76
+ function upsertUnderstandingSourceGrant(input) {
77
+ const id = randomUUID();
78
+ const now = input.nowMs ?? Date.now();
79
+ const existingRow = getSqliteDatabase().prepare("SELECT * FROM understanding_source_grants WHERE source_key = ?").get(input.sourceKey);
80
+ const existing = existingRow ? grantFromRow(existingRow) : void 0;
81
+ runSqliteWriteTransaction((db) => db.prepare(`
82
+ INSERT INTO understanding_source_grants (
83
+ grant_id, source_key, adapter_id, category, platform, display_name, status, access_mode,
84
+ retention_policy, processing_policy, config_json, checkpoint_json, last_collected_at, created_at, updated_at
85
+ ) VALUES (?, ?, ?, ?, ?, ?, 'active', ?, ?, ?, ?, ?, ?, ?, ?)
86
+ ON CONFLICT(source_key) DO UPDATE SET
87
+ 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,
90
+ config_json = excluded.config_json, checkpoint_json = excluded.checkpoint_json,
91
+ last_collected_at = COALESCE(excluded.last_collected_at, understanding_source_grants.last_collected_at),
92
+ updated_at = excluded.updated_at
93
+ `).run(id, input.sourceKey, input.adapterId, input.category, input.platform, input.displayName, input.accessMode, input.retentionPolicy, input.processingPolicy, JSON.stringify(input.config), JSON.stringify(input.checkpoint ?? existing?.checkpoint ?? {}), input.lastCollectedAt ?? null, now, now));
94
+ return grantFromRow(getSqliteDatabase().prepare("SELECT * FROM understanding_source_grants WHERE source_key = ?").get(input.sourceKey));
95
+ }
96
+ function updateUnderstandingSourceGrantCheckpoint(id, input) {
97
+ const current = getUnderstandingSourceGrant(id);
98
+ if (!current) return null;
99
+ const now = input.nowMs ?? Date.now();
100
+ runSqliteWriteTransaction((db) => db.prepare(`
101
+ UPDATE understanding_source_grants
102
+ SET checkpoint_json = ?, last_collected_at = ?, updated_at = ?
103
+ WHERE grant_id = ?
104
+ `).run(JSON.stringify(input.checkpoint ?? current.checkpoint), input.lastCollectedAt ?? current.lastCollectedAt ?? null, now, id));
105
+ return getUnderstandingSourceGrant(id);
106
+ }
107
+ function revokeUnderstandingSourceGrant(id, nowMs = Date.now()) {
108
+ runSqliteWriteTransaction((db) => db.prepare("UPDATE understanding_source_grants SET status = 'revoked', updated_at = ? WHERE grant_id = ?").run(nowMs, id));
109
+ return getUnderstandingSourceGrant(id);
110
+ }
111
+ function createUnderstandingSourceRun(input) {
112
+ const id = randomUUID();
113
+ const now = input.nowMs ?? Date.now();
114
+ runSqliteWriteTransaction((db) => db.prepare(`
115
+ INSERT INTO understanding_source_runs (
116
+ run_id, grant_id, kind, status, cursor_before, metadata_json, started_at
117
+ ) VALUES (?, ?, ?, ?, ?, ?, ?)
118
+ `).run(id, input.grantId, input.kind, input.status ?? "running", input.cursorBefore ?? null, JSON.stringify(input.metadata ?? {}), now));
119
+ return getUnderstandingSourceRun(id);
120
+ }
121
+ function getUnderstandingSourceRun(id) {
122
+ const row = getSqliteDatabase().prepare("SELECT * FROM understanding_source_runs WHERE run_id = ?").get(id);
123
+ return row ? runFromRow(row) : null;
124
+ }
125
+ function listUnderstandingSourceRuns(grantId, limit = 20) {
126
+ return getSqliteDatabase().prepare("SELECT * FROM understanding_source_runs WHERE grant_id = ? ORDER BY started_at DESC LIMIT ?").all(grantId, Math.max(1, Math.min(100, limit))).map(runFromRow);
127
+ }
128
+ function updateUnderstandingSourceRun(id, patch) {
129
+ const current = getUnderstandingSourceRun(id);
130
+ if (!current) return null;
131
+ const completedAt = patch.completed ? patch.nowMs ?? Date.now() : current.completedAt ?? null;
132
+ runSqliteWriteTransaction((db) => db.prepare(`
133
+ UPDATE understanding_source_runs SET status = ?, cursor_after = ?, items_seen = ?, metadata_json = ?,
134
+ error_message = ?, completed_at = ? WHERE run_id = ?
135
+ `).run(patch.status ?? current.status, patch.cursorAfter ?? current.cursorAfter ?? null, patch.itemsSeen ?? current.itemsSeen, JSON.stringify(patch.metadata ?? current.metadata), patch.errorMessage ?? current.errorMessage ?? null, completedAt, id));
136
+ return getUnderstandingSourceRun(id);
137
+ }
138
+ function upsertUserFocus(input) {
139
+ const id = randomUUID();
140
+ const now = input.nowMs ?? Date.now();
141
+ runSqliteWriteTransaction((db) => db.prepare(`
142
+ 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
146
+ ON CONFLICT(canonical_key) DO UPDATE SET title = excluded.title, summary = excluded.summary,
147
+ horizon = excluded.horizon, status = excluded.status, confidence = excluded.confidence,
148
+ project_id = excluded.project_id, evidence_refs_json = excluded.evidence_refs_json,
149
+ source_run_id = excluded.source_run_id, updated_at = excluded.updated_at
150
+ `).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));
151
+ return focusFromRow(getSqliteDatabase().prepare("SELECT * FROM user_focuses WHERE canonical_key = ?").get(input.canonicalKey));
152
+ }
153
+ function listUserFocuses(statuses) {
154
+ if (!statuses?.length) return getSqliteDatabase().prepare("SELECT * FROM user_focuses ORDER BY updated_at DESC").all().map(focusFromRow);
155
+ const placeholders = statuses.map(() => "?").join(", ");
156
+ return getSqliteDatabase().prepare(`SELECT * FROM user_focuses WHERE status IN (${placeholders}) ORDER BY updated_at DESC`).all(...statuses).map(focusFromRow);
157
+ }
158
+ function setUserFocusStatus(id, status, nowMs = Date.now()) {
159
+ runSqliteWriteTransaction((db) => db.prepare("UPDATE user_focuses SET status = ?, updated_at = ? WHERE focus_id = ?").run(status, nowMs, id));
160
+ const row = getSqliteDatabase().prepare("SELECT * FROM user_focuses WHERE focus_id = ?").get(id);
161
+ return row ? focusFromRow(row) : null;
162
+ }
163
+ //#endregion
164
+ export { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocuses, revokeUnderstandingSourceGrant, setUserFocusStatus, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant, upsertUserFocus };
@@ -0,0 +1,83 @@
1
+ export type UnderstandingSourcePlatform = 'darwin' | 'win32' | 'linux' | 'all';
2
+ export type UnderstandingSourceCategory = 'files' | 'recent_documents' | 'calendar' | 'tasks' | 'notes' | 'mail' | 'messages' | 'code_activity';
3
+ export type UnderstandingSourceAccessMode = 'once' | 'continuous';
4
+ export type UnderstandingSourceRetentionPolicy = 'metadata_only' | 'derived_only' | 'bounded_raw';
5
+ export type UnderstandingSourceProcessingPolicy = 'local_only' | 'remote_allowed';
6
+ export interface UnderstandingSourceDefinition {
7
+ id: string;
8
+ category: UnderstandingSourceCategory;
9
+ platform: UnderstandingSourcePlatform;
10
+ displayName: string;
11
+ description: string;
12
+ availability: 'available' | 'unavailable';
13
+ permission: 'not_requested' | 'granted' | 'denied' | 'unavailable';
14
+ defaultAccessMode: UnderstandingSourceAccessMode;
15
+ supportedAccessModes: UnderstandingSourceAccessMode[];
16
+ recommended: boolean;
17
+ sensitive: boolean;
18
+ }
19
+ export interface UnderstandingSourceGrant {
20
+ id: string;
21
+ sourceKey: string;
22
+ adapterId: string;
23
+ category: UnderstandingSourceCategory;
24
+ platform: UnderstandingSourcePlatform;
25
+ displayName: string;
26
+ status: 'active' | 'revoked';
27
+ accessMode: UnderstandingSourceAccessMode;
28
+ retentionPolicy: UnderstandingSourceRetentionPolicy;
29
+ processingPolicy: UnderstandingSourceProcessingPolicy;
30
+ config: Record<string, unknown>;
31
+ checkpoint: Record<string, unknown>;
32
+ lastCollectedAt?: number;
33
+ createdAt: number;
34
+ updatedAt: number;
35
+ }
36
+ export interface UnderstandingSourceItem {
37
+ id: string;
38
+ sourceId: string;
39
+ type: 'document' | 'calendar_event' | 'task' | 'note' | 'mail' | 'message' | 'code_activity';
40
+ title: string;
41
+ text?: string;
42
+ group?: string;
43
+ occurredAt?: number;
44
+ modifiedAt?: number;
45
+ startsAt?: number;
46
+ endsAt?: number;
47
+ ownerAttribution: 'user' | 'other' | 'shared' | 'unknown';
48
+ sensitivity: 'normal' | 'personal' | 'secret' | 'regulated';
49
+ evidenceRef: string;
50
+ }
51
+ export interface UnderstandingSourceCollectionResult {
52
+ sourceId: string;
53
+ status: 'completed' | 'denied' | 'failed';
54
+ items: UnderstandingSourceItem[];
55
+ error?: string;
56
+ }
57
+ export interface UnderstandingSourceRun {
58
+ id: string;
59
+ grantId: string;
60
+ kind: 'preview' | 'bootstrap' | 'incremental' | 'fingerprint';
61
+ status: 'queued' | 'running' | 'completed' | 'partial' | 'failed' | 'canceled';
62
+ cursorBefore?: string;
63
+ cursorAfter?: string;
64
+ itemsSeen: number;
65
+ metadata: Record<string, unknown>;
66
+ errorMessage?: string;
67
+ startedAt: number;
68
+ completedAt?: number;
69
+ }
70
+ export interface UserFocus {
71
+ id: string;
72
+ canonicalKey: string;
73
+ title: string;
74
+ summary: string;
75
+ horizon: 'current' | 'ongoing' | 'long_term';
76
+ status: 'candidate' | 'active' | 'paused' | 'completed' | 'rejected';
77
+ confidence: number;
78
+ projectId?: string;
79
+ evidenceRefs: string[];
80
+ sourceRunId?: string;
81
+ createdAt: number;
82
+ updatedAt: number;
83
+ }
@@ -1,5 +1,6 @@
1
1
  import type { Config } from '../config/schema.js';
2
- import type { WorkContextSnapshot, WorkDiscoveryCandidate, WorkDiscoveryPersonalContextItem, WorkDiscoveryProfileCandidate, WorkDiscoveryResult, WorkUnderstandingThreadCandidate } from './types.js';
2
+ import type { UnderstandingSourceItem } from '../user-context/sources/types.js';
3
+ import type { WorkContextSnapshot, WorkDiscoveryCandidate, WorkDiscoveryProfileCandidate, WorkDiscoveryResult, WorkUnderstandingThreadCandidate } from './types.js';
3
4
  export declare function analyzeWorkContext(input: {
4
5
  config: Config;
5
6
  snapshot: WorkContextSnapshot;
@@ -9,9 +10,9 @@ export declare function analyzeWorkContext(input: {
9
10
  modelRef: string;
10
11
  result: WorkDiscoveryResult;
11
12
  }>;
12
- export declare function analyzePersonalContext(input: {
13
+ export declare function analyzeUnderstandingSources(input: {
13
14
  config: Config;
14
- items: WorkDiscoveryPersonalContextItem[];
15
+ items: UnderstandingSourceItem[];
15
16
  workContext?: Pick<WorkDiscoveryResult, 'projectSummary' | 'currentState' | 'uncertainties' | 'workThreads'>;
16
17
  signal?: AbortSignal;
17
18
  }): Promise<{
@@ -6,7 +6,7 @@ import { randomUUID } from "node:crypto";
6
6
  init_schema();
7
7
  init_providers();
8
8
  const MAX_MODEL_CONTEXT_CHARS = 12e4;
9
- const MAX_PERSONAL_CONTEXT_CHARS = 1e5;
9
+ const MAX_UNDERSTANDING_SOURCE_CHARS = 1e5;
10
10
  const WORK_ANALYSIS_MAX_TOKENS = 6e3;
11
11
  function extractText(content) {
12
12
  if (typeof content === "string") return content;
@@ -234,43 +234,48 @@ async function analyzeWorkContext(input) {
234
234
  }
235
235
  };
236
236
  }
237
- async function analyzePersonalContext(input) {
237
+ async function analyzeUnderstandingSources(input) {
238
238
  const modelRef = getAgentDefaultModelRef(input.config);
239
239
  if (!modelRef) throw new Error("No default model configured");
240
- let remaining = MAX_PERSONAL_CONTEXT_CHARS;
241
- const items = input.items.slice(0, 150).flatMap((item, index) => {
240
+ let remaining = MAX_UNDERSTANDING_SOURCE_CHARS;
241
+ const items = input.items.filter((item) => item.sensitivity !== "secret" && item.sensitivity !== "regulated").slice(0, 150).flatMap((item) => {
242
242
  if (remaining <= 0) return [];
243
- const content = item.content.slice(0, remaining);
244
- remaining -= content.length;
243
+ const text = (item.text ?? "").slice(0, remaining);
244
+ remaining -= text.length;
245
245
  return [{
246
- ref: `${item.source}:${index + 1}`,
247
- source: item.source,
246
+ ref: item.evidenceRef,
247
+ source: item.sourceId,
248
+ type: item.type,
248
249
  title: item.title,
249
250
  group: item.group,
250
- createdAt: item.createdAt,
251
+ occurredAt: item.occurredAt,
251
252
  modifiedAt: item.modifiedAt,
252
253
  startsAt: item.startsAt,
253
254
  endsAt: item.endsAt,
254
- content
255
+ ownerAttribution: item.ownerAttribution,
256
+ sensitivity: item.sensitivity,
257
+ text
255
258
  }];
256
259
  });
257
- if (!items.some((item) => item.title.trim() || item.content.trim())) return {
260
+ if (!items.some((item) => item.title.trim() || item.text.trim())) return {
258
261
  modelRef,
259
262
  profileCandidates: [],
260
263
  workThreadCandidates: []
261
264
  };
262
265
  const prompt = [
263
- "Analyze the bounded personal work context that the user explicitly chose to connect from Apple Notes, Calendar, and Reminders.",
266
+ "Analyze bounded context from sources the user explicitly chose to connect.",
264
267
  "Return only one JSON object with profileCandidates and workThreads.",
265
268
  "profileCandidates contains at most 6 stable, useful work-related facts.",
266
269
  "Each item has category (role, focus, technology, workflow, or preference), statement, confidence, and evidence.",
267
270
  "workThreads contains at most 3 evidence-backed current, ongoing, or long-term work streams.",
268
271
  "Each work thread has topicKey, title, summary, status, horizon, confidence, and evidenceRefs.",
269
- "evidenceRefs must contain only the supplied source:index refs. Do not create a thread without direct support.",
272
+ "evidenceRefs must contain only supplied refs. Do not create a thread without direct support.",
273
+ "Synthesize across source types. Repeated independent signals are stronger than a single item.",
274
+ "Treat ownerAttribution other/shared/unknown conservatively: it may describe someone else and must not become a user fact without user-owned corroboration.",
270
275
  "Prefer recurring work themes and durable preferences. Do not turn one-off errands or stale notes into user facts.",
271
276
  "Do not infer sensitive identity, health, finances, political views, relationships, passwords, credentials, or private contact details.",
272
277
  "Evidence must be a short paraphrase and must not quote private note content verbatim.",
273
- "Calendar and reminder titles may establish commitments and timing, but must not be treated as stable preferences without repeated evidence.",
278
+ "Calendar events and tasks may establish commitments and timing, but must not be treated as stable preferences without repeated evidence.",
274
279
  "When a work-directory summary is supplied, reconcile it with the personal sources: identify corroboration, conflicts, and whether an apparent focus is current or merely stale.",
275
280
  "Do not repeat the directory summary as a personal fact unless at least one supplied personal source supports it.",
276
281
  "Use Simplified Chinese when the supplied items are mainly Chinese; otherwise use English.",
@@ -288,7 +293,7 @@ async function analyzePersonalContext(input) {
288
293
  });
289
294
  const raw = extractText(response.content);
290
295
  const parsed = parseJson(raw);
291
- if (!parsed) throw invalidJsonError("Personal context analysis", response, raw);
296
+ if (!parsed) throw invalidJsonError("Understanding source analysis", response, raw);
292
297
  const profileCandidates = Array.isArray(parsed.profileCandidates) ? parsed.profileCandidates.map(validateProfileCandidate).filter((value) => Boolean(value)).slice(0, 6) : [];
293
298
  const allowedRefs = new Set(items.map((item) => item.ref));
294
299
  return {
@@ -317,4 +322,4 @@ function workDiscoveryResultMarkdown(result) {
317
322
  return lines.join("\n");
318
323
  }
319
324
  //#endregion
320
- export { analyzePersonalContext, analyzeWorkContext, workDiscoveryResultMarkdown };
325
+ export { analyzeUnderstandingSources, analyzeWorkContext, workDiscoveryResultMarkdown };
@@ -1,55 +1,57 @@
1
- import { requireXopcDatabase } from "../storage/sqlite/connection.js";
2
- import { runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
1
+ import { createUnderstandingSourceRun, listUnderstandingSourceGrants, listUnderstandingSourceRuns, updateUnderstandingSourceRun } from "../user-context/sources/repository.js";
3
2
  import { workDiscoveryFingerprintsEqual } from "./incremental.js";
4
- import { randomUUID } from "node:crypto";
3
+ import { getWorkDiscoveryRun } from "./repository.js";
5
4
  //#region src/work-discovery/incremental-repository.ts
6
- function parseFingerprint(value) {
7
- if (!value) return void 0;
8
- try {
9
- return JSON.parse(value);
10
- } catch {
11
- return;
12
- }
13
- }
14
- function fromRow(row) {
5
+ function refreshFromRun(run) {
6
+ const previousFingerprint = run.metadata.previousFingerprint;
15
7
  return {
16
- id: row.refresh_id,
17
- sourceId: row.source_id,
18
- changed: row.changed === 1,
19
- ...parseFingerprint(row.previous_fingerprint_json) ? { previousFingerprint: parseFingerprint(row.previous_fingerprint_json) } : {},
20
- currentFingerprint: parseFingerprint(row.current_fingerprint_json),
21
- status: row.status,
22
- ...row.discovery_run_id ? { discoveryRunId: row.discovery_run_id } : {},
23
- checkedAt: row.checked_at
8
+ id: run.id,
9
+ sourceId: run.grantId,
10
+ changed: run.metadata.changed === true,
11
+ ...previousFingerprint ? { previousFingerprint } : {},
12
+ currentFingerprint: run.metadata.currentFingerprint,
13
+ status: run.status === "running" ? "queued" : run.status,
14
+ ...typeof run.metadata.discoveryRunId === "string" ? { discoveryRunId: run.metadata.discoveryRunId } : {},
15
+ checkedAt: run.startedAt
24
16
  };
25
17
  }
26
18
  function recordWorkDiscoverySourceRefresh(input) {
27
- const id = randomUUID();
28
- runSqliteWriteTransaction((db) => {
29
- db.prepare(`INSERT INTO work_discovery_source_refreshes (
30
- refresh_id, source_id, discovery_run_id, changed, previous_fingerprint_json,
31
- current_fingerprint_json, status, checked_at
32
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(id, input.sourceId, input.discoveryRunId ?? null, input.changed ? 1 : 0, input.previousFingerprint ? JSON.stringify(input.previousFingerprint) : null, JSON.stringify(input.currentFingerprint), input.status ?? "checked", input.checkedAt ?? Date.now());
33
- });
34
- const { db } = requireXopcDatabase();
35
- return fromRow(db.prepare("SELECT * FROM work_discovery_source_refreshes WHERE refresh_id = ?").get(id));
19
+ const status = input.status === "queued" ? "running" : input.status === "failed" ? "failed" : "completed";
20
+ return refreshFromRun(createUnderstandingSourceRun({
21
+ grantId: input.sourceId,
22
+ kind: "fingerprint",
23
+ status,
24
+ metadata: {
25
+ changed: input.changed,
26
+ ...input.previousFingerprint ? { previousFingerprint: input.previousFingerprint } : {},
27
+ currentFingerprint: input.currentFingerprint,
28
+ ...input.discoveryRunId ? { discoveryRunId: input.discoveryRunId } : {}
29
+ },
30
+ ...input.checkedAt != null ? { nowMs: input.checkedAt } : {}
31
+ }));
36
32
  }
37
33
  function listWorkDiscoverySourceRefreshes(sourceId, limit = 20) {
38
- const { db } = requireXopcDatabase();
39
- return db.prepare("SELECT * FROM work_discovery_source_refreshes WHERE source_id = ? ORDER BY checked_at DESC LIMIT ?").all(sourceId, Math.max(1, Math.min(100, limit))).map(fromRow);
34
+ return listUnderstandingSourceRuns(sourceId, limit).filter((run) => run.kind === "fingerprint").map(refreshFromRun);
40
35
  }
41
36
  function findActiveWorkDiscoverySourceRefresh(sourceId, fingerprint) {
42
- const { db } = requireXopcDatabase();
43
- return db.prepare(`SELECT refresh.* FROM work_discovery_source_refreshes refresh
44
- JOIN work_discovery_runs run ON run.id = refresh.discovery_run_id
45
- WHERE refresh.source_id = ? AND refresh.status = 'queued'
46
- AND run.status IN ('queued', 'probing', 'analyzing')
47
- ORDER BY refresh.checked_at DESC`).all(sourceId).map(fromRow).find((refresh) => workDiscoveryFingerprintsEqual(refresh.currentFingerprint, fingerprint)) ?? null;
37
+ return listWorkDiscoverySourceRefreshes(sourceId, 100).find((refresh) => {
38
+ if (refresh.status !== "queued" || !refresh.discoveryRunId) return false;
39
+ const run = getWorkDiscoveryRun(refresh.discoveryRunId);
40
+ return Boolean(run && [
41
+ "queued",
42
+ "probing",
43
+ "analyzing"
44
+ ].includes(run.status) && workDiscoveryFingerprintsEqual(refresh.currentFingerprint, fingerprint));
45
+ }) ?? null;
48
46
  }
49
47
  function updateWorkDiscoverySourceRefreshForRun(runId, status) {
50
- runSqliteWriteTransaction((db) => {
51
- db.prepare("UPDATE work_discovery_source_refreshes SET status = ? WHERE discovery_run_id = ?").run(status, runId);
52
- });
48
+ for (const source of listUnderstandingSourceGrants()) {
49
+ const refresh = listUnderstandingSourceRuns(source.id, 100).find((item) => item.kind === "fingerprint" && item.metadata.discoveryRunId === runId);
50
+ if (refresh) updateUnderstandingSourceRun(refresh.id, {
51
+ status,
52
+ completed: true
53
+ });
54
+ }
53
55
  }
54
56
  //#endregion
55
57
  export { findActiveWorkDiscoverySourceRefresh, listWorkDiscoverySourceRefreshes, recordWorkDiscoverySourceRefresh, updateWorkDiscoverySourceRefreshForRun };