harnery 0.40.0 → 0.41.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 (441) hide show
  1. package/README.md +1 -1
  2. package/dist/commander.js +1 -0
  3. package/dist/commands/agents.d.ts.map +1 -1
  4. package/dist/commands/agents.js +25 -19
  5. package/dist/commands/browse-ai.d.ts.map +1 -1
  6. package/dist/commands/browse-ai.js +4 -0
  7. package/dist/commands/browse.d.ts.map +1 -1
  8. package/dist/commands/browse.js +141 -10
  9. package/dist/commands/checkpoint.js +8 -12
  10. package/dist/commands/deinit.d.ts +1 -1
  11. package/dist/commands/deinit.d.ts.map +1 -1
  12. package/dist/commands/deinit.js +8 -4
  13. package/dist/commands/docs.d.ts.map +1 -1
  14. package/dist/commands/docs.js +2 -0
  15. package/dist/commands/doctor.js +10 -2
  16. package/dist/commands/fetch.d.ts.map +1 -1
  17. package/dist/commands/fetch.js +10 -0
  18. package/dist/commands/init.d.ts +19 -3
  19. package/dist/commands/init.d.ts.map +1 -1
  20. package/dist/commands/init.js +232 -104
  21. package/dist/commands/instructions.js +5 -4
  22. package/dist/commands/ledger-v3.d.ts.map +1 -1
  23. package/dist/commands/ledger-v3.js +2 -1
  24. package/dist/commands/webview.d.ts +4 -0
  25. package/dist/commands/webview.d.ts.map +1 -0
  26. package/dist/commands/webview.js +94 -0
  27. package/dist/core/adapter.d.ts +50 -1
  28. package/dist/core/adapter.d.ts.map +1 -1
  29. package/dist/core/adapter.js +59 -1
  30. package/dist/core/adapters/attestation.d.ts.map +1 -1
  31. package/dist/core/adapters/attestation.js +3 -2
  32. package/dist/core/adapters/profiles.d.ts +20 -3
  33. package/dist/core/adapters/profiles.d.ts.map +1 -1
  34. package/dist/core/adapters/profiles.js +32 -1
  35. package/dist/core/adapters/registry.d.ts.map +1 -1
  36. package/dist/core/adapters/registry.js +33 -0
  37. package/dist/core/agents/canonical-emit.d.ts +1 -1
  38. package/dist/core/agents/canonical-emit.d.ts.map +1 -1
  39. package/dist/core/agents/canonical-emit.js +2 -7
  40. package/dist/core/agents/cli.js +18 -16
  41. package/dist/core/agents/coord-client.d.ts.map +1 -1
  42. package/dist/core/agents/coord-client.js +7 -2
  43. package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -1
  44. package/dist/core/agents/rules/claim-conflict.js +3 -9
  45. package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
  46. package/dist/core/agents/rules/commit-conflict.js +2 -8
  47. package/dist/core/agents/rules/stop-hook.d.ts +2 -0
  48. package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
  49. package/dist/core/agents/rules/stop-hook.js +1 -1
  50. package/dist/core/agents/session-events.d.ts +6 -2
  51. package/dist/core/agents/session-events.d.ts.map +1 -1
  52. package/dist/core/agents/session-events.js +105 -26
  53. package/dist/core/agents/session-finalization-state-v3.d.ts.map +1 -1
  54. package/dist/core/agents/session-finalization-state-v3.js +2 -1
  55. package/dist/core/agents/session-finalizer-v3.d.ts.map +1 -1
  56. package/dist/core/agents/session-finalizer-v3.js +5 -4
  57. package/dist/core/agents/session-name-display.d.ts +28 -0
  58. package/dist/core/agents/session-name-display.d.ts.map +1 -1
  59. package/dist/core/agents/session-name-display.js +43 -0
  60. package/dist/core/agents/state/heartbeat-reader.d.ts +7 -0
  61. package/dist/core/agents/state/heartbeat-reader.d.ts.map +1 -1
  62. package/dist/core/agents/state/heartbeat-writer.d.ts +10 -0
  63. package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
  64. package/dist/core/agents/state/heartbeat-writer.js +21 -2
  65. package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -1
  66. package/dist/core/agents/state/live-coordination-view.js +1 -0
  67. package/dist/core/agents/state/live-coordination-writer.js +3 -0
  68. package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
  69. package/dist/core/agents/state/stale-sweep.js +2 -10
  70. package/dist/core/agents/turn-changes.d.ts +17 -0
  71. package/dist/core/agents/turn-changes.d.ts.map +1 -0
  72. package/dist/core/agents/turn-changes.js +76 -0
  73. package/dist/core/artifacts/delivery-card.d.ts.map +1 -1
  74. package/dist/core/artifacts/delivery-card.js +2 -1
  75. package/dist/core/artifacts/index.d.ts.map +1 -1
  76. package/dist/core/artifacts/index.js +4 -3
  77. package/dist/core/config.d.ts +5 -0
  78. package/dist/core/config.d.ts.map +1 -1
  79. package/dist/core/config.js +14 -0
  80. package/dist/core/context/index.d.ts.map +1 -1
  81. package/dist/core/context/index.js +2 -1
  82. package/dist/core/conversations/archive.d.ts.map +1 -1
  83. package/dist/core/conversations/archive.js +4 -3
  84. package/dist/core/diagnostics/bundle.d.ts.map +1 -1
  85. package/dist/core/diagnostics/bundle.js +3 -2
  86. package/dist/core/events/legacy-storage/canary.d.ts.map +1 -1
  87. package/dist/core/events/legacy-storage/canary.js +5 -4
  88. package/dist/core/events/legacy-storage/compression.d.ts.map +1 -1
  89. package/dist/core/events/legacy-storage/compression.js +2 -1
  90. package/dist/core/events/v3/adapter-id.d.ts +10 -2
  91. package/dist/core/events/v3/adapter-id.d.ts.map +1 -1
  92. package/dist/core/events/v3/adapter-id.js +16 -0
  93. package/dist/core/events/v3/authority-outbox.d.ts.map +1 -1
  94. package/dist/core/events/v3/authority-outbox.js +2 -1
  95. package/dist/core/events/v3/bootstrap.d.ts.map +1 -1
  96. package/dist/core/events/v3/bootstrap.js +5 -4
  97. package/dist/core/events/v3/capabilities.d.ts.map +1 -1
  98. package/dist/core/events/v3/capabilities.js +17 -0
  99. package/dist/core/events/v3/contract.d.ts +5 -0
  100. package/dist/core/events/v3/contract.d.ts.map +1 -1
  101. package/dist/core/events/v3/contract.js +7 -1
  102. package/dist/core/events/v3/control-witness.d.ts.map +1 -1
  103. package/dist/core/events/v3/control-witness.js +3 -2
  104. package/dist/core/events/v3/coordination-transaction-recovery.d.ts.map +1 -1
  105. package/dist/core/events/v3/coordination-transaction-recovery.js +4 -3
  106. package/dist/core/events/v3/fingerprint-keys.d.ts.map +1 -1
  107. package/dist/core/events/v3/fingerprint-keys.js +7 -6
  108. package/dist/core/events/v3/generated.d.ts +1 -1
  109. package/dist/core/events/v3/generated.js +1 -1
  110. package/dist/core/events/v3/live-feed.d.ts.map +1 -1
  111. package/dist/core/events/v3/live-feed.js +5 -4
  112. package/dist/core/events/v3/producers/command-recorder.d.ts.map +1 -1
  113. package/dist/core/events/v3/producers/command-recorder.js +8 -7
  114. package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -1
  115. package/dist/core/events/v3/producers/coordination-recorder.js +8 -7
  116. package/dist/core/events/v3/producers/diagnostic-summaries.d.ts.map +1 -1
  117. package/dist/core/events/v3/producers/diagnostic-summaries.js +5 -4
  118. package/dist/core/events/v3/producers/hook-base.d.ts +1 -0
  119. package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -1
  120. package/dist/core/events/v3/producers/hook-base.js +10 -4
  121. package/dist/core/events/v3/producers/hook.d.ts +2 -0
  122. package/dist/core/events/v3/producers/hook.d.ts.map +1 -1
  123. package/dist/core/events/v3/producers/hook.js +16 -1
  124. package/dist/core/events/v3/producers/intake.d.ts.map +1 -1
  125. package/dist/core/events/v3/producers/intake.js +16 -6
  126. package/dist/core/events/v3/producers/recorder.d.ts +2 -4
  127. package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
  128. package/dist/core/events/v3/producers/recorder.js +109 -101
  129. package/dist/core/events/v3/recovery.d.ts.map +1 -1
  130. package/dist/core/events/v3/recovery.js +4 -3
  131. package/dist/core/events/v3/support-storage/inventory.d.ts.map +1 -1
  132. package/dist/core/events/v3/support-storage/inventory.js +2 -1
  133. package/dist/core/events/v3/support-storage/maintenance.d.ts.map +1 -1
  134. package/dist/core/events/v3/support-storage/maintenance.js +4 -3
  135. package/dist/core/events/v3/support-storage/pack-reader.d.ts.map +1 -1
  136. package/dist/core/events/v3/support-storage/pack-reader.js +4 -3
  137. package/dist/core/events/v3/support-storage/pack-writer.d.ts.map +1 -1
  138. package/dist/core/events/v3/support-storage/pack-writer.js +6 -5
  139. package/dist/core/events/v3/tool-line-changes.d.ts +8 -0
  140. package/dist/core/events/v3/tool-line-changes.d.ts.map +1 -0
  141. package/dist/core/events/v3/tool-line-changes.js +135 -0
  142. package/dist/core/events/v3/writer.d.ts.map +1 -1
  143. package/dist/core/events/v3/writer.js +8 -7
  144. package/dist/core/governor/planning.d.ts.map +1 -1
  145. package/dist/core/governor/planning.js +6 -5
  146. package/dist/core/governor/service.d.ts.map +1 -1
  147. package/dist/core/governor/service.js +12 -11
  148. package/dist/core/governor/state.d.ts.map +1 -1
  149. package/dist/core/governor/state.js +7 -6
  150. package/dist/core/guard/evaluator.js +1 -0
  151. package/dist/core/guard/storage.d.ts.map +1 -1
  152. package/dist/core/guard/storage.js +3 -2
  153. package/dist/core/hooks/adapter/behaviors/claude-code.d.ts +4 -0
  154. package/dist/core/hooks/adapter/behaviors/claude-code.d.ts.map +1 -0
  155. package/dist/core/hooks/adapter/behaviors/claude-code.js +31 -0
  156. package/dist/core/hooks/adapter/behaviors/codex.d.ts +15 -0
  157. package/dist/core/hooks/adapter/behaviors/codex.d.ts.map +1 -0
  158. package/dist/core/hooks/adapter/behaviors/codex.js +82 -0
  159. package/dist/core/hooks/adapter/behaviors/cursor.d.ts +7 -0
  160. package/dist/core/hooks/adapter/behaviors/cursor.d.ts.map +1 -0
  161. package/dist/core/hooks/adapter/behaviors/cursor.js +35 -0
  162. package/dist/core/hooks/adapter/behaviors/index.d.ts +11 -0
  163. package/dist/core/hooks/adapter/behaviors/index.d.ts.map +1 -0
  164. package/dist/core/hooks/adapter/behaviors/index.js +20 -0
  165. package/dist/core/hooks/adapter/behaviors/openclaw.d.ts +7 -0
  166. package/dist/core/hooks/adapter/behaviors/openclaw.d.ts.map +1 -0
  167. package/dist/core/hooks/adapter/behaviors/openclaw.js +34 -0
  168. package/dist/core/hooks/adapter/behaviors/opencode.d.ts +7 -0
  169. package/dist/core/hooks/adapter/behaviors/opencode.d.ts.map +1 -0
  170. package/dist/core/hooks/adapter/behaviors/opencode.js +34 -0
  171. package/dist/core/hooks/adapter/behaviors/types.d.ts +89 -0
  172. package/dist/core/hooks/adapter/behaviors/types.d.ts.map +1 -0
  173. package/dist/core/hooks/adapter/behaviors/types.js +1 -0
  174. package/dist/core/hooks/adapter/detect.d.ts +1 -1
  175. package/dist/core/hooks/adapter/detect.d.ts.map +1 -1
  176. package/dist/core/hooks/adapter/detect.js +2 -3
  177. package/dist/core/hooks/adapter/events.d.ts +29 -1
  178. package/dist/core/hooks/adapter/events.d.ts.map +1 -1
  179. package/dist/core/hooks/adapter/events.js +31 -0
  180. package/dist/core/hooks/adapter/opencode-plugin.d.ts +60 -0
  181. package/dist/core/hooks/adapter/opencode-plugin.d.ts.map +1 -0
  182. package/dist/core/hooks/adapter/opencode-plugin.js +129 -0
  183. package/dist/core/hooks/adapter/output.d.ts +7 -0
  184. package/dist/core/hooks/adapter/output.d.ts.map +1 -1
  185. package/dist/core/hooks/adapter/output.js +8 -1
  186. package/dist/core/hooks/adapter/wiring.d.ts +15 -1
  187. package/dist/core/hooks/adapter/wiring.d.ts.map +1 -1
  188. package/dist/core/hooks/adapter/wiring.js +74 -11
  189. package/dist/core/hooks/cli.js +635 -529
  190. package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
  191. package/dist/core/hooks/effects/image-capture.js +2 -1
  192. package/dist/core/hooks/prompt-context/contract.d.ts.map +1 -1
  193. package/dist/core/hooks/prompt-context/contract.js +1 -0
  194. package/dist/core/hooks/resolve/transcript.d.ts +1 -1
  195. package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
  196. package/dist/core/hooks/resolve/transcript.js +35 -4
  197. package/dist/core/hooks/session-name-presence.d.ts +3 -1
  198. package/dist/core/hooks/session-name-presence.d.ts.map +1 -1
  199. package/dist/core/hooks/session-name-presence.js +7 -2
  200. package/dist/core/hooks/shell-waiter.d.ts +2 -0
  201. package/dist/core/hooks/shell-waiter.d.ts.map +1 -0
  202. package/dist/core/hooks/shell-waiter.js +173 -0
  203. package/dist/core/resources/service.d.ts.map +1 -1
  204. package/dist/core/resources/service.js +5 -4
  205. package/dist/core/semantic/review.d.ts.map +1 -1
  206. package/dist/core/semantic/review.js +5 -4
  207. package/dist/core/semantic/service.d.ts.map +1 -1
  208. package/dist/core/semantic/service.js +15 -14
  209. package/dist/core/semantic/storage.d.ts.map +1 -1
  210. package/dist/core/semantic/storage.js +5 -4
  211. package/dist/core/storage/atomic-json.d.ts.map +1 -1
  212. package/dist/core/storage/atomic-json.js +7 -3
  213. package/dist/core/storage/durable-history.d.ts.map +1 -1
  214. package/dist/core/storage/durable-history.js +6 -5
  215. package/dist/core/storage/maintenance-providers.d.ts.map +1 -1
  216. package/dist/core/storage/maintenance-providers.js +2 -1
  217. package/dist/core/storage/maintenance.d.ts.map +1 -1
  218. package/dist/core/storage/maintenance.js +7 -6
  219. package/dist/core/storage/metrics.d.ts.map +1 -1
  220. package/dist/core/storage/metrics.js +5 -1
  221. package/dist/core/storage/modes.d.ts +17 -0
  222. package/dist/core/storage/modes.d.ts.map +1 -0
  223. package/dist/core/storage/modes.js +47 -0
  224. package/dist/core/storage/process-log.d.ts.map +1 -1
  225. package/dist/core/storage/process-log.js +3 -2
  226. package/dist/core/storage/receipts.d.ts.map +1 -1
  227. package/dist/core/storage/receipts.js +4 -3
  228. package/dist/core/storage/segments.d.ts.map +1 -1
  229. package/dist/core/storage/segments.js +7 -6
  230. package/dist/core/supervisor/hook-health.d.ts +2 -1
  231. package/dist/core/supervisor/hook-health.d.ts.map +1 -1
  232. package/dist/core/supervisor/hook-health.js +4 -3
  233. package/dist/core/supervisor/service.d.ts.map +1 -1
  234. package/dist/core/supervisor/service.js +7 -6
  235. package/dist/core/work/state.d.ts.map +1 -1
  236. package/dist/core/work/state.js +8 -7
  237. package/dist/core/workflow/adapters.d.ts +7 -0
  238. package/dist/core/workflow/adapters.d.ts.map +1 -1
  239. package/dist/core/workflow/adapters.js +9 -0
  240. package/dist/core/workflow/approvals.d.ts.map +1 -1
  241. package/dist/core/workflow/approvals.js +6 -5
  242. package/dist/core/workflow/billing.d.ts.map +1 -1
  243. package/dist/core/workflow/billing.js +33 -4
  244. package/dist/core/workflow/durable-record.d.ts.map +1 -1
  245. package/dist/core/workflow/durable-record.js +4 -3
  246. package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
  247. package/dist/core/workflow/live-session-v3.js +2 -3
  248. package/dist/core/workflow/run-state.d.ts.map +1 -1
  249. package/dist/core/workflow/run-state.js +3 -2
  250. package/dist/core/workflow/spawn-opencode.d.ts +36 -0
  251. package/dist/core/workflow/spawn-opencode.d.ts.map +1 -0
  252. package/dist/core/workflow/spawn-opencode.js +132 -0
  253. package/dist/core/workflow/transcript.d.ts.map +1 -1
  254. package/dist/core/workflow/transcript.js +3 -2
  255. package/dist/core/workflow/workspaces/leases.d.ts.map +1 -1
  256. package/dist/core/workflow/workspaces/leases.js +5 -4
  257. package/dist/core/workflow/workspaces/local-git.d.ts.map +1 -1
  258. package/dist/core/workflow/workspaces/local-git.js +3 -2
  259. package/dist/core/workflow/workspaces/paths.d.ts.map +1 -1
  260. package/dist/core/workflow/workspaces/paths.js +2 -1
  261. package/dist/core/workflow/workspaces/state.d.ts.map +1 -1
  262. package/dist/core/workflow/workspaces/state.js +10 -9
  263. package/dist/lazy-commands.js +8 -1
  264. package/dist/lib/agent-browser/client.d.ts +9 -0
  265. package/dist/lib/agent-browser/client.d.ts.map +1 -1
  266. package/dist/lib/agent-browser/client.js +13 -0
  267. package/dist/lib/browser/client.d.ts +35 -1
  268. package/dist/lib/browser/client.d.ts.map +1 -1
  269. package/dist/lib/browser/client.js +117 -8
  270. package/dist/lib/browser/identity.d.ts +25 -0
  271. package/dist/lib/browser/identity.d.ts.map +1 -0
  272. package/dist/lib/browser/identity.js +66 -0
  273. package/dist/lib/browser/index.d.ts +2 -1
  274. package/dist/lib/browser/index.d.ts.map +1 -1
  275. package/dist/lib/browser/index.js +2 -1
  276. package/dist/lib/browser/launch-args.d.ts +26 -0
  277. package/dist/lib/browser/launch-args.d.ts.map +1 -1
  278. package/dist/lib/browser/launch-args.js +41 -1
  279. package/dist/lib/browser/user-agent.d.ts +53 -0
  280. package/dist/lib/browser/user-agent.d.ts.map +1 -0
  281. package/dist/lib/browser/user-agent.js +79 -0
  282. package/dist/lib/docs-metadata-managed.d.ts +1 -0
  283. package/dist/lib/docs-metadata-managed.d.ts.map +1 -1
  284. package/dist/lib/docs-metadata-managed.js +17 -1
  285. package/dist/lib/identities/assume.d.ts.map +1 -1
  286. package/dist/lib/identities/assume.js +4 -9
  287. package/dist/lib/instructions/apply.d.ts.map +1 -1
  288. package/dist/lib/instructions/apply.js +2 -0
  289. package/dist/lib/pace/index.d.ts +2 -0
  290. package/dist/lib/pace/index.d.ts.map +1 -0
  291. package/dist/lib/pace/index.js +1 -0
  292. package/dist/lib/pace/pace.d.ts +95 -0
  293. package/dist/lib/pace/pace.d.ts.map +1 -0
  294. package/dist/lib/pace/pace.js +313 -0
  295. package/dist/lib/tunnel/forward-headers.d.ts +11 -0
  296. package/dist/lib/tunnel/forward-headers.d.ts.map +1 -0
  297. package/dist/lib/tunnel/forward-headers.js +17 -0
  298. package/dist/lib/tunnel/gate.js +15 -10
  299. package/dist/lib/webview/index.d.ts +2 -0
  300. package/dist/lib/webview/index.d.ts.map +1 -0
  301. package/dist/lib/webview/index.js +1 -0
  302. package/dist/lib/webview/webview.d.ts +116 -0
  303. package/dist/lib/webview/webview.d.ts.map +1 -0
  304. package/dist/lib/webview/webview.js +289 -0
  305. package/opencode-plugin/package.json +19 -0
  306. package/opencode-plugin/src/index.ts +791 -0
  307. package/package.json +11 -4
  308. package/schemas/config.schema.json +13 -0
  309. package/schemas/event-v3.schema.json +164 -0
  310. package/src/commander.ts +7 -0
  311. package/src/commands/agents.ts +33 -18
  312. package/src/commands/browse-ai.ts +8 -0
  313. package/src/commands/browse.ts +189 -10
  314. package/src/commands/checkpoint.ts +7 -9
  315. package/src/commands/deinit.ts +9 -4
  316. package/src/commands/docs.ts +2 -0
  317. package/src/commands/doctor.ts +11 -2
  318. package/src/commands/fetch.ts +14 -0
  319. package/src/commands/init.ts +281 -119
  320. package/src/commands/instructions.ts +8 -4
  321. package/src/commands/ledger-v3.ts +2 -1
  322. package/src/commands/webview.ts +159 -0
  323. package/src/core/adapter.ts +102 -1
  324. package/src/core/adapters/attestation.ts +3 -2
  325. package/src/core/adapters/profiles.ts +42 -1
  326. package/src/core/adapters/registry.ts +37 -0
  327. package/src/core/agents/canonical-emit.ts +2 -5
  328. package/src/core/agents/cli.ts +18 -17
  329. package/src/core/agents/coord-client.ts +9 -3
  330. package/src/core/agents/rules/claim-conflict.ts +3 -8
  331. package/src/core/agents/rules/commit-conflict.ts +2 -7
  332. package/src/core/agents/rules/stop-hook.ts +3 -1
  333. package/src/core/agents/session-events.ts +120 -26
  334. package/src/core/agents/session-finalization-state-v3.ts +2 -1
  335. package/src/core/agents/session-finalizer-v3.ts +5 -4
  336. package/src/core/agents/session-name-display.ts +48 -0
  337. package/src/core/agents/state/heartbeat-reader.ts +7 -0
  338. package/src/core/agents/state/heartbeat-writer.ts +24 -2
  339. package/src/core/agents/state/live-coordination-view.ts +1 -0
  340. package/src/core/agents/state/live-coordination-writer.ts +3 -0
  341. package/src/core/agents/state/stale-sweep.ts +2 -9
  342. package/src/core/agents/turn-changes.ts +97 -0
  343. package/src/core/artifacts/delivery-card.ts +2 -1
  344. package/src/core/artifacts/index.ts +4 -3
  345. package/src/core/config.ts +23 -0
  346. package/src/core/context/index.ts +2 -1
  347. package/src/core/conversations/archive.ts +4 -3
  348. package/src/core/diagnostics/bundle.ts +3 -2
  349. package/src/core/events/legacy-storage/canary.ts +5 -4
  350. package/src/core/events/legacy-storage/compression.ts +2 -1
  351. package/src/core/events/v3/adapter-id.ts +29 -1
  352. package/src/core/events/v3/authority-outbox.ts +2 -1
  353. package/src/core/events/v3/bootstrap.ts +5 -4
  354. package/src/core/events/v3/capabilities.ts +17 -0
  355. package/src/core/events/v3/contract.ts +9 -1
  356. package/src/core/events/v3/control-witness.ts +3 -2
  357. package/src/core/events/v3/coordination-transaction-recovery.ts +4 -3
  358. package/src/core/events/v3/fingerprint-keys.ts +7 -6
  359. package/src/core/events/v3/generated.ts +1 -1
  360. package/src/core/events/v3/live-feed.ts +5 -4
  361. package/src/core/events/v3/producers/command-recorder.ts +8 -6
  362. package/src/core/events/v3/producers/coordination-recorder.ts +8 -7
  363. package/src/core/events/v3/producers/diagnostic-summaries.ts +5 -4
  364. package/src/core/events/v3/producers/hook-base.ts +11 -4
  365. package/src/core/events/v3/producers/hook.ts +19 -1
  366. package/src/core/events/v3/producers/intake.ts +18 -6
  367. package/src/core/events/v3/producers/recorder.ts +123 -114
  368. package/src/core/events/v3/recovery.ts +4 -3
  369. package/src/core/events/v3/support-storage/inventory.ts +2 -1
  370. package/src/core/events/v3/support-storage/maintenance.ts +8 -3
  371. package/src/core/events/v3/support-storage/pack-reader.ts +4 -3
  372. package/src/core/events/v3/support-storage/pack-writer.ts +6 -5
  373. package/src/core/events/v3/tool-line-changes.ts +139 -0
  374. package/src/core/events/v3/writer.ts +8 -7
  375. package/src/core/governor/planning.ts +6 -5
  376. package/src/core/governor/service.ts +12 -11
  377. package/src/core/governor/state.ts +7 -6
  378. package/src/core/guard/evaluator.ts +1 -0
  379. package/src/core/guard/storage.ts +3 -2
  380. package/src/core/hooks/adapter/behaviors/claude-code.ts +33 -0
  381. package/src/core/hooks/adapter/behaviors/codex.ts +96 -0
  382. package/src/core/hooks/adapter/behaviors/cursor.ts +37 -0
  383. package/src/core/hooks/adapter/behaviors/index.ts +31 -0
  384. package/src/core/hooks/adapter/behaviors/openclaw.ts +36 -0
  385. package/src/core/hooks/adapter/behaviors/opencode.ts +36 -0
  386. package/src/core/hooks/adapter/behaviors/types.ts +110 -0
  387. package/src/core/hooks/adapter/detect.ts +2 -3
  388. package/src/core/hooks/adapter/events.ts +53 -1
  389. package/src/core/hooks/adapter/opencode-plugin.ts +177 -0
  390. package/src/core/hooks/adapter/output.ts +8 -1
  391. package/src/core/hooks/adapter/wiring.ts +85 -11
  392. package/src/core/hooks/cli.ts +733 -537
  393. package/src/core/hooks/effects/image-capture.ts +2 -1
  394. package/src/core/hooks/prompt-context/contract.ts +1 -0
  395. package/src/core/hooks/resolve/transcript.ts +42 -5
  396. package/src/core/hooks/session-name-presence.ts +10 -3
  397. package/src/core/hooks/shell-waiter.ts +166 -0
  398. package/src/core/resources/service.ts +5 -4
  399. package/src/core/semantic/review.ts +5 -4
  400. package/src/core/semantic/service.ts +15 -14
  401. package/src/core/semantic/storage.ts +5 -4
  402. package/src/core/storage/atomic-json.ts +7 -3
  403. package/src/core/storage/durable-history.ts +6 -5
  404. package/src/core/storage/maintenance-providers.ts +2 -1
  405. package/src/core/storage/maintenance.ts +7 -6
  406. package/src/core/storage/metrics.ts +5 -1
  407. package/src/core/storage/modes.ts +53 -0
  408. package/src/core/storage/process-log.ts +3 -2
  409. package/src/core/storage/receipts.ts +4 -3
  410. package/src/core/storage/segments.ts +7 -6
  411. package/src/core/supervisor/hook-health.ts +4 -4
  412. package/src/core/supervisor/service.ts +7 -6
  413. package/src/core/work/state.ts +8 -7
  414. package/src/core/workflow/adapters.ts +15 -0
  415. package/src/core/workflow/approvals.ts +6 -5
  416. package/src/core/workflow/billing.ts +34 -4
  417. package/src/core/workflow/durable-record.ts +4 -3
  418. package/src/core/workflow/live-session-v3.ts +2 -3
  419. package/src/core/workflow/run-state.ts +3 -2
  420. package/src/core/workflow/spawn-opencode.ts +150 -0
  421. package/src/core/workflow/transcript.ts +3 -2
  422. package/src/core/workflow/workspaces/leases.ts +5 -4
  423. package/src/core/workflow/workspaces/local-git.ts +3 -2
  424. package/src/core/workflow/workspaces/paths.ts +2 -1
  425. package/src/core/workflow/workspaces/state.ts +10 -9
  426. package/src/lazy-commands.ts +11 -1
  427. package/src/lib/agent-browser/client.ts +18 -0
  428. package/src/lib/browser/client.ts +147 -9
  429. package/src/lib/browser/identity.ts +64 -0
  430. package/src/lib/browser/index.ts +15 -1
  431. package/src/lib/browser/launch-args.ts +53 -1
  432. package/src/lib/browser/user-agent.ts +130 -0
  433. package/src/lib/docs-metadata-managed.ts +21 -0
  434. package/src/lib/identities/assume.ts +7 -7
  435. package/src/lib/instructions/apply.ts +2 -0
  436. package/src/lib/pace/index.ts +14 -0
  437. package/src/lib/pace/pace.ts +370 -0
  438. package/src/lib/tunnel/forward-headers.ts +16 -0
  439. package/src/lib/tunnel/gate.ts +18 -10
  440. package/src/lib/webview/index.ts +13 -0
  441. package/src/lib/webview/webview.ts +457 -0
