@xopcai/xopc 0.0.161 → 0.0.162

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 (233) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-o7GRljfD.js → activity-store-hpcNv9MZ.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-9R3szLMc.js → agent-avatar-dicebear-Zf9UQEmQ.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-DfVkZlHc.js +2 -0
  6. package/dist/gateway/static/root/assets/{api-jSTqFMq9.js → api-Dnatri09.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-D81cyE76.js → app-management-settings-panel-BBTR9wJP.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-Ct6bZQCV.js → appearance-settings-C2zpLCHD.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-BMtAa4Ra.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-CfD7AZKn.js → archive-plugin-9eR_ODY1.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-CP_Gaxt3.js → attachment-load-DPuWYUeX.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-BGKM_NDZ.js → automation-suggestion-card-Dw49OJRl.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-page-BiSAMYTr.js +6 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-IPr2EVnS.js → binary-plugins-BdkJpDFm.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-B6aHEGA6.js → block-editor-CAi7SXYU.js} +47 -47
  16. package/dist/gateway/static/root/assets/browser-settings-page-DHmaEJS2.js +8 -0
  17. package/dist/gateway/static/root/assets/browser-workflow-inputs-Dx6wkGz1.js +1 -0
  18. package/dist/gateway/static/root/assets/browser-workflows-page-Skertc-A.js +3 -0
  19. package/dist/gateway/static/root/assets/capabilities-settings-panel-B5wSgf4f.js +2 -0
  20. package/dist/gateway/static/root/assets/{capability-presets-api-CCX9-LjU.js → capability-presets-api-CNFl7dM3.js} +1 -1
  21. package/dist/gateway/static/root/assets/capability-presets-settings-panel-DyvFZwBj.js +2 -0
  22. package/dist/gateway/static/root/assets/{channel-recipient-api-MmLMLDWf.js → channel-recipient-api-DYQyGDw4.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-settings-BBKEqDZn.js +1 -0
  24. package/dist/gateway/static/root/assets/channels-status-swr-Drk110ve.js +1 -0
  25. package/dist/gateway/static/root/assets/{connector-logo-BbjzIs87.js → connector-logo-Bng6kxYF.js} +1 -1
  26. package/dist/gateway/static/root/assets/connectors-page-HpgaUDQ1.js +2 -0
  27. package/dist/gateway/static/root/assets/desktop-pet-Bpf6oegd.js +1 -0
  28. package/dist/gateway/static/root/assets/{desktop-pet-settings-DQLqGLc0.js → desktop-pet-settings-BVUyefSd.js} +1 -1
  29. package/dist/gateway/static/root/assets/{directory-picker-path-field-ClsiXhmz.js → directory-picker-path-field-DjSZAPz_.js} +1 -1
  30. package/dist/gateway/static/root/assets/{dreaming-settings-CjMPPdzg.js → dreaming-settings-CAZk2AM4.js} +3 -3
  31. package/dist/gateway/static/root/assets/{extension-debug-page-57eizjhB.js → extension-debug-page-C2F6vTTd.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-page-CsbSb3u1.js → extension-page-AnIt4bn4.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-DKA9-lyP.js → extension-settings-page-CLSc6682.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-config-api-DIPJuzBZ.js → gateway-config-api-DLFyZv33.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-settings-CDLqAQY7.js → gateway-settings-DnQAA-qq.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-startup-retry-DrfSJtvT.js → gateway-startup-retry-DbzLyJ3R.js} +1 -1
  37. package/dist/gateway/static/root/assets/goal-create-dialog-DrnKFC6M.js +1 -0
  38. package/dist/gateway/static/root/assets/goal-detail-page-Cw1hpJkZ.js +4 -0
  39. package/dist/gateway/static/root/assets/{goals-config-api-lGC10UkU.js → goals-config-api-REmr3QCr.js} +1 -1
  40. package/dist/gateway/static/root/assets/goals-page-BDGkTVma.js +2 -0
  41. package/dist/gateway/static/root/assets/{goals-settings-BWq0pdrA.js → goals-settings-Dz0F3uRO.js} +1 -1
  42. package/dist/gateway/static/root/assets/{heartbeat-settings-D4o8BJVv.js → heartbeat-settings-CQFY5gYs.js} +1 -1
  43. package/dist/gateway/static/root/assets/index-C8JkTS6d.js +199 -0
  44. package/dist/gateway/static/root/assets/index-hmrG55qg.css +1 -0
  45. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-6T2QYehS.js → keyboard-shortcuts-settings-BnOQXU5k.js} +1 -1
  46. package/dist/gateway/static/root/assets/local-app-workbench-page-Bdef1b7F.js +2 -0
  47. package/dist/gateway/static/root/assets/{local-apps-page-DCjg2K9f.js → local-apps-page-KsOtWOyM.js} +1 -1
  48. package/dist/gateway/static/root/assets/{locale-store-Dar-xqQr.js → locale-store-0lpYdNDr.js} +1 -1
  49. package/dist/gateway/static/root/assets/{logs-page-CyYCBqym.js → logs-page-CwLPgrWh.js} +3 -3
  50. package/dist/gateway/static/root/assets/{markdown-split-rt1XO43g.js → markdown-split-D5GRg10r.js} +1 -1
  51. package/dist/gateway/static/root/assets/{media-plugins-Bwo8CJuh.js → media-plugins-C1ryULGs.js} +1 -1
  52. package/dist/gateway/static/root/assets/messages-BwQ3WssU.js +5 -0
  53. package/dist/gateway/static/root/assets/{notes-page-Dp-pkX7d.js → notes-page-CIeZ1_DT.js} +1 -1
  54. package/dist/gateway/static/root/assets/notes-workbench-Cf06q19x.js +4 -0
  55. package/dist/gateway/static/root/assets/{page-tabs-CzZ4iKOb.js → page-tabs-Caj1-E_X.js} +1 -1
  56. package/dist/gateway/static/root/assets/{preview-open-alternatives-3E_Qa-58.js → preview-open-alternatives-DKwEce-9.js} +1 -1
  57. package/dist/gateway/static/root/assets/{product-open-page-B2T48Sbt.js → product-open-page-B90ZskkN.js} +1 -1
  58. package/dist/gateway/static/root/assets/project-detail-page-SHTurM4t.js +1 -0
  59. package/dist/gateway/static/root/assets/projects-page-BcC2qUAw.js +1 -0
  60. package/dist/gateway/static/root/assets/remote-access-hub-6vGefBHv.js +1 -0
  61. package/dist/gateway/static/root/assets/save-bar-controls-BDYt53uQ.js +1 -0
  62. package/dist/gateway/static/root/assets/{schedule-field-TkqUL3wm.js → schedule-field-Bcdni4Pj.js} +1 -1
  63. package/dist/gateway/static/root/assets/{schema-form-DC-iU5IG.js → schema-form-D7oCARF7.js} +1 -1
  64. package/dist/gateway/static/root/assets/sessions-page-C5014a53.js +1 -0
  65. package/dist/gateway/static/root/assets/settings-advanced-gate-CDY3ZI1K.js +1 -0
  66. package/dist/gateway/static/root/assets/{settings-collapsible-section-Dpqth3oA.js → settings-collapsible-section-6eNF8Jey.js} +1 -1
  67. package/dist/gateway/static/root/assets/{settings-form-section-CNqF6IwY.js → settings-form-section-CARTHCxH.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-loading-skeleton-DkvwitK_.js → settings-loading-skeleton-DEwYqESe.js} +1 -1
  69. package/dist/gateway/static/root/assets/settings-page-B6vVdHeQ.js +1 -0
  70. package/dist/gateway/static/root/assets/{settings-page-layout-DWvNgISx.js → settings-page-layout-D3srt5Bi.js} +1 -1
  71. package/dist/gateway/static/root/assets/setup-status-panel-z-rF0Hdg.js +1 -0
  72. package/dist/gateway/static/root/assets/{share-preview-page-DGpSPW-n.js → share-preview-page-Ck9SxiXw.js} +1 -1
  73. package/dist/gateway/static/root/assets/shares-settings-CHZFXE_d.js +1 -0
  74. package/dist/gateway/static/root/assets/skill-reload-api-B7p2QNXt.js +1 -0
  75. package/dist/gateway/static/root/assets/skills-page-ncw3tX9P.js +2 -0
  76. package/dist/gateway/static/root/assets/{system-settings-panel-8TxxSbUw.js → system-settings-panel-DLBUQSk2.js} +1 -1
  77. package/dist/gateway/static/root/assets/{theme-store-B5FzMWOx.js → theme-store-C1oaqeD2.js} +1 -1
  78. package/dist/gateway/static/root/assets/{typed-models-lib-DEGtSA5h.js → typed-models-lib-Divbg_C4.js} +1 -1
  79. package/dist/gateway/static/root/assets/{use-channel-catalog-BDU6FneG.js → use-channel-catalog-CP9a_rAf.js} +1 -1
  80. package/dist/gateway/static/root/assets/user-context-page-iYfeSLKI.js +1 -0
  81. package/dist/gateway/static/root/assets/voice-api-key-field-CrwkicvT.js +1 -0
  82. package/dist/gateway/static/root/assets/work-discovery-page-BQWxyPg8.js +1 -0
  83. package/dist/gateway/static/root/assets/work-item-detail-page-50ZzGay5.js +1 -0
  84. package/dist/gateway/static/root/assets/work-page-DPqEahx7.js +1 -0
  85. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Cwi8Pz7n.js → workflow-run-setup-panel-DbDPYQwB.js} +2 -2
  86. package/dist/gateway/static/root/assets/workflows-page-C3eIC5HZ.js +11 -0
  87. package/dist/gateway/static/root/index.html +7 -7
  88. package/dist/package.js +1 -1
  89. package/dist/src/agent/agent-manager.d.ts +1 -0
  90. package/dist/src/agent/agent-manager.js +1 -0
  91. package/dist/src/agent/client-error-format.js +3 -3
  92. package/dist/src/agent/outcomes/task-evaluation.d.ts +20 -0
  93. package/dist/src/agent/outcomes/task-evaluation.js +48 -0
  94. package/dist/src/agent/outcomes/task-verifier.d.ts +29 -0
  95. package/dist/src/agent/outcomes/task-verifier.js +71 -0
  96. package/dist/src/agent/prompt/memory/index.js +1 -1
  97. package/dist/src/agent/prompt/service-prompt-builder.js +32 -1
  98. package/dist/src/agent/service.js +1 -0
  99. package/dist/src/agent/service.types.d.ts +1 -0
  100. package/dist/src/agent/tools/browser/tool/browser-use-tool.d.ts +1 -7
  101. package/dist/src/agent/tools/browser/tool/browser-use-tool.js +2 -73
  102. package/dist/src/agent/tools/browser/tool/schemas.d.ts +1 -13
  103. package/dist/src/agent/tools/browser/tool/schemas.js +1 -9
  104. package/dist/src/agent/tools/browser-recipe-tool.d.ts +12 -0
  105. package/dist/src/agent/tools/browser-recipe-tool.js +113 -0
  106. package/dist/src/agent/tools/factory.d.ts +2 -0
  107. package/dist/src/agent/tools/factory.js +2 -0
  108. package/dist/src/agent/tools/index.d.ts +1 -0
  109. package/dist/src/agent/tools/index.js +2 -1
  110. package/dist/src/automations/domain/types.d.ts +13 -0
  111. package/dist/src/automations/domain/validation.d.ts +44 -24
  112. package/dist/src/automations/domain/validation.js +27 -18
  113. package/dist/src/automations/draft/automation-draft-validator.d.ts +6 -1
  114. package/dist/src/automations/draft/automation-draft-validator.js +1 -0
  115. package/dist/src/automations/service/action-executor.d.ts +1 -0
  116. package/dist/src/automations/service/action-executor.js +22 -0
  117. package/dist/src/browser/index.d.ts +0 -1
  118. package/dist/src/browser/index.js +1 -2
  119. package/dist/src/browser/pipeline/runner.d.ts +9 -2
  120. package/dist/src/browser/pipeline/runner.js +151 -105
  121. package/dist/src/browser/pipeline/schema.d.ts +21 -15
  122. package/dist/src/browser/pipeline/schema.js +93 -99
  123. package/dist/src/browser/recipes/index.d.ts +3 -0
  124. package/dist/src/browser/recipes/index.js +3 -0
  125. package/dist/src/browser/recipes/repository.d.ts +13 -0
  126. package/dist/src/browser/recipes/repository.js +81 -0
  127. package/dist/src/browser/recipes/runtime-service.d.ts +6 -0
  128. package/dist/src/browser/recipes/runtime-service.js +30 -0
  129. package/dist/src/browser/recipes/service.d.ts +36 -0
  130. package/dist/src/browser/recipes/service.js +186 -0
  131. package/dist/src/browser/recipes/types.d.ts +36 -0
  132. package/dist/src/browser/recipes/types.js +1 -0
  133. package/dist/src/cli/commands/browser-cli-helpers.js +6 -12
  134. package/dist/src/cli/commands/browser.js +4 -3
  135. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  136. package/dist/src/config/agent-profile.js +1 -1
  137. package/dist/src/config/schema.d.ts +3 -3
  138. package/dist/src/config/schema.js +21 -21
  139. package/dist/src/gateway/agents-admin.js +1 -1
  140. package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -1
  141. package/dist/src/gateway/hono/routes/browser-workflows.d.ts +3 -0
  142. package/dist/src/gateway/hono/routes/browser-workflows.js +78 -0
  143. package/dist/src/gateway/hono/routes/home.js +1 -0
  144. package/dist/src/gateway/hono/routes/index.js +4 -0
  145. package/dist/src/gateway/hono/routes/interaction-state.d.ts +3 -0
  146. package/dist/src/gateway/hono/routes/interaction-state.js +45 -0
  147. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  148. package/dist/src/gateway/hono/routes/memory.js +33 -4
  149. package/dist/src/gateway/hono/routes/task-outcomes.d.ts +3 -0
  150. package/dist/src/gateway/hono/routes/task-outcomes.js +109 -0
  151. package/dist/src/gateway/hono/routes/you.d.ts +10 -2
  152. package/dist/src/gateway/hono/routes/you.js +184 -28
  153. package/dist/src/gateway/service/run-gateway-agent.js +84 -0
  154. package/dist/src/gateway/service.d.ts +3 -0
  155. package/dist/src/gateway/service.js +14 -0
  156. package/dist/src/proactive/insight-repository.d.ts +2 -0
  157. package/dist/src/proactive/insight-repository.js +5 -2
  158. package/dist/src/proactive/run-processor.js +22 -1
  159. package/dist/src/proactive/types.d.ts +2 -0
  160. package/dist/src/proactive/value-score.d.ts +13 -0
  161. package/dist/src/proactive/value-score.js +30 -0
  162. package/dist/src/share/share-types.js +5 -5
  163. package/dist/src/share/site-share-types.d.ts +1 -1
  164. package/dist/src/share/site-share-types.js +5 -5
  165. package/dist/src/storage/sqlite/index.d.ts +3 -0
  166. package/dist/src/storage/sqlite/index.js +4 -1
  167. package/dist/src/storage/sqlite/interaction-state-repository.d.ts +17 -0
  168. package/dist/src/storage/sqlite/interaction-state-repository.js +60 -0
  169. package/dist/src/storage/sqlite/memory-records-repository.js +1 -1
  170. package/dist/src/storage/sqlite/migrations/053_browser_recipes.sql +45 -0
  171. package/dist/src/storage/sqlite/migrations/054_task_outcomes.sql +24 -0
  172. package/dist/src/storage/sqlite/migrations/055_relationship_settings.sql +14 -0
  173. package/dist/src/storage/sqlite/migrations/056_task_verification.sql +6 -0
  174. package/dist/src/storage/sqlite/migrations/057_interaction_states.sql +11 -0
  175. package/dist/src/storage/sqlite/migrations/058_proactive_value.sql +3 -0
  176. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  177. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  178. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  179. package/dist/src/storage/sqlite/relationship-settings-repository.d.ts +17 -0
  180. package/dist/src/storage/sqlite/relationship-settings-repository.js +64 -0
  181. package/dist/src/storage/sqlite/schema.js +1 -1
  182. package/dist/src/storage/sqlite/schema.sql +46 -0
  183. package/dist/src/storage/sqlite/task-outcome-repository.d.ts +90 -0
  184. package/dist/src/storage/sqlite/task-outcome-repository.js +138 -0
  185. package/dist/src/user-context/interaction-state.d.ts +13 -0
  186. package/dist/src/user-context/interaction-state.js +69 -0
  187. package/dist/src/user-context/memory-use-audit.d.ts +10 -0
  188. package/dist/src/user-context/memory-use-audit.js +25 -0
  189. package/dist/src/user-context/personal-playbook.d.ts +11 -0
  190. package/dist/src/user-context/personal-playbook.js +41 -0
  191. package/dist/src/user-context/projection.d.ts +4 -0
  192. package/dist/src/user-context/projection.js +5 -1
  193. package/dist/src/user-context/relationship-continuity.d.ts +14 -0
  194. package/dist/src/user-context/relationship-continuity.js +51 -0
  195. package/package.json +1 -1
  196. package/dist/gateway/static/root/assets/action-boundary-settings-panel-BIVBUiNT.js +0 -1
  197. package/dist/gateway/static/root/assets/agents-_qbUaYbs.js +0 -2
  198. package/dist/gateway/static/root/assets/apps-page-0sPqD0FK.js +0 -1
  199. package/dist/gateway/static/root/assets/automations-page-BxWBuBsE.js +0 -6
  200. package/dist/gateway/static/root/assets/browser-settings-page-C499b9AH.js +0 -8
  201. package/dist/gateway/static/root/assets/capability-presets-settings-panel-Dva9SiPK.js +0 -2
  202. package/dist/gateway/static/root/assets/channels-settings-DNAU7u9o.js +0 -1
  203. package/dist/gateway/static/root/assets/channels-status-swr-CIOH7tgn.js +0 -1
  204. package/dist/gateway/static/root/assets/connectors-page-TwiBp8vY.js +0 -2
  205. package/dist/gateway/static/root/assets/desktop-pet-CYH5ZSXy.js +0 -1
  206. package/dist/gateway/static/root/assets/goal-create-dialog-Q3B0E-0s.js +0 -1
  207. package/dist/gateway/static/root/assets/goal-detail-page-C5VAK04G.js +0 -4
  208. package/dist/gateway/static/root/assets/goals-page-BJb-5IYw.js +0 -2
  209. package/dist/gateway/static/root/assets/index-CkUHH170.css +0 -1
  210. package/dist/gateway/static/root/assets/index-vq_cJZJC.js +0 -199
  211. package/dist/gateway/static/root/assets/local-app-workbench-page-euH17Kvb.js +0 -2
  212. package/dist/gateway/static/root/assets/messages-CxySDn9d.js +0 -5
  213. package/dist/gateway/static/root/assets/models-hub-panel-DObxxjc9.js +0 -2
  214. package/dist/gateway/static/root/assets/notes-workbench-CCb4RXcZ.js +0 -4
  215. package/dist/gateway/static/root/assets/project-detail-page-BvEcriRC.js +0 -1
  216. package/dist/gateway/static/root/assets/projects-page-B_e79MRJ.js +0 -1
  217. package/dist/gateway/static/root/assets/remote-access-hub-DGcqnYfR.js +0 -1
  218. package/dist/gateway/static/root/assets/save-bar-controls-CkeKasGm.js +0 -1
  219. package/dist/gateway/static/root/assets/sessions-page-DQZhrDJ8.js +0 -1
  220. package/dist/gateway/static/root/assets/settings-advanced-gate-BkdeN99Y.js +0 -1
  221. package/dist/gateway/static/root/assets/settings-page-qPG7I2zd.js +0 -1
  222. package/dist/gateway/static/root/assets/setup-status-panel-lwRAh9aw.js +0 -1
  223. package/dist/gateway/static/root/assets/shares-settings-BGj9IVUr.js +0 -1
  224. package/dist/gateway/static/root/assets/skill-reload-api-B2UBAs5U.js +0 -1
  225. package/dist/gateway/static/root/assets/skills-page-DdjzFZ8I.js +0 -2
  226. package/dist/gateway/static/root/assets/user-context-page-BTTZpAGV.js +0 -1
  227. package/dist/gateway/static/root/assets/voice-api-key-field-DuDQd-WU.js +0 -1
  228. package/dist/gateway/static/root/assets/work-discovery-page-BUVkVCsW.js +0 -1
  229. package/dist/gateway/static/root/assets/work-item-detail-page-DeEPPu4n.js +0 -1
  230. package/dist/gateway/static/root/assets/work-page-DQNUyTUq.js +0 -1
  231. package/dist/gateway/static/root/assets/workflows-page-BIy4wrzO.js +0 -11
  232. package/dist/src/browser/pipeline/source.d.ts +0 -9
  233. package/dist/src/browser/pipeline/source.js +0 -77
