@circuitwall/jarela 2.2.1 → 2.3.0

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 (651) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +6 -5
  3. package/.next/standalone/.next/build-manifest.json +2 -2
  4. package/.next/standalone/.next/prerender-manifest.json +3 -3
  5. package/.next/standalone/.next/routes-manifest.json +8 -0
  6. package/.next/standalone/.next/server/app/_global-error/page.js +68 -68
  7. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_not-found/page.js +76 -76
  14. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next/standalone/.next/server/app/_not-found.html +2 -2
  16. package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
  17. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  18. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  19. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  20. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  21. package/.next/standalone/.next/server/app/api/v1/access/[identity]/route.js +93 -93
  22. package/.next/standalone/.next/server/app/api/v1/access/route.js +169 -169
  23. package/.next/standalone/.next/server/app/api/v1/agents/[id]/compact/route.js +82 -56
  24. package/.next/standalone/.next/server/app/api/v1/agents/[id]/compact/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/v1/agents/[id]/display-filters/route.js +122 -122
  26. package/.next/standalone/.next/server/app/api/v1/agents/[id]/route.js +100 -100
  27. package/.next/standalone/.next/server/app/api/v1/agents/[id]/thread/route.js +753 -753
  28. package/.next/standalone/.next/server/app/api/v1/agents/route.js +65 -65
  29. package/.next/standalone/.next/server/app/api/v1/allowed-sites/[hostname]/route.js +364 -364
  30. package/.next/standalone/.next/server/app/api/v1/allowed-sites/route.js +802 -802
  31. package/.next/standalone/.next/server/app/api/v1/artifacts/lifecycle/route.js +2 -2
  32. package/.next/standalone/.next/server/app/api/v1/attachments/files/route.js +49 -49
  33. package/.next/standalone/.next/server/app/api/v1/attachments/images/route.js +910 -910
  34. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js +589 -16
  35. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js.nft.json +1 -1
  36. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/ignores/[remote_jid]/route.js +23 -23
  37. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/ignores/route.js +30 -30
  38. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js +703 -130
  39. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js.nft.json +1 -1
  40. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js +708 -135
  41. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js.nft.json +1 -1
  42. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js +802 -229
  43. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js.nft.json +1 -1
  44. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/routes/[route_id]/route.js +739 -739
  45. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/routes/route.js +1035 -1035
  46. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js +679 -106
  47. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js.nft.json +1 -1
  48. package/.next/standalone/.next/server/app/api/v1/bridges/kinds/route.js +804 -804
  49. package/.next/standalone/.next/server/app/api/v1/bridges/route.js +700 -700
  50. package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js +9 -9
  51. package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js.nft.json +1 -1
  52. package/.next/standalone/.next/server/app/api/v1/config/route.js +85 -85
  53. package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js +709 -709
  54. package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js.nft.json +1 -1
  55. package/.next/standalone/.next/server/app/api/v1/credentials/route.js +2 -2
  56. package/.next/standalone/.next/server/app/api/v1/credentials/route.js.nft.json +1 -1
  57. package/.next/standalone/.next/server/app/api/v1/dashboard/currency/route.js +10 -10
  58. package/.next/standalone/.next/server/app/api/v1/dashboard/metrics/route.js +784 -784
  59. package/.next/standalone/.next/server/app/api/v1/dashboard/pricing/route.js +23 -23
  60. package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js +86 -86
  61. package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js.nft.json +1 -1
  62. package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js +57 -57
  63. package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js.nft.json +1 -1
  64. package/.next/standalone/.next/server/app/api/v1/documents/search/route.js +523 -523
  65. package/.next/standalone/.next/server/app/api/v1/documents/settings/route.js +44 -44
  66. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js +65 -65
  67. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js.nft.json +1 -1
  68. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js +122 -122
  69. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js.nft.json +1 -1
  70. package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js +37 -37
  71. package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js.nft.json +1 -1
  72. package/.next/standalone/.next/server/app/api/v1/env/route.js +9 -9
  73. package/.next/standalone/.next/server/app/api/v1/env-sync/allowlist/route.js +368 -368
  74. package/.next/standalone/.next/server/app/api/v1/env-sync/route.js +44 -44
  75. package/.next/standalone/.next/server/app/api/v1/events/route.js +751 -178
  76. package/.next/standalone/.next/server/app/api/v1/events/route.js.nft.json +1 -1
  77. package/.next/standalone/.next/server/app/api/v1/events/test/route.js +77 -77
  78. package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js +763 -763
  79. package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js.nft.json +1 -1
  80. package/.next/standalone/.next/server/app/api/v1/extension/browser/activate/route.js +44 -44
  81. package/.next/standalone/.next/server/app/api/v1/extension/browser/foreground/route.js +9 -9
  82. package/.next/standalone/.next/server/app/api/v1/extension/browser/history/route.js +65 -65
  83. package/.next/standalone/.next/server/app/api/v1/extension/browser/poll/route.js +34 -34
  84. package/.next/standalone/.next/server/app/api/v1/extension/browser/progress/route.js +204 -204
  85. package/.next/standalone/.next/server/app/api/v1/extension/browser/result/route.js +133 -133
  86. package/.next/standalone/.next/server/app/api/v1/extension/browser/retry/route.js +106 -106
  87. package/.next/standalone/.next/server/app/api/v1/extension/browser/status/route.js +114 -114
  88. package/.next/standalone/.next/server/app/api/v1/extension/browser/tabs/route.js +134 -134
  89. package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js +690 -690
  90. package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js.nft.json +1 -1
  91. package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js +93 -93
  92. package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js.nft.json +1 -1
  93. package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js +9 -9
  94. package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js.nft.json +1 -1
  95. package/.next/standalone/.next/server/app/api/v1/extensions/route.js +185 -185
  96. package/.next/standalone/.next/server/app/api/v1/extensions/route.js.nft.json +1 -1
  97. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js +171 -171
  98. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js.nft.json +1 -1
  99. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js +396 -396
  100. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js.nft.json +1 -1
  101. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js +212 -212
  102. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js.nft.json +1 -1
  103. package/.next/standalone/.next/server/app/api/v1/files/[name]/route.js +235 -235
  104. package/.next/standalone/.next/server/app/api/v1/fs/browse/route.js +26 -26
  105. package/.next/standalone/.next/server/app/api/v1/harnesses/[id]/route.js +221 -221
  106. package/.next/standalone/.next/server/app/api/v1/harnesses/default/route.js +58 -58
  107. package/.next/standalone/.next/server/app/api/v1/harnesses/route.js +72 -72
  108. package/.next/standalone/.next/server/app/api/v1/health/probes/route.js +9 -9
  109. package/.next/standalone/.next/server/app/api/v1/health/probes/route.js.nft.json +1 -1
  110. package/.next/standalone/.next/server/app/api/v1/health/route.js +772 -772
  111. package/.next/standalone/.next/server/app/api/v1/integrations/[name]/route.js +133 -133
  112. package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js +9 -9
  113. package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js.nft.json +1 -1
  114. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/callback/route.js +363 -363
  115. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/start/route.js +233 -233
  116. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/status/route.js +682 -682
  117. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/callback/route.js +879 -879
  118. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/start/route.js +108 -108
  119. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/status/route.js +952 -952
  120. package/.next/standalone/.next/server/app/api/v1/integrations/route.js +216 -216
  121. package/.next/standalone/.next/server/app/api/v1/lifecycle/adoption/route.js +864 -847
  122. package/.next/standalone/.next/server/app/api/v1/lifecycle/adoption/route.js.nft.json +1 -1
  123. package/.next/standalone/.next/server/app/api/v1/local-file/route.js +26 -26
  124. package/.next/standalone/.next/server/app/api/v1/logs/route.js +70 -70
  125. package/.next/standalone/.next/server/app/api/v1/maps/embed/route.js +72 -72
  126. package/.next/standalone/.next/server/app/api/v1/mcp-servers/[name]/route.js +979 -979
  127. package/.next/standalone/.next/server/app/api/v1/mcp-servers/registry/route.js +196 -196
  128. package/.next/standalone/.next/server/app/api/v1/mcp-servers/route.js +2 -2
  129. package/.next/standalone/.next/server/app/api/v1/memory/[namespace]/[key]/route.js +381 -381
  130. package/.next/standalone/.next/server/app/api/v1/memory/policy/route.js +79 -79
  131. package/.next/standalone/.next/server/app/api/v1/memory/route.js +51 -51
  132. package/.next/standalone/.next/server/app/api/v1/memory/search/route.js +131 -131
  133. package/.next/standalone/.next/server/app/api/v1/models/[name]/compact-threads/route.js +374 -369
  134. package/.next/standalone/.next/server/app/api/v1/models/[name]/compact-threads/route.js.nft.json +1 -1
  135. package/.next/standalone/.next/server/app/api/v1/models/[name]/route.js +143 -143
  136. package/.next/standalone/.next/server/app/api/v1/models/route.js +543 -543
  137. package/.next/standalone/.next/server/app/api/v1/packages/catalog/route.js +445 -445
  138. package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js +120 -120
  139. package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js.nft.json +1 -1
  140. package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js +234 -234
  141. package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js.nft.json +1 -1
  142. package/.next/standalone/.next/server/app/api/v1/packages/install/route.js +407 -407
  143. package/.next/standalone/.next/server/app/api/v1/packages/install/route.js.nft.json +1 -1
  144. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js +37 -37
  145. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js.nft.json +1 -1
  146. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js +107 -107
  147. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js.nft.json +1 -1
  148. package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js +228 -228
  149. package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js.nft.json +1 -1
  150. package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js +9 -9
  151. package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js.nft.json +1 -1
  152. package/.next/standalone/.next/server/app/api/v1/packages/route.js +148 -148
  153. package/.next/standalone/.next/server/app/api/v1/packages/route.js.nft.json +1 -1
  154. package/.next/standalone/.next/server/app/api/v1/page-capture/route.js +787 -787
  155. package/.next/standalone/.next/server/app/api/v1/page-capture/route.js.nft.json +1 -1
  156. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js +507 -507
  157. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js.nft.json +1 -1
  158. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js +181 -181
  159. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js.nft.json +1 -1
  160. package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js +258 -258
  161. package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js.nft.json +1 -1
  162. package/.next/standalone/.next/server/app/api/v1/profile/location/route.js +30 -30
  163. package/.next/standalone/.next/server/app/api/v1/profile/route.js +164 -164
  164. package/.next/standalone/.next/server/app/api/v1/providers/[provider]/models/route.js +44 -44
  165. package/.next/standalone/.next/server/app/api/v1/providers/[provider]/probe/route.js +9 -9
  166. package/.next/standalone/.next/server/app/api/v1/providers/github-copilot/auth/route.js +164 -164
  167. package/.next/standalone/.next/server/app/api/v1/providers/route.js +94 -94
  168. package/.next/standalone/.next/server/app/api/v1/proxy-config/route.js +450 -450
  169. package/.next/standalone/.next/server/app/api/v1/redaction/init/route.js +37 -37
  170. package/.next/standalone/.next/server/app/api/v1/redaction/route.js +58 -58
  171. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/route.js +600 -600
  172. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js +44 -44
  173. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js.nft.json +1 -1
  174. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/route.js +732 -732
  175. package/.next/standalone/.next/server/app/api/v1/security/idle-timeout/route.js +359 -359
  176. package/.next/standalone/.next/server/app/api/v1/security/pin/route.js +197 -197
  177. package/.next/standalone/.next/server/app/api/v1/security/state/route.js +51 -51
  178. package/.next/standalone/.next/server/app/api/v1/security/unlock/route.js +176 -176
  179. package/.next/standalone/.next/server/app/api/v1/security/verify-pin/route.js +190 -190
  180. package/.next/standalone/.next/server/app/api/v1/setup/test-key/route.js +26 -26
  181. package/.next/standalone/.next/server/app/api/v1/skills/[id]/route.js +770 -770
  182. package/.next/standalone/.next/server/app/api/v1/skills/repos/[id]/route.js +115 -115
  183. package/.next/standalone/.next/server/app/api/v1/skills/repos/route.js +327 -327
  184. package/.next/standalone/.next/server/app/api/v1/skills/route.js +870 -870
  185. package/.next/standalone/.next/server/app/api/v1/system/abort/route.js +838 -808
  186. package/.next/standalone/.next/server/app/api/v1/system/restart/route.js +177 -177
  187. package/.next/standalone/.next/server/app/api/v1/system/restart/route.js.nft.json +1 -1
  188. package/.next/standalone/.next/server/app/api/v1/tailscale/route.js +164 -164
  189. package/.next/standalone/.next/server/app/api/v1/tasks/[agent_id]/route.js +115 -115
  190. package/.next/standalone/.next/server/app/api/v1/tasks/route.js +23 -23
  191. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/activity/route.js +1429 -0
  192. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/activity/route.js.nft.json +1 -0
  193. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/activity/route_client-reference-manifest.js +1 -0
  194. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/context-pin/route.js +635 -634
  195. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/context-pin/route.js.nft.json +1 -1
  196. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/route.js +53 -439
  197. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/route.js.nft.json +1 -1
  198. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js +172 -172
  199. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js.nft.json +1 -1
  200. package/.next/standalone/.next/server/app/api/v1/threads/route.js +908 -908
  201. package/.next/standalone/.next/server/app/api/v1/tools/route.js +2 -2
  202. package/.next/standalone/.next/server/app/api/v1/tools/route.js.nft.json +1 -1
  203. package/.next/standalone/.next/server/app/api/v1/update/apply/route.js +17 -17
  204. package/.next/standalone/.next/server/app/api/v1/update/apply/route.js.nft.json +1 -1
  205. package/.next/standalone/.next/server/app/api/v1/update/route.js +570 -570
  206. package/.next/standalone/.next/server/app/api/v1/voice/transcribe/route.js +224 -224
  207. package/.next/standalone/.next/server/app/api/v1/voice/tts/route.js +975 -975
  208. package/.next/standalone/.next/server/app/api/v1/watchers/[id]/route.js +23 -23
  209. package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js +72 -72
  210. package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js.nft.json +1 -1
  211. package/.next/standalone/.next/server/app/api/v1/watchers/reaction-scripts/route.js +128 -128
  212. package/.next/standalone/.next/server/app/api/v1/watchers/route.js +164 -164
  213. package/.next/standalone/.next/server/app/api/v1/watchers/route.js.nft.json +1 -1
  214. package/.next/standalone/.next/server/app/icon.svg/route.js +62 -62
  215. package/.next/standalone/.next/server/app/manifest.webmanifest/route.js +436 -436
  216. package/.next/standalone/.next/server/app/page.js +1243 -854
  217. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  218. package/.next/standalone/.next/server/app/setup/page.js +91 -91
  219. package/.next/standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  220. package/.next/standalone/.next/server/app-paths-manifest.json +6 -5
  221. package/.next/standalone/.next/server/chunks/{424.js → 1388.js} +335 -986
  222. package/.next/standalone/.next/server/chunks/1433.js +1 -1
  223. package/.next/standalone/.next/server/chunks/1638.js +1 -2
  224. package/.next/standalone/.next/server/chunks/1738.js +1 -1
  225. package/.next/standalone/.next/server/chunks/210.js +6 -6
  226. package/.next/standalone/.next/server/chunks/2151.js +31 -1
  227. package/.next/standalone/.next/server/chunks/2207.js +1 -0
  228. package/.next/standalone/.next/server/chunks/2471.js +28 -28
  229. package/.next/standalone/.next/server/chunks/2504.js +1 -1
  230. package/.next/standalone/.next/server/chunks/2695.js +17 -17
  231. package/.next/standalone/.next/server/chunks/3042.js +14 -8
  232. package/.next/standalone/.next/server/chunks/3399.js +1 -1
  233. package/.next/standalone/.next/server/chunks/3566.js +1 -1
  234. package/.next/standalone/.next/server/chunks/4189.js +946 -0
  235. package/.next/standalone/.next/server/chunks/{9590.js → 423.js} +8 -3
  236. package/.next/standalone/.next/server/chunks/4433.js +146 -146
  237. package/.next/standalone/.next/server/chunks/4508.js +1 -1
  238. package/.next/standalone/.next/server/chunks/4588.js +1 -0
  239. package/.next/standalone/.next/server/chunks/46.js +5 -0
  240. package/.next/standalone/.next/server/chunks/466.js +12 -0
  241. package/.next/standalone/.next/server/chunks/4868.js +206 -206
  242. package/.next/standalone/.next/server/chunks/4992.js +13 -0
  243. package/.next/standalone/.next/server/chunks/5120.js +963 -0
  244. package/.next/standalone/.next/server/chunks/5701.js +1 -1
  245. package/.next/standalone/.next/server/chunks/5900.js +1 -1
  246. package/.next/standalone/.next/server/chunks/6210.js +1 -0
  247. package/.next/standalone/.next/server/chunks/6213.js +1 -1
  248. package/.next/standalone/.next/server/chunks/6649.js +2 -2
  249. package/.next/standalone/.next/server/chunks/6703.js +3 -3
  250. package/.next/standalone/.next/server/chunks/7445.js +1 -0
  251. package/.next/standalone/.next/server/chunks/8067.js +12 -0
  252. package/.next/standalone/.next/server/chunks/8461.js +14 -9
  253. package/.next/standalone/.next/server/chunks/8558.js +1 -1
  254. package/.next/standalone/.next/server/chunks/8724.js +1 -1
  255. package/.next/standalone/.next/server/chunks/8849.js +91 -91
  256. package/.next/standalone/.next/server/chunks/9032.js +6 -5
  257. package/.next/standalone/.next/server/chunks/{2563.js → 9164.js} +33173 -31461
  258. package/.next/standalone/.next/server/chunks/9237.js +396 -396
  259. package/.next/standalone/.next/server/chunks/{9640.js → 9304.js} +1628 -570
  260. package/.next/standalone/.next/server/chunks/9406.js +1 -1
  261. package/.next/standalone/.next/server/chunks/9824.js +98 -98
  262. package/.next/standalone/.next/server/chunks/9826.js +1 -0
  263. package/.next/standalone/.next/server/middleware-build-manifest.js +2 -2
  264. package/.next/standalone/.next/server/middleware.js +415 -397
  265. package/.next/standalone/.next/server/pages/404.html +2 -2
  266. package/.next/standalone/.next/server/pages/500.html +1 -1
  267. package/.next/standalone/.next/server/preview-props.json +3 -3
  268. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  269. package/.next/standalone/.next/static/chunks/{1395-a340fb0a345382a4.js → 1395-e4a99912b8f83044.js} +13 -1
  270. package/.next/standalone/.next/static/chunks/app/_global-error/{page-36cb8b428b38b26a.js → page-6fc5f8e744c81802.js} +1 -1
  271. package/.next/standalone/.next/static/chunks/app/api/v1/access/[identity]/{route-36cb8b428b38b26a.js → route-6fc5f8e744c81802.js} +1 -1
  272. package/.next/standalone/.next/static/chunks/app/api/v1/access/{route-36cb8b428b38b26a.js → route-6fc5f8e744c81802.js} +1 -1
  273. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/compact/{route-36cb8b428b38b26a.js → route-6fc5f8e744c81802.js} +1 -1
  274. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/display-filters/route-6fc5f8e744c81802.js +17 -0
  275. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/route-6fc5f8e744c81802.js +17 -0
  276. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/thread/route-6fc5f8e744c81802.js +17 -0
  277. package/.next/standalone/.next/static/chunks/app/api/v1/agents/route-6fc5f8e744c81802.js +17 -0
  278. package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/[hostname]/route-6fc5f8e744c81802.js +17 -0
  279. package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/route-6fc5f8e744c81802.js +17 -0
  280. package/.next/standalone/.next/static/chunks/app/api/v1/artifacts/lifecycle/route-6fc5f8e744c81802.js +17 -0
  281. package/.next/standalone/.next/static/chunks/app/api/v1/attachments/files/route-6fc5f8e744c81802.js +17 -0
  282. package/.next/standalone/.next/static/chunks/app/api/v1/attachments/images/route-6fc5f8e744c81802.js +17 -0
  283. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/chats/route-6fc5f8e744c81802.js +17 -0
  284. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/[remote_jid]/route-6fc5f8e744c81802.js +17 -0
  285. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/route-6fc5f8e744c81802.js +17 -0
  286. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/lookup/route-6fc5f8e744c81802.js +17 -0
  287. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/pair/route-6fc5f8e744c81802.js +17 -0
  288. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/route-6fc5f8e744c81802.js +17 -0
  289. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/[route_id]/route-6fc5f8e744c81802.js +17 -0
  290. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/route-6fc5f8e744c81802.js +17 -0
  291. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/status/route-6fc5f8e744c81802.js +17 -0
  292. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/kinds/route-6fc5f8e744c81802.js +17 -0
  293. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/route-6fc5f8e744c81802.js +17 -0
  294. package/.next/standalone/.next/static/chunks/app/api/v1/builtin-tools/route-6fc5f8e744c81802.js +17 -0
  295. package/.next/standalone/.next/static/chunks/app/api/v1/config/route-6fc5f8e744c81802.js +17 -0
  296. package/.next/standalone/.next/static/chunks/app/api/v1/credentials/[id]/route-6fc5f8e744c81802.js +17 -0
  297. package/.next/standalone/.next/static/chunks/app/api/v1/credentials/route-6fc5f8e744c81802.js +17 -0
  298. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/currency/route-6fc5f8e744c81802.js +17 -0
  299. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/metrics/route-6fc5f8e744c81802.js +17 -0
  300. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing/route-6fc5f8e744c81802.js +17 -0
  301. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing-task/route-6fc5f8e744c81802.js +17 -0
  302. package/.next/standalone/.next/static/chunks/app/api/v1/delegations/codex/[job_id]/route-6fc5f8e744c81802.js +17 -0
  303. package/.next/standalone/.next/static/chunks/app/api/v1/documents/search/route-6fc5f8e744c81802.js +17 -0
  304. package/.next/standalone/.next/static/chunks/app/api/v1/documents/settings/route-6fc5f8e744c81802.js +17 -0
  305. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/reindex/route-6fc5f8e744c81802.js +17 -0
  306. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/route-6fc5f8e744c81802.js +17 -0
  307. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/route-6fc5f8e744c81802.js +17 -0
  308. package/.next/standalone/.next/static/chunks/app/api/v1/env/route-6fc5f8e744c81802.js +17 -0
  309. package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/allowlist/route-6fc5f8e744c81802.js +17 -0
  310. package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/route-6fc5f8e744c81802.js +17 -0
  311. package/.next/standalone/.next/static/chunks/app/api/v1/events/route-6fc5f8e744c81802.js +17 -0
  312. package/.next/standalone/.next/static/chunks/app/api/v1/events/test/route-6fc5f8e744c81802.js +17 -0
  313. package/.next/standalone/.next/static/chunks/app/api/v1/extension/agents/route-6fc5f8e744c81802.js +17 -0
  314. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/activate/route-6fc5f8e744c81802.js +17 -0
  315. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/foreground/route-6fc5f8e744c81802.js +17 -0
  316. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/history/route-6fc5f8e744c81802.js +17 -0
  317. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/poll/route-6fc5f8e744c81802.js +17 -0
  318. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/progress/route-6fc5f8e744c81802.js +17 -0
  319. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/result/route-6fc5f8e744c81802.js +17 -0
  320. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/retry/route-6fc5f8e744c81802.js +17 -0
  321. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/status/route-6fc5f8e744c81802.js +17 -0
  322. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/tabs/route-6fc5f8e744c81802.js +17 -0
  323. package/.next/standalone/.next/static/chunks/app/api/v1/extension/fill/route-6fc5f8e744c81802.js +17 -0
  324. package/.next/standalone/.next/static/chunks/app/api/v1/extension/refine/route-6fc5f8e744c81802.js +17 -0
  325. package/.next/standalone/.next/static/chunks/app/api/v1/extension/turn/route-6fc5f8e744c81802.js +17 -0
  326. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/route-6fc5f8e744c81802.js +17 -0
  327. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/config/route-6fc5f8e744c81802.js +17 -0
  328. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/route-6fc5f8e744c81802.js +17 -0
  329. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/secrets/route-6fc5f8e744c81802.js +17 -0
  330. package/.next/standalone/.next/static/chunks/app/api/v1/files/[name]/route-6fc5f8e744c81802.js +17 -0
  331. package/.next/standalone/.next/static/chunks/app/api/v1/fs/browse/route-6fc5f8e744c81802.js +17 -0
  332. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/[id]/route-6fc5f8e744c81802.js +17 -0
  333. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/default/route-6fc5f8e744c81802.js +17 -0
  334. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/route-6fc5f8e744c81802.js +17 -0
  335. package/.next/standalone/.next/static/chunks/app/api/v1/health/probes/route-6fc5f8e744c81802.js +17 -0
  336. package/.next/standalone/.next/static/chunks/app/api/v1/health/route-6fc5f8e744c81802.js +17 -0
  337. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/route-6fc5f8e744c81802.js +17 -0
  338. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/test/route-6fc5f8e744c81802.js +17 -0
  339. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/callback/route-6fc5f8e744c81802.js +17 -0
  340. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/start/route-6fc5f8e744c81802.js +17 -0
  341. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/status/route-6fc5f8e744c81802.js +17 -0
  342. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/callback/route-6fc5f8e744c81802.js +17 -0
  343. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/start/route-6fc5f8e744c81802.js +17 -0
  344. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/status/route-6fc5f8e744c81802.js +17 -0
  345. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/route-6fc5f8e744c81802.js +17 -0
  346. package/.next/standalone/.next/static/chunks/app/api/v1/lifecycle/adoption/route-6fc5f8e744c81802.js +17 -0
  347. package/.next/standalone/.next/static/chunks/app/api/v1/local-file/route-6fc5f8e744c81802.js +17 -0
  348. package/.next/standalone/.next/static/chunks/app/api/v1/logs/route-6fc5f8e744c81802.js +17 -0
  349. package/.next/standalone/.next/static/chunks/app/api/v1/maps/embed/route-6fc5f8e744c81802.js +17 -0
  350. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/[name]/route-6fc5f8e744c81802.js +17 -0
  351. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/registry/route-6fc5f8e744c81802.js +17 -0
  352. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/route-6fc5f8e744c81802.js +17 -0
  353. package/.next/standalone/.next/static/chunks/app/api/v1/memory/[namespace]/[key]/route-6fc5f8e744c81802.js +17 -0
  354. package/.next/standalone/.next/static/chunks/app/api/v1/memory/policy/route-6fc5f8e744c81802.js +17 -0
  355. package/.next/standalone/.next/static/chunks/app/api/v1/memory/route-6fc5f8e744c81802.js +17 -0
  356. package/.next/standalone/.next/static/chunks/app/api/v1/memory/search/route-6fc5f8e744c81802.js +17 -0
  357. package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/compact-threads/route-6fc5f8e744c81802.js +17 -0
  358. package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/route-6fc5f8e744c81802.js +17 -0
  359. package/.next/standalone/.next/static/chunks/app/api/v1/models/route-6fc5f8e744c81802.js +17 -0
  360. package/.next/standalone/.next/static/chunks/app/api/v1/packages/catalog/route-6fc5f8e744c81802.js +17 -0
  361. package/.next/standalone/.next/static/chunks/app/api/v1/packages/defaults/[id]/route-6fc5f8e744c81802.js +17 -0
  362. package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/[id]/route-6fc5f8e744c81802.js +17 -0
  363. package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/route-6fc5f8e744c81802.js +17 -0
  364. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/enabled/route-6fc5f8e744c81802.js +17 -0
  365. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/route-6fc5f8e744c81802.js +17 -0
  366. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/route-6fc5f8e744c81802.js +17 -0
  367. package/.next/standalone/.next/static/chunks/app/api/v1/packages/reload/route-6fc5f8e744c81802.js +17 -0
  368. package/.next/standalone/.next/static/chunks/app/api/v1/packages/route-6fc5f8e744c81802.js +17 -0
  369. package/.next/standalone/.next/static/chunks/app/api/v1/page-capture/route-6fc5f8e744c81802.js +17 -0
  370. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/approve/route-6fc5f8e744c81802.js +17 -0
  371. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/deny/route-6fc5f8e744c81802.js +17 -0
  372. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/route-6fc5f8e744c81802.js +17 -0
  373. package/.next/standalone/.next/static/chunks/app/api/v1/profile/location/route-6fc5f8e744c81802.js +17 -0
  374. package/.next/standalone/.next/static/chunks/app/api/v1/profile/route-6fc5f8e744c81802.js +17 -0
  375. package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/models/route-6fc5f8e744c81802.js +17 -0
  376. package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/probe/route-6fc5f8e744c81802.js +17 -0
  377. package/.next/standalone/.next/static/chunks/app/api/v1/providers/github-copilot/auth/route-6fc5f8e744c81802.js +17 -0
  378. package/.next/standalone/.next/static/chunks/app/api/v1/providers/route-6fc5f8e744c81802.js +17 -0
  379. package/.next/standalone/.next/static/chunks/app/api/v1/proxy-config/route-6fc5f8e744c81802.js +17 -0
  380. package/.next/standalone/.next/static/chunks/app/api/v1/redaction/init/route-6fc5f8e744c81802.js +17 -0
  381. package/.next/standalone/.next/static/chunks/app/api/v1/redaction/route-6fc5f8e744c81802.js +17 -0
  382. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/route-6fc5f8e744c81802.js +17 -0
  383. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/run/route-6fc5f8e744c81802.js +17 -0
  384. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/route-6fc5f8e744c81802.js +17 -0
  385. package/.next/standalone/.next/static/chunks/app/api/v1/security/idle-timeout/route-6fc5f8e744c81802.js +17 -0
  386. package/.next/standalone/.next/static/chunks/app/api/v1/security/pin/route-6fc5f8e744c81802.js +17 -0
  387. package/.next/standalone/.next/static/chunks/app/api/v1/security/state/route-6fc5f8e744c81802.js +17 -0
  388. package/.next/standalone/.next/static/chunks/app/api/v1/security/unlock/route-6fc5f8e744c81802.js +17 -0
  389. package/.next/standalone/.next/static/chunks/app/api/v1/security/verify-pin/route-6fc5f8e744c81802.js +17 -0
  390. package/.next/standalone/.next/static/chunks/app/api/v1/setup/test-key/route-6fc5f8e744c81802.js +17 -0
  391. package/.next/standalone/.next/static/chunks/app/api/v1/skills/[id]/route-6fc5f8e744c81802.js +17 -0
  392. package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/[id]/route-6fc5f8e744c81802.js +17 -0
  393. package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/route-6fc5f8e744c81802.js +17 -0
  394. package/.next/standalone/.next/static/chunks/app/api/v1/skills/route-6fc5f8e744c81802.js +17 -0
  395. package/.next/standalone/.next/static/chunks/app/api/v1/system/abort/route-6fc5f8e744c81802.js +17 -0
  396. package/.next/standalone/.next/static/chunks/app/api/v1/system/restart/route-6fc5f8e744c81802.js +17 -0
  397. package/.next/standalone/.next/static/chunks/app/api/v1/tailscale/route-6fc5f8e744c81802.js +17 -0
  398. package/.next/standalone/.next/static/chunks/app/api/v1/tasks/[agent_id]/route-6fc5f8e744c81802.js +17 -0
  399. package/.next/standalone/.next/static/chunks/app/api/v1/tasks/route-6fc5f8e744c81802.js +17 -0
  400. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/activity/route-6fc5f8e744c81802.js +17 -0
  401. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/context-pin/route-6fc5f8e744c81802.js +17 -0
  402. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/route-6fc5f8e744c81802.js +17 -0
  403. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/run/route-6fc5f8e744c81802.js +17 -0
  404. package/.next/standalone/.next/static/chunks/app/api/v1/threads/route-6fc5f8e744c81802.js +17 -0
  405. package/.next/standalone/.next/static/chunks/app/api/v1/tools/route-6fc5f8e744c81802.js +17 -0
  406. package/.next/standalone/.next/static/chunks/app/api/v1/update/apply/route-6fc5f8e744c81802.js +17 -0
  407. package/.next/standalone/.next/static/chunks/app/api/v1/update/route-6fc5f8e744c81802.js +17 -0
  408. package/.next/standalone/.next/static/chunks/app/api/v1/voice/transcribe/route-6fc5f8e744c81802.js +17 -0
  409. package/.next/standalone/.next/static/chunks/app/api/v1/voice/tts/route-6fc5f8e744c81802.js +17 -0
  410. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/route-6fc5f8e744c81802.js +17 -0
  411. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/run/route-6fc5f8e744c81802.js +17 -0
  412. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/reaction-scripts/route-6fc5f8e744c81802.js +17 -0
  413. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/route-6fc5f8e744c81802.js +17 -0
  414. package/.next/standalone/.next/static/chunks/app/manifest.webmanifest/route-6fc5f8e744c81802.js +17 -0
  415. package/.next/standalone/.next/static/chunks/app/{page-7017f07f8a7a083c.js → page-213a623b37226452.js} +1041 -652
  416. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-6fc5f8e744c81802.js +17 -0
  417. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-6fc5f8e744c81802.js +17 -0
  418. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-6fc5f8e744c81802.js +17 -0
  419. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-6fc5f8e744c81802.js +17 -0
  420. package/.next/standalone/.next/static/css/{d80058f0b9b41c09.css → 312542a5725ba0d5.css} +2 -2
  421. package/.next/standalone/docs/adoption/changesets.json +309 -0
  422. package/.next/standalone/lib/skills/builtins/memory-organization/SKILL.md +16 -0
  423. package/.next/standalone/package.json +3 -3
  424. package/CHANGELOG.md +25 -0
  425. package/api/client.ts +9 -0
  426. package/api/types.ts +29 -0
  427. package/app/api/v1/lifecycle/adoption/route.ts +14 -2
  428. package/app/api/v1/models/[name]/compact-threads/route.ts +14 -11
  429. package/app/api/v1/threads/[thread_id]/activity/route.ts +19 -0
  430. package/app/api/v1/threads/[thread_id]/context-pin/route.test.ts +1 -0
  431. package/app/api/v1/threads/[thread_id]/context-pin/route.ts +2 -1
  432. package/app/api/v1/threads/[thread_id]/route.ts +5 -1
  433. package/components/chat/ChatView.tsx +52 -11
  434. package/components/chat/ContextBoundary.test.tsx +68 -1
  435. package/components/chat/ContextBoundary.tsx +92 -13
  436. package/components/chat/MessageList.test.tsx +31 -0
  437. package/components/chat/MessageList.tsx +49 -28
  438. package/components/chat/ToolList.test.tsx +92 -16
  439. package/components/chat/ToolList.tsx +59 -4
  440. package/components/chat/chat-helpers.test.tsx +24 -1
  441. package/components/chat/chat-helpers.ts +47 -4
  442. package/components/chat/useThreadActivity.test.tsx +113 -0
  443. package/components/chat/useThreadActivity.ts +94 -0
  444. package/components/chat/useThreadData.ts +16 -16
  445. package/components/chat/workflow-step-retry.ts +25 -0
  446. package/components/ui/BootScreen.tsx +17 -0
  447. package/components/ui/WorkflowChecklist.tsx +71 -33
  448. package/hooks/useSSE.ts +28 -3
  449. package/lib/agents/compaction-pipeline.test.ts +202 -0
  450. package/lib/agents/compaction-pipeline.ts +483 -0
  451. package/lib/agents/conversation-summary.ts +37 -21
  452. package/lib/agents/prepare/history-window.test.ts +18 -0
  453. package/lib/agents/prepare/history-window.ts +11 -2
  454. package/lib/agents/prepare/request.ts +4 -0
  455. package/lib/agents/prepare/system-prompt.test.ts +39 -0
  456. package/lib/agents/prepare/system-prompt.ts +8 -3
  457. package/lib/agents/prompt-registry.test.ts +5 -140
  458. package/lib/agents/prompt-registry.ts +45 -1
  459. package/lib/agents/prompt-variants.ts +146 -0
  460. package/lib/agents/run-registry.test.ts +22 -0
  461. package/lib/agents/run-registry.ts +29 -0
  462. package/lib/agents/run-thread.retry.test.ts +67 -1
  463. package/lib/agents/run-thread.ts +86 -1
  464. package/lib/agents/thread-activity.test.ts +31 -0
  465. package/lib/agents/thread-activity.ts +27 -0
  466. package/lib/agents/thread-compaction-state.test.ts +82 -0
  467. package/lib/agents/thread-compaction-state.ts +121 -0
  468. package/lib/agents/thread-compaction.test.ts +83 -4
  469. package/lib/agents/thread-compaction.ts +34 -11
  470. package/lib/agents/warm-summary-background.test.ts +219 -5
  471. package/lib/agents/warm-summary-background.ts +325 -142
  472. package/lib/agents/warm-topics.test.ts +37 -0
  473. package/lib/agents/warm-topics.ts +297 -0
  474. package/lib/agents/workflow-step-retry.test.ts +96 -0
  475. package/lib/agents/workflow-step-retry.ts +216 -0
  476. package/lib/api/browser-control.ts +0 -3
  477. package/lib/db/migrations.ts +5 -0
  478. package/lib/env/config.ts +2 -0
  479. package/lib/env/schema.ts +12 -0
  480. package/lib/lifecycle/changeset-build.test.ts +93 -0
  481. package/lib/lifecycle/changeset-build.ts +210 -0
  482. package/lib/lifecycle/changesets.test.ts +101 -0
  483. package/lib/lifecycle/changesets.ts +166 -0
  484. package/lib/lifecycle/surface-collect.test.ts +88 -0
  485. package/lib/lifecycle/surface-collect.ts +64 -0
  486. package/lib/lifecycle/surface-snapshot.test.ts +104 -0
  487. package/lib/lifecycle/surface-snapshot.ts +210 -0
  488. package/lib/memory/record.ts +0 -2
  489. package/lib/providers/external.ts +0 -2
  490. package/lib/skills/builtins/memory-organization/SKILL.md +16 -0
  491. package/lib/stores/threads.test.ts +9 -0
  492. package/lib/stores/threads.ts +21 -11
  493. package/lib/stores/version-adoption.test.ts +96 -0
  494. package/lib/stores/version-adoption.ts +239 -26
  495. package/lib/stores/workflow-progress.ts +3 -0
  496. package/lib/tools/communications/ms-todo.ts +0 -7
  497. package/lib/tools/general/memory.ts +1 -1
  498. package/lib/tools/general/workflow-progress.ts +2 -0
  499. package/lib/tools/runtime/catalog.ts +1 -25
  500. package/lib/triggers/registry.ts +0 -4
  501. package/package.json +3 -3
  502. package/scripts/install-to-system.ps1 +39 -11
  503. package/scripts/install-to-system.sh +37 -3
  504. package/.next/standalone/.next/server/chunks/3979.js +0 -581
  505. package/.next/standalone/.next/server/chunks/5936.js +0 -594
  506. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/display-filters/route-36cb8b428b38b26a.js +0 -17
  507. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/route-36cb8b428b38b26a.js +0 -17
  508. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/thread/route-36cb8b428b38b26a.js +0 -17
  509. package/.next/standalone/.next/static/chunks/app/api/v1/agents/route-36cb8b428b38b26a.js +0 -17
  510. package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/[hostname]/route-36cb8b428b38b26a.js +0 -17
  511. package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/route-36cb8b428b38b26a.js +0 -17
  512. package/.next/standalone/.next/static/chunks/app/api/v1/artifacts/lifecycle/route-36cb8b428b38b26a.js +0 -17
  513. package/.next/standalone/.next/static/chunks/app/api/v1/attachments/files/route-36cb8b428b38b26a.js +0 -17
  514. package/.next/standalone/.next/static/chunks/app/api/v1/attachments/images/route-36cb8b428b38b26a.js +0 -17
  515. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/chats/route-36cb8b428b38b26a.js +0 -17
  516. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/[remote_jid]/route-36cb8b428b38b26a.js +0 -17
  517. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/route-36cb8b428b38b26a.js +0 -17
  518. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/lookup/route-36cb8b428b38b26a.js +0 -17
  519. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/pair/route-36cb8b428b38b26a.js +0 -17
  520. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/route-36cb8b428b38b26a.js +0 -17
  521. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/[route_id]/route-36cb8b428b38b26a.js +0 -17
  522. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/route-36cb8b428b38b26a.js +0 -17
  523. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/status/route-36cb8b428b38b26a.js +0 -17
  524. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/kinds/route-36cb8b428b38b26a.js +0 -17
  525. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/route-36cb8b428b38b26a.js +0 -17
  526. package/.next/standalone/.next/static/chunks/app/api/v1/builtin-tools/route-36cb8b428b38b26a.js +0 -17
  527. package/.next/standalone/.next/static/chunks/app/api/v1/config/route-36cb8b428b38b26a.js +0 -17
  528. package/.next/standalone/.next/static/chunks/app/api/v1/credentials/[id]/route-36cb8b428b38b26a.js +0 -17
  529. package/.next/standalone/.next/static/chunks/app/api/v1/credentials/route-36cb8b428b38b26a.js +0 -17
  530. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/currency/route-36cb8b428b38b26a.js +0 -17
  531. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/metrics/route-36cb8b428b38b26a.js +0 -17
  532. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing/route-36cb8b428b38b26a.js +0 -17
  533. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing-task/route-36cb8b428b38b26a.js +0 -17
  534. package/.next/standalone/.next/static/chunks/app/api/v1/delegations/codex/[job_id]/route-36cb8b428b38b26a.js +0 -17
  535. package/.next/standalone/.next/static/chunks/app/api/v1/documents/search/route-36cb8b428b38b26a.js +0 -17
  536. package/.next/standalone/.next/static/chunks/app/api/v1/documents/settings/route-36cb8b428b38b26a.js +0 -17
  537. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/reindex/route-36cb8b428b38b26a.js +0 -17
  538. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/route-36cb8b428b38b26a.js +0 -17
  539. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/route-36cb8b428b38b26a.js +0 -17
  540. package/.next/standalone/.next/static/chunks/app/api/v1/env/route-36cb8b428b38b26a.js +0 -17
  541. package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/allowlist/route-36cb8b428b38b26a.js +0 -17
  542. package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/route-36cb8b428b38b26a.js +0 -17
  543. package/.next/standalone/.next/static/chunks/app/api/v1/events/route-36cb8b428b38b26a.js +0 -17
  544. package/.next/standalone/.next/static/chunks/app/api/v1/events/test/route-36cb8b428b38b26a.js +0 -17
  545. package/.next/standalone/.next/static/chunks/app/api/v1/extension/agents/route-36cb8b428b38b26a.js +0 -17
  546. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/activate/route-36cb8b428b38b26a.js +0 -17
  547. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/foreground/route-36cb8b428b38b26a.js +0 -17
  548. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/history/route-36cb8b428b38b26a.js +0 -17
  549. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/poll/route-36cb8b428b38b26a.js +0 -17
  550. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/progress/route-36cb8b428b38b26a.js +0 -17
  551. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/result/route-36cb8b428b38b26a.js +0 -17
  552. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/retry/route-36cb8b428b38b26a.js +0 -17
  553. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/status/route-36cb8b428b38b26a.js +0 -17
  554. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/tabs/route-36cb8b428b38b26a.js +0 -17
  555. package/.next/standalone/.next/static/chunks/app/api/v1/extension/fill/route-36cb8b428b38b26a.js +0 -17
  556. package/.next/standalone/.next/static/chunks/app/api/v1/extension/refine/route-36cb8b428b38b26a.js +0 -17
  557. package/.next/standalone/.next/static/chunks/app/api/v1/extension/turn/route-36cb8b428b38b26a.js +0 -17
  558. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/route-36cb8b428b38b26a.js +0 -17
  559. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/config/route-36cb8b428b38b26a.js +0 -17
  560. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/route-36cb8b428b38b26a.js +0 -17
  561. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/secrets/route-36cb8b428b38b26a.js +0 -17
  562. package/.next/standalone/.next/static/chunks/app/api/v1/files/[name]/route-36cb8b428b38b26a.js +0 -17
  563. package/.next/standalone/.next/static/chunks/app/api/v1/fs/browse/route-36cb8b428b38b26a.js +0 -17
  564. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/[id]/route-36cb8b428b38b26a.js +0 -17
  565. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/default/route-36cb8b428b38b26a.js +0 -17
  566. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/route-36cb8b428b38b26a.js +0 -17
  567. package/.next/standalone/.next/static/chunks/app/api/v1/health/probes/route-36cb8b428b38b26a.js +0 -17
  568. package/.next/standalone/.next/static/chunks/app/api/v1/health/route-36cb8b428b38b26a.js +0 -17
  569. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/route-36cb8b428b38b26a.js +0 -17
  570. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/test/route-36cb8b428b38b26a.js +0 -17
  571. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/callback/route-36cb8b428b38b26a.js +0 -17
  572. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/start/route-36cb8b428b38b26a.js +0 -17
  573. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/status/route-36cb8b428b38b26a.js +0 -17
  574. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/callback/route-36cb8b428b38b26a.js +0 -17
  575. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/start/route-36cb8b428b38b26a.js +0 -17
  576. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/status/route-36cb8b428b38b26a.js +0 -17
  577. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/route-36cb8b428b38b26a.js +0 -17
  578. package/.next/standalone/.next/static/chunks/app/api/v1/lifecycle/adoption/route-36cb8b428b38b26a.js +0 -17
  579. package/.next/standalone/.next/static/chunks/app/api/v1/local-file/route-36cb8b428b38b26a.js +0 -17
  580. package/.next/standalone/.next/static/chunks/app/api/v1/logs/route-36cb8b428b38b26a.js +0 -17
  581. package/.next/standalone/.next/static/chunks/app/api/v1/maps/embed/route-36cb8b428b38b26a.js +0 -17
  582. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/[name]/route-36cb8b428b38b26a.js +0 -17
  583. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/registry/route-36cb8b428b38b26a.js +0 -17
  584. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/route-36cb8b428b38b26a.js +0 -17
  585. package/.next/standalone/.next/static/chunks/app/api/v1/memory/[namespace]/[key]/route-36cb8b428b38b26a.js +0 -17
  586. package/.next/standalone/.next/static/chunks/app/api/v1/memory/policy/route-36cb8b428b38b26a.js +0 -17
  587. package/.next/standalone/.next/static/chunks/app/api/v1/memory/route-36cb8b428b38b26a.js +0 -17
  588. package/.next/standalone/.next/static/chunks/app/api/v1/memory/search/route-36cb8b428b38b26a.js +0 -17
  589. package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/compact-threads/route-36cb8b428b38b26a.js +0 -17
  590. package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/route-36cb8b428b38b26a.js +0 -17
  591. package/.next/standalone/.next/static/chunks/app/api/v1/models/route-36cb8b428b38b26a.js +0 -17
  592. package/.next/standalone/.next/static/chunks/app/api/v1/packages/catalog/route-36cb8b428b38b26a.js +0 -17
  593. package/.next/standalone/.next/static/chunks/app/api/v1/packages/defaults/[id]/route-36cb8b428b38b26a.js +0 -17
  594. package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/[id]/route-36cb8b428b38b26a.js +0 -17
  595. package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/route-36cb8b428b38b26a.js +0 -17
  596. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/enabled/route-36cb8b428b38b26a.js +0 -17
  597. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/route-36cb8b428b38b26a.js +0 -17
  598. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/route-36cb8b428b38b26a.js +0 -17
  599. package/.next/standalone/.next/static/chunks/app/api/v1/packages/reload/route-36cb8b428b38b26a.js +0 -17
  600. package/.next/standalone/.next/static/chunks/app/api/v1/packages/route-36cb8b428b38b26a.js +0 -17
  601. package/.next/standalone/.next/static/chunks/app/api/v1/page-capture/route-36cb8b428b38b26a.js +0 -17
  602. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/approve/route-36cb8b428b38b26a.js +0 -17
  603. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/deny/route-36cb8b428b38b26a.js +0 -17
  604. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/route-36cb8b428b38b26a.js +0 -17
  605. package/.next/standalone/.next/static/chunks/app/api/v1/profile/location/route-36cb8b428b38b26a.js +0 -17
  606. package/.next/standalone/.next/static/chunks/app/api/v1/profile/route-36cb8b428b38b26a.js +0 -17
  607. package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/models/route-36cb8b428b38b26a.js +0 -17
  608. package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/probe/route-36cb8b428b38b26a.js +0 -17
  609. package/.next/standalone/.next/static/chunks/app/api/v1/providers/github-copilot/auth/route-36cb8b428b38b26a.js +0 -17
  610. package/.next/standalone/.next/static/chunks/app/api/v1/providers/route-36cb8b428b38b26a.js +0 -17
  611. package/.next/standalone/.next/static/chunks/app/api/v1/proxy-config/route-36cb8b428b38b26a.js +0 -17
  612. package/.next/standalone/.next/static/chunks/app/api/v1/redaction/init/route-36cb8b428b38b26a.js +0 -17
  613. package/.next/standalone/.next/static/chunks/app/api/v1/redaction/route-36cb8b428b38b26a.js +0 -17
  614. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/route-36cb8b428b38b26a.js +0 -17
  615. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/run/route-36cb8b428b38b26a.js +0 -17
  616. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/route-36cb8b428b38b26a.js +0 -17
  617. package/.next/standalone/.next/static/chunks/app/api/v1/security/idle-timeout/route-36cb8b428b38b26a.js +0 -17
  618. package/.next/standalone/.next/static/chunks/app/api/v1/security/pin/route-36cb8b428b38b26a.js +0 -17
  619. package/.next/standalone/.next/static/chunks/app/api/v1/security/state/route-36cb8b428b38b26a.js +0 -17
  620. package/.next/standalone/.next/static/chunks/app/api/v1/security/unlock/route-36cb8b428b38b26a.js +0 -17
  621. package/.next/standalone/.next/static/chunks/app/api/v1/security/verify-pin/route-36cb8b428b38b26a.js +0 -17
  622. package/.next/standalone/.next/static/chunks/app/api/v1/setup/test-key/route-36cb8b428b38b26a.js +0 -17
  623. package/.next/standalone/.next/static/chunks/app/api/v1/skills/[id]/route-36cb8b428b38b26a.js +0 -17
  624. package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/[id]/route-36cb8b428b38b26a.js +0 -17
  625. package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/route-36cb8b428b38b26a.js +0 -17
  626. package/.next/standalone/.next/static/chunks/app/api/v1/skills/route-36cb8b428b38b26a.js +0 -17
  627. package/.next/standalone/.next/static/chunks/app/api/v1/system/abort/route-36cb8b428b38b26a.js +0 -17
  628. package/.next/standalone/.next/static/chunks/app/api/v1/system/restart/route-36cb8b428b38b26a.js +0 -17
  629. package/.next/standalone/.next/static/chunks/app/api/v1/tailscale/route-36cb8b428b38b26a.js +0 -17
  630. package/.next/standalone/.next/static/chunks/app/api/v1/tasks/[agent_id]/route-36cb8b428b38b26a.js +0 -17
  631. package/.next/standalone/.next/static/chunks/app/api/v1/tasks/route-36cb8b428b38b26a.js +0 -17
  632. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/context-pin/route-36cb8b428b38b26a.js +0 -17
  633. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/route-36cb8b428b38b26a.js +0 -17
  634. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/run/route-36cb8b428b38b26a.js +0 -17
  635. package/.next/standalone/.next/static/chunks/app/api/v1/threads/route-36cb8b428b38b26a.js +0 -17
  636. package/.next/standalone/.next/static/chunks/app/api/v1/tools/route-36cb8b428b38b26a.js +0 -17
  637. package/.next/standalone/.next/static/chunks/app/api/v1/update/apply/route-36cb8b428b38b26a.js +0 -17
  638. package/.next/standalone/.next/static/chunks/app/api/v1/update/route-36cb8b428b38b26a.js +0 -17
  639. package/.next/standalone/.next/static/chunks/app/api/v1/voice/transcribe/route-36cb8b428b38b26a.js +0 -17
  640. package/.next/standalone/.next/static/chunks/app/api/v1/voice/tts/route-36cb8b428b38b26a.js +0 -17
  641. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/route-36cb8b428b38b26a.js +0 -17
  642. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/run/route-36cb8b428b38b26a.js +0 -17
  643. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/reaction-scripts/route-36cb8b428b38b26a.js +0 -17
  644. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/route-36cb8b428b38b26a.js +0 -17
  645. package/.next/standalone/.next/static/chunks/app/manifest.webmanifest/route-36cb8b428b38b26a.js +0 -17
  646. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-36cb8b428b38b26a.js +0 -17
  647. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-36cb8b428b38b26a.js +0 -17
  648. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-36cb8b428b38b26a.js +0 -17
  649. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-36cb8b428b38b26a.js +0 -17
  650. /package/.next/standalone/.next/static/{NUrC9xax1sp1Q70nlFqS6 → bMRK5y3ruT7c3WtBfCQOG}/_buildManifest.js +0 -0
  651. /package/.next/standalone/.next/static/{NUrC9xax1sp1Q70nlFqS6 → bMRK5y3ruT7c3WtBfCQOG}/_ssgManifest.js +0 -0
