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
@@ -9,13 +9,15 @@ export function createInlineSessionRuntimeHost({
9
9
  cwd = process.cwd(),
10
10
  log = () => {},
11
11
  loadLocalModule = () => import('../tui/session-local.mjs'),
12
+ loadAgentGraph = () => Promise.all([
13
+ import('../runtime/agent/orchestrator/config.mjs'),
14
+ import('../runtime/agent/orchestrator/providers/registry.mjs'),
15
+ import('../runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs'),
16
+ ]).then(([config, registry, dispatch]) => ({ config, registry, dispatch })),
17
+ executeAgentControl = null,
12
18
  } = {}) {
13
19
  const records = new Map();
14
20
  const recordsBySessionId = new Map();
15
- const agentSessionListeners = new Set();
16
- const agentSessionSnapshots = new Map();
17
- const activeAgentSessionProjections = new Set();
18
- const pendingAgentSessionProjections = new Map();
19
21
  const agentDispatchers = new Map();
20
22
  const agentDispatchRuns = new Map();
21
23
  let nextRuntimeId = 0;
@@ -25,8 +27,6 @@ export function createInlineSessionRuntimeHost({
25
27
  let agentGraphPromise = null;
26
28
  let preparedProviderSignature = null;
27
29
  let providerPreparePromise = null;
28
- let unsubscribeAgentSessionPublisher = null;
29
- let agentSessionPublisherPromise = null;
30
30
 
31
31
  function localModule() {
32
32
  localModulePromise ??= Promise.resolve().then(loadLocalModule).catch((error) => {
@@ -37,12 +37,8 @@ export function createInlineSessionRuntimeHost({
37
37
  }
38
38
 
39
39
  function agentGraph() {
40
- agentGraphPromise ??= Promise.all([
41
- import('../runtime/agent/orchestrator/config.mjs'),
42
- import('../runtime/agent/orchestrator/providers/registry.mjs'),
43
- import('../runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs'),
44
- ]).then(
45
- ([config, registry, dispatch]) => ({ config, registry, dispatch }),
40
+ agentGraphPromise ??= Promise.resolve().then(loadAgentGraph).then(
41
+ (graph) => graph,
46
42
  (error) => {
47
43
  agentGraphPromise = null;
48
44
  throw error;
@@ -72,101 +68,6 @@ export function createInlineSessionRuntimeHost({
72
68
  await tracked;
73
69
  }
74
70
 
75
- function agentOwnedSession(session) {
76
- const owner = String(session?.owner || '').trim().toLowerCase();
77
- const agent = String(session?.agent || '').trim().toLowerCase();
78
- return Boolean(session?.id)
79
- && (owner === 'agent' || (agent && agent !== 'lead'));
80
- }
81
-
82
- async function projectAgentSession(session) {
83
- const [
84
- { restoreTranscriptItems },
85
- { getSessionProgressSnapshot },
86
- ] = await Promise.all([
87
- import('../tui/session/session-api-ext.mjs'),
88
- import('../runtime/agent/orchestrator/session/manager.mjs'),
89
- ]);
90
- const sessionId = String(session.id || '');
91
- const status = String(session.status || '').trim().toLowerCase();
92
- const progress = getSessionProgressSnapshot?.(sessionId) || null;
93
- const stage = String(progress?.stage || '').trim().toLowerCase();
94
- const busy = status === 'running' || status === 'queued'
95
- || (stage && stage !== 'idle' && stage !== 'done' && stage !== 'closed');
96
- return {
97
- sessionId,
98
- items: restoreTranscriptItems(
99
- Array.isArray(session.messages) ? session.messages : [],
100
- { sessionId, itemLimit: 512 },
101
- ),
102
- queued: [],
103
- busy,
104
- commandBusy: false,
105
- provider: session.provider || '',
106
- model: session.model || '',
107
- effort: session.effort || '',
108
- fast: session.fast === true,
109
- modelParameters: session.modelParameters || {},
110
- cwd: session.cwd || '',
111
- desktopSession: session.desktopSession || null,
112
- workflow: session.workflow || null,
113
- ownerClientHostPid: Number(session.clientHostPid) || process.pid,
114
- };
115
- }
116
-
117
- function publishAgentSessionState(sessionId, snapshot) {
118
- agentSessionSnapshots.delete(sessionId);
119
- agentSessionSnapshots.set(sessionId, snapshot);
120
- while (agentSessionSnapshots.size > 256) {
121
- const oldest = agentSessionSnapshots.keys().next().value;
122
- if (oldest === undefined) break;
123
- agentSessionSnapshots.delete(oldest);
124
- }
125
- for (const listener of [...agentSessionListeners]) {
126
- try { listener({ sessionId, snapshot }); } catch {}
127
- }
128
- }
129
-
130
- function scheduleAgentSessionProjection(session) {
131
- if (!agentOwnedSession(session) || closed) return;
132
- const sessionId = String(session.id);
133
- pendingAgentSessionProjections.set(sessionId, session);
134
- if (activeAgentSessionProjections.has(sessionId)) return;
135
- activeAgentSessionProjections.add(sessionId);
136
- queueMicrotask(() => {
137
- void (async () => {
138
- while (!closed) {
139
- const latest = pendingAgentSessionProjections.get(sessionId);
140
- if (!latest) break;
141
- pendingAgentSessionProjections.delete(sessionId);
142
- const snapshot = await projectAgentSession(latest);
143
- if (!closed) publishAgentSessionState(sessionId, snapshot);
144
- }
145
- })().catch((error) => {
146
- log(`agent session projection failed session=${sessionId}: ${error?.message || error}`);
147
- }).finally(() => {
148
- activeAgentSessionProjections.delete(sessionId);
149
- if (pendingAgentSessionProjections.has(sessionId) && !closed) {
150
- scheduleAgentSessionProjection(pendingAgentSessionProjections.get(sessionId));
151
- }
152
- });
153
- });
154
- }
155
-
156
- async function ensureAgentSessionPublisher() {
157
- if (unsubscribeAgentSessionPublisher) return;
158
- agentSessionPublisherPromise ??= import(
159
- '../runtime/agent/orchestrator/session/store.mjs'
160
- ).then((store) => {
161
- unsubscribeAgentSessionPublisher = store.subscribeLiveSessions(
162
- scheduleAgentSessionProjection,
163
- );
164
- }).finally(() => {
165
- agentSessionPublisherPromise = null;
166
- });
167
- await agentSessionPublisherPromise;
168
- }
169
-
170
71
  function forget(record) {
171
72
  if (!record || !records.delete(record.id)) return;
172
73
  for (const [sessionId, owner] of recordsBySessionId) {
@@ -193,6 +94,7 @@ export function createInlineSessionRuntimeHost({
193
94
  const runtime = await module.createLocalSessionRuntime({
194
95
  ...options,
195
96
  ...(options.cwd ? {} : { cwd }),
97
+ ...(typeof executeAgentControl === 'function' ? { executeAgentControl } : {}),
196
98
  });
197
99
  const record = {
198
100
  id: `inline-${process.pid}-${++nextRuntimeId}`,
@@ -244,7 +146,6 @@ export function createInlineSessionRuntimeHost({
244
146
  if (controller.signal.aborted) throw controller.signal.reason || new Error('agent dispatch canceled');
245
147
  const agent = String(payload.agent || '');
246
148
  const { dispatch } = await agentGraph();
247
- await ensureAgentSessionPublisher();
248
149
  await prepareAgentProviders();
249
150
  if (controller.signal.aborted) throw controller.signal.reason || new Error('agent dispatch canceled');
250
151
  let dispatcher = agentDispatchers.get(agent);
@@ -256,8 +157,9 @@ export function createInlineSessionRuntimeHost({
256
157
  agentDispatchers.set(agent, dispatcher);
257
158
  }
258
159
  const params = payload.params && typeof payload.params === 'object' ? payload.params : {};
160
+ const prompt = String(params.prompt ?? '');
259
161
  return await dispatcher({
260
- prompt: String(params.prompt ?? ''),
162
+ prompt,
261
163
  preset: params.preset || undefined,
262
164
  cwd: typeof params.cwd === 'string' && params.cwd ? params.cwd : undefined,
263
165
  parentSignal: controller.signal,
@@ -277,25 +179,35 @@ export function createInlineSessionRuntimeHost({
277
179
  agentDispatch,
278
180
  async agentControl(args = {}, context = {}) {
279
181
  if (closed) throw new Error('session runtime host is closed');
280
- const runtime = ownerRuntime(context?.callerSessionId);
281
- if (!runtime?.agentControl) {
282
- throw new Error(`session ${context?.callerSessionId || 'unknown'} is not loaded`);
182
+ if (typeof executeAgentControl === 'function') {
183
+ return await executeAgentControl(args, context);
283
184
  }
284
- return runtime.agentControl(args);
185
+ throw new Error('canonical Agent control is unavailable');
186
+ },
187
+ notifySessionCompletion(ownerSessionId, text, meta = {}) {
188
+ const runtime = ownerRuntime(ownerSessionId);
189
+ return runtime?.deliverToolCompletion?.(
190
+ String(ownerSessionId || ''),
191
+ String(text || ''),
192
+ meta,
193
+ ) === true;
194
+ },
195
+ async agentSessionAction(sessionId, action, args = []) {
196
+ void sessionId;
197
+ void action;
198
+ void args;
199
+ throw new Error('Agent sessions are owned by the canonical session service');
285
200
  },
286
201
  refreshRuntimeWorkload() {
287
202
  return Promise.resolve(this.workloads);
288
203
  },
289
204
  subscribeAgentSessionStates(listener) {
290
- if (typeof listener !== 'function') return () => {};
291
- agentSessionListeners.add(listener);
292
- void ensureAgentSessionPublisher().catch((error) => {
293
- log(`agent session publisher failed (non-fatal): ${error?.message || error}`);
294
- });
295
- for (const [sessionId, snapshot] of agentSessionSnapshots) {
296
- try { listener({ sessionId, snapshot }); } catch {}
297
- }
298
- return () => agentSessionListeners.delete(listener);
205
+ void listener;
206
+ return () => {};
207
+ },
208
+ agentSessionState(sessionId) {
209
+ void sessionId;
210
+ return null;
299
211
  },
300
212
  get workloads() {
301
213
  const memory = process.memoryUsage();
@@ -319,11 +231,6 @@ export function createInlineSessionRuntimeHost({
319
231
  async close(reason = 'session runtime host closed') {
320
232
  if (closed) return;
321
233
  closed = true;
322
- try { unsubscribeAgentSessionPublisher?.(); } catch {}
323
- unsubscribeAgentSessionPublisher = null;
324
- agentSessionListeners.clear();
325
- agentSessionSnapshots.clear();
326
- pendingAgentSessionProjections.clear();
327
234
  for (const controller of agentDispatchRuns.values()) {
328
235
  try { controller.abort(new Error(reason)); } catch {}
329
236
  }
@@ -20,6 +20,7 @@ import { getEventListeners } from 'node:events';
20
20
  import { safeIpcSend } from '../runtime/shared/safe-ipc-send.mjs';
21
21
  import { sanitizeForWire } from './session-service.mjs';
22
22
  import { disposeSessionRuntimeRecord } from './session-runtime-record.mjs';
23
+ import { releaseAllComputerSessions } from '../runtime/computer-bridge/client.mjs';
23
24
  import { diffSessionState } from './session-state-patch.mjs';
24
25
  import {
25
26
  applyProviderCooldown,
@@ -44,10 +45,6 @@ let sessionModulePromise = null;
44
45
  let stopping = false;
45
46
  let unhealthyDetail = null;
46
47
  let unhealthyReported = false;
47
- let unsubscribeAgentSessionPublisher = null;
48
- let agentSessionPublisherPromise = null;
49
- const pendingAgentSessionProjections = new Map();
50
- const activeAgentSessionProjections = new Set();
51
48
  const pendingAbortPressureChecks = new WeakSet();
52
49
  const ABORT_PRESSURE_RETENTION_CHECK_MS = 30_000;
53
50
 
@@ -261,94 +258,6 @@ function publish(record, forceFull = false) {
261
258
  });
262
259
  }
263
260
 
264
- function agentOwnedSession(session) {
265
- const owner = String(session?.owner || '').trim().toLowerCase();
266
- const agent = String(session?.agent || '').trim().toLowerCase();
267
- return Boolean(session?.id)
268
- && (owner === 'agent' || (agent && agent !== 'lead'));
269
- }
270
-
271
- async function projectAgentSession(session) {
272
- const [
273
- { restoreTranscriptItems },
274
- { getSessionProgressSnapshot },
275
- ] = await Promise.all([
276
- import('../tui/session/session-api-ext.mjs'),
277
- import('../runtime/agent/orchestrator/session/manager.mjs'),
278
- ]);
279
- const sessionId = String(session.id || '');
280
- const status = String(session.status || '').trim().toLowerCase();
281
- const progress = getSessionProgressSnapshot?.(sessionId) || null;
282
- const stage = String(progress?.stage || '').trim().toLowerCase();
283
- const busy = status === 'running' || status === 'queued'
284
- || (stage && stage !== 'idle' && stage !== 'done' && stage !== 'closed');
285
- return sanitizeForWire({
286
- sessionId,
287
- items: restoreTranscriptItems(
288
- Array.isArray(session.messages) ? session.messages : [],
289
- { sessionId, itemLimit: 512 },
290
- ),
291
- queued: [],
292
- busy,
293
- commandBusy: false,
294
- provider: session.provider || '',
295
- model: session.model || '',
296
- effort: session.effort || '',
297
- fast: session.fast === true,
298
- modelParameters: session.modelParameters || {},
299
- cwd: session.cwd || '',
300
- desktopSession: session.desktopSession || null,
301
- workflow: session.workflow || null,
302
- ownerClientHostPid: Number(session.clientHostPid) || process.pid,
303
- }) || null;
304
- }
305
-
306
- function scheduleAgentSessionProjection(session) {
307
- if (!agentOwnedSession(session) || stopping) return;
308
- const sessionId = String(session.id);
309
- pendingAgentSessionProjections.set(sessionId, session);
310
- if (activeAgentSessionProjections.has(sessionId)) return;
311
- activeAgentSessionProjections.add(sessionId);
312
- queueMicrotask(() => {
313
- void (async () => {
314
- while (!stopping) {
315
- const latest = pendingAgentSessionProjections.get(sessionId);
316
- if (!latest) break;
317
- pendingAgentSessionProjections.delete(sessionId);
318
- const snapshot = await projectAgentSession(latest);
319
- if (!snapshot || stopping) continue;
320
- send({ type: 'agent-session-state', sessionId, snapshot });
321
- }
322
- })().catch((error) => {
323
- try {
324
- process.stderr.write(
325
- `[session-runtime-worker] agent session projection failed session=${sessionId}: `
326
- + `${error?.message || error}\n`,
327
- );
328
- } catch {}
329
- }).finally(() => {
330
- activeAgentSessionProjections.delete(sessionId);
331
- if (pendingAgentSessionProjections.has(sessionId) && !stopping) {
332
- scheduleAgentSessionProjection(pendingAgentSessionProjections.get(sessionId));
333
- }
334
- });
335
- });
336
- }
337
-
338
- async function ensureAgentSessionPublisher() {
339
- if (unsubscribeAgentSessionPublisher) return;
340
- agentSessionPublisherPromise ??= import(
341
- '../runtime/agent/orchestrator/session/store.mjs'
342
- ).then((store) => {
343
- unsubscribeAgentSessionPublisher = store.subscribeLiveSessions(
344
- scheduleAgentSessionProjection,
345
- );
346
- }).finally(() => {
347
- agentSessionPublisherPromise = null;
348
- });
349
- await agentSessionPublisherPromise;
350
- }
351
-
352
261
  async function createRuntime(message) {
353
262
  const module = await sessionModule();
354
263
  const runtime = await module.createLocalSessionRuntime(message.options || {});
@@ -395,105 +304,29 @@ async function callRuntime(message) {
395
304
  // first dispatch; an in-flight dispatch holds an 'agent' admission lease, so
396
305
  // the host's recycle guard (activeResources) never interrupts one.
397
306
  let agentGraphPromise = null;
398
- function agentGraph() {
399
- agentGraphPromise ??= Promise.all([
307
+ function loadAgentGraph() {
308
+ const testModule = process.env.NODE_ENV === 'test'
309
+ ? String(process.env.MIXDOG_SESSION_RUNTIME_TEST_AGENT_GRAPH || '')
310
+ : '';
311
+ if (testModule) {
312
+ return import(testModule).then((module) => module.default || module);
313
+ }
314
+ return Promise.all([
400
315
  import('../runtime/agent/orchestrator/config.mjs'),
401
316
  import('../runtime/agent/orchestrator/providers/registry.mjs'),
402
317
  import('../runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs'),
403
- ]).then(
404
- ([config, registry, dispatch]) => ({ config, registry, dispatch }),
405
- (error) => {
318
+ ]).then(([config, registry, dispatch]) => ({ config, registry, dispatch }));
319
+ }
320
+
321
+ function agentGraph() {
322
+ agentGraphPromise ??= loadAgentGraph().catch((error) => {
406
323
  agentGraphPromise = null;
407
324
  throw error;
408
- },
409
- );
325
+ });
410
326
  return agentGraphPromise;
411
327
  }
412
328
  const agentDispatchers = new Map();
413
329
  const agentDispatchRuns = new Map(); // dispatchId -> AbortController
414
- let distributedAgentToolPromise = null;
415
- const distributedAgentControlRuns = new Map(); // controlId -> AbortController
416
-
417
- function distributedAgentTool() {
418
- distributedAgentToolPromise ??= Promise.all([
419
- import('../standalone/agent-tool.mjs'),
420
- import('../runtime/agent/orchestrator/config.mjs'),
421
- import('../runtime/agent/orchestrator/providers/registry.mjs'),
422
- import('../runtime/agent/orchestrator/session/manager.mjs'),
423
- ]).then(async ([agentModule, cfgMod, reg, mgr]) => {
424
- await ensureAgentSessionPublisher();
425
- return agentModule.createStandaloneAgent({
426
- cfgMod,
427
- reg,
428
- mgr,
429
- dataDir: cfgMod.getPluginData(),
430
- cwd: process.cwd(),
431
- awaitKeychainPrewarm: async () => {},
432
- isKeychainPrewarmReady: () => true,
433
- notifySessionCompletion(ownerSessionId, text, meta = {}) {
434
- return send({
435
- type: 'agent-control-notification',
436
- ownerSessionId: String(ownerSessionId || ''),
437
- text: String(text || ''),
438
- meta: sanitizeForWire(meta) || {},
439
- });
440
- },
441
- });
442
- }).catch((error) => {
443
- distributedAgentToolPromise = null;
444
- throw error;
445
- });
446
- return distributedAgentToolPromise;
447
- }
448
-
449
- async function runDistributedAgentControl(message) {
450
- const controlId = String(message.controlId || '');
451
- if (!controlId) throw new Error('agent control id is required');
452
- if (distributedAgentControlRuns.has(controlId)) {
453
- throw new Error(`agent control ${controlId} is already running`);
454
- }
455
- const controller = new AbortController();
456
- distributedAgentControlRuns.set(controlId, controller);
457
- try {
458
- const tool = await distributedAgentTool();
459
- if (controller.signal.aborted) throw controller.signal.reason;
460
- const context = message.context && typeof message.context === 'object'
461
- ? message.context
462
- : {};
463
- if (String(message.args?.type || '') === '__close_all') {
464
- tool.closeAll?.(
465
- String(message.args?.reason || 'agent owner closed'),
466
- { callerSessionId: context.callerSessionId || null },
467
- );
468
- return 'agent close all: ok';
469
- }
470
- return await tool.execute(message.args || {}, {
471
- callerCwd: context.callerCwd || process.cwd(),
472
- invocationSource: context.invocationSource || 'model-tool',
473
- callerSessionId: context.callerSessionId || null,
474
- clientHostPid: Number(context.clientHostPid) || process.pid,
475
- signal: controller.signal,
476
- });
477
- } finally {
478
- distributedAgentControlRuns.delete(controlId);
479
- }
480
- }
481
-
482
- async function distributedAgentStatus(message) {
483
- const tool = await distributedAgentTool();
484
- return tool.getStatus?.(message.context || {}) || { workers: [], jobs: [], scope: null };
485
- }
486
-
487
- function cancelDistributedAgentControl(message) {
488
- const controlId = String(message.controlId || '');
489
- const controller = distributedAgentControlRuns.get(controlId);
490
- if (!controller) return { cancelled: false };
491
- abortDispatchController(
492
- controller,
493
- new Error(String(message.reason || 'agent control canceled')),
494
- );
495
- return { cancelled: true };
496
- }
497
330
 
498
331
  async function deliverDistributedAgentNotification(message) {
499
332
  const ownerSessionId = String(message.ownerSessionId || '');
@@ -609,8 +442,6 @@ async function runAgentDispatch(message) {
609
442
  const agent = String(message.agent || '');
610
443
  const { dispatch } = await agentGraph();
611
444
  throwIfDispatchAborted(controller);
612
- await ensureAgentSessionPublisher();
613
- throwIfDispatchAborted(controller);
614
445
  await prepareAgentProviders();
615
446
  throwIfDispatchAborted(controller);
616
447
  ensureProviderCooldownBridge();
@@ -623,8 +454,9 @@ async function runAgentDispatch(message) {
623
454
  agentDispatchers.set(agent, dispatcher);
624
455
  }
625
456
  const params = message.params && typeof message.params === 'object' ? message.params : {};
457
+ const prompt = String(params.prompt ?? '');
626
458
  const value = await dispatcher({
627
- prompt: String(params.prompt ?? ''),
459
+ prompt,
628
460
  preset: params.preset || undefined,
629
461
  cwd: typeof params.cwd === 'string' && params.cwd ? params.cwd : undefined,
630
462
  parentSignal: controller.signal,
@@ -720,17 +552,9 @@ async function stopAll(reason = 'session runtime worker shutdown') {
720
552
  try { cooldownBridgeUnsubscribe?.(); } catch {}
721
553
  cooldownBridgeUnsubscribe = null;
722
554
  retainedDispatchCancels.clear();
723
- for (const controller of distributedAgentControlRuns.values()) {
724
- abortDispatchController(controller, new Error(reason));
725
- }
726
- distributedAgentControlRuns.clear();
727
555
  for (const controller of agentDispatchRuns.values()) {
728
556
  try { controller.abort(new Error(reason)); } catch { /* settled */ }
729
557
  }
730
- try { unsubscribeAgentSessionPublisher?.(); } catch {}
731
- unsubscribeAgentSessionPublisher = null;
732
- pendingAgentSessionProjections.clear();
733
- try { (await distributedAgentToolPromise)?.closeAll?.(); } catch {}
734
558
  for (const record of [...records.values()]) {
735
559
  try {
736
560
  await disposeSessionRuntimeRecord(
@@ -741,6 +565,9 @@ async function stopAll(reason = 'session runtime worker shutdown') {
741
565
  } catch {}
742
566
  }
743
567
  records.clear();
568
+ // Backstop for sessions whose runtime never reached a clean dispose: the host
569
+ // keeps their workers and target claims until it is told to release them.
570
+ try { await releaseAllComputerSessions(); } catch { /* best-effort shutdown */ }
744
571
  }
745
572
 
746
573
  process.on('message', (message) => {
@@ -770,11 +597,6 @@ process.on('message', (message) => {
770
597
  if (message.type === 'workload') return workloadSnapshot();
771
598
  if (message.type === 'agent-dispatch') return runAgentDispatch(message);
772
599
  if (message.type === 'agent-dispatch-cancel') return cancelAgentDispatch(message);
773
- if (message.type === 'agent-control-local') return runDistributedAgentControl(message);
774
- if (message.type === 'agent-control-status') return distributedAgentStatus(message);
775
- if (message.type === 'agent-control-local-cancel') {
776
- return cancelDistributedAgentControl(message);
777
- }
778
600
  if (message.type === 'shutdown') {
779
601
  await stopAll(message.reason);
780
602
  return { stopped: true };