mixdog 1.4.3 → 1.4.5

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 (281) hide show
  1. package/package.json +1 -2
  2. package/src/cli.mjs +5 -1
  3. package/src/defaults/shipped-history.json +30 -2
  4. package/src/defaults/skills/browser-use/SKILL.md +148 -273
  5. package/src/defaults/skills/browser-use/references/devtools.md +14 -0
  6. package/src/defaults/skills/browser-use/references/page-flows.md +66 -0
  7. package/src/defaults/skills/browser-use/references/sign-in.md +70 -0
  8. package/src/defaults/skills/code-tidy/SKILL.md +60 -84
  9. package/src/defaults/skills/code-tidy/references/agent-cleanup.md +27 -2
  10. package/src/defaults/skills/computer-use/SKILL.md +145 -229
  11. package/src/defaults/skills/computer-use/references/flows.md +35 -0
  12. package/src/defaults/skills/computer-use/references/operations.md +22 -0
  13. package/src/defaults/skills/computer-use/references/platforms.md +12 -0
  14. package/src/defaults/skills/docx/SKILL.md +23 -31
  15. package/src/defaults/skills/docx/references/native-authoring.md +26 -3
  16. package/src/defaults/skills/docx/references/redlining.md +15 -0
  17. package/src/defaults/skills/image/SKILL.md +37 -77
  18. package/src/defaults/skills/image/references/prompt-forms.md +51 -0
  19. package/src/defaults/skills/image/references/text.md +6 -0
  20. package/src/defaults/skills/local-provider/SKILL.md +75 -105
  21. package/src/defaults/skills/local-provider/references/lifecycle.md +14 -0
  22. package/src/defaults/skills/local-provider/references/maintenance.md +19 -0
  23. package/src/defaults/skills/local-provider/references/recovery.md +30 -0
  24. package/src/defaults/skills/memory-management/SKILL.md +22 -21
  25. package/src/defaults/skills/pdf/SKILL.md +21 -23
  26. package/src/defaults/skills/pdf/references/blocks.md +20 -0
  27. package/src/defaults/skills/pdf/references/forms.md +12 -0
  28. package/src/defaults/skills/pdf/references/html.md +2 -2
  29. package/src/defaults/skills/pdf/references/ocr.md +7 -0
  30. package/src/defaults/skills/pdf/references/security.md +8 -0
  31. package/src/defaults/skills/pptx/SKILL.md +30 -109
  32. package/src/defaults/skills/pptx/references/audit.md +45 -0
  33. package/src/defaults/skills/pptx/references/brief-critique.md +47 -0
  34. package/src/defaults/skills/pptx/references/editing.md +24 -0
  35. package/src/defaults/skills/pptx/references/html.md +1 -1
  36. package/src/defaults/skills/pptx/references/script.md +33 -0
  37. package/src/defaults/skills/setup/SKILL.md +34 -102
  38. package/src/defaults/skills/setup/references/actions.md +73 -14
  39. package/src/defaults/skills/setup/references/surfaces.md +23 -8
  40. package/src/defaults/skills/setup-guide/SKILL.md +28 -115
  41. package/src/defaults/skills/setup-guide/references/features.md +36 -0
  42. package/src/defaults/skills/setup-guide/references/glossary.md +38 -0
  43. package/src/defaults/skills/setup-guide/references/workflow-models.md +62 -0
  44. package/src/defaults/skills/test-suite/SKILL.md +15 -127
  45. package/src/defaults/skills/test-suite/references/case-management.md +17 -9
  46. package/src/defaults/skills/test-suite/references/diagnose.md +23 -0
  47. package/src/defaults/skills/test-suite/references/prune.md +27 -0
  48. package/src/defaults/skills/test-suite/references/write.md +44 -0
  49. package/src/defaults/skills/video/SKILL.md +28 -42
  50. package/src/defaults/skills/video/references/prompting.md +31 -0
  51. package/src/defaults/skills/visualize/SKILL.md +73 -107
  52. package/src/defaults/skills/visualize/references/craft.md +1 -2
  53. package/src/defaults/skills/visualize/references/feedback.md +36 -0
  54. package/src/defaults/skills/visualize/references/showing.md +13 -0
  55. package/src/defaults/skills/xlsx/SKILL.md +23 -50
  56. package/src/defaults/skills/xlsx/references/editing.md +15 -0
  57. package/src/defaults/skills/xlsx/references/model-conventions.md +1 -1
  58. package/src/defaults/skills/xlsx/references/recalculation.md +37 -0
  59. package/src/defaults/skills/xlsx/references/report-design.md +18 -2
  60. package/src/lib/keychain-cjs.cjs +22 -1
  61. package/src/lib/rules-builder.cjs +1 -1
  62. package/src/rules/agent/AGENT.md +3 -0
  63. package/src/rules/agent-mode/MIXY.md +5 -3
  64. package/src/rules/lead/LEAD.md +3 -1
  65. package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +8 -30
  66. package/src/runtime/agent/orchestrator/agent-runtime/title-completion.mjs +5 -0
  67. package/src/runtime/agent/orchestrator/mcp/oauth-request.mjs +21 -2
  68. package/src/runtime/agent/orchestrator/providers/account-pool.mjs +3 -0
  69. package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +4 -3
  70. package/src/runtime/agent/orchestrator/providers/anthropic-api-request.mjs +11 -1
  71. package/src/runtime/agent/orchestrator/providers/anthropic-api-transport.mjs +2 -0
  72. package/src/runtime/agent/orchestrator/providers/anthropic-message-threads.mjs +583 -0
  73. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +1 -1
  74. package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +81 -19
  75. package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events/content-block-start.mjs +4 -0
  76. package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-outcome.mjs +2 -0
  77. package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +180 -13
  78. package/src/runtime/agent/orchestrator/providers/anthropic-turn-result.mjs +2 -0
  79. package/src/runtime/agent/orchestrator/providers/anthropic.mjs +58 -6
  80. package/src/runtime/agent/orchestrator/providers/cursor-wire.mjs +4 -2
  81. package/src/runtime/agent/orchestrator/providers/custom-provider-config.mjs +121 -9
  82. package/src/runtime/agent/orchestrator/providers/custom-provider.mjs +4 -1
  83. package/src/runtime/agent/orchestrator/providers/gemini-error-contract.mjs +6 -6
  84. package/src/runtime/agent/orchestrator/providers/gemini-model-redirect.mjs +44 -0
  85. package/src/runtime/agent/orchestrator/providers/gemini-reasoning-relay.mjs +5 -0
  86. package/src/runtime/agent/orchestrator/providers/gemini-request-body.mjs +34 -5
  87. package/src/runtime/agent/orchestrator/providers/gemini-response.mjs +10 -0
  88. package/src/runtime/agent/orchestrator/providers/gemini-schema.mjs +11 -6
  89. package/src/runtime/agent/orchestrator/providers/gemini-sdk-request.mjs +4 -100
  90. package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +3 -227
  91. package/src/runtime/agent/orchestrator/providers/gemini.mjs +226 -118
  92. package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +11 -1
  93. package/src/runtime/agent/orchestrator/providers/lib/claude-bridge-schema.mjs +15 -3
  94. package/src/runtime/agent/orchestrator/providers/lib/gemini-model-catalog.mjs +2 -1
  95. package/src/runtime/agent/orchestrator/providers/lib/generation-window.mjs +9 -0
  96. package/src/runtime/agent/orchestrator/providers/openai-compat-chat-send.mjs +9 -1
  97. package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-result.mjs +2 -0
  98. package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-state.mjs +5 -0
  99. package/src/runtime/agent/orchestrator/providers/openai-compat-options.mjs +3 -0
  100. package/src/runtime/agent/orchestrator/providers/openai-compat-response-normalization.mjs +2 -0
  101. package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +10 -1
  102. package/src/runtime/agent/orchestrator/providers/openai-direct-request.mjs +5 -28
  103. package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events.mjs +3 -0
  104. package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-outcome.mjs +2 -0
  105. package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +50 -28
  106. package/src/runtime/agent/orchestrator/providers/openai-ws-response-state.mjs +9 -2
  107. package/src/runtime/agent/orchestrator/providers/openai-ws-stream/socket-handlers.mjs +14 -10
  108. package/src/runtime/agent/orchestrator/providers/openai-ws.mjs +1 -3
  109. package/src/runtime/agent/orchestrator/providers/openrouter-provider-routing.mjs +28 -0
  110. package/src/runtime/agent/orchestrator/providers/openrouter.mjs +4 -1
  111. package/src/runtime/agent/orchestrator/providers/registry.mjs +30 -25
  112. package/src/runtime/agent/orchestrator/providers/stream-json-pool/worker-slots/slot-spawn.mjs +8 -3
  113. package/src/runtime/agent/orchestrator/providers/vertex-ai-maas.mjs +2 -2
  114. package/src/runtime/agent/orchestrator/runtime-core/ask-user-result.mjs +66 -0
  115. package/src/runtime/agent/orchestrator/runtime-core/config-helpers.mjs +4 -5
  116. package/src/runtime/agent/orchestrator/runtime-core/goal-tool-defs.mjs +2 -2
  117. package/src/runtime/agent/orchestrator/runtime-core/provider-request-tools.mjs +15 -8
  118. package/src/runtime/agent/orchestrator/runtime-core/session-title.mjs +1 -0
  119. package/src/runtime/agent/orchestrator/runtime-core/todo-list.mjs +9 -32
  120. package/src/runtime/agent/orchestrator/runtime-core/todo-tool-defs.mjs +4 -5
  121. package/src/runtime/agent/orchestrator/session/compact/summary-route.mjs +1 -3
  122. package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +5 -2
  123. package/src/runtime/agent/orchestrator/session/loop/no-tool-turn/todo-check.mjs +2 -17
  124. package/src/runtime/agent/orchestrator/session/loop/usage.mjs +7 -3
  125. package/src/runtime/agent/orchestrator/session/manager/ask-turn-settle.mjs +9 -2
  126. package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +8 -1
  127. package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +26 -13
  128. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +4 -5
  129. package/src/runtime/agent/orchestrator/session/manager/usage-metrics.mjs +16 -5
  130. package/src/runtime/agent/orchestrator/session/store/lifecycle-barriers.mjs +22 -1
  131. package/src/runtime/agent/orchestrator/session/store/live-state.mjs +4 -0
  132. package/src/runtime/agent/orchestrator/session/store.mjs +12 -6
  133. package/src/runtime/agent/orchestrator/tools/builtin/cache-layers.mjs +11 -9
  134. package/src/runtime/agent/orchestrator/tools/builtin/grep-formatting.mjs +2 -8
  135. package/src/runtime/agent/orchestrator/tools/builtin/lib/search-input-helpers.mjs +1 -9
  136. package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-output-silence.mjs +64 -0
  137. package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-task-output.mjs +20 -6
  138. package/src/runtime/agent/orchestrator/tools/builtin/local-search-telemetry.mjs +2 -2
  139. package/src/runtime/agent/orchestrator/tools/builtin/native-search-client.mjs +1 -1
  140. package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs +12 -3
  141. package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +12 -1
  142. package/src/runtime/agent/orchestrator/tools/code-graph/ast-calls.mjs +9 -2
  143. package/src/runtime/agent/orchestrator/tools/code-graph/build.mjs +137 -7
  144. package/src/runtime/agent/orchestrator/tools/code-graph/calls-cache.mjs +43 -14
  145. package/src/runtime/agent/orchestrator/tools/code-graph/calls-sidecar-worker.mjs +33 -0
  146. package/src/runtime/agent/orchestrator/tools/code-graph/disk-cache.mjs +146 -11
  147. package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +31 -24
  148. package/src/runtime/agent/orchestrator/tools/code-graph/graph-binary/spawn-jsonl.mjs +172 -25
  149. package/src/runtime/agent/orchestrator/tools/code-graph/graph-model.mjs +100 -2
  150. package/src/runtime/agent/orchestrator/tools/code-graph/main-thread-slice.mjs +18 -0
  151. package/src/runtime/agent/orchestrator/tools/code-graph/mask-pool.mjs +219 -0
  152. package/src/runtime/agent/orchestrator/tools/code-graph/mask-worker.mjs +12 -0
  153. package/src/runtime/agent/orchestrator/tools/code-graph/memory-cache.mjs +6 -1
  154. package/src/runtime/agent/orchestrator/tools/code-graph/modes/calls.mjs +9 -2
  155. package/src/runtime/agent/orchestrator/tools/code-graph/modes/dependents.mjs +5 -1
  156. package/src/runtime/agent/orchestrator/tools/code-graph/modes/structure.mjs +8 -2
  157. package/src/runtime/agent/orchestrator/tools/code-graph/modes/symbols.mjs +14 -11
  158. package/src/runtime/agent/orchestrator/tools/code-graph/search-references.mjs +41 -18
  159. package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +391 -83
  160. package/src/runtime/agent/orchestrator/tools/code-graph/symbol-index.mjs +109 -9
  161. package/src/runtime/agent/orchestrator/tools/code-graph/text-mask.mjs +73 -29
  162. package/src/runtime/agent/orchestrator/tools/code-graph-prewarm-worker.mjs +6 -5
  163. package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.mjs +7 -3
  164. package/src/runtime/channels/lib/crash-log.mjs +21 -1
  165. package/src/runtime/channels/lib/routines-db.mjs +35 -0
  166. package/src/runtime/channels/lib/schedules-db.mjs +4 -0
  167. package/src/runtime/channels/lib/webhooks-db.mjs +4 -0
  168. package/src/runtime/channels/lib/worker-main.mjs +8 -25
  169. package/src/runtime/computer-bridge/action-schema.mjs +2 -2
  170. package/src/runtime/computer-bridge/core-actions.mjs +16 -2
  171. package/src/runtime/computer-bridge/result-canonical.mjs +6 -0
  172. package/src/runtime/media/jobs.mjs +5 -0
  173. package/src/runtime/media/store.mjs +146 -3
  174. package/src/runtime/memory/tool-defs.mjs +1 -1
  175. package/src/runtime/office/core/office-write-ledger.mjs +2 -2
  176. package/src/runtime/shared/agent-reap-state.mjs +19 -0
  177. package/src/runtime/shared/desktop-notice-host.d.mts +13 -0
  178. package/src/runtime/shared/desktop-notice-host.mjs +87 -0
  179. package/src/runtime/shared/file-lock.mjs +2 -2
  180. package/src/runtime/shared/heap-cap.mjs +9 -11
  181. package/src/runtime/shared/llm/http-agent.mjs +11 -1
  182. package/src/runtime/shared/llm/system-proxy.mjs +100 -25
  183. package/src/runtime/shared/llm/usage-accounting.mjs +121 -19
  184. package/src/runtime/shared/llm/usage-context.mjs +3 -3
  185. package/src/runtime/shared/llm/usage-ledger-quota.mjs +2 -0
  186. package/src/runtime/shared/llm/usage-ledger-requests.mjs +190 -0
  187. package/src/runtime/shared/llm/usage-ledger-rollup.mjs +7 -3
  188. package/src/runtime/shared/llm/usage-ledger-worker.mjs +2 -0
  189. package/src/runtime/shared/llm/usage-ledger.mjs +69 -1
  190. package/src/runtime/shared/llm/usage-request-status.mjs +48 -0
  191. package/src/runtime/shared/provider-accounts.mjs +22 -0
  192. package/src/runtime/shared/provider-auth-binding.mjs +2 -2
  193. package/src/runtime/shared/resource-admission.mjs +2 -2
  194. package/src/runtime/shared/root-async-context.mjs +51 -0
  195. package/src/runtime/shared/run-child.mjs +18 -1
  196. package/src/runtime/shared/slow-span.mjs +2 -2
  197. package/src/runtime/shared/tool-execution-owner.mjs +2 -2
  198. package/src/runtime/shared/tool-result-summary.mjs +1 -1
  199. package/src/runtime/shared/tool-work-units.mjs +2 -0
  200. package/src/runtime/shared/turn-snapshot-store.mjs +75 -18
  201. package/src/runtime/shared/turn-worktree-snapshot.mjs +38 -8
  202. package/src/runtime/shared/user-cwd.mjs +2 -2
  203. package/src/runtime/shared/worker-requests.mjs +3 -1
  204. package/src/runtime/shared/worktrees/lock.mjs +2 -2
  205. package/src/runtime/visualize-bridge/client.mjs +26 -4
  206. package/src/runtime/visualize-bridge/tool-defs.mjs +46 -5
  207. package/src/session-runtime/agent-home-delivery.mjs +76 -8
  208. package/src/session-runtime/agent-task-sessions.mjs +63 -22
  209. package/src/session-runtime/boot/apis.mjs +16 -0
  210. package/src/session-runtime/boot/begin.mjs +2 -0
  211. package/src/session-runtime/boot/tools.mjs +8 -2
  212. package/src/session-runtime/internal-tool-executor/ask-user-tool.mjs +3 -58
  213. package/src/session-runtime/media-api.mjs +15 -0
  214. package/src/session-runtime/model-route/route-persist.mjs +12 -4
  215. package/src/session-runtime/provider-models/row-hydration.mjs +2 -0
  216. package/src/session-runtime/provider-readiness.mjs +10 -2
  217. package/src/session-runtime/routine-owner.mjs +9 -3
  218. package/src/session-runtime/runtime-core.mjs +35 -8
  219. package/src/session-runtime/runtime-review-api.mjs +3 -1
  220. package/src/session-runtime/services/agent-task-status.mjs +29 -1
  221. package/src/session-runtime/services/agent-tool/close-flow.mjs +6 -1
  222. package/src/session-runtime/services/agent-tool/execute-resume.mjs +94 -0
  223. package/src/session-runtime/services/agent-tool/execute-send.mjs +77 -27
  224. package/src/session-runtime/services/agent-tool/execute-spawn.mjs +28 -7
  225. package/src/session-runtime/services/agent-tool/execute.mjs +6 -1
  226. package/src/session-runtime/services/agent-tool/helpers.mjs +11 -0
  227. package/src/session-runtime/services/agent-tool/job-views/job-render.mjs +13 -10
  228. package/src/session-runtime/services/agent-tool/job-views/session-progress.mjs +3 -0
  229. package/src/session-runtime/services/agent-tool/render.mjs +8 -1
  230. package/src/session-runtime/services/agent-tool/send-flow.mjs +1 -0
  231. package/src/session-runtime/services/agent-tool/spawn-flow/spawn-prep.mjs +6 -0
  232. package/src/session-runtime/services/agent-tool/spawn-flow/spawn-run.mjs +2 -1
  233. package/src/session-runtime/services/agent-tool/tag-registry/reaped-sessions.mjs +82 -0
  234. package/src/session-runtime/services/agent-tool/tag-registry/record-facts-worker.mjs +36 -0
  235. package/src/session-runtime/services/agent-tool/tag-registry.mjs +4 -0
  236. package/src/session-runtime/services/agent-tool/terminal-reaper/row-helpers.mjs +29 -0
  237. package/src/session-runtime/services/agent-tool/terminal-reaper/scan-admission.mjs +11 -3
  238. package/src/session-runtime/services/agent-tool/terminal-reaper/stale-rows.mjs +19 -8
  239. package/src/session-runtime/services/agent-tool/terminal-reaper.mjs +5 -2
  240. package/src/session-runtime/services/agent-tool/worker-index.mjs +1 -0
  241. package/src/session-runtime/services/channel-admin.mjs +44 -3
  242. package/src/session-runtime/services/daemon-crash-capture/daemon-exit-record.mjs +2 -2
  243. package/src/session-runtime/services/plugin-admin.mjs +46 -7
  244. package/src/session-runtime/services/provider-admin.mjs +5 -0
  245. package/src/session-runtime/session-create.mjs +5 -0
  246. package/src/session-runtime/setup-tool/agent-settings-actions.mjs +1 -1
  247. package/src/session-runtime/setup-tool/executor.mjs +1 -1
  248. package/src/session-runtime/setup-tool/extended-actions.mjs +1 -1
  249. package/src/session-runtime/setup-tool/settings-contract.mjs +4 -2
  250. package/src/session-runtime/usage-stats-api.mjs +120 -1
  251. package/src/session-runtime/workflow-agents-api/agent-connectors.mjs +36 -29
  252. package/src/session-runtime/workflow-agents-api/agent-editor.mjs +183 -23
  253. package/src/session-runtime/workspace/admission-gate.mjs +25 -7
  254. package/src/session-runtime/workspace/transitions.mjs +4 -0
  255. package/src/standalone/daemon-log.mjs +28 -4
  256. package/src/standalone/daemon-owner.mjs +41 -7
  257. package/src/standalone/daemon-work-gate.mjs +139 -0
  258. package/src/standalone/daemon.mjs +80 -11
  259. package/src/standalone/desktop-service-registry.mjs +11 -4
  260. package/src/standalone/session-client.mjs +57 -5
  261. package/src/standalone/session-protocol.mjs +6 -0
  262. package/src/standalone/session-service/agent-tree/agent-cancel.mjs +17 -1
  263. package/src/standalone/session-service/agent-tree.mjs +7 -0
  264. package/src/standalone/session-service/retention/busy.mjs +3 -2
  265. package/src/standalone/session-service/session-calls/session-turns.mjs +12 -5
  266. package/src/standalone/session-transport/call-route.mjs +10 -4
  267. package/src/standalone/session-transport/routes.mjs +21 -0
  268. package/src/standalone/session-transport/stack.mjs +3 -1
  269. package/src/standalone/session-transport.mjs +5 -0
  270. package/src/tui/app/model-picker/model-footer.mjs +1 -1
  271. package/src/tui/app/model-picker/provider-models-list.mjs +7 -3
  272. package/src/tui/app/model-picker/route-selection/fast-parameters.mjs +23 -3
  273. package/src/tui/app/model-picker/route-selection.mjs +1 -0
  274. package/src/tui/dist/index.mjs +536 -484
  275. package/src/tui/session/session-api/integrations.mjs +3 -0
  276. package/src/tui/session/session-api/media.mjs +5 -0
  277. package/src/tui/session/tool-approval-settle.mjs +24 -4
  278. package/src/tui/session/tool-approval.mjs +35 -10
  279. package/src/tui/session/turn.mjs +13 -0
  280. package/src/runtime/agent/orchestrator/providers/gemini-sdk-stream/cancellation.mjs +0 -71
  281. package/src/runtime/agent/orchestrator/providers/gemini-sdk-stream/reader.mjs +0 -108
