mixdog 0.9.168 → 0.9.169

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 (1216) hide show
  1. package/README.md +84 -11
  2. package/package.json +1 -1
  3. package/scripts/agent-lead-e2e-probe.mjs +66 -39
  4. package/scripts/agent-turn-trace-probe.mjs +68 -36
  5. package/scripts/audit-usage-ledger.mjs +102 -47
  6. package/scripts/build-tui.mjs +1 -4
  7. package/scripts/code-graph-description-contract.mjs +41 -30
  8. package/scripts/computer-task-cost-report.mjs +5 -19
  9. package/scripts/context-renewal-live-check.mjs +64 -24
  10. package/scripts/daemon-stub.mjs +66 -24
  11. package/scripts/dependency-lock-cache-key.mjs +15 -17
  12. package/scripts/embedding-quality-probe.mjs +42 -34
  13. package/scripts/fixtures/spawn-lease-fixture-worker.mjs +5 -1
  14. package/scripts/generate-runtime-manifest.mjs +37 -22
  15. package/scripts/graph-parity.mjs +103 -41
  16. package/scripts/import-usage-ledger.mjs +5 -3
  17. package/scripts/lib/embedding-model-bench-core.mjs +126 -124
  18. package/scripts/lib/isolated-root-cleanup.mjs +11 -5
  19. package/scripts/lib/local-provider-live-scenarios.mjs +14 -5
  20. package/scripts/lib/recall-bench-eval.mjs +32 -18
  21. package/scripts/lib/stage-postgres-runtime-windows.ps1 +2 -2
  22. package/scripts/lib/test-timing-reporter.mjs +8 -2
  23. package/scripts/llm-trace-summary.mjs +48 -23
  24. package/scripts/local-provider-live-check.mjs +180 -79
  25. package/scripts/manifest-cache-key.mjs +16 -16
  26. package/scripts/media-image-live.mjs +123 -56
  27. package/scripts/memory-chunk-quality.mjs +120 -87
  28. package/scripts/memory-layer2-check.mjs +157 -104
  29. package/scripts/model-catalog-audit.mjs +22 -14
  30. package/scripts/mouse-probe.mjs +17 -3
  31. package/scripts/native-binary-arch.mjs +62 -50
  32. package/scripts/native-spawn-test-runtime.mjs +1 -1
  33. package/scripts/native-tool-download.mjs +61 -60
  34. package/scripts/office/aesthetics-probe.mjs +28 -7
  35. package/scripts/office/author-deck.mjs +48 -13
  36. package/scripts/office/build-pptx-icons.mjs +278 -12
  37. package/scripts/office-design-audit.mjs +16 -16
  38. package/scripts/office-live-test-plan.mjs +10 -1
  39. package/scripts/patch-replay.mjs +46 -16
  40. package/scripts/pdf-rotation-stress.mjs +8 -4
  41. package/scripts/perf/cold-reconnect-probe.mjs +78 -41
  42. package/scripts/perf/transcript-baseline.mjs +76 -47
  43. package/scripts/perf/transcript-runtime-probe.mjs +50 -24
  44. package/scripts/pg-memory-diet-apply.mjs +86 -56
  45. package/scripts/pg-memory-diet-verify.mjs +101 -60
  46. package/scripts/pg-memory-diet.mjs +208 -113
  47. package/scripts/prepare-native-assets.mjs +8 -19
  48. package/scripts/prune-desktop-runtime.mjs +136 -163
  49. package/scripts/prune-embedding-runtime.mjs +78 -90
  50. package/scripts/reduction-trace-report.mjs +18 -14
  51. package/scripts/release-paths.mjs +2 -12
  52. package/scripts/release-timing-report.mjs +38 -26
  53. package/scripts/routing-corpus.mjs +311 -102
  54. package/scripts/run-office-live-tests.mjs +4 -1
  55. package/scripts/runtime-dependency-cache-key.mjs +39 -39
  56. package/scripts/search-rg-parity.mjs +149 -97
  57. package/scripts/session-diag.mjs +30 -18
  58. package/scripts/session-sweep.mjs +235 -191
  59. package/scripts/smoke.mjs +9 -2
  60. package/scripts/suite-health.mjs +1 -2
  61. package/scripts/test.mjs +13 -5
  62. package/scripts/tidy/sync-engines-manifest.mjs +274 -266
  63. package/scripts/tool-efficiency-diag.mjs +36 -11
  64. package/scripts/tool-failures.mjs +68 -50
  65. package/scripts/tool-overhead-microbench.mjs +17 -11
  66. package/scripts/tool-stress.mjs +166 -57
  67. package/scripts/tui-frame-harness-shim.mjs +16 -6
  68. package/scripts/tui-frame-harness.mjs +171 -68
  69. package/scripts/tui-transcript-jitter-harness.mjs +0 -2
  70. package/scripts/verify-release-assets.mjs +25 -38
  71. package/src/app.mjs +24 -18
  72. package/src/cli.mjs +24 -19
  73. package/src/defaults/skills/browser-use/SKILL.md +5 -3
  74. package/src/defaults/skills/code-tidy/SKILL.md +8 -7
  75. package/src/defaults/skills/computer-use/SKILL.md +3 -1
  76. package/src/defaults/skills/pptx/scripts/qc-pages.mjs +107 -54
  77. package/src/defaults/skills/pptx/scripts/review-deck.mjs +102 -34
  78. package/src/defaults/skills/pptx/scripts/source-extract.mjs +6 -3
  79. package/src/defaults/skills/skill-creator/scripts/validate-skill.mjs +25 -27
  80. package/src/headless-command.mjs +22 -13
  81. package/src/headless-exec.mjs +272 -268
  82. package/src/headless-role.mjs +17 -31
  83. package/src/lib/keychain-cjs.cjs +410 -358
  84. package/src/lib/mixdog-debug.cjs +20 -14
  85. package/src/lib/output-style-meta.cjs +22 -13
  86. package/src/lib/rules-builder.cjs +46 -23
  87. package/src/lib/text-utils.cjs +44 -42
  88. package/src/repl.mjs +72 -57
  89. package/src/rules/lead/lead-brief.md +9 -13
  90. package/src/runtime/agent/orchestrator/activity-bus.mjs +5 -1
  91. package/src/runtime/agent/orchestrator/agent-owner.mjs +9 -4
  92. package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +419 -382
  93. package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +215 -221
  94. package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +255 -254
  95. package/src/runtime/agent/orchestrator/agent-runtime/completion-text.mjs +9 -9
  96. package/src/runtime/agent/orchestrator/agent-runtime/maintenance-route.mjs +36 -36
  97. package/src/runtime/agent/orchestrator/agent-runtime/session-builder.mjs +108 -93
  98. package/src/runtime/agent/orchestrator/agent-runtime/title-completion.mjs +54 -48
  99. package/src/runtime/agent/orchestrator/agent-trace-format.mjs +702 -609
  100. package/src/runtime/agent/orchestrator/agent-trace-io.mjs +353 -330
  101. package/src/runtime/agent/orchestrator/agent-trace.mjs +295 -298
  102. package/src/runtime/agent/orchestrator/cache-break-trace.mjs +87 -86
  103. package/src/runtime/agent/orchestrator/cache-mtime.mjs +32 -21
  104. package/src/runtime/agent/orchestrator/config-presets.mjs +99 -63
  105. package/src/runtime/agent/orchestrator/config-storage.mjs +226 -194
  106. package/src/runtime/agent/orchestrator/config.mjs +343 -338
  107. package/src/runtime/agent/orchestrator/context/collect.mjs +19 -19
  108. package/src/runtime/agent/orchestrator/context/deferred-tools.mjs +180 -176
  109. package/src/runtime/agent/orchestrator/context/role-instructions.mjs +199 -194
  110. package/src/runtime/agent/orchestrator/context/skill-catalog.mjs +288 -288
  111. package/src/runtime/agent/orchestrator/context/skill-state.mjs +38 -30
  112. package/src/runtime/agent/orchestrator/dispatch-persist.mjs +52 -240
  113. package/src/runtime/agent/orchestrator/internal-agents.mjs +59 -58
  114. package/src/runtime/agent/orchestrator/internal-tools.mjs +47 -51
  115. package/src/runtime/agent/orchestrator/mcp/child-tree.mjs +222 -161
  116. package/src/runtime/agent/orchestrator/mcp/client.mjs +984 -904
  117. package/src/runtime/agent/orchestrator/mcp/reconnect-singleflight.mjs +21 -21
  118. package/src/runtime/agent/orchestrator/providers/account-pool.mjs +33 -17
  119. package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +532 -513
  120. package/src/runtime/agent/orchestrator/providers/anthropic-betas.mjs +34 -32
  121. package/src/runtime/agent/orchestrator/providers/anthropic-effort.mjs +249 -237
  122. package/src/runtime/agent/orchestrator/providers/anthropic-fable-history.mjs +64 -55
  123. package/src/runtime/agent/orchestrator/providers/anthropic-fast-mode.mjs +32 -32
  124. package/src/runtime/agent/orchestrator/providers/anthropic-leaked-toolcall.mjs +297 -280
  125. package/src/runtime/agent/orchestrator/providers/anthropic-max-tokens.mjs +33 -33
  126. package/src/runtime/agent/orchestrator/providers/anthropic-messages.mjs +107 -96
  127. package/src/runtime/agent/orchestrator/providers/anthropic-model-resolve.mjs +117 -118
  128. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +72 -67
  129. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-credentials.mjs +564 -496
  130. package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +1262 -1138
  131. package/src/runtime/agent/orchestrator/providers/anthropic-server-fallback.mjs +24 -34
  132. package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +1017 -915
  133. package/src/runtime/agent/orchestrator/providers/anthropic-thinking-contract.mjs +11 -7
  134. package/src/runtime/agent/orchestrator/providers/anthropic.mjs +745 -674
  135. package/src/runtime/agent/orchestrator/providers/antigravity-oauth-catalog.mjs +135 -134
  136. package/src/runtime/agent/orchestrator/providers/antigravity-oauth-login.mjs +361 -308
  137. package/src/runtime/agent/orchestrator/providers/antigravity-oauth-tokens.mjs +205 -189
  138. package/src/runtime/agent/orchestrator/providers/antigravity-oauth.mjs +440 -424
  139. package/src/runtime/agent/orchestrator/providers/antigravity-request.mjs +77 -65
  140. package/src/runtime/agent/orchestrator/providers/api-usage.mjs +99 -55
  141. package/src/runtime/agent/orchestrator/providers/codex-client-meta.mjs +59 -53
  142. package/src/runtime/agent/orchestrator/providers/compat-request-policy.mjs +9 -9
  143. package/src/runtime/agent/orchestrator/providers/cursor-auth.mjs +242 -215
  144. package/src/runtime/agent/orchestrator/providers/cursor-wire-guards.mjs +227 -221
  145. package/src/runtime/agent/orchestrator/providers/cursor-wire-interactions.mjs +68 -68
  146. package/src/runtime/agent/orchestrator/providers/cursor-wire-normalization.mjs +174 -156
  147. package/src/runtime/agent/orchestrator/providers/cursor-wire-protobuf.mjs +823 -827
  148. package/src/runtime/agent/orchestrator/providers/cursor-wire.mjs +1413 -1286
  149. package/src/runtime/agent/orchestrator/providers/cursor.mjs +614 -589
  150. package/src/runtime/agent/orchestrator/providers/custom-tool-wire.mjs +27 -19
  151. package/src/runtime/agent/orchestrator/providers/effort-configuration.mjs +120 -97
  152. package/src/runtime/agent/orchestrator/providers/gemini-cache.mjs +223 -231
  153. package/src/runtime/agent/orchestrator/providers/gemini-history-signatures.mjs +27 -21
  154. package/src/runtime/agent/orchestrator/providers/gemini-schema.mjs +752 -733
  155. package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +700 -628
  156. package/src/runtime/agent/orchestrator/providers/gemini-thinking.mjs +39 -39
  157. package/src/runtime/agent/orchestrator/providers/gemini.mjs +1055 -1002
  158. package/src/runtime/agent/orchestrator/providers/grok-oauth-login.mjs +149 -127
  159. package/src/runtime/agent/orchestrator/providers/grok-oauth-tokens.mjs +325 -268
  160. package/src/runtime/agent/orchestrator/providers/grok-oauth.mjs +444 -397
  161. package/src/runtime/agent/orchestrator/providers/lib/action-input-contract.mjs +29 -25
  162. package/src/runtime/agent/orchestrator/providers/lib/anthropic-image-input.mjs +101 -89
  163. package/src/runtime/agent/orchestrator/providers/lib/anthropic-native-blocks.mjs +7 -8
  164. package/src/runtime/agent/orchestrator/providers/lib/anthropic-replay-blocks.mjs +37 -36
  165. package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +387 -394
  166. package/src/runtime/agent/orchestrator/providers/lib/gemini-model-catalog.mjs +96 -92
  167. package/src/runtime/agent/orchestrator/providers/lib/grok-tool-schema.mjs +200 -176
  168. package/src/runtime/agent/orchestrator/providers/lib/oauth-pkce.mjs +20 -20
  169. package/src/runtime/agent/orchestrator/providers/lib/oauth-token-utils.mjs +22 -20
  170. package/src/runtime/agent/orchestrator/providers/lib/openai-tool-args.mjs +41 -42
  171. package/src/runtime/agent/orchestrator/providers/lib/provider-replay.mjs +40 -34
  172. package/src/runtime/agent/orchestrator/providers/lib/sse-framing.mjs +39 -39
  173. package/src/runtime/agent/orchestrator/providers/lib/stream-outcome.mjs +119 -90
  174. package/src/runtime/agent/orchestrator/providers/lib/wire-pairing.mjs +87 -81
  175. package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +489 -421
  176. package/src/runtime/agent/orchestrator/providers/mixdog-local-wire.mjs +1 -3
  177. package/src/runtime/agent/orchestrator/providers/mixdog-local.mjs +24 -17
  178. package/src/runtime/agent/orchestrator/providers/model-cache.mjs +31 -23
  179. package/src/runtime/agent/orchestrator/providers/model-catalog-projection.mjs +106 -100
  180. package/src/runtime/agent/orchestrator/providers/model-catalog.mjs +562 -494
  181. package/src/runtime/agent/orchestrator/providers/model-list-sanitize.mjs +93 -39
  182. package/src/runtime/agent/orchestrator/providers/model-pricing-rates.mjs +50 -34
  183. package/src/runtime/agent/orchestrator/providers/model-service-tiers.mjs +8 -6
  184. package/src/runtime/agent/orchestrator/providers/oauth-credential-probes.mjs +117 -95
  185. package/src/runtime/agent/orchestrator/providers/oauth-usage.mjs +177 -147
  186. package/src/runtime/agent/orchestrator/providers/openai-codex-endpoints.mjs +1 -1
  187. package/src/runtime/agent/orchestrator/providers/openai-codex-metadata.mjs +186 -186
  188. package/src/runtime/agent/orchestrator/providers/openai-codex-model.mjs +80 -83
  189. package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream.mjs +317 -295
  190. package/src/runtime/agent/orchestrator/providers/openai-compat-presets.mjs +20 -20
  191. package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +183 -167
  192. package/src/runtime/agent/orchestrator/providers/openai-compat-stream-common.mjs +113 -111
  193. package/src/runtime/agent/orchestrator/providers/openai-compat-stream.mjs +579 -498
  194. package/src/runtime/agent/orchestrator/providers/openai-compat-trace.mjs +41 -43
  195. package/src/runtime/agent/orchestrator/providers/openai-compat-wire.mjs +367 -352
  196. package/src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs +549 -476
  197. package/src/runtime/agent/orchestrator/providers/openai-compat.mjs +1132 -1106
  198. package/src/runtime/agent/orchestrator/providers/openai-direct-request.mjs +12 -12
  199. package/src/runtime/agent/orchestrator/providers/openai-oauth-catalog.mjs +81 -82
  200. package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +1122 -1049
  201. package/src/runtime/agent/orchestrator/providers/openai-oauth-login.mjs +137 -124
  202. package/src/runtime/agent/orchestrator/providers/openai-oauth-tokens.mjs +257 -200
  203. package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +1509 -1419
  204. package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +567 -564
  205. package/src/runtime/agent/orchestrator/providers/openai-responses-input.mjs +157 -158
  206. package/src/runtime/agent/orchestrator/providers/openai-responses-payload.mjs +197 -201
  207. package/src/runtime/agent/orchestrator/providers/openai-startup-prewarm.mjs +104 -100
  208. package/src/runtime/agent/orchestrator/providers/openai-transport-policy.mjs +76 -62
  209. package/src/runtime/agent/orchestrator/providers/openai-turn-state.mjs +37 -37
  210. package/src/runtime/agent/orchestrator/providers/openai-ws-delta.mjs +345 -336
  211. package/src/runtime/agent/orchestrator/providers/openai-ws-events.mjs +72 -66
  212. package/src/runtime/agent/orchestrator/providers/openai-ws-headers.mjs +92 -91
  213. package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +805 -665
  214. package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +1425 -1331
  215. package/src/runtime/agent/orchestrator/providers/openai-ws.mjs +229 -239
  216. package/src/runtime/agent/orchestrator/providers/opencode-go-usage.mjs +46 -34
  217. package/src/runtime/agent/orchestrator/providers/opencode-go.mjs +132 -140
  218. package/src/runtime/agent/orchestrator/providers/provider-catalog-cache.mjs +19 -11
  219. package/src/runtime/agent/orchestrator/providers/provider-model-identities.mjs +30 -27
  220. package/src/runtime/agent/orchestrator/providers/registry.mjs +383 -354
  221. package/src/runtime/agent/orchestrator/providers/retry-classifier.mjs +644 -537
  222. package/src/runtime/agent/orchestrator/providers/stream-json-pool.mjs +592 -567
  223. package/src/runtime/agent/orchestrator/providers/stream-json-worker.mjs +37 -37
  224. package/src/runtime/agent/orchestrator/providers/tool-stream-state.mjs +43 -46
  225. package/src/runtime/agent/orchestrator/providers/trace-utils.mjs +30 -30
  226. package/src/runtime/agent/orchestrator/session/abort-lookup.mjs +6 -6
  227. package/src/runtime/agent/orchestrator/session/agent-loop.mjs +508 -469
  228. package/src/runtime/agent/orchestrator/session/browser-snapshot-supersession.mjs +2 -2
  229. package/src/runtime/agent/orchestrator/session/cache/prefetch-cache.mjs +112 -94
  230. package/src/runtime/agent/orchestrator/session/cache/read-cache.mjs +260 -243
  231. package/src/runtime/agent/orchestrator/session/cache/scoped-cache-outcome.mjs +3 -3
  232. package/src/runtime/agent/orchestrator/session/cache/scoped-cache.mjs +400 -316
  233. package/src/runtime/agent/orchestrator/session/cache/util.mjs +45 -34
  234. package/src/runtime/agent/orchestrator/session/compact/budget.mjs +96 -83
  235. package/src/runtime/agent/orchestrator/session/compact/constants.mjs +20 -17
  236. package/src/runtime/agent/orchestrator/session/compact/continuation.mjs +33 -40
  237. package/src/runtime/agent/orchestrator/session/compact/execution-tail.mjs +117 -110
  238. package/src/runtime/agent/orchestrator/session/compact/messages.mjs +119 -123
  239. package/src/runtime/agent/orchestrator/session/compact/runner.mjs +427 -448
  240. package/src/runtime/agent/orchestrator/session/compact/summary-schema.mjs +223 -222
  241. package/src/runtime/agent/orchestrator/session/compact/summary.mjs +433 -441
  242. package/src/runtime/agent/orchestrator/session/compact/text-utils.mjs +217 -195
  243. package/src/runtime/agent/orchestrator/session/compact.mjs +19 -19
  244. package/src/runtime/agent/orchestrator/session/context-compaction-policy.mjs +136 -132
  245. package/src/runtime/agent/orchestrator/session/context-fingerprint.mjs +65 -45
  246. package/src/runtime/agent/orchestrator/session/context-utils.mjs +700 -682
  247. package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +326 -292
  248. package/src/runtime/agent/orchestrator/session/evidence-union.mjs +454 -452
  249. package/src/runtime/agent/orchestrator/session/explicit-skills.mjs +48 -39
  250. package/src/runtime/agent/orchestrator/session/image-strip-recovery.mjs +96 -93
  251. package/src/runtime/agent/orchestrator/session/lifecycle-scan.mjs +105 -88
  252. package/src/runtime/agent/orchestrator/session/loop/arg-schema-coerce.mjs +61 -61
  253. package/src/runtime/agent/orchestrator/session/loop/assistant-commit.mjs +70 -66
  254. package/src/runtime/agent/orchestrator/session/loop/compact-debug.mjs +17 -11
  255. package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +585 -567
  256. package/src/runtime/agent/orchestrator/session/loop/completion-guards.mjs +26 -16
  257. package/src/runtime/agent/orchestrator/session/loop/context-overflow.mjs +60 -48
  258. package/src/runtime/agent/orchestrator/session/loop/deferred-call-through.mjs +59 -53
  259. package/src/runtime/agent/orchestrator/session/loop/diagnostics.mjs +54 -40
  260. package/src/runtime/agent/orchestrator/session/loop/fresh-context.mjs +157 -141
  261. package/src/runtime/agent/orchestrator/session/loop/hidden-agents.mjs +8 -6
  262. package/src/runtime/agent/orchestrator/session/loop/no-tool-turn.mjs +242 -218
  263. package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +71 -73
  264. package/src/runtime/agent/orchestrator/session/loop/request-boundary.mjs +112 -110
  265. package/src/runtime/agent/orchestrator/session/loop/request-projection.mjs +93 -77
  266. package/src/runtime/agent/orchestrator/session/loop/steering.mjs +194 -181
  267. package/src/runtime/agent/orchestrator/session/loop/stored-tool-args.mjs +96 -91
  268. package/src/runtime/agent/orchestrator/session/loop/termination.mjs +37 -44
  269. package/src/runtime/agent/orchestrator/session/loop/tool-classify.mjs +102 -83
  270. package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +352 -312
  271. package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +174 -167
  272. package/src/runtime/agent/orchestrator/session/loop/transcript-repair.mjs +75 -72
  273. package/src/runtime/agent/orchestrator/session/loop/usage.mjs +59 -53
  274. package/src/runtime/agent/orchestrator/session/loop.mjs +9 -9
  275. package/src/runtime/agent/orchestrator/session/manager/agent-runtime-singleton.mjs +5 -5
  276. package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +1382 -1303
  277. package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +426 -388
  278. package/src/runtime/agent/orchestrator/session/manager/context-meta.mjs +180 -179
  279. package/src/runtime/agent/orchestrator/session/manager/delivered-completions.mjs +60 -55
  280. package/src/runtime/agent/orchestrator/session/manager/foreign-pending-messages.mjs +324 -316
  281. package/src/runtime/agent/orchestrator/session/manager/idle-cleanup.mjs +136 -125
  282. package/src/runtime/agent/orchestrator/session/manager/message-sanitize.mjs +112 -112
  283. package/src/runtime/agent/orchestrator/session/manager/pending-message-entry.mjs +242 -233
  284. package/src/runtime/agent/orchestrator/session/manager/pending-messages.mjs +1048 -951
  285. package/src/runtime/agent/orchestrator/session/manager/prefetch-bridge.mjs +214 -203
  286. package/src/runtime/agent/orchestrator/session/manager/prompt-utils.mjs +152 -148
  287. package/src/runtime/agent/orchestrator/session/manager/provider-cache-key.mjs +17 -17
  288. package/src/runtime/agent/orchestrator/session/manager/rules-cache.mjs +80 -58
  289. package/src/runtime/agent/orchestrator/session/manager/rules-source-cache.mjs +48 -48
  290. package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +392 -389
  291. package/src/runtime/agent/orchestrator/session/manager/runtime-loaders.mjs +10 -10
  292. package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +212 -169
  293. package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +323 -300
  294. package/src/runtime/agent/orchestrator/session/manager/session-errors.mjs +12 -12
  295. package/src/runtime/agent/orchestrator/session/manager/session-id.mjs +49 -52
  296. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +786 -778
  297. package/src/runtime/agent/orchestrator/session/manager/session-lock.mjs +54 -51
  298. package/src/runtime/agent/orchestrator/session/manager/status-telemetry.mjs +77 -71
  299. package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +173 -182
  300. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-context.mjs +171 -171
  301. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.mjs +392 -385
  302. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +175 -172
  303. package/src/runtime/agent/orchestrator/session/manager/turn-interruption.mjs +388 -399
  304. package/src/runtime/agent/orchestrator/session/manager/usage-metrics.mjs +371 -352
  305. package/src/runtime/agent/orchestrator/session/manager.mjs +60 -60
  306. package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +485 -430
  307. package/src/runtime/agent/orchestrator/session/provider-prefix-guard.mjs +144 -145
  308. package/src/runtime/agent/orchestrator/session/reduction-metrics.mjs +102 -104
  309. package/src/runtime/agent/orchestrator/session/result-classification.mjs +37 -38
  310. package/src/runtime/agent/orchestrator/session/save-session-worker.mjs +76 -70
  311. package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +680 -643
  312. package/src/runtime/agent/orchestrator/session/store/canonical-reader.mjs +49 -48
  313. package/src/runtime/agent/orchestrator/session/store/fs-probe.mjs +24 -24
  314. package/src/runtime/agent/orchestrator/session/store/listing.mjs +722 -655
  315. package/src/runtime/agent/orchestrator/session/store/live-state.mjs +104 -104
  316. package/src/runtime/agent/orchestrator/session/store/load-cache.mjs +124 -124
  317. package/src/runtime/agent/orchestrator/session/store/paths-heartbeat.mjs +119 -100
  318. package/src/runtime/agent/orchestrator/session/store/save-fault.mjs +147 -141
  319. package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +711 -615
  320. package/src/runtime/agent/orchestrator/session/store/serialize.mjs +96 -91
  321. package/src/runtime/agent/orchestrator/session/store/summary-cache.mjs +159 -154
  322. package/src/runtime/agent/orchestrator/session/store/summary-rebuild-worker.mjs +12 -12
  323. package/src/runtime/agent/orchestrator/session/store/write-guards.mjs +86 -86
  324. package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +291 -272
  325. package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +904 -897
  326. package/src/runtime/agent/orchestrator/session/store-summary-visibility.mjs +26 -28
  327. package/src/runtime/agent/orchestrator/session/store-transcript-cache.mjs +93 -93
  328. package/src/runtime/agent/orchestrator/session/store.mjs +897 -842
  329. package/src/runtime/agent/orchestrator/session/synthetic-user-envelope.mjs +71 -76
  330. package/src/runtime/agent/orchestrator/session/task-wait-control.mjs +9 -3
  331. package/src/runtime/agent/orchestrator/session/thinking-replay-recovery.mjs +55 -58
  332. package/src/runtime/agent/orchestrator/session/token-estimate-floors.mjs +25 -24
  333. package/src/runtime/agent/orchestrator/session/token-estimate.mjs +42 -42
  334. package/src/runtime/agent/orchestrator/session/tool-batch.mjs +989 -918
  335. package/src/runtime/agent/orchestrator/session/tool-envelope.mjs +25 -32
  336. package/src/runtime/agent/orchestrator/session/tool-result-offload.mjs +390 -369
  337. package/src/runtime/agent/orchestrator/stall-policy.mjs +184 -180
  338. package/src/runtime/agent/orchestrator/tool-loop-guard.mjs +4 -3
  339. package/src/runtime/agent/orchestrator/tools/bash-policy-scan.mjs +7 -6
  340. package/src/runtime/agent/orchestrator/tools/builtin/advisory-lock.mjs +166 -153
  341. package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +859 -795
  342. package/src/runtime/agent/orchestrator/tools/builtin/atomic-write.mjs +234 -184
  343. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +772 -722
  344. package/src/runtime/agent/orchestrator/tools/builtin/binary-file.mjs +83 -80
  345. package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +336 -231
  346. package/src/runtime/agent/orchestrator/tools/builtin/cache-layers.mjs +444 -408
  347. package/src/runtime/agent/orchestrator/tools/builtin/device-paths.mjs +152 -103
  348. package/src/runtime/agent/orchestrator/tools/builtin/diff-utils.mjs +104 -90
  349. package/src/runtime/agent/orchestrator/tools/builtin/external-tool-adapters.mjs +559 -498
  350. package/src/runtime/agent/orchestrator/tools/builtin/fs-reachability.mjs +49 -42
  351. package/src/runtime/agent/orchestrator/tools/builtin/git-command-policy.mjs +169 -100
  352. package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +1072 -793
  353. package/src/runtime/agent/orchestrator/tools/builtin/git-partial-stage.mjs +215 -209
  354. package/src/runtime/agent/orchestrator/tools/builtin/git-repo-rw-lock.mjs +66 -66
  355. package/src/runtime/agent/orchestrator/tools/builtin/glob-walk.mjs +212 -173
  356. package/src/runtime/agent/orchestrator/tools/builtin/grep-formatting.mjs +114 -111
  357. package/src/runtime/agent/orchestrator/tools/builtin/hash-utils.mjs +4 -2
  358. package/src/runtime/agent/orchestrator/tools/builtin/lib/absolute-glob-expand.mjs +98 -86
  359. package/src/runtime/agent/orchestrator/tools/builtin/lib/glob-static-prefix.mjs +91 -91
  360. package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-chunk-merge.mjs +100 -101
  361. package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-context-expander.mjs +456 -461
  362. package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-output.mjs +229 -182
  363. package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-path-fanout.mjs +240 -238
  364. package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-pattern-fanout.mjs +350 -323
  365. package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-single-file-rescue.mjs +201 -162
  366. package/src/runtime/agent/orchestrator/tools/builtin/lib/list-helpers.mjs +22 -25
  367. package/src/runtime/agent/orchestrator/tools/builtin/lib/search-grep-chunks.mjs +124 -125
  368. package/src/runtime/agent/orchestrator/tools/builtin/lib/search-input-helpers.mjs +39 -43
  369. package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-insights.mjs +75 -69
  370. package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.mjs +221 -194
  371. package/src/runtime/agent/orchestrator/tools/builtin/list-formatting.mjs +6 -6
  372. package/src/runtime/agent/orchestrator/tools/builtin/list-tool.mjs +894 -868
  373. package/src/runtime/agent/orchestrator/tools/builtin/local-search-telemetry.mjs +52 -50
  374. package/src/runtime/agent/orchestrator/tools/builtin/native-search-client.mjs +128 -114
  375. package/src/runtime/agent/orchestrator/tools/builtin/native-search-runner.mjs +36 -34
  376. package/src/runtime/agent/orchestrator/tools/builtin/native-search-transport.mjs +35 -7
  377. package/src/runtime/agent/orchestrator/tools/builtin/path-diagnostics.mjs +217 -179
  378. package/src/runtime/agent/orchestrator/tools/builtin/path-locks.mjs +28 -23
  379. package/src/runtime/agent/orchestrator/tools/builtin/path-utils.mjs +239 -216
  380. package/src/runtime/agent/orchestrator/tools/builtin/read-args.mjs +52 -52
  381. package/src/runtime/agent/orchestrator/tools/builtin/read-batch.mjs +228 -217
  382. package/src/runtime/agent/orchestrator/tools/builtin/read-formatting.mjs +60 -61
  383. package/src/runtime/agent/orchestrator/tools/builtin/read-image-resize.mjs +217 -202
  384. package/src/runtime/agent/orchestrator/tools/builtin/read-image.mjs +29 -19
  385. package/src/runtime/agent/orchestrator/tools/builtin/read-lines.mjs +7 -7
  386. package/src/runtime/agent/orchestrator/tools/builtin/read-mode-tool.mjs +406 -368
  387. package/src/runtime/agent/orchestrator/tools/builtin/read-office-files.mjs +479 -417
  388. package/src/runtime/agent/orchestrator/tools/builtin/read-open.mjs +157 -148
  389. package/src/runtime/agent/orchestrator/tools/builtin/read-range-index.mjs +237 -214
  390. package/src/runtime/agent/orchestrator/tools/builtin/read-ranges.mjs +24 -23
  391. package/src/runtime/agent/orchestrator/tools/builtin/read-single-tool.mjs +807 -739
  392. package/src/runtime/agent/orchestrator/tools/builtin/read-snapshot-runtime.mjs +181 -185
  393. package/src/runtime/agent/orchestrator/tools/builtin/read-source-windows.mjs +76 -71
  394. package/src/runtime/agent/orchestrator/tools/builtin/read-special-files.mjs +231 -191
  395. package/src/runtime/agent/orchestrator/tools/builtin/read-streaming.mjs +553 -538
  396. package/src/runtime/agent/orchestrator/tools/builtin/read-tool.mjs +670 -607
  397. package/src/runtime/agent/orchestrator/tools/builtin/read-windows.mjs +111 -111
  398. package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs +183 -180
  399. package/src/runtime/agent/orchestrator/tools/builtin/search-admission.mjs +7 -16
  400. package/src/runtime/agent/orchestrator/tools/builtin/search-builders.mjs +222 -203
  401. package/src/runtime/agent/orchestrator/tools/builtin/search-glob-tool.mjs +466 -438
  402. package/src/runtime/agent/orchestrator/tools/builtin/search-grep-tool.mjs +730 -718
  403. package/src/runtime/agent/orchestrator/tools/builtin/search-path-diagnostics.mjs +194 -163
  404. package/src/runtime/agent/orchestrator/tools/builtin/search-tool.mjs +8 -8
  405. package/src/runtime/agent/orchestrator/tools/builtin/shell-analysis.mjs +834 -770
  406. package/src/runtime/agent/orchestrator/tools/builtin/shell-direct-exe.mjs +209 -136
  407. package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +417 -384
  408. package/src/runtime/agent/orchestrator/tools/builtin/shell-lossless-compact.mjs +315 -318
  409. package/src/runtime/agent/orchestrator/tools/builtin/shell-output.mjs +67 -68
  410. package/src/runtime/agent/orchestrator/tools/builtin/shell-runtime.mjs +171 -156
  411. package/src/runtime/agent/orchestrator/tools/builtin/snapshot-helpers.mjs +103 -100
  412. package/src/runtime/agent/orchestrator/tools/builtin/snapshot-store.mjs +277 -253
  413. package/src/runtime/agent/orchestrator/tools/builtin/snapshot-validation.mjs +86 -85
  414. package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +226 -230
  415. package/src/runtime/agent/orchestrator/tools/builtin/text-stats.mjs +59 -57
  416. package/src/runtime/agent/orchestrator/tools/builtin/tool-output-limit.mjs +31 -34
  417. package/src/runtime/agent/orchestrator/tools/builtin/windows-roots.mjs +3 -3
  418. package/src/runtime/agent/orchestrator/tools/builtin.mjs +384 -411
  419. package/src/runtime/agent/orchestrator/tools/code-graph/aggregate-roots.mjs +68 -30
  420. package/src/runtime/agent/orchestrator/tools/code-graph/ast-calls.mjs +20 -13
  421. package/src/runtime/agent/orchestrator/tools/code-graph/build.mjs +215 -152
  422. package/src/runtime/agent/orchestrator/tools/code-graph/calls-cache.mjs +4 -3
  423. package/src/runtime/agent/orchestrator/tools/code-graph/constants.mjs +64 -18
  424. package/src/runtime/agent/orchestrator/tools/code-graph/disk-cache.mjs +133 -82
  425. package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +380 -226
  426. package/src/runtime/agent/orchestrator/tools/code-graph/exact-file-graph.mjs +5 -4
  427. package/src/runtime/agent/orchestrator/tools/code-graph/graph-binary.mjs +233 -200
  428. package/src/runtime/agent/orchestrator/tools/code-graph/graph-model.mjs +10 -8
  429. package/src/runtime/agent/orchestrator/tools/code-graph/keyword-match.mjs +10 -3
  430. package/src/runtime/agent/orchestrator/tools/code-graph/lang-predicates.mjs +60 -26
  431. package/src/runtime/agent/orchestrator/tools/code-graph/memory-cache.mjs +6 -14
  432. package/src/runtime/agent/orchestrator/tools/code-graph/project-root.mjs +31 -10
  433. package/src/runtime/agent/orchestrator/tools/code-graph/search-references.mjs +116 -95
  434. package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +134 -85
  435. package/src/runtime/agent/orchestrator/tools/code-graph/source-access.mjs +11 -3
  436. package/src/runtime/agent/orchestrator/tools/code-graph/span.mjs +1 -1
  437. package/src/runtime/agent/orchestrator/tools/code-graph/symbol-index.mjs +19 -23
  438. package/src/runtime/agent/orchestrator/tools/code-graph/text-columns.mjs +5 -1
  439. package/src/runtime/agent/orchestrator/tools/code-graph/text-mask.mjs +20 -9
  440. package/src/runtime/agent/orchestrator/tools/code-graph/trusted-roots.mjs +23 -18
  441. package/src/runtime/agent/orchestrator/tools/code-graph-prewarm-worker.mjs +4 -9
  442. package/src/runtime/agent/orchestrator/tools/code-graph-state.mjs +1 -3
  443. package/src/runtime/agent/orchestrator/tools/code-graph-tool-defs.mjs +49 -7
  444. package/src/runtime/agent/orchestrator/tools/destructive-warning.mjs +247 -52
  445. package/src/runtime/agent/orchestrator/tools/env-scrub.mjs +93 -91
  446. package/src/runtime/agent/orchestrator/tools/graph-binary-fetcher.mjs +6 -5
  447. package/src/runtime/agent/orchestrator/tools/graph-manifest.json +11 -11
  448. package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.mjs +125 -81
  449. package/src/runtime/agent/orchestrator/tools/lib/shell-descendants.mjs +10 -3
  450. package/src/runtime/agent/orchestrator/tools/lib/shell-spawn-retry.mjs +18 -13
  451. package/src/runtime/agent/orchestrator/tools/lib/shell-warm-standby.mjs +123 -105
  452. package/src/runtime/agent/orchestrator/tools/next-call-utils.mjs +5 -2
  453. package/src/runtime/agent/orchestrator/tools/patch/dispatch.mjs +85 -53
  454. package/src/runtime/agent/orchestrator/tools/patch/matcher.mjs +109 -86
  455. package/src/runtime/agent/orchestrator/tools/patch/native-server.mjs +158 -70
  456. package/src/runtime/agent/orchestrator/tools/patch/orchestrator.mjs +287 -213
  457. package/src/runtime/agent/orchestrator/tools/patch/parsing.mjs +30 -17
  458. package/src/runtime/agent/orchestrator/tools/patch/paths.mjs +31 -23
  459. package/src/runtime/agent/orchestrator/tools/patch/v4a-anchors.mjs +17 -16
  460. package/src/runtime/agent/orchestrator/tools/patch/v4a-convert.mjs +71 -71
  461. package/src/runtime/agent/orchestrator/tools/patch/v4a-windows.mjs +23 -19
  462. package/src/runtime/agent/orchestrator/tools/patch-binary-fetcher.mjs +7 -7
  463. package/src/runtime/agent/orchestrator/tools/patch-tool-defs.mjs +11 -5
  464. package/src/runtime/agent/orchestrator/tools/patch.mjs +7 -1
  465. package/src/runtime/agent/orchestrator/tools/progress-message.mjs +83 -85
  466. package/src/runtime/agent/orchestrator/tools/shell-command.mjs +258 -148
  467. package/src/runtime/agent/orchestrator/tools/shell-exec-output.mjs +39 -29
  468. package/src/runtime/agent/orchestrator/tools/shell-exec-policy.mjs +23 -12
  469. package/src/runtime/agent/orchestrator/tools/shell-policy-danger-target.mjs +29 -8
  470. package/src/runtime/agent/orchestrator/tools/shell-policy.mjs +77 -33
  471. package/src/runtime/agent/orchestrator/tools/shell-powershell.mjs +12 -13
  472. package/src/runtime/agent/orchestrator/tools/shell-snapshot.mjs +112 -101
  473. package/src/runtime/agent/orchestrator/tools/spawn-binary-fetcher.mjs +2 -2
  474. package/src/runtime/agent/orchestrator/tools/tool-batch-trace.mjs +32 -27
  475. package/src/runtime/attachments/pdf-extract.mjs +28 -14
  476. package/src/runtime/attachments/pdfjs-runtime.mjs +3 -1
  477. package/src/runtime/attachments/store.mjs +66 -62
  478. package/src/runtime/bridge-discovery.mjs +7 -7
  479. package/src/runtime/browser-bridge/action-schema.d.mts +5 -4
  480. package/src/runtime/browser-bridge/action-schema.mjs +168 -134
  481. package/src/runtime/browser-bridge/browser-action-contract.mjs +75 -15
  482. package/src/runtime/browser-bridge/client.mjs +40 -39
  483. package/src/runtime/browser-bridge/input-fields.mjs +269 -50
  484. package/src/runtime/browser-bridge/timing.mjs +9 -5
  485. package/src/runtime/browser-bridge/tool-defs.mjs +20 -20
  486. package/src/runtime/channels/index.mjs +2 -2
  487. package/src/runtime/channels/lib/boot-profile.mjs +3 -3
  488. package/src/runtime/channels/lib/cli-worker-host.mjs +2 -5
  489. package/src/runtime/channels/lib/config.mjs +36 -54
  490. package/src/runtime/channels/lib/crash-log.mjs +48 -29
  491. package/src/runtime/channels/lib/event-pipeline.mjs +19 -19
  492. package/src/runtime/channels/lib/event-queue.mjs +63 -52
  493. package/src/runtime/channels/lib/executor.mjs +58 -61
  494. package/src/runtime/channels/lib/index-drop-trace.mjs +44 -24
  495. package/src/runtime/channels/lib/network-retry.mjs +8 -7
  496. package/src/runtime/channels/lib/owned-runtime.mjs +410 -376
  497. package/src/runtime/channels/lib/owner-heartbeat.mjs +1 -1
  498. package/src/runtime/channels/lib/parent-bridge.mjs +39 -17
  499. package/src/runtime/channels/lib/runtime-paths.mjs +202 -169
  500. package/src/runtime/channels/lib/scheduler.mjs +166 -128
  501. package/src/runtime/channels/lib/settings.mjs +3 -5
  502. package/src/runtime/channels/lib/state-file.mjs +7 -14
  503. package/src/runtime/channels/lib/status-snapshot.mjs +17 -17
  504. package/src/runtime/channels/lib/tool-dispatch.mjs +71 -65
  505. package/src/runtime/channels/lib/voice-runtime-fetcher.mjs +444 -374
  506. package/src/runtime/channels/lib/voice-transcription.mjs +101 -40
  507. package/src/runtime/channels/lib/webhook/deliveries.mjs +10 -11
  508. package/src/runtime/channels/lib/webhook/log.mjs +13 -12
  509. package/src/runtime/channels/lib/webhook/relay-tunnel.mjs +199 -110
  510. package/src/runtime/channels/lib/webhook/signature.mjs +14 -14
  511. package/src/runtime/channels/lib/webhook.mjs +173 -132
  512. package/src/runtime/channels/lib/whisper-language.mjs +19 -18
  513. package/src/runtime/channels/lib/whisper-port.mjs +20 -12
  514. package/src/runtime/channels/lib/whisper-server.mjs +135 -75
  515. package/src/runtime/channels/lib/worker-bootstrap.mjs +94 -78
  516. package/src/runtime/channels/lib/worker-ipc.mjs +92 -73
  517. package/src/runtime/channels/lib/worker-main.mjs +106 -79
  518. package/src/runtime/computer-bridge/action-schema.mjs +206 -142
  519. package/src/runtime/computer-bridge/actions.d.mts +3 -1
  520. package/src/runtime/computer-bridge/actions.mjs +48 -7
  521. package/src/runtime/computer-bridge/capture-size.d.mts +5 -1
  522. package/src/runtime/computer-bridge/capture-size.mjs +3 -4
  523. package/src/runtime/computer-bridge/client.mjs +120 -76
  524. package/src/runtime/computer-bridge/core-actions.mjs +33 -21
  525. package/src/runtime/computer-bridge/error-code.mjs +1 -2
  526. package/src/runtime/computer-bridge/error-recovery.mjs +60 -34
  527. package/src/runtime/computer-bridge/limits.mjs +17 -6
  528. package/src/runtime/computer-bridge/pending-continuation.mjs +79 -32
  529. package/src/runtime/computer-bridge/tool-defs.mjs +2 -5
  530. package/src/runtime/github/client.d.mts +5 -1
  531. package/src/runtime/github/client.mjs +80 -43
  532. package/src/runtime/github/commands.mjs +72 -31
  533. package/src/runtime/github/contract.d.mts +45 -11
  534. package/src/runtime/github/contract.mjs +62 -27
  535. package/src/runtime/github/tool.mjs +29 -7
  536. package/src/runtime/local-provider/asset-installer.mjs +66 -46
  537. package/src/runtime/local-provider/asset-storage.mjs +3 -1
  538. package/src/runtime/local-provider/catalog.mjs +20 -23
  539. package/src/runtime/local-provider/context-settings.mjs +2 -2
  540. package/src/runtime/local-provider/gguf-header.mjs +69 -18
  541. package/src/runtime/local-provider/hardware.mjs +84 -31
  542. package/src/runtime/local-provider/hugging-face.mjs +108 -33
  543. package/src/runtime/local-provider/input-capabilities.mjs +16 -5
  544. package/src/runtime/local-provider/install-progress.mjs +42 -17
  545. package/src/runtime/local-provider/model-maintenance.mjs +79 -35
  546. package/src/runtime/local-provider/model-state.mjs +21 -8
  547. package/src/runtime/local-provider/registered-models.mjs +23 -13
  548. package/src/runtime/local-provider/request-queue.mjs +31 -10
  549. package/src/runtime/local-provider/resumable-installations.mjs +25 -7
  550. package/src/runtime/local-provider/server-process.mjs +42 -16
  551. package/src/runtime/local-provider/server.mjs +63 -47
  552. package/src/runtime/media/adapters/antigravity-image.mjs +5 -4
  553. package/src/runtime/media/adapters/codex-image.mjs +24 -9
  554. package/src/runtime/media/adapters/gemini-image.mjs +17 -16
  555. package/src/runtime/media/adapters/gemini-video.mjs +4 -5
  556. package/src/runtime/media/adapters/xai-media.mjs +5 -1
  557. package/src/runtime/media/catalog-errors.mjs +5 -2
  558. package/src/runtime/media/catalog.mjs +77 -55
  559. package/src/runtime/media/download.mjs +12 -31
  560. package/src/runtime/media/jobs.mjs +17 -19
  561. package/src/runtime/media/lanes.mjs +24 -12
  562. package/src/runtime/media/renditions.mjs +94 -63
  563. package/src/runtime/media/store.mjs +8 -21
  564. package/src/runtime/media/tool-defs.mjs +38 -12
  565. package/src/runtime/media/tool.mjs +118 -31
  566. package/src/runtime/media/upstream-error.mjs +5 -1
  567. package/src/runtime/memory/data/runtime-manifest.json +3 -3
  568. package/src/runtime/memory/index.mjs +332 -300
  569. package/src/runtime/memory/lib/agent-ipc.mjs +122 -100
  570. package/src/runtime/memory/lib/compact-handoff.mjs +76 -74
  571. package/src/runtime/memory/lib/compact-vector-cache.mjs +34 -37
  572. package/src/runtime/memory/lib/core-memory-file.mjs +86 -73
  573. package/src/runtime/memory/lib/core-memory-index.mjs +57 -47
  574. package/src/runtime/memory/lib/core-memory-management.mjs +41 -24
  575. package/src/runtime/memory/lib/core-memory-store.mjs +205 -165
  576. package/src/runtime/memory/lib/core-memory-uniqueness.mjs +21 -12
  577. package/src/runtime/memory/lib/cycle-llm-adapters.mjs +12 -9
  578. package/src/runtime/memory/lib/cycle-scheduler.mjs +289 -228
  579. package/src/runtime/memory/lib/cycle-signatures.mjs +3 -3
  580. package/src/runtime/memory/lib/embedding-cache-retention.mjs +21 -31
  581. package/src/runtime/memory/lib/embedding-model-cache-compression.mjs +21 -33
  582. package/src/runtime/memory/lib/embedding-model-config.mjs +25 -26
  583. package/src/runtime/memory/lib/embedding-provider.mjs +221 -209
  584. package/src/runtime/memory/lib/embedding-reindex.mjs +30 -30
  585. package/src/runtime/memory/lib/embedding-worker.mjs +324 -248
  586. package/src/runtime/memory/lib/history-duplicates.mjs +6 -6
  587. package/src/runtime/memory/lib/http-router.mjs +357 -294
  588. package/src/runtime/memory/lib/http-wire.mjs +22 -22
  589. package/src/runtime/memory/lib/light-ko-morph.mjs +100 -41
  590. package/src/runtime/memory/lib/llm-worker-host.mjs +2 -4
  591. package/src/runtime/memory/lib/memory-action-handlers.mjs +337 -293
  592. package/src/runtime/memory/lib/memory-chunk-audit.mjs +26 -20
  593. package/src/runtime/memory/lib/memory-chunk-quality.mjs +314 -225
  594. package/src/runtime/memory/lib/memory-config-flags.mjs +27 -29
  595. package/src/runtime/memory/lib/memory-cycle-requests.mjs +125 -108
  596. package/src/runtime/memory/lib/memory-cycle.mjs +8 -4
  597. package/src/runtime/memory/lib/memory-cycle1.mjs +444 -354
  598. package/src/runtime/memory/lib/memory-cycle2-mutations.mjs +69 -33
  599. package/src/runtime/memory/lib/memory-cycle2-review.mjs +128 -95
  600. package/src/runtime/memory/lib/memory-cycle2-shared.mjs +31 -28
  601. package/src/runtime/memory/lib/memory-cycle2.mjs +108 -77
  602. package/src/runtime/memory/lib/memory-daemon-lifecycle.mjs +65 -57
  603. package/src/runtime/memory/lib/memory-embed.mjs +324 -298
  604. package/src/runtime/memory/lib/memory-extraction.mjs +4 -4
  605. package/src/runtime/memory/lib/memory-fingerprint.mjs +30 -26
  606. package/src/runtime/memory/lib/memory-maintenance-store.mjs +13 -11
  607. package/src/runtime/memory/lib/memory-ops-policy.mjs +112 -101
  608. package/src/runtime/memory/lib/memory-port-advertiser.mjs +55 -44
  609. package/src/runtime/memory/lib/memory-process-lock.mjs +61 -46
  610. package/src/runtime/memory/lib/memory-recall-id-patch.mjs +7 -7
  611. package/src/runtime/memory/lib/memory-recall-read-query.mjs +4 -4
  612. package/src/runtime/memory/lib/memory-recall-scope-filter.mjs +61 -44
  613. package/src/runtime/memory/lib/memory-recall-store.mjs +298 -255
  614. package/src/runtime/memory/lib/memory-retrievers.mjs +75 -56
  615. package/src/runtime/memory/lib/memory-score.mjs +21 -18
  616. package/src/runtime/memory/lib/memory-service-lifecycle.mjs +70 -62
  617. package/src/runtime/memory/lib/memory-session-merge.mjs +21 -15
  618. package/src/runtime/memory/lib/memory-text-utils.mjs +146 -83
  619. package/src/runtime/memory/lib/memory.mjs +263 -200
  620. package/src/runtime/memory/lib/pg/adapter.mjs +213 -198
  621. package/src/runtime/memory/lib/pg/compact-indexes.mjs +78 -59
  622. package/src/runtime/memory/lib/pg/process.mjs +434 -300
  623. package/src/runtime/memory/lib/pg/supervisor.mjs +217 -131
  624. package/src/runtime/memory/lib/project-id-resolver.mjs +1 -1
  625. package/src/runtime/memory/lib/query-handlers.mjs +564 -477
  626. package/src/runtime/memory/lib/query-maintenance-handlers.mjs +98 -56
  627. package/src/runtime/memory/lib/query-ranking.mjs +218 -170
  628. package/src/runtime/memory/lib/recall-embedding-readiness.mjs +35 -45
  629. package/src/runtime/memory/lib/recall-event-context.mjs +81 -72
  630. package/src/runtime/memory/lib/recall-format.mjs +293 -259
  631. package/src/runtime/memory/lib/recall-fusion.mjs +20 -28
  632. package/src/runtime/memory/lib/recall-limits.mjs +3 -3
  633. package/src/runtime/memory/lib/recall-order.mjs +12 -12
  634. package/src/runtime/memory/lib/recall-page-cursor.mjs +17 -17
  635. package/src/runtime/memory/lib/recall-scoring.mjs +25 -22
  636. package/src/runtime/memory/lib/recall-substring-predicate.mjs +2 -2
  637. package/src/runtime/memory/lib/runtime-fetcher.mjs +253 -215
  638. package/src/runtime/memory/lib/session-ingest-runtime.mjs +177 -155
  639. package/src/runtime/memory/lib/session-ingest.mjs +163 -141
  640. package/src/runtime/memory/lib/tool-call-handler.mjs +27 -18
  641. package/src/runtime/memory/lib/trace-mode.mjs +30 -34
  642. package/src/runtime/memory/lib/trace-store.mjs +506 -381
  643. package/src/runtime/memory/lib/transcript-ingest.mjs +253 -203
  644. package/src/runtime/memory/tool-defs.mjs +105 -23
  645. package/src/runtime/office/authoring/pptx-author-action.mjs +20 -11
  646. package/src/runtime/office/authoring/pptx-author-session.mjs +20 -18
  647. package/src/runtime/office/authoring/pptx-brief.mjs +80 -22
  648. package/src/runtime/office/authoring/pptx-contact-sheet.mjs +9 -2
  649. package/src/runtime/office/authoring/pptx-icons.json +265 -1
  650. package/src/runtime/office/authoring/pptx-icons.mjs +19 -9
  651. package/src/runtime/office/authoring/pptx-receipt.mjs +262 -82
  652. package/src/runtime/office/authoring/pptx-script-contract.mjs +5 -3
  653. package/src/runtime/office/authoring/pptx-script-normalize.mjs +85 -34
  654. package/src/runtime/office/authoring/pptx-script-runner.mjs +53 -14
  655. package/src/runtime/office/bench/assurance-benchmark.mjs +204 -144
  656. package/src/runtime/office/bench/benchmark.mjs +162 -101
  657. package/src/runtime/office/bench/contract-benchmark.mjs +2 -1
  658. package/src/runtime/office/bench/deck-bench.mjs +11 -3
  659. package/src/runtime/office/bench/polish-benchmark.mjs +240 -120
  660. package/src/runtime/office/bench/quality-live-benchmark.mjs +234 -133
  661. package/src/runtime/office/capabilities.mjs +1031 -243
  662. package/src/runtime/office/com/com-adapter.mjs +108 -70
  663. package/src/runtime/office/com/office-com-cleanup.ps1 +125 -116
  664. package/src/runtime/office/com/office-com-session-host.ps1 +820 -783
  665. package/src/runtime/office/com/office-session-client.mjs +36 -16
  666. package/src/runtime/office/com/office-word-formatting.ps1 +23 -23
  667. package/src/runtime/office/core/journal.mjs +2 -13
  668. package/src/runtime/office/core/office-actions-batch.mjs +156 -107
  669. package/src/runtime/office/core/office-actions-inspect.mjs +110 -85
  670. package/src/runtime/office/core/office-actions-lifecycle.mjs +54 -43
  671. package/src/runtime/office/core/office-actions-open.mjs +61 -46
  672. package/src/runtime/office/core/office-actions-read.mjs +18 -17
  673. package/src/runtime/office/core/office-actions-render.mjs +75 -72
  674. package/src/runtime/office/core/office-core.mjs +88 -98
  675. package/src/runtime/office/core/office-documents.mjs +18 -12
  676. package/src/runtime/office/core/office-recalculation.mjs +9 -5
  677. package/src/runtime/office/core/office-render-preview.mjs +90 -44
  678. package/src/runtime/office/core/office-sessions.mjs +183 -111
  679. package/src/runtime/office/core/office-transactions.mjs +73 -60
  680. package/src/runtime/office/core/pagination.mjs +36 -32
  681. package/src/runtime/office/core/pptx-page-cache.mjs +37 -17
  682. package/src/runtime/office/core/snapshot-contract.mjs +18 -11
  683. package/src/runtime/office/core/tabular.mjs +71 -42
  684. package/src/runtime/office/design/composition-system.mjs +155 -77
  685. package/src/runtime/office/design/content-model.mjs +11 -7
  686. package/src/runtime/office/design/design-art-direction.mjs +43 -38
  687. package/src/runtime/office/design/design-creative-director.mjs +12 -17
  688. package/src/runtime/office/design/design-discipline.mjs +50 -30
  689. package/src/runtime/office/design/design-system.mjs +10 -4
  690. package/src/runtime/office/design/design-tokens.mjs +81 -76
  691. package/src/runtime/office/design/docx/design-docx-components.mjs +21 -31
  692. package/src/runtime/office/design/docx/design-docx.mjs +25 -21
  693. package/src/runtime/office/design/docx/document-typography.mjs +2 -1
  694. package/src/runtime/office/design/library/design-library-core.mjs +15 -29
  695. package/src/runtime/office/design/library/design-library-pack.mjs +86 -63
  696. package/src/runtime/office/design/library/design-library.mjs +49 -68
  697. package/src/runtime/office/design/library/design-template-index.mjs +45 -47
  698. package/src/runtime/office/design/library/design-template-inspect.mjs +73 -85
  699. package/src/runtime/office/design/library/templates/mixdog-executive.pptx.mixdog.json +89 -10
  700. package/src/runtime/office/design/xlsx/design-xlsx-components.mjs +31 -43
  701. package/src/runtime/office/design/xlsx/design-xlsx.mjs +85 -91
  702. package/src/runtime/office/index.mjs +81 -47
  703. package/src/runtime/office/office-test-support.mjs +4 -4
  704. package/src/runtime/office/pdf/document-preview.mjs +30 -20
  705. package/src/runtime/office/pdf/pdf-adapter.mjs +258 -93
  706. package/src/runtime/office/pdf/pdf-analysis.mjs +130 -72
  707. package/src/runtime/office/pdf/pdf-draw.mjs +12 -6
  708. package/src/runtime/office/pdf/pdf-fonts.mjs +30 -23
  709. package/src/runtime/office/pdf/pdf-forms.mjs +47 -15
  710. package/src/runtime/office/pdf/pdf-render.mjs +57 -65
  711. package/src/runtime/office/pdf/pdf-safety.mjs +10 -13
  712. package/src/runtime/office/pdf/pdf-search.mjs +33 -24
  713. package/src/runtime/office/pdf/pdf-security.mjs +16 -17
  714. package/src/runtime/office/pdf/pdf-writer.mjs +184 -70
  715. package/src/runtime/office/portable/docx-formatting.mjs +27 -10
  716. package/src/runtime/office/portable/docx-revisions.mjs +75 -35
  717. package/src/runtime/office/portable/docx-runs.mjs +53 -21
  718. package/src/runtime/office/portable/docx-tracked-edits.mjs +12 -5
  719. package/src/runtime/office/portable/font-provisioner.mjs +11 -9
  720. package/src/runtime/office/portable/image-layout.mjs +7 -5
  721. package/src/runtime/office/portable/ooxml-validator.mjs +61 -44
  722. package/src/runtime/office/portable/portable-cells.mjs +33 -35
  723. package/src/runtime/office/portable/portable-chart-faults.mjs +30 -16
  724. package/src/runtime/office/portable/portable-chart.mjs +162 -131
  725. package/src/runtime/office/portable/portable-docx-parts.mjs +161 -138
  726. package/src/runtime/office/portable/portable-docx-xml.mjs +136 -95
  727. package/src/runtime/office/portable/portable-docx.mjs +375 -189
  728. package/src/runtime/office/portable/portable-ooxml.mjs +6 -5
  729. package/src/runtime/office/portable/portable-opc.mjs +56 -55
  730. package/src/runtime/office/portable/portable-package.mjs +335 -236
  731. package/src/runtime/office/portable/portable-pivot.mjs +159 -127
  732. package/src/runtime/office/portable/portable-pptx-chart.mjs +63 -44
  733. package/src/runtime/office/portable/portable-pptx-charts.mjs +110 -81
  734. package/src/runtime/office/portable/portable-pptx-core.mjs +56 -83
  735. package/src/runtime/office/portable/portable-pptx-deck.mjs +101 -78
  736. package/src/runtime/office/portable/portable-pptx-package.mjs +129 -111
  737. package/src/runtime/office/portable/portable-pptx-shapes.mjs +183 -120
  738. package/src/runtime/office/portable/portable-pptx.mjs +53 -7
  739. package/src/runtime/office/portable/portable-sheet-page.mjs +72 -27
  740. package/src/runtime/office/portable/portable-sheet-parts.mjs +55 -41
  741. package/src/runtime/office/portable/portable-sheet-styles.mjs +83 -34
  742. package/src/runtime/office/portable/portable-sheet-xml.mjs +94 -100
  743. package/src/runtime/office/portable/portable-slide-shapes.mjs +107 -80
  744. package/src/runtime/office/portable/portable-snapshot.mjs +216 -137
  745. package/src/runtime/office/portable/portable-soffice.mjs +85 -55
  746. package/src/runtime/office/portable/portable-validation.mjs +344 -167
  747. package/src/runtime/office/portable/portable-xlsx.mjs +416 -211
  748. package/src/runtime/office/portable/portable-xml.mjs +10 -26
  749. package/src/runtime/office/portable/pptx-relations.mjs +38 -14
  750. package/src/runtime/office/portable/pptx-targets.mjs +9 -4
  751. package/src/runtime/office/portable/review-editability.mjs +28 -6
  752. package/src/runtime/office/portable/text-metrics.mjs +95 -70
  753. package/src/runtime/office/portable/xlsx-assertions.mjs +111 -43
  754. package/src/runtime/office/portable/xlsx-audit-support.mjs +12 -12
  755. package/src/runtime/office/portable/xlsx-contract.mjs +93 -51
  756. package/src/runtime/office/portable/xlsx-formula-audit.mjs +98 -30
  757. package/src/runtime/office/portable/xlsx-sheet-hygiene.mjs +59 -14
  758. package/src/runtime/office/quality/assurance-checklist.mjs +23 -17
  759. package/src/runtime/office/quality/assurance-rendered.mjs +49 -56
  760. package/src/runtime/office/quality/assurance-structure.mjs +342 -265
  761. package/src/runtime/office/quality/assurance-trust.mjs +38 -31
  762. package/src/runtime/office/quality/design-aesthetics-metrics.mjs +23 -17
  763. package/src/runtime/office/quality/design-aesthetics.mjs +100 -101
  764. package/src/runtime/office/quality/design-deck-diversity.mjs +53 -37
  765. package/src/runtime/office/quality/design-review-authored.mjs +36 -24
  766. package/src/runtime/office/quality/design-review-critique.mjs +55 -22
  767. package/src/runtime/office/quality/design-review.mjs +148 -162
  768. package/src/runtime/office/quality/document-acceptance.mjs +37 -18
  769. package/src/runtime/office/quality/inline-audit.mjs +13 -11
  770. package/src/runtime/office/quality/pptx-deck-rubric.mjs +30 -12
  771. package/src/runtime/office/quality/pptx-slide-roles.mjs +28 -15
  772. package/src/runtime/office/quality/presentation-acceptance.mjs +11 -10
  773. package/src/runtime/office/quality/quality-pipeline.mjs +151 -88
  774. package/src/runtime/office/quality/quality-score.mjs +13 -20
  775. package/src/runtime/office/quality/render-air.mjs +59 -24
  776. package/src/runtime/office/quality/visual-diff.mjs +5 -2
  777. package/src/runtime/office/shared/values.mjs +9 -2
  778. package/src/runtime/office/tool-defs.mjs +108 -27
  779. package/src/runtime/shared/abort-controller.mjs +5 -1
  780. package/src/runtime/shared/abort-race.mjs +4 -2
  781. package/src/runtime/shared/agent-route-config.mjs +18 -21
  782. package/src/runtime/shared/atomic-file.d.mts +3 -3
  783. package/src/runtime/shared/atomic-file.mjs +81 -47
  784. package/src/runtime/shared/automation-attachments.mjs +10 -5
  785. package/src/runtime/shared/automation-workflow.mjs +4 -2
  786. package/src/runtime/shared/background-tasks.mjs +59 -46
  787. package/src/runtime/shared/boot-profile.mjs +5 -3
  788. package/src/runtime/shared/bounded-download.mjs +9 -13
  789. package/src/runtime/shared/bridge-tool-args.mjs +1 -3
  790. package/src/runtime/shared/buffered-appender.mjs +151 -142
  791. package/src/runtime/shared/child-guardian.mjs +7 -9
  792. package/src/runtime/shared/child-spawn-gate.mjs +40 -47
  793. package/src/runtime/shared/child-spawn-remote.mjs +44 -32
  794. package/src/runtime/shared/config.mjs +246 -210
  795. package/src/runtime/shared/debounced-writer.mjs +33 -31
  796. package/src/runtime/shared/edit-tool-dialect.mjs +6 -5
  797. package/src/runtime/shared/err-text.mjs +57 -32
  798. package/src/runtime/shared/error-presentation.mjs +67 -19
  799. package/src/runtime/shared/file-lock.mjs +44 -18
  800. package/src/runtime/shared/file-permissions.d.mts +2 -8
  801. package/src/runtime/shared/file-permissions.mjs +5 -1
  802. package/src/runtime/shared/http-request-body.mjs +26 -15
  803. package/src/runtime/shared/idle-gc.mjs +19 -7
  804. package/src/runtime/shared/json-file.mjs +5 -1
  805. package/src/runtime/shared/json-metrics.mjs +19 -8
  806. package/src/runtime/shared/keyed-serial-queue.d.mts +1 -4
  807. package/src/runtime/shared/keyed-serial-queue.mjs +4 -1
  808. package/src/runtime/shared/llm/cost.mjs +81 -63
  809. package/src/runtime/shared/llm/http-agent.mjs +78 -60
  810. package/src/runtime/shared/llm/index.mjs +13 -14
  811. package/src/runtime/shared/llm/usage-accounting.mjs +64 -56
  812. package/src/runtime/shared/llm/usage-ledger-import.mjs +169 -125
  813. package/src/runtime/shared/llm/usage-ledger-repair.mjs +125 -88
  814. package/src/runtime/shared/llm/usage-ledger.mjs +481 -325
  815. package/src/runtime/shared/llm/usage-log.mjs +19 -17
  816. package/src/runtime/shared/llm/usage-measurement.mjs +45 -28
  817. package/src/runtime/shared/llm/usage-pricing-refresh.mjs +15 -11
  818. package/src/runtime/shared/llm/usage-rollup.mjs +39 -30
  819. package/src/runtime/shared/llm/usage-session-history.mjs +23 -18
  820. package/src/runtime/shared/loopback-listener.mjs +56 -44
  821. package/src/runtime/shared/markdown-frontmatter.mjs +6 -2
  822. package/src/runtime/shared/memory-snapshot.mjs +68 -54
  823. package/src/runtime/shared/native-asset.mjs +54 -24
  824. package/src/runtime/shared/notify-trace.mjs +8 -2
  825. package/src/runtime/shared/open-url.mjs +3 -1
  826. package/src/runtime/shared/orchestration.mjs +35 -0
  827. package/src/runtime/shared/owner-fair-gate.mjs +47 -31
  828. package/src/runtime/shared/plugin-manifest.mjs +1 -3
  829. package/src/runtime/shared/plugin-metadata.mjs +1 -5
  830. package/src/runtime/shared/pristine-execution.mjs +52 -59
  831. package/src/runtime/shared/process-lifecycle.mjs +130 -91
  832. package/src/runtime/shared/process-listener-headroom.mjs +3 -2
  833. package/src/runtime/shared/process-shutdown.mjs +36 -24
  834. package/src/runtime/shared/profile-config.cjs +15 -9
  835. package/src/runtime/shared/provider-accounts.mjs +50 -24
  836. package/src/runtime/shared/provider-api-key.mjs +8 -3
  837. package/src/runtime/shared/provider-auth-binding.mjs +8 -7
  838. package/src/runtime/shared/resource-admission.mjs +47 -59
  839. package/src/runtime/shared/runtime-root.mjs +3 -14
  840. package/src/runtime/shared/safe-ipc-send.mjs +6 -2
  841. package/src/runtime/shared/schedule-time.mjs +1 -3
  842. package/src/runtime/shared/schedules-db.mjs +33 -53
  843. package/src/runtime/shared/schema-value-error.mjs +5 -2
  844. package/src/runtime/shared/service-discovery.mjs +44 -46
  845. package/src/runtime/shared/session-runtime-health.mjs +18 -11
  846. package/src/runtime/shared/shell-display.mjs +5 -5
  847. package/src/runtime/shared/singleton-owner.mjs +1 -5
  848. package/src/runtime/shared/skill-document.mjs +6 -9
  849. package/src/runtime/shared/skill-selection.mjs +12 -12
  850. package/src/runtime/shared/skill-tool-dependencies.mjs +46 -29
  851. package/src/runtime/shared/sleep.mjs +3 -3
  852. package/src/runtime/shared/staged-update.mjs +186 -46
  853. package/src/runtime/shared/task-notification-envelope.mjs +15 -14
  854. package/src/runtime/shared/time-format.mjs +1 -2
  855. package/src/runtime/shared/tool-card-model.mjs +283 -145
  856. package/src/runtime/shared/tool-execution-contract.mjs +66 -61
  857. package/src/runtime/shared/tool-execution-owner.mjs +4 -1
  858. package/src/runtime/shared/tool-primitives.mjs +43 -23
  859. package/src/runtime/shared/tool-result-summary.mjs +98 -42
  860. package/src/runtime/shared/tool-status.mjs +12 -5
  861. package/src/runtime/shared/tool-surface.mjs +214 -94
  862. package/src/runtime/shared/transcript-writer.mjs +35 -20
  863. package/src/runtime/shared/transport-error-text.mjs +80 -21
  864. package/src/runtime/shared/turn-snapshot-store.mjs +20 -11
  865. package/src/runtime/shared/turn-snapshot.mjs +59 -69
  866. package/src/runtime/shared/turn-worktree-snapshot.mjs +103 -123
  867. package/src/runtime/shared/update-checker.mjs +24 -64
  868. package/src/runtime/shared/user-cwd.mjs +68 -75
  869. package/src/runtime/shared/user-data-guard.mjs +33 -40
  870. package/src/runtime/shared/webhook-session-run.mjs +11 -2
  871. package/src/runtime/shared/webhooks-db.mjs +30 -28
  872. package/src/runtime/tidy/apply.mjs +23 -11
  873. package/src/runtime/tidy/core-install.mjs +444 -0
  874. package/src/runtime/tidy/engines-manifest.json +37 -69
  875. package/src/runtime/tidy/engines.mjs +72 -18
  876. package/src/runtime/tidy/extract.mjs +22 -2
  877. package/src/runtime/tidy/history-comment.mjs +277 -0
  878. package/src/runtime/tidy/install.mjs +52 -24
  879. package/src/runtime/tidy/languages.mjs +33 -12
  880. package/src/runtime/tidy/process.mjs +86 -29
  881. package/src/runtime/tidy/report.mjs +37 -1
  882. package/src/runtime/tidy/resolve.mjs +108 -13
  883. package/src/runtime/tidy/rules/__tests__/no-history-comment.yml +24 -0
  884. package/src/runtime/tidy/rules/bash/no-history-comment.yml +2 -2
  885. package/src/runtime/tidy/rules/c/no-history-comment.yml +2 -2
  886. package/src/runtime/tidy/rules/cpp/no-history-comment.yml +2 -2
  887. package/src/runtime/tidy/rules/csharp/no-history-comment.yml +2 -2
  888. package/src/runtime/tidy/rules/go/no-history-comment.yml +2 -2
  889. package/src/runtime/tidy/rules/java/no-history-comment.yml +3 -3
  890. package/src/runtime/tidy/rules/javascript/no-history-comment.yml +2 -2
  891. package/src/runtime/tidy/rules/kotlin/no-history-comment.yml +3 -3
  892. package/src/runtime/tidy/rules/lua/no-history-comment.yml +2 -2
  893. package/src/runtime/tidy/rules/php/no-history-comment.yml +2 -2
  894. package/src/runtime/tidy/rules/python/no-history-comment.yml +2 -2
  895. package/src/runtime/tidy/rules/ruby/no-history-comment.yml +2 -2
  896. package/src/runtime/tidy/rules/rust/no-history-comment.yml +3 -3
  897. package/src/runtime/tidy/rules/swift/no-history-comment.yml +3 -3
  898. package/src/runtime/tidy/rules/tsx/no-history-comment.yml +2 -2
  899. package/src/runtime/tidy/rules/typescript/no-history-comment.yml +2 -2
  900. package/src/runtime/tidy/run-engines.mjs +38 -5
  901. package/src/runtime/tidy/runners/air.mjs +16 -11
  902. package/src/runtime/tidy/runners/biome.mjs +389 -39
  903. package/src/runtime/tidy/runners/clang-format.mjs +19 -10
  904. package/src/runtime/tidy/runners/dotnet-format.mjs +238 -0
  905. package/src/runtime/tidy/runners/dprint.mjs +19 -14
  906. package/src/runtime/tidy/runners/eslint.mjs +16 -10
  907. package/src/runtime/tidy/runners/index.mjs +2 -0
  908. package/src/runtime/tidy/runners/mago.mjs +30 -14
  909. package/src/runtime/tidy/runners/psscriptanalyzer.mjs +77 -28
  910. package/src/runtime/tidy/runners/ruff.mjs +23 -14
  911. package/src/runtime/tidy/runners/rustfmt.mjs +41 -13
  912. package/src/runtime/tidy/runners/shared.mjs +55 -26
  913. package/src/runtime/tidy/runners/shellcheck.mjs +16 -10
  914. package/src/runtime/tidy/runners/stylua.mjs +16 -11
  915. package/src/runtime/tidy/structural.mjs +89 -29
  916. package/src/runtime/tidy/tool-defs.mjs +9 -6
  917. package/src/runtime/tidy/tool.mjs +44 -32
  918. package/src/runtime/web-search/index.mjs +296 -254
  919. package/src/runtime/web-search/lib/cache.mjs +92 -86
  920. package/src/runtime/web-search/lib/config.mjs +27 -24
  921. package/src/runtime/web-search/lib/document-content.mjs +139 -86
  922. package/src/runtime/web-search/lib/fetch-pipeline.mjs +128 -108
  923. package/src/runtime/web-search/lib/formatter.mjs +103 -89
  924. package/src/runtime/web-search/lib/http-fetch.mjs +284 -228
  925. package/src/runtime/web-search/lib/ssrf-guard.mjs +140 -122
  926. package/src/runtime/web-search/lib/state.mjs +65 -71
  927. package/src/runtime/web-search/lib/web-tools.mjs +213 -197
  928. package/src/runtime/web-search/tool-defs.mjs +47 -13
  929. package/src/session-runtime/agent-tool-routing.mjs +21 -19
  930. package/src/session-runtime/bridge-first-use-gate.mjs +18 -11
  931. package/src/session-runtime/builtin-features.d.mts +13 -4
  932. package/src/session-runtime/builtin-features.mjs +33 -31
  933. package/src/session-runtime/channel-config-api.mjs +4 -9
  934. package/src/session-runtime/config-helpers.mjs +53 -28
  935. package/src/session-runtime/config-lifecycle.mjs +17 -25
  936. package/src/session-runtime/context-status.mjs +58 -64
  937. package/src/session-runtime/cwd-plugins.mjs +19 -14
  938. package/src/session-runtime/deferred-tool-availability.mjs +5 -3
  939. package/src/session-runtime/deferred-tool-delta.mjs +2 -5
  940. package/src/session-runtime/effort.mjs +10 -8
  941. package/src/session-runtime/extension-scopes.mjs +10 -4
  942. package/src/session-runtime/fs-utils.mjs +5 -1
  943. package/src/session-runtime/goal-deadlines.mjs +29 -14
  944. package/src/session-runtime/goal-facade-api.mjs +9 -9
  945. package/src/session-runtime/goal-reminder.mjs +7 -11
  946. package/src/session-runtime/goal-runtime.mjs +211 -120
  947. package/src/session-runtime/goal-state.mjs +29 -26
  948. package/src/session-runtime/goal-storage.mjs +16 -5
  949. package/src/session-runtime/goal-tasks.mjs +45 -23
  950. package/src/session-runtime/goal-text.mjs +30 -24
  951. package/src/session-runtime/goal-tool-defs.mjs +91 -47
  952. package/src/session-runtime/hitch-profile.mjs +1 -1
  953. package/src/session-runtime/hook-payload.mjs +0 -1
  954. package/src/session-runtime/inheritance-fit.mjs +13 -15
  955. package/src/session-runtime/internal-tool-executor.mjs +26 -18
  956. package/src/session-runtime/lifecycle-api.mjs +288 -216
  957. package/src/session-runtime/local-model-api.mjs +9 -3
  958. package/src/session-runtime/local-provider-settings.mjs +19 -8
  959. package/src/session-runtime/mcp-glue.mjs +28 -21
  960. package/src/session-runtime/memory-runtime-prewarm.mjs +5 -5
  961. package/src/session-runtime/model-capabilities.mjs +19 -13
  962. package/src/session-runtime/model-recency.mjs +27 -11
  963. package/src/session-runtime/model-route-api.mjs +72 -55
  964. package/src/session-runtime/native-web-search.mjs +55 -45
  965. package/src/session-runtime/notification-bus.mjs +32 -17
  966. package/src/session-runtime/orchestration.mjs +27 -0
  967. package/src/session-runtime/output-styles.mjs +23 -8
  968. package/src/session-runtime/plugin-mcp.mjs +31 -27
  969. package/src/session-runtime/prewarm.mjs +96 -68
  970. package/src/session-runtime/provider-auth-api.mjs +40 -24
  971. package/src/session-runtime/provider-catalog-cache.mjs +25 -21
  972. package/src/session-runtime/provider-models.mjs +53 -42
  973. package/src/session-runtime/provider-readiness.mjs +1 -6
  974. package/src/session-runtime/provider-request-snapshot.mjs +53 -47
  975. package/src/session-runtime/provider-request-tools.mjs +13 -13
  976. package/src/session-runtime/provider-usage.mjs +13 -11
  977. package/src/session-runtime/quick-model-rows.mjs +19 -17
  978. package/src/session-runtime/quick-web-search-models.mjs +2 -6
  979. package/src/session-runtime/resource-api.mjs +78 -60
  980. package/src/session-runtime/runtime-bootstrap.mjs +5 -1
  981. package/src/session-runtime/runtime-core.mjs +179 -153
  982. package/src/session-runtime/runtime-facade.mjs +4 -0
  983. package/src/session-runtime/runtime-feature-gates.mjs +7 -10
  984. package/src/session-runtime/runtime-paths.mjs +1 -1
  985. package/src/session-runtime/runtime-review-api.mjs +4 -8
  986. package/src/session-runtime/runtime-tool-routing.mjs +11 -13
  987. package/src/session-runtime/runtime-tunables.mjs +18 -17
  988. package/src/session-runtime/self-update.mjs +11 -11
  989. package/src/session-runtime/session-hooks.mjs +62 -38
  990. package/src/session-runtime/session-lifecycle.mjs +99 -89
  991. package/src/session-runtime/session-route-policy.mjs +8 -7
  992. package/src/session-runtime/session-text.mjs +44 -26
  993. package/src/session-runtime/session-title.mjs +59 -49
  994. package/src/session-runtime/session-transcript.mjs +15 -8
  995. package/src/session-runtime/session-turn-api.mjs +502 -382
  996. package/src/session-runtime/settings-api.mjs +65 -27
  997. package/src/session-runtime/setup-tool/executor.mjs +151 -68
  998. package/src/session-runtime/setup-tool/tool-defs.mjs +95 -21
  999. package/src/session-runtime/skill-tool-loading.mjs +22 -17
  1000. package/src/session-runtime/skills-api.mjs +37 -24
  1001. package/src/session-runtime/statusline-route.mjs +1 -1
  1002. package/src/session-runtime/tool-catalog-data.mjs +56 -11
  1003. package/src/session-runtime/tool-catalog-schema.mjs +21 -24
  1004. package/src/session-runtime/tool-catalog.mjs +114 -97
  1005. package/src/session-runtime/tool-defs.mjs +16 -14
  1006. package/src/session-runtime/tool-policy-refresh.mjs +42 -36
  1007. package/src/session-runtime/tool-profile.mjs +18 -14
  1008. package/src/session-runtime/tool-surface.mjs +29 -51
  1009. package/src/session-runtime/usage-stats-api.mjs +22 -9
  1010. package/src/session-runtime/warmup-schedulers.mjs +10 -8
  1011. package/src/session-runtime/workflow-agents-api.mjs +102 -54
  1012. package/src/session-runtime/workflow.mjs +86 -90
  1013. package/src/standalone/agent-dispatch-broker.mjs +31 -22
  1014. package/src/standalone/agent-task-status.mjs +10 -24
  1015. package/src/standalone/agent-tool/helpers.mjs +44 -9
  1016. package/src/standalone/agent-tool/job-task-reconcile.mjs +16 -15
  1017. package/src/standalone/agent-tool/job-views.mjs +69 -42
  1018. package/src/standalone/agent-tool/lead-worker-index.mjs +28 -18
  1019. package/src/standalone/agent-tool/notify.mjs +23 -11
  1020. package/src/standalone/agent-tool/provider-init.mjs +35 -10
  1021. package/src/standalone/agent-tool/render.mjs +16 -9
  1022. package/src/standalone/agent-tool/spawn-flow.mjs +132 -107
  1023. package/src/standalone/agent-tool/spawn-preset.mjs +3 -5
  1024. package/src/standalone/agent-tool/tag-registry.mjs +145 -3
  1025. package/src/standalone/agent-tool/tool-def.mjs +26 -7
  1026. package/src/standalone/agent-tool/worker-index.mjs +73 -51
  1027. package/src/standalone/agent-tool/worker-rows.mjs +22 -7
  1028. package/src/standalone/agent-tool.mjs +189 -184
  1029. package/src/standalone/agent-watchdog-registry.mjs +32 -11
  1030. package/src/standalone/boot-phase-profiler.mjs +1 -5
  1031. package/src/standalone/channel-admin.mjs +44 -45
  1032. package/src/standalone/channel-binding.mjs +6 -2
  1033. package/src/standalone/channel-client.mjs +238 -151
  1034. package/src/standalone/channel-session-router.mjs +8 -10
  1035. package/src/standalone/channel-transport.mjs +233 -115
  1036. package/src/standalone/channel-worker.mjs +74 -40
  1037. package/src/standalone/daemon-boot-coordinator.mjs +2 -2
  1038. package/src/standalone/daemon-crash-capture.mjs +81 -37
  1039. package/src/standalone/daemon-log.mjs +34 -15
  1040. package/src/standalone/daemon-telemetry.mjs +14 -9
  1041. package/src/standalone/daemon.mjs +199 -117
  1042. package/src/standalone/desktop-service-registry.mjs +28 -19
  1043. package/src/standalone/fair-call-scheduler.mjs +18 -20
  1044. package/src/standalone/folder-dialog.mjs +19 -10
  1045. package/src/standalone/hook-bus/command-handler.mjs +31 -18
  1046. package/src/standalone/hook-bus/config.mjs +22 -14
  1047. package/src/standalone/hook-bus/constants.mjs +1 -5
  1048. package/src/standalone/hook-bus/handlers.mjs +68 -29
  1049. package/src/standalone/hook-bus/rules.mjs +6 -4
  1050. package/src/standalone/hook-bus.mjs +76 -49
  1051. package/src/standalone/memory-runtime-proxy.mjs +187 -132
  1052. package/src/standalone/opencode-go-login.mjs +22 -7
  1053. package/src/standalone/plugin-admin.mjs +52 -41
  1054. package/src/standalone/projects.mjs +1 -3
  1055. package/src/standalone/provider-admin.mjs +173 -67
  1056. package/src/standalone/rpc-call-identity.mjs +3 -4
  1057. package/src/standalone/seeds.mjs +18 -4
  1058. package/src/standalone/session-attachment-pool.mjs +1 -6
  1059. package/src/standalone/session-call-cache.mjs +62 -33
  1060. package/src/standalone/session-client.mjs +245 -187
  1061. package/src/standalone/session-frame-stream.mjs +44 -24
  1062. package/src/standalone/session-protocol.mjs +4 -0
  1063. package/src/standalone/session-proxy.mjs +152 -110
  1064. package/src/standalone/session-runtime-agent-control-client.mjs +41 -39
  1065. package/src/standalone/session-runtime-host-factory.mjs +11 -6
  1066. package/src/standalone/session-runtime-host.mjs +291 -203
  1067. package/src/standalone/session-runtime-inline-host.mjs +29 -35
  1068. package/src/standalone/session-runtime-provider-cooldown.mjs +15 -15
  1069. package/src/standalone/session-runtime-record.mjs +3 -1
  1070. package/src/standalone/session-runtime-shard-router.mjs +12 -6
  1071. package/src/standalone/session-runtime-worker.mjs +105 -74
  1072. package/src/standalone/session-service/agent-tree.mjs +63 -70
  1073. package/src/standalone/session-service/projection.mjs +37 -31
  1074. package/src/standalone/session-service/stored-reader.mjs +2 -3
  1075. package/src/standalone/session-service.mjs +130 -134
  1076. package/src/standalone/session-state-patch.mjs +2 -7
  1077. package/src/standalone/session-state-projection.mjs +1 -1
  1078. package/src/standalone/session-transport.mjs +110 -89
  1079. package/src/standalone/session-wire.mjs +8 -9
  1080. package/src/standalone/usage-dashboard-model.mjs +170 -93
  1081. package/src/standalone/usage-dashboard.mjs +14 -15
  1082. package/src/standalone/usage-stats-hours.mjs +49 -13
  1083. package/src/standalone/usage-stats-model.mjs +38 -43
  1084. package/src/standalone/usage-stats-period.mjs +46 -11
  1085. package/src/tui/App.jsx +167 -272
  1086. package/src/tui/app/app-format.mjs +26 -28
  1087. package/src/tui/app/app-view.jsx +363 -177
  1088. package/src/tui/app/clipboard.mjs +4 -2
  1089. package/src/tui/app/core-memory-picker.mjs +18 -22
  1090. package/src/tui/app/create-app-pickers.mjs +10 -12
  1091. package/src/tui/app/doctor.mjs +14 -3
  1092. package/src/tui/app/extension-pickers.mjs +43 -20
  1093. package/src/tui/app/input-parsers.mjs +17 -6
  1094. package/src/tui/app/live-spinner-visibility.mjs +15 -12
  1095. package/src/tui/app/maintenance-pickers.mjs +63 -37
  1096. package/src/tui/app/message-selector.mjs +27 -19
  1097. package/src/tui/app/model-options.mjs +40 -45
  1098. package/src/tui/app/model-picker.mjs +98 -76
  1099. package/src/tui/app/onboarding-steps.mjs +50 -33
  1100. package/src/tui/app/panel-surface.mjs +1 -3
  1101. package/src/tui/app/project-picker.mjs +25 -24
  1102. package/src/tui/app/prompt-submit.mjs +143 -86
  1103. package/src/tui/app/provider-setup-picker.mjs +66 -49
  1104. package/src/tui/app/resume-picker.mjs +13 -11
  1105. package/src/tui/app/route-pickers.mjs +71 -51
  1106. package/src/tui/app/settings-picker.mjs +93 -57
  1107. package/src/tui/app/shell-layout.mjs +78 -66
  1108. package/src/tui/app/slash-commands.mjs +57 -11
  1109. package/src/tui/app/slash-dispatch.mjs +80 -52
  1110. package/src/tui/app/text-entry-policy.mjs +1 -5
  1111. package/src/tui/app/text-layout.mjs +2 -2
  1112. package/src/tui/app/theme-effort-pickers.mjs +36 -25
  1113. package/src/tui/app/transcript-row-estimate.mjs +51 -23
  1114. package/src/tui/app/transcript-window.mjs +142 -147
  1115. package/src/tui/app/usage-context-panels.mjs +39 -28
  1116. package/src/tui/app/use-copy-selection.mjs +44 -45
  1117. package/src/tui/app/use-global-key-input.mjs +131 -116
  1118. package/src/tui/app/use-mouse-input.mjs +78 -52
  1119. package/src/tui/app/use-prompt-draft-flow.mjs +96 -75
  1120. package/src/tui/app/use-prompt-handlers.mjs +259 -208
  1121. package/src/tui/app/use-prompt-hint.mjs +7 -7
  1122. package/src/tui/app/use-prompt-queue-history.mjs +109 -95
  1123. package/src/tui/app/use-terminal-chrome.mjs +3 -1
  1124. package/src/tui/app/use-transcript-activity.mjs +16 -7
  1125. package/src/tui/app/use-transcript-scroll.mjs +484 -442
  1126. package/src/tui/app/use-transcript-window.mjs +101 -84
  1127. package/src/tui/app/use-welcome-prompt-hint.mjs +8 -3
  1128. package/src/tui/components/AnsiText.jsx +1 -4
  1129. package/src/tui/components/ConfirmBar.jsx +1 -5
  1130. package/src/tui/components/ContextPanel.jsx +38 -13
  1131. package/src/tui/components/ItemRightHintOverprint.jsx +8 -17
  1132. package/src/tui/components/Markdown.jsx +32 -31
  1133. package/src/tui/components/MarkdownTable.jsx +0 -1
  1134. package/src/tui/components/Message.jsx +20 -18
  1135. package/src/tui/components/Picker.jsx +136 -51
  1136. package/src/tui/components/PromptInput.jsx +523 -471
  1137. package/src/tui/components/QueuedCommands.jsx +13 -5
  1138. package/src/tui/components/SlashCommandPalette.jsx +27 -22
  1139. package/src/tui/components/Spinner.jsx +106 -39
  1140. package/src/tui/components/StatusLine.jsx +143 -59
  1141. package/src/tui/components/TextEntryPanel.jsx +219 -189
  1142. package/src/tui/components/ToolExecution.jsx +120 -72
  1143. package/src/tui/components/TranscriptItem.jsx +88 -16
  1144. package/src/tui/components/TurnDone.jsx +48 -10
  1145. package/src/tui/components/UsagePanel.jsx +38 -17
  1146. package/src/tui/components/prompt-input/edit-helpers.mjs +4 -8
  1147. package/src/tui/components/prompt-input/escape-policy.mjs +7 -8
  1148. package/src/tui/components/prompt-input/restore-policy.d.mts +3 -6
  1149. package/src/tui/components/prompt-input/restore-policy.mjs +30 -38
  1150. package/src/tui/components/tool-execution/ResultBody.jsx +16 -16
  1151. package/src/tui/components/tool-output-format.mjs +20 -20
  1152. package/src/tui/dist/index.mjs +18026 -16836
  1153. package/src/tui/index.jsx +139 -42
  1154. package/src/tui/input-editing.mjs +6 -7
  1155. package/src/tui/lib/voice-setup.mjs +2 -4
  1156. package/src/tui/markdown/format-token.mjs +111 -55
  1157. package/src/tui/markdown/measure-rendered-rows.mjs +34 -24
  1158. package/src/tui/markdown/render-ansi.mjs +15 -15
  1159. package/src/tui/markdown/stream-fence.mjs +6 -6
  1160. package/src/tui/markdown/streaming-markdown.mjs +3 -8
  1161. package/src/tui/markdown/table-layout.mjs +3 -4
  1162. package/src/tui/paste-attachments.mjs +43 -22
  1163. package/src/tui/paste-text-policy.mjs +4 -3
  1164. package/src/tui/prompt-history-store.mjs +15 -18
  1165. package/src/tui/session/agent-envelope.mjs +106 -58
  1166. package/src/tui/session/agent-job-feed.mjs +105 -71
  1167. package/src/tui/session/agent-response-tail.mjs +10 -8
  1168. package/src/tui/session/boot-profile.mjs +1 -1
  1169. package/src/tui/session/context-state.mjs +25 -19
  1170. package/src/tui/session/goal-continuation.mjs +20 -25
  1171. package/src/tui/session/goal-turn-state.mjs +4 -2
  1172. package/src/tui/session/labels.mjs +3 -12
  1173. package/src/tui/session/live-share.mjs +250 -132
  1174. package/src/tui/session/notice-text.mjs +4 -5
  1175. package/src/tui/session/notification-plan.mjs +10 -4
  1176. package/src/tui/session/oauth-flows.mjs +26 -21
  1177. package/src/tui/session/prompt-history.mjs +4 -1
  1178. package/src/tui/session/queue-helpers.mjs +33 -31
  1179. package/src/tui/session/render-frame-source.mjs +9 -9
  1180. package/src/tui/session/render-timing.mjs +69 -79
  1181. package/src/tui/session/session-api-ext.mjs +234 -148
  1182. package/src/tui/session/session-api.mjs +142 -63
  1183. package/src/tui/session/session-flow.mjs +174 -84
  1184. package/src/tui/session/tool-approval.mjs +12 -4
  1185. package/src/tui/session/tool-call-fields.mjs +2 -6
  1186. package/src/tui/session/tool-card-results.mjs +41 -10
  1187. package/src/tui/session/tool-result-status.mjs +34 -41
  1188. package/src/tui/session/tool-result-text.mjs +48 -13
  1189. package/src/tui/session/transcript-spill.mjs +73 -46
  1190. package/src/tui/session/tui-steering-persist.mjs +105 -83
  1191. package/src/tui/session/turn-aggregate-cards.mjs +19 -14
  1192. package/src/tui/session/turn-deferred-cards.mjs +23 -6
  1193. package/src/tui/session/turn.mjs +278 -120
  1194. package/src/tui/session-local.mjs +277 -151
  1195. package/src/tui/spinner-meta.mjs +6 -2
  1196. package/src/tui/spinner-verbs.mjs +188 -35
  1197. package/src/tui/statusline-ansi-bridge.mjs +10 -8
  1198. package/src/tui/theme.mjs +9 -16
  1199. package/src/tui/themes/catppuccin.mjs +0 -1
  1200. package/src/tui/themes/index.mjs +85 -15
  1201. package/src/tui/themes/nord.mjs +0 -1
  1202. package/src/tui/themes/utils.mjs +8 -12
  1203. package/src/tui/transcript-tool-failures.mjs +3 -1
  1204. package/src/ui/ansi.mjs +13 -13
  1205. package/src/ui/context-measurement.mjs +24 -15
  1206. package/src/ui/markdown.mjs +28 -23
  1207. package/src/ui/model-display.mjs +6 -8
  1208. package/src/ui/statusline-agents.mjs +32 -16
  1209. package/src/ui/statusline-format.mjs +2 -2
  1210. package/src/ui/statusline-segments.mjs +27 -9
  1211. package/src/ui/statusline.mjs +149 -66
  1212. package/src/ui/streaming-markdown-heal.mjs +57 -6
  1213. package/src/ui/tool-card.mjs +5 -1
  1214. package/src/workflows/default/WORKFLOW.md +3 -10
  1215. package/src/workflows/headless/WORKFLOW.md +0 -1
  1216. package/src/workflows/solo/WORKFLOW.md +0 -16
