@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
@@ -249,13 +249,13 @@ export declare const CustomModelSchema: z.ZodObject<{
249
249
  api: z.ZodOptional<z.ZodEnum<{
250
250
  "openai-completions": "openai-completions";
251
251
  "openai-responses": "openai-responses";
252
- "anthropic-messages": "anthropic-messages";
253
- "google-generative-ai": "google-generative-ai";
254
252
  "azure-openai-responses": "azure-openai-responses";
255
- "bedrock-converse-stream": "bedrock-converse-stream";
256
253
  "openai-codex-responses": "openai-codex-responses";
257
- "google-gemini-cli": "google-gemini-cli";
254
+ "anthropic-messages": "anthropic-messages";
255
+ "bedrock-converse-stream": "bedrock-converse-stream";
256
+ "google-generative-ai": "google-generative-ai";
258
257
  "google-vertex": "google-vertex";
258
+ "google-gemini-cli": "google-gemini-cli";
259
259
  }>>;
260
260
  reasoning: z.ZodOptional<z.ZodBoolean>;
261
261
  input: z.ZodOptional<z.ZodArray<z.ZodEnum<{
@@ -351,13 +351,13 @@ export declare const ProviderConfigSchema: z.ZodObject<{
351
351
  api: z.ZodOptional<z.ZodEnum<{
352
352
  "openai-completions": "openai-completions";
353
353
  "openai-responses": "openai-responses";
354
- "anthropic-messages": "anthropic-messages";
355
- "google-generative-ai": "google-generative-ai";
356
354
  "azure-openai-responses": "azure-openai-responses";
357
- "bedrock-converse-stream": "bedrock-converse-stream";
358
355
  "openai-codex-responses": "openai-codex-responses";
359
- "google-gemini-cli": "google-gemini-cli";
356
+ "anthropic-messages": "anthropic-messages";
357
+ "bedrock-converse-stream": "bedrock-converse-stream";
358
+ "google-generative-ai": "google-generative-ai";
360
359
  "google-vertex": "google-vertex";
360
+ "google-gemini-cli": "google-gemini-cli";
361
361
  }>>;
362
362
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
363
363
  authHeader: z.ZodOptional<z.ZodBoolean>;
@@ -367,13 +367,13 @@ export declare const ProviderConfigSchema: z.ZodObject<{
367
367
  api: z.ZodOptional<z.ZodEnum<{
368
368
  "openai-completions": "openai-completions";
369
369
  "openai-responses": "openai-responses";
370
- "anthropic-messages": "anthropic-messages";
371
- "google-generative-ai": "google-generative-ai";
372
370
  "azure-openai-responses": "azure-openai-responses";
373
- "bedrock-converse-stream": "bedrock-converse-stream";
374
371
  "openai-codex-responses": "openai-codex-responses";
375
- "google-gemini-cli": "google-gemini-cli";
372
+ "anthropic-messages": "anthropic-messages";
373
+ "bedrock-converse-stream": "bedrock-converse-stream";
374
+ "google-generative-ai": "google-generative-ai";
376
375
  "google-vertex": "google-vertex";
376
+ "google-gemini-cli": "google-gemini-cli";
377
377
  }>>;
378
378
  reasoning: z.ZodOptional<z.ZodBoolean>;
379
379
  input: z.ZodOptional<z.ZodArray<z.ZodEnum<{
@@ -550,13 +550,13 @@ export declare const ModelsJsonSchema: z.ZodObject<{
550
550
  api: z.ZodOptional<z.ZodEnum<{
551
551
  "openai-completions": "openai-completions";
552
552
  "openai-responses": "openai-responses";
553
- "anthropic-messages": "anthropic-messages";
554
- "google-generative-ai": "google-generative-ai";
555
553
  "azure-openai-responses": "azure-openai-responses";
556
- "bedrock-converse-stream": "bedrock-converse-stream";
557
554
  "openai-codex-responses": "openai-codex-responses";
558
- "google-gemini-cli": "google-gemini-cli";
555
+ "anthropic-messages": "anthropic-messages";
556
+ "bedrock-converse-stream": "bedrock-converse-stream";
557
+ "google-generative-ai": "google-generative-ai";
559
558
  "google-vertex": "google-vertex";
559
+ "google-gemini-cli": "google-gemini-cli";
560
560
  }>>;
561
561
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
562
562
  authHeader: z.ZodOptional<z.ZodBoolean>;
@@ -566,13 +566,13 @@ export declare const ModelsJsonSchema: z.ZodObject<{
566
566
  api: z.ZodOptional<z.ZodEnum<{
567
567
  "openai-completions": "openai-completions";
568
568
  "openai-responses": "openai-responses";
569
- "anthropic-messages": "anthropic-messages";
570
- "google-generative-ai": "google-generative-ai";
571
569
  "azure-openai-responses": "azure-openai-responses";
572
- "bedrock-converse-stream": "bedrock-converse-stream";
573
570
  "openai-codex-responses": "openai-codex-responses";
574
- "google-gemini-cli": "google-gemini-cli";
571
+ "anthropic-messages": "anthropic-messages";
572
+ "bedrock-converse-stream": "bedrock-converse-stream";
573
+ "google-generative-ai": "google-generative-ai";
575
574
  "google-vertex": "google-vertex";
575
+ "google-gemini-cli": "google-gemini-cli";
576
576
  }>>;
577
577
  reasoning: z.ZodOptional<z.ZodBoolean>;
578
578
  input: z.ZodOptional<z.ZodArray<z.ZodEnum<{
@@ -31,6 +31,9 @@ function asRecord(value) {
31
31
  function boundedPersonValue(value, maxLength = 320) {
32
32
  return typeof value === "string" ? value.trim().slice(0, maxLength) : "";
33
33
  }
34
+ function normalizedEmail(value) {
35
+ return /<([^<>\s]+@[^<>\s]+)>/.exec(value)?.[1]?.toLowerCase() ?? value.toLowerCase();
36
+ }
34
37
  function personEntities(record) {
35
38
  if (!record) return [];
36
39
  const extractPerson = (value, role) => {
@@ -39,7 +42,7 @@ function personEntities(record) {
39
42
  if (!normalized) return [];
40
43
  return normalized.includes("@") ? [{
41
44
  role,
42
- email: normalized
45
+ email: normalizedEmail(normalized)
43
46
  }] : [{
44
47
  role,
45
48
  name: normalized
@@ -91,6 +94,20 @@ function peopleSignals(entities) {
91
94
  function connectionIdentities(identity) {
92
95
  return [...new Set(Object.values(identity).filter((value) => typeof value === "string").map((value) => value.trim().toLowerCase()).filter(Boolean))];
93
96
  }
97
+ function hasOwnerAttribution(toolkit, people, ownerIdentities) {
98
+ const attributableRoles = toolkit === "gmail" ? new Set(["sender", "from"]) : toolkit === "googlecalendar" ? new Set(["organizer"]) : new Set([
99
+ "author",
100
+ "user",
101
+ "username",
102
+ "owner",
103
+ "owners"
104
+ ]);
105
+ return people.filter((person) => attributableRoles.has(person.role)).flatMap((person) => [
106
+ person.email,
107
+ person.username,
108
+ person.name
109
+ ]).filter((value) => Boolean(value)).some((value) => ownerIdentities.includes(value.trim().toLowerCase()));
110
+ }
94
111
  function resultPayload(value) {
95
112
  const root = asRecord(value) ?? {};
96
113
  return asRecord(root.data) ?? root;
@@ -119,10 +136,10 @@ function resultToSourceItems(input) {
119
136
  const record = entity.value;
120
137
  const people = personEntities(record);
121
138
  const ownerIdentities = connectionIdentities(input.connectionIdentity);
122
- const observedIdentities = peopleSignals(people).map((value) => value.toLowerCase());
123
- const actorAttributed = entity.metadata.actorAttributed === true || input.toolkit === "gmail" || input.toolkit === "googlecalendar" || ["github", "googledrive"].includes(input.toolkit) && observedIdentities.some((value) => ownerIdentities.includes(value));
139
+ const actorAttributed = entity.metadata.actorAttributed === true || hasOwnerAttribution(input.toolkit, people, ownerIdentities);
124
140
  const serialized = JSON.stringify(sanitizeConnectedSourceValue(entity.value), null, 2);
125
- const normalizedText = serialized.length > 8e3 ? `${serialized.slice(0, 8e3)}\n…` : serialized;
141
+ const contentChars = typeof entity.value.content === "string" ? 24e3 : 8e3;
142
+ const normalizedText = serialized.length > contentChars ? `${serialized.slice(0, contentChars)}\n…` : serialized;
126
143
  const contentHash = createHash("sha256").update(serialized).digest("hex");
127
144
  return {
128
145
  sourceInstanceId: input.sourceInstanceId,
@@ -32,11 +32,57 @@ function rows(data, ...keys) {
32
32
  function compact(value) {
33
33
  return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0 && item !== null && item !== ""));
34
34
  }
35
+ const MAX_EMAIL_CONTENT_CHARS = 24e3;
36
+ function gmailHeaders(message) {
37
+ const messagePayload = record(message.payload);
38
+ const values = Array.isArray(messagePayload?.headers) ? messagePayload.headers : [];
39
+ const headers = /* @__PURE__ */ new Map();
40
+ for (const value of values) {
41
+ const header = record(value);
42
+ const name = text(header, "name")?.toLowerCase();
43
+ const headerValue = text(header, "value");
44
+ if (name && headerValue) headers.set(name, headerValue);
45
+ }
46
+ return headers;
47
+ }
48
+ function decodeGmailBody(value) {
49
+ if (typeof value !== "string" || !value.trim() || value.length > 256e3) return void 0;
50
+ try {
51
+ return Buffer.from(value.replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf8").trim() || void 0;
52
+ } catch {
53
+ return;
54
+ }
55
+ }
56
+ function stripHtml(value) {
57
+ return value.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, " ").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, " ").replace(/<[^>]+>/g, " ").replace(/&nbsp;/gi, " ").replace(/&amp;/gi, "&").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/\s+/g, " ").trim();
58
+ }
59
+ function gmailContent(message) {
60
+ const direct = text(message, "plainText", "plain_text", "text", "content", "body");
61
+ if (direct) return direct.slice(0, MAX_EMAIL_CONTENT_CHARS);
62
+ const plain = [];
63
+ const html = [];
64
+ const visit = (value, depth = 0) => {
65
+ if (depth > 10 || plain.join("").length >= MAX_EMAIL_CONTENT_CHARS) return;
66
+ const part = record(value);
67
+ if (!part) return;
68
+ const mimeType = text(part, "mimeType", "mime_type")?.toLowerCase();
69
+ const decoded = decodeGmailBody(record(part.body)?.data);
70
+ if (decoded) {
71
+ if (mimeType === "text/html") html.push(stripHtml(decoded));
72
+ else if (!mimeType || mimeType === "text/plain") plain.push(decoded);
73
+ }
74
+ if (Array.isArray(part.parts)) for (const nested of part.parts) visit(nested, depth + 1);
75
+ };
76
+ visit(message.payload);
77
+ const content = (plain.length ? plain : html).filter(Boolean).join("\n\n").trim();
78
+ return content ? content.slice(0, MAX_EMAIL_CONTENT_CHARS) : void 0;
79
+ }
35
80
  function normalizeGmail(result) {
36
81
  return rows(payload(result), "messages").flatMap((message) => {
37
82
  const externalId = text(message, "id", "messageId", "message_id");
38
83
  if (!externalId) return [];
39
84
  const occurredAt = time(message.internalDate ?? message.internal_date ?? message.date ?? message.timestamp);
85
+ const headers = gmailHeaders(message);
40
86
  return [{
41
87
  externalId,
42
88
  itemType: "email",
@@ -45,12 +91,13 @@ function normalizeGmail(result) {
45
91
  value: compact({
46
92
  id: externalId,
47
93
  threadId: text(message, "threadId", "thread_id"),
48
- subject: text(message, "subject"),
49
- sender: message.sender ?? message.from,
50
- recipients: message.recipients ?? message.to,
94
+ subject: text(message, "subject") ?? headers.get("subject"),
95
+ sender: message.sender ?? message.from ?? headers.get("from"),
96
+ recipients: message.recipients ?? message.to ?? headers.get("to"),
51
97
  date: occurredAt,
52
98
  labels: message.labelIds ?? message.label_ids ?? message.labels,
53
- snippet: text(message, "snippet", "preview")
99
+ snippet: text(message, "snippet", "preview"),
100
+ content: gmailContent(message)
54
101
  }),
55
102
  metadata: {
56
103
  observationKind: "message",
@@ -0,0 +1,20 @@
1
+ import type { MemoryManager } from '../agent/memory/manager.js';
2
+ import type { Config } from '../config/schema.js';
3
+ import type { KnowledgeSourceItem } from '../knowledge/types.js';
4
+ import type { UnderstandingSourceItem } from '../user-context/sources/types.js';
5
+ import { analyzeUnderstandingSources } from '../work-discovery/analyzer.js';
6
+ export declare function connectedItemsForUnderstanding(items: KnowledgeSourceItem[]): UnderstandingSourceItem[];
7
+ export declare function deriveConnectedSourceUnderstanding(input: {
8
+ config: Config;
9
+ agentId: string;
10
+ sourceInstanceId: string;
11
+ sourceRunId: string;
12
+ processingPolicy: 'local_only' | 'remote_allowed';
13
+ memoryManager: MemoryManager;
14
+ analyze?: typeof analyzeUnderstandingSources;
15
+ }): Promise<{
16
+ created: number;
17
+ focusCount: number;
18
+ status: 'completed' | 'partial' | 'failed';
19
+ error?: string;
20
+ }>;
@@ -0,0 +1,180 @@
1
+ import { finishContextExtractionRun } from "../storage/sqlite/context-extraction-repository.js";
2
+ import { listKnowledgeSourceItems } from "../storage/sqlite/knowledge-repository.js";
3
+ import "../storage/sqlite/index.js";
4
+ import { upsertUserFocus } from "../user-context/sources/repository.js";
5
+ import { claimRegisteredExtraction } from "../user-context/extraction/registry.js";
6
+ import { allowsRemoteSourceProcessing } from "../user-context/sources/processing-policy.js";
7
+ import { analyzeUnderstandingSources } from "../work-discovery/analyzer.js";
8
+ import { createHash } from "node:crypto";
9
+ //#region src/connectors/connected-source-understanding.ts
10
+ const MAX_CONNECTED_ITEMS = 150;
11
+ function normalizedValue(item) {
12
+ if (!item.normalizedText) return {};
13
+ try {
14
+ const value = JSON.parse(item.normalizedText);
15
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
16
+ } catch {
17
+ return {};
18
+ }
19
+ }
20
+ function text(value) {
21
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
22
+ }
23
+ function itemType(itemType) {
24
+ if (itemType === "email") return "mail";
25
+ if (itemType === "calendar_event") return "calendar_event";
26
+ if (itemType === "external_task") return "task";
27
+ if (itemType === "development_activity" || itemType === "repository") return "code_activity";
28
+ return "document";
29
+ }
30
+ function timestamp(value) {
31
+ if (!value) return void 0;
32
+ const parsed = Date.parse(value);
33
+ return Number.isFinite(parsed) ? parsed : void 0;
34
+ }
35
+ function contentPriority(item) {
36
+ const value = normalizedValue(item);
37
+ if (item.itemType === "connected_content") return 3;
38
+ if (text(value.content)) return 2;
39
+ return 1;
40
+ }
41
+ function connectedItemsForUnderstanding(items) {
42
+ return [...items].sort((left, right) => contentPriority(right) - contentPriority(left)).slice(0, MAX_CONNECTED_ITEMS).flatMap((item) => {
43
+ const value = normalizedValue(item);
44
+ const title = text(value.title) ?? text(value.subject) ?? text(value.fullName) ?? text(value.repository) ?? `${text(item.metadata.toolkit) ?? "Connected source"} ${item.itemType}`;
45
+ const normalizedText = item.normalizedText?.trim();
46
+ if (!title && !normalizedText) return [];
47
+ return [{
48
+ id: item.id,
49
+ sourceId: "connected-work",
50
+ type: itemType(item.itemType),
51
+ title,
52
+ ...normalizedText ? { text: normalizedText.slice(0, 24e3) } : {},
53
+ ...text(item.metadata.toolkit) ? { group: text(item.metadata.toolkit) } : {},
54
+ ...timestamp(item.occurredAt) ? { occurredAt: timestamp(item.occurredAt) } : {},
55
+ ...timestamp(item.sourceUpdatedAt) ? { modifiedAt: timestamp(item.sourceUpdatedAt) } : {},
56
+ ownerAttribution: item.metadata.actorAttributed === true ? "user" : "shared",
57
+ sensitivity: item.sensitivity,
58
+ evidenceRef: `knowledge-source://${item.id}`
59
+ }];
60
+ });
61
+ }
62
+ function understandingKind(category) {
63
+ if (category === "preference") return "preference";
64
+ if (category === "workflow") return "routine";
65
+ if (category === "focus") return "current_state";
66
+ return "project_context";
67
+ }
68
+ function understandingCandidate(candidate) {
69
+ const normalized = candidate.statement.toLocaleLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
70
+ return {
71
+ kind: understandingKind(candidate.category),
72
+ content: candidate.statement,
73
+ canonicalKey: `connected-semantic:${candidate.category}:${createHash("sha256").update(normalized).digest("hex").slice(0, 20)}`,
74
+ confidence: candidate.confidence === "high" ? .9 : candidate.confidence === "medium" ? .72 : .55,
75
+ importance: candidate.category === "focus" ? .8 : .68,
76
+ explicitness: "inferred",
77
+ durability: candidate.category === "focus" ? "ephemeral" : candidate.category === "workflow" ? "recurring" : "durable",
78
+ sensitivity: "personal",
79
+ disclosurePolicy: "referenceable"
80
+ };
81
+ }
82
+ function hasLongVerbatimOverlap(value, sourceTexts, minimumLength = 32) {
83
+ const normalized = value.replace(/\s+/g, " ").trim();
84
+ if (normalized.length < minimumLength) return false;
85
+ return sourceTexts.some((source) => source.replace(/\s+/g, " ").includes(normalized));
86
+ }
87
+ async function deriveConnectedSourceUnderstanding(input) {
88
+ const knowledgeItems = listKnowledgeSourceItems({
89
+ agentId: input.agentId,
90
+ sourceInstanceId: input.sourceInstanceId,
91
+ includeDeleted: false,
92
+ limit: MAX_CONNECTED_ITEMS
93
+ });
94
+ const items = connectedItemsForUnderstanding(knowledgeItems);
95
+ if (!items.length) return {
96
+ created: 0,
97
+ focusCount: 0,
98
+ status: "completed"
99
+ };
100
+ const extraction = claimRegisteredExtraction({
101
+ extractorId: "connector-semantic",
102
+ sourceRef: `understanding-source-run:${input.sourceRunId}`,
103
+ contentForHash: knowledgeItems.map((item) => `${item.id}:${item.sourceUpdatedAt ?? ""}`).join("\n"),
104
+ processingPolicy: input.processingPolicy,
105
+ destination: "remote_model"
106
+ });
107
+ if (!allowsRemoteSourceProcessing([input.processingPolicy]) || !extraction.shouldExecute) return {
108
+ created: 0,
109
+ focusCount: 0,
110
+ status: "completed"
111
+ };
112
+ try {
113
+ const analysis = await (input.analyze ?? analyzeUnderstandingSources)({
114
+ config: input.config,
115
+ items
116
+ });
117
+ const rawTexts = items.flatMap((item) => item.text ? [item.text] : []);
118
+ const profileCandidates = analysis.profileCandidates.filter((candidate) => !hasLongVerbatimOverlap(candidate.statement, rawTexts));
119
+ const sourceItemIds = [...new Set([...profileCandidates.flatMap((candidate) => candidate.evidenceRefs ?? []), ...analysis.workThreadCandidates.flatMap((candidate) => candidate.evidenceRefs)].map((ref) => ref.startsWith("knowledge-source://") ? ref.slice(19) : ""))].filter(Boolean).slice(0, 20);
120
+ const reviewed = profileCandidates.length ? await input.memoryManager.applyUnderstandingCandidates(profileCandidates.map(understandingCandidate), {
121
+ agentId: input.agentId,
122
+ sourceItemIds,
123
+ sourceText: "Bounded semantic synthesis from explicitly connected work sources.",
124
+ source: {
125
+ provider: "connected-sources",
126
+ sourceInstanceId: input.sourceInstanceId
127
+ },
128
+ reviewSource: "background",
129
+ extractionRunId: extraction.run.id
130
+ }) : {
131
+ created: 0,
132
+ writeOutputs: []
133
+ };
134
+ const focuses = analysis.workThreadCandidates.filter((candidate) => !hasLongVerbatimOverlap(candidate.title, rawTexts) && !hasLongVerbatimOverlap(candidate.summary, rawTexts)).map((candidate) => upsertUserFocus({
135
+ canonicalKey: `connected-focus:${candidate.topicKey}`,
136
+ title: candidate.title,
137
+ summary: candidate.summary,
138
+ horizon: candidate.horizon,
139
+ status: "candidate",
140
+ confidence: candidate.confidence === "high" ? .9 : candidate.confidence === "medium" ? .72 : .55,
141
+ evidenceRefs: candidate.evidenceRefs,
142
+ sourceRunId: input.sourceRunId
143
+ }));
144
+ finishContextExtractionRun({
145
+ runId: extraction.run.id,
146
+ status: "completed",
147
+ outputs: [...(reviewed.writeOutputs ?? []).map((output) => ({
148
+ candidateKey: output.candidateKey,
149
+ ...output.objectId ? {
150
+ objectType: "understanding",
151
+ objectId: output.objectId
152
+ } : {},
153
+ ...output.versionId ? { versionId: output.versionId } : {},
154
+ outcome: output.outcome
155
+ })), ...focuses.map((focus) => ({
156
+ candidateKey: focus.canonicalKey,
157
+ objectType: "focus",
158
+ objectId: focus.id,
159
+ versionId: focus.versionId,
160
+ outcome: "created"
161
+ }))]
162
+ });
163
+ const sourceStatus = analysis.sourceStatuses.find((item) => item.sourceId === "connected-work");
164
+ return {
165
+ created: reviewed.created,
166
+ focusCount: focuses.length,
167
+ status: sourceStatus?.status ?? "failed",
168
+ ...sourceStatus?.error ? { error: sourceStatus.error } : {}
169
+ };
170
+ } catch (error) {
171
+ finishContextExtractionRun({
172
+ runId: extraction.run.id,
173
+ status: "failed",
174
+ errorCode: "extractor_failed"
175
+ });
176
+ throw error;
177
+ }
178
+ }
179
+ //#endregion
180
+ export { connectedItemsForUnderstanding, deriveConnectedSourceUnderstanding };
@@ -19,6 +19,7 @@ export type ConnectedContentReadResult = {
19
19
  };
20
20
  export declare function listConnectedContentCandidates(options: {
21
21
  agentId: string;
22
+ sourceInstanceId?: string;
22
23
  limit?: number;
23
24
  }): ConnectedContentCandidate[];
24
25
  export declare function readConnectedContent(input: {
@@ -43,13 +43,16 @@ function candidateFor(item) {
43
43
  const value = normalizedRecord(item);
44
44
  const title = text(value.title) ?? text(value.subject);
45
45
  if (!title) return void 0;
46
- if (toolkit === "gmail" && item.itemType === "email") return {
47
- sourceItemId: item.id,
48
- sourceInstanceId: item.sourceInstanceId,
49
- toolkit,
50
- title,
51
- occurredAt: item.occurredAt
52
- };
46
+ if (toolkit === "gmail" && item.itemType === "email") {
47
+ if (text(value.content)) return void 0;
48
+ return {
49
+ sourceItemId: item.id,
50
+ sourceInstanceId: item.sourceInstanceId,
51
+ toolkit,
52
+ title,
53
+ occurredAt: item.occurredAt
54
+ };
55
+ }
53
56
  const mimeType = text(item.metadata.mimeType) ?? text(value.mimeType);
54
57
  if (toolkit === "googledrive" && item.itemType === "cloud_document" && mimeType && (mimeType === GOOGLE_DOCUMENT_MIME || DOWNLOADABLE_TEXT_MIMES.has(mimeType))) return {
55
58
  sourceItemId: item.id,
@@ -64,6 +67,7 @@ function listConnectedContentCandidates(options) {
64
67
  const limit = Math.max(1, Math.min(20, options.limit ?? 10));
65
68
  const items = listKnowledgeSourceItems({
66
69
  agentId: options.agentId,
70
+ ...options.sourceInstanceId ? { sourceInstanceId: options.sourceInstanceId } : {},
67
71
  includeDeleted: false,
68
72
  limit: 500
69
73
  });
@@ -1,5 +1,6 @@
1
1
  import { createLogger } from "../utils/logger/index.js";
2
2
  import { init_logger } from "../utils/logger.js";
3
+ import { finishContextExtractionRun } from "../storage/sqlite/context-extraction-repository.js";
3
4
  import { claimNextConnectorLearningJob, enqueueConnectorLearningJob, listConnectorLearningJobs, recoverStaleConnectorLearningJobs, setConnectorLearningPaused, updateConnectorLearningJob } from "../storage/sqlite/connector-learning-repository.js";
4
5
  import { pruneBoundedKnowledgeSourceItems } from "../storage/sqlite/knowledge-repository.js";
5
6
  import { getConnectorInstallation, listConnectorConnections, upsertConnectorConnection } from "../storage/sqlite/connector-repository.js";
@@ -10,15 +11,19 @@ import { connectorIdentityKey, normalizeConnectorIdentity } from "./connector-id
10
11
  import { ComposioSessionsAdapter } from "./composio-sessions.js";
11
12
  import { buildConnectorLearningArguments, getConnectorLearningPlan } from "./learning-recipes.js";
12
13
  import { getConnectorDefinition } from "./catalog.js";
13
- import { createUnderstandingSourceRun, listUnderstandingSourceRuns, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant, upsertUserFocus } from "../user-context/sources/repository.js";
14
+ import { createUnderstandingSourceRun, getUnderstandingSourceGrant, listUnderstandingSourceRuns, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant, upsertUserFocus } from "../user-context/sources/repository.js";
15
+ import { claimRegisteredExtraction } from "../user-context/extraction/registry.js";
14
16
  import { ConnectedUnderstandingPipeline } from "../knowledge/connected-understanding-pipeline.js";
15
17
  import "../knowledge/index.js";
16
18
  import { ingestComposioConnectedSource } from "./connected-source-ingestion.js";
19
+ import { deriveConnectedSourceUnderstanding } from "./connected-source-understanding.js";
20
+ import { listConnectedContentCandidates, readConnectedContent } from "./content-enrichment.js";
17
21
  //#region src/connectors/learning-coordinator.ts
18
22
  init_logger();
19
23
  const log = createLogger("ConnectorLearning");
20
24
  const CONNECTED_ACCOUNT_UNAVAILABLE = "connected_account_unavailable";
21
25
  const CONNECTED_SOURCE_SYNC_FAILED = "connected_source_sync_failed";
26
+ const CONNECTED_SOURCE_ANALYSIS_FAILED = "connected_source_analysis_failed";
22
27
  function learningFailureCode(error) {
23
28
  const message = error instanceof Error ? error.message : String(error);
24
29
  return message.includes("ToolRouterV2_InvalidConnectedAccountIds") || message.includes("Could not find connected account(s)") || message.includes("missing its provider identity") ? CONNECTED_ACCOUNT_UNAVAILABLE : CONNECTED_SOURCE_SYNC_FAILED;
@@ -178,6 +183,22 @@ function startConnectorLearningCoordinator(options) {
178
183
  itemsSeen += synced.itemsSeen;
179
184
  itemsIndexed += synced.itemsIndexed;
180
185
  }
186
+ const enrichmentErrors = [];
187
+ if (plan.toolkit === "googledrive") {
188
+ const candidates = listConnectedContentCandidates({
189
+ agentId: job.agentId,
190
+ sourceInstanceId: job.sourceInstanceId,
191
+ limit: 5
192
+ });
193
+ if (candidates.length) {
194
+ const enriched = await readConnectedContent({
195
+ agentId: job.agentId,
196
+ sourceItemIds: candidates.map((candidate) => candidate.sourceItemId)
197
+ });
198
+ enrichmentErrors.push(...enriched.failed.map((failure) => failure.error));
199
+ itemsIndexed += enriched.completed;
200
+ }
201
+ }
181
202
  if (listConnectorLearningJobs({
182
203
  accountId: job.accountId,
183
204
  limit: 100
@@ -188,33 +209,109 @@ function startConnectorLearningCoordinator(options) {
188
209
  itemsIndexed
189
210
  }));
190
211
  publish(updateConnectorLearningJob(job.id, { phase: "deriving" }));
191
- const understanding = await new ConnectedUnderstandingPipeline(options.getMemoryManager()).process(job.agentId);
192
- for (const record of understanding.createdRecords.filter((item) => item.kind === "project_context")) upsertUserFocus({
193
- canonicalKey: `connector-focus:${job.accountId}:${record.id}`,
194
- title: record.content.slice(0, 120),
195
- summary: record.content,
196
- horizon: "ongoing",
197
- status: "candidate",
198
- confidence: .72,
199
- evidenceRefs: [`connector-account:${job.accountId}`],
200
- sourceRunId: sourceRun.id
212
+ const structuralExtraction = claimRegisteredExtraction({
213
+ extractorId: "connector-structural",
214
+ sourceRef: `understanding-source-run:${sourceRun.id}`,
215
+ contentForHash: `${job.sourceInstanceId}:${itemsSeen}:${itemsIndexed}`,
216
+ processingPolicy: "local_only",
217
+ destination: "deterministic"
201
218
  });
219
+ let understanding = {
220
+ proposed: 0,
221
+ created: 0,
222
+ deduplicated: 0,
223
+ rejected: 0,
224
+ createdRecords: [],
225
+ writeOutputs: []
226
+ };
227
+ if (structuralExtraction.shouldExecute) try {
228
+ understanding = await new ConnectedUnderstandingPipeline(options.getMemoryManager()).process(job.agentId, structuralExtraction.run.id);
229
+ const structuralFocuses = understanding.createdRecords.filter((item) => item.kind === "project_context").map((record) => upsertUserFocus({
230
+ canonicalKey: `connector-focus:${job.accountId}:${record.id}`,
231
+ title: record.content.slice(0, 120),
232
+ summary: record.content,
233
+ horizon: "ongoing",
234
+ status: "candidate",
235
+ confidence: .72,
236
+ evidenceRefs: [`connector-account:${job.accountId}`],
237
+ sourceRunId: sourceRun.id
238
+ }));
239
+ finishContextExtractionRun({
240
+ runId: structuralExtraction.run.id,
241
+ status: "completed",
242
+ outputs: [...(understanding.writeOutputs ?? []).map((output) => ({
243
+ candidateKey: output.candidateKey,
244
+ ...output.objectId ? {
245
+ objectType: "understanding",
246
+ objectId: output.objectId
247
+ } : {},
248
+ ...output.versionId ? { versionId: output.versionId } : {},
249
+ outcome: output.outcome
250
+ })), ...structuralFocuses.map((focus) => ({
251
+ candidateKey: focus.canonicalKey,
252
+ objectType: "focus",
253
+ objectId: focus.id,
254
+ versionId: focus.versionId,
255
+ outcome: "created"
256
+ }))]
257
+ });
258
+ } catch (error) {
259
+ finishContextExtractionRun({
260
+ runId: structuralExtraction.run.id,
261
+ status: "failed",
262
+ errorCode: "extractor_failed"
263
+ });
264
+ throw error;
265
+ }
266
+ let semantic = {
267
+ created: 0,
268
+ focusCount: 0,
269
+ status: "completed"
270
+ };
271
+ try {
272
+ semantic = await deriveConnectedSourceUnderstanding({
273
+ config: options.getConfig(),
274
+ agentId: job.agentId,
275
+ sourceInstanceId: job.sourceInstanceId,
276
+ sourceRunId: sourceRun.id,
277
+ processingPolicy: getUnderstandingSourceGrant(sourceRun.grantId)?.processingPolicy ?? "local_only",
278
+ memoryManager: options.getMemoryManager()
279
+ });
280
+ } catch (error) {
281
+ const errorMessage = error instanceof Error ? error.message : String(error);
282
+ semantic = {
283
+ created: 0,
284
+ focusCount: 0,
285
+ status: "failed",
286
+ error: CONNECTED_SOURCE_ANALYSIS_FAILED
287
+ };
288
+ log.warn({
289
+ err: error,
290
+ jobId: job.id,
291
+ connectorId: job.connectorId
292
+ }, `Connected source semantic analysis failed: ${errorMessage}`);
293
+ }
294
+ const candidatesCreated = understanding.created + semantic.created + semantic.focusCount;
295
+ const incomplete = enrichmentErrors.length > 0 || semantic.status !== "completed";
202
296
  const completed = updateConnectorLearningJob(job.id, {
203
297
  status: "completed",
204
298
  phase: "completed",
205
- candidatesCreated: understanding.created,
299
+ candidatesCreated,
206
300
  nextRunAt: null,
207
301
  finished: true
208
302
  });
209
303
  updateUnderstandingSourceRun(sourceRun.id, {
210
- status: "completed",
304
+ status: incomplete ? "partial" : "completed",
211
305
  itemsSeen,
212
306
  cursorAfter: (/* @__PURE__ */ new Date()).toISOString(),
213
307
  completed: true,
214
308
  metadata: {
215
309
  ...sourceRun.metadata,
216
310
  itemsIndexed,
217
- candidatesCreated: understanding.created
311
+ candidatesCreated,
312
+ semanticStatus: semantic.status,
313
+ ...semantic.error ? { semanticError: semantic.error } : {},
314
+ ...enrichmentErrors.length ? { enrichmentFailureCount: enrichmentErrors.length } : {}
218
315
  }
219
316
  });
220
317
  updateUnderstandingSourceGrantCheckpoint(sourceRun.grantId, {
@@ -258,7 +355,7 @@ function startConnectorLearningCoordinator(options) {
258
355
  const definition = getConnectorDefinition(job.connectorId);
259
356
  if (definition?.runtime.type === "composio" && definition.runtime.role === "toolkit") updateUnderstandingSourceRun(ensureUnderstandingSourceRun(job, definition.runtime.toolkit, definition.displayName).id, {
260
357
  status: "failed",
261
- errorMessage,
358
+ errorMessage: learningFailureCode(err),
262
359
  completed: true
263
360
  });
264
361
  log.warn({
@@ -43,8 +43,8 @@ const PLANS = {
43
43
  actionId: "GMAIL_FETCH_EMAILS",
44
44
  kind: "activity",
45
45
  arguments: {
46
- max_results: 100,
47
- include_payload: false,
46
+ max_results: 30,
47
+ include_payload: true,
48
48
  verbose: false,
49
49
  query: "newer_than:30d -in:spam -in:trash"
50
50
  }
@@ -1,7 +1,7 @@
1
1
  export type DocumentExtractionResult = {
2
2
  ok: true;
3
3
  text: string;
4
- kind: 'plain' | 'pdf';
4
+ kind: 'plain' | 'pdf' | 'office';
5
5
  } | {
6
6
  ok: false;
7
7
  reason: string;