@xopcai/xopc 0.0.218 → 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 (326) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-DF2dYXG1.js → activity-store-slG02hSm.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Dw9rF5o1.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-_H0Bam-t.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-DZCOhXch.js → archive-plugin-DKXa160O.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Bjb0FH2B.js → attachment-load-CzwA9g2y.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-D4N3ZDhu.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-uXPt0s47.js → binary-plugins-DoQ_DnT7.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-gukkIEro.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-DAhdS-XZ.js → browser-workflow-inputs-D4roXE6r.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-workflows-page-LKjYzXS_.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-BBUkH833.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-E5mo8M3a.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-BGNuaqvI.js → cron-expression-4DvCFs-v.js} +1 -1
  28. package/dist/gateway/static/root/assets/{date-picker-k7mkklMU.js → date-picker-B6FSjt4Z.js} +1 -1
  29. package/dist/gateway/static/root/assets/dependency-picker-Za18eMp1.js +1 -0
  30. package/dist/gateway/static/root/assets/{desktop-pet-p9EZyGzV.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-Cd4BMKm_.js → extension-debug-page-Cordpg4X.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-CzEGCkOa.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-DNrttVr2.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-B1vD3vRb.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-BTR0Wk_k.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-CYlS4RGA.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-CNppYVew.js → local-apps-page-Be79cyMG.js} +1 -1
  55. package/dist/gateway/static/root/assets/{locale-store-gf9Bg2gb.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-IYk9xLgt.js → management-settings-CRspx0oY.js} +1 -1
  58. package/dist/gateway/static/root/assets/{markdown-split-D8e6pRMH.js → markdown-split-G3PTpGw3.js} +1 -1
  59. package/dist/gateway/static/root/assets/{markdown-view-D0fiJjBQ.js → markdown-view-D4FPJZ91.js} +1 -1
  60. package/dist/gateway/static/root/assets/{media-plugins-CCq6TtEf.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-BBtWnlUU.js → notes-api-q7HjYO07.js} +1 -1
  63. package/dist/gateway/static/root/assets/{notes-page-BKe1xa3U.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-DXe5iWI6.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-xj5gOva_.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-BJTvmBCA.js → runtime-tools-settings-panel-CXHQc53b.js} +2 -2
  74. package/dist/gateway/static/root/assets/{schema-form-DvGBa_7R.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-sbef7GTm.js → settings-loading-skeleton-H3ZH6a6l.js} +1 -1
  80. package/dist/gateway/static/root/assets/{settings-page-BNGxxXZe.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-C1523ij3.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-Ditgz7Vo.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/task-detail-page-BwOyrADL.js +1 -0
  89. package/dist/gateway/static/root/assets/{theme-store-DgSjes3O.js → theme-store-Br4BtK4x.js} +1 -1
  90. package/dist/gateway/static/root/assets/typed-models-lib-q5-Vfqd8.js +1 -0
  91. package/dist/gateway/static/root/assets/{use-autosave-Bp_qFZkl.js → use-autosave-DRS3RwS9.js} +1 -1
  92. package/dist/gateway/static/root/assets/user-context-page-ClV2r3Cr.js +1 -0
  93. package/dist/gateway/static/root/assets/{voice-api-key-field-hbzDfErG.js → voice-api-key-field-CGTE5156.js} +1 -1
  94. package/dist/gateway/static/root/assets/{work-discovery-overlay-DZVib-04.js → work-discovery-overlay-CW-HKD7h.js} +1 -1
  95. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C2RKay1p.js → workflow-run-setup-panel-Dtr9fDC8.js} +2 -2
  96. package/dist/gateway/static/root/assets/workflows-page-CDOyNgZf.js +5 -0
  97. package/dist/gateway/static/root/index.html +20 -11
  98. package/dist/package.js +1 -1
  99. package/dist/packages/gateway-contract/src/new-session.js +99 -0
  100. package/dist/packages/gateway-contract/src/tasks.js +5 -0
  101. package/dist/packages/gateway-contract/src/user-message-display.js +55 -0
  102. package/dist/src/agent/agent-manager.js +5 -4
  103. package/dist/src/agent/background-review/prompts.d.ts +1 -1
  104. package/dist/src/agent/background-review/prompts.js +2 -2
  105. package/dist/src/agent/background-review/run-background-review.js +144 -16
  106. package/dist/src/agent/embedded/model-runtime.js +1 -1
  107. package/dist/src/agent/embedded/run-for-session.js +1 -1
  108. package/dist/src/agent/image/tool-model-config.js +1 -1
  109. package/dist/src/agent/inbound/turn-dispatcher.d.ts +3 -1
  110. package/dist/src/agent/inbound/turn-dispatcher.js +2 -1
  111. package/dist/src/agent/ipc/inbox.js +1 -1
  112. package/dist/src/agent/memory/context/types.d.ts +1 -1
  113. package/dist/src/agent/memory/manager.d.ts +2 -1
  114. package/dist/src/agent/memory/manager.js +2 -6
  115. package/dist/src/agent/memory/understanding/service.d.ts +1 -0
  116. package/dist/src/agent/memory/understanding/service.js +179 -36
  117. package/dist/src/agent/memory/understanding/types.d.ts +6 -0
  118. package/dist/src/agent/messaging/command-handler.d.ts +2 -0
  119. package/dist/src/agent/messaging/command-handler.js +3 -1
  120. package/dist/src/agent/service/direct-turn-helpers.d.ts +3 -0
  121. package/dist/src/agent/service/direct-turn-helpers.js +13 -3
  122. package/dist/src/agent/service/process-direct-streaming.d.ts +2 -1
  123. package/dist/src/agent/service/process-direct-streaming.js +12 -11
  124. package/dist/src/agent/service.js +2 -2
  125. package/dist/src/agent/session/session-config-service.d.ts +1 -0
  126. package/dist/src/agent/session/session-config-service.js +11 -0
  127. package/dist/src/agent/session/session-inspector.d.ts +1 -0
  128. package/dist/src/agent/session/session-inspector.js +2 -1
  129. package/dist/src/agent/skills/hub-lock.js +1 -1
  130. package/dist/src/agent/source-context/budget.d.ts +3 -0
  131. package/dist/src/agent/source-context/budget.js +21 -0
  132. package/dist/src/agent/source-context/index.js +3 -3
  133. package/dist/src/agent/source-context/injector.d.ts +2 -2
  134. package/dist/src/agent/source-context/injector.js +19 -9
  135. package/dist/src/agent/source-context/types.d.ts +16 -0
  136. package/dist/src/agent/source-context/types.js +25 -1
  137. package/dist/src/agent/tasks/task-judge-service.js +3 -3
  138. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  139. package/dist/src/agent/tool-manuals/xopc-use.js +19 -2
  140. package/dist/src/agent/tools/xopc-use-tool.js +62 -2
  141. package/dist/src/ai-assist/text-assist.js +1 -1
  142. package/dist/src/auth/credentials.js +2 -2
  143. package/dist/src/auth/profiles/store.js +1 -1
  144. package/dist/src/auth/sync-provider-auth.js +2 -2
  145. package/dist/src/browser/backend-from-config.d.ts +8 -0
  146. package/dist/src/browser/backend-from-config.js +16 -1
  147. package/dist/src/browser/providers/browser-ext-install.d.ts +3 -2
  148. package/dist/src/browser/providers/browser-ext-install.js +5 -3
  149. package/dist/src/chat-commands/builtins/review.js +11 -2
  150. package/dist/src/chat-commands/builtins/understanding.js +11 -4
  151. package/dist/src/chat-commands/types.d.ts +4 -0
  152. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  153. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  154. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  155. package/dist/src/cli/commands/extension.js +1 -1
  156. package/dist/src/cli/commands/models.js +1 -1
  157. package/dist/src/config/index.js +4 -4
  158. package/dist/src/config/loader.js +1 -1
  159. package/dist/src/config/models-json.d.ts +20 -20
  160. package/dist/src/config/models-json.js +1 -1
  161. package/dist/src/connectors/connected-source-understanding.d.ts +1 -0
  162. package/dist/src/connectors/connected-source-understanding.js +82 -34
  163. package/dist/src/connectors/learning-coordinator.js +57 -11
  164. package/dist/src/extensions/lockfile.js +1 -1
  165. package/dist/src/extensions/update.js +1 -1
  166. package/dist/src/gateway/agents-admin.js +1 -1
  167. package/dist/src/gateway/chat-stream/mapper.js +18 -0
  168. package/dist/src/gateway/file-path-classifier.js +1 -1
  169. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  170. package/dist/src/gateway/hono/routes/agent-stream.js +12 -2
  171. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  172. package/dist/src/gateway/hono/routes/commands-skills.js +1 -0
  173. package/dist/src/gateway/hono/routes/models.js +1 -1
  174. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +46 -2
  175. package/dist/src/gateway/hono/routes/session-input-handler.js +23 -3
  176. package/dist/src/gateway/hono/routes/sessions.js +17 -20
  177. package/dist/src/gateway/hono/routes/tasks.js +25 -0
  178. package/dist/src/gateway/hono/routes/understanding-sources.d.ts +9 -0
  179. package/dist/src/gateway/hono/routes/understanding-sources.js +127 -31
  180. package/dist/src/gateway/hono/routes/workflows.js +2 -2
  181. package/dist/src/gateway/hono/routes/you.js +71 -4
  182. package/dist/src/gateway/service/agent-runner.d.ts +7 -2
  183. package/dist/src/gateway/service/agent-runner.js +21 -1
  184. package/dist/src/gateway/service/config-coordinator.js +2 -2
  185. package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -0
  186. package/dist/src/gateway/service/run-gateway-agent.js +2 -1
  187. package/dist/src/gateway/service/session-input-coordinator.d.ts +8 -2
  188. package/dist/src/gateway/service/session-input-coordinator.js +62 -3
  189. package/dist/src/gateway/service/sessions-api.d.ts +1 -0
  190. package/dist/src/gateway/service.d.ts +3 -2
  191. package/dist/src/gateway/service.js +25 -15
  192. package/dist/src/gateway/user-turn-input.d.ts +2 -0
  193. package/dist/src/gateway/xopc-cloud-capability-setup.d.ts +3 -2
  194. package/dist/src/gateway/xopc-cloud-capability-setup.js +16 -3
  195. package/dist/src/infra/update-runner.js +1 -1
  196. package/dist/src/knowledge/connected-understanding-pipeline.d.ts +1 -1
  197. package/dist/src/knowledge/connected-understanding-pipeline.js +4 -2
  198. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  199. package/dist/src/providers/index.js +2 -2
  200. package/dist/src/providers/model-registry.js +1 -1
  201. package/dist/src/providers/register-runtime-providers.js +1 -1
  202. package/dist/src/retrieval/queryProfile.d.ts +1 -0
  203. package/dist/src/retrieval/queryProfile.js +9 -1
  204. package/dist/src/session/client-history.d.ts +11 -0
  205. package/dist/src/session/client-history.js +24 -2
  206. package/dist/src/session/config-types.d.ts +1 -1
  207. package/dist/src/session/session-title.js +2 -3
  208. package/dist/src/session/store.js +1 -0
  209. package/dist/src/session/transcript-outline.js +5 -2
  210. package/dist/src/session/types.d.ts +1 -0
  211. package/dist/src/session/user-message-display.d.ts +4 -0
  212. package/dist/src/session/user-message-display.js +22 -0
  213. package/dist/src/storage/sqlite/context-extraction-repository.d.ts +57 -0
  214. package/dist/src/storage/sqlite/context-extraction-repository.js +119 -0
  215. package/dist/src/storage/sqlite/context-relation-repository.d.ts +50 -0
  216. package/dist/src/storage/sqlite/context-relation-repository.js +97 -0
  217. package/dist/src/storage/sqlite/index.d.ts +4 -2
  218. package/dist/src/storage/sqlite/index.js +5 -3
  219. package/dist/src/storage/sqlite/migrations/126_focus_context_governance.sql +72 -0
  220. package/dist/src/storage/sqlite/migrations/127_context_object_origin.sql +36 -0
  221. package/dist/src/storage/sqlite/migrations/128_context_extraction.sql +73 -0
  222. package/dist/src/storage/sqlite/migrations/129_focus_versions.sql +51 -0
  223. package/dist/src/storage/sqlite/migrations/130_context_evidence_provenance.sql +18 -0
  224. package/dist/src/storage/sqlite/migrations/131_session_input_contexts.sql +2 -0
  225. package/dist/src/storage/sqlite/migrations/132_transcript_source_context_metadata.sql +34 -0
  226. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  227. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  228. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  229. package/dist/src/storage/sqlite/schema.js +1 -1
  230. package/dist/src/storage/sqlite/session-input-repository.d.ts +8 -0
  231. package/dist/src/storage/sqlite/session-input-repository.js +19 -7
  232. package/dist/src/storage/sqlite/session-turn-replace-repository.d.ts +3 -0
  233. package/dist/src/storage/sqlite/session-turn-replace-repository.js +3 -2
  234. package/dist/src/storage/sqlite/transcript-repository.js +29 -3
  235. package/dist/src/storage/sqlite/user-context-repository.d.ts +4 -1
  236. package/dist/src/storage/sqlite/user-context-repository.js +65 -29
  237. package/dist/src/tasks/index.d.ts +1 -0
  238. package/dist/src/tasks/index.js +2 -1
  239. package/dist/src/tasks/task-deletion-service.d.ts +21 -0
  240. package/dist/src/tasks/task-deletion-service.js +35 -0
  241. package/dist/src/tasks/task-repository.js +22 -1
  242. package/dist/src/tui/backends/embedded-backend.js +5 -3
  243. package/dist/src/tui/backends/gateway-realtime-backend.js +5 -3
  244. package/dist/src/tui/chat-history.js +2 -1
  245. package/dist/src/tui/tui-agent-events.js +4 -2
  246. package/dist/src/tui/tui-commands.d.ts +1 -0
  247. package/dist/src/tui/tui-commands.js +8 -3
  248. package/dist/src/tui/tui-empty-session-cleanup.d.ts +0 -1
  249. package/dist/src/tui/tui-empty-session-cleanup.js +1 -11
  250. package/dist/src/tui/tui-new-session-preferences.d.ts +10 -0
  251. package/dist/src/tui/tui-new-session-preferences.js +32 -0
  252. package/dist/src/tui/tui-session-actions.d.ts +1 -0
  253. package/dist/src/tui/tui-session-actions.js +2 -1
  254. package/dist/src/tui/tui-settings.d.ts +2 -0
  255. package/dist/src/tui/tui-settings.js +4 -1
  256. package/dist/src/tui/tui-startup-resources.js +1 -1
  257. package/dist/src/tui/tui-types.d.ts +1 -0
  258. package/dist/src/tui/tui.js +58 -5
  259. package/dist/src/tunnel/frpc-process.js +3 -0
  260. package/dist/src/tunnel/tunnel-service.d.ts +2 -0
  261. package/dist/src/tunnel/tunnel-service.js +40 -28
  262. package/dist/src/user-context/context-objects.d.ts +17 -0
  263. package/dist/src/user-context/context-objects.js +99 -0
  264. package/dist/src/user-context/domain.d.ts +13 -1
  265. package/dist/src/user-context/evaluation/harness.d.ts +13 -0
  266. package/dist/src/user-context/evaluation/harness.js +31 -0
  267. package/dist/src/user-context/extraction/registry.d.ts +26 -0
  268. package/dist/src/user-context/extraction/registry.js +113 -0
  269. package/dist/src/user-context/extraction/repair.d.ts +19 -0
  270. package/dist/src/user-context/extraction/repair.js +68 -0
  271. package/dist/src/user-context/planner.js +214 -57
  272. package/dist/src/user-context/retriever.js +69 -9
  273. package/dist/src/user-context/sources/index.js +2 -2
  274. package/dist/src/user-context/sources/processing-policy.d.ts +2 -0
  275. package/dist/src/user-context/sources/processing-policy.js +7 -0
  276. package/dist/src/user-context/sources/repository.d.ts +23 -4
  277. package/dist/src/user-context/sources/repository.js +122 -12
  278. package/dist/src/user-context/sources/types.d.ts +10 -1
  279. package/dist/src/user-context/understanding.js +1 -1
  280. package/dist/src/work-discovery/service.js +21 -5
  281. package/dist/src/work-discovery/source-repository.js +1 -1
  282. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  283. package/package.json +3 -3
  284. package/dist/gateway/static/root/assets/agents-Dj86bHkl.js +0 -68
  285. package/dist/gateway/static/root/assets/app-management-settings-panel-D-M6GN-8.js +0 -1
  286. package/dist/gateway/static/root/assets/appearance-settings-XDhmzdIc.js +0 -1
  287. package/dist/gateway/static/root/assets/apps-page-sfO835uz.js +0 -1
  288. package/dist/gateway/static/root/assets/automations-workspace-PptuZgoo.js +0 -6
  289. package/dist/gateway/static/root/assets/browser-settings-page-BoCmzMFV.js +0 -8
  290. package/dist/gateway/static/root/assets/capabilities-settings-panel-DhkJsU8Z.js +0 -7
  291. package/dist/gateway/static/root/assets/capability-presets-settings-panel-Dm7T61fE.js +0 -3
  292. package/dist/gateway/static/root/assets/channels-settings-dG6UFVqt.js +0 -1
  293. package/dist/gateway/static/root/assets/channels-status-swr-DgJxfNyK.js +0 -1
  294. package/dist/gateway/static/root/assets/chat-terminal-dock-CT5yoSMD.js +0 -36
  295. package/dist/gateway/static/root/assets/connectors-page-BC6Ft9SU.js +0 -2
  296. package/dist/gateway/static/root/assets/dependency-picker-DZVSgLXH.js +0 -1
  297. package/dist/gateway/static/root/assets/desktop-pet-settings-Bw4cCFzI.js +0 -1
  298. package/dist/gateway/static/root/assets/directory-picker-path-field-Cbst7IXR.js +0 -1
  299. package/dist/gateway/static/root/assets/extension-settings-page-C1PAKSy2.js +0 -1
  300. package/dist/gateway/static/root/assets/gateway-config-api-Bch9vO6t.js +0 -1
  301. package/dist/gateway/static/root/assets/gateway-settings-DkDxZFGG.js +0 -1
  302. package/dist/gateway/static/root/assets/heartbeat-settings-DXNMxy5b.js +0 -1
  303. package/dist/gateway/static/root/assets/home-page-CYcpVFNT.js +0 -1
  304. package/dist/gateway/static/root/assets/index-Dgb1R07E.css +0 -2
  305. package/dist/gateway/static/root/assets/index-DlOYwVFK.js +0 -108
  306. package/dist/gateway/static/root/assets/local-app-workbench-page-BFrgPwGE.js +0 -2
  307. package/dist/gateway/static/root/assets/logs-page-CPweLw3k.js +0 -2
  308. package/dist/gateway/static/root/assets/messages-B9WQcZ1V.js +0 -3
  309. package/dist/gateway/static/root/assets/notes-workbench-wieRAd1y.js +0 -4
  310. package/dist/gateway/static/root/assets/page-tabs-Bsluqyfb.js +0 -1
  311. package/dist/gateway/static/root/assets/preview-open-alternatives-BrpTWv44.js +0 -1
  312. package/dist/gateway/static/root/assets/project-detail-page-Cww6V7HJ.js +0 -1
  313. package/dist/gateway/static/root/assets/projects-page-D0LKhCCw.js +0 -1
  314. package/dist/gateway/static/root/assets/remote-access-hub-Sf4Pde6Z.js +0 -1
  315. package/dist/gateway/static/root/assets/sessions-page-S5gvgfu5.js +0 -1
  316. package/dist/gateway/static/root/assets/settings-advanced-gate-B3XvdEy8.js +0 -1
  317. package/dist/gateway/static/root/assets/settings-form-section-CiGFtdD8.js +0 -1
  318. package/dist/gateway/static/root/assets/setup-status-panel-CGU_Mxjr.js +0 -1
  319. package/dist/gateway/static/root/assets/shares-settings-k0UQ8WxO.js +0 -1
  320. package/dist/gateway/static/root/assets/skill-reload-api-DQ1GvL1w.js +0 -1
  321. package/dist/gateway/static/root/assets/skills-page-OuHd9GcN.js +0 -2
  322. package/dist/gateway/static/root/assets/system-settings-panel-CERqCsz2.js +0 -1
  323. package/dist/gateway/static/root/assets/task-detail-page-BnRNL2sn.js +0 -1
  324. package/dist/gateway/static/root/assets/typed-models-lib-abEJNkCO.js +0 -1
  325. package/dist/gateway/static/root/assets/user-context-page-Cnkaiky5.js +0 -1
  326. package/dist/gateway/static/root/assets/workflows-page-B_VlcKiK.js +0 -5