package/README.md CHANGED
@@ -17,7 +17,7 @@ to coordinating agents and shaping your own workflows.
17
17
  - **Efficiency that turns into more work.** Cache-aware context, focused
18
18
  tools, and compaction reduce overhead so more of your budget goes toward
19
19
  the task. The same-model Terminal-Bench comparisons below show comparable
20
- or better results with less context and lower priced cost.
20
+ or better results with smaller contexts and lower costs at the same API rates.
21
21
  - **Advanced capabilities, within easy reach.** Guided setup and visual
22
22
  controls help you assign models by role, configure workflows, and work
23
23
  with parallel agent sessions without building your own agent stack.
@@ -100,16 +100,60 @@ task checksums, and the usage snapshots behind every cost figure — alongside
100
100
  the harness, presets, and metric scripts that recompute each number above:
101
101
  [`benchmarks/terminal-bench-2.1/`](benchmarks/terminal-bench-2.1/).
102
102
 
103
+ ## How Mixdog keeps context lean
104
+
105
+ Efficiency comes from several layers working together, not just a shorter
106
+ prompt or a larger context window:
107
+
108
+ 1. **Lightweight system instructions** — continuously refined rules keep
109
+ operating guidance focused without repeating the same policy.
110
+ 2. **Purpose-built tools** — scoped queries, batched calls, and bounded
111
+ results retrieve the evidence a task needs instead of dumping whole files.
112
+ 3. **Built-in ast-grep and code graphs** — parsed symbols, signatures, calls,
113
+ and imports answer structural questions without repeated text searches.
114
+ 4. **Provider-aware caching** — stable prompt layers and provider-specific
115
+ cache controls help reuse context that has already been processed.
116
+ 5. **Structured compaction** — a task handoff, the latest request, and a
117
+ bounded execution history keep long sessions moving.
118
+ 6. **Idle-time context reduction** — configurable automatic compaction
119
+ reduces the context sent after long idle gaps, when caches may be cold.
120
+ 7. **On-demand prompt loading** — skill bodies and deferred tool schemas
121
+ load when needed; stable instructions stay separate from changing state.
122
+ 8. **Database-backed long-term memory** — retrieve relevant history instead
123
+ of injecting the whole archive into every session.
124
+ 9. **Tool-result reduction** — repeated results become short references,
125
+ while large outputs can be saved separately and returned as previews.
126
+
127
+ Caching can reduce repeated processing and input cost, but cached tokens
128
+ still count toward the model's context limit. Compaction, selective retrieval,
129
+ and output reduction reduce the amount of context the model needs. See
130
+ [Context efficiency](docs/context-efficiency.md) for the mechanisms,
131
+ implementation references, and limits.
132
+
103
133
  ## What you can do
