@xopcai/xopc 0.0.178 → 0.0.180

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 (450) 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-BzGX__8I.js → activity-store-DFKtQDgE.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BzxntcaZ.js → agent-avatar-dicebear-CcTvB_4W.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-DgGj9bu6.js +2 -0
  6. package/dist/gateway/static/root/assets/{api-hi6f2Xtp.js → api-CUClAvuL.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-fTY1F7ac.js → app-management-settings-panel-Ib-cWKHM.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-BZ-IxQfB.js → appearance-settings-CRSN8WuA.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-B5xahuT-.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-ZSLLG8wB.js → archive-plugin-BBF9zspN.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-D4YktqIF.js → attachment-load-D3QQfA7w.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-page-BUYrvMmD.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-BIkPxfxj.js → binary-plugins-D78XOjJ3.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-Q3v_YQom.js → block-editor-D_VVXlYX.js} +46 -46
  15. package/dist/gateway/static/root/assets/browser-settings-page-Cjw07q9h.js +8 -0
  16. package/dist/gateway/static/root/assets/{browser-workflow-inputs-M5lTEW1I.js → browser-workflow-inputs-_gu08MA4.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflows-page-B3T1KYk4.js → browser-workflows-page-58DBMXgG.js} +2 -2
  18. package/dist/gateway/static/root/assets/capabilities-settings-panel-D_dfVxHY.js +7 -0
  19. package/dist/gateway/static/root/assets/{capability-presets-api-DE09c0VB.js → capability-presets-api-DhCn9rPv.js} +1 -1
  20. package/dist/gateway/static/root/assets/capability-presets-settings-panel-LWWIYUT7.js +1 -0
  21. package/dist/gateway/static/root/assets/{channel-recipient-api-CFR5FBfS.js → channel-recipient-api-DYtoNV5A.js} +1 -1
  22. package/dist/gateway/static/root/assets/channels-settings-Cyj5OunL.js +1 -0
  23. package/dist/gateway/static/root/assets/channels-status-swr-TEFnV0IG.js +1 -0
  24. package/dist/gateway/static/root/assets/{connector-logo-B1mD-3pM.js → connector-logo-CxIXnifA.js} +1 -1
  25. package/dist/gateway/static/root/assets/connectors-page-0TobCpBB.js +2 -0
  26. package/dist/gateway/static/root/assets/desktop-pet-CwVSLL6N.js +1 -0
  27. package/dist/gateway/static/root/assets/desktop-pet-settings-BOIp4q0Z.js +1 -0
  28. package/dist/gateway/static/root/assets/{directory-picker-path-field-BYQJ2XUS.js → directory-picker-path-field-C8_lsW6S.js} +1 -1
  29. package/dist/gateway/static/root/assets/{dreaming-settings-BXcb8fwx.js → dreaming-settings-Da9FeWQl.js} +3 -3
  30. package/dist/gateway/static/root/assets/{extension-debug-page-O1Xu1r4Q.js → extension-debug-page-CMNnSJP6.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-page-C2Jraq8l.js → extension-page-t0pJqLvM.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-settings-page-DcXQDTpG.js → extension-settings-page-aiR-tKnW.js} +1 -1
  33. package/dist/gateway/static/root/assets/{gateway-config-api-DmPIZrvg.js → gateway-config-api-CkyQBD6r.js} +1 -1
  34. package/dist/gateway/static/root/assets/gateway-settings-BIZfAgfB.js +1 -0
  35. package/dist/gateway/static/root/assets/{gateway-startup-retry-BZEkOdPm.js → gateway-startup-retry-CSU7UvzG.js} +1 -1
  36. package/dist/gateway/static/root/assets/goals-settings-Dx9uTyWF.js +1 -0
  37. package/dist/gateway/static/root/assets/{heartbeat-settings-BtKu2NWT.js → heartbeat-settings-Cnr5ORXL.js} +1 -1
  38. package/dist/gateway/static/root/assets/{image-generation-api-05Gg8wsU.js → image-generation-api-BR6Kb77X.js} +1 -1
  39. package/dist/gateway/static/root/assets/index-B0Tdge_q.css +1 -0
  40. package/dist/gateway/static/root/assets/index-BA56bQ68.js +224 -0
  41. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CfmDR9Sc.js → keyboard-shortcuts-settings-D76uYKeQ.js} +1 -1
  42. package/dist/gateway/static/root/assets/local-app-workbench-page-DSUNtLHg.js +2 -0
  43. package/dist/gateway/static/root/assets/{local-apps-page-Df8BW1A_.js → local-apps-page-BsLnojTh.js} +1 -1
  44. package/dist/gateway/static/root/assets/{locale-store-CTwSy7yW.js → locale-store-BNC8HUCI.js} +1 -1
  45. package/dist/gateway/static/root/assets/logs-page-yI8kpQtO.js +7 -0
  46. package/dist/gateway/static/root/assets/{markdown-split-B3FvKbaP.js → markdown-split-D6smTQWD.js} +1 -1
  47. package/dist/gateway/static/root/assets/{media-plugins-DsjrvvB6.js → media-plugins-D1TmMF0A.js} +1 -1
  48. package/dist/gateway/static/root/assets/messages-H_iJjnEM.js +3 -0
  49. package/dist/gateway/static/root/assets/{notes-page-tuzIwy3c.js → notes-page-Vt-diFf0.js} +1 -1
  50. package/dist/gateway/static/root/assets/notes-workbench-BD297EZt.js +4 -0
  51. package/dist/gateway/static/root/assets/outcome-detail-page-C5i_ZR9a.js +1 -0
  52. package/dist/gateway/static/root/assets/{page-tabs-ke9s4nYi.js → page-tabs-BnSzIjH0.js} +1 -1
  53. package/dist/gateway/static/root/assets/{preview-open-alternatives-Cp1eI4S9.js → preview-open-alternatives-CF12Eqi4.js} +1 -1
  54. package/dist/gateway/static/root/assets/product-delivery-BVG-eWQO.js +1 -0
  55. package/dist/gateway/static/root/assets/{product-open-page-dXQCMAtH.js → product-open-page-Du0TE_CU.js} +1 -1
  56. package/dist/gateway/static/root/assets/project-detail-page-D1HGz7Dy.js +1 -0
  57. package/dist/gateway/static/root/assets/projects-page-CqP2TnW-.js +1 -0
  58. package/dist/gateway/static/root/assets/remote-access-hub-BXdVJLS3.js +1 -0
  59. package/dist/gateway/static/root/assets/{save-bar-controls-Bl30zjHc.js → save-bar-controls-B53UNtDM.js} +1 -1
  60. package/dist/gateway/static/root/assets/{schedule-field-DqhmXQKo.js → schedule-field-C3dIMN5q.js} +1 -1
  61. package/dist/gateway/static/root/assets/{schema-form-DkUCy6vf.js → schema-form-BKvpxqof.js} +1 -1
  62. package/dist/gateway/static/root/assets/{schemas-DgQq6Z5S.js → schemas-C6onAggk.js} +2 -2
  63. package/dist/gateway/static/root/assets/sessions-page-CPAwDdl5.js +1 -0
  64. package/dist/gateway/static/root/assets/settings-advanced-gate-C-jGsoft.js +1 -0
  65. package/dist/gateway/static/root/assets/{settings-form-section-C6ZbNpdy.js → settings-form-section-kt6GIS32.js} +1 -1
  66. package/dist/gateway/static/root/assets/{settings-loading-skeleton-Bk58_cr7.js → settings-loading-skeleton-85eUPcKz.js} +1 -1
  67. package/dist/gateway/static/root/assets/{settings-page-k8iE_NdX.js → settings-page-Di5x6Xrc.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-page-layout-DgFSya2e.js → settings-page-layout-CkkCee_x.js} +1 -1
  69. package/dist/gateway/static/root/assets/{setup-status-panel-B_KDlyZA.js → setup-status-panel-uxEE6gAB.js} +1 -1
  70. package/dist/gateway/static/root/assets/{share-preview-page-CV7nL_J9.js → share-preview-page-BtLEstaI.js} +1 -1
  71. package/dist/gateway/static/root/assets/shares-settings-2mcsMWgn.js +1 -0
  72. package/dist/gateway/static/root/assets/skill-reload-api-ocDwsrEt.js +1 -0
  73. package/dist/gateway/static/root/assets/skills-page-9_jfsFU5.js +2 -0
  74. package/dist/gateway/static/root/assets/{skills-page.utils-kahBIHg0.js → skills-page.utils-C2SHvq8V.js} +1 -1
  75. package/dist/gateway/static/root/assets/{system-settings-panel-JV3-MG5F.js → system-settings-panel-CIJ66cUy.js} +1 -1
  76. package/dist/gateway/static/root/assets/{theme-store-DFLyzoLO.js → theme-store-ClDa_Bci.js} +1 -1
  77. package/dist/gateway/static/root/assets/time-picker-D0zAsHOo.js +1 -0
  78. package/dist/gateway/static/root/assets/{typed-models-lib-60Aqo-UJ.js → typed-models-lib-GsmwmB40.js} +1 -1
  79. package/dist/gateway/static/root/assets/{use-channel-catalog-CnTkHDnw.js → use-channel-catalog-BQz3K7xj.js} +1 -1
  80. package/dist/gateway/static/root/assets/user-context-page-Bn4BLg4W.js +1 -0
  81. package/dist/gateway/static/root/assets/{voice-api-key-field-CNa8qUgS.js → voice-api-key-field-Blaxsbb3.js} +1 -1
  82. package/dist/gateway/static/root/assets/work-copy-Cwyan9Sn.js +1 -0
  83. package/dist/gateway/static/root/assets/work-discovery-page-iJ9RBSpu.js +1 -0
  84. package/dist/gateway/static/root/assets/work-item-detail-page-CqTH7PQX.js +1 -0
  85. package/dist/gateway/static/root/assets/work-page-H3m99ccS.js +3 -0
  86. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-yV_x595t.js → workflow-run-setup-panel-CTG4RpRE.js} +2 -2
  87. package/dist/gateway/static/root/assets/workflows-page-BxZSKMfv.js +11 -0
  88. package/dist/gateway/static/root/index.html +9 -10
  89. package/dist/package.js +1 -1
  90. package/dist/packages/gateway-contract/src/outcomes.js +137 -0
  91. package/dist/packages/gateway-contract/src/product-delivery.js +1 -0
  92. package/dist/packages/gateway-contract/src/work-intake.js +85 -0
  93. package/dist/src/activity/service.d.ts +1 -0
  94. package/dist/src/activity/service.js +4 -1
  95. package/dist/src/agent/agent-manager.d.ts +4 -1
  96. package/dist/src/agent/agent-manager.js +21 -7
  97. package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
  98. package/dist/src/agent/code-intelligence/binary.js +1 -1
  99. package/dist/src/agent/context/execution-scope.d.ts +1 -1
  100. package/dist/src/agent/context/execution-scope.js +6 -4
  101. package/dist/src/agent/embedded/model-runtime.js +1 -1
  102. package/dist/src/agent/embedded/run-for-session.d.ts +2 -0
  103. package/dist/src/agent/embedded/run-for-session.js +3 -1
  104. package/dist/src/agent/goals/post-turn.js +7 -6
  105. package/dist/src/agent/image/tool-model-config.js +1 -1
  106. package/dist/src/agent/inbound/turn-dispatcher.d.ts +6 -1
  107. package/dist/src/agent/inbound/turn-dispatcher.js +5 -2
  108. package/dist/src/agent/ipc/inbox.js +1 -1
  109. package/dist/src/agent/lifecycle/timeout-wrapper.d.ts +2 -0
  110. package/dist/src/agent/lifecycle/timeout-wrapper.js +39 -9
  111. package/dist/src/agent/mcp/bundle-mcp-materialize.js +2 -2
  112. package/dist/src/agent/mcp/bundle-mcp-runtime.js +6 -1
  113. package/dist/src/agent/mcp/bundle-mcp-types.d.ts +1 -1
  114. package/dist/src/agent/mcp/mcp-stdio-transport.js +1 -1
  115. package/dist/src/agent/mcp/mcp-transport-config.d.ts +2 -0
  116. package/dist/src/agent/mcp/mcp-transport-config.js +10 -3
  117. package/dist/src/agent/mcp/mcp-transport.d.ts +1 -0
  118. package/dist/src/agent/mcp/mcp-transport.js +5 -2
  119. package/dist/src/agent/memory/dreaming/config.js +1 -1
  120. package/dist/src/agent/memory/user-context-coordinator.d.ts +1 -0
  121. package/dist/src/agent/memory/user-context-coordinator.js +17 -1
  122. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.d.ts +1 -1
  123. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +6 -2
  124. package/dist/src/agent/outcomes/{task-evaluation.d.ts → execution-evaluation.d.ts} +3 -3
  125. package/dist/src/agent/outcomes/{task-evaluation.js → execution-evaluation.js} +5 -5
  126. package/dist/src/agent/outcomes/execution-verifier.d.ts +29 -0
  127. package/dist/src/agent/outcomes/{task-verifier.js → execution-verifier.js} +4 -4
  128. package/dist/src/agent/service/direct-turn-helpers.d.ts +1 -0
  129. package/dist/src/agent/service/direct-turn-helpers.js +1 -0
  130. package/dist/src/agent/service/process-direct-one-shot.d.ts +3 -0
  131. package/dist/src/agent/service/process-direct-one-shot.js +4 -1
  132. package/dist/src/agent/service/process-direct-streaming.js +3 -1
  133. package/dist/src/agent/service.d.ts +1 -0
  134. package/dist/src/agent/service.js +5 -2
  135. package/dist/src/agent/session/session-inspector.js +1 -1
  136. package/dist/src/agent/skills/config.js +6 -0
  137. package/dist/src/agent/skills/filesystem-watcher.d.ts +4 -0
  138. package/dist/src/agent/skills/filesystem-watcher.js +16 -7
  139. package/dist/src/agent/skills/hub-lock.js +1 -1
  140. package/dist/src/agent/skills/index.d.ts +10 -7
  141. package/dist/src/agent/skills/index.js +56 -47
  142. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  143. package/dist/src/agent/skills/skill-manager.d.ts +5 -2
  144. package/dist/src/agent/skills/skill-manager.js +10 -5
  145. package/dist/src/agent/skills/skill-sources.d.ts +18 -0
  146. package/dist/src/agent/skills/skill-sources.js +143 -0
  147. package/dist/src/agent/skills/types.d.ts +25 -2
  148. package/dist/src/agent/tools/delegate-tool.js +2 -1
  149. package/dist/src/agent/tools/executor.d.ts +2 -0
  150. package/dist/src/agent/tools/executor.js +18 -11
  151. package/dist/src/agent/tools/factory.js +18 -1
  152. package/dist/src/agent/tools/goal-tool.js +5 -3
  153. package/dist/src/agent/tools/index.d.ts +1 -0
  154. package/dist/src/agent/tools/index.js +2 -1
  155. package/dist/src/agent/tools/managed-job-tool.d.ts +2 -0
  156. package/dist/src/agent/tools/managed-job-tool.js +160 -0
  157. package/dist/src/agent/tools/todo-tool.d.ts +5 -0
  158. package/dist/src/agent/tools/todo-tool.js +16 -4
  159. package/dist/src/agent/tools/update-plan-tool.d.ts +1 -0
  160. package/dist/src/agent/tools/update-plan-tool.js +6 -0
  161. package/dist/src/agent/workspace-runtime/registry.d.ts +3 -0
  162. package/dist/src/agent/workspace-runtime/registry.js +3 -1
  163. package/dist/src/agent-runtime/index.js +1 -1
  164. package/dist/src/agent-runtime/runtime-profile.js +1 -1
  165. package/dist/src/auth/credentials.d.ts +9 -1
  166. package/dist/src/auth/credentials.js +112 -56
  167. package/dist/src/auth/model-credential-store.js +7 -22
  168. package/dist/src/auth/oauth-provider-lock.d.ts +5 -0
  169. package/dist/src/auth/oauth-provider-lock.js +91 -0
  170. package/dist/src/auth/profiles/store.js +1 -1
  171. package/dist/src/auth/sync-provider-auth.js +2 -2
  172. package/dist/src/automations/domain/defaults.d.ts +8 -1
  173. package/dist/src/automations/domain/defaults.js +9 -2
  174. package/dist/src/automations/domain/index.js +2 -2
  175. package/dist/src/automations/domain/types.d.ts +33 -7
  176. package/dist/src/automations/domain/validation.d.ts +8 -0
  177. package/dist/src/automations/domain/validation.js +2 -0
  178. package/dist/src/automations/draft/automation-draft-validator.d.ts +2 -1
  179. package/dist/src/automations/index.js +2 -2
  180. package/dist/src/automations/service/action-executor.d.ts +2 -2
  181. package/dist/src/automations/service/action-executor.js +144 -34
  182. package/dist/src/automations/service/automation-service.d.ts +4 -0
  183. package/dist/src/automations/service/automation-service.js +197 -18
  184. package/dist/src/automations/storage/automation-run-repository.d.ts +1 -0
  185. package/dist/src/automations/storage/automation-run-repository.js +37 -7
  186. package/dist/src/automations/storage/index.js +2 -2
  187. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  188. package/dist/src/browser/providers/cloakbrowser.js +2 -2
  189. package/dist/src/channels/attachments/voice-stt-webchat.d.ts +0 -3
  190. package/dist/src/channels/attachments/voice-stt-webchat.js +1 -24
  191. package/dist/src/chat-commands/builtins/goal.js +5 -4
  192. package/dist/src/cli/commands/agents.js +1 -1
  193. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  194. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  195. package/dist/src/cli/commands/goal.js +6 -5
  196. package/dist/src/cli/commands/models.js +1 -1
  197. package/dist/src/cli/commands/tunnel.js +3 -3
  198. package/dist/src/cli/utils/oauth-login.js +1 -7
  199. package/dist/src/config/agent-profile.js +1 -1
  200. package/dist/src/config/index.js +4 -4
  201. package/dist/src/config/loader.js +1 -1
  202. package/dist/src/config/models-json.js +1 -1
  203. package/dist/src/config/schema.d.ts +3 -0
  204. package/dist/src/config/schema.js +2 -1
  205. package/dist/src/connectors/learning-coordinator.js +7 -1
  206. package/dist/src/connectors/source-change-publisher.d.ts +17 -0
  207. package/dist/src/connectors/source-change-publisher.js +148 -0
  208. package/dist/src/discussions/analyzer.d.ts +35 -0
  209. package/dist/src/discussions/analyzer.js +127 -0
  210. package/dist/src/discussions/index.d.ts +7 -0
  211. package/dist/src/discussions/index.js +7 -0
  212. package/dist/src/discussions/live-worker.d.ts +33 -0
  213. package/dist/src/discussions/live-worker.js +148 -0
  214. package/dist/src/discussions/pipeline.d.ts +33 -0
  215. package/dist/src/discussions/pipeline.js +205 -0
  216. package/dist/src/discussions/project-inference.d.ts +13 -0
  217. package/dist/src/discussions/project-inference.js +19 -0
  218. package/dist/src/discussions/repository.d.ts +29 -0
  219. package/dist/src/discussions/repository.js +255 -0
  220. package/dist/src/discussions/service.d.ts +51 -0
  221. package/dist/src/discussions/service.js +335 -0
  222. package/dist/src/discussions/transcript.d.ts +3 -0
  223. package/dist/src/discussions/transcript.js +15 -0
  224. package/dist/src/discussions/types.d.ts +116 -0
  225. package/dist/src/discussions/types.js +10 -0
  226. package/dist/src/discussions/worker.d.ts +18 -0
  227. package/dist/src/discussions/worker.js +74 -0
  228. package/dist/src/extensions/activation-context.js +2 -1
  229. package/dist/src/extensions/lockfile.js +1 -1
  230. package/dist/src/extensions/sdk/testing.js +1 -1
  231. package/dist/src/gateway/agents-admin.js +3 -3
  232. package/dist/src/gateway/chat-stream/mapper.js +53 -3
  233. package/dist/src/gateway/chat-stream/protocol.d.ts +17 -1
  234. package/dist/src/gateway/file-path-classifier.js +1 -1
  235. package/dist/src/gateway/hono/app.js +8 -3
  236. package/dist/src/gateway/hono/lib/config-payload.js +2 -2
  237. package/dist/src/gateway/hono/middleware/auth.js +2 -2
  238. package/dist/src/gateway/hono/middleware/logger.js +1 -1
  239. package/dist/src/gateway/hono/middleware/strict-rate-limit.js +1 -1
  240. package/dist/src/gateway/hono/oauth-async.js +1 -7
  241. package/dist/src/gateway/hono/oauth.js +1 -7
  242. package/dist/src/gateway/hono/routes/agents.js +1 -1
  243. package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
  244. package/dist/src/gateway/hono/routes/connectors.js +79 -0
  245. package/dist/src/gateway/hono/routes/discussions.d.ts +3 -0
  246. package/dist/src/gateway/hono/routes/discussions.js +177 -0
  247. package/dist/src/gateway/hono/routes/execution-receipts.d.ts +3 -0
  248. package/dist/src/gateway/hono/routes/execution-receipts.js +163 -0
  249. package/dist/src/gateway/hono/routes/exposure.js +1 -1
  250. package/dist/src/gateway/hono/routes/goals.js +3 -288
  251. package/dist/src/gateway/hono/routes/home.d.ts +2 -102
  252. package/dist/src/gateway/hono/routes/home.js +8 -424
  253. package/dist/src/gateway/hono/routes/index.js +6 -2
  254. package/dist/src/gateway/hono/routes/memory.js +7 -7
  255. package/dist/src/gateway/hono/routes/models.js +1 -1
  256. package/dist/src/gateway/hono/routes/notes.js +30 -0
  257. package/dist/src/gateway/hono/routes/projects.js +8 -152
  258. package/dist/src/gateway/hono/routes/shares.js +1 -1
  259. package/dist/src/gateway/hono/routes/status.js +2 -2
  260. package/dist/src/gateway/hono/routes/tunnel.js +3 -3
  261. package/dist/src/gateway/hono/routes/voice.js +1 -1
  262. package/dist/src/gateway/hono/routes/work.d.ts +3 -0
  263. package/dist/src/gateway/hono/routes/work.js +207 -0
  264. package/dist/src/gateway/hono/routes/you.js +13 -15
  265. package/dist/src/gateway/index.js +2 -2
  266. package/dist/src/gateway/runtime-config.js +2 -2
  267. package/dist/src/gateway/security/audit.js +2 -2
  268. package/dist/src/gateway/security/index.js +1 -1
  269. package/dist/src/gateway/service/config-coordinator.js +2 -2
  270. package/dist/src/gateway/service/run-gateway-agent.js +46 -51
  271. package/dist/src/gateway/service.d.ts +8 -1
  272. package/dist/src/gateway/service.js +142 -15
  273. package/dist/src/goals/goal-queue-store.d.ts +1 -0
  274. package/dist/src/goals/goal-queue-store.js +5 -1
  275. package/dist/src/goals/goal-queue-types.d.ts +11 -1
  276. package/dist/src/goals/goal-runner.js +10 -6
  277. package/dist/src/goals/goal-service.d.ts +2 -15
  278. package/dist/src/goals/goal-service.js +9 -42
  279. package/dist/src/goals/goal-store.d.ts +1 -18
  280. package/dist/src/goals/goal-store.js +25 -231
  281. package/dist/src/goals/goal-workflow-judge.js +1 -1
  282. package/dist/src/goals/index.d.ts +0 -4
  283. package/dist/src/goals/index.js +1 -3
  284. package/dist/src/goals/types.d.ts +4 -66
  285. package/dist/src/notes/agent-context.js +1 -1
  286. package/dist/src/notes/service.d.ts +1 -0
  287. package/dist/src/notes/service.js +10 -1
  288. package/dist/src/notes/types.d.ts +1 -0
  289. package/dist/src/proactive/events/product-event-bridge.d.ts +7 -0
  290. package/dist/src/proactive/events/product-event-bridge.js +84 -0
  291. package/dist/src/proactive/execution/context.d.ts +27 -11
  292. package/dist/src/proactive/execution/context.js +259 -25
  293. package/dist/src/proactive/execution/repository.js +18 -5
  294. package/dist/src/proactive/execution/types.d.ts +7 -1
  295. package/dist/src/proactive/execution/worker.js +7 -6
  296. package/dist/src/proactive/inbox/repository.js +8 -2
  297. package/dist/src/proactive/index.d.ts +4 -2
  298. package/dist/src/proactive/index.js +5 -3
  299. package/dist/src/proactive/temporal/worker.d.ts +16 -0
  300. package/dist/src/proactive/temporal/worker.js +110 -0
  301. package/dist/src/projects/project-loop.js +3 -3
  302. package/dist/src/providers/auth-runtime/oauth.js +12 -0
  303. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  304. package/dist/src/providers/index.js +2 -2
  305. package/dist/src/providers/model-registry.js +1 -1
  306. package/dist/src/providers/register-runtime-providers.js +1 -1
  307. package/dist/src/share/share-zip.js +1 -1
  308. package/dist/src/share/site-proxy.js +1 -1
  309. package/dist/src/storage/sqlite/activity-repository.d.ts +1 -0
  310. package/dist/src/storage/sqlite/activity-repository.js +4 -1
  311. package/dist/src/storage/sqlite/connector-sync-policy-repository.d.ts +20 -0
  312. package/dist/src/storage/sqlite/connector-sync-policy-repository.js +50 -0
  313. package/dist/src/storage/sqlite/execution-receipt-repository.d.ts +146 -0
  314. package/dist/src/storage/sqlite/execution-receipt-repository.js +235 -0
  315. package/dist/src/storage/sqlite/index.d.ts +4 -2
  316. package/dist/src/storage/sqlite/index.js +6 -4
  317. package/dist/src/storage/sqlite/knowledge-repository.d.ts +3 -0
  318. package/dist/src/storage/sqlite/knowledge-repository.js +9 -1
  319. package/dist/src/storage/sqlite/memory-records-repository.js +1 -1
  320. package/dist/src/storage/sqlite/migrations/075_connector_sync_policies.sql +13 -0
  321. package/dist/src/storage/sqlite/migrations/076_meeting_preparation_scenario.sql +29 -0
  322. package/dist/src/storage/sqlite/migrations/077_proactive_insight_fingerprints.sql +4 -0
  323. package/dist/src/storage/sqlite/migrations/078_discussion_captures.sql +64 -0
  324. package/dist/src/storage/sqlite/migrations/079_discussion_follow_up_scenario.sql +29 -0
  325. package/dist/src/storage/sqlite/migrations/080_task_outcome_context.sql +15 -0
  326. package/dist/src/storage/sqlite/migrations/081_project_monitoring_policies.sql +10 -0
  327. package/dist/src/storage/sqlite/migrations/082_one_click_live_discussions.sql +100 -0
  328. package/dist/src/storage/sqlite/migrations/083_session_task_plans.sql +9 -0
  329. package/dist/src/storage/sqlite/migrations/084_work_intake_lifecycle.sql +26 -0
  330. package/dist/src/storage/sqlite/migrations/085_task_outcome_projection.sql +19 -0
  331. package/dist/src/storage/sqlite/migrations/086_outcome_aggregates.sql +168 -0
  332. package/dist/src/storage/sqlite/migrations/087_context_snapshots.sql +21 -0
  333. package/dist/src/storage/sqlite/migrations/088_automation_execution_deadlines.sql +5 -0
  334. package/dist/src/storage/sqlite/migrations/089_automation_run_leases.sql +8 -0
  335. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  336. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  337. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  338. package/dist/src/storage/sqlite/notes-repository.js +9 -0
  339. package/dist/src/storage/sqlite/schema.js +1 -1
  340. package/dist/src/storage/sqlite/schema.sql +89 -44
  341. package/dist/src/storage/sqlite/session-repository.js +1 -1
  342. package/dist/src/storage/sqlite/session-task-plan-repository.d.ts +20 -0
  343. package/dist/src/storage/sqlite/session-task-plan-repository.js +77 -0
  344. package/dist/src/tui/backends/embedded-backend.d.ts +2 -0
  345. package/dist/src/tui/backends/embedded-backend.js +12 -8
  346. package/dist/src/tui/tui-backend.d.ts +2 -0
  347. package/dist/src/tui/tui-oauth-login.js +1 -7
  348. package/dist/src/tui/tui-picker-overlay.js +1 -0
  349. package/dist/src/tui/tui-picker-services.d.ts +1 -0
  350. package/dist/src/tui/tui-skills-autocomplete.d.ts +6 -2
  351. package/dist/src/tui/tui-skills-autocomplete.js +10 -6
  352. package/dist/src/tui/tui-startup-resources.d.ts +3 -1
  353. package/dist/src/tui/tui-startup-resources.js +4 -3
  354. package/dist/src/tui/tui.js +4 -1
  355. package/dist/src/tunnel/frpc-binary.js +1 -1
  356. package/dist/src/tunnel/frpc-extract.js +1 -1
  357. package/dist/src/tunnel/index.js +2 -2
  358. package/dist/src/user-context/context-compiler.d.ts +31 -0
  359. package/dist/src/user-context/context-compiler.js +51 -0
  360. package/dist/src/voice/local/model-files.js +1 -1
  361. package/dist/src/voice/stt/config.d.ts +4 -0
  362. package/dist/src/voice/stt/config.js +26 -0
  363. package/dist/src/voice/stt/index.d.ts +1 -0
  364. package/dist/src/voice/stt/index.js +2 -1
  365. package/dist/src/voice/stt/list-providers.js +1 -1
  366. package/dist/src/work/attention-governor.d.ts +20 -0
  367. package/dist/src/work/attention-governor.js +46 -0
  368. package/dist/src/work/execution-context.d.ts +16 -0
  369. package/dist/src/work/execution-context.js +66 -0
  370. package/dist/src/work/home-query-service.d.ts +147 -0
  371. package/dist/src/work/home-query-service.js +389 -0
  372. package/dist/src/work/index.d.ts +14 -0
  373. package/dist/src/work/index.js +15 -0
  374. package/dist/src/work/outcome-contract-definition.d.ts +8 -0
  375. package/dist/src/work/outcome-contract-definition.js +15 -0
  376. package/dist/src/work/outcome-execution-service.d.ts +27 -0
  377. package/dist/src/work/outcome-execution-service.js +60 -0
  378. package/dist/src/work/outcome-projection-service.d.ts +7 -0
  379. package/dist/src/work/outcome-projection-service.js +51 -0
  380. package/dist/src/work/outcome-receipt-service.d.ts +13 -0
  381. package/dist/src/work/outcome-receipt-service.js +55 -0
  382. package/dist/src/work/outcome-repository.d.ts +50 -0
  383. package/dist/src/work/outcome-repository.js +112 -0
  384. package/dist/src/work/outcome-run-coordinator.d.ts +25 -0
  385. package/dist/src/work/outcome-run-coordinator.js +117 -0
  386. package/dist/src/work/project-monitoring-service.d.ts +21 -0
  387. package/dist/src/work/project-monitoring-service.js +76 -0
  388. package/dist/src/work/project-operating-view-service.d.ts +10 -0
  389. package/dist/src/work/project-operating-view-service.js +46 -0
  390. package/dist/src/work/work-intake-repository.d.ts +49 -0
  391. package/dist/src/work/work-intake-repository.js +97 -0
  392. package/dist/src/work/work-intake-service.d.ts +26 -0
  393. package/dist/src/work/work-intake-service.js +171 -0
  394. package/dist/src/work/work-value-metrics-service.d.ts +4 -0
  395. package/dist/src/work/work-value-metrics-service.js +88 -0
  396. package/dist/src/work-items/work-item-service.d.ts +0 -2
  397. package/dist/src/work-items/work-item-service.js +0 -28
  398. package/dist/src/workflows/service/workflow-run-service.js +2 -2
  399. package/dist/src/workflows/service/workflow-run-service.types.d.ts +3 -1
  400. package/dist/src/workflows/service/workflow-session-bridge.js +2 -2
  401. package/package.json +1 -1
  402. package/dist/gateway/static/root/assets/agents-DC9F12Kw.js +0 -2
  403. package/dist/gateway/static/root/assets/apps-page-5bKr05Fa.js +0 -1
  404. package/dist/gateway/static/root/assets/automation-suggestion-card-B7mxFRtf.js +0 -1
  405. package/dist/gateway/static/root/assets/automations-page-Dg6dmt5g.js +0 -6
  406. package/dist/gateway/static/root/assets/browser-settings-page-BHoo6Rpq.js +0 -8
  407. package/dist/gateway/static/root/assets/capabilities-settings-panel-BlsqN8Fu.js +0 -7
  408. package/dist/gateway/static/root/assets/capability-presets-settings-panel-DJeT8_B4.js +0 -1
  409. package/dist/gateway/static/root/assets/channels-settings-C4VVjYEm.js +0 -1
  410. package/dist/gateway/static/root/assets/channels-status-swr-vdf8kB16.js +0 -1
  411. package/dist/gateway/static/root/assets/circle-alert-BEjgurr2.js +0 -1
  412. package/dist/gateway/static/root/assets/connectors-page-DNcrDThX.js +0 -2
  413. package/dist/gateway/static/root/assets/desktop-pet-B1urphOZ.js +0 -1
  414. package/dist/gateway/static/root/assets/desktop-pet-settings-DTL6J3EP.js +0 -1
  415. package/dist/gateway/static/root/assets/gateway-settings-DmObBx9b.js +0 -1
  416. package/dist/gateway/static/root/assets/goal-create-dialog-BRhmmBe9.js +0 -1
  417. package/dist/gateway/static/root/assets/goal-detail-page-C1k7_s_O.js +0 -4
  418. package/dist/gateway/static/root/assets/goals-config-api-Fwu1wjEP.js +0 -1
  419. package/dist/gateway/static/root/assets/goals-page-hOu9uA3q.js +0 -2
  420. package/dist/gateway/static/root/assets/goals-settings-DY-JjvHz.js +0 -1
  421. package/dist/gateway/static/root/assets/index-C0CGebQ1.js +0 -212
  422. package/dist/gateway/static/root/assets/index-eqq25gvV.css +0 -1
  423. package/dist/gateway/static/root/assets/local-app-workbench-page-EjsNT7nJ.js +0 -2
  424. package/dist/gateway/static/root/assets/logs-page-Dswjlraa.js +0 -7
  425. package/dist/gateway/static/root/assets/messages-DP6tPKk-.js +0 -3
  426. package/dist/gateway/static/root/assets/notes-workbench-DSh3-hMY.js +0 -4
  427. package/dist/gateway/static/root/assets/product-delivery-BTRT9kCS.js +0 -1
  428. package/dist/gateway/static/root/assets/project-detail-page-D0QPRHR_.js +0 -1
  429. package/dist/gateway/static/root/assets/projects-page-CI5Vz62F.js +0 -1
  430. package/dist/gateway/static/root/assets/remote-access-hub-S1jpzBS5.js +0 -1
  431. package/dist/gateway/static/root/assets/sessions-page-CTm66k7h.js +0 -1
  432. package/dist/gateway/static/root/assets/settings-advanced-gate-CU52AUVD.js +0 -1
  433. package/dist/gateway/static/root/assets/shares-settings-DK6XK95e.js +0 -1
  434. package/dist/gateway/static/root/assets/skill-reload-api-Bvv_u4ii.js +0 -1
  435. package/dist/gateway/static/root/assets/skills-page-BGHvVbay.js +0 -2
  436. package/dist/gateway/static/root/assets/time-picker-XwpxdZFr.js +0 -1
  437. package/dist/gateway/static/root/assets/user-context-page-DBCMk-Vn.js +0 -1
  438. package/dist/gateway/static/root/assets/work-discovery-page-C1UIdsCl.js +0 -1
  439. package/dist/gateway/static/root/assets/work-item-detail-page-DEAQepB8.js +0 -1
  440. package/dist/gateway/static/root/assets/work-page-D5qYmCTq.js +0 -3
  441. package/dist/gateway/static/root/assets/workflows-page-yrK17ZZ5.js +0 -11
  442. package/dist/src/agent/outcomes/task-verifier.d.ts +0 -29
  443. package/dist/src/gateway/hono/routes/task-outcomes.d.ts +0 -3
  444. package/dist/src/gateway/hono/routes/task-outcomes.js +0 -109
  445. package/dist/src/goals/goal-contract-draft.d.ts +0 -15
  446. package/dist/src/goals/goal-contract-draft.js +0 -112
  447. package/dist/src/goals/goal-evidence-review.d.ts +0 -15
  448. package/dist/src/goals/goal-evidence-review.js +0 -89
  449. package/dist/src/storage/sqlite/task-outcome-repository.d.ts +0 -90
  450. package/dist/src/storage/sqlite/task-outcome-repository.js +0 -138
