@xopcai/xopc 0.0.125 → 0.0.126

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/README.md +56 -102
  2. package/README.zh-CN.md +51 -98
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/feishu/src/schema/config-schema.d.ts +6 -6
  5. package/dist/extensions/feishu/src/workflow-progress.js +1 -1
  6. package/dist/extensions/telegram/src/adapters/streaming-adapter.js +1 -1
  7. package/dist/extensions/telegram/src/config-schema.d.ts +8 -8
  8. package/dist/extensions/telegram/src/inbound-processor.js +1 -1
  9. package/dist/extensions/telegram/src/plugin.js +1 -1
  10. package/dist/extensions/telegram/src/routing-integration.js +2 -2
  11. package/dist/extensions/telegram/src/workflow-progress.js +1 -1
  12. package/dist/extensions/telegram/xopc.extension.json +1 -1
  13. package/dist/extensions/weixin/src/api/api.js +1 -1
  14. package/dist/extensions/weixin/src/config-schema.d.ts +3 -3
  15. package/dist/extensions/weixin/src/plugin.js +1 -1
  16. package/dist/extensions/weixin/src/workflow-progress.js +1 -1
  17. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BKDKICZV.js → agent-avatar-dicebear-C70vgt60.js} +1 -1
  18. package/dist/gateway/static/root/assets/agents-DRYVahI-.js +2 -0
  19. package/dist/gateway/static/root/assets/{app-management-settings-panel-DI4BqHKW.js → app-management-settings-panel-D9-HW6cy.js} +1 -1
  20. package/dist/gateway/static/root/assets/{appearance-settings-6_ie3NQ4.js → appearance-settings-BHlahIDL.js} +1 -1
  21. package/dist/gateway/static/root/assets/apps-page-BdJ1eQg3.js +1 -0
  22. package/dist/gateway/static/root/assets/{archive-plugin-kUHEJ1HK.js → archive-plugin-B-aoIt0w.js} +1 -1
  23. package/dist/gateway/static/root/assets/{attachment-load-Dm-9prpU.js → attachment-load-BD0G0FD5.js} +1 -1
  24. package/dist/gateway/static/root/assets/{automation-suggestion-card-OTxQTPnC.js → automation-suggestion-card-iJRVI7aZ.js} +1 -1
  25. package/dist/gateway/static/root/assets/automations-page-D8hYQbkl.js +4 -0
  26. package/dist/gateway/static/root/assets/{binary-plugins-DllA_jQ0.js → binary-plugins-B0mNlVSz.js} +1 -1
  27. package/dist/gateway/static/root/assets/{block-editor-Cm6CWNj1.js → block-editor-CJY9Lu5G.js} +6 -6
  28. package/dist/gateway/static/root/assets/browser-settings-page-CiWEO-Iy.js +8 -0
  29. package/dist/gateway/static/root/assets/{capability-presets-api-VJ89b6I2.js → capability-presets-api-Bgc8ag55.js} +1 -1
  30. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-BaPj8wC2.js → capability-presets-settings-panel-B1nIi0TC.js} +1 -1
  31. package/dist/gateway/static/root/assets/{channel-recipient-api-B5PwBEUx.js → channel-recipient-api-0sauApoC.js} +1 -1
  32. package/dist/gateway/static/root/assets/channels-settings-BddPdqVo.js +1 -0
  33. package/dist/gateway/static/root/assets/connectors-page-Ba2GDhSE.js +2 -0
  34. package/dist/gateway/static/root/assets/{directory-picker-path-field-DySMzOF6.js → directory-picker-path-field-CiEc4KmY.js} +1 -1
  35. package/dist/gateway/static/root/assets/{dreaming-settings-D_AjSnV_.js → dreaming-settings-4bvpk5wr.js} +2 -2
  36. package/dist/gateway/static/root/assets/{extension-debug-page-BaM0FpW7.js → extension-debug-page-BbyczVZ3.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-page-DuZWVOGA.js → extension-page-DLN1I3DR.js} +1 -1
  38. package/dist/gateway/static/root/assets/{extension-settings-page-DarVtbmJ.js → extension-settings-page-D9VGHmYJ.js} +1 -1
  39. package/dist/gateway/static/root/assets/{fetch-NFKfkqrd.js → fetch-5V96dUz3.js} +1 -1
  40. package/dist/gateway/static/root/assets/{gateway-config-api-CFEm9rgy.js → gateway-config-api-BtIzObwp.js} +1 -1
  41. package/dist/gateway/static/root/assets/{gateway-settings-BMk2S5td.js → gateway-settings-KFsGGDhg.js} +1 -1
  42. package/dist/gateway/static/root/assets/{gateway-startup-retry-Dtwh_yGg.js → gateway-startup-retry-DEMad2wt.js} +1 -1
  43. package/dist/gateway/static/root/assets/{goal-create-dialog-BKP7ylcG.js → goal-create-dialog-4PcF6Sh6.js} +1 -1
  44. package/dist/gateway/static/root/assets/goal-detail-page-B482PSaG.js +1 -0
  45. package/dist/gateway/static/root/assets/{goals-config-api-DTWZNA_Y.js → goals-config-api-CVN7-pdM.js} +1 -1
  46. package/dist/gateway/static/root/assets/{goals-page-CTmA3hWK.js → goals-page-CUdgJuDn.js} +2 -2
  47. package/dist/gateway/static/root/assets/{goals-settings-Bhct0ZT-.js → goals-settings-IYCH3-Pi.js} +1 -1
  48. package/dist/gateway/static/root/assets/{heartbeat-settings-C-UxSU4a.js → heartbeat-settings-Cf_a2Bmz.js} +1 -1
  49. package/dist/gateway/static/root/assets/index-CA2tR2vm.js +256 -0
  50. package/dist/gateway/static/root/assets/index-Ds3u0LOk.css +1 -0
  51. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DCjy2y4d.js → keyboard-shortcuts-settings-lKTg6St7.js} +1 -1
  52. package/dist/gateway/static/root/assets/logs-page-BCporcNH.js +2 -0
  53. package/dist/gateway/static/root/assets/{markdown-split-BaqxP-GQ.js → markdown-split-Bv4k6iGJ.js} +1 -1
  54. package/dist/gateway/static/root/assets/{media-plugins-DQ_EXloK.js → media-plugins-Bbi8g3N8.js} +1 -1
  55. package/dist/gateway/static/root/assets/messages-C22hxE1N.js +3 -0
  56. package/dist/gateway/static/root/assets/models-hub-panel-D68Pyow7.js +2 -0
  57. package/dist/gateway/static/root/assets/notes-page-CuUMOiyv.js +1 -0
  58. package/dist/gateway/static/root/assets/notes-workbench-Dx2N5zTk.js +2 -0
  59. package/dist/gateway/static/root/assets/{page-tabs-EIZhLppK.js → page-tabs-Cp395RYD.js} +1 -1
  60. package/dist/gateway/static/root/assets/{preview-open-alternatives-r_uB4Epr.js → preview-open-alternatives-DqV5OM4m.js} +1 -1
  61. package/dist/gateway/static/root/assets/project-detail-page-sB8AzZi3.js +1 -0
  62. package/dist/gateway/static/root/assets/projects-page-LBnJqWK2.js +1 -0
  63. package/dist/gateway/static/root/assets/remote-access-hub-Dbj0o6SC.js +1 -0
  64. package/dist/gateway/static/root/assets/{save-bar-controls-B132Uf-2.js → save-bar-controls-BItmzAzI.js} +1 -1
  65. package/dist/gateway/static/root/assets/{schedule-field-B5qshALm.js → schedule-field-BQ8IjjCn.js} +1 -1
  66. package/dist/gateway/static/root/assets/{schema-form-CvLmkdS9.js → schema-form-BRpD6x3d.js} +1 -1
  67. package/dist/gateway/static/root/assets/sessions-page-DhDZKspB.js +1 -0
  68. package/dist/gateway/static/root/assets/settings-advanced-gate-BvXLMNL6.js +1 -0
  69. package/dist/gateway/static/root/assets/{settings-collapsible-section-pRlvqsAf.js → settings-collapsible-section-BKSPQM4R.js} +1 -1
  70. package/dist/gateway/static/root/assets/settings-form-section-BmyfthNQ.js +1 -0
  71. package/dist/gateway/static/root/assets/settings-page-Cfm9UxAr.js +1 -0
  72. package/dist/gateway/static/root/assets/settings-page-layout-Bls5tfbH.js +1 -0
  73. package/dist/gateway/static/root/assets/setup-status-panel-kQEsTGAs.js +1 -0
  74. package/dist/gateway/static/root/assets/{share-preview-page-v6-IOp8t.js → share-preview-page-DbYZNAPb.js} +1 -1
  75. package/dist/gateway/static/root/assets/shares-settings-BtR4B0kn.js +1 -0
  76. package/dist/gateway/static/root/assets/skill-reload-api-CJNVOWoK.js +1 -0
  77. package/dist/gateway/static/root/assets/skills-page-DcWDHrt3.js +2 -0
  78. package/dist/gateway/static/root/assets/{system-settings-panel-HUU2FFjM.js → system-settings-panel-DKDAojWM.js} +1 -1
  79. package/dist/gateway/static/root/assets/{typed-models-lib-AH160QHh.js → typed-models-lib-BCCV4Kkp.js} +1 -1
  80. package/dist/gateway/static/root/assets/{use-channel-catalog-BXzDmjCQ.js → use-channel-catalog-NBqg3iFY.js} +1 -1
  81. package/dist/gateway/static/root/assets/{user-profile-settings-panel-DxwnQvQ3.js → user-profile-settings-panel-suQ2x-LB.js} +1 -1
  82. package/dist/gateway/static/root/assets/{utils-i5POEtqd.js → utils-DPGVr3tS.js} +1 -1
  83. package/dist/gateway/static/root/assets/voice-api-key-field-DaJASKFP.js +1 -0
  84. package/dist/gateway/static/root/assets/{work-item-detail-page-CD6FL_Rs.js → work-item-detail-page-BrCZpAWh.js} +1 -1
  85. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-ClVVMgN-.js → workflow-run-setup-panel-BTkRVNAh.js} +2 -2
  86. package/dist/gateway/static/root/assets/{workflow-start-dialog-Dv4ZA1T0.js → workflow-start-dialog-DAImVtdO.js} +1 -1
  87. package/dist/gateway/static/root/assets/workflows-page-vyJ8wSXm.js +18 -0
  88. package/dist/gateway/static/root/index.html +5 -5
  89. package/dist/package.js +1 -1
  90. package/dist/src/activity/context.d.ts +11 -0
  91. package/dist/src/activity/context.js +36 -0
  92. package/dist/src/activity/context.js.map +1 -0
  93. package/dist/src/activity/emitter.d.ts +6 -0
  94. package/dist/src/activity/emitter.js +43 -0
  95. package/dist/src/activity/emitter.js.map +1 -0
  96. package/dist/src/activity/index.d.ts +3 -0
  97. package/dist/src/activity/index.js +3 -0
  98. package/dist/src/activity/service.d.ts +12 -0
  99. package/dist/src/activity/service.js +59 -0
  100. package/dist/src/activity/service.js.map +1 -0
  101. package/dist/src/activity/types.d.ts +109 -0
  102. package/dist/src/activity/types.js +1 -0
  103. package/dist/src/agent/agent-manager.d.ts +7 -0
  104. package/dist/src/agent/agent-manager.js +7 -4
  105. package/dist/src/agent/agent-manager.js.map +1 -1
  106. package/dist/src/agent/context/project-context.js +2 -2
  107. package/dist/src/agent/context/workspace-seed.js +2 -2
  108. package/dist/src/agent/embedded/run-for-session.js +1 -1
  109. package/dist/src/agent/goals/post-turn.js +2 -2
  110. package/dist/src/agent/ipc/bus.js +1 -1
  111. package/dist/src/agent/mcp/bundle-mcp-materialize.js +1 -1
  112. package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
  113. package/dist/src/agent/mcp/mcp-transport-config.js +1 -1
  114. package/dist/src/agent/mcp/mcp-transport.js +1 -1
  115. package/dist/src/agent/memory/plugin-discovery.js +1 -1
  116. package/dist/src/agent/models/manager.js +1 -1
  117. package/dist/src/agent/orchestration/agent-orchestrator.js +1 -1
  118. package/dist/src/agent/service.js +6 -3
  119. package/dist/src/agent/service.js.map +1 -1
  120. package/dist/src/agent/service.types.d.ts +7 -0
  121. package/dist/src/agent/session/session-inspector.js +1 -1
  122. package/dist/src/agent/skills/hub-pull.js +1 -1
  123. package/dist/src/agent/tool-manuals/index.js +15 -6
  124. package/dist/src/agent/tool-manuals/index.js.map +1 -1
  125. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -0
  126. package/dist/src/agent/tool-manuals/xopc-use.js +204 -0
  127. package/dist/src/agent/tool-manuals/xopc-use.js.map +1 -0
  128. package/dist/src/agent/tools/factory.d.ts +7 -0
  129. package/dist/src/agent/tools/factory.js +9 -0
  130. package/dist/src/agent/tools/factory.js.map +1 -1
  131. package/dist/src/agent/tools/goal-tool.js +2 -2
  132. package/dist/src/agent/tools/index.d.ts +1 -0
  133. package/dist/src/agent/tools/index.js +2 -1
  134. package/dist/src/agent/tools/workflow-tool.js +1 -1
  135. package/dist/src/agent/tools/xopc-use-tool.d.ts +34 -0
  136. package/dist/src/agent/tools/xopc-use-tool.js +636 -0
  137. package/dist/src/agent/tools/xopc-use-tool.js.map +1 -0
  138. package/dist/src/agent-manifest/schema.d.ts +27 -27
  139. package/dist/src/automations/api/routes.js +1 -1
  140. package/dist/src/automations/domain/validation.d.ts +55 -55
  141. package/dist/src/automations/draft/automation-draft-validator.d.ts +25 -25
  142. package/dist/src/automations/service/action-executor.js +2 -2
  143. package/dist/src/browser/cdp-local-launcher.js +1 -1
  144. package/dist/src/browser/providers/browser-ext-install.js +3 -3
  145. package/dist/src/browser/providers/cloakbrowser.js +2 -2
  146. package/dist/src/browser/providers/playwright-doctor.js +1 -1
  147. package/dist/src/browser/stealth.js +1 -1
  148. package/dist/src/chat-commands/agent-edit.js +1 -1
  149. package/dist/src/chat-commands/builtins/config.js +1 -1
  150. package/dist/src/chat-commands/builtins/goal.js +2 -2
  151. package/dist/src/chat-commands/context.js +1 -1
  152. package/dist/src/cli/commands/agent.js +1 -1
  153. package/dist/src/cli/commands/doctor/checks/database-schema.js +2 -2
  154. package/dist/src/cli/commands/doctor/checks/session-integrity.js +1 -1
  155. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  156. package/dist/src/cli/commands/extension-pack.js +1 -1
  157. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  158. package/dist/src/cli/commands/goal.js +3 -3
  159. package/dist/src/cli/commands/init.js +1 -1
  160. package/dist/src/cli/commands/project.js +4 -4
  161. package/dist/src/config/agent-profile.js +1 -1
  162. package/dist/src/config/gateway-bind.js +1 -1
  163. package/dist/src/config/index.js +1 -1
  164. package/dist/src/config/loader.js +1 -1
  165. package/dist/src/config/models-json.d.ts +14 -14
  166. package/dist/src/config/models-json.js +1 -1
  167. package/dist/src/config/schema.d.ts +60 -60
  168. package/dist/src/daemon/launchd.js +1 -1
  169. package/dist/src/daemon/systemd.js +1 -1
  170. package/dist/src/extensions/discover-extensions.js +1 -1
  171. package/dist/src/extensions/loader.js +2 -2
  172. package/dist/src/gateway/agents-admin.js +1 -1
  173. package/dist/src/gateway/hono/lib/config-payload.d.ts +14 -14
  174. package/dist/src/gateway/hono/lib/static-ui.js +1 -1
  175. package/dist/src/gateway/hono/middleware/log-context.js +8 -1
  176. package/dist/src/gateway/hono/middleware/log-context.js.map +1 -1
  177. package/dist/src/gateway/hono/routes/activity.d.ts +14 -0
  178. package/dist/src/gateway/hono/routes/activity.js +72 -0
  179. package/dist/src/gateway/hono/routes/activity.js.map +1 -0
  180. package/dist/src/gateway/hono/routes/goals.js +1 -1
  181. package/dist/src/gateway/hono/routes/index.js +2 -0
  182. package/dist/src/gateway/hono/routes/index.js.map +1 -1
  183. package/dist/src/gateway/hono/routes/memory.js +2 -2
  184. package/dist/src/gateway/hono/routes/projects.js +65 -15
  185. package/dist/src/gateway/hono/routes/projects.js.map +1 -1
  186. package/dist/src/gateway/hono/routes/sessions.js +101 -2
  187. package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
  188. package/dist/src/gateway/hono/routes/workflows.js +2 -2
  189. package/dist/src/gateway/lock.js +1 -1
  190. package/dist/src/gateway/ports.js +1 -1
  191. package/dist/src/gateway/service/sessions-api.d.ts +10 -0
  192. package/dist/src/gateway/service/sessions-api.js +31 -0
  193. package/dist/src/gateway/service/sessions-api.js.map +1 -1
  194. package/dist/src/gateway/service.js +12 -9
  195. package/dist/src/gateway/service.js.map +1 -1
  196. package/dist/src/goals/goal-store.js +1 -1
  197. package/dist/src/goals/goal-store.js.map +1 -1
  198. package/dist/src/goals/goal-workflow-judge.js +1 -1
  199. package/dist/src/infra/ports.js +1 -1
  200. package/dist/src/infra/ssh-tunnel.js +1 -1
  201. package/dist/src/infra/update-check.js +1 -1
  202. package/dist/src/infra/update-restart.js +1 -1
  203. package/dist/src/mcp/channel-bridge.js +1 -1
  204. package/dist/src/migrations/runner.js +1 -1
  205. package/dist/src/notes/service.js +65 -6
  206. package/dist/src/notes/service.js.map +1 -1
  207. package/dist/src/notes/store.js +1 -1
  208. package/dist/src/projects/project-service.d.ts +2 -1
  209. package/dist/src/projects/project-service.js +59 -2
  210. package/dist/src/projects/project-service.js.map +1 -1
  211. package/dist/src/projects/project-store.d.ts +2 -1
  212. package/dist/src/projects/project-store.js +43 -0
  213. package/dist/src/projects/project-store.js.map +1 -1
  214. package/dist/src/projects/types.d.ts +10 -0
  215. package/dist/src/projects/workspace.js +1 -1
  216. package/dist/src/routing/agent-session-key.js +1 -1
  217. package/dist/src/routing/resolve-route.js +1 -1
  218. package/dist/src/routing/resolve-tui-session-key.js +1 -1
  219. package/dist/src/session/client-history.d.ts +3 -0
  220. package/dist/src/session/client-history.js +24 -9
  221. package/dist/src/session/client-history.js.map +1 -1
  222. package/dist/src/session/init-session-turn.js +1 -1
  223. package/dist/src/session/resolve-session.js +1 -1
  224. package/dist/src/session/session-title.js +2 -2
  225. package/dist/src/session/store.js +1 -1
  226. package/dist/src/session/types.d.ts +4 -0
  227. package/dist/src/session/types.js.map +1 -1
  228. package/dist/src/storage/sqlite/activity-repository.d.ts +8 -0
  229. package/dist/src/storage/sqlite/activity-repository.js +208 -0
  230. package/dist/src/storage/sqlite/activity-repository.js.map +1 -0
  231. package/dist/src/storage/sqlite/connection.js +1 -1
  232. package/dist/src/storage/sqlite/index.d.ts +1 -0
  233. package/dist/src/storage/sqlite/index.js +2 -1
  234. package/dist/src/storage/sqlite/migrations/024_activity_events.sql +62 -0
  235. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  236. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  237. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  238. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  239. package/dist/src/storage/sqlite/row-mappers.js +1 -1
  240. package/dist/src/storage/sqlite/schema.js +1 -1
  241. package/dist/src/storage/sqlite/schema.sql +63 -0
  242. package/dist/src/storage/sqlite/session-repository.js +11 -0
  243. package/dist/src/storage/sqlite/session-repository.js.map +1 -1
  244. package/dist/src/tui/backends/embedded-backend.d.ts +13 -0
  245. package/dist/src/tui/backends/embedded-backend.js +76 -7
  246. package/dist/src/tui/backends/embedded-backend.js.map +1 -1
  247. package/dist/src/tui/backends/gateway-sse-backend.d.ts +13 -0
  248. package/dist/src/tui/backends/gateway-sse-backend.js +53 -0
  249. package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
  250. package/dist/src/tui/chat-history.js +16 -3
  251. package/dist/src/tui/chat-history.js.map +1 -1
  252. package/dist/src/tui/clipboard-image.js +1 -1
  253. package/dist/src/tui/components/chat-log.d.ts +23 -3
  254. package/dist/src/tui/components/chat-log.js +68 -9
  255. package/dist/src/tui/components/chat-log.js.map +1 -1
  256. package/dist/src/tui/components/tui-bottom-bar.js +9 -5
  257. package/dist/src/tui/components/tui-bottom-bar.js.map +1 -1
  258. package/dist/src/tui/tui-backend.d.ts +16 -0
  259. package/dist/src/tui/tui-command-formatters.js +2 -2
  260. package/dist/src/tui/tui-commands.d.ts +9 -0
  261. package/dist/src/tui/tui-commands.js +95 -6
  262. package/dist/src/tui/tui-commands.js.map +1 -1
  263. package/dist/src/tui/tui-picker-overlay.d.ts +1 -0
  264. package/dist/src/tui/tui-picker-overlay.js +36 -1
  265. package/dist/src/tui/tui-picker-overlay.js.map +1 -1
  266. package/dist/src/tui/tui-picker-services.d.ts +13 -0
  267. package/dist/src/tui/tui-run-state.js +11 -0
  268. package/dist/src/tui/tui-run-state.js.map +1 -1
  269. package/dist/src/tui/tui-run-status-format.d.ts +3 -0
  270. package/dist/src/tui/tui-run-status-format.js +33 -0
  271. package/dist/src/tui/tui-run-status-format.js.map +1 -0
  272. package/dist/src/tui/tui-session-actions.d.ts +5 -0
  273. package/dist/src/tui/tui-session-actions.js +24 -0
  274. package/dist/src/tui/tui-session-actions.js.map +1 -1
  275. package/dist/src/tui/tui-timeline-picker.d.ts +19 -0
  276. package/dist/src/tui/tui-timeline-picker.js +81 -0
  277. package/dist/src/tui/tui-timeline-picker.js.map +1 -0
  278. package/dist/src/tui/tui-timeline.d.ts +15 -0
  279. package/dist/src/tui/tui-timeline.js +65 -0
  280. package/dist/src/tui/tui-timeline.js.map +1 -0
  281. package/dist/src/tui/tui-types.d.ts +1 -0
  282. package/dist/src/tui/tui-types.js +1 -0
  283. package/dist/src/tui/tui-types.js.map +1 -1
  284. package/dist/src/tui/tui.js +31 -25
  285. package/dist/src/tui/tui.js.map +1 -1
  286. package/dist/src/utils/index.js +1 -1
  287. package/dist/src/utils/logger/index.js +1 -1
  288. package/dist/src/utils/logger/stats.d.ts +3 -3
  289. package/dist/src/utils/logger.js +1 -1
  290. package/dist/src/work-items/agent-context.d.ts +5 -1
  291. package/dist/src/work-items/agent-context.js +39 -3
  292. package/dist/src/work-items/agent-context.js.map +1 -1
  293. package/dist/src/work-items/work-item-service.d.ts +2 -0
  294. package/dist/src/work-items/work-item-service.js +97 -0
  295. package/dist/src/work-items/work-item-service.js.map +1 -1
  296. package/dist/src/workflows/draft/workflow-draft-service.js +1 -1
  297. package/dist/src/workflows/service/workflow-session-bridge.js +1 -1
  298. package/package.json +5 -5
  299. package/dist/gateway/static/root/assets/agents-BnTB7-c5.js +0 -2
  300. package/dist/gateway/static/root/assets/apps-page-B6bG65SW.js +0 -1
  301. package/dist/gateway/static/root/assets/automations-page-1lVbo0dS.js +0 -1
  302. package/dist/gateway/static/root/assets/browser-settings-page-CzDBlOK0.js +0 -8
  303. package/dist/gateway/static/root/assets/channels-settings-Df4m7p1k.js +0 -1
  304. package/dist/gateway/static/root/assets/connectors-page-BMTphmHS.js +0 -2
  305. package/dist/gateway/static/root/assets/goal-detail-page-C2cTxf71.js +0 -1
  306. package/dist/gateway/static/root/assets/index-BNHDd2j1.css +0 -1
  307. package/dist/gateway/static/root/assets/index-BPXLPMuY.js +0 -193
  308. package/dist/gateway/static/root/assets/logs-page-CGc3_CQU.js +0 -2
  309. package/dist/gateway/static/root/assets/messages-CjuIJcZl.js +0 -3
  310. package/dist/gateway/static/root/assets/models-hub-panel-Drz4UQMb.js +0 -2
  311. package/dist/gateway/static/root/assets/notes-page-CY1ylng1.js +0 -1
  312. package/dist/gateway/static/root/assets/notes-workbench-X7IaD--t.js +0 -2
  313. package/dist/gateway/static/root/assets/project-detail-page-DE5adRBE.js +0 -1
  314. package/dist/gateway/static/root/assets/projects-page-CuOb1k6F.js +0 -1
  315. package/dist/gateway/static/root/assets/remote-access-hub-BOxNrUVA.js +0 -1
  316. package/dist/gateway/static/root/assets/sessions-page-CY0IQcGW.js +0 -1
  317. package/dist/gateway/static/root/assets/settings-advanced-gate-D4NBNVCB.js +0 -1
  318. package/dist/gateway/static/root/assets/settings-form-section-BBYUDLVd.js +0 -1
  319. package/dist/gateway/static/root/assets/settings-page-DaO7zYZM.js +0 -1
  320. package/dist/gateway/static/root/assets/settings-page-layout-D8g9PAek.js +0 -1
  321. package/dist/gateway/static/root/assets/setup-status-panel-Bks0CLLT.js +0 -1
  322. package/dist/gateway/static/root/assets/shares-settings-CEZsKm9r.js +0 -1
  323. package/dist/gateway/static/root/assets/skill-reload-api-oTkHbb9W.js +0 -1
  324. package/dist/gateway/static/root/assets/skills-page-DigsbZ6K.js +0 -2
  325. package/dist/gateway/static/root/assets/voice-api-key-field-CEJklEgb.js +0 -1
  326. package/dist/gateway/static/root/assets/workflows-page-OLQiUpoW.js +0 -18