104
134
 
105
135
  ### Build, test, and review
106
136
 
107
- Search repositories with text and symbol-aware tools, edit files, run tests
137
+ Search repositories with text and AST-based tools, edit files, run tests
108
138
  and background commands, and review changes. Desktop brings the agent together
109
139
  with a Monaco editor, Git, terminals, and a file explorer. Use workflows and
110
140
  role-specific models to organize work, and extend the toolset with MCP
111
141
  servers, skills, hooks, and plugins.
112
142
 
143
+ **Code graph.** Inspect exports, signatures, and nested members; locate
144
+ declarations and references; trace calls and imports; and assess which files
145
+ a change may affect. Call relationships come from parsed call sites rather than
146
+ text matches, and identifier references exclude comment-only mentions.
147
+ The native engine embeds tree-sitter and ast-grep, parses 31 languages, and
148
+ extracts symbols and imports for 24. Capabilities vary by language; this is
149
+ structural navigation, not a replacement for a compiler's type analysis.
150
+
151
+ **Code Tidy.** Install the built-in capability to format, lint, and check
152
+ structural rules through the agent. It respects project configuration and
153
+ uses project-local, system-installed, or supported managed engines.
154
+ Fixes are previewed without changing files unless explicitly applied. See
155
+ [Code Tidy](docs/code-tidy.md) for engine setup and rule coverage.
156
+
113
157
  The GitHub integration manages repositories, issues, pull requests and reviews,
