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
@@ -1,311 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import test from 'node:test';
3
-
4
- import { createModelPicker } from './model-picker.mjs';
5
- import { shouldSupersedePanelEpoch, supersedePanelEpoch } from './panel-epoch.mjs';
6
- import { createPanelSurface } from './panel-surface.mjs';
7
- import { createRoutePickers } from './route-pickers.mjs';
8
- import { createSettingsPicker } from './settings-picker.mjs';
9
- import { createSlashDispatch } from './slash-dispatch.mjs';
10
- import { createThemeEffortPickers } from './theme-effort-pickers.mjs';
11
-
12
- function deferred() {
13
- let resolve;
14
- let reject;
15
- const promise = new Promise((res, rej) => { resolve = res; reject = rej; });
16
- return { promise, resolve, reject };
17
- }
18
-
19
- const flush = async () => {
20
- await new Promise((resolve) => setTimeout(resolve, 0));
21
- await new Promise((resolve) => setImmediate(resolve));
22
- };
23
-
24
- function createPanelHost() {
25
- let current = null;
26
- const painted = [];
27
- const setPicker = (next) => {
28
- const previous = current;
29
- current = typeof next === 'function' ? next(previous) : next;
30
- if (shouldSupersedePanelEpoch(previous, current)) supersedePanelEpoch();
31
- painted.push(current);
32
- };
33
- const surface = createPanelSurface({
34
- setPicker,
35
- setContextPanel: () => {},
36
- setUsagePanel: () => {},
37
- });
38
- return { current: () => current, painted, setPicker, surface };
39
- }
40
-
41
- const HANDOFF = {
42
- title: 'Settings',
43
- description: 'Applying selection...',
44
- help: 'Esc Close',
45
- indexMode: 'never',
46
- pickerKey: 'settings-handoff',
47
- loading: true,
48
- items: [],
49
- };
50
-
51
- function settingsDeps(host, store, opened = {}) {
52
- const noop = () => {};
53
- return {
54
- store: { pushNotice: noop, ...store },
55
- state: { model: 'gpt-5', provider: 'openai', workflow: { id: 'default' } },
56
- surface: host.surface,
57
- setProviderPrompt: noop,
58
- setSettingsPrompt: noop,
59
- settingsHeavyCacheRef: { current: null },
60
- settingsRequestRef: { current: 0 },
61
- formatDuration: (ms) => `${ms}ms`,
62
- displayModelName: () => 'GPT-5',
63
- routeModelLabel: () => '(unset)',
64
- workflowDisplayName: () => 'Default',
65
- workflowSwitchNotice: () => 'workflow switched',
66
- themeNotice: () => 'theme set',
67
- openModelPicker: (options) => { opened.model = options; },
68
- openWebSearchPicker: noop,
69
- openAgentsPicker: noop,
70
- openWorkflowPicker: (options) => { opened.workflow = options; },
71
- openOutputStylePicker: (options) => { opened.outputStyle = options; },
72
- openProviderSetupPicker: noop,
73
- openThemePicker: (options) => { opened.theme = options; },
74
- openAutoClearPicker: noop,
75
- openProfilePicker: noop,
76
- openMcpPicker: noop,
77
- openPluginsPicker: noop,
78
- openHooksPicker: noop,
79
- openSkillsPicker: noop,
80
- openMemoryCorePicker: noop,
81
- openUpdatePicker: noop,
82
- };
83
- }
84
-
85
- test('Settings paints its loading destination before the daemon snapshot settles', async () => {
86
- supersedePanelEpoch();
87
- const host = createPanelHost();
88
- host.setPicker({ title: 'Theme' });
89
- const snapshotGate = deferred();
90
- const opened = {};
91
- const { openSettingsPicker } = createSettingsPicker(settingsDeps(
92
- host,
93
- { getSettingsSnapshot: () => snapshotGate.promise },
94
- opened,
95
- ));
96
-
97
- const opening = openSettingsPicker();
98
- assert.equal(host.current()?.title, 'Settings');
99
- assert.match(host.current()?.description || '', /Loading settings/i);
100
- assert.notEqual(host.current(), null);
101
-
102
- snapshotGate.resolve({});
103
- await opening;
104
- const settings = host.current();
105
- assert.equal(settings?.title, 'Settings');
106
- assert.ok(settings.items.length > 0);
107
-
108
- for (const action of ['model', 'workflow', 'output-style', 'theme']) {
109
- const item = settings.items.find((entry) => entry._action === action);
110
- settings.onSelect(item.value, item);
111
- }
112
- for (const options of [opened.model, opened.workflow, opened.outputStyle, opened.theme]) {
113
- assert.equal(options?.handoffPanel?.title, 'Settings');
114
- assert.equal(options?.handoffPanel?.pickerKey, 'settings-handoff');
115
- assert.equal(options?.handoffPanel?.loading, true);
116
- }
117
- });
118
-
119
- test('Model save keeps a Settings handoff panel visible until the write settles', async () => {
120
- supersedePanelEpoch();
121
- const host = createPanelHost();
122
- const saveGate = deferred();
123
- const { openModelPicker } = createModelPicker({
124
- store: {
125
- pushNotice: () => {},
126
- listProviderModels: async () => [],
127
- setRoute: () => saveGate.promise,
128
- },
129
- getState: () => ({ provider: 'openai', model: 'gpt-5', effort: null, fast: false }),
130
- surface: host.surface,
131
- setProviderPrompt: () => {},
132
- setSettingsPrompt: () => {},
133
- providerModelsCacheRef: {
134
- current: {
135
- at: Date.now(),
136
- models: [{ provider: 'openai', id: 'gpt-5', display: 'GPT-5' }],
137
- },
138
- },
139
- webSearchModelsCacheRef: { current: { models: [], at: 0 } },
140
- modelPickerRequestRef: { current: 0 },
141
- clearModelCaches: () => {},
142
- modelSwitchNotice: () => 'switched',
143
- openProviderSetupPicker: () => {},
144
- });
145
-
146
- await openModelPicker({
147
- handoffPanel: HANDOFF,
148
- onAfterSelect: () => host.setPicker({ title: 'Settings', items: [{ value: 'done' }] }),
149
- });
150
- const providers = host.current();
151
- providers.onSelect(providers.items[0].value, providers.items[0]);
152
- const models = host.current();
153
- models.onSelect(models.items[0].value, models.items[0]);
154
-
155
- assert.equal(host.current(), HANDOFF);
156
- assert.equal(host.painted.at(-1), HANDOFF);
157
-
158
- saveGate.resolve(true);
159
- await flush();
160
- assert.equal(host.current()?.title, 'Settings');
161
- assert.notEqual(host.current(), HANDOFF);
162
- });
163
-
164
- function routePicker(host, store) {
165
- return createRoutePickers({
166
- store: { pushNotice: () => {}, ...store },
167
- state: {},
168
- surface: host.surface,
169
- setProviderPrompt: () => {},
170
- setSettingsPrompt: () => {},
171
- closeUsagePanel: () => {},
172
- clean: (value) => value,
173
- routeLabel: () => 'route',
174
- agentModelParts: () => [],
175
- agentModelProfile: () => 'profile',
176
- workflowSwitchNotice: () => 'workflow switched',
177
- openModelPicker: () => {},
178
- });
179
- }
180
-
181
- test('Workflow and output-style saves keep the Settings handoff visible until their writes settle', async () => {
182
- supersedePanelEpoch();
183
- const workflowHost = createPanelHost();
184
- const workflowGate = deferred();
185
- const workflow = routePicker(workflowHost, {
186
- listWorkflows: async () => [{ id: 'solo', name: 'Solo', active: true }],
187
- setWorkflow: () => workflowGate.promise,
188
- });
189
- await workflow.openWorkflowPicker({
190
- returnTo: () => workflowHost.setPicker({ title: 'Settings', items: [{ value: 'done' }] }),
191
- handoffPanel: HANDOFF,
192
- });
193
- const workflowPanel = workflowHost.current();
194
- workflowPanel.onSelect(workflowPanel.items[0].value, workflowPanel.items[0]);
195
- assert.equal(workflowHost.current(), HANDOFF);
196
-
197
- workflowGate.resolve({ id: 'solo' });
198
- await flush();
199
- assert.equal(workflowHost.current()?.title, 'Settings');
200
-
201
- const styleHost = createPanelHost();
202
- const styleGate = deferred();
203
- const outputStyle = routePicker(styleHost, {
204
- listOutputStyles: async () => ({
205
- current: { id: 'simple' },
206
- styles: [{ id: 'simple', label: 'Simple' }],
207
- }),
208
- setOutputStyle: () => styleGate.promise,
209
- });
210
- await outputStyle.openOutputStylePicker({
211
- returnTo: () => styleHost.setPicker({ title: 'Settings', items: [{ value: 'done' }] }),
212
- handoffPanel: HANDOFF,
213
- });
214
- const stylePanel = styleHost.current();
215
- stylePanel.onSelect(stylePanel.items[0].value, stylePanel.items[0]);
216
- assert.equal(styleHost.current(), HANDOFF);
217
-
218
- styleGate.resolve({ current: { id: 'simple', label: 'Simple' } });
219
- await flush();
220
- assert.equal(styleHost.current()?.title, 'Settings');
221
- });
222
-
223
- test('Theme selection hands directly to Settings without a null panel', () => {
224
- supersedePanelEpoch();
225
- const host = createPanelHost();
226
- const { openThemePicker } = createThemeEffortPickers({
227
- state: {},
228
- store: {
229
- listThemes: () => [{ id: 'basic', label: 'Basic' }],
230
- getTheme: () => 'basic',
231
- setTheme: (id) => ({ id, label: 'Basic' }),
232
- pushNotice: () => {},
233
- },
234
- surface: host.surface,
235
- setProviderPrompt: () => {},
236
- setSettingsPrompt: () => {},
237
- closeUsagePanel: () => {},
238
- clean: (value) => value,
239
- });
240
-
241
- openThemePicker({
242
- returnTo: () => host.setPicker({ title: 'Settings', items: [{ value: 'done' }] }),
243
- handoffPanel: HANDOFF,
244
- });
245
- const theme = host.current();
246
- const paintedBefore = host.painted.length;
247
- theme.onSelect(theme.items[0].value, theme.items[0]);
248
-
249
- const transitionPaints = host.painted.slice(paintedBefore);
250
- assert.deepEqual(transitionPaints.map((panel) => panel?.title), ['Settings', 'Settings']);
251
- assert.ok(transitionPaints.every(Boolean));
252
- });
253
-
254
- function workflowSlashDispatch(host, openWorkflowPicker, notices = []) {
255
- return createSlashDispatch({
256
- state: { busy: false, commandBusy: false },
257
- store: { pushNotice: (message, tone) => notices.push([message, tone]) },
258
- normalizeSlashCommandName: (value) => value,
259
- surface: host.surface,
260
- closeUsagePanel: () => {},
261
- openWorkflowPicker,
262
- });
263
- }
264
-
265
- test('slash option entry keeps a loading panel until the async picker paints', async () => {
266
- supersedePanelEpoch();
267
- const host = createPanelHost();
268
- const openGate = deferred();
269
- const { runSlashCommand } = workflowSlashDispatch(host, () => {
270
- const own = host.surface.claim();
271
- return openGate.promise.then(() => own.paint({
272
- title: 'Workflow',
273
- description: 'Select active workflow.',
274
- items: [{ value: 'solo', label: 'Solo' }],
275
- }));
276
- });
277
-
278
- assert.equal(runSlashCommand('workflow'), true);
279
- assert.equal(host.current()?._kind, 'slash-loading:workflow');
280
- assert.equal(host.current()?.title, 'Workflow');
281
- assert.equal(host.current()?.loading, true);
282
-
283
- openGate.resolve();
284
- await flush();
285
- assert.equal(host.current()?.title, 'Workflow');
286
- assert.equal(host.current()?._kind, undefined);
287
- assert.ok(host.current()?.items.length > 0);
288
- });
289
-
290
- test('Esc on slash loading prevents the pending picker from appearing later', async () => {
291
- supersedePanelEpoch();
292
- const host = createPanelHost();
293
- const openGate = deferred();
294
- const { runSlashCommand } = workflowSlashDispatch(host, () => {
295
- const own = host.surface.claim();
296
- return openGate.promise.then(() => own.paint({
297
- title: 'Workflow',
298
- items: [{ value: 'solo', label: 'Solo' }],
299
- }));
300
- });
301
-
302
- runSlashCommand('workflow');
303
- const loading = host.current();
304
- assert.equal(loading?._kind, 'slash-loading:workflow');
305
- loading.onCancel();
306
- assert.equal(host.current(), null);
307
-
308
- openGate.resolve();
309
- await flush();
310
- assert.equal(host.current(), null);
311
- });
@@ -1,206 +0,0 @@
1
- // Prompt-submit dispatcher contract for daemon-backed settings writes.
2
- //
3
- // Two properties are pinned here because both lose user input when they break:
4
- // 1. one write per surface at a time (a fast second Enter must be refused,
5
- // never started as an overlapping write), and
6
- // 2. an ack that no longer owns the surface (superseded by Esc or by a newer
7
- // submit) must not close the prompt, navigate, or claim success.
8
- // Plus the documented clear-by-empty settings actions must reach the daemon.
9
- import assert from 'node:assert/strict';
10
- import test from 'node:test';
11
- import { readFile } from 'node:fs/promises';
12
-
13
- import { createPromptSubmit } from './prompt-submit.mjs';
14
- import { supersedePanelEpoch } from './panel-epoch.mjs';
15
- import { canSubmitTextEntry, textEntryClearsByEmpty } from './text-entry-policy.mjs';
16
-
17
- function deferred() {
18
- let resolve;
19
- let reject;
20
- const promise = new Promise((res, rej) => { resolve = res; reject = rej; });
21
- return { promise, resolve, reject };
22
- }
23
-
24
- const flush = async () => {
25
- for (let i = 0; i < 4; i += 1) await new Promise((resolve) => setImmediate(resolve));
26
- };
27
-
28
- function createHarness({ settingsPrompt = null, store: storeOverrides = {} } = {}) {
29
- const notices = [];
30
- const settingsPromptSet = [];
31
- const opened = [];
32
- const store = {
33
- pushNotice: (message, tone) => notices.push([message, tone]),
34
- ...storeOverrides,
35
- };
36
- const { onSubmit } = createPromptSubmit({
37
- store,
38
- state: { commandBusy: false },
39
- providerPrompt: null,
40
- settingsPrompt,
41
- setProviderPrompt: () => {},
42
- setSettingsPrompt: (next) => {
43
- settingsPromptSet.push(typeof next === 'function' ? next(settingsPrompt) : next);
44
- },
45
- oauthSubmitRef: { current: false },
46
- clearModelCaches: () => {},
47
- openProviderSetupPicker: () => { opened.push('providers'); },
48
- openSettingsPicker: () => { opened.push('settings'); },
49
- openProjectPicker: () => { opened.push('projects'); },
50
- openAutoClearPicker: () => { opened.push('autoclear'); },
51
- openProfilePicker: () => { opened.push('profile'); },
52
- openPluginsPicker: () => {},
53
- openMcpServersPicker: () => {},
54
- openProjectSkillsPicker: () => {},
55
- openMemoryCorePicker: () => {},
56
- registerProject: () => {},
57
- runSlashCommand: () => true,
58
- armTranscriptFollow: () => {},
59
- clearPastedImagesSnapshot: () => {},
60
- clearPastedTextsSnapshot: () => {},
61
- pastedImagesRef: { current: {} },
62
- pastedTextsRef: { current: {} },
63
- });
64
- return { onSubmit, notices, settingsPromptSet, opened };
65
- }
66
-
67
- const closedCount = (harness) => harness.settingsPromptSet.filter((value) => value === null).length;
68
-
69
- test('a second settings submit is refused while the first daemon write is in flight', async () => {
70
- supersedePanelEpoch();
71
- const gate = deferred();
72
- const shellCalls = [];
73
- const harness = createHarness({
74
- settingsPrompt: { kind: 'system-shell', label: 'System shell' },
75
- store: {
76
- setSystemShell: (command) => { shellCalls.push(command); return gate.promise; },
77
- },
78
- });
79
-
80
- assert.equal(harness.onSubmit('pwsh'), true);
81
- // Fast second Enter (before React re-renders the prompt): refused, so the
82
- // draft is kept and no overlapping write is started.
83
- assert.equal(harness.onSubmit('bash'), false);
84
- assert.deepEqual(shellCalls, ['pwsh']);
85
- assert.ok(harness.notices.some(([message, tone]) => tone === 'warn' && /settings change/.test(message)));
86
-
87
- gate.resolve(true);
88
- await flush();
89
- assert.equal(closedCount(harness), 1);
90
- assert.deepEqual(harness.opened, ['settings']);
91
- });
92
-
93
- test('an ack superseded by Esc and a newer submit never closes the live prompt', async () => {
94
- supersedePanelEpoch();
95
- const first = deferred();
96
- const second = deferred();
97
-
98
- const firstHarness = createHarness({
99
- settingsPrompt: { kind: 'system-shell', label: 'System shell' },
100
- store: { setSystemShell: () => first.promise },
101
- });
102
- assert.equal(firstHarness.onSubmit('pwsh'), true);
103
-
104
- // Esc on the prompt (cancelSettingsPrompt) hands the surface back.
105
- supersedePanelEpoch();
106
-
107
- // A fresh prompt + submit: the abandoned write must not block it.
108
- const secondHarness = createHarness({
109
- settingsPrompt: { kind: 'system-shell', label: 'System shell' },
110
- store: { setSystemShell: () => second.promise },
111
- });
112
- assert.equal(secondHarness.onSubmit('bash'), true);
113
-
114
- first.resolve(true);
115
- await flush();
116
- // The older ack owns nothing: no close, no navigation, no success claim.
117
- assert.equal(closedCount(firstHarness), 0);
118
- assert.deepEqual(firstHarness.opened, []);
119
-
120
- second.resolve(true);
121
- await flush();
122
- assert.equal(closedCount(secondHarness), 1);
123
- assert.deepEqual(secondHarness.opened, ['settings']);
124
- });
125
-
126
- test('a rejected settings write restores the typed value instead of closing', async () => {
127
- supersedePanelEpoch();
128
- const gate = deferred();
129
- const harness = createHarness({
130
- settingsPrompt: { kind: 'system-shell', label: 'System shell' },
131
- store: { setSystemShell: () => gate.promise },
132
- });
133
- assert.equal(harness.onSubmit('pwsh -NoLogo'), true);
134
-
135
- gate.reject(new Error('daemon offline'));
136
- await flush();
137
-
138
- assert.equal(closedCount(harness), 0);
139
- const restored = harness.settingsPromptSet[harness.settingsPromptSet.length - 1];
140
- assert.equal(restored.kind, 'system-shell');
141
- assert.equal(restored.initialValue, 'pwsh -NoLogo');
142
- assert.equal(restored.submitting, false);
143
- assert.ok(restored.restoreEpoch >= 1);
144
- assert.ok(harness.notices.some(([message, tone]) => tone === 'error' && /daemon offline/.test(message)));
145
- });
146
-
147
- test('empty submits reach the daemon as the documented reset/clear actions', async () => {
148
- supersedePanelEpoch();
149
- const shellCalls = [];
150
- const shell = createHarness({
151
- settingsPrompt: { kind: 'system-shell', label: 'System shell' },
152
- store: { setSystemShell: (command) => { shellCalls.push(command); return Promise.resolve(true); } },
153
- });
154
- assert.equal(shell.onSubmit(''), true);
155
- await flush();
156
- assert.deepEqual(shellCalls, ['']);
157
- assert.equal(closedCount(shell), 1);
158
-
159
- supersedePanelEpoch();
160
- const autoClearCalls = [];
161
- const autoClear = createHarness({
162
- settingsPrompt: { kind: 'autoclear-provider', label: 'Auto-clear · openai', provider: 'openai' },
163
- store: { setAutoClear: (patch) => { autoClearCalls.push(patch); return Promise.resolve({ enabled: true }); } },
164
- });
165
- assert.equal(autoClear.onSubmit(''), true);
166
- await flush();
167
- assert.deepEqual(autoClearCalls, [{ provider: 'openai', resetProvider: true }]);
168
- assert.ok(autoClear.notices.some(([message]) => /default reset/.test(message)));
169
-
170
- supersedePanelEpoch();
171
- const profileCalls = [];
172
- const profile = createHarness({
173
- settingsPrompt: { kind: 'profile-title', label: 'Profile · Title' },
174
- store: { setProfile: (patch) => { profileCalls.push(patch); return Promise.resolve({ title: '' }); } },
175
- });
176
- assert.equal(profile.onSubmit(''), true);
177
- await flush();
178
- assert.deepEqual(profileCalls, [{ title: '' }]);
179
- assert.ok(profile.notices.some(([message]) => /Title cleared/.test(message)));
180
- });
181
-
182
- test('the settings text-entry panel is wired to the clear-by-empty policy', async () => {
183
- // The dispatcher cases above enter through onSubmit and therefore bypass
184
- // TextEntryPanel entirely — they pass even when the view drops the prop and
185
- // the panel refuses every blank submit. No JSX parser exists in this
186
- // workspace, so the wiring is pinned as source text instead.
187
- const view = await readFile(new URL('./app-view.jsx', import.meta.url), 'utf8');
188
- assert.match(view, /import \{ textEntryClearsByEmpty \} from '\.\/text-entry-policy\.mjs';/);
189
- assert.match(view, /allowEmpty=\{textEntryClearsByEmpty\(settingsPrompt\.kind\)\}/);
190
- // The panel's own submit gate must consult the same policy value.
191
- const panel = await readFile(new URL('../components/TextEntryPanel.jsx', import.meta.url), 'utf8');
192
- assert.match(panel, /canSubmitTextEntry\(draftRef\.current\.value, allowEmpty\)/);
193
- assert.match(panel, /canSubmitTextEntry\(next\.value, allowEmpty\)/);
194
- });
195
-
196
- test('clear-by-empty prompt kinds bypass the blank-submit gate', () => {
197
- assert.equal(textEntryClearsByEmpty('system-shell'), true);
198
- assert.equal(textEntryClearsByEmpty('autoclear-provider'), true);
199
- assert.equal(textEntryClearsByEmpty('profile-title'), true);
200
- assert.equal(textEntryClearsByEmpty('core-add'), false);
201
- assert.equal(textEntryClearsByEmpty(''), false);
202
- assert.equal(canSubmitTextEntry('', true), true);
203
- assert.equal(canSubmitTextEntry(' ', true), true);
204
- assert.equal(canSubmitTextEntry('', false), false);
205
- assert.equal(canSubmitTextEntry(' value ', false), true);
206
- });
@@ -1,111 +0,0 @@
1
- // Regression: persisted async-completion wrappers must restore as tool cards.
2
- // 2026-08-17 field report — background shell completions (bench runs) resumed
3
- // the model turn but left NO transcript card: the live notification push is
4
- // event-ephemeral, and the transcript rebuild dropped the persisted wrapper
5
- // row via the internal-display suppression. restoreTranscriptItems now
6
- // projects wrapper rows through the same synthetic tool-card shape.
7
- import test from 'node:test';
8
- import assert from 'node:assert/strict';
9
- import { restoreTranscriptItems } from './session-api-ext.mjs';
10
-
11
- const wrapper = (taskId, body) => [
12
- `Async shell task ${taskId} (completed, exit 0) finished.`,
13
- '',
14
- 'Result:',
15
- ...body.split('\n').map((line) => `> ${line}`),
16
- ].join('\n');
17
-
18
- const bodyFor = (taskId) => [
19
- 'background task',
20
- `task_id: ${taskId}`,
21
- 'label: pwsh run.ps1',
22
- 'status: completed',
23
- '',
24
- `[task_id: ${taskId}]`,
25
- '[status: completed]',
26
- '[exit: 0]',
27
- '',
28
- 'Summary: report jobs/report.json',
29
- '',
30
- '[stdout preview]',
31
- '8/8 Mean: 1.000',
32
- ].join('\n');
33
-
34
- test('completion wrapper user rows restore as tool cards, not dropped rows', () => {
35
- const messages = [
36
- { role: 'user', content: '벤치 돌려줘' },
37
- { role: 'assistant', content: '돌립니다.' },
38
- { role: 'user', content: wrapper('job_regress_1', bodyFor('job_regress_1')) },
39
- { role: 'assistant', content: '완료 보고.' },
40
- ];
41
- const restored = restoreTranscriptItems(messages, { sessionId: 'sess_test' });
42
- const items = Array.isArray(restored) ? restored : restored.items;
43
- const card = items.find((it) => it?.kind === 'tool' && it?.args?.task_id === 'job_regress_1');
44
- assert.ok(card, 'wrapper row must project a tool card');
45
- assert.equal(card.isError, false);
46
- assert.match(String(card.result || ''), /8\/8 Mean: 1\.000/);
47
- // The raw wrapper must never surface as a plain user bubble.
48
- assert.ok(!items.some((it) => it?.kind === 'user' && /Async shell task/.test(it.text || '')));
49
- });
50
-
51
- test('non-wrapper internal rows stay suppressed on restore', () => {
52
- const messages = [
53
- { role: 'user', content: '<system-reminder>internal</system-reminder>' },
54
- { role: 'user', content: '[mixdog-runtime] nudge' },
55
- ];
56
- const restored = restoreTranscriptItems(messages, { sessionId: 'sess_test2' });
57
- const items = Array.isArray(restored) ? restored : restored.items;
58
- assert.equal(items.filter((it) => it?.kind === 'user').length, 0);
59
- });
60
-
61
- test('restored shell results preserve command-failure and no-match taxonomy', () => {
62
- const offload = `[tool output offloaded: shell → C:/safe/result.txt (60 KB, 900 lines, sha256 ${'a'.repeat(64)})]`;
63
- const messages = [
64
- {
65
- role: 'assistant',
66
- toolCalls: [{ id: 'call_fail', name: 'shell', arguments: { command: 'npm test' } }],
67
- },
68
- {
69
- role: 'tool',
70
- toolCallId: 'call_fail',
71
- toolKind: 'error',
72
- content: `${offload}\n\n[exit code: 2]\nfailed tests`,
73
- },
74
- {
75
- role: 'assistant',
76
- content: '다음 조회',
77
- toolCalls: [{ id: 'call_probe', name: 'shell', arguments: { command: 'rg missing .' } }],
78
- },
79
- {
80
- role: 'tool',
81
- toolCallId: 'call_probe',
82
- toolKind: 'error',
83
- content: '[exit code: 1]\n[outcome: no-match]\n\n(no output)',
84
- },
85
- ];
86
- const items = restoreTranscriptItems(messages, { sessionId: 'sess_shell_restore' });
87
- const failed = items.find((item) => item?.args?.command === 'npm test');
88
- const probe = items.find((item) => item?.args?.command === 'rg missing .');
89
- assert.equal(failed?.isError, false);
90
- assert.equal(failed?.exitErrorCount, 1);
91
- assert.equal(probe?.isError, false);
92
- assert.equal(probe?.exitErrorCount, 0);
93
- });
94
-
95
- test('task wait calls stay hidden when a session transcript is restored', () => {
96
- const messages = [
97
- {
98
- role: 'assistant',
99
- toolCalls: [
100
- { id: 'call_wait', name: 'task', arguments: { action: 'wait', task_id: 'task_shell_1' } },
101
- { id: 'call_read', name: 'task', arguments: { action: 'read', task_id: 'task_shell_1' } },
102
- ],
103
- },
104
- { role: 'tool', toolCallId: 'call_wait', content: 'status: running' },
105
- { role: 'tool', toolCallId: 'call_read', content: 'status: completed' },
106
- ];
107
-
108
- const items = restoreTranscriptItems(messages, { sessionId: 'sess_task_wait_restore' });
109
- assert.equal(items.some((item) => item?.kind === 'tool' && item?.args?.action === 'wait'), false);
110
- assert.equal(items.some((item) => item?.kind === 'tool' && item?.args?.action === 'read'), true);
111
- });