@1agh/maude 2.0.8 → 2.1.1

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 (401) hide show
  1. package/README.md +2 -1
  2. package/apps/hub/src/project-transactions/kernel.mjs +13 -7
  3. package/apps/studio/access/closure.ts +86 -10
  4. package/apps/studio/access/filters.ts +18 -1
  5. package/apps/studio/access/request.ts +8 -0
  6. package/apps/studio/acp/design-write-verb.ts +12 -2
  7. package/apps/studio/acp/env.ts +7 -2
  8. package/apps/studio/acp/index.ts +15 -4
  9. package/apps/studio/acp/login-state.ts +22 -5
  10. package/apps/studio/acp/may-scope.ts +38 -1
  11. package/apps/studio/acp/plugin-bootstrap.ts +13 -1
  12. package/apps/studio/acp/probe.ts +11 -4
  13. package/apps/studio/actions/agents.ts +110 -28
  14. package/apps/studio/actions/canvas-keys.ts +4 -2
  15. package/apps/studio/actions/ctx.ts +3 -0
  16. package/apps/studio/actions/defs/annotation.ts +84 -2
  17. package/apps/studio/actions/defs/app.ts +28 -1
  18. package/apps/studio/actions/defs/edit.ts +13 -0
  19. package/apps/studio/actions/defs/export.ts +12 -0
  20. package/apps/studio/actions/defs/sync.ts +18 -0
  21. package/apps/studio/actions/defs/video.ts +9 -0
  22. package/apps/studio/actions/documents.ts +6 -1
  23. package/apps/studio/actions/keymap.gen.ts +147 -9
  24. package/apps/studio/actions/menu.ts +5 -1
  25. package/apps/studio/actions/types.ts +4 -2
  26. package/apps/studio/actions/verbs.ts +9 -0
  27. package/apps/studio/actions.manifest.json +300 -45
  28. package/apps/studio/actions.parity.json +19 -1
  29. package/apps/studio/ai/save-hold.ts +2 -1
  30. package/apps/studio/ai/write-claim-scope.ts +7 -1
  31. package/apps/studio/ai/write-claim.ts +154 -3
  32. package/apps/studio/annotations/ai-read.ts +42 -6
  33. package/apps/studio/annotations/ai-write.ts +145 -2
  34. package/apps/studio/annotations/board-ops.ts +34 -3
  35. package/apps/studio/annotations/checklist-ops.ts +374 -0
  36. package/apps/studio/annotations/elements/checkitem.model.ts +129 -0
  37. package/apps/studio/annotations/elements/sticky.model.ts +54 -2
  38. package/apps/studio/annotations/ops.ts +30 -0
  39. package/apps/studio/annotations/registry.ts +9 -1
  40. package/apps/studio/annotations/templates.ts +4 -2
  41. package/apps/studio/annotations/text-steps.ts +114 -10
  42. package/apps/studio/annotations/ui/checklist-wire.ts +129 -0
  43. package/apps/studio/annotations/ui/checklist.tsx +429 -0
  44. package/apps/studio/annotations/ui/element-node.tsx +48 -2
  45. package/apps/studio/annotations/ui/template-place.ts +11 -1
  46. package/apps/studio/annotations/v1-adapter.ts +22 -3
  47. package/apps/studio/annotations-context-toolbar.tsx +12 -0
  48. package/apps/studio/annotations-layer.tsx +442 -49
  49. package/apps/studio/annotations-model.ts +4 -2
  50. package/apps/studio/api.ts +148 -21
  51. package/apps/studio/artboard-live-gate.tsx +54 -17
  52. package/apps/studio/artboard-still-persist.ts +166 -0
  53. package/apps/studio/artboard-still-raster.ts +6 -2
  54. package/apps/studio/artboard-still.ts +390 -20
  55. package/apps/studio/asset-added.ts +154 -0
  56. package/apps/studio/asset-details.ts +46 -3
  57. package/apps/studio/asset-origins.ts +5 -3
  58. package/apps/studio/asset-trash.ts +6 -1
  59. package/apps/studio/bin/_agent-browser-safe.mjs +3 -4
  60. package/apps/studio/bin/_annotate-post.mjs +14 -5
  61. package/apps/studio/bin/_audio-search.mjs +8 -2
  62. package/apps/studio/bin/_curl-local.mjs +7 -4
  63. package/apps/studio/bin/_desktop-locate.sh +145 -0
  64. package/apps/studio/bin/_ds-check-live.mjs +2 -1
  65. package/apps/studio/bin/_exports.mjs +38 -2
  66. package/apps/studio/bin/_history.mjs +79 -8
  67. package/apps/studio/bin/_import-asset.mjs +14 -9
  68. package/apps/studio/bin/_import-figma.mjs +510 -98
  69. package/apps/studio/bin/_index-cli.mjs +10 -21
  70. package/apps/studio/bin/_ingest-footage.mjs +24 -6
  71. package/apps/studio/bin/_media-probe.mjs +232 -0
  72. package/apps/studio/bin/_perf-probe-open.mjs +6 -0
  73. package/apps/studio/bin/_perf-probe-safari.mjs +6 -0
  74. package/apps/studio/bin/_perf-probe-studio.mjs +6 -1
  75. package/apps/studio/bin/_perf-probe.mjs +8 -3
  76. package/apps/studio/bin/_perf-sweep-shared.mjs +789 -0
  77. package/apps/studio/bin/_perf-sweep.mjs +240 -0
  78. package/apps/studio/bin/_record-shot.sh +33 -8
  79. package/apps/studio/bin/_screenshot-playwright.mjs +45 -2
  80. package/apps/studio/bin/_studio-verb.mjs +8 -3
  81. package/apps/studio/bin/_thumb-route.mjs +21 -0
  82. package/apps/studio/bin/_thumbs-playwright.mjs +83 -1
  83. package/apps/studio/bin/_transcribe.mjs +22 -6
  84. package/apps/studio/bin/_unsynced-refs.mjs +22 -0
  85. package/apps/studio/bin/_url-guard.mjs +120 -5
  86. package/apps/studio/bin/_url-guard.sh +29 -7
  87. package/apps/studio/bin/_video-limits.mjs +104 -0
  88. package/apps/studio/bin/_video-playwright.mjs +119 -19
  89. package/apps/studio/bin/_video-proxy.mjs +130 -0
  90. package/apps/studio/bin/_write-claim.mjs +38 -16
  91. package/apps/studio/bin/annotate.mjs +12 -2
  92. package/apps/studio/bin/canvas-rects.sh +19 -4
  93. package/apps/studio/bin/chat-open.sh +7 -1
  94. package/apps/studio/bin/draw-proof.sh +6 -2
  95. package/apps/studio/bin/generate.sh +32 -10
  96. package/apps/studio/bin/handoff.sh +2 -2
  97. package/apps/studio/bin/perf.sh +96 -15
  98. package/apps/studio/bin/photo-adjust.sh +6 -3
  99. package/apps/studio/bin/photo-bg-remove.sh +2 -2
  100. package/apps/studio/bin/prep.sh +21 -4
  101. package/apps/studio/bin/read-annotations.mjs +3 -0
  102. package/apps/studio/bin/runtime-health.sh +27 -1
  103. package/apps/studio/bin/screenshot.sh +152 -12
  104. package/apps/studio/bin/server-up.sh +64 -6
  105. package/apps/studio/bin/smoke.sh +43 -8
  106. package/apps/studio/bin/to-lottie.sh +3 -2
  107. package/apps/studio/bin/video-proxy.sh +27 -0
  108. package/apps/studio/bin/visual-sanity.sh +3 -1
  109. package/apps/studio/bridge/dgn-protocol.ts +157 -1
  110. package/apps/studio/bridge/mode-shows.ts +8 -6
  111. package/apps/studio/bridge/still-webp.ts +233 -0
  112. package/apps/studio/build.ts +18 -0
  113. package/apps/studio/canvas-build.ts +93 -11
  114. package/apps/studio/canvas-comment-mount.tsx +53 -8
  115. package/apps/studio/canvas-edit.ts +34 -1
  116. package/apps/studio/canvas-lib-module.ts +210 -0
  117. package/apps/studio/canvas-lib.tsx +3 -12
  118. package/apps/studio/canvas-pipeline.ts +111 -5
  119. package/apps/studio/canvas-shell.tsx +8 -11
  120. package/apps/studio/canvas-theme-pill.tsx +5 -3
  121. package/apps/studio/check/index.ts +12 -5
  122. package/apps/studio/check/video.ts +18 -2
  123. package/apps/studio/client/app.jsx +65 -7
  124. package/apps/studio/client/clipboard-relay.ts +193 -16
  125. package/apps/studio/client/comments-overlay.css +18 -0
  126. package/apps/studio/client/export-center.jsx +30 -0
  127. package/apps/studio/client/generate-dialog.jsx +49 -4
  128. package/apps/studio/client/github.js +7 -0
  129. package/apps/studio/client/home/HomeAccountsRow.jsx +221 -0
  130. package/apps/studio/client/home/HomeConnection.jsx +111 -0
  131. package/apps/studio/client/home/home-accounts-model.js +110 -1
  132. package/apps/studio/client/home/home-api.js +9 -2
  133. package/apps/studio/client/home/home-app.jsx +126 -13
  134. package/apps/studio/client/home/home-model.js +69 -1
  135. package/apps/studio/client/home/home-where-model.js +105 -0
  136. package/apps/studio/client/home/home.css +239 -1
  137. package/apps/studio/client/hooks/use-canvas-bridge.jsx +173 -98
  138. package/apps/studio/client/hooks/use-palette-and-panels.jsx +5 -1
  139. package/apps/studio/client/hooks/use-tabs.jsx +11 -4
  140. package/apps/studio/client/panels/DiffView.jsx +7 -1
  141. package/apps/studio/client/panels/TeamProjects.jsx +137 -134
  142. package/apps/studio/client/panels/chat-context.js +2 -0
  143. package/apps/studio/client/panels/slash-commands.gen.js +13 -13
  144. package/apps/studio/client/selection-scope.js +16 -9
  145. package/apps/studio/client/share-link.js +12 -0
  146. package/apps/studio/client/shell/viewport.jsx +11 -1
  147. package/apps/studio/client/shell-events.js +8 -0
  148. package/apps/studio/client/styles/3-kit-maude-v2.css +16 -0
  149. package/apps/studio/client/styles/_index.css +4 -0
  150. package/apps/studio/client/v2/ai/Feed.jsx +1 -1
  151. package/apps/studio/client/v2/ai/OfferCard.jsx +34 -0
  152. package/apps/studio/client/v2/ai/activity-line.js +54 -1
  153. package/apps/studio/client/v2/ai/ai-offer.js +21 -1
  154. package/apps/studio/client/v2/ai/run-model.js +3 -1
  155. package/apps/studio/client/v2/annotations/vote-store.js +28 -4
  156. package/apps/studio/client/v2/assets/asset-drop-session.js +37 -2
  157. package/apps/studio/client/v2/assets/canvas-drop-catcher.jsx +7 -5
  158. package/apps/studio/client/v2/assets/details-model.js +1 -1
  159. package/apps/studio/client/v2/assets/details.jsx +5 -0
  160. package/apps/studio/client/v2/assets/tile-drag.js +11 -7
  161. package/apps/studio/client/v2/comments/comments-panel.jsx +22 -3
  162. package/apps/studio/client/v2/create/duplicate-done.js +6 -2
  163. package/apps/studio/client/v2/diagnostics/diagnostics-host.jsx +1 -0
  164. package/apps/studio/client/v2/diagnostics/diagnostics-model.js +32 -2
  165. package/apps/studio/client/v2/diagnostics/diagnostics-sheet.jsx +35 -8
  166. package/apps/studio/client/v2/diagnostics/diagnostics.css +34 -0
  167. package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +113 -3
  168. package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +343 -6
  169. package/apps/studio/client/v2/diagnostics/sync-details/unsynced-refs.js +55 -0
  170. package/apps/studio/client/v2/ds/review.css +1 -1
  171. package/apps/studio/client/v2/export/exports-model.js +7 -0
  172. package/apps/studio/client/v2/export/exports-panel.jsx +1 -0
  173. package/apps/studio/client/v2/export/job-row.jsx +32 -2
  174. package/apps/studio/client/v2/handoff/ready-card.jsx +1 -1
  175. package/apps/studio/client/v2/history/compare-view.jsx +1 -0
  176. package/apps/studio/client/v2/inspector/css-write.js +6 -1
  177. package/apps/studio/client/v2/inspector/frame.jsx +28 -4
  178. package/apps/studio/client/v2/inspector/kinds/clip-model.js +51 -0
  179. package/apps/studio/client/v2/inspector/kinds/clip.jsx +75 -2
  180. package/apps/studio/client/v2/inspector/model.js +21 -0
  181. package/apps/studio/client/v2/inspector/sections/fill.jsx +12 -3
  182. package/apps/studio/client/v2/inspector/sections/recent-colours.js +8 -5
  183. package/apps/studio/client/v2/inspector/view-mode.jsx +11 -1
  184. package/apps/studio/client/v2/link-server/LinkServerDialog.jsx +492 -0
  185. package/apps/studio/client/v2/link-server/LinkServerHost.jsx +42 -0
  186. package/apps/studio/client/v2/link-server/link-server-api.js +142 -0
  187. package/apps/studio/client/v2/link-server/link-server-model.js +438 -0
  188. package/apps/studio/client/v2/link-server/link-server.css +109 -0
  189. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +31 -86
  190. package/apps/studio/client/v2/onboarding/onboarding-model.js +1 -18
  191. package/apps/studio/client/v2/preview/link-follow.js +4 -2
  192. package/apps/studio/client/v2/preview/preview-chrome-host.jsx +16 -6
  193. package/apps/studio/client/v2/search/help-model.js +2 -0
  194. package/apps/studio/client/v2/search/search-keywords.js +3 -2
  195. package/apps/studio/client/v2/settings/account.jsx +4 -2
  196. package/apps/studio/client/v2/settings/advanced-section.jsx +344 -137
  197. package/apps/studio/client/v2/settings/connection-row.jsx +3 -59
  198. package/apps/studio/client/v2/settings/connections-section.jsx +118 -425
  199. package/apps/studio/client/v2/settings/general-section.jsx +155 -24
  200. package/apps/studio/client/v2/settings/project-sync-settings.jsx +4 -3
  201. package/apps/studio/client/v2/settings/reset-section.jsx +14 -3
  202. package/apps/studio/client/v2/settings/settings-card.jsx +142 -0
  203. package/apps/studio/client/v2/settings/settings-cards.js +220 -0
  204. package/apps/studio/client/v2/settings/settings-handlers.js +7 -6
  205. package/apps/studio/client/v2/settings/settings-model.js +100 -31
  206. package/apps/studio/client/v2/settings/settings-sheet.jsx +25 -6
  207. package/apps/studio/client/v2/settings/settings.css +374 -64
  208. package/apps/studio/client/v2/settings/this-project-card.jsx +730 -0
  209. package/apps/studio/client/v2/settings/this-project-model.js +172 -0
  210. package/apps/studio/client/v2/settings/use-connections.js +3 -2
  211. package/apps/studio/client/v2/settings/use-open-card.js +37 -0
  212. package/apps/studio/client/v2/share/share-sheet.jsx +28 -11
  213. package/apps/studio/client/v2/shell/api-session-boot.js +6 -0
  214. package/apps/studio/client/v2/shell/api-session.js +126 -0
  215. package/apps/studio/client/v2/shell/connection-state.js +197 -0
  216. package/apps/studio/client/v2/shell/floating-panels.css +31 -1
  217. package/apps/studio/client/v2/shell/image-pick.js +61 -8
  218. package/apps/studio/client/v2/shell/menu-aim.js +43 -0
  219. package/apps/studio/client/v2/shell/menu-runner.js +25 -7
  220. package/apps/studio/client/v2/shell/occlusion-insets.js +18 -1
  221. package/apps/studio/client/v2/shell/project-account-bus.js +36 -0
  222. package/apps/studio/client/v2/shell/project-account-card.jsx +357 -148
  223. package/apps/studio/client/v2/shell/project-account-model.js +272 -149
  224. package/apps/studio/client/v2/shell/project-account-toast.js +66 -0
  225. package/apps/studio/client/v2/shell/project-account.css +237 -0
  226. package/apps/studio/client/v2/shell/project-pill.jsx +52 -6
  227. package/apps/studio/client/v2/shell/share-cluster-host.jsx +166 -83
  228. package/apps/studio/client/v2/shell/shell-parity.js +3 -2
  229. package/apps/studio/client/v2/shell/shell-parity.json +71 -36
  230. package/apps/studio/client/v2/shell/still-bridge.js +194 -0
  231. package/apps/studio/client/v2/shell/still-store.js +319 -0
  232. package/apps/studio/client/v2/shell/use-account.js +2 -0
  233. package/apps/studio/client/v2/shell/use-tool-panels.js +2 -1
  234. package/apps/studio/client/v2/signin/use-signin.js +1 -1
  235. package/apps/studio/client/v2/timeline/Timeline.jsx +15 -0
  236. package/apps/studio/client/v2/timeline/frame-handle-model.js +142 -0
  237. package/apps/studio/client/v2/timeline/frame-handle.jsx +151 -0
  238. package/apps/studio/clip-ops.ts +126 -8
  239. package/apps/studio/cloud/endpoints.ts +29 -4
  240. package/apps/studio/collab/ai-activity.ts +10 -8
  241. package/apps/studio/collab/awareness-bridge.ts +34 -9
  242. package/apps/studio/collab/index.ts +3 -0
  243. package/apps/studio/collab/registry.ts +41 -10
  244. package/apps/studio/comment-reattach.ts +149 -0
  245. package/apps/studio/comments/mine-stamp.ts +15 -7
  246. package/apps/studio/comments/ops.ts +52 -8
  247. package/apps/studio/comments-overlay.tsx +146 -9
  248. package/apps/studio/dist/client.bundle.js +892 -885
  249. package/apps/studio/dist/comment-mount.js +2 -2
  250. package/apps/studio/dist/styles.css +1 -1
  251. package/apps/studio/dom-selection.ts +87 -18
  252. package/apps/studio/ds/board/directions.css +8 -0
  253. package/apps/studio/ds/board/outline.tsx +16 -0
  254. package/apps/studio/ds/canvas-check.ts +6 -0
  255. package/apps/studio/edit-ops/clip/reframe.ts +19 -3
  256. package/apps/studio/edit-ops/clip-carry.ts +602 -0
  257. package/apps/studio/edit-ops/clipboard.ts +318 -23
  258. package/apps/studio/edit-ops/dispatch.ts +20 -2
  259. package/apps/studio/edit-ops/scope-names.ts +249 -40
  260. package/apps/studio/edit-ops/slot-defaults.ts +3 -0
  261. package/apps/studio/edit-ops/types.ts +6 -0
  262. package/apps/studio/editing/align-bar.tsx +33 -9
  263. package/apps/studio/editing/artboard-actions.ts +5 -0
  264. package/apps/studio/editing/artboard-menu.tsx +6 -2
  265. package/apps/studio/editing/click-to-type.ts +1 -1
  266. package/apps/studio/editing/clip-words.ts +48 -0
  267. package/apps/studio/editing/clipboard.ts +21 -6
  268. package/apps/studio/editing/declared-background.ts +25 -0
  269. package/apps/studio/editing/index.tsx +3 -0
  270. package/apps/studio/editing/object-keys.ts +4 -4
  271. package/apps/studio/editing/object-menu.tsx +13 -3
  272. package/apps/studio/editing/pen/points.tsx +61 -0
  273. package/apps/studio/editing/text-in-place.tsx +11 -0
  274. package/apps/studio/editing/video-frame-handle.tsx +425 -0
  275. package/apps/studio/exporters/capture-prepass.ts +374 -0
  276. package/apps/studio/exporters/degraded.ts +148 -0
  277. package/apps/studio/exporters/hub-render-door.ts +28 -2
  278. package/apps/studio/exporters/index.ts +3 -1
  279. package/apps/studio/exporters/job-budget.ts +93 -0
  280. package/apps/studio/exporters/jobs.ts +215 -28
  281. package/apps/studio/exporters/parity-check.ts +254 -0
  282. package/apps/studio/exporters/remote.ts +209 -15
  283. package/apps/studio/exporters/svg-inline.ts +87 -0
  284. package/apps/studio/exporters/video-render-lib.ts +88 -26
  285. package/apps/studio/exporters/video.ts +29 -6
  286. package/apps/studio/figma/assets.ts +58 -43
  287. package/apps/studio/figma/codegen-fonts.ts +100 -0
  288. package/apps/studio/figma/fig-decode.ts +390 -25
  289. package/apps/studio/figma/fig-kiwi.ts +18 -4
  290. package/apps/studio/figma/fig-vector.ts +59 -3
  291. package/apps/studio/figma/sanitize.ts +2 -0
  292. package/apps/studio/figma/style-map.ts +293 -48
  293. package/apps/studio/figma/to-artboard.ts +455 -69
  294. package/apps/studio/figma/to-strokes.ts +44 -11
  295. package/apps/studio/figma/types.ts +13 -0
  296. package/apps/studio/footage/schema.ts +3 -3
  297. package/apps/studio/generation/adapters/elevenlabs.ts +7 -1
  298. package/apps/studio/generation/adapters/groq.ts +8 -1
  299. package/apps/studio/generation/spend.ts +312 -0
  300. package/apps/studio/generation/types.ts +12 -0
  301. package/apps/studio/handoff/run.ts +1 -1
  302. package/apps/studio/handoff/targets.ts +2 -2
  303. package/apps/studio/handoff/write-scopes.ts +1 -1
  304. package/apps/studio/history/describe-annotations.ts +4 -0
  305. package/apps/studio/home/accounts.ts +30 -11
  306. package/apps/studio/home/cloud.ts +6 -1
  307. package/apps/studio/home/create-local.ts +32 -3
  308. package/apps/studio/home/hub-health.ts +76 -0
  309. package/apps/studio/home/routes.ts +15 -4
  310. package/apps/studio/http.ts +438 -86
  311. package/apps/studio/imported-module-ids.ts +91 -0
  312. package/apps/studio/inspect.ts +2 -0
  313. package/apps/studio/migrate/hub.ts +8 -1
  314. package/apps/studio/notifications.tsx +47 -5
  315. package/apps/studio/paths.ts +10 -1
  316. package/apps/studio/port.ts +3 -2
  317. package/apps/studio/preview/preview-camera.tsx +15 -382
  318. package/apps/studio/readiness.ts +10 -1
  319. package/apps/studio/release-build.ts +51 -0
  320. package/apps/studio/routes/agent.ts +188 -9
  321. package/apps/studio/routes/ai.ts +43 -11
  322. package/apps/studio/routes/annotations.ts +27 -1
  323. package/apps/studio/routes/assets.ts +18 -1
  324. package/apps/studio/routes/canvas-origin.ts +12 -9
  325. package/apps/studio/routes/cloud-move.ts +15 -0
  326. package/apps/studio/routes/edit.ts +3 -0
  327. package/apps/studio/routes/export.ts +51 -0
  328. package/apps/studio/routes/generate.ts +42 -12
  329. package/apps/studio/routes/hub-link-folder.ts +334 -0
  330. package/apps/studio/routes/hub-signin.ts +78 -1
  331. package/apps/studio/routes/index.ts +9 -1
  332. package/apps/studio/routes/shell.ts +217 -5
  333. package/apps/studio/routes/sync.ts +136 -8
  334. package/apps/studio/routes/votes.ts +2 -1
  335. package/apps/studio/schema/annotations.v2.schema.json +143 -1
  336. package/apps/studio/schema/beats.v1.schema.json +1 -1
  337. package/apps/studio/schema/edl.v1.schema.json +1 -1
  338. package/apps/studio/schema/formats.ts +3 -3
  339. package/apps/studio/schema/transcript.v1.schema.json +1 -1
  340. package/apps/studio/server.ts +142 -43
  341. package/apps/studio/shell/api-key.ts +503 -0
  342. package/apps/studio/shell/attest.ts +59 -0
  343. package/apps/studio/shell/capture-url.ts +20 -0
  344. package/apps/studio/shell/cli-yield.ts +276 -0
  345. package/apps/studio/shell/clip-transfer.ts +302 -0
  346. package/apps/studio/shell/key-file.ts +108 -0
  347. package/apps/studio/shell/server-json.ts +75 -0
  348. package/apps/studio/shell/worktree.ts +19 -0
  349. package/apps/studio/spoof-chars.ts +9 -0
  350. package/apps/studio/studio-page-host.ts +1 -1
  351. package/apps/studio/sync/accepted-cold-start.ts +144 -8
  352. package/apps/studio/sync/accepted-link.ts +76 -29
  353. package/apps/studio/sync/action-stage.ts +575 -44
  354. package/apps/studio/sync/adopt-held.ts +85 -0
  355. package/apps/studio/sync/ctl-heal.ts +58 -0
  356. package/apps/studio/sync/file-ledger.ts +38 -4
  357. package/apps/studio/sync/file-membership.ts +16 -1
  358. package/apps/studio/sync/file-plane.ts +289 -22
  359. package/apps/studio/sync/held-deletes.ts +86 -5
  360. package/apps/studio/sync/hub-link.ts +8 -0
  361. package/apps/studio/sync/index.ts +196 -12
  362. package/apps/studio/sync/journal-client.ts +50 -4
  363. package/apps/studio/sync/link-consent.ts +22 -75
  364. package/apps/studio/sync/link-survey.ts +252 -0
  365. package/apps/studio/sync/local-kernel.ts +296 -8
  366. package/apps/studio/sync/projection.ts +22 -3
  367. package/apps/studio/sync/seed-progress.ts +12 -0
  368. package/apps/studio/sync/source-recovery.ts +59 -3
  369. package/apps/studio/sync/status.ts +19 -2
  370. package/apps/studio/sync/unsynced-refs.ts +397 -0
  371. package/apps/studio/sync/writer-registry.ts +20 -0
  372. package/apps/studio/thumbs/service.ts +4 -1
  373. package/apps/studio/tool-palette.tsx +23 -0
  374. package/apps/studio/ui-prefs.ts +40 -0
  375. package/apps/studio/use-agent-presence.tsx +2 -2
  376. package/apps/studio/use-canvas-keys.ts +6 -1
  377. package/apps/studio/video/format-ids.ts +2 -2
  378. package/apps/studio/video/inject.ts +31 -0
  379. package/apps/studio/video/media-risk.ts +58 -0
  380. package/apps/studio/video/object-fit.ts +137 -0
  381. package/apps/studio/video/provider-transcript.ts +141 -0
  382. package/apps/studio/whats-new.json +137 -0
  383. package/apps/studio/workspace-mode.ts +1 -0
  384. package/apps/studio/ws.ts +5 -0
  385. package/cli/commands/design.mjs +119 -8
  386. package/cli/lib/bash-guard.mjs +366 -6
  387. package/cli/lib/confine-read.mjs +1 -0
  388. package/cli/lib/design-help.gen.mjs +3 -2
  389. package/cli/lib/design-hook.mjs +387 -81
  390. package/cli/lib/design-link.mjs +16 -1
  391. package/cli/lib/design-open.mjs +49 -3
  392. package/cli/lib/desktop-locate.mjs +770 -0
  393. package/cli/lib/handoff.mjs +1 -1
  394. package/cli/lib/hook-state.mjs +291 -0
  395. package/cli/lib/pkg-root.mjs +65 -13
  396. package/cli/lib/studio-locate.mjs +59 -16
  397. package/package.json +15 -8
  398. package/plugins/design/templates/_shell.html +13 -0
  399. package/apps/studio/client/v2/onboarding/HubSheet.jsx +0 -212
  400. package/apps/studio/client/v2/shell/account-card-model.js +0 -114
  401. package/apps/studio/client/v2/shell/account-card.jsx +0 -189
