mixdog 0.9.159 → 0.9.161

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 (871) hide show
  1. package/LICENSES/MIT.txt +1 -1
  2. package/NOTICE.md +2 -1
  3. package/README.md +3 -1
  4. package/package.json +23 -13
  5. package/scripts/build-tui.mjs +1 -16
  6. package/scripts/lib/local-provider-live-scenarios.mjs +22 -0
  7. package/scripts/lib/test-timing-reporter.mjs +38 -0
  8. package/scripts/local-provider-live-check.mjs +141 -0
  9. package/scripts/office/aesthetics-probe.mjs +59 -0
  10. package/scripts/office/author-deck.mjs +56 -0
  11. package/scripts/office/build-pptx-icons.mjs +48 -0
  12. package/scripts/office-design-audit.mjs +1 -1
  13. package/scripts/office-live-test-plan.mjs +34 -0
  14. package/scripts/pdf-rotation-stress.mjs +74 -0
  15. package/scripts/perf/cold-reconnect-probe.mjs +109 -0
  16. package/scripts/perf/transcript-baseline.mjs +56 -0
  17. package/scripts/perf/transcript-runtime-probe.mjs +62 -0
  18. package/scripts/release-paths.mjs +8 -38
  19. package/scripts/run-advisory-spec.mjs +6 -0
  20. package/scripts/run-office-live-tests.mjs +51 -18
  21. package/scripts/suite-health.mjs +3 -5
  22. package/scripts/test.mjs +100 -0
  23. package/scripts/tui-frame-harness-shim.mjs +1 -1
  24. package/scripts/tui-frame-harness.mjs +7 -2
  25. package/scripts/tui-transcript-jitter-harness.mjs +0 -11
  26. package/src/app.mjs +2 -14
  27. package/src/defaults/cycle3-review-prompt.md +32 -14
  28. package/src/defaults/plugin.json +6 -0
  29. package/src/defaults/skills/browser-use/SKILL.md +159 -0
  30. package/src/defaults/skills/computer-use/SKILL.md +157 -0
  31. package/src/defaults/skills/docx/SKILL.md +52 -0
  32. package/src/defaults/skills/image/SKILL.md +94 -0
  33. package/src/defaults/skills/local-provider/SKILL.md +115 -0
  34. package/src/defaults/skills/pdf/SKILL.md +51 -0
  35. package/src/defaults/skills/pptx/SKILL.md +145 -0
  36. package/src/defaults/skills/pptx/references/charts.md +153 -0
  37. package/src/defaults/skills/pptx/references/composition.md +182 -0
  38. package/src/defaults/skills/pptx/references/direction.md +70 -0
  39. package/src/defaults/skills/pptx/references/kit.md +551 -0
  40. package/src/defaults/skills/pptx/references/pictures.md +76 -0
  41. package/src/defaults/skills/pptx/references/review.md +104 -0
  42. package/src/defaults/skills/pptx/scripts/qc-pages.mjs +368 -0
  43. package/src/defaults/skills/pptx/scripts/review-deck.mjs +155 -0
  44. package/src/defaults/skills/pptx/scripts/source-extract.mjs +121 -0
  45. package/src/defaults/skills/setup/SKILL.md +86 -460
  46. package/src/defaults/skills/setup/references/actions.md +127 -0
  47. package/src/defaults/skills/setup/references/surfaces.md +72 -0
  48. package/src/defaults/skills/skill-creator/SKILL.md +191 -0
  49. package/src/defaults/skills/skill-creator/references/design.md +182 -0
  50. package/src/defaults/skills/skill-creator/references/evaluation.md +111 -0
  51. package/src/defaults/skills/skill-creator/references/source-review.md +94 -0
  52. package/src/defaults/skills/skill-creator/scripts/validate-skill.mjs +166 -0
  53. package/src/defaults/skills/video/SKILL.md +63 -0
  54. package/src/defaults/skills/xlsx/SKILL.md +72 -0
  55. package/src/defaults/skills/xlsx/references/model-conventions.md +52 -0
  56. package/src/headless-exec.mjs +1 -4
  57. package/src/headless-role.mjs +2 -5
  58. package/src/help.mjs +1 -1
  59. package/src/lib/output-style-meta.cjs +5 -1
  60. package/src/lib/rules-builder.cjs +24 -23
  61. package/src/mixdog-session-runtime.mjs +16 -7
  62. package/src/output-styles/extreme-minimal.md +1 -1
  63. package/src/rules/lead/01-general.md +5 -4
  64. package/src/rules/shared/00-general.md +4 -0
  65. package/src/rules/shared/30-exploration.md +2 -1
  66. package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +2 -2
  67. package/src/runtime/agent/orchestrator/agent-runtime/agent-loop-policy.mjs +1 -6
  68. package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +2 -63
  69. package/src/runtime/agent/orchestrator/agent-runtime/completion-text.mjs +13 -0
  70. package/src/runtime/agent/orchestrator/agent-runtime/session-builder.mjs +0 -1
  71. package/src/runtime/agent/orchestrator/agent-runtime/title-completion.mjs +4 -15
  72. package/src/runtime/agent/orchestrator/agent-trace-format.mjs +1 -1
  73. package/src/runtime/agent/orchestrator/agent-trace-io.mjs +1 -2
  74. package/src/runtime/agent/orchestrator/agent-trace.mjs +3 -4
  75. package/src/runtime/agent/orchestrator/cache-break-trace.mjs +1 -1
  76. package/src/runtime/agent/orchestrator/config.mjs +64 -7
  77. package/src/runtime/agent/orchestrator/context/collect.mjs +122 -58
  78. package/src/runtime/agent/orchestrator/dispatch-persist.mjs +1 -1
  79. package/src/runtime/agent/orchestrator/internal-tools.mjs +0 -5
  80. package/src/runtime/agent/orchestrator/mcp/client.mjs +2 -34
  81. package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +5 -16
  82. package/src/runtime/agent/orchestrator/providers/anthropic-betas.mjs +10 -0
  83. package/src/runtime/agent/orchestrator/providers/anthropic-effort.mjs +7 -0
  84. package/src/runtime/agent/orchestrator/providers/anthropic-fable-history.mjs +77 -0
  85. package/src/runtime/agent/orchestrator/providers/anthropic-leaked-toolcall.mjs +1 -1
  86. package/src/runtime/agent/orchestrator/providers/anthropic-max-tokens.mjs +1 -15
  87. package/src/runtime/agent/orchestrator/providers/anthropic-messages.mjs +14 -63
  88. package/src/runtime/agent/orchestrator/providers/anthropic-model-resolve.mjs +5 -5
  89. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +111 -0
  90. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-credentials.mjs +5 -146
  91. package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +124 -45
  92. package/src/runtime/agent/orchestrator/providers/anthropic-thinking-contract.mjs +13 -0
  93. package/src/runtime/agent/orchestrator/providers/anthropic.mjs +50 -42
  94. package/src/runtime/agent/orchestrator/providers/antigravity-oauth-login.mjs +5 -22
  95. package/src/runtime/agent/orchestrator/providers/antigravity-oauth-tokens.mjs +7 -10
  96. package/src/runtime/agent/orchestrator/providers/antigravity-oauth.mjs +2 -85
  97. package/src/runtime/agent/orchestrator/providers/antigravity-request.mjs +91 -0
  98. package/src/runtime/agent/orchestrator/providers/api-usage.mjs +4 -19
  99. package/src/runtime/agent/orchestrator/providers/compat-request-policy.mjs +21 -0
  100. package/src/runtime/agent/orchestrator/providers/cursor-auth.mjs +1 -1
  101. package/src/runtime/agent/orchestrator/providers/cursor-wire-guards.mjs +63 -6
  102. package/src/runtime/agent/orchestrator/providers/cursor-wire-normalization.mjs +12 -7
  103. package/src/runtime/agent/orchestrator/providers/cursor-wire.mjs +27 -7
  104. package/src/runtime/agent/orchestrator/providers/cursor.mjs +16 -10
  105. package/src/runtime/agent/orchestrator/providers/effort-configuration.mjs +150 -0
  106. package/src/runtime/agent/orchestrator/providers/gemini-cache.mjs +1 -1
  107. package/src/runtime/agent/orchestrator/providers/gemini-history-signatures.mjs +29 -0
  108. package/src/runtime/agent/orchestrator/providers/gemini-schema.mjs +5 -4
  109. package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +5 -6
  110. package/src/runtime/agent/orchestrator/providers/gemini-thinking.mjs +48 -0
  111. package/src/runtime/agent/orchestrator/providers/gemini.mjs +23 -26
  112. package/src/runtime/agent/orchestrator/providers/grok-oauth-login.mjs +5 -36
  113. package/src/runtime/agent/orchestrator/providers/grok-oauth-tokens.mjs +19 -38
  114. package/src/runtime/agent/orchestrator/providers/grok-oauth.mjs +1 -7
  115. package/src/runtime/agent/orchestrator/providers/lib/anthropic-image-input.mjs +105 -0
  116. package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +50 -94
  117. package/src/runtime/agent/orchestrator/providers/lib/json-memory-cache.mjs +27 -0
  118. package/src/runtime/agent/orchestrator/providers/lib/oauth-pkce.mjs +27 -0
  119. package/src/runtime/agent/orchestrator/providers/lib/oauth-token-utils.mjs +29 -0
  120. package/src/runtime/agent/orchestrator/providers/lib/provider-replay.mjs +9 -6
  121. package/src/runtime/agent/orchestrator/providers/lib/wire-pairing.mjs +143 -0
  122. package/src/runtime/agent/orchestrator/providers/mixdog-local-wire.mjs +25 -0
  123. package/src/runtime/agent/orchestrator/providers/mixdog-local.mjs +79 -0
  124. package/src/runtime/agent/orchestrator/providers/model-catalog-projection.mjs +8 -0
  125. package/src/runtime/agent/orchestrator/providers/model-catalog.mjs +18 -1
  126. package/src/runtime/agent/orchestrator/providers/model-list-sanitize.mjs +2 -2
  127. package/src/runtime/agent/orchestrator/providers/model-service-tiers.mjs +11 -0
  128. package/src/runtime/agent/orchestrator/providers/oauth-usage.mjs +1 -1
  129. package/src/runtime/agent/orchestrator/providers/openai-compat-presets.mjs +0 -8
  130. package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +205 -0
  131. package/src/runtime/agent/orchestrator/providers/openai-compat-stream.mjs +5 -3
  132. package/src/runtime/agent/orchestrator/providers/openai-compat-wire.mjs +17 -14
  133. package/src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs +1 -1
  134. package/src/runtime/agent/orchestrator/providers/openai-compat.mjs +22 -25
  135. package/src/runtime/agent/orchestrator/providers/openai-direct-request.mjs +18 -0
  136. package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +2 -15
  137. package/src/runtime/agent/orchestrator/providers/openai-oauth-login.mjs +4 -29
  138. package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +3 -4
  139. package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +48 -84
  140. package/src/runtime/agent/orchestrator/providers/openai-responses-input.mjs +152 -0
  141. package/src/runtime/agent/orchestrator/providers/openai-responses-payload.mjs +15 -243
  142. package/src/runtime/agent/orchestrator/providers/openai-ws-headers.mjs +1 -36
  143. package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +2 -3
  144. package/src/runtime/agent/orchestrator/providers/openai-ws.mjs +6 -38
  145. package/src/runtime/agent/orchestrator/providers/opencode-go-usage.mjs +7 -20
  146. package/src/runtime/agent/orchestrator/providers/opencode-go.mjs +44 -19
  147. package/src/runtime/agent/orchestrator/providers/registry.mjs +15 -0
  148. package/src/runtime/agent/orchestrator/providers/retry-classifier.mjs +44 -5
  149. package/src/runtime/agent/orchestrator/providers/statusline-route-meta.mjs +0 -5
  150. package/src/runtime/agent/orchestrator/providers/stream-json-pool.mjs +2 -6
  151. package/src/runtime/agent/orchestrator/session/agent-loop.mjs +41 -57
  152. package/src/runtime/agent/orchestrator/session/cache/scoped-cache.mjs +38 -11
  153. package/src/runtime/agent/orchestrator/session/cache/util.mjs +3 -3
  154. package/src/runtime/agent/orchestrator/session/compact/budget.mjs +1 -112
  155. package/src/runtime/agent/orchestrator/session/compact/messages.mjs +1 -1
  156. package/src/runtime/agent/orchestrator/session/compact/runner.mjs +7 -2
  157. package/src/runtime/agent/orchestrator/session/compact/summary.mjs +3 -5
  158. package/src/runtime/agent/orchestrator/session/compact/text-utils.mjs +0 -12
  159. package/src/runtime/agent/orchestrator/session/context-compaction-policy.mjs +18 -23
  160. package/src/runtime/agent/orchestrator/session/context-fingerprint.mjs +54 -0
  161. package/src/runtime/agent/orchestrator/session/context-utils.mjs +9 -58
  162. package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +4 -5
  163. package/src/runtime/agent/orchestrator/session/evidence-union.mjs +3 -7
  164. package/src/runtime/agent/orchestrator/session/image-strip-recovery.mjs +1 -8
  165. package/src/runtime/agent/orchestrator/session/loop/arg-schema-coerce.mjs +92 -0
  166. package/src/runtime/agent/orchestrator/session/loop/compact-debug.mjs +2 -10
  167. package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +38 -63
  168. package/src/runtime/agent/orchestrator/session/loop/fresh-context.mjs +14 -14
  169. package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +1 -1
  170. package/src/runtime/agent/orchestrator/session/loop/steering.mjs +17 -0
  171. package/src/runtime/agent/orchestrator/session/loop/tool-classify.mjs +5 -2
  172. package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +6 -1
  173. package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +7 -2
  174. package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +87 -38
  175. package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +12 -14
  176. package/src/runtime/agent/orchestrator/session/manager/context-meta.mjs +30 -33
  177. package/src/runtime/agent/orchestrator/session/manager/foreign-pending-messages.mjs +355 -0
  178. package/src/runtime/agent/orchestrator/session/manager/idle-cleanup.mjs +6 -6
  179. package/src/runtime/agent/orchestrator/session/manager/message-sanitize.mjs +1 -1
  180. package/src/runtime/agent/orchestrator/session/manager/pending-message-entry.mjs +324 -0
  181. package/src/runtime/agent/orchestrator/session/manager/pending-messages.mjs +62 -688
  182. package/src/runtime/agent/orchestrator/session/manager/prompt-surface-publish.mjs +35 -0
  183. package/src/runtime/agent/orchestrator/session/manager/prompt-utils.mjs +15 -2
  184. package/src/runtime/agent/orchestrator/session/manager/rules-cache.mjs +38 -79
  185. package/src/runtime/agent/orchestrator/session/manager/rules-source-cache.mjs +61 -0
  186. package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +1 -1
  187. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +44 -14
  188. package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +9 -4
  189. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.mjs +3 -3
  190. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +2 -28
  191. package/src/runtime/agent/orchestrator/session/manager.mjs +1 -0
  192. package/src/runtime/agent/orchestrator/session/provider-prefix-guard.mjs +1 -1
  193. package/src/runtime/agent/orchestrator/session/result-classification.mjs +0 -67
  194. package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +5 -0
  195. package/src/runtime/agent/orchestrator/session/store/canonical-reader.mjs +62 -0
  196. package/src/runtime/agent/orchestrator/session/store/fs-probe.mjs +1 -20
  197. package/src/runtime/agent/orchestrator/session/store/listing.mjs +60 -9
  198. package/src/runtime/agent/orchestrator/session/store/load-cache.mjs +0 -19
  199. package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +0 -11
  200. package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +117 -134
  201. package/src/runtime/agent/orchestrator/session/store-summary-visibility.mjs +4 -4
  202. package/src/runtime/agent/orchestrator/session/store-transcript-cache.mjs +131 -0
  203. package/src/runtime/agent/orchestrator/session/store.mjs +20 -46
  204. package/src/runtime/agent/orchestrator/session/synthetic-user-envelope.mjs +133 -0
  205. package/src/runtime/agent/orchestrator/session/thinking-replay-recovery.mjs +1 -4
  206. package/src/runtime/agent/orchestrator/session/token-estimate-floors.mjs +34 -0
  207. package/src/runtime/agent/orchestrator/session/token-estimate.mjs +3 -36
  208. package/src/runtime/agent/orchestrator/session/tool-batch.mjs +4 -0
  209. package/src/runtime/agent/orchestrator/session/tool-result-offload.mjs +5 -5
  210. package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +1 -7
  211. package/src/runtime/agent/orchestrator/tools/builtin/atomic-write.mjs +2 -1
  212. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +1 -1
  213. package/src/runtime/agent/orchestrator/tools/builtin/binary-file.mjs +0 -25
  214. package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +7 -5
  215. package/src/runtime/agent/orchestrator/tools/builtin/cache-layers.mjs +2 -7
  216. package/src/runtime/agent/orchestrator/tools/builtin/git-partial-stage.mjs +1 -5
  217. package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-context-expander.mjs +19 -0
  218. package/src/runtime/agent/orchestrator/tools/builtin/lib/search-input-helpers.mjs +1 -2
  219. package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.mjs +1 -1
  220. package/src/runtime/agent/orchestrator/tools/builtin/list-tool.mjs +26 -2
  221. package/src/runtime/agent/orchestrator/tools/builtin/local-search-telemetry.mjs +0 -9
  222. package/src/runtime/agent/orchestrator/tools/builtin/native-search-client.mjs +0 -20
  223. package/src/runtime/agent/orchestrator/tools/builtin/read-formatting.mjs +0 -6
  224. package/src/runtime/agent/orchestrator/tools/builtin/read-image-resize.mjs +7 -16
  225. package/src/runtime/agent/orchestrator/tools/builtin/read-open.mjs +1 -14
  226. package/src/runtime/agent/orchestrator/tools/builtin/read-range-index.mjs +1 -1
  227. package/src/runtime/agent/orchestrator/tools/builtin/read-single-tool.mjs +5 -22
  228. package/src/runtime/agent/orchestrator/tools/builtin/read-tool.mjs +0 -1
  229. package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs +1 -1
  230. package/src/runtime/agent/orchestrator/tools/builtin/search-admission.mjs +1 -1
  231. package/src/runtime/agent/orchestrator/tools/builtin/search-glob-tool.mjs +17 -75
  232. package/src/runtime/agent/orchestrator/tools/builtin/search-grep-tool.mjs +3 -19
  233. package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +4 -57
  234. package/src/runtime/agent/orchestrator/tools/builtin/shell-lossless-compact.mjs +0 -12
  235. package/src/runtime/agent/orchestrator/tools/builtin/shell-output.mjs +1 -1
  236. package/src/runtime/agent/orchestrator/tools/builtin/shell-runtime.mjs +1 -1
  237. package/src/runtime/agent/orchestrator/tools/builtin/snapshot-helpers.mjs +1 -7
  238. package/src/runtime/agent/orchestrator/tools/builtin/snapshot-store.mjs +3 -25
  239. package/src/runtime/agent/orchestrator/tools/builtin.mjs +9 -7
  240. package/src/runtime/agent/orchestrator/tools/code-graph/aggregate-roots.mjs +276 -0
  241. package/src/runtime/agent/orchestrator/tools/code-graph/build.mjs +38 -16
  242. package/src/runtime/agent/orchestrator/tools/code-graph/disk-cache.mjs +11 -3
  243. package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +23 -355
  244. package/src/runtime/agent/orchestrator/tools/code-graph/exact-file-graph.mjs +92 -0
  245. package/src/runtime/agent/orchestrator/tools/code-graph/graph-binary.mjs +1 -2
  246. package/src/runtime/agent/orchestrator/tools/code-graph/search-references.mjs +1 -11
  247. package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +2 -4
  248. package/src/runtime/agent/orchestrator/tools/code-graph/symbol-index.mjs +8 -0
  249. package/src/runtime/agent/orchestrator/tools/code-graph-tool-defs.mjs +1 -1
  250. package/src/runtime/agent/orchestrator/tools/graph-binary-fetcher.mjs +51 -124
  251. package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.mjs +2 -68
  252. package/src/runtime/agent/orchestrator/tools/lib/shell-warm-standby.mjs +1 -10
  253. package/src/runtime/agent/orchestrator/tools/patch/dispatch.mjs +0 -1
  254. package/src/runtime/agent/orchestrator/tools/patch/matcher.mjs +1 -2
  255. package/src/runtime/agent/orchestrator/tools/patch/native-server.mjs +2 -1
  256. package/src/runtime/agent/orchestrator/tools/patch/orchestrator.mjs +1 -1
  257. package/src/runtime/agent/orchestrator/tools/patch/v4a-convert.mjs +2 -14
  258. package/src/runtime/agent/orchestrator/tools/patch-binary-fetcher.mjs +57 -138
  259. package/src/runtime/agent/orchestrator/tools/progress-message.mjs +4 -0
  260. package/src/runtime/agent/orchestrator/tools/shell-command.mjs +2 -2
  261. package/src/runtime/agent/orchestrator/tools/shell-exec-output.mjs +4 -8
  262. package/src/runtime/agent/orchestrator/tools/spawn-binary-fetcher.mjs +45 -122
  263. package/src/runtime/attachments/pdf-extract.mjs +14 -6
  264. package/src/runtime/attachments/pdfjs-runtime.mjs +12 -0
  265. package/src/runtime/attachments/store.mjs +8 -8
  266. package/src/runtime/bridge-discovery.mjs +67 -0
  267. package/src/runtime/browser-bridge/action-schema.d.mts +6 -0
  268. package/src/runtime/browser-bridge/action-schema.mjs +9 -3
  269. package/src/runtime/browser-bridge/client.mjs +18 -31
  270. package/src/runtime/browser-bridge/tool-defs.mjs +16 -7
  271. package/src/runtime/channels/lib/boot-profile.mjs +3 -16
  272. package/src/runtime/channels/lib/config.mjs +0 -1
  273. package/src/runtime/channels/lib/runtime-paths.mjs +2 -15
  274. package/src/runtime/channels/lib/scheduler.mjs +0 -15
  275. package/src/runtime/channels/lib/voice-runtime-fetcher.mjs +7 -59
  276. package/src/runtime/channels/lib/worker-main.mjs +2 -30
  277. package/src/runtime/computer-bridge/action-schema.mjs +7 -5
  278. package/src/runtime/computer-bridge/actions.d.mts +6 -0
  279. package/src/runtime/computer-bridge/actions.mjs +75 -0
  280. package/src/runtime/computer-bridge/client.mjs +21 -39
  281. package/src/runtime/computer-bridge/core-actions.mjs +2 -3
  282. package/src/runtime/computer-bridge/error-recovery.mjs +15 -3
  283. package/src/runtime/computer-bridge/limits.d.mts +8 -0
  284. package/src/runtime/computer-bridge/limits.mjs +67 -0
  285. package/src/runtime/computer-bridge/tool-defs.mjs +10 -16
  286. package/src/runtime/github/client.d.mts +17 -0
  287. package/src/runtime/github/client.mjs +127 -0
  288. package/src/runtime/github/commands.mjs +106 -0
  289. package/src/runtime/github/contract.d.mts +58 -0
  290. package/src/runtime/github/contract.mjs +147 -0
  291. package/src/runtime/github/tool.mjs +64 -0
  292. package/src/runtime/local-provider/asset-installer.mjs +261 -0
  293. package/src/runtime/local-provider/asset-storage.mjs +36 -0
  294. package/src/runtime/local-provider/catalog.mjs +151 -0
  295. package/src/runtime/local-provider/data/manifest.json +48 -0
  296. package/src/runtime/local-provider/gguf-header.mjs +92 -0
  297. package/src/runtime/local-provider/hardware.mjs +83 -0
  298. package/src/runtime/local-provider/hugging-face.mjs +111 -0
  299. package/src/runtime/local-provider/input-capabilities.mjs +19 -0
  300. package/src/runtime/local-provider/install-progress.mjs +77 -0
  301. package/src/runtime/local-provider/managed-runtime.mjs +45 -0
  302. package/src/runtime/local-provider/model-maintenance.mjs +114 -0
  303. package/src/runtime/local-provider/model-state.mjs +53 -0
  304. package/src/runtime/local-provider/registered-models.mjs +67 -0
  305. package/src/runtime/local-provider/request-queue.mjs +125 -0
  306. package/src/runtime/local-provider/resumable-installations.mjs +27 -0
  307. package/src/runtime/local-provider/server-process.mjs +209 -0
  308. package/src/runtime/local-provider/server.mjs +99 -0
  309. package/src/runtime/media/download.mjs +1 -1
  310. package/src/runtime/media/lanes.mjs +1 -1
  311. package/src/runtime/media/renditions.mjs +1 -1
  312. package/src/runtime/media/store.mjs +1 -1
  313. package/src/runtime/media/tool-defs.mjs +40 -0
  314. package/src/runtime/media/tool.mjs +277 -0
  315. package/src/runtime/memory/index.mjs +11 -29
  316. package/src/runtime/memory/lib/core-memory-candidates.mjs +0 -5
  317. package/src/runtime/memory/lib/core-memory-file.mjs +2 -2
  318. package/src/runtime/memory/lib/core-memory-store.mjs +37 -8
  319. package/src/runtime/memory/lib/cycle-scheduler.mjs +16 -2
  320. package/src/runtime/memory/lib/embedding-model-config.mjs +2 -4
  321. package/src/runtime/memory/lib/embedding-reindex.mjs +2 -4
  322. package/src/runtime/memory/lib/http-router.mjs +13 -1
  323. package/src/runtime/memory/lib/http-wire.mjs +1 -1
  324. package/src/runtime/memory/lib/memory-action-handlers.mjs +4 -1
  325. package/src/runtime/memory/lib/memory-config-flags.mjs +8 -12
  326. package/src/runtime/memory/lib/memory-cycle-requests.mjs +0 -40
  327. package/src/runtime/memory/lib/memory-cycle1.mjs +1 -5
  328. package/src/runtime/memory/lib/memory-cycle2-gate.mjs +30 -9
  329. package/src/runtime/memory/lib/memory-cycle2-mutations.mjs +35 -4
  330. package/src/runtime/memory/lib/memory-cycle2.mjs +1 -1
  331. package/src/runtime/memory/lib/memory-cycle3-evidence.mjs +117 -0
  332. package/src/runtime/memory/lib/memory-cycle3-guards.mjs +272 -0
  333. package/src/runtime/memory/lib/memory-cycle3.mjs +81 -238
  334. package/src/runtime/memory/lib/memory-embed.mjs +1 -4
  335. package/src/runtime/memory/lib/memory-score.mjs +0 -13
  336. package/src/runtime/memory/lib/memory-text-utils.mjs +7 -1
  337. package/src/runtime/memory/lib/pg/adapter.mjs +2 -2
  338. package/src/runtime/memory/lib/phase-merge-verdicts.mjs +54 -0
  339. package/src/runtime/memory/lib/prompt-surface-file.mjs +98 -0
  340. package/src/runtime/memory/lib/query-handlers.mjs +4 -1
  341. package/src/runtime/memory/lib/recall-embedding-readiness.mjs +1 -1
  342. package/src/runtime/memory/lib/recall-format.mjs +15 -7
  343. package/src/runtime/memory/lib/recall-order.mjs +6 -0
  344. package/src/runtime/memory/lib/runtime-fetcher.mjs +25 -52
  345. package/src/runtime/memory/lib/session-ingest.mjs +3 -3
  346. package/src/runtime/memory/lib/trace-mode.mjs +1 -1
  347. package/src/runtime/memory/lib/trace-store.mjs +1 -10
  348. package/src/runtime/memory/lib/transcript-ingest.mjs +2 -2
  349. package/src/runtime/office/README.md +54 -0
  350. package/src/runtime/office/authoring/pptx-author-action.mjs +166 -0
  351. package/src/runtime/office/authoring/pptx-author-session.mjs +112 -0
  352. package/src/runtime/office/authoring/pptx-brief.mjs +270 -0
  353. package/src/runtime/office/authoring/pptx-contact-sheet.mjs +54 -0
  354. package/src/runtime/office/authoring/pptx-icons.json +1 -0
  355. package/src/runtime/office/authoring/pptx-icons.mjs +50 -0
  356. package/src/runtime/office/authoring/pptx-kit.mjs +33 -0
  357. package/src/runtime/office/authoring/pptx-receipt.mjs +388 -0
  358. package/src/runtime/office/authoring/pptx-review-artifacts.mjs +32 -0
  359. package/src/runtime/office/authoring/pptx-script-contract.mjs +15 -0
  360. package/src/runtime/office/authoring/pptx-script-normalize.mjs +244 -0
  361. package/src/runtime/office/authoring/pptx-script-runner.mjs +142 -0
  362. package/src/runtime/office/{assurance-benchmark.mjs → bench/assurance-benchmark.mjs} +8 -98
  363. package/src/runtime/office/bench/bench-support.mjs +18 -0
  364. package/src/runtime/office/{benchmark.mjs → bench/benchmark.mjs} +6 -11
  365. package/src/runtime/office/{contract-benchmark.mjs → bench/contract-benchmark.mjs} +4 -9
  366. package/src/runtime/office/bench/deck-bench.mjs +78 -0
  367. package/src/runtime/office/{polish-benchmark.mjs → bench/polish-benchmark.mjs} +2 -7
  368. package/src/runtime/office/{quality-live-benchmark.mjs → bench/quality-live-benchmark.mjs} +5 -260
  369. package/src/runtime/office/capabilities.mjs +105 -45
  370. package/src/runtime/office/{com-adapter.mjs → com/com-adapter.mjs} +58 -53
  371. package/src/runtime/office/com/office-com-cleanup.ps1 +126 -0
  372. package/src/runtime/office/{office-com-host.ps1 → com/office-com-host.ps1} +427 -90
  373. package/src/runtime/office/{office-com-session-host.ps1 → com/office-com-session-host.ps1} +117 -90
  374. package/src/runtime/office/com/office-session-client.mjs +91 -0
  375. package/src/runtime/office/{journal.mjs → core/journal.mjs} +1 -1
  376. package/src/runtime/office/core/office-actions-batch.mjs +348 -0
  377. package/src/runtime/office/core/office-actions-inspect.mjs +157 -0
  378. package/src/runtime/office/core/office-actions-lifecycle.mjs +253 -0
  379. package/src/runtime/office/core/office-actions-render.mjs +307 -0
  380. package/src/runtime/office/core/office-actions.mjs +6 -0
  381. package/src/runtime/office/{office-core.mjs → core/office-core.mjs} +26 -5
  382. package/src/runtime/office/core/office-render-preview.mjs +160 -0
  383. package/src/runtime/office/{office-sessions.mjs → core/office-sessions.mjs} +141 -9
  384. package/src/runtime/office/{office-transactions.mjs → core/office-transactions.mjs} +2 -1
  385. package/src/runtime/office/core/pptx-page-cache.mjs +70 -0
  386. package/src/runtime/office/{snapshot-contract.mjs → core/snapshot-contract.mjs} +28 -0
  387. package/src/runtime/office/{tabular.mjs → core/tabular.mjs} +2 -12
  388. package/src/runtime/office/{composition-system.mjs → design/composition-system.mjs} +2 -11
  389. package/src/runtime/office/{content-model.mjs → design/content-model.mjs} +1 -14
  390. package/src/runtime/office/{design-art-direction.mjs → design/design-art-direction.mjs} +51 -65
  391. package/src/runtime/office/{design-creative-director.mjs → design/design-creative-director.mjs} +7 -25
  392. package/src/runtime/office/design/design-discipline.mjs +310 -0
  393. package/src/runtime/office/{design-system.mjs → design/design-system.mjs} +14 -102
  394. package/src/runtime/office/{design-tokens.mjs → design/design-tokens.mjs} +33 -47
  395. package/src/runtime/office/{design-docx.mjs → design/docx/design-docx.mjs} +2 -1
  396. package/src/runtime/office/{design-library-core.mjs → design/library/design-library-core.mjs} +8 -34
  397. package/src/runtime/office/{design-library-pack.mjs → design/library/design-library-pack.mjs} +16 -1
  398. package/src/runtime/office/{design-library.mjs → design/library/design-library.mjs} +15 -2
  399. package/src/runtime/office/{design-template-index.mjs → design/library/design-template-index.mjs} +24 -2
  400. package/src/runtime/office/{design-template-inspect.mjs → design/library/design-template-inspect.mjs} +1 -12
  401. package/src/runtime/office/{design-xlsx-components.mjs → design/xlsx/design-xlsx-components.mjs} +2 -1
  402. package/src/runtime/office/{design-xlsx.mjs → design/xlsx/design-xlsx.mjs} +3 -1
  403. package/src/runtime/office/index.mjs +99 -30
  404. package/src/runtime/office/office-test-support.mjs +66 -0
  405. package/src/runtime/office/{document-preview.mjs → pdf/document-preview.mjs} +1 -1
  406. package/src/runtime/office/pdf/pdf-adapter.mjs +824 -0
  407. package/src/runtime/office/pdf/pdf-analysis.mjs +733 -0
  408. package/src/runtime/office/pdf/pdf-draw.mjs +91 -0
  409. package/src/runtime/office/pdf/pdf-fonts.mjs +91 -0
  410. package/src/runtime/office/pdf/pdf-forms.mjs +265 -0
  411. package/src/runtime/office/{pdf-render.mjs → pdf/pdf-render.mjs} +42 -36
  412. package/src/runtime/office/pdf/pdf-safety.mjs +50 -0
  413. package/src/runtime/office/pdf/pdf-search.mjs +187 -0
  414. package/src/runtime/office/{pdf-security.mjs → pdf/pdf-security.mjs} +7 -3
  415. package/src/runtime/office/pdf/pdf-writer.mjs +195 -0
  416. package/src/runtime/office/portable/docx-revisions.mjs +474 -0
  417. package/src/runtime/office/portable/docx-runs.mjs +293 -0
  418. package/src/runtime/office/portable/docx-tracked-edits.mjs +165 -0
  419. package/src/runtime/office/portable/font-provisioner.mjs +210 -0
  420. package/src/runtime/office/{ooxml-validator.mjs → portable/ooxml-validator.mjs} +26 -3
  421. package/src/runtime/office/{portable-cells.mjs → portable/portable-cells.mjs} +12 -3
  422. package/src/runtime/office/portable/portable-chart-faults.mjs +96 -0
  423. package/src/runtime/office/{portable-chart.mjs → portable/portable-chart.mjs} +21 -19
  424. package/src/runtime/office/{portable-docx-parts.mjs → portable/portable-docx-parts.mjs} +97 -0
  425. package/src/runtime/office/{portable-docx-xml.mjs → portable/portable-docx-xml.mjs} +2 -2
  426. package/src/runtime/office/{portable-docx.mjs → portable/portable-docx.mjs} +211 -36
  427. package/src/runtime/office/{portable-opc.mjs → portable/portable-opc.mjs} +11 -3
  428. package/src/runtime/office/{portable-package.mjs → portable/portable-package.mjs} +7 -25
  429. package/src/runtime/office/{portable-pivot.mjs → portable/portable-pivot.mjs} +1 -1
  430. package/src/runtime/office/{portable-pptx-chart.mjs → portable/portable-pptx-chart.mjs} +4 -2
  431. package/src/runtime/office/{portable-pptx-charts.mjs → portable/portable-pptx-charts.mjs} +5 -19
  432. package/src/runtime/office/{portable-pptx-core.mjs → portable/portable-pptx-core.mjs} +14 -3
  433. package/src/runtime/office/{portable-pptx-package.mjs → portable/portable-pptx-package.mjs} +62 -5
  434. package/src/runtime/office/{portable-pptx-shapes.mjs → portable/portable-pptx-shapes.mjs} +1 -1
  435. package/src/runtime/office/{portable-pptx.mjs → portable/portable-pptx.mjs} +11 -2
  436. package/src/runtime/office/{portable-sheet-styles.mjs → portable/portable-sheet-styles.mjs} +74 -11
  437. package/src/runtime/office/{portable-slide-shapes.mjs → portable/portable-slide-shapes.mjs} +8 -15
  438. package/src/runtime/office/{portable-snapshot.mjs → portable/portable-snapshot.mjs} +254 -27
  439. package/src/runtime/office/{portable-soffice.mjs → portable/portable-soffice.mjs} +45 -1
  440. package/src/runtime/office/{portable-validation.mjs → portable/portable-validation.mjs} +73 -34
  441. package/src/runtime/office/{portable-xlsx.mjs → portable/portable-xlsx.mjs} +3 -1
  442. package/src/runtime/office/{portable-xml.mjs → portable/portable-xml.mjs} +20 -0
  443. package/src/runtime/office/portable/pptx-relations.mjs +92 -0
  444. package/src/runtime/office/portable/pptx-targets.mjs +30 -0
  445. package/src/runtime/office/portable/review-editability.mjs +111 -0
  446. package/src/runtime/office/{text-metrics.mjs → portable/text-metrics.mjs} +232 -28
  447. package/src/runtime/office/{xlsx-assertions.mjs → portable/xlsx-assertions.mjs} +5 -21
  448. package/src/runtime/office/portable/xlsx-audit-support.mjs +132 -0
  449. package/src/runtime/office/{xlsx-contract.mjs → portable/xlsx-contract.mjs} +50 -12
  450. package/src/runtime/office/portable/xlsx-conventions.mjs +75 -0
  451. package/src/runtime/office/portable/xlsx-formula-audit.mjs +247 -0
  452. package/src/runtime/office/portable/xlsx-sheet-hygiene.mjs +100 -0
  453. package/src/runtime/office/quality/assurance-checklist.mjs +185 -0
  454. package/src/runtime/office/quality/assurance-rendered.mjs +167 -0
  455. package/src/runtime/office/quality/assurance-structure.mjs +440 -0
  456. package/src/runtime/office/quality/assurance-trust.mjs +246 -0
  457. package/src/runtime/office/quality/assurance.mjs +11 -0
  458. package/src/runtime/office/quality/design-aesthetics-metrics.mjs +271 -0
  459. package/src/runtime/office/quality/design-aesthetics.mjs +285 -0
  460. package/src/runtime/office/{design-deck-diversity.mjs → quality/design-deck-diversity.mjs} +31 -1
  461. package/src/runtime/office/quality/design-review-authored.mjs +113 -0
  462. package/src/runtime/office/quality/design-review-critique.mjs +120 -0
  463. package/src/runtime/office/{design-review.mjs → quality/design-review.mjs} +167 -123
  464. package/src/runtime/office/quality/inline-audit.mjs +139 -0
  465. package/src/runtime/office/quality/pptx-deck-rubric.mjs +93 -0
  466. package/src/runtime/office/quality/pptx-slide-roles.mjs +136 -0
  467. package/src/runtime/office/quality/quality-pipeline.mjs +280 -0
  468. package/src/runtime/office/{quality-score.mjs → quality/quality-score.mjs} +2 -4
  469. package/src/runtime/office/quality/render-air.mjs +114 -0
  470. package/src/runtime/office/shared/asar-path.mjs +5 -0
  471. package/src/runtime/office/shared/values.mjs +32 -0
  472. package/src/runtime/office/tool-defs.mjs +35 -29
  473. package/src/runtime/shared/agent-route-config.mjs +3 -3
  474. package/src/runtime/shared/atomic-file.mjs +27 -20
  475. package/src/runtime/shared/background-tasks.mjs +2 -37
  476. package/src/runtime/shared/boot-profile.mjs +26 -0
  477. package/src/runtime/shared/bounded-download.mjs +40 -0
  478. package/src/runtime/shared/bridge-tool-args.mjs +1 -1
  479. package/src/runtime/shared/buffered-appender.mjs +1 -1
  480. package/src/runtime/shared/child-guardian.mjs +1 -5
  481. package/src/runtime/shared/child-spawn-gate.mjs +2 -2
  482. package/src/runtime/shared/clean.mjs +5 -0
  483. package/src/runtime/shared/config.mjs +8 -30
  484. package/src/runtime/shared/edit-tool-dialect.mjs +19 -6
  485. package/src/runtime/shared/env.mjs +41 -0
  486. package/src/runtime/shared/err-text.mjs +15 -5
  487. package/src/runtime/shared/error-presentation.mjs +101 -0
  488. package/src/runtime/shared/extension-scopes.mjs +139 -0
  489. package/src/runtime/shared/json-file.mjs +6 -0
  490. package/src/runtime/shared/llm/cost.mjs +2 -2
  491. package/src/runtime/shared/llm/http-agent.mjs +18 -6
  492. package/src/runtime/shared/markdown-frontmatter.mjs +2 -4
  493. package/src/runtime/shared/memory-snapshot.mjs +0 -4
  494. package/src/runtime/shared/native-asset.mjs +149 -0
  495. package/src/runtime/shared/numbers.mjs +12 -0
  496. package/src/runtime/shared/object.mjs +7 -0
  497. package/src/runtime/shared/owner-fair-gate.mjs +1 -5
  498. package/src/runtime/shared/plugin-manifest.mjs +44 -0
  499. package/src/runtime/shared/pristine-execution.mjs +4 -7
  500. package/src/runtime/shared/process-lifecycle.mjs +1 -5
  501. package/src/runtime/shared/resource-admission.mjs +4 -7
  502. package/src/runtime/shared/service-discovery.mjs +1 -22
  503. package/src/runtime/shared/session-runtime-health.mjs +15 -1
  504. package/src/runtime/shared/skill-document.mjs +36 -8
  505. package/src/runtime/shared/task-notification-envelope.mjs +0 -25
  506. package/src/runtime/shared/time-format.mjs +1 -1
  507. package/src/runtime/shared/tool-execution-contract.mjs +29 -7
  508. package/src/runtime/shared/tool-result-summary.mjs +1 -1
  509. package/src/runtime/shared/tool-surface.mjs +21 -21
  510. package/src/runtime/shared/tool-workload-gates.mjs +1 -5
  511. package/src/runtime/shared/transcript-writer.mjs +5 -2
  512. package/src/runtime/shared/transport-error-text.mjs +128 -0
  513. package/src/runtime/shared/turn-snapshot-store.mjs +81 -7
  514. package/src/runtime/shared/turn-snapshot.mjs +147 -19
  515. package/src/runtime/shared/user-data-guard.mjs +1 -73
  516. package/src/runtime/web-search/lib/web-tools.mjs +0 -157
  517. package/src/session-runtime/agent-tool-routing.mjs +56 -0
  518. package/src/session-runtime/boot-profile.mjs +6 -18
  519. package/src/session-runtime/builtin-features.d.mts +8 -0
  520. package/src/session-runtime/builtin-features.mjs +42 -4
  521. package/src/session-runtime/config-helpers.mjs +1 -1
  522. package/src/session-runtime/context-status.mjs +44 -11
  523. package/src/session-runtime/effort.mjs +28 -32
  524. package/src/session-runtime/extension-scopes.mjs +94 -0
  525. package/src/session-runtime/fs-utils.mjs +1 -3
  526. package/src/session-runtime/goal-facade-api.mjs +52 -0
  527. package/src/session-runtime/goal-reminder.mjs +12 -5
  528. package/src/session-runtime/goal-runtime.mjs +196 -305
  529. package/src/session-runtime/goal-storage.mjs +60 -0
  530. package/src/session-runtime/goal-tasks.mjs +125 -0
  531. package/src/session-runtime/goal-text.mjs +8 -5
  532. package/src/session-runtime/goal-tool-defs.mjs +91 -0
  533. package/src/session-runtime/hitch-profile.mjs +1 -1
  534. package/src/session-runtime/hook-payload.mjs +32 -0
  535. package/src/session-runtime/internal-tool-executor.mjs +171 -0
  536. package/src/session-runtime/lifecycle-api.mjs +7 -2
  537. package/src/session-runtime/local-model-api.mjs +22 -0
  538. package/src/session-runtime/local-provider-settings.mjs +49 -0
  539. package/src/session-runtime/mcp-glue.mjs +8 -3
  540. package/src/session-runtime/model-capabilities.mjs +3 -15
  541. package/src/session-runtime/model-recency.mjs +3 -0
  542. package/src/session-runtime/model-route-api.mjs +26 -51
  543. package/src/session-runtime/native-teardown.mjs +42 -0
  544. package/src/session-runtime/notification-bus.mjs +13 -1
  545. package/src/session-runtime/plugin-mcp.mjs +9 -30
  546. package/src/session-runtime/provider-auth-api.mjs +2 -13
  547. package/src/session-runtime/provider-models.mjs +9 -0
  548. package/src/session-runtime/provider-readiness.mjs +131 -0
  549. package/src/session-runtime/provider-request-snapshot.mjs +0 -19
  550. package/src/session-runtime/resource-api.mjs +70 -3
  551. package/src/session-runtime/runtime-core.mjs +176 -705
  552. package/src/session-runtime/runtime-facade.mjs +112 -0
  553. package/src/session-runtime/runtime-modules.mjs +56 -0
  554. package/src/session-runtime/runtime-review-api.mjs +19 -0
  555. package/src/session-runtime/runtime-tunables.mjs +1 -1
  556. package/src/session-runtime/session-lifecycle.mjs +14 -4
  557. package/src/session-runtime/session-route-policy.mjs +26 -0
  558. package/src/session-runtime/session-text.mjs +3 -32
  559. package/src/session-runtime/session-turn-api.mjs +16 -4
  560. package/src/session-runtime/settings-api.mjs +56 -3
  561. package/src/session-runtime/setup-tool/executor.mjs +316 -0
  562. package/src/session-runtime/setup-tool/tool-defs.mjs +164 -0
  563. package/src/session-runtime/skills-api.mjs +39 -13
  564. package/src/session-runtime/tool-catalog-data.mjs +3 -2
  565. package/src/session-runtime/tool-catalog-schema.mjs +1 -16
  566. package/src/session-runtime/tool-catalog.mjs +0 -6
  567. package/src/session-runtime/tool-defs.mjs +1 -1
  568. package/src/session-runtime/tool-policy-refresh.mjs +4 -1
  569. package/src/session-runtime/tool-profile.mjs +1 -0
  570. package/src/session-runtime/tool-surface.mjs +2 -0
  571. package/src/session-runtime/workflow-agents-api.mjs +2 -1
  572. package/src/session-runtime/workflow.mjs +2 -2
  573. package/src/standalone/agent-tool/helpers.mjs +31 -7
  574. package/src/standalone/agent-tool/lead-worker-index.mjs +3 -27
  575. package/src/standalone/agent-tool/notify.mjs +1 -0
  576. package/src/standalone/agent-tool/worker-index.mjs +1 -25
  577. package/src/standalone/agent-tool.mjs +0 -24
  578. package/src/standalone/boot-phase-profiler.mjs +60 -0
  579. package/src/standalone/channel-admin.mjs +1 -42
  580. package/src/standalone/channel-transport.mjs +21 -4
  581. package/src/standalone/daemon-boot-coordinator.mjs +103 -0
  582. package/src/standalone/daemon.mjs +50 -46
  583. package/src/standalone/desktop-service-registry.mjs +226 -0
  584. package/src/standalone/fair-call-scheduler.mjs +1 -4
  585. package/src/standalone/hook-bus/config.mjs +1 -1
  586. package/src/standalone/hook-bus.mjs +11 -0
  587. package/src/standalone/plugin-admin.mjs +3 -15
  588. package/src/standalone/provider-admin.mjs +40 -53
  589. package/src/standalone/seeds.mjs +62 -18
  590. package/src/standalone/session-attachment-pool.mjs +127 -0
  591. package/src/standalone/session-client.mjs +53 -669
  592. package/src/standalone/session-protocol.mjs +12 -1
  593. package/src/standalone/session-proxy.mjs +538 -0
  594. package/src/standalone/session-runtime-inline-host.mjs +28 -11
  595. package/src/standalone/session-runtime-worker.mjs +13 -3
  596. package/src/standalone/session-service/agent-tree.mjs +477 -0
  597. package/src/standalone/session-service/project-catalog.mjs +86 -0
  598. package/src/standalone/session-service/projection.mjs +295 -0
  599. package/src/standalone/session-service-api.mjs +56 -0
  600. package/src/standalone/session-service.mjs +151 -1078
  601. package/src/standalone/session-state-projection.mjs +57 -0
  602. package/src/standalone/session-transport.mjs +44 -5
  603. package/src/standalone/session-wire-values.mjs +54 -0
  604. package/src/standalone/session-wire.mjs +1 -1
  605. package/src/standalone/usage-dashboard.mjs +3 -30
  606. package/src/tui/App.jsx +14 -0
  607. package/src/tui/app/app-format.mjs +5 -13
  608. package/src/tui/app/app-view.jsx +1 -0
  609. package/src/tui/app/extension-pickers.mjs +20 -4
  610. package/src/tui/app/input-parsers.mjs +3 -21
  611. package/src/tui/app/model-options.mjs +7 -5
  612. package/src/tui/app/prompt-submit.mjs +0 -18
  613. package/src/tui/app/provider-setup-picker.mjs +24 -76
  614. package/src/tui/app/transcript-row-estimate.mjs +0 -1
  615. package/src/tui/app/transcript-window.mjs +2 -13
  616. package/src/tui/app/use-transcript-scroll.mjs +1 -1
  617. package/src/tui/app/use-transcript-window.mjs +1 -1
  618. package/src/tui/components/PromptInput.jsx +4 -4
  619. package/src/tui/display-width.mjs +5 -6
  620. package/src/tui/dist/index.mjs +5349 -5096
  621. package/src/tui/index.jsx +4 -2
  622. package/src/tui/markdown/format-token.mjs +0 -5
  623. package/src/tui/markdown/streaming-markdown.mjs +2 -157
  624. package/src/tui/prompt-history-store.mjs +0 -13
  625. package/src/tui/session/agent-envelope.mjs +38 -5
  626. package/src/tui/session/agent-job-feed.mjs +8 -0
  627. package/src/tui/session/boot-profile.mjs +2 -14
  628. package/src/tui/session/context-state.mjs +0 -4
  629. package/src/tui/session/goal-continuation.mjs +1 -10
  630. package/src/tui/session/notification-plan.mjs +8 -0
  631. package/src/tui/session/render-frame-source.mjs +22 -0
  632. package/src/tui/session/render-timing.mjs +13 -3
  633. package/src/tui/session/session-api-ext.mjs +18 -9
  634. package/src/tui/session/session-api.mjs +28 -0
  635. package/src/tui/session/session-stats.mjs +7 -41
  636. package/src/tui/session/transcript-spill.mjs +2 -83
  637. package/src/tui/session/turn-aggregate-cards.mjs +252 -0
  638. package/src/tui/session/turn-deferred-cards.mjs +127 -0
  639. package/src/tui/session/turn.mjs +77 -379
  640. package/src/tui/session-local.mjs +19 -74
  641. package/src/ui/model-display.mjs +57 -1
  642. package/src/ui/statusline-agents.mjs +1 -5
  643. package/src/ui/statusline-segments.mjs +1 -5
  644. package/src/ui/statusline.mjs +16 -6
  645. package/src/ui/streaming-markdown-heal.mjs +147 -0
  646. package/src/vendor/statusline/bin/statusline-route.mjs +1 -1
  647. package/src/vendor/statusline/src/gateway/route-meta.mjs +1 -1
  648. package/src/workflows/default/WORKFLOW.md +5 -3
  649. package/src/workflows/solo/WORKFLOW.md +5 -3
  650. package/src/runtime/agent/orchestrator/agent-runtime/commit-message-completion.mjs +0 -67
  651. package/src/runtime/agent/orchestrator/providers/lib/env-utils.mjs +0 -15
  652. package/src/runtime/agent/orchestrator/session/compact/file-reattach.mjs +0 -112
  653. package/src/runtime/agent/orchestrator/session/compact/handoff.mjs +0 -476
  654. package/src/runtime/agent/orchestrator/session/loop/env.mjs +0 -14
  655. package/src/runtime/agent/orchestrator/session/manager/env-utils.mjs +0 -8
  656. package/src/runtime/office/assurance.mjs +0 -962
  657. package/src/runtime/office/design-aesthetics.mjs +0 -460
  658. package/src/runtime/office/design-frontier-review.mjs +0 -129
  659. package/src/runtime/office/design-layout-grammar.mjs +0 -134
  660. package/src/runtime/office/design-pptx-executive.mjs +0 -335
  661. package/src/runtime/office/design-pptx-plan.mjs +0 -1002
  662. package/src/runtime/office/design-pptx-primitives.mjs +0 -87
  663. package/src/runtime/office/design-pptx-semantic-flow.mjs +0 -111
  664. package/src/runtime/office/design-pptx-semantic-visuals.mjs +0 -885
  665. package/src/runtime/office/design-pptx-stack.mjs +0 -58
  666. package/src/runtime/office/design-pptx.mjs +0 -776
  667. package/src/runtime/office/office-actions.mjs +0 -979
  668. package/src/runtime/office/pdf-adapter.mjs +0 -591
  669. package/src/runtime/office/pdf-analysis.mjs +0 -429
  670. package/src/runtime/office/quality-pipeline.mjs +0 -154
  671. package/src/session-runtime/env.mjs +0 -16
  672. package/vendor/ink/build/ansi-tokenizer.d.ts +0 -38
  673. package/vendor/ink/build/ansi-tokenizer.js +0 -316
  674. package/vendor/ink/build/ansi-tokenizer.js.map +0 -1
  675. package/vendor/ink/build/colorize.d.ts +0 -3
  676. package/vendor/ink/build/colorize.js +0 -48
  677. package/vendor/ink/build/colorize.js.map +0 -1
  678. package/vendor/ink/build/components/AccessibilityContext.d.ts +0 -3
  679. package/vendor/ink/build/components/AccessibilityContext.js +0 -5
  680. package/vendor/ink/build/components/AccessibilityContext.js.map +0 -1
  681. package/vendor/ink/build/components/AnimationContext.d.ts +0 -9
  682. package/vendor/ink/build/components/AnimationContext.js +0 -13
  683. package/vendor/ink/build/components/AnimationContext.js.map +0 -1
  684. package/vendor/ink/build/components/App.d.ts +0 -24
  685. package/vendor/ink/build/components/App.js +0 -608
  686. package/vendor/ink/build/components/App.js.map +0 -1
  687. package/vendor/ink/build/components/AppContext.d.ts +0 -80
  688. package/vendor/ink/build/components/AppContext.js +0 -25
  689. package/vendor/ink/build/components/AppContext.js.map +0 -1
  690. package/vendor/ink/build/components/BackgroundContext.d.ts +0 -4
  691. package/vendor/ink/build/components/BackgroundContext.js +0 -3
  692. package/vendor/ink/build/components/BackgroundContext.js.map +0 -1
  693. package/vendor/ink/build/components/Box.d.ts +0 -130
  694. package/vendor/ink/build/components/Box.js +0 -34
  695. package/vendor/ink/build/components/Box.js.map +0 -1
  696. package/vendor/ink/build/components/CursorContext.d.ts +0 -11
  697. package/vendor/ink/build/components/CursorContext.js +0 -8
  698. package/vendor/ink/build/components/CursorContext.js.map +0 -1
  699. package/vendor/ink/build/components/ErrorBoundary.d.ts +0 -18
  700. package/vendor/ink/build/components/ErrorBoundary.js +0 -23
  701. package/vendor/ink/build/components/ErrorBoundary.js.map +0 -1
  702. package/vendor/ink/build/components/ErrorOverview.d.ts +0 -6
  703. package/vendor/ink/build/components/ErrorOverview.js +0 -90
  704. package/vendor/ink/build/components/ErrorOverview.js.map +0 -1
  705. package/vendor/ink/build/components/FocusContext.d.ts +0 -16
  706. package/vendor/ink/build/components/FocusContext.js +0 -17
  707. package/vendor/ink/build/components/FocusContext.js.map +0 -1
  708. package/vendor/ink/build/components/Newline.d.ts +0 -13
  709. package/vendor/ink/build/components/Newline.js +0 -8
  710. package/vendor/ink/build/components/Newline.js.map +0 -1
  711. package/vendor/ink/build/components/Spacer.d.ts +0 -7
  712. package/vendor/ink/build/components/Spacer.js +0 -11
  713. package/vendor/ink/build/components/Spacer.js.map +0 -1
  714. package/vendor/ink/build/components/Static.d.ts +0 -24
  715. package/vendor/ink/build/components/Static.js +0 -28
  716. package/vendor/ink/build/components/Static.js.map +0 -1
  717. package/vendor/ink/build/components/StderrContext.d.ts +0 -15
  718. package/vendor/ink/build/components/StderrContext.js +0 -13
  719. package/vendor/ink/build/components/StderrContext.js.map +0 -1
  720. package/vendor/ink/build/components/StdinContext.d.ts +0 -28
  721. package/vendor/ink/build/components/StdinContext.js +0 -20
  722. package/vendor/ink/build/components/StdinContext.js.map +0 -1
  723. package/vendor/ink/build/components/StdoutContext.d.ts +0 -15
  724. package/vendor/ink/build/components/StdoutContext.js +0 -13
  725. package/vendor/ink/build/components/StdoutContext.js.map +0 -1
  726. package/vendor/ink/build/components/Text.d.ts +0 -55
  727. package/vendor/ink/build/components/Text.js +0 -50
  728. package/vendor/ink/build/components/Text.js.map +0 -1
  729. package/vendor/ink/build/components/Transform.d.ts +0 -16
  730. package/vendor/ink/build/components/Transform.js +0 -15
  731. package/vendor/ink/build/components/Transform.js.map +0 -1
  732. package/vendor/ink/build/cursor-helpers.d.ts +0 -39
  733. package/vendor/ink/build/cursor-helpers.js +0 -62
  734. package/vendor/ink/build/cursor-helpers.js.map +0 -1
  735. package/vendor/ink/build/devtools-window-polyfill.d.ts +0 -1
  736. package/vendor/ink/build/devtools-window-polyfill.js +0 -68
  737. package/vendor/ink/build/devtools-window-polyfill.js.map +0 -1
  738. package/vendor/ink/build/devtools.d.ts +0 -1
  739. package/vendor/ink/build/devtools.js +0 -36
  740. package/vendor/ink/build/devtools.js.map +0 -1
  741. package/vendor/ink/build/display-width.js +0 -96
  742. package/vendor/ink/build/dom.d.ts +0 -62
  743. package/vendor/ink/build/dom.js +0 -143
  744. package/vendor/ink/build/dom.js.map +0 -1
  745. package/vendor/ink/build/get-max-width.d.ts +0 -3
  746. package/vendor/ink/build/get-max-width.js +0 -10
  747. package/vendor/ink/build/get-max-width.js.map +0 -1
  748. package/vendor/ink/build/hooks/use-animation.d.ts +0 -49
  749. package/vendor/ink/build/hooks/use-animation.js +0 -87
  750. package/vendor/ink/build/hooks/use-animation.js.map +0 -1
  751. package/vendor/ink/build/hooks/use-app.d.ts +0 -5
  752. package/vendor/ink/build/hooks/use-app.js +0 -8
  753. package/vendor/ink/build/hooks/use-app.js.map +0 -1
  754. package/vendor/ink/build/hooks/use-box-metrics.d.ts +0 -59
  755. package/vendor/ink/build/hooks/use-box-metrics.js +0 -81
  756. package/vendor/ink/build/hooks/use-box-metrics.js.map +0 -1
  757. package/vendor/ink/build/hooks/use-cursor.d.ts +0 -12
  758. package/vendor/ink/build/hooks/use-cursor.js +0 -29
  759. package/vendor/ink/build/hooks/use-cursor.js.map +0 -1
  760. package/vendor/ink/build/hooks/use-focus-manager.d.ts +0 -43
  761. package/vendor/ink/build/hooks/use-focus-manager.js +0 -18
  762. package/vendor/ink/build/hooks/use-focus-manager.js.map +0 -1
  763. package/vendor/ink/build/hooks/use-focus.d.ts +0 -30
  764. package/vendor/ink/build/hooks/use-focus.js +0 -43
  765. package/vendor/ink/build/hooks/use-focus.js.map +0 -1
  766. package/vendor/ink/build/hooks/use-input.d.ts +0 -132
  767. package/vendor/ink/build/hooks/use-input.js +0 -126
  768. package/vendor/ink/build/hooks/use-input.js.map +0 -1
  769. package/vendor/ink/build/hooks/use-is-screen-reader-enabled.d.ts +0 -6
  770. package/vendor/ink/build/hooks/use-is-screen-reader-enabled.js +0 -12
  771. package/vendor/ink/build/hooks/use-is-screen-reader-enabled.js.map +0 -1
  772. package/vendor/ink/build/hooks/use-paste.d.ts +0 -35
  773. package/vendor/ink/build/hooks/use-paste.js +0 -62
  774. package/vendor/ink/build/hooks/use-paste.js.map +0 -1
  775. package/vendor/ink/build/hooks/use-stderr.d.ts +0 -5
  776. package/vendor/ink/build/hooks/use-stderr.js +0 -8
  777. package/vendor/ink/build/hooks/use-stderr.js.map +0 -1
  778. package/vendor/ink/build/hooks/use-stdin.d.ts +0 -7
  779. package/vendor/ink/build/hooks/use-stdin.js +0 -9
  780. package/vendor/ink/build/hooks/use-stdin.js.map +0 -1
  781. package/vendor/ink/build/hooks/use-stdout.d.ts +0 -5
  782. package/vendor/ink/build/hooks/use-stdout.js +0 -8
  783. package/vendor/ink/build/hooks/use-stdout.js.map +0 -1
  784. package/vendor/ink/build/hooks/use-window-size.d.ts +0 -18
  785. package/vendor/ink/build/hooks/use-window-size.js +0 -22
  786. package/vendor/ink/build/hooks/use-window-size.js.map +0 -1
  787. package/vendor/ink/build/index.d.ts +0 -42
  788. package/vendor/ink/build/index.js +0 -24
  789. package/vendor/ink/build/index.js.map +0 -1
  790. package/vendor/ink/build/ink.d.ts +0 -146
  791. package/vendor/ink/build/ink.js +0 -1287
  792. package/vendor/ink/build/ink.js.map +0 -1
  793. package/vendor/ink/build/input-parser.d.ts +0 -15
  794. package/vendor/ink/build/input-parser.js +0 -63
  795. package/vendor/ink/build/input-parser.js.map +0 -1
  796. package/vendor/ink/build/instances.d.ts +0 -3
  797. package/vendor/ink/build/instances.js +0 -8
  798. package/vendor/ink/build/instances.js.map +0 -1
  799. package/vendor/ink/build/kitty-keyboard.d.ts +0 -23
  800. package/vendor/ink/build/kitty-keyboard.js +0 -32
  801. package/vendor/ink/build/kitty-keyboard.js.map +0 -1
  802. package/vendor/ink/build/log-update.d.ts +0 -20
  803. package/vendor/ink/build/log-update.js +0 -320
  804. package/vendor/ink/build/log-update.js.map +0 -1
  805. package/vendor/ink/build/measure-element.d.ts +0 -20
  806. package/vendor/ink/build/measure-element.js +0 -13
  807. package/vendor/ink/build/measure-element.js.map +0 -1
  808. package/vendor/ink/build/measure-text.d.ts +0 -6
  809. package/vendor/ink/build/measure-text.js +0 -24
  810. package/vendor/ink/build/measure-text.js.map +0 -1
  811. package/vendor/ink/build/output.d.ts +0 -35
  812. package/vendor/ink/build/output.js +0 -567
  813. package/vendor/ink/build/output.js.map +0 -1
  814. package/vendor/ink/build/parse-keypress.d.ts +0 -20
  815. package/vendor/ink/build/parse-keypress.js +0 -495
  816. package/vendor/ink/build/parse-keypress.js.map +0 -1
  817. package/vendor/ink/build/reconciler.d.ts +0 -4
  818. package/vendor/ink/build/reconciler.js +0 -306
  819. package/vendor/ink/build/reconciler.js.map +0 -1
  820. package/vendor/ink/build/render-background.d.ts +0 -4
  821. package/vendor/ink/build/render-background.js +0 -25
  822. package/vendor/ink/build/render-background.js.map +0 -1
  823. package/vendor/ink/build/render-border.d.ts +0 -4
  824. package/vendor/ink/build/render-border.js +0 -84
  825. package/vendor/ink/build/render-border.js.map +0 -1
  826. package/vendor/ink/build/render-node-to-output.d.ts +0 -14
  827. package/vendor/ink/build/render-node-to-output.js +0 -207
  828. package/vendor/ink/build/render-node-to-output.js.map +0 -1
  829. package/vendor/ink/build/render-to-string.d.ts +0 -38
  830. package/vendor/ink/build/render-to-string.js +0 -116
  831. package/vendor/ink/build/render-to-string.js.map +0 -1
  832. package/vendor/ink/build/render.d.ts +0 -176
  833. package/vendor/ink/build/render.js +0 -84
  834. package/vendor/ink/build/render.js.map +0 -1
  835. package/vendor/ink/build/renderer.d.ts +0 -8
  836. package/vendor/ink/build/renderer.js +0 -67
  837. package/vendor/ink/build/renderer.js.map +0 -1
  838. package/vendor/ink/build/sanitize-ansi.d.ts +0 -2
  839. package/vendor/ink/build/sanitize-ansi.js +0 -27
  840. package/vendor/ink/build/sanitize-ansi.js.map +0 -1
  841. package/vendor/ink/build/selection-rect.js +0 -80
  842. package/vendor/ink/build/squash-text-nodes.d.ts +0 -3
  843. package/vendor/ink/build/squash-text-nodes.js +0 -36
  844. package/vendor/ink/build/squash-text-nodes.js.map +0 -1
  845. package/vendor/ink/build/styles.d.ts +0 -302
  846. package/vendor/ink/build/styles.js +0 -303
  847. package/vendor/ink/build/styles.js.map +0 -1
  848. package/vendor/ink/build/termio-keypress.js +0 -271
  849. package/vendor/ink/build/termio-tokenize.js +0 -188
  850. package/vendor/ink/build/utils.d.ts +0 -9
  851. package/vendor/ink/build/utils.js +0 -19
  852. package/vendor/ink/build/utils.js.map +0 -1
  853. package/vendor/ink/build/wrap-text.d.ts +0 -5
  854. package/vendor/ink/build/wrap-text.js +0 -204
  855. package/vendor/ink/build/wrap-text.js.map +0 -1
  856. package/vendor/ink/build/write-synchronized.d.ts +0 -4
  857. package/vendor/ink/build/write-synchronized.js +0 -9
  858. package/vendor/ink/build/write-synchronized.js.map +0 -1
  859. package/vendor/ink/license +0 -10
  860. package/vendor/ink/package.json +0 -137
  861. /package/src/runtime/office/{office-documents.mjs → core/office-documents.mjs} +0 -0
  862. /package/src/runtime/office/{pagination.mjs → core/pagination.mjs} +0 -0
  863. /package/src/runtime/office/{design-docx-components.mjs → design/docx/design-docx-components.mjs} +0 -0
  864. /package/src/runtime/office/{templates → design/library/templates}/mixdog-executive.pptx +0 -0
  865. /package/src/runtime/office/{templates → design/library/templates}/mixdog-executive.pptx.mixdog.json +0 -0
  866. /package/src/runtime/office/{image-layout.mjs → portable/image-layout.mjs} +0 -0
  867. /package/src/runtime/office/{portable-ooxml.mjs → portable/portable-ooxml.mjs} +0 -0
  868. /package/src/runtime/office/{portable-pptx-deck.mjs → portable/portable-pptx-deck.mjs} +0 -0
  869. /package/src/runtime/office/{portable-sheet-parts.mjs → portable/portable-sheet-parts.mjs} +0 -0
  870. /package/src/runtime/office/{portable-sheet-xml.mjs → portable/portable-sheet-xml.mjs} +0 -0
  871. /package/src/runtime/office/{visual-diff.mjs → quality/visual-diff.mjs} +0 -0