114
158
  Actions, releases, and notifications. Source Control commits use a manually
115
159
  entered summary and optional description; there is no built-in AI commit-message
@@ -118,11 +162,18 @@ operations and permission requirements.
118
162
 
119
163
  ### Keep longer work moving
120
164
 
121
- Resume saved chats, recall prior work through local semantic and lexical
122
- search, and retain project-scoped preferences across sessions. Compaction
123
- keeps long conversations manageable. For an explicitly requested longer-running
124
- objective, **Goals** track completion conditions and tasks, support time limits
125
- and automatic continuation, and let you pause or resume the work.
165
+ Resume saved chats and recall prior work through local semantic and lexical
166
+ search. Long-term memory separates searchable conversation history (`recall`)
167
+ from approved shared or project-scoped preferences (`memory`); generated
168
+ conversation summaries do not become standing instructions.
169
+
170
+ Compaction keeps long conversations manageable while retaining the latest
171
+ request and the context needed to continue. Configurable idle-time compaction
172
+ can also reduce input cost when resuming after a long idle period, when the
173
+ provider's cache may have expired.
174
+ For an explicitly requested longer-running objective, **Goals** track
175
+ completion conditions and tasks, support time limits and automatic
176
+ continuation, and let you pause or resume the work.
126
177
 
