mixdog 1.2.5 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (493) hide show
  1. package/LICENSES/simple-icons-CC0-1.0.txt +30 -0
  2. package/NOTICE.md +19 -0
  3. package/package.json +4 -1
  4. package/scripts/check-model-recommendations.mjs +89 -0
  5. package/scripts/gate-local.mjs +7 -0
  6. package/scripts/lib/gate-scheduler.mjs +2 -2
  7. package/scripts/lib/isolated-test-env.mjs +16 -0
  8. package/scripts/lib/run-node-tests.mjs +5 -14
  9. package/scripts/provider-pingpong-live.mjs +9 -9
  10. package/src/agents/advisor/AGENT.md +4 -4
  11. package/src/agents/advisor/agent.json +1 -1
  12. package/src/agents/reviewer/AGENT.md +5 -4
  13. package/src/agents/reviewer/agent.json +1 -1
  14. package/src/defaults/shipped-history.json +17 -0
  15. package/src/defaults/skills/browser-use/SKILL.md +7 -1
  16. package/src/defaults/skills/computer-use/SKILL.md +3 -1
  17. package/src/defaults/skills/memory-management/SKILL.md +4 -1
  18. package/src/defaults/skills/setup/references/actions.md +11 -4
  19. package/src/defaults/skills/setup-guide/SKILL.md +175 -0
  20. package/src/defaults/skills/setup-guide/model-recommendations.json +333 -0
  21. package/src/defaults/skills/visualize/SKILL.md +3 -2
  22. package/src/lib/rules-builder.cjs +56 -7
  23. package/src/output-styles/common.md +22 -6
  24. package/src/output-styles/detailed.md +7 -5
  25. package/src/output-styles/minimal.md +7 -3
  26. package/src/output-styles/simple.md +2 -3
  27. package/src/rules/agent/AGENT.md +7 -1
  28. package/src/rules/agent-mode/AGENT_MODE.md +24 -0
  29. package/src/rules/agent-mode/MIXY.md +21 -0
  30. package/src/rules/agent-mode/ROUTINE.md +6 -0
  31. package/src/rules/lead/LEAD.md +9 -4
  32. package/src/rules/shared/10-tool-workflow.md +2 -1
  33. package/src/rules/shared/60-verification.md +4 -5
  34. package/src/rules/shared/70-delivery.md +3 -0
  35. package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +2 -1
  36. package/src/runtime/agent/orchestrator/agent-runtime/room-supervisor-completion.mjs +86 -0
  37. package/src/runtime/agent/orchestrator/config.mjs +6 -0
  38. package/src/runtime/agent/orchestrator/context/deferred-tools.mjs +77 -14
  39. package/src/runtime/agent/orchestrator/context/role-instructions.mjs +182 -13
  40. package/src/runtime/agent/orchestrator/context/skill-catalog.mjs +5 -3
  41. package/src/runtime/agent/orchestrator/internal-agents.mjs +10 -0
  42. package/src/runtime/agent/orchestrator/mcp/agent-connectors.mjs +215 -0
  43. package/src/runtime/agent/orchestrator/mcp/child-tree.mjs +58 -64
  44. package/src/runtime/agent/orchestrator/mcp/client-transport.mjs +10 -1
  45. package/src/runtime/agent/orchestrator/mcp/client.mjs +122 -15
  46. package/src/runtime/agent/orchestrator/mcp/oauth-account.mjs +97 -0
  47. package/src/runtime/agent/orchestrator/mcp/oauth-callback.mjs +2 -3
  48. package/src/runtime/agent/orchestrator/mcp/oauth-client.mjs +49 -0
  49. package/src/runtime/agent/orchestrator/mcp/oauth-credentials.mjs +59 -9
  50. package/src/runtime/agent/orchestrator/mcp/oauth-login.mjs +32 -7
  51. package/src/runtime/agent/orchestrator/mcp/oauth-provider.mjs +45 -6
  52. package/src/runtime/agent/orchestrator/mcp/oauth.mjs +195 -6
  53. package/src/runtime/agent/orchestrator/mcp/server-connectors.mjs +17 -0
  54. package/src/runtime/agent/orchestrator/providers/account-pool.mjs +9 -2
  55. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +1 -1
  56. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-credentials.mjs +41 -19
  57. package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +3 -2
  58. package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events/content-block-start.mjs +4 -1
  59. package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events.mjs +2 -0
  60. package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn.mjs +3 -0
  61. package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +2 -1
  62. package/src/runtime/agent/orchestrator/providers/anthropic.mjs +3 -1
  63. package/src/runtime/agent/orchestrator/providers/antigravity-oauth-login.mjs +11 -5
  64. package/src/runtime/agent/orchestrator/providers/antigravity-oauth-tokens.mjs +4 -0
  65. package/src/runtime/agent/orchestrator/providers/catalog-deadline.mjs +163 -0
  66. package/src/runtime/agent/orchestrator/providers/catalog-failures.mjs +34 -0
  67. package/src/runtime/agent/orchestrator/providers/cursor-client-version.mjs +1 -1
  68. package/src/runtime/agent/orchestrator/providers/grok-oauth-login.mjs +38 -14
  69. package/src/runtime/agent/orchestrator/providers/lib/oauth-page.mjs +100 -26
  70. package/src/runtime/agent/orchestrator/providers/lib/send-callbacks.mjs +24 -0
  71. package/src/runtime/agent/orchestrator/providers/oauth-credential-probes.mjs +13 -0
  72. package/src/runtime/agent/orchestrator/providers/oauth-usage.mjs +2 -1
  73. package/src/runtime/agent/orchestrator/providers/openai-compat-chat-send.mjs +1 -0
  74. package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/chunk-events.mjs +4 -0
  75. package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-state.mjs +3 -1
  76. package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream.mjs +2 -0
  77. package/src/runtime/agent/orchestrator/providers/openai-compat-models.mjs +49 -4
  78. package/src/runtime/agent/orchestrator/providers/openai-compat-presets.mjs +0 -7
  79. package/src/runtime/agent/orchestrator/providers/openai-compat-responses-events.mjs +7 -1
  80. package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +1 -0
  81. package/src/runtime/agent/orchestrator/providers/openai-compat-stream.mjs +2 -0
  82. package/src/runtime/agent/orchestrator/providers/openai-compat-xai-send.mjs +1 -0
  83. package/src/runtime/agent/orchestrator/providers/openai-error-contract.mjs +17 -12
  84. package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events.mjs +5 -1
  85. package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state.mjs +11 -2
  86. package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +1 -0
  87. package/src/runtime/agent/orchestrator/providers/openai-oauth-login.mjs +45 -16
  88. package/src/runtime/agent/orchestrator/providers/openai-oauth-tokens.mjs +10 -0
  89. package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +1 -0
  90. package/src/runtime/agent/orchestrator/providers/openai-ws-connect.mjs +196 -0
  91. package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +74 -9
  92. package/src/runtime/agent/orchestrator/providers/openai-ws-stream/event-switch.mjs +14 -1
  93. package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +2 -0
  94. package/src/runtime/agent/orchestrator/providers/opencode-go-oauth-login.mjs +194 -0
  95. package/src/runtime/agent/orchestrator/providers/opencode-go-oauth-tokens.mjs +353 -0
  96. package/src/runtime/agent/orchestrator/providers/opencode-go-oauth.mjs +293 -0
  97. package/src/runtime/agent/orchestrator/providers/opencode-go-usage.mjs +33 -100
  98. package/src/runtime/agent/orchestrator/providers/opencode-go.mjs +23 -14
  99. package/src/runtime/agent/orchestrator/providers/registry.mjs +41 -27
  100. package/src/runtime/agent/orchestrator/runtime-core/ask-user-tool-defs.mjs +98 -4
  101. package/src/runtime/agent/orchestrator/runtime-core/context-status-shape.mjs +4 -0
  102. package/src/runtime/agent/orchestrator/runtime-core/extension-scopes.mjs +6 -4
  103. package/src/runtime/agent/orchestrator/runtime-core/orchestration.mjs +15 -8
  104. package/src/runtime/agent/orchestrator/runtime-core/plugin-mcp.mjs +1 -0
  105. package/src/runtime/agent/orchestrator/runtime-core/tool-bridge.mjs +12 -6
  106. package/src/runtime/agent/orchestrator/runtime-core/tool-catalog.mjs +32 -5
  107. package/src/runtime/agent/orchestrator/runtime-core/tool-defs.mjs +10 -4
  108. package/src/runtime/agent/orchestrator/runtime-core/workflow/agents.mjs +4 -1
  109. package/src/runtime/agent/orchestrator/runtime-core/workflow/context.mjs +50 -20
  110. package/src/runtime/agent/orchestrator/runtime-core/workflow-ids.mjs +2 -0
  111. package/src/runtime/agent/orchestrator/session/agent-home.d.mts +4 -0
  112. package/src/runtime/agent/orchestrator/session/agent-home.mjs +33 -0
  113. package/src/runtime/agent/orchestrator/session/agent-mode.mjs +62 -0
  114. package/src/runtime/agent/orchestrator/session/agent-pool-progress.mjs +15 -3
  115. package/src/runtime/agent/orchestrator/session/agent-room-supervisor.d.mts +31 -0
  116. package/src/runtime/agent/orchestrator/session/agent-room-supervisor.mjs +241 -0
  117. package/src/runtime/agent/orchestrator/session/agent-room.d.mts +162 -0
  118. package/src/runtime/agent/orchestrator/session/agent-room.mjs +641 -0
  119. package/src/runtime/agent/orchestrator/session/catalog-db/schema.mjs +7 -1
  120. package/src/runtime/agent/orchestrator/session/compact/execution-tail.mjs +74 -13
  121. package/src/runtime/agent/orchestrator/session/compact/forked-summary.mjs +102 -0
  122. package/src/runtime/agent/orchestrator/session/compact/runner.mjs +8 -2
  123. package/src/runtime/agent/orchestrator/session/compact/summary.mjs +16 -0
  124. package/src/runtime/agent/orchestrator/session/compact/user-message-kind.mjs +2 -0
  125. package/src/runtime/agent/orchestrator/session/compaction-archive-capture.mjs +6 -2
  126. package/src/runtime/agent/orchestrator/session/human-gate/gate.mjs +165 -0
  127. package/src/runtime/agent/orchestrator/session/human-gate/held-message.mjs +95 -0
  128. package/src/runtime/agent/orchestrator/session/human-gate/outbound-policy.mjs +221 -0
  129. package/src/runtime/agent/orchestrator/session/human-gate/requests.mjs +195 -0
  130. package/src/runtime/agent/orchestrator/session/human-gate/store.mjs +167 -0
  131. package/src/runtime/agent/orchestrator/session/lifecycle-scan.mjs +9 -0
  132. package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +3 -1
  133. package/src/runtime/agent/orchestrator/session/loop/fresh-context.mjs +39 -2
  134. package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +10 -0
  135. package/src/runtime/agent/orchestrator/session/loop/send-phase.mjs +16 -1
  136. package/src/runtime/agent/orchestrator/session/loop/tool-exec/before-hook.mjs +82 -33
  137. package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +11 -4
  138. package/src/runtime/agent/orchestrator/session/loop/tool-exposure-migration.mjs +5 -4
  139. package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +13 -3
  140. package/src/runtime/agent/orchestrator/session/loop/usage.mjs +7 -0
  141. package/src/runtime/agent/orchestrator/session/manager/ask-turn-execute.mjs +1 -0
  142. package/src/runtime/agent/orchestrator/session/manager/ask-turn-loop-options.mjs +6 -1
  143. package/src/runtime/agent/orchestrator/session/manager/ask-turn-prepare.mjs +6 -0
  144. package/src/runtime/agent/orchestrator/session/manager/ask-turn-settle.mjs +2 -0
  145. package/src/runtime/agent/orchestrator/session/manager/ask-turn-steering-drain.mjs +13 -5
  146. package/src/runtime/agent/orchestrator/session/manager/pending-lifecycle-epoch.mjs +0 -8
  147. package/src/runtime/agent/orchestrator/session/manager/pending-message-entry.mjs +10 -7
  148. package/src/runtime/agent/orchestrator/session/manager/pending-messages.mjs +62 -22
  149. package/src/runtime/agent/orchestrator/session/manager/prompt-utils.mjs +44 -16
  150. package/src/runtime/agent/orchestrator/session/manager/rules-cache.mjs +22 -5
  151. package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +23 -1
  152. package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +81 -34
  153. package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +39 -4
  154. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +27 -5
  155. package/src/runtime/agent/orchestrator/session/manager/session-prompt-composition.mjs +55 -8
  156. package/src/runtime/agent/orchestrator/session/manager/session-record.mjs +16 -0
  157. package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +3 -2
  158. package/src/runtime/agent/orchestrator/session/manager/usage-metrics.mjs +6 -0
  159. package/src/runtime/agent/orchestrator/session/manager/workflow-switch-notice.mjs +58 -0
  160. package/src/runtime/agent/orchestrator/session/manager.mjs +2 -2
  161. package/src/runtime/agent/orchestrator/session/mixy-name.mjs +24 -0
  162. package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +32 -5
  163. package/src/runtime/agent/orchestrator/session/request-fork.mjs +47 -0
  164. package/src/runtime/agent/orchestrator/session/routine-result.d.mts +70 -0
  165. package/src/runtime/agent/orchestrator/session/routine-result.mjs +277 -0
  166. package/src/runtime/agent/orchestrator/session/side-question-store.mjs +16 -1
  167. package/src/runtime/agent/orchestrator/session/side-question.mjs +5 -43
  168. package/src/runtime/agent/orchestrator/session/store/fs-probe.mjs +10 -0
  169. package/src/runtime/agent/orchestrator/session/store/lifecycle-barriers.mjs +73 -6
  170. package/src/runtime/agent/orchestrator/session/store/load-session.mjs +40 -0
  171. package/src/runtime/agent/orchestrator/session/store/save-fault.mjs +15 -0
  172. package/src/runtime/agent/orchestrator/session/store/session-paths.mjs +12 -0
  173. package/src/runtime/agent/orchestrator/session/store/sweep/sweep-row.mjs +8 -0
  174. package/src/runtime/agent/orchestrator/session/store-agent-worker-header.mjs +36 -0
  175. package/src/runtime/agent/orchestrator/session/store-agent-worker-rows.mjs +258 -43
  176. package/src/runtime/agent/orchestrator/session/store-record-strict-scan.mjs +325 -0
  177. package/src/runtime/agent/orchestrator/session/store-summary-catalog.mjs +84 -21
  178. package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +44 -12
  179. package/src/runtime/agent/orchestrator/session/store-summary-last-message.mjs +46 -0
  180. package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +46 -30
  181. package/src/runtime/agent/orchestrator/session/store-summary-visibility.mjs +0 -4
  182. package/src/runtime/agent/orchestrator/session/store-transcript-cache.mjs +144 -45
  183. package/src/runtime/agent/orchestrator/session/store-transcript-projection.mjs +32 -13
  184. package/src/runtime/agent/orchestrator/session/store-transcript-worker.mjs +364 -38
  185. package/src/runtime/agent/orchestrator/session/store.mjs +9 -2
  186. package/src/runtime/agent/orchestrator/session/task-wait-control.mjs +43 -12
  187. package/src/runtime/agent/orchestrator/session/tool-result-offload.mjs +23 -6
  188. package/src/runtime/agent/orchestrator/session/transcript-restore/restore.mjs +44 -1
  189. package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +12 -6
  190. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/backgrounded-result.mjs +13 -7
  191. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/bashism-rewrite.mjs +1 -1
  192. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/benign-exit.mjs +7 -1
  193. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/completed-result.mjs +40 -7
  194. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/deadline-plan.mjs +37 -34
  195. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/inline-hoist.mjs +1 -1
  196. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/spawn-env.mjs +0 -4
  197. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +6 -0
  198. package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +29 -27
  199. package/src/runtime/agent/orchestrator/tools/builtin/external-tool-adapters.mjs +1 -1
  200. package/src/runtime/agent/orchestrator/tools/builtin/find-files-tool.mjs +28 -11
  201. package/src/runtime/agent/orchestrator/tools/builtin/git-command-policy.mjs +12 -3
  202. package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +203 -101
  203. package/src/runtime/agent/orchestrator/tools/builtin/git-repo-rw-lock.mjs +90 -41
  204. package/src/runtime/agent/orchestrator/tools/builtin/lib/list-helpers.mjs +17 -1
  205. package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-delivery.mjs +199 -0
  206. package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.mjs +12 -0
  207. package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-task-output.mjs +165 -39
  208. package/src/runtime/agent/orchestrator/tools/builtin/list-tool.mjs +25 -13
  209. package/src/runtime/agent/orchestrator/tools/builtin/native-search-client.mjs +113 -5
  210. package/src/runtime/agent/orchestrator/tools/builtin/read-batch.mjs +7 -6
  211. package/src/runtime/agent/orchestrator/tools/builtin/read-formatting.mjs +19 -4
  212. package/src/runtime/agent/orchestrator/tools/builtin/read-line-collector.mjs +5 -3
  213. package/src/runtime/agent/orchestrator/tools/builtin/read-single-render.mjs +25 -7
  214. package/src/runtime/agent/orchestrator/tools/builtin/read-special-files.mjs +2 -1
  215. package/src/runtime/agent/orchestrator/tools/builtin/read-tool/batch-render.mjs +3 -1
  216. package/src/runtime/agent/orchestrator/tools/builtin/search-glob-tool.mjs +12 -5
  217. package/src/runtime/agent/orchestrator/tools/builtin/search-grep-tool.mjs +61 -22
  218. package/src/runtime/agent/orchestrator/tools/builtin/search-path-diagnostics.mjs +32 -8
  219. package/src/runtime/agent/orchestrator/tools/builtin/shell-analysis.mjs +193 -19
  220. package/src/runtime/agent/orchestrator/tools/builtin/shell-direct-exe.mjs +57 -7
  221. package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +123 -32
  222. package/src/runtime/agent/orchestrator/tools/builtin/shell-lossless-compact.mjs +26 -1
  223. package/src/runtime/agent/orchestrator/tools/builtin/shell-output.mjs +13 -28
  224. package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +90 -11
  225. package/src/runtime/agent/orchestrator/tools/builtin/wait-budgets.mjs +23 -0
  226. package/src/runtime/agent/orchestrator/tools/builtin.mjs +54 -10
  227. package/src/runtime/agent/orchestrator/tools/code-graph/build.mjs +22 -28
  228. package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +11 -7
  229. package/src/runtime/agent/orchestrator/tools/destructive-warning.mjs +126 -9
  230. package/src/runtime/agent/orchestrator/tools/graph-manifest.json +13 -13
  231. package/src/runtime/agent/orchestrator/tools/lib/owned-shell-trees.mjs +15 -6
  232. package/src/runtime/agent/orchestrator/tools/lib/shell-descendants.mjs +64 -2
  233. package/src/runtime/agent/orchestrator/tools/lib/shell-run-background/promote-job.mjs +10 -2
  234. package/src/runtime/agent/orchestrator/tools/lib/shell-run-background/promotion-results.mjs +13 -3
  235. package/src/runtime/agent/orchestrator/tools/lib/shell-run-settle.mjs +8 -0
  236. package/src/runtime/agent/orchestrator/tools/lib/shell-run-state.mjs +6 -1
  237. package/src/runtime/agent/orchestrator/tools/patch/v4a-convert.mjs +1 -1
  238. package/src/runtime/agent/orchestrator/tools/shell-command.mjs +104 -55
  239. package/src/runtime/agent/orchestrator/tools/shell-policy.mjs +7 -2
  240. package/src/runtime/agent/orchestrator/tools/shell-powershell.mjs +39 -23
  241. package/src/runtime/agent/orchestrator/tools/shell-snapshot.mjs +6 -2
  242. package/src/runtime/agent/orchestrator/tools/spawn-manifest.json +13 -13
  243. package/src/runtime/attachments/office-extract.mjs +11 -9
  244. package/src/runtime/browser-bridge/client.mjs +24 -0
  245. package/src/runtime/channels/lib/scheduler.mjs +40 -12
  246. package/src/runtime/channels/lib/schedules-db.mjs +71 -12
  247. package/src/runtime/channels/lib/webhook/session-dispatch.mjs +36 -16
  248. package/src/runtime/channels/lib/webhook.mjs +0 -1
  249. package/src/runtime/channels/lib/webhooks-db.mjs +100 -10
  250. package/src/runtime/channels/lib/worker-main.mjs +17 -20
  251. package/src/runtime/computer-bridge/client.mjs +28 -1
  252. package/src/runtime/connectors/gmail-app-password.mjs +690 -0
  253. package/src/runtime/connectors/google-mcp.mjs +446 -0
  254. package/src/runtime/memory/lib/core-memory-access.mjs +69 -0
  255. package/src/runtime/memory/lib/core-memory-file.mjs +16 -8
  256. package/src/runtime/memory/lib/core-memory-index.mjs +15 -9
  257. package/src/runtime/memory/lib/core-memory-management.mjs +10 -4
  258. package/src/runtime/memory/lib/core-memory-store.mjs +53 -30
  259. package/src/runtime/memory/lib/core-memory-uniqueness.mjs +10 -6
  260. package/src/runtime/memory/lib/embedding-tokenizer.mjs +32 -18
  261. package/src/runtime/memory/lib/http-router/session-routes.mjs +3 -2
  262. package/src/runtime/memory/lib/memory-action-handlers/core-actions.mjs +44 -14
  263. package/src/runtime/memory/lib/memory-schema/core-and-meta.mjs +11 -0
  264. package/src/runtime/memory/lib/memory.mjs +7 -1
  265. package/src/runtime/memory/lib/query-core-recall.mjs +9 -1
  266. package/src/runtime/memory/lib/query-hybrid-search.mjs +2 -0
  267. package/src/runtime/memory/lib/runtime-fetcher.mjs +1 -1
  268. package/src/runtime/memory/lib/tool-call-handler.mjs +9 -5
  269. package/src/runtime/memory/tool-defs.mjs +5 -0
  270. package/src/runtime/office/authoring/pptx-script-normalize.mjs +11 -8
  271. package/src/runtime/office/core/tabular.mjs +1 -1
  272. package/src/runtime/office/design/library/design-template-inspect.mjs +7 -4
  273. package/src/runtime/office/portable/docx-formatting.mjs +1 -1
  274. package/src/runtime/office/portable/docx-runs.mjs +1 -1
  275. package/src/runtime/office/portable/docx-tracked-edits.mjs +2 -2
  276. package/src/runtime/office/portable/portable-docx-edits.mjs +11 -10
  277. package/src/runtime/office/portable/portable-docx-operations.mjs +21 -17
  278. package/src/runtime/office/portable/portable-docx-parts.mjs +15 -9
  279. package/src/runtime/office/portable/portable-docx-styles.mjs +4 -1
  280. package/src/runtime/office/portable/portable-docx-xml.mjs +9 -9
  281. package/src/runtime/office/portable/portable-opc.mjs +27 -13
  282. package/src/runtime/office/portable/portable-pivot.mjs +3 -3
  283. package/src/runtime/office/portable/portable-pptx-chart.mjs +3 -3
  284. package/src/runtime/office/portable/portable-pptx-charts.mjs +24 -18
  285. package/src/runtime/office/portable/portable-pptx-core.mjs +5 -5
  286. package/src/runtime/office/portable/portable-pptx-deck.mjs +8 -4
  287. package/src/runtime/office/portable/portable-pptx-package.mjs +7 -4
  288. package/src/runtime/office/portable/portable-pptx-shapes.mjs +18 -9
  289. package/src/runtime/office/portable/portable-sheet-parts.mjs +9 -3
  290. package/src/runtime/office/portable/portable-sheet-xml.mjs +5 -5
  291. package/src/runtime/office/portable/portable-xlsx-charts.mjs +4 -1
  292. package/src/runtime/office/portable/portable-xlsx-drawings.mjs +10 -6
  293. package/src/runtime/office/portable/portable-xlsx-operations.mjs +8 -5
  294. package/src/runtime/office/portable/portable-xlsx-pivot-ops.mjs +1 -1
  295. package/src/runtime/office/portable/portable-xlsx-reference-shift.mjs +11 -7
  296. package/src/runtime/office/portable/portable-xlsx-sheet-edits.mjs +6 -3
  297. package/src/runtime/office/portable/portable-xml.mjs +1 -1
  298. package/src/runtime/shared/agent-avatar-sprites.mjs +445 -0
  299. package/src/runtime/shared/agent-avatar.d.mts +64 -0
  300. package/src/runtime/shared/agent-avatar.mjs +320 -0
  301. package/src/runtime/shared/agent-route-config.d.mts +3 -0
  302. package/src/runtime/shared/agent-route-config.mjs +16 -0
  303. package/src/runtime/shared/atomic-file.mjs +36 -14
  304. package/src/runtime/shared/background-tasks.mjs +60 -20
  305. package/src/runtime/shared/child-spawn-gate.mjs +26 -16
  306. package/src/runtime/shared/config.mjs +8 -11
  307. package/src/runtime/shared/connector-accounts.mjs +15 -0
  308. package/src/runtime/shared/connector-catalog.d.mts +52 -0
  309. package/src/runtime/shared/connector-catalog.mjs +230 -0
  310. package/src/runtime/shared/connector-triggers.d.mts +3 -0
  311. package/src/runtime/shared/connector-triggers.mjs +43 -0
  312. package/src/runtime/shared/file-lock.mjs +7 -1
  313. package/src/runtime/shared/file-permissions-worker.mjs +38 -0
  314. package/src/runtime/shared/file-permissions.d.mts +19 -4
  315. package/src/runtime/shared/file-permissions.mjs +310 -4
  316. package/src/runtime/shared/git-runner-worker.mjs +6 -78
  317. package/src/runtime/shared/google-oauth-client.mjs +24 -0
  318. package/src/runtime/shared/held-request-host.d.mts +12 -0
  319. package/src/runtime/shared/held-request-host.mjs +71 -0
  320. package/src/runtime/shared/llm/http-agent.mjs +7 -3
  321. package/src/runtime/shared/llm/provider-catalog-registry.mjs +10 -0
  322. package/src/runtime/shared/llm/usage-accounting.mjs +2 -0
  323. package/src/runtime/shared/llm/usage-ledger-import.mjs +32 -3
  324. package/src/runtime/shared/llm/usage-ledger-rollup.mjs +12 -5
  325. package/src/runtime/shared/llm/usage-ledger-worker.mjs +1 -1
  326. package/src/runtime/shared/llm/usage-ledger.mjs +20 -5
  327. package/src/runtime/shared/memory-snapshot.mjs +5 -1
  328. package/src/runtime/shared/notify-trace.mjs +8 -1
  329. package/src/runtime/shared/plain-preview.d.mts +1 -0
  330. package/src/runtime/shared/plain-preview.mjs +28 -0
  331. package/src/runtime/shared/pristine-execution-contract.json +5 -1
  332. package/src/runtime/shared/process-runner-worker.mjs +7 -0
  333. package/src/runtime/shared/process-runner.mjs +38 -0
  334. package/src/runtime/shared/provider-accounts.mjs +2 -1
  335. package/src/runtime/shared/provider-api-key.mjs +0 -1
  336. package/src/runtime/shared/read-row-numbers.mjs +1 -1
  337. package/src/runtime/shared/resource-admission.mjs +60 -18
  338. package/src/runtime/shared/routine-limits.d.mts +11 -0
  339. package/src/runtime/shared/routine-limits.mjs +21 -0
  340. package/src/runtime/shared/routine-trigger.d.mts +10 -0
  341. package/src/runtime/shared/routine-trigger.mjs +44 -0
  342. package/src/runtime/shared/run-child.mjs +84 -0
  343. package/src/runtime/shared/schedule-model-ref.mjs +9 -10
  344. package/src/runtime/shared/session-activity-signal.mjs +23 -0
  345. package/src/runtime/shared/shell-output-summary.mjs +23 -0
  346. package/src/runtime/shared/singleton-owner.mjs +126 -42
  347. package/src/runtime/shared/slow-span.mjs +4 -12
  348. package/src/runtime/shared/statusline/statusline-segments.mjs +13 -1
  349. package/src/runtime/shared/tool-output-limit.mjs +4 -2
  350. package/src/runtime/shared/tool-output-marker.mjs +58 -0
  351. package/src/runtime/shared/transcript-metadata.mjs +10 -0
  352. package/src/runtime/shared/turn-changes.mjs +0 -8
  353. package/src/runtime/shared/usage-readout-totals.mjs +56 -0
  354. package/src/runtime/shared/user-data-guard.mjs +131 -34
  355. package/src/runtime/shared/worktrees/activity-gate.mjs +33 -8
  356. package/src/runtime/shared/worktrees/git-head.mjs +20 -2
  357. package/src/runtime/shared/worktrees/lock.mjs +3 -2
  358. package/src/runtime/terminal-bridge/tool-defs.mjs +1 -1
  359. package/src/runtime/tidy/runners/biome.mjs +3 -1
  360. package/src/runtime/tidy/shadow.mjs +2 -1
  361. package/src/runtime/web-search/index.mjs +5 -7
  362. package/src/runtime/web-search/lib/formatter.mjs +42 -6
  363. package/src/runtime/web-search/tool-defs.mjs +6 -1
  364. package/src/session-runtime/agent-home-delivery.mjs +459 -0
  365. package/src/session-runtime/agent-profile-changes.mjs +21 -0
  366. package/src/session-runtime/agent-room-delivery.mjs +92 -0
  367. package/src/session-runtime/agent-task-sessions.mjs +200 -0
  368. package/src/session-runtime/boot/apis.mjs +50 -18
  369. package/src/session-runtime/boot/facade.mjs +5 -8
  370. package/src/session-runtime/boot/infrastructure.mjs +28 -17
  371. package/src/session-runtime/boot/tools.mjs +3 -0
  372. package/src/session-runtime/channel-config-api.mjs +53 -5
  373. package/src/session-runtime/cwd-plugins/core-memory-context.mjs +36 -20
  374. package/src/session-runtime/cwd-plugins/plugin-status.mjs +6 -1
  375. package/src/session-runtime/held-requests.mjs +228 -0
  376. package/src/session-runtime/internal-tool-executor/ask-user-tool.mjs +121 -0
  377. package/src/session-runtime/internal-tool-executor/feature-tools.mjs +5 -1
  378. package/src/session-runtime/internal-tool-executor/knowledge-tools.mjs +31 -2
  379. package/src/session-runtime/internal-tool-executor/workspace-tools.mjs +31 -2
  380. package/src/session-runtime/internal-tool-executor.mjs +2 -0
  381. package/src/session-runtime/lifecycle/session-catalog.mjs +9 -0
  382. package/src/session-runtime/lifecycle/session-switch/context-switch.mjs +4 -3
  383. package/src/session-runtime/lifecycle/session-switch/resume.mjs +11 -4
  384. package/src/session-runtime/lifecycle/session-switch/session-delete.mjs +3 -3
  385. package/src/session-runtime/lifecycle/shared.mjs +25 -2
  386. package/src/session-runtime/lifecycle/teardown/session-close.mjs +2 -0
  387. package/src/session-runtime/lifecycle/teardown.mjs +5 -2
  388. package/src/session-runtime/lifecycle-api.mjs +3 -1
  389. package/src/session-runtime/mcp-glue/server-catalog.mjs +8 -0
  390. package/src/session-runtime/mcp-glue/server-input.mjs +3 -0
  391. package/src/session-runtime/mcp-oauth-login.mjs +112 -15
  392. package/src/session-runtime/model-route/set-route.mjs +14 -3
  393. package/src/session-runtime/owned-automation-run.mjs +229 -0
  394. package/src/session-runtime/provider-auth/login.mjs +10 -6
  395. package/src/session-runtime/provider-auth/setup.mjs +19 -2
  396. package/src/session-runtime/provider-catalog-cache.mjs +101 -25
  397. package/src/session-runtime/provider-models/catalog-load.mjs +14 -3
  398. package/src/session-runtime/provider-models/row-hydration.mjs +4 -0
  399. package/src/session-runtime/provider-models.mjs +76 -10
  400. package/src/session-runtime/provider-readiness.mjs +4 -0
  401. package/src/session-runtime/resource-api.mjs +5 -0
  402. package/src/session-runtime/resource-mcp-api.mjs +107 -13
  403. package/src/session-runtime/resource-skills-api.mjs +12 -0
  404. package/src/session-runtime/room-member-gate.mjs +48 -0
  405. package/src/session-runtime/routine-home-turn.mjs +156 -0
  406. package/src/session-runtime/routine-owner.mjs +48 -0
  407. package/src/session-runtime/schedule-session-run.mjs +30 -64
  408. package/src/session-runtime/services/agent-tool/close-flow.mjs +2 -1
  409. package/src/session-runtime/services/agent-tool/helpers.mjs +10 -0
  410. package/src/session-runtime/services/agent-tool/job-views/agent-list.mjs +10 -2
  411. package/src/session-runtime/services/agent-tool/job-views/session-progress.mjs +13 -4
  412. package/src/session-runtime/services/agent-tool/notify.mjs +15 -4
  413. package/src/session-runtime/services/agent-tool/restart-notify.mjs +134 -0
  414. package/src/session-runtime/services/agent-tool/send-flow.mjs +24 -1
  415. package/src/session-runtime/services/agent-tool/spawn-flow/deferred-spawn.mjs +2 -1
  416. package/src/session-runtime/services/agent-tool/spawn-flow/job-start.mjs +4 -3
  417. package/src/session-runtime/services/agent-tool/spawn-flow/spawn-plan.mjs +19 -4
  418. package/src/session-runtime/services/agent-tool/spawn-flow/spawn-prep.mjs +2 -0
  419. package/src/session-runtime/services/agent-tool/spawn-flow/spawn-run.mjs +5 -1
  420. package/src/session-runtime/services/agent-tool/tag-registry/tag-lookup.mjs +8 -3
  421. package/src/session-runtime/services/agent-tool/tag-registry.mjs +3 -0
  422. package/src/session-runtime/services/agent-tool/worker-index/row-shape.mjs +4 -0
  423. package/src/session-runtime/services/agent-tool/worker-index.mjs +44 -10
  424. package/src/session-runtime/services/agent-tool.mjs +20 -0
  425. package/src/session-runtime/services/channel-admin.mjs +93 -24
  426. package/src/session-runtime/services/memory-access.mjs +37 -0
  427. package/src/session-runtime/services/provider-admin.mjs +166 -59
  428. package/src/session-runtime/services/schedule-access.mjs +91 -0
  429. package/src/session-runtime/services/usage-dashboard-model.mjs +2 -2
  430. package/src/session-runtime/services/usage-dashboard.mjs +27 -69
  431. package/src/session-runtime/session-create/session-options.mjs +34 -7
  432. package/src/session-runtime/session-hooks.mjs +16 -8
  433. package/src/session-runtime/setup-tool/executor.mjs +68 -6
  434. package/src/session-runtime/setup-tool/extended-actions.mjs +72 -14
  435. package/src/session-runtime/setup-tool/settings-contract.mjs +8 -6
  436. package/src/session-runtime/setup-tool/tool-defs.mjs +8 -0
  437. package/src/session-runtime/skills-api.mjs +16 -1
  438. package/src/session-runtime/tool-policy-refresh.mjs +238 -29
  439. package/src/session-runtime/turn/session-ops.mjs +10 -3
  440. package/src/session-runtime/turn/turn-run/ask-callbacks.mjs +11 -2
  441. package/src/session-runtime/turn/turn-run/turn-prepare.mjs +3 -0
  442. package/src/session-runtime/usage-stats-api.mjs +6 -1
  443. package/src/session-runtime/webhook-session-run.mjs +49 -67
  444. package/src/session-runtime/workflow-agents-api/agent-connectors.mjs +239 -0
  445. package/src/session-runtime/workflow-agents-api/agent-editor.mjs +556 -22
  446. package/src/session-runtime/workflow-agents-api/workflow-packs.mjs +11 -1
  447. package/src/session-runtime/workflow-agents-api.mjs +4 -1
  448. package/src/standalone/channel-transport/http-routes.mjs +10 -9
  449. package/src/standalone/daemon-agent-control.mjs +1 -8
  450. package/src/standalone/daemon-desktop-runtime.mjs +20 -7
  451. package/src/standalone/daemon-owner.mjs +117 -25
  452. package/src/standalone/daemon-session-control.mjs +11 -2
  453. package/src/standalone/daemon.mjs +61 -17
  454. package/src/standalone/session-call-cache.mjs +6 -0
  455. package/src/standalone/session-protocol.mjs +28 -1
  456. package/src/standalone/session-service/retention/busy.mjs +7 -2
  457. package/src/standalone/session-service/session-calls/session-turns.mjs +9 -0
  458. package/src/standalone/session-service.mjs +19 -0
  459. package/src/standalone/session-transport/routes.mjs +7 -6
  460. package/src/tui/app/model-options.mjs +39 -2
  461. package/src/tui/app/model-picker.mjs +16 -2
  462. package/src/tui/app/provider-setup-picker.mjs +1 -2
  463. package/src/tui/app/slash-commands.mjs +20 -0
  464. package/src/tui/dist/index.mjs +487 -128
  465. package/src/tui/session/context-state.mjs +6 -1
  466. package/src/tui/session/notice-surface.mjs +35 -4
  467. package/src/tui/session/notice-text.mjs +0 -1
  468. package/src/tui/session/queue-helpers.mjs +2 -1
  469. package/src/tui/session/session-api/extensions.mjs +4 -0
  470. package/src/tui/session/session-api/intake/submission.mjs +12 -13
  471. package/src/tui/session/session-api/integrations.mjs +9 -5
  472. package/src/tui/session/session-api/lifecycle/session-reset.mjs +13 -3
  473. package/src/tui/session/session-api/lifecycle.mjs +17 -1
  474. package/src/tui/session/session-api/routes.mjs +48 -3
  475. package/src/tui/session/session-flow/drain.mjs +20 -3
  476. package/src/tui/session/session-flow/queue/entry-shape.mjs +2 -1
  477. package/src/tui/session/session-flow/queue/take-entries.mjs +3 -2
  478. package/src/tui/session/session-flow/steering.mjs +104 -24
  479. package/src/tui/session/session-flow.mjs +2 -0
  480. package/src/tui/session/tool-approval.mjs +26 -5
  481. package/src/tui/session/transcript-intake.mjs +6 -2
  482. package/src/tui/session/transcript-spill.mjs +5 -1
  483. package/src/tui/session/tui-steering-persist.mjs +65 -42
  484. package/src/tui/session/turn-live-call.mjs +56 -0
  485. package/src/tui/session/turn-stream.mjs +33 -0
  486. package/src/tui/session/turn.mjs +50 -7
  487. package/src/ui/statusline.mjs +1 -6
  488. package/src/ui/streaming-markdown-heal.mjs +24 -7
  489. package/src/vendor/statusline/bin/statusline-route.mjs +0 -1
  490. package/src/vendor/statusline/src/gateway/route-meta.mjs +0 -1
  491. package/src/workflows/default/WORKFLOW.md +9 -13
  492. package/src/session-runtime/automation-agents.mjs +0 -94
  493. package/src/session-runtime/automation-workflow.mjs +0 -59