@@ -0,0 +1,55 @@
1
+ //#region packages/gateway-contract/src/user-message-display.ts
2
+ const ENVELOPE_TIMESTAMP_PREFIX_RE = /^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}[^\]]*\]\s*/u;
3
+ const USER_CONTEXT_TAGS = [
4
+ "user-profile",
5
+ "active-focuses",
6
+ "collaboration-contract",
7
+ "user-context"
8
+ ];
9
+ function stripLeadingTaggedBlock(text, tag) {
10
+ const opening = `<${tag}>`;
11
+ if (!text.startsWith(opening)) return null;
12
+ const closing = `</${tag}>`;
13
+ const closingIndex = text.indexOf(closing, opening.length);
14
+ if (closingIndex < 0) return null;
15
+ return text.slice(closingIndex + closing.length).trimStart();
16
+ }
17
+ function beginsWithGeneratedTurnPayload(text) {
18
+ return ENVELOPE_TIMESTAMP_PREFIX_RE.test(text) || text.startsWith("<source_contexts>") || USER_CONTEXT_TAGS.some((tag) => text.startsWith(`<${tag}>`));
19
+ }
20
+ /** Remove frozen source snapshots while preserving the wrapped user-authored message. */
21
+ function stripSourceContextsEnvelope(text) {
22
+ if (!text.includes("<source_contexts>")) return text;
23
+ const withoutContexts = text.replace(/^\s*<source_contexts>[\s\S]*?<\/source_contexts>\s*/u, "").trimStart();
24
+ return withoutContexts.match(/^<user_message>\r?\n([\s\S]*)\r?\n<\/user_message>\s*$/u)?.[1] ?? withoutContexts;
25
+ }
26
+ /**
27
+ * Restore a model-facing user message to its client-facing text.
28
+ * Generated profile/memory blocks require the runtime timestamp anchor, which
29
+ * keeps equivalent user-authored XML visible.
30
+ */
31
+ function stripRuntimeUserMessageEnvelope(text) {
32
+ let remaining = text;
33
+ const taskStripped = stripLeadingTaggedBlock(remaining.trimStart(), "xopc_task_execution");
34
+ if (taskStripped !== null && beginsWithGeneratedTurnPayload(taskStripped)) remaining = taskStripped;
35
+ remaining = stripSourceContextsEnvelope(remaining);
36
+ const beforeUserContext = remaining;
37
+ let removedUserContext = false;
38
+ remaining = remaining.trimStart();
39
+ while (true) {
40
+ const tag = USER_CONTEXT_TAGS.find((candidate) => remaining.startsWith(`<${candidate}>`));
41
+ if (!tag) break;
42
+ const next = stripLeadingTaggedBlock(remaining, tag);
43
+ if (next === null) {
44
+ remaining = beforeUserContext;
45
+ removedUserContext = false;
46
+ break;
47
+ }
48
+ remaining = next;
49
+ removedUserContext = true;
50
+ }
51
+ if (removedUserContext && !ENVELOPE_TIMESTAMP_PREFIX_RE.test(remaining)) remaining = beforeUserContext;
52
+ return remaining.replace(ENVELOPE_TIMESTAMP_PREFIX_RE, "");
53
+ }
54
+ //#endregion
55
+ export { stripRuntimeUserMessageEnvelope };
@@ -6,15 +6,15 @@ import { getSessionConfig } from "../storage/sqlite/config-repository.js";
6
6
  import "../storage/sqlite/index.js";
