@xopcai/xopc 0.0.255 → 0.0.256

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 (164) 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-DvjK5FEm.js → activity-store-DYb6xFC3.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Cqspzbf_.js → agent-avatar-dicebear-BZJZvmYw.js} +1 -1
  5. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Bq7GNF1L.js +1 -0
  6. package/dist/gateway/static/root/assets/agents-1vtaw07m.js +1 -0
  7. package/dist/gateway/static/root/assets/{api-CsYi3heY.js → api-NADZ8X8B.js} +1 -1
  8. package/dist/gateway/static/root/assets/{app-management-settings-panel-Gd4a5hdE.js → app-management-settings-panel-DG64SQsx.js} +1 -1
  9. package/dist/gateway/static/root/assets/{appearance-settings-CZ6KOnbd.js → appearance-settings-BRWQdIIy.js} +1 -1
  10. package/dist/gateway/static/root/assets/apps-page-D3ziBisx.js +1 -0
  11. package/dist/gateway/static/root/assets/{archive-plugin-y82Rwhjm.js → archive-plugin-D3FQ9VzV.js} +1 -1
  12. package/dist/gateway/static/root/assets/{attachment-load-D46SGNpv.js → attachment-load-Cid3dBaW.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-wilciIZ1.js → automations-page-BUTNaZtj.js} +1 -1
  14. package/dist/gateway/static/root/assets/automations-workspace-D4NJSE8l.js +6 -0
  15. package/dist/gateway/static/root/assets/{binary-plugins-CuMkNNCe.js → binary-plugins-BSYMCuaB.js} +1 -1
  16. package/dist/gateway/static/root/assets/block-editor-qDlC3t7b.js +159 -0
  17. package/dist/gateway/static/root/assets/{browser-automation-inputs-hlmcSp4p.js → browser-automation-inputs-rA2QROKe.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-automations-page-OjZvbARU.js → browser-automations-page-Du1KVE01.js} +2 -2
  19. package/dist/gateway/static/root/assets/browser-settings-page-WZ0Jt5Hp.js +8 -0
  20. package/dist/gateway/static/root/assets/capabilities-settings-panel-D1AYoRx4.js +7 -0
  21. package/dist/gateway/static/root/assets/channels-settings-CZnlYu2L.js +1 -0
  22. package/dist/gateway/static/root/assets/{channels-status-swr-D1HHFzkE.js → channels-status-swr-B2aMPOSM.js} +1 -1
  23. package/dist/gateway/static/root/assets/{chat-terminal-dock-Ce_T9BPq.js → chat-terminal-dock-CY-I_bCe.js} +2 -2
  24. package/dist/gateway/static/root/assets/{chunk-KS7C4IRE-BaASWQor.js → chunk-KS7C4IRE-Cq1tE_3b.js} +2 -2
  25. package/dist/gateway/static/root/assets/code-editor-CXIH8jQw.js +1 -0
  26. package/dist/gateway/static/root/assets/connectors-page-CkH3gaqs.js +2 -0
  27. package/dist/gateway/static/root/assets/{cron-expression-BRrCwYyD.js → cron-expression-z4WOWyBU.js} +1 -1
  28. package/dist/gateway/static/root/assets/{date-picker-C35RuuWW.js → date-picker-vKUcJeQZ.js} +1 -1
  29. package/dist/gateway/static/root/assets/{dependency-picker-4pNXVcRM.js → dependency-picker-BpZ9A2gi.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-z91GYnPf.js → desktop-pet-ClrAMqgn.js} +1 -1
  31. package/dist/gateway/static/root/assets/{desktop-pet-settings-BvV1UA5g.js → desktop-pet-settings-DKNKGiEG.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-debug-page-CkVF5HvV.js → extension-debug-page-C39hFkJm.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-page-DW0zQGaB.js → extension-page-DkqVsWB7.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-settings-page-BLQhizZ3.js → extension-settings-page-Be4lFw8f.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-config-swr-02BBC1mK.js → gateway-config-swr-DEKSw3d-.js} +1 -1
  36. package/dist/gateway/static/root/assets/gateway-settings-HIHGY-0Y.js +1 -0
  37. package/dist/gateway/static/root/assets/{gateway-startup-retry-XZnY6621.js → gateway-startup-retry-Dlyt2VhF.js} +1 -1
  38. package/dist/gateway/static/root/assets/heartbeat-settings-DiYjWa1F.js +1 -0
  39. package/dist/gateway/static/root/assets/home-page-BLZNEVmk.js +1 -0
  40. package/dist/gateway/static/root/assets/{image-generation-api-CIcKz4Xs.js → image-generation-api-CJIPVk_d.js} +1 -1
  41. package/dist/gateway/static/root/assets/index-50Kr6L6C.css +2 -0
  42. package/dist/gateway/static/root/assets/{index-PksHo9hS.js → index-BWdn9NaX.js} +49 -47
  43. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-yfaGz6SE.js → keyboard-shortcuts-settings-ge76J038.js} +1 -1
  44. package/dist/gateway/static/root/assets/languages-BFe8nIOO.js +2 -0
  45. package/dist/gateway/static/root/assets/local-app-workbench-page-E47xrPDI.js +2 -0
  46. package/dist/gateway/static/root/assets/{local-apps-page-Cp-nEtgV.js → local-apps-page-gkw7VRL4.js} +1 -1
  47. package/dist/gateway/static/root/assets/{locale-store-VsboRLD7.js → locale-store-DJPCr2mb.js} +1 -1
  48. package/dist/gateway/static/root/assets/{logs-page-DkqsRCri.js → logs-page-HHtDMSUW.js} +2 -2
  49. package/dist/gateway/static/root/assets/{management-settings-24_JyDPk.js → management-settings-DOfCSojd.js} +1 -1
  50. package/dist/gateway/static/root/assets/markdown-editor-BhBJANcx.js +1 -0
  51. package/dist/gateway/static/root/assets/{markdown-view-CPXhy6nh.js → markdown-view-k_PJsY2C.js} +2 -2
  52. package/dist/gateway/static/root/assets/{media-plugins-CwLvIb9r.js → media-plugins-D8wMcUtB.js} +1 -1
  53. package/dist/gateway/static/root/assets/messages-BeIiRpmk.js +3 -0
  54. package/dist/gateway/static/root/assets/{mobile-pairing-wizard-BbJCDv57.js → mobile-pairing-wizard-B4Ewewwr.js} +1 -1
  55. package/dist/gateway/static/root/assets/note-detail-panel-DPd5L2A9.js +5 -0
  56. package/dist/gateway/static/root/assets/notes-page-CE_De-iQ.js +8 -0
  57. package/dist/gateway/static/root/assets/{page-tabs-0YXn9Gkl.js → page-tabs-DoxnT3X4.js} +1 -1
  58. package/dist/gateway/static/root/assets/{preview-open-alternatives-2jVV5kfZ.js → preview-open-alternatives-D4oL1yua.js} +1 -1
  59. package/dist/gateway/static/root/assets/product-open-page-CeStuxSl.js +1 -0
  60. package/dist/gateway/static/root/assets/project-detail-page-DXhBJzJy.js +1 -0
  61. package/dist/gateway/static/root/assets/{projects-page-D6jY2ZWl.js → projects-page-CcqhmZoX.js} +1 -1
  62. package/dist/gateway/static/root/assets/{registry-api-DlTWbXQA.js → registry-api-Dalzf2w0.js} +1 -1
  63. package/dist/gateway/static/root/assets/remote-access-hub-ulmJT_Ac.js +1 -0
  64. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-B-NDgmJ4.js → runtime-tools-settings-panel-CrOpchy5.js} +2 -2
  65. package/dist/gateway/static/root/assets/{schema-form-DZYeBS1v.js → schema-form-Dk52v4cQ.js} +1 -1
  66. package/dist/gateway/static/root/assets/sessions-page-RM0kAsNa.js +1 -0
  67. package/dist/gateway/static/root/assets/settings-advanced-gate-BfLbu67w.js +1 -0
  68. package/dist/gateway/static/root/assets/{settings-form-section-zy5UMvPk.js → settings-form-section-dvGi1APN.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-page-CTuipbJq.js → settings-page-CEYjEm2D.js} +1 -1
  70. package/dist/gateway/static/root/assets/setup-status-panel-BZ4i0CYX.js +1 -0
  71. package/dist/gateway/static/root/assets/{share-preview-page-D3Uawo_h.js → share-preview-page-DP4Qgsv6.js} +1 -1
  72. package/dist/gateway/static/root/assets/shares-settings-B5yHTrGO.js +1 -0
  73. package/dist/gateway/static/root/assets/skill-reload-api-BicZK04u.js +1 -0
  74. package/dist/gateway/static/root/assets/{skills-page-DDbabz7p.js → skills-page-Dlr1Ue1w.js} +1 -1
  75. package/dist/gateway/static/root/assets/{skills-page.utils-DkGhbiMa.js → skills-page.utils-I1wcnceD.js} +1 -1
  76. package/dist/gateway/static/root/assets/source-workspace-editor-DunRD1gY.js +1 -0
  77. package/dist/gateway/static/root/assets/{system-settings-panel-Fc-WbX6-.js → system-settings-panel-DIaFAHT0.js} +1 -1
  78. package/dist/gateway/static/root/assets/task-detail-page-4_5g-V8B.js +1 -0
  79. package/dist/gateway/static/root/assets/{theme-store-vdB57bTn.js → theme-store-DYDrhfnD.js} +1 -1
  80. package/dist/gateway/static/root/assets/{tunnel-api-DZ0evABj.js → tunnel-api-DAXx1rHF.js} +1 -1
  81. package/dist/gateway/static/root/assets/{use-autosave-Ckof_m7e.js → use-autosave-BwEFbveP.js} +1 -1
  82. package/dist/gateway/static/root/assets/user-model-page-CQnXw4ba.js +2 -0
  83. package/dist/gateway/static/root/assets/{vendor-codemirror-Qdcjid65.js → vendor-codemirror-DFxP3B9T.js} +16 -16
  84. package/dist/gateway/static/root/assets/{voice-api-key-field-CnmtpWlq.js → voice-api-key-field-C-WbC2fM.js} +1 -1
  85. package/dist/gateway/static/root/assets/{voice-config-api-OA04c71t.js → voice-config-api-Ds0z9O11.js} +1 -1
  86. package/dist/gateway/static/root/assets/{work-discovery-overlay-sxvsDIC3.js → work-discovery-overlay-DiGw5KKj.js} +1 -1
  87. package/dist/gateway/static/root/assets/workflow-run-setup-panel-BIU2wg99.js +3 -0
  88. package/dist/gateway/static/root/assets/workflows-page-D3Z7JVHH.js +6 -0
  89. package/dist/gateway/static/root/index.html +11 -11
  90. package/dist/package.js +1 -1
  91. package/dist/packages/gateway-contract/src/user-message-display.js +0 -18
  92. package/dist/src/agent/context/execution-context.js +34 -21
  93. package/dist/src/agent/context/execution-context.types.d.ts +2 -0
  94. package/dist/src/agent/inbound/attachment-pipeline.d.ts +1 -0
  95. package/dist/src/agent/inbound/attachment-pipeline.js +6 -1
  96. package/dist/src/agent/prompt/sections/memory-skills.js +2 -1
  97. package/dist/src/agent/prompt/sections/tooling.js +2 -0
  98. package/dist/src/agent/tools/delegate-tool.js +1 -0
  99. package/dist/src/agent/tools/factory.js +14 -1
  100. package/dist/src/agent/tools/index.d.ts +1 -1
  101. package/dist/src/agent/tools/index.js +2 -2
  102. package/dist/src/agent/tools/user-context-tool.d.ts +3 -0
  103. package/dist/src/agent/tools/user-context-tool.js +147 -4
  104. package/dist/src/agent/tools/xopc-use-tool.js +2 -2
  105. package/dist/src/agent/workflow/catalog.js +6 -2
  106. package/dist/src/chat-commands/builtins/workflow.js +1 -1
  107. package/dist/src/connectors/connected-source-understanding.js +4 -4
  108. package/dist/src/gateway/agent-builtin-tools.d.ts +7 -1
  109. package/dist/src/gateway/agent-builtin-tools.js +7 -0
  110. package/dist/src/gateway/hono/routes/user-model.js +35 -102
  111. package/dist/src/gateway/hono/routes/workflows.js +7 -4
  112. package/dist/src/gateway/service.js +9 -9
  113. package/dist/src/tasks/home-query-service.js +2 -2
  114. package/dist/src/tui/tui-workflow-slash.d.ts +3 -6
  115. package/dist/src/tui/tui-workflow-slash.js +3 -6
  116. package/dist/src/user-model/bootstrap.d.ts +17 -0
  117. package/dist/src/user-model/bootstrap.js +118 -0
  118. package/dist/src/user-model/index.d.ts +3 -0
  119. package/dist/src/user-model/index.js +4 -1
  120. package/dist/src/user-model/profile.d.ts +5 -0
  121. package/dist/src/user-model/profile.js +98 -0
  122. package/dist/src/user-model/usage-policy.d.ts +2 -0
  123. package/dist/src/user-model/usage-policy.js +6 -0
  124. package/dist/src/work-discovery/analyzer.js +8 -6
  125. package/dist/src/work-discovery/service.d.ts +1 -1
  126. package/dist/src/work-discovery/service.js +4 -4
  127. package/dist/src/work-discovery/types.d.ts +1 -1
  128. package/dist/src/workflows/domain/run.d.ts +8 -1
  129. package/dist/src/workflows/domain/validation.d.ts +3 -4
  130. package/dist/src/workflows/domain/validation.js +119 -8
  131. package/dist/src/workflows/service/workflow-run-service.js +9 -2
  132. package/package.json +5 -5
  133. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CL3Mi-uM.js +0 -1
  134. package/dist/gateway/static/root/assets/agents-odqXmGhA.js +0 -1
  135. package/dist/gateway/static/root/assets/apps-page-DyBDoCam.js +0 -1
  136. package/dist/gateway/static/root/assets/automations-workspace-8U86Umig.js +0 -6
  137. package/dist/gateway/static/root/assets/block-editor-DFnPsrxI.js +0 -185
  138. package/dist/gateway/static/root/assets/browser-settings-page-DOUG84qV.js +0 -8
  139. package/dist/gateway/static/root/assets/capabilities-settings-panel-CG73Mwi8.js +0 -7
  140. package/dist/gateway/static/root/assets/channels-settings-MDywEWWM.js +0 -1
  141. package/dist/gateway/static/root/assets/connectors-page-D29p6Zvm.js +0 -2
  142. package/dist/gateway/static/root/assets/gateway-settings-rAXx8FGP.js +0 -1
  143. package/dist/gateway/static/root/assets/heartbeat-settings-BaW_r1t9.js +0 -1
  144. package/dist/gateway/static/root/assets/home-page-BoTS8-Z9.js +0 -1
  145. package/dist/gateway/static/root/assets/index-DsonmRCH.css +0 -2
  146. package/dist/gateway/static/root/assets/languages-5WaOu0Lf.js +0 -2
  147. package/dist/gateway/static/root/assets/local-app-workbench-page-B3flRQH1.js +0 -2
  148. package/dist/gateway/static/root/assets/markdown-editor-BjMTIM-m.js +0 -1
  149. package/dist/gateway/static/root/assets/messages-DngsF_Kx.js +0 -3
  150. package/dist/gateway/static/root/assets/note-detail-panel-OklYXK7y.js +0 -5
  151. package/dist/gateway/static/root/assets/notes-page-BjfgJIQw.js +0 -8
  152. package/dist/gateway/static/root/assets/product-open-page-D7p0NfTK.js +0 -1
  153. package/dist/gateway/static/root/assets/project-detail-page-rLNM2mP0.js +0 -1
  154. package/dist/gateway/static/root/assets/remote-access-hub-CZZg0kXc.js +0 -1
  155. package/dist/gateway/static/root/assets/sessions-page-BvuxJegi.js +0 -1
  156. package/dist/gateway/static/root/assets/settings-advanced-gate-BAQHP4mB.js +0 -1
  157. package/dist/gateway/static/root/assets/setup-status-panel-BkWoc5j5.js +0 -1
  158. package/dist/gateway/static/root/assets/shares-settings-B2doziIn.js +0 -1
  159. package/dist/gateway/static/root/assets/skill-reload-api-D2ymjqG5.js +0 -1
  160. package/dist/gateway/static/root/assets/source-workspace-editor-CVWzt0oT.js +0 -1
  161. package/dist/gateway/static/root/assets/task-detail-page-7w7eB9nB.js +0 -1
  162. package/dist/gateway/static/root/assets/user-model-page-CcNCyrXZ.js +0 -2
  163. package/dist/gateway/static/root/assets/workflow-run-setup-panel-CUCfBpPF.js +0 -3
  164. package/dist/gateway/static/root/assets/workflows-page-Bp-nvnLa.js +0 -5