127
178
  ### Work beyond the repository
128
179
 
@@ -135,8 +186,12 @@ and automatic continuation, and let you pause or resume the work.
135
186
  `browser_devtools`.
136
187
  - **Computer Use on Windows** — operate native apps through accessibility,
137
188
  screenshots, OCR, keyboard, and pointer input with guarded execution.
189
+ An overlay provides Stop and Resume controls.
138
190
  - **Documents** — create and edit Word, Excel, and PowerPoint files, work
139
- with PDFs, and inspect rendered previews and document quality checks.
191
+ with PDFs, and review rendered previews alongside automated checks.
192
+ Use portable OOXML editing without Microsoft Office, or Microsoft Office
193
+ automation on Windows. Rendering and spreadsheet recalculation depend on
194
+ the available engines. See [Office runtime](src/runtime/office/README.md).
140
195
  - **Image and video Studio** — generate and edit images, generate short video
141
196
  clips, and keep the results in a persistent local gallery. Continue a clip
142
197
  by using its last frame as the reference for a new generation; this carries
@@ -247,7 +302,7 @@ diagnostics remain on stderr.
247
302
  /inherit carry this conversation into a new session on the current model
248
303
  /compact compact older conversation context
249
304
  /goal start, inspect, pause, or resume a durable session Goal
