@xopcai/xopc 0.0.145 → 0.0.147

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 (380) hide show
  1. package/README.md +2 -2
  2. package/dist/browser-ext/manifest.json +1 -1
  3. package/dist/extensions/demo-memory/src/index.js +6 -4
  4. package/dist/extensions/demo-memory/src/index.js.map +1 -1
  5. package/dist/extensions/telegram/xopc.extension.json +1 -1
  6. package/dist/gateway/static/root/assets/Combination-14nmIgxH.js +41 -0
  7. package/dist/gateway/static/root/assets/activity-store-DXeSSlw1.js +1 -0
  8. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BEUxdhZx.js → agent-avatar-dicebear-CFdJKSjY.js} +1 -1
  9. package/dist/gateway/static/root/assets/agents-DKjbRpbA.js +2 -0
  10. package/dist/gateway/static/root/assets/api-Bs69B5zA.js +1 -0
  11. package/dist/gateway/static/root/assets/{app-management-settings-panel-CRHSZJWi.js → app-management-settings-panel-ag1ViXT_.js} +1 -1
  12. package/dist/gateway/static/root/assets/{appearance-settings-BunADYJb.js → appearance-settings-C6iMpwOM.js} +1 -1
  13. package/dist/gateway/static/root/assets/apps-page-CpX3lBFF.js +1 -0
  14. package/dist/gateway/static/root/assets/{archive-plugin-B6vTkH2A.js → archive-plugin-Dwi3mIBy.js} +1 -1
  15. package/dist/gateway/static/root/assets/{attachment-load-BjZXzaNv.js → attachment-load-BaCDoq40.js} +1 -1
  16. package/dist/gateway/static/root/assets/{automation-suggestion-card-ZDA-Stg1.js → automation-suggestion-card-CwqtFgnw.js} +1 -1
  17. package/dist/gateway/static/root/assets/automations-page-DlupOxFQ.js +6 -0
  18. package/dist/gateway/static/root/assets/{binary-plugins-DYZfLvPz.js → binary-plugins-DoAYhsxa.js} +1 -1
  19. package/dist/gateway/static/root/assets/{block-editor-C3MUlYC9.js → block-editor-Bw72pO7S.js} +31 -31
  20. package/dist/gateway/static/root/assets/browser-settings-page-BwLoUBcZ.js +8 -0
  21. package/dist/gateway/static/root/assets/capability-presets-api-vdbAR65Q.js +1 -0
  22. package/dist/gateway/static/root/assets/capability-presets-settings-panel-BAsKbJgm.js +2 -0
  23. package/dist/gateway/static/root/assets/{channel-recipient-api-fTlTnWB4.js → channel-recipient-api-rTG26jpV.js} +1 -1
  24. package/dist/gateway/static/root/assets/channels-settings-CxFWy0cE.js +1 -0
  25. package/dist/gateway/static/root/assets/channels-status-swr-OKlqTtKJ.js +1 -0
  26. package/dist/gateway/static/root/assets/{connector-logo-BVFNT2zW.js → connector-logo-DIMP4NWY.js} +1 -1
  27. package/dist/gateway/static/root/assets/connectors-page-BjQQwX62.js +2 -0
  28. package/dist/gateway/static/root/assets/{desktop-pet-_jUmoXd3.js → desktop-pet-kQq2e0BN.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-settings-DwGOy4AQ.js → desktop-pet-settings-B6vtozMY.js} +1 -1
  30. package/dist/gateway/static/root/assets/{directory-picker-path-field-akvF0F-u.js → directory-picker-path-field-Dn5-e3v4.js} +1 -1
  31. package/dist/gateway/static/root/assets/dist-C230izr8.js +1 -0
  32. package/dist/gateway/static/root/assets/dist-CxGUk8J-.js +1 -0
  33. package/dist/gateway/static/root/assets/dreaming-settings-BzwIujPG.js +3 -0
  34. package/dist/gateway/static/root/assets/extension-debug-page-D_e_hsEy.js +1 -0
  35. package/dist/gateway/static/root/assets/{extension-page-CwWktRNz.js → extension-page-D15CWHBd.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-settings-page-CuggWOIl.js → extension-settings-page-D4P0n1om.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-config-api-B7sxIbza.js → gateway-config-api-B4qZctjG.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-settings-DIv0eKMf.js → gateway-settings-BvndV7TP.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-startup-retry-DtoLihQE.js → gateway-startup-retry-BpgMunEb.js} +1 -1
  40. package/dist/gateway/static/root/assets/{goal-create-dialog-C4Kw0mfS.js → goal-create-dialog-DrVHKXHq.js} +1 -1
  41. package/dist/gateway/static/root/assets/goal-detail-page-PHlCwv68.js +4 -0
  42. package/dist/gateway/static/root/assets/{goals-config-api-B0jm5JaA.js → goals-config-api-B6YJB_ct.js} +1 -1
  43. package/dist/gateway/static/root/assets/goals-page-Hg9uyO6e.js +2 -0
  44. package/dist/gateway/static/root/assets/{goals-settings-N5_iL7es.js → goals-settings-BROWCIcL.js} +1 -1
  45. package/dist/gateway/static/root/assets/{heartbeat-settings-XzH3lbRR.js → heartbeat-settings-CoCwIOIg.js} +1 -1
  46. package/dist/gateway/static/root/assets/index-CxkNzw3e.js +259 -0
  47. package/dist/gateway/static/root/assets/index-DjCSOyaN.css +1 -0
  48. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-Bm_AIYQ7.js +1 -0
  49. package/dist/gateway/static/root/assets/local-app-workbench-page-BJWFcxwG.js +2 -0
  50. package/dist/gateway/static/root/assets/local-apps-page-BsiZMrEf.js +1 -0
  51. package/dist/gateway/static/root/assets/{locale-store-CiM-D9jA.js → locale-store-Bp8joZck.js} +1 -1
  52. package/dist/gateway/static/root/assets/logs-page-DOmK61ey.js +7 -0
  53. package/dist/gateway/static/root/assets/{markdown-split-5rJx5flj.js → markdown-split-Dy7QpaAz.js} +1 -1
  54. package/dist/gateway/static/root/assets/{media-plugins-DYXccwAd.js → media-plugins-3Lxliy9D.js} +1 -1
  55. package/dist/gateway/static/root/assets/messages-CQGpD-dC.js +5 -0
  56. package/dist/gateway/static/root/assets/models-hub-panel-DGCZom4o.js +2 -0
  57. package/dist/gateway/static/root/assets/{notes-page-BgLyndCO.js → notes-page-BJtT4vSf.js} +1 -1
  58. package/dist/gateway/static/root/assets/notes-workbench-B_bN7cOR.js +4 -0
  59. package/dist/gateway/static/root/assets/{page-tabs-6Al9_sGz.js → page-tabs-DKB6RDre.js} +1 -1
  60. package/dist/gateway/static/root/assets/{preview-open-alternatives-Cm3G72Hv.js → preview-open-alternatives-Br_YhYHp.js} +1 -1
  61. package/dist/gateway/static/root/assets/project-detail-page-Dq8JouJj.js +1 -0
  62. package/dist/gateway/static/root/assets/projects-page-DvfL7fSe.js +1 -0
  63. package/dist/gateway/static/root/assets/remote-access-hub-DqwMXSXP.js +1 -0
  64. package/dist/gateway/static/root/assets/{save-bar-controls-BYtfzu_F.js → save-bar-controls-BgIE9BBh.js} +1 -1
  65. package/dist/gateway/static/root/assets/{schedule-field-CvIRc6yK.js → schedule-field-BXDP-oMz.js} +1 -1
  66. package/dist/gateway/static/root/assets/{schema-form-CQuKx0n7.js → schema-form-Dhv-SmjG.js} +1 -1
  67. package/dist/gateway/static/root/assets/sessions-page-B_mOZkQk.js +1 -0
  68. package/dist/gateway/static/root/assets/settings-advanced-gate-BHGmH6YS.js +1 -0
  69. package/dist/gateway/static/root/assets/{settings-collapsible-section-CF3HHM-t.js → settings-collapsible-section-CUTExnlK.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-form-section-CwWjoRN6.js → settings-form-section-CmnDhsf0.js} +1 -1
  71. package/dist/gateway/static/root/assets/{settings-loading-skeleton-aUFmJa13.js → settings-loading-skeleton-B79dq-XY.js} +1 -1
  72. package/dist/gateway/static/root/assets/{settings-page-B2UUU9TF.js → settings-page-Db8uAv3X.js} +1 -1
  73. package/dist/gateway/static/root/assets/{settings-page-layout-DqpbTWqI.js → settings-page-layout-DaFwstQw.js} +1 -1
  74. package/dist/gateway/static/root/assets/setup-status-panel-BUSEj0KK.js +1 -0
  75. package/dist/gateway/static/root/assets/{share-preview-page-BOhlPsS1.js → share-preview-page-Bi00uXzV.js} +1 -1
  76. package/dist/gateway/static/root/assets/shares-settings-DzsTYfuX.js +1 -0
  77. package/dist/gateway/static/root/assets/skill-reload-api-DSsdU081.js +1 -0
  78. package/dist/gateway/static/root/assets/skills-page-DeB1tQZL.js +2 -0
  79. package/dist/gateway/static/root/assets/{system-settings-panel-CWxSvuwD.js → system-settings-panel-Cxaph7hW.js} +1 -1
  80. package/dist/gateway/static/root/assets/{theme-store-C9Dxcppm.js → theme-store-eCTN1RpG.js} +1 -1
  81. package/dist/gateway/static/root/assets/{typed-models-lib-qROAvqTw.js → typed-models-lib-CcZ_tyFY.js} +1 -1
  82. package/dist/gateway/static/root/assets/{use-channel-catalog-DE9cpn4G.js → use-channel-catalog-C4PWbNoi.js} +1 -1
  83. package/dist/gateway/static/root/assets/user-context-page-QTVMx_hG.js +1 -0
  84. package/dist/gateway/static/root/assets/{user-profile-fields-editor-CWxc0ghP.js → user-profile-fields-editor-CPOO9Jz5.js} +1 -1
  85. package/dist/gateway/static/root/assets/{user-profile-settings-panel-DW-Up6vt.js → user-profile-settings-panel-C8cgtSF7.js} +1 -1
  86. package/dist/gateway/static/root/assets/{utils-D53uRXVr.js → utils-CiZK2KwH.js} +1 -1
  87. package/dist/gateway/static/root/assets/voice-api-key-field-b-YZtvUu.js +1 -0
  88. package/dist/gateway/static/root/assets/work-discovery-page-4zVDOl2G.js +1 -0
  89. package/dist/gateway/static/root/assets/work-item-detail-page-CHe2tfkc.js +1 -0
  90. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-D_x9ELJp.js → workflow-run-setup-panel-8SLCYeXE.js} +2 -2
  91. package/dist/gateway/static/root/assets/workflows-page-DEOFqiWn.js +11 -0
  92. package/dist/gateway/static/root/index.html +10 -9
  93. package/dist/package.js +1 -1
  94. package/dist/src/activity/types.d.ts +1 -1
  95. package/dist/src/agent/agent-instance-gateway.d.ts +1 -1
  96. package/dist/src/agent/agent-manager.d.ts +1 -1
  97. package/dist/src/agent/agent-manager.js +5 -4
  98. package/dist/src/agent/agent-manager.js.map +1 -1
  99. package/dist/src/agent/background-review/coordinator.js +0 -1
  100. package/dist/src/agent/background-review/coordinator.js.map +1 -1
  101. package/dist/src/agent/background-review/settings.d.ts +1 -1
  102. package/dist/src/agent/background-review/settings.js +10 -17
  103. package/dist/src/agent/background-review/settings.js.map +1 -1
  104. package/dist/src/agent/bootstrap/filter-bootstrap-files.d.ts +1 -1
  105. package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
  106. package/dist/src/agent/bootstrap/filter-bootstrap-files.js.map +1 -1
  107. package/dist/src/agent/bootstrap/load-bootstrap-files.js +2 -3
  108. package/dist/src/agent/bootstrap/load-bootstrap-files.js.map +1 -1
  109. package/dist/src/agent/code-intelligence/binary.js +1 -1
  110. package/dist/src/agent/context/project-context.d.ts +14 -0
  111. package/dist/src/agent/context/project-context.js +23 -1
  112. package/dist/src/agent/context/project-context.js.map +1 -1
  113. package/dist/src/agent/context/workspace-templates/AGENTS.md +1 -1
  114. package/dist/src/agent/context/workspace.d.ts +1 -2
  115. package/dist/src/agent/context/workspace.js +2 -4
  116. package/dist/src/agent/context/workspace.js.map +1 -1
  117. package/dist/src/agent/embedded/run-for-session.js +1 -2
  118. package/dist/src/agent/embedded/run-for-session.js.map +1 -1
  119. package/dist/src/agent/embedded/run-turn.js +6 -1
  120. package/dist/src/agent/embedded/run-turn.js.map +1 -1
  121. package/dist/src/agent/embedded/types.d.ts +17 -0
  122. package/dist/src/agent/memory/builtin-memory-store.d.ts +2 -2
  123. package/dist/src/agent/memory/builtin-memory-store.js +2 -2
  124. package/dist/src/agent/memory/builtin-memory-store.js.map +1 -1
  125. package/dist/src/agent/memory/builtin-provider.d.ts +1 -3
  126. package/dist/src/agent/memory/builtin-provider.js +21 -48
  127. package/dist/src/agent/memory/builtin-provider.js.map +1 -1
  128. package/dist/src/agent/memory/context/planner.js +48 -9
  129. package/dist/src/agent/memory/context/planner.js.map +1 -1
  130. package/dist/src/agent/memory/context/types.d.ts +7 -1
  131. package/dist/src/agent/memory/context-fence.js +1 -1
  132. package/dist/src/agent/memory/context-fence.js.map +1 -1
  133. package/dist/src/agent/memory/create-memory-manager.js +2 -9
  134. package/dist/src/agent/memory/create-memory-manager.js.map +1 -1
  135. package/dist/src/agent/memory/dreaming/config.js +5 -10
  136. package/dist/src/agent/memory/dreaming/config.js.map +1 -1
  137. package/dist/src/agent/memory/dreaming/promotion-lifecycle.js +2 -2
  138. package/dist/src/agent/memory/dreaming/promotion-lifecycle.js.map +1 -1
  139. package/dist/src/agent/memory/dreaming/scope.d.ts +2 -3
  140. package/dist/src/agent/memory/dreaming/scope.js +8 -8
  141. package/dist/src/agent/memory/dreaming/scope.js.map +1 -1
  142. package/dist/src/agent/memory/manager.d.ts +1 -5
  143. package/dist/src/agent/memory/manager.js +2 -23
  144. package/dist/src/agent/memory/manager.js.map +1 -1
  145. package/dist/src/agent/memory/memory-config.d.ts +3 -3
  146. package/dist/src/agent/memory/memory-config.js +9 -14
  147. package/dist/src/agent/memory/memory-config.js.map +1 -1
  148. package/dist/src/agent/memory/types.d.ts +9 -5
  149. package/dist/src/agent/memory/understanding/service.js +21 -8
  150. package/dist/src/agent/memory/understanding/service.js.map +1 -1
  151. package/dist/src/agent/memory/understanding/types.d.ts +5 -0
  152. package/dist/src/agent/memory/user-context-coordinator.d.ts +1 -1
  153. package/dist/src/agent/memory/user-context-coordinator.js +6 -2
  154. package/dist/src/agent/memory/user-context-coordinator.js.map +1 -1
  155. package/dist/src/agent/orchestration/agent-orchestrator.js +2 -2
  156. package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
  157. package/dist/src/agent/prompt/memory/index.d.ts +1 -2
  158. package/dist/src/agent/prompt/memory/index.js +6 -7
  159. package/dist/src/agent/prompt/memory/index.js.map +1 -1
  160. package/dist/src/agent/prompt/sections/tooling.js +1 -1
  161. package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
  162. package/dist/src/agent/service/direct-turn-helpers.js +13 -2
  163. package/dist/src/agent/service/direct-turn-helpers.js.map +1 -1
  164. package/dist/src/agent/tools/curated-memory-tool.js +4 -4
  165. package/dist/src/agent/tools/curated-memory-tool.js.map +1 -1
  166. package/dist/src/agent/tools/factory.d.ts +1 -1
  167. package/dist/src/agent/tools/factory.js +2 -2
  168. package/dist/src/agent/tools/factory.js.map +1 -1
  169. package/dist/src/agent/tools/memory-tool.js +1 -1
  170. package/dist/src/agent/tools/memory-tool.js.map +1 -1
  171. package/dist/src/agent/workflow/workflow-child-tools.js +2 -3
  172. package/dist/src/agent/workflow/workflow-child-tools.js.map +1 -1
  173. package/dist/src/agent/workspace-runtime/registry.d.ts +5 -5
  174. package/dist/src/agent/workspace-runtime/registry.js +6 -11
  175. package/dist/src/agent/workspace-runtime/registry.js.map +1 -1
  176. package/dist/src/agent-manifest/index.js +2 -2
  177. package/dist/src/agent-manifest/prompt.js +1 -7
  178. package/dist/src/agent-manifest/prompt.js.map +1 -1
  179. package/dist/src/agent-manifest/schema.d.ts +0 -598
  180. package/dist/src/agent-manifest/schema.js +2 -143
  181. package/dist/src/agent-manifest/schema.js.map +1 -1
  182. package/dist/src/agent-manifest/validator.js +0 -12
  183. package/dist/src/agent-manifest/validator.js.map +1 -1
  184. package/dist/src/agent-runtime/index.js +1 -1
  185. package/dist/src/agent-runtime/memory-runtime.d.ts +2 -2
  186. package/dist/src/agent-runtime/memory-runtime.js +8 -7
  187. package/dist/src/agent-runtime/memory-runtime.js.map +1 -1
  188. package/dist/src/agent-runtime/runtime-profile.d.ts +2 -0
  189. package/dist/src/agent-runtime/runtime-profile.js +2 -2
  190. package/dist/src/agent-runtime/runtime-profile.js.map +1 -1
  191. package/dist/src/chat-commands/agent-edit.js +1 -2
  192. package/dist/src/chat-commands/agent-edit.js.map +1 -1
  193. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  194. package/dist/src/cli/commands/init.js +0 -22
  195. package/dist/src/cli/commands/init.js.map +1 -1
  196. package/dist/src/cli/templates.d.ts +1 -1
  197. package/dist/src/cli/templates.js +1 -16
  198. package/dist/src/cli/templates.js.map +1 -1
  199. package/dist/src/commands/agents.config.js +0 -10
  200. package/dist/src/commands/agents.config.js.map +1 -1
  201. package/dist/src/config/agent-profile.js +1 -1
  202. package/dist/src/config/index.js +2 -2
  203. package/dist/src/config/paths.d.ts +0 -1
  204. package/dist/src/config/paths.js +1 -2
  205. package/dist/src/config/paths.js.map +1 -1
  206. package/dist/src/config/schema.d.ts +118 -532
  207. package/dist/src/config/schema.js +32 -26
  208. package/dist/src/config/schema.js.map +1 -1
  209. package/dist/src/extensions/loader.js +2 -1
  210. package/dist/src/extensions/loader.js.map +1 -1
  211. package/dist/src/gateway/agents-admin.d.ts +0 -2
  212. package/dist/src/gateway/agents-admin.js +1 -7
  213. package/dist/src/gateway/agents-admin.js.map +1 -1
  214. package/dist/src/gateway/capability-presets-admin.d.ts +0 -2
  215. package/dist/src/gateway/capability-presets-admin.js.map +1 -1
  216. package/dist/src/gateway/chat-stream/mapper.js +26 -0
  217. package/dist/src/gateway/chat-stream/mapper.js.map +1 -1
  218. package/dist/src/gateway/chat-stream/protocol.d.ts +16 -1
  219. package/dist/src/gateway/dreaming-automation-reconciler.d.ts +0 -1
  220. package/dist/src/gateway/dreaming-automation-reconciler.js +41 -63
  221. package/dist/src/gateway/dreaming-automation-reconciler.js.map +1 -1
  222. package/dist/src/gateway/heartbeat/service.js +1 -1
  223. package/dist/src/gateway/hono/app.js +3 -1
  224. package/dist/src/gateway/hono/app.js.map +1 -1
  225. package/dist/src/gateway/hono/lib/config-payload.d.ts +0 -130
  226. package/dist/src/gateway/hono/lib/config-payload.js +0 -1
  227. package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
  228. package/dist/src/gateway/hono/routes/agents.js +6 -12
  229. package/dist/src/gateway/hono/routes/agents.js.map +1 -1
  230. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +6 -0
  231. package/dist/src/gateway/hono/routes/auth-registry-extensions.js.map +1 -1
  232. package/dist/src/gateway/hono/routes/capability-presets.js +2 -2
  233. package/dist/src/gateway/hono/routes/capability-presets.js.map +1 -1
  234. package/dist/src/gateway/hono/routes/dreaming.js +9 -20
  235. package/dist/src/gateway/hono/routes/dreaming.js.map +1 -1
  236. package/dist/src/gateway/hono/routes/index.js +4 -0
  237. package/dist/src/gateway/hono/routes/index.js.map +1 -1
  238. package/dist/src/gateway/hono/routes/local-apps.d.ts +5 -0
  239. package/dist/src/gateway/hono/routes/local-apps.js +99 -0
  240. package/dist/src/gateway/hono/routes/local-apps.js.map +1 -0
  241. package/dist/src/gateway/hono/routes/memory.js +48 -65
  242. package/dist/src/gateway/hono/routes/memory.js.map +1 -1
  243. package/dist/src/gateway/hono/routes/projects.js +2 -2
  244. package/dist/src/gateway/hono/routes/projects.js.map +1 -1
  245. package/dist/src/gateway/hono/routes/work-discovery.d.ts +3 -0
  246. package/dist/src/gateway/hono/routes/work-discovery.js +150 -0
  247. package/dist/src/gateway/hono/routes/work-discovery.js.map +1 -0
  248. package/dist/src/gateway/hono/routes/you.d.ts +3 -0
  249. package/dist/src/gateway/hono/routes/you.js +358 -91
  250. package/dist/src/gateway/hono/routes/you.js.map +1 -1
  251. package/dist/src/gateway/service.d.ts +3 -0
  252. package/dist/src/gateway/service.js +12 -0
  253. package/dist/src/gateway/service.js.map +1 -1
  254. package/dist/src/heartbeat/index.js +1 -1
  255. package/dist/src/knowledge/connected-knowledge-pipeline.js +9 -5
  256. package/dist/src/knowledge/connected-knowledge-pipeline.js.map +1 -1
  257. package/dist/src/local-apps/acceptance.d.ts +30 -0
  258. package/dist/src/local-apps/acceptance.js +93 -0
  259. package/dist/src/local-apps/acceptance.js.map +1 -0
  260. package/dist/src/local-apps/index.d.ts +5 -0
  261. package/dist/src/local-apps/index.js +4 -0
  262. package/dist/src/local-apps/preview-runtime-bridge.d.ts +4 -0
  263. package/dist/src/local-apps/preview-runtime-bridge.js +171 -0
  264. package/dist/src/local-apps/preview-runtime-bridge.js.map +1 -0
  265. package/dist/src/local-apps/runtime-entry.d.ts +8 -0
  266. package/dist/src/local-apps/runtime-entry.js +25 -0
  267. package/dist/src/local-apps/runtime-entry.js.map +1 -0
  268. package/dist/src/local-apps/scaffold.d.ts +8 -0
  269. package/dist/src/local-apps/scaffold.js +122 -0
  270. package/dist/src/local-apps/scaffold.js.map +1 -0
  271. package/dist/src/local-apps/service.d.ts +37 -0
  272. package/dist/src/local-apps/service.js +553 -0
  273. package/dist/src/local-apps/service.js.map +1 -0
  274. package/dist/src/local-apps/store.d.ts +44 -0
  275. package/dist/src/local-apps/store.js +195 -0
  276. package/dist/src/local-apps/store.js.map +1 -0
  277. package/dist/src/local-apps/types.d.ts +105 -0
  278. package/dist/src/local-apps/types.js +1 -0
  279. package/dist/src/storage/sqlite/index.d.ts +3 -2
  280. package/dist/src/storage/sqlite/index.js +4 -3
  281. package/dist/src/storage/sqlite/memory-index-repository.d.ts +2 -3
  282. package/dist/src/storage/sqlite/memory-index-repository.js +16 -20
  283. package/dist/src/storage/sqlite/memory-index-repository.js.map +1 -1
  284. package/dist/src/storage/sqlite/memory-records-repository.d.ts +18 -10
  285. package/dist/src/storage/sqlite/memory-records-repository.js +79 -34
  286. package/dist/src/storage/sqlite/memory-records-repository.js.map +1 -1
  287. package/dist/src/storage/sqlite/memory-reference-consent-repository.d.ts +27 -0
  288. package/dist/src/storage/sqlite/memory-reference-consent-repository.js +109 -0
  289. package/dist/src/storage/sqlite/memory-reference-consent-repository.js.map +1 -0
  290. package/dist/src/storage/sqlite/migrations/038_user_owned_memory.sql +68 -0
  291. package/dist/src/storage/sqlite/migrations/039_memory_reference_consents.sql +19 -0
  292. package/dist/src/storage/sqlite/migrations/040_local_apps.sql +32 -0
  293. package/dist/src/storage/sqlite/migrations/041_local_app_release_lifecycle.sql +17 -0
  294. package/dist/src/storage/sqlite/migrations/042_work_discovery.sql +41 -0
  295. package/dist/src/storage/sqlite/migrations/043_local_app_acceptance_runs.sql +16 -0
  296. package/dist/src/storage/sqlite/migrations/044_repair_work_discovery_foreign_keys.sql +75 -0
  297. package/dist/src/storage/sqlite/migrations/045_extension_ui_grants.sql +13 -0
  298. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  299. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  300. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  301. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  302. package/dist/src/storage/sqlite/schema.js +1 -1
  303. package/dist/src/storage/sqlite/schema.sql +20 -0
  304. package/dist/src/user-context/config.d.ts +227 -0
  305. package/dist/src/user-context/config.js +158 -0
  306. package/dist/src/user-context/config.js.map +1 -0
  307. package/dist/src/user-context/import.d.ts +1 -1
  308. package/dist/src/user-context/import.js +6 -1
  309. package/dist/src/user-context/import.js.map +1 -1
  310. package/dist/src/user-context/owner.d.ts +5 -0
  311. package/dist/src/user-context/owner.js +9 -0
  312. package/dist/src/user-context/owner.js.map +1 -0
  313. package/dist/src/user-context/projection.d.ts +11 -9
  314. package/dist/src/user-context/projection.js +74 -47
  315. package/dist/src/user-context/projection.js.map +1 -1
  316. package/dist/src/user-context/runtime.d.ts +13 -0
  317. package/dist/src/user-context/runtime.js +36 -0
  318. package/dist/src/user-context/runtime.js.map +1 -0
  319. package/dist/src/work-discovery/analyzer.d.ts +11 -0
  320. package/dist/src/work-discovery/analyzer.js +171 -0
  321. package/dist/src/work-discovery/analyzer.js.map +1 -0
  322. package/dist/src/work-discovery/index.d.ts +5 -0
  323. package/dist/src/work-discovery/index.js +5 -0
  324. package/dist/src/work-discovery/probe.d.ts +12 -0
  325. package/dist/src/work-discovery/probe.js +335 -0
  326. package/dist/src/work-discovery/probe.js.map +1 -0
  327. package/dist/src/work-discovery/repository.d.ts +11 -0
  328. package/dist/src/work-discovery/repository.js +100 -0
  329. package/dist/src/work-discovery/repository.js.map +1 -0
  330. package/dist/src/work-discovery/service.d.ts +30 -0
  331. package/dist/src/work-discovery/service.js +387 -0
  332. package/dist/src/work-discovery/service.js.map +1 -0
  333. package/dist/src/work-discovery/types.d.ts +114 -0
  334. package/dist/src/work-discovery/types.js +1 -0
  335. package/dist/src/workflows/service/workflow-session-bridge.js +1 -1
  336. package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
  337. package/package.json +5 -3
  338. package/skills/engineering/build-xopc-local-app/SKILL.md +45 -0
  339. package/skills/engineering/build-xopc-local-app/references/app-contract.md +33 -0
  340. package/skills/engineering/build-xopc-local-app/scripts/validate-local-app.mjs +72 -0
  341. package/dist/gateway/static/root/assets/Combination-DolwnuKi.js +0 -41
  342. package/dist/gateway/static/root/assets/activity-center-store-3l9ahUqb.js +0 -1
  343. package/dist/gateway/static/root/assets/agents-1bpT0xRO.js +0 -2
  344. package/dist/gateway/static/root/assets/apps-page-Cc4JgVUQ.js +0 -1
  345. package/dist/gateway/static/root/assets/automations-page-mb0fdVpq.js +0 -6
  346. package/dist/gateway/static/root/assets/browser-settings-page-Bb0xhaMN.js +0 -8
  347. package/dist/gateway/static/root/assets/capability-presets-api-BV76yN9a.js +0 -1
  348. package/dist/gateway/static/root/assets/capability-presets-settings-panel-CUcGKZqC.js +0 -2
  349. package/dist/gateway/static/root/assets/channels-settings-BlSDMGdy.js +0 -1
  350. package/dist/gateway/static/root/assets/channels-status-swr-CJauF1CW.js +0 -1
  351. package/dist/gateway/static/root/assets/connectors-page-CMgAFGvb.js +0 -2
  352. package/dist/gateway/static/root/assets/dist-C99RGfAH.js +0 -1
  353. package/dist/gateway/static/root/assets/dreaming-settings-BLetQiYY.js +0 -3
  354. package/dist/gateway/static/root/assets/extension-debug-page-Cof2ncxE.js +0 -1
  355. package/dist/gateway/static/root/assets/goal-detail-page-BMmzYpZL.js +0 -4
  356. package/dist/gateway/static/root/assets/goals-page-CGeT77PC.js +0 -2
  357. package/dist/gateway/static/root/assets/index-CSLF84-Q.css +0 -1
  358. package/dist/gateway/static/root/assets/index-I-ZCenVw.js +0 -259
  359. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-x_v0nrIi.js +0 -1
  360. package/dist/gateway/static/root/assets/logs-page-BSh1t8cD.js +0 -7
  361. package/dist/gateway/static/root/assets/messages-Cb1VMeqP.js +0 -5
  362. package/dist/gateway/static/root/assets/models-hub-panel-BNpTenAI.js +0 -2
  363. package/dist/gateway/static/root/assets/notes-workbench-teklkhcE.js +0 -4
  364. package/dist/gateway/static/root/assets/project-detail-page-CCB_dKoh.js +0 -1
  365. package/dist/gateway/static/root/assets/projects-page-VOAFAHYj.js +0 -1
  366. package/dist/gateway/static/root/assets/remote-access-hub-USYu64Ru.js +0 -1
  367. package/dist/gateway/static/root/assets/sessions-page-oGC8O5h_.js +0 -1
  368. package/dist/gateway/static/root/assets/settings-advanced-gate-D4rP66R1.js +0 -1
  369. package/dist/gateway/static/root/assets/setup-status-panel-Ck9keROI.js +0 -1
  370. package/dist/gateway/static/root/assets/shares-settings-BYLsCuqj.js +0 -1
  371. package/dist/gateway/static/root/assets/skill-reload-api-BNHUyVML.js +0 -1
  372. package/dist/gateway/static/root/assets/skills-page-CpXbQH4n.js +0 -2
  373. package/dist/gateway/static/root/assets/user-context-page-DbNEK4Yp.js +0 -1
  374. package/dist/gateway/static/root/assets/voice-api-key-field-Cs7MOrg0.js +0 -1
  375. package/dist/gateway/static/root/assets/work-item-detail-page-D1ziG1Pp.js +0 -1
  376. package/dist/gateway/static/root/assets/workflows-page-DHGV_n6i.js +0 -11
  377. package/dist/src/agent/context/workspace-templates/MEMORY.md +0 -33
  378. package/dist/src/agent/memory/access-policy.d.ts +0 -12
  379. package/dist/src/agent/memory/access-policy.js +0 -44
  380. package/dist/src/agent/memory/access-policy.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"you.js","names":[],"sources":["../../../../../src/gateway/hono/routes/you.ts"],"sourcesContent":["import type { Hono } from 'hono';\n\nimport { resolveDefaultAgentId } from '../../../agent/agent-scope.js';\nimport type { MemoryRecord } from '../../../agent/memory/types.js';\nimport { nextMemoryReviewAt, resolveMemoryStability } from '../../../agent/memory/lifecycle.js';\nimport { MemoryPolicySchema } from '../../../agent-manifest/schema.js';\nimport { resolveEffectiveAgentManifestForAgent } from '../../../config/agent-profile.js';\nimport type { Config } from '../../../config/schema.js';\nimport { listConnectorCatalog } from '../../../connectors/catalog.js';\nimport { listConnectorInstances } from '../../../connectors/instances.js';\nimport { uninstallConnector } from '../../../connectors/install.js';\nimport { draftGoalContract, GoalService } from '../../../goals/index.js';\nimport { prepareUpdateAgent, readUserProfileFile, writeUserProfileFile } from '../../agents-admin.js';\nimport {\n deleteMemoryRecord,\n getMemoryRecord,\n getUserProfilePromptState,\n getUserTrustPolicy,\n listKnowledgeSourceItems,\n listKnowledgeSyncRuns,\n listMemoryRecords,\n runSqliteWriteTransaction,\n setUserProfilePromptState,\n setUserTrustPolicy,\n upsertMemoryRecord,\n} from '../../../storage/sqlite/index.js';\nimport { isUserTrustLevel, USER_TRUST_LEVELS } from '../../../user-context/trust-policy.js';\nimport {\n buildUserProfileSetup,\n parseUserProfileMarkdown,\n patchUserProfileMarkdown,\n type UserProfileFields,\n} from '../../../user-context/profile.js';\nimport {\n isUserContextRecord,\n projectPersonalContextSources,\n projectUserContextRecord,\n recordsDerivedFromPersonalContextSource,\n} from '../../../user-context/projection.js';\nimport { prepareUserContextImport } from '../../../user-context/import.js';\nimport { buildGoalSourceRecommendations } from '../../../user-context/source-recommendations.js';\nimport type { AuthenticatedRouteDeps } from './deps.js';\n\nconst VISIBLE_STATUSES = new Set<MemoryRecord['status']>(['active', 'candidate', 'needs_review']);\nconst ACTIONABLE_INSIGHT_KINDS = new Set<MemoryRecord['kind']>([\n 'routine',\n 'commitment',\n 'long_term_goal',\n 'derived_insight',\n 'task_lesson',\n]);\nconst INSIGHT_ACCEPTED_TAG = 'insight-action:accepted';\nconst INSIGHT_DISMISSED_TAG = 'insight-action:dismissed';\nconst PLAYBOOK_IDS = ['communication', 'execution', 'routines'] as const;\ntype PlaybookId = typeof PLAYBOOK_IDS[number];\nconst PROFILE_FIELD_LIMITS: Record<keyof UserProfileFields, number> = {\n callName: 80,\n pronouns: 80,\n timezone: 100,\n notes: 5_000,\n};\nconst PROFILE_PROMPT_SNOOZE_MS = 7 * 24 * 60 * 60 * 1_000;\nconst ALL_MEMORY_STATUSES: MemoryRecord['status'][] = [\n 'candidate',\n 'active',\n 'needs_review',\n 'stale',\n 'archived',\n 'rejected',\n];\n\nfunction listAllAgentMemoryRecords(agentId: string, statuses: MemoryRecord['status'][]): MemoryRecord[] {\n return statuses.flatMap((status) => {\n const records: MemoryRecord[] = [];\n let offset = 0;\n while (true) {\n const page = listMemoryRecords({ agentId, status, limit: 500, offset });\n records.push(...page);\n if (page.length < 500) break;\n offset += page.length;\n }\n return records;\n });\n}\n\nasync function readProfileBundle(config: Config) {\n const result = await readUserProfileFile();\n const profileContent = result.ok ? result.data.content : '';\n const profile = parseUserProfileMarkdown(profileContent);\n const promptState = getUserProfilePromptState();\n return {\n profileContent,\n profile,\n profileSetup: buildUserProfileSetup({ profile, promptState, config }),\n };\n}\n\nfunction parseProfilePatch(body: unknown): { patch: Partial<UserProfileFields> } | { error: string } {\n if (!body || typeof body !== 'object' || Array.isArray(body)) return { error: 'Invalid profile patch' };\n const record = body as Record<string, unknown>;\n const patch: Partial<UserProfileFields> = {};\n for (const field of Object.keys(PROFILE_FIELD_LIMITS) as Array<keyof UserProfileFields>) {\n if (!(field in record)) continue;\n if (typeof record[field] !== 'string') return { error: `${field} must be a string` };\n const value = record[field].trim();\n if (value.length > PROFILE_FIELD_LIMITS[field]) {\n return { error: `${field} is too long` };\n }\n patch[field] = value;\n }\n return Object.keys(patch).length > 0 ? { patch } : { error: 'No profile fields provided' };\n}\n\nfunction playbookForRecord(record: MemoryRecord): PlaybookId | undefined {\n if (record.kind === 'preference' || record.kind === 'boundary' || record.kind === 'tool_preference') return 'communication';\n if (record.kind === 'task_lesson' || record.kind === 'derived_insight') return 'execution';\n if (record.kind === 'routine') return 'routines';\n return undefined;\n}\n\nexport function buildPersonalPlaybooks(records: MemoryRecord[]) {\n return PLAYBOOK_IDS.flatMap((id) => {\n const rules = records.filter((record) => playbookForRecord(record) === id);\n if (rules.length === 0) return [];\n return [{\n id,\n enabled: rules.some((record) => record.status === 'active'),\n rules: rules.map((record) => ({\n id: record.id,\n statement: record.content,\n origin: record.explicitness,\n })),\n updatedAt: rules.map((record) => record.updatedAt).sort().at(-1),\n }];\n });\n}\n\nexport function buildInsightSuggestions(records: MemoryRecord[]) {\n return records\n .filter((record) => record.status === 'active')\n .filter((record) => ACTIONABLE_INSIGHT_KINDS.has(record.kind))\n .filter((record) => !record.tags?.includes(INSIGHT_ACCEPTED_TAG) && !record.tags?.includes(INSIGHT_DISMISSED_TAG))\n .filter((record) => {\n const stability = resolveMemoryStability(record);\n return record.explicitness === 'explicit' || (record.evidence?.length ?? 0) >= 2 || stability.band === 'strong';\n })\n .sort((left, right) => right.importance - left.importance || Date.parse(right.updatedAt) - Date.parse(left.updatedAt))\n .slice(0, 5)\n .map((record) => ({\n id: record.id,\n insight: record.content,\n kind: record.kind,\n action: record.kind === 'routine' ? 'make_repeatable' as const : 'start_progress' as const,\n evidenceCount: record.evidence?.length ?? 0,\n confidence: record.confidence,\n sourceName: record.source.provider ?? 'local',\n }));\n}\n\nfunction selectedAgentId(config: Config): string {\n return resolveDefaultAgentId(config);\n}\n\nfunction editableRecord(recordId: string, config: Config): MemoryRecord | null {\n const record = getMemoryRecord(recordId);\n if (\n !record\n || record.scope.agentId !== selectedAgentId(config)\n || !VISIBLE_STATUSES.has(record.status)\n || !isUserContextRecord(record)\n ) return null;\n return record;\n}\n\nfunction preserveRecord(record: MemoryRecord, patch: Partial<Parameters<typeof upsertMemoryRecord>[0]>) {\n return upsertMemoryRecord({\n id: record.id,\n providerId: record.source.provider ?? 'local',\n kind: record.kind,\n agentId: record.scope.agentId,\n workspaceId: record.scope.workspaceId,\n sessionKey: record.scope.sessionKey,\n projectId: record.scope.projectId,\n content: record.content,\n source: record.source,\n confidence: record.confidence,\n tags: record.tags,\n status: record.status,\n sensitivity: record.sensitivity,\n canonicalKey: record.canonicalKey,\n explicitness: record.explicitness,\n durability: record.durability,\n importance: record.importance,\n disclosurePolicy: record.disclosurePolicy,\n evidence: record.evidence,\n reviewAfter: record.reviewAfter,\n expiresAt: record.expiresAt,\n validFrom: record.validFrom,\n validTo: record.validTo,\n supersedesRecordId: record.supersedesRecordId,\n conflictGroupId: record.conflictGroupId,\n ...patch,\n });\n}\n\nexport function registerYouRoutes(authenticated: Hono, deps: AuthenticatedRouteDeps): void {\n authenticated.get('/api/you', async (c) => {\n const config = deps.service.currentConfig as Config;\n const agentId = selectedAgentId(config);\n const profileBundle = await readProfileBundle(config);\n const allUserContextRecords = listAllAgentMemoryRecords(agentId, ALL_MEMORY_STATUSES)\n .filter(isUserContextRecord);\n const records = allUserContextRecords.filter((record) => VISIBLE_STATUSES.has(record.status));\n const pausedPlaybookRecords = listMemoryRecords({ agentId, status: 'archived', limit: 200 })\n .filter(isUserContextRecord)\n .filter((record) => record.tags?.some((tag) => tag.startsWith('playbook:paused:')));\n const manifest = resolveEffectiveAgentManifestForAgent(config, agentId);\n const trustPolicy = getUserTrustPolicy();\n const sourceDefinitions = listConnectorCatalog();\n const sourceInstances = listConnectorInstances(config);\n const sources = projectPersonalContextSources(sourceDefinitions, sourceInstances, allUserContextRecords, {\n sourceItems: listKnowledgeSourceItems({ limit: 500 }),\n syncRuns: listKnowledgeSyncRuns({ limit: 500 }),\n });\n const activeGoals = new GoalService().list({\n agentId,\n status: ['active', 'paused', 'blocked', 'needs_input'],\n limit: 20,\n });\n return c.json({\n agentId,\n scope: {\n profile: 'global',\n memory: 'agent',\n trust: 'global',\n agentId,\n },\n ...profileBundle,\n understanding: records.map(projectUserContextRecord),\n insights: buildInsightSuggestions(records),\n playbooks: buildPersonalPlaybooks([...records.filter((record) => record.status === 'active'), ...pausedPlaybookRecords]),\n sources,\n sourceRecommendations: buildGoalSourceRecommendations(\n sourceDefinitions.filter((definition) => (\n definition.capabilities.includes('context') || definition.capabilities.includes('memory_source')\n )),\n new Set(sourceInstances.map((instance) => instance.connectorId)),\n activeGoals,\n ),\n controls: {\n mode: manifest.memory.mode,\n sensitiveWritePolicy: manifest.memory.privacy?.sensitiveWritePolicy ?? 'confirm',\n crossAgentSharing: manifest.memory.privacy?.crossAgentSharing ?? 'deny',\n },\n trust: {\n defaultActionLevel: trustPolicy.defaultActionLevel,\n levels: USER_TRUST_LEVELS,\n autoRequiresExplicitOptIn: true,\n },\n });\n });\n\n authenticated.get('/api/you/profile', async (c) => {\n return c.json(await readProfileBundle(deps.service.currentConfig as Config));\n });\n\n authenticated.get('/api/you/export', async (c) => {\n const config = deps.service.currentConfig as Config;\n const agentId = selectedAgentId(config);\n const profileBundle = await readProfileBundle(config);\n const understanding = listAllAgentMemoryRecords(agentId, ALL_MEMORY_STATUSES)\n .filter(isUserContextRecord)\n .map((record) => ({\n statement: record.content,\n kind: record.kind,\n status: record.status,\n sensitivity: record.sensitivity ?? 'normal',\n durability: record.durability,\n canReference: record.disclosurePolicy !== 'silent',\n sourceName: record.source.provider ?? 'local',\n updatedAt: record.updatedAt,\n }));\n return c.json({\n version: 1,\n exportedAt: new Date().toISOString(),\n agentId,\n profile: profileBundle.profile,\n understanding,\n });\n });\n\n authenticated.post('/api/you/import', deps.strictRateLimitMiddleware, async (c) => {\n const body = await c.req.json().catch(() => null);\n if (!body || typeof body !== 'object' || Array.isArray(body) || body.version !== 1 || !Array.isArray(body.understanding)) {\n return c.json({ error: 'Invalid About You export' }, 400);\n }\n if (body.understanding.length > 500) return c.json({ error: 'Import is limited to 500 understandings' }, 400);\n const config = deps.service.currentConfig as Config;\n const agentId = selectedAgentId(config);\n const existingStatements = listAllAgentMemoryRecords(agentId, ALL_MEMORY_STATUSES)\n .filter(isUserContextRecord)\n .map((record) => record.content);\n const { imports, skippedCount } = prepareUserContextImport(body.understanding, existingStatements);\n runSqliteWriteTransaction(() => {\n for (const item of imports) {\n upsertMemoryRecord({\n providerId: 'local',\n kind: item.kind,\n agentId,\n content: item.statement,\n source: { provider: 'local', path: 'import://about-you' },\n confidence: 1,\n tags: ['user-understanding', 'user-import'],\n status: 'candidate',\n sensitivity: item.sensitivity,\n explicitness: 'explicit',\n durability: item.durability,\n importance: 0.7,\n disclosurePolicy: item.canReference ? 'referenceable' : 'silent',\n });\n }\n });\n return c.json({ ok: true, importedCount: imports.length, skippedCount });\n });\n\n authenticated.patch('/api/you/profile', deps.strictRateLimitMiddleware, async (c) => {\n const config = deps.service.currentConfig as Config;\n const parsed = parseProfilePatch(await c.req.json().catch(() => null));\n if ('error' in parsed) return c.json({ error: parsed.error }, 400);\n const current = await readUserProfileFile();\n const content = current.ok ? current.data.content : '';\n const nextContent = patchUserProfileMarkdown(content, parsed.patch);\n const saved = await writeUserProfileFile(nextContent);\n if (saved.ok === false) return c.json({ error: saved.error }, saved.status ?? 500);\n if (parsed.patch.callName !== undefined) {\n setUserProfilePromptState({ state: 'active' });\n }\n deps.service.refreshUserProfileContext();\n return c.json(await readProfileBundle(config));\n });\n\n authenticated.post('/api/you/profile-prompt', deps.strictRateLimitMiddleware, async (c) => {\n const body = await c.req.json().catch(() => ({}));\n const action = typeof body.action === 'string' ? body.action : '';\n if (action !== 'snooze' && action !== 'reset') {\n return c.json({ error: 'Action must be snooze or reset' }, 400);\n }\n const config = deps.service.currentConfig as Config;\n const current = await readProfileBundle(config);\n const suggestionHash = current.profileSetup.callNameSuggestion?.id;\n const promptState = action === 'snooze'\n ? setUserProfilePromptState({\n state: 'snoozed',\n suggestionHash,\n snoozedUntil: new Date(Date.now() + PROFILE_PROMPT_SNOOZE_MS).toISOString(),\n })\n : setUserProfilePromptState({ state: 'active', suggestionHash });\n return c.json({\n profileSetup: buildUserProfileSetup({ profile: current.profile, promptState, config }),\n });\n });\n\n authenticated.patch('/api/you/trust', deps.strictRateLimitMiddleware, async (c) => {\n const body = await c.req.json().catch(() => ({}));\n if (!isUserTrustLevel(body.defaultActionLevel)) {\n return c.json({ error: 'Invalid default action level' }, 400);\n }\n const policy = setUserTrustPolicy(body.defaultActionLevel);\n deps.service.refreshActionTrustPolicy();\n return c.json({\n trust: {\n defaultActionLevel: policy.defaultActionLevel,\n levels: USER_TRUST_LEVELS,\n autoRequiresExplicitOptIn: true,\n },\n });\n });\n\n authenticated.patch('/api/you/playbooks/:id', deps.strictRateLimitMiddleware, async (c) => {\n const id = c.req.param('id') as PlaybookId;\n if (!PLAYBOOK_IDS.includes(id)) return c.json({ error: 'Playbook not found' }, 404);\n const body = await c.req.json().catch(() => ({}));\n const enabled = body.enabled;\n if (typeof enabled !== 'boolean') return c.json({ error: 'enabled must be a boolean' }, 400);\n const config = deps.service.currentConfig as Config;\n const agentId = selectedAgentId(config);\n const pauseTag = `playbook:paused:${id}`;\n const active = listMemoryRecords({ agentId, status: 'active', limit: 500 })\n .filter(isUserContextRecord)\n .filter((record) => playbookForRecord(record) === id);\n const paused = listMemoryRecords({ agentId, status: 'archived', limit: 500 })\n .filter(isUserContextRecord)\n .filter((record) => record.tags?.includes(pauseTag));\n const targets = enabled ? paused : active;\n runSqliteWriteTransaction(() => {\n for (const record of targets) {\n preserveRecord(record, {\n status: enabled ? 'active' : 'archived',\n tags: enabled\n ? (record.tags ?? []).filter((tag) => tag !== pauseTag)\n : [...new Set([...(record.tags ?? []), pauseTag])],\n });\n }\n });\n const current = active.concat(paused);\n return c.json({ ok: true, playbook: buildPersonalPlaybooks(current.map((record) => ({\n ...record,\n status: enabled ? 'active' : 'archived',\n })))[0] });\n });\n\n authenticated.patch('/api/you/insights/:id', deps.strictRateLimitMiddleware, async (c) => {\n const config = deps.service.currentConfig as Config;\n const existing = editableRecord(c.req.param('id'), config);\n if (!existing || existing.status !== 'active' || !ACTIONABLE_INSIGHT_KINDS.has(existing.kind)) {\n return c.json({ error: 'Insight not found' }, 404);\n }\n const body = await c.req.json().catch(() => ({}));\n const action = typeof body.action === 'string' ? body.action : '';\n if (action === 'dismiss') {\n preserveRecord(existing, { tags: [...new Set([...(existing.tags ?? []), INSIGHT_DISMISSED_TAG])] });\n return c.json({ ok: true, status: 'dismissed' });\n }\n if (action !== 'apply') return c.json({ error: 'Action must be apply or dismiss' }, 400);\n\n const title = existing.content.trim().split(/\\r?\\n/)[0]!.slice(0, 72);\n const uiLocale = body.uiLocale === 'zh' ? 'zh' : 'en';\n const contractDraft = await draftGoalContract({\n title,\n context: existing.content,\n uiLocale,\n modelRef: config.goals?.judgeModelRef,\n });\n const goals = new GoalService();\n const goal = goals.create({\n title,\n description: existing.content,\n agentId: selectedAgentId(config),\n priority: 'normal',\n uiLocale,\n source: 'api',\n contract: contractDraft.contract,\n config,\n });\n goals.setContextMessage({ goalId: goal.id, text: existing.content });\n let queued = false;\n try {\n deps.service.enqueueGoalRun(goal.id, { source: 'api' });\n queued = true;\n } catch {\n queued = false;\n } finally {\n preserveRecord(existing, { tags: [...new Set([...(existing.tags ?? []), INSIGHT_ACCEPTED_TAG])] });\n }\n return c.json({ ok: true, status: queued ? 'queued' : 'saved', goal: goals.get(goal.id), href: `/goals/${goal.id}` });\n });\n\n authenticated.patch('/api/you/controls', deps.strictRateLimitMiddleware, async (c) => {\n const config = deps.service.currentConfig as Config;\n const agentId = selectedAgentId(config);\n const manifest = resolveEffectiveAgentManifestForAgent(config, agentId);\n const body = await c.req.json().catch(() => ({}));\n const parsed = MemoryPolicySchema.safeParse({\n ...manifest.memory,\n mode: body.mode,\n privacy: {\n ...manifest.memory.privacy,\n sensitiveWritePolicy: body.sensitiveWritePolicy,\n crossAgentSharing: body.crossAgentSharing,\n },\n });\n if (!parsed.success) {\n return c.json({ error: parsed.error.issues[0]?.message ?? 'Invalid personal context controls' }, 400);\n }\n const prep = prepareUpdateAgent(config, agentId, { memory: parsed.data });\n if (prep.ok === false) return c.json({ error: prep.error }, prep.status ?? 400);\n const saved = await deps.service.saveConfig(prep.data.nextConfig);\n if (!saved.saved) return c.json({ error: saved.error ?? 'save failed' }, 500);\n const updated = resolveEffectiveAgentManifestForAgent(deps.service.currentConfig as Config, agentId);\n return c.json({\n controls: {\n mode: updated.memory.mode,\n sensitiveWritePolicy: updated.memory.privacy?.sensitiveWritePolicy ?? 'confirm',\n crossAgentSharing: updated.memory.privacy?.crossAgentSharing ?? 'deny',\n },\n });\n });\n\n authenticated.delete('/api/you/sources/:instanceId', deps.strictRateLimitMiddleware, async (c) => {\n const config = deps.service.currentConfig as Config;\n const instanceId = c.req.param('instanceId');\n const installedInstances = listConnectorInstances(config);\n const instance = installedInstances.find((item) => item.instanceId === instanceId);\n const definition = instance\n ? listConnectorCatalog().find((item) => item.id === instance.connectorId)\n : undefined;\n if (!instance || !definition || !definition.capabilities.some((capability) => (\n capability === 'context' || capability === 'memory_source'\n ))) {\n return c.json({ error: 'Personal context source not found' }, 404);\n }\n const body = await c.req.json().catch(() => ({}));\n if (typeof body.deleteDerivedUnderstanding !== 'boolean') {\n return c.json({ error: 'deleteDerivedUnderstanding must be a boolean' }, 400);\n }\n\n try {\n const sourceInstances = installedInstances.filter((item) => item.connectorId === instance.connectorId);\n for (const sourceInstance of sourceInstances) {\n uninstallConnector(config, sourceInstance.instanceId);\n }\n const saved = await deps.service.saveConfig(config);\n if (!saved.saved) return c.json({ error: saved.error ?? 'save failed' }, 500);\n } catch (error) {\n return c.json({ error: error instanceof Error ? error.message : String(error) }, 400);\n }\n\n let deletedUnderstandingCount = 0;\n if (body.deleteDerivedUnderstanding) {\n const agentId = selectedAgentId(config);\n const targets = recordsDerivedFromPersonalContextSource(\n listAllAgentMemoryRecords(agentId, ALL_MEMORY_STATUSES),\n agentId,\n instance.connectorId,\n );\n runSqliteWriteTransaction(() => {\n for (const record of targets) deleteMemoryRecord(record.id);\n });\n deletedUnderstandingCount = targets.length;\n }\n return c.json({ ok: true, deletedUnderstandingCount });\n });\n\n authenticated.patch('/api/you/understanding/:id', deps.strictRateLimitMiddleware, async (c) => {\n const config = deps.service.currentConfig as Config;\n const existing = editableRecord(c.req.param('id'), config);\n if (!existing) return c.json({ error: 'Understanding not found' }, 404);\n const body = await c.req.json().catch(() => ({}));\n const action = typeof body.action === 'string' ? body.action : '';\n if (action === 'confirm') {\n return c.json({\n understanding: projectUserContextRecord(preserveRecord(existing, {\n status: 'active',\n reviewAfter: nextMemoryReviewAt(existing),\n })),\n });\n }\n if (action === 'reject') {\n return c.json({ understanding: projectUserContextRecord(preserveRecord(existing, { status: 'rejected' })) });\n }\n if (action === 'update') {\n const content = typeof body.content === 'string' ? body.content.trim() : '';\n if (!content) return c.json({ error: 'Updated understanding cannot be empty' }, 400);\n const replacement = upsertMemoryRecord({\n providerId: 'local',\n kind: existing.kind,\n agentId: existing.scope.agentId,\n workspaceId: existing.scope.workspaceId,\n sessionKey: existing.scope.sessionKey,\n projectId: existing.scope.projectId,\n content,\n source: { provider: 'local' },\n confidence: 1,\n tags: [...new Set([...(existing.tags ?? []), 'user-understanding', 'explicit-user-correction'])],\n status: 'active',\n sensitivity: existing.sensitivity,\n explicitness: 'explicit',\n durability: existing.durability,\n importance: Math.max(existing.importance, 0.8),\n disclosurePolicy: existing.disclosurePolicy,\n evidence: existing.evidence,\n reviewAfter: nextMemoryReviewAt({ durability: existing.durability, explicitness: 'explicit' }),\n supersedesRecordId: existing.id,\n conflictGroupId: existing.conflictGroupId,\n });\n preserveRecord(existing, { status: 'archived', validTo: new Date().toISOString() });\n return c.json({ understanding: projectUserContextRecord(replacement) });\n }\n return c.json({ error: 'Action must be confirm, reject, or update' }, 400);\n });\n\n authenticated.delete('/api/you/understanding/:id', deps.strictRateLimitMiddleware, (c) => {\n const config = deps.service.currentConfig as Config;\n const existing = editableRecord(c.req.param('id'), config);\n if (!existing) return c.json({ error: 'Understanding not found' }, 404);\n deleteMemoryRecord(existing.id);\n return c.json({ ok: true });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;kBAEsE;aAGC;AAsCvE,MAAM,mBAAmB,IAAI,IAA4B;CAAC;CAAU;CAAa;CAAe,CAAC;AACjG,MAAM,2BAA2B,IAAI,IAA0B;CAC7D;CACA;CACA;CACA;CACA;CACD,CAAC;AACF,MAAM,uBAAuB;AAC7B,MAAM,wBAAwB;AAC9B,MAAM,eAAe;CAAC;CAAiB;CAAa;CAAW;AAE/D,MAAM,uBAAgE;CACpE,UAAU;CACV,UAAU;CACV,UAAU;CACV,OAAO;CACR;AACD,MAAM,2BAA2B,QAAc,KAAK;AACpD,MAAM,sBAAgD;CACpD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AA4B,MAAM;EACxF,MAAM,SAAS,KAAK,QAAQ;EAC5B,MAAM,WAAW,eAAe,EAAE,IAAI,MAAM,KAAK,EAAE,OAAO;AAC1D,MAAI,CAAC,SAAU,QAAO,EAAE,KAAK,EAAE,OAAO,2BAA2B,EAAE,IAAI;AACvE,qBAAmB,SAAS,GAAG;AAC/B,SAAO,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC;GAC3B"}
