mixdog 0.9.152 → 0.9.154

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (300) hide show
  1. package/LICENSES/browser-import-NOTICE.txt +11 -0
  2. package/NOTICE.md +11 -0
  3. package/README.md +8 -10
  4. package/package.json +19 -3
  5. package/scripts/computer-task-cost-report.mjs +144 -0
  6. package/scripts/run-office-live-tests.mjs +32 -0
  7. package/src/agents/front-worker/AGENT.md +13 -0
  8. package/src/agents/front-worker/agent.json +6 -0
  9. package/src/agents/heavy-worker/AGENT.md +10 -11
  10. package/src/agents/heavy-worker/agent.json +1 -1
  11. package/src/agents/maintainer/AGENT.md +0 -2
  12. package/src/agents/reviewer/AGENT.md +9 -13
  13. package/src/agents/reviewer/agent.json +1 -1
  14. package/src/agents/security/AGENT.md +14 -0
  15. package/src/agents/security/agent.json +6 -0
  16. package/src/agents/worker/AGENT.md +8 -8
  17. package/src/agents/worker/agent.json +1 -1
  18. package/src/agents/writer/AGENT.md +14 -0
  19. package/src/agents/writer/agent.json +6 -0
  20. package/src/rules/agent/00-common.md +4 -7
  21. package/src/rules/lead/01-general.md +0 -3
  22. package/src/rules/shared/10-tool-workflow.md +10 -2
  23. package/src/rules/shared/60-verification.md +2 -0
  24. package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +183 -26
  25. package/src/runtime/agent/orchestrator/agent-runtime/session-builder.mjs +4 -0
  26. package/src/runtime/agent/orchestrator/cache-break-trace.mjs +109 -0
  27. package/src/runtime/agent/orchestrator/config.mjs +7 -2
  28. package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +16 -3
  29. package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +9 -1
  30. package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +30 -9
  31. package/src/runtime/agent/orchestrator/providers/openai-codex-metadata.mjs +18 -26
  32. package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +25 -2
  33. package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +103 -10
  34. package/src/runtime/agent/orchestrator/providers/openai-turn-state.mjs +68 -0
  35. package/src/runtime/agent/orchestrator/providers/openai-ws-delta.mjs +36 -11
  36. package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +140 -86
  37. package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +9 -13
  38. package/src/runtime/agent/orchestrator/session/agent-loop.mjs +72 -4
  39. package/src/runtime/agent/orchestrator/session/browser-snapshot-supersession.mjs +61 -0
  40. package/src/runtime/agent/orchestrator/session/compact/handoff.mjs +0 -22
  41. package/src/runtime/agent/orchestrator/session/compact/messages.mjs +2 -2
  42. package/src/runtime/agent/orchestrator/session/compact/runner.mjs +11 -23
  43. package/src/runtime/agent/orchestrator/session/compact/summary.mjs +28 -269
  44. package/src/runtime/agent/orchestrator/session/compact.mjs +0 -6
  45. package/src/runtime/agent/orchestrator/session/context-utils.mjs +86 -11
  46. package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +17 -1
  47. package/src/runtime/agent/orchestrator/session/image-strip-recovery.mjs +12 -8
  48. package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +110 -2
  49. package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +3 -16
  50. package/src/runtime/agent/orchestrator/session/loop/recall-fasttrack.mjs +80 -18
  51. package/src/runtime/agent/orchestrator/session/loop/steering.mjs +6 -0
  52. package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +3 -0
  53. package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +6 -0
  54. package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +80 -21
  55. package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +33 -72
  56. package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +21 -2
  57. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +25 -51
  58. package/src/runtime/agent/orchestrator/session/manager/status-telemetry.mjs +3 -0
  59. package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +4 -110
  60. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.mjs +39 -15
  61. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +14 -4
  62. package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +41 -8
  63. package/src/runtime/agent/orchestrator/session/provider-prefix-guard.mjs +129 -12
  64. package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +2 -2
  65. package/src/runtime/agent/orchestrator/session/store/listing.mjs +8 -1
  66. package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +15 -1
  67. package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +36 -2
  68. package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +157 -30
  69. package/src/runtime/agent/orchestrator/session/store-summary-visibility.mjs +57 -0
  70. package/src/runtime/agent/orchestrator/session/store.mjs +3 -1
  71. package/src/runtime/agent/orchestrator/session/tool-batch.mjs +22 -0
  72. package/src/runtime/agent/orchestrator/tools/builtin/read-special-files.mjs +6 -6
  73. package/src/runtime/agent/orchestrator/tools/progress-message.mjs +4 -0
  74. package/src/runtime/attachments/pdf-extract.mjs +3 -0
  75. package/src/runtime/attachments/pdfjs-runtime.mjs +13 -0
  76. package/src/runtime/browser-bridge/action-schema.mjs +251 -0
  77. package/src/runtime/browser-bridge/client.mjs +75 -26
  78. package/src/runtime/browser-bridge/tool-defs.mjs +132 -15
  79. package/src/runtime/computer-bridge/action-schema.mjs +653 -0
  80. package/src/runtime/computer-bridge/client.mjs +211 -28
  81. package/src/runtime/computer-bridge/tool-defs.mjs +25 -45
  82. package/src/runtime/office/assurance-benchmark.mjs +358 -0
  83. package/src/runtime/office/assurance.mjs +833 -0
  84. package/src/runtime/office/benchmark.mjs +496 -0
  85. package/src/runtime/office/capabilities.mjs +551 -0
  86. package/src/runtime/office/com-adapter.mjs +283 -0
  87. package/src/runtime/office/content-model.mjs +183 -0
  88. package/src/runtime/office/contract-benchmark.mjs +105 -0
  89. package/src/runtime/office/design-library.mjs +1562 -0
  90. package/src/runtime/office/design-system.mjs +1966 -0
  91. package/src/runtime/office/index.mjs +2413 -0
  92. package/src/runtime/office/journal.mjs +82 -0
  93. package/src/runtime/office/office-com-host.ps1 +3781 -0
  94. package/src/runtime/office/office-com-session-host.ps1 +855 -0
  95. package/src/runtime/office/ooxml-validator.mjs +271 -0
  96. package/src/runtime/office/pagination.mjs +132 -0
  97. package/src/runtime/office/pdf-adapter.mjs +591 -0
  98. package/src/runtime/office/pdf-analysis.mjs +372 -0
  99. package/src/runtime/office/pdf-render.mjs +167 -0
  100. package/src/runtime/office/pdf-security.mjs +63 -0
  101. package/src/runtime/office/polish-benchmark.mjs +190 -0
  102. package/src/runtime/office/portable-ooxml.mjs +1867 -0
  103. package/src/runtime/office/quality-live-benchmark.mjs +486 -0
  104. package/src/runtime/office/quality-pipeline.mjs +136 -0
  105. package/src/runtime/office/tabular.mjs +302 -0
  106. package/src/runtime/office/templates/mixdog-executive.pptx +0 -0
  107. package/src/runtime/office/templates/mixdog-executive.pptx.mixdog.json +190 -0
  108. package/src/runtime/office/tool-defs.mjs +113 -0
  109. package/src/runtime/office/visual-diff.mjs +89 -0
  110. package/src/runtime/office/xlsx-assertions.mjs +172 -0
  111. package/src/runtime/office/xlsx-contract.mjs +147 -0
  112. package/src/runtime/shared/agent-route-config.mjs +9 -0
  113. package/src/runtime/shared/tool-execution-contract.mjs +16 -0
  114. package/src/runtime/shared/tool-surface.mjs +9 -0
  115. package/src/session-runtime/context-status.mjs +9 -3
  116. package/src/session-runtime/deferred-tool-delta.mjs +104 -0
  117. package/src/session-runtime/goal-runtime.mjs +617 -197
  118. package/src/session-runtime/lifecycle-api.mjs +50 -8
  119. package/src/session-runtime/provider-request-snapshot.mjs +33 -9
  120. package/src/session-runtime/resource-api.mjs +31 -94
  121. package/src/session-runtime/runtime-core.mjs +78 -26
  122. package/src/session-runtime/session-lifecycle.mjs +34 -12
  123. package/src/session-runtime/session-title.mjs +2 -2
  124. package/src/session-runtime/session-turn-api.mjs +15 -14
  125. package/src/session-runtime/tool-catalog-data.mjs +1 -1
  126. package/src/session-runtime/tool-catalog.mjs +38 -99
  127. package/src/session-runtime/tool-defs.mjs +6 -1
  128. package/src/session-runtime/tool-surface.mjs +18 -8
  129. package/src/session-runtime/workflow-agents-api.mjs +8 -25
  130. package/src/session-runtime/workflow.mjs +8 -6
  131. package/src/standalone/agent-tool/helpers.mjs +2 -2
  132. package/src/standalone/agent-tool/job-views.mjs +3 -1
  133. package/src/standalone/agent-tool/notify.mjs +5 -1
  134. package/src/standalone/agent-tool/render.mjs +3 -0
  135. package/src/standalone/agent-tool/spawn-flow.mjs +61 -16
  136. package/src/standalone/agent-tool/tool-def.mjs +1 -1
  137. package/src/standalone/agent-tool/worker-index.mjs +123 -0
  138. package/src/standalone/agent-tool/worker-rows.mjs +2 -1
  139. package/src/standalone/agent-tool.mjs +57 -10
  140. package/src/standalone/daemon.mjs +105 -6
  141. package/src/standalone/session-runtime-host.mjs +61 -48
  142. package/src/standalone/session-runtime-inline-host.mjs +34 -127
  143. package/src/standalone/session-runtime-worker.mjs +20 -198
  144. package/src/standalone/session-service.mjs +632 -7
  145. package/src/tui/dist/index.mjs +24 -1
  146. package/src/tui/lib/voice-setup.mjs +4 -1
  147. package/src/tui/session/context-state.mjs +2 -13
  148. package/src/tui/session/goal-continuation.mjs +38 -7
  149. package/src/tui/session/session-api-ext.mjs +9 -0
  150. package/src/tui/session/session-api.mjs +15 -1
  151. package/src/tui/session/session-flow.mjs +25 -1
  152. package/src/tui/session/turn.mjs +88 -16
  153. package/src/tui/session-local.mjs +25 -3
  154. package/src/vendor/statusline/src/gateway/route-meta.mjs +31 -0
  155. package/scripts/generate-voice-runtime-manifest.test.mjs +0 -135
  156. package/scripts/native-binary-arch.test.mjs +0 -111
  157. package/scripts/patch-replay.test.mjs +0 -94
  158. package/src/headless-exec.test.mjs +0 -539
  159. package/src/runtime/agent/orchestrator/agent-trace-timing.test.mjs +0 -57
  160. package/src/runtime/agent/orchestrator/context/collect-skills.test.mjs +0 -153
  161. package/src/runtime/agent/orchestrator/mcp/cancellation.test.mjs +0 -139
  162. package/src/runtime/agent/orchestrator/mcp/features.test.mjs +0 -66
  163. package/src/runtime/agent/orchestrator/mcp/security.test.mjs +0 -80
  164. package/src/runtime/agent/orchestrator/providers/anthropic-fast-mode.test.mjs +0 -90
  165. package/src/runtime/agent/orchestrator/providers/anthropic-server-fallback.test.mjs +0 -215
  166. package/src/runtime/agent/orchestrator/providers/antigravity-oauth.test.mjs +0 -165
  167. package/src/runtime/agent/orchestrator/providers/media-parity.test.mjs +0 -142
  168. package/src/runtime/agent/orchestrator/providers/openai-codex-identity.test.mjs +0 -153
  169. package/src/runtime/agent/orchestrator/providers/openai-codex-model.test.mjs +0 -24
  170. package/src/runtime/agent/orchestrator/providers/openai-ws-delta-parity.test.mjs +0 -190
  171. package/src/runtime/agent/orchestrator/providers/provider-replay.test.mjs +0 -235
  172. package/src/runtime/agent/orchestrator/providers/sse-framing.test.mjs +0 -719
  173. package/src/runtime/agent/orchestrator/session/cache/prefetch-cache.test.mjs +0 -40
  174. package/src/runtime/agent/orchestrator/session/compact-policy.test.mjs +0 -176
  175. package/src/runtime/agent/orchestrator/session/compaction-read-reset.test.mjs +0 -161
  176. package/src/runtime/agent/orchestrator/session/eager-dispatch.test.mjs +0 -115
  177. package/src/runtime/agent/orchestrator/session/evidence-union.test.mjs +0 -228
  178. package/src/runtime/agent/orchestrator/session/image-strip-recovery.test.mjs +0 -245
  179. package/src/runtime/agent/orchestrator/session/lossless-tool-output.test.mjs +0 -125
  180. package/src/runtime/agent/orchestrator/session/manager/pending-messages-persistence.test.mjs +0 -325
  181. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.test.mjs +0 -70
  182. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.test.mjs +0 -457
  183. package/src/runtime/agent/orchestrator/session/provider-prefix-guard.test.mjs +0 -117
  184. package/src/runtime/agent/orchestrator/session/reduction-metrics.test.mjs +0 -87
  185. package/src/runtime/agent/orchestrator/session/store/serialize.test.mjs +0 -60
  186. package/src/runtime/agent/orchestrator/session/store-summary-reader.test.mjs +0 -583
  187. package/src/runtime/agent/orchestrator/session/task-wait-control.test.mjs +0 -78
  188. package/src/runtime/agent/orchestrator/tools/builtin/absence-absorption.test.mjs +0 -43
  189. package/src/runtime/agent/orchestrator/tools/builtin/absolute-glob-expand.test.mjs +0 -63
  190. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool-cwd-env.test.mjs +0 -14
  191. package/src/runtime/agent/orchestrator/tools/builtin/edit-encoding-eol.test.mjs +0 -224
  192. package/src/runtime/agent/orchestrator/tools/builtin/edit-sequential-occupation.test.mjs +0 -224
  193. package/src/runtime/agent/orchestrator/tools/builtin/enoent-outside-project.test.mjs +0 -56
  194. package/src/runtime/agent/orchestrator/tools/builtin/find-search-budget.test.mjs +0 -103
  195. package/src/runtime/agent/orchestrator/tools/builtin/git-command-policy.test.mjs +0 -30
  196. package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.test.mjs +0 -390
  197. package/src/runtime/agent/orchestrator/tools/builtin/git-repo-rw-lock.test.mjs +0 -83
  198. package/src/runtime/agent/orchestrator/tools/builtin/grep-output-budget.test.mjs +0 -31
  199. package/src/runtime/agent/orchestrator/tools/builtin/grep-single-file-rescue.test.mjs +0 -106
  200. package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.test.mjs +0 -102
  201. package/src/runtime/agent/orchestrator/tools/builtin/list-tool-integrity.test.mjs +0 -152
  202. package/src/runtime/agent/orchestrator/tools/builtin/native-search-health.test.mjs +0 -24
  203. package/src/runtime/agent/orchestrator/tools/builtin/native-search-transport.test.mjs +0 -24
  204. package/src/runtime/agent/orchestrator/tools/builtin/noise-dir-visibility.test.mjs +0 -69
  205. package/src/runtime/agent/orchestrator/tools/builtin/read-glob-survey.test.mjs +0 -71
  206. package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.test.mjs +0 -56
  207. package/src/runtime/agent/orchestrator/tools/builtin/search-builders.test.mjs +0 -16
  208. package/src/runtime/agent/orchestrator/tools/builtin/search-glob-top-k.test.mjs +0 -39
  209. package/src/runtime/agent/orchestrator/tools/builtin/write-symlink.test.mjs +0 -153
  210. package/src/runtime/agent/orchestrator/tools/code-graph/aggregate-anchor-relocation.test.mjs +0 -55
  211. package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.test.mjs +0 -88
  212. package/src/runtime/agent/orchestrator/tools/code-graph/loose-file-target.test.mjs +0 -72
  213. package/src/runtime/agent/orchestrator/tools/code-graph/memory-cache.test.mjs +0 -54
  214. package/src/runtime/agent/orchestrator/tools/code-graph/search-references.test.mjs +0 -20
  215. package/src/runtime/agent/orchestrator/tools/code-graph/symbol-search-scope.test.mjs +0 -55
  216. package/src/runtime/agent/orchestrator/tools/code-graph/text-span-mask.test.mjs +0 -268
  217. package/src/runtime/agent/orchestrator/tools/env-scrub.test.mjs +0 -57
  218. package/src/runtime/agent/orchestrator/tools/graph-binary-fetcher.test.mjs +0 -19
  219. package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.test.mjs +0 -104
  220. package/src/runtime/agent/orchestrator/tools/patch/engine-contract-gate.test.mjs +0 -661
  221. package/src/runtime/agent/orchestrator/tools/patch/patch-codec-eol.test.mjs +0 -552
  222. package/src/runtime/agent/orchestrator/tools/patch/patch-symlink.test.mjs +0 -141
  223. package/src/runtime/agent/orchestrator/tools/patch/v4a-pure-move.test.mjs +0 -57
  224. package/src/runtime/agent/orchestrator/tools/patch/v4a-section-coalesce.test.mjs +0 -81
  225. package/src/runtime/agent/orchestrator/tools/spawn-binary-fetcher.test.mjs +0 -52
  226. package/src/runtime/attachments/store.test.mjs +0 -209
  227. package/src/runtime/channels/lib/voice-runtime-fetcher.test.mjs +0 -17
  228. package/src/runtime/channels/lib/webhook/deliveries.test.mjs +0 -18
  229. package/src/runtime/channels/lib/webhook/relay-tunnel.test.mjs +0 -68
  230. package/src/runtime/media/adapters/codex-image.test.mjs +0 -22
  231. package/src/runtime/media/download.test.mjs +0 -52
  232. package/src/runtime/media/renditions.test.mjs +0 -99
  233. package/src/runtime/media/store.test.mjs +0 -159
  234. package/src/runtime/memory/lib/archive-security.test.mjs +0 -128
  235. package/src/runtime/memory/lib/embedding-model-config.test.mjs +0 -33
  236. package/src/runtime/memory/lib/http-wire.test.mjs +0 -15
  237. package/src/runtime/memory/lib/memory-cycle-packets.test.mjs +0 -49
  238. package/src/runtime/memory/lib/memory-cycle2-shared.test.mjs +0 -78
  239. package/src/runtime/memory/lib/memory-embedding-migration.test.mjs +0 -50
  240. package/src/runtime/memory/lib/pg/process.test.mjs +0 -36
  241. package/src/runtime/memory/lib/trace-store.test.mjs +0 -57
  242. package/src/runtime/memory/lib/transcript-ingest.test.mjs +0 -52
  243. package/src/runtime/shared/background-tasks.test.mjs +0 -78
  244. package/src/runtime/shared/bounded-download.test.mjs +0 -41
  245. package/src/runtime/shared/channel-notification-routing.test.mjs +0 -25
  246. package/src/runtime/shared/child-spawn-remote.test.mjs +0 -124
  247. package/src/runtime/shared/remote-intent.test.mjs +0 -40
  248. package/src/runtime/shared/resource-admission.test.mjs +0 -43
  249. package/src/runtime/shared/runtime-root.test.mjs +0 -34
  250. package/src/runtime/shared/schedule-time.test.mjs +0 -29
  251. package/src/runtime/shared/session-runtime-health.test.mjs +0 -83
  252. package/src/runtime/shared/skill-document.test.mjs +0 -81
  253. package/src/runtime/shared/tool-surface.test.mjs +0 -87
  254. package/src/runtime/shared/update-checker.test.mjs +0 -33
  255. package/src/runtime/shared/user-cwd.test.mjs +0 -43
  256. package/src/runtime/shared/webhook-session-run.test.mjs +0 -14
  257. package/src/session-runtime/agent-disable.test.mjs +0 -123
  258. package/src/session-runtime/cwd-plugins.test.mjs +0 -75
  259. package/src/session-runtime/cwd-tool-routing.test.mjs +0 -61
  260. package/src/session-runtime/global-extensions.test.mjs +0 -28
  261. package/src/session-runtime/goal-runtime.test.mjs +0 -108
  262. package/src/session-runtime/lifecycle-api.test.mjs +0 -21
  263. package/src/session-runtime/model-settings-persist.test.mjs +0 -105
  264. package/src/session-runtime/notification-bus.test.mjs +0 -148
  265. package/src/session-runtime/plugin-mcp-standard.test.mjs +0 -177
  266. package/src/session-runtime/prewarm.test.mjs +0 -52
  267. package/src/session-runtime/provider-request-snapshot.test.mjs +0 -37
  268. package/src/session-runtime/resource-api-global.test.mjs +0 -69
  269. package/src/session-runtime/session-lifecycle.test.mjs +0 -125
  270. package/src/session-runtime/session-title.test.mjs +0 -36
  271. package/src/session-runtime/skills-api.test.mjs +0 -99
  272. package/src/session-runtime/tool-policy-surface.test.mjs +0 -331
  273. package/src/standalone/agent-tool/helpers.test.mjs +0 -62
  274. package/src/standalone/agent-tool/notify.test.mjs +0 -37
  275. package/src/standalone/agent-tool/spawn-flow.test.mjs +0 -63
  276. package/src/standalone/channel-restart.test.mjs +0 -145
  277. package/src/standalone/channel-session-router.test.mjs +0 -37
  278. package/src/standalone/channel-worker-heartbeat.test.mjs +0 -30
  279. package/src/standalone/hook-bus/handlers.test.mjs +0 -88
  280. package/src/standalone/plugin-admin.test.mjs +0 -173
  281. package/src/standalone/session-runtime-agent-control-client.test.mjs +0 -71
  282. package/src/standalone/session-runtime-dispatch-cancel.test.mjs +0 -139
  283. package/src/standalone/session-runtime-host-factory.test.mjs +0 -31
  284. package/src/standalone/session-runtime-host-health.test.mjs +0 -160
  285. package/src/standalone/session-runtime-inline-host.test.mjs +0 -83
  286. package/src/standalone/session-runtime-provider-cooldown.test.mjs +0 -80
  287. package/src/standalone/session-runtime-shard-host.test.mjs +0 -569
  288. package/src/standalone/session-runtime-shard-router.test.mjs +0 -101
  289. package/src/tui/app/live-spinner-visibility.test.mjs +0 -44
  290. package/src/tui/app/panel-epoch.test.mjs +0 -1009
  291. package/src/tui/app/panel-handoff.test.mjs +0 -311
  292. package/src/tui/app/prompt-submit.test.mjs +0 -206
  293. package/src/tui/session/completion-card-restore.test.mjs +0 -111
  294. package/src/tui/session/goal-continuation.test.mjs +0 -84
  295. package/src/tui/session/oauth-flows.test.mjs +0 -134
  296. package/src/tui/session/queue-helpers.test.mjs +0 -46
  297. package/src/tui/session/session-action-surface.test.mjs +0 -108
  298. package/src/tui/session/task-wait-submit.test.mjs +0 -80
  299. package/src/tui/session/tool-result-status.test.mjs +0 -131
  300. package/src/tui/session/tui-steering-persist.test.mjs +0 -104