250
- /autoclear manage idle-time context clearing
305
+ /autoclear manage idle-time context compaction
251
306
  /context inspect the current context surface
252
307
  /usage show provider quota and balance
253
308
  /providers configure provider authentication
@@ -300,6 +355,7 @@ The workspace includes:
300
355
  - Split panes for parallel, independently routed agent sessions
301
356
  - Live session handoff between the TUI, desktop windows, and paired browsers
302
357
  - Monaco editor, LSP integration, diffs, and turn-by-turn edit review
358
+ - Built-in code graph navigation and installable Code Tidy checks and fixes
303
359
  - Git staging, commits with manually entered messages, and branches
304
360
  - GitHub repositories, issues, pull requests, reviews, Actions, releases,
305
361
  and notifications
@@ -313,7 +369,7 @@ The workspace includes:
313
369
  progress and controls
314
370
  - Voice dictation with an optional local transcription runtime
315
371
  - Extensions hub with guided setup for Git & GitHub, Memory, Browser Use,
316
- Computer Use, Office, Local Provider, and voice
372
+ Computer Use, Office, Code Tidy, Local Provider, and voice
317
373
  - Provider setup, usage, git identity, and remote pairing settings
318
374
 
319
375
  In **Extensions**, the **Plugin** tab manages integrations and built-in