@@ -1 +1 @@
1
- {"version":3,"file":"commit-conflict.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/rules/commit-conflict.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAoBH,UAAU,QAAQ;IAChB,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,YAAY,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB;wEACoE;IACpE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,qFAAqF;IACrF,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,oBAAoB,GAAG,mBAAmB,CAgIhG"}
1
+ {"version":3,"file":"commit-conflict.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/rules/commit-conflict.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAqBH,UAAU,QAAQ;IAChB,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,YAAY,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB;wEACoE;IACpE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,qFAAqF;IACrF,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,oBAAoB,GAAG,mBAAmB,CAgIhG"}
@@ -22,6 +22,7 @@
22
22
  import { spawnSync } from "node:child_process";
23
23
  import { appendFileSync, existsSync } from "node:fs";
24
24
  import { basename, dirname, join } from "node:path";
25
+ import { adapterFromPlatform as sharedAdapterFromPlatform } from "../../adapter.js";
25
26
  import { coordFreshnessSeconds } from "../../config.js";
26
27
  import { resolveOwner } from "../../hooks/resolve/owner.js";
27
28
  import { recordLiveClaimChangeV3 } from "../live-authority-v3.js";
@@ -153,7 +154,7 @@ function retainBlockedStagedPaths(coordRoot, instanceId, sessionId, stagedPaths,
153
154
  coordRoot,
154
155
  owner: instanceId,
155
156
  nativeSessionId: self.session_id ?? sessionId,
156
- adapter: adapterFromPlatform(self.platform),
157
+ adapter: sharedAdapterFromPlatform(self.platform, { context: "commit-conflict" }),
157
158
  operation: "acquired",
158
159
  path,
159
160
  access: "write",
@@ -165,13 +166,6 @@ function retainBlockedStagedPaths(coordRoot, instanceId, sessionId, stagedPaths,
165
166
  }
166
167
  }