@@ -0,0 +1,551 @@
1
+ import { officeDesignCatalog } from './design-system.mjs';
2
+
3
+ export const OFFICE_ACTIONS = Object.freeze([
4
+ 'detect', 'transactions', 'recover', 'describe', 'create', 'attach', 'open', 'secure',
5
+ 'begin', 'snapshot', 'get', 'query', 'batch', 'diff', 'commit', 'rollback',
6
+ 'issues', 'qa', 'validate', 'render', 'save', 'finalize', 'close',
7
+ ]);
8
+
9
+ const COMMON = {
10
+ actions: OFFICE_ACTIONS,
11
+ observation: {
12
+ selection: 'attached and visible Microsoft Office snapshots include the active range, paragraph, slide, or shapes; background and portable sessions report document state only',
13
+ },
14
+ batch: {
15
+ atomic: 'all modes roll back failed batches; live Word/PowerPoint use Office Undo boundaries and live Excel restores an in-memory checkpoint without saving',
16
+ operationShape: '{ op, target-specific fields, properties?, allowNoChange? }; silent no-op results roll back unless requireChanges:false',
17
+ initialOperations: 'create/open accept known operations; their results prove the edit without a redundant snapshot unless snapshotAfter:true',
18
+ },
19
+ };
20
+
21
+ const TABULAR = {
22
+ paths: ['/sheet[NAME]', '/sheet[NAME]/cell[A1]', '/sheet[NAME]/range[A1:C10]'],
23
+ operations: {
24
+ common: ['replace_text', 'set_cell', 'set_formula', 'set_range', 'append_row', 'clear_cell', 'insert_rows', 'delete_rows', 'insert_columns', 'delete_columns'],
25
+ office: [],
26
+ portable: [],
27
+ },
28
+ properties: {
29
+ cell: ['value', 'formula'],
30
+ structure: ['row', 'column', 'count', 'range'],
31
+ safety: ['formulaLikeValue', 'raggedRow', 'utf8'],
32
+ },
33
+ };
34
+
35
+ const CATALOG = {
36
+ docx: {
37
+ paths: ['/body/p[N]', '/body/p[N]/run[N]', '/body/tbl[N]/row[N]/cell[N]', '/body/comment[N]', '/body/comment-thread[N]', '/body/revision[N]', '/body/footnote[N]', '/body/endnote[N]', '/body/content-control[N]'],
38
+ operations: {
39
+ common: ['replace_text', 'fill_template', 'compose_document', 'append_text', 'set_paragraph_text', 'set_run_text', 'set_table_cell', 'remove_paragraph', 'move_paragraph', 'add_table', 'set_table_style', 'merge_table_cells', 'set_table_cell_style', 'set_paragraph_format'],
40
+ office: ['set_paragraph_style', 'set_font', 'add_image', 'add_comment', 'add_comment_reply', 'delete_comment', 'set_comment_resolved', 'insert_table_row', 'delete_table_row', 'insert_table_column', 'delete_table_column', 'set_header_footer', 'track_changes', 'resolve_revision', 'resolve_revisions', 'set_page', 'fit_table', 'insert_toc', 'add_page_numbers', 'insert_break', 'set_list', 'add_hyperlink', 'add_bookmark', 'add_provenance'],
41
+ portable: ['set_paragraph_style'],
42
+ },
43
+ properties: {
44
+ paragraph: ['style'],
45
+ font: ['name', 'size', 'bold', 'italic', 'color'],
46
+ page: ['orientation', 'topMargin', 'bottomMargin', 'leftMargin', 'rightMargin'],
47
+ headerFooter: ['section', 'kind', 'header', 'text'],
48
+ table: ['style', 'textStyle', 'fontName', 'fontSize', 'color', 'spacingAfter', 'columnWidths', 'borders', 'shading', 'alignment'],
49
+ tableCell: ['fillColor', 'verticalAlignment', 'width', 'fontName', 'fontSize', 'bold', 'italic', 'color'],
50
+ paragraphFormat: ['alignment', 'spacingBefore', 'spacingAfter', 'lineSpacing', 'keepWithNext', 'pageBreakBefore', 'border', 'tabStops', 'listKind', 'listLevel'],
51
+ comment: ['author', 'initials', 'date', 'text', 'anchoredText', 'resolved', 'replies'],
52
+ contentControl: ['tag', 'title', 'lock', 'text'],
53
+ revision: ['author', 'date', 'type', 'typeCode', 'text', 'resolution'],
54
+ fields: ['toc', 'page', 'numPages', 'pageBreak', 'sectionBreak'],
55
+ links: ['address', 'subAddress', 'display', 'bookmark'],
56
+ provenance: ['source.document', 'source.target', 'source.label'],
57
+ design: ['profile', 'intent', 'audience', 'tone', 'density', 'palette', 'typography', 'signature', 'content.packageId', 'content.audience', 'content.objective', 'content.decision', 'content.period', 'content.facts', 'content.claims', 'review'],
58
+ },
59
+ },
60
+ xlsx: {
61
+ paths: ['/sheet[NAME]', '/sheet[NAME]/cell[A1]', '/sheet[NAME]/range[A1:C10]'],
62
+ operations: {
63
+ common: ['replace_text', 'set_cell', 'set_formula', 'set_range', 'append_row', 'clear_cell'],
64
+ office: ['compose_sheet', 'add_sheet', 'copy_sheet', 'delete_sheet', 'rename_sheet', 'set_style', 'add_note', 'delete_note', 'add_image', 'add_table', 'add_chart', 'add_conditional_format', 'delete_conditional_formats', 'add_validation', 'freeze_panes', 'add_pivot_table', 'autofit_range', 'set_page_setup', 'set_sheet_view', 'set_sheet_visibility', 'insert_rows', 'delete_rows', 'insert_columns', 'delete_columns', 'merge_cells', 'unmerge_cells', 'set_autofilter', 'set_hyperlink', 'define_name', 'delete_name', 'protect_sheet', 'unprotect_sheet', 'add_provenance'],
65
+ portable: [],
66
+ },
67
+ properties: {
68
+ cellStyle: ['fontName', 'fontSize', 'bold', 'italic', 'color', 'fillColor', 'numberFormat', 'horizontalAlignment', 'verticalAlignment', 'wrapText'],
69
+ chart: ['chartType', 'left', 'top', 'width', 'height', 'title'],
70
+ table: ['name', 'style'],
71
+ pivot: ['source', 'destination', 'name', 'rows', 'columns', 'values'],
72
+ note: ['text', 'author'],
73
+ structure: ['row', 'column', 'count', 'range', 'referenceAware'],
74
+ links: ['address', 'text'],
75
+ protection: ['password', 'allowFormattingCells', 'allowSorting', 'allowFiltering'],
76
+ audit: ['conditionalFormats', 'formulaLineage', 'checksSheet', 'hardcodeSource', 'rogueHardcode'],
77
+ pageSetup: ['printArea', 'orientation', 'fitToPagesWide', 'fitToPagesTall', 'centerHorizontally', 'topMargin', 'bottomMargin', 'leftMargin', 'rightMargin'],
78
+ sheetView: ['showGridlines', 'zoom'],
79
+ provenance: ['source.document', 'source.target', 'source.label'],
80
+ design: ['profile', 'intent', 'audience', 'tone', 'density', 'palette', 'typography', 'signature', 'content.packageId', 'content.audience', 'content.objective', 'content.decision', 'content.period', 'content.facts', 'content.claims', 'review'],
81
+ },
82
+ },
83
+ pptx: {
84
+ paths: ['/slide[N]', '/slide[N]/shape[N]'],
85
+ operations: {
86
+ common: ['replace_text', 'fill_template', 'set_text', 'add_textbox', 'delete_shape'],
87
+ office: ['compose_slide', 'add_slide', 'delete_slide', 'move_slide', 'duplicate_slide', 'import_slides', 'keep_slides', 'set_notes', 'set_footer', 'set_slide_number', 'add_comment', 'delete_comment', 'add_image', 'replace_image', 'crop_image', 'add_media', 'set_shape', 'group_shapes', 'ungroup_shape', 'set_slide_background', 'set_layout', 'apply_theme', 'set_transition', 'add_animation', 'add_chart', 'fit_text', 'add_shape', 'add_table', 'set_table_data', 'set_chart_data', 'set_chart_series', 'set_chart_axis', 'set_chart_data_labels', 'set_chart_trendline', 'set_chart_error_bars', 'set_hyperlink', 'z_order', 'align_shapes', 'distribute_shapes', 'add_provenance'],
88
+ portable: [],
89
+ },
90
+ properties: {
91
+ shape: ['left', 'top', 'width', 'height', 'rotation', 'fillColor', 'fillTransparency', 'lineColor', 'lineTransparency', 'shadow', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'fontName', 'fontSize', 'bold', 'italic', 'color', 'paragraphSpacing'],
92
+ chart: ['chartType', 'left', 'top', 'width', 'height', 'title', 'series', 'axis', 'dataLabels', 'seriesType', 'secondaryAxis', 'trendline', 'errorBars'],
93
+ slide: ['background', 'layout', 'layoutName'],
94
+ placeholder: ['type', 'index'],
95
+ table: ['rows', 'columns', 'values', 'fontName', 'fontSize', 'color', 'headerFillColor', 'headerColor', 'bodyFillColor', 'headerRowHeight', 'bodyRowHeight'],
96
+ template: ['tokens', 'strict'],
97
+ authoring: ['shapeType', 'paragraphs', 'bullet', 'level', 'hyperlink', 'zOrder', 'align', 'distribute', 'group', 'crop', 'theme', 'footer', 'slideNumber'],
98
+ transition: ['effect', 'duration', 'advanceOnTime', 'advanceTime'],
99
+ animation: ['effect', 'trigger', 'duration', 'delay'],
100
+ media: ['kind', 'link', 'embed', 'poster'],
101
+ comment: ['author', 'initials', 'left', 'top'],
102
+ provenance: ['source.document', 'source.target', 'source.label'],
103
+ design: ['profile', 'intent', 'audience', 'tone', 'density', 'palette', 'typography', 'signature', 'content.packageId', 'content.audience', 'content.objective', 'content.decision', 'content.period', 'content.facts', 'content.claims', 'template', 'deck.backgroundMode', 'deck.dominantColorRole', 'deck.motif', 'deck.spacingScale', 'deck.sectionSlides', 'deck.roles', 'deck.requireSlidePlan', 'deck.templateMode', 'review', 'reviewed', 'reviewToken', 'critique'],
104
+ },
105
+ },
106
+ pdf: {
107
+ paths: ['/page[N]', '/field[N]', '/metadata', '/attachments'],
108
+ operations: {
109
+ common: ['add_text', 'watermark', 'stamp_image', 'ocr_pages', 'rotate_pages', 'delete_pages', 'move_page', 'extract_pages', 'fill_form', 'add_form_field', 'flatten_form', 'merge_pdf', 'add_attachment', 'compress', 'set_metadata'],
110
+ office: [],
111
+ portable: [],
112
+ },
113
+ properties: {
114
+ text: ['x', 'y', 'size', 'color', 'opacity', 'rotation'],
115
+ metadata: ['title', 'author', 'subject', 'keywords'],
116
+ form: ['name', 'type', 'page', 'x', 'y', 'width', 'height', 'options', 'value', 'multiline'],
117
+ attachment: ['path', 'name', 'mimeType', 'description'],
118
+ textFont: ['fontPath'],
119
+ unsupportedSecurity: ['secureRedaction', 'digitalSignature', 'PDF/A'],
120
+ },
121
+ },
122
+ csv: TABULAR,
123
+ tsv: TABULAR,
124
+ };
125
+
126
+ const BACKENDS = new Set(['microsoft-office-com', 'mixdog-ooxml', 'mixdog-tabular', 'mixdog-pdf']);
127
+ const VIRTUAL_OPERATIONS = new Set(['compose_document', 'compose_sheet', 'compose_slide']);
128
+
129
+ function signature(required = [], optional = [], {
130
+ oneOf = [],
131
+ propertySets = [],
132
+ notes = '',
133
+ } = {}) {
134
+ return { required, optional, oneOf, propertySets, notes };
135
+ }
136
+
137
+ const COMMON_SIGNATURES = {
138
+ replace_text: signature(['find', 'replace']),
139
+ fill_template: signature(['tokens'], ['strict'], {
140
+ notes: 'Use strict:true to fail when a token is missing or left unresolved.',
141
+ }),
142
+ };
143
+
144
+ const FORMAT_SIGNATURES = {
145
+ docx: {
146
+ compose_document: signature(['title'], ['claimId', 'subtitle', 'summary', 'meta', 'sections', 'footer', 'orientation', 'pageNumbers'], {
147
+ propertySets: ['design'],
148
+ notes: 'Semantic create-time composition. Content is mapped to native Word title, heading, paragraph, list, table, section, and footer operations.',
149
+ }),
150
+ append_text: signature(['text'], ['style', 'properties'], {
151
+ propertySets: ['paragraph', 'font', 'paragraphFormat'],
152
+ notes: 'Creates one real paragraph.',
153
+ }),
154
+ set_paragraph_text: signature(['paragraph', 'text']),
155
+ set_run_text: signature(['paragraph', 'run', 'text']),
156
+ set_table_cell: signature(['table', 'row', 'col', 'text']),
157
+ add_table: signature(['values'], ['paragraph', 'rows', 'columns', 'properties'], { propertySets: ['table'] }),
158
+ set_table_style: signature(['table', 'properties'], [], { propertySets: ['table'] }),
159
+ merge_table_cells: signature(['table', 'row', 'col'], ['rowSpan', 'colSpan']),
160
+ set_table_cell_style: signature(['table', 'row', 'col', 'properties'], [], { propertySets: ['tableCell'] }),
161
+ set_paragraph_format: signature(['paragraph', 'properties'], [], { propertySets: ['paragraphFormat'] }),
162
+ remove_paragraph: signature(['paragraph']),
163
+ move_paragraph: signature(['paragraph', 'index']),
164
+ set_paragraph_style: signature(['paragraph', 'style']),
165
+ set_font: signature(['find', 'properties'], [], { propertySets: ['font'] }),
166
+ add_image: signature(['path'], ['paragraph', 'width', 'height']),
167
+ add_comment: signature(['find', 'text'], ['author', 'initials']),
168
+ add_comment_reply: signature(['comment', 'text'], ['author', 'initials']),
169
+ delete_comment: signature(['comment']),
170
+ set_comment_resolved: signature(['comment', 'resolved']),
171
+ insert_table_row: signature(['table', 'row']),
172
+ delete_table_row: signature(['table', 'row']),
173
+ insert_table_column: signature(['table', 'column']),
174
+ delete_table_column: signature(['table', 'column']),
175
+ set_header_footer: signature(['text'], ['section', 'kind', 'header'], { propertySets: ['headerFooter'] }),
176
+ track_changes: signature(['enabled']),
177
+ resolve_revision: signature(['revision', 'resolution']),
178
+ resolve_revisions: signature(['resolution']),
179
+ set_page: signature(['properties'], ['section'], { propertySets: ['page'] }),
180
+ fit_table: signature(['table']),
181
+ insert_toc: signature([], ['paragraph', 'lowerHeadingLevel', 'upperHeadingLevel']),
182
+ add_page_numbers: signature([], ['section', 'kind', 'prefix', 'separator', 'includeTotal']),
183
+ insert_break: signature([], ['paragraph', 'kind']),
184
+ set_list: signature(['paragraph', 'kind'], ['level']),
185
+ add_hyperlink: signature([], ['find', 'paragraph', 'address', 'subAddress', 'display'], {
186
+ oneOf: [['find'], ['paragraph']],
187
+ propertySets: ['links'],
188
+ }),
189
+ add_bookmark: signature(['name'], ['find', 'paragraph'], { oneOf: [['find'], ['paragraph']] }),
190
+ add_provenance: signature(['paragraph', 'source'], [], { propertySets: ['provenance'] }),
191
+ },
192
+ xlsx: {
193
+ compose_sheet: signature(['rows'], ['claimId', 'sheet', 'kind', 'title', 'subtitle', 'source', 'headers', 'metrics', 'insights', 'columnFormats', 'tableName', 'tableStyle', 'chart'], {
194
+ propertySets: ['design'],
195
+ notes: 'Semantic Excel composition with title hierarchy, native table styling, frozen headers, chart placement, and autofit.',
196
+ }),
197
+ set_cell: signature(['cell', 'value'], ['sheet']),
198
+ set_formula: signature(['cell', 'formula'], ['sheet']),
199
+ set_range: signature(['range', 'values'], ['sheet']),
200
+ append_row: signature(['values'], ['sheet']),
201
+ clear_cell: signature(['cell'], ['sheet']),
202
+ add_sheet: signature(['name']),
203
+ copy_sheet: signature(['sheet'], ['name']),
204
+ delete_sheet: signature(['sheet']),
205
+ rename_sheet: signature(['name'], ['sheet']),
206
+ set_style: signature(['properties'], ['sheet'], {
207
+ oneOf: [['cell'], ['range']],
208
+ propertySets: ['cellStyle'],
209
+ }),
210
+ add_note: signature(['cell', 'text'], ['sheet']),
211
+ delete_note: signature(['cell'], ['sheet']),
212
+ add_image: signature(['path'], ['sheet', 'left', 'top', 'width', 'height']),
213
+ add_table: signature(['range'], ['sheet', 'name', 'style'], { propertySets: ['table'] }),
214
+ add_chart: signature(['range'], ['sheet', 'chartType', 'title', 'left', 'top', 'width', 'height'], {
215
+ propertySets: ['chart'],
216
+ notes: 'The first source column supplies categories; remaining columns become series.',
217
+ }),
218
+ add_conditional_format: signature(['range', 'formula'], ['sheet', 'color', 'fillColor']),
219
+ delete_conditional_formats: signature(['range'], ['sheet']),
220
+ add_validation: signature(['range', 'formula1'], ['sheet', 'inputMessage', 'errorMessage']),
221
+ freeze_panes: signature([], ['sheet', 'row', 'column']),
222
+ add_pivot_table: signature(['source', 'destination'], ['sheet', 'destinationSheet', 'name', 'rows', 'columns', 'values'], { propertySets: ['pivot'] }),
223
+ autofit_range: signature(['range'], ['sheet', 'rows'], {
224
+ notes: 'Accepts cell, whole-column, or whole-row ranges such as A1:D5, A:D, or 2:8.',
225
+ }),
226
+ set_page_setup: signature([], ['sheet', 'printArea', 'orientation', 'fitToPagesWide', 'fitToPagesTall', 'centerHorizontally', 'topMargin', 'bottomMargin', 'leftMargin', 'rightMargin'], {
227
+ propertySets: ['pageSetup'],
228
+ }),
229
+ set_sheet_view: signature([], ['sheet', 'showGridlines', 'zoom'], {
230
+ propertySets: ['sheetView'],
231
+ }),
232
+ set_sheet_visibility: signature(['sheet', 'visibility'], [], {
233
+ notes: 'visibility is visible, hidden, or very_hidden; keep at least one worksheet visible.',
234
+ }),
235
+ insert_rows: signature(['row'], ['sheet', 'count']),
236
+ delete_rows: signature(['row'], ['sheet', 'count']),
237
+ insert_columns: signature(['column'], ['sheet', 'count']),
238
+ delete_columns: signature(['column'], ['sheet', 'count']),
239
+ merge_cells: signature(['range'], ['sheet']),
240
+ unmerge_cells: signature(['range'], ['sheet']),
241
+ set_autofilter: signature(['range'], ['sheet', 'enabled']),
242
+ set_hyperlink: signature(['cell'], ['sheet', 'address', 'subAddress', 'text', 'screenTip'], { propertySets: ['links'] }),
243
+ define_name: signature(['name', 'refersTo']),
244
+ delete_name: signature(['name']),
245
+ protect_sheet: signature([], ['sheet', 'password', 'allowFormattingCells', 'allowSorting', 'allowFiltering'], { propertySets: ['protection'] }),
246
+ unprotect_sheet: signature([], ['sheet', 'password']),
247
+ add_provenance: signature(['cell', 'source'], ['sheet'], { propertySets: ['provenance'] }),
248
+ },
249
+ pptx: {
250
+ compose_slide: signature(['kind'], ['claimId', 'title', 'subtitle', 'takeaway', 'eyebrow', 'body', 'bullets', 'metrics', 'columns', 'steps', 'chart', 'table', 'image', 'imagePath', 'visualText', 'visualLabel', 'meta', 'notes', 'source', 'background', 'backgroundRole', 'slideRole', 'plan', 'create', 'slide', 'layoutId', 'variant', 'titleSize'], {
251
+ propertySets: ['design'],
252
+ notes: 'Template-first semantic slide. Use a declarative title as the takeaway, subject-specific evidence, and source notes for material numbers. Approved sample slides preserve native masters/layouts; deck.templateMode:"strict" rejects scratch fallback. Kinds: cover, statement, content, split, comparison, metrics, process, chart, table, closing.',
253
+ }),
254
+ set_text: signature(['slide', 'shape', 'text']),
255
+ add_textbox: signature(['slide', 'text'], ['paragraphs', 'left', 'top', 'width', 'height', 'fontName', 'fontSize', 'color', 'properties'], { propertySets: ['shape', 'authoring'] }),
256
+ delete_shape: signature(['slide', 'shape']),
257
+ add_slide: signature([], ['index', 'layout']),
258
+ delete_slide: signature(['slide']),
259
+ move_slide: signature(['slide', 'index']),
260
+ duplicate_slide: signature(['slide'], ['index']),
261
+ import_slides: signature(['path'], ['after', 'slides']),
262
+ keep_slides: signature(['slides']),
263
+ set_notes: signature(['slide', 'text']),
264
+ set_footer: signature(['slide', 'text']),
265
+ set_slide_number: signature(['slide', 'visible']),
266
+ add_comment: signature(['slide', 'text'], ['author', 'initials', 'left', 'top'], { propertySets: ['comment'] }),
267
+ delete_comment: signature(['slide', 'comment']),
268
+ add_image: signature(['slide', 'path'], ['left', 'top', 'width', 'height']),
269
+ replace_image: signature(['slide', 'shape', 'path']),
270
+ crop_image: signature(['slide', 'shape'], ['left', 'top', 'right', 'bottom']),
271
+ add_media: signature(['slide', 'path'], ['kind', 'link', 'embed', 'poster', 'left', 'top', 'width', 'height'], { propertySets: ['media', 'shape'] }),
272
+ set_shape: signature(['slide', 'shape', 'properties'], [], { propertySets: ['shape'] }),
273
+ group_shapes: signature(['slide', 'shapes']),
274
+ ungroup_shape: signature(['slide', 'shape']),
275
+ set_slide_background: signature(['slide', 'color']),
276
+ set_layout: signature(['slide', 'layout']),
277
+ apply_theme: signature(['path']),
278
+ set_transition: signature(['slide'], ['effect', 'duration', 'advanceOnTime', 'advanceTime'], { propertySets: ['transition'] }),
279
+ add_animation: signature(['slide', 'shape'], ['effect', 'trigger', 'duration', 'delay'], { propertySets: ['animation'] }),
280
+ add_chart: signature(['slide'], ['chartType', 'title', 'categories', 'series', 'left', 'top', 'width', 'height'], { propertySets: ['chart'] }),
281
+ fit_text: signature(['slide', 'shape'], ['minFontSize', 'allowNoChange']),
282
+ add_shape: signature(['slide', 'shapeType'], ['text', 'paragraphs', 'left', 'top', 'width', 'height', 'fillColor', 'lineColor', 'properties'], { propertySets: ['shape', 'authoring'] }),
283
+ add_table: signature(['slide', 'values'], ['rows', 'columns', 'left', 'top', 'width', 'height', 'properties'], { propertySets: ['table'] }),
284
+ set_table_data: signature(['slide', 'shape', 'values'], [], { propertySets: ['table'] }),
285
+ set_chart_data: signature(['slide', 'shape', 'series'], ['categories', 'title'], { propertySets: ['chart'] }),
286
+ set_chart_series: signature(['slide', 'shape', 'series'], ['name', 'categories', 'values', 'chartType', 'secondaryAxis'], { propertySets: ['chart'] }),
287
+ set_chart_axis: signature(['slide', 'shape', 'axis'], ['title', 'minimum', 'maximum', 'majorUnit', 'numberFormat', 'secondaryAxis'], { propertySets: ['chart'] }),
288
+ set_chart_data_labels: signature(['slide', 'shape'], ['series', 'showValue', 'showCategoryName', 'position', 'numberFormat'], { propertySets: ['chart'] }),
289
+ set_chart_trendline: signature(['slide', 'shape'], ['series', 'type', 'displayEquation', 'displayRSquared'], { propertySets: ['chart'] }),
290
+ set_chart_error_bars: signature(['slide', 'shape'], ['series', 'amount', 'direction', 'endStyle'], { propertySets: ['chart'] }),
291
+ set_hyperlink: signature(['slide', 'shape'], ['address', 'subAddress'], { propertySets: ['authoring'] }),
292
+ z_order: signature(['slide', 'shape', 'command']),
293
+ align_shapes: signature(['slide', 'shapes', 'align'], ['relativeToSlide']),
294
+ distribute_shapes: signature(['slide', 'shapes', 'direction'], ['relativeToSlide']),
295
+ add_provenance: signature(['slide', 'shape', 'source'], [], { propertySets: ['provenance'] }),
296
+ },
297
+ pdf: {
298
+ add_text: signature(['text'], ['page', 'pages', 'x', 'y', 'size', 'color', 'opacity', 'rotation', 'fontPath'], {
299
+ propertySets: ['text', 'textFont'],
300
+ notes: 'Non-Latin text in an existing PDF requires fontPath.',
301
+ }),
302
+ watermark: signature(['text'], ['page', 'pages', 'x', 'y', 'size', 'color', 'opacity', 'rotation', 'fontPath'], {
303
+ propertySets: ['text', 'textFont'],
304
+ notes: 'Non-Latin text requires fontPath.',
305
+ }),
306
+ stamp_image: signature(['path'], ['page', 'pages', 'x', 'y', 'width', 'height', 'opacity']),
307
+ ocr_pages: signature([], ['page', 'pages', 'languages', 'minConfidence', 'maxWidth', 'fontPath']),
308
+ rotate_pages: signature([], ['page', 'pages', 'rotation']),
309
+ delete_pages: signature([], ['page', 'pages']),
310
+ move_page: signature(['page', 'index']),
311
+ extract_pages: signature([], ['page', 'pages']),
312
+ fill_form: signature(['values'], ['flatten']),
313
+ add_form_field: signature(['name', 'type', 'page', 'x', 'y', 'width', 'height'], ['options', 'value', 'multiline'], { propertySets: ['form'] }),
314
+ flatten_form: signature(),
315
+ merge_pdf: signature(['path']),
316
+ add_attachment: signature(['path'], ['name', 'mimeType', 'description'], { propertySets: ['attachment'] }),
317
+ compress: signature(),
318
+ set_metadata: signature(['properties'], [], { propertySets: ['metadata'] }),
319
+ },
320
+ };
321
+
322
+ function rawCatalogOperations(catalog) {
323
+ return [...new Set([
324
+ ...catalog.operations.common,
325
+ ...catalog.operations.office,
326
+ ...catalog.operations.portable,
327
+ ])];
328
+ }
329
+
330
+ function operationBackends(format, catalog, operation) {
331
+ if (format === 'pdf') return ['mixdog-pdf'];
332
+ if (format === 'csv' || format === 'tsv') return ['mixdog-tabular'];
333
+ const backends = [];
334
+ if (catalog.operations.common.includes(operation) || catalog.operations.office.includes(operation)) {
335
+ backends.push('microsoft-office-com');
336
+ }
337
+ if (catalog.operations.common.includes(operation) || catalog.operations.portable.includes(operation)) {
338
+ backends.push('mixdog-ooxml');
339
+ }
340
+ return backends;
341
+ }
342
+
343
+ function explicitOperationSignature(format, operation) {
344
+ const formatSignatures = format === 'csv' || format === 'tsv'
345
+ ? FORMAT_SIGNATURES.xlsx
346
+ : FORMAT_SIGNATURES[format];
347
+ if (Object.hasOwn(formatSignatures || {}, operation)) return formatSignatures[operation];
348
+ if (Object.hasOwn(COMMON_SIGNATURES, operation)) return COMMON_SIGNATURES[operation];
349
+ return null;
350
+ }
351
+
352
+ export const OFFICE_OPERATION_REGISTRY = Object.freeze(Object.fromEntries(
353
+ Object.entries(CATALOG).map(([format, catalog]) => [
354
+ format,
355
+ Object.freeze(Object.fromEntries(rawCatalogOperations(catalog).map((operation) => {
356
+ const input = explicitOperationSignature(format, operation);
357
+ if (!input) throw new Error(`Office operation registry is missing a signature for ${format}.${operation}`);
358
+ return [operation, Object.freeze({
359
+ input,
360
+ supportedBackends: Object.freeze(operationBackends(format, catalog, operation)),
361
+ })];
362
+ }))),
363
+ ]),
364
+ ));
365
+
366
+ function catalogOperations(format) {
367
+ return Object.keys(OFFICE_OPERATION_REGISTRY[format] || {});
368
+ }
369
+
370
+ function operationsForBackend(format, backend) {
371
+ const entries = Object.entries(OFFICE_OPERATION_REGISTRY[format] || {});
372
+ if (!backend) return entries.map(([operation]) => operation);
373
+ return entries
374
+ .filter(([, definition]) => definition.supportedBackends.includes(backend))
375
+ .map(([operation]) => operation);
376
+ }
377
+
378
+ function supportedBackends(format, operation) {
379
+ return [...(OFFICE_OPERATION_REGISTRY[format]?.[operation]?.supportedBackends || [])];
380
+ }
381
+
382
+ function operationSignature(format, operation) {
383
+ return OFFICE_OPERATION_REGISTRY[format]?.[operation]?.input || signature();
384
+ }
385
+
386
+ function editDistance(left, right) {
387
+ const a = String(left);
388
+ const b = String(right);
389
+ const row = Array.from({ length: b.length + 1 }, (_, index) => index);
390
+ for (let i = 1; i <= a.length; i += 1) {
391
+ let diagonal = row[0];
392
+ row[0] = i;
393
+ for (let j = 1; j <= b.length; j += 1) {
394
+ const previous = row[j];
395
+ row[j] = Math.min(
396
+ row[j] + 1,
397
+ row[j - 1] + 1,
398
+ diagonal + (a[i - 1] === b[j - 1] ? 0 : 1),
399
+ );
400
+ diagonal = previous;
401
+ }
402
+ }
403
+ return row[b.length];
404
+ }
405
+
406
+ function operationSuggestions(operation, operations) {
407
+ return [...operations]
408
+ .map((candidate) => ({ candidate, distance: editDistance(operation, candidate) }))
409
+ .sort((left, right) => left.distance - right.distance || left.candidate.localeCompare(right.candidate))
410
+ .slice(0, 3)
411
+ .map(({ candidate }) => candidate);
412
+ }
413
+
414
+ function describeHint(format, backend, operation) {
415
+ return `Call office with ${JSON.stringify({
416
+ action: 'describe',
417
+ format,
418
+ ...(backend ? { backend } : {}),
419
+ operation,
420
+ })}.`;
421
+ }
422
+
423
+ function operationDescription(format, backend, catalog, operation) {
424
+ const knownOperations = catalogOperations(format);
425
+ if (!knownOperations.includes(operation)) {
426
+ const suggestions = operationSuggestions(operation, knownOperations);
427
+ throw new Error(`Unknown ${format.toUpperCase()} operation "${operation}".${suggestions.length ? ` Did you mean: ${suggestions.join(', ')}?` : ''} Call describe with format:"${format}" to list operations.`);
428
+ }
429
+ const available = operationsForBackend(format, backend);
430
+ const signatureValue = operationSignature(format, operation);
431
+ const properties = Object.fromEntries(
432
+ signatureValue.propertySets
433
+ .filter((name) => catalog.properties[name])
434
+ .map((name) => [name, catalog.properties[name]]),
435
+ );
436
+ return {
437
+ name: operation,
438
+ ...(VIRTUAL_OPERATIONS.has(operation) ? { virtual: true } : {}),
439
+ supported: !backend || available.includes(operation),
440
+ supportedBackends: supportedBackends(format, operation),
441
+ input: {
442
+ required: ['op', ...signatureValue.required],
443
+ ...(signatureValue.oneOf.length ? { oneOf: signatureValue.oneOf } : {}),
444
+ optional: [...new Set([...signatureValue.optional, 'allowNoChange'])]
445
+ .filter((field) => !signatureValue.required.includes(field)),
446
+ },
447
+ ...(Object.keys(properties).length ? { properties } : {}),
448
+ ...(signatureValue.notes ? { notes: signatureValue.notes } : {}),
449
+ };
450
+ }
451
+
452
+ export function assertOfficeOperationContracts({ format = '', backend = '', operations = [] } = {}) {
453
+ const catalog = CATALOG[format];
454
+ if (!catalog) throw new Error(`Unsupported Office Use format: ${format}`);
455
+ const available = operationsForBackend(format, backend);
456
+ const known = catalogOperations(format);
457
+ for (let index = 0; index < operations.length; index += 1) {
458
+ const operation = operations[index];
459
+ if (!operation || typeof operation !== 'object' || Array.isArray(operation)) {
460
+ throw new Error(`Office operation ${index + 1} must be an object`);
461
+ }
462
+ const name = String(operation.op || '').trim();
463
+ if (!name) throw new Error(`Office operation ${index + 1} requires op`);
464
+ if (!known.includes(name)) {
465
+ const suggestions = operationSuggestions(name, known);
466
+ throw new Error(`Unknown ${format.toUpperCase()} operation "${name}" at index ${index + 1}.${suggestions.length ? ` Did you mean: ${suggestions.join(', ')}?` : ''} ${describeHint(format, backend, name)}`);
467
+ }
468
+ if (!available.includes(name)) {
469
+ const alternatives = supportedBackends(format, name);
470
+ throw new Error(`${format.toUpperCase()} operation "${name}" is unsupported by ${backend || 'this backend'}.${alternatives.length ? ` Supported backend(s): ${alternatives.join(', ')}.` : ''} ${describeHint(format, backend, name)}`);
471
+ }
472
+ const signatureValue = operationSignature(format, name);
473
+ const allowed = new Set([
474
+ 'op',
475
+ 'allowNoChange',
476
+ ...signatureValue.required,
477
+ ...signatureValue.optional,
478
+ ...signatureValue.oneOf.flat(),
479
+ ]);
480
+ const unknown = Object.keys(operation).filter((field) => !allowed.has(field));
481
+ if (unknown.length) {
482
+ const suggestions = unknown.map((field) => {
483
+ const [candidate] = operationSuggestions(field, allowed);
484
+ return candidate && candidate !== field ? `${field}→${candidate}` : field;
485
+ });
486
+ throw new Error(`${format.toUpperCase()} operation "${name}" at index ${index + 1} has unknown field(s): ${unknown.join(', ')}.${suggestions.length ? ` Did you mean: ${suggestions.join(', ')}?` : ''} ${describeHint(format, backend, name)}`);
487
+ }
488
+ const missing = signatureValue.required.filter((field) => operation[field] === undefined);
489
+ const matchesAlternative = !signatureValue.oneOf.length
490
+ || signatureValue.oneOf.some((alternative) => alternative.every((field) => operation[field] !== undefined));
491
+ if (missing.length || !matchesAlternative) {
492
+ const requirements = [
493
+ ...(missing.length ? [`missing: ${missing.join(', ')}`] : []),
494
+ ...(!matchesAlternative ? [`requires one of: ${signatureValue.oneOf.map((entry) => entry.join('+')).join(' or ')}`] : []),
495
+ ].join('; ');
496
+ throw new Error(`${format.toUpperCase()} operation "${name}" at index ${index + 1} has invalid input (${requirements}). ${describeHint(format, backend, name)}`);
497
+ }
498
+ }
499
+ return operations;
500
+ }
501
+
502
+ export function describeOfficeCapabilities({
503
+ format = '',
504
+ backend = '',
505
+ target = '',
506
+ operation = '',
507
+ } = {}) {
508
+ if (backend && !BACKENDS.has(backend)) throw new Error(`Unsupported Office backend: ${backend}`);
509
+ if (!format) {
510
+ if (operation) throw new Error('describe with operation requires format, path, or session');
511
+ return {
512
+ ...COMMON,
513
+ designs: officeDesignCatalog(),
514
+ formats: Object.fromEntries(Object.entries(CATALOG).map(([name, value]) => [name, {
515
+ paths: value.paths,
516
+ operationCount: catalogOperations(name).length,
517
+ }])),
518
+ nextAction: 'When discovery is needed, add format for its operation list or add operation for one compact input contract; otherwise call create/open/batch directly.',
519
+ };
520
+ }
521
+ const catalog = CATALOG[format];
522
+ if (!catalog) throw new Error(`Unsupported Office Use format: ${format}`);
523
+ const normalizedOperation = String(operation || '').trim();
524
+ if (normalizedOperation) {
525
+ return {
526
+ ...COMMON,
527
+ format,
528
+ backend,
529
+ target: target || '/',
530
+ paths: catalog.paths,
531
+ operation: operationDescription(format, backend, catalog, normalizedOperation),
532
+ designs: officeDesignCatalog(format),
533
+ };
534
+ }
535
+ const operations = operationsForBackend(format, backend);
536
+ const unsupported = backend
537
+ ? catalogOperations(format).filter((name) => !operations.includes(name))
538
+ : [];
539
+ return {
540
+ ...COMMON,
541
+ format,
542
+ backend,
543
+ target: target || '/',
544
+ paths: catalog.paths,
545
+ operations,
546
+ unsupportedInBackend: unsupported,
547
+ properties: catalog.properties,
548
+ designs: officeDesignCatalog(format),
549
+ nextAction: 'If exact fields are unknown, add operation for its compact contract; otherwise call create/open/batch directly.',
550
+ };
551
+ }