@@ -1,8 +1,8 @@
1
+ import { getAsyncLogContext, inboundCorrelationMetadataFromAsyncLogContext, runWithLogContext, updateAsyncLogContext } from "./logger/context.js";
1
2
  import { getLogDir, getLoggerConfig } from "./logger/config.js";
2
3
  import { getRuntimeLogStats } from "./logger/stats.js";
3
4
  import { flushAndClose, isLoggerShuttingDown, setShuttingDown } from "./logger/shutdown.js";
4
5
  import { cleanOldLogs, rotateLogs } from "./logger/rotation.js";
5
- import { getAsyncLogContext, inboundCorrelationMetadataFromAsyncLogContext, runWithLogContext, updateAsyncLogContext } from "./logger/context.js";
6
6
  import { isLogRedactionEnabled, redactObject, redactPemBlock, redactSecret, redactSensitiveInfo } from "./logger/redact.js";
7
7
  import { exportLog, flushExporters, getExporters, initializeExporters } from "./logger/exporters.js";
8
8
  import { configureAuditLog, getAuditConfig, logAuditEvent, logAuthEvent, logConfigChange, logDataAccess, logPermissionChange } from "./logger/audit.js";
@@ -1,11 +1,11 @@
1
1
  import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
2
2
  import { PACKAGE_VERSION, init_package_version } from "../../package-version.js";