@@ -0,0 +1,37 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { canMergeIntoTopics, savedMemoryFacts } from "./warm-topics";
3
+
4
+ const events = (...list: unknown[]) => JSON.stringify(list);
5
+
6
+ describe("savedMemoryFacts", () => {
7
+ it("counts only saves the tool result confirms, including ones routed through invoke_tool", () => {
8
+ const row = {
9
+ seq: 1,
10
+ content: "",
11
+ tool_events: events(
12
+ { id: "a", phase: "call", name: "invoke_tool", payload: { name: "memory_write", args_json: JSON.stringify({ namespace: "facts", key: "editor", value: "Uses VS Code." }) } },
13
+ { id: "a", phase: "result", name: "invoke_tool", payload: JSON.stringify({ ok: true, namespace: "facts", key: "editor" }) },
14
+ { id: "b", phase: "call", name: "memory_upsert", payload: { namespace: "facts", key: "failed", record: { subject: "Failed" } } },
15
+ { id: "b", phase: "result", name: "memory_upsert", payload: JSON.stringify({ ok: false, error: "denied" }) },
16
+ { id: "c", phase: "call", name: "memory_upsert", payload: { namespace: "facts", key: "mismatch", record: { subject: "Mismatch" } } },
17
+ { id: "c", phase: "result", name: "memory_upsert", payload: JSON.stringify({ ok: true, key: "other" }) },
18
+ { id: "d", phase: "call", name: "memory_write", payload: { namespace: "state", key: "last_run", value: "x" } },
19
+ { id: "d", phase: "result", name: "memory_write", payload: JSON.stringify({ ok: true, key: "last_run" }) },
20
+ ),
21
+ };
22
+ expect(savedMemoryFacts(row)).toEqual([
23
+ { subject: "editor", content: "Uses VS Code.", tags: [], confidence: "explicit", key: "facts/editor", origin: "agent" },
24
+ ]);
25
+ });
26
+ });
27
+
28
+ describe("canMergeIntoTopics", () => {
29
+ const topic = { title: "t", start_seq: 1, end_seq: 4, start_at: "", end_at: "", recap: "r", facts: [], message_count: 4 };
30
+
31
+ it("extends stored topics only when the boundary moved forward and every topic carries its counts", () => {
32
+ expect(canMergeIntoTopics([topic], 5, 9)).toBe(true);
33
+ expect(canMergeIntoTopics([topic], 5, 5)).toBe(false);
34
+ expect(canMergeIntoTopics([{ ...topic, message_count: undefined }], 5, 9)).toBe(false);
35
+ expect(canMergeIntoTopics([topic], null, 9)).toBe(false);
36
+ });
37
+ });
@@ -0,0 +1,297 @@
1
+ import { transcriptText, type SummaryTopicFact, type SummaryTopicSegment } from "@/lib/agents/conversation-summary";
2
+ import type { PersistedToolEvent } from "@/lib/stores/threads";
3
+
4
+ // Deterministic half of warm-context compaction. The summarizer model only
5
+ // segments and recaps; everything that can be checked or computed in code —
6
+ // message counts, which topic a saved memory belongs to, merging into the
7
+ // stored topics, and fading out the oldest ones — lives here.
8
+
9
+ export interface WarmTopicSourceRow {
10
+ seq: number;
11
+ content: string;
12
+ tool_events?: string | null;
13
+ }
14
+
15
+ const MAX_TOPIC_FACTS = 16;
16
+ const MEMORY_WRITE_NAMESPACES = new Set(["facts"]);
17
+
18
+ /** Stable id the compaction pipeline uses to refer to stored topic `index`. */
19
+ export function warmTopicId(index: number): string {
20
+ return `t${index + 1}`;
21
+ }
22
+
23
+ function rowsInRange<T extends WarmTopicSourceRow>(rows: readonly T[], topic: SummaryTopicSegment): T[] {
24
+ return rows.filter((row) => row.seq >= (topic.start_seq ?? Infinity) && row.seq <= (topic.end_seq ?? -Infinity));
25
+ }
26
+
27
+ export function slugifyForMemoryKey(subject: string): string {
28
+ return subject
29
+ .toLowerCase()
30
+ .replace(/[^a-z0-9]+/g, "-")
31
+ .replace(/^-+|-+$/g, "")
32
+ .slice(0, 80);
33
+ }
34
+
35
+ /**
36
+ * Merge facts by subject (case-insensitive) and memory key. Later entries win,
37
+ * so callers pass the newer or more trustworthy list last. Keeps the newest
38
+ * MAX_TOPIC_FACTS.
39
+ */
40
+ export function mergeTopicFacts(...lists: readonly (readonly SummaryTopicFact[])[]): SummaryTopicFact[] {
41
+ const merged = new Map<string, SummaryTopicFact>();
42
+ const keyToSubject = new Map<string, string>();
43
+ for (const list of lists) {
44
+ for (const fact of list) {
45
+ const subjectId = fact.subject.trim().toLowerCase();
46
+ const existingSubject = fact.key ? keyToSubject.get(fact.key) : undefined;
47
+ if (existingSubject && existingSubject !== subjectId) merged.delete(existingSubject);
48
+ merged.delete(subjectId);
49
+ merged.set(subjectId, fact);
50
+ if (fact.key) keyToSubject.set(fact.key, subjectId);
51
+ }
52
+ }
53
+ return [...merged.values()].slice(-MAX_TOPIC_FACTS);
54
+ }
55
+
56
+ /**
57
+ * A topic must span at least two messages. Fold any single-message topic into
58
+ * the previous topic (or the next one when it is first). Input must be the
59
+ * ordered, non-overlapping output of validateTopicSegments.
60
+ */
61
+ export function foldSingleMessageTopics(
62
+ topics: readonly SummaryTopicSegment[],
63
+ rows: readonly WarmTopicSourceRow[],
64
+ ): SummaryTopicSegment[] {
65
+ const out = topics.map((topic) => ({ ...topic, facts: [...topic.facts] }));
66
+ let index = 0;
67
+ while (out.length > 1 && index < out.length) {
68
+ if (rowsInRange(rows, out[index]).length >= 2) {
69
+ index += 1;
70
+ continue;
71
+ }
72
+ const single = out[index];
73
+ const targetIndex = index > 0 ? index - 1 : 1;
74
+ const target = out[targetIndex];
75
+ const [first, second] = targetIndex < index ? [target, single] : [single, target];
76
+ out[targetIndex] = {
77
+ ...target,
78
+ start_seq: first.start_seq,
79
+ start_at: first.start_at,
80
+ partial_start: first.partial_start,
81
+ end_seq: second.end_seq,
82
+ end_at: second.end_at,
83
+ recap: targetIndex < index ? `${target.recap} ${single.recap}` : `${single.recap} ${target.recap}`,
84
+ facts: mergeTopicFacts(target.facts, single.facts),
85
+ continues: target.continues ?? single.continues,
86
+ };
87
+ out.splice(index, 1);
88
+ if (targetIndex < index) index = targetIndex;
89
+ }
90
+ return out;
91
+ }
92
+
93
+ function toolResultText(payload: unknown): string | null {
94
+ if (typeof payload === "string") return payload;
95
+ if (!payload || typeof payload !== "object") return null;
96
+ const obj = payload as Record<string, unknown>;
97
+ if (obj.__truncated) return null;
98
+ const kwargs = obj.kwargs as Record<string, unknown> | undefined;
99
+ if (typeof kwargs?.content === "string") return kwargs.content;
100
+ if (typeof obj.content === "string") return obj.content;
101
+ return JSON.stringify(obj);
102
+ }
103
+
104
+ function parseObject(value: unknown): Record<string, unknown> | null {
105
+ if (value && typeof value === "object" && !Array.isArray(value)) return value as Record<string, unknown>;
106
+ if (typeof value !== "string") return null;
107
+ try {
108
+ const parsed = JSON.parse(value) as unknown;
109
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed as Record<string, unknown> : null;
110
+ } catch {
111
+ return null;
112
+ }
113
+ }
114
+
115
+ function unwrapCall(event: PersistedToolEvent): { name: string; args: Record<string, unknown> } | null {
116
+ const payload = parseObject(event.payload);
117
+ if (!payload) return null;
118
+ if (event.name !== "invoke_tool") return { name: event.name, args: payload };
119
+ const name = typeof payload.name === "string" ? payload.name : "";
120
+ const args = parseObject(payload.args_json) ?? parseObject(payload.args) ?? {};
121
+ return name ? { name, args } : null;
122
+ }
123
+
124
+ function savedFactFromCall(name: string, args: Record<string, unknown>, key: string): SummaryTopicFact | null {
125
+ const namespace = typeof args.namespace === "string" ? args.namespace : "";
126
+ if (name === "memory_upsert") {
127
+ const record = parseObject(args.record) ?? {};
128
+ const subject = typeof record.subject === "string" && record.subject.trim() ? record.subject.trim() : key;
129
+ const content = typeof record.content === "string" ? record.content.trim() : "";
130
+ const confidence = record.confidence === "explicit" || record.confidence === "inferred" || record.confidence === "verified"
131
+ ? record.confidence
132
+ : "explicit";
133
+ const tags = Array.isArray(record.tags) ? record.tags.filter((t): t is string => typeof t === "string").slice(0, 16) : [];
134
+ return { subject: subject.slice(0, 160), content: content.slice(0, 1_000), tags, confidence, key: `${namespace}/${key}`, origin: "agent" };
135
+ }
136
+ if (name === "memory_write" && MEMORY_WRITE_NAMESPACES.has(namespace)) {
137
+ const value = typeof args.value === "string" ? args.value.trim() : "";
138
+ return { subject: key, content: value.slice(0, 1_000), tags: [], confidence: "explicit", key: `${namespace}/${key}`, origin: "agent" };
139
+ }
140
+ return null;
141
+ }
142
+
143
+ /**
144
+ * Memory records the agent saved in a message, verified by the tool result
145
+ * (`ok: true` echoing the same key). Unverified or failed writes are skipped.
146
+ */
147
+ export function savedMemoryFacts(row: WarmTopicSourceRow): SummaryTopicFact[] {
148
+ if (!row.tool_events) return [];
149
+ let events: PersistedToolEvent[];
150
+ try {
151
+ const parsed = JSON.parse(row.tool_events) as unknown;
152
+ if (!Array.isArray(parsed)) return [];
153
+ events = parsed as PersistedToolEvent[];
154
+ } catch {
155
+ return [];
156
+ }
157
+ const calls = new Map<string, { name: string; args: Record<string, unknown> }>();
158
+ for (const event of events) {
159
+ if (event?.phase !== "call") continue;
160
+ const call = unwrapCall(event);
161
+ if (call && (call.name === "memory_upsert" || call.name === "memory_write")) calls.set(event.id, call);
162
+ }
163
+ const facts: SummaryTopicFact[] = [];
164
+ for (const event of events) {
165
+ if (event?.phase !== "result") continue;
166
+ const call = calls.get(event.id);
167
+ if (!call) continue;
168
+ const text = toolResultText(event.payload);
169
+ let result = text ? parseObject(text) : null;
170
+ if (result && typeof result.result === "string") result = parseObject(result.result) ?? result;
171
+ const key = typeof call.args.key === "string" ? call.args.key : "";
172
+ if (!result || result.ok !== true || !key || (typeof result.key === "string" && result.key !== key)) continue;
173
+ const fact = savedFactFromCall(call.name, call.args, key);
174
+ if (fact) facts.push(fact);
175
+ }
176
+ return facts;
177
+ }
178
+
179
+ /**
180
+ * Attach the code-derived fields to one topic: message count and size of the
181
+ * rows it covers, keys for extracted facts, and memory the agent saved there.
182
+ */
183
+ export function finalizeTopic(
184
+ topic: SummaryTopicSegment,
185
+ covered: readonly WarmTopicSourceRow[],
186
+ ): SummaryTopicSegment {
187
+ const extracted = topic.facts.map((fact): SummaryTopicFact => ({
188
+ ...fact,
189
+ key: fact.key ?? `facts/${slugifyForMemoryKey(fact.subject)}`,
190
+ origin: fact.origin ?? "compaction",
191
+ }));
192
+ return {
193
+ ...topic,
194
+ facts: mergeTopicFacts(extracted, covered.flatMap(savedMemoryFacts)),
195
+ message_count: covered.length,
196
+ source_chars: covered.reduce((total, row) => total + transcriptText(row.content).length, 0),
197
+ };
198
+ }
199
+
200
+ /**
201
+ * Turn validated summarizer topics into stored topics: fold single-message
202
+ * topics, then finalize each against the rows in its seq range.
203
+ */
204
+ export function finalizeFreshTopics(
205
+ topics: readonly SummaryTopicSegment[],
206
+ rows: readonly WarmTopicSourceRow[],
207
+ ): SummaryTopicSegment[] {
208
+ return foldSingleMessageTopics(topics, rows).map((topic) => finalizeTopic(topic, rowsInRange(rows, topic)));
209
+ }
210
+
211
+ /** Stored topics can be extended incrementally only when every one carries its message count and seq range. */
212
+ export function canMergeIntoTopics(
213
+ prior: readonly SummaryTopicSegment[] | null | undefined,
214
+ priorBeforeSeq: number | null | undefined,
215
+ boundarySeq: number,
216
+ ): prior is SummaryTopicSegment[] {
217
+ if (!prior || prior.length === 0 || priorBeforeSeq == null || boundarySeq <= priorBeforeSeq) return false;
218
+ return prior.every((topic) =>
219
+ Number.isSafeInteger(topic.start_seq)
220
+ && Number.isSafeInteger(topic.end_seq)
221
+ && topic.end_seq! < priorBeforeSeq
222
+ && typeof topic.message_count === "number"
223
+ && Array.isArray(topic.facts),
224
+ );
225
+ }
226
+
227
+ /** Model-facing text for stored topics: one heading per topic, its recap, and the memory keys it produced. */
228
+ export function renderTopicRecaps(topics: readonly SummaryTopicSegment[]): string {
229
+ return topics.map((topic) => {
230
+ const memorized = topic.facts.flatMap((fact) => fact.key ? [fact.key] : []);
231
+ return [
232
+ `### ${topic.title}${topic.partial_start ? " (partial; earlier messages omitted)" : ""}`,
233
+ topic.recap,
234
+ ...(memorized.length > 0 ? [`Memorized: ${memorized.join(", ")}`] : []),
235
+ ].join("\n");
236
+ }).join("\n\n");
237
+ }
238
+
239
+ export interface MergedWarmTopics {
240
+ topics: SummaryTopicSegment[];
241
+ sourceMessages: number;
242
+ sourceChars: number;
243
+ evicted: number;
244
+ }
245
+
246
+ /**
247
+ * Fold fresh topics into the stored ones, newest last. A fresh topic that
248
+ * `continues` a stored one updates it in place (newer recap, merged facts,
249
+ * summed counts). Then the least recently active topics fade out until the
250
+ * kept topics fit `messageLimit`, mirroring how memory keeps recent detail.
251
+ * Their facts already live in the memory store, so eviction loses no record.
252
+ */
253
+ export function mergeWarmTopics(
254
+ prior: readonly SummaryTopicSegment[],
255
+ fresh: readonly SummaryTopicSegment[],
256
+ messageLimit: number,
257
+ ): MergedWarmTopics {
258
+ const out: SummaryTopicSegment[] = prior.map((topic) => ({ ...topic, facts: [...topic.facts] }));
259
+ const indexById = new Map(prior.map((_, index) => [warmTopicId(index), index]));
260
+ for (const topic of fresh) {
261
+ const { continues, ...clean } = topic;
262
+ const index = continues ? indexById.get(continues) : undefined;
263
+ if (index === undefined) {
264
+ out.push(clean);
265
+ continue;
266
+ }
267
+ const base = out[index];
268
+ out[index] = {
269
+ ...base,
270
+ title: clean.title,
271
+ end_seq: clean.end_seq,
272
+ end_at: clean.end_at,
273
+ recap: clean.recap,
274
+ facts: mergeTopicFacts(base.facts, clean.facts),
275
+ message_count: (base.message_count ?? 0) + (clean.message_count ?? 0),
276
+ source_chars: (base.source_chars ?? 0) + (clean.source_chars ?? 0),
277
+ };
278
+ }
279
+ out.sort((a, b) => (a.end_seq ?? 0) - (b.end_seq ?? 0));
280
+
281
+ let total = out.reduce((sum, topic) => sum + (topic.message_count ?? 0), 0);
282
+ let evicted = 0;
283
+ while (out.length > 1 && total > messageLimit) {
284
+ total -= out[0].message_count ?? 0;
285
+ out.shift();
286
+ evicted += 1;
287
+ }
288
+ return {
289
+ topics: out,
290
+ // The warm cache treats a count above the limit as an oversized legacy
291
+ // summary and rebuilds it; one topic larger than the limit is still a
292
+ // bounded, merged recap, so report it at the limit.
293
+ sourceMessages: Math.min(total, messageLimit),
294
+ sourceChars: out.reduce((sum, topic) => sum + (topic.source_chars ?? 0), 0),
295
+ evicted,
296
+ };
297
+ }
@@ -0,0 +1,96 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import {
3
+ buildWorkflowStepRetryNudge,
4
+ collectWorkflowContractFailures,
5
+ planWorkflowStepRetries,
6
+ WORKFLOW_STEP_MAX_ATTEMPTS,
7
+ workflowProgressArgs,
8
+ } from "./workflow-step-retry";
9
+
10
+ const item = (id: string, status: string, extra: Record<string, unknown> = {}) => ({
11
+ id, label: `Step ${id}`, input: "in", output: "out", validation: "check", status, ...extra,
12
+ });
13
+ const ok = (workflowId: string, checklist: unknown[], phase: string | null = null, error: string | null = null) =>
14
+ JSON.stringify({ ok: true, workflow_id: workflowId, state: { phase, summary: "", error, checklist } });
15
+
16
+ describe("collectWorkflowContractFailures", () => {
17
+ it("passes a workflow whose steps are verified or pending", () => {
18
+ expect(collectWorkflowContractFailures([
19
+ { args: { workflow_id: "w" }, result: ok("w", [item("a", "done", { validation_evidence: "ran" }), item("b", "pending")]) },
20
+ ])).toEqual([]);
21
+ });
22
+
23
+ it("flags a rejected update and names the step that broke the contract", () => {
24
+ const failures = collectWorkflowContractFailures([
25
+ { args: { workflow_id: "w", items: [item("a", "done")] }, result: JSON.stringify({ ok: false, workflow_id: "w", error: "Every completed workflow item requires observed validation_evidence." }) },
26
+ ]);
27
+ expect(failures).toEqual([expect.objectContaining({ key: "w:a", itemId: "a", label: "Step a" })]);
28
+ expect(failures[0].reason).toContain("validation_evidence");
29
+ });
30
+
31
+ it("clears a rejection once a later update for the same workflow is accepted", () => {
32
+ expect(collectWorkflowContractFailures([
33
+ { args: { workflow_id: "w", items: [item("a", "done")] }, result: { ok: false, workflow_id: "w", error: "x" } },
34
+ { args: { workflow_id: "w" }, result: ok("w", [item("a", "done", { validation_evidence: "ran" })]) },
35
+ ])).toEqual([]);
36
+ });
37
+
38
+ it("flags steps left checking or needing attention at turn end", () => {
39
+ const failures = collectWorkflowContractFailures([
40
+ { args: { workflow_id: "w" }, result: ok("w", [item("a", "checking"), item("b", "needs_attention")], null, "tests failed") },
41
+ ]);
42
+ expect(failures.map((f) => f.key)).toEqual(["w:a", "w:b"]);
43
+ expect(failures[1].reason).toContain("tests failed");
44
+ });
45
+
46
+ it("does not retry steps that are waiting on the user", () => {
47
+ expect(collectWorkflowContractFailures([
48
+ { args: { workflow_id: "w" }, result: ok("w", [item("a", "needs_attention", { needs_user: true })]) },
49
+ { args: { workflow_id: "version_adoption", item_id: "review-tools", status: "needs_attention", needs_user: true }, result: ok("version_adoption", [item("review-tools", "needs_attention")]) },
50
+ ])).toEqual([]);
51
+ });
52
+
53
+ it("ignores completed workflows and reads invoke_tool envelopes", () => {
54
+ expect(collectWorkflowContractFailures([
55
+ { args: { workflow_id: "w" }, result: ok("w", [item("a", "checking")], "complete") },
56
+ ])).toEqual([]);
57
+ expect(collectWorkflowContractFailures([
58
+ { args: { workflow_id: "w" }, result: { ok: true, tool: "workflow_progress", status: "done", result: ok("w", [item("a", "checking")]) } },
59
+ ]).map((f) => f.key)).toEqual(["w:a"]);
60
+ });
61
+ });
62
+
63
+ describe("workflowProgressArgs", () => {
64
+ it("unwraps direct and proxied workflow_progress calls only", () => {
65
+ expect(workflowProgressArgs("workflow_progress", { workflow_id: "w" })).toEqual({ workflow_id: "w" });
66
+ expect(workflowProgressArgs("invoke_tool", { name: "workflow_progress", args_json: "{\"workflow_id\":\"w\"}" })).toEqual({ workflow_id: "w" });
67
+ expect(workflowProgressArgs("invoke_tool", { name: "file_read", args_json: "{}" })).toBeNull();
68
+ expect(workflowProgressArgs("file_read", { workflow_id: "w" })).toBeNull();
69
+ });
70
+ });
71
+
72
+ describe("planWorkflowStepRetries", () => {
73
+ const failure = { key: "w:a", workflowId: "w", itemId: "a", label: "Step a", reason: "r" };
74
+
75
+ it(`allows ${WORKFLOW_STEP_MAX_ATTEMPTS} total attempts per step`, () => {
76
+ expect(planWorkflowStepRetries([failure]).retry).toEqual([{ ...failure, attempt: 2 }]);
77
+ expect(planWorkflowStepRetries([failure], { "w:a": 1 }).retry).toEqual([{ ...failure, attempt: 3 }]);
78
+ const exhausted = planWorkflowStepRetries([failure], { "w:a": 2 });
79
+ expect(exhausted.retry).toEqual([]);
80
+ expect(exhausted.exhausted).toEqual([failure]);
81
+ });
82
+ });
83
+
84
+ describe("buildWorkflowStepRetryNudge", () => {
85
+ it("states the attempt, the failure, and the exact progress call for each workflow kind", () => {
86
+ const nudge = buildWorkflowStepRetryNudge([
87
+ { key: "w:a", workflowId: "w", itemId: "a", label: "Step a", reason: "validation failed", attempt: 2 },
88
+ { key: "version_adoption:review-tools", workflowId: "version_adoption", itemId: "review-tools", label: "Review tools", reason: "left checking", attempt: 3 },
89
+ ]);
90
+ expect(nudge).toContain(`attempt 2 of ${WORKFLOW_STEP_MAX_ATTEMPTS}`);
91
+ expect(nudge).toContain("complete items snapshot");
92
+ expect(nudge).toContain('item_id: "review-tools"');
93
+ expect(nudge).toContain("needs_user: true");
94
+ expect(nudge).not.toMatch(/undefined|NaN|\[object Object\]/);
95
+ });
96
+ });
@@ -0,0 +1,216 @@
1
+ // Workflow-step contract enforcement. Every workflow_progress step promises
2
+ // an input, an output, and a validation check; a model can still end a turn
3
+ // with a rejected update, a step left mid-flight, or a step whose validation
4
+ // failed. This module detects those breaches from the turn's own tool results
5
+ // (code, not model judgement) and builds the targeted auto-retry nudge.
6
+
7
+ /** Total attempts per step: the original attempt plus two automatic retries. */
8
+ export const WORKFLOW_STEP_MAX_ATTEMPTS = 3;
9
+ export const WORKFLOW_STEP_AUTO_RETRIES = WORKFLOW_STEP_MAX_ATTEMPTS - 1;
10
+ /** Hard cap on automatic workflow retries in one turn, across all steps. */
11
+ export const WORKFLOW_TURN_AUTO_RETRY_LIMIT = 6;
12
+
13
+ export interface WorkflowProgressObservation {
14
+ args: unknown;
15
+ result: unknown;
16
+ }
17
+
18
+ export interface WorkflowStepFailure {
19
+ key: string;
20
+ workflowId: string;
21
+ itemId: string | null;
22
+ label: string;
23
+ reason: string;
24
+ }
25
+
26
+ type JsonObject = Record<string, unknown>;
27
+
28
+ function asObject(value: unknown): JsonObject | null {
29
+ if (typeof value === "string") {
30
+ try { return asObject(JSON.parse(value)); } catch { return null; }
31
+ }
32
+ if (value && typeof value === "object" && !Array.isArray(value)) {
33
+ const obj = value as JsonObject;
34
+ // LangChain ToolMessage-ish wrappers carry the JSON string in `content`
35
+ // or `kwargs.content`.
36
+ if (obj.workflow_id === undefined) {
37
+ // invoke_tool envelope: { ok, tool, status, result }.
38
+ if (obj.tool === "workflow_progress" && obj.result !== undefined) return asObject(obj.result);
39
+ const kwargs = asPlainObject(obj.kwargs);
40
+ const content = obj.content ?? kwargs?.content;
41
+ if (typeof content === "string") return asObject(content);
42
+ }
43
+ return obj;
44
+ }
45
+ return null;
46
+ }
47
+
48
+ function asPlainObject(value: unknown): JsonObject | null {
49
+ return value && typeof value === "object" && !Array.isArray(value) ? value as JsonObject : null;
50
+ }
51
+
52
+ function str(value: unknown): string | null {
53
+ return typeof value === "string" && value.trim() ? value.trim() : null;
54
+ }
55
+
56
+ /** Normalizes a direct workflow_progress call or an invoke_tool proxy of one. */
57
+ export function workflowProgressArgs(name: string, args: unknown): JsonObject | null {
58
+ const obj = asPlainObject(args);
59
+ if (!obj) return null;
60
+ if (name === "workflow_progress") return obj;
61
+ if (name === "invoke_tool" && obj.name === "workflow_progress") {
62
+ const inner = obj.args_json ?? obj.args;
63
+ return asObject(inner);
64
+ }
65
+ return null;
66
+ }
67
+
68
+ function labelFor(itemId: string | null, items: unknown): string {
69
+ if (!itemId) return "workflow update";
70
+ if (Array.isArray(items)) {
71
+ for (const raw of items) {
72
+ const item = asPlainObject(raw);
73
+ if (item?.id === itemId && str(item.label)) return str(item.label)!;
74
+ }
75
+ }
76
+ return itemId.replace(/[_-]/g, " ");
77
+ }
78
+
79
+ function rejectedItemId(args: JsonObject | null): string | null {
80
+ if (!args) return null;
81
+ if (str(args.item_id)) return str(args.item_id);
82
+ if (Array.isArray(args.items)) {
83
+ for (const raw of args.items) {
84
+ const item = asPlainObject(raw);
85
+ if (item?.status === "done" && !str(item.validation_evidence) && str(item.id)) return str(item.id);
86
+ }
87
+ }
88
+ return null;
89
+ }
90
+
91
+ /**
92
+ * Returns the contract breaches still standing at the end of the turn, in
93
+ * the order the workflows were last touched. A later accepted update for the
94
+ * same workflow clears an earlier rejection.
95
+ */
96
+ export function collectWorkflowContractFailures(observations: readonly WorkflowProgressObservation[]): WorkflowStepFailure[] {
97
+ type Entry = {
98
+ rejected: { itemId: string | null; label: string; error: string } | null;
99
+ checklist: unknown[];
100
+ phase: string | null;
101
+ error: string | null;
102
+ needsUser: Set<string>;
103
+ };
104
+ const latest = new Map<string, Entry>();
105
+ for (const { args, result } of observations) {
106
+ const payload = asObject(result);
107
+ const callArgs = asPlainObject(args);
108
+ const workflowId = str(payload?.workflow_id) ?? str(callArgs?.workflow_id);
109
+ if (!workflowId) continue;
110
+ const previous: Entry = latest.get(workflowId) ?? { rejected: null, checklist: [], phase: null, error: null, needsUser: new Set<string>() };
111
+ latest.delete(workflowId);
112
+ if (payload?.ok === false) {
113
+ const itemId = rejectedItemId(callArgs);
114
+ latest.set(workflowId, {
115
+ ...previous,
116
+ rejected: {
117
+ itemId,
118
+ label: labelFor(itemId, callArgs?.items ?? previous.checklist),
119
+ error: str(payload.error) ?? "the update was rejected",
120
+ },
121
+ });
122
+ continue;
123
+ }
124
+ const state = asPlainObject(payload?.state);
125
+ const needsUser = new Set(previous.needsUser);
126
+ const updatedItemId = str(callArgs?.item_id);
127
+ if (updatedItemId) {
128
+ if (callArgs?.needs_user === true) needsUser.add(updatedItemId);
129
+ else needsUser.delete(updatedItemId);
130
+ }
131
+ latest.set(workflowId, {
132
+ rejected: null,
133
+ checklist: Array.isArray(state?.checklist) ? state.checklist : previous.checklist,
134
+ phase: typeof state?.phase === "string" ? state.phase : null,
135
+ error: str(state?.error),
136
+ needsUser,
137
+ });
138
+ }
139
+
140
+ const failures: WorkflowStepFailure[] = [];
141
+ for (const [workflowId, entry] of latest) {
142
+ if (entry.rejected) {
143
+ const { itemId, label, error } = entry.rejected;
144
+ failures.push({
145
+ key: `${workflowId}:${itemId ?? "*"}`,
146
+ workflowId,
147
+ itemId,
148
+ label,
149
+ reason: `workflow_progress rejected the update: ${error}`,
150
+ });
151
+ continue;
152
+ }
153
+ if (entry.phase === "complete") continue;
154
+ for (const raw of entry.checklist) {
155
+ const item = asPlainObject(raw);
156
+ const itemId = str(item?.id);
157
+ if (!item || !itemId || item.needs_user === true || entry.needsUser.has(itemId)) continue;
158
+ const label = str(item.label) ?? itemId;
159
+ if (item.status === "checking") {
160
+ failures.push({
161
+ key: `${workflowId}:${itemId}`,
162
+ workflowId,
163
+ itemId,
164
+ label,
165
+ reason: "the step was started but the turn ended before its output was validated",
166
+ });
167
+ } else if (item.status === "needs_attention") {
168
+ const why = entry.error;
169
+ failures.push({
170
+ key: `${workflowId}:${itemId}`,
171
+ workflowId,
172
+ itemId,
173
+ label,
174
+ reason: `the step's validation did not pass (needs_attention${why ? `: ${why}` : ""})`,
175
+ });
176
+ }
177
+ }
178
+ }
179
+ return failures;
180
+ }
181
+
182
+ /** Splits failures into those with automatic retries left and those exhausted. */
183
+ export function planWorkflowStepRetries(
184
+ failures: readonly WorkflowStepFailure[],
185
+ spent: Readonly<Record<string, number>> = {},
186
+ ): { retry: Array<WorkflowStepFailure & { attempt: number }>; exhausted: WorkflowStepFailure[] } {
187
+ const retry: Array<WorkflowStepFailure & { attempt: number }> = [];
188
+ const exhausted: WorkflowStepFailure[] = [];
189
+ for (const failure of failures) {
190
+ const used = spent[failure.key] ?? 0;
191
+ if (used < WORKFLOW_STEP_AUTO_RETRIES) retry.push({ ...failure, attempt: used + 2 });
192
+ else exhausted.push(failure);
193
+ }
194
+ return { retry, exhausted };
195
+ }
196
+
197
+ export function workflowStepRetryInstruction(workflowId: string, itemId: string | null, label: string): string {
198
+ if (!itemId) {
199
+ return `Resend the \`workflow_progress\` update for workflow \`${workflowId}\` so it satisfies the contract.`;
200
+ }
201
+ const progressUpdate = workflowId === "version_adoption"
202
+ ? `Call \`workflow_progress\` with \`workflow_id: "version_adoption"\`, \`item_id: "${itemId}"\`, and \`status: "checking"\``
203
+ : `Call \`workflow_progress\` for workflow \`${workflowId}\` with the complete items snapshot, setting this step to \`checking\``;
204
+ return `${progressUpdate}, then redo "${label}" from its stated input and run its validation again. Finally mark it \`done\` with newly observed \`validation_evidence\`, or \`needs_attention\` with the reason.`;
205
+ }
206
+
207
+ export function buildWorkflowStepRetryNudge(retries: ReadonlyArray<WorkflowStepFailure & { attempt: number }>): string {
208
+ const lines = retries.map((failure) => (
209
+ `- "${failure.label}" in \`${failure.workflowId}\` (attempt ${failure.attempt} of ${WORKFLOW_STEP_MAX_ATTEMPTS}): ${failure.reason}. ${workflowStepRetryInstruction(failure.workflowId, failure.itemId, failure.label)}`
210
+ ));
211
+ return [
212
+ `↻ Auto-retry: ${retries.length === 1 ? "a workflow step has" : `${retries.length} workflow steps have`} not met the step contract (input → output → validation):`,
213
+ ...lines,
214
+ "Work only on these steps and leave the others unchanged. Do not reuse earlier evidence or claim a result you did not observe. If a step is genuinely paused for the user's approval or input, mark it `needs_attention` with `needs_user: true` and say what you need instead of retrying.",
215
+ ].join("\n");
216
+ }
@@ -663,6 +663,3 @@ export async function handleBrowserRetry(req: Request): Promise<Response> {
663
663
  if (!entry.retryable || !entry.retry_payload) return jsonResponse({ error: "browser command is not retryable" }, 409);
664
664
  return awaitBrowserCommand(entry.retry_payload, parsed.data.timeout_ms ?? 30_000);
665
665
  }
666
-
667
- /** @internal — exported for the agent-side tool layer; do not import elsewhere. */
668
- export { CommandShape as _CommandShape };
@@ -629,6 +629,11 @@ function ensureThreadChannelSummariesTable(db: DatabaseSync): void {
629
629
  if (!cols.some((column) => column.name === "summary_before_seq")) {
630
630
  db.exec("ALTER TABLE thread_channel_summaries ADD COLUMN summary_before_seq INTEGER");
631
631
  }
632
+ // Stored topic segments (JSON array) so the next compaction can merge new
633
+ // activity into them instead of re-summarising the channel from scratch.
634
+ if (!cols.some((column) => column.name === "topics")) {
635
+ db.exec("ALTER TABLE thread_channel_summaries ADD COLUMN topics TEXT");
636
+ }
632
637
  }
633
638
 
634
639
  // ADR-0041. Immutable per-assistant-turn snapshot of LLM usage. Written once