@@ -11,7 +11,7 @@
11
11
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=20260713-1" />
12
12
  <link rel="manifest" href="/site.webmanifest?v=20260713-1" />
13
13
  <title>XOPC — Keep what matters moving.</title>
14
- <script type="module" crossorigin src="/assets/index-PksHo9hS.js"></script>
14
+ <script type="module" crossorigin src="/assets/index-BWdn9NaX.js"></script>
15
15
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-aKtaBQYM.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-zJ_50EbN.js">
17
17
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-BOUWij0V.js">
@@ -20,18 +20,18 @@
20
20
  <link rel="modulepreload" crossorigin href="/assets/floating-ui.dom-B7uQOZZW.js">
21
21
  <link rel="modulepreload" crossorigin href="/assets/dist-DBS3OB8K.js">
22
22
  <link rel="modulepreload" crossorigin href="/assets/dist-CpzYSoz7.js">
23
- <link rel="modulepreload" crossorigin href="/assets/chunk-KS7C4IRE-BaASWQor.js">
23
+ <link rel="modulepreload" crossorigin href="/assets/chunk-KS7C4IRE-Cq1tE_3b.js">
24
24
  <link rel="modulepreload" crossorigin href="/assets/createLucideIcon-DPHK1VkS.js">
25
25
  <link rel="modulepreload" crossorigin href="/assets/download-Dk-ZjtO6.js">