@@ -27,6 +27,9 @@
27
27
  // CLI: `node _url-guard.mjs <url>` → exit 0 (allowed, nothing printed) · 2 (refused, reason on
28
28
  // stderr). Pure Node ESM, no dependencies beyond the sibling _curl-local.mjs.
29
29
 
30
+ import { closeSync, lstatSync, readFileSync, unlinkSync } from 'node:fs';
31
+ import { homedir } from 'node:os';
32
+ import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
30
33
  import { pathToFileURL } from 'node:url';
31
34
 
32
35
  import { isLoopbackAddress } from './_curl-local.mjs';
@@ -49,8 +52,37 @@ export function ownPorts(env = process.env) {
49
52
  return ports.every((p) => p > 0 && p < 65536) ? ports : null;
50
53
  }
51
54
 
52
- /** Why `raw` may not be opened by a browser helper, or null when it may. */
53
- export function urlRefusal(raw, env = process.env) {
55
+ const LAUNCH_RE = /maude-launch/i;
56
+ const LAUNCH_MSG =
57
+ "a Maude opening link (maude-launch) is for the person's own browser, never this one";
58
+ const UNDECODABLE_MSG = 'the URL has an escape that does not decode';
59
+
60
+ /**
61
+ * sec-loopback-bearer §7.5 (re-check B/C) — a one-time opening link opens a full studio session, so a
62
+ * browser helper never takes one from its caller. Parsed as the server parses it (`URLSearchParams`
63
+ * decodes leniently), every key and value is checked, case-insensitively; a query or fragment that does
64
+ * not decode is refused rather than checked in its raw form.
65
+ */
66
+ export function launchRefusal(u, raw) {
67
+ const msg = LAUNCH_MSG;
68
+ try {
69
+ decodeURIComponent(u.search);
70
+ decodeURIComponent(u.hash);
71
+ decodeURIComponent(u.pathname);
72
+ } catch {
73
+ return UNDECODABLE_MSG;
74
+ }
75
+ if (LAUNCH_RE.test(raw) || LAUNCH_RE.test(decodeURIComponent(u.href))) return msg;
76
+ for (const [k, v] of u.searchParams) if (LAUNCH_RE.test(k) || LAUNCH_RE.test(v)) return msg;
77
+ return null;
78
+ }
79
+
80
+ /**
81
+ * Why `raw` may not be opened by a browser helper, or null when it may. `allowLaunch` only for a link
82
+ * the helper minted itself or took from the server's private folder (screenshot.sh), never one its
83
+ * caller passed.
84
+ */
85
+ export function urlRefusal(raw, env = process.env, opts = {}) {
54
86
  if (typeof raw !== 'string' || raw === '') return 'no URL given';
55
87
  // biome-ignore lint/suspicious/noControlCharactersInRegex: the control range is the point
56
88
  if (/[\u0000- \u007f\\]/.test(raw)) return 'the URL has spaces, control characters or "\\"';
@@ -73,14 +105,97 @@ export function urlRefusal(raw, env = process.env) {
73
105
  if (!mine.includes(port))
74
106
  return `only this project's own Maude server is allowed, not port ${port}`;
75
107
  }
108
+ if (!opts.allowLaunch) return launchRefusal(u, raw);
76
109
  return null;
77
110
  }
78
111
 
112
+ /** A log line never carries a one-time opening link or a frame capability (stderr reaches the AI). */
113
+ export function redactUrl(s) {
114
+ return String(s).replace(/(maude-launch|fc)=[^&#\s"']*/gi, '$1=…');
115
+ }
116
+
117
+ /**
118
+ * `<state>/maude/servers/links` — the server's private folder for a link it hands a capture helper
119
+ * (shell/key-file.ts `serverLinkDir`; inside the key folder the AI chat's Read is denied).
120
+ */
121
+ export function linkFileDir(env = process.env) {
122
+ const s = env.XDG_STATE_HOME;
123
+ const state = s && isAbsolute(s) ? s : join(env.HOME || homedir(), '.local', 'state');
124
+ return join(state, 'maude', 'servers', 'links');
125
+ }
126
+
127
+ const LINK_NAME_RE = /^[0-9a-f]{32}\.url$/;
128
+
129
+ /**
130
+ * sec-loopback-bearer §7.5 (re-check A) — take the link the server wrote for `screenshot --url-file`:
131
+ * only `<linkFileDir>/<32 hex>.url`, a regular file of this user that nobody else may read, in a 0700
132
+ * folder of this user. Anything else is refused WITHOUT being read or removed (the flag is reachable
133
+ * from an auto-tier verb). → `{ url }` (the file is gone) or `{ error }`.
134
+ */
135
+ export function takeLinkFile(path, env = process.env) {
136
+ const refuse = (why) => ({ error: `--url-file takes only a link Maude wrote for it (${why})` });
137
+ if (typeof path !== 'string' || !isAbsolute(path)) return refuse('not an absolute path');
138
+ const dir = linkFileDir(env);
139
+ if (resolve(path) !== path || dirname(path) !== dir || !LINK_NAME_RE.test(basename(path)))
140
+ return refuse('not in its folder');
141
+ const uid = typeof process.getuid === 'function' ? process.getuid() : null;
142
+ try {
143
+ const d = lstatSync(dir);
144
+ if (!d.isDirectory() || (uid !== null && d.uid !== uid) || (d.mode & 0o077) !== 0)
145
+ return refuse('its folder is not private');
146
+ const f = lstatSync(path);
147
+ if (!f.isFile() || (uid !== null && f.uid !== uid) || (f.mode & 0o077) !== 0 || f.size > 4096)
148
+ return refuse('not a private file');
149
+ const url = readFileSync(path, 'utf8').split('\n')[0].trim();
150
+ unlinkSync(path);
151
+ return { url };
152
+ } catch {
153
+ return refuse('unreadable');
154
+ }
155
+ }
156
+
157
+ /**
158
+ * sec-loopback-bearer §7.4–7.5 (re-check A) — the perf probes' opening link, on a pipe perf.sh hands
159
+ * them as fd 3–9 (`--launch-fd 3 3< <(studio_launch_url …)`): no file, so nothing to read or delete
160
+ * anywhere else. The first line; '' when the fd is not open or not one of those.
161
+ */
162
+ export function readLaunchFd(arg) {
163
+ if (!/^[3-9]$/.test(String(arg))) return '';
164
+ const fd = Number(arg);
165
+ try {
166
+ return readFileSync(fd, 'utf8').split('\n')[0].trim();
167
+ } catch {
168
+ return '';
169
+ } finally {
170
+ try {
171
+ closeSync(fd);
172
+ } catch {}
173
+ }
174
+ }
175
+
79
176
  function main() {
80
- const [url, ...extra] = process.argv.slice(2);
81
- const why = extra.length ? 'expected exactly one URL' : urlRefusal(url);
177
+ const argv = process.argv.slice(2);
178
+ if (argv[0] === '--take-link-file') {
179
+ const r = argv.length === 2 ? takeLinkFile(argv[1]) : { error: 'expected one path' };
180
+ if (r.error) {
181
+ process.stderr.write(`maude: ${r.error}.\n`);
182
+ process.exit(2);
183
+ }
184
+ process.stdout.write(`${r.url}\n`);
185
+ return;
186
+ }
187
+ const allowLaunch = argv[0] === '--launch-ok';
188
+ const [url, ...extra] = allowLaunch ? argv.slice(1) : argv;
189
+ const why = extra.length
190
+ ? 'expected exactly one URL'
191
+ : urlRefusal(url, process.env, { allowLaunch });
82
192
  if (why) {
83
- process.stderr.write(`maude: refusing to open ${JSON.stringify(url ?? '')}: ${why}.\n`);
193
+ // a refused opening link is never echoed, not even redacted (an encoded name escapes the pattern)
194
+ const shown =
195
+ why === LAUNCH_MSG || why === UNDECODABLE_MSG
196
+ ? 'that link'
197
+ : JSON.stringify(redactUrl(url ?? ''));
198
+ process.stderr.write(`maude: refusing to open ${shown}: ${why}.\n`);
84
199
  process.exit(2);
85
200
  }
86
201
  }
@@ -1,16 +1,38 @@
1
- # _url-guard.sh — sourced by the browser helpers (V2-8.9 B2). `maude_url_guard <url>` returns 0 when
2
- # a browser may open <url> (http(s) to this Mac only — the rule lives in _url-guard.mjs) and prints
3
- # the refusal and returns 2 otherwise. Node when present, else bun (the packaged app stages a `bun`
4
- # shim for every helper, DDR-177); neither → refused, never skipped.
1
+ # _url-guard.sh — sourced by the browser helpers (V2-8.9 B2). `maude_url_guard [--launch-ok] <url>`
2
+ # returns 0 when a browser may open <url> (http(s) to this Mac only, and never a one-time opening link
3
+ # unless the helper passes --launch-ok for a link it minted itself — the rule lives in _url-guard.mjs)
4
+ # and prints the refusal and returns 2 otherwise. Node when present, else bun (the packaged app stages a
5
+ # `bun` shim for every helper, DDR-177); neither → refused, never skipped.
6
+ #
7
+ # `maude_redact <text>` — the one redaction every helper log line goes through (sec-loopback-bearer
8
+ # §7.5, re-check E): `maude-launch=` and `fc=` values never reach stderr, which the AI chat reads.
5
9
  maude_url_guard() {
6
10
  local guard
7
11
  guard="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_url-guard.mjs"
8
12
  if command -v node >/dev/null 2>&1; then
9
- node "$guard" "$1" || return 2
13
+ node "$guard" "$@" || return 2
10
14
  elif command -v bun >/dev/null 2>&1; then
11
- bun run "$guard" "$1" || return 2
15
+ bun run "$guard" "$@" || return 2
12
16
  else
13
- echo "maude: refusing to open $1: node (or bun) is needed to check the URL." >&2
17
+ echo "maude: refusing to open that URL: node (or bun) is needed to check it." >&2
14
18
  return 2
15
19
  fi
16
20
  }
21
+
22
+ # `maude_take_link_file <path>` — prints the link the server left for this helper and removes the file;
23
+ # refuses (2) any path outside the server's private link folder without reading or removing it.
24
+ maude_take_link_file() {
25
+ local guard
26
+ guard="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_url-guard.mjs"
27
+ if command -v node >/dev/null 2>&1; then
28
+ node "$guard" --take-link-file "$1" || return 2
29
+ elif command -v bun >/dev/null 2>&1; then
30
+ bun run "$guard" --take-link-file "$1" || return 2
31
+ else
32
+ return 2
33
+ fi
34
+ }
35
+
36
+ maude_redact() {
37
+ printf '%s' "$*" | sed -E "s/(maude-launch|fc)=[^&#[:space:]\"']*/\\1=…/g"
38
+ }
@@ -0,0 +1,104 @@
1
+ // _video-limits.mjs — the pure decisions of the video capture shim (_video-playwright.mjs):
2
+ // how long it may run, what it says when it is killed, and the default output scale.
3
+ // Kept out of the shim so bun:test can pin them without a browser. Issue #128 §2.
4
+
5
+ /** The old flat ceiling, now the floor: setup + a short render never needed more. */
6
+ export const HARD_KILL_BASE_MS = 150_000;
7
+ /** Budget per frame. The frame-step fallback measures ~2.5 s/frame (exporters/video.ts), so 3 s
8
+ * leaves headroom for a slower Mac without letting a wedged run hang for hours. */
9
+ export const HARD_KILL_PER_FRAME_MS = 3_000;
10
+ /** Once frames are completing, the render is only killed after this long WITHOUT a new frame. */
11
+ export const HARD_KILL_STALL_MS = 150_000;
12
+
13
+ /** The wall-clock budget for a render of `frames` frames (0 / unknown → the old flat ceiling). */
14
+ export function hardKillBudgetMs({ timeoutMs, frames }) {
15
+ const floor = Math.max(Number(timeoutMs) || 0, HARD_KILL_BASE_MS);
16
+ const n = Number.isFinite(frames) && frames > 0 ? frames : 0;
17
+ return floor + n * HARD_KILL_PER_FRAME_MS;
18
+ }
19
+
20
+ /**
21
+ * The self-kill watchdog. The deadline is `start + hardKillBudgetMs(frames)`, pushed out to
22
+ * `lastProgress + HARD_KILL_STALL_MS` while frames keep completing, so a long export that is making
23
+ * progress is never killed and a wedged one still is. The timer re-checks the (moving) deadline
24
+ * when it fires instead of being re-armed on every frame.
25
+ *
26
+ * `setFrames(n)` — the frame count became known (comp meta / --frames), possibly after the fast
27
+ * path failed. `progress()` — a frame completed. `stop()` — the render finished.
28
+ */
29
+ export function createHardKill({
30
+ timeoutMs,
31
+ onKill,
32
+ now = Date.now,
33
+ setTimer = setTimeout,
34
+ clearTimer = clearTimeout,
35
+ }) {
36
+ const startedAt = now();
37
+ let frames = 0;
38
+ let lastProgress = null;
39
+ let handle = null;
40
+ let stopped = false;
41
+
42
+ const deadline = () => {
43
+ const byBudget = startedAt + hardKillBudgetMs({ timeoutMs, frames });
44
+ return lastProgress === null ? byBudget : Math.max(byBudget, lastProgress + HARD_KILL_STALL_MS);
45
+ };
46
+ const arm = () => {
47
+ if (stopped) return;
48
+ const wait = Math.max(0, deadline() - now());
49
+ handle = setTimer(() => {
50
+ if (stopped) return;
51
+ if (now() < deadline()) return arm();
52
+ onKill(deadline() - startedAt);
53
+ }, wait);
54
+ handle?.unref?.();
55
+ };
56
+ arm();
57
+ return {
58
+ setFrames(n) {
59
+ if (Number.isFinite(n) && n > 0) frames = n;
60
+ },
61
+ progress() {
62
+ lastProgress = now();
63
+ },
64
+ stop() {
65
+ stopped = true;
66
+ if (handle) clearTimer(handle);
67
+ },
68
+ };
69
+ }
70
+
71
+ /** The text printed when the watchdog fires — honest about the machine it is on (issue #128 §2b). */
72
+ export function hardTimeoutMessage({ ms, platform, gpu, frame, total }) {
73
+ const got =
74
+ Number.isFinite(frame) && frame > 0 && Number.isFinite(total) && total > 0
75
+ ? ` It made it to frame ${frame} of ${total}.`
76
+ : '';
77
+ let hint;
78
+ if (platform === 'darwin') {
79
+ hint =
80
+ 'on macOS this is usually a long or heavy capture (the cost grows with frames and with the ' +
81
+ 'export scale) or a stalled video encoder — try a lower scale or a shorter range';
82
+ } else if (platform === 'linux') {
83
+ hint = 'on headless Linux this is usually the video encoder or GPU init';
84
+ } else {
85
+ hint = 'this is usually a long or heavy capture or a stalled video encoder';
86
+ }
87
+ return (
88
+ `_video-playwright: HARD TIMEOUT after ${ms}ms — exiting. The render did not complete` +
89
+ ` (see the last stage logged above; ${hint}).${got} gpu=${gpu ? 'on' : 'off'}.`
90
+ );
91
+ }
92
+
93
+ /**
94
+ * Default output scale when the user passed none (decision maude/burndown-d6-default-export-scale):
95
+ * 1× when the artboard's short side is already >= 1080 px (a social-format Reel at 1080×1900 gains
96
+ * nothing from 2160×3804 and pays double per frame), else 2× so a small comp is not a tiny capture.
97
+ * An artboard that could not be measured keeps the historical 2×.
98
+ */
99
+ export function defaultVideoScale(width, height) {
100
+ const w = Number(width);
101
+ const h = Number(height);
102
+ if (!Number.isFinite(w) || !Number.isFinite(h) || w <= 0 || h <= 0) return 2;
103
+ return Math.min(w, h) >= 1080 ? 1 : 2;
104
+ }
@@ -31,6 +31,7 @@ import {
31
31
  launchChromium,
32
32
  newShellContext,
33
33
  } from './_pw-launch.mjs';
34
+ import { createHardKill, defaultVideoScale, hardTimeoutMessage } from './_video-limits.mjs';
34
35
 
35
36
  const args = Object.fromEntries(
36
37
  process.argv.slice(2).reduce((acc, cur, i, all) => {
@@ -67,25 +68,43 @@ if (!url) {
67
68
  }
68
69
 
69
70
  const timeoutMs = Number(timeout) * 1000;
70
- const deviceScaleFactor = Math.max(1, Math.min(4, Number(scale) || 1));
71
+ // `--scale auto` (the exporter's answer when the user passed none): the artboard is measured once the
72
+ // browser is up and the default is picked from its size (issue #128 §2c, _video-limits.mjs).
73
+ const scaleIsAuto = scale === 'auto';
74
+ let deviceScaleFactor = Math.max(1, Math.min(4, Number(scale) || 1));
71
75
 
72
76
  // Hard self-kill — the whole shim, not just individual Playwright calls, has a
73
77
  // wall-clock ceiling. `launchChromium` has NO timeout, and on headless Linux
74
78
  // `--enable-gpu` can hang Chromium at GPU-process init before a single log line
75
79
  // — a silent wedge that ate the full 600s render budget with nothing to show.
76
80
  // This guarantees the process EXITS with a diagnostic instead of hanging, so
77
- // the render worker (and the export gate) fail fast and legibly. Generous
78
- // enough for a slow software encode; well under any job/test budget.
79
- const HARD_KILL_MS = Math.max(timeoutMs, 150_000);
80
- const hardKill = setTimeout(() => {
81
- console.error(
82
- `_video-playwright: HARD TIMEOUT after ${HARD_KILL_MS}ms — exiting. The render did not ` +
83
- `complete (see the last stage logged above; on headless Linux this is usually the video ` +
84
- `encoder or GPU init). gpu=${process.env.MAUDE_CAPTURE_GPU === '1' ? 'on' : 'off'}.`
85
- );
86
- process.exit(7);
87
- }, HARD_KILL_MS);
88
- hardKill.unref?.();
81
+ // the render worker (and the export gate) fail fast and legibly.
82
+ //
83
+ // The ceiling is NOT flat (issue #128 §2a): the frame-step fallback runs ~2.5 s/frame, so a flat
84
+ // 150 s killed a 1294-frame comp at frame 413. The budget grows with the frame count (known once
85
+ // the comp meta / --frames is read) and is stretched while frames keep completing; only a render
86
+ // that stops producing frames, or never starts, hits it.
87
+ let lastFrame = 0;
88
+ let totalFrames = 0;
89
+ const hardKill = createHardKill({
90
+ timeoutMs,
91
+ onKill: (ms) => {
92
+ console.error(
93
+ hardTimeoutMessage({
94
+ ms,
95
+ platform: process.platform,
96
+ gpu: process.env.MAUDE_CAPTURE_GPU === '1',
97
+ frame: lastFrame,
98
+ total: totalFrames,
99
+ })
100
+ );
101
+ process.exit(7);
102
+ },
103
+ });
104
+ if (Number(framesArg) > 0) {
105
+ totalFrames = Number(framesArg);
106
+ hardKill.setFrames(totalFrames);
107
+ }
89
108
  // `--audio` is presence-checked (Object.fromEntries maps a bare flag to '1'), so
90
109
  // absence of the flag entirely (not passed) still defaults to audio ON — video.ts
91
110
  // always passes an explicit '0'/'1'.
@@ -148,8 +167,62 @@ const gpuArgs =
148
167
  console.error(
149
168
  `_video-playwright: launching chromium (gpu=${gpuArgs.length ? 'on' : 'off'}, format=${format})`
150
169
  );
170
+ const widen = args.widen !== undefined;
171
+ const selector = selectorArg
172
+ ? selectorArg
173
+ : artboard
174
+ ? `[data-dc-screen="${cssEscape(artboard)}"]`
175
+ : '[data-dc-screen]';
176
+
177
+ /**
178
+ * `--scale auto`: load the canvas once at 1x, measure the target artboard and pick the default
179
+ * scale from its short side (decision maude/burndown-d6-default-export-scale). A device scale
180
+ * factor is fixed per browser context, so the real run opens a fresh context at the result.
181
+ * Anything that goes wrong measuring keeps the historical 2x.
182
+ */
183
+ async function probeDefaultScale(browser) {
184
+ try {
185
+ const { ctx, goto } = await newShellContext(browser, {
186
+ serviceWorkers: 'block',
187
+ viewport: { width: 1440, height: 900 },
188
+ deviceScaleFactor: 1,
189
+ });
190
+ try {
191
+ const page = await ctx.newPage();
192
+ await goto(page, url, { waitUntil: 'load', timeout: timeoutMs });
193
+ const target = page.locator(selector).first();
194
+ await target.waitFor({ state: 'visible', timeout: timeoutMs });
195
+ await page.evaluate(() => {
196
+ const world = document.querySelector('.dc-world');
197
+ if (world) {
198
+ world.style.zoom = '1';
199
+ world.style.transform = 'none';
200
+ }
201
+ });
202
+ const size = await target.evaluate((el, wide) => {
203
+ const ab = wide ? (el.closest('[data-dc-screen]') ?? el) : el;
204
+ const r = ab.getBoundingClientRect();
205
+ return { width: r.width, height: r.height };
206
+ }, widen);
207
+ const chosen = defaultVideoScale(size.width, size.height);
208
+ console.error(
209
+ `_video-playwright: scale auto → ${chosen}x (artboard ${Math.round(size.width)}×${Math.round(size.height)})`
210
+ );
211
+ return chosen;
212
+ } finally {
213
+ await ctx.close().catch(() => {});
214
+ }
215
+ } catch (e) {
216
+ console.error(
217
+ `_video-playwright: scale auto: could not measure the artboard (${e instanceof Error ? e.message : e}) — using 2x`
218
+ );
219
+ return defaultVideoScale(0, 0);
220
+ }
221
+ }
222
+
151
223
  const browser = await launchChromium(gpuArgs.length ? { args: gpuArgs } : undefined);
152
224
  console.error('_video-playwright: browser launched');
225
+ if (scaleIsAuto) deviceScaleFactor = await probeDefaultScale(browser);
153
226
  try {
154
227
  // gate-b-c4d — confined to the origin the shell lands on (popups, other origins refused).
155
228
  const { ctx, goto: gotoShell } = await newShellContext(browser, {
@@ -202,12 +275,6 @@ try {
202
275
  // Resolve the target artboard handle. Priority: explicit --selector (from the
203
276
  // export scope Target) → --artboard id → first artboard. `--widen` climbs to
204
277
  // the enclosing [data-dc-screen] (the descendant-selector export case).
205
- const widen = args.widen !== undefined;
206
- const selector = selectorArg
207
- ? selectorArg
208
- : artboard
209
- ? `[data-dc-screen="${cssEscape(artboard)}"]`
210
- : '[data-dc-screen]';
211
278
  const located = page.locator(selector).first();
212
279
  await located.waitFor({ state: 'visible', timeout: timeoutMs });
213
280
  const handle = widen
@@ -282,6 +349,27 @@ try {
282
349
  const frameRange =
283
350
  Number.isFinite(explicitFrames) && explicitFrames > 0 ? [0, explicitFrames - 1] : null;
284
351
 
352
+ // #150 §4 / #128 §8 — before the render starts, list what the renderer will not draw the
353
+ // way the Player does (the parity scan, exporters/parity-check.ts). A warning only: any
354
+ // failure here costs the warning, never the export.
355
+ let parity = null;
356
+ try {
357
+ if ((await page.evaluate(() => typeof window.__maudeParityCheck__)) === 'function') {
358
+ const scan = await evalWithTimeout(
359
+ page,
360
+ (id) => window.__maudeParityCheck__(id),
361
+ compId,
362
+ 15_000,
363
+ 'parity check'
364
+ );
365
+ if (scan && Array.isArray(scan.findings) && scan.findings.length > 0) parity = scan;
366
+ }
367
+ } catch (e) {
368
+ console.error(
369
+ `_video-playwright: parity check skipped: ${e instanceof Error ? e.message : e}`
370
+ );
371
+ }
372
+
285
373
  // Bound the whole-comp render: @remotion/web-renderer drives WebCodecs,
286
374
  // which on headless Linux without a working encoder never resolves — a
287
375
  // hang, not a throw, so the graceful frame-step fallback below never
@@ -324,6 +412,11 @@ try {
324
412
  const frameCount = frameRange
325
413
  ? frameRange[1] - frameRange[0] + 1
326
414
  : (compMeta?.durationInFrames ?? 0);
415
+ // The fast path can fail and hand over to frame-step: the budget must already know the length.
416
+ if (frameCount > 0) {
417
+ totalFrames = frameCount;
418
+ hardKill.setFrames(frameCount);
419
+ }
327
420
 
328
421
  const result = {
329
422
  fps: compMeta?.fps ?? null,
@@ -335,6 +428,9 @@ try {
335
428
  container: rendered.container,
336
429
  codec: rendered.videoCodec,
337
430
  audioCodec: rendered.audioCodec,
431
+ // only when the one-pass renderer drew this file: the frame-step path is Chromium's own
432
+ // compositor and has none of these gaps
433
+ ...(parity ? { parity } : {}),
338
434
  };
339
435
  const ms = Date.now() - t0;
340
436
  // Same shape as the frame-step line, so the two paths are directly
@@ -480,6 +576,8 @@ async function frameStepCapture({
480
576
  const maxFrames = Number(maxFramesArg) > 0 ? Number(maxFramesArg) : 3600;
481
577
  const wantedFrames = Number(framesArg) || compMeta?.durationInFrames || Math.round(fps * 3); // 3 s default
482
578
  const frameCount = Math.min(maxFrames, wantedFrames);
579
+ totalFrames = frameCount;
580
+ hardKill.setFrames(frameCount);
483
581
  if (wantedFrames > maxFrames) {
484
582
  console.error(
485
583
  `⚠ _video-playwright: comp is ${wantedFrames} frames but the export cap is ` +
@@ -615,6 +713,8 @@ async function frameStepCapture({
615
713
  // "N of M" instead of a static "Exporting…". Filtered out of the summary
616
714
  // stdout the exporter reads. Human log stays throttled on stderr.
617
715
  console.log(`MAUDE_PROGRESS {"current":${f + 1},"total":${frameCount}}`);
716
+ lastFrame = f + 1;
717
+ hardKill.progress();
618
718
  if (f % 30 === 0) console.error(`frame ${f + 1}/${frameCount}`);
619
719
  }
620
720
 
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env node
2
+ // _video-proxy.mjs — make an H.264 / constant-frame-rate / single-AAC copy of one video asset, behind
3
+ // `maude design video-proxy` (DDR-062 dispatch). #128 §1, root cause of #127.
4
+ //
5
+ // WHY: an iPhone clip (HEVC, variable frame rate) or a `.mov` with a second audio track plays in the Player
6
+ // but the export's audio renderer cannot decode it — the export then falls back to frame-by-frame capture
7
+ // and the file ships with no sound. A proxy is the fix: the same picture and sound in a form the export can
8
+ // read. It is an EXPLICIT action, never automatic: the user's file is never converted behind their back, and
9
+ // the original is only ever read. The copy is a new asset next to it, `assets/<sha8>.mp4` (content-
10
+ // addressed like every asset, so it resolves everywhere one does); put it in the canvas in place of the clip.
11
+ //
12
+ // Needs ffmpeg + ffprobe (a soft dependency, never bundled — DDR-177). The file is read only from inside
13
+ // `<designRoot>/assets/` (realpath-checked). Reached via `maude design video-proxy`, never a raw path.
14
+ //
15
+ // stdout = JSON { source, proxy, reused, found:[label], width?, height?, fps }. Exit: 0 ok · 2 usage ·
16
+ // 3 no ffmpeg/ffprobe · 4 not a readable video · 6 outside assets/ · 1 other.
17
+
18
+ import { realpathSync, statSync } from 'node:fs';
19
+ import { isAbsolute, relative, resolve, sep } from 'node:path';
20
+ import { pathToFileURL } from 'node:url';
21
+
22
+ import { makeProxy, ProxyError, proxyFps } from './_media-probe.mjs';
23
+
24
+ class UsageError extends Error {
25
+ constructor(message, code = 2) {
26
+ super(message);
27
+ this.code = code;
28
+ }
29
+ }
30
+
31
+ const VIDEO_EXT = /\.(?:mp4|m4v|mov|webm)$/i;
32
+
33
+ /** The absolute path of a video inside `<root>/<designRootRel>/assets`, or throw. */
34
+ export function resolveAsset(asset, root, designRootRel = '.design') {
35
+ const assetsDir = realpathSync(resolve(root, designRootRel, 'assets'));
36
+ const given = String(asset);
37
+ const abs = isAbsolute(given)
38
+ ? given
39
+ : resolve(root, designRootRel, given.replace(/^\.?\/+/, ''));
40
+ let real;
41
+ try {
42
+ real = realpathSync(abs);
43
+ } catch {
44
+ throw new UsageError(`no such asset: ${given}`);
45
+ }
46
+ const rel = relative(assetsDir, real);
47
+ if (!rel || rel.startsWith('..') || isAbsolute(rel) || rel.includes(sep)) {
48
+ throw new UsageError('the clip must be a file directly inside the project’s assets/ folder', 6);
49
+ }
50
+ if (!VIDEO_EXT.test(rel)) throw new UsageError(`${rel} is not a video (mp4, m4v, mov, webm)`, 4);
51
+ if (!statSync(real).isFile()) throw new UsageError(`${rel} is not a file`, 4);
52
+ return { real, assetsDir, name: rel };
53
+ }
54
+
55
+ /** Make the proxy. Returns the manifest the verb prints. */
56
+ export function videoProxy({ asset, root, designRootRel = '.design', ffmpeg, ffprobe }) {
57
+ const { real, assetsDir, name } = resolveAsset(asset, root, designRootRel);
58
+ const r = makeProxy({ src: real, outDir: assetsDir, ffmpeg, ffprobe });
59
+ return {
60
+ source: `assets/${name}`,
61
+ proxy: `assets/${r.name}`,
62
+ reused: r.reused,
63
+ found: r.issues.map((i) => i.label),
64
+ width: r.probe.video.width,
65
+ height: r.probe.video.height,
66
+ fps: proxyFps(r.probe),
67
+ };
68
+ }
69
+
70
+ const HELP = `video-proxy — make an H.264 copy of a video asset that exports with sound
71
+ (reached via \`maude design video-proxy\`)
72
+
73
+ Usage:
74
+ maude design video-proxy assets/<clip> --root <repo> [--design-root .design]
75
+
76
+ Writes a new asset next to the original — assets/<sha8>.mp4: H.264, constant frame rate,
77
+ the first audio track as AAC. The original is never changed; use the copy in the canvas in
78
+ its place. Needs ffmpeg and ffprobe. Do this for a clip the import or an export said is HEVC,
79
+ variable frame rate, or has more than one audio track.
80
+
81
+ Exit: 0 ok · 2 usage · 3 no ffmpeg · 4 not a readable video · 6 outside assets/ · 1 other.`;
82
+
83
+ function parseArgv(argv) {
84
+ const out = { asset: null, root: null, designRoot: '.design', help: false };
85
+ for (let i = 0; i < argv.length; i += 1) {
86
+ const a = argv[i];
87
+ if (a === '--root') out.root = argv[++i];
88
+ else if (a === '--design-root') out.designRoot = argv[++i];
89
+ else if (a === '--help' || a === '-h') out.help = true;
90
+ else if (a.startsWith('-')) throw new UsageError(`unknown flag ${a}`);
91
+ else if (out.asset === null) out.asset = a;
92
+ else throw new UsageError(`unexpected extra arg ${a}`);
93
+ }
94
+ return out;
95
+ }
96
+
97
+ function main() {
98
+ let opts;
99
+ try {
100
+ opts = parseArgv(process.argv.slice(2));
101
+ } catch (err) {
102
+ process.stderr.write(`video-proxy: ${err.message}\n`);
103
+ process.exit(err.code ?? 2);
104
+ }
105
+ if (opts.help) {
106
+ process.stdout.write(`${HELP}\n`);
107
+ return;
108
+ }
109
+ if (!opts.asset) {
110
+ process.stderr.write('video-proxy: an asset is required (assets/<clip>)\n');
111
+ process.exit(2);
112
+ }
113
+ const root = opts.root || process.env.CLAUDE_PROJECT_DIR || process.cwd();
114
+ try {
115
+ process.stderr.write(
116
+ 'video-proxy: making an H.264 copy — this can take a while for a long clip\n'
117
+ );
118
+ const r = videoProxy({ asset: opts.asset, root, designRootRel: opts.designRoot });
119
+ if (r.found.length)
120
+ process.stderr.write(`video-proxy: the original is ${r.found.join(', ')}\n`);
121
+ process.stdout.write(`${JSON.stringify(r, null, 2)}\n`);
122
+ } catch (err) {
123
+ process.stderr.write(`video-proxy: ${err.message}\n`);
124
+ process.exit(err instanceof UsageError || err instanceof ProxyError ? err.code : 1);
125
+ }
126
+ }
127
+
128
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
129
+ main();
130
+ }