@@ -1825,8 +1825,8 @@ var require_react_reconciler_production = __commonJS({
1825
1825
  currentEntangledActionThenable = {
1826
1826
  status: "pending",
1827
1827
  value: void 0,
1828
- then: function(resolve6) {
1829
- entangledListeners.push(resolve6);
1828
+ then: function(resolve8) {
1829
+ entangledListeners.push(resolve8);
1830
1830
  }
1831
1831
  };
1832
1832
  }
@@ -1849,8 +1849,8 @@ var require_react_reconciler_production = __commonJS({
1849
1849
  status: "pending",
1850
1850
  value: null,
1851
1851
  reason: null,
1852
- then: function(resolve6) {
1853
- listeners.push(resolve6);
1852
+ then: function(resolve8) {
1853
+ listeners.push(resolve8);
1854
1854
  }
1855
1855
  };
1856
1856
  thenable.then(
@@ -11449,8 +11449,8 @@ var require_react_reconciler_development = __commonJS({
11449
11449
  currentEntangledActionThenable = {
11450
11450
  status: "pending",
11451
11451
  value: void 0,
11452
- then: function(resolve6) {
11453
- entangledListeners.push(resolve6);
11452
+ then: function(resolve8) {
11453
+ entangledListeners.push(resolve8);
11454
11454
  }
11455
11455
  };
11456
11456
  }
@@ -11473,8 +11473,8 @@ var require_react_reconciler_development = __commonJS({
11473
11473
  status: "pending",
11474
11474
  value: null,
11475
11475
  reason: null,
11476
- then: function(resolve6) {
11477
- listeners.push(resolve6);
11476
+ then: function(resolve8) {
11477
+ listeners.push(resolve8);
11478
11478
  }
11479
11479
  };
11480
11480
  thenable.then(
@@ -23114,9 +23114,194 @@ var require_stack_utils = __commonJS({
23114
23114
 
23115
23115
  // src/runtime/shared/file-permissions.mjs
23116
23116
  import { existsSync as existsSync4 } from "node:fs";
23117
- import { dirname as dirname3, join as join3 } from "node:path";
23118
- import { execFile as execFile2, execFileSync as execFileSync2 } from "node:child_process";
23119
- import { promisify } from "node:util";
23117
+ import { dirname as dirname3, join as join3, resolve as resolve3 } from "node:path";
23118
+ import { execFile as execFile2, execFileSync as execFileSync2, spawn as spawn3 } from "node:child_process";
23119
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
23120
+ import { MessageChannel as MessageChannel2, receiveMessageOnPort, SHARE_ENV, Worker } from "node:worker_threads";
23121
+ function execFileAsync(file, args, options) {
23122
+ return new Promise((done, fail) => {
23123
+ execFile2(file, args, options, (error, stdout2, stderr) => {
23124
+ if (error) fail(Object.assign(error, { stdout: stdout2, stderr }));
23125
+ else done({ stdout: stdout2, stderr });
23126
+ });
23127
+ });
23128
+ }
23129
+ function aclHelperScript(sid) {
23130
+ return [
23131
+ "$ErrorActionPreference = 'Stop';",
23132
+ `$sid = [System.Security.Principal.SecurityIdentifier]::new(${quoteForPowerShell(sid)});`,
23133
+ "$full = [System.Security.AccessControl.FileSystemRights]::FullControl;",
23134
+ "$utf8 = [System.Text.Encoding]::UTF8;",
23135
+ "$out = [Console]::Out;",
23136
+ "while ($null -ne ($line = [Console]::In.ReadLine())) {",
23137
+ "$parts = $line.Split(@([char]32), 2);",
23138
+ "if ($parts.Count -ne 2) { continue };",
23139
+ "try {",
23140
+ "$path = $utf8.GetString([Convert]::FromBase64String($parts[1]));",
23141
+ "$directory = [System.IO.Directory]::Exists($path);",
23142
+ "$current = if ($directory) { [System.IO.Directory]::GetAccessControl($path) }",
23143
+ "else { [System.IO.File]::GetAccessControl($path) };",
23144
+ "$rules = @($current.GetAccessRules($true, $true, [System.Security.Principal.SecurityIdentifier]));",
23145
+ "$ownerOnly = $current.AreAccessRulesProtected -and $rules.Count -eq 1 -and",
23146
+ "$rules[0].AccessControlType -eq 'Allow' -and $rules[0].IdentityReference -eq $sid -and",
23147
+ "$rules[0].FileSystemRights -eq $full;",
23148
+ "if ($ownerOnly) { $out.WriteLine($parts[0] + ' ok') } else {",
23149
+ "$acl = if ($directory) { [System.Security.AccessControl.DirectorySecurity]::new() }",
23150
+ "else { [System.Security.AccessControl.FileSecurity]::new() };",
23151
+ "$acl.SetAccessRuleProtection($true, $false);",
23152
+ "$acl.AddAccessRule([System.Security.AccessControl.FileSystemAccessRule]::new(",
23153
+ "$sid, $full, [System.Security.AccessControl.AccessControlType]::Allow));",
23154
+ "if ($directory) { [System.IO.Directory]::SetAccessControl($path, $acl) }",
23155
+ "else { [System.IO.File]::SetAccessControl($path, $acl) };",
23156
+ "$out.WriteLine($parts[0] + ' fixed') }",
23157
+ "} catch {",
23158
+ "$out.WriteLine($parts[0] + ' err ' + [Convert]::ToBase64String($utf8.GetBytes([string]$_.Exception.Message)))",
23159
+ "};",
23160
+ "$out.Flush() }"
23161
+ ].join(" ");
23162
+ }
23163
+ function startAclHelper(icacls, sid) {
23164
+ const now = Date.now();
23165
+ aclHelperStartTimes = aclHelperStartTimes.filter((at) => now - at < ACL_HELPER_START_WINDOW_MS);
23166
+ if (aclHelperStartTimes.length >= ACL_HELPER_MAX_STARTS) return null;
23167
+ aclHelperStartTimes.push(now);
23168
+ const command = powerShellCommand(icacls, aclHelperScript(sid));
23169
+ let child;
23170
+ try {
23171
+ child = spawn3(command.executable, command.args, {
23172
+ cwd: dirname3(icacls),
23173
+ stdio: ["pipe", "pipe", "ignore"],
23174
+ windowsHide: true
23175
+ });
23176
+ } catch {
23177
+ return null;
23178
+ }
23179
+ const helper = { child, pending: /* @__PURE__ */ new Map(), buffer: "", dead: false };
23180
+ helper.fail = (cause) => {
23181
+ if (aclHelper === helper) aclHelper = null;
23182
+ if (helper.dead) return;
23183
+ helper.dead = true;
23184
+ const lost = [...helper.pending.values()];
23185
+ helper.pending.clear();
23186
+ for (const request of lost) request.lost(cause);
23187
+ try {
23188
+ child.kill();
23189
+ } catch {
23190
+ }
23191
+ };
23192
+ child.on("error", helper.fail);
23193
+ child.on("exit", () => helper.fail(new Error("Windows ACL helper exited")));
23194
+ child.stdin.on("error", helper.fail);
23195
+ child.stdout.on("error", helper.fail);
23196
+ child.stdout.on("close", () => helper.fail(new Error("Windows ACL helper closed its output")));
23197
+ child.stdout.setEncoding("utf8");
23198
+ child.stdout.on("data", (chunk) => {
23199
+ helper.buffer += chunk;
23200
+ let newline = helper.buffer.indexOf("\n");
23201
+ while (newline >= 0) {
23202
+ const [id, status, detail = ""] = helper.buffer.slice(0, newline).trim().split(" ");
23203
+ helper.buffer = helper.buffer.slice(newline + 1);
23204
+ newline = helper.buffer.indexOf("\n");
23205
+ const request = helper.pending.get(id);
23206
+ if (!request) continue;
23207
+ helper.pending.delete(id);
23208
+ syncAclHelperRef(helper);
23209
+ request.answer(status, Buffer.from(detail, "base64").toString("utf8"));
23210
+ }
23211
+ });
23212
+ syncAclHelperRef(helper);
23213
+ return helper;
23214
+ }
23215
+ function syncAclHelperRef(helper) {
23216
+ const method = helper.pending.size > 0 ? "ref" : "unref";
23217
+ helper.child[method]();
23218
+ helper.child.stdin[method]?.();
23219
+ helper.child.stdout[method]?.();
23220
+ }
23221
+ function askAclHelper(targetPath, icacls, sid) {
23222
+ if (!aclHelper) aclHelper = startAclHelper(icacls, sid);
23223
+ const helper = aclHelper;
23224
+ if (!helper) return Promise.resolve({ lost: new Error("Windows ACL helper unavailable") });
23225
+ return new Promise((done) => {
23226
+ aclHelperSeq += 1;
23227
+ const id = String(aclHelperSeq);
23228
+ const timer2 = setTimeout(() => {
23229
+ helper.pending.delete(id);
23230
+ syncAclHelperRef(helper);
23231
+ done({ lost: new Error("Windows ACL helper timed out") });
23232
+ helper.fail(new Error("Windows ACL helper timed out"));
23233
+ }, ACL_HELPER_REQUEST_TIMEOUT_MS);
23234
+ helper.pending.set(id, {
23235
+ answer(status, detail) {
23236
+ clearTimeout(timer2);
23237
+ done({ status, detail });
23238
+ },
23239
+ lost(cause) {
23240
+ clearTimeout(timer2);
23241
+ done({ lost: cause });
23242
+ }
23243
+ });
23244
+ syncAclHelperRef(helper);
23245
+ helper.child.stdin.write(`${id} ${Buffer.from(targetPath, "utf8").toString("base64")}
23246
+ `);
23247
+ });
23248
+ }
23249
+ function syncBridge() {
23250
+ if (aclSyncBridge || aclSyncBridgeBroken) return aclSyncBridge;
23251
+ try {
23252
+ const url = new URL("./file-permissions-worker.mjs", import.meta.url);
23253
+ if (!existsSync4(fileURLToPath2(url))) throw new Error("Windows ACL bridge worker is not shipped here");
23254
+ const { port1, port2 } = new MessageChannel2();
23255
+ const signal = new Int32Array(new SharedArrayBuffer(12));
23256
+ const worker = new Worker(url, {
23257
+ env: SHARE_ENV,
23258
+ execArgv: [],
23259
+ workerData: { port: port2, signal },
23260
+ transferList: [port2]
23261
+ });
23262
+ const bridge = { worker, port: port1, signal, seq: 0, startedAt: Date.now() };
23263
+ const drop = () => {
23264
+ if (aclSyncBridge === bridge) aclSyncBridge = null;
23265
+ };
23266
+ worker.on("error", drop);
23267
+ worker.on("exit", drop);
23268
+ worker.unref();
23269
+ port1.unref?.();
23270
+ aclSyncBridge = bridge;
23271
+ } catch {
23272
+ aclSyncBridgeBroken = true;
23273
+ }
23274
+ return aclSyncBridge;
23275
+ }
23276
+ function dropSyncBridge(bridge) {
23277
+ if (aclSyncBridge !== bridge) return;
23278
+ aclSyncBridge = null;
23279
+ void bridge.worker.terminate();
23280
+ }
23281
+ function askSyncBridge(targetPath) {
23282
+ const bridge = syncBridge();
23283
+ if (!bridge) return { lost: new Error("Windows ACL bridge unavailable") };
23284
+ bridge.seq += 1;
23285
+ const id = bridge.seq;
23286
+ let seen = Atomics.load(bridge.signal, 0);
23287
+ bridge.port.postMessage({ id, path: targetPath });
23288
+ const deadline = Date.now() + ACL_SYNC_BRIDGE_TIMEOUT_MS;
23289
+ for (; ; ) {
23290
+ for (let received = receiveMessageOnPort(bridge.port); received; received = receiveMessageOnPort(bridge.port)) {
23291
+ if (received.message?.id === id) return received.message;
23292
+ }
23293
+ const now = Date.now();
23294
+ const ready = Atomics.load(bridge.signal, 2) === 1;
23295
+ if (Atomics.load(bridge.signal, 1) === 1 || !ready && now - bridge.startedAt >= ACL_SYNC_BRIDGE_READY_MS) {
23296
+ dropSyncBridge(bridge);
23297
+ return { lost: new Error("Windows ACL bridge exited") };
23298
+ }
23299
+ if (now >= deadline) return { timedOut: true };
23300
+ const wait = ready ? deadline - now : Math.min(deadline - now, bridge.startedAt + ACL_SYNC_BRIDGE_READY_MS - now);
23301
+ Atomics.wait(bridge.signal, 0, seen, Math.max(1, wait));
23302
+ seen = Atomics.load(bridge.signal, 0);
23303
+ }
23304
+ }
23120
23305
  function systemToolPath(name) {
23121
23306
  const systemRoot = process.env.SystemRoot || process.env.windir;
23122
23307
  return systemRoot ? join3(systemRoot, "System32", name) : null;
@@ -23216,6 +23401,14 @@ function aclFailure(targetPath, cause, label = "icacls") {
23216
23401
  function enforceOwnerOnlyAclWin32(targetPath, { fresh = false } = {}) {
23217
23402
  if (process.platform !== "win32") return;
23218
23403
  const icacls = icaclsPath();
23404
+ if (fresh) {
23405
+ const reply = askSyncBridge(resolve3(targetPath));
23406
+ if (reply.ok === true) return;
23407
+ if (reply.ok === false) throw Object.assign(new Error(reply.message), { code: reply.code || "EACLFAIL" });
23408
+ if (reply.timedOut) {
23409
+ throw aclFailure(targetPath, new Error("the Windows ACL bridge did not answer"), "Windows ACL helper");
23410
+ }
23411
+ }
23219
23412
  if (cachedUserSid === null) cachedUserSid = resolveCurrentUserPrincipal();
23220
23413
  const command = ownerOnlyAclCommand(targetPath, cachedUserSid, fresh, icacls);
23221
23414
  try {
@@ -23230,6 +23423,16 @@ function enforceOwnerOnlyAclWin32(targetPath, { fresh = false } = {}) {
23230
23423
  }
23231
23424
  async function enforceOwnerOnlyAclWin32Async(targetPath, { fresh = false } = {}) {
23232
23425
  if (process.platform !== "win32") return;
23426
+ const icacls = icaclsPath();
23427
+ if (cachedUserSid === null) cachedUserSid = await resolveCurrentUserPrincipalAsync();
23428
+ const reply = await askAclHelper(resolve3(targetPath), icacls, cachedUserSid);
23429
+ if (reply.status === "ok" || reply.status === "fixed") return;
23430
+ if (reply.status === "err") {
23431
+ throw aclFailure(targetPath, new Error(reply.detail || "unknown error"), "Windows ACL helper");
23432
+ }
23433
+ return applyOwnerOnlyAclAsync(targetPath, fresh);
23434
+ }
23435
+ async function applyOwnerOnlyAclAsync(targetPath, fresh) {
23233
23436
  const icacls = icaclsPath();
23234
23437
  if (cachedUserSid === null) cachedUserSid = await resolveCurrentUserPrincipalAsync();
23235
23438
  const command = ownerOnlyAclCommand(targetPath, cachedUserSid, fresh, icacls);
@@ -23239,11 +23442,20 @@ async function enforceOwnerOnlyAclWin32Async(targetPath, { fresh = false } = {})
23239
23442
  throw aclFailure(targetPath, error, command.label);
23240
23443
  }
23241
23444
  }
23242
- var execFileAsync, cachedUserSid, quoteForPowerShell;
23445
+ var cachedUserSid, ACL_HELPER_REQUEST_TIMEOUT_MS, ACL_HELPER_MAX_STARTS, ACL_HELPER_START_WINDOW_MS, aclHelper, aclHelperStartTimes, aclHelperSeq, ACL_SYNC_BRIDGE_READY_MS, ACL_SYNC_BRIDGE_TIMEOUT_MS, aclSyncBridge, aclSyncBridgeBroken, quoteForPowerShell;
23243
23446
  var init_file_permissions = __esm({
23244
23447
  "src/runtime/shared/file-permissions.mjs"() {
23245
- execFileAsync = promisify(execFile2);
23246
23448
  cachedUserSid = null;
23449
+ ACL_HELPER_REQUEST_TIMEOUT_MS = 15e3;
23450
+ ACL_HELPER_MAX_STARTS = 3;
23451
+ ACL_HELPER_START_WINDOW_MS = 10 * 6e4;
23452
+ aclHelper = null;
23453
+ aclHelperStartTimes = [];
23454
+ aclHelperSeq = 0;
23455
+ ACL_SYNC_BRIDGE_READY_MS = 1e4;
23456
+ ACL_SYNC_BRIDGE_TIMEOUT_MS = 2 * ACL_HELPER_REQUEST_TIMEOUT_MS + 5e3;
23457
+ aclSyncBridge = null;
23458
+ aclSyncBridgeBroken = false;
23247
23459
  quoteForPowerShell = (value) => `'${String(value).replaceAll("'", "''")}'`;
23248
23460
  }
23249
23461
  });
@@ -23274,7 +23486,7 @@ var init_keyed_serial_queue = __esm({
23274
23486
 
23275
23487
  // src/runtime/shared/sleep.mjs
23276
23488
  function sleep(ms) {
23277
- return new Promise((resolve6) => setTimeout(resolve6, ms));
23489
+ return new Promise((resolve8) => setTimeout(resolve8, ms));
23278
23490
  }
23279
23491
  function sleepSync(ms) {
23280
23492
  const buffer = new SharedArrayBuffer(4);
@@ -23671,14 +23883,15 @@ async function withOsFileLock(lockPath, fn, opts = {}, queueWaitMs = 0) {
23671
23883
  }
23672
23884
  }
23673
23885
  }
23674
- var LOCK_WAIT_CODES, DEFAULT_BACKOFFS_MS, configuredLockTimeoutMs, DEFAULT_LOCK_TIMEOUT_MS, OWNER_TOKEN, osHeldPaths, lockQueue, heldLockPaths, RECLAIM_GUARD_STALE_MS, LOCK_WAIT_WARN_MS, LOCK_WAIT_WARN_INTERVAL_MS, LOCK_HELD_WARN_MS, lockWaitWarnedAt, lockHeldWarnedAt, SYNC_IO, ASYNC_IO, STAGED_LOCK_FILE_STALE_MS, sweptLockPaths;
23886
+ var LOCK_WAIT_CODES, RETRY_MAX_MS, DEFAULT_BACKOFFS_MS, configuredLockTimeoutMs, DEFAULT_LOCK_TIMEOUT_MS, OWNER_TOKEN, osHeldPaths, lockQueue, heldLockPaths, RECLAIM_GUARD_STALE_MS, LOCK_WAIT_WARN_MS, LOCK_WAIT_WARN_INTERVAL_MS, LOCK_HELD_WARN_MS, lockWaitWarnedAt, lockHeldWarnedAt, SYNC_IO, ASYNC_IO, STAGED_LOCK_FILE_STALE_MS, sweptLockPaths;
23675
23887
  var init_file_lock = __esm({
23676
23888
  "src/runtime/shared/file-lock.mjs"() {
23677
23889
  init_file_permissions();
23678
23890
  init_keyed_serial_queue();
23679
23891
  init_sleep();
23680
23892
  LOCK_WAIT_CODES = /* @__PURE__ */ new Set(["EEXIST", "EPERM", "EACCES", "EBUSY"]);
23681
- DEFAULT_BACKOFFS_MS = Object.freeze([25, 50, 100, 200, 400, 800, 1200, 1600]);
23893
+ RETRY_MAX_MS = 200;
23894
+ DEFAULT_BACKOFFS_MS = Object.freeze([25, 50, 100, ...Array(20).fill(RETRY_MAX_MS)]);
23682
23895
  configuredLockTimeoutMs = Number(process.env.MIXDOG_LOCK_TIMEOUT_MS);
23683
23896
  DEFAULT_LOCK_TIMEOUT_MS = Number.isFinite(configuredLockTimeoutMs) && configuredLockTimeoutMs >= 0 ? configuredLockTimeoutMs : 2e3;
23684
23897
  OWNER_TOKEN = randomBytes2(12).toString("hex");
@@ -23738,7 +23951,8 @@ import {
23738
23951
  unlink as unlinkAsync2,
23739
23952
  writeFile as writeFileAsync2
23740
23953
  } from "node:fs/promises";
23741
- import { dirname as dirname5, basename as basename3, join as join5 } from "node:path";
23954
+ import { tmpdir as tmpdir2 } from "node:os";
23955
+ import { dirname as dirname5, basename as basename3, join as join5, relative, isAbsolute as isAbsolute2, resolve as resolve4 } from "node:path";
23742
23956
  import { randomBytes as randomBytes3 } from "node:crypto";
23743
23957
  function _drainAdaptiveFileIo() {
23744
23958
  while (_ioActive < _ioLimit && _ioQueue.length > 0) {
@@ -23765,8 +23979,8 @@ function _drainAdaptiveFileIo() {
23765
23979
  }
23766
23980
  }
23767
23981
  function _runAdaptiveFileIo(run) {
23768
- return new Promise((resolve6, reject) => {
23769
- _ioQueue.push({ run, resolve: resolve6, reject });
23982
+ return new Promise((resolve8, reject) => {
23983
+ _ioQueue.push({ run, resolve: resolve8, reject });
23770
23984
  _drainAdaptiveFileIo();
23771
23985
  });
23772
23986
  }
@@ -23777,21 +23991,22 @@ function nextRenameDelayMs(err, attempt, backoffs) {
23777
23991
  if (!RETRY_CODES.has(err?.code) || attempt >= backoffs.length) return null;
23778
23992
  return backoffs[attempt] + Math.floor(Math.random() * Math.min(50, Math.max(1, backoffs[attempt])));
23779
23993
  }
23994
+ function renameAttempt(src, dst, attempt, opts = {}) {
23995
+ try {
23996
+ renameSync3(src, dst);
23997
+ return null;
23998
+ } catch (err) {
23999
+ const delayMs = nextRenameDelayMs(err, attempt, renameBackoffs(opts));
24000
+ if (delayMs === null) throw err;
24001
+ return delayMs;
24002
+ }
24003
+ }
23780
24004
  function renameWithRetrySync(src, dst, opts = {}) {
23781
- const backoffs = renameBackoffs(opts);
23782
- let lastErr = null;
23783
- for (let attempt = 0; attempt <= backoffs.length; attempt++) {
23784
- try {
23785
- renameSync3(src, dst);
23786
- return true;
23787
- } catch (err) {
23788
- lastErr = err;
23789
- const delayMs = nextRenameDelayMs(err, attempt, backoffs);
23790
- if (delayMs === null) break;
23791
- sleepSync(delayMs);
23792
- }
24005
+ for (let attempt = 0; ; attempt++) {
24006
+ const delayMs = renameAttempt(src, dst, attempt, opts);
24007
+ if (delayMs === null) return true;
24008
+ sleepSync(delayMs);
23793
24009
  }
23794
- throw lastErr;
23795
24010
  }
23796
24011
  async function renameWithRetry(src, dst, opts = {}) {
23797
24012
  const backoffs = renameBackoffs(opts);
@@ -23837,7 +24052,14 @@ async function fsyncPathAsync(path2, tolerated) {
23837
24052
  }
23838
24053
  }
23839
24054
  }
24055
+ function assertTestSecretWriteSafe(filePath, opts) {
24056
+ if (opts.secret !== true || !process.env.NODE_TEST_CONTEXT) return;
24057
+ const rel = relative(resolve4(tmpdir2()).toLowerCase(), resolve4(filePath).toLowerCase());
24058
+ if (rel === "" || !rel.startsWith("..") && !isAbsolute2(rel)) return;
24059
+ throw new Error(`refusing to write a secret outside the temp dir under node --test: ${filePath}`);
24060
+ }
23840
24061
  function writeFileAtomicSync(filePath, data, opts = {}) {
24062
+ assertTestSecretWriteSafe(filePath, opts);
23841
24063
  const run = () => {
23842
24064
  const dir = dirname5(filePath);
23843
24065
  mkdirSync3(dir, { recursive: true });
@@ -23902,6 +24124,7 @@ function writeJsonAtomicSync(filePath, value, opts = {}) {
23902
24124
  `, opts);
23903
24125
  }
23904
24126
  async function writeFileAtomicAsync(filePath, data, opts = {}) {
24127
+ assertTestSecretWriteSafe(filePath, opts);
23905
24128
  const run = async () => {
23906
24129
  const dir = dirname5(filePath);
23907
24130
  await mkdirAsync2(dir, { recursive: true });
@@ -24160,7 +24383,7 @@ import {
24160
24383
  } from "node:fs";
24161
24384
  import { setTimeout as sleep2 } from "node:timers/promises";
24162
24385
  import { join as join14, dirname as dirname11 } from "node:path";
24163
- import { fileURLToPath as fileURLToPath3 } from "node:url";
24386
+ import { fileURLToPath as fileURLToPath4 } from "node:url";
24164
24387
  import { pipeline as pipeline2 } from "node:stream/promises";
24165
24388
  import { spawnSync } from "node:child_process";
24166
24389
  import { createGunzip } from "node:zlib";
@@ -24881,7 +25104,7 @@ var init_voice_runtime_fetcher = __esm({
24881
25104
  init_bounded_download();
24882
25105
  init_native_asset();
24883
25106
  init_windows_roots();
24884
- BUNDLED_MANIFEST_PATH = fileURLToPath3(new URL("../data/voice-runtime-manifest.json", import.meta.url));
25107
+ BUNDLED_MANIFEST_PATH = fileURLToPath4(new URL("../data/voice-runtime-manifest.json", import.meta.url));
24885
25108
  MANIFEST_URL = "https://raw.githubusercontent.com/tribgames/mixdog/main/src/runtime/channels/data/voice-runtime-manifest.json";
24886
25109
  LOCK_WAIT_CODES2 = /* @__PURE__ */ new Set(["EEXIST", "EPERM", "EACCES", "EBUSY"]);
24887
25110
  LOCK_MAX_AGE_MS = 30 * 60 * 1e3;
@@ -33876,8 +34099,8 @@ var App_default = App;
33876
34099
  var noop = () => {
33877
34100
  };
33878
34101
  var textEncoder = new TextEncoder();
33879
- var yieldImmediate = async () => new Promise((resolve6) => {
33880
- setImmediate(resolve6);
34102
+ var yieldImmediate = async () => new Promise((resolve8) => {
34103
+ setImmediate(resolve8);
33881
34104
  });
33882
34105
  var kittyQueryEscapeByte = 27;
33883
34106
  var kittyQueryOpenBracketByte = 91;
@@ -34132,8 +34355,8 @@ var Ink = class {
34132
34355
  };
34133
34356
  }
34134
34357
  this.initKittyKeyboard();
34135
- this.exitPromise = new Promise((resolve6, reject) => {
34136
- this.resolveExitPromise = resolve6;
34358
+ this.exitPromise = new Promise((resolve8, reject) => {
34359
+ this.resolveExitPromise = resolve8;
34137
34360
  this.rejectExitPromise = reject;
34138
34361
  });
34139
34362
  void this.exitPromise.catch(noop);
@@ -34573,9 +34796,9 @@ var Ink = class {
34573
34796
  settleThrottle(this.throttledOnRender, canWriteToStdout);
34574
34797
  settleThrottle(this.throttledLog, canWriteToStdout);
34575
34798
  if (canWriteToStdout && hasWritableState) {
34576
- await new Promise((resolve6) => {
34799
+ await new Promise((resolve8) => {
34577
34800
  this.options.stdout.write("", () => {
34578
- resolve6();
34801
+ resolve8();
34579
34802
  });
34580
34803
  });
34581
34804
  return;
@@ -34661,8 +34884,8 @@ var Ink = class {
34661
34884
  async awaitNextRender() {
34662
34885
  if (!this.nextRenderCommit) {
34663
34886
  let resolveRender;
34664
- const promise = new Promise((resolve6) => {
34665
- resolveRender = resolve6;
34887
+ const promise = new Promise((resolve8) => {
34888
+ resolveRender = resolve8;
34666
34889
  });
34667
34890
  this.nextRenderCommit = { promise, resolve: resolveRender };
34668
34891
  }
@@ -35114,7 +35337,7 @@ import { useState as useState5, useEffect as useEffect6, useCallback as useCallb
35114
35337
 
35115
35338
  // src/tui/index.jsx
35116
35339
  import { closeSync as closeSync3, constants as fsConstants, createWriteStream as createWriteStream3, mkdirSync as mkdirSync8, openSync as openSync3, readSync } from "node:fs";
35117
- import { tmpdir as tmpdir3 } from "node:os";
35340
+ import { tmpdir as tmpdir4 } from "node:os";
35118
35341
  import { dirname as dirname12, join as join17 } from "node:path";
35119
35342
  import { performance as performance2 } from "node:perf_hooks";
35120
35343
  import { format } from "node:util";
@@ -35133,12 +35356,12 @@ import { spawn } from "node:child_process";
35133
35356
  import path from "node:path";
35134
35357
  var DIALOG_TIMEOUT_MS = 5 * 60 * 1e3;
35135
35358
  function runCapture(cmd, args, { timeoutMs = DIALOG_TIMEOUT_MS } = {}) {
35136
- return new Promise((resolve6) => {
35359
+ return new Promise((resolve8) => {
35137
35360
  let child;
35138
35361
  try {
35139
35362
  child = spawn(cmd, args, { stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
35140
35363
  } catch (error) {
35141
- resolve6({ ok: false, code: -1, stdout: "", error });
35364
+ resolve8({ ok: false, code: -1, stdout: "", error });
35142
35365
  return;
35143
35366
  }
35144
35367
  let stdout2 = "";
@@ -35150,7 +35373,7 @@ function runCapture(cmd, args, { timeoutMs = DIALOG_TIMEOUT_MS } = {}) {
35150
35373
  child.kill();
35151
35374
  } catch {
35152
35375
  }
35153
- resolve6({ ok: false, code: -1, stdout: "", error: new Error("dialog timed out") });
35376
+ resolve8({ ok: false, code: -1, stdout: "", error: new Error("dialog timed out") });
35154
35377
  }, timeoutMs);
35155
35378
  timer2.unref?.();
35156
35379
  child.stdout.on("data", (chunk) => {
@@ -35160,13 +35383,13 @@ function runCapture(cmd, args, { timeoutMs = DIALOG_TIMEOUT_MS } = {}) {
35160
35383
  if (settled) return;
35161
35384
  settled = true;
35162
35385
  clearTimeout(timer2);
35163
- resolve6({ ok: false, code: -1, stdout: "", error });
35386
+ resolve8({ ok: false, code: -1, stdout: "", error });
35164
35387
  });
35165
35388
  child.on("close", (code) => {
35166
35389
  if (settled) return;
35167
35390
  settled = true;
35168
35391
  clearTimeout(timer2);
35169
- resolve6({ ok: code === 0, code, stdout: stdout2 });
35392
+ resolve8({ ok: code === 0, code, stdout: stdout2 });
35170
35393
  });
35171
35394
  });
35172
35395
  }
@@ -35174,10 +35397,10 @@ function spawnFailed(result) {
35174
35397
  return !!result && result.code === -1;
35175
35398
  }
35176
35399
  function commandExists(cmd) {
35177
- return new Promise((resolve6) => {
35400
+ return new Promise((resolve8) => {
35178
35401
  const probe = process.platform === "win32" ? spawn("where", [cmd], { stdio: "ignore", windowsHide: true }) : spawn("which", [cmd], { stdio: "ignore" });
35179
- probe.on("error", () => resolve6(false));
35180
- probe.on("close", (code) => resolve6(code === 0));
35402
+ probe.on("error", () => resolve8(false));
35403
+ probe.on("close", (code) => resolve8(code === 0));
35181
35404
  });
35182
35405
  }
35183
35406
  function psSingleQuoted(value) {
@@ -38714,13 +38937,22 @@ function trimPendingTableHead(text) {
38714
38937
  for (const blank of text.matchAll(/\n[ \t]*\r?\n/g)) offset = blank.index + blank[0].length;
38715
38938
  const block = text.slice(offset);
38716
38939
  const lines = block.split("\n").map((line) => line.replace(/\r$/, ""));
38717
- if (lines.length === 0 || lines.length > 2 || !PIPE_ROW.test(lines[0])) return text;
38718
- if (lines.length === 2) {
38719
- const delimiter2 = lines[1];
38720
- if (!PARTIAL_DELIMITER_ROW.test(delimiter2)) return text;
38721
- if (DELIMITER_ROW.test(delimiter2) && tableCells(delimiter2) === tableCells(lines[0])) return text;
38722
- }
38723
- return text.slice(0, offset);
38940
+ let last = lines.length - 1;
38941
+ if (last >= 1 && !lines[last].trim()) last -= 1;
38942
+ let head = last;
38943
+ if (last >= 1 && PARTIAL_DELIMITER_ROW.test(lines[last]) && hasCellPipe(lines[last - 1])) {
38944
+ const delimiter2 = lines[last];
38945
+ if (DELIMITER_ROW.test(delimiter2) && tableCells(delimiter2) === tableCells(lines[last - 1])) return text;
38946
+ head = last - 1;
38947
+ }
38948
+ if (!(PIPE_ROW.test(lines[head]) || hasCellPipe(lines[head]))) return text;
38949
+ if (lines.slice(0, head).some((line) => DELIMITER_ROW.test(line))) return text;
38950
+ let start = offset;
38951
+ for (let index = 0; index < head; index += 1) start += lines[index].length + 1;
38952
+ return text.slice(0, start);
38953
+ }
38954
+ function hasCellPipe(line) {
38955
+ return /(?<!\\)\|/.test(line.replace(INLINE_CODE_SPAN, ""));
38724
38956
  }
38725
38957
  function healStreamingMarkdownTail(text, isPendingLocalPath) {
38726
38958
  const source = String(text ?? "");
@@ -45974,8 +46206,8 @@ var notifyRenderFrame = (seq) => {
45974
46206
  for (const ack of acks) ack(seq);
45975
46207
  };
45976
46208
  var yieldToRenderer = ({ frames = 1 } = {}) => {
45977
- if (!hasRenderFrameSource()) return new Promise((resolve6) => setImmediate(resolve6));
45978
- return new Promise((resolve6) => {
46209
+ if (!hasRenderFrameSource()) return new Promise((resolve8) => setImmediate(resolve8));
46210
+ return new Promise((resolve8) => {
45979
46211
  const minSeq = renderAckSeq;
45980
46212
  let remainingFrames = Math.max(1, Math.floor(Number(frames) || 1));
45981
46213
  let settled = false;
@@ -45990,7 +46222,7 @@ var yieldToRenderer = ({ frames = 1 } = {}) => {
45990
46222
  releaseClosedListener();
45991
46223
  const idx = pendingRenderAcks.indexOf(onFrame);
45992
46224
  if (idx !== -1) pendingRenderAcks.splice(idx, 1);
45993
- resolve6();
46225
+ resolve8();
45994
46226
  };
45995
46227
  releaseClosedListener = onRenderFrameSourcesClosed(finish);
45996
46228
  const onTimeout = () => {
@@ -46790,13 +47022,13 @@ function nativeClipboardCommand(text) {
46790
47022
  function copyToClipboard(text) {
46791
47023
  const value = String(text ?? "");
46792
47024
  const wroteOsc52 = writeOsc52Clipboard(value);
46793
- return new Promise((resolve6, reject) => {
47025
+ return new Promise((resolve8, reject) => {
46794
47026
  const { cmd, args, input } = nativeClipboardCommand(value);
46795
47027
  let child;
46796
47028
  try {
46797
47029
  child = spawn2(cmd, args, { stdio: ["pipe", "ignore", "ignore"], windowsHide: true });
46798
47030
  } catch (e) {
46799
- if (wroteOsc52) resolve6();
47031
+ if (wroteOsc52) resolve8();
46800
47032
  else reject(clipboardHelperError(cmd, e));
46801
47033
  return;
46802
47034
  }
@@ -46805,7 +47037,7 @@ function copyToClipboard(text) {
46805
47037
  });
46806
47038
  if (!wroteOsc52) {
46807
47039
  child.on("close", (code) => {
46808
- if (code === 0) resolve6();
47040
+ if (code === 0) resolve8();
46809
47041
  else reject(new Error(`${cmd} exited with code ${code}`));
46810
47042
  });
46811
47043
  }
@@ -46814,7 +47046,7 @@ function copyToClipboard(text) {
46814
47046
  child.stdin.end(input);
46815
47047
  if (wroteOsc52) {
46816
47048
  child.unref?.();
46817
- resolve6();
47049
+ resolve8();
46818
47050
  }
46819
47051
  });
46820
47052
  }
@@ -47118,7 +47350,7 @@ function mimeForPath(path2) {
47118
47350
  return IMAGE_MIME[extname(String(path2 || "")).toLowerCase()] || null;
47119
47351
  }
47120
47352
  function execFileBuffer(cmd, args, options = {}) {
47121
- return new Promise((resolve6) => {
47353
+ return new Promise((resolve8) => {
47122
47354
  execFile(
47123
47355
  cmd,
47124
47356
  args,
@@ -47130,7 +47362,7 @@ function execFileBuffer(cmd, args, options = {}) {
47130
47362
  ...options
47131
47363
  },
47132
47364
  (error, stdout2, stderr) => {
47133
- resolve6({ ok: !error, code: error?.code ?? 0, stdout: stdout2, stderr, error });
47365
+ resolve8({ ok: !error, code: error?.code ?? 0, stdout: stdout2, stderr, error });
47134
47366
  }
47135
47367
  );
47136
47368
  });
@@ -48526,7 +48758,7 @@ function completeOAuthCode(ctx, target, commandText) {
48526
48758
  }
48527
48759
  oauthSubmitRef.current = true;
48528
48760
  setProviderPrompt((prompt) => prompt === target ? { ...prompt, submitting: true } : prompt);
48529
- const completion = typeof target.login?.completeCode === "function" ? new Promise((resolve6) => resolve6(target.login.completeCode(commandText))) : Promise.reject(new Error("OAuth login is no longer active"));
48761
+ const completion = typeof target.login?.completeCode === "function" ? new Promise((resolve8) => resolve8(target.login.completeCode(commandText))) : Promise.reject(new Error("OAuth login is no longer active"));
48530
48762
  void completion.then(() => {
48531
48763
  const successReturn = target.successReturn;
48532
48764
  const afterSave = target.afterSave;
@@ -49740,11 +49972,11 @@ init_atomic_file();
49740
49972
  init_json_file();
49741
49973
  import { existsSync as existsSync6, readFileSync as readFileSync6, realpathSync } from "node:fs";
49742
49974
  import { basename as basename4, delimiter, dirname as dirname6, join as join6 } from "node:path";
49743
- import { fileURLToPath as fileURLToPath2 } from "node:url";
49975
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
49744
49976
  var PACKAGE_NAME = "mixdog";
49745
49977
  var REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
49746
49978
  var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
49747
- var _MODULE_DIR = dirname6(fileURLToPath2(import.meta.url));
49979
+ var _MODULE_DIR = dirname6(fileURLToPath3(import.meta.url));
49748
49980
  var _PACKAGE_JSON_PATH = join6(_MODULE_DIR, "..", "..", "..", "package.json");
49749
49981
  var _PACKAGE_ROOT = dirname6(_PACKAGE_JSON_PATH);
49750
49982
  var _localVersionCache = null;
@@ -50730,7 +50962,17 @@ var PROVIDER_CATALOGS = Object.freeze({
50730
50962
  },
50731
50963
  "cursor-oauth": { relay: true },
50732
50964
  "cursor-api": { relay: true },
50733
- "opencode-go": { relay: true }
50965
+ // The models.dev listing id of the Go gateway: a relay catalog, not a
50966
+ // selectable provider (the model lookup needs it flagged as a relay).
50967
+ "opencode-go": { relay: true },
50968
+ // The Go gateway through an OpenCode Console login; the organization
50969
+ // config's catalog is the live roster.
50970
+ "opencode-go-oauth": {
50971
+ modelsDev: "opencode-go",
50972
+ relay: true,
50973
+ rosterFiles: ["opencode-go-oauth-models.json"],
50974
+ rosterLimitsAuthoritative: true
50975
+ }
50734
50976
  });
50735
50977
  var VERIFIED_CORRECTIONS = Object.freeze({
50736
50978
  "muse-code-oauth": Object.freeze({
@@ -51090,11 +51332,11 @@ function isPidAlive(value) {
51090
51332
 
51091
51333
  // src/runtime/shared/worktrees/git-head.mjs
51092
51334
  import { readFileSync as readFileSync9, statSync as statSync2, watch } from "node:fs";
51093
- import { dirname as dirname8, resolve as resolve4 } from "node:path";
51335
+ import { dirname as dirname8, resolve as resolve6 } from "node:path";
51094
51336
 
51095
51337
  // src/runtime/shared/worktrees/paths.mjs
51096
51338
  import { existsSync as existsSync9, realpathSync as realpathSync2 } from "node:fs";
51097
- import { dirname as dirname7, isAbsolute as isAbsolute2, join as join9, relative, resolve as resolve3, sep } from "node:path";
51339
+ import { dirname as dirname7, isAbsolute as isAbsolute3, join as join9, relative as relative2, resolve as resolve5, sep } from "node:path";
51098
51340
 
51099
51341
  // src/runtime/shared/statusline/statusline-segments.mjs
51100
51342
  var DEFAULT_MIXDOG_HOME = process.env.MIXDOG_HOME || join10(homedir2(), ".mixdog");
@@ -51182,7 +51424,8 @@ async function refreshShellJobsStatus(ownerPid) {
51182
51424
  continue;
51183
51425
  }
51184
51426
  const unconfirmed = detail?.terminationUnconfirmed === true;
51185
- if (unconfirmed ? !isPidAlive(ownerByJob.get(id) || 0) : !await isShellJobAlive(detail, p, dir, id)) continue;
51427
+ if (unconfirmed ? !isHeldShellJobAlive(detail, ownerByJob.get(id)) : !await isShellJobAlive(detail, p, dir, id))
51428
+ continue;
51186
51429
  if (detail?.foreground === true && !unconfirmed) continue;
51187
51430
  const ownedByThisHost = ownerByJob.get(id) === ownerPid;
51188
51431
  if (ownedByThisHost) count++;
@@ -51271,6 +51514,12 @@ function summarizeShellJobs({ count, oldestMs, jobs, bySession }) {
51271
51514
  }
51272
51515
  return { count, elapsedLabel, jobs, sessions };
51273
51516
  }
51517
+ function isHeldShellJobAlive(detail, ownerPid) {
51518
+ if (!isPidAlive(ownerPid || 0)) return false;
51519
+ if (detail?.ownerSessionClosed !== true) return true;
51520
+ const survivors = Array.isArray(detail?.survivorPids) ? detail.survivorPids : [];
51521
+ return [detail?.pid, ...survivors].some((pid) => isPidAlive(positiveInt(pid)));
51522
+ }
51274
51523
  async function isShellJobAlive(detail, detailPath, dir, id) {
51275
51524
  const pid = positiveInt(detail?.pid);
51276
51525
  if (!pid) return false;
@@ -55639,7 +55888,7 @@ function renderToolApproval({ toolApproval, store, frameColumns, expandedOptionP
55639
55888
  toolApproval.id
55640
55889
  );
55641
55890
  }
55642
- const resolve6 = (approved) => {
55891
+ const resolve8 = (approved) => {
55643
55892
  store.resolveToolApproval?.(toolApproval.id, {
55644
55893
  approved,
55645
55894
  reason: approved ? "approved by user" : "denied by user"
@@ -55664,12 +55913,12 @@ function renderToolApproval({ toolApproval, store, frameColumns, expandedOptionP
55664
55913
  description: "run this tool call"
55665
55914
  }
55666
55915
  ],
55667
- onSelect: (value) => resolve6(value === "approve"),
55668
- onCancel: () => resolve6(false),
55916
+ onSelect: (value) => resolve8(value === "approve"),
55917
+ onCancel: () => resolve8(false),
55669
55918
  onKey: (input) => {
55670
55919
  const value = String(input || "").trim().toLowerCase();
55671
- if (value === "a" || value === "y") resolve6(true);
55672
- else if (value === "d" || value === "n") resolve6(false);
55920
+ if (value === "a" || value === "y") resolve8(true);
55921
+ else if (value === "d" || value === "n") resolve8(false);
55673
55922
  },
55674
55923
  title: "Tool approval",
55675
55924
  description: toolApprovalDescription(toolApproval),
@@ -59049,7 +59298,7 @@ var PROVIDER_DISPLAY_NAMES = /* @__PURE__ */ new Map([
59049
59298
  ["xai-api", "xAI API"],
59050
59299
  ["deepseek", "DeepSeek API"],
59051
59300
  ["deepseek-api", "DeepSeek API"],
59052
- ["opencode-go", "OpenCode Go API"],
59301
+ ["opencode-go-oauth", "OpenCode Go OAuth"],
59053
59302
  ["openrouter", "OpenRouter"],
59054
59303
  ["mixdog-local", "Local Provider"],
59055
59304
  ["default", "Default"]
@@ -59076,6 +59325,33 @@ var loadProviderDisplayNames = async (store) => {
59076
59325
  }
59077
59326
  return names;
59078
59327
  };
59328
+ var loadProviderCatalogFailures = async (store) => {
59329
+ let setup = null;
59330
+ try {
59331
+ setup = await store?.getProviderSetup?.();
59332
+ } catch {
59333
+ return [];
59334
+ }
59335
+ const failures = [];
59336
+ for (const group of ["api", "oauth", "local"]) {
59337
+ for (const entry of Array.isArray(setup?.[group]) ? setup[group] : []) {
59338
+ const failure = entry?.catalogError;
59339
+ if (!failure?.message) continue;
59340
+ const { summary, recovery } = describeError({ message: failure.message, errorKind: failure.errorKind });
59341
+ failures.push({ id: String(entry.id || "").trim(), text: [summary, recovery].filter(Boolean).join(" ") });
59342
+ }
59343
+ }
59344
+ return failures;
59345
+ };
59346
+ var buildCatalogFailureItems = (failures, models, providerNames = null) => failures.filter(({ id }) => id && !models.some((model) => model.provider === id)).map(({ id, text }) => ({
59347
+ value: `provider-failed:${id}`,
59348
+ label: resolveProviderDisplayName(id, providerNames),
59349
+ marker: "!",
59350
+ markerColor: theme.error,
59351
+ description: text,
59352
+ _action: "catalog-failed",
59353
+ _failure: text
59354
+ }));
59079
59355
  var PROVIDER_DISPLAY_RANKS = {
59080
59356
  default: 0,
59081
59357
  "openai-oauth": 10,
@@ -59086,7 +59362,7 @@ var PROVIDER_DISPLAY_RANKS = {
59086
59362
  "mimo-oauth": 34,
59087
59363
  "antigravity-oauth": 31,
59088
59364
  "cursor-oauth": 32,
59089
- "opencode-go": 35,
59365
+ "opencode-go-oauth": 34.5,
59090
59366
  openai: 40,
59091
59367
  "openai-api": 40,
59092
59368
  anthropic: 50,
@@ -59551,7 +59827,7 @@ function createOnboardingSteps({
59551
59827
  }
59552
59828
 
59553
59829
  // src/runtime/shared/open-url.mjs
59554
- import { spawn as spawn3 } from "node:child_process";
59830
+ import { spawn as spawn4 } from "node:child_process";
59555
59831
 
59556
59832
  // src/runtime/shared/wsl.mjs
59557
59833
  import { readFileSync as readFileSync10 } from "node:fs";
@@ -59609,7 +59885,7 @@ function tryOpenCandidates(candidates, index) {
59609
59885
  if (index >= candidates.length) return;
59610
59886
  const [cmd, args] = candidates[index];
59611
59887
  try {
59612
- const child = spawn3(cmd, args, { stdio: "ignore", ...detachedSpawnOpts });
59888
+ const child = spawn4(cmd, args, { stdio: "ignore", ...detachedSpawnOpts });
59613
59889
  child.on("error", () => {
59614
59890
  tryOpenCandidates(candidates, index + 1);
59615
59891
  });
@@ -60013,7 +60289,7 @@ function createProviderSetupPicker({
60013
60289
  }
60014
60290
  });
60015
60291
  try {
60016
- await new Promise((resolve6) => setTimeout(resolve6, 0));
60292
+ await new Promise((resolve8) => setTimeout(resolve8, 0));
60017
60293
  return await store.getProviderSetup(options.forceRefresh ? { force: true } : void 0);
60018
60294
  } catch (e) {
60019
60295
  store.pushNotice(`providers failed: ${e?.message || e}`, "error");
@@ -60135,7 +60411,7 @@ function createModelCatalog({ store, providerModelsCacheRef, webSearchModelsCach
60135
60411
  let renderedQuickModels = false;
60136
60412
  if (!providerModels.length || options.refreshModels === true) {
60137
60413
  paintLoading();
60138
- await new Promise((resolve6) => setTimeout(resolve6, 0));
60414
+ await new Promise((resolve8) => setTimeout(resolve8, 0));
60139
60415
  try {
60140
60416
  if (options.refreshModels !== true && options.cacheRef !== "webSearch") {
60141
60417
  refreshModelsPromise = Promise.resolve(loadModels({ force: false }));
@@ -60642,6 +60918,7 @@ function createModelPicker({
60642
60918
  }
60643
60919
  const models = normalizeModelOptions(providerModels);
60644
60920
  const providerNames = await loadProviderDisplayNames(store);
60921
+ const catalogFailures = await loadProviderCatalogFailures(store);
60645
60922
  const activeRoute = options.currentRoute || {
60646
60923
  provider: state.provider,
60647
60924
  model: state.model,
@@ -60679,7 +60956,10 @@ function createModelPicker({
60679
60956
  providerListHighlightProvider = renderOptions.highlightProvider;
60680
60957
  }
60681
60958
  const highlightProvider = renderOptions.highlightProvider || providerListHighlightProvider || null;
60682
- const providerItems = buildModelProviderItems(models, activeRoute, providerNames);
60959
+ const providerItems = [
60960
+ ...buildModelProviderItems(models, activeRoute, providerNames),
60961
+ ...buildCatalogFailureItems(catalogFailures, models, providerNames)
60962
+ ];
60683
60963
  const providerHighlight = highlightProvider || activeRoute?.provider || null;
60684
60964
  const providerInitialIndex = Math.max(
60685
60965
  0,
@@ -60696,6 +60976,10 @@ function createModelPicker({
60696
60976
  pickerKey: `model-picker:providers:${providerHighlight || "default"}`,
60697
60977
  items: providerItems,
60698
60978
  onSelect: (_value, item) => {
60979
+ if (item?._failure) {
60980
+ store.pushNotice(`${item.label}: ${item._failure}`, "warn");
60981
+ return;
60982
+ }
60699
60983
  if (!item?._provider) return;
60700
60984
  openProviderModelsPicker({
60701
60985
  view,
@@ -61169,7 +61453,7 @@ import {
61169
61453
  rm as rmP,
61170
61454
  stat as statP
61171
61455
  } from "node:fs/promises";
61172
- import { basename as basename5, dirname as dirname9, join as join11, resolve as resolve5 } from "node:path";
61456
+ import { basename as basename5, dirname as dirname9, join as join11, resolve as resolve7 } from "node:path";
61173
61457
  import { homedir as homedir3 } from "node:os";
61174
61458
  import { createHash as createHash4, randomUUID } from "node:crypto";
61175
61459
  function getBackupRoot() {
@@ -61181,15 +61465,75 @@ var BACKUP_MANIFEST = "backup.json";
61181
61465
  var INIT_MARKER = ".mixdog-user-data.json";
61182
61466
  var SCOPE_PREFIX = "scope-";
61183
61467
  function normalizeDataDir(dataDir2) {
61184
- const full = resolve5(String(dataDir2));
61468
+ const full = resolve7(String(dataDir2));
61185
61469
  return process.platform === "win32" ? full.toLowerCase() : full;
61186
61470
  }
61187
61471
  function scopeDirFor(dataDir2) {
61188
61472
  const id = createHash4("sha256").update(normalizeDataDir(dataDir2)).digest("hex").slice(0, 16);
61189
61473
  return join11(getBackupRoot(), `${SCOPE_PREFIX}${id}`);
61190
61474
  }
61191
- function stamp() {
61192
- return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
61475
+ var lastBackupMs = 0;
61476
+ var backupSeq = 0;
61477
+ var BACKUP_NAME_RE = /^(\d{4}-\d{2}-\d{2})T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z-(?:(\d{10})-)?/;
61478
+ function newestBackupOrder(names) {
61479
+ let ms = 0;
61480
+ let seq = -1;
61481
+ for (const name of names) {
61482
+ const match = BACKUP_NAME_RE.exec(name);
61483
+ if (!match) continue;
61484
+ const time = Date.parse(`${match[1]}T${match[2]}:${match[3]}:${match[4]}.${match[5]}Z`);
61485
+ if (!Number.isFinite(time)) continue;
61486
+ const order = match[6] === void 0 ? Number.POSITIVE_INFINITY : Number(match[6]);
61487
+ if (time > ms || time === ms && order > seq) {
61488
+ ms = time;
61489
+ seq = order;
61490
+ }
61491
+ }
61492
+ return { ms, seq };
61493
+ }
61494
+ function nextBackupName(names, reason) {
61495
+ const newest = newestBackupOrder(names);
61496
+ lastBackupMs = Math.max(Date.now(), lastBackupMs, newest.ms);
61497
+ if (lastBackupMs === newest.ms) {
61498
+ if (newest.seq === Number.POSITIVE_INFINITY) lastBackupMs += 1;
61499
+ else backupSeq = Math.max(backupSeq, newest.seq + 1);
61500
+ }
61501
+ const time = new Date(lastBackupMs).toISOString().replace(/[:.]/g, "-");
61502
+ return `${time}-${String(backupSeq++).padStart(10, "0")}-${safeReason(reason)}`;
61503
+ }
61504
+ function scopeBackupNames(entries) {
61505
+ return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
61506
+ }
61507
+ function reserveBackupDir(scopeDir, reason) {
61508
+ mkdirSync4(scopeDir, { recursive: true });
61509
+ const names = scopeBackupNames(readdirSync2(scopeDir, { withFileTypes: true }));
61510
+ for (; ; ) {
61511
+ const name = nextBackupName(names, reason);
61512
+ names.push(name);
61513
+ try {
61514
+ mkdirSync4(join11(scopeDir, name));
61515
+ return { backupDir: join11(scopeDir, name), names };
61516
+ } catch (error) {
61517
+ if (error?.code !== "EEXIST") throw error;
61518
+ }
61519
+ }
61520
+ }
61521
+ async function reserveBackupDirAsync(scopeDir, reason) {
61522
+ await mkdirP(scopeDir, { recursive: true });
61523
+ const names = scopeBackupNames(await readdirP(scopeDir, { withFileTypes: true }));
61524
+ for (; ; ) {
61525
+ const name = nextBackupName(names, reason);
61526
+ names.push(name);
61527
+ try {
61528
+ await mkdirP(join11(scopeDir, name));
61529
+ return { backupDir: join11(scopeDir, name), names };
61530
+ } catch (error) {
61531
+ if (error?.code !== "EEXIST") throw error;
61532
+ }
61533
+ }
61534
+ }
61535
+ function backupsToPrune(names, own, keep = 40) {
61536
+ return [...names].sort().reverse().slice(keep).filter((name) => name !== own);
61193
61537
  }
61194
61538
  function safeReason(reason) {
61195
61539
  return String(reason || "snapshot").replace(/[^a-z0-9_.-]+/gi, "-").slice(0, 48) || "snapshot";
@@ -61221,7 +61565,7 @@ function manifestDataDirMatches(backupDir, dataDirKey) {
61221
61565
  }
61222
61566
  function legacyMarkersFor(root, dataDir2, dataDirKey) {
61223
61567
  const hashed = new Set(
61224
- [String(dataDir2), resolve5(String(dataDir2))].map(
61568
+ [String(dataDir2), resolve7(String(dataDir2))].map(
61225
61569
  (value) => `.initialized-${createHash4("sha256").update(value).digest("hex").slice(0, 16)}.json`
61226
61570
  )
61227
61571
  );
@@ -61275,9 +61619,20 @@ function isStructurallyCompleteMixdogConfigBackup(parsed) {
61275
61619
  if (!parsed.agent && !parsed.channels) return false;
61276
61620
  return true;
61277
61621
  }
61278
- function backupDirsNewestFirst(dir) {
61622
+ function isAbsentBackupError(error) {
61623
+ return error instanceof SyntaxError || error?.code === "ENOENT" || error?.code === "ENOTDIR";
61624
+ }
61625
+ function listBackupDirsNewestFirst(dir) {
61279
61626
  try {
61280
61627
  return readdirSync2(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort().reverse();
61628
+ } catch (error) {
61629
+ if (isAbsentBackupError(error)) return [];
61630
+ throw error;
61631
+ }
61632
+ }
61633
+ function backupDirsNewestFirst(dir) {
61634
+ try {
61635
+ return listBackupDirsNewestFirst(dir);
61281
61636
  } catch {
61282
61637
  return [];
61283
61638
  }
@@ -61289,19 +61644,20 @@ function readRestorableConfig(backupDir, dataDirKey, instanceId) {
61289
61644
  if (manifest.instanceId !== instanceId) return null;
61290
61645
  const parsed = JSON.parse(readFileSync11(join11(backupDir, "mixdog-config.json"), "utf8"));
61291
61646
  return isStructurallyCompleteMixdogConfigBackup(parsed) ? parsed : null;
61292
- } catch {
61293
- return null;
61647
+ } catch (error) {
61648
+ if (isAbsentBackupError(error)) return null;
61649
+ throw error;
61294
61650
  }
61295
61651
  }
61296
61652
  function findRestorableConfig(dataDir2, instanceId) {
61297
61653
  const key = normalizeDataDir(dataDir2);
61298
61654
  const scopeDir = scopeDirFor(dataDir2);
61299
- for (const name of backupDirsNewestFirst(scopeDir)) {
61655
+ for (const name of listBackupDirsNewestFirst(scopeDir)) {
61300
61656
  const parsed = readRestorableConfig(join11(scopeDir, name), key, instanceId);
61301
61657
  if (parsed) return parsed;
61302
61658
  }
61303
61659
  const root = getBackupRoot();
61304
- for (const name of backupDirsNewestFirst(root)) {
61660
+ for (const name of listBackupDirsNewestFirst(root)) {
61305
61661
  if (name.startsWith(SCOPE_PREFIX)) continue;
61306
61662
  const parsed = readRestorableConfig(join11(root, name), key, instanceId);
61307
61663
  if (parsed) return parsed;
@@ -61315,7 +61671,8 @@ function loadLatestMixdogConfigFromBackup(dataDir2, options) {
61315
61671
  const key = normalizeDataDir(dataDir2);
61316
61672
  const root = getBackupRoot();
61317
61673
  let hit = restoreLookupCache.get(key);
61318
- if (!hit || hit.root !== root || hit.instanceId !== instanceId) {
61674
+ if (options?.fresh || !hit || hit.root !== root || hit.instanceId !== instanceId) {
61675
+ restoreLookupCache.delete(key);
61319
61676
  hit = { root, instanceId, config: findRestorableConfig(dataDir2, instanceId) };
61320
61677
  restoreLookupCache.set(key, hit);
61321
61678
  }
@@ -61345,8 +61702,8 @@ function copyTree(src, dst, copied) {
61345
61702
  copyFileSync(src, dst);
61346
61703
  copied.push(dst);
61347
61704
  }
61348
- function pruneBackups(scopeDir, keep = 40) {
61349
- for (const name of backupDirsNewestFirst(scopeDir).slice(keep)) {
61705
+ function pruneBackups(scopeDir, names, own) {
61706
+ for (const name of backupsToPrune(names, own)) {
61350
61707
  try {
61351
61708
  rmSync(join11(scopeDir, name), { recursive: true, force: true });
61352
61709
  } catch {
@@ -61360,7 +61717,7 @@ function markUserDataInitialized(dataDir2) {
61360
61717
  writeFileSync4(
61361
61718
  join11(dataDir2, INIT_MARKER),
61362
61719
  `${JSON.stringify(
61363
- { instanceId: randomUUID(), dataDir: resolve5(dataDir2), createdAt: (/* @__PURE__ */ new Date()).toISOString() },
61720
+ { instanceId: randomUUID(), dataDir: resolve7(dataDir2), createdAt: (/* @__PURE__ */ new Date()).toISOString() },
61364
61721
  null,
61365
61722
  2
61366
61723
  )}
@@ -61383,16 +61740,12 @@ function ensureUserDataInitialized(dataDir2) {
61383
61740
  function skipBackups() {
61384
61741
  return process.env.MIXDOG_SKIP_USER_DATA_BACKUP === "1" || process.env.MIXDOG_SKIP_USER_DATA_BACKUP === "true";
61385
61742
  }
61386
- function backupTarget(dataDir2, reason) {
61387
- const scopeDir = scopeDirFor(dataDir2);
61388
- return { scopeDir, backupDir: join11(scopeDir, `${stamp()}-${safeReason(reason)}`) };
61389
- }
61390
61743
  function finishBackup(dataDir2, backupDir, reason) {
61391
61744
  const instanceId = markUserDataInitialized(dataDir2);
61392
61745
  writeFileSync4(
61393
61746
  join11(backupDir, BACKUP_MANIFEST),
61394
61747
  `${JSON.stringify(
61395
- { dataDir: resolve5(dataDir2), instanceId, reason, createdAt: (/* @__PURE__ */ new Date()).toISOString() },
61748
+ { dataDir: resolve7(dataDir2), instanceId, reason, createdAt: (/* @__PURE__ */ new Date()).toISOString() },
61396
61749
  null,
61397
61750
  2
61398
61751
  )}
@@ -61405,7 +61758,8 @@ function finishBackup(dataDir2, backupDir, reason) {
61405
61758
  function backupUserData(dataDir2, reason = "snapshot") {
61406
61759
  if (skipBackups()) return { dir: null, copied: [] };
61407
61760
  if (!dataDir2 || !existsSync10(dataDir2)) return { dir: null, copied: [] };
61408
- const { scopeDir, backupDir } = backupTarget(dataDir2, reason);
61761
+ const scopeDir = scopeDirFor(dataDir2);
61762
+ const { backupDir, names } = reserveBackupDir(scopeDir, reason);
61409
61763
  const copied = [];
61410
61764
  for (const rel of USER_DATA_FILES) {
61411
61765
  const src = join11(dataDir2, rel);
@@ -61417,11 +61771,13 @@ function backupUserData(dataDir2, reason = "snapshot") {
61417
61771
  }
61418
61772
  if (copied.length > 0) {
61419
61773
  finishBackup(dataDir2, backupDir, reason);
61420
- pruneBackups(scopeDir);
61774
+ pruneBackups(scopeDir, names, basename5(backupDir));
61421
61775
  if (process.env.MIXDOG_SETUP_QUIET !== "1") {
61422
61776
  process.stderr.write(`[user-data-backup] ${reason}: copied ${copied.length} file(s) to ${backupDir}
61423
61777
  `);
61424
61778
  }
61779
+ } else {
61780
+ rmSync(backupDir, { recursive: true, force: true });
61425
61781
  }
61426
61782
  return { dir: copied.length > 0 ? backupDir : null, copied };
61427
61783
  }
@@ -61438,14 +61794,8 @@ async function copyTreeAsync(src, dst, copied) {
61438
61794
  await copyFileP(src, dst);
61439
61795
  copied.push(dst);
61440
61796
  }
61441
- async function pruneBackupsAsync(scopeDir, keep = 40) {
61442
- let entries = [];
61443
- try {
61444
- entries = (await readdirP(scopeDir, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort().reverse();
61445
- } catch {
61446
- return;
61447
- }
61448
- for (const name of entries.slice(keep)) {
61797
+ async function pruneBackupsAsync(scopeDir, names, own) {
61798
+ for (const name of backupsToPrune(names, own)) {
61449
61799
  try {
61450
61800
  await rmP(join11(scopeDir, name), { recursive: true, force: true });
61451
61801
  } catch {
@@ -61455,7 +61805,8 @@ async function pruneBackupsAsync(scopeDir, keep = 40) {
61455
61805
  async function backupUserDataAsync(dataDir2, reason = "snapshot") {
61456
61806
  if (skipBackups()) return { dir: null, copied: [] };
61457
61807
  if (!dataDir2 || !existsSync10(dataDir2)) return { dir: null, copied: [] };
61458
- const { scopeDir, backupDir } = backupTarget(dataDir2, reason);
61808
+ const scopeDir = scopeDirFor(dataDir2);
61809
+ const { backupDir, names } = await reserveBackupDirAsync(scopeDir, reason);
61459
61810
  const copied = [];
61460
61811
  for (const rel of USER_DATA_FILES) {
61461
61812
  const src = join11(dataDir2, rel);
@@ -61467,11 +61818,13 @@ async function backupUserDataAsync(dataDir2, reason = "snapshot") {
61467
61818
  }
61468
61819
  if (copied.length > 0) {
61469
61820
  finishBackup(dataDir2, backupDir, reason);
61470
- await pruneBackupsAsync(scopeDir);
61821
+ await pruneBackupsAsync(scopeDir, names, basename5(backupDir));
61471
61822
  if (process.env.MIXDOG_SETUP_QUIET !== "1") {
61472
61823
  process.stderr.write(`[user-data-backup] ${reason}: copied ${copied.length} file(s) to ${backupDir}
61473
61824
  `);
61474
61825
  }
61826
+ } else {
61827
+ rmSync(backupDir, { recursive: true, force: true });
61475
61828
  }
61476
61829
  return { dir: copied.length > 0 ? backupDir : null, copied };
61477
61830
  }
@@ -61486,7 +61839,6 @@ var AGENT_PROVIDER_ENV = Object.freeze({
61486
61839
  gemini: "GEMINI_API_KEY",
61487
61840
  deepseek: "DEEPSEEK_API_KEY",
61488
61841
  xai: "XAI_API_KEY",
61489
- "opencode-go": "OPENCODE_API_KEY",
61490
61842
  openrouter: "OPENROUTER_API_KEY"
61491
61843
  });
61492
61844
  var AGENT_PROVIDER_ENV_ALIASES = Object.freeze({
@@ -61688,7 +62040,13 @@ function readAll() {
61688
62040
  return canonicalizeUnifiedConfig(parsed);
61689
62041
  }
61690
62042
  if (isUserDataRecoveryExpected(resolvePluginData())) {
61691
- const restored = loadLatestMixdogConfigFromBackup(resolvePluginData());
62043
+ let restored = null;
62044
+ try {
62045
+ restored = loadLatestMixdogConfigFromBackup(resolvePluginData());
62046
+ } catch (err) {
62047
+ process.stderr.write(`[config] backup restore lookup failed: ${err.message}
62048
+ `);
62049
+ }
61692
62050
  if (restored && isPlainObject(restored)) {
61693
62051
  const config = canonicalizeUnifiedConfig(restored);
61694
62052
  persistRestoredConfig(config);
@@ -61828,8 +62186,7 @@ function updateSectionAsync(section, updater) {
61828
62186
  }
61829
62187
  var SECRET_ACCOUNTS = Object.freeze({
61830
62188
  agentApiKey: (provider) => `agent.${provider}.apiKey`,
61831
- openaiUsageSessionKey: "agent.openai.usageSessionKey",
61832
- opencodeGoConsoleKey: "agent.opencode-go.consoleKey"
62189
+ openaiUsageSessionKey: "agent.openai.usageSessionKey"
61833
62190
  });
61834
62191
 
61835
62192
  // src/runtime/channels/lib/voice-setup.mjs
@@ -63282,8 +63639,8 @@ function usePromptQueueHistory({
63282
63639
  let timer2 = null;
63283
63640
  Promise.race([
63284
63641
  Promise.resolve(store.dispose?.("cli-react-exit", { detach: true })),
63285
- new Promise((resolve6) => {
63286
- timer2 = setTimeout(resolve6, 350);
63642
+ new Promise((resolve8) => {
63643
+ timer2 = setTimeout(resolve8, 350);
63287
63644
  })
63288
63645
  ]).finally(() => {
63289
63646
  if (timer2) clearTimeout(timer2);
@@ -63488,14 +63845,15 @@ function useTerminalChrome({ stdout: stdout2, isRawModeSupported, setResizeState
63488
63845
  import { useCallback as useCallback21, useEffect as useEffect27, useLayoutEffect as useLayoutEffect8 } from "react";
63489
63846
 
63490
63847
  // src/tui/session/transcript-spill.mjs
63848
+ import { randomBytes as randomBytes4 } from "node:crypto";
63491
63849
  import { readFileSync as readFileSync16 } from "node:fs";
63492
63850
  import { join as join16 } from "node:path";
63493
- import { Worker } from "node:worker_threads";
63851
+ import { Worker as Worker2 } from "node:worker_threads";
63494
63852
 
63495
63853
  // src/tui/session/transcript-spill/spill-dir.mjs
63496
63854
  import { randomUUID as randomUUID2 } from "node:crypto";
63497
63855
  import { mkdtempSync, readdirSync as readdirSync5, readFileSync as readFileSync15, rmSync as rmSync5, statSync as statSync6, writeFileSync as writeFileSync6 } from "node:fs";
63498
- import { tmpdir as tmpdir2 } from "node:os";
63856
+ import { tmpdir as tmpdir3 } from "node:os";
63499
63857
  import { join as join15 } from "node:path";
63500
63858
  var STALE_MS = 24 * 60 * 60 * 1e3;
63501
63859
  var PROCESS_NONCE = randomUUID2();
@@ -63505,6 +63863,7 @@ import { randomUUID as randomUUID3 } from "node:crypto";
63505
63863
 
63506
63864
  // src/tui/session/transcript-spill.mjs
63507
63865
  var TUI_DEBUG = /^(1|true|yes|on)$/i.test(String(process.env.MIXDOG_TUI_DEBUG || ""));
63866
+ var ID_PREFIX = `it_${randomBytes4(4).toString("hex")}_`;
63508
63867
 
63509
63868
  // src/tui/app/transcript-measure.mjs
63510
63869
  var HARVEST_BUMP_STREAK_LIMIT = 10;
@@ -65870,8 +66229,8 @@ function waitWithTimeout(promise, ms) {
65870
66229
  let timer2 = null;
65871
66230
  return Promise.race([
65872
66231
  Promise.resolve(promise).then(() => true),
65873
- new Promise((resolve6) => {
65874
- timer2 = setTimeout(() => resolve6(false), ms);
66232
+ new Promise((resolve8) => {
66233
+ timer2 = setTimeout(() => resolve8(false), ms);
65875
66234
  })
65876
66235
  ]).finally(() => {
65877
66236
  if (timer2) clearTimeout(timer2);
@@ -65890,7 +66249,7 @@ function scheduleHardExit(code = 0) {
65890
66249
  timer2.unref?.();
65891
66250
  }
65892
66251
  function resolveTuiStderrLogPath() {
65893
- return process.env.MIXDOG_TUI_STDERR_LOG || join17(process.env.MIXDOG_RUNTIME_ROOT || join17(tmpdir3(), "mixdog"), "mixdog-tui.stderr.log");
66252
+ return process.env.MIXDOG_TUI_STDERR_LOG || join17(process.env.MIXDOG_RUNTIME_ROOT || join17(tmpdir4(), "mixdog"), "mixdog-tui.stderr.log");
65894
66253
  }
65895
66254
  function ansiFg(rgb2) {
65896
66255
  const m = /rgb\((\d+),\s*(\d+),\s*(\d+)\)/.exec(String(rgb2 || ""));