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,57 +0,0 @@
1
- // `*** Update File: X` + `*** Move to: Y` with no hunks is a pure move — the
2
- // V4A spelling of `git mv` — and its outcome is fully specified by the two
3
- // paths.
4
- import { test } from 'node:test';
5
- import assert from 'node:assert/strict';
6
- import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
7
- import { tmpdir } from 'node:os';
8
- import { join } from 'node:path';
9
-
10
- import { executePatchTool } from '../patch.mjs';
11
- import { closeNativePatchServerForTests } from './native-server.mjs';
12
-
13
- function makeDir() {
14
- return mkdtempSync(join(tmpdir(), 'mixdog-v4a-move-'));
15
- }
16
-
17
- test('a hunkless rename moves the file byte-identically', async (t) => {
18
- const dir = makeDir();
19
- t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
20
- const before = 'CPU_ONLY := 1\r\nBLAS := atlas\n';
21
- writeFileSync(join(dir, 'Makefile.config'), before);
22
- mkdirSync(join(dir, 'caffe'), { recursive: true });
23
-
24
- const result = String(await executePatchTool('apply_patch', {
25
- base_path: dir,
26
- patch: `*** Begin Patch
27
- *** Update File: Makefile.config
28
- *** Move to: caffe/Makefile.config
29
- *** End Patch
30
- `,
31
- }, dir, {}));
32
-
33
- assert.doesNotMatch(result, /no update hunks/);
34
- assert.doesNotMatch(result, /^Error/);
35
- assert.equal(existsSync(join(dir, 'Makefile.config')), false);
36
- assert.equal(readFileSync(join(dir, 'caffe', 'Makefile.config'), 'utf8'), before);
37
- });
38
-
39
- test('a move onto an existing file is still refused', async (t) => {
40
- const dir = makeDir();
41
- t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
42
- writeFileSync(join(dir, 'a.txt'), 'source\n');
43
- writeFileSync(join(dir, 'b.txt'), 'occupied\n');
44
-
45
- const result = String(await executePatchTool('apply_patch', {
46
- base_path: dir,
47
- patch: `*** Begin Patch
48
- *** Update File: a.txt
49
- *** Move to: b.txt
50
- *** End Patch
51
- `,
52
- }, dir, {}));
53
-
54
- assert.match(result, /destination already exists/);
55
- assert.equal(readFileSync(join(dir, 'a.txt'), 'utf8'), 'source\n');
56
- assert.equal(readFileSync(join(dir, 'b.txt'), 'utf8'), 'occupied\n');
57
- });
@@ -1,81 +0,0 @@
1
- // A whole-file rewrite written as "Delete File + Add File" for ONE path has a
2
- // single possible outcome, so it applies instead of being rejected as a
3
- // conflicting target. Genuinely ambiguous pairs keep rejecting.
4
- import { test } from 'node:test';
5
- import assert from 'node:assert/strict';
6
- import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
7
- import { tmpdir } from 'node:os';
8
- import { join } from 'node:path';
9
-
10
- import { executePatchTool } from '../patch.mjs';
11
- import { closeNativePatchServerForTests } from './native-server.mjs';
12
-
13
- function makeDir() {
14
- return mkdtempSync(join(tmpdir(), 'mixdog-v4a-coalesce-'));
15
- }
16
-
17
- test('Delete + Add on one existing path rewrites the file', async (t) => {
18
- const dir = makeDir();
19
- t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
20
- const file = join(dir, 'algo.py');
21
- writeFileSync(file, 'def map(grid):\n return grid\n');
22
-
23
- const result = String(await executePatchTool('apply_patch', {
24
- base_path: dir,
25
- patch: `*** Begin Patch
26
- *** Delete File: algo.py
27
- *** Add File: algo.py
28
- +def map(grid):
29
- + return [row[::-1] for row in grid]
30
- *** End Patch
31
- `,
32
- }, dir, {}));
33
-
34
- assert.doesNotMatch(result, /conflicting operations target/);
35
- assert.doesNotMatch(result, /^Error/);
36
- assert.equal(
37
- readFileSync(file, 'utf8'),
38
- 'def map(grid):\n return [row[::-1] for row in grid]\n',
39
- );
40
- });
41
-
42
- test('Delete + Add for a path that does not exist still creates the file', async (t) => {
43
- const dir = makeDir();
44
- t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
45
- const file = join(dir, 'fresh.txt');
46
-
47
- const result = String(await executePatchTool('apply_patch', {
48
- base_path: dir,
49
- patch: `*** Begin Patch
50
- *** Delete File: fresh.txt
51
- *** Add File: fresh.txt
52
- +created
53
- *** End Patch
54
- `,
55
- }, dir, {}));
56
-
57
- assert.doesNotMatch(result, /^Error/);
58
- assert.equal(readFileSync(file, 'utf8'), 'created\n');
59
- });
60
-
61
- test('Update + Delete on one path is still refused without touching the file', async (t) => {
62
- const dir = makeDir();
63
- t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
64
- const file = join(dir, 'target.txt');
65
- writeFileSync(file, 'aleph\nbravo\ndelta\n');
66
-
67
- const result = String(await executePatchTool('apply_patch', {
68
- base_path: dir,
69
- patch: `*** Begin Patch
70
- *** Update File: target.txt
71
- @@
72
- -bravo
73
- +temporary
74
- *** Delete File: target.txt
75
- *** End Patch
76
- `,
77
- }, dir, {}));
78
-
79
- assert.match(result, /conflicting operations target/);
80
- assert.equal(readFileSync(file, 'utf8'), 'aleph\nbravo\ndelta\n');
81
- });
@@ -1,52 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { createHash } from 'node:crypto';
3
- import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
4
- import { tmpdir } from 'node:os';
5
- import { join } from 'node:path';
6
- import test from 'node:test';
7
- import { ensureSpawnBinary, findCachedSpawnBinary } from './spawn-binary-fetcher.mjs';
8
-
9
- test('spawn cache accepts only a manifest-pinned binary', () => {
10
- const root = mkdtempSync(join(tmpdir(), 'mixdog-spawn-cache-'));
11
- const bytes = Buffer.from('verified-spawn-fixture');
12
- const version = '1.2.3';
13
- const pkey = `${process.platform}-${process.arch}`;
14
- const suffix = process.platform === 'win32' ? '.exe' : '';
15
- const manifest = {
16
- version,
17
- assets: {
18
- [pkey]: {
19
- url: `https://github.com/tribgames/mixdog/releases/download/spawn-v${version}/mixdog-spawn-${pkey}${suffix}`,
20
- sha256: createHash('sha256').update(bytes).digest('hex'),
21
- },
22
- },
23
- };
24
- try {
25
- const dir = join(root, 'spawn-bin');
26
- mkdirSync(dir, { recursive: true });
27
- writeFileSync(join(dir, `mixdog-spawn-${version}${suffix}`), bytes);
28
- assert.ok(findCachedSpawnBinary(root, { bundledManifest: manifest }));
29
- writeFileSync(join(dir, `mixdog-spawn-${version}${suffix}`), 'tampered');
30
- assert.equal(findCachedSpawnBinary(root, { bundledManifest: manifest }), null);
31
- } finally {
32
- rmSync(root, { recursive: true, force: true });
33
- }
34
- });
35
-
36
- test('spawn bootstrap has no local-build or environment fallback', async () => {
37
- const root = mkdtempSync(join(tmpdir(), 'mixdog-spawn-bootstrap-'));
38
- try {
39
- await assert.rejects(
40
- ensureSpawnBinary(root, {
41
- bundledManifest: {
42
- version: '0.1.0',
43
- _comment: 'bootstrap',
44
- assets: {},
45
- },
46
- }),
47
- /No local-build or Node shell fallback is permitted/,
48
- );
49
- } finally {
50
- rmSync(root, { recursive: true, force: true });
51
- }
52
- });
@@ -1,209 +0,0 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import {
4
- existsSync,
5
- mkdirSync,
6
- mkdtempSync,
7
- rmSync,
8
- utimesSync,
9
- writeFileSync,
10
- } from 'node:fs';
11
- import { tmpdir } from 'node:os';
12
- import { join } from 'node:path';
13
-
14
- const dataDir = mkdtempSync(join(tmpdir(), 'mixdog-attachments-'));
15
- process.env.MIXDOG_DATA_DIR = dataDir;
16
-
17
- const {
18
- attachmentStoreCacheStats,
19
- collectPromptAttachments,
20
- hydratePastedAttachments,
21
- materializePromptSubmission,
22
- preparePromptSubmissionForProvider,
23
- } = await import('./store.mjs');
24
- const {
25
- normalizeContentForAnthropic,
26
- normalizeContentForOpenAIResponses,
27
- sanitizeContentForStoredHistory,
28
- } = await import('../agent/orchestrator/providers/media-normalization.mjs');
29
- const {
30
- imageResizeCacheStats,
31
- openAIImagePatchCount,
32
- resizeImageBuffer,
33
- } = await import('../agent/orchestrator/tools/builtin/read-image-resize.mjs');
34
-
35
- function minimalPdf(text = 'Hello PDF') {
36
- const objects = [
37
- '<< /Type /Catalog /Pages 2 0 R >>',
38
- '<< /Type /Pages /Kids [3 0 R] /Count 1 >>',
39
- '<< /Type /Page /Parent 2 0 R /MediaBox [0 0 300 200] /Resources << /Font << /F1 5 0 R >> >> /Contents 4 0 R >>',
40
- `<< /Length ${text.length + 31} >>\nstream\nBT /F1 12 Tf 40 100 Td (${text}) Tj ET\nendstream`,
41
- '<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>',
42
- ];
43
- let body = '%PDF-1.4\n';
44
- const offsets = [0];
45
- objects.forEach((object, index) => {
46
- offsets.push(Buffer.byteLength(body, 'latin1'));
47
- body += `${index + 1} 0 obj\n${object}\nendobj\n`;
48
- });
49
- const xref = Buffer.byteLength(body, 'latin1');
50
- body += `xref\n0 ${objects.length + 1}\n0000000000 65535 f \n`;
51
- body += offsets.slice(1).map((offset) => `${String(offset).padStart(10, '0')} 00000 n \n`).join('');
52
- body += `trailer\n<< /Size ${objects.length + 1} /Root 1 0 R >>\nstartxref\n${xref}\n%%EOF\n`;
53
- return Buffer.from(body, 'latin1');
54
- }
55
-
56
- test('daemon intake stores one payload and keeps byte-free refs through history/provider lowering', () => {
57
- const imageData = Buffer.from('small-image').toString('base64');
58
- const pdfData = Buffer.from('%PDF-1.7\nsmall-pdf').toString('base64');
59
- const pastedText = 'large context '.repeat(100);
60
- const before = {
61
- prompt: [
62
- { type: 'text', text: 'Review [Pasted text #7 +100 lines]' },
63
- { type: 'image', data: imageData, mimeType: 'image/png' },
64
- { type: 'file', data: pdfData, mimeType: 'application/pdf', filename: 'notes.pdf' },
65
- ],
66
- options: {
67
- displayText: 'Review [Pasted text #7 +100 lines] [Image]',
68
- pastedImages: {
69
- 1: { id: 1, type: 'image', mediaType: 'image/png', filename: 'shot.png', sizeBytes: 11 },
70
- },
71
- pastedTexts: {
72
- 7: { id: 7, text: pastedText, source: 'paste' },
73
- },
74
- },
75
- };
76
-
77
- const intake = materializePromptSubmission(before.prompt, before.options);
78
- const encoded = JSON.stringify(intake);
79
- assert.doesNotMatch(encoded, new RegExp(imageData));
80
- assert.doesNotMatch(encoded, /small-pdf/);
81
- assert.doesNotMatch(encoded, /large context large context/);
82
- const imagePart = intake.prompt.find((part) => part.type === 'image');
83
- assert.match(imagePart.attachmentRef, /^[a-f0-9]{64}$/);
84
- assert.equal(intake.options.pastedImages[1].attachmentRef, imagePart.attachmentRef);
85
- assert.equal(intake.options.pastedTexts[7].text, undefined);
86
-
87
- const stored = sanitizeContentForStoredHistory(intake.prompt);
88
- assert.equal(stored, intake.prompt, 'byte-free attachment refs remain durable session content');
89
-
90
- const anthropic = normalizeContentForAnthropic(intake.prompt);
91
- assert.equal(anthropic.find((part) => part.type === 'text' && part.text === pastedText)?.text, pastedText);
92
- assert.equal(anthropic.find((part) => part.type === 'image')?.source.data, imageData);
93
- assert.equal(anthropic.find((part) => part.type === 'document')?.source.data, pdfData);
94
- const responses = normalizeContentForOpenAIResponses(intake.prompt);
95
- assert.equal(responses.find((part) => part.type === 'input_text' && part.text === pastedText)?.text, pastedText);
96
- assert.match(responses.find((part) => part.type === 'input_image')?.image_url, /^data:image\/png;base64,/);
97
- assert.match(responses.find((part) => part.type === 'input_file')?.file_data, /^data:application\/pdf;base64,/);
98
-
99
- const hydrated = hydratePastedAttachments(
100
- intake.options.pastedImages,
101
- intake.options.pastedTexts,
102
- );
103
- assert.equal(hydrated.pastedImages[1].content, imageData);
104
- assert.equal(hydrated.pastedTexts[7].text, pastedText);
105
- assert.ok(attachmentStoreCacheStats().bytes <= attachmentStoreCacheStats().maxBytes);
106
- });
107
-
108
- test('attachment reads reject content that no longer matches its sha256 reference', async () => {
109
- const stored = materializePromptSubmission([{
110
- type: 'file',
111
- data: Buffer.from('original attachment').toString('base64'),
112
- mimeType: 'application/octet-stream',
113
- }]).prompt[0];
114
- const blobPath = join(
115
- dataDir,
116
- 'prompt-attachments',
117
- 'sha256',
118
- stored.attachmentRef.slice(0, 2),
119
- stored.attachmentRef,
120
- );
121
- writeFileSync(blobPath, 'tampered attachment');
122
- const freshStore = await import(`./store.mjs?integrity=${Date.now()}`);
123
- assert.throws(
124
- () => freshStore.readAttachmentBuffer(stored),
125
- /integrity check failed/,
126
- );
127
- });
128
-
129
- test('image resize output is reused from the bounded hash LRU', async () => {
130
- const onePixelPng = Buffer.from(
131
- 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=',
132
- 'base64',
133
- );
134
- const before = imageResizeCacheStats();
135
- const first = await resizeImageBuffer(onePixelPng, 'png');
136
- assert.ok(first?.data, 'sharp is a required image backend');
137
- const second = await resizeImageBuffer(onePixelPng, 'png');
138
- assert.equal(second.data, first.data);
139
- const after = imageResizeCacheStats();
140
- assert.equal(after.hits, before.hits + 1);
141
- assert.ok(after.bytes <= after.maxBytes);
142
- });
143
-
144
- test('OpenAI image profile respects the 2048px and 1536-patch budget', async () => {
145
- const sharp = (await import('sharp')).default;
146
- const source = await sharp({
147
- create: { width: 1600, height: 1200, channels: 3, background: '#abcdef' },
148
- }).png().toBuffer();
149
- const anthropic = await resizeImageBuffer(source, 'png', { profile: 'anthropic' });
150
- const openai = await resizeImageBuffer(source, 'png', { profile: 'openai' });
151
- assert.equal(anthropic.dimensions.displayWidth, 1600);
152
- assert.ok(openAIImagePatchCount(
153
- openai.dimensions.displayWidth,
154
- openai.dimensions.displayHeight,
155
- ) <= 1536);
156
- });
157
-
158
- test('PDF intake keeps native documents and extracts page text for compat providers', async () => {
159
- const data = minimalPdf('Provider parity').toString('base64');
160
- const native = await preparePromptSubmissionForProvider(
161
- materializePromptSubmission([{ type: 'file', data, mimeType: 'application/pdf', filename: 'native.pdf' }]),
162
- 'anthropic',
163
- );
164
- assert.equal(native.prompt[0].type, 'file');
165
- assert.equal(native.prompt[0].pageCount, 1);
166
- const compat = await preparePromptSubmissionForProvider(
167
- materializePromptSubmission([{ type: 'file', data, mimeType: 'application/pdf', filename: 'compat.pdf' }]),
168
- 'xai',
169
- );
170
- assert.equal(compat.prompt[0].type, 'text');
171
- assert.match(normalizeContentForAnthropic(compat.prompt)[0].text, /Provider parity/);
172
- assert.doesNotMatch(JSON.stringify(compat), new RegExp(data.slice(0, 40)));
173
- });
174
-
175
- test('attachment GC preserves durable refs and the safety window while deleting stale orphans', async () => {
176
- const makeFile = (text) => materializePromptSubmission([{
177
- type: 'file',
178
- data: Buffer.from(text).toString('base64'),
179
- mimeType: 'application/octet-stream',
180
- }]).prompt[0];
181
- const referenced = makeFile('durably referenced attachment');
182
- const orphan = makeFile('stale orphan attachment');
183
- const fresh = makeFile('fresh orphan attachment');
184
- const blobPath = (part) => join(
185
- dataDir,
186
- 'prompt-attachments',
187
- 'sha256',
188
- part.attachmentRef.slice(0, 2),
189
- part.attachmentRef,
190
- );
191
- mkdirSync(join(dataDir, 'sessions'), { recursive: true });
192
- writeFileSync(
193
- join(dataDir, 'sessions', 'sess_attachment_gc.json'),
194
- JSON.stringify({ id: 'sess_attachment_gc', messages: [{ content: [referenced] }] }),
195
- );
196
- const old = new Date(Date.now() - 10_000);
197
- utimesSync(blobPath(referenced), old, old);
198
- utimesSync(blobPath(orphan), old, old);
199
-
200
- const result = await collectPromptAttachments({ now: Date.now(), minAgeMs: 1_000 });
201
- assert.equal(existsSync(blobPath(referenced)), true);
202
- assert.equal(existsSync(blobPath(fresh)), true);
203
- assert.equal(existsSync(blobPath(orphan)), false);
204
- assert.equal(result.deleted, 1);
205
- });
206
-
207
- test.after(() => {
208
- rmSync(dataDir, { recursive: true, force: true });
209
- });
@@ -1,17 +0,0 @@
1
- import assert from 'node:assert/strict'
2
- import { readFile } from 'node:fs/promises'
3
- import test from 'node:test'
4
-
5
- import { selectVoiceModelId } from './voice-runtime-fetcher.mjs'
6
-
7
- test('managed voice always uses the standard multilingual model', () => {
8
- assert.equal(selectVoiceModelId(), 'standard')
9
- assert.equal(selectVoiceModelId({ model: 'korean', language: 'ko' }), 'standard')
10
- })
11
-
12
- test('voice manifest contains no language-specific model', async () => {
13
- const manifestPath = new URL('../data/voice-runtime-manifest.json', import.meta.url)
14
- const manifest = JSON.parse(await readFile(manifestPath, 'utf8'))
15
- assert.deepEqual(Object.keys(manifest.models), ['standard'])
16
- assert.equal(manifest.models.standard.id, 'large-v3-turbo-q8_0')
17
- })
@@ -1,18 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
-
4
- import { buildHeadersSummary, contentDeliveryId } from "./deliveries.mjs";
5
-
6
- test("webhook claim identity is stable for signed content and ignores mutable headers", () => {
7
- const body = Buffer.from('{"event":"same"}');
8
- const first = contentDeliveryId(body);
9
- const replay = contentDeliveryId(Buffer.from(body));
10
-
11
- assert.equal(first, replay);
12
- assert.match(first, /^body-sha256-[a-f0-9]{64}$/);
13
- assert.notEqual(first, contentDeliveryId(Buffer.from('{"event":"different"}')));
14
- assert.equal(
15
- buildHeadersSummary({ "x-request-id": "attacker-selected" }).delivery_id,
16
- "attacker-selected",
17
- );
18
- });
@@ -1,68 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
-
4
- import {
5
- hookLegSocketOptions,
6
- MAX_TUNNEL_BODY_BYTES,
7
- normalizeHookRequestFrame,
8
- resolveHookRelayUrl,
9
- } from "./relay-tunnel.mjs";
10
-
11
- test("webhook relay requires encrypted remote transport", () => {
12
- assert.equal(resolveHookRelayUrl({ MIXDOG_RELAY_URL: "off" }), null);
13
- assert.equal(
14
- resolveHookRelayUrl({ MIXDOG_RELAY_URL: "ws://127.0.0.1:9800" }),
15
- "ws://127.0.0.1:9800/",
16
- );
17
- assert.throws(
18
- () => resolveHookRelayUrl({ MIXDOG_RELAY_URL: "ws://relay.example" }),
19
- /must use wss/,
20
- );
21
- assert.throws(
22
- () => resolveHookRelayUrl({ MIXDOG_RELAY_URL: "wss://token@relay.example" }),
23
- /must not contain credentials/,
24
- );
25
- });
26
-
27
- test("webhook relay credentials use Authorization instead of the URL", () => {
28
- const connection = hookLegSocketOptions("wss://relay.example", {
29
- deviceId: "device-id",
30
- deviceSecret: "device-secret-value",
31
- });
32
- const url = new URL(connection.url);
33
- assert.equal(url.pathname, "/hookleg");
34
- assert.equal(url.search, "");
35
- assert.equal(
36
- Buffer.from(connection.headers.Authorization.slice("Basic ".length), "base64").toString("utf8"),
37
- "device-id:device-secret-value",
38
- );
39
- });
40
-
41
- test("webhook relay frames are bounded and confined to POST webhook routes", () => {
42
- const frame = normalizeHookRequestFrame({
43
- type: "http",
44
- id: "request-id",
45
- method: "POST",
46
- path: "/webhook/github?source=test",
47
- headers: { "content-type": "application/json", host: "ignored.example" },
48
- body: Buffer.from("{}").toString("base64"),
49
- });
50
- assert.equal(frame.body.toString(), "{}");
51
- assert.equal(frame.headers.host, undefined);
52
- assert.throws(
53
- () => normalizeHookRequestFrame({ ...frame, type: "http", method: "GET", body: "" }),
54
- /method must be POST/,
55
- );
56
- assert.throws(
57
- () => normalizeHookRequestFrame({ ...frame, type: "http", path: "/", body: "" }),
58
- /invalid webhook relay path/,
59
- );
60
- assert.throws(
61
- () => normalizeHookRequestFrame({
62
- ...frame,
63
- type: "http",
64
- body: "A".repeat(Math.ceil(MAX_TUNNEL_BODY_BYTES / 3) * 4 + 4),
65
- }),
66
- /invalid webhook relay body/,
67
- );
68
- });
@@ -1,22 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { test } from 'node:test';
3
- import { codexImageRequestBody } from './codex-image.mjs';
4
-
5
- for (const model of ['gpt-5.6-sol', 'gpt-5.4-mini']) {
6
- test(`${model} forces the hosted image generation tool`, () => {
7
- const body = codexImageRequestBody({
8
- model,
9
- prompt: 'Draw a blue square.',
10
- options: { size: '1024x1024', quality: 'low' },
11
- });
12
-
13
- assert.equal(body.model, model);
14
- assert.deepEqual(body.tool_choice, { type: 'image_generation' });
15
- assert.deepEqual(body.tools, [{
16
- type: 'image_generation',
17
- size: '1024x1024',
18
- quality: 'low',
19
- }]);
20
- assert.equal(body.input[0].content.at(-1)?.text, 'Draw a blue square.');
21
- });
22
- }
@@ -1,52 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import test from 'node:test';
3
-
4
- import {
5
- decodeBase64Media,
6
- downloadGeminiMedia,
7
- downloadPublicMedia,
8
- geminiMediaDownloadUrl,
9
- } from './download.mjs';
10
-
11
- test('public media downloads reject private targets before network access', async () => {
12
- let called = false;
13
- await assert.rejects(
14
- downloadPublicMedia('http://127.0.0.1/private', {
15
- fetchImpl: async () => {
16
- called = true;
17
- return new Response('secret');
18
- },
19
- }),
20
- /private address/,
21
- );
22
- assert.equal(called, false);
23
- });
24
-
25
- test('Gemini media keeps API credentials on the trusted HTTPS host', async () => {
26
- assert.equal(
27
- geminiMediaDownloadUrl('https://generativelanguage.googleapis.com/v1beta/files/clip'),
28
- 'https://generativelanguage.googleapis.com/v1beta/files/clip?alt=media',
29
- );
30
- assert.throws(
31
- () => geminiMediaDownloadUrl('https://generativelanguage.googleapis.com.attacker.test/clip'),
32
- /untrusted/,
33
- );
34
- let receivedHeaders;
35
- const bytes = await downloadGeminiMedia(
36
- 'https://generativelanguage.googleapis.com/v1beta/files/clip',
37
- {
38
- key: 'test-key',
39
- fetchImpl: async (_url, options) => {
40
- receivedHeaders = options.headers;
41
- return new Response('video');
42
- },
43
- },
44
- );
45
- assert.equal(bytes.toString(), 'video');
46
- assert.equal(receivedHeaders['x-goog-api-key'], 'test-key');
47
- });
48
-
49
- test('inline media decoding enforces the common result limit', () => {
50
- assert.equal(decodeBase64Media(Buffer.from('image').toString('base64')).toString(), 'image');
51
- assert.throws(() => decodeBase64Media(''), /size limit/);
52
- });
@@ -1,99 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import {
3
- existsSync,
4
- mkdtempSync,
5
- rmSync,
6
- utimesSync,
7
- } from 'node:fs';
8
- import { tmpdir } from 'node:os';
9
- import { join } from 'node:path';
10
- import { test } from 'node:test';
11
-
12
- import {
13
- cacheRendition,
14
- createPriorityScheduler,
15
- pruneRenditionCache,
16
- videoPosterArguments,
17
- } from './renditions.mjs';
18
-
19
- test('video posters seek off frame zero and encode one JPEG without a second still pass', () => {
20
- const args = videoPosterArguments('clip.mp4', { maxEdge: 512 });
21
- assert.deepEqual(args.slice(args.indexOf('-ss'), args.indexOf('-ss') + 2), ['-ss', '0.12']);
22
- assert.equal(args[args.indexOf('-vcodec') + 1], 'mjpeg');
23
- assert.equal(args.includes('png'), false);
24
- });
25
-
26
- test('rendition scheduler bounds work and prioritizes visible requests over queued warmups', async () => {
27
- const schedule = createPriorityScheduler(2);
28
- const releases = [];
29
- const started = [];
30
- let active = 0;
31
- let peak = 0;
32
- const blocked = (name) => schedule(() => new Promise((resolve) => {
33
- started.push(name);
34
- active += 1;
35
- peak = Math.max(peak, active);
36
- releases.push(() => {
37
- active -= 1;
38
- resolve(name);
39
- });
40
- }), 'background');
41
- const first = blocked('background-a');
42
- const second = blocked('background-b');
43
- const third = blocked('background-c');
44
- const foreground = schedule(async () => {
45
- started.push('foreground');
46
- active += 1;
47
- peak = Math.max(peak, active);
48
- active -= 1;
49
- return 'foreground';
50
- });
51
- await new Promise((resolve) => setImmediate(resolve));
52
- assert.deepEqual(started, ['background-a', 'foreground'],
53
- 'one slot must stay available for a visible request');
54
- assert.equal(await foreground, 'foreground');
55
- releases.shift()();
56
- await new Promise((resolve) => setImmediate(resolve));
57
- assert.deepEqual(started, ['background-a', 'foreground', 'background-b']);
58
- releases.shift()();
59
- await new Promise((resolve) => setImmediate(resolve));
60
- assert.deepEqual(started, ['background-a', 'foreground', 'background-b', 'background-c']);
61
- releases.shift()();
62
- await Promise.all([first, second, third]);
63
- assert.equal(peak, 2);
64
- });
65
-
66
- test('rendition files reject oversized entries and obey a total disk budget', () => {
67
- const root = mkdtempSync(join(tmpdir(), 'mixdog-rendition-cache-'));
68
- try {
69
- const first = cacheRendition({
70
- id: 'first',
71
- variant: 'thumb',
72
- mime: 'image/jpeg',
73
- buffer: Buffer.alloc(10, 1),
74
- cacheDir: root,
75
- });
76
- const second = cacheRendition({
77
- id: 'second',
78
- variant: 'thumb',
79
- mime: 'image/jpeg',
80
- buffer: Buffer.alloc(10, 2),
81
- cacheDir: root,
82
- });
83
- assert.ok(first && second);
84
- utimesSync(first.path, new Date(1_000), new Date(1_000));
85
- const pruned = pruneRenditionCache(root, { maxBytes: 10 });
86
- assert.equal(pruned.bytes, 10);
87
- assert.equal(existsSync(first.path), false);
88
- assert.equal(existsSync(second.path), true);
89
- assert.equal(cacheRendition({
90
- id: 'oversized',
91
- variant: 'thumb',
92
- mime: 'image/jpeg',
93
- buffer: Buffer.alloc(4 * 1024 * 1024 + 1),
94
- cacheDir: root,
95
- }), null);
96
- } finally {
97
- rmSync(root, { recursive: true, force: true });
98
- }
99
- });