26
26
  <link rel="modulepreload" crossorigin href="/assets/plus-Q2yW6OE7.js">
27
27
  <link rel="modulepreload" crossorigin href="/assets/x-B_N4OPjy.js">
28
- <link rel="modulepreload" crossorigin href="/assets/messages-DngsF_Kx.js">
29
- <link rel="modulepreload" crossorigin href="/assets/locale-store-VsboRLD7.js">
28
+ <link rel="modulepreload" crossorigin href="/assets/messages-BeIiRpmk.js">
29
+ <link rel="modulepreload" crossorigin href="/assets/locale-store-DJPCr2mb.js">
30
30
  <link rel="modulepreload" crossorigin href="/assets/cn-JdwAhgNB.js">
31
31
  <link rel="modulepreload" crossorigin href="/assets/schemas-BHS7bo06.js">
32
32
  <link rel="modulepreload" crossorigin href="/assets/product-delivery-CV4pDOtG.js">
33
33
  <link rel="modulepreload" crossorigin href="/assets/copy-to-clipboard-HOJ79TWv.js">
34
- <link rel="modulepreload" crossorigin href="/assets/markdown-view-CPXhy6nh.js">
34
+ <link rel="modulepreload" crossorigin href="/assets/markdown-view-k_PJsY2C.js">
35
35
  <link rel="modulepreload" crossorigin href="/assets/dist-DLmwHyAh.js">
36
36
  <link rel="modulepreload" crossorigin href="/assets/vendor-swr-BIWyz7Rc.js">
37
37
  <link rel="modulepreload" crossorigin href="/assets/check-DUBLcKHA.js">
@@ -48,15 +48,15 @@
48
48
  <link rel="modulepreload" crossorigin href="/assets/files-BArWTfr7.js">
49
49
  <link rel="modulepreload" crossorigin href="/assets/tool-activity-R8V9l6nk.js">
50
50
  <link rel="modulepreload" crossorigin href="/assets/button-CtTvuElV.js">
51
- <link rel="modulepreload" crossorigin href="/assets/gateway-startup-retry-XZnY6621.js">
52
- <link rel="modulepreload" crossorigin href="/assets/registry-api-DlTWbXQA.js">
51
+ <link rel="modulepreload" crossorigin href="/assets/gateway-startup-retry-Dlyt2VhF.js">
52
+ <link rel="modulepreload" crossorigin href="/assets/registry-api-Dalzf2w0.js">
53
53
  <link rel="modulepreload" crossorigin href="/assets/config-reload-event-Bjh2zoKp.js">
54
- <link rel="modulepreload" crossorigin href="/assets/gateway-config-swr-02BBC1mK.js">
54
+ <link rel="modulepreload" crossorigin href="/assets/gateway-config-swr-DEKSw3d-.js">
55
55
  <link rel="modulepreload" crossorigin href="/assets/electron-env-DH5wF8X8.js">
56
- <link rel="modulepreload" crossorigin href="/assets/activity-store-DvjK5FEm.js">
57
- <link rel="modulepreload" crossorigin href="/assets/theme-store-vdB57bTn.js">
56
+ <link rel="modulepreload" crossorigin href="/assets/activity-store-DYb6xFC3.js">
57
+ <link rel="modulepreload" crossorigin href="/assets/theme-store-DYDrhfnD.js">
58
58
  <link rel="stylesheet" crossorigin href="/assets/markdown-view-Y68dCxuc.css">
59
- <link rel="stylesheet" crossorigin href="/assets/index-DsonmRCH.css">
59
+ <link rel="stylesheet" crossorigin href="/assets/index-50Kr6L6C.css">
60
60
  </head>
61
61
  <body>
62
62
  <div id="root"></div>
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.0.255";
2
+ var version = "0.0.256";
3
3
  //#endregion
4
4
  export { version };
@@ -6,14 +6,6 @@ const USER_CONTEXT_TAGS = [
6
6
  "collaboration-contract",
7
7
  "user-context"
8
8
  ];