@@ -344,6 +400,23 @@ Useful environment variables:
344
400
  - `MIXDOG_MODE=ship|dev` — select shipping or development diagnostics.
345
401
  - `MIXDOG_DIAGNOSTICS=1` — force diagnostic trace and log output.
346
402
 
403
+ ## Core technology
404
+
405
+ | Layer | Stack |
406
+ | --- | --- |
407
+ | Shared agent runtime | Node.js and ECMAScript modules, shared by CLI and Desktop |
408
+ | Terminal UI | React and Ink |
409
+ | Desktop workspace | Electron, React, TypeScript, Monaco, and xterm.js |
410
+ | Native code tools | Rust, tree-sitter, and embedded ast-grep for parsing, structural queries, and rule-based checks |
411
+ | Browser automation | Chromium and the Chrome DevTools Protocol (CDP) |
412
+ | Long-term memory | Managed local PostgreSQL with pgvector and full-text search |
413
+ | Documents | Portable OOXML and PDF tooling, plus Microsoft Office automation on Windows |
414
+
415
+ These components serve different roles: native tools analyze code, database
416
+ retrieval keeps historical context selective, and provider-specific caching
417
+ reduces repeated model processing. See [Context efficiency](docs/context-efficiency.md)
418
+ for how they work with prompt management and compaction.
419
+
347
420
  ## Development
348
421
 