@@ -10,24 +10,28 @@ export const TOOL_DEFS = [
10
10
  name: 'visualize',
11
11
  title: 'Mixdog Visualize',
12
12
  description:
13
- 'Show the user a finished deliverable you produced or changed (mockups, docs, decks, sheets, PDFs, images, video, local dev pages) in the desktop side panel beside the chat. A summary, plan or report of your own work is not one either: it stays in the chat. Your own check screenshots are not deliverables: look at them with read; open with verify: true only to run check/inspect/capture/export. Panel tabs auto-reload when a file changes, so re-opening after edits is unnecessary. ' +
14
- 'open: input.targets (1-3 file paths, relative to the working directory or absolute anywhere on this machine; 2-3 = side-by-side comparison; or a single http(s) URL alone, never mixed with files or other URLs), optional label, optional version (show that kept version of a file tab read-only; each open/reload that changes the files keeps a version), optional verify (true = you open only to check your own work with check/inspect/capture/export: the user is not shown the tab and it closes when the turn ends; leave it off for anything the user should see). close: optional tab (omit = all). ' +
13
+ 'Show the user a finished deliverable you produced or changed (mockups, docs, decks, sheets, PDFs, images, video, local dev pages) in the desktop side panel beside the chat. A summary, plan or report of your own work is not one either: it stays in the chat. Your own check screenshots are not deliverables: look at them with read; open with verify: true only to run check/inspect/act/capture/export. Panel tabs auto-reload when a file changes, so re-opening after edits is unnecessary. ' +
14
+ 'open: input.targets (1-3 file paths, relative to the working directory or absolute anywhere on this machine; 2-3 = side-by-side comparison; or a single http(s) URL alone, never mixed with files or other URLs), optional label, optional version (show that kept version of a file tab read-only; each open/reload that changes the files keeps a version), optional verify (true = you open only to check your own work with check/inspect/act/capture/export: the user is not shown the tab and it closes when the turn ends; leave it off for anything the user should see). close: optional tab (omit = all). ' +
15
15
  'annotate: tab + add [{selector,label?}] | remove [selector] | clear; HTML pages only, never edits the file. capture: tab + output (.png path). ' +
16
16
  'export: tab + format (png|pdf) + output (project-relative path ending .png/.pdf) + optional version (a kept version of the tab) + optional overwrite (true replaces an existing file, only under design/; otherwise an existing file is refused). Writes a record of the approved page inside the project and returns its project-relative path, size/dimensions and the page problems seen while rendering. A single HTML page (file, or inline html/chart) is rendered whole in a hidden window, so the tab need not be on screen (PDF: HTML pages only; PNG has a pixel cap, over it export pdf or shorten the page); any other tab exports as capture does (the displayed tab, PNG only). Same project containment as capture: links and paths outside the working directory are refused. ' +
17
17
  'check: tab; HTML pages only; waits briefly for the page to settle and returns only its runtime problems (uncaught errors, unhandled rejections, CSP violations, console errors/warnings, missing local assets). ' +
18
18
  'inspect: tab + optional viewport {width,height} (e.g. 375x812 to look at a mobile layout) + optional selector (scope); HTML pages with scripts/styles only (not static mermaid/svg/markdown). Returns a compact text read-out of the rendered page without a screenshot: viewport, landmarks and headings, interactive elements (role, accessible name, selector, x/y/w/h), and layout findings (horizontal overflow, clipped text, overlapping or tiny tap targets, low text contrast, images without alt, unlabeled inputs). Run it (desktop width and, for responsive designs, a mobile width) and fix the findings before reporting; `check` also says when findings exist. Secret field values are never included. ' +
19
+ 'act: tab + steps (1-25, run in order, 15 s in total) + optional pane (1-based, default the first HTML page) + optional output (.png capture of the final state); operates an HTML page (file or inline html/chart) and reads the result. Steps: {do:"click",selector} | {do:"type",selector,text} (replaces the field value, fires input/change) | {do:"key",key,selector?} (a key or chord like "Enter", "Shift+Tab", "Control+a"; to the focused element or the selector) | {do:"scroll",selector?,x?,y?} (selector alone = into view, x/y = pixels to scroll it or the page by) | {do:"wait",ms} or {do:"wait",selector,timeout?} (until it is shown; ms and timeout up to 10000) | {do:"evaluate",script} (one JS expression or IIFE run in the page, promises awaited; its JSON result is returned, cut at 4000 characters). Selectors are CSS, e.g. those inspect reports. Input is simulated in the page with synthetic DOM events (no real mouse or keyboard; Enter in a form field submits it), inside the same sandbox and network limits. Stops at the first failing step and says which and why; returns each step\'s outcome, the evaluate values and the page problems seen. On a tab shown in the panel the user sees it happen; on a verify tab or while your turn holds the panel it runs off screen in a freshly loaded page each call. ' +
19
20
  'Any result about a tab ends with a "Page problems" section when the page has problems: fix them in the file and re-check before reporting; never report a page with unresolved problems as done. ' +
20
21
  'HTML pages run their scripts, but outside network (CDNs, web fonts, APIs, any other http(s)/ws address) is blocked unless the user allows it for the tab, so mockups must be self-contained; a blocked request appears as a "blocked-network" page problem on open/check. ' +
21
22
  'Direct renderers: instead of targets, open takes input.content {kind: mermaid|svg|chart|html|markdown, source, title?} (max 512 KiB; chart = an ECharts option as JSON) and shows it with no file written. ' +
22
23
  'Prefer inline content for diagrams, charts and quick sketches; write a file for real mockups that need iteration, scripts or versioning on disk. ' +
23
24
  'mermaid, svg and markdown render as static, sanitized output (no scripts, no network). chart (ECharts option JSON, interactive: tooltips, zoom) and html (scripts run) open as in-memory pages with the same protections as HTML file pages (outside network blocked, page problems captured); html content must be self-contained. Re-open with the same title to add a version. A render error (Mermaid parse error, bad chart JSON) is returned as a page problem: fix the source and open again. ' +
24
25
  'Tweaks: an HTML page (file or inline html/chart) can declare adjustable parameters in <script type="application/json" id="mx-tweaks">[{id,label,type:color|range|select|toggle,var:"--name" or attr:"data-name",min,max,step,unit,options:[{value,label}],default}] (max 16, keep it to a few meaningful ones). The panel shows a Tweaks drawer and applies changes live to the page root (CSS variables / data attributes your CSS and script read); the chosen values come back with their next message under tweaks: to bake into the file. A malformed block is a "tweaks: <reason>" page problem. ' +
25
- 'Does not replace browser for clicking/typing. ' +
26
+ 'To check a local HTML page, open it here and operate it with act; never serve it yourself to drive it in browser (browser is for web URLs and real browser input). ' +
26
27
  TOOL_SYNC_EXECUTION_CONTRACT,
27
28
  inputSchema: {
28
29
  type: 'object',
29
30
  properties: {
30
- action: { type: 'string', enum: ['open', 'close', 'annotate', 'capture', 'export', 'check', 'inspect'] },
31
+ action: {
32
+ type: 'string',
33
+ enum: ['open', 'close', 'annotate', 'capture', 'export', 'check', 'inspect', 'act'],
34
+ },
31
35
  input: {
32
36
  type: 'object',
33
37
  properties: {
@@ -82,7 +86,44 @@ export const TOOL_DEFS = [
82
86
  output: {
83
87
  type: 'string',
84
88
  description:
85
- 'capture: project path ending .png. export: project path ending .png or .pdf (matching format).',
89
+ 'capture: project path ending .png. export: project path ending .png or .pdf (matching format). act: optional project path ending .png for a capture of the final state.',
90
+ },
91
+ steps: {
92
+ type: 'array',
93
+ minItems: 1,
94
+ maxItems: 25,
95
+ items: {
96
+ type: 'object',
97
+ properties: {
98
+ do: { type: 'string', enum: ['click', 'type', 'key', 'scroll', 'wait', 'evaluate'] },
99
+ selector: { type: 'string', maxLength: 500, description: 'CSS selector of the target element.' },
100
+ text: { type: 'string', maxLength: 10000, description: 'type: the new field value.' },
101
+ key: { type: 'string', maxLength: 40, description: 'key: a key or chord, e.g. Enter, Shift+Tab.' },
102
+ x: { type: 'integer', description: 'scroll: pixels to the right (negative = left).' },
103
+ y: { type: 'integer', description: 'scroll: pixels down (negative = up).' },
104
+ ms: { type: 'integer', minimum: 1, maximum: 10000, description: 'wait: pause length.' },
105
+ timeout: {
106
+ type: 'integer',
107
+ minimum: 1,
108
+ maximum: 10000,
109
+ description: 'wait with selector: longest wait for it to be shown (default 5000).',
110
+ },
111
+ script: {
112
+ type: 'string',
113
+ maxLength: 20000,
114
+ description: 'evaluate: one JS expression or IIFE; its JSON-serializable result is returned.',
115
+ },
116
+ },
117
+ required: ['do'],
118
+ additionalProperties: false,
119
+ },
120
+ description: 'act: the steps, run in order; the first failure stops the rest.',
121
+ },
122
+ pane: {
123
+ type: 'integer',
124
+ minimum: 1,
125
+ maximum: 6,
126
+ description: 'act: the pane (1-based position in the tab) to operate; default the first HTML page.',
86
127
  },
87
128
  format: { type: 'string', enum: ['png', 'pdf'], description: 'export: file format.' },
88
129
  overwrite: {
@@ -63,6 +63,7 @@ import { readJsonState, updateJsonAtomic } from '../runtime/shared/atomic-file.m
63
63
  import { endHandoff, noteHandoff } from '../runtime/shared/delegated-approval-host.mjs';
64
64
  import { ROUTINE_LIMITS } from '../runtime/shared/routine-limits.mjs';
65
65
  import { submissionIdsOf, submissionOutcome } from './agent-task-sessions.mjs';
66
+ import { HANDOFF_LIMITS } from './handoff-attachments.mjs';
66
67
  import {
67
68
  heldRequestMessage,
68
69
  heldRequestNotice,
@@ -298,16 +299,70 @@ function withDequeued(doc, homeId, runIds, omitted) {
298
299
  function withoutRepeatedProgress(doc, homeId, item, posted) {
299
300
  const { progressRunId, ...report } = item;
300
301
  if (!progressRunId) return { doc, item };
301
- if (posted || (doc.delivered[homeId] || []).includes(progressRunId)) {
302
+ const key = answerKey(progressRunId);
303
+ if (posted || (doc.delivered[homeId] || []).some((runId) => answerKey(runId) === key)) {
302
304
  const { text: _text, textChars: _textChars, ...rest } = report;
303
305
  return { doc, item: { ...rest, text: '', answerAbove: true } };
304
306
  }
305
307
  const queued = doc.homes[homeId] || [];
306
- if (!queued.some((row) => row.runId === progressRunId)) return { doc, item: report };
307
- const homes = { ...doc.homes, [homeId]: queued.filter((row) => row.runId !== progressRunId) };
308
+ if (!queued.some((row) => answerKey(row.runId) === key)) return { doc, item: report };
309
+ const homes = { ...doc.homes, [homeId]: queued.filter((row) => answerKey(row.runId) !== key) };
308
310
  return { doc: { ...doc, homes }, item: report };
309
311
  }
310
312
 
313
+ /** The answer a progress row `runId` carries (`_progress_<turn id>`), '' for
314
+ * any other row. A row is named by its task session now and was by its send
315
+ * before (agent-task-sessions.mjs progressRunId); turn ids are unique, so
316
+ * either name of one answer's update gives the same key, and an update
317
+ * already posted under the old name is never posted again. */
318
+ function answerKey(runId) {
319
+ const at = String(runId || '').indexOf('_progress_');
320
+ return at < 0 ? '' : String(runId).slice(at);
321
+ }
322
+
323
+ /** Whether progress row `item` carries an answer `homeId` already holds or
324
+ * posted (answerKey), under whichever name. */
325
+ function repeatsProgress(doc, homeId, item) {
326
+ const key = item.status === 'working' ? answerKey(item.runId) : '';
327
+ if (!key) return false;
328
+ const held = [...(doc.homes[homeId] || []).map((row) => row.runId), ...(doc.delivered[homeId] || [])];
329
+ return held.some((runId) => answerKey(runId) === key);
330
+ }
331
+
332
+ /** `doc` with task report `item` folded into the row of the same run id
333
+ * still queued for `homeId` — the one card of an answer several open sends'
334
+ * chains reached: it names every send and lists the files each produced
335
+ * (the folded ones by path, at most HANDOFF_LIMITS.count, the rest counted
336
+ * as omitted). Null when no such row is queued. */
337
+ function withFoldedReport(doc, homeId, item) {
338
+ const list = doc.homes[homeId] || [];
339
+ const index = list.findIndex((row) => row.runId === item.runId);
340
+ if (index < 0 || item.kind !== 'agent-task') return null;
341
+ const row = list[index];
342
+ const rowSends = [row.sendId, ...(row.sendIds || [])].filter(Boolean);
343
+ const itemSends = [item.sendId, ...(item.sendIds || [])].filter(Boolean);
344
+ // The row's sends are the contributions already folded into it: a replay of
345
+ // one (or a file its cap dropped, whose path is not kept) adds nothing, so
346
+ // its omissions are never counted twice.
347
+ if (itemSends.length && itemSends.every((id) => rowSends.includes(id))) return null;
348
+ const sendIds = [...new Set([...rowSends, ...itemSends])];
349
+ const paths = new Set((row.files || []).map((file) => file.path));
350
+ const added = (item.files || [])
351
+ .filter((file) => !paths.has(file.path) && paths.add(file.path))
352
+ .map(({ id: _id, ...file }) => file);
353
+ const files = [...(row.files || []), ...added];
354
+ const omitted = (row.omitted || 0) + (item.omitted || 0) + Math.max(0, files.length - HANDOFF_LIMITS.count);
355
+ const folded = {
356
+ ...row,
357
+ ...(sendIds.length > 1 ? { sendIds } : {}),
358
+ ...(files.length ? { files: files.slice(0, HANDOFF_LIMITS.count) } : {}),
359
+ ...(omitted > 0 ? { omitted } : {}),
360
+ };
361
+ if (JSON.stringify(folded) === JSON.stringify(row)) return null;
362
+ const next = list.map((entry, at) => (at === index ? folded : entry));
363
+ return { ...doc, homes: { ...doc.homes, [homeId]: next } };
364
+ }
365
+
311
366
  /** The persisted queue at `filePath`: `{ homes: { [homeSessionId]: item[] },
312
367
  * omitted: { [homeSessionId]: { id, count } }, delivered: { [homeSessionId]:
313
368
  * runId[] } }`. A home keeps at most `limit` items: past it the oldest drop,
@@ -477,7 +532,8 @@ export function createRoutineResultQueue(
477
532
  return (await read()).omitted[homeId] || null;
478
533
  },
479
534
  /** Queue `item` for `homeId`; `unwatch` (run ids) drops those watches in the
480
- * same write, also when the item was queued or posted before.
535
+ * same write, also when the item was queued or posted before (a task
536
+ * report of a row still queued folds into it: withFoldedReport).
481
537
  * `progressPosted`: the thread holds the progress update a final report
482
538
  * names (withoutRepeatedProgress). `progressed` (`{ runId, turnId }`):
483
539
  * watch `runId` reported turn `turnId` as progress — its durable mark,
@@ -485,8 +541,13 @@ export function createRoutineResultQueue(
485
541
  async add(homeId, queued, { unwatch = [], progressPosted = false, progressed = null } = {}) {
486
542
  await update((stored) => {
487
543
  const { doc, item } = withoutRepeatedProgress(stored, homeId, queued, progressPosted);
544
+ // An answer's update or end that open sends converging on it each
545
+ // report: queued once (folded into the queued end), never reposted.
546
+ const folded = withFoldedReport(doc, homeId, item);
488
547
  let next = null;
489
- if (item.roundTrip !== true) next = appended(doc, homeId, [item]);
548
+ if (repeatsProgress(doc, homeId, item)) next = null;
549
+ else if (folded) next = folded;
550
+ else if (item.roundTrip !== true) next = appended(doc, homeId, [item]);
490
551
  else {
491
552
  // A task turn's end counts one round trip, once per run id, per home
492
553
  // and target: the user's next message in that home starts over
@@ -1191,11 +1252,18 @@ export function createAgentHomeDelivery({
1191
1252
  });
1192
1253
  return run;
1193
1254
  }
1194
- /** Whether queued row `runId` is in thread `homeId` (posted, saved or not). */
1255
+ /** Whether progress row `runId`, or another carrying the same answer
1256
+ * (answerKey), is in thread `homeId` (posted, saved or not). */
1195
1257
  const postedIn = (homeId, runId) => {
1196
1258
  const messages = loadSession(homeId)?.messages;
1197
- const messageId = messageIdOf(runId);
1198
- return Array.isArray(messages) && messages.some((message) => message?.meta?.transcript?.messageId === messageId);
1259
+ const key = answerKey(runId);
1260
+ return (
1261
+ Array.isArray(messages) &&
1262
+ messages.some((message) => {
1263
+ const messageId = message?.meta?.transcript?.messageId;
1264
+ return messageId === messageIdOf(runId) || (key && answerKey(messageId) === key);
1265
+ })
1266
+ );
1199
1267
  };
1200
1268
  const intake = createHomeEnqueue(queue, drain, { postingFor, postedIn });
1201
1269
  const { watchTask, recover } = createHomeBookkeeping({ queue, log, homeDeleted, sessionDeleted, drain });
@@ -189,7 +189,8 @@ export function latestTurnOutcome(messages, runId) {
189
189
  return chain && { id: chain.id, outcome: chain.outcome, at: chain.at, ambiguous: chain.ambiguous };
190
190
  }
191
191
 
192
- /** latestTurnOutcome with what a report's wait needs besides: `answers`,
192
+ /** latestTurnOutcome with what a report's wait needs besides: `first`, the
193
+ * id of the turn that took runId (its prompt's checkpoint); `answers`,
193
194
  * every turn of the chain that recorded its end, oldest first (`{ id,
194
195
  * status, text }`: its submission id and submissionOutcome); `taskIds`, the
195
196
  * agent tasks the chain's turns started — the only tasks proven the chain's
@@ -201,21 +202,26 @@ export function latestTurnOutcome(messages, runId) {
201
202
  * steer is not stored yet. */
202
203
  function turnChain(messages, runId) {
203
204
  const list = Array.isArray(messages) ? messages : [];
204
- const start = list.findIndex((message) => submissionIdsOf(message).includes(runId));
205
- if (start < 0) return null;
205
+ const asked = list.findIndex((message) => submissionIdsOf(message).includes(runId));
206
+ if (asked < 0) return null;
207
+ // The chain starts with the whole turn that took runId, named by that turn:
208
+ // a send steered into it or batched with it follows the same chain as the
209
+ // turn's own submission, and its answers carry the same ids.
210
+ const start = turnStartOf(list, asked);
211
+ const first = list[start]?.meta?.transcript?.checkpointId || runId;
206
212
  const started = new Set();
207
213
  // The agent tasks whose results a stored turn took (as its prompt or steered in).
208
214
  const taken = new Set();
209
215
  const startingCalls = new Set();
210
216
  let at = start;
211
- let id = runId;
217
+ let id = first;
212
218
  let inChain = true;
213
219
  let ambiguous = false;
214
220
  // The turn the walk is in: where its prompt is stored and its submission id.
215
221
  let turnAt = start;
216
- let turnId = runId;
222
+ let turnId = first;
217
223
  // Every turn of the chain, in order: where its prompt is stored, its id.
218
- const turns = [{ at: start, id: runId }];
224
+ const turns = [{ at: start, id: first }];
219
225
  for (let index = start; index < list.length; index += 1) {
220
226
  const message = list[index];
221
227
  const checkpointId = index > start && message?.role === 'user' ? message.meta?.transcript?.checkpointId : '';
@@ -274,6 +280,7 @@ function turnChain(messages, runId) {
274
280
  }
275
281
  return {
276
282
  id,
283
+ first,
277
284
  outcome,
278
285
  at: Number(ended?.meta?.transcript?.at) || 0,
279
286
  ambiguous,
@@ -283,6 +290,23 @@ function turnChain(messages, runId) {
283
290
  };
284
291
  }
285
292
 
293
+ /** Where the turn that took the submission stored at `list[at]` keeps its
294
+ * prompt: `at` itself for a turn's prompt; for a message steered into a
295
+ * running turn (no checkpoint of its own), that turn's prompt — unless the
296
+ * turn before it ended first (a completion or interruption on the way back),
297
+ * when `at` stays the start. */
298
+ function turnStartOf(list, at) {
299
+ if (list[at]?.meta?.transcript?.checkpointId) return at;
300
+ for (let index = at - 1; index >= 0; index -= 1) {
301
+ const message = list[index];
302
+ if (message?.meta?.transcript?.completion) return at;
303
+ if (message?.role !== 'user') continue;
304
+ if (message.meta?.transcript?.checkpointId) return index;
305
+ if (INTERRUPTED.test(messageText(message.content))) return at;
306
+ }
307
+ return at;
308
+ }
309
+
286
310
  /** The agent task an owed result reports; null when it names none. */
287
311
  function owedTaskId(result) {
288
312
  const executionId = result?.meta?.execution_id;
@@ -532,7 +556,8 @@ function followTaskToFinal(
532
556
  const answersOf = (latest) => {
533
557
  const stored = latest?.answers || [];
534
558
  if (!immediate) return stored;
535
- return [{ id: runId, ...immediate }, ...stored.filter((answer) => answer.id !== runId)];
559
+ const firstId = latest?.first || runId;
560
+ return [{ id: firstId, ...immediate }, ...stored.filter((answer) => answer.id !== firstId)];
536
561
  };
537
562
  // The answers already handed to `interim`, by turn.
538
563
  const interimIds = new Set();
@@ -554,7 +579,10 @@ function followTaskToFinal(
554
579
  * `held` (the final candidate, reported only when it proves not final);
555
580
  * false, stopping there, at the first that could not be queued. */
556
581
  async function reportEarlier(answers, held) {
557
- const through = progressedThrough ? answers.findIndex((answer) => answer.id === progressedThrough) : -1;
582
+ // A mark stored before answers were named by their turn names runId for
583
+ // the chain's first answer.
584
+ const mark = progressedThrough === runId ? answers[0]?.id : progressedThrough;
585
+ const through = mark ? answers.findIndex((answer) => answer.id === mark) : -1;
558
586
  for (const [index, answer] of answers.entries()) {
559
587
  if (index <= through) interimIds.add(answer.id);
560
588
  else if (answer !== held && !(await reportInterim(answer))) return false;
@@ -838,7 +866,7 @@ async function rearmTaskWatch(
838
866
  endBotWork(watch.runId);
839
867
  if (quiet) return disown(watch.runId);
840
868
  return deliver(watch.agentId, {
841
- runId: `${watch.runId}_end`,
869
+ runId: turnReportRunId(sessionId, watch.runId, status, { answerId }),
842
870
  taskSessionId: sessionId,
843
871
  title: watch.title,
844
872
  status,
@@ -847,7 +875,7 @@ async function rearmTaskWatch(
847
875
  ...(watch.hop > 0 ? { hop: watch.hop } : {}),
848
876
  ...roomFrom(watch.homeSessionId),
849
877
  watchId: watch.runId,
850
- ...progressOf(watch.runId, answerId),
878
+ ...progressOf(sessionId, answerId),
851
879
  ...(watch.textOnly || text === GONE_TEXT || text === LOST_TEXT ? {} : await artifactFields(sessionId, turnId)),
852
880
  });
853
881
  };
@@ -903,7 +931,7 @@ async function rearmTaskWatch(
903
931
  ? null
904
932
  : (answer) =>
905
933
  deliver(watch.agentId, {
906
- runId: progressRunId(watch.runId, answer.id),
934
+ runId: progressRunId(sessionId, answer.id),
907
935
  taskSessionId: sessionId,
908
936
  title: watch.title,
909
937
  status: 'working',
@@ -984,23 +1012,36 @@ function createSendSettlement(log) {
984
1012
  return { join, nextSeq };
985
1013
  }
986
1014
 
987
- /** The queue row of send `id`'s progress update carrying the answer of turn
988
- * `answerId` (followToFinal `interim`): one per answer, across restarts. */
989
- const progressRunId = (id, answerId) => `${id}_progress_${answerId}`;
990
-
991
- /** The queue row of send `id`'s report of `status`. 'working': a progress
992
- * update (progressRunId), not the end. A wait for approval belongs to the
993
- * target session, not to this send: every watcher of it names the same row,
994
- * so it posts once. */
1015
+ /** The queue row of the progress update of task session `sessionId` carrying
1016
+ * the answer of turn `answerId` (followToFinal `interim`): one per answer,
1017
+ * across restarts and however many open sends' chains reach it. Rows queued
1018
+ * before were named by the send (`${sendId}_progress_${answerId}`); both end
1019
+ * in `_progress_${answerId}`, which the queue matches (agent-home-delivery.mjs
1020
+ * answerKey). */
1021
+ const progressRunId = (sessionId, answerId) => `${sessionId}_progress_${answerId}`;
1022
+
1023
+ /** The queue row of send `id`'s report of `status` to task session
1024
+ * `sessionId`. 'working': a progress update (progressRunId), not the end. An
1025
+ * end that carries the answer of turn `answerId` belongs to that answer, not
1026
+ * to this send: every open send whose chain ends in it names the same row,
1027
+ * so it posts once and closes them all; an end of no turn is the send's own.
1028
+ * A wait for approval belongs to the target session: every watcher of it
1029
+ * names the same row, so it posts once.
1030
+ * Upgrade: ends were named `${sendId}_end` before and record no answer, so a
1031
+ * send still watched across the upgrade posts one extra card for an answer a
1032
+ * converged send already reported under its old name. That one-time
1033
+ * duplicate is accepted: matching old rows by their text would drop genuinely
1034
+ * new answers that happen to read the same. */
995
1035
  const turnReportRunId = (sessionId, id, status, { approvalId = '', answerId = '' } = {}) => {
996
1036
  if (status === 'blocked') return `${sessionId}_${approvalId}_blocked`;
997
- return status === 'working' ? progressRunId(id, answerId) : `${id}_end`;
1037
+ if (status === 'working') return progressRunId(sessionId, answerId);
1038
+ return answerId ? `${sessionId}_${answerId}_end` : `${id}_end`;
998
1039
  };
999
1040
 
1000
1041
  /** The report fields naming the progress update that may have carried the
1001
1042
  * final answer of turn `answerId` already (the queue then does not repeat
1002
1043
  * it); none for a report of no turn. */
1003
- const progressOf = (id, answerId) => (answerId ? { progressRunId: progressRunId(id, answerId) } : {});
1044
+ const progressOf = (sessionId, answerId) => (answerId ? { progressRunId: progressRunId(sessionId, answerId) } : {});
1004
1045
 
1005
1046
  /** The handler of send `id`'s task-session state: a wait for the user's
1006
1047
  * approval reports blocked once; a later, different one reports again. */
@@ -1126,7 +1167,7 @@ function sendReporter({ deliver, retryDelaysMs, artifactFields, log }, { session
1126
1167
  : {
1127
1168
  watchId: id,
1128
1169
  ...(turn.sendIds.length > 1 ? { watchIds: turn.sendIds } : {}),
1129
- ...progressOf(id, answerId),
1170
+ ...progressOf(sessionId, answerId),
1130
1171
  ...(origin.textOnly ? {} : await artifactFields(sessionId, id, turn.runtime)),
1131
1172
  }),
1132
1173
  })
@@ -36,6 +36,7 @@ import { createSettingsApi } from '../settings-api.mjs';
36
36
  import { createSessionTitleController } from '../../runtime/agent/orchestrator/runtime-core/session-title.mjs';
37
37
  import { closeNativeToolTransports, closePatchRuntimeIfLoaded, withTeardownDeadline } from '../native-teardown.mjs';
38
38
  import { createChannelConfigApi } from '../channel-config-api.mjs';
39
+ import { deleteOwnedRoutines } from '../services/channel-admin.mjs';
39
40
  import { createMediaApi } from '../media-api.mjs';
40
41
  import { createProviderAuthApi } from '../provider-auth-api.mjs';
41
42
  import { createUsageStatsApi } from '../usage-stats-api.mjs';
@@ -122,12 +123,17 @@ export function wireApis(boot) {
122
123
  if (boot.ensureConnectorAccountIds()) boot.reloadFullConfig();
123
124
  }
124
125
  boot.disposeGlobalExtensionSubscription = () => {
126
+ boot.disposeProviderReadiness();
125
127
  boot.disposeConfigSync?.();
126
128
  boot.disposeAgentProfileChanges();
127
129
  boot.resourceApi.disposeGlobalExtensionSubscription?.();
128
130
  };
129
131
  boot.modelRouteApi = modelRouteApiFor(boot);
130
132
  boot.workflowAgentsApi = workflowAgentsApiFor(boot);
133
+ // A bot's purge that stopped before its folder was removed is finished.
134
+ boot.workflowAgentsApi.finishUnfinishedPurges().catch((error) => {
135
+ bootProfile('bot-purge:finish-failed', { error: error?.message || String(error) });
136
+ });
131
137
  // Connector allow lists (agent lists, MCP project scopes) become the
132
138
  // equivalent "switched off" lists once; a later connector is on everywhere.
133
139
  if (!boot.params.initialConfig || typeof boot.params.initialConfig !== 'object') {
@@ -645,6 +651,16 @@ function workflowAgentsApiFor(boot) {
645
651
  settingsReachCurrentSession: () => boot.settingsReachCurrentSession(),
646
652
  switchSessionWorkflow: boot.switchSessionWorkflow,
647
653
  switchSessionOrchestrationMode: boot.switchSessionOrchestrationMode,
654
+ // A bot deleted for good takes its schedules and webhooks; the channels worker
655
+ // drops their cron jobs and endpoints on its reload.
656
+ deleteOwnedRoutines: async (agentId) => {
657
+ const removed = await deleteOwnedRoutines(agentId);
658
+ if (removed.schedules.length || removed.webhooks.length) boot.reloadChannelsSoon();
659
+ return removed;
660
+ },
661
+ // A restored bot's routines are armed again by the same reload; the
662
+ // restore waits for it and reports its failure.
663
+ reloadRoutines: () => boot.reloadChannels(),
648
664
  });
649
665
  }
650
666
 
@@ -37,6 +37,7 @@ export function beginBoot(params) {
37
37
  invalidateProviderCaches,
38
38
  reinitProviders,
39
39
  ensureProvidersReady,
40
+ dispose: disposeProviderReadiness,
40
41
  modelMetaByRoute,
41
42
  providerModelCaches,
42
43
  providerUsageCaches,
@@ -57,6 +58,7 @@ export function beginBoot(params) {
57
58
  invalidateProviderCaches,
58
59
  reinitProviders,
59
60
  ensureProvidersReady,
61
+ disposeProviderReadiness,
60
62
  modelMetaByRoute,
61
63
  providerModelCaches,
62
64
  providerUsageCaches,
@@ -64,9 +64,15 @@ export function wireTools(boot) {
64
64
  .catch((error) => bootProfile('mcp:failed', { error: error?.message || String(error) }));
65
65
  // A lost reload leaves the old timers armed; the scheduler re-reads each
66
66
  // schedule before it fires (scheduler.mjs fireTimed), so it is only reported.
67
+ // `reloadChannels` settles once the worker re-armed them and rejects when it
68
+ // could not (a refusal comes back as an isError reply, not a rejection).
69
+ boot.reloadChannels = async () => {
70
+ const reply = await boot.channels.execute('reload_config', {});
71
+ if (reply?.isError === true) throw new Error(reply.content?.[0]?.text || 'reload_config failed');
72
+ };
67
73
  boot.reloadChannelsSoon = () => {
68
- boot.channels
69
- .execute('reload_config', {})
74
+ boot
75
+ .reloadChannels()
70
76
  .catch((error) =>
71
77
  process.stderr.write(`[channels] schedule reload failed: ${error?.message || String(error)}\n`)
72
78
  );
@@ -5,8 +5,8 @@ import { randomUUID } from 'node:crypto';
5
5
  import {
6
6
  validateUserHandoff,
7
7
  validateAskUserQuestions,
8
- ASK_USER_MAX_TEXT,
9
8
  } from '../../runtime/agent/orchestrator/runtime-core/ask-user-tool-defs.mjs';
9
+ import { askUserResultText } from '../../runtime/agent/orchestrator/runtime-core/ask-user-result.mjs';
10
10
  import { createCallerContextResolvers } from './caller-context.mjs';
11
11
  import { noteTodoUserWait } from '../../runtime/agent/orchestrator/session/loop/no-tool-turn/todo-check.mjs';
12
12
  import { runAbortable } from '../../runtime/shared/abort-race.mjs';
@@ -227,55 +227,6 @@ export function handoffSite(handoff) {
227
227
 
228
228
  const NO_USER =
229
229
  'No user is available to answer in this session. Proceed with your best judgment and state the choices you made.';
230
- const DISMISSED =
231
- 'User closed the questions without answering. Proceed with your best judgment; ask again only if something new depends on it.';
232
-
233
- /** Wire answers -> array aligned with questions; invalid entries become null. */
234
- function normalizeAskUserAnswers(answers, questions) {
235
- const list = Array.isArray(answers) ? answers.slice(0, 4) : [];
236
- return questions.map((q, i) => {
237
- const entry = list[i];
238
- if (!entry || typeof entry !== 'object') return null;
239
- const labels = new Set(q.options.map((o) => o.label));
240
- const rawSelected = entry.selected == null ? [] : entry.selected;
241
- if (!Array.isArray(rawSelected) || !rawSelected.every((l) => typeof l === 'string' && labels.has(l))) return null;
242
- if (entry.text != null && (typeof entry.text !== 'string' || entry.text.length > ASK_USER_MAX_TEXT)) return null;
243
- const selected = q.multi_select === true ? [...new Set(rawSelected)] : rawSelected.slice(0, 1);
244
- const text = typeof entry.text === 'string' ? entry.text.trim() : '';
245
- if (!selected.length && !text) return null;
246
- return text ? { selected, text } : { selected };
247
- });
248
- }
249
-
250
- // Strings are JSON-quoted so a quote inside one cannot end it early; typed
251
- // text stays apart from the picked labels (`"picked" + "typed" (typed)`).
252
- function formatAskUserAnswers(questions, answers) {
253
- const quote = (text) => JSON.stringify(text);
254
- const parts = questions.map((q, i) => {
255
- const a = answers[i];
256
- if (!a) return `${quote(q.question)}=(no answer)`;
257
- const picked = a.selected.length ? quote(a.selected.join(', ')) : '';
258
- const typed = a.text ? `${quote(a.text)} (typed)` : '';
259
- return `${quote(q.question)}=${[picked, typed].filter(Boolean).join(' + ')}`;
260
- });
261
- return `User has answered your questions: ${parts.join('; ')}. You can now continue with these answers in mind.`;
262
- }
263
-
264
- /** A composer message sent instead of (or with) picking: kept when it is a
265
- * non-empty string within the typed-answer limit, else dropped. */
266
- function normalizeAskUserReply(reply) {
267
- if (typeof reply !== 'string' || reply.length > ASK_USER_MAX_TEXT) return '';
268
- return reply.trim();
269
- }
270
-
271
- // `User replied in chat: "<reply>". ` leads, then the usual picks sentence
272
- // when any question was answered, else just the closing sentence.
273
- function formatAskUserResult(questions, answers, reply) {
274
- if (!reply) return formatAskUserAnswers(questions, answers);
275
- const lead = `User replied in chat: ${JSON.stringify(reply)}. `;
276
- if (answers.some(Boolean)) return `${lead}${formatAskUserAnswers(questions, answers)}`;
277
- return `${lead}You can now continue with these answers in mind.`;
278
- }
279
230
 
280
231
  export function createAskUserToolHandlers({ rt }) {
281
232
  const { sessionIdFor, signalFor } = createCallerContextResolvers(rt);
@@ -304,15 +255,9 @@ export function createAskUserToolHandlers({ rt }) {
304
255
  toolCallId: callerCtx?.toolCallId || null,
305
256
  })
306
257
  );
307
- if (result?.approved === true)
308
- return formatAskUserResult(
309
- questions,
310
- normalizeAskUserAnswers(result.answers, questions),
311
- normalizeAskUserReply(result.reply)
312
- );
313
258
  // A question left unanswered: the turn may end waiting on the user.
314
- noteTodoUserWait(sessionIdFor(callerCtx));
315
- return DISMISSED;
259
+ if (result?.approved !== true) noteTodoUserWait(sessionIdFor(callerCtx));
260
+ return askUserResultText(questions, result);
316
261
  },
317
262
  };
318
263
  }
@@ -78,6 +78,21 @@ export function createMediaApi() {
78
78
  async listMediaAssets(options) {
79
79
  return (await store()).listMediaAssets(options || {});
80
80
  },
81
+ async listMediaBoards() {
82
+ return (await store()).listMediaBoards();
83
+ },
84
+ async createMediaBoard(name) {
85
+ return (await store()).createMediaBoard(name);
86
+ },
87
+ async renameMediaBoard(id, name) {
88
+ return (await store()).renameMediaBoard(id, name);
89
+ },
90
+ async deleteMediaBoard(id) {
91
+ return (await store()).deleteMediaBoard(id);
92
+ },
93
+ async setMediaAssetBoard(ids, boardId) {
94
+ return (await store()).setMediaAssetBoard(ids, boardId);
95
+ },
81
96
  async readMediaAsset(id, options) {
82
97
  return (await store()).readMediaAsset(id, options || {});
83
98
  },
@@ -4,9 +4,12 @@
4
4
  * fast/effort tuning of a session that runs on the selected route.
5
5
  */
6
6
  import { saveModelSettings } from '../../runtime/agent/orchestrator/runtime-core/model-capabilities.mjs';
7
+ import { OPENROUTER_SORT_PARAMETER } from '../../runtime/agent/orchestrator/providers/openrouter-provider-routing.mjs';
7
8
  import { writeStatuslineRoute } from '../statusline-route.mjs';
8
9
  import { sessionUsesRoute } from '../../runtime/agent/orchestrator/runtime-core/session-route-policy.mjs';
9
10
 
11
+ const TUNED_PARAMETERS = ['serviceTier', OPENROUTER_SORT_PARAMETER];
12
+
10
13
  /** Re-tuning the live model (effort, Fast, context, or re-picking it) is not a
11
14
  * main-model choice: new tasks keep their main model unless it is that model. */
12
15
  function tunesNonMainModel(liveRoute, route, mainRoute) {
@@ -57,10 +60,15 @@ export function createRoutePersistence(deps) {
57
60
  if (route.autoEffort === false) session.autoEffort = false;
58
61
  else delete session.autoEffort;
59
62
  session.effort = route.effectiveEffort || null;
60
- // The request path reads session.modelParameters; keep only serviceTier in step.
61
- const { serviceTier: _previous, ...otherParameters } = session.modelParameters || {};
62
- const serviceTier = route.modelParameters?.serviceTier;
63
- session.modelParameters = serviceTier ? { ...otherParameters, serviceTier } : otherParameters;
63
+ // The request path reads session.modelParameters; keep only the tuned
64
+ // parameters (serviceTier, OpenRouter's providerSort) in step.
65
+ const otherParameters = { ...(session.modelParameters || {}) };
66
+ for (const key of TUNED_PARAMETERS) {
67
+ delete otherParameters[key];
68
+ const value = route.modelParameters?.[key];
69
+ if (value) otherParameters[key] = value;
70
+ }
71
+ session.modelParameters = otherParameters;
64
72
  writeStatuslineRoute(statusRoutes, session, route);
65
73
  invalidateContextStatusCache();
66
74
  },
@@ -14,6 +14,7 @@ import {
14
14
  effortConfigurationMode,
15
15
  } from '../../runtime/agent/orchestrator/providers/effort-configuration.mjs';
16
16
  import { getProvider } from '../../runtime/agent/orchestrator/providers/registry.mjs';
17
+ import { OPENROUTER_SORT_OPTION } from '../../runtime/agent/orchestrator/providers/openrouter-provider-routing.mjs';
17
18
  import { providerAvailable } from '../../runtime/agent/orchestrator/providers/provider-availability.mjs';
18
19
  import {
19
20
  DAYBREAK_PARAMETER_OPTION,
@@ -42,6 +43,7 @@ export function hydrateProviderModelRow(cfg, row) {
42
43
  const addedOptions = [
43
44
  ...(row.provider === DAYBREAK_PROVIDER && daybreakBlueSupported(row) ? [DAYBREAK_PARAMETER_OPTION] : []),
44
45
  ...(fastCapable && ultrafastCapableFor(row.provider, row) ? [ULTRAFAST_SPEED_OPTION] : []),
46
+ ...(row.provider === 'openrouter' ? [OPENROUTER_SORT_OPTION] : []),
45
47
  ];
46
48
  const modelParameterOptions = addedOptions.length
47
49
  ? [...existingOptions.filter((option) => !addedOptions.some((added) => added.id === option?.id)), ...addedOptions]