3
+ import { getAsyncLogContext, getAsyncLogCorrelationKeys, inboundCorrelationMetadataFromAsyncLogContext, init_context, mergeContext, runWithLogContext, updateAsyncLogContext } from "./context.js";
3
4
  import { config, getLogDir, getLoggerConfig, init_config } from "./config.js";
4
5
  import { init_streams, initializeStreams } from "./streams.js";
5
6
  import { getRuntimeLogStats, incrementStats, init_stats } from "./stats.js";
6
7
  import { flushAndClose, init_shutdown, isLoggerShuttingDown, setShuttingDown } from "./shutdown.js";
7
8
  import { cleanOldLogs, init_rotation, rotateLogs } from "./rotation.js";
8
- import { getAsyncLogContext, getAsyncLogCorrelationKeys, inboundCorrelationMetadataFromAsyncLogContext, init_context, mergeContext, runWithLogContext, updateAsyncLogContext } from "./context.js";
9
9
  import { init_redact, isLogRedactionEnabled, redactLogRecord, redactObject, redactPemBlock, redactSecret, redactSensitiveInfo } from "./redact.js";
10
10
  import { exportLog, flushExporters, getExporters, init_exporters, initializeExporters } from "./exporters.js";
11
11
  import { configureAuditLog, getAuditConfig, init_audit, logAuditEvent, logAuthEvent, logConfigChange, logDataAccess, logPermissionChange } from "./audit.js";