@@ -0,0 +1,13 @@
1
+ import type { FocusWatchKind } from './types.js';
2
+ export interface ProactiveValueScore {
3
+ score: number;
4
+ reasons: string[];
5
+ shouldDeliver: boolean;
6
+ }
7
+ export declare function scoreProactiveValue(input: {
8
+ kind: FocusWatchKind;
9
+ evidenceCount: number;
10
+ hasNextAction: boolean;
11
+ approvedCount: number;
12
+ dismissedCount: number;
13
+ }): ProactiveValueScore;
@@ -0,0 +1,30 @@
1
+ //#region src/proactive/value-score.ts
2
+ function scoreProactiveValue(input) {
3
+ const reasons = [];
4
+ let score = .15;
5
+ if (input.evidenceCount > 0) {
6
+ score += Math.min(.25, input.evidenceCount * .1);
7
+ reasons.push("evidence_backed");
8
+ }
9
+ if (input.hasNextAction) {
10
+ score += .25;
11
+ reasons.push("actionable");
12
+ }
13
+ const urgency = input.kind === "deadline" ? .25 : input.kind === "staleness" ? .2 : .15;
14
+ score += urgency;
15
+ reasons.push(input.kind === "deadline" ? "time_sensitive" : "focus_relevant");
16
+ const rated = input.approvedCount + input.dismissedCount;
17
+ if (rated > 0) {
18
+ const approvalRate = input.approvedCount / rated;
19
+ score += (approvalRate - .5) * .4;
20
+ reasons.push(approvalRate >= .5 ? "historically_useful" : "historically_dismissed");
21
+ }
22
+ score = Math.max(0, Math.min(1, score));
23
+ return {
24
+ score,
25
+ reasons,
26
+ shouldDeliver: score >= .65
27
+ };
28
+ }
29
+ //#endregion
30
+ export { scoreProactiveValue };
@@ -3,9 +3,9 @@
3
3
  const SHARE_CONFIG_DEFAULTS = {
4
4
  enabled: true,
5
5
  defaultTtlMs: 864e5,
6
- maxTtlMs: 6048e5,
7
- maxActiveShares: 100,
8
- maxFileSize: 104857600,
6
+ maxTtlMs: 2592e6,
7
+ maxActiveShares: 500,
8
+ maxFileSize: 524288e3,
9
9
  inlinePreviewMimes: [
10
10
  "image/png",
11
11
  "image/jpeg",
@@ -20,8 +20,8 @@ const SHARE_CONFIG_DEFAULTS = {
20
20
  ],
21
21
  directory: {
22
22
  enabled: true,
23
- maxFolderSize: 1073741824,
24
- maxFileCount: 1e3,
23
+ maxFolderSize: 2147483648,
24
+ maxFileCount: 1e4,
25
25
  maxDepth: 20,
26
26
  listingCacheMs: 6e4,
27
27
  zipConcurrency: 1
@@ -60,7 +60,7 @@ export interface CreateSiteShareParams {
60
60
  path?: string;
61
61
  /** Proxy: full upstream URL (must be loopback or whitelisted). */
62
62
  upstreamUrl?: string;
63
- /** Default 6h. */
63
+ /** Default 24h. */
64
64
  ttlMs?: number;
65
65
  /** Optional friendly description. */
66
66
  description?: string;
@@ -2,13 +2,13 @@
2
2
  const SITE_SHARE_CONFIG_DEFAULTS = {
3
3
  enabled: true,
4
4
  publicHostSuffix: "share.xopc.ai",
5
- defaultTtlMs: 216e5,
6
- maxTtlMs: 6048e5,
7
- maxActiveSites: 5,
5
+ defaultTtlMs: 864e5,
6
+ maxTtlMs: 2592e6,
7
+ maxActiveSites: 50,
8
8
  static: {
9
9
  enabled: true,
10
- maxRootDirSize: 524288e3,
11
- maxFileCount: 1e4,
10
+ maxRootDirSize: 1073741824,
11
+ maxFileCount: 2e4,
12
12
  rewriteEnabledByDefault: false
13
13
  },
14
14
  proxy: {
@@ -5,6 +5,9 @@ export { DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, } from './m
5
5
  export { discoverSqlMigrations, listRegisteredMigrationTargets } from './migrations/discover.js';
6
6
  export { closeXopcDatabase, getXopcDatabase, isXopcDatabaseOpen, openXopcDatabase, requireXopcDatabase, resetXopcDatabaseSingletonForTest, type OpenXopcDatabaseOptions, type XopcDatabase, } from './connection.js';
7
7
  export { getSqliteDatabase, runSqliteWriteTransaction } from './transaction.js';
8
+ export { getInteractionState, setInteractionState, updateInteractionStateFromMessage, type InteractionState, } from './interaction-state-repository.js';
9
+ export { buildRelationshipPrompt, getRelationshipSettings, isProactiveSupportAllowed, updateRelationshipSettings, type RelationshipSettings, type SupportMode, } from './relationship-settings-repository.js';
10
+ export { completeTaskOutcome, findTaskOutcomeForAssistant, getTaskOutcome, listTaskOutcomes, setTaskOutcomeFeedback, startTaskOutcome, summarizeTaskOutcomes, updateTaskOutcome, type TaskContract, type TaskEvidence, type TaskFeedbackOutcome, type TaskOutcome, type TaskOutcomeMetrics, type TaskOutcomeStatus, } from './task-outcome-repository.js';
8
11
  export { buildDefaultSessionMetadata, type SessionMetadataSeed, } from './session-metadata.js';
9
12
  export { buildGlobalSessionStats, classifyStoredRow, estimateTokensFromMessages, extractFtsContent, metadataToSessionInsert, sessionConfigRowToConfig, sessionRowToMetadata, transcriptEntryRowToStoredRow, type SessionConfigRow, type SessionRow, type TranscriptEntryRow, } from './row-mappers.js';
10
13
  export { deleteSessionRecord, ensureSessionRecord, getCurrentSessionId, getGlobalSessionStats, findSessionKeyBySessionId, getSessionPersistedLevels, getSessionMetadata, incrementSessionStatsOnAppend, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord, resolveSessionAgentId, updateSessionStats, } from './session-repository.js';
@@ -6,6 +6,9 @@ import { XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_SCHEMA_VERSION, applyPendingMi
6
6
  import { ensureXopcDatabaseSchema } from "./schema.js";
7
7
  import { closeXopcDatabase, getXopcDatabase, isXopcDatabaseOpen, openXopcDatabase, requireXopcDatabase, resetXopcDatabaseSingletonForTest } from "./connection.js";
8
8
  import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
9
+ import { getInteractionState, setInteractionState, updateInteractionStateFromMessage } from "./interaction-state-repository.js";
10
+ import { buildRelationshipPrompt, getRelationshipSettings, isProactiveSupportAllowed, updateRelationshipSettings } from "./relationship-settings-repository.js";
11
+ import { completeTaskOutcome, findTaskOutcomeForAssistant, getTaskOutcome, listTaskOutcomes, setTaskOutcomeFeedback, startTaskOutcome, summarizeTaskOutcomes, updateTaskOutcome } from "./task-outcome-repository.js";
9
12
  import { buildDefaultSessionMetadata } from "./session-metadata.js";
10
13
  import { buildGlobalSessionStats, classifyStoredRow, estimateTokensFromMessages, extractFtsContent, metadataToSessionInsert, sessionConfigRowToConfig, sessionRowToMetadata, transcriptEntryRowToStoredRow } from "./row-mappers.js";
11
14
  import { deleteSessionRecord, ensureSessionRecord, findSessionKeyBySessionId, getCurrentSessionId, getGlobalSessionStats, getSessionMetadata, getSessionPersistedLevels, incrementSessionStatsOnAppend, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord, resolveSessionAgentId, updateSessionStats } from "./session-repository.js";
@@ -21,4 +24,4 @@ import { appendConnectorExecutionAudit, claimConnectorWebhookDelivery, completeC
21
24
  import { getUserTrustPolicy, setUserTrustPolicy } from "./user-trust-repository.js";
22
25
  import { consumeMemoryReferenceConsent, decideMemoryReferenceConsent, ensureMemoryReferenceConsentRequest, hasMemoryReferenceConsent, listMemoryReferenceConsents, revokeMemoryReferenceConsent } from "./memory-reference-consent-repository.js";
23
26
  import { getUserProfilePromptState, setUserProfilePromptState } from "./user-profile-setup-repository.js";
24
- export { DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, SCHEMA_META_SCHEMA_VERSION_KEY, USER_UNDERSTANDING_REMEDIATION_POLICY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, appendConnectorExecutionAudit, appendMemorySignal, appendMemoryTraceEvent, appendTranscriptEntry, applyPendingMigrations, attachMemoryEvidence, buildDefaultSessionMetadata, buildGlobalSessionStats, captureCompactionCheckpoint, claimConnectorWebhookDelivery, claimKnowledgeSourceItems, classifyStoredRow, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, consumeConnectorApproval, consumeMemoryReferenceConsent, createConnectorApproval, createObjectLinkRecord, decideConnectorApproval, decideMemoryReferenceConsent, deleteConnectorConnection, deleteConnectorInstallation, deleteMemoryEvidenceForRecord, deleteMemoryRecord, deleteNoteAgentContextRecord, deleteNoteRecord, deleteSessionConfig, deleteSessionRecord, discoverSqlMigrations, ensureMemoryReferenceConsentRequest, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findLatestMemoryInjectTrace, findSessionKeyBySessionId, finishKnowledgeSyncRun, getActivityEventRecord, getCachedConnectorCatalogEntry, getCompactionCheckpointDetail, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getCurrentSessionId, getGlobalSessionStats, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getMemoryProviderState, getMemoryRecord, getNoteAgentContextRecord, getNoteRecord, getSessionConfig, getSessionMetadata, getSessionPersistedLevels, getSqliteDatabase, getUserProfilePromptState, getUserTrustPolicy, getXopcDatabase, hasMemoryReferenceConsent, hasSessionConfig, hasUnresolvedMemoryConflict, incrementSessionStatsOnAppend, inspectSchemaMigrationStatus, isXopcDatabaseOpen, listActivityRecords, listCachedConnectorCatalogEntries, listCompactionCheckpoints, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listMemoryEvidence, listMemoryRecords, listMemoryReferenceConsents, listMemorySignals, listMemoryTraceEvents, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, loadCheckpointRows, loadLlmMessagesForSession, loadTranscriptRows, loadTranscriptRowsForSession, markMemoryRecordsConflicted, metadataToSessionInsert, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, readSchemaVersion, readSchemaVersionForTest, recordActivityEvent, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceTranscriptRows, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreCompactionCheckpoint, revokeMemoryReferenceConsent, runSqliteWriteTransaction, searchMemoryIndex, searchMemoryRecords, sessionConfigRowToConfig, sessionRowToMetadata, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setLatestMemoryInjectFeedback, setMemoryProviderState, setMemoryTraceFeedback, setSessionConfig, setUserProfilePromptState, setUserTrustPolicy, startKnowledgeSyncRun, summarizeMemoryRecallFeedback, summarizeUserUnderstandingQuality, syncMemoryIndex, transcriptEntryRowToStoredRow, updateSessionConfig, updateSessionStats, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertKnowledgeSourceItems, upsertMemoryRecord, upsertNoteAgentContextRecord, upsertNoteRecord };
27
+ export { DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, SCHEMA_META_SCHEMA_VERSION_KEY, USER_UNDERSTANDING_REMEDIATION_POLICY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, appendConnectorExecutionAudit, appendMemorySignal, appendMemoryTraceEvent, appendTranscriptEntry, applyPendingMigrations, attachMemoryEvidence, buildDefaultSessionMetadata, buildGlobalSessionStats, buildRelationshipPrompt, captureCompactionCheckpoint, claimConnectorWebhookDelivery, claimKnowledgeSourceItems, classifyStoredRow, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, completeTaskOutcome, consumeConnectorApproval, consumeMemoryReferenceConsent, createConnectorApproval, createObjectLinkRecord, decideConnectorApproval, decideMemoryReferenceConsent, deleteConnectorConnection, deleteConnectorInstallation, deleteMemoryEvidenceForRecord, deleteMemoryRecord, deleteNoteAgentContextRecord, deleteNoteRecord, deleteSessionConfig, deleteSessionRecord, discoverSqlMigrations, ensureMemoryReferenceConsentRequest, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findLatestMemoryInjectTrace, findSessionKeyBySessionId, findTaskOutcomeForAssistant, finishKnowledgeSyncRun, getActivityEventRecord, getCachedConnectorCatalogEntry, getCompactionCheckpointDetail, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getCurrentSessionId, getGlobalSessionStats, getInteractionState, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getMemoryProviderState, getMemoryRecord, getNoteAgentContextRecord, getNoteRecord, getRelationshipSettings, getSessionConfig, getSessionMetadata, getSessionPersistedLevels, getSqliteDatabase, getTaskOutcome, getUserProfilePromptState, getUserTrustPolicy, getXopcDatabase, hasMemoryReferenceConsent, hasSessionConfig, hasUnresolvedMemoryConflict, incrementSessionStatsOnAppend, inspectSchemaMigrationStatus, isProactiveSupportAllowed, isXopcDatabaseOpen, listActivityRecords, listCachedConnectorCatalogEntries, listCompactionCheckpoints, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listMemoryEvidence, listMemoryRecords, listMemoryReferenceConsents, listMemorySignals, listMemoryTraceEvents, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, listTaskOutcomes, loadCheckpointRows, loadLlmMessagesForSession, loadTranscriptRows, loadTranscriptRowsForSession, markMemoryRecordsConflicted, metadataToSessionInsert, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, readSchemaVersion, readSchemaVersionForTest, recordActivityEvent, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceTranscriptRows, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreCompactionCheckpoint, revokeMemoryReferenceConsent, runSqliteWriteTransaction, searchMemoryIndex, searchMemoryRecords, sessionConfigRowToConfig, sessionRowToMetadata, setInteractionState, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setLatestMemoryInjectFeedback, setMemoryProviderState, setMemoryTraceFeedback, setSessionConfig, setTaskOutcomeFeedback, setUserProfilePromptState, setUserTrustPolicy, startKnowledgeSyncRun, startTaskOutcome, summarizeMemoryRecallFeedback, summarizeTaskOutcomes, summarizeUserUnderstandingQuality, syncMemoryIndex, transcriptEntryRowToStoredRow, updateInteractionStateFromMessage, updateRelationshipSettings, updateSessionConfig, updateSessionStats, updateTaskOutcome, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertKnowledgeSourceItems, upsertMemoryRecord, upsertNoteAgentContextRecord, upsertNoteRecord };
@@ -0,0 +1,17 @@
1
+ import { type InteractionStateSignal } from '../../user-context/interaction-state.js';
2
+ export interface InteractionState extends InteractionStateSignal {
3
+ sessionKey: string;
4
+ expiresAt: number;
5
+ updatedAt: number;
6
+ }
7
+ export declare function getInteractionState(sessionKey: string, now?: number): InteractionState | undefined;
8
+ export declare function setInteractionState(input: {
9
+ sessionKey: string;
10
+ signal: InteractionStateSignal;
11
+ now?: number;
12
+ }): InteractionState;
13
+ export declare function updateInteractionStateFromMessage(input: {
14
+ sessionKey: string;
15
+ message: string;
16
+ now?: number;
17
+ }): InteractionState;
@@ -0,0 +1,60 @@
1
+ import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
2
+ import { inferInteractionState } from "../../user-context/interaction-state.js";
3
+ //#region src/storage/sqlite/interaction-state-repository.ts
4
+ const STATE_TTL_MS = 360 * 60 * 1e3;
5
+ function fromRow(row) {
6
+ return {
7
+ sessionKey: row.session_key,
8
+ supportNeed: row.support_need,
9
+ ...row.emotion_hypothesis ? { emotionHypothesis: row.emotion_hypothesis } : {},
10
+ confidence: row.confidence,
11
+ source: row.source,
12
+ repairStatus: row.repair_status,
13
+ ...row.repair_reason ? { repairReason: row.repair_reason } : {},
14
+ expiresAt: row.expires_at,
15
+ updatedAt: row.updated_at
16
+ };
17
+ }
18
+ function getInteractionState(sessionKey, now = Date.now()) {
19
+ const row = getSqliteDatabase().prepare(`SELECT session_key, support_need, emotion_hypothesis, confidence, source,
20
+ repair_status, repair_reason, expires_at, updated_at
21
+ FROM interaction_states WHERE session_key = ? AND expires_at > ?`).get(sessionKey, now);
22
+ return row ? fromRow(row) : void 0;
23
+ }
24
+ function setInteractionState(input) {
25
+ const now = input.now ?? Date.now();
26
+ const expiresAt = now + STATE_TTL_MS;
27
+ runSqliteWriteTransaction((db) => {
28
+ db.prepare(`INSERT INTO interaction_states (
29
+ session_key, support_need, emotion_hypothesis, confidence, source,
30
+ repair_status, repair_reason, expires_at, updated_at
31
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
32
+ ON CONFLICT(session_key) DO UPDATE SET
33
+ support_need = excluded.support_need,
34
+ emotion_hypothesis = excluded.emotion_hypothesis,
35
+ confidence = excluded.confidence,
36
+ source = excluded.source,
37
+ repair_status = excluded.repair_status,
38
+ repair_reason = excluded.repair_reason,
39
+ expires_at = excluded.expires_at,
40
+ updated_at = excluded.updated_at`).run(input.sessionKey, input.signal.supportNeed, input.signal.emotionHypothesis ?? null, input.signal.confidence, input.signal.source, input.signal.repairStatus, input.signal.repairReason ?? null, expiresAt, now);
41
+ });
42
+ return getInteractionState(input.sessionKey, now);
43
+ }
44
+ function updateInteractionStateFromMessage(input) {
45
+ const now = input.now ?? Date.now();
46
+ const previous = getInteractionState(input.sessionKey, now);
47
+ const inferred = inferInteractionState(input.message);
48
+ const signal = previous?.repairStatus === "needed" && inferred.repairStatus === "none" ? {
49
+ ...inferred,
50
+ repairStatus: "needed",
51
+ repairReason: previous.repairReason
52
+ } : inferred;
53
+ return setInteractionState({
54
+ sessionKey: input.sessionKey,
55
+ signal,
56
+ now
57
+ });
58
+ }
59
+ //#endregion
60
+ export { getInteractionState, setInteractionState, updateInteractionStateFromMessage };
@@ -1,6 +1,6 @@
1
1
  import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
2
- import { buildFts5SearchQuery, fts5RankToScore, memoryLexicalSimilarity } from "./fts.js";
3
2
  import { LOCAL_USER_ID } from "../../user-context/owner.js";
3
+ import { buildFts5SearchQuery, fts5RankToScore, memoryLexicalSimilarity } from "./fts.js";
4
4
  import { randomUUID } from "node:crypto";
5
5
  //#region src/storage/sqlite/memory-records-repository.ts
6
6
  const USER_UNDERSTANDING_REMEDIATION_POLICY = {
@@ -0,0 +1,45 @@
1
+ CREATE TABLE IF NOT EXISTS browser_recipes (
2
+ recipe_id TEXT PRIMARY KEY,
3
+ revision INTEGER NOT NULL,
4
+ name TEXT NOT NULL,
5
+ description TEXT,
6
+ status TEXT NOT NULL CHECK (status IN ('published', 'disabled')),
7
+ yaml_source TEXT NOT NULL,
8
+ risk_level TEXT NOT NULL CHECK (risk_level IN ('read_only', 'account_write', 'sensitive')),
9
+ domains_json TEXT NOT NULL,
10
+ created_at_ms INTEGER NOT NULL,
11
+ updated_at_ms INTEGER NOT NULL
12
+ );
13
+
14
+ CREATE TABLE IF NOT EXISTS browser_recipe_runs (
15
+ run_id TEXT PRIMARY KEY,
16
+ recipe_id TEXT NOT NULL,
17
+ recipe_revision INTEGER NOT NULL,
18
+ recipe_yaml TEXT NOT NULL,
19
+ status TEXT NOT NULL CHECK (status IN ('queued', 'running', 'succeeded', 'failed', 'cancelled')),
20
+ args_json TEXT NOT NULL,
21
+ result_json TEXT,
22
+ error TEXT,
23
+ created_at_ms INTEGER NOT NULL,
24
+ started_at_ms INTEGER,
25
+ ended_at_ms INTEGER,
26
+ duration_ms INTEGER,
27
+ FOREIGN KEY (recipe_id) REFERENCES browser_recipes(recipe_id) ON DELETE CASCADE
28
+ );
29
+
30
+ CREATE INDEX IF NOT EXISTS idx_browser_recipe_runs_recipe_created
31
+ ON browser_recipe_runs(recipe_id, created_at_ms DESC);
32
+
33
+ CREATE TABLE IF NOT EXISTS browser_recipe_run_events (
34
+ event_id TEXT PRIMARY KEY,
35
+ run_id TEXT NOT NULL,
36
+ seq INTEGER NOT NULL,
37
+ type TEXT NOT NULL,
38
+ data_json TEXT,
39
+ created_at_ms INTEGER NOT NULL,
40
+ UNIQUE(run_id, seq),
41
+ FOREIGN KEY (run_id) REFERENCES browser_recipe_runs(run_id) ON DELETE CASCADE
42
+ );
43
+
44
+ CREATE INDEX IF NOT EXISTS idx_browser_recipe_run_events_run_seq
45
+ ON browser_recipe_run_events(run_id, seq ASC);
@@ -0,0 +1,24 @@
1
+ CREATE TABLE task_outcomes (
2
+ run_id TEXT PRIMARY KEY,
3
+ session_key TEXT NOT NULL,
4
+ channel TEXT NOT NULL,
5
+ objective TEXT NOT NULL,
6
+ status TEXT NOT NULL CHECK (status IN ('running', 'succeeded', 'failed', 'cancelled')),
7
+ summary TEXT,
8
+ contract_json TEXT,
9
+ evidence_json TEXT NOT NULL DEFAULT '[]',
10
+ feedback_outcome TEXT CHECK (feedback_outcome IN ('helpful', 'not_helpful')),
11
+ feedback_reason TEXT,
12
+ needs_correction INTEGER CHECK (needs_correction IN (0, 1)),
13
+ support_fit INTEGER CHECK (support_fit IN (0, 1)),
14
+ started_at INTEGER NOT NULL,
15
+ completed_at INTEGER,
16
+ updated_at INTEGER NOT NULL,
17
+ FOREIGN KEY (session_key) REFERENCES sessions(session_key) ON DELETE CASCADE
18
+ );
19
+
20
+ CREATE INDEX idx_task_outcomes_session_started
21
+ ON task_outcomes(session_key, started_at DESC);
22
+
23
+ CREATE INDEX idx_task_outcomes_status_started
24
+ ON task_outcomes(status, started_at DESC);
@@ -0,0 +1,14 @@
1
+ CREATE TABLE relationship_settings (
2
+ owner_id TEXT PRIMARY KEY CHECK (owner_id = 'local-owner'),
3
+ support_mode TEXT NOT NULL CHECK (support_mode IN ('efficient', 'coach', 'companion', 'auto')),
4
+ proactive_enabled INTEGER NOT NULL CHECK (proactive_enabled IN (0, 1)),
5
+ quiet_start TEXT,
6
+ quiet_end TEXT,
7
+ allowed_topics_json TEXT NOT NULL,
8
+ blocked_topics_json TEXT NOT NULL,
9
+ updated_at INTEGER NOT NULL
10
+ );
11
+
12
+ INSERT INTO relationship_settings (
13
+ owner_id, support_mode, proactive_enabled, allowed_topics_json, blocked_topics_json, updated_at
14
+ ) VALUES ('local-owner', 'auto', 0, '[]', '[]', unixepoch() * 1000);
@@ -0,0 +1,6 @@
1
+ ALTER TABLE task_outcomes ADD COLUMN verification_status TEXT NOT NULL DEFAULT 'unverified'
2
+ CHECK (verification_status IN ('passed', 'failed', 'unverified'));
3
+ ALTER TABLE task_outcomes ADD COLUMN verification_json TEXT NOT NULL DEFAULT '{"checks":[]}';
4
+ ALTER TABLE task_outcomes ADD COLUMN failure_code TEXT;
5
+ ALTER TABLE task_outcomes ADD COLUMN failure_phase TEXT;
6
+ ALTER TABLE task_outcomes ADD COLUMN recovery_action TEXT;
@@ -0,0 +1,11 @@
1
+ CREATE TABLE interaction_states (
2
+ session_key TEXT PRIMARY KEY REFERENCES sessions(session_key) ON DELETE CASCADE,
3
+ support_need TEXT NOT NULL CHECK (support_need IN ('listen', 'clarify', 'advise', 'act', 'unknown')),
4
+ emotion_hypothesis TEXT,
5
+ confidence REAL NOT NULL CHECK (confidence >= 0 AND confidence <= 1),
6
+ source TEXT NOT NULL CHECK (source IN ('explicit', 'inferred')),
7
+ repair_status TEXT NOT NULL CHECK (repair_status IN ('none', 'needed', 'repaired')),
8
+ repair_reason TEXT,
9
+ expires_at INTEGER NOT NULL,
10
+ updated_at INTEGER NOT NULL
11
+ );
@@ -0,0 +1,3 @@
1
+ ALTER TABLE proactive_insights ADD COLUMN value_score REAL NOT NULL DEFAULT 0
2
+ CHECK (value_score >= 0 AND value_score <= 1);
3
+ ALTER TABLE proactive_insights ADD COLUMN value_reasons_json TEXT NOT NULL DEFAULT '[]';
@@ -3,7 +3,7 @@ import type { ApplyMigrationsOptions } from './types.js';
3
3
  /** Baseline schema version applied from schema.sql on first open. */
4
4
  export declare const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
5
5
  /** Latest schema version this release supports (increment when adding migrations). */
6
- export declare const XOPC_DB_SCHEMA_VERSION = 52;
6
+ export declare const XOPC_DB_SCHEMA_VERSION = 58;
7
7
  export declare function resolveMigrationsDir(override?: string): string;
8
8
  /**
9
9
  * Apply sequential SQL migrations from (currentVersion + 1) through targetVersion.
@@ -12,7 +12,7 @@ const log = createLogger("Sqlite:Migrations");
12
12
  /** Baseline schema version applied from schema.sql on first open. */
13
13
  const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
14
14
  /** Latest schema version this release supports (increment when adding migrations). */
15
- const XOPC_DB_SCHEMA_VERSION = 52;
15
+ const XOPC_DB_SCHEMA_VERSION = 58;
16
16
  const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
17
17
  function resolveMigrationsDir(override) {
18
18
  if (override) return override;
@@ -46,7 +46,7 @@ function applySingleMigration(db, migration) {
46
46
  * Each step runs in its own transaction and updates schema_meta on success.
47
47
  */
48
48
  function applyPendingMigrations(db, options = {}) {
49
- const targetVersion = options.targetVersion ?? 52;
49
+ const targetVersion = options.targetVersion ?? 58;
50
50
  let currentVersion = readSchemaVersion(db);
51
51
  if (currentVersion > targetVersion) throw new DatabaseSchemaTooNewError(currentVersion, targetVersion);
52
52
  if (currentVersion >= targetVersion) return currentVersion;
@@ -62,7 +62,7 @@ function applyPendingMigrations(db, options = {}) {
62
62
  }
63
63
  /** Inspect schema version without mutating the database. */
64
64
  function inspectSchemaMigrationStatus(db, options = {}) {
65
- const appVersion = options.targetVersion ?? 52;
65
+ const appVersion = options.targetVersion ?? 58;
66
66
  const dbVersion = readSchemaVersion(db);
67
67
  if (dbVersion > appVersion) return {
68
68
  dbVersion,
@@ -19,7 +19,7 @@ const log = createLogger('Sqlite:Migrations');
19
19
  export const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
20
20
 
21
21
  /** Latest schema version this release supports (increment when adding migrations). */
22
- export const XOPC_DB_SCHEMA_VERSION = 52;
22
+ export const XOPC_DB_SCHEMA_VERSION = 58;
23
23
 
24
24
  const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
25
25
 
@@ -0,0 +1,17 @@
1
+ export type SupportMode = 'efficient' | 'coach' | 'companion' | 'auto';
2
+ export interface RelationshipSettings {
3
+ supportMode: SupportMode;
4
+ proactiveEnabled: boolean;
5
+ quietStart?: string;
6
+ quietEnd?: string;
7
+ allowedTopics: string[];
8
+ blockedTopics: string[];
9
+ updatedAt: number;
10
+ }
11
+ export declare function getRelationshipSettings(): RelationshipSettings;
12
+ export declare function updateRelationshipSettings(patch: Partial<Omit<RelationshipSettings, 'updatedAt'>>): RelationshipSettings;
13
+ export declare function buildRelationshipPrompt(settings: RelationshipSettings): string;
14
+ export declare function isProactiveSupportAllowed(settings: RelationshipSettings, input: {
15
+ now: Date;
16
+ topic: string;
17
+ }): boolean;
@@ -0,0 +1,64 @@
1
+ import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
2
+ import { LOCAL_USER_ID } from "../../user-context/owner.js";
3
+ //#region src/storage/sqlite/relationship-settings-repository.ts
4
+ function fromRow(row) {
5
+ return {
6
+ supportMode: row.support_mode,
7
+ proactiveEnabled: row.proactive_enabled === 1,
8
+ ...row.quiet_start ? { quietStart: row.quiet_start } : {},
9
+ ...row.quiet_end ? { quietEnd: row.quiet_end } : {},
10
+ allowedTopics: JSON.parse(row.allowed_topics_json),
11
+ blockedTopics: JSON.parse(row.blocked_topics_json),
12
+ updatedAt: row.updated_at
13
+ };
14
+ }
15
+ function getRelationshipSettings() {
16
+ return fromRow(getSqliteDatabase().prepare(`SELECT support_mode, proactive_enabled, quiet_start, quiet_end,
17
+ allowed_topics_json, blocked_topics_json, updated_at
18
+ FROM relationship_settings WHERE owner_id = ?`).get(LOCAL_USER_ID));
19
+ }
20
+ function updateRelationshipSettings(patch) {
21
+ const next = {
22
+ ...getRelationshipSettings(),
23
+ ...patch,
24
+ updatedAt: Date.now()
25
+ };
26
+ runSqliteWriteTransaction((db) => {
27
+ db.prepare(`UPDATE relationship_settings
28
+ SET support_mode = ?, proactive_enabled = ?, quiet_start = ?, quiet_end = ?,
29
+ allowed_topics_json = ?, blocked_topics_json = ?, updated_at = ?
30
+ WHERE owner_id = ?`).run(next.supportMode, Number(next.proactiveEnabled), next.quietStart ?? null, next.quietEnd ?? null, JSON.stringify(next.allowedTopics), JSON.stringify(next.blockedTopics), next.updatedAt, LOCAL_USER_ID);
31
+ });
32
+ return next;
33
+ }
34
+ function buildRelationshipPrompt(settings) {
35
+ return [
36
+ "## Support mode",
37
+ {
38
+ efficient: "Prioritize direct action and concise answers. Acknowledge emotion briefly only when it materially helps.",
39
+ coach: "Help the user clarify goals and move forward. Ask focused questions and turn reflection into practical next steps.",
40
+ companion: "Acknowledge the user’s experience before offering solutions. Do not rush advice; ask whether they want listening or action when unclear.",
41
+ auto: "Infer whether the user needs listening, validation, analysis, advice, or action. Ask one concise question when the need is ambiguous."
42
+ }[settings.supportMode],
43
+ "Never claim to have human feelings, encourage exclusivity or dependency, use guilt, or present yourself as a replacement for human relationships or professional care.",
44
+ "Treat inferred emotions as hypotheses, not facts. In high-risk situations, encourage timely support from trusted people or appropriate emergency/professional services."
45
+ ].join("\n\n");
46
+ }
47
+ function isProactiveSupportAllowed(settings, input) {
48
+ if (!settings.proactiveEnabled) return false;
49
+ const topic = input.topic.trim().toLocaleLowerCase();
50
+ if (settings.blockedTopics.map((value) => value.toLocaleLowerCase()).includes(topic)) return false;
51
+ const allowed = settings.allowedTopics.map((value) => value.toLocaleLowerCase());
52
+ if (allowed.length > 0 && !allowed.includes(topic)) return false;
53
+ if (!settings.quietStart || !settings.quietEnd) return true;
54
+ const minutes = input.now.getHours() * 60 + input.now.getMinutes();
55
+ const toMinutes = (value) => {
56
+ const [hours, minute] = value.split(":").map(Number);
57
+ return hours * 60 + minute;
58
+ };
59
+ const start = toMinutes(settings.quietStart);
60
+ const end = toMinutes(settings.quietEnd);
61
+ return !(start <= end ? minutes >= start && minutes < end : minutes >= start || minutes < end);
62
+ }
63
+ //#endregion
64
+ export { buildRelationshipPrompt, getRelationshipSettings, isProactiveSupportAllowed, updateRelationshipSettings };
@@ -31,7 +31,7 @@ function ensureXopcDatabaseSchema(db) {
31
31
  bootstrapFreshDatabase(db);
32
32
  currentVersion = 11;
33
33
  }
34
- applyPendingMigrations(db, { targetVersion: 52 });
34
+ applyPendingMigrations(db, { targetVersion: 58 });
35
35
  }
36
36
  //#endregion
37
37
  export { SCHEMA_META_SCHEMA_VERSION_KEY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_SCHEMA_VERSION, ensureSchemaMetaTable, ensureXopcDatabaseSchema, readSchemaVersion, readSchemaVersionForTest, setSchemaVersion };
@@ -724,3 +724,49 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_memory_reference_consents_pending
724
724
 
725
725
  CREATE INDEX IF NOT EXISTS idx_memory_reference_consents_resolution
726
726
  ON memory_reference_consents(record_id, status, session_key, expires_at);
727
+
728
+ CREATE TABLE IF NOT EXISTS browser_recipes (
729
+ recipe_id TEXT PRIMARY KEY,
730
+ revision INTEGER NOT NULL,
731
+ name TEXT NOT NULL,
732
+ description TEXT,
733
+ status TEXT NOT NULL CHECK (status IN ('published', 'disabled')),
734
+ yaml_source TEXT NOT NULL,
735
+ risk_level TEXT NOT NULL CHECK (risk_level IN ('read_only', 'account_write', 'sensitive')),
736
+ domains_json TEXT NOT NULL,
737
+ created_at_ms INTEGER NOT NULL,
738
+ updated_at_ms INTEGER NOT NULL
739
+ );
740
+
741
+ CREATE TABLE IF NOT EXISTS browser_recipe_runs (
742
+ run_id TEXT PRIMARY KEY,
743
+ recipe_id TEXT NOT NULL,
744
+ recipe_revision INTEGER NOT NULL,
745
+ recipe_yaml TEXT NOT NULL,
746
+ status TEXT NOT NULL CHECK (status IN ('queued', 'running', 'succeeded', 'failed', 'cancelled')),
747
+ args_json TEXT NOT NULL,
748
+ result_json TEXT,
749
+ error TEXT,
750
+ created_at_ms INTEGER NOT NULL,
751
+ started_at_ms INTEGER,
752
+ ended_at_ms INTEGER,
753
+ duration_ms INTEGER,
754
+ FOREIGN KEY (recipe_id) REFERENCES browser_recipes(recipe_id) ON DELETE CASCADE
755
+ );
756
+
757
+ CREATE INDEX IF NOT EXISTS idx_browser_recipe_runs_recipe_created
758
+ ON browser_recipe_runs(recipe_id, created_at_ms DESC);
759
+
760
+ CREATE TABLE IF NOT EXISTS browser_recipe_run_events (
761
+ event_id TEXT PRIMARY KEY,
762
+ run_id TEXT NOT NULL,
763
+ seq INTEGER NOT NULL,
764
+ type TEXT NOT NULL,
765
+ data_json TEXT,
766
+ created_at_ms INTEGER NOT NULL,
767
+ UNIQUE(run_id, seq),
768
+ FOREIGN KEY (run_id) REFERENCES browser_recipe_runs(run_id) ON DELETE CASCADE
769
+ );
770
+
771
+ CREATE INDEX IF NOT EXISTS idx_browser_recipe_run_events_run_seq
772
+ ON browser_recipe_run_events(run_id, seq ASC);
@@ -0,0 +1,90 @@
1
+ import { type TaskFailureCode, type TaskFailurePhase, type TaskRecoveryAction, type TaskVerification } from '../../agent/outcomes/task-verifier.js';
2
+ export type TaskOutcomeStatus = 'running' | 'succeeded' | 'failed' | 'cancelled';
3
+ export type TaskFeedbackOutcome = 'helpful' | 'not_helpful';
4
+ export interface TaskContract {
5
+ objective: string;
6
+ deliverables: string[];
7
+ acceptanceCriteria: string[];
8
+ constraints: string[];
9
+ approvalRequired: string[];
10
+ }
11
+ export interface TaskEvidence {
12
+ kind: 'artifact' | 'test' | 'state' | 'source';
13
+ title: string;
14
+ summary: string;
15
+ uri?: string;
16
+ verifies?: string[];
17
+ }
18
+ export interface TaskOutcome {
19
+ runId: string;
20
+ sessionKey: string;
21
+ channel: string;
22
+ objective: string;
23
+ status: TaskOutcomeStatus;
24
+ summary?: string;
25
+ contract?: TaskContract;
26
+ evidence: TaskEvidence[];
27
+ verification: TaskVerification;
28
+ failure?: {
29
+ code: TaskFailureCode;
30
+ phase: TaskFailurePhase;
31
+ recoveryAction: TaskRecoveryAction;
32
+ };
33
+ feedback?: {
34
+ outcome: TaskFeedbackOutcome;
35
+ reason?: string;
36
+ needsCorrection?: boolean;
37
+ supportFit?: boolean;
38
+ };
39
+ startedAt: number;
40
+ completedAt?: number;
41
+ updatedAt: number;
42
+ }
43
+ export interface TaskOutcomeMetrics {
44
+ total: number;
45
+ completed: number;
46
+ succeeded: number;
47
+ verified: number;
48
+ helpful: number;
49
+ notHelpful: number;
50
+ completionRate: number;
51
+ successRate: number;
52
+ verificationRate: number;
53
+ helpfulRate: number;
54
+ }
55
+ export declare function startTaskOutcome(input: {
56
+ runId: string;
57
+ sessionKey: string;
58
+ channel: string;
59
+ objective: string;
60
+ now?: number;
61
+ }): TaskOutcome;
62
+ export declare function completeTaskOutcome(input: {
63
+ runId: string;
64
+ status: Exclude<TaskOutcomeStatus, 'running'>;
65
+ summary: string;
66
+ now?: number;
67
+ }): TaskOutcome | undefined;
68
+ export declare function updateTaskOutcome(input: {
69
+ runId: string;
70
+ contract?: TaskContract;
71
+ evidence?: TaskEvidence[];
72
+ summary?: string;
73
+ now?: number;
74
+ }): TaskOutcome | undefined;
75
+ export declare function setTaskOutcomeFeedback(input: {
76
+ sessionKey: string;
77
+ assistantTimestamp: number;
78
+ outcome: TaskFeedbackOutcome;
79
+ reason?: string;
80
+ needsCorrection?: boolean;
81
+ supportFit?: boolean;
82
+ now?: number;
83
+ }): TaskOutcome | undefined;
84
+ export declare function getTaskOutcome(runId: string): TaskOutcome | undefined;
85
+ export declare function findTaskOutcomeForAssistant(sessionKey: string, assistantTimestamp: number): TaskOutcome | undefined;
86
+ export declare function listTaskOutcomes(input?: {
87
+ sessionKey?: string;
88
+ limit?: number;
89
+ }): TaskOutcome[];
90
+ export declare function summarizeTaskOutcomes(): TaskOutcomeMetrics;