167
168
  }
168
- function adapterFromPlatform(platform) {
169
- if (platform === "cursor")
170
- return "cursor";
171
- if (platform === "codex")
172
- return "codex";
173
- return "claude-code";
174
- }
175
169
  function findOverlap(staged, files, coordRoot, stagedIsGitlink) {
176
170
  for (const claimed of files) {
177
171
  if (claimed === staged)
@@ -22,6 +22,8 @@ export interface StopHookRequest {
22
22
  };
23
23
  stop_hook_active?: boolean;
24
24
  status_box_present_strict?: boolean;
25
+ /** Current observation overrides an older failed terminal during remediation. */
26
+ session_name_observation_unavailable?: boolean;
25
27
  bypass?: boolean;
26
28
  workflow_child?: boolean;
27
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"stop-hook.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/rules/stop-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,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,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,iFAAiF;IACjF,oCAAoC,CAAC,EAAE,OAAO,CAAC;IAC/C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AAInE,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,GAAG,aAAa,CA6BvF;AAED,oFAAoF;AACpF,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,eAAe,EACpB,MAAM,EAAE,SAAS,OAAO,EAAE,GACzB,aAAa,CAiIf"}
@@ -123,7 +123,7 @@ export function evaluateStopHookV3Events(coordRoot, req, events) {
123
123
  pending.push(rule33Block(coordRoot, req.session_id));
124
124
  // Claude Code can prove session-name presentation from assistant-only text.
125
125
  // Cursor cannot expose that text and Codex returned observe-only above.
126
- if (req.adapter !== "cursor") {
126
+ if (req.adapter !== "cursor" && !req.session_name_observation_unavailable) {
127
127
  const naming = turnTerminals
128
128
  .map((event) => observedNaming(event.payload.ritual?.session_name))
129
129
  .filter((value) => value !== undefined);
@@ -21,9 +21,13 @@ export declare function newCmdId(): string;
21
21
  * Path: `.harnery/.last-intent.<instance_id>` next to the agent's heartbeat.
22
22
  */
23
23
  export declare function readLastIntent(instanceId?: string): string | null;
24
+ /** Count the non-empty lines in one output chunk; a single event may carry many. */
25
+ export declare function countOutputLines(text: string): number;
24
26
  /**
25
- * Record a command event in V3. Best-effort, never throws into the caller;
26
- * telemetry must not break or slow a command.
27
+ * Start/completion use the durable V3 recorder. Output only updates bounded
28
+ * per-stream counters and hashes; summaries flush before completion or at
29
+ * process exit. A forced kill can lose unflushed summaries (ADR 0188).
30
+ * Best-effort: telemetry never throws into the caller.
27
31
  */
28
32
  export declare function writeSessionEvent(type: SessionEventType, fields?: Record<string, unknown>): void;
29
33
  /** Trim long values to keep individual events small. */
@@ -1 +1 @@
1
- {"version":3,"file":"session-events.d.ts","sourceRoot":"","sources":["../../../src/core/agents/session-events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkBH,mDAAmD;AACnD,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,GAAG,yBAAyB,GAAG,mBAAmB,CAAC;AAEnG;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAG7C;AAED,6EAA6E;AAC7E,wBAAgB,QAAQ,IAAI,MAAM,CAEjC;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiBjE;AAsID;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,gBAAgB,EACtB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACnC,IAAI,CAEN;AAED,wDAAwD;AACxD,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,SAAO,GAAG,MAAM,CAGxD"}
1
+ {"version":3,"file":"session-events.d.ts","sourceRoot":"","sources":["../../../src/core/agents/session-events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkBH,mDAAmD;AACnD,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,GAAG,yBAAyB,GAAG,mBAAmB,CAAC;AAEnG;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAG7C;AAED,6EAA6E;AAC7E,wBAAgB,QAAQ,IAAI,MAAM,CAEjC;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiBjE;AA4GD,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKrD;AAgED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,gBAAgB,EACtB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACnC,IAAI,CAkDN;AAED,wDAAwD;AACxD,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,SAAO,GAAG,MAAM,CAGxD"}
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * `writeSessionEvent` records command spans in the canonical V3 ledger.
5
5
  */
6
- import { randomBytes } from "node:crypto";
6
+ import { createHash, randomBytes } from "node:crypto";
7
7
  import { existsSync, readFileSync } from "node:fs";
8
8
  import { resolve } from "node:path";
9
9
  // Kept dependency-light: vendored verbatim into a downstream consumer, so no coordEnv import.
@@ -55,19 +55,30 @@ export function readLastIntent(instanceId) {
55
55
  return null;
56
56
  }
57
57
  }
58
- const outputSequence = new Map();
58
+ const pendingCommands = new Map();
59
+ let exitFlushInstalled = false;
60
+ function commandKey(fields) {
61
+ return typeof fields.instance_id === "string" && typeof fields.cmd_id === "string"
62
+ ? JSON.stringify([fields.instance_id, fields.cmd_id])
63
+ : undefined;
64
+ }
65
+ function flushCommandOutput(command) {
66
+ for (const summary of command.streams.values()) {
67
+ recordCommandObservation("command.output_observed", command.fields, command.coordRoot, summary);
68
+ }
69
+ command.streams.clear();
70
+ }
59
71
  /** Emit a command/narration event to the canonical stream. Swallows every
60
72
  * error and skips when identity can't be resolved: telemetry must never break
61
73
  * or slow down a command. */
62
- function recordCommandObservation(type, fields) {
74
+ function recordCommandObservation(type, fields, coordRoot, summary) {
63
75
  const instanceId = typeof fields.instance_id === "string" ? fields.instance_id : undefined;
64
76
  if (!instanceId)
65
- return;
77
+ return false;
66
78
  try {
67
- const coordRoot = coordinationRootPath();
68
79
  const route = resolveLiveEventLedgerRouteV3(coordRoot);
69
80
  if (route.state === "blocked")
70
- return;
81
+ return false;
71
82
  const liveInstanceId = liveInstanceIdV3(instanceId);
72
83
  const hook = readHookProducerStateByInstanceV3(coordRoot, liveInstanceId);
73
84
  if (!hook) {
@@ -76,11 +87,11 @@ function recordCommandObservation(type, fields) {
76
87
  instance_id: instanceId,
77
88
  reason: "hook_generation_not_found",
78
89
  });
79
- return;
90
+ return false;
80
91
  }
81
- const command = commandSignalAndObservation(type, fields);
92
+ const command = commandSignalAndObservation(type, fields, summary);
82
93
  if (!command)
83
- return;
94
+ return false;
84
95
  const result = recordCommandSignalV3({
85
96
  coordRoot,
86
97
  mode: route.mode,
@@ -98,7 +109,7 @@ function recordCommandObservation(type, fields) {
98
109
  const expectedLifecycleReopenGap = result.reason === "turn_not_started" &&
99
110
  hook.session_start_derivation === "approved_lifecycle_reopen";
100
111
  if (expectedLifecycleReopenGap)
101
- return;
112
+ return false;
102
113
  writeProducerDiagnosticV3(coordRoot, "command_emit_unjoinable", {
103
114
  type,
104
115
  instance_id: instanceId,
@@ -114,11 +125,11 @@ function recordCommandObservation(type, fields) {
114
125
  result_state: result.state,
115
126
  });
116
127
  }
128
+ return result.state === "recorded" || result.state === "already_recorded";
117
129
  }
118
130
  catch (error) {
119
131
  // Telemetry must never break the command, but the loss is preserved.
120
132
  try {
121
- const coordRoot = coordinationRootPath();
122
133
  writeProducerDiagnosticV3(coordRoot, "command_emit_failed", {
123
134
  type,
124
135
  instance_id: instanceId,
@@ -128,14 +139,24 @@ function recordCommandObservation(type, fields) {
128
139
  catch {
129
140
  /* diagnostics are best-effort */
130
141
  }
142
+ return false;
131
143
  }
132
144
  }
133
- function commandSignalAndObservation(type, fields) {
145
+ /** Count the non-empty lines in one output chunk; a single event may carry many. */
146
+ export function countOutputLines(text) {
147
+ if (!text)
148
+ return 0;
149
+ let count = 0;
150
+ for (const line of text.split("\n"))
151
+ if (line.length > 0)
152
+ count += 1;
153
+ return count;
154
+ }
155
+ function commandSignalAndObservation(type, fields, summary) {
134
156
  const commandId = typeof fields.cmd_id === "string" ? fields.cmd_id : undefined;
135
157
  if (!commandId)
136
158
  return undefined;
137
159
  if (type === "command.started") {
138
- outputSequence.set(commandId, 0);
139
160
  const command = typeof fields.cmd === "string" ? fields.cmd : "";
140
161
  const executable = command.trim().split(/\s+/, 1)[0] || "unknown";
141
162
  return {
@@ -154,23 +175,26 @@ function commandSignalAndObservation(type, fields) {
154
175
  };
155
176
  }
156
177
  if (type === "command.output_observed") {
157
- const sequence = (outputSequence.get(commandId) ?? 0) + 1;
158
- outputSequence.set(commandId, sequence);
159
- const line = typeof fields.line === "string" ? fields.line : "";
160
- const stream = fields.stream === "stdout" || fields.stream === "stderr" ? fields.stream : "combined";
178
+ if (!summary)
179
+ return undefined;
161
180
  return {
162
181
  signal: "command.output_observed",
163
182
  observation: {
164
183
  native_command_id: commandId,
165
- native_observation_id: `${commandId}:output:${sequence}`,
166
- stream,
167
- output: line,
168
- output_bytes: Buffer.byteLength(line, "utf8"),
169
- output_lines: line ? 1 : 0,
184
+ native_observation_id: `${commandId}:output-summary:${summary.stream}`,
185
+ stream: summary.stream,
186
+ // The normalizer HMACs this bounded descriptor with the generation key.
187
+ // Neither raw output nor its unkeyed digest is written to the ledger.
188
+ output: {
189
+ format: "harnery-output-chunks-v1",
190
+ chunks: summary.chunks,
191
+ sha256: summary.hash.digest("hex"),
192
+ },
193
+ output_bytes: summary.bytes,
194
+ output_lines: summary.lines,
170
195
  },
171
196
  };
172
197
  }
173
- outputSequence.delete(commandId);
174
198
  const exitCode = typeof fields.exit === "number" && Number.isSafeInteger(fields.exit) ? fields.exit : undefined;
175
199
  return {
176
200
  signal: "command.completed",
@@ -186,11 +210,66 @@ function commandSignalAndObservation(type, fields) {
186
210
  };
187
211
  }
188
212
  /**
189
- * Record a command event in V3. Best-effort, never throws into the caller;
190
- * telemetry must not break or slow a command.
213
+ * Start/completion use the durable V3 recorder. Output only updates bounded
214
+ * per-stream counters and hashes; summaries flush before completion or at
215
+ * process exit. A forced kill can lose unflushed summaries (ADR 0188).
216
+ * Best-effort: telemetry never throws into the caller.
191
217
  */
192
218
  export function writeSessionEvent(type, fields = {}) {
193
- recordCommandObservation(type, fields);
219
+ try {
220
+ const key = commandKey(fields);
221
+ if (!key)
222
+ return;
223
+ if (type === "command.output_observed") {
224
+ const command = pendingCommands.get(key);
225
+ if (!command)
226
+ return;
227
+ const stream = fields.stream === "stdout" || fields.stream === "stderr" ? fields.stream : "combined";
228
+ let summary = command.streams.get(stream);
229
+ if (!summary) {
230
+ summary = { stream, bytes: 0, lines: 0, chunks: 0, hash: createHash("sha256") };
231
+ command.streams.set(stream, summary);
232
+ }
233
+ const line = typeof fields.line === "string" ? fields.line : "";
234
+ const normalized = line.normalize("NFC");
235
+ // Length framing preserves chunk boundaries, including empty chunks.
236
+ summary.hash.update(`${Buffer.byteLength(normalized, "utf8")}:`).update(normalized);
237
+ summary.bytes += Buffer.byteLength(line, "utf8");
238
+ summary.lines += countOutputLines(line);
239
+ summary.chunks += 1;
240
+ return;
241
+ }
242
+ const command = pendingCommands.get(key);
243
+ const coordRoot = command?.coordRoot ?? coordinationRootPath();
244
+ if (type === "command.completed") {
245
+ pendingCommands.delete(key);
246
+ if (command)
247
+ flushCommandOutput(command);
248
+ recordCommandObservation(type, fields, coordRoot);
249
+ }
250
+ else if (recordCommandObservation(type, fields, coordRoot) && !command) {
251
+ pendingCommands.set(key, {
252
+ coordRoot,
253
+ fields: {
254
+ instance_id: fields.instance_id,
255
+ cmd_id: fields.cmd_id,
256
+ bridge: fields.bridge,
257
+ },
258
+ streams: new Map(),
259
+ });
260
+ if (!exitFlushInstalled) {
261
+ exitFlushInstalled = true;
262
+ process.once("exit", () => {
263
+ for (const pending of pendingCommands.values())
264
+ flushCommandOutput(pending);
265
+ pendingCommands.clear();
266
+ });
267
+ }
268
+ }
269
+ }
270
+ catch {
271
+ // Root resolution and in-memory bookkeeping must not break the command.
272
+ }
194
273
  }
195
274
  /** Trim long values to keep individual events small. */
196
275
  export function clampField(v, max = 1024) {
@@ -1 +1 @@
1
- {"version":3,"file":"session-finalization-state-v3.d.ts","sourceRoot":"","sources":["../../../src/core/agents/session-finalization-state-v3.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAGrF,eAAO,MAAM,sCAAsC,EACjD,yCAAkD,CAAC;AACrD,eAAO,MAAM,uCAAuC,EAAG,CAAU,CAAC;AAElE,MAAM,MAAM,4BAA4B,GACpC,cAAc,GACd,kBAAkB,GAClB,cAAc,GACd,iBAAiB,GACjB,aAAa,GACb,iBAAiB,GACjB,eAAe,GACf,YAAY,GACZ,kBAAkB,CAAC;AAEvB,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,OAAO,sCAAsC,CAAC;IACtD,cAAc,EAAE,OAAO,uCAAuC,CAAC;IAC/D,UAAU,EAAE,OAAO,MAAM,EAAE,CAAC;IAC5B,WAAW,EAAE,QAAQ,MAAM,EAAE,CAAC;IAC9B,aAAa,EAAE,OAAO,MAAM,EAAE,CAAC;IAC/B,OAAO,EAAE,4BAA4B,CAAC;IACtC,MAAM,EAAE,0BAA0B,CAAC;IACnC,OAAO,EACH,WAAW,GACX,QAAQ,GACR,WAAW,GACX,WAAW,GACX,QAAQ,GACR,aAAa,GACb,SAAS,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,OAAO,MAAM,EAAE,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,MAAM,EAAE,CAAC;IACvC,iBAAiB,CAAC,EAAE,OAAO,MAAM,EAAE,CAAC;IACpC,qBAAqB,CAAC,EAAE,QAAQ,MAAM,EAAE,EAAE,CAAC;IAC3C,sBAAsB,EAAE,OAAO,CAAC;IAChC,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,OAAO,MAAM,EAAE,CAAC;CACrC;AAED,wBAAgB,qCAAqC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE/E;AAED,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7F;AAED,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,MAAM,GAChB,4BAA4B,EAAE,CAWhC;AAED,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,MAAM,GAAG,4BAA4B,CAiB/F"}
1
+ {"version":3,"file":"session-finalization-state-v3.d.ts","sourceRoot":"","sources":["../../../src/core/agents/session-finalization-state-v3.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAIrF,eAAO,MAAM,sCAAsC,EACjD,yCAAkD,CAAC;AACrD,eAAO,MAAM,uCAAuC,EAAG,CAAU,CAAC;AAElE,MAAM,MAAM,4BAA4B,GACpC,cAAc,GACd,kBAAkB,GAClB,cAAc,GACd,iBAAiB,GACjB,aAAa,GACb,iBAAiB,GACjB,eAAe,GACf,YAAY,GACZ,kBAAkB,CAAC;AAEvB,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,OAAO,sCAAsC,CAAC;IACtD,cAAc,EAAE,OAAO,uCAAuC,CAAC;IAC/D,UAAU,EAAE,OAAO,MAAM,EAAE,CAAC;IAC5B,WAAW,EAAE,QAAQ,MAAM,EAAE,CAAC;IAC9B,aAAa,EAAE,OAAO,MAAM,EAAE,CAAC;IAC/B,OAAO,EAAE,4BAA4B,CAAC;IACtC,MAAM,EAAE,0BAA0B,CAAC;IACnC,OAAO,EACH,WAAW,GACX,QAAQ,GACR,WAAW,GACX,WAAW,GACX,QAAQ,GACR,aAAa,GACb,SAAS,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,OAAO,MAAM,EAAE,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,MAAM,EAAE,CAAC;IACvC,iBAAiB,CAAC,EAAE,OAAO,MAAM,EAAE,CAAC;IACpC,qBAAqB,CAAC,EAAE,QAAQ,MAAM,EAAE,EAAE,CAAC;IAC3C,sBAAsB,EAAE,OAAO,CAAC;IAChC,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,OAAO,MAAM,EAAE,CAAC;CACrC;AAED,wBAAgB,qCAAqC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE/E;AAED,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7F;AAED,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,MAAM,GAChB,4BAA4B,EAAE,CAWhC;AAED,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,MAAM,GAAG,4BAA4B,CAiB/F"}
@@ -1,6 +1,7 @@
1
1
  import { existsSync, lstatSync, readdirSync, readFileSync } from "node:fs";
2
2
  import { join, resolve } from "node:path";
3
3
  import { EVENT_V3_LEDGER_RELATIVE_ROOT } from "../events/v3/reader.js";
4
+ import { stateModeTooOpen } from "../storage/modes.js";
4
5
  export const SESSION_FINALIZATION_REQUEST_FORMAT_V3 = "harnery-v3-session-finalization-request";
5
6
  export const SESSION_FINALIZATION_REQUEST_VERSION_V3 = 1;
6
7
  export function sessionFinalizationRequestDirectoryV3(coordRoot) {
@@ -24,7 +25,7 @@ export function listSessionFinalizationRequestsV3(coordRoot) {
24
25
  }
25
26
  export function readSessionFinalizationRequestV3(filePath) {
26
27
  const metadata = lstatSync(filePath);
27
- if (!metadata.isFile() || metadata.isSymbolicLink() || (metadata.mode & 0o077) !== 0) {
28
+ if (!metadata.isFile() || metadata.isSymbolicLink() || stateModeTooOpen(metadata.mode)) {
28
29
  throw new Error("V3 session finalization request is unsafe");
29
30
  }
30
31
  const request = JSON.parse(readFileSync(filePath, "utf8"));
@@ -1 +1 @@
1
- {"version":3,"file":"session-finalizer-v3.d.ts","sourceRoot":"","sources":["../../../src/core/agents/session-finalizer-v3.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAmBxD,OAAO,EAIL,KAAK,4BAA4B,EAIlC,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACL,iCAAiC,EACjC,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,GAClC,MAAM,oCAAoC,CAAC;AAK5C,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,gBAAgB,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,qCAAqC;IACpD,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,oBAAoB,CAAC,EAAE,SAAS,2BAA2B,EAAE,CAAC;CAC/D;AAED,MAAM,WAAW,oCAAoC;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,QAAQ,MAAM,EAAE,CAAC;IAC9B,aAAa,EAAE,OAAO,MAAM,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE,4BAA4B,CAAC,SAAS,CAAC,CAAC;IAClD,WAAW,CAAC,EA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13
13
  import { assertEventV3 } from "../events/v3/validate.js";
14
14
  import { EVENT_V3_LEDGER_RELATIVE_ROOT, writeEventV3 } from "../events/v3/writer.js";
15
+ import { stateDirMode, stateFileMode } from "../storage/modes.js";
15
16
  import { fsyncParentDirectory } from "../workflow/durable-record.js";
16
17
  import { acquireNoClobberLease } from "../workflow/workspaces/leases.js";
17
18
  import { readCodexArchiveObservationsV3 } from "./codex-archive-v3.js";
@@ -686,21 +687,21 @@ function completeRequest(coordRoot, request, eventId) {
686
687
  }
687
688
  function writeRequest(coordRoot, request, create = false) {
688
689
  const directory = sessionFinalizationRequestDirectoryV3(coordRoot);
689
- mkdirSync(directory, { recursive: true, mode: 0o700 });
690
- chmodSync(directory, 0o700);
690
+ mkdirSync(directory, { recursive: true, mode: stateDirMode() });
691
+ chmodSync(directory, stateDirMode());
691
692
  const path = sessionFinalizationRequestPathV3(coordRoot, request.request_id);
692
693
  if (create && existsSync(path))
693
694
  throw new Error("V3 finalization request already exists");
694
695
  const temporary = `${path}.tmp-${process.pid}-${randomUUID()}`;
695
696
  let fd;
696
697
  try {
697
- fd = openSync(temporary, "wx", 0o600);
698
+ fd = openSync(temporary, "wx", stateFileMode());
698
699
  writeFileSync(fd, `${JSON.stringify(request)}\n`, "utf8");
699
700
  fsyncSync(fd);
700
701
  closeSync(fd);
701
702
  fd = undefined;
702
703
  renameSync(temporary, path);
703
- chmodSync(path, 0o600);
704
+ chmodSync(path, stateFileMode());
704
705
  fsyncParentDirectory(path);
705
706
  }
706
707
  finally {
@@ -8,7 +8,15 @@ export interface SessionNameDisplayState {
8
8
  suggested_session_name?: string;
9
9
  session_name_seen_for?: string;
10
10
  session_name_display_requested_for?: string;
11
+ session_name_display_reminders?: number;
11
12
  }
13
+ /**
14
+ * How many times PostToolUse may re-attach the display instruction after the
15
+ * mint-time one, per requested title. Two covers the observed miss (the model
16
+ * narrates, calls a tool, and forgets) without turning an unreadable
17
+ * transcript into a reminder on every tool for the rest of the session.
18
+ */
19
+ export declare const SESSION_NAME_DISPLAY_REMINDER_LIMIT = 2;
12
20
  export declare const SESSION_NAME_DISPLAY_NOTE = "Next, before any prose or another tool call, send suggested_session_name verbatim by itself in a fenced code block.";
13
21
  export declare function sessionNameDisplayPending(row: SessionNameDisplayState | null | undefined): string | null;
14
22
  /**
@@ -32,6 +40,26 @@ export declare function matchSessionNameDisplay(row: SessionNameDisplayState | n
32
40
  } | null;
33
41
  export declare function sessionNameDisplayBlock(name: string): string;
34
42
  export declare function sessionNameDisplayInstruction(name: string): string;
43
+ /**
44
+ * Whether an ordinary tool result should carry a bounded reminder.
45
+ *
46
+ * Only after the mint-time instruction has gone out (`requested_for` is set
47
+ * for the pending title), and only while the counter is under the cap. The
48
+ * transcript is deliberately not consulted: PreToolUse already stamped a
49
+ * readable sighting, and an unreadable one is exactly the case the reminder
50
+ * exists for.
51
+ */
52
+ export declare function sessionNameDisplayReminderDue(row: SessionNameDisplayState | null | undefined): string | null;
53
+ /**
54
+ * The follow-up nudge for a title still pending after an ordinary tool.
55
+ *
56
+ * Worded so the model can answer it from its own memory: the desktop transcript
57
+ * sometimes drops a text row that the operator did see, so Harnery cannot tell
58
+ * a skipped block from an unrecorded one. A model that already showed the block
59
+ * is told to do nothing, which is what keeps the reminder from producing
60
+ * duplicate blocks in the chat.
61
+ */
62
+ export declare function sessionNameDisplayReminder(name: string): string;
35
63
  export declare function sessionNameDisplayRecoveryInstruction(name: string, binName: string): string;
36
64
  /**
37
65
  * A PostToolUse result should announce the display protocol only when that
@@ -1 +1 @@
1
- {"version":3,"file":"session-name-display.d.ts","sourceRoot":"","sources":["../../../src/core/agents/session-name-display.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,uBAAuB;IACtC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,kCAAkC,CAAC,EAAE,MAAM,CAAC;CAC7C;AAED,eAAO,MAAM,yBAAyB,wHACiF,CAAC;AAExH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,uBAAuB,GAAG,IAAI,GAAG,SAAS,GAC9C,MAAM,GAAG,IAAI,CAIf;AAED;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,uBAAuB,GAAG,IAAI,GAAG,SAAS,GAC9C,MAAM,EAAE,CAKV;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,uBAAuB,GAAG,IAAI,GAAG,SAAS,EAC/C,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,eAAe,GAAE,CACf,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,KACjB,OAAiD,GACrD;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAO/C;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASlE;AAED,wBAAgB,qCAAqC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM3F;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAGtF;AAqFD,wBAAgB,uCAAuC,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAI3F;AAUD;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAmBT"}
1
+ {"version":3,"file":"session-name-display.d.ts","sourceRoot":"","sources":["../../../src/core/agents/session-name-display.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,uBAAuB;IACtC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,q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,EAAE,MAAM,GAAG,OAAO,CAGtF;AAqFD,wBAAgB,uCAAuC,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAI3F;AAUD;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAmBT"}
@@ -4,6 +4,13 @@
4
4
  * prompt context, PostToolUse injection, and PreToolUse enforcement cannot
5
5
  * drift apart.
6
6
  */
7
+ /**
8
+ * How many times PostToolUse may re-attach the display instruction after the
9
+ * mint-time one, per requested title. Two covers the observed miss (the model
10
+ * narrates, calls a tool, and forgets) without turning an unreadable
11
+ * transcript into a reminder on every tool for the rest of the session.
12
+ */
13
+ export const SESSION_NAME_DISPLAY_REMINDER_LIMIT = 2;
7
14
  export const SESSION_NAME_DISPLAY_NOTE = "Next, before any prose or another tool call, send suggested_session_name verbatim by itself in a fenced code block.";
8
15
  export function sessionNameDisplayPending(row) {
9
16
  const name = row?.suggested_session_name;
@@ -55,6 +62,42 @@ export function sessionNameDisplayInstruction(name) {
55
62
  "Do not put commentary before the block. Harnery will reject tool calls until it is shown.",
56
63
  ].join("\n");
57
64
  }
65
+ /**
66
+ * Whether an ordinary tool result should carry a bounded reminder.
67
+ *
68
+ * Only after the mint-time instruction has gone out (`requested_for` is set
69
+ * for the pending title), and only while the counter is under the cap. The
70
+ * transcript is deliberately not consulted: PreToolUse already stamped a
71
+ * readable sighting, and an unreadable one is exactly the case the reminder
72
+ * exists for.
73
+ */
74
+ export function sessionNameDisplayReminderDue(row) {
75
+ const pending = sessionNameDisplayPending(row);
76
+ if (!pending || row?.session_name_display_requested_for !== pending)
77
+ return null;
78
+ return (row.session_name_display_reminders ?? 0) < SESSION_NAME_DISPLAY_REMINDER_LIMIT
79
+ ? pending
80
+ : null;
81
+ }
82
+ /**
83
+ * The follow-up nudge for a title still pending after an ordinary tool.
84
+ *
85
+ * Worded so the model can answer it from its own memory: the desktop transcript
86
+ * sometimes drops a text row that the operator did see, so Harnery cannot tell
87
+ * a skipped block from an unrecorded one. A model that already showed the block
88
+ * is told to do nothing, which is what keeps the reminder from producing
89
+ * duplicate blocks in the chat.
90
+ */
91
+ export function sessionNameDisplayReminder(name) {
92
+ return [
93
+ "Session name still pending.",
94
+ "If you have not already shown it this turn, send this exact fenced block as your next assistant text, before any prose or another tool call:",
95
+ "",
96
+ sessionNameDisplayBlock(name),
97
+ "",
98
+ "If you already showed that block, do nothing; Harnery could not read the transcript row and is asking once more.",
99
+ ].join("\n");
100
+ }
58
101
  export function sessionNameDisplayRecoveryInstruction(name, binName) {
59
102
  return [
60
103
  sessionNameDisplayInstruction(name),
@@ -36,6 +36,13 @@ export interface Heartbeat {
36
36
  * counts so that drift cannot strand the latch.
37
37
  */
38
38
  session_name_display_requested_for?: string;
39
+ /**
40
+ * How many bounded PostToolUse reminders have gone out for
41
+ * `session_name_display_requested_for`. Reset whenever a different title is
42
+ * requested. Caps the nudge so an unreadable transcript never turns into an
43
+ * endless stream of "show the block" context.
44
+ */
45
+ session_name_display_reminders?: number;
39
46
  last_status_at?: string;
40
47
  current_turn_id?: string;
41
48
  parent_instance_id?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"heartbeat-reader.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/state/heartbeat-reader.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAIhE,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEnE,MAAM,WAAW,SAAS;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B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IAC9B,wEAAwE;IACxE,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;;OAKG;IACH,kCAAkC,CAAC,EAAE,MAAM,CAAC;IAC5C;;;;;OAKG;IACH,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uFAAuF;IACvF,cAAc,CAAC,EAAE,QAAQ,MAAM,EAAE,CAAC;IAClC,gBAAgB,CAAC,EAAE,OAAO,MAAM,EAAE,CAAC;IACnC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IAClC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAU3E;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAQrF"}
@@ -55,6 +55,16 @@ export declare function stampSessionNameSeen(coordRoot: string, instanceId: stri
55
55
  * and on Cursor no later surface can repair it.
56
56
  */
57
57
  export declare function stampSessionNameRequested(coordRoot: string, instanceId: string, name: string): Heartbeat | null;
58
+ /**
59
+ * Count one bounded PostToolUse reminder for the title currently requested.
60
+ *
61
+ * The mint-time instruction is the only thing that used to make the block
62
+ * appear; a model that went straight to another tool was never asked again,
63
+ * because the fail-open gate writes its reason to stderr, which the model
64
+ * cannot read. The counter lets the hook re-attach the instruction a fixed
65
+ * number of times and then stop, whatever the transcript can or cannot prove.
66
+ */
67
+ export declare function stampSessionNameReminded(coordRoot: string, instanceId: string, name: string): Heartbeat | null;
58
68
  export declare function releaseClaim(coordRoot: string, instanceId: string, path: string): Heartbeat | null;
59
69
  /** Materialize one V3 write-claim authority transition into the heartbeat cache. */
60
70
  export declare function acquireClaim(coordRoot: string, instanceId: string, path: string): Heartbeat | null;
@@ -1 +1 @@
1
- {"version":3,"file":"heartbeat-writer.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/state/heartbeat-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAaH,OAAO,EAAE,KAAK,SAAS,EAAgC,MAAM,uBAAuB,CAAC;AACrF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,KAAK,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAatE,kFAAkF;AAClF,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS,EAChB,MAAM,CAAC,EAAE,MAAM,EACf,oBAAoB,CAAC,EAAE,MAAM,GAC5B,SAAS,GAAG,IAAI,CAQlB;AAeD,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAoB7F;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,SAAS,GAAG,IAAI,CAOlB;AAED;;;;6BAI6B;AAC7B,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,SAAS,GAAG,UAAU,GAAG,WAAuB,GACrD,SAAS,GAAG,IAAI,CAelB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,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S,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAiBnF"}
@@ -139,11 +139,30 @@ export function stampSessionNameSeen(coordRoot, instanceId, name) {
139
139
  * and on Cursor no later surface can repair it.
140
140
  */
141
141
  export function stampSessionNameRequested(coordRoot, instanceId, name) {
142
+ if (!name)
143
+ return null;
144
+ return mutate(coordRoot, instanceId, (hb) => {
145
+ if (hb.session_name_display_requested_for === name)
146
+ return hb;
147
+ const { session_name_display_reminders: _reset, ...rest } = hb;
148
+ return { ...rest, session_name_display_requested_for: name };
149
+ });
150
+ }
151
+ /**
152
+ * Count one bounded PostToolUse reminder for the title currently requested.
153
+ *
154
+ * The mint-time instruction is the only thing that used to make the block
155
+ * appear; a model that went straight to another tool was never asked again,
156
+ * because the fail-open gate writes its reason to stderr, which the model
157
+ * cannot read. The counter lets the hook re-attach the instruction a fixed
158
+ * number of times and then stop, whatever the transcript can or cannot prove.
159
+ */
160
+ export function stampSessionNameReminded(coordRoot, instanceId, name) {
142
161
  if (!name)
143
162
  return null;
144
163
  return mutate(coordRoot, instanceId, (hb) => hb.session_name_display_requested_for === name
145
- ? hb
146
- : { ...hb, session_name_display_requested_for: name });
164
+ ? { ...hb, session_name_display_reminders: (hb.session_name_display_reminders ?? 0) + 1 }
165
+ : hb);
147
166
  }
148
167
  export function releaseClaim(coordRoot, instanceId, path) {
149
168
  const target = canonicalClaimPath(coordRoot, path);
@@ -1 +1 @@
1
- {"version":3,"file":"live-coordination-view.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/state/live-coordination-view.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EACL,KAAK,4BAA4B,EAIlC,MAAM,sCAAsC,CAAC;AAM9C,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,uBAAuB,CAAC;AAGtE;;;GAGG;AACH,MAAM,WAAW,0BAA2B,SAAQ,SAAS;IAC3D,cAAc,EAAE,CAAC,CAAC;IAClB,cAAc,EAAE,QAAQ,MAAM,EAAE,CAAC;IACjC,gBAAgB,EAAE,OAAO,MAAM,EAAE,CAAC;IAClC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,aAAa,EAAE,KAAK,GAAG,SAAS,CAAC;CAClC;AAED,yEAAyE;AACzE,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,0BAA0B,EAAE,CA2BxF;AAED,kEAAkE;AAClE,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,MAAM,GACvB,0BAA0B,GAAG,IAAI,CAuBnC;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,MAAM,GACvB,gBAAgB,GAAG,IAAI,CAWzB;AA8BD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,EACnC,UAAU,EAAE,4BAA4B,GACvC,KAAK,IAAI,SAAS,CAMpB;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,4BAA4B,EACxC,KAAK,EAAE,SAAS,GAAG,SAAS,EAC5B,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,MAAM,CAAC,EAAE,4BAA4B,GACpC,0BAA0B,CAsD5B;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,4BAA4B,GAAG,MAAM,GAAG,SAAS,CAG9F;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,IAAI,gBAAgB,CAEhF"}
1
+ {"version":3,"file":"live-coordination-view.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/state/live-coordination-view.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EACL,KAAK,4BAA4B,EA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I
135
135
  session_name_seen_at: cache?.session_name_seen_at,
136
136
  session_name_seen_for: cache?.session_name_seen_for,
137
137
  session_name_display_requested_for: cache?.session_name_display_requested_for,
138
+ session_name_display_reminders: cache?.session_name_display_reminders,
138
139
  workflow_run_id: generation.run_id,
139
140
  workflow_agent_id: generation.workflow_agent_id,
140
141
  parent_instance_id: parent ? nativeInstanceIdV3(parent.instance_id) : undefined,
@@ -64,6 +64,9 @@ function materializeLiveCoordinationHeartbeat(coordRoot, nativeInstanceId, nativ
64
64
  session_name_display_requested_for: current.session_name_display_requested_for,
65
65
  }
66
66
  : {}),
67
+ ...(typeof current.session_name_display_reminders === "number"
68
+ ? { session_name_display_reminders: current.session_name_display_reminders }
69
+ : {}),
67
70
  }
68
71
  : {};
69
72
  const materialized = {
@@ -1 +1 @@
1
- {"version":3,"file":"stale-sweep.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/state/stale-sweep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAyEH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG;IAC7C,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,MAAM,CAAC;CAC/B,CAyJA"}
1
+ {"version":3,"file":"stale-sweep.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/state/stale-sweep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAkEH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG;IAC7C,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,MAAM,CAAC;CAC/B,CAyJA"}