349
422
  ```bash
@@ -379,7 +452,7 @@ Main directories:
379
452
  src/ CLI, TUI, runtime, workflows, agents, and rules
380
453
  apps/desktop/ cross-platform desktop app
381
454
  apps/relay/ remote web app and relay
382
- native/ native process, search, patch, and support binaries
455
+ native/ native process, search, graph, patch, and support binaries
383
456
  scripts/ tests, diagnostics, benchmarks, and build scripts
384
457
  benchmarks/ reproducible benchmark harnesses, results, and raw artifacts
385
458
  src/vendor/ vendored runtime components
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mixdog",
3
- "version": "0.9.168",
3
+ "version": "0.9.169",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Standalone mixdog coding-agent CLI/TUI workspace.",
@@ -79,20 +79,21 @@ try {
79
79
  const toolEvents = [];
80
80
  const askOptions = {
81
81
  onAssistantToolCallObserved: (call) => toolEvents.push({ kind: 'call', name: call?.name || call?.tool || '?' }),
82
- onToolResult: (message) => toolEvents.push({
83
- kind: 'result',
84
- name: message?.name || message?.tool || '?',
85
- preview: String(message?.content ?? message?.output ?? '').slice(0, 200),
86
- }),
82
+ onToolResult: (message) =>
83
+ toolEvents.push({
84
+ kind: 'result',
85
+ name: message?.name || message?.tool || '?',
86
+ preview: String(message?.content ?? message?.output ?? '').slice(0, 200),
87
+ }),
87
88
  };
88
89
  const ask1 = await runtime.ask(
89
- 'Delegate one task via the agent tool. If `agent` is not directly callable, first call '
90
- + `load_tool with names=['agent'] to activate it. Then call agent with exactly type=spawn, agent=${WORKER_AGENT} and prompt `
91
- + "'Read package.json in the current repo and reply with exactly the value of its name field, one word, nothing else.' "
92
- + 'Do NOT set provider/model/effort (routing decides). Do not use read/grep/shell yourself. '
93
- + 'After the spawn tool call returns, reply with exactly: SPAWNED. '
94
- + 'Only if activating AND calling the agent tool both fail, reply exactly: AGENT_UNAVAILABLE',
95
- askOptions,
90
+ 'Delegate one task via the agent tool. If `agent` is not directly callable, first call ' +
91
+ `load_tool with names=['agent'] to activate it. Then call agent with exactly type=spawn, agent=${WORKER_AGENT} and prompt ` +
92
+ "'Read package.json in the current repo and reply with exactly the value of its name field, one word, nothing else.' " +
93
+ 'Do NOT set provider/model/effort (routing decides). Do not use read/grep/shell yourself. ' +
94
+ 'After the spawn tool call returns, reply with exactly: SPAWNED. ' +
95
+ 'Only if activating AND calling the agent tool both fail, reply exactly: AGENT_UNAVAILABLE',
96
+ askOptions
96
97
  );
97
98
  const spawnReply = String(ask1?.result?.content || '');
98
99
  process.stdout.write(`turn1 tools: ${JSON.stringify(toolEvents)}\n`);
@@ -111,45 +112,71 @@ try {
111
112
  scope = status.agentScope || scope;
112
113
  const workers = status.agentWorkers || [];
113
114
  if (!sawWorkerRow && workers.length > 0) sawWorkerRow = workers[0];
114
- terminalJob = (status.agentJobs || []).find(
115
- (job) => /completed|failed|cancelled/i.test(String(job.status)),
116
- ) || null;
115
+ terminalJob =
116
+ (status.agentJobs || []).find((job) => /completed|failed|cancelled/i.test(String(job.status))) || null;
117
117
  if (!terminalJob) await sleep(300);
118
118
  }
119
- process.stdout.write(`final status surface: ${JSON.stringify({
120
- workers: lastStatus?.agentWorkers || [],
121
- jobs: lastStatus?.agentJobs || [],
122
- }).slice(0, 1_500)}\n`);
123
- check(Boolean(sawWorkerRow), 'worker visible on the session agent status surface',
124
- sawWorkerRow ? `tag=${sawWorkerRow.tag} stage=${sawWorkerRow.stage}` : 'never appeared');
119
+ process.stdout.write(
120
+ `final status surface: ${JSON.stringify({
121
+ workers: lastStatus?.agentWorkers || [],
122
+ jobs: lastStatus?.agentJobs || [],
123
+ }).slice(0, 1_500)}\n`
124
+ );
125
+ check(
126
+ Boolean(sawWorkerRow),
127
+ 'worker visible on the session agent status surface',
128
+ sawWorkerRow ? `tag=${sawWorkerRow.tag} stage=${sawWorkerRow.stage}` : 'never appeared'
129
+ );
125
130
  check(Boolean(terminalJob), 'agent job reached a terminal state');
126
- check(terminalJob?.status === 'completed', 'agent job completed without error',
127
- `status=${terminalJob?.status} error=${terminalJob?.error || 'none'}`);
128
- check(Boolean(terminalJob?.provider && terminalJob?.model), 'routing rules resolved the worker route',
129
- `agent=${terminalJob?.agent} route=${terminalJob?.provider}/${terminalJob?.model} preset=${terminalJob?.preset || '-'}`);
130
- check(scope?.sessionId === runtime.id, 'agent status surface is scoped to the owner session',
131
- `scope=${JSON.stringify(scope)} lead=${runtime.id}`);
131
+ check(
132
+ terminalJob?.status === 'completed',
133
+ 'agent job completed without error',
134
+ `status=${terminalJob?.status} error=${terminalJob?.error || 'none'}`
135
+ );
136
+ check(
137
+ Boolean(terminalJob?.provider && terminalJob?.model),
138
+ 'routing rules resolved the worker route',
139
+ `agent=${terminalJob?.agent} route=${terminalJob?.provider}/${terminalJob?.model} preset=${terminalJob?.preset || '-'}`
140
+ );
141
+ check(
142
+ scope?.sessionId === runtime.id,
143
+ 'agent status surface is scoped to the owner session',
144
+ `scope=${JSON.stringify(scope)} lead=${runtime.id}`
145
+ );
132
146
  await sleep(500);
133
- check(notifications.length > 0, 'owner received the completion notification',
134
- `count=${notifications.length}`);
147
+ check(notifications.length > 0, 'owner received the completion notification', `count=${notifications.length}`);
135
148
 
136
149
  // Mirror the surface's notification injection into the next Lead turn.
137
- const notifText = notifications.map((event) => {
138
- try { return typeof event === 'string' ? event : JSON.stringify(event); } catch { return String(event); }
139
- }).join('\n').slice(0, 4_000);
150
+ const notifText = notifications
151
+ .map((event) => {
152
+ try {
153
+ return typeof event === 'string' ? event : JSON.stringify(event);
154
+ } catch {
155
+ return String(event);
156
+ }
157
+ })
158
+ .join('\n')
159
+ .slice(0, 4_000);
140
160
  const ask2 = await runtime.ask(
141
- `Agent completion notification:\n${notifText}\n\n`
142
- + 'Reply with exactly: WORKER_SAID=<the worker\'s one-word answer from the notification>',
143
- {},
161
+ `Agent completion notification:\n${notifText}\n\n` +
162
+ "Reply with exactly: WORKER_SAID=<the worker's one-word answer from the notification>",
163
+ {}
144
164
  );
145
165
  const finalReply = String(ask2?.result?.content || '');
146
- check(/WORKER_SAID=\s*mixdog/i.test(finalReply), 'Lead surfaced the worker result',
147
- finalReply.slice(0, 160));
166
+ check(/WORKER_SAID=\s*mixdog/i.test(finalReply), 'Lead surfaced the worker result', finalReply.slice(0, 160));
148
167
 
149
168
  process.stdout.write(`verdict: ${failures.length === 0 ? 'PASS' : `FAIL (${failures.join('; ')})`}\n`);
150
169
  process.exitCode = failures.length === 0 ? 0 : 1;
151
170
  } finally {
152
- try { await runtime?.stop?.('lead-e2e-probe-exit'); } catch { /* teardown */ }
153
- try { rmSync(ROOT, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 }); } catch { /* temp */ }
171
+ try {
172
+ await runtime?.stop?.('lead-e2e-probe-exit');
173
+ } catch {
174
+ /* teardown */
175
+ }
176
+ try {
177
+ rmSync(ROOT, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
178
+ } catch {
179
+ /* temp */
180
+ }
154
181
  }
155
182
  process.exit(process.exitCode || 0);
@@ -52,31 +52,36 @@ const mgr = await import('../src/runtime/agent/orchestrator/session/manager.mjs'
52
52
  const { createStandaloneAgent } = await import('../src/standalone/agent-tool.mjs');
53
53
  const { ensureDaemon, readSessionDiscovery, shutdownDaemon } = await import('../src/standalone/session-client.mjs');
54
54
 
55
- function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); }
55
+ function sleep(ms) {
56
+ return new Promise((resolve) => setTimeout(resolve, ms));
57
+ }
56
58
 
57
59
  try {
58
60
  await ensureDaemon({ cwd: REPO, log: () => {} });
59
61
  const agent = createStandaloneAgent({ cfgMod, reg, mgr, dataDir: join(ROOT, 'data-probe'), cwd: REPO });
60
62
  const t0 = Date.now();
61
- const out = await agent.execute({
62
- type: 'spawn',
63
- agent: 'worker',
64
- provider: PROVIDER,
65
- model: MODEL,
66
- effort: EFFORT,
67
- tag: 'turn-trace',
68
- cwd: REPO,
69
- prompt: [
70
- 'Execute these steps strictly IN ORDER, exactly ONE tool call per assistant message',
71
- '(never batch two calls in one message this measures sequential rounds):',
72
- '1) read package.json',
73
- '2) read README.md (first 40 lines)',
74
- '3) run the shell command: node -v',
75
- '4) read apps/desktop/package.json',
76
- '5) grep the string "createSessionRuntimeHost" under src/standalone (files list only)',
77
- 'Then reply with one line: DONE <package name> <node version>. Do not edit anything.',
78
- ].join('\n'),
79
- }, { invocationSource: 'model-tool', cwd: REPO });
63
+ const out = await agent.execute(
64
+ {
65
+ type: 'spawn',
66
+ agent: 'worker',
67
+ provider: PROVIDER,
68
+ model: MODEL,
69
+ effort: EFFORT,
70
+ tag: 'turn-trace',
71
+ cwd: REPO,
72
+ prompt: [
73
+ 'Execute these steps strictly IN ORDER, exactly ONE tool call per assistant message',
74
+ '(never batch two calls in one message — this measures sequential rounds):',
75
+ '1) read package.json',
76
+ '2) read README.md (first 40 lines)',
77
+ '3) run the shell command: node -v',
78
+ '4) read apps/desktop/package.json',
79
+ '5) grep the string "createSessionRuntimeHost" under src/standalone (files list only)',
80
+ 'Then reply with one line: DONE <package name> <node version>. Do not edit anything.',
81
+ ].join('\n'),
82
+ },
83
+ { invocationSource: 'model-tool', cwd: REPO }
84
+ );
80
85
  const id = String(out).match(/agent task: (\S+)/)?.[1];
81
86
  if (!id) throw new Error(`no task id: ${out}`);
82
87
  let last = '';
@@ -86,41 +91,68 @@ try {
86
91
  await sleep(500);
87
92
  }
88
93
  process.stdout.write(`wall=${((Date.now() - t0) / 1000).toFixed(1)}s\n--- result ---\n${last.slice(0, 400)}\n`);
89
- try { agent.closeAll('turn-trace probe end'); } catch { /* teardown */ }
94
+ try {
95
+ agent.closeAll('turn-trace probe end');
96
+ } catch {
97
+ /* teardown */
98
+ }
90
99
 
91
100
  // The runtime worker flushes its local trace buffer on a short timer.
92
101
  await sleep(9_000);
93
102
  const rows = existsSync(TRACE_PATH)
94
- ? readFileSync(TRACE_PATH, 'utf8').split('\n').filter(Boolean).flatMap((line) => {
95
- try { return [JSON.parse(line)]; } catch { return []; }
96
- })
103
+ ? readFileSync(TRACE_PATH, 'utf8')
104
+ .split('\n')
105
+ .filter(Boolean)
106
+ .flatMap((line) => {
107
+ try {
108
+ return [JSON.parse(line)];
109
+ } catch {
110
+ return [];
111
+ }
112
+ })
97
113
  : [];
98
114
  process.stdout.write(`--- trace (${rows.length} rows) ---\n`);
99
115
  for (const row of rows) {
100
116
  if (row.kind === 'loop') {
101
- process.stdout.write(`[loop] iter=${row.iteration ?? row.payload?.iteration} send=${row.send_ms ?? row.payload?.send_ms}ms`
102
- + ` preSend=${row.pre_send_ms ?? row.payload?.pre_send_ms}ms toolResume=${row.tool_resume_ms ?? row.payload?.tool_resume_ms}ms`
103
- + ` msgs=${row.message_count ?? row.payload?.message_count}\n`);
117
+ process.stdout.write(
118
+ `[loop] iter=${row.iteration ?? row.payload?.iteration} send=${row.send_ms ?? row.payload?.send_ms}ms` +
119
+ ` preSend=${row.pre_send_ms ?? row.payload?.pre_send_ms}ms toolResume=${row.tool_resume_ms ?? row.payload?.tool_resume_ms}ms` +
120
+ ` msgs=${row.message_count ?? row.payload?.message_count}\n`
121
+ );
104
122
  } else if (row.kind === 'sse') {
105
123
  process.stdout.write(`[sse] ttft=${row.ttft_ms}ms streamTotal=${row.stream_total_ms}ms\n`);
106
124
  } else if (row.kind === 'turn_timing') {
107
- process.stdout.write(`[turn] status=${row.status} ttft=${row.ttft_ms}ms e2eTtft=${row.end_to_end_ttft_ms}ms`
108
- + ` queue=${row.queue_ms}ms route=${row.route_ms}ms preflight=${row.preflight_ms}ms provider=${row.provider_ms}ms\n`);
125
+ process.stdout.write(
126
+ `[turn] status=${row.status} ttft=${row.ttft_ms}ms e2eTtft=${row.end_to_end_ttft_ms}ms` +
127
+ ` queue=${row.queue_ms}ms route=${row.route_ms}ms preflight=${row.preflight_ms}ms provider=${row.provider_ms}ms\n`
128
+ );
109
129
  } else if (row.kind === 'usage_raw') {
110
- process.stdout.write(`[usage] iter=${row.iteration} input=${row.input_tokens} cached=${row.cached_tokens}`
111
- + ` cacheWrite=${row.cache_write_tokens} uncached=${row.uncached_input_tokens} output=${row.output_tokens}`
112
- + ` chain=${row.chain_continuous ?? '-'}\n`);
130
+ process.stdout.write(
131
+ `[usage] iter=${row.iteration} input=${row.input_tokens} cached=${row.cached_tokens}` +
132
+ ` cacheWrite=${row.cache_write_tokens} uncached=${row.uncached_input_tokens} output=${row.output_tokens}` +
133
+ ` chain=${row.chain_continuous ?? '-'}\n`
134
+ );
113
135
  } else if (row.kind === 'tool') {
114
136
  const p = row.payload || row;
115
- process.stdout.write(`[tool] ${row.tool || row.tool_name || p.tool || p.tool_name || ''}`
116
- + ` ${row.duration_ms ?? row.tool_ms ?? p.duration_ms ?? p.tool_ms ?? '?'}ms\n`);
137
+ process.stdout.write(
138
+ `[tool] ${row.tool || row.tool_name || p.tool || p.tool_name || ''}` +
139
+ ` ${row.duration_ms ?? row.tool_ms ?? p.duration_ms ?? p.tool_ms ?? '?'}ms\n`
140
+ );
117
141
  } else {
118
142
  process.stdout.write(`[${row.kind}] ${JSON.stringify(row).slice(0, 220)}\n`);
119
143
  }
120
144
  }
121
145
  } finally {
122
- try { await shutdownDaemon(readSessionDiscovery()); } catch { /* teardown */ }
146
+ try {
147
+ await shutdownDaemon(readSessionDiscovery());
148
+ } catch {
149
+ /* teardown */
150
+ }
123
151
  await sleep(300);
124
- try { rmSync(ROOT, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 }); } catch { /* temp */ }
152
+ try {
153
+ rmSync(ROOT, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
154
+ } catch {
155
+ /* temp */
156
+ }
125
157
  }
126
158
  process.exit(0);
@@ -12,12 +12,12 @@ import { usageStatsSnapshot } from '../src/standalone/usage-stats-model.mjs';
12
12
  const options = process.argv.slice(2);
13
13
  const ledgerArg = options.find((arg) => arg.startsWith('--ledger='))?.slice(9);
14
14
  if (!ledgerArg || !isAbsolute(ledgerArg) || !/\.sqlite$/i.test(ledgerArg)) {
15
- throw new Error('Supply an exact absolute --ledger=<file.sqlite> path');
15
+ throw new Error('Supply an exact absolute --ledger=<file.sqlite> path');
16
16
  }
17
17
  for (const arg of options) {
18
- if (!arg.startsWith('--ledger=') && !['--reattribute-xai-to-grok', '--apply'].includes(arg)) {
19
- throw new Error(`Unknown argument: ${arg}`);
20
- }
18
+ if (!arg.startsWith('--ledger=') && !['--reattribute-xai-to-grok', '--apply'].includes(arg)) {
19
+ throw new Error(`Unknown argument: ${arg}`);
20
+ }
21
21
  }
22
22
  const source = resolve(ledgerArg);
23
23
  const auditRoot = join(dirname(source), 'audits');
@@ -26,61 +26,116 @@ const workspace = mkdtempSync(join(auditRoot, 'usage-'));
26
26
  const raw = join(workspace, 'original-files');
27
27
  mkdirSync(raw);
28
28
  for (const suffix of ['', '-wal', '-shm']) {
29
- try { copyFileSync(source + suffix, join(raw, basename(source) + suffix)); }
30
- catch (error) { if (!suffix || error.code !== 'ENOENT') throw error; }
29
+ try {
30
+ copyFileSync(source + suffix, join(raw, basename(source) + suffix));
31
+ } catch (error) {
32
+ if (!suffix || error.code !== 'ENOENT') throw error;
33
+ }
31
34
  }
32
35
  const snapshotPath = join(workspace, 'backup.sqlite');
33
36
  const original = new DatabaseSync(source, { readOnly: true });
34
- try { await backup(original, snapshotPath); } finally { original.close(); }
37
+ try {
38
+ await backup(original, snapshotPath);
39
+ } finally {
40
+ original.close();
41
+ }
35
42
  const workingPath = join(workspace, 'working.sqlite');
36
43
  copyFileSync(snapshotPath, workingPath);
37
44
  const throughTs = Date.now();
38
45
  const providerOverrides = options.includes('--reattribute-xai-to-grok') ? { xai: 'grok-oauth' } : {};
39
46
  const summarize = (ledger) => {
40
- const stats = usageStatsSnapshot({ rollup: ledger.rollup(), now: throughTs, source: 'all' });
41
- const sum = (rows, key) => rows.reduce((n, row) => n + Number(row[key] || 0), 0);
42
- for (const key of ['turns', 'input', 'output', 'cacheRead', 'cacheWrite', 'costKnownTurns']) {
43
- assert.equal(sum(stats.providers, key), stats.totals[key], `provider sum: ${key}`);
44
- }
45
- for (const rows of [stats.providers, stats.daily]) {
46
- assert.ok(Math.abs(sum(rows, 'costUsd') - stats.totals.costUsd) <= rows.length * 0.000001 + 0.000001, 'cost sum');
47
- assert.equal(sum(rows, 'tokens'), stats.totals.tokens, 'token sum');
48
- assert.equal(sum(rows, 'turns'), stats.totals.turns, 'record sum');
49
- }
50
- assert.ok(Math.abs(stats.totals.costBilled + stats.totals.costEstimated - stats.totals.costUsd) < 0.000002, 'cost categories');
51
- assert.ok(stats.totals.costKnownTurns <= stats.totals.turns, 'price coverage');
52
- for (const p of stats.providers) {
53
- assert.equal(sum(p.models, 'turns'), p.turns, `model sum: ${p.provider}`);
54
- }
55
- return {
56
- integrity: usageLedgerIntegrity(ledger.db), totals: stats.totals,
57
- providers: stats.providers.map(({ provider, providerKind, turns, tokens, costUsd, costUnpricedTurns }) =>
58
- ({ provider, providerKind, turns, tokens, costUsd, costUnpricedTurns })),
59
- };
47
+ const stats = usageStatsSnapshot({ rollup: ledger.rollup(), now: throughTs, source: 'all' });
48
+ const sum = (rows, key) => rows.reduce((n, row) => n + Number(row[key] || 0), 0);
49
+ for (const key of ['turns', 'input', 'output', 'cacheRead', 'cacheWrite', 'costKnownTurns']) {
50
+ assert.equal(sum(stats.providers, key), stats.totals[key], `provider sum: ${key}`);
51
+ }
52
+ for (const rows of [stats.providers, stats.daily]) {
53
+ assert.ok(Math.abs(sum(rows, 'costUsd') - stats.totals.costUsd) <= rows.length * 0.000001 + 0.000001, 'cost sum');
54
+ assert.equal(sum(rows, 'tokens'), stats.totals.tokens, 'token sum');
55
+ assert.equal(sum(rows, 'turns'), stats.totals.turns, 'record sum');
56
+ }
57
+ assert.ok(
58
+ Math.abs(stats.totals.costBilled + stats.totals.costEstimated - stats.totals.costUsd) < 0.000002,
59
+ 'cost categories'
60
+ );
61
+ assert.ok(stats.totals.costKnownTurns <= stats.totals.turns, 'price coverage');
62
+ for (const p of stats.providers) {
63
+ assert.equal(sum(p.models, 'turns'), p.turns, `model sum: ${p.provider}`);
64
+ }
65
+ return {
66
+ integrity: usageLedgerIntegrity(ledger.db),
67
+ totals: stats.totals,
68
+ providers: stats.providers.map(({ provider, providerKind, turns, tokens, costUsd, costUnpricedTurns }) => ({
69
+ provider,
70
+ providerKind,
71
+ turns,
72
+ tokens,
73
+ costUsd,
74
+ costUnpricedTurns,
75
+ })),
76
+ };
60
77
  };
61
78
  const working = new UsageLedger(workingPath);
62
79
  let before, preview, after;
63
80
  try {
64
- assert.deepEqual(working.db.prepare('PRAGMA quick_check').all().map((r) => r.quick_check), ['ok']);
65
- before = summarize(working);
66
- preview = repairUsageLedger(working, { throughTs, providerOverrides });
67
- after = summarize(working);
68
- assert.deepEqual(before.integrity, after.integrity);
69
- } finally { working.close(); }
70
- const report = { source, workspace, backup: snapshotPath, throughTs, providerOverrides, before, preview, after, applied: false };
81
+ assert.deepEqual(
82
+ working.db
83
+ .prepare('PRAGMA quick_check')
84
+ .all()
85
+ .map((r) => r.quick_check),
86
+ ['ok']
87
+ );
88
+ before = summarize(working);
89
+ preview = repairUsageLedger(working, { throughTs, providerOverrides });
90
+ after = summarize(working);
91
+ assert.deepEqual(before.integrity, after.integrity);
92
+ } finally {
93
+ working.close();
94
+ }
95
+ const report = {
96
+ source,
97
+ workspace,
98
+ backup: snapshotPath,
99
+ throughTs,
100
+ providerOverrides,
101
+ before,
102
+ preview,
103
+ after,
104
+ applied: false,
105
+ };
71
106
  writeFileSync(join(workspace, 'report.json'), JSON.stringify(report, null, 2));
72
107
  if (options.includes('--apply')) {
73
- const live = new UsageLedger(source);
74
- try {
75
- // The transaction repairs only the bounded history. Concurrent new
76
- // requests are retained and indexed too; no database file is replaced.
77
- report.appliedRepair = repairUsageLedger(live, { throughTs, providerOverrides });
78
- report.live = summarize(live);
79
- assert.deepEqual(live.db.prepare('PRAGMA quick_check').all().map((r) => r.quick_check), ['ok']);
80
- report.applied = true;
81
- } finally { live.close(); }
82
- writeFileSync(join(workspace, 'report.json'), JSON.stringify(report, null, 2));
108
+ const live = new UsageLedger(source);
109
+ try {
110
+ // The transaction repairs only the bounded history. Concurrent new
111
+ // requests are retained and indexed too; no database file is replaced.
112
+ report.appliedRepair = repairUsageLedger(live, { throughTs, providerOverrides });
113
+ report.live = summarize(live);
114
+ assert.deepEqual(
115
+ live.db
116
+ .prepare('PRAGMA quick_check')
117
+ .all()
118
+ .map((r) => r.quick_check),
119
+ ['ok']
120
+ );
121
+ report.applied = true;
122
+ } finally {
123
+ live.close();
124
+ }
125
+ writeFileSync(join(workspace, 'report.json'), JSON.stringify(report, null, 2));
83
126
  }
84
- console.log(JSON.stringify({ workspace, backup: snapshotPath, applied: report.applied,
85
- preview, ...(report.appliedRepair ? { appliedRepair: report.appliedRepair } : {}),
86
- totals: (report.live || after).totals, providers: (report.live || after).providers }, null, 2));
127
+ console.log(
128
+ JSON.stringify(
129
+ {
130
+ workspace,
131
+ backup: snapshotPath,
132
+ applied: report.applied,
133
+ preview,
134
+ ...(report.appliedRepair ? { appliedRepair: report.appliedRepair } : {}),
135
+ totals: (report.live || after).totals,
136
+ providers: (report.live || after).providers,
137
+ },
138
+ null,
139
+ 2
140
+ )
141
+ );
@@ -73,10 +73,7 @@ await build({
73
73
  '../../runtime/channels/lib/voice-runtime-fetcher.mjs',
74
74
  '../../runtime/channels/lib/whisper-server.mjs',
75
75
  ],
76
- plugins: [
77
- sharedRuntimeExternalPlugin,
78
- sessionClientExternalPlugin,
79
- ],
76
+ plugins: [sharedRuntimeExternalPlugin, sessionClientExternalPlugin],
80
77
  logLevel: 'info',
81
78
  });
82
79