@@ -12,13 +12,13 @@ export declare function incrementStats(level: LogLevel, module?: string): void;
12
12
  */
13
13
  export declare function getRuntimeLogStats(): {
14
14
  byLevel: {
15
- error: number;
16
- debug: number;
17
- silent: number;
18
15
  trace: number;
16
+ debug: number;
19
17
  info: number;
20
18
  warn: number;
19
+ error: number;
21
20
  fatal: number;
21
+ silent: number;
22
22
  };
23
23
  byModule: {
24
24
  [k: string]: number;
@@ -1,9 +1,9 @@
1
1
  import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
2
+ import { getAsyncLogContext, inboundCorrelationMetadataFromAsyncLogContext, runWithLogContext, updateAsyncLogContext } from "./logger/context.js";
2
3
  import { getLogDir, getLoggerConfig } from "./logger/config.js";
3
4
  import { getRuntimeLogStats } from "./logger/stats.js";
4
5
  import { flushAndClose, isLoggerShuttingDown, setShuttingDown } from "./logger/shutdown.js";
5
6
  import { cleanOldLogs, rotateLogs } from "./logger/rotation.js";
6
- import { getAsyncLogContext, inboundCorrelationMetadataFromAsyncLogContext, runWithLogContext, updateAsyncLogContext } from "./logger/context.js";
7
7
  import { isLogRedactionEnabled, redactObject, redactPemBlock, redactSecret, redactSensitiveInfo } from "./logger/redact.js";
8
8
  import { exportLog, flushExporters, getExporters, initializeExporters } from "./logger/exporters.js";
9
9
  import { configureAuditLog, getAuditConfig, logAuditEvent, logAuthEvent, logConfigChange, logDataAccess, logPermissionChange } from "./logger/audit.js";
@@ -1,3 +1,7 @@
1
1
  import type { AgentSourceContext } from '../agent/source-context/types.js';
2
+ import type { MediaRef } from '../media/types.js';
2
3
  import type { WorkItem } from './types.js';
3
- export declare function buildWorkItemAgentContext(item: WorkItem): AgentSourceContext;
4
+ export declare function buildWorkItemAgentContext(item: WorkItem, opts?: {
5
+ attachments?: readonly MediaRef[];
6
+ includeImages?: boolean;
7
+ }): Promise<AgentSourceContext>;
@@ -1,12 +1,47 @@
1
+ import { readMediaReferenceBase64 } from "../media/media-reference.js";
1
2
  //#region src/work-items/agent-context.ts
3
+ const MAX_NATIVE_VISION_IMAGES = 6;
4
+ const MAX_NATIVE_VISION_IMAGE_BYTES = 2 * 1024 * 1024;
2
5
  function contextLine(label, value) {
3
6
  if (value === void 0 || value === null) return null;
4
7
  const text = String(value).trim();
5
8
  return text ? `${label}: ${text}` : null;
6
9
  }
7
- function buildWorkItemAgentContext(item) {
10
+ async function loadWorkItemNativeVisionImages(item) {
11
+ const images = [];
12
+ for (const attachment of item.attachments ?? []) {
13
+ if (attachment.type !== "image") continue;
14
+ if (!attachment.mimeType.toLowerCase().startsWith("image/")) continue;
15
+ if (attachment.size > MAX_NATIVE_VISION_IMAGE_BYTES) continue;
16
+ try {
17
+ const loaded = await readMediaReferenceBase64(attachment.mediaUri, MAX_NATIVE_VISION_IMAGE_BYTES);
18
+ images.push({
19
+ type: "image",
20
+ data: loaded.data,
21
+ mimeType: attachment.mimeType || loaded.mimeType
22
+ });
23
+ if (images.length >= MAX_NATIVE_VISION_IMAGES) break;
24
+ } catch {
25
+ continue;
26
+ }
27
+ }
28
+ return images;
29
+ }
30
+ function renderAttachmentLines(item, refs) {
31
+ if (!item.attachments?.length) return "";
32
+ return item.attachments.slice(0, 12).map((attachment, index) => {
33
+ const ref = refs?.[index];
34
+ return [
35
+ `- ${ref?.name ?? attachment.fileName} (${ref?.mimeType ?? attachment.mimeType}, ${ref?.size ?? attachment.size} bytes)`,
36
+ ` xopc-media-uri:${ref?.uri ?? attachment.mediaUri}`,
37
+ " Use the read_media tool with the xopc-media-uri value when you need to inspect this attachment."
38
+ ].join("\n");
39
+ }).join("\n");
40
+ }
41
+ async function buildWorkItemAgentContext(item, opts = {}) {
8
42
  const links = item.links?.length ? item.links.slice(0, 12).map((link) => `- ${link.kind}: ${link.title || link.targetId}${link.statusSnapshot ? ` (${link.statusSnapshot})` : ""}`).join("\n") : "";
9
- const attachments = item.attachments?.length ? item.attachments.slice(0, 12).map((attachment) => `- ${attachment.fileName} (${attachment.mimeType}, ${attachment.size} bytes)`).join("\n") : "";
43
+ const attachments = renderAttachmentLines(item, opts.attachments);
44
+ const images = opts.includeImages === false ? [] : await loadWorkItemNativeVisionImages(item);
10
45
  const text = [
11
46
  "You are working inside a project work item. Treat this as the active task context, not as a new user message.",
12
47
  "",
@@ -30,7 +65,8 @@ function buildWorkItemAgentContext(item) {
30
65
  sourceId: item.id,
31
66
  version: String(item.updatedAt),
32
67
  title: item.title,
33
- text
68
+ text,
69
+ ...images.length ? { images } : {}
34
70
  };
35
71
  }
36
72
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"agent-context.js","names":[],"sources":["../../../src/work-items/agent-context.ts"],"sourcesContent":["import type { AgentSourceContext } from '../agent/source-context/types.js';\n\nimport type { WorkItem } from './types.js';\n\nfunction contextLine(label: string, value: string | number | undefined | null): string | null {\n if (value === undefined || value === null) return null;\n const text = String(value).trim();\n return text ? `${label}: ${text}` : null;\n}\n\nexport function buildWorkItemAgentContext(item: WorkItem): AgentSourceContext {\n const links = item.links?.length\n ? item.links\n .slice(0, 12)\n .map((link) => `- ${link.kind}: ${link.title || link.targetId}${link.statusSnapshot ? ` (${link.statusSnapshot})` : ''}`)\n .join('\\n')\n : '';\n const attachments = item.attachments?.length\n ? item.attachments\n .slice(0, 12)\n .map((attachment) => `- ${attachment.fileName} (${attachment.mimeType}, ${attachment.size} bytes)`)\n .join('\\n')\n : '';\n const text = [\n 'You are working inside a project work item. Treat this as the active task context, not as a new user message.',\n '',\n contextLine('Work item id', item.id),\n contextLine('Project id', item.projectId),\n contextLine('Title', item.title),\n contextLine('Status', item.status),\n contextLine('Priority', item.priority),\n contextLine('Owner agent', item.ownerAgentId),\n contextLine('Description', item.description),\n contextLine('Next action', item.nextAction),\n contextLine('Blocked reason', item.blockedReason),\n item.dueAt ? contextLine('Due at', new Date(item.dueAt).toISOString()) : null,\n links ? `Linked executions:\\n${links}` : null,\n attachments ? `Attachments:\\n${attachments}` : null,\n '',\n 'When you answer, keep the work item moving. If the discussion changes scope, call out the suggested work item update explicitly.',\n ].filter(Boolean).join('\\n');\n\n return {\n kind: 'work_item',\n sourceId: item.id,\n version: String(item.updatedAt),\n title: item.title,\n text,\n };\n}\n"],"mappings":";AAIA,SAAS,YAAY,OAAe,OAA0D;AAC5F,KAAI,UAAU,KAAA,KAAa,UAAU,KAAM,QAAO;CAClD,MAAM,OAAO,OAAO,MAAM,CAAC,MAAM;AACjC,QAAO,OAAO,GAAG,MAAM,IAAI,SAAS;;AAGtC,SAAgB,0BAA0B,MAAoC;CAC5E,MAAM,QAAQ,KAAK,OAAO,SACtB,KAAK,MACJ,MAAM,GAAG,GAAG,CACZ,KAAK,SAAS,KAAK,KAAK,KAAK,IAAI,KAAK,SAAS,KAAK,WAAW,KAAK,iBAAiB,KAAK,KAAK,eAAe,KAAK,KAAK,CACxH,KAAK,KAAK,GACX;CACJ,MAAM,cAAc,KAAK,aAAa,SAClC,KAAK,YACJ,MAAM,GAAG,GAAG,CACZ,KAAK,eAAe,KAAK,WAAW,SAAS,IAAI,WAAW,SAAS,IAAI,WAAW,KAAK,SAAS,CAClG,KAAK,KAAK,GACX;CACJ,MAAM,OAAO;EACX;EACA;EACA,YAAY,gBAAgB,KAAK,GAAG;EACpC,YAAY,cAAc,KAAK,UAAU;EACzC,YAAY,SAAS,KAAK,MAAM;EAChC,YAAY,UAAU,KAAK,OAAO;EAClC,YAAY,YAAY,KAAK,SAAS;EACtC,YAAY,eAAe,KAAK,aAAa;EAC7C,YAAY,eAAe,KAAK,YAAY;EAC5C,YAAY,eAAe,KAAK,WAAW;EAC3C,YAAY,kBAAkB,KAAK,cAAc;EACjD,KAAK,QAAQ,YAAY,UAAU,IAAI,KAAK,KAAK,MAAM,CAAC,aAAa,CAAC,GAAG;EACzE,QAAQ,uBAAuB,UAAU;EACzC,cAAc,iBAAiB,gBAAgB;EAC/C;EACA;EACD,CAAC,OAAO,QAAQ,CAAC,KAAK,KAAK;AAE5B,QAAO;EACL,MAAM;EACN,UAAU,KAAK;EACf,SAAS,OAAO,KAAK,UAAU;EAC/B,OAAO,KAAK;EACZ;EACD"}
1
+ {"version":3,"file":"agent-context.js","names":[],"sources":["../../../src/work-items/agent-context.ts"],"sourcesContent":["import type { ImageContent } from '@earendil-works/pi-ai';\n\nimport type { AgentSourceContext } from '../agent/source-context/types.js';\nimport { readMediaReferenceBase64 } from '../media/media-reference.js';\nimport type { MediaRef } from '../media/types.js';\n\nimport type { WorkItem } from './types.js';\n\nconst MAX_NATIVE_VISION_IMAGES = 6;\nconst MAX_NATIVE_VISION_IMAGE_BYTES = 2 * 1024 * 1024;\n\nfunction contextLine(label: string, value: string | number | undefined | null): string | null {\n if (value === undefined || value === null) return null;\n const text = String(value).trim();\n return text ? `${label}: ${text}` : null;\n}\n\nasync function loadWorkItemNativeVisionImages(item: WorkItem): Promise<ImageContent[]> {\n const images: ImageContent[] = [];\n for (const attachment of item.attachments ?? []) {\n if (attachment.type !== 'image') continue;\n if (!attachment.mimeType.toLowerCase().startsWith('image/')) continue;\n if (attachment.size > MAX_NATIVE_VISION_IMAGE_BYTES) continue;\n try {\n const loaded = await readMediaReferenceBase64(attachment.mediaUri, MAX_NATIVE_VISION_IMAGE_BYTES);\n images.push({ type: 'image', data: loaded.data, mimeType: attachment.mimeType || loaded.mimeType });\n if (images.length >= MAX_NATIVE_VISION_IMAGES) break;\n } catch {\n continue;\n }\n }\n return images;\n}\n\nfunction renderAttachmentLines(item: WorkItem, refs?: readonly MediaRef[]): string {\n if (!item.attachments?.length) return '';\n return item.attachments\n .slice(0, 12)\n .map((attachment, index) => {\n const ref = refs?.[index];\n return [\n `- ${ref?.name ?? attachment.fileName} (${ref?.mimeType ?? attachment.mimeType}, ${ref?.size ?? attachment.size} bytes)`,\n ` xopc-media-uri:${ref?.uri ?? attachment.mediaUri}`,\n ' Use the read_media tool with the xopc-media-uri value when you need to inspect this attachment.',\n ].join('\\n');\n })\n .join('\\n');\n}\n\nexport async function buildWorkItemAgentContext(\n item: WorkItem,\n opts: { attachments?: readonly MediaRef[]; includeImages?: boolean } = {},\n): Promise<AgentSourceContext> {\n const links = item.links?.length\n ? item.links\n .slice(0, 12)\n .map((link) => `- ${link.kind}: ${link.title || link.targetId}${link.statusSnapshot ? ` (${link.statusSnapshot})` : ''}`)\n .join('\\n')\n : '';\n const attachments = renderAttachmentLines(item, opts.attachments);\n const images = opts.includeImages === false ? [] : await loadWorkItemNativeVisionImages(item);\n const text = [\n 'You are working inside a project work item. Treat this as the active task context, not as a new user message.',\n '',\n contextLine('Work item id', item.id),\n contextLine('Project id', item.projectId),\n contextLine('Title', item.title),\n contextLine('Status', item.status),\n contextLine('Priority', item.priority),\n contextLine('Owner agent', item.ownerAgentId),\n contextLine('Description', item.description),\n contextLine('Next action', item.nextAction),\n contextLine('Blocked reason', item.blockedReason),\n item.dueAt ? contextLine('Due at', new Date(item.dueAt).toISOString()) : null,\n links ? `Linked executions:\\n${links}` : null,\n attachments ? `Attachments:\\n${attachments}` : null,\n '',\n 'When you answer, keep the work item moving. If the discussion changes scope, call out the suggested work item update explicitly.',\n ].filter(Boolean).join('\\n');\n\n return {\n kind: 'work_item',\n sourceId: item.id,\n version: String(item.updatedAt),\n title: item.title,\n text,\n ...(images.length ?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AW,KAAK,iBAAiB,KAAK,KAAK,eAAe,KAAK,KAAK,CACxH,KAAK,KAAK,GACX;CACJ,MAAM,cAAc,sBAAsB,MAAM,KAAK,YAAY;CACjE,MAAM,SAAS,KAAK,kBAAkB,QAAQ,EAAE,GAAG,MAAM,+BAA+B,KAAK;CAC7F,MAAM,OAAO;EACX;EACA;EACA,YAAY,gBAAgB,KAAK,GAAG;EACpC,YAAY,cAAc,KAAK,UAAU;EACzC,YAAY,SAAS,KAAK,MAAM;EAChC,YAAY,UAAU,KAAK,OAAO;EAClC,YAAY,YAAY,KAAK,SAAS;EACtC,YAAY,eAAe,KAAK,aAAa;EAC7C,YAAY,eAAe,KAAK,YAAY;EAC5C,YAAY,eAAe,KAAK,WAAW;EAC3C,YAAY,kBAAkB,KAAK,cAAc;EACjD,KAAK,QAAQ,YAAY,UAAU,IAAI,KAAK,KAAK,MAAM,CAAC,aAAa,CAAC,GAAG;EACzE,QAAQ,uBAAuB,UAAU;EACzC,cAAc,iBAAiB,gBAAgB;EAC/C;EACA;EACD,CAAC,OAAO,QAAQ,CAAC,KAAK,KAAK;AAE5B,QAAO;EACL,MAAM;EACN,UAAU,KAAK;EACf,SAAS,OAAO,KAAK,UAAU;EAC/B,OAAO,KAAK;EACZ;EACA,GAAI,OAAO,SAAS,EAAE,QAAQ,GAAG,EAAE;EACpC"}
@@ -1,3 +1,4 @@
1
+ import type { MediaRef } from '../media/types.js';
1
2
  import { WorkItemStore } from './work-item-store.js';
2
3
  import type { CreateWorkItemUpdateSuggestionInput, CreateWorkItemInput, UpdateWorkItemInput, WorkItem, WorkItemAttachment, WorkItemEvent, WorkItemLink, WorkItemListQuery, WorkItemListResult, WorkItemUpdateSuggestion, WorkItemUpdateSuggestionStatus } from './types.js';
3
4
  export declare const WORK_ITEM_ATTACHMENT_MAX_BYTES: number;
@@ -23,6 +24,7 @@ export declare class WorkItemService {
23
24
  buffer: Buffer;
24
25
  } | null>;
25
26
  removeAttachment(workItemId: string, attachmentId: string): Promise<WorkItemAttachment | null>;
27
+ snapshotAttachmentsForGoal(workItemId: string): Promise<MediaRef[] | null>;
26
28
  createUpdateSuggestion(workItemId: string, input: CreateWorkItemUpdateSuggestionInput): WorkItemUpdateSuggestion | null;
27
29
  listUpdateSuggestions(workItemId: string, status?: WorkItemUpdateSuggestionStatus): WorkItemUpdateSuggestion[];
28
30
  applyUpdateSuggestion(id: string): {
@@ -1,3 +1,4 @@
1
+ import { changedFieldsFromPatch, emitActivity, systemActivityActor, systemActivitySource } from "../activity/emitter.js";
1
2
  import { deleteMediaBuffer, mimeTypeFromMediaPath, saveMediaBuffer } from "../media/store.js";
2
3
  import { readMediaReference } from "../media/media-reference.js";
3
4
  import { WorkItemStore } from "./work-item-store.js";
@@ -11,6 +12,9 @@ function inferAttachmentType(mimeType) {
11
12
  if (mimeType.startsWith("video/")) return "video";
12
13
  return "file";
13
14
  }
15
+ function attachmentTypeForMediaRef(attachment) {
16
+ return attachment.type === "file" ? "document" : attachment.type;
17
+ }
14
18
  var WorkItemService = class {
15
19
  constructor(store = new WorkItemStore()) {
16
20
  this.store = store;
@@ -25,6 +29,27 @@ var WorkItemService = class {
25
29
  status: item.status,
26
30
  priority: item.priority
27
31
  });
32
+ emitActivity({
33
+ type: "work_item.created",
34
+ primaryObject: {
35
+ kind: "work_item",
36
+ id: item.id,
37
+ title: item.title
38
+ },
39
+ actor: systemActivityActor(),
40
+ source: systemActivitySource(),
41
+ payload: {
42
+ title: item.title,
43
+ status: item.status,
44
+ priority: item.priority
45
+ },
46
+ scopes: [{
47
+ scopeKind: "project",
48
+ scopeId: projectId,
49
+ reason: "object_owner"
50
+ }],
51
+ nowMs: item.createdAt
52
+ });
28
53
  return {
29
54
  ...item,
30
55
  links: []
@@ -44,6 +69,31 @@ var WorkItemService = class {
44
69
  });
45
70
  else this.store.addEvent(id, "updated", patch);
46
71
  if (!before.archivedAt && after.archivedAt) this.store.addEvent(id, "archived", { archivedAt: after.archivedAt });
72
+ const type = !before.archivedAt && after.archivedAt ? "work_item.archived" : before.status !== after.status ? "work_item.status_changed" : "work_item.updated";
73
+ emitActivity({
74
+ type,
75
+ primaryObject: {
76
+ kind: "work_item",
77
+ id: after.id,
78
+ title: after.title
79
+ },
80
+ actor: systemActivityActor(),
81
+ source: systemActivitySource(),
82
+ payload: {
83
+ changes: changedFieldsFromPatch(patch),
84
+ ...type === "work_item.status_changed" ? {
85
+ from: before.status,
86
+ to: after.status
87
+ } : {},
88
+ ...type === "work_item.archived" ? { archivedAt: after.archivedAt } : {}
89
+ },
90
+ scopes: [{
91
+ scopeKind: "project",
92
+ scopeId: after.projectId,
93
+ reason: "object_owner"
94
+ }],
95
+ nowMs: after.updatedAt
96
+ });
47
97
  return after;
48
98
  }
49
99
  addLink(workItemId, input, eventType = "link_added") {
@@ -58,6 +108,28 @@ var WorkItemService = class {
58
108
  title: link.title,
59
109
  statusSnapshot: link.statusSnapshot
60
110
  });
111
+ const item = this.store.get(workItemId);
112
+ if (item) emitActivity({
113
+ type: "work_item.link_added",
114
+ primaryObject: {
115
+ kind: "work_item",
116
+ id: item.id,
117
+ title: item.title
118
+ },
119
+ actor: systemActivityActor(),
120
+ source: systemActivitySource(),
121
+ payload: { target: {
122
+ kind: link.kind,
123
+ id: link.targetId,
124
+ title: link.title
125
+ } },
126
+ scopes: [{
127
+ scopeKind: "project",
128
+ scopeId: item.projectId,
129
+ reason: "object_owner"
130
+ }],
131
+ nowMs: link.createdAt
132
+ });
61
133
  return link;
62
134
  }
63
135
  listEvents(workItemId) {
@@ -115,6 +187,31 @@ var WorkItemService = class {
115
187
  });
116
188
  return attachment;
117
189
  }
190
+ async snapshotAttachmentsForGoal(workItemId) {
191
+ const item = this.store.get(workItemId);
192
+ if (!item) return null;
193
+ const refs = [];
194
+ for (const attachment of item.attachments ?? []) {
195
+ const { buffer } = await readMediaReference(attachment.mediaUri, WORK_ITEM_ATTACHMENT_MAX_BYTES);
196
+ const saved = await saveMediaBuffer(buffer, {
197
+ bucket: "inbound",
198
+ contentType: attachment.mimeType,
199
+ maxBytes: WORK_ITEM_ATTACHMENT_MAX_BYTES,
200
+ originalFilename: attachment.fileName
201
+ });
202
+ refs.push({
203
+ id: saved.id,
204
+ bucket: saved.bucket,
205
+ type: attachmentTypeForMediaRef(attachment),
206
+ mimeType: saved.contentType || attachment.mimeType,
207
+ name: attachment.fileName,
208
+ size: saved.size,
209
+ uri: saved.uri,
210
+ path: saved.path
211
+ });
212
+ }
213
+ return refs;
214
+ }
118
215
  createUpdateSuggestion(workItemId, input) {
119
216
  const suggestion = this.store.createUpdateSuggestion(workItemId, input);
120
217
  if (!suggestion) return null;
@@ -1 +1 @@
1
- {"version":3,"file":"work-item-service.js","names":[],"sources":["../../../src/work-items/work-item-service.ts"],"sourcesContent":["import { deleteMediaBuffer, mimeTypeFromMediaPath, saveMediaBuffer } from '../media/store.js';\nimport { readMediaReference } from '../media/media-reference.js';\nimport { WorkItemStore } from './work-item-store.js';\nimport type {\n CreateWorkItemUpdateSuggestionInput,\n CreateWorkItemInput,\n UpdateWorkItemInput,\n WorkItem,\n WorkItemAttachment,\n WorkItemEvent,\n WorkItemLink,\n WorkItemListQuery,\n WorkItemListResult,\n WorkItemUpdateSuggestion,\n WorkItemUpdateSuggestionStatus,\n} from './types.js';\n\nexport const WORK_ITEM_ATTACHMENT_MAX_BYTES = 25 * 1024 * 1024;\nexport const WORK_ITEM_ATTACHMENT_MAX_COUNT = 10;\nexport const WORK_ITEM_ATTACHMENT_UPLOAD_BODY_MAX_BYTES =\n WORK_ITEM_ATTACHMENT_MAX_BYTES * WORK_ITEM_ATTACHMENT_MAX_COUNT + 1024 * 1024;\n\nfunction inferAttachmentType(mimeType: string): WorkItemAttachment['type'] {\n if (mimeType.startsWith('image/')) return 'image';\n if (mimeType.startsWith('audio/')) return 'audio';\n if (mimeType.startsWith('video/')) return 'video';\n return 'file';\n}\n\nexport class WorkItemService {\n constructor(private readonly store = new WorkItemStore()) {}\n\n listProjectWorkItems(projectId: string, query: WorkItemListQuery = {}): WorkItemListResult {\n return this.store.list(projectId, query);\n }\n\n createProjectWorkItem(projectId: string, input: CreateWorkItemInput): WorkItem {\n const item = this.store.create(projectId, input);\n this.store.addEvent(item.id, 'created', { title: item.title, status: item.status, priority: item.priority });\n return { ...item, links: [] };\n }\n\n getWorkItem(id: string): WorkItem | null {\n return this.store.get(id);\n }\n\n updateWorkItem(id: string, patch: UpdateWorkItemInput): WorkItem | null {\n const before = this.store.get(id);\n if (!before) return null;\n const after = this.store.update(id, patch);\n if (!after) return null;\n if (before.status !== after.status) {\n this.store.addEvent(id, 'status_changed', { from: before.status, to: after.status });\n } else {\n this.store.addEvent(id, 'updated', patch);\n }\n if (!before.archivedAt && after.archivedAt) {\n this.store.addEvent(id, 'archived', { archivedAt: after.archivedAt });\n }\n return after;\n }\n\n addLink(workItemId: string, input: Omit<WorkItemLink, 'id' | 'workItemId' | 'createdAt'>, eventType: Parameters<WorkItemStore['addEvent']>[1] = 'link_added'): WorkItemLink | null {\n if (!this.store.get(workItemId)) return null;\n const link = this.store.addLink({ ...input, workItemId });\n this.store.addEvent(workItemId, eventType, { kind: link.kind, targetId: link.targetId, title: link.title, statusSnapshot: link.statusSnapshot });\n return link;\n }\n\n listEvents(workItemId: string): WorkItemEvent[] {\n return this.store.listEvents(workItemId);\n }\n\n listAttachments(workItemId: string): WorkItemAttachment[] | null {\n if (!this.store.get(workItemId)) return null;\n return this.store.listAttachments(workItemId);\n }\n\n async addAttachment(\n workItemId: string,\n file: { name: string; buffer: Buffer; mimeType: string },\n ): Promise<WorkItemAttachment | null> {\n if (!this.store.get(workItemId)) return null;\n const saved = await saveMediaBuffer(file.buffer, {\n bucket: 'work-item',\n contentType: file.mimeType,\n maxBytes: WORK_ITEM_ATTACHMENT_MAX_BYTES,\n originalFilename: file.name,\n });\n const mimeType = saved.contentType || file.mimeType || mimeTypeFromMediaPath(saved.path);\n const attachment = this.store.addAttachment({\n workItemId,\n mediaUri: saved.uri,\n mediaId: saved.id,\n bucket: saved.bucket,\n type: inferAttachmentType(mimeType),\n mimeType,\n fileName: file.name.trim() || saved.id,\n size: saved.size,\n });\n this.store.addEvent(workItemId, 'attachment_added', {\n attachmentId: attachment.id,\n fileName: attachment.fileName,\n mimeType: attachment.mimeType,\n size: attachment.size,\n });\n return attachment;\n }\n\n async readAttachment(\n workItemId: string,\n attachmentId: string,\n ): Promise<{ attachment: WorkItemAttachment; buffer: Buffer } | null> {\n const attachment = this.store.getAttachment(workItemId, attachmentId);\n if (!attachment) return null;\n const { buffer } = await readMediaReference(attachment.mediaUri, WORK_ITEM_ATTACHMENT_MAX_BYTES);\n return { attachment, buffer };\n }\n\n async removeAttachment(workItemId: string, attachmentId: string): Promise<WorkItemAttachment | null> {\n const attachment = this.store.removeAttachment(workItemId, attachmentId);\n if (!attachment) return null;\n await deleteMediaBuffer(attachment.mediaId, 'work-item');\n this.store.addEvent(workItemId, 'attachment_removed', {\n attachmentId: attachment.id,\n fileName: attachment.fileName,\n mimeType: attachment.mimeType,\n size: attachment.size,\n });\n return attachment;\n }\n\n createUpdateSuggestion(workItemId: string, input: CreateWorkItemUpdateSuggestionInput): WorkItemUpdateSuggestion | null {\n const suggestion = this.store.createUpdateSuggestion(workItemId, input);\n if (!suggestion) return null;\n this.store.addEvent(workItemId, 'update_suggestion_created', {\n suggestionId: suggestion.id,\n sourceKind: suggestion.sourceKind,\n sourceId: suggestion.sourceId,\n patch: suggestion.patch,\n hasProgressNote: Boolean(suggestion.progressNote),\n });\n return suggestion;\n }\n\n listUpdateSuggestions(workItemId: string, status?: WorkItemUpdateSuggestionStatus): WorkItemUpdateSuggestion[] {\n return this.store.listUpdateSuggestions(workItemId, status);\n }\n\n applyUpdateSuggestion(id: string): { item: WorkItem; suggestion: WorkItemUpdateSuggestion } | null {\n const suggestion = this.store.getUpdateSuggestion(id);\n if (!suggestion || suggestion.status !== 'pending') return null;\n const before = this.store.get(suggestion.workItemId);\n if (!before) return null;\n const patch: UpdateWorkItemInput = {};\n if (suggestion.patch.status !== undefined) patch.status = suggestion.patch.status;\n if (suggestion.patch.nextAction !== undefined) patch.nextAction = suggestion.patch.nextAction;\n if (suggestion.patch.blockedReason !== undefined) patch.blockedReason = suggestion.patch.blockedReason;\n const item = Object.keys(patch).length > 0\n ? this.updateWorkItem(suggestion.workItemId, patch)\n : before;\n if (!item) return null;\n if (suggestion.progressNote) {\n this.store.addEvent(suggestion.workItemId, 'progress_note_added', {\n sourceKind: suggestion.sourceKind,\n sourceId: suggestion.sourceId,\n suggestionId: suggestion.id,\n text: suggestion.progressNote,\n });\n }\n const marked = this.store.markUpdateSuggestion(id, 'applied');\n if (!marked) return null;\n this.store.addEvent(suggestion.workItemId, 'update_suggestion_applied', {\n suggestionId: suggestion.id,\n sourceKind: suggestion.sourceKind,\n sourceId: suggestion.sourceId,\n patch,\n previousStatus: before.status,\n nextStatus: item.status,\n });\n return { item, suggestion: marked };\n }\n\n dismissUpdateSuggestion(id: string): WorkItemUpdateSuggestion | null {\n const suggestion = this.store.getUpdateSuggestion(id);\n if (!suggestion || suggestion.status !== 'pending') return null;\n const marked = this.store.markUpdateSuggestion(id, 'dismissed');\n if (marked) {\n this.store.addEvent(marked.workItemId, 'update_suggestion_dismissed', {\n suggestionId: marked.id,\n sourceKind: marked.sourceKind,\n sourceId: marked.sourceId,\n });\n }\n return marked;\n }\n}\n"],"mappings":";;;;AAiBA,MAAa,iCAAiC,KAAK,OAAO;AAC1D,MAAa,iCAAiC;AAC9C,MAAa,6CACX,iCAAA,KAAkE,OAAO;AAE3E,SAAS,oBAAoB,UAA8C;AACzE,KAAI,SAAS,WAAW,SAAS,CAAE,QAAO;AAC1C,KAAI,SAAS,WAAW,SAAS,CAAE,QAAO;AAC1C,KAAI,SAAS,WAAW,SAAS,CAAE,QAAO;AAC1C,QAAO;;AAGT,IAAa,kBAAb,MAA6B;CAC3B,YAAY,QAAyB,IAAI,eAAe,EAAE;AAA7B,OAAA,QAAA;;CAE7B,qBAAqB,WAAmB,QAA2B,EAAE,E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;CAGrC,wBAAwB,IAA6C;EACnE,MAAM,aAAa,KAAK,MAAM,oBAAoB,GAAG;AACrD,MAAI,CAAC,cAAc,WAAW,WAAW,UAAW,QAAO;EAC3D,MAAM,SAAS,KAAK,MAAM,qBAAqB,IAAI,YAAY;AAC/D,MAAI,OACF,MAAK,MAAM,SAAS,OAAO,YAAY,+BAA+B;GACpE,cAAc,OAAO;GACrB,YAAY,OAAO;GACnB,UAAU,OAAO;GAClB,CAAC;AAEJ,SAAO"}
1
+ {"version":3,"file":"work-item-service.js","names":[],"sources":["../../../src/work-items/work-item-service.ts"],"sourcesContent":["import { changedFieldsFromPatch, emitActivity, systemActivityActor, systemActivitySource } from '../activity/emitter.js';\nimport { deleteMediaBuffer, mimeTypeFromMediaPath, saveMediaBuffer } from '../media/store.js';\nimport { readMediaReference } from '../media/media-reference.js';\nimport type { MediaRef } from '../media/types.js';\nimport { WorkItemStore } from './work-item-store.js';\nimport type {\n CreateWorkItemUpdateSuggestionInput,\n CreateWorkItemInput,\n UpdateWorkItemInput,\n WorkItem,\n WorkItemAttachment,\n WorkItemEvent,\n WorkItemLink,\n WorkItemListQuery,\n WorkItemListResult,\n WorkItemUpdateSuggestion,\n WorkItemUpdateSuggestionStatus,\n} from './types.js';\n\nexport const WORK_ITEM_ATTACHMENT_MAX_BYTES = 25 * 1024 * 1024;\nexport const WORK_ITEM_ATTACHMENT_MAX_COUNT = 10;\nexport const WORK_ITEM_ATTACHMENT_UPLOAD_BODY_MAX_BYTES =\n WORK_ITEM_ATTACHMENT_MAX_BYTES * WORK_ITEM_ATTACHMENT_MAX_COUNT + 1024 * 1024;\n\nfunction inferAttachmentType(mimeType: string): WorkItemAttachment['type'] {\n if (mimeType.startsWith('image/')) return 'image';\n if (mimeType.startsWith('audio/')) return 'audio';\n if (mimeType.startsWith('video/')) return 'video';\n return 'file';\n}\n\nfunction attachmentTypeForMediaRef(attachment: WorkItemAttachment): string {\n return attachment.type === 'file' ? 'document' : attachment.type;\n}\n\nexport class WorkItemService {\n constructor(private readonly store = new WorkItemStore()) {}\n\n listProjectWorkItems(projectId: string, query: WorkItemListQuery = {}): WorkItemListResult {\n return this.store.list(projectId, query);\n }\n\n createProjectWorkItem(projectId: string, input: CreateWorkItemInput): WorkItem {\n const item = this.store.create(projectId, input);\n this.store.addEvent(item.id, 'created', { title: item.title, status: item.status, priority: item.priority });\n emitActivity({\n type: 'work_item.created',\n primaryObject: { kind: 'work_item', id: item.id, title: item.title },\n actor: systemActivityActor(),\n source: systemActivitySource(),\n payload: { title: item.title, status: item.status, priority: item.priority },\n scopes: [{ scopeKind: 'project', scopeId: projectId, reason: 'object_owner' }],\n nowMs: item.createdAt,\n });\n return { ...item, links: [] };\n }\n\n getWorkItem(id: string): WorkItem | null {\n return this.store.get(id);\n }\n\n updateWorkItem(id: string, patch: UpdateWorkItemInput): WorkItem | null {\n const before = this.store.get(id);\n if (!before) return null;\n const after = this.store.update(id, patch);\n if (!after) return null;\n if (before.status !== after.status) {\n this.store.addEvent(id, 'status_changed', { from: before.status, to: after.status });\n } else {\n this.store.addEvent(id, 'updated', patch);\n }\n if (!before.archivedAt && after.archivedAt) {\n this.store.addEvent(id, 'archived', { archivedAt: after.archivedAt });\n }\n const type = !before.archivedAt && after.archivedAt\n ? 'work_item.archived'\n : before.status !== after.status\n ? 'work_item.status_changed'\n : 'work_item.updated';\n emitActivity({\n type,\n primaryObject: { kind: 'work_item', id: after.id, title: after.title },\n actor: systemActivityActor(),\n source: systemActivitySource(),\n payload: {\n changes: changedFieldsFromPatch(patch as Record<string, unknown>),\n ...(type === 'work_item.status_changed' ? { from: before.status, to: after.status } : {}),\n ...(type === 'work_item.archived' ? { archivedAt: after.archivedAt } : {}),\n },\n scopes: [{ scopeKind: 'project', scopeId: after.projectId, reason: 'object_owner' }],\n nowMs: after.updatedAt,\n });\n return after;\n }\n\n addLink(workItemId: string, input: Omit<WorkItemLink, 'id' | 'workItemId' | 'createdAt'>, eventType: Parameters<WorkItemStore['addEvent']>[1] = 'link_added'): WorkItemLink | null {\n if (!this.store.get(workItemId)) return null;\n const link = this.store.addLink({ ...input, workItemId });\n this.store.addEvent(workItemId, eventType, { kind: link.kind, targetId: link.targetId, title: link.title, statusSnapshot: link.statusSnapshot });\n const item = this.store.get(workItemId);\n if (item) {\n emitActivity({\n type: 'work_item.link_added',\n primaryObject: { kind: 'work_item', id: item.id, title: item.title },\n actor: systemActivityActor(),\n source: systemActivitySource(),\n payload: { target: { kind: link.kind, id: link.targetId, title: link.title } },\n scopes: [{ scopeKind: 'project', scopeId: item.projectId, reason: 'object_owner' }],\n nowMs: link.createdAt,\n });\n }\n return link;\n }\n\n listEvents(workItemId: string): WorkItemEvent[] {\n return this.store.listEvents(workItemId);\n }\n\n listAttachments(workItemId: string): WorkItemAttachment[] | null {\n if (!this.store.get(workItemId)) return null;\n return this.store.listAttachments(workItemId);\n }\n\n async addAttachment(\n workItemId: string,\n file: { name: string; buffer: Buffer; mimeType: string },\n ): Promise<WorkItemAttachment | null> {\n if (!this.store.get(workItemId)) return null;\n const saved = await saveMediaBuffer(file.buffer, {\n bucket: 'work-item',\n contentType: file.mimeType,\n maxBytes: WORK_ITEM_ATTACHMENT_MAX_BYTES,\n originalFilename: file.name,\n });\n const mimeType = saved.contentType || file.mimeType || mimeTypeFromMediaPath(saved.path);\n const attachment = this.store.addAttachment({\n workItemId,\n mediaUri: saved.uri,\n mediaId: saved.id,\n bucket: saved.bucket,\n type: inferAttachmentType(mimeType),\n mimeType,\n fileName: file.name.trim() || saved.id,\n size: saved.size,\n });\n this.store.addEvent(workItemId, 'attachment_added', {\n attachmentId: attachment.id,\n fileName: attachment.fileName,\n mimeType: attachment.mimeType,\n size: attachment.size,\n });\n return attachment;\n }\n\n async readAttachment(\n workItemId: string,\n attachmentId: string,\n ): Promise<{ attachment: WorkItemAttachment; buffer: Buffer } | null> {\n const attachment = this.store.getAttachment(workItemId, attachmentId);\n if (!attachment) return null;\n const { buffer } = await readMediaReference(attachment.mediaUri, WORK_ITEM_ATTACHMENT_MAX_BYTES);\n return { attachment, buffer };\n }\n\n async removeAttachment(workItemId: string, attachmentId: string): Promise<WorkItemAttachment | null> {\n const attachment = this.store.removeAttachment(workItemId, attachmentId);\n if (!attachment) return null;\n await deleteMediaBuffer(attachment.mediaId, 'work-item');\n this.store.addEvent(workItemId, 'attachment_removed', {\n attachmentId: attachment.id,\n fileName: attachment.fileName,\n mimeType: attachment.mimeType,\n size: attachment.size,\n });\n return attachment;\n }\n\n async snapshotAttachmentsForGoal(workItemId: string): Promise<MediaRef[] | null> {\n const item = this.store.get(workItemId);\n if (!item) return null;\n const refs: MediaRef[] = [];\n for (const attachment of item.attachments ?? []) {\n const { buffer } = await readMediaReference(attachment.mediaUri, WORK_ITEM_ATTACHMENT_MAX_BYTES);\n const saved = await saveMediaBuffer(buffer, {\n bucket: 'inbound',\n contentType: attachment.mimeType,\n maxBytes: WORK_ITEM_ATTACHMENT_MAX_BYTES,\n originalFilename: attachment.fileName,\n });\n refs.push({\n id: saved.id,\n bucket: saved.bucket,\n type: attachmentTypeForMediaRef(attachment),\n mimeType: saved.contentType || attachment.mimeType,\n name: attachment.fileName,\n size: saved.size,\n uri: saved.uri,\n path: saved.path,\n });\n }\n return refs;\n }\n\n createUpdateSuggestion(workItemId: string, input: CreateWorkItemUpdateSuggestionInput): WorkItemUpdateSuggestion | null {\n const suggestion = this.store.createUpdateSuggestion(workItemId, input);\n if (!suggestion) return null;\n this.store.addEvent(workItemId, 'update_suggestion_created', {\n suggestionId: suggestion.id,\n sourceKind: suggestion.sourceKind,\n sourceId: suggestion.sourceId,\n patch: suggestion.patch,\n hasProgressNote: Boolean(suggestion.progressNote),\n });\n return suggestion;\n }\n\n listUpdateSuggestions(workItemId: string, status?: WorkItemUpdateSuggestionStatus): WorkItemUpdateSuggestion[] {\n return this.store.listUpdateSuggestions(workItemId, status);\n }\n\n applyUpdateSuggestion(id: string): { item: WorkItem; suggestion: WorkItemUpdateSuggestion } | null {\n const suggestion = this.store.getUpdateSuggestion(id);\n if (!suggestion || suggestion.status !== 'pending') return null;\n const before = this.store.get(suggestion.workItemId);\n if (!before) return null;\n const patch: UpdateWorkItemInput = {};\n if (suggestion.patch.status !== undefined) patch.status = suggestion.patch.status;\n if (suggestion.patch.nextAction !== undefined) patch.nextAction = suggestion.patch.nextAction;\n if (suggestion.patch.blockedReason !== undefined) patch.blockedReason = suggestion.patch.blockedReason;\n const item = Object.keys(patch).length > 0\n ? this.updateWorkItem(suggestion.workItemId, patch)\n : before;\n if (!item) return null;\n if (suggestion.progressNote) {\n this.store.addEvent(suggestion.workItemId, 'progress_note_added', {\n sourceKind: suggestion.sourceKind,\n sourceId: suggestion.sourceId,\n suggestionId: suggestion.id,\n text: suggestion.progressNote,\n });\n }\n const marked = this.store.markUpdateSuggestion(id, 'applied');\n if (!marked) return null;\n this.store.addEvent(suggestion.workItemId, 'update_suggestion_applied', {\n suggestionId: suggestion.id,\n sourceKind: suggestion.sourceKind,\n sourceId: suggestion.sourceId,\n patch,\n previousStatus: before.status,\n nextStatus: item.status,\n });\n return { item, suggestion: marked };\n }\n\n dismissUpdateSuggestion(id: string): WorkItemUpdateSuggestion | null {\n const suggestion = this.store.getUpdateSuggestion(id);\n if (!suggestion || suggestion.status !== 'pending') return null;\n const marked = this.store.markUpdateSuggestion(id, 'dismissed');\n if (marked) {\n this.store.addEvent(marked.workItemId, 'update_suggestion_dismissed', {\n suggestionId: marked.id,\n sourceKind: marked.sourceKind,\n sourceId: marked.sourceId,\n });\n }\n return marked;\n }\n}\n"],"mappings":";;;;;AAmBA,MAAa,iCAAiC,KAAK,OAAO;AAC1D,MAAa,iCAAiC;AAC9C,MAAa,6CACX,iCAAA,KAAkE,OAAO;AAE3E,SAAS,oBAAoB,UAA8C;AACzE,KAAI,SAAS,WAAW,SAAS,CAAE,QAAO;AAC1C,KAAI,SAAS,WAAW,SAAS,CAAE,QAAO;AAC1C,KAAI,SAAS,WAAW,SAAS,CAAE,QAAO;AAC1C,QAAO;;AAGT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A,EAAW,OAAM,SAAS,WAAW,MAAM;AAC3E,MAAI,WAAW,MAAM,eAAe,KAAA,EAAW,OAAM,aAAa,WAAW,MAAM;AACnF,MAAI,WAAW,MAAM,kBAAkB,KAAA,EAAW,OAAM,gBAAgB,WAAW,MAAM;EACzF,MAAM,OAAO,OAAO,KAAK,MAAM,CAAC,SAAS,IACrC,KAAK,eAAe,WAAW,YAAY,MAAM,GACjD;AACJ,MAAI,CAAC,KAAM,QAAO;AAClB,MAAI,WAAW,aACb,MAAK,MAAM,SAAS,WAAW,YAAY,uBAAuB;GAChE,YAAY,WAAW;GACvB,UAAU,WAAW;GACrB,cAAc,WAAW;GACzB,MAAM,WAAW;GAClB,CAAC;EAEJ,MAAM,SAAS,KAAK,MAAM,qBAAqB,IAAI,UAAU;AAC7D,MAAI,CAAC,OAAQ,QAAO;AACpB,OAAK,MAAM,SAAS,WAAW,YAAY,6BAA6B;GACtE,cAAc,WAAW;GACzB,YAAY,WAAW;GACvB,UAAU,WAAW;GACrB;GACA,gBAAgB,OAAO;GACvB,YAAY,KAAK;GAClB,CAAC;AACF,SAAO;GAAE;GAAM,YAAY;GAAQ;;CAGrC,wBAAwB,IAA6C;EACnE,MAAM,aAAa,KAAK,MAAM,oBAAoB,GAAG;AACrD,MAAI,CAAC,cAAc,WAAW,WAAW,UAAW,QAAO;EAC3D,MAAM,SAAS,KAAK,MAAM,qBAAqB,IAAI,YAAY;AAC/D,MAAI,OACF,MAAK,MAAM,SAAS,OAAO,YAAY,+BAA+B;GACpE,cAAc,OAAO;GACrB,YAAY,OAAO;GACnB,UAAU,OAAO;GAClB,CAAC;AAEJ,SAAO"}
@@ -1,6 +1,6 @@
1
- import { getAgentDefaultModelRef, init_schema } from "../../config/schema.js";
2
1
  import { createLogger } from "../../utils/logger/index.js";
3
2
  import { init_logger } from "../../utils/logger.js";
3
+ import { getAgentDefaultModelRef, init_schema } from "../../config/schema.js";
4
4
  import { getDefaultModelSync, init_providers, resolveModel } from "../../providers/index.js";
5
5
  import { resolveModelRef } from "../../config/agent-typed-models.js";
6
6
  import { buildWorkflowDraftPrompt, buildWorkflowDraftRepairPrompt } from "./workflow-draft-prompt.js";
@@ -1,8 +1,8 @@
1
+ import "../../session/types.js";
1
2
  import { renderWorkflowText } from "../../agent/workflow/snapshot.js";
2
3
  import { runViewToSnapshot } from "./run-view-to-snapshot.js";
3
4
  import { GoalWorkflowJudge } from "../../goals/goal-workflow-judge.js";
4
5
  import "../../goals/index.js";
5
- import "../../session/types.js";
6
6
  import { isTerminalWorkflowRunStatus } from "../domain/run.js";
7
7
  import "../domain/index.js";
8
8
  import { buildWorkflowRunSessionKey } from "./workflow-session-key.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xopcai/xopc",
3
- "version": "0.0.125",
3
+ "version": "0.0.126",
4
4
  "description": "Local-first AI system that remembers context, coordinates AI, and sustains long-term progress.",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -65,10 +65,10 @@
65
65
  "node": ">=22.19.0"
66
66
  },
67
67
  "dependencies": {
68
- "@earendil-works/pi-agent-core": "^0.80.3",
69
- "@earendil-works/pi-ai": "^0.80.3",
70
- "@earendil-works/pi-coding-agent": "^0.80.3",
71
- "@earendil-works/pi-tui": "^0.80.3",
68
+ "@earendil-works/pi-agent-core": "^0.80.6",
69
+ "@earendil-works/pi-ai": "^0.80.6",
70
+ "@earendil-works/pi-coding-agent": "^0.80.6",
71
+ "@earendil-works/pi-tui": "^0.80.6",
72
72
  "@grammyjs/runner": "^2.0.3",
73
73
  "@hono/node-server": "^2.0.4",
74
74
  "@inquirer/prompts": "^8.5.0",