@@ -1,591 +0,0 @@
1
- import { readFile, writeFile } from 'node:fs/promises';
2
- import { basename, dirname, extname, resolve } from 'node:path';
3
- import {
4
- PDFDocument,
5
- PDFArray,
6
- PDFDict,
7
- PDFHexString,
8
- PDFName,
9
- PDFString,
10
- StandardFonts,
11
- degrees,
12
- rgb,
13
- } from 'pdf-lib';
14
- import { inspectPdfBuffer } from '../attachments/pdf-extract.mjs';
15
- import { ocrPdf } from './pdf-analysis.mjs';
16
-
17
- function color(value = '') {
18
- const hex = String(value || '000000').replace(/^#/, '');
19
- if (!/^[0-9a-f]{6}$/i.test(hex)) throw new Error(`Invalid PDF color: ${value}`);
20
- return rgb(
21
- Number.parseInt(hex.slice(0, 2), 16) / 255,
22
- Number.parseInt(hex.slice(2, 4), 16) / 255,
23
- Number.parseInt(hex.slice(4, 6), 16) / 255,
24
- );
25
- }
26
-
27
- function selectedPages(document, operation) {
28
- const count = document.getPageCount();
29
- const pages = Array.isArray(operation.pages) && operation.pages.length
30
- ? operation.pages
31
- : operation.page
32
- ? [operation.page]
33
- : Array.from({ length: count }, (_, index) => index + 1);
34
- return pages.map((page) => {
35
- const index = Number(page) - 1;
36
- if (!Number.isInteger(index) || index < 0 || index >= count) throw new Error(`PDF page out of range: ${page}`);
37
- return { page: document.getPage(index), index };
38
- });
39
- }
40
-
41
- function pageSize(properties = {}) {
42
- const named = String(properties.pageSize || 'a4').toLowerCase();
43
- if (named === 'letter') return [612, 792];
44
- if (named === 'legal') return [612, 1008];
45
- if (Array.isArray(properties.pageSize) && properties.pageSize.length === 2) {
46
- return properties.pageSize.map(Number);
47
- }
48
- return [595.28, 841.89];
49
- }
50
-
51
- function fieldWidgets(field, document) {
52
- try {
53
- return field.acroField.getWidgets().map((widget) => {
54
- const rectangle = widget.getRectangle();
55
- const pageRef = widget.P();
56
- const page = document.getPages().findIndex((entry) => entry.ref === pageRef) + 1;
57
- return {
58
- page,
59
- x: Number(rectangle.x),
60
- y: Number(rectangle.y),
61
- width: Number(rectangle.width),
62
- height: Number(rectangle.height),
63
- };
64
- });
65
- } catch {
66
- return [];
67
- }
68
- }
69
-
70
- function pdfAttachments(document) {
71
- try {
72
- const names = document.catalog.lookup(PDFName.of('Names'), PDFDict);
73
- const embedded = names?.lookup(PDFName.of('EmbeddedFiles'), PDFDict);
74
- const entries = embedded?.lookup(PDFName.of('Names'), PDFArray);
75
- if (!entries) return [];
76
- const output = [];
77
- for (let index = 0; index + 1 < entries.size(); index += 2) {
78
- const nameObject = entries.lookup(index, PDFString, PDFHexString);
79
- const spec = entries.lookup(index + 1, PDFDict);
80
- const description = spec?.lookupMaybe?.(PDFName.of('Desc'), PDFString, PDFHexString);
81
- output.push({
82
- path: `/attachments[${output.length + 1}]`,
83
- index: output.length + 1,
84
- name: nameObject?.decodeText?.() || '',
85
- description: description?.decodeText?.() || '',
86
- });
87
- }
88
- return output;
89
- } catch {
90
- return [];
91
- }
92
- }
93
-
94
- function fieldValue(field) {
95
- const type = field.constructor?.name || '';
96
- try {
97
- if (type.includes('CheckBox')) return field.isChecked();
98
- if (type.includes('RadioGroup') || type.includes('Dropdown') || type.includes('OptionList')) return field.getSelected();
99
- if (type.includes('TextField')) return field.getText() || '';
100
- } catch {}
101
- return null;
102
- }
103
-
104
- function rectanglesOverlap(left, right) {
105
- return left.x < right.x + right.width
106
- && left.x + left.width > right.x
107
- && left.y < right.y + right.height
108
- && left.y + left.height > right.y;
109
- }
110
-
111
- export function lintPdfFormFields(fields = [], pages = []) {
112
- const issues = [];
113
- const normalized = fields.map((field, index) => ({
114
- index: index + 1,
115
- name: String(field.name || ''),
116
- type: String(field.type || 'text').toLowerCase(),
117
- page: Math.max(1, Number(field.page) || 1),
118
- x: Number(field.x),
119
- y: Number(field.y),
120
- width: Number(field.width),
121
- height: Number(field.height),
122
- }));
123
- const names = new Set();
124
- for (const field of normalized) {
125
- const size = pages[field.page - 1] || [595.28, 841.89];
126
- if (!field.name) issues.push({ severity: 'error', code: 'missing_field_name', path: `/field[${field.index}]`, message: 'Form field name is required.' });
127
- if (names.has(field.name)) issues.push({ severity: 'error', code: 'duplicate_field_name', path: `/field[${field.index}]`, message: `Duplicate form field name: ${field.name}` });
128
- names.add(field.name);
129
- if (![field.x, field.y, field.width, field.height].every(Number.isFinite) || field.width <= 0 || field.height <= 0) {
130
- issues.push({ severity: 'error', code: 'invalid_field_box', path: `/field[${field.index}]`, message: 'Form field box must have finite positive dimensions.' });
131
- } else if (field.x < 0 || field.y < 0 || field.x + field.width > size[0] || field.y + field.height > size[1]) {
132
- issues.push({ severity: 'error', code: 'field_outside_page', path: `/field[${field.index}]`, message: `Form field is outside page ${field.page}.` });
133
- }
134
- }
135
- for (let left = 0; left < normalized.length; left += 1) {
136
- for (let right = left + 1; right < normalized.length; right += 1) {
137
- if (normalized[left].page === normalized[right].page && rectanglesOverlap(normalized[left], normalized[right])) {
138
- issues.push({
139
- severity: 'warning',
140
- code: 'overlapping_form_fields',
141
- path: `/field[${normalized[left].index}]`,
142
- message: `Form fields ${normalized[left].name || normalized[left].index} and ${normalized[right].name || normalized[right].index} overlap.`,
143
- });
144
- }
145
- }
146
- }
147
- return { ok: !issues.some((issue) => issue.severity === 'error'), fields: normalized, issueCount: issues.length, issues };
148
- }
149
-
150
- async function embedPdfFont(document, properties = {}) {
151
- if (!properties.fontPath) return await document.embedFont(StandardFonts.Helvetica);
152
- const fontkit = (await import('@pdf-lib/fontkit')).default;
153
- document.registerFontkit(fontkit);
154
- return await document.embedFont(await readFile(resolve(String(properties.fontPath))), { subset: true });
155
- }
156
-
157
- function wrapText(text, font, size, width) {
158
- const words = String(text || '').split(/\s+/);
159
- const lines = [];
160
- let line = '';
161
- for (const word of words) {
162
- const candidate = line ? `${line} ${word}` : word;
163
- if (!line || font.widthOfTextAtSize(candidate, size) <= width) line = candidate;
164
- else {
165
- lines.push(line);
166
- line = word;
167
- }
168
- }
169
- if (line) lines.push(line);
170
- return lines.length ? lines : [''];
171
- }
172
-
173
- async function addFormField(document, field) {
174
- const page = document.getPage(Math.max(1, Number(field.page) || 1) - 1);
175
- const form = document.getForm();
176
- const name = String(field.name);
177
- const options = {
178
- x: Number(field.x),
179
- y: Number(field.y),
180
- width: Number(field.width),
181
- height: Number(field.height),
182
- borderWidth: Number(field.borderWidth ?? 1),
183
- textColor: color(field.textColor || '000000'),
184
- borderColor: color(field.borderColor || '666666'),
185
- backgroundColor: color(field.backgroundColor || 'FFFFFF'),
186
- };
187
- const type = String(field.type || 'text').toLowerCase();
188
- if (type === 'checkbox') {
189
- const control = form.createCheckBox(name);
190
- control.addToPage(page, options);
191
- if (field.value) control.check();
192
- } else if (type === 'dropdown') {
193
- const control = form.createDropdown(name);
194
- control.addOptions((field.options || []).map(String));
195
- control.addToPage(page, options);
196
- if (field.value != null) control.select(String(field.value));
197
- } else if (type === 'radio') {
198
- const control = form.createRadioGroup(name);
199
- for (const option of field.options || []) {
200
- control.addOptionToPage(String(option.value ?? option), page, {
201
- ...options,
202
- x: Number(option.x ?? field.x),
203
- y: Number(option.y ?? field.y),
204
- });
205
- }
206
- if (field.value != null) control.select(String(field.value));
207
- } else {
208
- const control = form.createTextField(name);
209
- control.addToPage(page, options);
210
- if (field.multiline) control.enableMultiline();
211
- if (field.value != null) control.setText(String(field.value));
212
- }
213
- }
214
-
215
- export async function createPdf(path, {
216
- blocks = [],
217
- fields = [],
218
- properties = {},
219
- } = {}) {
220
- const document = await PDFDocument.create();
221
- const size = pageSize(properties);
222
- const margin = Number(properties.margin ?? 54);
223
- const font = await embedPdfFont(document, properties);
224
- const preparePage = (entry) => {
225
- if (properties.background) {
226
- entry.drawRectangle({
227
- x: 0,
228
- y: 0,
229
- width: entry.getWidth(),
230
- height: entry.getHeight(),
231
- color: color(properties.background),
232
- });
233
- }
234
- return entry;
235
- };
236
- let page = preparePage(document.addPage(size));
237
- let y = page.getHeight() - margin;
238
- const newPage = () => {
239
- page = preparePage(document.addPage(size));
240
- y = page.getHeight() - margin;
241
- };
242
- for (const block of blocks || []) {
243
- const type = String(block.type || 'paragraph').toLowerCase();
244
- if (type === 'pagebreak') {
245
- newPage();
246
- continue;
247
- }
248
- if (type === 'image') {
249
- const imagePath = resolve(dirname(path), String(block.path || ''));
250
- const data = await readFile(imagePath);
251
- const image = /\.png$/i.test(imagePath) ? await document.embedPng(data) : await document.embedJpg(data);
252
- const width = Number(block.width || Math.min(image.width, page.getWidth() - (margin * 2)));
253
- const height = Number(block.height || (image.height * width / image.width));
254
- if (y - height < margin) newPage();
255
- page.drawImage(image, { x: Number(block.x ?? margin), y: Number(block.y ?? y - height), width, height });
256
- y -= height + Number(block.after ?? 12);
257
- continue;
258
- }
259
- if (type === 'table') {
260
- const rows = Array.isArray(block.rows) ? block.rows : [];
261
- const columns = Math.max(1, ...rows.map((row) => row.length));
262
- const width = Number(block.width || page.getWidth() - (margin * 2));
263
- const cellWidth = width / columns;
264
- const rowHeight = Number(block.rowHeight || 24);
265
- for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
266
- const row = rows[rowIndex];
267
- if (y - rowHeight < margin) newPage();
268
- row.forEach((value, column) => {
269
- const x = margin + (column * cellWidth);
270
- const fill = rowIndex === 0
271
- ? block.headerFill
272
- : rowIndex % 2 === 0
273
- ? block.zebraFill
274
- : '';
275
- page.drawRectangle({
276
- x,
277
- y: y - rowHeight,
278
- width: cellWidth,
279
- height: rowHeight,
280
- ...(fill ? { color: color(fill) } : {}),
281
- borderWidth: 0.5,
282
- borderColor: color(block.borderColor || '999999'),
283
- });
284
- page.drawText(String(value ?? ''), {
285
- x: x + 4,
286
- y: y - rowHeight + 7,
287
- size: Number(block.fontSize || 9),
288
- font,
289
- color: color(rowIndex === 0 ? block.headerColor || block.color : block.color),
290
- });
291
- });
292
- y -= rowHeight;
293
- }
294
- y -= Number(block.after ?? 12);
295
- continue;
296
- }
297
- const heading = type === 'heading';
298
- const fontSize = Number(block.size || (heading ? 20 : 11));
299
- const lineHeight = Number(block.lineHeight || fontSize * 1.35);
300
- const lines = wrapText(block.text, font, fontSize, page.getWidth() - (margin * 2));
301
- for (const line of lines) {
302
- if (y - lineHeight < margin) newPage();
303
- page.drawText(line, { x: Number(block.x ?? margin), y: y - fontSize, size: fontSize, font, color: color(block.color) });
304
- y -= lineHeight;
305
- }
306
- y -= Number(block.after ?? (heading ? 10 : 6));
307
- }
308
- if (properties.title != null) document.setTitle(String(properties.title));
309
- if (properties.author != null) document.setAuthor(String(properties.author));
310
- if (properties.subject != null) document.setSubject(String(properties.subject));
311
- if (properties.keywords != null) document.setKeywords(Array.isArray(properties.keywords) ? properties.keywords.map(String) : [String(properties.keywords)]);
312
- const formCheck = lintPdfFormFields(fields, document.getPages().map((entry) => [entry.getWidth(), entry.getHeight()]));
313
- if (!formCheck.ok) throw new Error(`PDF form layout is invalid: ${formCheck.issues.filter((issue) => issue.severity === 'error').map((issue) => issue.message).join(' ')}`);
314
- for (const field of fields || []) await addFormField(document, field);
315
- await writeFile(path, await document.save({ useObjectStreams: true, addDefaultPage: false }));
316
- return { ok: true, path, pages: document.getPageCount(), form: formCheck };
317
- }
318
-
319
- export async function snapshotPdf(path, options = {}) {
320
- const maxChars = Math.max(1_000, Number(options.maxChars) || 30_000);
321
- const buffer = await readFile(path);
322
- const structure = await PDFDocument.load(buffer, {
323
- ignoreEncryption: false,
324
- updateMetadata: false,
325
- });
326
- const pageCount = structure.getPageCount();
327
- const offset = options.paged ? Math.max(0, Number(options.offset) || 0) : 0;
328
- const limit = options.paged ? Math.max(1, Number(options.limit) || 20) : pageCount;
329
- const selected = Array.isArray(options.pages) && options.pages.length
330
- ? options.pages.map(Number)
331
- : Array.from({ length: Math.max(0, Math.min(limit, pageCount - offset)) }, (_, index) => offset + index + 1);
332
- const from = selected.length ? Math.min(...selected) : 1;
333
- const to = selected.length ? Math.max(...selected) : 1;
334
- const result = await inspectPdfBuffer(buffer, {
335
- extractText: true,
336
- maxPages: Math.max(500, pageCount),
337
- maxOutputBytes: maxChars,
338
- pageRange: { from, to },
339
- });
340
- const pages = [];
341
- const regex = /--- Page (\d+) ---\n([\s\S]*?)(?=\n\n--- Page \d+ ---|$)/g;
342
- let match;
343
- while ((match = regex.exec(result.text || ''))) {
344
- const index = Number(match[1]);
345
- if (selected.includes(index)) pages.push({ path: `/page[${index}]`, index, text: match[2] });
346
- }
347
- const fields = structure.getForm().getFields().map((field, index) => ({
348
- path: `/field[${index + 1}]`,
349
- index: index + 1,
350
- name: field.getName(),
351
- type: field.constructor?.name || '',
352
- value: fieldValue(field),
353
- widgets: fieldWidgets(field, structure),
354
- }));
355
- const attachments = pdfAttachments(structure);
356
- const likelyScannedPages = pages.filter((page) => page.text.includes('(no extractable text on this page)')).map((page) => page.index);
357
- return {
358
- format: 'pdf',
359
- ...result,
360
- pageCount,
361
- pages,
362
- fields,
363
- fieldCount: fields.length,
364
- attachmentCount: attachments.length,
365
- attachments,
366
- metadata: {
367
- title: structure.getTitle() || '',
368
- author: structure.getAuthor() || '',
369
- subject: structure.getSubject() || '',
370
- keywords: structure.getKeywords() || '',
371
- },
372
- likelyScannedPages,
373
- ocrRequired: likelyScannedPages.length > 0,
374
- encrypted: false,
375
- ...(options.paged ? {
376
- pagination: {
377
- unit: 'page',
378
- offset,
379
- limit,
380
- returned: pages.length,
381
- total: pageCount,
382
- nextOffset: !options.pages?.length && offset + pages.length < pageCount ? offset + pages.length : null,
383
- },
384
- } : {}),
385
- };
386
- }
387
-
388
- export async function applyPdfBatch(path, operations, context = {}) {
389
- let document = await PDFDocument.load(await readFile(path), {
390
- ignoreEncryption: false,
391
- updateMetadata: false,
392
- });
393
- const results = [];
394
- for (const operation of operations) {
395
- switch (operation.op) {
396
- case 'add_text':
397
- case 'watermark': {
398
- const font = await embedPdfFont(document, operation);
399
- for (const { page } of selectedPages(document, operation)) {
400
- const size = Number(operation.size ?? (operation.op === 'watermark' ? 48 : 12));
401
- const opacity = Number(operation.opacity ?? (operation.op === 'watermark' ? 0.25 : 1));
402
- const x = Number(operation.x ?? 36);
403
- const y = Number(operation.y ?? (operation.op === 'watermark' ? page.getHeight() / 2 : 36));
404
- page.drawText(String(operation.text || ''), {
405
- x,
406
- y,
407
- size,
408
- font,
409
- color: color(operation.color),
410
- opacity,
411
- rotate: degrees(Number(operation.rotation ?? (operation.op === 'watermark' ? 45 : 0))),
412
- });
413
- }
414
- results.push({ op: operation.op, changed: true, fontEmbedded: Boolean(operation.fontPath) });
415
- break;
416
- }
417
- case 'stamp_image': {
418
- const imagePath = resolve(dirname(path), String(operation.path || ''));
419
- const data = await readFile(imagePath);
420
- const image = /\.png$/i.test(imagePath) ? await document.embedPng(data) : await document.embedJpg(data);
421
- for (const { page } of selectedPages(document, operation)) {
422
- const width = Number(operation.width || image.width);
423
- const height = Number(operation.height || (image.height * width / image.width));
424
- page.drawImage(image, {
425
- x: Number(operation.x || 0),
426
- y: Number(operation.y || 0),
427
- width,
428
- height,
429
- opacity: Number(operation.opacity ?? 1),
430
- });
431
- }
432
- results.push({ op: operation.op, changed: true, image: imagePath });
433
- break;
434
- }
435
- case 'ocr_pages': {
436
- await writeFile(path, await document.save({ useObjectStreams: true, addDefaultPage: false }));
437
- const result = await ocrPdf(path, operation, context);
438
- document = await PDFDocument.load(await readFile(path), {
439
- ignoreEncryption: false,
440
- updateMetadata: false,
441
- });
442
- results.push(result);
443
- break;
444
- }
445
- case 'rotate_pages': {
446
- for (const { page } of selectedPages(document, operation)) page.setRotation(degrees(Number(operation.rotation ?? 90)));
447
- results.push({ op: operation.op, changed: true });
448
- break;
449
- }
450
- case 'delete_pages': {
451
- const indexes = selectedPages(document, operation).map(({ index }) => index).sort((a, b) => b - a);
452
- for (const index of indexes) document.removePage(index);
453
- results.push({ op: operation.op, changed: indexes.length > 0, count: indexes.length });
454
- break;
455
- }
456
- case 'extract_pages': {
457
- const next = await PDFDocument.create();
458
- const indexes = selectedPages(document, operation).map(({ index }) => index);
459
- const copied = await next.copyPages(document, indexes);
460
- copied.forEach((page) => next.addPage(page));
461
- document = next;
462
- results.push({ op: operation.op, changed: true, count: indexes.length });
463
- break;
464
- }
465
- case 'fill_form': {
466
- const form = document.getForm();
467
- for (const [name, value] of Object.entries(operation.values || {})) {
468
- const field = form.getField(name);
469
- const type = field.constructor?.name || '';
470
- if (type.includes('CheckBox')) {
471
- value ? field.check() : field.uncheck();
472
- } else if (type.includes('Dropdown') || type.includes('OptionList') || type.includes('RadioGroup')) {
473
- field.select(String(value));
474
- } else {
475
- field.setText(String(value ?? ''));
476
- }
477
- }
478
- if (operation.flatten) form.flatten();
479
- results.push({ op: operation.op, changed: true });
480
- break;
481
- }
482
- case 'add_form_field': {
483
- const check = lintPdfFormFields([operation], document.getPages().map((entry) => [entry.getWidth(), entry.getHeight()]));
484
- if (!check.ok) throw new Error(check.issues.map((issue) => issue.message).join(' '));
485
- await addFormField(document, operation);
486
- results.push({ op: operation.op, changed: true, name: operation.name });
487
- break;
488
- }
489
- case 'flatten_form': {
490
- document.getForm().flatten();
491
- results.push({ op: operation.op, changed: true });
492
- break;
493
- }
494
- case 'add_attachment': {
495
- const attachmentPath = resolve(dirname(path), String(operation.path || ''));
496
- await document.attach(await readFile(attachmentPath), String(operation.name || basename(attachmentPath)), {
497
- mimeType: String(operation.mimeType || 'application/octet-stream'),
498
- description: String(operation.description || ''),
499
- });
500
- results.push({ op: operation.op, changed: true, name: String(operation.name || basename(attachmentPath)) });
501
- break;
502
- }
503
- case 'compress': {
504
- results.push({ op: operation.op, changed: true, method: 'object-streams' });
505
- break;
506
- }
507
- case 'merge_pdf': {
508
- const otherPath = resolve(dirname(path), String(operation.path || ''));
509
- const other = await PDFDocument.load(await readFile(otherPath));
510
- const copied = await document.copyPages(other, other.getPageIndices());
511
- copied.forEach((page) => document.addPage(page));
512
- results.push({ op: operation.op, changed: true, pagesAdded: copied.length });
513
- break;
514
- }
515
- case 'set_metadata': {
516
- const props = operation.properties || {};
517
- if (props.title !== undefined) document.setTitle(String(props.title));
518
- if (props.author !== undefined) document.setAuthor(String(props.author));
519
- if (props.subject !== undefined) document.setSubject(String(props.subject));
520
- if (props.keywords !== undefined) document.setKeywords(Array.isArray(props.keywords) ? props.keywords.map(String) : [String(props.keywords)]);
521
- results.push({ op: operation.op, changed: true });
522
- break;
523
- }
524
- case 'move_page': {
525
- const from = Number(operation.page) - 1;
526
- const to = Number(operation.index) - 1;
527
- const count = document.getPageCount();
528
- if (!Number.isInteger(from) || from < 0 || from >= count) throw new Error(`PDF page out of range: ${operation.page}`);
529
- if (!Number.isInteger(to) || to < 0 || to >= count) throw new Error(`PDF destination page out of range: ${operation.index}`);
530
- const order = document.getPageIndices();
531
- const [moved] = order.splice(from, 1);
532
- order.splice(to, 0, moved);
533
- const next = await PDFDocument.create();
534
- const copied = await next.copyPages(document, order);
535
- copied.forEach((page) => next.addPage(page));
536
- document = next;
537
- results.push({ op: operation.op, changed: from !== to, from: from + 1, to: to + 1 });
538
- break;
539
- }
540
- default:
541
- throw new Error(`PDF backend does not support operation: ${operation.op}`);
542
- }
543
- }
544
- await writeFile(path, await document.save({ useObjectStreams: true, addDefaultPage: false }));
545
- return results;
546
- }
547
-
548
- export async function validatePdf(path) {
549
- const document = await PDFDocument.load(await readFile(path), {
550
- ignoreEncryption: false,
551
- updateMetadata: false,
552
- });
553
- return {
554
- ok: true,
555
- format: 'pdf',
556
- pages: document.getPageCount(),
557
- validation: 'pdf-parse',
558
- };
559
- }
560
-
561
- export async function issuesPdf(path, options = {}) {
562
- const snapshot = await snapshotPdf(path, { ...options, maxChars: options.maxChars || 30_000 });
563
- const issues = [];
564
- for (const page of snapshot.pages) {
565
- if (!page.text || page.text.includes('(no extractable text on this page)')) {
566
- issues.push({
567
- severity: 'warning',
568
- code: 'no_text_layer',
569
- path: page.path,
570
- message: 'Page has no extractable text layer; OCR may be required.',
571
- });
572
- }
573
- }
574
- for (const page of snapshot.likelyScannedPages) {
575
- issues.push({
576
- severity: 'warning',
577
- code: 'ocr_required',
578
- path: `/page[${page}]`,
579
- message: 'Page has no text layer. Render at high resolution and use OCR instead of treating it as empty.',
580
- });
581
- }
582
- const widgets = snapshot.fields.flatMap((field) => field.widgets.map((widget) => ({ ...widget, name: field.name, path: field.path })));
583
- for (let left = 0; left < widgets.length; left += 1) {
584
- for (let right = left + 1; right < widgets.length; right += 1) {
585
- if (widgets[left].page === widgets[right].page && rectanglesOverlap(widgets[left], widgets[right])) {
586
- issues.push({ severity: 'warning', code: 'overlapping_form_fields', path: widgets[left].path, message: `Form fields ${widgets[left].name} and ${widgets[right].name} overlap.` });
587
- }
588
- }
589
- }
590
- return { ok: true, format: 'pdf', issueCount: issues.length, issues };
591
- }