7
7
  import { checkBoundary } from "../agent-runtime/boundary-guard.js";
8
8
  import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
9
+ import { applyConfigOverrides } from "../config/runtime-overrides.js";
9
10
  import { expandWorkspacePathString, init_workspace_path } from "../config/workspace-path.js";
10
11
  import { init_agent_scope, resolveAgentProfileDir } from "./agent-scope.js";
12
+ import { resolveEffectiveAgentProfile, resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
11
13
  import { init_paths, resolveBundledSkillsDir } from "../config/paths.js";
12
- import { CredentialResolver, init_credentials } from "../auth/credentials.js";
13
14
  import { init_sync_provider_auth, resolveProviderApiKeySync } from "../auth/sync-provider-auth.js";
15
+ import { CredentialResolver, init_credentials } from "../auth/credentials.js";
14
16
  import { getApiKeySync, getDefaultModelSync, init_providers, resolveModel } from "../providers/index.js";
15
17
  import { createExtensionAwareStreamFn } from "../providers/extension-stream-bridge.js";
16
- import { applyConfigOverrides } from "../config/runtime-overrides.js";
17
- import { resolveEffectiveAgentProfile, resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
18
18
  import { extractTextContent } from "./context/workspace.js";
19
19
  import { buildExecutionScopeContextForPrompt } from "./context/execution-scope.js";
20
20
  import { clearBootstrapSnapshot } from "./bootstrap/bootstrap-cache.js";
@@ -149,7 +149,8 @@ var AgentManager = class {
149
149
  });
150
150
  }