1
+ {"version":3,"file":"you.js","names":[],"sources":["../../../../../src/gateway/hono/routes/you.ts"],"sourcesContent":["import type { Hono } from 'hono';\n\nimport { resolveDefaultAgentId } from '../../../agent/agent-scope.js';\nimport type { MemoryRecord } from '../../../agent/memory/types.js';\nimport { nextMemoryReviewAt, resolveMemoryStability } from '../../../agent/memory/lifecycle.js';\nimport type { Config } from '../../../config/schema.js';\nimport { UserContextConfigSchema } from '../../../user-context/config.js';\nimport { listConnectorCatalog } from '../../../connectors/catalog.js';\nimport { listConnectorInstances } from '../../../connectors/instances.js';\nimport { uninstallConnector } from '../../../connectors/install.js';\nimport { revokeComposioConnection } from '../../../connectors/composio.js';\nimport { draftGoalContract, GoalService } from '../../../goals/index.js';\nimport { readUserProfileFile, writeUserProfileFile } from '../../agents-admin.js';\nimport {\n decideMemoryReferenceConsent,\n deleteMemoryRecord,\n getMemoryRecord,\n getUserProfilePromptState,\n getUserTrustPolicy,\n listKnowledgeSourceItems,\n listKnowledgeSyncRuns,\n getConnectorConnection,\n listConnectorConnections,\n listMemoryRecords,\n listMemoryReferenceConsents,\n revokeMemoryReferenceConsent,\n runSqliteWriteTransaction,\n setUserProfilePromptState,\n setUserTrustPolicy,\n upsertMemoryRecord,\n} from '../../../storage/sqlite/index.js';\nimport { isUserTrustLevel, USER_TRUST_LEVELS } from '../../../user-context/trust-policy.js';\nimport {\n buildUserProfileSetup,\n parseUserProfileMarkdown,\n patchUserProfileMarkdown,\n type UserProfileFields,\n} from '../../../user-context/profile.js';\nimport {\n isUserContextRecord,\n isUserContextMemoryKind,\n projectPersonalContextSources,\n projectUserContextRecord,\n recordsDerivedFromPersonalContextSource,\n} from '../../../user-context/projection.js';\nimport { prepareUserContextImport } from '../../../user-context/import.js';\nimport { buildGoalSourceRecommendations } from '../../../user-context/source-recommendations.js';\nimport type { AuthenticatedRouteDeps } from './deps.js';\n\nconst VISIBLE_STATUSES = new Set<MemoryRecord['status']>(['active', 'candidate', 'needs_review']);\nconst ACTIONABLE_INSIGHT_KINDS = new Set<MemoryRecord['kind']>([\n 'routine',\n 'commitment',\n 'long_term_goal',\n 'derived_insight',\n 'task_lesson',\n]);\nconst INSIGHT_ACCEPTED_TAG = 'insight-action:accepted';\nconst INSIGHT_DISMISSED_TAG = 'insight-action:dismissed';\nconst PLAYBOOK_IDS = ['communication', 'execution', 'routines'] as const;\ntype PlaybookId = typeof PLAYBOOK_IDS[number];\nconst PLAYBOOK_DISABLED_TAG = 'playbook:disabled';\nconst PLAYBOOK_ORDER_PREFIX = 'playbook:order:';\nconst PROFILE_FIELD_LIMITS: Record<keyof UserProfileFields, number> = {\n callName: 80,\n pronouns: 80,\n timezone: 100,\n notes: 5_000,\n};\nconst PROFILE_PROMPT_SNOOZE_MS = 7 * 24 * 60 * 60 * 1_000;\nconst ALL_MEMORY_STATUSES: MemoryRecord['status'][] = [\n 'candidate',\n 'active',\n 'needs_review',\n 'stale',\n 'archived',\n 'rejected',\n];\nconst MEMORY_SENSITIVITIES = new Set<NonNullable<MemoryRecord['sensitivity']>>(['normal', 'personal', 'secret', 'regulated']);\nconst MEMORY_DURABILITIES = new Set<MemoryRecord['durability']>(['ephemeral', 'durable', 'recurring']);\nconst MEMORY_DISCLOSURE_POLICIES = new Set<MemoryRecord['disclosurePolicy']>(['silent', 'referenceable', 'ask_before_reference']);\n\nfunction listAllUserContextRecords(statuses: MemoryRecord['status'][]): MemoryRecord[] {\n return statuses.flatMap((status) => {\n const records: MemoryRecord[] = [];\n let offset = 0;\n while (true) {\n const page = listMemoryRecords({ status, limit: 500, offset });\n records.push(...page);\n if (page.length < 500) break;\n offset += page.length;\n }\n return records;\n });\n}\n\nfunction projectReferenceConsent(consent: ReturnType<typeof listMemoryReferenceConsents>[number], record: MemoryRecord) {\n return {\n id: consent.id,\n recordId: consent.recordId,\n sessionKey: consent.sessionKey,\n purpose: consent.purpose,\n statement: record.content,\n sourceName: record.source.provider ?? 'local',\n status: consent.status,\n grantScope: consent.grantScope,\n expiresAt: consent.expiresAt,\n createdAt: consent.createdAt,\n updatedAt: consent.updatedAt,\n };\n}\n\nfunction buildConflictGroups(records: MemoryRecord[]) {\n const groups = new Map<string, MemoryRecord[]>();\n for (const record of records) {\n if (!record.conflictGroupId) continue;\n const group = groups.get(record.conflictGroupId) ?? [];\n group.push(record);\n groups.set(record.conflictGroupId, group);\n }\n return [...groups.entries()]\n .filter(([, group]) => group.length > 1 && group.some((record) => VISIBLE_STATUSES.has(record.status)))\n .map(([id, group]) => ({\n id,\n records: group\n .sort((left, right) => Date.parse(right.updatedAt) - Date.parse(left.updatedAt))\n .map((record) => ({ ...projectUserContextRecord(record), storedStatus: record.status })),\n unresolved: group.filter((record) => VISIBLE_STATUSES.has(record.status)).length > 1,\n }));\n}\n\nasync function readProfileBundle(config: Config) {\n const result = await readUserProfileFile();\n const profileContent = result.ok ? result.data.content : '';\n const profile = parseUserProfileMarkdown(profileContent);\n const promptState = getUserProfilePromptState();\n return {\n profileContent,\n profile,\n profileSetup: buildUserProfileSetup({ profile, promptState, config }),\n };\n}\n\nfunction parseProfilePatch(body: unknown): { patch: Partial<UserProfileFields> } | { error: string } {\n if (!body || typeof body !== 'object' || Array.isArray(body)) return { error: 'Invalid profile patch' };\n const record = body as Record<string, unknown>;\n const patch: Partial<UserProfileFields> = {};\n for (const field of Object.keys(PROFILE_FIELD_LIMITS) as Array<keyof UserProfileFields>) {\n if (!(field in record)) continue;\n if (typeof record[field] !== 'string') return { error: `${field} must be a string` };\n const value = record[field].trim();\n if (value.length > PROFILE_FIELD_LIMITS[field]) {\n return { error: `${field} is too long` };\n }\n patch[field] = value;\n }\n return Object.keys(patch).length > 0 ? { patch } : { error: 'No profile fields provided' };\n}\n\nfunction playbookForRecord(record: MemoryRecord): PlaybookId | undefined {\n if (record.kind === 'preference' || record.kind === 'boundary' || record.kind === 'tool_preference') return 'communication';\n if (record.kind === 'task_lesson' || record.kind === 'derived_insight') return 'execution';\n if (record.kind === 'routine') return 'routines';\n return undefined;\n}\n\nfunction playbookRuleOrder(record: MemoryRecord): number {\n const tag = record.tags?.find((value) => value.startsWith(PLAYBOOK_ORDER_PREFIX));\n const parsed = tag ? Number.parseInt(tag.slice(PLAYBOOK_ORDER_PREFIX.length), 10) : Number.NaN;\n return Number.isFinite(parsed) ? parsed : 1_000;\n}\n\nfunction patchPlaybookRuleTags(record: MemoryRecord, patch: { enabled?: boolean; order?: number }): string[] {\n let tags = (record.tags ?? []).filter((tag) => !tag.startsWith(PLAYBOOK_ORDER_PREFIX));\n if (patch.enabled === true) tags = tags.filter((tag) => tag !== PLAYBOOK_DISABLED_TAG);\n if (patch.enabled === false) tags.push(PLAYBOOK_DISABLED_TAG);\n if (patch.order !== undefined) tags.push(`${PLAYBOOK_ORDER_PREFIX}${patch.order}`);\n return [...new Set(tags)];\n}\n\nexport function buildPersonalPlaybooks(records: MemoryRecord[]) {\n return PLAYBOOK_IDS.map((id) => {\n const rules = records\n .filter((record) => playbookForRecord(record) === id)\n .sort((left, right) => playbookRuleOrder(left) - playbookRuleOrder(right) || left.updatedAt.localeCompare(right.updatedAt));\n return {\n id,\n enabled: rules.some((record) => !record.tags?.includes(PLAYBOOK_DISABLED_TAG)),\n rules: rules.map((record) => ({\n id: record.id,\n statement: record.content,\n origin: record.explicitness,\n enabled: !record.tags?.includes(PLAYBOOK_DISABLED_TAG),\n order: playbookRuleOrder(record),\n })),\n updatedAt: rules.map((record) => record.updatedAt).sort().at(-1),\n };\n });\n}\n\nexport function buildInsightSuggestions(records: MemoryRecord[]) {\n return records\n .filter((record) => record.status === 'active')\n .filter((record) => ACTIONABLE_INSIGHT_KINDS.has(record.kind))\n .filter((record) => !record.tags?.includes(INSIGHT_ACCEPTED_TAG) && !record.tags?.includes(INSIGHT_DISMISSED_TAG))\n .filter((record) => {\n const stability = resolveMemoryStability(record);\n return record.explicitness === 'explicit' || (record.evidence?.length ?? 0) >= 2 || stability.band === 'strong';\n })\n .sort((left, right) => right.importance - left.importance || Date.parse(right.updatedAt) - Date.parse(left.updatedAt))\n .slice(0, 5)\n .map((record) => ({\n id: record.id,\n insight: record.content,\n kind: record.kind,\n action: record.kind === 'routine' ? 'make_repeatable' as const : 'start_progress' as const,\n evidenceCount: record.evidence?.length ?? 0,\n confidence: record.confidence,\n sourceName: record.source.provider ?? 'local',\n }));\n}\n\nexport function buildRoutineAutomationDraftHref(record: Pick<MemoryRecord, 'id' | 'content'>): string {\n const params = new URLSearchParams({\n draft: record.content,\n autogenerate: '1',\n insight: record.id,\n });\n return `/automations?${params.toString()}`;\n}\n\nfunction selectedAgentId(config: Config): string {\n return resolveDefaultAgentId(config);\n}\n\nfunction editableRecord(recordId: string): MemoryRecord | null {\n const record = getMemoryRecord(recordId);\n if (\n !record\n || !VISIBLE_STATUSES.has(record.status)\n || !isUserContextRecord(record)\n ) return null;\n return record;\n}\n\nfunction preserveRecord(record: MemoryRecord, patch: Partial<Parameters<typeof upsertMemoryRecord>[0]>) {\n return upsertMemoryRecord({\n id: record.id,\n providerId: record.source.provider ?? 'local',\n kind: record.kind,\n sourceAgentId: record.provenance.sourceAgentId,\n workspaceId: record.scope.workspaceId,\n sessionKey: record.scope.sessionKey,\n projectId: record.scope.projectId,\n content: record.content,\n source: record.source,\n confidence: record.confidence,\n tags: record.tags,\n status: record.status,\n sensitivity: record.sensitivity,\n canonicalKey: record.canonicalKey,\n explicitness: record.explicitness,\n durability: record.durability,\n importance: record.importance,\n disclosurePolicy: record.disclosurePolicy,\n evidence: record.evidence,\n reviewAfter: record.reviewAfter,\n expiresAt: record.expiresAt,\n validFrom: record.validFrom,\n validTo: record.validTo,\n supersedesRecordId: record.supersedesRecordId,\n conflictGroupId: record.conflictGroupId,\n ...patch,\n });\n}\n\nexport function registerYouRoutes(authenticated: Hono, deps: AuthenticatedRouteDeps): void {\n authenticated.get('/api/you', async (c) => {\n const config = deps.service.currentConfig as Config;\n const agentId = selectedAgentId(config);\n const profileBundle = await readProfileBundle(config);\n const allUserContextRecords = listAllUserContextRecords(ALL_MEMORY_STATUSES)\n .filter(isUserContextRecord);\n const records = allUserContextRecords.filter((record) => VISIBLE_STATUSES.has(record.status));\n const recordById = new Map(allUserContextRecords.map((record) => [record.id, record]));\n const consents = listMemoryReferenceConsents();\n const trustPolicy = getUserTrustPolicy();\n const sourceDefinitions = listConnectorCatalog();\n const sourceInstances = listConnectorInstances(config);\n const sources = projectPersonalContextSources(sourceDefinitions, sourceInstances, allUserContextRecords, {\n sourceItems: listKnowledgeSourceItems({ limit: 500 }),\n syncRuns: listKnowledgeSyncRuns({ limit: 500 }),\n connections: listConnectorConnections({ principalId: 'local-owner' }),\n });\n const activeGoals = new GoalService().list({\n agentId,\n status: ['active', 'paused', 'blocked', 'needs_input'],\n limit: 20,\n });\n return c.json({\n scope: {\n profile: 'global',\n memory: 'global',\n trust: 'global',\n },\n ...profileBundle,\n understanding: records.map(projectUserContextRecord),\n consentRequests: consents.filter((consent) => consent.status === 'pending').flatMap((consent) => {\n const record = recordById.get(consent.recordId);\n return record ? [projectReferenceConsent(consent, record)] : [];\n }),\n referenceGrants: consents.filter((consent) => (\n consent.status === 'granted'\n && (!consent.expiresAt || Date.parse(consent.expiresAt) > Date.now())\n )).flatMap((consent) => {\n const record = recordById.get(consent.recordId);\n return record ? [projectReferenceConsent(consent, record)] : [];\n }),\n conflictGroups: buildConflictGroups(allUserContextRecords),\n insights: buildInsightSuggestions(records),\n playbooks: buildPersonalPlaybooks(records.filter((record) => record.status === 'active')),\n sources,\n sourceRecommendations: buildGoalSourceRecommendations(\n sourceDefinitions.filter((definition) => (\n definition.capabilities.includes('context') || definition.capabilities.includes('memory_source')\n )),\n new Set(sourceInstances.map((instance) => instance.connectorId)),\n activeGoals,\n ),\n controls: {\n mode: config.userContext.memory.mode,\n sensitiveWritePolicy: config.userContext.privacy.sensitiveWritePolicy,\n },\n trust: {\n defaultActionLevel: trustPolicy.defaultActionLevel,\n levels: USER_TRUST_LEVELS,\n autoRequiresExplicitOptIn: true,\n },\n });\n });\n\n authenticated.get('/api/you/profile', async (c) => {\n return c.json(await readProfileBundle(deps.service.currentConfig as Config));\n });\n\n authenticated.get('/api/you/export', async (c) => {\n const config = deps.service.currentConfig as Config;\n const profileBundle = await readProfileBundle(config);\n const understanding = listAllUserContextRecords(ALL_MEMORY_STATUSES)\n .filter(isUserContextRecord)\n .map((record) => ({\n statement: record.content,\n kind: record.kind,\n status: record.status,\n sensitivity: record.sensitivity ?? 'normal',\n durability: record.durability,\n disclosurePolicy: record.disclosurePolicy,\n sourceName: record.source.provider ?? 'local',\n updatedAt: record.updatedAt,\n }));\n return c.json({\n version: 2,\n exportedAt: new Date().toISOString(),\n profile: profileBundle.profile,\n understanding,\n });\n });\n\n authenticated.post('/api/you/import', deps.strictRateLimitMiddleware, async (c) => {\n const body = await c.req.json().catch(() => null);\n if (!body || typeof body !== 'object' || Array.isArray(body) || body.version !== 2 || !Array.isArray(body.understanding)) {\n return c.json({ error: 'Invalid About You export' }, 400);\n }\n if (body.understanding.length > 500) return c.json({ error: 'Import is limited to 500 understandings' }, 400);\n const config = deps.service.currentConfig as Config;\n const agentId = selectedAgentId(config);\n const existingStatements = listAllUserContextRecords(ALL_MEMORY_STATUSES)\n .filter(isUserContextRecord)\n .map((record) => record.content);\n const { imports, skippedCount } = prepareUserContextImport(body.understanding, existingStatements);\n runSqliteWriteTransaction(() => {\n for (const item of imports) {\n upsertMemoryRecord({\n providerId: 'local',\n kind: item.kind,\n sourceAgentId: agentId,\n content: item.statement,\n source: { provider: 'local', path: 'import://about-you' },\n confidence: 1,\n tags: ['user-understanding', 'user-import'],\n status: 'candidate',\n sensitivity: item.sensitivity,\n explicitness: 'explicit',\n durability: item.durability,\n importance: 0.7,\n disclosurePolicy: item.disclosurePolicy,\n });\n }\n });\n return c.json({ ok: true, importedCount: imports.length, skippedCount });\n });\n\n authenticated.post('/api/you/understanding', deps.strictRateLimitMiddleware, async (c) => {\n const body = await c.req.json().catch(() => ({}));\n const content = typeof body.content === 'string' ? body.content.trim() : '';\n const kind = isUserContextMemoryKind(body.kind) ? body.kind : undefined;\n if (!content || content.length > 5_000) return c.json({ error: 'Understanding content must be 1-5000 characters' }, 400);\n if (!kind) return c.json({ error: 'A valid user understanding kind is required' }, 400);\n const duplicate = listAllUserContextRecords(ALL_MEMORY_STATUSES)\n .filter(isUserContextRecord)\n .find((record) => record.content.trim().toLocaleLowerCase() === content.toLocaleLowerCase());\n if (duplicate) return c.json({ error: 'This understanding already exists', understanding: projectUserContextRecord(duplicate) }, 409);\n const sensitivity = MEMORY_SENSITIVITIES.has(body.sensitivity) ? body.sensitivity : 'normal';\n const durability = MEMORY_DURABILITIES.has(body.durability) ? body.durability : 'durable';\n const disclosurePolicy = MEMORY_DISCLOSURE_POLICIES.has(body.disclosurePolicy)\n ? body.disclosurePolicy\n : 'referenceable';\n const config = deps.service.currentConfig as Config;\n const created = upsertMemoryRecord({\n providerId: 'local',\n kind,\n sourceAgentId: selectedAgentId(config),\n content,\n source: { provider: 'local', path: 'you://manual' },\n confidence: 1,\n tags: ['user-understanding', 'explicit-user-memory'],\n status: 'active',\n sensitivity,\n explicitness: 'explicit',\n durability,\n importance: 0.8,\n disclosurePolicy,\n reviewAfter: nextMemoryReviewAt({ durability, explicitness: 'explicit' }),\n });\n return c.json({ understanding: projectUserContextRecord(created) }, 201);\n });\n\n authenticated.get('/api/you/understanding/:id/history', (c) => {\n const all = listAllUserContextRecords(ALL_MEMORY_STATUSES).filter(isUserContextRecord);\n const target = all.find((record) => record.id === c.req.param('id'));\n if (!target) return c.json({ error: 'Understanding not found' }, 404);\n const relatedIds = new Set([target.id]);\n let changed = true;\n while (changed) {\n changed = false;\n for (const record of all) {\n if (\n (record.supersedesRecordId && relatedIds.has(record.supersedesRecordId))\n || (record.supersedesRecordId && relatedIds.has(record.id))\n ) {\n if (!relatedIds.has(record.id)) { relatedIds.add(record.id); changed = true; }\n if (record.supersedesRecordId && !relatedIds.has(record.supersedesRecordId)) {\n relatedIds.add(record.supersedesRecordId);\n changed = true;\n }\n }\n }\n }\n const history = all\n .filter((record) => relatedIds.has(record.id))\n .sort((left, right) => Date.parse(right.updatedAt) - Date.parse(left.updatedAt))\n .map((record) => ({ ...projectUserContextRecord(record), storedStatus: record.status }));\n return c.json({ history });\n });\n\n authenticated.post('/api/you/understanding/batch', deps.strictRateLimitMiddleware, async (c) => {\n const body = await c.req.json().catch(() => ({}));\n const ids: string[] = Array.isArray(body.ids)\n ? [...new Set<string>(body.ids.filter((id: unknown): id is string => typeof id === 'string' && id.trim().length > 0).slice(0, 100))]\n : [];\n const action = body.action === 'confirm' || body.action === 'reject' || body.action === 'forget' ? body.action : undefined;\n if (!ids.length || !action) return c.json({ error: 'ids and a valid action are required' }, 400);\n let updatedCount = 0;\n runSqliteWriteTransaction(() => {\n for (const id of ids) {\n const record = editableRecord(id);\n if (!record) continue;\n if (action === 'forget') deleteMemoryRecord(id);\n else preserveRecord(record, {\n status: action === 'confirm' ? 'active' : 'rejected',\n ...(action === 'confirm' ? { reviewAfter: nextMemoryReviewAt(record) } : {}),\n });\n updatedCount += 1;\n }\n });\n return c.json({ ok: true, updatedCount });\n });\n\n authenticated.post('/api/you/conflicts/:id/resolve', deps.strictRateLimitMiddleware, async (c) => {\n const body = await c.req.json().catch(() => ({}));\n const winnerId = typeof body.winnerId === 'string' ? body.winnerId : '';\n const group = listAllUserContextRecords(ALL_MEMORY_STATUSES)\n .filter(isUserContextRecord)\n .filter((record) => record.conflictGroupId === c.req.param('id'));\n const winner = group.find((record) => record.id === winnerId && VISIBLE_STATUSES.has(record.status));\n if (group.length < 2 || !winner) return c.json({ error: 'Conflict group or winner not found' }, 404);\n const now = new Date().toISOString();\n runSqliteWriteTransaction(() => {\n for (const record of group) {\n preserveRecord(record, record.id === winnerId\n ? { status: 'active', reviewAfter: nextMemoryReviewAt(record) }\n : { status: 'archived', validTo: record.validTo ?? now });\n }\n });\n return c.json({ ok: true, understanding: projectUserContextRecord(getMemoryRecord(winnerId)!) });\n });\n\n authenticated.patch('/api/you/profile', deps.strictRateLimitMiddleware, async (c) => {\n const config = deps.service.currentConfig as Config;\n const parsed = parseProfilePatch(await c.req.json().catch(() => null));\n if ('error' in parsed) return c.json({ error: parsed.error }, 400);\n const current = await readUserProfileFile();\n const content = current.ok ? current.data.content : '';\n const nextContent = patchUserProfileMarkdown(content, parsed.patch);\n const saved = await writeUserProfileFile(nextContent);\n if (saved.ok === false) return c.json({ error: saved.error }, saved.status ?? 500);\n if (parsed.patch.callName !== undefined) {\n setUserProfilePromptState({ state: 'active' });\n }\n deps.service.refreshUserProfileContext();\n return c.json(await readProfileBundle(config));\n });\n\n authenticated.post('/api/you/profile-prompt', deps.strictRateLimitMiddleware, async (c) => {\n const body = await c.req.json().catch(() => ({}));\n const action = typeof body.action === 'string' ? body.action : '';\n if (action !== 'snooze' && action !== 'reset') {\n return c.json({ error: 'Action must be snooze or reset' }, 400);\n }\n const config = deps.service.currentConfig as Config;\n const current = await readProfileBundle(config);\n const suggestionHash = current.profileSetup.callNameSuggestion?.id;\n const promptState = action === 'snooze'\n ? setUserProfilePromptState({\n state: 'snoozed',\n suggestionHash,\n snoozedUntil: new Date(Date.now() + PROFILE_PROMPT_SNOOZE_MS).toISOString(),\n })\n : setUserProfilePromptState({ state: 'active', suggestionHash });\n return c.json({\n profileSetup: buildUserProfileSetup({ profile: current.profile, promptState, config }),\n });\n });\n\n authenticated.patch('/api/you/trust', deps.strictRateLimitMiddleware, async (c) => {\n const body = await c.req.json().catch(() => ({}));\n if (!isUserTrustLevel(body.defaultActionLevel)) {\n return c.json({ error: 'Invalid default action level' }, 400);\n }\n const policy = setUserTrustPolicy(body.defaultActionLevel);\n deps.service.refreshActionTrustPolicy();\n return c.json({\n trust: {\n defaultActionLevel: policy.defaultActionLevel,\n levels: USER_TRUST_LEVELS,\n autoRequiresExplicitOptIn: true,\n },\n });\n });\n\n authenticated.patch('/api/you/playbooks/:id', deps.strictRateLimitMiddleware, async (c) => {\n const id = c.req.param('id') as PlaybookId;\n if (!PLAYBOOK_IDS.includes(id)) return c.json({ error: 'Playbook not found' }, 404);\n const body = await c.req.json().catch(() => ({}));\n const enabled = body.enabled;\n if (typeof enabled !== 'boolean') return c.json({ error: 'enabled must be a boolean' }, 400);\n const active = listMemoryRecords({ status: 'active', limit: 500 })\n .filter(isUserContextRecord)\n .filter((record) => playbookForRecord(record) === id);\n runSqliteWriteTransaction(() => {\n for (const record of active) {\n preserveRecord(record, {\n tags: patchPlaybookRuleTags(record, { enabled }),\n });\n }\n });\n const current = active.map((record) => ({ ...record, tags: patchPlaybookRuleTags(record, { enabled }) }));\n return c.json({ ok: true, playbook: buildPersonalPlaybooks(current).find((playbook) => playbook.id === id) });\n });\n\n authenticated.post('/api/you/playbooks/:id/rules', deps.strictRateLimitMiddleware, async (c) => {\n const id = c.req.param('id') as PlaybookId;\n if (!PLAYBOOK_IDS.includes(id)) return c.json({ error: 'Playbook not found' }, 404);\n const body = await c.req.json().catch(() => ({}));\n const statement = typeof body.statement === 'string' ? body.statement.trim() : '';\n if (!statement || statement.length > 5_000) return c.json({ error: 'Rule statement is required' }, 400);\n const kind: MemoryRecord['kind'] = id === 'communication' ? 'preference' : id === 'execution' ? 'task_lesson' : 'routine';\n const record = upsertMemoryRecord({\n providerId: 'local',\n kind,\n sourceAgentId: selectedAgentId(deps.service.currentConfig as Config),\n content: statement,\n source: { provider: 'local', path: 'you://playbook' },\n confidence: 1,\n tags: ['user-understanding', 'playbook:explicit', `${PLAYBOOK_ORDER_PREFIX}${Number.isInteger(body.order) ? body.order : 1_000}`],\n status: 'active',\n sensitivity: 'normal',\n explicitness: 'explicit',\n durability: id === 'routines' ? 'recurring' : 'durable',\n importance: 0.85,\n disclosurePolicy: 'referenceable',\n });\n return c.json({\n ok: true,\n rule: buildPersonalPlaybooks([record]).find((playbook) => playbook.id === id)?.rules[0],\n }, 201);\n });\n\n authenticated.patch('/api/you/playbooks/:id/rules/:recordId', deps.strictRateLimitMiddleware, async (c) => {\n const id = c.req.param('id') as PlaybookId;\n const record = editableRecord(c.req.param('recordId'));\n if (!PLAYBOOK_IDS.includes(id) || !record || playbookForRecord(record) !== id) {\n return c.json({ error: 'Playbook rule not found' }, 404);\n }\n const body = await c.req.json().catch(() => ({}));\n const content = body.statement === undefined\n ? record.content\n : typeof body.statement === 'string' ? body.statement.trim() : '';\n if (!content || content.length > 5_000) return c.json({ error: 'Rule statement is required' }, 400);\n if (body.enabled !== undefined && typeof body.enabled !== 'boolean') return c.json({ error: 'enabled must be boolean' }, 400);\n if (body.order !== undefined && (!Number.isInteger(body.order) || body.order < 0 || body.order > 10_000)) {\n return c.json({ error: 'order must be an integer between 0 and 10000' }, 400);\n }\n const updated = preserveRecord(record, {\n content,\n tags: patchPlaybookRuleTags(record, { enabled: body.enabled, order: body.order }),\n explicitness: body.statement === undefined ? record.explicitness : 'explicit',\n });\n return c.json({\n ok: true,\n rule: buildPersonalPlaybooks([updated]).find((playbook) => playbook.id === id)?.rules[0],\n });\n });\n\n authenticated.delete('/api/you/playbooks/:id/rules/:recordId', deps.strictRateLimitMiddleware, (c) => {\n const id = c.req.param('id') as PlaybookId;\n const record = editableRecord(c.req.param('recordId'));\n if (!PLAYBOOK_IDS.includes(id) || !record || playbookForRecord(record) !== id) {\n return c.json({ error: 'Playbook rule not found' }, 404);\n }\n deleteMemoryRecord(record.id);\n return c.json({ ok: true });\n });\n\n authenticated.patch('/api/you/insights/:id', deps.strictRateLimitMiddleware, async (c) => {\n const config = deps.service.currentConfig as Config;\n const existing = editableRecord(c.req.param('id'));\n if (!existing || existing.status !== 'active' || !ACTIONABLE_INSIGHT_KINDS.has(existing.kind)) {\n return c.json({ error: 'Insight not found' }, 404);\n }\n const body = await c.req.json().catch(() => ({}));\n const action = typeof body.action === 'string' ? body.action : '';\n if (action === 'dismiss') {\n preserveRecord(existing, { tags: [...new Set([...(existing.tags ?? []), INSIGHT_DISMISSED_TAG])] });\n return c.json({ ok: true, status: 'dismissed' });\n }\n if (action === 'complete' && existing.kind === 'routine') {\n preserveRecord(existing, { tags: [...new Set([...(existing.tags ?? []), INSIGHT_ACCEPTED_TAG])] });\n return c.json({ ok: true, status: 'saved' });\n }\n if (action !== 'apply') return c.json({ error: 'Action must be apply, complete, or dismiss' }, 400);\n\n if (existing.kind === 'routine') {\n return c.json({ ok: true, status: 'drafting', href: buildRoutineAutomationDraftHref(existing) });\n }\n\n const title = existing.content.trim().split(/\\r?\\n/)[0]!.slice(0, 72);\n const uiLocale = body.uiLocale === 'zh' ? 'zh' : 'en';\n const contractDraft = await draftGoalContract({\n title,\n context: existing.content,\n uiLocale,\n modelRef: config.goals?.judgeModelRef,\n });\n const goals = new GoalService();\n const goal = goals.create({\n title,\n description: existing.content,\n agentId: selectedAgentId(config),\n priority: 'normal',\n uiLocale,\n source: 'api',\n contract: contractDraft.contract,\n config,\n });\n goals.setContextMessage({ goalId: goal.id, text: existing.content });\n let queued = false;\n try {\n deps.service.enqueueGoalRun(goal.id, { source: 'api' });\n queued = true;\n } catch {\n queued = false;\n } finally {\n preserveRecord(existing, { tags: [...new Set([...(existing.tags ?? []), INSIGHT_ACCEPTED_TAG])] });\n }\n return c.json({ ok: true, status: queued ? 'queued' : 'saved', goal: goals.get(goal.id), href: `/goals/${goal.id}` });\n });\n\n authenticated.patch('/api/you/controls', deps.strictRateLimitMiddleware, async (c) => {\n const config = deps.service.currentConfig as Config;\n const body = await c.req.json().catch(() => ({}));\n const parsed = UserContextConfigSchema.safeParse({\n ...config.userContext,\n memory: { ...config.userContext.memory, mode: body.mode },\n privacy: { ...config.userContext.privacy, sensitiveWritePolicy: body.sensitiveWritePolicy },\n });\n if (!parsed.success) {\n return c.json({ error: parsed.error.issues[0]?.message ?? 'Invalid personal context controls' }, 400);\n }\n const saved = await deps.service.saveConfig({ ...config, userContext: parsed.data });\n if (!saved.saved) return c.json({ error: saved.error ?? 'save failed' }, 500);\n const updated = (deps.service.currentConfig as Config).userContext;\n return c.json({\n controls: {\n mode: updated.memory.mode,\n sensitiveWritePolicy: updated.privacy.sensitiveWritePolicy,\n },\n });\n });\n\n authenticated.patch('/api/you/consents/:id', deps.strictRateLimitMiddleware, async (c) => {\n const body = await c.req.json().catch(() => ({}));\n const decision = typeof body.decision === 'string' ? body.decision : '';\n if (!['once', 'session', 'always', 'deny'].includes(decision)) {\n return c.json({ error: 'Decision must be once, session, always, or deny' }, 400);\n }\n const consent = decideMemoryReferenceConsent(\n c.req.param('id'),\n decision as 'once' | 'session' | 'always' | 'deny',\n );\n if (!consent) return c.json({ error: 'Pending consent not found' }, 404);\n return c.json({ ok: true, consent });\n });\n\n authenticated.delete('/api/you/consents/:id', deps.strictRateLimitMiddleware, (c) => {\n const consent = revokeMemoryReferenceConsent(c.req.param('id'));\n if (!consent) return c.json({ error: 'Active reference grant not found' }, 404);\n return c.json({ ok: true, consent });\n });\n\n authenticated.delete('/api/you/sources/:instanceId', deps.strictRateLimitMiddleware, async (c) => {\n const config = deps.service.currentConfig as Config;\n const instanceId = c.req.param('instanceId');\n const installedInstances = listConnectorInstances(config);\n const connection = getConnectorConnection(instanceId);\n const instance = installedInstances.find((item) => item.instanceId === instanceId);\n const connectorId = connection?.connectorId ?? instance?.connectorId;\n const definition = connectorId\n ? listConnectorCatalog().find((item) => item.id === connectorId)\n : undefined;\n if ((!instance && !connection) || !definition || !definition.capabilities.some((capability) => (\n capability === 'context' || capability === 'memory_source'\n ))) {\n return c.json({ error: 'Personal context source not found' }, 404);\n }\n const body = await c.req.json().catch(() => ({}));\n if (typeof body.deleteDerivedUnderstanding !== 'boolean') {\n return c.json({ error: 'deleteDerivedUnderstanding must be a boolean' }, 400);\n }\n\n try {\n if (connection) {\n await revokeComposioConnection(connection.id);\n } else if (instance) {\n uninstallConnector(config, instance.instanceId);\n const saved = await deps.service.saveConfig(config);\n if (!saved.saved) return c.json({ error: saved.error ?? 'save failed' }, 500);\n }\n } catch (error) {\n return c.json({ error: error instanceof Error ? error.message : String(error) }, 400);\n }\n\n let deletedUnderstandingCount = 0;\n if (body.deleteDerivedUnderstanding) {\n const sourceInstanceId = connection\n ? `composio:${connection.connectorId}:${connection.id}`\n : instanceId;\n const targets = recordsDerivedFromPersonalContextSource(\n listAllUserContextRecords(ALL_MEMORY_STATUSES),\n sourceInstanceId,\n );\n runSqliteWriteTransaction(() => {\n for (const record of targets) deleteMemoryRecord(record.id);\n });\n deletedUnderstandingCount = targets.length;\n }\n return c.json({ ok: true, deletedUnderstandingCount });\n });\n\n authenticated.patch('/api/you/understanding/:id', deps.strictRateLimitMiddleware, async (c) => {\n const existing = editableRecord(c.req.param('id'));\n if (!existing) return c.json({ error: 'Understanding not found' }, 404);\n const body = await c.req.json().catch(() => ({}));\n const action = typeof body.action === 'string' ? body.action : '';\n if (action === 'confirm') {\n return c.json({\n understanding: projectUserContextRecord(preserveRecord(existing, {\n status: 'active',\n reviewAfter: nextMemoryReviewAt(existing),\n })),\n });\n }\n if (action === 'reject') {\n return c.json({ understanding: projectUserContextRecord(preserveRecord(existing, { status: 'rejected' })) });\n }\n if (action === 'update') {\n const content = typeof body.content === 'string' ? body.content.trim() : '';\n if (!content) return c.json({ error: 'Updated understanding cannot be empty' }, 400);\n const replacement = upsertMemoryRecord({\n providerId: 'local',\n kind: existing.kind,\n sourceAgentId: existing.provenance.sourceAgentId,\n workspaceId: existing.scope.workspaceId,\n sessionKey: existing.scope.sessionKey,\n projectId: existing.scope.projectId,\n content,\n source: { provider: 'local' },\n confidence: 1,\n tags: [...new Set([...(existing.tags ?? []), 'user-understanding', 'explicit-user-correction'])],\n status: 'active',\n sensitivity: existing.sensitivity,\n explicitness: 'explicit',\n durability: existing.durability,\n importance: Math.max(existing.importance, 0.8),\n disclosurePolicy: existing.disclosurePolicy,\n evidence: existing.evidence,\n reviewAfter: nextMemoryReviewAt({ durability: existing.durability, explicitness: 'explicit' }),\n supersedesRecordId: existing.id,\n conflictGroupId: existing.conflictGroupId,\n });\n preserveRecord(existing, { status: 'archived', validTo: new Date().toISOString() });\n return c.json({ understanding: projectUserContextRecord(replacement) });\n }\n return c.json({ error: 'Action must be confirm, reject, or update' }, 400);\n });\n\n authenticated.delete('/api/you/understanding/:id', deps.strictRateLimitMiddleware, (c) => {\n const existing = editableRecord(c.req.param('id'));\n if (!existing) return c.json({ error: 'Understanding not found' }, 404);\n deleteMemoryRecord(existing.id);\n return c.json({ ok: true });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;kBAEsE;aAII;AA2C1E,MAAM,mBAAmB,IAAI,IAA4B;CAAC;CAAU;CAAa;CAAe,CAAC;AACjG,MAAM,2BAA2B,IAAI,IAA0B;CAC7D;CACA;CACA;CACA;CACA;CACD,CAAC;AACF,MAAM,uBAAuB;AAC7B,MAAM,wBAAwB;AAC9B,MAAM,eAAe;CAAC;CAAiB;CAAa;CAAW;AAE/D,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,uBAAgE;CACpE,UAAU;CACV,UAAU;CACV,UAAU;CACV,OAAO;CACR;AACD,MAAM,2BAA2B,QAAc,KAAK;AACpD,MAAM,sBAAgD;CACpD;CACA;CACA;CACA;CACA;CACA;CACD;AACD,MAAM,uBAAuB,IAAI,IAA8C;CAAC;CAAU;CAAY;CAAU;CAAY,CAAC;AAC7H,MAAM,sBAAsB,IAAI,IAAgC;CAAC;CAAa;CAAW;CAAY,CAAC;AACtG,MAAM,6BAA6B,IAAI,IAAsC;CAAC;CAAU;CAAiB;CAAuB,CAAC;AAEjI,SAAS,0BAA0B,UAAoD;AACrF,QAAO,SAAS,SAAS,WAAW;EAClC,MAAM,UAA0B,EAAE;EAClC,IAAI,SAAS;AACb,SAAO,MAAM;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,eAAc,OAAO,8BAA8B,KAAK,4BAA4B,MAAM;EACxF,MAAM,WAAW,eAAe,EAAE,IAAI,MAAM,KAAK,CAAC;AAClD,MAAI,CAAC,SAAU,QAAO,EAAE,KAAK,EAAE,OAAO,2BAA2B,EAAE,IAAI;AACvE,qBAAmB,SAAS,GAAG;AAC/B,SAAO,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC;GAC3B"}
@@ -10,6 +10,7 @@ import { type ResolvedGatewayAuth } from './auth.js';
10
10
  import { AgentRunRelay } from './agent-run-relay.js';
11
11
  import { type EnqueueGoalRunOptions } from '../goals/index.js';
12
12
  import { ProjectService } from '../projects/index.js';
13
+ import { LocalAppService } from '../local-apps/index.js';
13
14
  import { GatewaySessionsApi } from './service/sessions-api.js';
14
15
  import { GatewayMarketplaceService } from './service/marketplace-service.js';
15
16
  import { GatewayAgentRunner } from './service/agent-runner.js';
@@ -80,6 +81,8 @@ export declare class GatewayService {
80
81
  readonly marketplace: GatewayMarketplaceService;
81
82
  /** First-class project grouping surface. */
82
83
  readonly projects: ProjectService;
84
+ /** Local user-created apps, their coder projects, previews, and installs. */
85
+ readonly localApps: LocalAppService;
83
86
  constructor(serviceConfig?: GatewayServiceConfig);
84
87
  /** Lazy AgentService — constructed on first use or during `start()`. */
85
88
  get agentService(): AgentService;
@@ -71,6 +71,8 @@ import { assertGatewayRuntimeConfig } from "./runtime-config.js";
71
71
  import { auditGatewayConfig } from "./security/audit.js";
72
72
  import { runBootstrapMigrationsSync } from "../migrations/runner.js";
73
73
  import { MobileNotificationService } from "../mobile/notification-service.js";
74
+ import { LocalAppService } from "../local-apps/service.js";
75
+ import "../local-apps/index.js";
74
76
  import { scheduleGatewayUpdateCheck } from "../infra/update-startup.js";
75
77
  import { resolveChannelConnectDeferSet } from "./resolve-channel-connect-defer.js";
76
78
  import { restartGatewayProcessWithFreshPid } from "./respawn.js";
@@ -160,6 +162,8 @@ var GatewayService = class {
160
162
  marketplace;
161
163
  /** First-class project grouping surface. */
162
164
  projects;
165
+ /** Local user-created apps, their coder projects, previews, and installs. */
166
+ localApps;
163
167
  constructor(serviceConfig = {}) {
164
168
  this.serviceConfig = serviceConfig;
165
169
  this.bus = new MessageBus();
@@ -222,6 +226,14 @@ var GatewayService = class {
222
226
  this.automationService = new AutomationService();
223
227
  this.notesService = new NotesService(new NotesStore());
224
228
  this.projects = new ProjectService();
229
+ this.localApps = new LocalAppService({
230
+ projects: this.projects,
231
+ workspaceRoot: this.workspacePath,
232
+ getConfig: () => this.config,
233
+ saveConfig: (cfg) => this.saveConfig(cfg),
234
+ getExtensionLoader: () => this.extensionLoader,
235
+ emit: (type, payload) => this.emit(type, payload)
236
+ });
225
237
  this.agentRunner = new GatewayAgentRunner({
226
238
  bus: this.bus,
227
239
  sessionIndex: this.sessionIndex,