@tea-agent/loop-agent 0.51.0 → 0.52.0-next.10

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 (234) hide show
  1. package/CHANGELOG.md +123 -5
  2. package/dist/build-stamp.json +3 -3
  3. package/dist/cli/command-definitions.js +1 -75
  4. package/dist/cli/help.js +1 -1
  5. package/dist/cli/program.js +1 -28
  6. package/dist/commands/init-accepted-merge.js +46 -0
  7. package/dist/commands/init-upgrade.js +115 -2
  8. package/dist/commands/init.js +79 -12
  9. package/dist/executors/pi-sdk-executor.js +3 -3
  10. package/dist/governance/path-guard.js +2 -0
  11. package/dist/records/harvest.js +1 -1
  12. package/dist/shared/git-progress.js +3 -0
  13. package/dist/shared/operator/capabilities.js +0 -122
  14. package/dist/shared/pi-context-pressure/checkpoint.js +94 -24
  15. package/dist/shared/pi-context-pressure/compaction-policy.js +152 -66
  16. package/dist/shared/pi-context-pressure/extension.js +25 -8
  17. package/dist/shared/pi-context-pressure/index.js +1 -1
  18. package/dist/shared/pi-context-pressure/telemetry.js +10 -0
  19. package/dist/shared/update/npm-client.js +14 -3
  20. package/dist/task/config-types.js +5 -10
  21. package/dist/task/delegate.js +1 -1
  22. package/dist/task/read-model.js +0 -4
  23. package/dist/task/runtime.js +0 -1
  24. package/dist/task/worktree.js +1 -1
  25. package/dist/worker/console/chat/api-workbench-core.js +17 -6
  26. package/dist/worker/console/chat/api-workbench.js +2 -0
  27. package/dist/worker/console/chat/assistant-content.js +21 -3
  28. package/dist/worker/console/chat/chat-event-projection.js +6 -0
  29. package/dist/worker/console/chat/chat-event-store.js +32 -2
  30. package/dist/worker/console/chat/chat-references.js +4 -0
  31. package/dist/worker/console/chat/compaction-errors.js +14 -2
  32. package/dist/worker/console/chat/context-insights.js +41 -4
  33. package/dist/worker/console/chat/context-usage.js +4 -1
  34. package/dist/worker/console/chat/pi-runtime/custom-tools/apiworkbench-tools.js +65 -3
  35. package/dist/worker/console/chat/pi-runtime/custom-tools/browser-tools.js +2 -2
  36. package/dist/worker/console/chat/pi-runtime/extension-bindings.js +39 -0
  37. package/dist/worker/console/chat/pi-runtime/sdk-bindings.js +4 -0
  38. package/dist/worker/console/chat/pi-runtime.js +389 -191
  39. package/dist/worker/console/chat/repo-browser.js +5 -2
  40. package/dist/worker/console/chat/repo-preview-kind.js +16 -6
  41. package/dist/worker/console/chat/routes.js +299 -25
  42. package/dist/worker/console/chat/scheduled-goal-request.js +1 -1
  43. package/dist/worker/console/chat/subagents/jobs.js +115 -4
  44. package/dist/worker/console/chat/terminal-sessions.js +52 -6
  45. package/dist/worker/console/chat/tool-exposure-catalog.js +1 -1
  46. package/dist/worker/console/chat/tool-presentation.js +17 -10
  47. package/dist/worker/console/chat/tool-preview.js +22 -0
  48. package/dist/worker/console/chat/turn-process.js +49 -0
  49. package/dist/worker/console/chat/vcp-prompt.js +14 -9
  50. package/dist/worker/console/chat/workspace-changes.js +17 -0
  51. package/dist/worker/console/console-update-runtime.js +5 -1
  52. package/dist/worker/console/operator-actions.js +7 -6
  53. package/dist/worker/console/operator-user-error.js +5 -1
  54. package/dist/worker/console/pi-compaction-settings.js +220 -0
  55. package/dist/worker/console/routes.js +1 -1
  56. package/dist/worker/console/server.js +148 -6
  57. package/dist/worker/console/static/assets/FilePreviewDocx-ybM3ZqSl.js +9 -0
  58. package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-CT26sIgH.js +1 -0
  59. package/dist/worker/console/static/assets/{arc-Bkf_oc0_.js → arc-CPwLqDB0.js} +1 -1
  60. package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-CzTSMPU_.js +36 -0
  61. package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-D62uVvbI.js → blockDiagram-VBNYF7ZC-BfgbtJLH.js} +1 -1
  62. package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-Iq0Y8Afx.js → c4Diagram-5PPSVZJV-B9pTjB8U.js} +1 -1
  63. package/dist/worker/console/static/assets/channel-DtYRMDck.js +1 -0
  64. package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-D1TxRE3k.js → chunk-2GRJ4B5K-xORV8QsC.js} +1 -1
  65. package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-BE-DHkAO.js → chunk-2Q5K7J3B-BzpYWAHK.js} +1 -1
  66. package/dist/worker/console/static/assets/{chunk-5RXB4S5H-t0iYO8Cc.js → chunk-5RXB4S5H-D8zcRP6c.js} +1 -1
  67. package/dist/worker/console/static/assets/{chunk-5VM5RSS4-Clo2nExi.js → chunk-5VM5RSS4-DVEXxzQJ.js} +1 -1
  68. package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-C7bSpo-3.js → chunk-6Q2QTUOP-CKZOJU2z.js} +1 -1
  69. package/dist/worker/console/static/assets/{chunk-GF5L2VYU-DorZaymh.js → chunk-GF5L2VYU-Cgx34Dj8.js} +1 -1
  70. package/dist/worker/console/static/assets/{chunk-JWPE2WC7-Ch_4HvyJ.js → chunk-JWPE2WC7-ehcSKOcx.js} +1 -1
  71. package/dist/worker/console/static/assets/{chunk-KBJHAD2P-yaSoFe-3.js → chunk-KBJHAD2P-CiY9emCG.js} +1 -1
  72. package/dist/worker/console/static/assets/{chunk-RYQCIY6F-QpjaXecS.js → chunk-RYQCIY6F-Bk9X-ksQ.js} +1 -1
  73. package/dist/worker/console/static/assets/{chunk-XXDRQBXY-B3t6cycg.js → chunk-XXDRQBXY-DC0xXfHy.js} +1 -1
  74. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-DyesHbs5.js +1 -0
  75. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-DyesHbs5.js +1 -0
  76. package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-C_EVg5l9.js +1 -0
  77. package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CP8LtrOl.js → cynefin-VYW2F7L2-BIFL8KrA.js} +1 -1
  78. package/dist/worker/console/static/assets/cynefinDiagram-MW4NZA55-DjtUYOlE.js +62 -0
  79. package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BK0ua9V8.js → dagre-VZM6K2ZE-D2aN2V9t.js} +1 -1
  80. package/dist/worker/console/static/assets/{diagram-7IWD3JNH-t9-HP13j.js → diagram-7IWD3JNH-D_twhmFi.js} +1 -1
  81. package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-L5Sg9jMD.js → diagram-B4RE2ZJO-ChzncqLV.js} +1 -1
  82. package/dist/worker/console/static/assets/diagram-LBJQPF4R-B6LO-bF2.js +24 -0
  83. package/dist/worker/console/static/assets/diagram-Q27KOJAE-GrzM7AFc.js +24 -0
  84. package/dist/worker/console/static/assets/diagram-UB23O5K3-Bv-lntaq.js +41 -0
  85. package/dist/worker/console/static/assets/docx-preview-CAbT0VNs.js +23 -0
  86. package/dist/worker/console/static/assets/docxPreview-D_T4B7qe.js +1 -0
  87. package/dist/worker/console/static/assets/ebnfDiagram-BXEA7PRR-BvD2jkO_.js +1 -0
  88. package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-CNOuj3BO.js → erDiagram-JOGREHBK-BirPCcmA.js} +1 -1
  89. package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-h_Cyayai.js → flowDiagram-UKHOOZJN-Chu1YnGQ.js} +1 -1
  90. package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-Djn17xhB.js +292 -0
  91. package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-Bx1qbGHx.js +106 -0
  92. package/dist/worker/console/static/assets/infoDiagram-6WML65LV-D-TLMqmb.js +2 -0
  93. package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DAdf5lHp.js → ishikawaDiagram-WSZJBQD7-DbJoh-6T.js} +1 -1
  94. package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-BQbGtg66.js → journeyDiagram-NVQOT4AX-DsyokZ6e.js} +1 -1
  95. package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-CetLubYc.js → kanban-definition-27J2QSJJ-DlzXTxic.js} +1 -1
  96. package/dist/worker/console/static/assets/{linear-DLZOjaVz.js → linear-ClnZn3vw.js} +1 -1
  97. package/dist/worker/console/static/assets/main-D-ZQ4gLb.css +1 -0
  98. package/dist/worker/console/static/assets/main-fc3P1HID.js +645 -0
  99. package/dist/worker/console/static/assets/{mermaid.core-B_xZl_gM.js → mermaid.core-DqSlcvbf.js} +5 -5
  100. package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-Dzo3dzp0.js → mindmap-definition-FAOFIHXS-CSFbzpiX.js} +1 -1
  101. package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-DK80yQqe.js +1 -0
  102. package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-Cp3YrVzQ.js → pieDiagram-7S7Q4E2Y-DWX7SFGb.js} +1 -1
  103. package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-4tI5mUgW.js → quadrantDiagram-CIZ2JOQS-BEPPhtXs.js} +1 -1
  104. package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-Ck_s6fQn.js +1 -0
  105. package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-DY-0JqdT.js → requirementDiagram-LRYGKXZP-CYig27Rj.js} +1 -1
  106. package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-DuJIzRKC.js → sankeyDiagram-W5VNT64P-u-0aSx5s.js} +1 -1
  107. package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-BTbVJ85l.js → sequenceDiagram-SI44F4Z6-NsEJI9sM.js} +1 -1
  108. package/dist/worker/console/static/assets/{sheet-workbook-BPPh1uLw.js → sheet-workbook-kZ_HK4Sg.js} +2 -2
  109. package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-8vneVM5U.js +1 -0
  110. package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-CMIobUBh.js +1 -0
  111. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Bd0pHHKP.js +1 -0
  112. package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-D4Qzt6ug.js +2 -0
  113. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-BzmSZnl_.js +8 -0
  114. package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-GR6lxokn.js → timeline-definition-Z64GVDOM-DMb1LpED.js} +1 -1
  115. package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-DEkwyzsF.js → vennDiagram-T6HMQDX7-C_9eFOs3.js} +1 -1
  116. package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-W5jnvEJ3.js → wardleyDiagram-T6FBY63Y-DJYMe3uT.js} +1 -1
  117. package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-cqsloioo.js → xychartDiagram-ELKLHX3M-Cv_1Mi3u.js} +1 -1
  118. package/dist/worker/console/static/docx-preview.html +25 -0
  119. package/dist/worker/console/static/index.html +3 -2
  120. package/dist/worker/console/static/vcp/fonts/README.md +28 -0
  121. package/dist/worker/console/static/vcp/vendor/vcp-engine-v1.js +4 -4
  122. package/dist/worker/console/static-src/operator-chat/StateDot.js +17 -0
  123. package/dist/worker/console/static-src/operator-chat/changed-file-diff.js +15 -0
  124. package/dist/worker/console/static-src/operator-chat/chat-font-size.js +90 -0
  125. package/dist/worker/console/static-src/operator-chat/chat-session-order.js +96 -0
  126. package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +8 -1
  127. package/dist/worker/console/static-src/operator-chat/compaction-message.js +4 -0
  128. package/dist/worker/console/static-src/operator-chat/details-rail-surfaces.js +2 -0
  129. package/dist/worker/console/static-src/operator-chat/file-touch.js +107 -0
  130. package/dist/worker/console/static-src/operator-chat/format-file-size.js +26 -0
  131. package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +44 -0
  132. package/dist/worker/console/static-src/operator-chat/reference-display.js +7 -1
  133. package/dist/worker/console/static-src/operator-chat/tasks-auto-open.js +100 -0
  134. package/dist/worker/console/static-src/operator-chat/tasks-layout-tween.js +103 -0
  135. package/dist/worker/console/static-src/operator-chat/tasks-model.js +657 -0
  136. package/dist/worker/console/static-src/operator-chat/tasks-view-glide.js +96 -0
  137. package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +1 -0
  138. package/dist/worker/console/static-src/operator-chat/use-auto-animate.js +61 -0
  139. package/dist/worker/console/static-src/operator-chat/useChatSessions.js +194 -47
  140. package/dist/worker/console/static-src/operator-chat/useChatStream.js +4 -0
  141. package/dist/worker/console/static-src/operator-chat/useChatThread.js +18 -0
  142. package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +111 -21
  143. package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +91 -47
  144. package/dist/worker/console/static-src/operator-chat/useVcpPreferences.js +1 -1
  145. package/dist/worker/console/static-src/operator-chat/user-turn-anchors-merge.js +50 -0
  146. package/dist/worker/console/static-src/operator-chat/vcp-fonts.js +180 -22
  147. package/dist/worker/console/static-src/operator-chat/vcp-frame.js +3 -3
  148. package/dist/worker/console/static-src/shell/console-update-progress.js +16 -0
  149. package/dist/worker/console/static-src/shell/console-update-reload.js +4 -1
  150. package/dist/worker/console/static-src/shell/workspace-route.js +0 -2
  151. package/dist/worker/console/vite.config.js +5 -1
  152. package/dist/worker/console/workspace-registry.js +62 -19
  153. package/dist/worker/observe/static/operator-chrome.js +0 -1
  154. package/dist/worker/scheduler/git-base.js +3 -0
  155. package/dist/worker/scheduler/night-git-finalizer.js +1 -1
  156. package/dist/worker/scheduler/night-harvest.js +1 -1
  157. package/dist/worker/scheduler/prepared-attempt-recovery.js +1 -1
  158. package/dist/worker/scheduler/scheduled-goal-evidence.js +1 -1
  159. package/dist/workflows/dag/backend-test-scenario-param.js +60 -4
  160. package/dist/workflows/dag/dynamic-runtime/reduction.js +7 -2
  161. package/dist/workflows/dag/frontend-test-framework-adapters.js +11 -2
  162. package/dist/workflows/script/windows/guest.js +13 -2
  163. package/dist/workflows/script/windows/native.js +21 -3
  164. package/docs/architecture/dag-execution.md +2 -13
  165. package/docs/architecture/facts-and-state.md +2 -3
  166. package/docs/architecture/runtime-boundaries.md +2 -2
  167. package/package.json +9 -7
  168. package/resource-catalog.v1.json +6 -6
  169. package/scripts/patch-pi-sdk-windows-hide.mjs +3 -3
  170. package/skills/loop-agent/references/command-reference.md +2 -41
  171. package/skills/loop-agent/references/harness-policy.md +3 -30
  172. package/skills/loop-agent/references/long-running-loop.md +6 -54
  173. package/dist/application/loop/run-action.js +0 -19
  174. package/dist/commands/dag-workflow-compile.js +0 -93
  175. package/dist/commands/dag-workflow-plan.js +0 -132
  176. package/dist/commands/dag-workflow-validate.js +0 -68
  177. package/dist/commands/loop-benchmark.js +0 -74
  178. package/dist/commands/loop.js +0 -251
  179. package/dist/commands/workflow.js +0 -259
  180. package/dist/infrastructure/harness/loop-store.js +0 -41
  181. package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-FQePHM07.js +0 -1
  182. package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-p_mwm8cd.js +0 -36
  183. package/dist/worker/console/static/assets/channel-CIBAg8WF.js +0 -1
  184. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-B4xQrSmv.js +0 -1
  185. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-B4xQrSmv.js +0 -1
  186. package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-BPXf8ZYr.js +0 -1
  187. package/dist/worker/console/static/assets/cynefinDiagram-MW4NZA55-CNsL9N2-.js +0 -62
  188. package/dist/worker/console/static/assets/diagram-LBJQPF4R-BipWFRgs.js +0 -24
  189. package/dist/worker/console/static/assets/diagram-Q27KOJAE-T2p4xa38.js +0 -24
  190. package/dist/worker/console/static/assets/diagram-UB23O5K3-CVwz6LVu.js +0 -41
  191. package/dist/worker/console/static/assets/ebnfDiagram-BXEA7PRR-CybQrGSA.js +0 -1
  192. package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-D411_55h.js +0 -292
  193. package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-DpVtzs9z.js +0 -106
  194. package/dist/worker/console/static/assets/index-B7cwOTL9.js +0 -649
  195. package/dist/worker/console/static/assets/index-CATbSkPc.css +0 -1
  196. package/dist/worker/console/static/assets/infoDiagram-6WML65LV-D74Uvx6K.js +0 -2
  197. package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-CSwoBOpM.js +0 -1
  198. package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-n0Mt3Yia.js +0 -1
  199. package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-Dmf1pC7B.js +0 -1
  200. package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-4-jdPUHD.js +0 -1
  201. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DojWfYnC.js +0 -1
  202. package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-DNhjjaAU.js +0 -2
  203. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-CJo4AKWH.js +0 -8
  204. package/dist/worker/console/static/vcp/fonts/Lanxi-/345/217/257/345/256/213.woff2 +0 -0
  205. package/dist/worker/console/static/vcp/fonts/Lanxi-/346/234/227/345/256/213.woff2 +0 -0
  206. package/dist/worker/console/static/vcp/fonts/Lanxi-/350/266/205/347/262/227/351/273/221.woff2 +0 -0
  207. package/dist/workflows/dynamic/compile.js +0 -371
  208. package/dist/workflows/dynamic/compileTypes.js +0 -1
  209. package/dist/workflows/dynamic/errors.js +0 -5
  210. package/dist/workflows/dynamic/profiles.js +0 -156
  211. package/dist/workflows/dynamic/spec.js +0 -115
  212. package/dist/workflows/dynamic/validate.js +0 -275
  213. package/dist/workflows/loop/actions/dag-action.js +0 -129
  214. package/dist/workflows/loop/actions/pi-review.js +0 -267
  215. package/dist/workflows/loop/actions/shared.js +0 -157
  216. package/dist/workflows/loop/actions/shell-verify.js +0 -82
  217. package/dist/workflows/loop/actions/types.js +0 -1
  218. package/dist/workflows/loop/actions/workflow-action.js +0 -255
  219. package/dist/workflows/loop/actions.js +0 -160
  220. package/dist/workflows/loop/benchmark.js +0 -513
  221. package/dist/workflows/loop/closeout.js +0 -135
  222. package/dist/workflows/loop/context.js +0 -47
  223. package/dist/workflows/loop/events.js +0 -26
  224. package/dist/workflows/loop/hash.js +0 -32
  225. package/dist/workflows/loop/index.js +0 -8
  226. package/dist/workflows/loop/paths.js +0 -17
  227. package/dist/workflows/loop/policy/auto-policy.js +0 -112
  228. package/dist/workflows/loop/policy/path-patterns.js +0 -13
  229. package/dist/workflows/loop/rounds.js +0 -81
  230. package/dist/workflows/loop/signals.js +0 -52
  231. package/dist/workflows/loop/state.js +0 -116
  232. package/dist/workflows/loop/templates.js +0 -54
  233. package/dist/workflows/loop/types.js +0 -28
  234. /package/dist/workflows/{dynamic/artifacts.js → dag/dynamic-runtime/reduction-artifacts.js} +0 -0