9
- const LEGACY_EXECUTION_CONTEXT_HEADINGS = [
10
- "Collaboration rules:",
11
- "Relevant user facts:",
12
- "Active goals:",
13
- "Current priorities:",
14
- "Relevant knowledge:"
15
- ];
16
- const EMBEDDED_TIMESTAMP_PREFIX_RE = /(?:^|\r?\n)(\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}[^\]]*\]\s*)/u;
17
9
  function stripLeadingTaggedBlock(text, tag) {
18
10
  const opening = `<${tag}>`;
19
11
  if (!text.startsWith(opening)) return null;
@@ -31,15 +23,6 @@ function stripSourceContextsEnvelope(text) {
31
23
  const withoutContexts = text.replace(/^\s*<source_contexts>[\s\S]*?<\/source_contexts>\s*/u, "").trimStart();
32
24
  return withoutContexts.match(/^<user_message>\r?\n([\s\S]*)\r?\n<\/user_message>\s*$/u)?.[1] ?? withoutContexts;
33
25
  }
34
- /** Remove execution context persisted before it gained a structured envelope. */
35
- function stripLegacyExecutionContext(text) {
36
- const trimmed = text.trimStart();
37
- if (!LEGACY_EXECUTION_CONTEXT_HEADINGS.some((heading) => trimmed.startsWith(heading))) return text;
38
- const timestamp = trimmed.match(EMBEDDED_TIMESTAMP_PREFIX_RE);
39
- if (!timestamp || timestamp.index === void 0) return text;
40
- const timestampStart = timestamp.index + timestamp[0].length - timestamp[1].length;
41
- return trimmed.slice(timestampStart);
42
- }
43
26
  /**
44
27
  * Restore a model-facing user message to its client-facing text.
45
28
  * Generated profile/memory blocks require the runtime timestamp anchor, which
@@ -66,7 +49,6 @@ function stripRuntimeUserMessageEnvelope(text) {
66
49
  removedUserContext = true;
67
50
  }
68
51
  if (removedUserContext && !ENVELOPE_TIMESTAMP_PREFIX_RE.test(remaining)) remaining = beforeUserContext;
69
- remaining = stripLegacyExecutionContext(remaining);
70
52
  return remaining.replace(ENVELOPE_TIMESTAMP_PREFIX_RE, "");
71
53
  }
72
54
  //#endregion
@@ -5,6 +5,7 @@ import "../../knowledge-memory/index.js";
5
5
  import { retrievalLexicalSimilarity } from "../../retrieval/textFeatures.js";
6
6
  import { calculateExecutionValue } from "../../user-model/importance.js";
7
7
  import { listUserAssertions } from "../../user-model/repository.js";
8
+ import { isWorkingAssumption } from "../../user-model/usage-policy.js";
8
9
  import { getExecutionContextFeedbackScores } from "./audit.js";
9
10
  import { buildUserContextBlock } from "../memory/context-fence.js";
10
11
  import { randomUUID } from "node:crypto";
@@ -43,24 +44,27 @@ function urgency(assertion, asOf) {
43
44
  }
44
45
  function rankAssertion(assertion, query, asOf, feedbackScore) {
45
46
  const taskRelevance = retrievalLexicalSimilarity(query, `${assertion.statement} ${assertion.normalizedValue}`);
47
+ const score = calculateExecutionValue({
48
+ declaredImportance: assertion.declaredImportance,
49
+ inferredImportance: assertion.inferredImportance,
50
+ consequence: assertion.consequence,
51
+ actionability: assertion.actionability,
52
+ taskRelevance,
53
+ urgency: urgency(assertion, asOf)
54
+ }) + feedbackScore;
55
+ const reasons = [
56
+ taskRelevance >= .35 ? "task_relevant" : "",
57
+ assertion.declaredImportance !== void 0 ? "user_declared_importance" : "",
58
+ assertion.consequence === "critical" || assertion.consequence === "high" ? "high_consequence" : "",
59
+ assertion.kind === "identity" || assertion.kind === "preference" ? "stable_personalization" : "",
60
+ feedbackScore > 0 ? "historically_helpful" : "",
61
+ feedbackScore < 0 ? "historically_irrelevant" : ""
62
+ ].filter(Boolean);
46
63
  return {
47
64
  assertion,
48
- score: calculateExecutionValue({
49
- declaredImportance: assertion.declaredImportance,
50
- inferredImportance: assertion.inferredImportance,
51
- consequence: assertion.consequence,
52
- actionability: assertion.actionability,
53
- taskRelevance,
54
- urgency: urgency(assertion, asOf)
55
- }) + feedbackScore,
56
- reasons: [
57
- taskRelevance >= .35 ? "task_relevant" : "",
58
- assertion.declaredImportance !== void 0 ? "user_declared_importance" : "",
59
- assertion.consequence === "critical" || assertion.consequence === "high" ? "high_consequence" : "",
60
- assertion.kind === "identity" || assertion.kind === "preference" ? "stable_personalization" : "",
61
- feedbackScore > 0 ? "historically_helpful" : "",
62
- feedbackScore < 0 ? "historically_irrelevant" : ""
63
- ].filter(Boolean)
65
+ usage: assertion.status === "active" ? "confirmed" : "working_assumption",
66
+ score: assertion.status === "candidate" ? score - .05 : score,
67
+ reasons
64
68
  };
65
69
  }
66
70
  function ruleEnforcement(conditions) {
@@ -91,6 +95,7 @@ function loadGoals(context, asOf) {
91
95
  title: row.title,
92
96
  desiredOutcome: row.desired_outcome,
93
97
  status: row.status,
98
+ usage: row.status === "active" ? "confirmed" : "working_assumption",
94
99
  ...row.declared_importance === null ? {} : { declaredImportance: row.declared_importance },
95
100
  ...row.target_at === null ? {} : { targetAt: row.target_at }
96
101
  }));
@@ -115,10 +120,12 @@ function buildExecutionContext(request) {
115
120
  const asOf = request.asOf ?? Date.now();
116
121
  const includeUserModel = request.includeUserModel !== false;
117
122
  const feedbackScores = getExecutionContextFeedbackScores();
118
- const assertions = includeUserModel ? listUserAssertions({
119
- statuses: ["active"],
123
+ const assertionLimit = Math.max(1, Math.min(100, request.maxAssertions ?? 20));
124
+ const rankedAssertions = includeUserModel ? listUserAssertions({
125
+ statuses: ["active", "candidate"],
120
126
  limit: 1e3
121
- }).filter((item) => scopeVisible(getAssertionScope(item.slotId), request)).filter((item) => applicabilityVisible(item.applicability, request)).filter((item) => (item.validFrom === void 0 || item.validFrom <= asOf) && (item.validTo === void 0 || item.validTo >= asOf)).filter((item) => item.authority !== "external_untrusted").filter((item) => item.sensitivity !== "secret" && item.sensitivity !== "regulated" && item.disclosurePolicy !== "ask_before_reference").map((item) => rankAssertion(item, request.query, asOf, feedbackScores.get(`assertion:${item.id}`) ?? 0)).filter((item) => item.score >= .12 || item.reasons.includes("high_consequence")).sort((left, right) => right.score - left.score).slice(0, Math.max(1, Math.min(100, request.maxAssertions ?? 20))) : [];
127
+ }).filter((item) => scopeVisible(getAssertionScope(item.slotId), request)).filter((item) => applicabilityVisible(item.applicability, request)).filter((item) => (item.validFrom === void 0 || item.validFrom <= asOf) && (item.validTo === void 0 || item.validTo >= asOf)).filter((item) => item.authority !== "external_untrusted").filter((item) => item.sensitivity !== "secret" && item.sensitivity !== "regulated" && item.disclosurePolicy !== "ask_before_reference").filter((item) => item.status === "active" || isWorkingAssumption(item)).map((item) => rankAssertion(item, request.query, asOf, feedbackScores.get(`assertion:${item.id}`) ?? 0)).filter((item) => item.score >= .12 || item.reasons.includes("high_consequence")).sort((left, right) => right.score - left.score) : [];
128
+ const assertions = [...rankedAssertions.filter((item) => item.usage === "confirmed"), ...rankedAssertions.filter((item) => item.usage === "working_assumption")].slice(0, assertionLimit);
122
129
  const maxKnowledge = Math.max(0, Math.min(100, request.maxKnowledge ?? 12));
123
130
  const knowledge = request.includeKnowledge === false || maxKnowledge === 0 ? [] : searchKnowledgeItems({
124
131
  query: request.query,
@@ -153,8 +160,14 @@ function getAssertionScope(slotId) {
153
160
  function renderExecutionContext(context) {
154
161
  const sections = [];
155
162
  if (context.rules.length) sections.push(`Collaboration rules:\n${context.rules.map((rule) => `- ${rule.statement}`).join("\n")}`);
156
- if (context.assertions.length) sections.push(`Relevant user facts:\n${context.assertions.map((item) => `- ${item.assertion.statement}`).join("\n")}`);
157
- if (context.goals.length) sections.push(`Active goals:\n${context.goals.map((goal) => `- ${goal.title}: ${goal.desiredOutcome}`).join("\n")}`);
163
+ const confirmedAssertions = context.assertions.filter((item) => item.usage === "confirmed");
164
+ const workingAssumptions = context.assertions.filter((item) => item.usage === "working_assumption");
165
+ if (confirmedAssertions.length) sections.push(`Confirmed user context:\n${confirmedAssertions.map((item) => `- ${item.assertion.statement}`).join("\n")}`);
166
+ if (workingAssumptions.length) sections.push(`Working assumptions (may be wrong; adapt quietly, never present them as confirmed facts, and accept corrections immediately):\n${workingAssumptions.map((item) => `- ${item.assertion.statement} (confidence ${item.assertion.confidence.toFixed(2)})`).join("\n")}`);
167
+ const confirmedGoals = context.goals.filter((goal) => goal.usage === "confirmed");
168
+ const assumedGoals = context.goals.filter((goal) => goal.usage === "working_assumption");
169
+ if (confirmedGoals.length) sections.push(`Confirmed goals:\n${confirmedGoals.map((goal) => `- ${goal.title}: ${goal.desiredOutcome}`).join("\n")}`);
170
+ if (assumedGoals.length) sections.push(`Possible goals (not yet confirmed):\n${assumedGoals.map((goal) => `- ${goal.title}: ${goal.desiredOutcome}`).join("\n")}`);
158
171
  if (context.priorities.length) sections.push(`Current priorities:\n${context.priorities.map((item) => `- ${item.rank}: ${item.targetType}/${item.targetId}`).join("\n")}`);
159
172
  if (context.knowledge.length) sections.push(`Relevant knowledge:\n${context.knowledge.map((item) => `- ${item.content}`).join("\n")}`);
160
173
  return sections.join("\n\n");
@@ -10,6 +10,7 @@ export interface ExecutionRule {
10
10
  }
11
11
  export interface RankedExecutionAssertion {
12
12
  assertion: UserAssertion;
13
+ usage: 'confirmed' | 'working_assumption';
13
14
  score: number;
14
15
  reasons: string[];
15
16
  }
@@ -18,6 +19,7 @@ export interface ExecutionGoal {
18
19
  title: string;
19
20
  desiredOutcome: string;
20
21
  status: string;
22
+ usage: 'confirmed' | 'working_assumption';
21
23
  declaredImportance?: number;
22
24
  targetAt?: number;
23
25
  }
@@ -31,6 +31,7 @@ export declare function hydrateUserTurnForLlm(opts: {
31
31
  modelRef: string;
32
32
  }): Promise<LlmUserTurn>;
33
33
  export declare function setPendingTranscriptUserMessage(sessionKey: string, message: TranscriptUserMessage): void;
34
+ export declare function getPendingTranscriptUserText(sessionKey: string): string | undefined;
34
35
  export declare function takePendingTranscriptUserMessage(sessionKey: string): TranscriptUserMessage | undefined;
35
36
  export declare function clearPendingTranscriptUserMessage(sessionKey: string, message?: TranscriptUserMessage): void;
36
37
  export declare function pendingTranscriptReferencesMediaUri(sessionKey: string, uri: string): boolean;
@@ -144,6 +144,11 @@ function setPendingTranscriptUserMessage(sessionKey, message) {
144
144
  assertTranscriptUserMessage(message);
145
145
  pendingTranscriptBySession.set(sessionKey, message);
146
146
  }
147
+ function getPendingTranscriptUserText(sessionKey) {
148
+ const message = pendingTranscriptBySession.get(sessionKey);
149
+ if (!message) return void 0;
150
+ return stripRuntimeUserMessageEnvelope(messageTextForPendingCompare(message)).trim();
151
+ }
147
152
  function takePendingTranscriptUserMessage(sessionKey) {
148
153
  const msg = pendingTranscriptBySession.get(sessionKey);
149
154
  pendingTranscriptBySession.delete(sessionKey);
@@ -171,4 +176,4 @@ function transformUserMessageForPersistence(sessionKey, message) {
171
176
  return message;
172
177
  }
173
178
  //#endregion
174
- export { assertTranscriptUserMessage, buildTranscriptUserMessage, clearPendingTranscriptUserMessage, hydrateUserTurnForLlm, pendingTranscriptReferencesMediaUri, setPendingTranscriptUserMessage, takePendingTranscriptUserMessage, transformUserMessageForPersistence };
179
+ export { assertTranscriptUserMessage, buildTranscriptUserMessage, clearPendingTranscriptUserMessage, getPendingTranscriptUserText, hydrateUserTurnForLlm, pendingTranscriptReferencesMediaUri, setPendingTranscriptUserMessage, takePendingTranscriptUserMessage, transformUserMessageForPersistence };
@@ -13,10 +13,11 @@ function buildMemorySection(params) {
13
13
  const lines = [
14
14
  "## Context and memory",
15
15
  "",
16
- "Relevant user facts, goals, priorities, collaboration rules, and task knowledge are selected for each turn.",
16
+ "Confirmed user context, labeled working assumptions, goals, priorities, collaboration rules, and task knowledge are selected for each turn.",
17
17
  "When exact or additional context is needed:"
18
18
  ];
19
19
  if (names.has("user_context_search")) lines.push("- Use `user_context_search` for user identity, preferences, routines, and current state.");
20
+ if (names.has("user_context_update")) lines.push("- When the current user explicitly corrects, confirms, rejects, or asks to forget an existing user assertion, use `user_context_update` immediately and include an exact quote as evidence. Never use it for an inference of your own.");
20
21
  if (names.has("knowledge_search")) lines.push("- Use `knowledge_search` for project facts, decisions, lessons, commitments, and open questions.");
21
22
  if (names.has("session_recall")) lines.push("- Use `session_recall` for exact raw content from the current session.");
22
23
  if (names.has("session_search")) lines.push("- Use `session_search` for other conversations.");
@@ -17,6 +17,7 @@ const CORE_TOOL_ORDER = [
17
17
  "publish_artifacts",
18
18
  "user_context_search",
19
19
  "user_context_get",
20
+ "user_context_update",
20
21
  "knowledge_search",
21
22
  "knowledge_get",
22
23
  "knowledge_write",
@@ -57,6 +58,7 @@ const CORE_TOOL_SUMMARIES = {
57
58
  publish_artifacts: "Publish final generated files as durable chat deliverables",
58
59
  user_context_search: "Search typed user facts, preferences, routines, and current state",
59
60
  user_context_get: "Read one typed user assertion with its scope and authority",
61
+ user_context_update: "Apply an explicit user confirmation, correction, rejection, or forget request to an existing assertion",
60
62
  knowledge_search: "Search scoped project, workspace, and session knowledge",
61
63
  knowledge_get: "Read one knowledge item returned by search",
62
64
  knowledge_write: "Store a scoped knowledge candidate with provenance",
@@ -28,6 +28,7 @@ const DELEGATE_BLOCKED_TOOLS = new Set([
28
28
  "session_search",
29
29
  "user_context_search",
30
30
  "user_context_get",
31
+ "user_context_update",
31
32
  "knowledge_search",
32
33
  "knowledge_get",
33
34
  "knowledge_write",
@@ -19,7 +19,7 @@ import { createListDirTool } from "./list-dir.js";
19
19
  import { createPublishArtifactsTool } from "./publish-artifacts.js";
20
20
  import { createExecCommandTool } from "./exec-command.js";
21
21
  import { createApplyPatchTool } from "./apply-patch.js";
22
- import { createUserContextGetTool, createUserContextSearchTool } from "./user-context-tool.js";
22
+ import { createUserContextGetTool, createUserContextSearchTool, createUserContextUpdateTool } from "./user-context-tool.js";
23
23
  import { createKnowledgeGetTool, createKnowledgeSearchTool, createKnowledgeWriteTool } from "./knowledge-memory-tool.js";
24
24
  import { createSessionSearchTool } from "./session-search-tool.js";
25
25
  import { createSessionRecallTool } from "./session-recall-tool.js";
@@ -40,6 +40,7 @@ import { BrowserRuntime } from "../../browser/runtime/browser-runtime.js";
40
40
  import { createBrowserDriver } from "../../browser/drivers/create-driver.js";
41
41
  import { checkBrowserReadiness } from "../../browser/readiness.js";
42
42
  import "../../browser/index.js";
43
+ import { getPendingTranscriptUserText } from "../inbound/attachment-pipeline.js";
43
44
  import { createDelegateTool } from "./delegate-tool.js";
44
45
  import { createWorkflowTool } from "./workflow-tool.js";
45
46
  import { createAutomationTool } from "./automation-tool.js";
@@ -324,6 +325,18 @@ var AgentToolsFactory = class AgentToolsFactory {
324
325
  getProjectId: currentProjectId,
325
326
  canRead: () => currentAccess().userModel
326
327
  }),
328
+ createUserContextUpdateTool({
329
+ agentId: resolvedAgentId,
330
+ workspaceId: workspace,
331
+ getSessionId: currentSessionKey,
332
+ getProjectId: currentProjectId,
333
+ canRead: () => currentAccess().userModel,
334
+ canWrite: () => currentAccess().userModel,
335
+ getCurrentUserText: () => {
336
+ const sessionKey = currentSessionKey();
337
+ return sessionKey ? getPendingTranscriptUserText(sessionKey) : void 0;
338
+ }
339
+ }),
327
340
  createKnowledgeSearchTool({
328
341
  agentId: resolvedAgentId,
329
342
  workspaceId: workspace,
@@ -5,7 +5,7 @@ export { createWriteFileTool, writeFileTool } from './write.js';
5
5
  export { createListDirTool, listDirTool } from './list-dir.js';
6
6
  export { createExecCommandTool, type ExecCommandDetails, type ExecCommandUpdateDetails, } from './exec-command.js';
7
7
  export { createApplyPatchTool, type AppliedPatchChange, type ApplyPatchDetails, } from './apply-patch.js';
8
- export { createUserContextSearchTool, createUserContextGetTool, type UserContextToolOptions, } from './user-context-tool.js';
8
+ export { createUserContextSearchTool, createUserContextGetTool, createUserContextUpdateTool, type UserContextToolOptions, } from './user-context-tool.js';
9
9
  export { createKnowledgeSearchTool, createKnowledgeGetTool, createKnowledgeWriteTool, type KnowledgeToolOptions, } from './knowledge-memory-tool.js';
10
10
  export { createSessionSearchTool } from './session-search-tool.js';
11
11
  export { createSessionRecallTool, type SessionRecallToolDeps } from './session-recall-tool.js';
@@ -8,7 +8,7 @@ import { createPublishArtifactsTool } from "./publish-artifacts.js";
8
8
  import { createExecCommandTool } from "./exec-command.js";
9
9
  import { fuzzyFindText, generateDiffString, normalizeForFuzzyMatch, normalizeToLF, restoreLineEndings, stripBom } from "./edit-diff.js";
10
10
  import { createApplyPatchTool } from "./apply-patch.js";
11
- import { createUserContextGetTool, createUserContextSearchTool } from "./user-context-tool.js";
11
+ import { createUserContextGetTool, createUserContextSearchTool, createUserContextUpdateTool } from "./user-context-tool.js";
12
12
  import { createKnowledgeGetTool, createKnowledgeSearchTool, createKnowledgeWriteTool } from "./knowledge-memory-tool.js";
13
13
  import { createSessionSearchTool } from "./session-search-tool.js";
14
14
  import { createSessionRecallTool } from "./session-recall-tool.js";
@@ -43,4 +43,4 @@ import { createDesktopPetTool } from "./desktop-pet-tool.js";
43
43
  import { createManagedJobTool } from "./managed-job-tool.js";
44
44
  import { createImageTool } from "./image-tool.js";
45
45
  import { createImageGenerateTool, resolveImageGenerationModelConfigForTool } from "./image-generate-tool.js";
46
- export { BrowserRuntime, DEFAULT_DELEGATE_TOOLS, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, DEFAULT_TOOL_METADATA, DEFAULT_WEB_EXTRACT_MAX_LENGTH, DELEGATE_BLOCKED_TOOLS, GREP_MAX_LINE_LENGTH, MAX_RAW_HTML_CHARS_FOR_WEB_EXTRACT, TodoStore, ToolConcurrencyController, assertBrowserUrlAllowed, createApplyPatchTool, createAutomationTool, createBrowserAutomationTool, createClarifyTool, createCreateShareTool, createDelegateTool, createDesktopPetTool, createExecCommandTool, createFindTool, createGrepTool, createImageGenerateTool, createImageTool, createKnowledgeGetTool, createKnowledgeSearchTool, createKnowledgeWriteTool, createListDirTool, createManagedJobTool, createMemoryMaintenanceTool, createMessageTool, createPublishArtifactsTool, createReadFileTool, createReadMediaTool, createSendMediaTool, createSessionRecallTool, createSessionSearchTool, createSessionStatusTool, createSkillInstallTool, createSkillManageTool, createSkillViewTool, createSkillsListTool, createSkillsMarketplaceSearchTool, createTodoTool, createToolManualTool, createUpdatePlanTool, createUserContextGetTool, createUserContextSearchTool, createWebExtractTool, createWebFetchTool, createWebSearchTool, createWorkflowTool, createWriteFileTool, createXopcUseTool, findTool, formatSize, fuzzyFindText, generateDiffString, getToolMetadata, grepTool, isShareToolAvailable, listDirTool, normalizeForFuzzyMatch, normalizeToLF, resolveImageGenerationModelConfigForTool, resolveImageModelConfigForTool, resolveToolLockMode, restoreLineEndings, stripBom, stripHtmlBoilerplate, truncateHead, truncateLine, truncateTail, writeFileTool };
46
+ export { BrowserRuntime, DEFAULT_DELEGATE_TOOLS, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, DEFAULT_TOOL_METADATA, DEFAULT_WEB_EXTRACT_MAX_LENGTH, DELEGATE_BLOCKED_TOOLS, GREP_MAX_LINE_LENGTH, MAX_RAW_HTML_CHARS_FOR_WEB_EXTRACT, TodoStore, ToolConcurrencyController, assertBrowserUrlAllowed, createApplyPatchTool, createAutomationTool, createBrowserAutomationTool, createClarifyTool, createCreateShareTool, createDelegateTool, createDesktopPetTool, createExecCommandTool, createFindTool, createGrepTool, createImageGenerateTool, createImageTool, createKnowledgeGetTool, createKnowledgeSearchTool, createKnowledgeWriteTool, createListDirTool, createManagedJobTool, createMemoryMaintenanceTool, createMessageTool, createPublishArtifactsTool, createReadFileTool, createReadMediaTool, createSendMediaTool, createSessionRecallTool, createSessionSearchTool, createSessionStatusTool, createSkillInstallTool, createSkillManageTool, createSkillViewTool, createSkillsListTool, createSkillsMarketplaceSearchTool, createTodoTool, createToolManualTool, createUpdatePlanTool, createUserContextGetTool, createUserContextSearchTool, createUserContextUpdateTool, createWebExtractTool, createWebFetchTool, createWebSearchTool, createWorkflowTool, createWriteFileTool, createXopcUseTool, findTool, formatSize, fuzzyFindText, generateDiffString, getToolMetadata, grepTool, isShareToolAvailable, listDirTool, normalizeForFuzzyMatch, normalizeToLF, resolveImageGenerationModelConfigForTool, resolveImageModelConfigForTool, resolveToolLockMode, restoreLineEndings, stripBom, stripHtmlBoilerplate, truncateHead, truncateLine, truncateTail, writeFileTool };
@@ -5,6 +5,9 @@ export interface UserContextToolOptions {
5
5
  getSessionId: () => string | undefined;
6
6
  getProjectId?: () => string | undefined;
7
7
  canRead: () => boolean;
8
+ canWrite?: () => boolean;
9
+ getCurrentUserText?: () => string | undefined;
8
10
  }
9
11
  export declare function createUserContextSearchTool(options: UserContextToolOptions): AgentTool;
10
12
  export declare function createUserContextGetTool(options: UserContextToolOptions): AgentTool;
13
+ export declare function createUserContextUpdateTool(options: UserContextToolOptions): AgentTool;
@@ -1,5 +1,6 @@
1
1
  import { retrievalLexicalSimilarity } from "../../retrieval/textFeatures.js";
2
- import { getAssertionSlot, getUserAssertion, listUserAssertions } from "../../user-model/repository.js";
2
+ import { getAssertionSlot, getUserAssertion, listUserAssertions, reconcileAssertion, setAssertionStatus } from "../../user-model/repository.js";
3
+ import { isWorkingAssumption } from "../../user-model/usage-policy.js";
3
4
  import "../../user-model/index.js";
4
5
  import { Type } from "@sinclair/typebox";
5
6
  //#region src/agent/tools/user-context-tool.ts
@@ -11,12 +12,27 @@ const SearchSchema = Type.Object({
11
12
  }))
12
13
  });
13
14
  const GetSchema = Type.Object({ id: Type.String() });
15
+ const UpdateSchema = Type.Object({
16
+ id: Type.String(),
17
+ action: Type.Union([
18
+ Type.Literal("confirm"),
19
+ Type.Literal("correct"),
20
+ Type.Literal("reject"),
21
+ Type.Literal("forget"),
22
+ Type.Literal("review")
23
+ ]),
24
+ replacement: Type.Optional(Type.String({ maxLength: 500 })),
25
+ userEvidence: Type.String({
26
+ minLength: 1,
27
+ maxLength: 500
28
+ })
29
+ });
14
30
  function visible(options, slotId) {
15
31
  const scope = getAssertionSlot(slotId)?.scope;
16
32
  return scope?.type === "global" || scope?.type === "agent" && scope.id === options.agentId || scope?.type === "workspace" && scope.id === options.workspaceId || scope?.type === "project" && scope.id === options.getProjectId?.() || scope?.type === "session" && scope.id === options.getSessionId();
17
33
  }
18
34
  function referenceable(assertion) {
19
- return assertion.status === "active" && assertion.authority !== "external_untrusted" && assertion.sensitivity !== "secret" && assertion.sensitivity !== "regulated" && assertion.disclosurePolicy !== "ask_before_reference";
35
+ return (assertion.status === "active" || isWorkingAssumption(assertion)) && assertion.authority !== "external_untrusted" && assertion.sensitivity !== "secret" && assertion.sensitivity !== "regulated" && assertion.disclosurePolicy !== "ask_before_reference";
20
36
  }
21
37
  function createUserContextSearchTool(options) {
22
38
  return {
@@ -34,7 +50,7 @@ function createUserContextSearchTool(options) {
34
50
  };
35
51
  const input = raw;
36
52
  const results = listUserAssertions({
37
- statuses: ["active"],
53
+ statuses: ["active", "candidate"],
38
54
  limit: 1e3
39
55
  }).filter((assertion) => visible(options, assertion.slotId)).filter(referenceable).map((assertion) => ({
40
56
  assertion,
@@ -94,5 +110,132 @@ function createUserContextGetTool(options) {
94
110
  }
95
111
  };
96
112
  }
113
+ function createUserContextUpdateTool(options) {
114
+ return {
115
+ name: "user_context_update",
116
+ label: "User Context Update",
117
+ description: "Confirm, correct, reject, forget, or flag an existing user assertion. Use only when the current user explicitly confirms or requests the change; userEvidence must quote that request.",
118
+ parameters: UpdateSchema,
119
+ async execute(_toolCallId, raw) {
120
+ if (!options.canRead() || !options.canWrite?.()) return {
121
+ content: [{
122
+ type: "text",
123
+ text: "User-context updates are disabled for this session."
124
+ }],
125
+ details: { error: "user_context_update_disabled" }
126
+ };
127
+ const input = raw;
128
+ const current = getUserAssertion(input.id);
129
+ const slot = current ? getAssertionSlot(current.slotId) : void 0;
130
+ if (!current || !slot || !visible(options, current.slotId)) return {
131
+ content: [{
132
+ type: "text",
133
+ text: `User assertion not found: ${input.id}`
134
+ }],
135
+ details: {
136
+ error: "assertion_not_found",
137
+ id: input.id
138
+ }
139
+ };
140
+ const evidence = input.userEvidence.trim();
141
+ if (!evidence) return {
142
+ content: [{
143
+ type: "text",
144
+ text: "A quote from the current user message is required."
145
+ }],
146
+ details: { error: "user_evidence_required" }
147
+ };
148
+ const currentUserText = options.getCurrentUserText?.();
149
+ if (options.getCurrentUserText && (!currentUserText || !currentUserText.includes(evidence))) return {
150
+ content: [{
151
+ type: "text",
152
+ text: "userEvidence must be an exact quote from the current user message."
153
+ }],
154
+ details: { error: "user_evidence_mismatch" }
155
+ };
156
+ try {
157
+ if (input.action === "correct") {
158
+ const replacement = input.replacement?.trim();
159
+ if (!replacement) return {
160
+ content: [{
161
+ type: "text",
162
+ text: "A replacement is required for correction."
163
+ }],
164
+ details: { error: "replacement_required" }
165
+ };
166
+ const receipt = {
167
+ action: "corrected",
168
+ assertion: reconcileAssertion({
169
+ subject: slot.subject,
170
+ predicate: slot.predicate,
171
+ cardinality: slot.cardinality,
172
+ scope: slot.scope,
173
+ kind: current.kind,
174
+ value: replacement,
175
+ normalizedValue: replacement.toLocaleLowerCase(),
176
+ statement: replacement,
177
+ authority: "user_explicit",
178
+ confidence: 1,
179
+ ...current.declaredImportance === void 0 ? {} : { declaredImportance: current.declaredImportance },
180
+ inferredImportance: current.inferredImportance,
181
+ consequence: current.consequence,
182
+ actionability: current.actionability,
183
+ volatility: current.volatility,
184
+ sensitivity: current.sensitivity,
185
+ disclosurePolicy: current.disclosurePolicy,
186
+ applicability: current.applicability,
187
+ observedAt: Date.now(),
188
+ createdBy: "user",
189
+ correctionOfAssertionId: current.id
190
+ }).assertion,
191
+ previousAssertionId: current.id,
192
+ userEvidence: evidence
193
+ };
194
+ return {
195
+ content: [{
196
+ type: "text",
197
+ text: JSON.stringify(receipt, null, 2)
198
+ }],
199
+ details: receipt
200
+ };
201
+ }
202
+ const status = {
203
+ confirm: "active",
204
+ reject: "rejected",
205
+ forget: "archived",
206
+ review: "needs_review"
207
+ }[input.action];
208
+ const assertion = setAssertionStatus(current.id, status, {
209
+ actor: "user",
210
+ reason: `User requested ${input.action}: ${evidence}`
211
+ });
212
+ const receipt = {
213
+ action: input.action,
214
+ assertion,
215
+ userEvidence: evidence
216
+ };
217
+ return {
218
+ content: [{
219
+ type: "text",
220
+ text: JSON.stringify(receipt, null, 2)
221
+ }],
222
+ details: receipt
223
+ };
224
+ } catch (error) {
225
+ const message = error instanceof Error ? error.message : String(error);
226
+ return {
227
+ content: [{
228
+ type: "text",
229
+ text: message
230
+ }],
231
+ details: {
232
+ error: "user_context_update_failed",
233
+ message
234
+ }
235
+ };
236
+ }
237
+ }
238
+ };
239
+ }
97
240
  //#endregion
98
- export { createUserContextGetTool, createUserContextSearchTool };
241
+ export { createUserContextGetTool, createUserContextSearchTool, createUserContextUpdateTool };
@@ -9,12 +9,12 @@ import "../../storage/sqlite/index.js";
9
9
  import { ObjectLinkService } from "../../activity/service.js";
10
10
  import "../../activity/index.js";
11
11
  import { getDefaultAgentId, init_resolve_route } from "../../routing/resolve-route.js";
12
- import { CreateAutomationSchema, UpdateAutomationSchema } from "../../automations/domain/validation.js";
13
- import "../../automations/index.js";
14
12
  import { TaskRepository } from "../../tasks/task-repository.js";
15
13
  import { TaskReadModelProjector } from "../../tasks/task-read-model-projector.js";
16
14
  import { isValidProjectAgentId, normalizeProjectAgentId, resolveProjectAgentId } from "../../projects/project-agent.js";
17
15
  import "../../projects/index.js";
16
+ import { CreateAutomationSchema, UpdateAutomationSchema } from "../../automations/domain/validation.js";
17
+ import "../../automations/index.js";
18
18
  import { TaskContextRepository } from "../../tasks/task-context-repository.js";
19
19
  import { TaskDependencyError, TaskDependencyService } from "../../tasks/task-dependency-service.js";
20
20
  import { TaskApplicationService } from "../../tasks/task-application-service.js";
@@ -2,7 +2,7 @@ import { requireXopcDatabase } from "../../storage/sqlite/connection.js";
2
2
  import { runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
3
3
  import { DurableState } from "../../storage/sqlite/durable-state.js";
4
4
  import { buildWorkflowDefinition } from "../../workflows/domain/definition-utils.js";
5
- import { validateWorkflowGraph } from "../../workflows/domain/validation.js";
5
+ import { validateWorkflowDefinitionInput } from "../../workflows/domain/validation.js";
6
6
  import { BUILTIN_WORKFLOWS } from "./builtins/index.js";
7
7
  //#region src/agent/workflow/catalog.ts
8
8
  const NAME_RE = /^[a-z][a-z0-9_-]*$/;
@@ -26,7 +26,11 @@ function createWorkflowCatalog() {
26
26
  const save = (input) => {
27
27
  const name = input.name.trim();
28
28
  requireValidName(name);
29
- const validation = validateWorkflowGraph(input.graph);
29
+ const validation = validateWorkflowDefinitionInput({
30
+ name,
31
+ graph: input.graph,
32
+ manifest: input.manifest
33
+ });
30
34
  if (!validation.valid) throw new Error(validation.errors.map((issue) => issue.message).join(" "));
31
35
  requireXopcDatabase();
32
36
  return runSqliteWriteTransaction(() => {
@@ -48,7 +48,7 @@ function formatWorkflowListContent(entries) {
48
48
  const workflowsCommand = {
49
49
  id: "system.workflows",
50
50
  name: "workflows",
51
- description: "List saved workflows (built-in + ~/.xopc/workflows/)",
51
+ description: "List built-in and saved workflows",
52
52
  category: "system",
53
53
  scope: [
54
54
  "global",
@@ -57,7 +57,7 @@ function connectedItemsForUnderstanding(items) {
57
57
  });
58
58
  }
59
59
  function isPortraitCandidate(candidate) {
60
- return candidate.category === "preference" || candidate.category === "routine";
60
+ return candidate.category === "preference" || candidate.category === "routine" || candidate.category === "communication";
61
61
  }
62
62
  function durableEvidence(candidate, items) {
63
63
  const evidence = [...new Set(candidate.evidenceRefs ?? [])].flatMap((ref) => items.get(ref) ?? []);
@@ -120,7 +120,7 @@ async function deriveConnectedSourceUnderstanding(input) {
120
120
  type: "agent",
121
121
  id: input.agentId
122
122
  },
123
- kind: candidate.category,
123
+ kind: candidate.category === "communication" ? "preference" : candidate.category,
124
124
  value: candidate.statement,
125
125
  normalizedValue: candidate.statement.toLocaleLowerCase(),
126
126
  statement: candidate.statement,
@@ -129,8 +129,8 @@ async function deriveConnectedSourceUnderstanding(input) {
129
129
  inferredImportance: .65,
130
130
  consequence: "medium",
131
131
  actionability: .6,
132
- volatility: candidate.category === "routine" ? "slow" : "stable",
133
- sensitivity: "personal",
132
+ volatility: candidate.category === "routine" || candidate.category === "communication" ? "slow" : "stable",
133
+ sensitivity: "normal",
134
134
  disclosurePolicy: "referenceable",
135
135
  observedAt: evidenceItem.occurredAt ?? evidenceItem.modifiedAt ?? Date.now(),
136
136
  createdBy: "connector",