mixdog 0.9.152 → 0.9.154

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 (300) hide show
  1. package/LICENSES/browser-import-NOTICE.txt +11 -0
  2. package/NOTICE.md +11 -0
  3. package/README.md +8 -10
  4. package/package.json +19 -3
  5. package/scripts/computer-task-cost-report.mjs +144 -0
  6. package/scripts/run-office-live-tests.mjs +32 -0
  7. package/src/agents/front-worker/AGENT.md +13 -0
  8. package/src/agents/front-worker/agent.json +6 -0
  9. package/src/agents/heavy-worker/AGENT.md +10 -11
  10. package/src/agents/heavy-worker/agent.json +1 -1
  11. package/src/agents/maintainer/AGENT.md +0 -2
  12. package/src/agents/reviewer/AGENT.md +9 -13
  13. package/src/agents/reviewer/agent.json +1 -1
  14. package/src/agents/security/AGENT.md +14 -0
  15. package/src/agents/security/agent.json +6 -0
  16. package/src/agents/worker/AGENT.md +8 -8
  17. package/src/agents/worker/agent.json +1 -1
  18. package/src/agents/writer/AGENT.md +14 -0
  19. package/src/agents/writer/agent.json +6 -0
  20. package/src/rules/agent/00-common.md +4 -7
  21. package/src/rules/lead/01-general.md +0 -3
  22. package/src/rules/shared/10-tool-workflow.md +10 -2
  23. package/src/rules/shared/60-verification.md +2 -0
  24. package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +183 -26
  25. package/src/runtime/agent/orchestrator/agent-runtime/session-builder.mjs +4 -0
  26. package/src/runtime/agent/orchestrator/cache-break-trace.mjs +109 -0
  27. package/src/runtime/agent/orchestrator/config.mjs +7 -2
  28. package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +16 -3
  29. package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +9 -1
  30. package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +30 -9
  31. package/src/runtime/agent/orchestrator/providers/openai-codex-metadata.mjs +18 -26
  32. package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +25 -2
  33. package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +103 -10
  34. package/src/runtime/agent/orchestrator/providers/openai-turn-state.mjs +68 -0
  35. package/src/runtime/agent/orchestrator/providers/openai-ws-delta.mjs +36 -11
  36. package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +140 -86
  37. package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +9 -13
  38. package/src/runtime/agent/orchestrator/session/agent-loop.mjs +72 -4
  39. package/src/runtime/agent/orchestrator/session/browser-snapshot-supersession.mjs +61 -0
  40. package/src/runtime/agent/orchestrator/session/compact/handoff.mjs +0 -22
  41. package/src/runtime/agent/orchestrator/session/compact/messages.mjs +2 -2
  42. package/src/runtime/agent/orchestrator/session/compact/runner.mjs +11 -23
  43. package/src/runtime/agent/orchestrator/session/compact/summary.mjs +28 -269
  44. package/src/runtime/agent/orchestrator/session/compact.mjs +0 -6
  45. package/src/runtime/agent/orchestrator/session/context-utils.mjs +86 -11
  46. package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +17 -1
  47. package/src/runtime/agent/orchestrator/session/image-strip-recovery.mjs +12 -8
  48. package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +110 -2
  49. package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +3 -16
  50. package/src/runtime/agent/orchestrator/session/loop/recall-fasttrack.mjs +80 -18
  51. package/src/runtime/agent/orchestrator/session/loop/steering.mjs +6 -0
  52. package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +3 -0
  53. package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +6 -0
  54. package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +80 -21
  55. package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +33 -72
  56. package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +21 -2
  57. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +25 -51
  58. package/src/runtime/agent/orchestrator/session/manager/status-telemetry.mjs +3 -0
  59. package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +4 -110
  60. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.mjs +39 -15
  61. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +14 -4
  62. package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +41 -8
  63. package/src/runtime/agent/orchestrator/session/provider-prefix-guard.mjs +129 -12
  64. package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +2 -2
  65. package/src/runtime/agent/orchestrator/session/store/listing.mjs +8 -1
  66. package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +15 -1
  67. package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +36 -2
  68. package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +157 -30
  69. package/src/runtime/agent/orchestrator/session/store-summary-visibility.mjs +57 -0
  70. package/src/runtime/agent/orchestrator/session/store.mjs +3 -1
  71. package/src/runtime/agent/orchestrator/session/tool-batch.mjs +22 -0
  72. package/src/runtime/agent/orchestrator/tools/builtin/read-special-files.mjs +6 -6
  73. package/src/runtime/agent/orchestrator/tools/progress-message.mjs +4 -0
  74. package/src/runtime/attachments/pdf-extract.mjs +3 -0
  75. package/src/runtime/attachments/pdfjs-runtime.mjs +13 -0
  76. package/src/runtime/browser-bridge/action-schema.mjs +251 -0
  77. package/src/runtime/browser-bridge/client.mjs +75 -26
  78. package/src/runtime/browser-bridge/tool-defs.mjs +132 -15
  79. package/src/runtime/computer-bridge/action-schema.mjs +653 -0
  80. package/src/runtime/computer-bridge/client.mjs +211 -28
  81. package/src/runtime/computer-bridge/tool-defs.mjs +25 -45
  82. package/src/runtime/office/assurance-benchmark.mjs +358 -0
  83. package/src/runtime/office/assurance.mjs +833 -0
  84. package/src/runtime/office/benchmark.mjs +496 -0
  85. package/src/runtime/office/capabilities.mjs +551 -0
  86. package/src/runtime/office/com-adapter.mjs +283 -0
  87. package/src/runtime/office/content-model.mjs +183 -0
  88. package/src/runtime/office/contract-benchmark.mjs +105 -0
  89. package/src/runtime/office/design-library.mjs +1562 -0
  90. package/src/runtime/office/design-system.mjs +1966 -0
  91. package/src/runtime/office/index.mjs +2413 -0
  92. package/src/runtime/office/journal.mjs +82 -0
  93. package/src/runtime/office/office-com-host.ps1 +3781 -0
  94. package/src/runtime/office/office-com-session-host.ps1 +855 -0
  95. package/src/runtime/office/ooxml-validator.mjs +271 -0
  96. package/src/runtime/office/pagination.mjs +132 -0
  97. package/src/runtime/office/pdf-adapter.mjs +591 -0
  98. package/src/runtime/office/pdf-analysis.mjs +372 -0
  99. package/src/runtime/office/pdf-render.mjs +167 -0
  100. package/src/runtime/office/pdf-security.mjs +63 -0
  101. package/src/runtime/office/polish-benchmark.mjs +190 -0
  102. package/src/runtime/office/portable-ooxml.mjs +1867 -0
  103. package/src/runtime/office/quality-live-benchmark.mjs +486 -0
  104. package/src/runtime/office/quality-pipeline.mjs +136 -0
  105. package/src/runtime/office/tabular.mjs +302 -0
  106. package/src/runtime/office/templates/mixdog-executive.pptx +0 -0
  107. package/src/runtime/office/templates/mixdog-executive.pptx.mixdog.json +190 -0
  108. package/src/runtime/office/tool-defs.mjs +113 -0
  109. package/src/runtime/office/visual-diff.mjs +89 -0
  110. package/src/runtime/office/xlsx-assertions.mjs +172 -0
  111. package/src/runtime/office/xlsx-contract.mjs +147 -0
  112. package/src/runtime/shared/agent-route-config.mjs +9 -0
  113. package/src/runtime/shared/tool-execution-contract.mjs +16 -0
  114. package/src/runtime/shared/tool-surface.mjs +9 -0
  115. package/src/session-runtime/context-status.mjs +9 -3
  116. package/src/session-runtime/deferred-tool-delta.mjs +104 -0
  117. package/src/session-runtime/goal-runtime.mjs +617 -197
  118. package/src/session-runtime/lifecycle-api.mjs +50 -8
  119. package/src/session-runtime/provider-request-snapshot.mjs +33 -9
  120. package/src/session-runtime/resource-api.mjs +31 -94
  121. package/src/session-runtime/runtime-core.mjs +78 -26
  122. package/src/session-runtime/session-lifecycle.mjs +34 -12
  123. package/src/session-runtime/session-title.mjs +2 -2
  124. package/src/session-runtime/session-turn-api.mjs +15 -14
  125. package/src/session-runtime/tool-catalog-data.mjs +1 -1
  126. package/src/session-runtime/tool-catalog.mjs +38 -99
  127. package/src/session-runtime/tool-defs.mjs +6 -1
  128. package/src/session-runtime/tool-surface.mjs +18 -8
  129. package/src/session-runtime/workflow-agents-api.mjs +8 -25
  130. package/src/session-runtime/workflow.mjs +8 -6
  131. package/src/standalone/agent-tool/helpers.mjs +2 -2
  132. package/src/standalone/agent-tool/job-views.mjs +3 -1
  133. package/src/standalone/agent-tool/notify.mjs +5 -1
  134. package/src/standalone/agent-tool/render.mjs +3 -0
  135. package/src/standalone/agent-tool/spawn-flow.mjs +61 -16
  136. package/src/standalone/agent-tool/tool-def.mjs +1 -1
  137. package/src/standalone/agent-tool/worker-index.mjs +123 -0
  138. package/src/standalone/agent-tool/worker-rows.mjs +2 -1
  139. package/src/standalone/agent-tool.mjs +57 -10
  140. package/src/standalone/daemon.mjs +105 -6
  141. package/src/standalone/session-runtime-host.mjs +61 -48
  142. package/src/standalone/session-runtime-inline-host.mjs +34 -127
  143. package/src/standalone/session-runtime-worker.mjs +20 -198
  144. package/src/standalone/session-service.mjs +632 -7
  145. package/src/tui/dist/index.mjs +24 -1
  146. package/src/tui/lib/voice-setup.mjs +4 -1
  147. package/src/tui/session/context-state.mjs +2 -13
  148. package/src/tui/session/goal-continuation.mjs +38 -7
  149. package/src/tui/session/session-api-ext.mjs +9 -0
  150. package/src/tui/session/session-api.mjs +15 -1
  151. package/src/tui/session/session-flow.mjs +25 -1
  152. package/src/tui/session/turn.mjs +88 -16
  153. package/src/tui/session-local.mjs +25 -3
  154. package/src/vendor/statusline/src/gateway/route-meta.mjs +31 -0
  155. package/scripts/generate-voice-runtime-manifest.test.mjs +0 -135
  156. package/scripts/native-binary-arch.test.mjs +0 -111
  157. package/scripts/patch-replay.test.mjs +0 -94
  158. package/src/headless-exec.test.mjs +0 -539
  159. package/src/runtime/agent/orchestrator/agent-trace-timing.test.mjs +0 -57
  160. package/src/runtime/agent/orchestrator/context/collect-skills.test.mjs +0 -153
  161. package/src/runtime/agent/orchestrator/mcp/cancellation.test.mjs +0 -139
  162. package/src/runtime/agent/orchestrator/mcp/features.test.mjs +0 -66
  163. package/src/runtime/agent/orchestrator/mcp/security.test.mjs +0 -80
  164. package/src/runtime/agent/orchestrator/providers/anthropic-fast-mode.test.mjs +0 -90
  165. package/src/runtime/agent/orchestrator/providers/anthropic-server-fallback.test.mjs +0 -215
  166. package/src/runtime/agent/orchestrator/providers/antigravity-oauth.test.mjs +0 -165
  167. package/src/runtime/agent/orchestrator/providers/media-parity.test.mjs +0 -142
  168. package/src/runtime/agent/orchestrator/providers/openai-codex-identity.test.mjs +0 -153
  169. package/src/runtime/agent/orchestrator/providers/openai-codex-model.test.mjs +0 -24
  170. package/src/runtime/agent/orchestrator/providers/openai-ws-delta-parity.test.mjs +0 -190
  171. package/src/runtime/agent/orchestrator/providers/provider-replay.test.mjs +0 -235
  172. package/src/runtime/agent/orchestrator/providers/sse-framing.test.mjs +0 -719
  173. package/src/runtime/agent/orchestrator/session/cache/prefetch-cache.test.mjs +0 -40
  174. package/src/runtime/agent/orchestrator/session/compact-policy.test.mjs +0 -176
  175. package/src/runtime/agent/orchestrator/session/compaction-read-reset.test.mjs +0 -161
  176. package/src/runtime/agent/orchestrator/session/eager-dispatch.test.mjs +0 -115
  177. package/src/runtime/agent/orchestrator/session/evidence-union.test.mjs +0 -228
  178. package/src/runtime/agent/orchestrator/session/image-strip-recovery.test.mjs +0 -245
  179. package/src/runtime/agent/orchestrator/session/lossless-tool-output.test.mjs +0 -125
  180. package/src/runtime/agent/orchestrator/session/manager/pending-messages-persistence.test.mjs +0 -325
  181. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.test.mjs +0 -70
  182. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.test.mjs +0 -457
  183. package/src/runtime/agent/orchestrator/session/provider-prefix-guard.test.mjs +0 -117
  184. package/src/runtime/agent/orchestrator/session/reduction-metrics.test.mjs +0 -87
  185. package/src/runtime/agent/orchestrator/session/store/serialize.test.mjs +0 -60
  186. package/src/runtime/agent/orchestrator/session/store-summary-reader.test.mjs +0 -583
  187. package/src/runtime/agent/orchestrator/session/task-wait-control.test.mjs +0 -78
  188. package/src/runtime/agent/orchestrator/tools/builtin/absence-absorption.test.mjs +0 -43
  189. package/src/runtime/agent/orchestrator/tools/builtin/absolute-glob-expand.test.mjs +0 -63
  190. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool-cwd-env.test.mjs +0 -14
  191. package/src/runtime/agent/orchestrator/tools/builtin/edit-encoding-eol.test.mjs +0 -224
  192. package/src/runtime/agent/orchestrator/tools/builtin/edit-sequential-occupation.test.mjs +0 -224
  193. package/src/runtime/agent/orchestrator/tools/builtin/enoent-outside-project.test.mjs +0 -56
  194. package/src/runtime/agent/orchestrator/tools/builtin/find-search-budget.test.mjs +0 -103
  195. package/src/runtime/agent/orchestrator/tools/builtin/git-command-policy.test.mjs +0 -30
  196. package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.test.mjs +0 -390
  197. package/src/runtime/agent/orchestrator/tools/builtin/git-repo-rw-lock.test.mjs +0 -83
  198. package/src/runtime/agent/orchestrator/tools/builtin/grep-output-budget.test.mjs +0 -31
  199. package/src/runtime/agent/orchestrator/tools/builtin/grep-single-file-rescue.test.mjs +0 -106
  200. package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.test.mjs +0 -102
  201. package/src/runtime/agent/orchestrator/tools/builtin/list-tool-integrity.test.mjs +0 -152
  202. package/src/runtime/agent/orchestrator/tools/builtin/native-search-health.test.mjs +0 -24
  203. package/src/runtime/agent/orchestrator/tools/builtin/native-search-transport.test.mjs +0 -24
  204. package/src/runtime/agent/orchestrator/tools/builtin/noise-dir-visibility.test.mjs +0 -69
  205. package/src/runtime/agent/orchestrator/tools/builtin/read-glob-survey.test.mjs +0 -71
  206. package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.test.mjs +0 -56
  207. package/src/runtime/agent/orchestrator/tools/builtin/search-builders.test.mjs +0 -16
  208. package/src/runtime/agent/orchestrator/tools/builtin/search-glob-top-k.test.mjs +0 -39
  209. package/src/runtime/agent/orchestrator/tools/builtin/write-symlink.test.mjs +0 -153
  210. package/src/runtime/agent/orchestrator/tools/code-graph/aggregate-anchor-relocation.test.mjs +0 -55
  211. package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.test.mjs +0 -88
  212. package/src/runtime/agent/orchestrator/tools/code-graph/loose-file-target.test.mjs +0 -72
  213. package/src/runtime/agent/orchestrator/tools/code-graph/memory-cache.test.mjs +0 -54
  214. package/src/runtime/agent/orchestrator/tools/code-graph/search-references.test.mjs +0 -20
  215. package/src/runtime/agent/orchestrator/tools/code-graph/symbol-search-scope.test.mjs +0 -55
  216. package/src/runtime/agent/orchestrator/tools/code-graph/text-span-mask.test.mjs +0 -268
  217. package/src/runtime/agent/orchestrator/tools/env-scrub.test.mjs +0 -57
  218. package/src/runtime/agent/orchestrator/tools/graph-binary-fetcher.test.mjs +0 -19
  219. package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.test.mjs +0 -104
  220. package/src/runtime/agent/orchestrator/tools/patch/engine-contract-gate.test.mjs +0 -661
  221. package/src/runtime/agent/orchestrator/tools/patch/patch-codec-eol.test.mjs +0 -552
  222. package/src/runtime/agent/orchestrator/tools/patch/patch-symlink.test.mjs +0 -141
  223. package/src/runtime/agent/orchestrator/tools/patch/v4a-pure-move.test.mjs +0 -57
  224. package/src/runtime/agent/orchestrator/tools/patch/v4a-section-coalesce.test.mjs +0 -81
  225. package/src/runtime/agent/orchestrator/tools/spawn-binary-fetcher.test.mjs +0 -52
  226. package/src/runtime/attachments/store.test.mjs +0 -209
  227. package/src/runtime/channels/lib/voice-runtime-fetcher.test.mjs +0 -17
  228. package/src/runtime/channels/lib/webhook/deliveries.test.mjs +0 -18
  229. package/src/runtime/channels/lib/webhook/relay-tunnel.test.mjs +0 -68
  230. package/src/runtime/media/adapters/codex-image.test.mjs +0 -22
  231. package/src/runtime/media/download.test.mjs +0 -52
  232. package/src/runtime/media/renditions.test.mjs +0 -99
  233. package/src/runtime/media/store.test.mjs +0 -159
  234. package/src/runtime/memory/lib/archive-security.test.mjs +0 -128
  235. package/src/runtime/memory/lib/embedding-model-config.test.mjs +0 -33
  236. package/src/runtime/memory/lib/http-wire.test.mjs +0 -15
  237. package/src/runtime/memory/lib/memory-cycle-packets.test.mjs +0 -49
  238. package/src/runtime/memory/lib/memory-cycle2-shared.test.mjs +0 -78
  239. package/src/runtime/memory/lib/memory-embedding-migration.test.mjs +0 -50
  240. package/src/runtime/memory/lib/pg/process.test.mjs +0 -36
  241. package/src/runtime/memory/lib/trace-store.test.mjs +0 -57
  242. package/src/runtime/memory/lib/transcript-ingest.test.mjs +0 -52
  243. package/src/runtime/shared/background-tasks.test.mjs +0 -78
  244. package/src/runtime/shared/bounded-download.test.mjs +0 -41
  245. package/src/runtime/shared/channel-notification-routing.test.mjs +0 -25
  246. package/src/runtime/shared/child-spawn-remote.test.mjs +0 -124
  247. package/src/runtime/shared/remote-intent.test.mjs +0 -40
  248. package/src/runtime/shared/resource-admission.test.mjs +0 -43
  249. package/src/runtime/shared/runtime-root.test.mjs +0 -34
  250. package/src/runtime/shared/schedule-time.test.mjs +0 -29
  251. package/src/runtime/shared/session-runtime-health.test.mjs +0 -83
  252. package/src/runtime/shared/skill-document.test.mjs +0 -81
  253. package/src/runtime/shared/tool-surface.test.mjs +0 -87
  254. package/src/runtime/shared/update-checker.test.mjs +0 -33
  255. package/src/runtime/shared/user-cwd.test.mjs +0 -43
  256. package/src/runtime/shared/webhook-session-run.test.mjs +0 -14
  257. package/src/session-runtime/agent-disable.test.mjs +0 -123
  258. package/src/session-runtime/cwd-plugins.test.mjs +0 -75
  259. package/src/session-runtime/cwd-tool-routing.test.mjs +0 -61
  260. package/src/session-runtime/global-extensions.test.mjs +0 -28
  261. package/src/session-runtime/goal-runtime.test.mjs +0 -108
  262. package/src/session-runtime/lifecycle-api.test.mjs +0 -21
  263. package/src/session-runtime/model-settings-persist.test.mjs +0 -105
  264. package/src/session-runtime/notification-bus.test.mjs +0 -148
  265. package/src/session-runtime/plugin-mcp-standard.test.mjs +0 -177
  266. package/src/session-runtime/prewarm.test.mjs +0 -52
  267. package/src/session-runtime/provider-request-snapshot.test.mjs +0 -37
  268. package/src/session-runtime/resource-api-global.test.mjs +0 -69
  269. package/src/session-runtime/session-lifecycle.test.mjs +0 -125
  270. package/src/session-runtime/session-title.test.mjs +0 -36
  271. package/src/session-runtime/skills-api.test.mjs +0 -99
  272. package/src/session-runtime/tool-policy-surface.test.mjs +0 -331
  273. package/src/standalone/agent-tool/helpers.test.mjs +0 -62
  274. package/src/standalone/agent-tool/notify.test.mjs +0 -37
  275. package/src/standalone/agent-tool/spawn-flow.test.mjs +0 -63
  276. package/src/standalone/channel-restart.test.mjs +0 -145
  277. package/src/standalone/channel-session-router.test.mjs +0 -37
  278. package/src/standalone/channel-worker-heartbeat.test.mjs +0 -30
  279. package/src/standalone/hook-bus/handlers.test.mjs +0 -88
  280. package/src/standalone/plugin-admin.test.mjs +0 -173
  281. package/src/standalone/session-runtime-agent-control-client.test.mjs +0 -71
  282. package/src/standalone/session-runtime-dispatch-cancel.test.mjs +0 -139
  283. package/src/standalone/session-runtime-host-factory.test.mjs +0 -31
  284. package/src/standalone/session-runtime-host-health.test.mjs +0 -160
  285. package/src/standalone/session-runtime-inline-host.test.mjs +0 -83
  286. package/src/standalone/session-runtime-provider-cooldown.test.mjs +0 -80
  287. package/src/standalone/session-runtime-shard-host.test.mjs +0 -569
  288. package/src/standalone/session-runtime-shard-router.test.mjs +0 -101
  289. package/src/tui/app/live-spinner-visibility.test.mjs +0 -44
  290. package/src/tui/app/panel-epoch.test.mjs +0 -1009
  291. package/src/tui/app/panel-handoff.test.mjs +0 -311
  292. package/src/tui/app/prompt-submit.test.mjs +0 -206
  293. package/src/tui/session/completion-card-restore.test.mjs +0 -111
  294. package/src/tui/session/goal-continuation.test.mjs +0 -84
  295. package/src/tui/session/oauth-flows.test.mjs +0 -134
  296. package/src/tui/session/queue-helpers.test.mjs +0 -46
  297. package/src/tui/session/session-action-surface.test.mjs +0 -108
  298. package/src/tui/session/task-wait-submit.test.mjs +0 -80
  299. package/src/tui/session/tool-result-status.test.mjs +0 -131
  300. package/src/tui/session/tui-steering-persist.test.mjs +0 -104