151
151
  isUserContextEnabledForSession(sessionKey) {
152
- return Boolean(this.config.config?.userContext.enabled && this.config.config.userContext.understanding.enabled && getSessionConfig(sessionKey)?.userContextMode !== "off");
152
+ const mode = getSessionConfig(sessionKey)?.userContextMode;
153
+ return Boolean(this.config.config?.userContext.enabled && this.config.config.userContext.understanding.enabled && (mode === void 0 || mode === "enabled"));
153
154
  }
154
155
  computeBaseWorkspacePath() {
155
156
  const cfg = this.config.config;
@@ -1,2 +1,2 @@
1
- export declare const MEMORY_REVIEW_USER_PROMPT = "Review the conversation above and identify durable user-understanding candidates.\n\nFocus on:\n1. Has the user revealed things about themselves \u2014 persona, desires, preferences, or personal details worth remembering?\n2. Has the user expressed expectations about how you should behave, their work style, emotional-support preferences, boundaries, or how they want you to communicate?\n3. Has the user explicitly corrected a prior assumption? Prefer the correction and do not preserve the contradicted interpretation.\n\nReturn JSON only, with this shape:\n{\"candidates\":[{\"kind\":\"preference\",\"content\":\"...\",\"confidence\":0.8,\"importance\":0.7,\"durability\":\"durable\",\"sensitivity\":\"normal\",\"disclosurePolicy\":\"referenceable\",\"tags\":[\"background-review\"]}]}\n\nAllowed kinds: preference, boundary, relationship, routine, current_state, long_term_goal, project_context, task_lesson, derived_insight.\nOnly include facts supported by the conversation and likely to matter in a future session. A temporary mood or one-off reaction is current context, not durable identity; omit it unless the user describes a recurring pattern that will matter later. Never include passwords, tokens, credentials, or speculative diagnoses. Use {\"candidates\":[]} when nothing qualifies.\n\nWrite each understanding as concise, neutral profile copy that can be shown directly to the person described, not as an internal note about \"the user\". Prefer a subject-omitted predicate or noun phrase. For example, write \u201C\u503E\u5411\u4F7F\u7528 pnpm \u4F5C\u4E3A\u5305\u7BA1\u7406\u5668\u201D or \u201Cxopc \u9879\u76EE\u7684\u6838\u5FC3\u5F00\u53D1\u8005\u201D, not \u201C\u7528\u6237\u503E\u5411\u4E8E\u4F7F\u7528 pnpm\u201D or \u201C\u7528\u6237\u662F xopc \u9879\u76EE\u7684\u5F00\u53D1\u8005\u201D; write \u201CPrefers pnpm as the package manager\u201D or \u201CCore maintainer of xopc\u201D, not \u201CThe user prefers pnpm\u201D or \u201CThe user is a maintainer of xopc\u201D. Do not begin with generic subject labels or pronouns such as \u201C\u7528\u6237\u201D, \u201C\u8BE5\u7528\u6237\u201D, \u201C\u6B64\u7528\u6237\u201D, \u201C\u4F60\u201D, \u201C\u6211\u201D, \u201Cthe user\u201D, \u201Cuser\u201D, \u201Cyou\u201D, or \u201CI\u201D.\n\nDo not turn a request about the current task into user understanding. Exclude requested outputs, follow-up instructions, project-note edits, investigations, and other one-off work. Every candidate must be a complete standalone profile statement or enduring pattern; never return a clause fragment beginning with a connector such as \"and\", \"also\", \"\u5E76\u4E14\", \"\u4EE5\u53CA\", or \"\u7684\u4E8B\u9879\". Use long_term_goal only when the person states an enduring personal goal, not when they ask the assistant to create, update, investigate, summarize, or track something.";
1
+ export declare const MEMORY_REVIEW_USER_PROMPT = "Review the conversation above and identify durable user-understanding candidates.\n\nFocus on:\n1. Has the user revealed things about themselves \u2014 persona, desires, preferences, or personal details worth remembering?\n2. Has the user expressed expectations about how you should behave, their work style, emotional-support preferences, boundaries, or how they want you to communicate?\n3. Has the user explicitly corrected a prior assumption? Prefer the correction and do not preserve the contradicted interpretation.\n\nReturn JSON only, with this shape:\n{\"candidates\":[{\"kind\":\"preference\",\"content\":\"...\",\"confidence\":0.8,\"importance\":0.7,\"durability\":\"durable\",\"sensitivity\":\"normal\",\"disclosurePolicy\":\"referenceable\",\"evidenceRefs\":[\"entry-id\"]}]}\n\nAllowed kinds: preference, boundary, relationship, routine, current_state, long_term_goal, project_context, task_lesson, derived_insight.\nEvery reviewed message is prefixed with an evidence_ref. Every candidate must list the exact one or more evidence_ref values that support it. Omit a candidate when no exact message supports it. Only include facts supported by the conversation and likely to matter in a future session. A temporary mood or one-off reaction is current context, not durable identity; omit it unless the user describes a recurring pattern that will matter later. Never include passwords, tokens, credentials, or speculative diagnoses. Use {\"candidates\":[]} when nothing qualifies.\n\nWrite each understanding as concise, neutral profile copy that can be shown directly to the person described, not as an internal note about \"the user\". Prefer a subject-omitted predicate or noun phrase. For example, write \u201C\u503E\u5411\u4F7F\u7528 pnpm \u4F5C\u4E3A\u5305\u7BA1\u7406\u5668\u201D or \u201Cxopc \u9879\u76EE\u7684\u6838\u5FC3\u5F00\u53D1\u8005\u201D, not \u201C\u7528\u6237\u503E\u5411\u4E8E\u4F7F\u7528 pnpm\u201D or \u201C\u7528\u6237\u662F xopc \u9879\u76EE\u7684\u5F00\u53D1\u8005\u201D; write \u201CPrefers pnpm as the package manager\u201D or \u201CCore maintainer of xopc\u201D, not \u201CThe user prefers pnpm\u201D or \u201CThe user is a maintainer of xopc\u201D. Do not begin with generic subject labels or pronouns such as \u201C\u7528\u6237\u201D, \u201C\u8BE5\u7528\u6237\u201D, \u201C\u6B64\u7528\u6237\u201D, \u201C\u4F60\u201D, \u201C\u6211\u201D, \u201Cthe user\u201D, \u201Cuser\u201D, \u201Cyou\u201D, or \u201CI\u201D.\n\nDo not turn a request about the current task into user understanding. Exclude requested outputs, follow-up instructions, project-note edits, investigations, and other one-off work. Every candidate must be a complete standalone profile statement or enduring pattern; never return a clause fragment beginning with a connector such as \"and\", \"also\", \"\u5E76\u4E14\", \"\u4EE5\u53CA\", or \"\u7684\u4E8B\u9879\". Use long_term_goal only when the person states an enduring personal goal, not when they ask the assistant to create, update, investigate, summarize, or track something.";
2
2
  export declare const UNDERSTANDING_REVIEW_SYSTEM_PROMPT = "You are the user-understanding synthesis stage for the same session. You do not chat with the user and cannot write storage directly. Extract only evidence-backed, durable candidates and return strict JSON matching the requested schema.";
@@ -8,10 +8,10 @@ Focus on:
8
8
  3. Has the user explicitly corrected a prior assumption? Prefer the correction and do not preserve the contradicted interpretation.
9
9
 
10
10
  Return JSON only, with this shape:
11
- {"candidates":[{"kind":"preference","content":"...","confidence":0.8,"importance":0.7,"durability":"durable","sensitivity":"normal","disclosurePolicy":"referenceable","tags":["background-review"]}]}
11
+ {"candidates":[{"kind":"preference","content":"...","confidence":0.8,"importance":0.7,"durability":"durable","sensitivity":"normal","disclosurePolicy":"referenceable","evidenceRefs":["entry-id"]}]}
12
12
 
13
13
  Allowed kinds: preference, boundary, relationship, routine, current_state, long_term_goal, project_context, task_lesson, derived_insight.
14
- Only include facts supported by the conversation and likely to matter in a future session. A temporary mood or one-off reaction is current context, not durable identity; omit it unless the user describes a recurring pattern that will matter later. Never include passwords, tokens, credentials, or speculative diagnoses. Use {"candidates":[]} when nothing qualifies.
14
+ Every reviewed message is prefixed with an evidence_ref. Every candidate must list the exact one or more evidence_ref values that support it. Omit a candidate when no exact message supports it. Only include facts supported by the conversation and likely to matter in a future session. A temporary mood or one-off reaction is current context, not durable identity; omit it unless the user describes a recurring pattern that will matter later. Never include passwords, tokens, credentials, or speculative diagnoses. Use {"candidates":[]} when nothing qualifies.
15
15
 
16
16
  ${USER_FACING_UNDERSTANDING_WRITING_GUIDANCE}
17
17
 
@@ -1,13 +1,18 @@
1
1
  import { createLogger } from "../../utils/logger/index.js";
2
2
  import { init_logger } from "../../utils/logger.js";
3
3
  import { UNDERSTANDING_KINDS } from "../../user-context/domain.js";
4
+ import { finishContextExtractionRun } from "../../storage/sqlite/context-extraction-repository.js";
5
+ import { createContextEvidence } from "../../storage/sqlite/user-context-repository.js";
4
6
  import { getSessionMetadata } from "../../storage/sqlite/session-repository.js";
7
+ import { loadCompactionSourceSnapshot } from "../../storage/sqlite/transcript-repository.js";
5
8
  import "../../storage/sqlite/index.js";
6
9
  import { init_sync_provider_auth, resolveProviderApiKeySync } from "../../auth/sync-provider-auth.js";
7
10
  import { getApiKeySync, init_providers } from "../../providers/index.js";
8
11
  import { createExtensionAwareStreamFn } from "../../providers/extension-stream-bridge.js";
9
12
  import { extractTextContent } from "../context/workspace.js";
13
+ import { readAgentMessageContent } from "../memory/agent-message-access.js";
10
14
  import { resolveAgentTurnTimeoutMs, runAgentTurnWithTimeout } from "../orchestration/run-agent-turn-with-timeout.js";
15
+ import { claimRegisteredExtraction, extractionInputHash } from "../../user-context/extraction/registry.js";
11
16
  import { isDurableUnderstandingCandidate } from "../../user-context/understandingQuality.js";
12
17
  import { isAssistantTurnAborted, isAssistantTurnFailed } from "../orchestration/llm-turn-retry.js";
13
18
  import { MEMORY_REVIEW_USER_PROMPT, UNDERSTANDING_REVIEW_SYSTEM_PROMPT } from "./prompts.js";
@@ -17,9 +22,45 @@ init_sync_provider_auth();
17
22
  init_providers();
18
23
  init_logger();
19
24
  const log = createLogger("BackgroundReview");
20
- function cloneMessageTail(messages, max) {
21
- const tail = messages.length <= max ? messages : messages.slice(-max);
22
- return JSON.parse(JSON.stringify(tail));
25
+ function isReviewMessage(value) {
26
+ if (!value || typeof value !== "object") return false;
27
+ const role = value.role;
28
+ return role === "user" || role === "assistant";
29
+ }
30
+ function tagMessage(message, entryId) {
31
+ const copy = JSON.parse(JSON.stringify(message));
32
+ const tag = `[evidence_ref:${entryId}]\n`;
33
+ const messageContent = readAgentMessageContent(copy);
34
+ if (typeof messageContent === "string") return {
35
+ ...copy,
36
+ content: `${tag}${messageContent}`
37
+ };
38
+ if (Array.isArray(messageContent)) {
39
+ const content = [...messageContent];
40
+ const first = content[0];
41
+ if (first?.type === "text") content[0] = {
42
+ ...first,
43
+ text: `${tag}${first.text ?? ""}`
44
+ };
45
+ else content.unshift({
46
+ type: "text",
47
+ text: tag
48
+ });
49
+ return {
50
+ ...copy,
51
+ content
52
+ };
53
+ }
54
+ return copy;
55
+ }
56
+ function loadEvidenceMessages(sessionKey, max) {
57
+ const snapshot = loadCompactionSourceSnapshot(sessionKey);
58
+ if (!snapshot) return [];
59
+ return snapshot.entries.filter((entry) => isReviewMessage(entry.row)).slice(-max).map((entry) => ({
60
+ entryId: entry.entryId,
61
+ createdAt: entry.createdAt,
62
+ message: entry.row
63
+ }));
23
64
  }
24
65
  const ALLOWED_UNDERSTANDING_KINDS = new Set(UNDERSTANDING_KINDS);
25
66
  const ALLOWED_SENSITIVITIES = new Set([
@@ -36,7 +77,7 @@ function lastAssistantText(agent) {
36
77
  }
37
78
  return "";
38
79
  }
39
- function parseUnderstandingCandidates(raw) {
80
+ function parseBackgroundCandidates(raw) {
40
81
  const fenced = /```(?:json)?\s*([\s\S]*?)```/i.exec(raw)?.[1];
41
82
  const start = raw.indexOf("{");
42
83
  const end = raw.lastIndexOf("}");
@@ -57,6 +98,7 @@ function parseUnderstandingCandidates(raw) {
57
98
  const durability = item.durability === "ephemeral" || item.durability === "recurring" ? item.durability : "durable";
58
99
  const sensitivity = ALLOWED_SENSITIVITIES.has(item.sensitivity) ? item.sensitivity : "personal";
59
100
  const disclosurePolicy = item.disclosurePolicy === "silent" || item.disclosurePolicy === "ask_before_reference" ? item.disclosurePolicy : "referenceable";
101
+ const evidenceRefs = Array.isArray(item.evidenceRefs) ? [...new Set(item.evidenceRefs.filter((value) => typeof value === "string" && value.trim().length > 0))] : [];
60
102
  output.push({
61
103
  kind,
62
104
  content: item.content.trim(),
@@ -65,7 +107,8 @@ function parseUnderstandingCandidates(raw) {
65
107
  explicitness: "inferred",
66
108
  durability,
67
109
  sensitivity,
68
- disclosurePolicy
110
+ disclosurePolicy,
111
+ evidenceRefs
69
112
  });
70
113
  }
71
114
  return output;
@@ -73,8 +116,25 @@ function parseUnderstandingCandidates(raw) {
73
116
  return [];
74
117
  }
75
118
  }
119
+ function parseUnderstandingCandidates(raw) {
120
+ return parseBackgroundCandidates(raw).map(({ evidenceRefs: _evidenceRefs, ...candidate }) => candidate);
121
+ }
76
122
  async function runUnderstandingReview(params) {
77
123
  const { sessionKey, mainAgent, settings, memoryManager, getConfig } = params;
124
+ const evidenceMessages = loadEvidenceMessages(sessionKey, settings.maxHistoryMessages);
125
+ if (!evidenceMessages.length) {
126
+ log.debug({ sessionKey }, "User-understanding review skipped because no persisted evidence was available");
127
+ return;
128
+ }
129
+ const lastEvidence = evidenceMessages[evidenceMessages.length - 1];
130
+ const extraction = claimRegisteredExtraction({
131
+ extractorId: "transcript-synthesis",
132
+ sourceRef: `session:${sessionKey}:window:${evidenceMessages[0].entryId}:${lastEvidence.entryId}`,
133
+ contentForHash: evidenceMessages.map((entry) => entry.entryId).join("\n"),
134
+ processingPolicy: "remote_allowed",
135
+ destination: "remote_model"
136
+ });
137
+ if (!extraction.shouldExecute) return;
78
138
  const reviewAgent = new Agent({
79
139
  initialState: {
80
140
  systemPrompt: UNDERSTANDING_REVIEW_SYSTEM_PROMPT,
@@ -86,7 +146,7 @@ async function runUnderstandingReview(params) {
86
146
  streamFn: createExtensionAwareStreamFn(),
87
147
  getApiKey: (provider) => resolveProviderApiKeySync(provider) ?? getApiKeySync(provider) ?? ""
88
148
  });
89
- reviewAgent.state.messages = cloneMessageTail(mainAgent.state.messages, settings.maxHistoryMessages);
149
+ reviewAgent.state.messages = evidenceMessages.map((entry) => tagMessage(entry.message, entry.entryId));
90
150
  const timeoutMs = Math.min(settings.maxDurationMs, resolveAgentTurnTimeoutMs(getConfig()));
91
151
  try {
92
152
  await runAgentTurnWithTimeout(reviewAgent, async () => {
@@ -104,20 +164,88 @@ async function runUnderstandingReview(params) {
104
164
  }, "User-understanding review failed or timed out");
105
165
  reviewAgent.abort();
106
166
  await reviewAgent.waitForIdle().catch(() => {});
167
+ finishContextExtractionRun({
168
+ runId: extraction.run.id,
169
+ status: "failed",
170
+ errorCode: "model_failed"
171
+ });
107
172
  return;
108
173
  }
109
- if (isAssistantTurnAborted(reviewAgent) || isAssistantTurnFailed(reviewAgent)) return;
110
- const candidates = parseUnderstandingCandidates(lastAssistantText(reviewAgent));
111
- const projectId = getSessionMetadata(sessionKey)?.projectId;
112
- await memoryManager.applyUnderstandingCandidates(candidates, {
113
- sessionKey,
114
- ...projectId ? { projectId } : {},
115
- sourceText: "Background review of the current session transcript",
116
- reviewSource: "background"
117
- });
174
+ if (isAssistantTurnAborted(reviewAgent) || isAssistantTurnFailed(reviewAgent)) {
175
+ finishContextExtractionRun({
176
+ runId: extraction.run.id,
177
+ status: "failed",
178
+ errorCode: "model_failed"
179
+ });
180
+ return;
181
+ }
182
+ const candidates = parseBackgroundCandidates(lastAssistantText(reviewAgent));
183
+ let applied = 0;
184
+ try {
185
+ const evidenceByRef = new Map(evidenceMessages.map((entry) => [entry.entryId, entry]));
186
+ const projectId = getSessionMetadata(sessionKey)?.projectId;
187
+ const outputs = [];
188
+ for (const { evidenceRefs, ...candidate } of candidates) {
189
+ const referenced = evidenceRefs.flatMap((ref) => {
190
+ const entry = evidenceByRef.get(ref);
191
+ return entry ? [entry] : [];
192
+ });
193
+ if (!referenced.length) {
194
+ outputs.push({
195
+ candidateKey: `${candidate.kind}:${candidate.content}`,
196
+ outcome: "rejected"
197
+ });
198
+ continue;
199
+ }
200
+ const evidenceIds = referenced.map((entry) => createContextEvidence({
201
+ sourceType: "conversation",
202
+ sourceRef: `session:${sessionKey}:entry:${entry.entryId}`,
203
+ sourceRunId: extraction.run.id,
204
+ sessionId: sessionKey,
205
+ messageId: entry.entryId,
206
+ contentHash: extractionInputHash(JSON.stringify(entry.message)),
207
+ retentionPolicy: "derived_only",
208
+ processingPolicy: "remote_allowed",
209
+ extractorId: "transcript-synthesis",
210
+ extractorVersion: "1",
211
+ trustLevel: "owner",
212
+ observedAt: entry.createdAt
213
+ }).id);
214
+ const result = await memoryManager.applyUnderstandingCandidates([candidate], {
215
+ sessionKey,
216
+ ...projectId ? { projectId } : {},
217
+ evidenceIds,
218
+ reviewSource: "background",
219
+ extractionRunId: extraction.run.id
220
+ });
221
+ outputs.push(...(result.writeOutputs ?? []).map((output) => ({
222
+ candidateKey: output.candidateKey,
223
+ ...output.objectId ? {
224
+ objectType: "understanding",
225
+ objectId: output.objectId
226
+ } : {},
227
+ ...output.versionId ? { versionId: output.versionId } : {},
228
+ outcome: output.outcome
229
+ })));
230
+ applied += 1;
231
+ }
232
+ finishContextExtractionRun({
233
+ runId: extraction.run.id,
234
+ status: "completed",
235
+ outputs
236
+ });
237
+ } catch (error) {
238
+ finishContextExtractionRun({
239
+ runId: extraction.run.id,
240
+ status: "failed",
241
+ errorCode: "write_failed"
242
+ });
243
+ throw error;
244
+ }
118
245
  log.debug({
119
246
  sessionKey,
120
- candidateCount: candidates.length
247
+ candidateCount: candidates.length,
248
+ applied
121
249
  }, "User-understanding review completed");
122
250
  }
123
251
  async function runBackgroundReviewTurn(params) {
@@ -1,6 +1,6 @@
1
1
  import { init_paths, resolveModelsJsonPath } from "../../config/paths.js";
2
- import { CredentialResolver, init_credentials } from "../../auth/credentials.js";
3
2
  import { init_sync_provider_auth, resolveProviderApiKeySync } from "../../auth/sync-provider-auth.js";
3
+ import { CredentialResolver, init_credentials } from "../../auth/credentials.js";
4
4
  import { XopcModelCredentialStore, init_model_credential_store } from "../../auth/model-credential-store.js";
5
5
  import { init_register_bundled_oauth_flows, registerBundledOAuthFlows } from "../../providers/register-bundled-oauth-flows.js";
6
6
  import { init_register_runtime_providers, registerRuntimeProviders } from "../../providers/register-runtime-providers.js";
@@ -1,7 +1,7 @@
1
1
  import { createLogger } from "../../utils/logger/index.js";
2
2
  import { init_logger } from "../../utils/logger.js";
3
- import { init_providers, resolveModel } from "../../providers/index.js";
4
3
  import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
4
+ import { init_providers, resolveModel } from "../../providers/index.js";
5
5
  import { resolveAgentTurnTimeoutMs } from "../orchestration/run-agent-turn-with-timeout.js";
6
6
  import { resolvePromptCachePolicy } from "../../providers/prompt-cache-plan.js";
7
7
  import { evaluateContextBudget } from "../memory/context-budget.js";
@@ -1,7 +1,7 @@
1
1
  import { getAgentDefaultImageModelConfig, getAgentDefaultModelRef, init_schema, parseModelRef } from "../../config/schema.js";
2
2
  import { init_agent_scope, resolveDefaultAgentId } from "../agent-scope.js";
3
- import { getDefaultModelSync, getModelsByProvider, init_providers, isProviderConfiguredSync, resolveModel } from "../../providers/index.js";
4
3
  import { resolveEffectiveAgentManifestForAgent } from "../../config/agent-profile.js";
4
+ import { getDefaultModelSync, getModelsByProvider, init_providers, isProviderConfiguredSync, resolveModel } from "../../providers/index.js";
5
5
  import { resolveAgentModelFallbackValues, resolveAgentModelPrimaryValue } from "../../config/model-input.js";
6
6
  import { buildCapabilityPlansForConfig } from "../../capabilities/readiness/from-config.js";
7
7
  import "../../capabilities/readiness/index.js";
@@ -25,7 +25,7 @@ import type { SessionStore } from '../../session/store.js';
25
25
  import type { SessionContext, SessionHydrator, SessionStateBag } from '../session/index.js';
26
26
  import type { InboundAttachmentInput, MediaRef } from '../../channels/attachments/inbound-persist.js';
27
27
  import { type ProcessDirectStreamEvent } from '../service/process-direct-streaming.js';
28
- import type { AgentSourceContextResolver } from '../source-context/types.js';
28
+ import type { AgentSourceContext, AgentSourceContextResolver } from '../source-context/types.js';
29
29
  export interface TurnDispatcherConfig {
30
30
  log: ContextualLogger;
31
31
  agentManager: AgentManager;
@@ -62,6 +62,7 @@ export interface ProcessDirectOptions {
62
62
  signal?: AbortSignal;
63
63
  runId?: string;
64
64
  deadlineAtMs?: number;
65
+ sourceContexts?: AgentSourceContext[];
65
66
  }
66
67
  export declare class TurnDispatcher {
67
68
  private readonly cfg;
@@ -73,6 +74,7 @@ export declare class TurnDispatcher {
73
74
  processDirectStreaming(content: string, sessionKey: string, origin: TurnOrigin, attachments?: DirectAttachment[], thinking?: string, options?: {
74
75
  signal?: AbortSignal;
75
76
  runId?: string;
77
+ sourceContexts?: AgentSourceContext[];
76
78
  }): AsyncGenerator<ProcessDirectStreamEvent, void, unknown>;
77
79
  /** Push an out-of-band event into the live webchat stream for a session. */
78
80
  enqueueWebchatStreamEvent(sessionKey: string, event: {
@@ -33,7 +33,8 @@ var TurnDispatcher = class {
33
33
  attachments,
34
34
  thinking,
35
35
  signal: options?.signal,
36
- runId: options?.runId
36
+ runId: options?.runId,
37
+ sourceContexts: options?.sourceContexts
37
38
  });
38
39
  }
39
40
  /** Push an out-of-band event into the live webchat stream for a session. */
@@ -1,7 +1,7 @@
1
1
  import { createLogger } from "../../utils/logger/index.js";
2
2
  import { init_logger } from "../../utils/logger.js";
3
- import { init_write_file_atomic, writeTextAtomic } from "../../infra/write-file-atomic.js";
4
3
  import { init_paths, resolveAgentDir } from "../../config/paths.js";
4
+ import { init_write_file_atomic, writeTextAtomic } from "../../infra/write-file-atomic.js";
5
5
  import { join } from "path";
6
6
  import { existsSync, watch } from "fs";
7
7
  import { mkdir, readFile, readdir, rename } from "fs/promises";
@@ -2,7 +2,7 @@ import type { AgentMessage } from '@earendil-works/pi-agent-core';
2
2
  export type UserContextRejectionReason = 'expired' | 'not_yet_valid' | 'sensitive' | 'requires_consent' | 'needs_review' | 'scope_mismatch' | 'disabled' | 'conflict' | 'low_score' | 'budget';
3
3
  export interface PlannedUserContextItem {
4
4
  recordId: string;
5
- objectType: 'profile' | 'rule' | 'understanding';
5
+ objectType: 'profile' | 'rule' | 'focus' | 'understanding';
6
6
  versionId?: string;
7
7
  content: string;
8
8
  score: number;
@@ -29,7 +29,6 @@ export declare class MemoryManager {
29
29
  private pluginProvidersLoaded;
30
30
  private readonly understanding;
31
31
  private readonly memoryRuntime?;
32
- private readonly lastTurnSourceItem;
33
32
  private readonly sessionContexts;
34
33
  constructor(options?: MemoryManagerOptions);
35
34
  addProvider(provider: MemoryProvider): void;
@@ -60,9 +59,11 @@ export declare class MemoryManager {
60
59
  projectId?: string;
61
60
  sourceItemId?: string;
62
61
  sourceItemIds?: string[];
62
+ evidenceIds?: string[];
63
63
  sourceText?: string;
64
64
  source?: MemoryRecord['source'];
65
65
  reviewSource?: 'turn' | 'background';
66
+ extractionRunId?: string;
66
67
  }): Promise<import('./understanding/types.js').UnderstandingReviewResult>;
67
68
  getExternalToolEntries(): Array<{
68
69
  providerId: string;
@@ -17,7 +17,6 @@ var MemoryManager = class {
17
17
  pluginProvidersLoaded = false;
18
18
  understanding;
19
19
  memoryRuntime;
20
- lastTurnSourceItem = /* @__PURE__ */ new Map();
21
20
  sessionContexts = /* @__PURE__ */ new Map();
22
21
  constructor(options = {}) {
23
22
  this.routing = {
@@ -88,7 +87,7 @@ var MemoryManager = class {
88
87
  }
89
88
  async captureTurnUnderstanding(userContent, assistantContent, options) {
90
89
  const sessionContext = options?.sessionId ? this.sessionContexts.get(options.sessionId) : void 0;
91
- const review = await this.understanding.reviewTurn({
90
+ return await this.understanding.reviewTurn({
92
91
  userContent,
93
92
  assistantContent,
94
93
  sessionKey: options?.sessionId,
@@ -97,8 +96,6 @@ var MemoryManager = class {
97
96
  projectId: options?.projectId,
98
97
  correctionTargetRecordIds: options?.correctionTargetRecordIds
99
98
  });
100
- if (options?.sessionId && review.sourceItemId) this.lastTurnSourceItem.set(options.sessionId, review.sourceItemId);
101
- return review;
102
99
  }
103
100
  async syncProvidersForTurn(userContent, assistantContent, options) {
104
101
  const event = {
@@ -131,7 +128,7 @@ var MemoryManager = class {
131
128
  }
132
129
  async applyUnderstandingCandidates(candidates, context = {}) {
133
130
  const sessionContext = context.sessionKey ? this.sessionContexts.get(context.sessionKey) : void 0;
134
- const sourceItemId = context.sourceItemId ?? (context.sessionKey ? this.lastTurnSourceItem.get(context.sessionKey) : void 0);
131
+ const sourceItemId = context.sourceItemId;
135
132
  const result = await this.understanding.applyCandidates(candidates, {
136
133
  ...context,
137
134
  workspaceId: context.workspaceId ?? sessionContext?.workspace ?? sessionContext?.agentWorkspace,
@@ -346,7 +343,6 @@ var MemoryManager = class {
346
343
  }
347
344
  }
348
345
  async shutdownAll() {
349
- this.lastTurnSourceItem.clear();
350
346
  this.sessionContexts.clear();
351
347
  for (const p of [...this.providers].reverse()) try {
352
348
  await p.shutdown();
@@ -25,5 +25,6 @@ export declare class UserUnderstandingService {
25
25
  evidenceIds?: string[];
26
26
  reviewSource?: 'turn' | 'background';
27
27
  supersedesRecordIds?: string[];
28
+ extractionRunId?: string;
28
29
  }): Promise<Omit<UnderstandingReviewResult, 'sourceItemId'>>;
29
30
  }