@@ -9,6 +9,8 @@ export type GoalRunStatus = 'running' | 'succeeded' | 'failed' | 'aborted';
9
9
  export type GoalRunVerdict = 'continue' | 'done' | 'blocked' | 'needs_input' | 'decompose';
10
10
  export interface Goal {
11
11
  id: string;
12
+ outcomeId: string;
13
+ outcomeContractVersion: number;
12
14
  title: string;
13
15
  description?: string;
14
16
  status: GoalStatus;
@@ -80,27 +82,8 @@ export interface GoalEvidence {
80
82
  summary?: string;
81
83
  uri?: string;
82
84
  data?: unknown;
83
- requirementIds?: string[];
84
85
  createdAt: number;
85
86
  }
86
- export type GoalEvidenceRequirementStatus = 'pending' | 'ai_verified' | 'approved' | 'rejected';
87
- export type GoalEvidenceReviewSource = 'ai' | 'user' | 'system';
88
- /** A single, reviewable proof obligation from the goal contract. */
89
- export interface GoalEvidenceRequirement {
90
- id: string;
91
- goalId: string;
92
- text: string;
93
- status: GoalEvidenceRequirementStatus;
94
- evidenceIds: string[];
95
- reviewReason?: string;
96
- reviewConfidence?: number;
97
- reviewedBy?: GoalEvidenceReviewSource;
98
- reviewedAt?: number;
99
- requiresHumanApproval: boolean;
100
- createdAt: number;
101
- updatedAt: number;
102
- sortOrder: number;
103
- }
104
87
  export type GoalContextAttachment = MediaRef;
105
88
  export interface GoalContextMessage {
106
89
  goalId: string;
@@ -109,56 +92,10 @@ export interface GoalContextMessage {
109
92
  createdAt: number;
110
93
  updatedAt: number;
111
94
  }
112
- /**
113
- * The user-confirmed definition of success for a persistent goal.
114
- * Checklist items hold the individual acceptance criteria; this contract
115
- * supplies the outcome, scope boundary, and expected evidence around them.
116
- */
117
- export interface GoalContract {
118
- goalId: string;
119
- version: number;
120
- objective: string;
121
- scopeBoundary?: string;
122
- evidencePlan: string[];
123
- outcomeMetric?: GoalOutcomeMetric;
124
- createdAt: number;
125
- updatedAt: number;
126
- }
127
- export type GoalOutcomeDirection = 'increase' | 'decrease';
128
- /** A measurable user-visible result used to verify that outputs changed the intended outcome. */
129
- export interface GoalOutcomeMetric {
130
- name: string;
131
- baselineValue: number;
132
- targetValue: number;
133
- currentValue?: number;
134
- unit?: string;
135
- direction: GoalOutcomeDirection;
136
- sourceUrl?: string;
137
- measuredAt?: number;
138
- }
139
- export interface GoalOutcomeMetricInput {
140
- name: string;
141
- baselineValue: number;
142
- targetValue: number;
143
- currentValue?: number;
144
- unit?: string;
145
- direction?: GoalOutcomeDirection;
146
- sourceUrl?: string;
147
- measuredAt?: number;
148
- }
149
- export interface GoalContractInput {
150
- objective?: string;
151
- scopeBoundary?: string;
152
- evidencePlan?: string[];
153
- criteria?: string[];
154
- outcomeMetric?: GoalOutcomeMetricInput | null;
155
- }
156
95
  export interface GoalWithDetails extends Goal {
157
96
  checklist: GoalChecklistItem[];
158
97
  latestRun?: GoalRun;
159
98
  contextMessage?: GoalContextMessage;
160
- contract?: GoalContract;
161
- evidenceRequirements: GoalEvidenceRequirement[];
162
99
  }
163
100
  export interface GoalListQuery {
164
101
  status?: GoalStatus | GoalStatus[];
@@ -169,6 +106,8 @@ export interface GoalListQuery {
169
106
  offset?: number;
170
107
  }
171
108
  export interface CreateGoalInput {
109
+ outcomeId: string;
110
+ outcomeContractVersion: number;
172
111
  title: string;
173
112
  description?: string;
174
113
  agentId: string;
@@ -180,7 +119,6 @@ export interface CreateGoalInput {
180
119
  uiLocale?: GoalUiLocale;
181
120
  source?: GoalSource;
182
121
  projectId?: string;
183
- contract?: GoalContractInput;
184
122
  }
185
123
  export interface GoalJudgeDecision {
186
124
  verdict: GoalRunVerdict;
@@ -4,8 +4,8 @@ import { resolveImageModelConfigForTool } from "../agent/image/tool-model-config
4
4
  import { describeImagesWithFallback } from "../agent/image/understanding/runtime.js";
5
5
  import { transcribe } from "../voice/stt/transcribe-core.js";
6
6
  import { isSTTAvailable } from "../voice/stt/availability.js";
7
+ import { mergeSttConfigFromAppConfig } from "../voice/stt/config.js";
7
8
  import "../voice/stt/index.js";
8
- import { mergeSttConfigFromAppConfig } from "../channels/attachments/voice-stt-webchat.js";
9
9
  import { extractDocumentText } from "../document-understanding/extract.js";
10
10
  import { extname } from "node:path";
11
11
  import { readFile } from "node:fs/promises";
@@ -49,6 +49,7 @@ export declare class NotesService {
49
49
  mimeType: string;
50
50
  duration?: number;
51
51
  }): Promise<NoteAttachment | null>;
52
+ removeAttachment(noteId: string, attachmentId: string): Promise<boolean>;
52
53
  getAttachmentPath(noteId: string, attachmentId: string): Promise<{
53
54
  filePath: string;
54
55
  mimeType: string;
@@ -4,8 +4,8 @@ import { buildNoteAttachmentRef } from "./attachment-ref.js";
4
4
  import { parseNoteMarkdown } from "./note-markdown.js";
5
5
  import { changedFieldsFromPatch, emitActivity, previewText, systemActivityActor, systemActivitySource } from "../activity/emitter.js";
6
6
  import { getDefaultModelSync, init_providers, resolveModel } from "../providers/index.js";
7
- import { publishAutomationProductEvent } from "../automations/product-events.js";
8
7
  import { completeWithResolvedCredentials } from "../providers/model-call.js";
8
+ import { publishAutomationProductEvent } from "../automations/product-events.js";
9
9
  import { NotesStore } from "./store.js";
10
10
  import { partitionAttachmentsByReference } from "./note-attachment-sync.js";
11
11
  import { buildNoteAgentContextArtifact, getCachedNoteAgentContextArtifact } from "./agent-context.js";
@@ -484,6 +484,15 @@ var NotesService = class {
484
484
  });
485
485
  return attachment;
486
486
  }
487
+ async removeAttachment(noteId, attachmentId) {
488
+ const note = await this.store.getNote(noteId);
489
+ if (!note) return false;
490
+ const attachment = note.attachments?.find((candidate) => candidate.id === attachmentId);
491
+ if (!attachment) return false;
492
+ await this.store.updateNote(noteId, { attachments: note.attachments?.filter((candidate) => candidate.id !== attachmentId) ?? [] });
493
+ await this.store.deleteAttachmentFile(noteId, attachment.relativePath);
494
+ return true;
495
+ }
487
496
  async getAttachmentPath(noteId, attachmentId) {
488
497
  const note = await this.store.getNote(noteId);
489
498
  if (!note) return null;
@@ -173,6 +173,7 @@ export interface NotesListQuery {
173
173
  status?: NoteStatus;
174
174
  kind?: NoteKind;
175
175
  tag?: string;
176
+ projectId?: string;
176
177
  pinned?: boolean;
177
178
  search?: string;
178
179
  limit?: number;
@@ -0,0 +1,7 @@
1
+ import type { AutomationEvent } from '../../automations/domain/types.js';
2
+ import type { PublishEventInput } from './types.js';
3
+ export declare function mapProductEventToProactive(input: {
4
+ event: AutomationEvent;
5
+ workspaceId: string;
6
+ defaultAgentId: string;
7
+ }): PublishEventInput | null;
@@ -0,0 +1,84 @@
1
+ //#region src/proactive/events/product-event-bridge.ts
2
+ const SUPPORTED_EVENT_TYPES = new Set([
3
+ "goal.created",
4
+ "goal.status_changed",
5
+ "note.created",
6
+ "note.updated",
7
+ "workflow.run.completed",
8
+ "session.transcript.updated",
9
+ "discussion.completed"
10
+ ]);
11
+ function stringValue(payload, key) {
12
+ const value = payload[key];
13
+ return typeof value === "string" && value.trim() ? value : void 0;
14
+ }
15
+ function subjectFor(event) {
16
+ const payload = event.payload ?? {};
17
+ if (event.type.startsWith("goal.")) {
18
+ const id = stringValue(payload, "goalId");
19
+ return id ? {
20
+ kind: "goal",
21
+ id
22
+ } : null;
23
+ }
24
+ if (event.type.startsWith("note.")) {
25
+ const id = stringValue(payload, "noteId");
26
+ return id ? {
27
+ kind: "note",
28
+ id
29
+ } : null;
30
+ }
31
+ if (event.type === "workflow.run.completed") {
32
+ const id = stringValue(payload, "runId");
33
+ return id ? {
34
+ kind: "workflow_run",
35
+ id
36
+ } : null;
37
+ }
38
+ if (event.type === "session.transcript.updated") {
39
+ const id = stringValue(payload, "sessionKey");
40
+ return id ? {
41
+ kind: "session",
42
+ id
43
+ } : null;
44
+ }
45
+ if (event.type === "discussion.completed") {
46
+ const id = stringValue(payload, "discussionId");
47
+ return id ? {
48
+ kind: "discussion",
49
+ id
50
+ } : null;
51
+ }
52
+ return null;
53
+ }
54
+ function mapProductEventToProactive(input) {
55
+ if (!SUPPORTED_EVENT_TYPES.has(input.event.type)) return null;
56
+ const subject = subjectFor(input.event);
57
+ if (!subject) return null;
58
+ const payload = input.event.payload ?? {};
59
+ const occurredAtMs = Number.isFinite(input.event.occurredAtMs) ? input.event.occurredAtMs : Date.now();
60
+ const versionId = stringValue(payload, "messageId") ?? stringValue(payload, "runId") ?? String(occurredAtMs);
61
+ const agentId = stringValue(payload, "agentId") ?? input.defaultAgentId;
62
+ const projectId = stringValue(payload, "projectId");
63
+ return {
64
+ type: `${input.event.type}.v1`,
65
+ schemaVersion: 1,
66
+ source: {
67
+ kind: "internal",
68
+ id: input.event.source ?? "xopc"
69
+ },
70
+ subject,
71
+ actor: { kind: "system" },
72
+ scope: {
73
+ workspaceId: input.workspaceId,
74
+ agentId,
75
+ ...projectId ? { projectId } : {}
76
+ },
77
+ occurredAt: new Date(occurredAtMs).toISOString(),
78
+ dedupeKey: `product-event:${input.event.type}:${subject.id}:${versionId}`,
79
+ sensitivity: "personal",
80
+ payload
81
+ };
82
+ }
83
+ //#endregion
84
+ export { mapProductEventToProactive };
@@ -1,24 +1,39 @@
1
- import type { ContextProvider } from './types.js';
1
+ import type { ContextProvider, ResolvedContext } from './types.js';
2
+ type ContextInput = Parameters<ContextProvider['collect']>[0];
2
3
  export declare class EventBatchContextProvider implements ContextProvider {
3
4
  readonly id = "event_batch";
4
5
  supports(): boolean;
5
- collect(input: {
6
- eventIds: string[];
7
- }): Promise<Record<string, unknown>>;
6
+ collect(input: ContextInput): Promise<ResolvedContext>;
7
+ }
8
+ export declare class ConnectedSourceContextProvider implements ContextProvider {
9
+ readonly id = "connected_source";
10
+ supports(): boolean;
11
+ collect(input: ContextInput): Promise<ResolvedContext>;
12
+ }
13
+ export declare class InternalObjectContextProvider implements ContextProvider {
14
+ readonly id = "internal_objects";
15
+ supports(): boolean;
16
+ collect(input: ContextInput): Promise<ResolvedContext>;
17
+ }
18
+ export declare class UserUnderstandingContextProvider implements ContextProvider {
19
+ readonly id = "user_understanding";
20
+ supports(): boolean;
21
+ collect(input: ContextInput): Promise<ResolvedContext>;
22
+ }
23
+ export declare class MeetingWorkspaceContextProvider implements ContextProvider {
24
+ readonly id = "meeting_workspace";
25
+ supports(scenarioKey: string): boolean;
26
+ collect(input: ContextInput): Promise<ResolvedContext>;
8
27
  }
9
28
  export declare class ProjectStateContextProvider implements ContextProvider {
10
29
  readonly id = "project_state";
11
30
  supports(scenarioKey: string): boolean;
12
- collect(input: {
13
- eventIds: string[];
14
- }): Promise<Record<string, unknown>>;
31
+ collect(input: ContextInput): Promise<ResolvedContext>;
15
32
  }
16
33
  export declare class AutomationStateContextProvider implements ContextProvider {
17
34
  readonly id = "automation_state";
18
35
  supports(scenarioKey: string): boolean;
19
- collect(input: {
20
- eventIds: string[];
21
- }): Promise<Record<string, unknown>>;
36
+ collect(input: ContextInput): Promise<ResolvedContext>;
22
37
  }
23
38
  export declare class ContextProviderRegistry {
24
39
  private readonly providers;
@@ -27,5 +42,6 @@ export declare class ContextProviderRegistry {
27
42
  batchId: string;
28
43
  eventIds: string[];
29
44
  subscriptionId: string;
30
- }): Promise<Record<string, unknown>>;
45
+ }): Promise<ResolvedContext>;
31
46
  }
47
+ export {};
@@ -1,23 +1,226 @@
1
1
  import { getSqliteDatabase } from "../../storage/sqlite/transaction.js";
2
+ import { listMemoryRecords } from "../../storage/sqlite/memory-records-repository.js";
3
+ import { getKnowledgeSourceItem } from "../../storage/sqlite/knowledge-repository.js";
4
+ import { getConnectorSyncPolicy } from "../../storage/sqlite/connector-sync-policy-repository.js";
5
+ import { wrapExternalContent } from "../../gateway/security/external-content.js";
2
6
  //#region src/proactive/execution/context.ts
7
+ const MAX_EVENT_COUNT = 50;
8
+ function boundedText(value, limit) {
9
+ if (typeof value !== "string") return void 0;
10
+ const normalized = value.trim();
11
+ if (!normalized) return void 0;
12
+ return normalized.length > limit ? `${normalized.slice(0, limit)}…` : normalized;
13
+ }
14
+ function eventRows(eventIds) {
15
+ const ids = [...new Set(eventIds)].slice(0, MAX_EVENT_COUNT);
16
+ if (ids.length === 0) return [];
17
+ return getSqliteDatabase().prepare(`SELECT event_id, type, subject_kind, subject_id, payload_json,
18
+ workspace_id, project_id, agent_id, occurred_at FROM proactive_events
19
+ WHERE event_id IN (${ids.map(() => "?").join(",")}) ORDER BY occurred_at`).all(...ids);
20
+ }
21
+ function emptyContext() {
22
+ return {
23
+ content: {},
24
+ snapshotContent: {},
25
+ evidenceIds: []
26
+ };
27
+ }
28
+ function authorizedConnectedSourceItem(event, scenarioKey) {
29
+ const item = getKnowledgeSourceItem(event.subject_id);
30
+ const connectionId = typeof item?.metadata.connectionId === "string" ? item.metadata.connectionId : void 0;
31
+ if (!item || item.deletedAt || !connectionId) return null;
32
+ if (item.sensitivity === "secret" || item.sensitivity === "regulated") return null;
33
+ if (item.metadata.workspaceId !== event.workspace_id) return null;
34
+ if (event.agent_id && item.metadata.agentId && item.metadata.agentId !== event.agent_id) return null;
35
+ const policy = getConnectorSyncPolicy(connectionId);
36
+ const scenarioAllowed = !policy?.allowedScenarioKeys.length || policy.allowedScenarioKeys.includes(scenarioKey);
37
+ return policy?.scanEnabled && policy.proactiveEnabled && scenarioAllowed ? item : null;
38
+ }
3
39
  var EventBatchContextProvider = class {
4
40
  id = "event_batch";
5
41
  supports() {
6
42
  return true;
7
43
  }
8
44
  async collect(input) {
9
- if (input.eventIds.length === 0) return { events: [] };
10
- return { events: getSqliteDatabase().prepare(`SELECT event_id, type, subject_kind, subject_id, payload_json, occurred_at
11
- FROM proactive_events WHERE event_id IN (${input.eventIds.map(() => "?").join(",")}) ORDER BY occurred_at`).all(...input.eventIds).map((row) => ({
12
- evidenceId: row.event_id,
13
- type: row.type,
14
- subject: {
15
- kind: row.subject_kind,
16
- id: row.subject_id
45
+ const rows = eventRows(input.eventIds).filter((row) => !row.type.startsWith("connected_source.") || Boolean(authorizedConnectedSourceItem(row, input.scenarioKey)));
46
+ return {
47
+ content: { events: rows.map((row) => ({
48
+ evidenceId: row.event_id,
49
+ type: row.type,
50
+ subject: {
51
+ kind: row.subject_kind,
52
+ id: row.subject_id
53
+ },
54
+ payload: JSON.parse(row.payload_json),
55
+ occurredAt: row.occurred_at
56
+ })) },
57
+ evidenceIds: rows.map((row) => row.event_id)
58
+ };
59
+ }
60
+ };
61
+ var ConnectedSourceContextProvider = class {
62
+ id = "connected_source";
63
+ supports() {
64
+ return true;
65
+ }
66
+ async collect(input) {
67
+ const items = [];
68
+ const snapshotItems = [];
69
+ const evidenceIds = [];
70
+ for (const event of eventRows(input.eventIds)) {
71
+ if (!event.type.startsWith("connected_source.") || event.type.includes("_deleted.")) continue;
72
+ const item = authorizedConnectedSourceItem(event, input.scenarioKey);
73
+ if (!item) continue;
74
+ const evidenceId = `source-item:${item.id}`;
75
+ const common = {
76
+ evidenceId,
77
+ sourceItemId: item.id,
78
+ sourceInstanceId: item.sourceInstanceId,
79
+ collectionScope: item.collectionScope,
80
+ itemType: item.itemType,
81
+ occurredAt: item.occurredAt,
82
+ sourceUpdatedAt: item.sourceUpdatedAt
83
+ };
84
+ const content = boundedText(item.normalizedText, 6e3);
85
+ items.push({
86
+ ...common,
87
+ ...content ? { content: wrapExternalContent(content, { source: item.itemType === "email" || item.itemType === "message" ? "email" : "api" }) } : {}
88
+ });
89
+ snapshotItems.push({
90
+ ...common,
91
+ contentHash: item.contentHash,
92
+ sensitivity: item.sensitivity
93
+ });
94
+ evidenceIds.push(evidenceId);
95
+ if (items.length >= 20) break;
96
+ }
97
+ return {
98
+ content: { items },
99
+ snapshotContent: { items: snapshotItems },
100
+ evidenceIds
101
+ };
102
+ }
103
+ };
104
+ var InternalObjectContextProvider = class {
105
+ id = "internal_objects";
106
+ supports() {
107
+ return true;
108
+ }
109
+ async collect(input) {
110
+ const db = getSqliteDatabase();
111
+ const objects = [];
112
+ const evidenceIds = [];
113
+ for (const event of eventRows(input.eventIds)) {
114
+ if (event.subject_kind === "goal") {
115
+ const goal = db.prepare(`SELECT goal_id, title, description, status, agent_id, priority,
116
+ deadline_at, updated_at, next_action, blocked_reason FROM goals WHERE goal_id = ?`).get(event.subject_id);
117
+ if (goal) {
118
+ const evidenceId = `goal:${event.subject_id}`;
119
+ objects.push({
120
+ evidenceId,
121
+ kind: "goal",
122
+ ...goal
123
+ });
124
+ evidenceIds.push(evidenceId);
125
+ }
126
+ } else if (event.subject_kind === "note") {
127
+ const note = db.prepare(`SELECT note_id, title, kind, status, snippet, pinned, tags_json,
128
+ task_done, task_due_at, unchecked_task_count, updated_at FROM notes WHERE note_id = ?`).get(event.subject_id);
129
+ if (note) {
130
+ const evidenceId = `note:${event.subject_id}`;
131
+ objects.push({
132
+ ...note,
133
+ evidenceId,
134
+ kind: "note",
135
+ snippet: boundedText(note.snippet, 1500)
136
+ });
137
+ evidenceIds.push(evidenceId);
138
+ }
139
+ }
140
+ if (objects.length >= 20) break;
141
+ }
142
+ return {
143
+ content: { objects },
144
+ evidenceIds
145
+ };
146
+ }
147
+ };
148
+ var UserUnderstandingContextProvider = class {
149
+ id = "user_understanding";
150
+ supports() {
151
+ return true;
152
+ }
153
+ async collect(input) {
154
+ const scope = eventRows(input.eventIds).at(-1);
155
+ if (!scope) return emptyContext();
156
+ const records = listMemoryRecords({
157
+ workspaceId: scope.workspace_id,
158
+ ...scope.project_id ? { visibleToProjectId: scope.project_id } : { unscopedProjectOnly: true },
159
+ status: "active",
160
+ limit: 20
161
+ }).filter((record) => {
162
+ const now = Date.now();
163
+ return record.disclosurePolicy === "referenceable" && record.sensitivity !== "secret" && record.sensitivity !== "regulated" && !record.tags?.includes("playbook:disabled") && (!record.validFrom || Date.parse(record.validFrom) <= now) && (!record.validTo || Date.parse(record.validTo) >= now) && (!record.expiresAt || Date.parse(record.expiresAt) >= now) && (!record.reviewAfter || Date.parse(record.reviewAfter) >= now) && !record.conflictGroupId && (record.explicitness === "explicit" || record.importance >= .7);
164
+ });
165
+ return {
166
+ content: { records: records.map((record) => ({
167
+ evidenceId: `memory:${record.id}`,
168
+ kind: record.kind,
169
+ content: boundedText(record.content, 1e3),
170
+ confidence: record.confidence,
171
+ importance: record.importance,
172
+ updatedAt: record.updatedAt
173
+ })) },
174
+ evidenceIds: records.map((record) => `memory:${record.id}`)
175
+ };
176
+ }
177
+ };
178
+ var MeetingWorkspaceContextProvider = class {
179
+ id = "meeting_workspace";
180
+ supports(scenarioKey) {
181
+ return scenarioKey === "meeting_preparation";
182
+ }
183
+ async collect(input) {
184
+ const scope = eventRows(input.eventIds).at(-1);
185
+ if (!scope) return emptyContext();
186
+ const calendarItem = authorizedConnectedSourceItem(scope, input.scenarioKey);
187
+ if (!calendarItem?.normalizedText) return emptyContext();
188
+ let title = "";
189
+ try {
190
+ const parsed = JSON.parse(calendarItem.normalizedText);
191
+ title = typeof parsed.title === "string" ? parsed.title : "";
192
+ } catch {
193
+ return emptyContext();
194
+ }
195
+ const terms = [...new Set(title.toLocaleLowerCase().match(/[\p{L}\p{N}]{2,}/gu) ?? [])].slice(0, 6);
196
+ if (terms.length === 0) return emptyContext();
197
+ const db = getSqliteDatabase();
198
+ const goalMatches = terms.map(() => `LOWER(COALESCE(title, '') || ' ' || COALESCE(description, '')
199
+ || ' ' || COALESCE(next_action, '')) LIKE ?`).join(" OR ");
200
+ const goals = db.prepare(`SELECT goal_id, title, description, status, priority, deadline_at,
201
+ next_action, blocked_reason, project_id, updated_at FROM goals
202
+ WHERE status NOT IN ('done', 'archived') AND agent_id = ? AND (${goalMatches})
203
+ ORDER BY updated_at DESC LIMIT 10`).all(scope.agent_id ?? "main", ...terms.map((term) => `%${term}%`));
204
+ const noteMatches = terms.map(() => `LOWER(COALESCE(title, '') || ' ' || COALESCE(snippet, '')) LIKE ?`).join(" OR ");
205
+ const notes = db.prepare(`SELECT note_id, title, kind, status, snippet, tags_json, task_due_at,
206
+ unchecked_task_count, updated_at FROM notes WHERE status NOT IN ('archived', 'trashed')
207
+ AND (${noteMatches}) ORDER BY updated_at DESC LIMIT 10`).all(...terms.map((term) => `%${term}%`));
208
+ const goalEvidenceIds = goals.map((goal) => `goal:${String(goal.goal_id)}`);
209
+ const noteEvidenceIds = notes.map((note) => `note:${String(note.note_id)}`);
210
+ return {
211
+ content: {
212
+ activeGoals: goals.map((goal, index) => ({
213
+ evidenceId: goalEvidenceIds[index],
214
+ ...goal
215
+ })),
216
+ recentNotes: notes.map((note, index) => ({
217
+ evidenceId: noteEvidenceIds[index],
218
+ ...note,
219
+ snippet: boundedText(note.snippet, 1500)
220
+ }))
17
221
  },
18
- payload: JSON.parse(row.payload_json),
19
- occurredAt: row.occurred_at
20
- })) };
222
+ evidenceIds: [...goalEvidenceIds, ...noteEvidenceIds]
223
+ };
21
224
  }
22
225
  };
23
226
  var ProjectStateContextProvider = class {
@@ -26,15 +229,27 @@ var ProjectStateContextProvider = class {
26
229
  return scenarioKey === "project_delivery_risk" || scenarioKey === "blocked_work";
27
230
  }
28
231
  async collect(input) {
29
- if (!input.eventIds.length) return {};
232
+ if (!input.eventIds.length) return emptyContext();
30
233
  const project = getSqliteDatabase().prepare(`SELECT p.* FROM proactive_events e JOIN projects p ON p.project_id = e.project_id
31
234
  WHERE e.event_id IN (${input.eventIds.map(() => "?").join(",")}) AND e.project_id IS NOT NULL ORDER BY e.occurred_at DESC LIMIT 1`).get(...input.eventIds);
32
- if (!project) return {};
33
- return {
34
- project,
35
- workItems: getSqliteDatabase().prepare(`SELECT id, title, status, priority, owner_agent_id, next_action,
235
+ if (!project) return emptyContext();
236
+ const workItems = getSqliteDatabase().prepare(`SELECT id, title, status, priority, owner_agent_id, next_action,
36
237
  blocked_reason, due_at, updated_at FROM work_items WHERE project_id = ? AND archived_at IS NULL
37
- ORDER BY CASE status WHEN 'blocked' THEN 0 ELSE 1 END, updated_at DESC LIMIT 100`).all(String(project.project_id))
238
+ ORDER BY CASE status WHEN 'blocked' THEN 0 ELSE 1 END, updated_at DESC LIMIT 100`).all(String(project.project_id));
239
+ const projectEvidenceId = `project:${String(project.project_id)}`;
240
+ const workItemEvidenceIds = workItems.map((item) => `work-item:${String(item.id)}`);
241
+ return {
242
+ content: {
243
+ project: {
244
+ evidenceId: projectEvidenceId,
245
+ ...project
246
+ },
247
+ workItems: workItems.map((item, index) => ({
248
+ evidenceId: workItemEvidenceIds[index],
249
+ ...item
250
+ }))
251
+ },
252
+ evidenceIds: [projectEvidenceId, ...workItemEvidenceIds]
38
253
  };
39
254
  }
40
255
  };
@@ -44,29 +259,48 @@ var AutomationStateContextProvider = class {
44
259
  return scenarioKey === "automation_failure_impact";
45
260
  }
46
261
  async collect(input) {
47
- if (!input.eventIds.length) return {};
262
+ if (!input.eventIds.length) return emptyContext();
48
263
  const run = getSqliteDatabase().prepare(`SELECT r.* FROM proactive_events e JOIN automation_runs r ON r.run_id = e.subject_id
49
264
  WHERE e.event_id IN (${input.eventIds.map(() => "?").join(",")}) ORDER BY e.occurred_at DESC LIMIT 1`).get(...input.eventIds);
50
- if (!run) return {};
265
+ if (!run) return emptyContext();
266
+ const automation = getSqliteDatabase().prepare(`SELECT automation_id, name, description, enabled, reliability_json, state_json, project_id
267
+ FROM automations WHERE automation_id = ?`).get(String(run.automation_id));
268
+ const runEvidenceId = `automation-run:${String(run.run_id)}`;
51
269
  return {
52
- automation: getSqliteDatabase().prepare(`SELECT automation_id, name, description, enabled, reliability_json, state_json, project_id
53
- FROM automations WHERE automation_id = ?`).get(String(run.automation_id)),
54
- failedRun: run
270
+ content: {
271
+ automation,
272
+ failedRun: {
273
+ evidenceId: runEvidenceId,
274
+ ...run
275
+ }
276
+ },
277
+ evidenceIds: [runEvidenceId]
55
278
  };
56
279
  }
57
280
  };
58
281
  var ContextProviderRegistry = class {
59
282
  constructor(providers = [
60
283
  new EventBatchContextProvider(),
284
+ new ConnectedSourceContextProvider(),
285
+ new InternalObjectContextProvider(),
286
+ new UserUnderstandingContextProvider(),
287
+ new MeetingWorkspaceContextProvider(),
61
288
  new ProjectStateContextProvider(),
62
289
  new AutomationStateContextProvider()
63
290
  ]) {
64
291
  this.providers = providers;
65
292
  }
66
293
  async collect(scenarioKey, input) {
67
- const entries = await Promise.all(this.providers.filter((provider) => provider.supports(scenarioKey)).map(async (provider) => [provider.id, await provider.collect(input)]));
68
- return Object.fromEntries(entries);
294
+ const entries = await Promise.all(this.providers.filter((provider) => provider.supports(scenarioKey)).map(async (provider) => [provider.id, await provider.collect({
295
+ ...input,
296
+ scenarioKey
297
+ })]));
298
+ return {
299
+ content: Object.fromEntries(entries.map(([id, result]) => [id, result.content])),
300
+ snapshotContent: Object.fromEntries(entries.map(([id, result]) => [id, result.snapshotContent ?? result.content])),
301
+ evidenceIds: [...new Set(entries.flatMap(([, result]) => result.evidenceIds))]
302
+ };
69
303
  }
70
304
  };
71
305
  //#endregion
72
- export { AutomationStateContextProvider, ContextProviderRegistry, EventBatchContextProvider, ProjectStateContextProvider };
306
+ export { AutomationStateContextProvider, ConnectedSourceContextProvider, ContextProviderRegistry, EventBatchContextProvider, InternalObjectContextProvider, MeetingWorkspaceContextProvider, ProjectStateContextProvider, UserUnderstandingContextProvider };