@@ -3,6 +3,7 @@ import { access, copyFile, lstat, mkdir, readdir, readFile, realpath, rename, rm
3
3
  import path from "node:path";
4
4
  import { isDeepStrictEqual } from "node:util";
5
5
  import { fileURLToPath } from "node:url";
6
+ import { normalizedAcceptedHarnessHash } from "./init-accepted-merge.js";
6
7
  import { GITIGNORE_BLOCK_END, GITIGNORE_BLOCK_START, buildManagedGitignoreBlock, extractGitignoreManagedBlock, mergeGitignoreManagedBlock, } from "../shared/gitignore-managed-block.js";
7
8
  import { isInitRuntimeActive, } from "../shared/runtime-activity.js";
8
9
  import { loadHarnessManifest } from "../governance/harness.js";
@@ -1657,16 +1658,8 @@ async function buildCurrentSurfaceState(input) {
1657
1658
  };
1658
1659
  }
1659
1660
  /** Follow only exact controller normalization edges, never infer acceptance
1660
- * from shape equality. Persisted edges recover an interrupted surface refresh. */
1661
- function normalizedAcceptedHarnessHash(acceptedHash, actions) {
1662
- let current = acceptedHash;
1663
- for (const action of actions) {
1664
- if (action.path === "harness.json" && action.type === "reconcile-harness-structure" &&
1665
- action.beforeSha256 === current && action.afterSha256)
1666
- current = action.afterSha256;
1667
- }
1668
- return current;
1669
- }
1661
+ * from shape equality. Persisted edges recover an interrupted surface refresh.
1662
+ * See `init-accepted-merge.ts` for the rewrite-action set and its history. */
1670
1663
  async function writeInitSurfaceState(input) {
1671
1664
  const state = await buildCurrentSurfaceState(input);
1672
1665
  state.dispositions = [
@@ -2752,7 +2745,59 @@ function actionForMissing(pathName, state) {
2752
2745
  reason: "managed block file is missing or stale",
2753
2746
  };
2754
2747
  }
2755
- function modelMergeTaskFor(pathName, state, allPaths, recordedState) {
2748
+ /**
2749
+ * Fields that carry verification authority.
2750
+ *
2751
+ * The controller preserves these from the project during reconciliation
2752
+ * (`buildHarness` keeps `existing.verification` etc.), so a merge that
2753
+ * rewrites them does not just change configuration — it changes which
2754
+ * checks gate the project. Callers need to know this before editing.
2755
+ */
2756
+ const HARNESS_AUTHORITY_LOCKED_FIELDS = [
2757
+ "verification",
2758
+ "workflowPolicy",
2759
+ "executors",
2760
+ ];
2761
+ /**
2762
+ * Compare two JSON documents and report the differing key paths.
2763
+ *
2764
+ * Values are never emitted: the caller only needs to know *which* paths to
2765
+ * reconcile. Arrays compare as whole values because element-wise paths are
2766
+ * noisy for configuration and rarely actionable.
2767
+ *
2768
+ * Exported so the key-path diff can be tested directly; a wrong diff misleads
2769
+ * the merge more than no diff at all.
2770
+ */
2771
+ export function diffJsonKeyPaths(current, desired) {
2772
+ const added = [];
2773
+ const removed = [];
2774
+ const changed = [];
2775
+ const walk = (left, right, prefix) => {
2776
+ const leftIsRecord = isRecord(left);
2777
+ const rightIsRecord = isRecord(right);
2778
+ if (leftIsRecord && rightIsRecord) {
2779
+ for (const key of new Set([...Object.keys(left), ...Object.keys(right)])) {
2780
+ const nextPrefix = prefix ? `${prefix}.${key}` : key;
2781
+ const inLeft = Object.hasOwn(left, key);
2782
+ const inRight = Object.hasOwn(right, key);
2783
+ if (!inLeft && inRight)
2784
+ added.push(nextPrefix);
2785
+ else if (inLeft && !inRight)
2786
+ removed.push(nextPrefix);
2787
+ else
2788
+ walk(left[key], right[key], nextPrefix);
2789
+ }
2790
+ return;
2791
+ }
2792
+ if (leftIsRecord !== rightIsRecord || !isDeepStrictEqual(left, right)) {
2793
+ if (prefix)
2794
+ changed.push(prefix);
2795
+ }
2796
+ };
2797
+ walk(current, desired, "");
2798
+ return { added: added.sort(), removed: removed.sort(), changed: changed.sort() };
2799
+ }
2800
+ function modelMergeTaskFor(pathName, state, allPaths, recordedState, desiredPatch) {
2756
2801
  return {
2757
2802
  taskId: `init-merge-${sha256Text(pathName).slice(0, 12)}`,
2758
2803
  path: pathName,
@@ -2774,12 +2819,25 @@ function modelMergeTaskFor(pathName, state, allPaths, recordedState) {
2774
2819
  verification: [
2775
2820
  `git diff --check -- ${pathName}`,
2776
2821
  ],
2822
+ // A merge task that only says "complete this task" leaves the caller to
2823
+ // rediscover the authority rules. That is a fact the controller already
2824
+ // holds, so state it in a slot call sites do not overwrite.
2825
+ ...(pathName === "harness.json"
2826
+ ? {
2827
+ authorityLockedFields: [...HARNESS_AUTHORITY_LOCKED_FIELDS],
2828
+ mergeGuidance: [
2829
+ `Keep the project values of these authority fields: ${HARNESS_AUTHORITY_LOCKED_FIELDS.join(", ")}.`,
2830
+ "`.harness/init-surface.json` is rewritten by the controller after a successful merge; do not edit it by hand.",
2831
+ ],
2832
+ }
2833
+ : {}),
2777
2834
  evidence: {
2778
2835
  baseSha256: recordedState?.files[pathName]?.currentSha256,
2779
2836
  currentSha256: state?.currentSha256,
2780
2837
  desiredSha256: state?.sourceSha256,
2781
2838
  sourceAnchorSha256: state?.sourceAnchorSha256,
2782
2839
  },
2840
+ ...(desiredPatch ? { desiredPatch } : {}),
2783
2841
  };
2784
2842
  }
2785
2843
  function recommendedNextFor(report) {
@@ -3056,7 +3114,16 @@ export async function checkInitUpdate(input) {
3056
3114
  }
3057
3115
  else if (modelMigration.kind === "ambiguous") {
3058
3116
  const state = currentState.files["harness.json"];
3059
- const mergeTask = modelMergeTaskFor("harness.json", state, allPaths, recordedState);
3117
+ // The desired structure is computable here, so the caller does
3118
+ // not have to infer which key paths differ.
3119
+ const template = await readJsonIfExists(path.join(assetRoot, "harness.json"));
3120
+ const desiredStructure = buildHarness({
3121
+ existing: harness,
3122
+ template,
3123
+ projectName,
3124
+ governanceRoot,
3125
+ });
3126
+ const mergeTask = modelMergeTaskFor("harness.json", state, allPaths, recordedState, diffJsonKeyPaths(harness, desiredStructure));
3060
3127
  mergeTask.reason = `legacy model configuration requires a human/model merge: ${modelMigration.reason}`;
3061
3128
  mergeTask.mergeRules = [
3062
3129
  "Preserve every existing harness.json field unless the user explicitly approves its migration.",
@@ -136,7 +136,7 @@ export function setPiSdkImportOverrideForTests(fn) {
136
136
  export function setPiSdkModuleOverrideForTests(fn) {
137
137
  sdkModuleOverrideForTests = fn;
138
138
  }
139
- /** Check whether the Pi SDK runtime dependency satisfies the 1.0.2 runtime contract. */
139
+ /** Check whether the Pi SDK runtime dependency satisfies the 1.3.0 runtime contract. */
140
140
  export async function checkPiSdkAvailability(_repoRoot) {
141
141
  if (sdkSessionFactoryOverride) {
142
142
  return { ok: true, detail: "pi SDK session factory override active" };
@@ -154,10 +154,10 @@ export async function checkPiSdkAvailability(_repoRoot) {
154
154
  !hasModelRuntime) {
155
155
  return {
156
156
  ok: false,
157
- detail: "pi SDK incompatible: requires createAgentSession, getAgentDir, and ModelRuntime.create (1.2.0 contract)",
157
+ detail: "pi SDK incompatible: requires createAgentSession, getAgentDir, and ModelRuntime.create (1.3.0 contract)",
158
158
  };
159
159
  }
160
- return { ok: true, detail: "pi SDK 1.2.0 contract available" };
160
+ return { ok: true, detail: "pi SDK 1.3.0 contract available" };
161
161
  }
162
162
  catch (error) {
163
163
  const message = error instanceof Error ? error.message : String(error);
@@ -52,6 +52,8 @@ export async function listDiffPaths(repoRoot, baseRef, headRef) {
52
52
  const child = spawn('git', ['diff', '--name-only', '-z', `${baseRef}..${headRef}`], {
53
53
  cwd: repoRoot,
54
54
  stdio: ['ignore', 'pipe', 'pipe'],
55
+ // A visible console per call would flash during every guarded write.
56
+ windowsHide: true,
55
57
  });
56
58
  const out = [];
57
59
  child.stdout?.on('data', (chunk) => out.push(chunk));
@@ -193,7 +193,7 @@ function runGit(repoRoot, args) {
193
193
  return new Promise((resolve, reject) => {
194
194
  const child = spawn('git', args, {
195
195
  cwd: repoRoot,
196
- stdio: ['ignore', 'pipe', 'pipe'],
196
+ stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true,
197
197
  });
198
198
  const stdoutChunks = [];
199
199
  const stderrChunks = [];
@@ -151,6 +151,9 @@ async function runGit(repoRoot, args) {
151
151
  const child = spawn('git', args, {
152
152
  cwd: repoRoot,
153
153
  stdio: ['ignore', 'pipe', 'pipe'],
154
+ // Without this Windows allocates a console for every child process, so
155
+ // each git call during a chat turn flashes a console window.
156
+ windowsHide: true,
154
157
  });
155
158
  let stdout = '';
156
159
  let stderr = '';
@@ -149,19 +149,6 @@ const OFFICIAL_ACTIONS = [
149
149
  "human-gated-required",
150
150
  ],
151
151
  ["dagInitHybrid", "loop-agent dag init-hybrid", "mutation", "advanced"],
152
- ["dagWorkflowPlan", "loop-agent dag workflow-plan", "read", "advanced"],
153
- [
154
- "dagWorkflowValidate",
155
- "loop-agent dag workflow-validate",
156
- "read",
157
- "advanced",
158
- ],
159
- [
160
- "dagWorkflowCompile",
161
- "loop-agent dag workflow-compile",
162
- "mutation",
163
- "advanced",
164
- ],
165
152
  ["planList", "loop-agent plan list", "read", "model-callable"],
166
153
  ["planCreate", "loop-agent plan create", "mutation", "model-callable"],
167
154
  ["planComplete", "loop-agent plan complete", "mutation", "model-callable"],
@@ -190,7 +177,6 @@ const OFFICIAL_ACTIONS = [
190
177
  "model-callable",
191
178
  ],
192
179
  ["piReuseBenchmark", "loop-agent pi-reuse-benchmark", "read", "advanced"],
193
- ["loopBenchmark", "loop-agent loop-benchmark", "read", "advanced"],
194
180
  [
195
181
  "knowledgeCurate",
196
182
  "loop-agent knowledge curate",
@@ -222,18 +208,6 @@ const OFFICIAL_ACTIONS = [
222
208
  "mutation",
223
209
  "advanced",
224
210
  ],
225
- ...["init", "status", "run", "record-round", "add-signal", "closeout"].map((leaf) => [
226
- `loop${leaf.replace(/(^|-)(.)/g, (_m, _d, c) => c.toUpperCase())}`,
227
- `loop-agent loop ${leaf}`,
228
- leaf === "status" ? "read" : "mutation",
229
- "advanced",
230
- ]),
231
- ...["list", "inspect", "save", "run", "diff", "replay"].map((leaf) => [
232
- `workflow${leaf[0].toUpperCase()}${leaf.slice(1)}`,
233
- `loop-agent workflow ${leaf}`,
234
- ["list", "inspect", "diff"].includes(leaf) ? "read" : "mutation",
235
- "advanced",
236
- ]),
237
211
  [
238
212
  "workerFeatureReview",
239
213
  "agent-worker feature review",
@@ -2000,12 +1974,6 @@ export const OPERATOR_COMMAND_COVERAGE = Object.freeze([
2000
1974
  action: "piReuseBenchmark",
2001
1975
  source: "loop-agent",
2002
1976
  },
2003
- {
2004
- command: "loop-agent loop-benchmark",
2005
- coverage: "advanced",
2006
- action: "loopBenchmark",
2007
- source: "loop-agent",
2008
- },
2009
1977
  {
2010
1978
  command: "loop-agent dag execute",
2011
1979
  coverage: "model-callable",
@@ -2373,24 +2341,6 @@ export const OPERATOR_COMMAND_COVERAGE = Object.freeze([
2373
2341
  action: "dagValidate",
2374
2342
  source: "loop-agent",
2375
2343
  },
2376
- {
2377
- command: "loop-agent dag workflow-plan",
2378
- coverage: "advanced",
2379
- action: "dagWorkflowPlan",
2380
- source: "loop-agent",
2381
- },
2382
- {
2383
- command: "loop-agent dag workflow-validate",
2384
- coverage: "advanced",
2385
- action: "dagWorkflowValidate",
2386
- source: "loop-agent",
2387
- },
2388
- {
2389
- command: "loop-agent dag workflow-compile",
2390
- coverage: "advanced",
2391
- action: "dagWorkflowCompile",
2392
- source: "loop-agent",
2393
- },
2394
2344
  {
2395
2345
  command: "loop-agent dag approve",
2396
2346
  coverage: "human-gated-required",
@@ -2492,78 +2442,6 @@ export const OPERATOR_COMMAND_COVERAGE = Object.freeze([
2492
2442
  source: "loop-agent",
2493
2443
  exclusionReason: "Artifact revision staging consumes a human-selected local file and remains on dedicated Console/CLI mutation gates.",
2494
2444
  },
2495
- {
2496
- command: "loop-agent workflow list",
2497
- coverage: "advanced",
2498
- action: "workflowList",
2499
- source: "loop-agent",
2500
- },
2501
- {
2502
- command: "loop-agent workflow inspect",
2503
- coverage: "advanced",
2504
- action: "workflowInspect",
2505
- source: "loop-agent",
2506
- },
2507
- {
2508
- command: "loop-agent workflow save",
2509
- coverage: "advanced",
2510
- action: "workflowSave",
2511
- source: "loop-agent",
2512
- },
2513
- {
2514
- command: "loop-agent workflow run",
2515
- coverage: "advanced",
2516
- action: "workflowRun",
2517
- source: "loop-agent",
2518
- },
2519
- {
2520
- command: "loop-agent workflow diff",
2521
- coverage: "advanced",
2522
- action: "workflowDiff",
2523
- source: "loop-agent",
2524
- },
2525
- {
2526
- command: "loop-agent workflow replay",
2527
- coverage: "advanced",
2528
- action: "workflowReplay",
2529
- source: "loop-agent",
2530
- },
2531
- {
2532
- command: "loop-agent loop init",
2533
- coverage: "advanced",
2534
- action: "loopInit",
2535
- source: "loop-agent",
2536
- },
2537
- {
2538
- command: "loop-agent loop status",
2539
- coverage: "advanced",
2540
- action: "loopStatus",
2541
- source: "loop-agent",
2542
- },
2543
- {
2544
- command: "loop-agent loop run",
2545
- coverage: "advanced",
2546
- action: "loopRun",
2547
- source: "loop-agent",
2548
- },
2549
- {
2550
- command: "loop-agent loop record-round",
2551
- coverage: "advanced",
2552
- action: "loopRecordRound",
2553
- source: "loop-agent",
2554
- },
2555
- {
2556
- command: "loop-agent loop add-signal",
2557
- coverage: "advanced",
2558
- action: "loopAddSignal",
2559
- source: "loop-agent",
2560
- },
2561
- {
2562
- command: "loop-agent loop closeout",
2563
- coverage: "advanced",
2564
- action: "loopCloseout",
2565
- source: "loop-agent",
2566
- },
2567
2445
  {
2568
2446
  command: "loop-agent dag decision inspect",
2569
2447
  coverage: "model-callable",
@@ -1,4 +1,25 @@
1
- const CHECKPOINT_MAX_BYTES = 12 * 1024;
1
+ const CHECKPOINT_MAX_BYTES = 16 * 1024;
2
+ /*
3
+ * Per-section BYTE budgets.
4
+ *
5
+ * The checkpoint limit is a byte limit (`truncateUtf8` counts UTF-8 bytes), so
6
+ * every budget here is bytes too. Naming them as characters and feeding them to
7
+ * a byte-level truncator silently gave CJK content a third of its intended
8
+ * room, which is how a Chinese-language session ended up with a summary that
9
+ * looked far emptier than the English one for the same input.
10
+ *
11
+ * The sum deliberately exceeds the total budget: sections are fitted to the
12
+ * real limit afterwards, sacrificing the lowest priority first.
13
+ */
14
+ const GOAL_MAX_BYTES = 2_400;
15
+ const PROGRESS_MAX_BYTES = 5_000;
16
+ /** How far back the Progress section looks for visible text. */
17
+ const PROGRESS_MAX_MESSAGES = 24;
18
+ const FILES_MAX_BYTES = 2_400;
19
+ const ERROR_MAX_BYTES = 1_400;
20
+ const TODOS_MAX_BYTES = 1_600;
21
+ const PREVIOUS_SUMMARY_MAX_BYTES = 4_000;
22
+ const CUSTOM_INSTRUCTIONS_MAX_BYTES = 1_200;
2
23
  function truncateUtf8(value, maxBytes) {
3
24
  if (maxBytes <= 0)
4
25
  return "";
@@ -17,10 +38,20 @@ function truncateUtf8(value, maxBytes) {
17
38
  }
18
39
  return `${result}${ellipsis}`;
19
40
  }
20
- function boundText(value, maxChars) {
41
+ /**
42
+ * Bound a string to a BYTE budget, keeping whole characters.
43
+ *
44
+ * Section budgets are bytes because the checkpoint limit is bytes. Cutting on
45
+ * `String.length` counts UTF-16 code units, so the same budget admitted three
46
+ * times as much Chinese as English and the sections never lined up with the
47
+ * real limit.
48
+ */
49
+ function boundText(value, maxBytes) {
21
50
  if (typeof value !== "string" || !value.trim())
22
51
  return "";
23
- return value.length <= maxChars ? value : `${value.slice(0, Math.max(0, maxChars - 1))}…`;
52
+ if (Buffer.byteLength(value, "utf8") <= maxBytes)
53
+ return value;
54
+ return truncateUtf8(value, maxBytes);
24
55
  }
25
56
  function asRecord(value) {
26
57
  return value !== null && typeof value === "object" && !Array.isArray(value)
@@ -140,21 +171,30 @@ function extractLastUserGoal(messages) {
140
171
  continue;
141
172
  const content = message.content;
142
173
  if (typeof content === "string")
143
- return boundText(content, 900);
174
+ return boundText(content, GOAL_MAX_BYTES);
144
175
  if (Array.isArray(content)) {
145
176
  const texts = content.map((block) => {
146
177
  const rec = asRecord(block);
147
178
  return typeof rec?.text === "string" ? rec.text : "";
148
179
  }).filter(Boolean);
149
180
  if (texts.length > 0)
150
- return boundText(texts.join("\n"), 900);
181
+ return boundText(texts.join("\n"), GOAL_MAX_BYTES);
151
182
  }
152
183
  }
153
184
  return "";
154
185
  }
186
+ /**
187
+ * Visible assistant/user text for the Progress section.
188
+ *
189
+ * The checkpoint used to keep only the last 8 messages, which drops an entire
190
+ * analysis chain the moment a long turn compacts: the model restarts without
191
+ * the reasoning it just produced and redoes the work. Widening the window and
192
+ * keeping the NEWEST entries first means the tail of the analysis survives even
193
+ * when the section is later truncated.
194
+ */
155
195
  function extractVisibleProgress(messages) {
156
196
  const lines = [];
157
- for (const message of messages.slice(-8)) {
197
+ for (const message of messages.slice(-PROGRESS_MAX_MESSAGES)) {
158
198
  const record = asRecord(message);
159
199
  if (!record || (record.role !== "assistant" && record.role !== "user"))
160
200
  continue;
@@ -170,7 +210,7 @@ function extractVisibleProgress(messages) {
170
210
  lines.push(`${String(record.role)}: ${text}`);
171
211
  }
172
212
  }
173
- return boundText(lines.join("\n"), 1800);
213
+ return boundText(lines.join("\n"), PROGRESS_MAX_BYTES);
174
214
  }
175
215
  function extractTodos(details) {
176
216
  const record = asRecord(details);
@@ -182,7 +222,7 @@ function extractTodos(details) {
182
222
  const status = typeof rec?.status === "string" ? rec.status : "pending";
183
223
  const content = typeof rec?.content === "string" ? rec.content : typeof rec?.title === "string" ? rec.title : "";
184
224
  return content ? `- [${status}] ${content}` : "";
185
- }).filter(Boolean).join("\n"), 1800);
225
+ }).filter(Boolean).join("\n"), TODOS_MAX_BYTES);
186
226
  }
187
227
  function extractFileOps(fileOps) {
188
228
  const parts = [];
@@ -195,18 +235,43 @@ function extractFileOps(fileOps) {
195
235
  function section(title, body) {
196
236
  return body ? `## ${title}\n${body}` : `## ${title}`;
197
237
  }
198
- function fitSections(sections, tail) {
199
- const fixedBytes = Buffer.byteLength(tail, "utf8");
200
- const available = Math.max(0, CHECKPOINT_MAX_BYTES - fixedBytes - 2 * (sections.length - 1));
238
+ /**
239
+ * Fit the sections into the byte limit, sacrificing low-priority content first.
240
+ *
241
+ * Two bugs drove this rewrite:
242
+ *
243
+ * 1. Truncation started at index 0, so an oversized section at the top ate the
244
+ * budget and the goal/error sections were the first to be cut.
245
+ * 2. `Pending Jobs` lived in the untouchable tail. Its bytes were counted as
246
+ * fixed overhead but it was never shrunk, so a long todo list could consume
247
+ * most of the checkpoint while the goal and file list were squeezed to a
248
+ * few dozen bytes.
249
+ *
250
+ * Now every section competes for the same budget and only the genuinely fixed
251
+ * closing lines are exempt.
252
+ */
253
+ function fitSections(sections, fixedTail) {
254
+ const separatorBytes = 2 * Math.max(0, sections.length);
255
+ const fixedBytes = Buffer.byteLength(fixedTail, "utf8") + separatorBytes;
256
+ const available = Math.max(0, CHECKPOINT_MAX_BYTES - fixedBytes);
201
257
  const texts = sections.map(({ text, budget }) => truncateUtf8(text, budget));
202
258
  let used = texts.reduce((sum, text) => sum + Buffer.byteLength(text, "utf8"), 0);
203
- for (let index = 0; used > available && index < texts.length; index += 1) {
259
+ if (used <= available) {
260
+ return [...texts, fixedTail].join("\n\n");
261
+ }
262
+ // Drop from the least important section until the overage is covered.
263
+ const order = sections
264
+ .map((entry, index) => ({ index, priority: entry.priority }))
265
+ .sort((left, right) => left.priority - right.priority);
266
+ for (const { index } of order) {
267
+ if (used <= available)
268
+ break;
204
269
  const current = texts[index];
205
270
  const next = truncateUtf8(current, Math.max(0, Buffer.byteLength(current, "utf8") - (used - available)));
206
271
  used -= Buffer.byteLength(current, "utf8") - Buffer.byteLength(next, "utf8");
207
272
  texts[index] = next;
208
273
  }
209
- return [...texts, tail].join("\n\n");
274
+ return [...texts, fixedTail].join("\n\n");
210
275
  }
211
276
  export function buildOverflowCheckpoint(input) {
212
277
  const preparation = normalizeCompactionPreparation(input.preparation);
@@ -217,22 +282,27 @@ export function buildOverflowCheckpoint(input) {
217
282
  const progress = extractVisibleProgress(messages);
218
283
  const todos = extractTodos(input.todos);
219
284
  const files = extractFileOps(preparation.fileOps);
220
- const error = typeof input.lastError === "string" && input.lastError ? boundText(input.lastError, 1000) : "";
221
- const customInstructions = boundText(input.customInstructions, 1000);
222
- const previousSummary = boundText(preparation.previousSummary, 2400);
223
- const tail = [
224
- section("Pending Jobs", `Open todos:\n${todos || "No structured pending jobs recorded."}`),
285
+ const error = typeof input.lastError === "string" && input.lastError ? boundText(input.lastError, ERROR_MAX_BYTES) : "";
286
+ const customInstructions = boundText(input.customInstructions, CUSTOM_INSTRUCTIONS_MAX_BYTES);
287
+ const previousSummary = boundText(preparation.previousSummary, PREVIOUS_SUMMARY_MAX_BYTES);
288
+ /*
289
+ * Only the closing instructions are exempt from the budget: they are what
290
+ * tells the model how to resume, and losing them is what makes a checkpoint
291
+ * useless. Everything else — including the todo list — competes for space.
292
+ */
293
+ const fixedTail = [
225
294
  section("Next Steps", "Next step: continue the interrupted turn from the kept recent messages. Do not repeat completed file writes."),
226
295
  section("Critical Context", customInstructions ? `Compaction instructions:\n${customInstructions}` : "The Pi provider summary was unavailable; use the kept recent messages as the source of truth."),
227
296
  section("Recovery Note", "This deterministic checkpoint was created without a model summary request. Details not restated here remain in the kept recent messages."),
228
297
  ].join("\n\n");
229
298
  const summary = fitSections([
230
- { text: "Deterministic local compaction checkpoint (no extra summary request).", budget: 900 },
231
- { text: section("Goal", `Latest user goal:\n${goal || "No recent user goal was available."}`), budget: 1800 },
232
- { text: section("Progress", [previousSummary ? `Previous summary:\n${previousSummary}` : "", progress].filter(Boolean).join("\n")), budget: 3200 },
233
- { text: section("Files and Code", `File ops:\n${files || "No file operations were recorded."}`), budget: 2400 },
234
- { text: section("Errors and Fixes", error ? `Latest error:\n${error}` : "No recent provider error was recorded."), budget: 1400 },
235
- ], tail);
299
+ { text: "Deterministic local compaction checkpoint (no extra summary request).", budget: 900, priority: 6 },
300
+ { text: section("Goal", `Latest user goal:\n${goal || "No recent user goal was available."}`), budget: GOAL_MAX_BYTES, priority: 5 },
301
+ { text: section("Progress", [previousSummary ? `Previous summary:\n${previousSummary}` : "", progress].filter(Boolean).join("\n")), budget: PROGRESS_MAX_BYTES, priority: 1 },
302
+ { text: section("Files and Code", `File ops:\n${files || "No file operations were recorded."}`), budget: FILES_MAX_BYTES, priority: 3 },
303
+ { text: section("Errors and Fixes", error ? `Latest error:\n${error}` : "No recent provider error was recorded."), budget: ERROR_MAX_BYTES, priority: 2 },
304
+ { text: section("Pending Jobs", `Open todos:\n${todos || "No structured pending jobs recorded."}`), budget: TODOS_MAX_BYTES, priority: 4 },
305
+ ], fixedTail);
236
306
  return {
237
307
  summary: truncateUtf8(summary, CHECKPOINT_MAX_BYTES),
238
308
  firstKeptEntryId: preparation.firstKeptEntryId,