@@ -14,6 +14,7 @@ import {
14
14
  isSessionPreviewNoise,
15
15
  sessionMessageText,
16
16
  } from '../../../../session-runtime/session-text.mjs';
17
+ import { sessionVisibility } from './store-summary-visibility.mjs';
17
18
 
18
19
  export const SESSION_SUMMARY_INDEX_VERSION = 2;
19
20
 
@@ -139,16 +140,32 @@ export function _sessionSummary(session) {
139
140
  sourceName: session.sourceName || null,
140
141
  sourceDelivery: session.sourceDelivery || null,
141
142
  scopeKey: session.scopeKey || null,
142
- ownerSessionId: session.ownerSessionId || null,
143
+ parentSessionId: session.parentSessionId || null,
144
+ ownerSessionId: session.ownerSessionId || session.parentSessionId || null,
145
+ visibility: sessionVisibility(session),
143
146
  clientHostPid: _positiveNumber(session.clientHostPid, 0) || null,
144
147
  cwd: session.cwd || '',
145
148
  desktopSession: _desktopSessionSummary(session.desktopSession, session.cwd),
146
149
  provider: session.provider || null,
147
150
  model: session.model || null,
151
+ presetName: session.presetName || session.profileId || null,
152
+ effort: session.effort || null,
153
+ fast: session.fast === true,
154
+ modelParameters: session.modelParameters && typeof session.modelParameters === 'object'
155
+ ? { ...session.modelParameters }
156
+ : null,
148
157
  agentTag: session.agentTag || null,
149
158
  task_id: session.task_id || session.taskId || null,
150
159
  permission: session.permission || null,
160
+ permissionMode: session.permissionMode || null,
151
161
  toolPermission: session.toolPermission || null,
162
+ schemaAllowedTools: Array.isArray(session.schemaAllowedTools)
163
+ ? session.schemaAllowedTools.map((name) => String(name))
164
+ : null,
165
+ taskType: session.taskType || null,
166
+ maxLoopIterations: Number.isFinite(session.maxLoopIterations)
167
+ ? session.maxLoopIterations
168
+ : null,
152
169
  messageCount: messageProjection.count,
153
170
  title: _cleanPreview(session.title || '', 100),
154
171
  preview: messageProjection.preview,
@@ -175,17 +192,34 @@ function _normalizeSummaryRow(row) {
175
192
  agent: row.agent || null,
176
193
  sourceType: row.sourceType || null,
177
194
  sourceName: row.sourceName || null,
195
+ sourceDelivery: row.sourceDelivery || null,
178
196
  scopeKey: row.scopeKey || null,
179
- ownerSessionId: row.ownerSessionId || null,
197
+ parentSessionId: row.parentSessionId || null,
198
+ ownerSessionId: row.ownerSessionId || row.parentSessionId || null,
199
+ visibility: sessionVisibility(row),
180
200
  clientHostPid: _positiveNumber(row.clientHostPid, 0) || null,
181
201
  cwd: row.cwd || '',
182
202
  desktopSession: _desktopSessionSummary(row.desktopSession, row.cwd),
183
203
  provider: row.provider || null,
184
204
  model: row.model || null,
205
+ presetName: row.presetName || row.profileId || null,
206
+ effort: row.effort || null,
207
+ fast: row.fast === true,
208
+ modelParameters: row.modelParameters && typeof row.modelParameters === 'object'
209
+ ? { ...row.modelParameters }
210
+ : null,
185
211
  agentTag: row.agentTag || null,
186
212
  task_id: row.task_id || null,
187
213
  permission: row.permission || null,
214
+ permissionMode: row.permissionMode || null,
188
215
  toolPermission: row.toolPermission || null,
216
+ schemaAllowedTools: Array.isArray(row.schemaAllowedTools)
217
+ ? row.schemaAllowedTools.map((name) => String(name))
218
+ : null,
219
+ taskType: row.taskType || null,
220
+ maxLoopIterations: Number.isFinite(row.maxLoopIterations)
221
+ ? row.maxLoopIterations
222
+ : null,
189
223
  messageCount: Math.max(0, Math.floor(Number(row.messageCount) || 0)),
190
224
  title: _cleanPreview(row.title || '', 100),
191
225
  preview: _cleanPreview(row.preview || ''),
@@ -14,6 +14,11 @@ import { join } from 'path';
14
14
  // authoritative store uses, so the cold catalog cannot disagree with it.
15
15
  import { probePath, readTextFile, PROBE_PRESENT, PROBE_ABSENT } from './store/fs-probe.mjs';
16
16
  import { readTopLevelLifecycleRecord, isLifecycleUnreadable } from './lifecycle-scan.mjs';
17
+ import {
18
+ isAgentOnlySession,
19
+ isRootLeadSession,
20
+ sessionVisibility,
21
+ } from './store-summary-visibility.mjs';
17
22
 
18
23
  const SESSION_SUMMARY_INDEX_VERSION = 2;
19
24
  const DEAD_AGENT_STATUS =
@@ -45,7 +50,8 @@ const LEAD_OWNERS = new Set(['cli', 'user', 'mixdog']);
45
50
 
46
51
  function isLeadVisibleRow(row) {
47
52
  const owner = String(row.owner || 'user').trim().toLowerCase();
48
- if (owner && !LEAD_OWNERS.has(owner)) return false;
53
+ if (isAgentOnlySession(row)) return false;
54
+ if (!isRootLeadSession(row) && owner && !LEAD_OWNERS.has(owner)) return false;
49
55
  // Mirror listLeadSessions: a previewless zero-message row is an unusable
50
56
  // scratch (desktop boot leftovers, crashed first turns) — resuming it
51
57
  // shows an empty conversation, so the catalog hides it.
@@ -72,10 +78,35 @@ function positiveNumber(value, fallback = 0) {
72
78
  return Number.isFinite(number) && number > 0 ? number : fallback;
73
79
  }
74
80
 
81
+ function runtimeAlive(pid) {
82
+ const id = positiveNumber(pid, 0);
83
+ if (id <= 0 || id === process.pid) return true;
84
+ try {
85
+ process.kill(id, 0);
86
+ return true;
87
+ } catch (error) {
88
+ return error?.code === 'EPERM';
89
+ }
90
+ }
91
+
75
92
  function cleanValue(value) {
76
93
  return String(value || '').trim();
77
94
  }
78
95
 
96
+ function workerOwnerSessionId(row, session) {
97
+ return cleanValue(
98
+ row?.ownerSessionId || session?.ownerSessionId
99
+ || row?.parentSessionId || session?.parentSessionId,
100
+ ) || null;
101
+ }
102
+
103
+ function workerParentSessionId(row, session) {
104
+ return cleanValue(
105
+ row?.parentSessionId || session?.parentSessionId
106
+ || row?.ownerSessionId || session?.ownerSessionId,
107
+ ) || null;
108
+ }
109
+
79
110
  function archivedAgentNotification(content, sessionId) {
80
111
  const text = typeof content === 'string' ? content : '';
81
112
  const marker = '\n\nResult:\n';
@@ -265,23 +296,52 @@ export function storedLeadWorkerIndexPath() {
265
296
  return join(dataDir(), 'lead-workers.json');
266
297
  }
267
298
 
268
- /** Process-global active agent pool. Fresh child heartbeat sidecars are the
269
- * cross-process running source even when their durable session is detached
270
- * (`closed`) and a terminal reaper has already removed the worker-index row.
271
- * The child and Lead indexes remain additive for living rows (running or idle)
272
- * published before the heartbeat or by runtimes without a sidecar. No runtime
273
- * starts and durable session history is never projected into either pool. */
274
- export function listStoredAgentWorkers() {
299
+ function storedAgentWorkerIndexRows() {
275
300
  let parsed = null;
276
301
  try {
277
302
  parsed = JSON.parse(readFileSync(storedAgentWorkerIndexPath(), 'utf8'));
278
- } catch { /* heartbeat-backed rows remain authoritative without the index */ }
279
- const source = Array.isArray(parsed?.workers)
303
+ } catch {
304
+ return [];
305
+ }
306
+ return Array.isArray(parsed?.workers)
280
307
  ? parsed.workers
281
308
  : parsed?.workers && typeof parsed.workers === 'object'
282
309
  ? Object.values(parsed.workers)
283
310
  : [];
311
+ }
312
+
313
+ /** Lightweight ancestry seam used to migrate pre-parentSessionId summary
314
+ * rows. It reads only agent-workers.json and never opens session transcripts. */
315
+ export function listStoredAgentWorkerLinks() {
316
+ return storedAgentWorkerIndexRows()
317
+ .map((row) => {
318
+ if (!row || typeof row !== 'object') return null;
319
+ const sessionId = cleanValue(row.sessionId);
320
+ const parentSessionId = cleanValue(row.parentSessionId);
321
+ const ownerSessionId = cleanValue(row.ownerSessionId || row.parentSessionId);
322
+ if (!/^[A-Za-z0-9_-]+$/.test(sessionId) || (!parentSessionId && !ownerSessionId)) {
323
+ return null;
324
+ }
325
+ return {
326
+ sessionId,
327
+ parentSessionId: parentSessionId || ownerSessionId,
328
+ ownerSessionId: ownerSessionId || parentSessionId,
329
+ };
330
+ })
331
+ .filter(Boolean);
332
+ }
333
+
334
+ /** Process-global active agent pool. Fresh child heartbeat sidecars are the
335
+ * cross-process running source even when their durable session is detached
336
+ * (`closed`) and a terminal reaper has already removed the worker-index row.
337
+ * The child and Lead indexes remain additive for living rows (running or idle)
338
+ * published before the heartbeat or by runtimes without a sidecar. No runtime
339
+ * starts and durable session history is never projected into either pool. */
340
+ export function listStoredAgentWorkers() {
341
+ const source = storedAgentWorkerIndexRows();
284
342
  const bySessionId = new Map();
343
+ const now = Date.now();
344
+ const heartbeatMtimes = sessionHeartbeatMtimes();
285
345
  for (const row of source) {
286
346
  if (!row || typeof row !== 'object') continue;
287
347
  // Cancelled rows stay visible so the 2-minute heartbeat lease cannot
@@ -300,28 +360,45 @@ export function listStoredAgentWorkers() {
300
360
  'utf8',
301
361
  ));
302
362
  } catch { /* a new row may precede its first session save */ }
363
+ const declaredStatus = cleanValue(row.status) || 'running';
364
+ const declaredStage = cleanValue(row.stage || row.status) || 'running';
365
+ const declaredWorking = WORKING_AGENT_STATUS.test(declaredStatus)
366
+ || WORKING_AGENT_STATUS.test(declaredStage);
367
+ const heartbeatAt = heartbeatMtimes.get(sessionId) || 0;
368
+ const heartbeatFresh = heartbeatAt > 0
369
+ && now - heartbeatAt <= AGENT_POOL_HEARTBEAT_FRESH_MS;
370
+ const updatedAt = Date.parse(cleanValue(row.updatedAt)) || 0;
371
+ const recentlyUpdated = updatedAt > 0
372
+ && now - updatedAt <= AGENT_POOL_HEARTBEAT_FRESH_MS;
373
+ const runtimePid = positiveNumber(row.runtimePid, 0);
374
+ const working = declaredWorking
375
+ && (!runtimePid || runtimeAlive(runtimePid))
376
+ && (heartbeatFresh || recentlyUpdated);
377
+ const projectedStatus = declaredWorking && !working ? 'idle' : declaredStatus;
378
+ const projectedStage = declaredWorking && !working ? 'idle' : declaredStage;
303
379
  bySessionId.set(sessionId, {
304
380
  tag,
305
381
  sessionId,
306
- ownerSessionId: cleanValue(
307
- row.ownerSessionId || row.parentSessionId
308
- || session?.ownerSessionId || session?.parentSessionId,
309
- ) || null,
382
+ // Root ownership and immediate ancestry are independent. Nested
383
+ // descendants keep the Lead/root owner while pointing at the Agent
384
+ // session that directly spawned them.
385
+ ownerSessionId: workerOwnerSessionId(row, session),
386
+ parentSessionId: workerParentSessionId(row, session),
310
387
  title: cleanValue(row.title || session?.title) || null,
311
388
  agent: cleanValue(row.agent || session?.agent) || null,
312
389
  provider: cleanValue(row.provider || session?.provider) || null,
313
390
  model: cleanValue(row.model || session?.model) || null,
314
391
  effort: cleanValue(row.effort || session?.effort) || null,
315
392
  fast: row.fast === true || session?.fast === true,
316
- status: cleanValue(row.status) || 'running',
317
- stage: cleanValue(row.stage || row.status) || 'running',
393
+ status: projectedStatus,
394
+ stage: projectedStage,
318
395
  startedAt: row.startedAt || row.createdAt || session?.createdAt || null,
319
- turnStartedAt: row.turnStartedAt || null,
396
+ turnStartedAt: working ? (row.turnStartedAt || null) : null,
320
397
  createdAt: row.createdAt || session?.createdAt || null,
321
398
  updatedAt: row.updatedAt || session?.updatedAt || null,
322
399
  idleSince: frozenIdleSince(
323
400
  sessionId,
324
- WORKING_AGENT_STATUS.test(cleanValue(row.stage || row.status)),
401
+ working,
325
402
  row.finishedAt || row.updatedAt || session?.updatedAt || null,
326
403
  ),
327
404
  reapAt: row.reapAt || null,
@@ -330,8 +407,6 @@ export function listStoredAgentWorkers() {
330
407
  taskId: cleanValue(row.task_id || row.taskId) || null,
331
408
  });
332
409
  }
333
- const now = Date.now();
334
- const heartbeatMtimes = sessionHeartbeatMtimes();
335
410
  for (const [sessionId, heartbeatAt] of heartbeatMtimes) {
336
411
  if (now - heartbeatAt > AGENT_POOL_HEARTBEAT_FRESH_MS) continue;
337
412
  let session;
@@ -343,13 +418,12 @@ export function listStoredAgentWorkers() {
343
418
  } catch {
344
419
  continue;
345
420
  }
346
- const ownerSessionId = cleanValue(
347
- session?.ownerSessionId || session?.parentSessionId,
348
- );
421
+ const current = bySessionId.get(sessionId) || {};
422
+ const ownerSessionId = workerOwnerSessionId(current, session);
423
+ const parentSessionId = workerParentSessionId(current, session);
349
424
  const owner = cleanValue(session?.owner).toLowerCase();
350
425
  const agent = cleanValue(session?.agent);
351
426
  if (!ownerSessionId || (owner !== 'agent' && (!agent || agent === 'lead'))) continue;
352
- const current = bySessionId.get(sessionId) || {};
353
427
  // The durable index row is authoritative for FINISHED work: a worker's
354
428
  // runtime unloads at turn end but its heartbeat sidecar stays fresh for
355
429
  // up to the 2-minute window, and overwriting an idle row to `running`
@@ -381,6 +455,7 @@ export function listStoredAgentWorkers() {
381
455
  || `${agent || 'agent'}:${sessionId}`,
382
456
  sessionId,
383
457
  ownerSessionId,
458
+ parentSessionId,
384
459
  title: cleanValue(session?.title) || current.title || null,
385
460
  agent: agent || current.agent || null,
386
461
  provider: cleanValue(session?.provider) || current.provider || null,
@@ -409,6 +484,7 @@ export function listStoredAgentWorkers() {
409
484
  || `${agent || 'agent'}:${sessionId}`,
410
485
  sessionId,
411
486
  ownerSessionId,
487
+ parentSessionId,
412
488
  title: cleanValue(session?.title) || current.title || null,
413
489
  agent: agent || current.agent || null,
414
490
  provider: cleanValue(session?.provider) || current.provider || null,
@@ -467,6 +543,7 @@ export function listStoredAgentWorkers() {
467
543
  tag: `lead:${sessionId}`,
468
544
  sessionId,
469
545
  ownerSessionId: sessionId,
546
+ parentSessionId: null,
470
547
  agent: 'lead',
471
548
  provider: cleanValue(row.provider) || null,
472
549
  model: cleanValue(row.model) || null,
@@ -548,7 +625,8 @@ function normalizedRow(row, heartbeatAt = 0) {
548
625
  sourceName: row.sourceName || null,
549
626
  sourceDelivery: row.sourceDelivery || null,
550
627
  scopeKey: row.scopeKey || null,
551
- ownerSessionId: row.ownerSessionId || null,
628
+ ownerSessionId: row.ownerSessionId || row.parentSessionId || null,
629
+ visibility: sessionVisibility(row),
552
630
  clientHostPid: positiveNumber(row.clientHostPid, 0) || null,
553
631
  cwd: row.cwd || '',
554
632
  desktopSession: desktopSession(row.desktopSession, row.cwd),
@@ -761,11 +839,47 @@ export async function readStoredSessionTranscript(id, options = {}) {
761
839
  // Same strict authority as the store, and the same fail-closed rule: an
762
840
  // absent, unreadable, ambiguous or foreign record yields no transcript.
763
841
  const read = readTextFile(join(dataDir(), 'sessions', `${sessionId}.json`));
764
- if (read.state === PROBE_ABSENT) return readArchivedAgentResult(sessionId);
842
+ if (read.state === PROBE_ABSENT) {
843
+ return options.metadataOnly === true ? null : readArchivedAgentResult(sessionId);
844
+ }
765
845
  if (read.state !== PROBE_PRESENT) return null;
766
846
  const record = readTopLevelLifecycleRecord(read.text);
767
847
  if (isLifecycleUnreadable(record) || record.id !== sessionId) return null;
768
848
  let session = record.doc;
849
+ if (options.metadataOnly === true) {
850
+ return {
851
+ id: sessionId,
852
+ sessionId,
853
+ owner: session.owner || null,
854
+ agent: session.agent || null,
855
+ parentSessionId: session.parentSessionId || null,
856
+ ownerSessionId: session.ownerSessionId || session.parentSessionId || null,
857
+ visibility: sessionVisibility(session),
858
+ agentTag: session.agentTag || null,
859
+ cwd: session.cwd || '',
860
+ provider: session.provider || null,
861
+ model: session.model || null,
862
+ presetName: session.presetName || session.profileId || null,
863
+ effort: session.effort || null,
864
+ fast: session.fast === true,
865
+ modelParameters: session.modelParameters || null,
866
+ taskType: session.taskType || null,
867
+ maxLoopIterations: session.maxLoopIterations ?? null,
868
+ permission: session.permission || null,
869
+ permissionMode: session.permissionMode || null,
870
+ toolPermission: session.toolPermission || null,
871
+ schemaAllowedTools: Array.isArray(session.schemaAllowedTools)
872
+ ? session.schemaAllowedTools
873
+ : null,
874
+ sourceType: session.sourceType || null,
875
+ sourceName: session.sourceName || null,
876
+ clientHostPid: session.clientHostPid || null,
877
+ createdAt: session.createdAt || null,
878
+ updatedAt: session.updatedAt || session.lastUsedAt || null,
879
+ status: session.status || (session.closed === true ? 'closed' : 'idle'),
880
+ closed: session.closed === true,
881
+ };
882
+ }
769
883
  const owner = cleanValue(session.owner).toLowerCase();
770
884
  const agent = cleanValue(session.agent).toLowerCase();
771
885
  const liveDetachedAgent = session.closed === true
@@ -774,11 +888,11 @@ export async function readStoredSessionTranscript(id, options = {}) {
774
888
  // Only a PROVABLY absent checkpoint skips recovery: an unreadable probe
775
889
  // must not silently downgrade an interrupted turn to a plain cold read.
776
890
  if (probePath(join(dataDir(), 'turn-checkpoints', `${sessionId}.json`)).state !== PROBE_ABSENT) {
891
+ const {
892
+ projectTurnCheckpointMessages,
893
+ readTurnCheckpoint,
894
+ } = await import('./manager/turn-checkpoint.mjs');
777
895
  if (liveDetachedAgent) {
778
- const {
779
- projectTurnCheckpointMessages,
780
- readTurnCheckpoint,
781
- } = await import('./manager/turn-checkpoint.mjs');
782
896
  const checkpoint = readTurnCheckpoint(sessionId);
783
897
  if (checkpoint) {
784
898
  session = {
@@ -789,6 +903,19 @@ export async function readStoredSessionTranscript(id, options = {}) {
789
903
  } else {
790
904
  const { recoverSessionAfterProcessRestart } = await import('./manager.mjs');
791
905
  session = recoverSessionAfterProcessRestart(sessionId) || session;
906
+ // A live foreign owner is intentionally not recovered/mutated.
907
+ // Project its durable working checkpoint read-only so the cold pane
908
+ // never repaints the stale pre-compaction session.messages while it
909
+ // waits for the owner's live-share frame.
910
+ if (session?.activeTurnCheckpoint) {
911
+ const checkpoint = readTurnCheckpoint(sessionId);
912
+ if (checkpoint) {
913
+ session = {
914
+ ...session,
915
+ messages: projectTurnCheckpointMessages(session, checkpoint),
916
+ };
917
+ }
918
+ }
792
919
  }
793
920
  }
794
921
  const {
@@ -0,0 +1,57 @@
1
+ export const SESSION_VISIBILITY_ORDINARY = 'ordinary';
2
+ export const SESSION_VISIBILITY_AGENT_ONLY = 'agent-only';
3
+
4
+ const SESSION_ID_PATTERN = /^[A-Za-z0-9_-]+$/;
5
+
6
+ function clean(value) {
7
+ return String(value || '').trim();
8
+ }
9
+
10
+ export function linkedParentSessionId(value) {
11
+ if (!value || typeof value !== 'object') return '';
12
+ for (const candidate of [value.ownerSessionId, value.parentSessionId]) {
13
+ const id = clean(candidate);
14
+ if (SESSION_ID_PATTERN.test(id)) return id;
15
+ }
16
+ return '';
17
+ }
18
+
19
+ /** A root Lead may carry a self owner link, but it is not a child session. */
20
+ export function isRootLeadSession(value) {
21
+ if (!value || typeof value !== 'object') return false;
22
+ if (clean(value.agent).toLowerCase() !== 'lead') return false;
23
+ const id = clean(value.id);
24
+ const parentId = linkedParentSessionId(value);
25
+ return !parentId || parentId === id;
26
+ }
27
+
28
+ /** Backward-compatible classification for child records written before the
29
+ * durable visibility field existed. Both Agent ownership and an external,
30
+ * valid parent link are required so ownerless/root sessions remain ordinary. */
31
+ export function isCanonicalAgentChildSession(value) {
32
+ if (!value || typeof value !== 'object') return false;
33
+ const id = clean(value.id);
34
+ const parentId = linkedParentSessionId(value);
35
+ return clean(value.owner).toLowerCase() === 'agent'
36
+ && Boolean(parentId)
37
+ && parentId !== id;
38
+ }
39
+
40
+ export function sessionVisibility(value) {
41
+ // Root Lead sessions are ordinary catalog entries even if stale metadata
42
+ // accidentally retained an agent-only declaration.
43
+ if (isRootLeadSession(value)) return SESSION_VISIBILITY_ORDINARY;
44
+ const declared = clean(value?.visibility || value?.sessionVisibility).toLowerCase();
45
+ if (declared === SESSION_VISIBILITY_AGENT_ONLY || isCanonicalAgentChildSession(value)) {
46
+ return SESSION_VISIBILITY_AGENT_ONLY;
47
+ }
48
+ return SESSION_VISIBILITY_ORDINARY;
49
+ }
50
+
51
+ export function isAgentOnlySession(value) {
52
+ return sessionVisibility(value) === SESSION_VISIBILITY_AGENT_ONLY;
53
+ }
54
+
55
+ export function isOrdinarySession(value) {
56
+ return !isAgentOnlySession(value);
57
+ }
@@ -71,7 +71,7 @@ import { _ensureSummaryCacheDataDir, _cachedSummaryRows, _setSummaryRowsCache, _
71
71
  import { _lastSaveError, _liveSessions, _droppedSaveIds, setLiveSession, _clearLiveSession, LIVE_MEDIA_RETENTION_MS, _messagesCarryLiveMedia, getSessionSaveError, clearSessionSaveError, _recordSaveFailure, _recordSaveDrop, _clearSaveStateIfCurrent, _nextSaveEpoch, _acquireSessionIncarnation, _releaseSessionIncarnation, _isCurrentSessionIncarnation, _retireSessionIncarnation, _clearSessionSaveState, SAVE_OUTCOME_SAVED, SAVE_OUTCOME_DROPPED, SAVE_OUTCOME_STALE, hasSessionSaveFailure, getFailedSaveSnapshot, _recordLifecycleCommitFailure, clearSessionLifecycleCommitError } from './store/live-state.mjs';
72
72
  import { _saveWorkerPending, _saveAsyncQueued, _saveAsyncInflight, _deferredSessionSaves, saveSessionAsync, saveSessionAsyncDeferred, _resetSaveWorkerBookkeeping } from './store/save-worker.mjs';
73
73
  import { purgeSessionSaveBookkeeping as _purgeSessionSaveBookkeeping } from './store/save-worker.mjs';
74
- import { _setSessionWriteAuthorityCheck } from './store/save-worker.mjs';
74
+ import { _setLiveSessionPublisher, _setSessionWriteAuthorityCheck } from './store/save-worker.mjs';
75
75
  import {
76
76
  _commitSessionWrite,
77
77
  _discardSaveTmp,
@@ -121,6 +121,8 @@ function _publishLiveSession(session) {
121
121
  }
122
122
  }
123
123
 
124
+ _setLiveSessionPublisher(_publishLiveSession);
125
+
124
126
  function _runSessionPurgeHooks(id) {
125
127
  for (const hook of _sessionPurgeHooks) {
126
128
  try { hook(id); } catch { /* a cleanup hook never breaks delete */ }
@@ -39,6 +39,7 @@ import {
39
39
  getToolKind,
40
40
  isEagerDispatchable,
41
41
  isParallelDispatchable,
42
+ isSingleCallPerTurnTool,
42
43
  isToolCallDedupEligible,
43
44
  parseNativeToolSearchPayload,
44
45
  } from './loop/tool-helpers.mjs';
@@ -96,6 +97,17 @@ export async function processToolBatch(ctx) {
96
97
  }
97
98
  }
98
99
  }
100
+ // Stateful Computer Use calls are one-at-a-time. This pre-pass covers
101
+ // non-streaming providers while eager-dispatch applies the same guard
102
+ // before streamed calls can execute.
103
+ const _singleCallBlockedIds = new Set();
104
+ const _singleCallFirstIdByName = new Map();
105
+ for (const c of calls) {
106
+ if (!c?.id || !isSingleCallPerTurnTool(c.name)) continue;
107
+ const firstId = _singleCallFirstIdByName.get(c.name);
108
+ if (firstId === undefined) _singleCallFirstIdByName.set(c.name, c.id);
109
+ else _singleCallBlockedIds.add(c.id);
110
+ }
99
111
  // One-shot sequential occupation for same-anchor edit batches: when
100
112
  // one assistant turn issues N `edit` calls with the SAME
101
113
  // file_path+old_string (replace_all=false) and N DISTINCT new_strings,
@@ -158,6 +170,16 @@ export async function processToolBatch(ctx) {
158
170
  if (isBuiltinTool(call.name)) {
159
171
  call.name = canonicalizeBuiltinToolName(call.name);
160
172
  }
173
+ if (_singleCallBlockedIds.has(call.id)) {
174
+ const _firstId = _singleCallFirstIdByName.get(call.name);
175
+ _stageToolResultMessage({
176
+ role: 'tool',
177
+ content: `[computer-call-cardinality] Only the first Computer Use call in an assistant turn is executed (tool_use_id=${_firstId}). This call was not executed. Inspect the first call's fresh result, then issue at most one next computer call; use sequence only for a deterministic same-window focus chain.`,
178
+ toolCallId: call.id,
179
+ toolKind: 'error',
180
+ });
181
+ continue;
182
+ }
161
183
  // Per-call cross-turn signature, computed at most once (lazily, only
162
184
  // when the call is eager — both consumer sites are eager-gated).
163
185
  let _ctSig = null;
@@ -6,8 +6,8 @@ import { inspectPdfBuffer } from '../../../../attachments/pdf-extract.mjs';
6
6
 
7
7
  const DEFAULT_READ_MAX_OUTPUT_BYTES = 100 * 1024;
8
8
 
9
- // PDFs at or under this size are emitted as an Anthropic base64 document
10
- // block (the model reads the rendered PDF directly): 20MB raw → ~27MB
9
+ // PDFs at or under this size are emitted as the runtime's canonical base64
10
+ // document block (providers convert it to their native file shape): 20MB raw → ~27MB
11
11
  // base64, which stays under the 32MB request cap.
12
12
  // Larger PDFs fall back to bounded PDF.js text extraction.
13
13
  const PDF_DOCUMENT_MAX_BYTES = 20 * 1024 * 1024;
@@ -90,10 +90,10 @@ export async function extractPdfText(fullPath, pagesArg, { maxOutputBytes = DEFA
90
90
  if (pages.error) return pages.error;
91
91
 
92
92
  // Document-block path: whole-PDF read, no page range, within the size
93
- // cap, and confirmed %PDF- magic. Emits a base64 document block the
94
- // model reads natively (figures, layout, tables) instead of lossy
95
- // pdf-parse text. The magic-byte guard prevents a non-PDF (mislabelled
96
- // extension) from poisoning history as a malformed document block.
93
+ // cap, and confirmed %PDF- magic. Emits the canonical document block
94
+ // that provider adapters convert to native media (figures, layout,
95
+ // tables) instead of lossy pdf-parse text. The magic-byte guard prevents
96
+ // a non-PDF (mislabelled extension) from poisoning history.
97
97
  // textOnly (batch context) skips the block and always emits text.
98
98
  if (!textOnly && !pages.filter && pdfStat.size <= PDF_DOCUMENT_MAX_BYTES) {
99
99
  if (await fileStartsWithPdfMagic(fullPath)) {
@@ -66,6 +66,10 @@ export function formatToolStartProgress(name, args = {}) {
66
66
  return a.action === 'snapshot' && a.window
67
67
  ? `reading ${_t(a.window)}`
68
68
  : `computer ${_t(a.action || 'command')}`;
69
+ case 'office':
70
+ return a.path
71
+ ? `office ${_t(a.action || 'command')} ${_t(a.path)}`
72
+ : `office ${_t(a.action || 'command')}`;
69
73
 
70
74
  // ── agent module: agent / models ─────────────────────────────────
71
75
  case 'agent': {
@@ -5,6 +5,8 @@
5
5
  * OpenAI-compatible providers without a document contract receive page-ordered
6
6
  * text extracted here, so they never see an unsupported inline Base64 block.
7
7
  */
8
+ import { resolvedPdfJs } from './pdfjs-runtime.mjs';
9
+
8
10
  const DEFAULT_MAX_PAGES = 100;
9
11
  const DEFAULT_MAX_OUTPUT_BYTES = 1024 * 1024;
10
12
 
@@ -23,6 +25,7 @@ export async function inspectPdfBuffer(buffer, {
23
25
  pageRange = null,
24
26
  } = {}) {
25
27
  if (!Buffer.isBuffer(buffer) || buffer.length === 0) throw new TypeError('PDF payload is empty');
28
+ await resolvedPdfJs();
26
29
  const { getDocumentProxy } = await import('unpdf');
27
30
  const pdf = await getDocumentProxy(new Uint8Array(buffer));
28
31
  try {
@@ -0,0 +1,13 @@
1
+ import { definePDFJSModule } from 'unpdf';
2
+
3
+ let configuredPromise = null;
4
+
5
+ export async function resolvedPdfJs() {
6
+ configuredPromise ??= Promise.resolve().then(async () => {
7
+ const pdfjs = await import('pdfjs-dist/legacy/build/pdf.mjs');
8
+ pdfjs.GlobalWorkerOptions.workerSrc = import.meta.resolve('pdfjs-dist/legacy/build/pdf.worker.mjs');
9
+ await definePDFJSModule(() => Promise.resolve(pdfjs));
10
+ return pdfjs;
11
+ });
12
+ return await configuredPromise;
13
+ }