@openartifactsai/cli 0.23.0-rc.0 → 0.24.0

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 (128) hide show
  1. package/SKILL.md +7 -2
  2. package/package.json +1 -1
  3. package/vendor/CHANGELOG.md +1082 -0
  4. package/vendor/artifact-types/page/SKILL.md +3 -1
  5. package/vendor/artifact-types/page/artifact-type/reference/capabilities.d.ts +0 -1
  6. package/vendor/artifact-types/page/artifact-type/reference/capabilities.md +1 -1
  7. package/vendor/frame-host/client/comments.js +20 -19
  8. package/vendor/frame-host/client/page.js +1352 -0
  9. package/vendor/frame-host/client/review.js +279 -0
  10. package/vendor/frame-host/client/runtime.js +8 -6
  11. package/vendor/frame-host/client/sample.js +1 -1
  12. package/vendor/frame-host/client/shell.css +1 -0
  13. package/vendor/frame-host/client/shell.js +206 -6
  14. package/vendor/frame-host/client/translate.js +375 -0
  15. package/vendor/frame-host/frame-host.mjs +267 -82
  16. package/vendor/home/assets/{browser-models-DWkPVHmp.js → browser-models-Ceon9UIN.js} +4 -4
  17. package/vendor/home/assets/library-RBaguEV9.js +397 -0
  18. package/vendor/home/assets/main-BKHYngAm.js +2 -0
  19. package/vendor/home/assets/main-Cw3mY0u9.css +1 -0
  20. package/vendor/home/assets/node.browser-BFrmG6rb.js +1 -0
  21. package/vendor/home/assets/node.browser-CPQVYRMD.js +1 -0
  22. package/vendor/home/assets/react-DQymU5Da.js +47 -0
  23. package/vendor/home/index.html +3 -3
  24. package/vendor/home/library/index.html +2 -2
  25. package/vendor/open-artifacts.mjs +2516 -1072
  26. package/vendor/runtime.json +1 -1
  27. package/vendor/shell/assets/{browser-models-BzwWAVuE.js → browser-models-CiXqE7b9.js} +4 -4
  28. package/vendor/shell/assets/index-BhxD6amu.js +53 -0
  29. package/vendor/shell/assets/index-Cw3mY0u9.css +1 -0
  30. package/vendor/shell/assets/{node.browser-BgqLTfql.js → node.browser-ByUkO9oN.js} +1 -1
  31. package/vendor/shell/assets/{node.browser-BvryIsl7.js → node.browser-CSEwiusG.js} +1 -1
  32. package/vendor/shell/index.html +2 -2
  33. package/vendor/type-server/cli.mjs +362 -197
  34. package/vendor/type-server/editors/data/assets/{index-CX_sn7ZZ.js → index-B0E35R1E.js} +5 -4
  35. package/vendor/type-server/editors/data/index.html +1 -1
  36. package/vendor/type-server/editors/design/assets/{index-BpNUmTVD.js → index-BOc3kd6N.js} +78 -77
  37. package/vendor/type-server/editors/design/index.html +1 -1
  38. package/vendor/type-server/editors/design-system/assets/{index-CP6AEO1P.js → index-B7MtPrtk.js} +5 -4
  39. package/vendor/type-server/editors/design-system/index.html +1 -1
  40. package/vendor/type-server/editors/docs/assets/{abnfDiagram-WEYOIA3C-Do25i7oS.js → abnfDiagram-WEYOIA3C-DcfGbMC9.js} +1 -1
  41. package/vendor/type-server/editors/docs/assets/{architectureDiagram-ZHVYKT53-BLlpboc2.js → architectureDiagram-ZHVYKT53-CfcGFZjM.js} +1 -1
  42. package/vendor/type-server/editors/docs/assets/{blockDiagram-RJAE7QA3-D0rO5p7M.js → blockDiagram-RJAE7QA3-C5s3aXD2.js} +1 -1
  43. package/vendor/type-server/editors/docs/assets/{c4Diagram-XDPPPE54-OoTiysJI.js → c4Diagram-XDPPPE54-BJgchX97.js} +1 -1
  44. package/vendor/type-server/editors/docs/assets/channel-B2TtMfsN.js +1 -0
  45. package/vendor/type-server/editors/docs/assets/{chunk-2E7WHVMD-yBl5BEaI.js → chunk-2E7WHVMD-BgQ4xapY.js} +1 -1
  46. package/vendor/type-server/editors/docs/assets/{chunk-2Q5K7J3B-DHKM5gd6.js → chunk-2Q5K7J3B-B1ktgQTo.js} +1 -1
  47. package/vendor/type-server/editors/docs/assets/{chunk-4EMNKR2T-B-f8WPM6.js → chunk-4EMNKR2T-Co-2oGfa.js} +1 -1
  48. package/vendor/type-server/editors/docs/assets/{chunk-55XCU76K-n8RDJr36.js → chunk-55XCU76K-BqpDaZgl.js} +1 -1
  49. package/vendor/type-server/editors/docs/assets/{chunk-5VM5RSS4-DzLzcqXE.js → chunk-5VM5RSS4-BJPvauTV.js} +1 -1
  50. package/vendor/type-server/editors/docs/assets/{chunk-JWPE2WC7-BLXkUVcK.js → chunk-JWPE2WC7-NCBAl-SW.js} +1 -1
  51. package/vendor/type-server/editors/docs/assets/{chunk-VQ5W62QI-DAGNVD29.js → chunk-VQ5W62QI-DPzloG3R.js} +1 -1
  52. package/vendor/type-server/editors/docs/assets/{chunk-XXDRQBXY-fgVyAbWV.js → chunk-XXDRQBXY-D08KAfXl.js} +1 -1
  53. package/vendor/type-server/editors/docs/assets/{chunk-ZCHMQSOR-D90xHR9n.js → chunk-ZCHMQSOR-CLWESu07.js} +2 -2
  54. package/vendor/type-server/editors/docs/assets/{classDiagram-v2-4MYWR3UA-uk1mPogR.js → classDiagram-v2-4MYWR3UA-BSPsabsn.js} +1 -1
  55. package/vendor/type-server/editors/docs/assets/{core-BMv5rGOd.js → core-Cqu2ilBr.js} +1 -1
  56. package/vendor/type-server/editors/docs/assets/{cose-bilkent-JH36ORCC-BJdqW8l3.js → cose-bilkent-JH36ORCC-D6at9M78.js} +1 -1
  57. package/vendor/type-server/editors/docs/assets/{cynefin-EF2NZ3EQ-BCce_ZhK.js → cynefin-EF2NZ3EQ-BTylb97F.js} +1 -1
  58. package/vendor/type-server/editors/docs/assets/{cynefinDiagram-WF24UDRP-DxD-4yjR.js → cynefinDiagram-WF24UDRP-Din3pKvL.js} +1 -1
  59. package/vendor/type-server/editors/docs/assets/{dagre-NK4GIZVX-B3VAS51Y.js → dagre-NK4GIZVX-5qfRwQnt.js} +1 -1
  60. package/vendor/type-server/editors/docs/assets/{diagram-CBK3MWTC-B0kHeUdr.js → diagram-CBK3MWTC-BnrAjIhJ.js} +1 -1
  61. package/vendor/type-server/editors/docs/assets/{diagram-I5XIIV2D-BCRvsLAu.js → diagram-I5XIIV2D-CH_xkoKv.js} +1 -1
  62. package/vendor/type-server/editors/docs/assets/{diagram-ODIL2UCW-DFOTsSuA.js → diagram-ODIL2UCW-D5dns2KC.js} +1 -1
  63. package/vendor/type-server/editors/docs/assets/{diagram-PFBEJUXE-_DT3jk0i.js → diagram-PFBEJUXE-D-3cnWXB.js} +1 -1
  64. package/vendor/type-server/editors/docs/assets/{diagram-RJA3I4VV-UFrdnTgs.js → diagram-RJA3I4VV-DImejfKM.js} +1 -1
  65. package/vendor/type-server/editors/docs/assets/{diagram-TYUNFSNR-DrbWyZOX.js → diagram-TYUNFSNR-DscxSG0M.js} +1 -1
  66. package/vendor/type-server/editors/docs/assets/{ebnfDiagram-V4P3TTPT-M-DCWgZM.js → ebnfDiagram-V4P3TTPT-C4wwb0NC.js} +1 -1
  67. package/vendor/type-server/editors/docs/assets/{elk-QONTBCTQ-l6XmbRQj.js → elk-QONTBCTQ-O05tgWzI.js} +1 -1
  68. package/vendor/type-server/editors/docs/assets/{erDiagram-KYQIGQAA-CHqbnmEE.js → erDiagram-KYQIGQAA-D171V8gY.js} +1 -1
  69. package/vendor/type-server/editors/docs/assets/{flowDiagram-IUGLLWBU-BzkFyGCL.js → flowDiagram-IUGLLWBU-DcvtJsgJ.js} +1 -1
  70. package/vendor/type-server/editors/docs/assets/{ganttDiagram-R7GPNTJY-BcNaSXNv.js → ganttDiagram-R7GPNTJY-DcuQ9a5m.js} +1 -1
  71. package/vendor/type-server/editors/docs/assets/{gitGraphDiagram-PDYL7XHY-JaNdSZbv.js → gitGraphDiagram-PDYL7XHY-iQoh6Yen.js} +1 -1
  72. package/vendor/type-server/editors/docs/assets/{index-BMNUnwXE.js → index-BNk_Jpgl.js} +49 -48
  73. package/vendor/type-server/editors/docs/assets/{infoDiagram-MVDRKAX5-Cl2Q_Ylf.js → infoDiagram-MVDRKAX5-DECkmgI6.js} +1 -1
  74. package/vendor/type-server/editors/docs/assets/{ishikawaDiagram-HPEHV2GE-umirqIpN.js → ishikawaDiagram-HPEHV2GE-CK0mATvD.js} +1 -1
  75. package/vendor/type-server/editors/docs/assets/{journeyDiagram-BOSHW7O7-HMtvkXvq.js → journeyDiagram-BOSHW7O7-Dz1u7rfA.js} +1 -1
  76. package/vendor/type-server/editors/docs/assets/{kanban-definition-FNSA4HC5-CYouTBUM.js → kanban-definition-FNSA4HC5-B1-0Mp0R.js} +1 -1
  77. package/vendor/type-server/editors/docs/assets/{mermaid.core-BEcbgpI8.js → mermaid.core-DhXbeevr.js} +4 -4
  78. package/vendor/type-server/editors/docs/assets/{mindmap-definition-6OY57UG3-BnwugHtV.js → mindmap-definition-6OY57UG3-Czy5C8sa.js} +1 -1
  79. package/vendor/type-server/editors/docs/assets/{pegDiagram-ECIUJNBX-DqT6jxo7.js → pegDiagram-ECIUJNBX-C97juwaO.js} +1 -1
  80. package/vendor/type-server/editors/docs/assets/{pieDiagram-GNMPY74T-CBKjnr1W.js → pieDiagram-GNMPY74T-rrh7flvh.js} +1 -1
  81. package/vendor/type-server/editors/docs/assets/{quadrantDiagram-D57K4MC3-CdTG11Ff.js → quadrantDiagram-D57K4MC3-D3xBy1ZX.js} +1 -1
  82. package/vendor/type-server/editors/docs/assets/{railroadDiagram-Y72NRBL7-BZgG8r2y.js → railroadDiagram-Y72NRBL7-B3r2jnFu.js} +1 -1
  83. package/vendor/type-server/editors/docs/assets/{requirementDiagram-EQYSW5RA-CutdnAmY.js → requirementDiagram-EQYSW5RA-BQ47C1Ra.js} +1 -1
  84. package/vendor/type-server/editors/docs/assets/{sankeyDiagram-SY24JHO5-DBaoPDhR.js → sankeyDiagram-SY24JHO5-CzPG7mjJ.js} +1 -1
  85. package/vendor/type-server/editors/docs/assets/{sequenceDiagram-BLEHNHQU-B6YZp-Wu.js → sequenceDiagram-BLEHNHQU-Bg7XKU4E.js} +1 -1
  86. package/vendor/type-server/editors/docs/assets/{sizeCapture-INFHLROL-xATlK6Zl.js → sizeCapture-INFHLROL-CKrHufer.js} +1 -1
  87. package/vendor/type-server/editors/docs/assets/{stateDiagram-v2-A6IESKWZ-C7BND5vv.js → stateDiagram-v2-A6IESKWZ-CW9zsuBs.js} +1 -1
  88. package/vendor/type-server/editors/docs/assets/{swimlanes-B3ENRKFQ-WYLzM6hb.js → swimlanes-B3ENRKFQ-ucM-4idg.js} +1 -1
  89. package/vendor/type-server/editors/docs/assets/swimlanesDiagram-AYQRV4AK-DuNOy5jj.js +8 -0
  90. package/vendor/type-server/editors/docs/assets/{timeline-definition-JXYKGLGB-BXC0F4xE.js → timeline-definition-JXYKGLGB-D__Vd4zC.js} +1 -1
  91. package/vendor/type-server/editors/docs/assets/{usecaseDiagram-WPOLBNNX-Cx58jkEj.js → usecaseDiagram-WPOLBNNX-MvJGETnL.js} +1 -1
  92. package/vendor/type-server/editors/docs/assets/{vennDiagram-Q3Y3IDCW-DhdwpApW.js → vennDiagram-Q3Y3IDCW-DqUtQLGR.js} +1 -1
  93. package/vendor/type-server/editors/docs/assets/{wardleyDiagram-IVAIDKWA-CBdbPWVr.js → wardleyDiagram-IVAIDKWA-usWt7-Hk.js} +1 -1
  94. package/vendor/type-server/editors/docs/assets/{xychartDiagram-4URNHDU4-Cb0tcPqs.js → xychartDiagram-4URNHDU4-D2RJz2yB.js} +1 -1
  95. package/vendor/type-server/editors/docs/index.html +1 -1
  96. package/vendor/type-server/editors/motion/assets/{gif-jobs-Bq4rwLBV.js → gif-jobs-Bn-j8izW.js} +1 -1
  97. package/vendor/type-server/editors/motion/assets/{index-BDOqtmcc.js → index-C6NXgLix.js} +7 -6
  98. package/vendor/type-server/editors/motion/assets/{src-8SKXU1IY.js → src-C0eDPv3h.js} +1 -1
  99. package/vendor/type-server/editors/motion/index.html +1 -1
  100. package/vendor/type-server/editors/sheets/assets/{index-BY38EAff.js → index-BzbNSKJF.js} +7 -6
  101. package/vendor/type-server/editors/sheets/assets/{workbook-worker-CRtLrZhP.js → workbook-worker-3zEBX9ep.js} +3 -2
  102. package/vendor/type-server/editors/sheets/index.html +1 -1
  103. package/vendor/type-server/editors/slides/assets/{index-B51oMclO.js → index-BfTA-zoQ.js} +7 -6
  104. package/vendor/type-server/editors/slides/assets/{src-CdsEFSuC.js → src-DPkvzCL6.js} +1 -1
  105. package/vendor/type-server/editors/slides/index.html +1 -1
  106. package/vendor/type-server/editors/whiteboard/assets/{drawing-look-worker-Dd2iYbXC.js → drawing-look-worker-CYqIJdVf.js} +4 -3
  107. package/vendor/type-server/editors/whiteboard/assets/{gif-jobs-DmIqT6gk.js → gif-jobs-CPyG3MAt.js} +1 -1
  108. package/vendor/type-server/editors/whiteboard/assets/{index-B3oRKavi.js → index-BBgN0Gcr.js} +2 -2
  109. package/vendor/type-server/editors/whiteboard/assets/{index-CTf9pd4S.js → index-BKFgBbwk.js} +8 -7
  110. package/vendor/type-server/editors/whiteboard/index.html +1 -1
  111. package/vendor/type-server/shell/assets/{browser-models-BzwWAVuE.js → browser-models-CiXqE7b9.js} +4 -4
  112. package/vendor/type-server/shell/assets/index-BhxD6amu.js +53 -0
  113. package/vendor/type-server/shell/assets/index-Cw3mY0u9.css +1 -0
  114. package/vendor/type-server/shell/assets/{node.browser-BgqLTfql.js → node.browser-ByUkO9oN.js} +1 -1
  115. package/vendor/type-server/shell/assets/{node.browser-BvryIsl7.js → node.browser-CSEwiusG.js} +1 -1
  116. package/vendor/type-server/shell/index.html +2 -2
  117. package/vendor/home/assets/RuntimeUpdate-BwvJ9sYp.js +0 -43
  118. package/vendor/home/assets/library-CyeaNaQo.js +0 -226
  119. package/vendor/home/assets/main-DUyobyFI.js +0 -5
  120. package/vendor/home/assets/main-DXpv3z2x.css +0 -1
  121. package/vendor/home/assets/node.browser-Cy4GM7Yl.js +0 -1
  122. package/vendor/home/assets/node.browser-nUfHL25Z.js +0 -1
  123. package/vendor/shell/assets/index-BIHLxOO6.js +0 -52
  124. package/vendor/shell/assets/index-DXpv3z2x.css +0 -1
  125. package/vendor/type-server/editors/docs/assets/channel-Cgat34ii.js +0 -1
  126. package/vendor/type-server/editors/docs/assets/swimlanesDiagram-AYQRV4AK-Bwh1tnzE.js +0 -8
  127. package/vendor/type-server/shell/assets/index-BIHLxOO6.js +0 -52
  128. package/vendor/type-server/shell/assets/index-DXpv3z2x.css +0 -1
@@ -396,6 +396,16 @@ var init_library = __esm({
396
396
  /** `GET`/`HEAD ?id=`: the artifact's folder as a .zip (the type server's `/__open-artifacts/archive`). */
397
397
  archive: "artifact.archive",
398
398
  thumbnail: "artifacts.thumbnail",
399
+ /**
400
+ * `POST` {@link ThumbnailPickRequest}: the thumbnail the person chose, shown and shared in place of the one captured
401
+ * of the page until removed; `picture: null` removes it, back to the captured one. Answers the {@link ArtifactView}.
402
+ */
403
+ thumbnailPick: "artifacts.thumbnail.pick",
404
+ /**
405
+ * `POST` {@link ThumbnailViewRequest}: a PNG of the artifact's page as the person sees it, at their view's size, taken
406
+ * in headless Chrome (`unsupported` when this computer has none). For "Use current view".
407
+ */
408
+ thumbnailView: "artifacts.thumbnail.view",
399
409
  restore: "artifacts.restore",
400
410
  open: "artifacts.open",
401
411
  /** `GET ?id=`: the finished {@link ShellBoot} of an artifact (waits for its page to open; never `pending`). */
@@ -491,18 +501,21 @@ var init_library = __esm({
491
501
  typesRestart: "types.restart",
492
502
  /**
493
503
  * `POST` a zip (`Content-Type: application/zip`, `?folder=` optional): an artifact archive made into a local artifact,
494
- * opened only by a type of the uid its `.artifact.json` names (`type_missing` otherwise). From the CLI or the home
495
- * page, never from a page.
504
+ * opened only by a type of the uid its `.artifact.json` names (`type_missing` otherwise). Or JSON `{ url, folder? }`:
505
+ * a local copy of an artifact shared to the web, from its copy link (`parseWebShareCopyLink`), or of a design canvas
506
+ * shared on claude.ai, from its link (`https://claude.ai/artifact/<id>`), downloaded, checked and added the same way.
507
+ * From the CLI or the home page, never from a page.
496
508
  */
497
509
  import: "artifacts.import",
498
510
  /**
499
511
  * Local runtime version and updates (`GET runtime.status` → {@link RuntimeStatus}, `POST runtime.check` →
500
- * {@link RuntimeStatus}, `POST runtime.update` → {@link RuntimeUpdateResult}). Same-origin or CLI only;
501
- * `runtime.update` is refused inside an agent's session.
512
+ * {@link RuntimeStatus}, `POST runtime.update` → {@link RuntimeUpdateResult}, `GET runtime.changelog` →
513
+ * release notes). Same-origin or CLI only; `runtime.update` is refused inside an agent's session.
502
514
  */
503
515
  runtimeStatus: "runtime.status",
504
516
  runtimeCheck: "runtime.check",
505
517
  runtimeUpdate: "runtime.update",
518
+ runtimeChangelog: "runtime.changelog",
506
519
  /**
507
520
  * Model sources, the permissions to use them, and usage ({@link SAMPLE_LIBRARY_ROUTES}, bodies in sample.ts):
508
521
  * `models.list`, `models.set`, `models.remove`, `models.test`, `models.catalog`, `grants.list`, `grants.answer`,
@@ -682,16 +695,33 @@ var init_link = __esm({
682
695
  }
683
696
  });
684
697
 
698
+ // packages/protocol/src/network.ts
699
+ var init_network = __esm({
700
+ "packages/protocol/src/network.ts"() {
701
+ "use strict";
702
+ }
703
+ });
704
+
685
705
  // packages/protocol/src/share.ts
686
706
  var WEB_SHARE_PREVIEW_MAX_BYTES;
687
707
  var init_share = __esm({
688
708
  "packages/protocol/src/share.ts"() {
689
709
  "use strict";
690
710
  init_legacy_wire();
711
+ init_network();
691
712
  WEB_SHARE_PREVIEW_MAX_BYTES = 1 << 20;
692
713
  }
693
714
  });
694
715
 
716
+ // packages/protocol/src/claude-link.ts
717
+ var init_claude_link = __esm({
718
+ "packages/protocol/src/claude-link.ts"() {
719
+ "use strict";
720
+ init_network();
721
+ init_share();
722
+ }
723
+ });
724
+
695
725
  // packages/protocol/src/media-types.ts
696
726
  function mediaTypeOf(path20) {
697
727
  const ext = path20.slice(path20.lastIndexOf(".") + 1).toLowerCase();
@@ -797,7 +827,7 @@ var ARTIFACT_ACTIONS, DATA_ACTIONS, COMMENTS_ACTIONS, ARTIFACT_PANELS, ARTIFACT_
797
827
  var init_tools = __esm({
798
828
  "packages/protocol/src/tools.ts"() {
799
829
  "use strict";
800
- ARTIFACT_ACTIONS = ["quickstart", "list", "publish", "read", "open", "call", "adopt", "delete", "share"];
830
+ ARTIFACT_ACTIONS = ["quickstart", "list", "publish", "read", "open", "call", "adopt", "import", "delete", "share"];
801
831
  DATA_ACTIONS = ["get", "list", "query", "set", "update", "delete", "str_replace", "batch"];
802
832
  COMMENTS_ACTIONS = ["read", "reply", "resolve", "reopen", "wait"];
803
833
  ARTIFACT_PANELS = ["share", "export"];
@@ -807,7 +837,7 @@ var init_tools = __esm({
807
837
  action: {
808
838
  type: "string",
809
839
  enum: ARTIFACT_ACTIONS,
810
- description: "What to do: quickstart, list, publish, read, open, call, adopt, delete or share. Omitted: publish."
840
+ description: "What to do: quickstart, list, publish, read, open, call, adopt, import, delete or share. Omitted: publish."
811
841
  },
812
842
  intent: {
813
843
  type: "string",
@@ -832,12 +862,16 @@ var init_tools = __esm({
832
862
  title: { type: "string", description: "publish without url: the new artifact's name. quickstart: the name it will have, to find similar ones." },
833
863
  folder: {
834
864
  type: "string",
835
- description: "publish without url: the exact folder for the new artifact (absolute, or relative to the workspace), only when the person named one. Omitted: Open Artifacts chooses the folder and its name. adopt: the folder to add."
865
+ description: "publish without url, import: the exact folder for the new artifact (absolute, or relative to the workspace; for import, one that does not exist yet), only when the person named one. Omitted: Open Artifacts chooses the folder and its name. adopt: the folder to add."
836
866
  },
837
867
  location: {
838
868
  type: "string",
839
869
  enum: ["home", "workspace"],
840
- description: "publish without url: where the new artifact's folder goes when the person asked: workspace (in the project, under the working folder) or home (the person's Open Artifacts folder). Omitted: what the person's settings say. The folder is named from the title either way."
870
+ description: "publish without url, import: where the new artifact's folder goes when the person asked: workspace (in the project, under the working folder) or home (the person's Open Artifacts folder). Omitted: what the person's settings say. The folder is named from the title either way."
871
+ },
872
+ source: {
873
+ type: "string",
874
+ description: "import: the copy link of an artifact shared to the web (https://<host>/a/<id>/copy), or its share page link (https://<host>/a/<id>); or the link of a design canvas shared on claude.ai (https://claude.ai/artifact/<id>)."
841
875
  },
842
876
  url: { type: "string", description: "An artifact: open-artifacts://artifact/<id>, as publish returned it." },
843
877
  files: {
@@ -859,7 +893,7 @@ var init_tools = __esm({
859
893
  open: {
860
894
  type: "string",
861
895
  enum: ["after_first_write", "now", "never"],
862
- description: "publish without url: after_first_write (the default) opens the page in your app once your first write lands; now opens it at once; never leaves it closed. Where your app cannot show pages by itself the result says so: open view_url in your app's built-in browser, if you have one."
896
+ description: "publish without url: after_first_write (the default) opens the page in your app once your first write lands; now opens it at once; never leaves it closed. import: now (the default) opens the copy once it is made; never leaves it closed. Where your app cannot show pages by itself the result says so: open view_url in your app's built-in browser, if you have one."
863
897
  },
864
898
  related: { type: "boolean", description: "quickstart: list existing artifacts the recommended type can build on, such as design systems (default true)." },
865
899
  path: { type: "string", description: "read: one file or folder under the root (omitted: the record and the file list)." },
@@ -941,6 +975,7 @@ var init_tools = __esm({
941
975
  `- open {url, panel?}: show it to the person in the computer's browser (or the app, when it shows pages), once its content is written. When your app has a built-in browser, open view_url there instead. panel "share" or "export" opens its Share panel or Export tab for them.`,
942
976
  "- call {url, name, args?}: run one of the type's actions (check, upload, ...). A long one answers {task, pending: true}; its result comes later as a message.",
943
977
  "- adopt {url | folder}: take over an artifact, or add an existing folder. Only when the person asks.",
978
+ "- import {source}: make a local copy of an artifact shared to the web, from its copy link (https://\u2026/a/<id>/copy) or its page link, or of a design canvas shared on claude.ai (https://claude.ai/artifact/<id>), as a design.",
944
979
  "- share {url}: whether it is shared on the local network, and its links. Only the person changes that, in the page's Share panel.",
945
980
  "- delete {url}: forget an artifact; its folder stays. Only when the person asks."
946
981
  ].join("\n"),
@@ -953,7 +988,7 @@ var init_tools = __esm({
953
988
  ArtifactComments: { title: "Artifact comments", destructiveHint: false, openWorldHint: false }
954
989
  };
955
990
  TOOL_ACTION_KINDS = {
956
- Artifact: { quickstart: "read", list: "read", read: "read", publish: "write", call: "write", open: "ui", delete: "remove", adopt: "remove", share: "person" },
991
+ Artifact: { quickstart: "read", list: "read", read: "read", publish: "write", call: "write", import: "write", open: "ui", delete: "remove", adopt: "remove", share: "person" },
957
992
  // `delete` removes one document inside the artifact (an element of a board): an edit, not removing the artifact.
958
993
  ArtifactData: { get: "read", list: "read", query: "read", set: "write", update: "write", str_replace: "write", batch: "write", delete: "write" },
959
994
  ArtifactComments: { read: "read", wait: "read", reply: "write", resolve: "write", reopen: "write" }
@@ -1060,6 +1095,7 @@ Decide where your output will live before you make anything.
1060
1095
  MAKING_ARTIFACTS = `<making_artifacts>
1061
1096
  - Continuing earlier work: find the artifact with Artifact {action: "list"} and change that one. Do not make a second artifact for a new version.
1062
1097
  - A new artifact: call Artifact {action: "quickstart", intent} once, before reading a type's skill or writing any file, unless you already hold the type's type_url. Then create it with the create call that quickstart returns.
1098
+ - A copy link (https://\u2026/a/<id>/copy) is an artifact someone shared to the web: Artifact {action: "import", source: "<the link>"} makes a local copy of it. A design canvas shared on claude.ai (https://claude.ai/artifact/<id>) is copied the same way, as a design.
1063
1099
  - Create the artifact once you have the material: its folder starts empty. By default (open: "after_first_write"), the page opens for the person after your first write and shows the rest as it lands, when your app shows pages by itself; open: "never" keeps it closed.
1064
1100
  - The create result carries the type's instructions. Read them before writing and follow them: they are the type's own guide to its files.
1065
1101
  - Write the files into root with your own file tools. Then, when the type has a check (the create result's next names it), run it (Artifact {action: "call", url, name: "check"}) and fix what it reports; a type without one, such as page, says how to look at the result instead.
@@ -1139,13 +1175,6 @@ var init_mcp = __esm({
1139
1175
  }
1140
1176
  });
1141
1177
 
1142
- // packages/protocol/src/network.ts
1143
- var init_network = __esm({
1144
- "packages/protocol/src/network.ts"() {
1145
- "use strict";
1146
- }
1147
- });
1148
-
1149
1178
  // packages/protocol/src/title-from.ts
1150
1179
  var init_title_from = __esm({
1151
1180
  "packages/protocol/src/title-from.ts"() {
@@ -1346,7 +1375,7 @@ function lineDecoder() {
1346
1375
  }
1347
1376
  async function* decode(body, decoder2, onChunk) {
1348
1377
  const reader = body.getReader();
1349
- let ended = false;
1378
+ let ended2 = false;
1350
1379
  try {
1351
1380
  for (; ; ) {
1352
1381
  const { value: value2, done: done2 } = await reader.read();
@@ -1354,10 +1383,10 @@ async function* decode(body, decoder2, onChunk) {
1354
1383
  onChunk?.();
1355
1384
  yield* decoder2.push(value2);
1356
1385
  }
1357
- ended = true;
1386
+ ended2 = true;
1358
1387
  yield* decoder2.end();
1359
1388
  } finally {
1360
- if (!ended) await reader.cancel().catch(() => void 0);
1389
+ if (!ended2) await reader.cancel().catch(() => void 0);
1361
1390
  reader.releaseLock();
1362
1391
  }
1363
1392
  }
@@ -1498,6 +1527,7 @@ var init_src = __esm({
1498
1527
  init_wake();
1499
1528
  init_link();
1500
1529
  init_share();
1530
+ init_claude_link();
1501
1531
  init_media_types();
1502
1532
  init_archive_paths();
1503
1533
  init_shell();
@@ -2364,11 +2394,14 @@ async function writeZip(entries, write) {
2364
2394
  };
2365
2395
  for (const entry of entries) {
2366
2396
  let data2;
2367
- try {
2368
- data2 = await readFile(entry.file);
2369
- } catch (error) {
2370
- if (error.code === "ENOENT") continue;
2371
- throw error;
2397
+ if (entry.data) data2 = Buffer.from(entry.data.buffer, entry.data.byteOffset, entry.data.byteLength);
2398
+ else {
2399
+ try {
2400
+ data2 = await readFile(entry.file);
2401
+ } catch (error) {
2402
+ if (error.code === "ENOENT") continue;
2403
+ throw error;
2404
+ }
2372
2405
  }
2373
2406
  const crc = crc32(data2);
2374
2407
  let method = 0;
@@ -9213,10 +9246,10 @@ var init_connectors2 = __esm({
9213
9246
  }
9214
9247
  }
9215
9248
  this.entries = next;
9216
- for (const [name, running] of [...this.clients]) {
9217
- if (next.get(name)?.key === running.key) continue;
9249
+ for (const [name, running2] of [...this.clients]) {
9250
+ if (next.get(name)?.key === running2.key) continue;
9218
9251
  this.clients.delete(name);
9219
- void running.client.close();
9252
+ void running2.client.close();
9220
9253
  }
9221
9254
  }
9222
9255
  /** The client of a usable, enabled server; throws `server_not_connected` otherwise. */
@@ -9229,8 +9262,8 @@ var init_connectors2 = __esm({
9229
9262
  }
9230
9263
  if (entry.error !== void 0) throw new McpError("server_not_connected", `${server}: ${entry.error}`);
9231
9264
  if (entry.config.disabled) throw new McpError("server_not_connected", `${server} is turned off in ${this.file}.`);
9232
- const running = this.clients.get(server);
9233
- if (running?.key === entry.key) return running.client;
9265
+ const running2 = this.clients.get(server);
9266
+ if (running2?.key === entry.key) return running2.client;
9234
9267
  const config = entry.config;
9235
9268
  const client = "command" in config ? new StdioMcpClient(server, config, { log: this.log, ...this.clientInfo ? { clientInfo: this.clientInfo } : {} }) : new HttpMcpClient(server, config, this.clientInfo ? { clientInfo: this.clientInfo } : {});
9236
9269
  this.clients.set(server, { key: entry.key, client });
@@ -9271,9 +9304,9 @@ var init_connectors2 = __esm({
9271
9304
  /** Stops every server this host started. */
9272
9305
  async close() {
9273
9306
  process.off("exit", this.onExit);
9274
- const running = [...this.clients.values()];
9307
+ const running2 = [...this.clients.values()];
9275
9308
  this.clients.clear();
9276
- await Promise.all(running.map(({ client }) => client.close()));
9309
+ await Promise.all(running2.map(({ client }) => client.close()));
9277
9310
  }
9278
9311
  };
9279
9312
  }
@@ -48835,11 +48868,156 @@ var init_history_host = __esm({
48835
48868
  }
48836
48869
  });
48837
48870
 
48871
+ // packages/server-sdk/src/chrome.ts
48872
+ import { readFileSync as readFileSync13, rmSync as rmSync6 } from "node:fs";
48873
+ import { join as join19 } from "node:path";
48874
+ function activePortEndpoint(profile) {
48875
+ let text;
48876
+ try {
48877
+ text = readFileSync13(join19(profile, DEVTOOLS_ACTIVE_PORT), "utf8");
48878
+ } catch {
48879
+ return null;
48880
+ }
48881
+ const [port, path20] = text.split(/\r?\n/);
48882
+ if (!port || !/^\d+$/.test(port) || !path20?.startsWith("/devtools/browser/")) return null;
48883
+ return `ws://127.0.0.1:${port}${path20}`;
48884
+ }
48885
+ function waitForDevTools(wait) {
48886
+ const { child: child2, profile, stderr, timeoutMs, relaunchMs = Infinity, name = "Chrome" } = wait;
48887
+ const started = Date.now();
48888
+ return new Promise((resolve19, reject2) => {
48889
+ let exitedAt = null;
48890
+ let poll;
48891
+ let settled = false;
48892
+ const settle = (then) => {
48893
+ if (settled) return;
48894
+ settled = true;
48895
+ clearInterval(poll);
48896
+ then();
48897
+ };
48898
+ child2.once("error", (error) => settle(() => reject2(error)));
48899
+ const check = () => {
48900
+ const said = stderr();
48901
+ const endpoint = /DevTools listening on (ws:\/\/\S+)/.exec(said)?.[1] ?? activePortEndpoint(profile);
48902
+ if (endpoint) return settle(() => resolve19(endpoint));
48903
+ const last = said.trim().slice(-400);
48904
+ const failed = (message) => settle(() => reject2(new Error(last ? `${message}: ${last}` : `${message}.`)));
48905
+ if (child2.signalCode !== null || child2.exitCode !== null && child2.exitCode !== 0) {
48906
+ return failed(`${name} exited (${child2.exitCode ?? child2.signalCode})`);
48907
+ }
48908
+ const relaunched = `${name} exited (0), and no browser it started serves its profile`;
48909
+ if (child2.exitCode === 0) {
48910
+ exitedAt ??= Date.now();
48911
+ if (Date.now() - exitedAt > relaunchMs) return failed(relaunched);
48912
+ }
48913
+ if (Date.now() - started > timeoutMs) failed(child2.exitCode === 0 ? relaunched : `${name} did not start in ${Math.round(timeoutMs / 1e3)} s`);
48914
+ };
48915
+ poll = setInterval(check, 50);
48916
+ });
48917
+ }
48918
+ function closeBrowserAt(endpoint, waitMs = 3e3, exitMs = 5e3) {
48919
+ return new Promise((resolve19) => {
48920
+ let socket;
48921
+ let pid = null;
48922
+ let closing = false;
48923
+ let hungUp = false;
48924
+ let unanswered;
48925
+ const timer = setTimeout(() => hangUp(), waitMs);
48926
+ const askToClose = () => {
48927
+ if (closing || hungUp) return;
48928
+ closing = true;
48929
+ socket.send(JSON.stringify({ id: 2, method: "Browser.close" }));
48930
+ };
48931
+ const hangUp = () => {
48932
+ if (hungUp) return;
48933
+ hungUp = true;
48934
+ clearTimeout(timer);
48935
+ clearTimeout(unanswered);
48936
+ try {
48937
+ socket?.close();
48938
+ } catch {
48939
+ }
48940
+ if (pid === null) resolve19();
48941
+ else void waitForExit(pid, exitMs).then(resolve19);
48942
+ };
48943
+ try {
48944
+ socket = new WebSocket(endpoint);
48945
+ } catch {
48946
+ return hangUp();
48947
+ }
48948
+ socket.addEventListener(
48949
+ "open",
48950
+ () => {
48951
+ socket.send(JSON.stringify({ id: 1, method: "SystemInfo.getProcessInfo" }));
48952
+ unanswered = setTimeout(askToClose, 1e3);
48953
+ },
48954
+ { once: true }
48955
+ );
48956
+ socket.addEventListener("message", (event) => {
48957
+ let answer;
48958
+ try {
48959
+ answer = JSON.parse(String(event.data));
48960
+ } catch {
48961
+ return;
48962
+ }
48963
+ if (answer.id !== 1) return;
48964
+ const browser = answer.result?.processInfo?.find((info) => info.type === "browser")?.id;
48965
+ if (typeof browser === "number" && Number.isInteger(browser) && browser > 0 && browser !== process.pid) pid = browser;
48966
+ askToClose();
48967
+ });
48968
+ socket.addEventListener("close", () => hangUp(), { once: true });
48969
+ socket.addEventListener("error", () => hangUp(), { once: true });
48970
+ });
48971
+ }
48972
+ function running(pid) {
48973
+ try {
48974
+ process.kill(pid, 0);
48975
+ return true;
48976
+ } catch (error) {
48977
+ return error.code === "EPERM";
48978
+ }
48979
+ }
48980
+ async function ended(pid, ms) {
48981
+ const deadline = Date.now() + ms;
48982
+ while (running(pid)) {
48983
+ if (Date.now() >= deadline) return false;
48984
+ await new Promise((done2) => setTimeout(done2, 25));
48985
+ }
48986
+ return true;
48987
+ }
48988
+ async function waitForExit(pid, ms) {
48989
+ if (await ended(pid, ms)) return;
48990
+ try {
48991
+ process.kill(pid, "SIGKILL");
48992
+ } catch {
48993
+ return;
48994
+ }
48995
+ await ended(pid, 1e3);
48996
+ }
48997
+ function removeProfile(profile) {
48998
+ const remove = () => {
48999
+ try {
49000
+ rmSync6(profile, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
49001
+ return true;
49002
+ } catch {
49003
+ return false;
49004
+ }
49005
+ };
49006
+ if (!remove()) setTimeout(remove, 2e3).unref();
49007
+ }
49008
+ var DEVTOOLS_ACTIVE_PORT;
49009
+ var init_chrome = __esm({
49010
+ "packages/server-sdk/src/chrome.ts"() {
49011
+ "use strict";
49012
+ DEVTOOLS_ACTIVE_PORT = "DevToolsActivePort";
49013
+ }
49014
+ });
49015
+
48838
49016
  // packages/server-sdk/src/snapshot.ts
48839
49017
  import { spawn as spawn2 } from "node:child_process";
48840
- import { closeSync as closeSync2, existsSync as existsSync11, mkdtempSync, openSync as openSync2, readFileSync as readFileSync13, rmSync as rmSync6 } from "node:fs";
49018
+ import { closeSync as closeSync2, existsSync as existsSync11, mkdtempSync, openSync as openSync2, readFileSync as readFileSync14 } from "node:fs";
48841
49019
  import { tmpdir } from "node:os";
48842
- import { join as join19, win32 } from "node:path";
49020
+ import { join as join20, win32 } from "node:path";
48843
49021
  function windowsCandidates(env = process.env) {
48844
49022
  const roots = [
48845
49023
  env.ProgramW6432,
@@ -48866,9 +49044,22 @@ function findChrome() {
48866
49044
  if (given) return existsSync11(given) ? given : null;
48867
49045
  return CANDIDATES.find((path20) => existsSync11(path20)) ?? null;
48868
49046
  }
49047
+ function areaIn(value2, view2) {
49048
+ if (!value2 || typeof value2 !== "object") return null;
49049
+ const { x, y, width, height } = value2;
49050
+ if (![x, y, width, height].every((n) => typeof n === "number" && Number.isFinite(n))) return null;
49051
+ const left = Math.max(0, Math.round(x));
49052
+ const top = Math.max(0, Math.round(y));
49053
+ const right = Math.min(view2.width, Math.round(x + width));
49054
+ const bottom = Math.min(view2.height, Math.round(y + height));
49055
+ return right - left >= 2 && bottom - top >= 2 ? { x: left, y: top, width: right - left, height: bottom - top } : null;
49056
+ }
48869
49057
  async function snapshotPage(chrome, request) {
48870
- const profile = mkdtempSync(join19(tmpdir(), "open-artifacts-snapshot-"));
48871
- const stderr = join19(profile, "chrome-stderr.log");
49058
+ return (await snapshotPageAndRead(chrome, request)).png;
49059
+ }
49060
+ async function snapshotPageAndRead(chrome, request) {
49061
+ const profile = mkdtempSync(join20(tmpdir(), "open-artifacts-snapshot-"));
49062
+ const stderr = join20(profile, "chrome-stderr.log");
48872
49063
  const fd = openSync2(stderr, "a");
48873
49064
  const child2 = spawn2(
48874
49065
  chrome,
@@ -48893,43 +49084,28 @@ async function snapshotPage(chrome, request) {
48893
49084
  );
48894
49085
  closeSync2(fd);
48895
49086
  let ws = null;
49087
+ let endpoint = null;
48896
49088
  let timer;
48897
- const removeProfile = () => {
48898
- try {
48899
- rmSync6(profile, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
48900
- return true;
48901
- } catch {
48902
- return false;
48903
- }
48904
- };
48905
49089
  const cleanup = async () => {
48906
49090
  clearTimeout(timer);
48907
49091
  try {
48908
49092
  ws?.close();
48909
49093
  } catch {
48910
49094
  }
49095
+ const browser = endpoint ?? activePortEndpoint(profile);
49096
+ if (browser) await closeBrowserAt(browser);
48911
49097
  await stopChild(child2, { graceMs: 0, settleMs: 3e3 });
48912
- if (!removeProfile()) setTimeout(removeProfile, 2e3).unref();
49098
+ removeProfile(profile);
48913
49099
  };
48914
49100
  const work = async () => {
48915
- const endpoint = await new Promise((resolveEndpoint, reject2) => {
48916
- const started = Date.now();
48917
- const poll = setInterval(() => {
48918
- let text = "";
48919
- try {
48920
- text = readFileSync13(stderr, "utf8");
48921
- } catch {
48922
- }
48923
- const found = /DevTools listening on (ws:\/\/\S+)/.exec(text);
48924
- if (found) {
48925
- clearInterval(poll);
48926
- resolveEndpoint(found[1]);
48927
- } else if (child2.exitCode !== null || Date.now() - started > CHROME_START_MS) {
48928
- clearInterval(poll);
48929
- reject2(new Error(`Chrome did not start: ${text.slice(-300)}`));
48930
- }
48931
- }, 50);
48932
- });
49101
+ const readStderr = () => {
49102
+ try {
49103
+ return readFileSync14(stderr, "utf8");
49104
+ } catch {
49105
+ return "";
49106
+ }
49107
+ };
49108
+ endpoint = await waitForDevTools({ child: child2, profile, stderr: readStderr, timeoutMs: CHROME_START_MS });
48933
49109
  const socket = new WebSocket(endpoint);
48934
49110
  ws = socket;
48935
49111
  await new Promise((opened, failed) => {
@@ -48974,16 +49150,31 @@ async function snapshotPage(chrome, request) {
48974
49150
  const navigated = await send2("Page.navigate", { url: request.url }, sessionId2);
48975
49151
  if (navigated.errorText) throw new Error(`the page did not load: ${navigated.errorText}`);
48976
49152
  await Promise.race([loaded, sleep(15e3)]);
49153
+ const evaluate = async (expression) => {
49154
+ const out = await send2("Runtime.evaluate", { expression, returnByValue: true }, sessionId2).catch(() => null);
49155
+ return out?.result?.value;
49156
+ };
48977
49157
  const ready3 = request.ready ?? DEFAULT_READY;
48978
49158
  const until = Date.now() + 1e4;
48979
49159
  while (Date.now() < until) {
48980
- const out = await send2("Runtime.evaluate", { expression: `!!(${ready3})`, returnByValue: true }, sessionId2).catch(() => null);
48981
- if (out?.result?.value === true) break;
49160
+ if (await evaluate(`!!(${ready3})`) === true) break;
48982
49161
  await sleep(150);
48983
49162
  }
49163
+ let clip2 = request.area ? areaIn(await evaluate(request.area), request) : null;
49164
+ while (request.area && !clip2 && Date.now() < until) {
49165
+ await sleep(250);
49166
+ clip2 = areaIn(await evaluate(request.area), request);
49167
+ }
48984
49168
  await sleep(request.settleMs ?? 1500);
48985
- const shot = await send2("Page.captureScreenshot", { format: "png" }, sessionId2);
48986
- return Buffer.from(shot.data, "base64");
49169
+ if (clip2 && request.area) clip2 = areaIn(await evaluate(request.area), request) ?? clip2;
49170
+ const shot = await send2("Page.captureScreenshot", { format: "png", ...clip2 ? { clip: { ...clip2, scale: 1 } } : {} }, sessionId2);
49171
+ const png = Buffer.from(shot.data, "base64");
49172
+ if (!request.read) return { png, read: void 0 };
49173
+ const read = await Promise.race([
49174
+ send2("Runtime.evaluate", { expression: request.read, returnByValue: true, awaitPromise: true }, sessionId2).catch(() => null),
49175
+ sleep(1e4).then(() => null)
49176
+ ]);
49177
+ return { png, read: read?.result?.value };
48987
49178
  };
48988
49179
  try {
48989
49180
  return await Promise.race([
@@ -49001,6 +49192,7 @@ var init_snapshot = __esm({
49001
49192
  "packages/server-sdk/src/snapshot.ts"() {
49002
49193
  "use strict";
49003
49194
  init_child();
49195
+ init_chrome();
49004
49196
  WINDOWS_BROWSERS = [
49005
49197
  ["Google\\Chrome\\Application", "chrome.exe"],
49006
49198
  ["Microsoft\\Edge\\Application", "msedge.exe"]
@@ -49639,7 +49831,7 @@ var init_daemon_connectors = __esm({
49639
49831
  });
49640
49832
 
49641
49833
  // packages/type-server/src/connector-shares.ts
49642
- import { mkdirSync as mkdirSync5, readFileSync as readFileSync14, renameSync as renameSync7, writeFileSync as writeFileSync7 } from "node:fs";
49834
+ import { mkdirSync as mkdirSync5, readFileSync as readFileSync15, renameSync as renameSync7, writeFileSync as writeFileSync7 } from "node:fs";
49643
49835
  import { dirname as dirname8 } from "node:path";
49644
49836
  function sharedCallKey(call) {
49645
49837
  return canonicalJson({
@@ -49720,7 +49912,7 @@ var init_connector_shares = __esm({
49720
49912
  if (this.#data !== null) return this.#data;
49721
49913
  let data2 = { version: 1, artifacts: {} };
49722
49914
  try {
49723
- const parsed3 = JSON.parse(readFileSync14(this.#file, "utf8"));
49915
+ const parsed3 = JSON.parse(readFileSync15(this.#file, "utf8"));
49724
49916
  if (isPlainObject(parsed3) && isPlainObject(parsed3.artifacts)) data2 = { version: 1, artifacts: parsed3.artifacts };
49725
49917
  } catch {
49726
49918
  }
@@ -49818,16 +50010,16 @@ ${canonicalJson([approved.tool, filled.args])}`;
49818
50010
  let answer;
49819
50011
  if (kept !== void 0 && (keptAge < SHARED_RESULT_FLOOR_MS || keptAge < reuse && options.refresh !== true)) answer = kept;
49820
50012
  else {
49821
- let running = this.#running.get(runKey);
49822
- if (running === void 0) {
50013
+ let running2 = this.#running.get(runKey);
50014
+ if (running2 === void 0) {
49823
50015
  const started = this.#call(approved.connector, approved.tool, filled.args, SHARED_CALL_TIMEOUT_MS).then((result) => ({ result, ranAt: this.#now() })).finally(() => {
49824
50016
  if (this.#running.get(runKey) === started) this.#running.delete(runKey);
49825
50017
  });
49826
- running = started;
49827
- this.#running.set(runKey, running);
50018
+ running2 = started;
50019
+ this.#running.set(runKey, running2);
49828
50020
  }
49829
50021
  try {
49830
- answer = await running;
50022
+ answer = await running2;
49831
50023
  } catch (error) {
49832
50024
  return { ok: false, code: failureCode(error), sharer: share.sharer };
49833
50025
  }
@@ -49857,7 +50049,7 @@ var init_mcp_client2 = __esm({
49857
50049
  // packages/type-server/src/upgrade-cli.ts
49858
50050
  import { existsSync as existsSync12 } from "node:fs";
49859
50051
  import { readdir as readdir5 } from "node:fs/promises";
49860
- import { join as join20, resolve as resolve9 } from "node:path";
50052
+ import { join as join21, resolve as resolve9 } from "node:path";
49861
50053
  async function writeOnDisk(root, writes) {
49862
50054
  const history = new History(root);
49863
50055
  const tracks = historyTracksOf("motion");
@@ -49900,7 +50092,7 @@ async function upgradeFilm(root, { dryRun = false, write } = {}) {
49900
50092
  }
49901
50093
  async function filmsUnder(root) {
49902
50094
  if (await detectType(root) === "motion") return [root];
49903
- if (existsSync12(join20(root, "db"))) return [];
50095
+ if (existsSync12(join21(root, "db"))) return [];
49904
50096
  let entries;
49905
50097
  try {
49906
50098
  entries = (await readdir5(root, { withFileTypes: true })).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name);
@@ -49909,7 +50101,7 @@ async function filmsUnder(root) {
49909
50101
  }
49910
50102
  const films = [];
49911
50103
  for (const name of entries.sort((a, b) => a.localeCompare(b, "en", { numeric: true }))) {
49912
- const dir = join20(root, name);
50104
+ const dir = join21(root, name);
49913
50105
  if (await detectType(dir) === "motion") films.push(dir);
49914
50106
  }
49915
50107
  return films;
@@ -52442,39 +52634,26 @@ async function launchChrome(chrome, args = []) {
52442
52634
  ],
52443
52635
  { stdio: ["ignore", "ignore", "pipe"] }
52444
52636
  );
52445
- const removeProfile = () => fs11.rmSync(profile, { recursive: true, force: true, maxRetries: 3 });
52446
- let endpoint;
52637
+ let said = "";
52638
+ child2.stderr.on("data", (chunk) => {
52639
+ said += chunk;
52640
+ });
52641
+ let endpoint = null;
52642
+ let ws;
52447
52643
  try {
52448
- endpoint = await new Promise((resolve19, reject2) => {
52449
- let text = "";
52450
- const timer = setTimeout(() => reject2(new Error(`Chrome did not start in 30 s: ${text.slice(-400)}`)), 3e4);
52451
- child2.stderr.on("data", (chunk) => {
52452
- text += chunk;
52453
- const found = /DevTools listening on (ws:\/\/\S+)/.exec(text);
52454
- if (found) {
52455
- clearTimeout(timer);
52456
- resolve19(found[1]);
52457
- }
52458
- });
52459
- child2.on("error", (error) => {
52460
- clearTimeout(timer);
52461
- reject2(error);
52462
- });
52463
- child2.on("exit", (code) => {
52464
- clearTimeout(timer);
52465
- reject2(new Error(`Chrome exited (${code}): ${text.slice(-400)}`));
52466
- });
52644
+ endpoint = await waitForDevTools({ child: child2, profile, stderr: () => said, timeoutMs: 3e4 });
52645
+ ws = new WebSocket(endpoint);
52646
+ await new Promise((resolve19, reject2) => {
52647
+ ws.addEventListener("open", () => resolve19(), { once: true });
52648
+ ws.addEventListener("error", () => reject2(new Error("could not connect to Chrome")), { once: true });
52467
52649
  });
52468
52650
  } catch (error) {
52651
+ if (endpoint) await closeBrowserAt(endpoint);
52469
52652
  void stopChild(child2, { graceMs: 0 });
52470
- removeProfile();
52653
+ removeProfile(profile);
52471
52654
  throw error;
52472
52655
  }
52473
- const ws = new WebSocket(endpoint);
52474
- await new Promise((resolve19, reject2) => {
52475
- ws.addEventListener("open", () => resolve19(), { once: true });
52476
- ws.addEventListener("error", () => reject2(new Error("could not connect to Chrome")), { once: true });
52477
- });
52656
+ const browserAt = endpoint;
52478
52657
  let nextId = 1;
52479
52658
  const pending2 = /* @__PURE__ */ new Map();
52480
52659
  const listeners = /* @__PURE__ */ new Set();
@@ -52540,24 +52719,22 @@ async function launchChrome(chrome, args = []) {
52540
52719
  };
52541
52720
  }
52542
52721
  async function close() {
52543
- try {
52544
- await Promise.race([send2("Browser.close"), sleep2(3e3)]);
52545
- } catch {
52546
- }
52547
52722
  try {
52548
52723
  ws.close();
52549
52724
  } catch {
52550
52725
  }
52726
+ await closeBrowserAt(browserAt);
52551
52727
  await stopChild(child2, { signal: null, graceMs: 3e3, settleMs: 0 });
52552
- removeProfile();
52728
+ removeProfile(profile);
52553
52729
  }
52554
52730
  return { page: page2, close };
52555
52731
  }
52556
52732
  var sleep2, exceptionText;
52557
- var init_chrome = __esm({
52733
+ var init_chrome2 = __esm({
52558
52734
  "packages/type-server/src/docs/chrome.ts"() {
52559
52735
  "use strict";
52560
52736
  init_child();
52737
+ init_chrome();
52561
52738
  init_snapshot2();
52562
52739
  sleep2 = (ms) => new Promise((done2) => setTimeout(done2, ms));
52563
52740
  exceptionText = (details) => String(details.exception?.description ?? details.text);
@@ -52838,7 +53015,7 @@ var init_print = __esm({
52838
53015
  "packages/type-server/src/docs/print.ts"() {
52839
53016
  "use strict";
52840
53017
  init_src9();
52841
- init_chrome();
53018
+ init_chrome2();
52842
53019
  MARGIN_MM = { y: 18, x: 16 };
52843
53020
  PAPER_INCHES = { a4: { width: 210 / 25.4, height: 297 / 25.4 }, letter: { width: 8.5, height: 11 } };
52844
53021
  PAGE_SIZE = { a4: "A4", letter: "letter" };
@@ -55652,7 +55829,7 @@ import { watch as watch2 } from "node:fs";
55652
55829
  import { mkdir as mkdir5, readFile as readFile6, readdir as readdir6, rm as rm6, stat as stat5, writeFile as writeFile3 } from "node:fs/promises";
55653
55830
  import { createServer as createServer2 } from "node:http";
55654
55831
  import { homedir as homedir2 } from "node:os";
55655
- import { basename as basename6, dirname as dirname9, isAbsolute as isAbsolute5, join as join21, normalize, relative as relative2, resolve as resolve10, sep as sep5 } from "node:path";
55832
+ import { basename as basename6, dirname as dirname9, isAbsolute as isAbsolute5, join as join22, normalize, relative as relative2, resolve as resolve10, sep as sep5 } from "node:path";
55656
55833
  function uploadLimitOf(type, hosted) {
55657
55834
  return type === "design" && !hosted ? LOCAL_DESIGN_MAX_UPLOAD : MAX_UPLOAD;
55658
55835
  }
@@ -55702,7 +55879,7 @@ function folderId(root) {
55702
55879
  }
55703
55880
  async function readArtifactMeta(root, files) {
55704
55881
  try {
55705
- const path20 = join21(root, ".artifact.json");
55882
+ const path20 = join22(root, ".artifact.json");
55706
55883
  const meta = JSON.parse(await readFile6(files?.resolve(path20) ?? path20, "utf8"));
55707
55884
  return {
55708
55885
  id: typeof meta.id === "string" ? meta.id : void 0,
@@ -55715,7 +55892,7 @@ async function readArtifactMeta(root, files) {
55715
55892
  }
55716
55893
  async function indexTitle(root, type, files) {
55717
55894
  try {
55718
- const path20 = join21(root, contentDirOf(type), TYPES[type].marker);
55895
+ const path20 = join22(root, contentDirOf(type), TYPES[type].marker);
55719
55896
  const index = JSON.parse(await readFile6(files?.resolve(path20) ?? path20, "utf8"));
55720
55897
  return typeof index.title === "string" && index.title.trim() ? index.title.trim() : void 0;
55721
55898
  } catch {
@@ -55727,7 +55904,7 @@ async function detectType(root, files) {
55727
55904
  if (isTypeName(meta.type)) return meta.type;
55728
55905
  for (const type of Object.values(TYPES)) {
55729
55906
  try {
55730
- const path20 = join21(root, contentDirOf(type.name), type.marker);
55907
+ const path20 = join22(root, contentDirOf(type.name), type.marker);
55731
55908
  await stat5(files?.resolve(path20) ?? path20);
55732
55909
  return type.name;
55733
55910
  } catch {
@@ -55736,7 +55913,7 @@ async function detectType(root, files) {
55736
55913
  for (const type of Object.values(TYPES)) {
55737
55914
  if (type.store !== "db" || !type.marker.includes("/")) continue;
55738
55915
  try {
55739
- const path20 = join21(root, contentDirOf(type.name), dirname9(type.marker));
55916
+ const path20 = join22(root, contentDirOf(type.name), dirname9(type.marker));
55740
55917
  if ((await stat5(files?.resolve(path20) ?? path20)).isDirectory()) return type.name;
55741
55918
  } catch {
55742
55919
  }
@@ -55774,7 +55951,7 @@ function createTypeServer(options) {
55774
55951
  const connectors = () => options.connectors ?? viaDaemon ?? ownHost();
55775
55952
  let ownShares = null;
55776
55953
  const connectorShares = () => ownShares ??= new ConnectorShares({
55777
- file: join21(dirname9(connectors().file), "connector-shares.json"),
55954
+ file: join22(dirname9(connectors().file), "connector-shares.json"),
55778
55955
  call: async (server2, tool, callArgs, timeoutMs) => ({ ...await connectors().callTool(server2, tool, callArgs, { timeoutMs }) }),
55779
55956
  log
55780
55957
  });
@@ -56032,7 +56209,7 @@ function createTypeServer(options) {
56032
56209
  return;
56033
56210
  }
56034
56211
  artifact.listing = await artifact.store.list();
56035
- const project = join21(artifact.root, PROJECT_DIR);
56212
+ const project = join22(artifact.root, PROJECT_DIR);
56036
56213
  await mkdir5(project, { recursive: true });
56037
56214
  if (artifact.watcher || artifact.statusTimer || artifact.watching || artifact.clients.size === 0) return;
56038
56215
  try {
@@ -56097,14 +56274,14 @@ function createTypeServer(options) {
56097
56274
  throw new HttpError(400, "invalid", "shell must be an origin.");
56098
56275
  }
56099
56276
  }
56100
- const marker = join21(root, contentDirOf(type), TYPES[type].marker);
56277
+ const marker = join22(root, contentDirOf(type), TYPES[type].marker);
56101
56278
  try {
56102
56279
  await stat5(files?.resolve(marker) ?? marker);
56103
56280
  } catch {
56104
56281
  const title2 = request.title?.trim() || meta.title || basename6(root);
56105
- const dir = join21(root, contentDirOf(type));
56282
+ const dir = join22(root, contentDirOf(type));
56106
56283
  for (const [path20, content] of Object.entries(TYPES[type].scaffold(title2, dir))) {
56107
- const target = join21(dir, path20);
56284
+ const target = join22(dir, path20);
56108
56285
  await writeAtomic(files?.resolve(target, false) ?? target, content);
56109
56286
  }
56110
56287
  }
@@ -56219,7 +56396,7 @@ function createTypeServer(options) {
56219
56396
  else send(res, 200, bytes, mimeOf(file), headers);
56220
56397
  };
56221
56398
  const inside = (dir, rel) => {
56222
- const target = normalize(join21(dir, rel));
56399
+ const target = normalize(join22(dir, rel));
56223
56400
  if (target !== dir && !target.startsWith(dir.endsWith(sep5) ? dir : dir + sep5)) throw new HttpError(404, "not_found", "Not found.");
56224
56401
  return target;
56225
56402
  };
@@ -56573,7 +56750,7 @@ data: ${JSON.stringify(payload)}
56573
56750
  }
56574
56751
  case API.downloads: {
56575
56752
  if (method !== "POST") throw new HttpError(405, "invalid", "POST only.");
56576
- const dir = options.downloadsDir ?? join21(homedir2(), "Downloads");
56753
+ const dir = options.downloadsDir ?? join22(homedir2(), "Downloads");
56577
56754
  const savedTo = await saveDownload(req, dir, downloadName(url.searchParams.get("name")), options.maxDownloadBytes);
56578
56755
  return sendJson(res, 200, { savedTo });
56579
56756
  }
@@ -56724,11 +56901,11 @@ data: ${JSON.stringify(payload)}
56724
56901
  const files = new WorkspaceDirectory(root);
56725
56902
  const dir = files.resolve("_agent/snapshots");
56726
56903
  await mkdir5(dir, { recursive: true });
56727
- const image = files.resolve(join21(dir, `snapshot-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.png`), false);
56904
+ const image = files.resolve(join22(dir, `snapshot-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.png`), false);
56728
56905
  await writeFile3(image, png, { flag: "wx" });
56729
56906
  const old = (await readdir6(dir)).filter((name) => /^snapshot-.*\.png$/.test(name)).sort();
56730
- for (const name of old.slice(0, Math.max(0, old.length - SNAPSHOTS_KEPT))) await rm6(files.resolve(join21(dir, name), false), { force: true });
56731
- return { image: join21(root, relative2(files.root, image)), width, height, bytes: png.length, note: SNAPSHOT_NOTE };
56907
+ for (const name of old.slice(0, Math.max(0, old.length - SNAPSHOTS_KEPT))) await rm6(files.resolve(join22(dir, name), false), { force: true });
56908
+ return { image: join22(root, relative2(files.root, image)), width, height, bytes: png.length, note: SNAPSHOT_NOTE };
56732
56909
  };
56733
56910
  const callTargetOf = async (body) => {
56734
56911
  const opened = typeof body.id === "string" ? byId.get(body.id) : void 0;
@@ -57680,7 +57857,7 @@ import { randomBytes as randomBytes16 } from "node:crypto";
57680
57857
  import { existsSync as existsSync17, openSync as openSync3 } from "node:fs";
57681
57858
  import { mkdir as mkdir6, readdir as readdir8, readFile as readFile9, rm as rm8, writeFile as writeFile5 } from "node:fs/promises";
57682
57859
  import { homedir as homedir4 } from "node:os";
57683
- import { basename as basename8, delimiter, dirname as dirname11, join as join25, relative as relative4, resolve as resolve18 } from "node:path";
57860
+ import { basename as basename8, delimiter, dirname as dirname11, join as join26, relative as relative4, resolve as resolve18 } from "node:path";
57684
57861
  import { fileURLToPath as fileURLToPath4 } from "node:url";
57685
57862
 
57686
57863
  // packages/type-server/src/db-cli.ts
@@ -57689,7 +57866,7 @@ init_db();
57689
57866
  init_agent();
57690
57867
  init_server();
57691
57868
  init_types2();
57692
- import { existsSync as existsSync13, readFileSync as readFileSync15 } from "node:fs";
57869
+ import { existsSync as existsSync13, readFileSync as readFileSync16 } from "node:fs";
57693
57870
  import { isAbsolute as isAbsolute6, resolve as resolve11 } from "node:path";
57694
57871
  function fail2(message) {
57695
57872
  console.error(message);
@@ -57741,7 +57918,7 @@ async function cmdReadDb(positional, options = {}) {
57741
57918
  }
57742
57919
  }
57743
57920
  function readWrites(source) {
57744
- const text = source === "-" ? readFileSync15(0, "utf8") : /^\s*[[{]/.test(source) ? source : existsSync13(source) ? readFileSync15(source, "utf8") : null;
57921
+ const text = source === "-" ? readFileSync16(0, "utf8") : /^\s*[[{]/.test(source) ? source : existsSync13(source) ? readFileSync16(source, "utf8") : null;
57745
57922
  if (text === null) throw new Error(`${source}: no such file (pass inline JSON, a file, or - for stdin).`);
57746
57923
  const value2 = JSON.parse(text);
57747
57924
  if (Array.isArray(value2)) return value2;
@@ -57764,7 +57941,7 @@ function resolveFileRefs(value2, where) {
57764
57941
  if (typeof value2.$file !== "string" || !value2.$file) throw new Refusal2("INVALID_FILE_REF", `${where}: {"$file": \u2026} names a file path.`);
57765
57942
  const file = resolve11(value2.$file);
57766
57943
  try {
57767
- return readFileSync15(file, "utf8");
57944
+ return readFileSync16(file, "utf8");
57768
57945
  } catch {
57769
57946
  throw new Refusal2("FILE_NOT_FOUND", `${where}: {"$file": ${JSON.stringify(value2.$file)}}: cannot read ${file}. Nothing was written.`);
57770
57947
  }
@@ -58022,7 +58199,7 @@ ${result.changed.map((p) => ` ${p}`).join("\n")}`);
58022
58199
 
58023
58200
  // packages/type-server/src/comments-cli.ts
58024
58201
  init_comments();
58025
- import { readFileSync as readFileSync16 } from "node:fs";
58202
+ import { readFileSync as readFileSync17 } from "node:fs";
58026
58203
  import { resolve as resolve13 } from "node:path";
58027
58204
 
58028
58205
  // packages/type-server/src/docs/comment-target.ts
@@ -58261,7 +58438,7 @@ async function cmdCommentReply(positional, flags) {
58261
58438
  const id = positional[1];
58262
58439
  if (!id) return fail4(`Pass the thread id: ${hint("comment-reply", positional[0], "<thread>", "<text>")}`);
58263
58440
  const given = positional.slice(2).join(" ");
58264
- const text = (given === "" || given === "-" ? process.stdin.isTTY ? "" : readFileSync16(0, "utf8") : given).replace(/\r\n?/g, "\n").trim();
58441
+ const text = (given === "" || given === "-" ? process.stdin.isTTY ? "" : readFileSync17(0, "utf8") : given).replace(/\r\n?/g, "\n").trim();
58265
58442
  if (!text) return fail4("The reply is empty: pass it as an argument, or as - with the text on stdin.");
58266
58443
  if (text.length > TEXT_MAX) return fail4(`A reply is at most ${TEXT_MAX} characters.`);
58267
58444
  try {
@@ -58287,7 +58464,7 @@ async function cmdCommentResolve(positional, flags) {
58287
58464
  }
58288
58465
  var DOC_THREADS_MAX = 1e3;
58289
58466
  function textOf4(given) {
58290
- return (given === "" || given === "-" ? process.stdin.isTTY ? "" : readFileSync16(0, "utf8") : given).replace(/\r\n?/g, "\n").trim();
58467
+ return (given === "" || given === "-" ? process.stdin.isTTY ? "" : readFileSync17(0, "utf8") : given).replace(/\r\n?/g, "\n").trim();
58291
58468
  }
58292
58469
  var flagText = (flags, name) => {
58293
58470
  const value2 = flags.get(name);
@@ -58332,7 +58509,7 @@ init_workspace_files();
58332
58509
  init_store();
58333
58510
  import { existsSync as existsSync14 } from "node:fs";
58334
58511
  import { readdir as readdir7, readFile as readFile7, rm as rm7, stat as stat6, writeFile as writeFile4 } from "node:fs/promises";
58335
- import { basename as basename7, join as join22, relative as relative3, resolve as resolve14, sep as sep6 } from "node:path";
58512
+ import { basename as basename7, join as join23, relative as relative3, resolve as resolve14, sep as sep6 } from "node:path";
58336
58513
  var MAX_SEARCHED_BYTES = 16 * 1024 * 1024;
58337
58514
  var SEARCHED = ["project", "db"];
58338
58515
  var SEARCHED_FILES = ["comments.json", ".artifact.json"];
@@ -58361,13 +58538,13 @@ async function referencesTo(root, id) {
58361
58538
  }
58362
58539
  for (const entry of entries) {
58363
58540
  if (entry.name === "node_modules" || entry.name === ".git") continue;
58364
- const file = join22(dir, entry.name);
58541
+ const file = join23(dir, entry.name);
58365
58542
  if (entry.isDirectory()) await walk3(file);
58366
58543
  else if (entry.isFile()) await visit(file);
58367
58544
  }
58368
58545
  };
58369
- for (const dir of SEARCHED) await walk3(join22(root, dir));
58370
- for (const name of SEARCHED_FILES) await visit(join22(root, name));
58546
+ for (const dir of SEARCHED) await walk3(join23(root, dir));
58547
+ for (const name of SEARCHED_FILES) await visit(join23(root, name));
58371
58548
  return users.sort();
58372
58549
  }
58373
58550
  var AssetError = class extends Error {
@@ -58381,7 +58558,7 @@ async function deleteAsset(root, given) {
58381
58558
  const id = blobIdOf2(given);
58382
58559
  if (!id) throw new AssetError("INVALID_ASSET", "Give the upload as its url (/_blob/<id>) or its id (32 hex digits).");
58383
58560
  const blob = await new ArtifactStore(root).findBlob(id);
58384
- if (!blob) throw new AssetError("NOT_FOUND", `No upload ${id} in ${join22(root, "_blobs")}.`);
58561
+ if (!blob) throw new AssetError("NOT_FOUND", `No upload ${id} in ${join23(root, "_blobs")}.`);
58385
58562
  const users = await referencesTo(root, id);
58386
58563
  if (users.length) throw new AssetError("IN_USE", `/_blob/${id} is still named by ${users.join(", ")}; change or delete those first. Nothing was removed.`);
58387
58564
  if (basename7(blob.file) === id) await rm7(blob.file + ".json", { force: true });
@@ -58488,15 +58665,17 @@ init_project_check();
58488
58665
  init_src13();
58489
58666
  import { existsSync as existsSync16 } from "node:fs";
58490
58667
  import { readFile as readFile8 } from "node:fs/promises";
58491
- import { dirname as dirname10, join as join24, resolve as resolve17 } from "node:path";
58668
+ import { dirname as dirname10, join as join25, resolve as resolve17 } from "node:path";
58492
58669
  import { fileURLToPath as fileURLToPath3 } from "node:url";
58493
58670
 
58494
58671
  // packages/motion-stage/src/stills.ts
58672
+ init_child();
58673
+ init_chrome();
58495
58674
  init_src13();
58496
58675
  import { spawn as spawn4 } from "node:child_process";
58497
- import { existsSync as existsSync15, lstatSync as lstatSync6, mkdirSync as mkdirSync6, mkdtempSync as mkdtempSync2, readFileSync as readFileSync17, readdirSync as readdirSync8, rmSync as rmSync7, writeFileSync as writeFileSync8 } from "node:fs";
58676
+ import { existsSync as existsSync15, lstatSync as lstatSync6, mkdirSync as mkdirSync6, mkdtempSync as mkdtempSync2, readFileSync as readFileSync18, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
58498
58677
  import { homedir as homedir3, tmpdir as tmpdir2 } from "node:os";
58499
- import { join as join23, resolve as resolve16 } from "node:path";
58678
+ import { join as join24, resolve as resolve16 } from "node:path";
58500
58679
  import { pathToFileURL as pathToFileURL2 } from "node:url";
58501
58680
  var StillsError = class extends Error {
58502
58681
  };
@@ -58514,24 +58693,24 @@ function parseStillScale(text) {
58514
58693
  var stillFileName = (t) => "t_" + t.toFixed(3) + ".png";
58515
58694
  var plainFile = (path20) => lstatSync6(path20, { throwIfNoEntry: false })?.isFile() === true;
58516
58695
  function readStillsFilm(root, warn = () => void 0) {
58517
- const db = join23(root, "db");
58518
- if (!plainFile(join23(db, "film", "meta.json"))) throw new StillsError(root + " is not a motion artifact: it has no db/film/meta.json.");
58696
+ const db = join24(root, "db");
58697
+ if (!plainFile(join24(db, "film", "meta.json"))) throw new StillsError(root + " is not a motion artifact: it has no db/film/meta.json.");
58519
58698
  const documents = {};
58520
58699
  for (const collection of [...FILM_COLLECTIONS, ...VERSION_COLLECTIONS]) {
58521
- const folder = join23(db, collection);
58700
+ const folder = join24(db, collection);
58522
58701
  if (!existsSync15(folder)) continue;
58523
58702
  for (const name of readdirSync8(folder)) {
58524
58703
  if (!name.endsWith(".json")) continue;
58525
- const path20 = join23(folder, name);
58704
+ const path20 = join24(folder, name);
58526
58705
  if (!plainFile(path20)) {
58527
58706
  warn("skipped " + path20 + ": not a plain file");
58528
58707
  continue;
58529
58708
  }
58530
- documents[collection + "/" + name.slice(0, -".json".length)] = readFileSync17(path20, "utf8");
58709
+ documents[collection + "/" + name.slice(0, -".json".length)] = readFileSync18(path20, "utf8");
58531
58710
  }
58532
58711
  }
58533
58712
  const blobs = {};
58534
- const uploads = join23(root, "_blobs");
58713
+ const uploads = join24(root, "_blobs");
58535
58714
  const stored = existsSync15(uploads) ? readdirSync8(uploads) : [];
58536
58715
  for (const [path20, text] of Object.entries(documents)) {
58537
58716
  if (!path20.startsWith("assets/")) continue;
@@ -58544,7 +58723,7 @@ function readStillsFilm(root, warn = () => void 0) {
58544
58723
  const id = /^\/?_blob\/([0-9a-f]{32})$/.exec(ref2)?.[1];
58545
58724
  if (id === void 0 || id in blobs) continue;
58546
58725
  const file = stored.find((name) => name === id || name.startsWith(id + "."));
58547
- if (file !== void 0 && plainFile(join23(uploads, file))) blobs[id] = readFileSync17(join23(uploads, file)).toString("base64");
58726
+ if (file !== void 0 && plainFile(join24(uploads, file))) blobs[id] = readFileSync18(join24(uploads, file)).toString("base64");
58548
58727
  }
58549
58728
  return { documents, blobs };
58550
58729
  }
@@ -58591,17 +58770,17 @@ function findChromium(env = process.env) {
58591
58770
  if (existsSync15(env.CHROME_PATH)) return env.CHROME_PATH;
58592
58771
  throw new StillsError("CHROME_PATH does not exist: " + env.CHROME_PATH);
58593
58772
  }
58594
- const caches = [env.PLAYWRIGHT_BROWSERS_PATH, join23(homedir3(), "Library", "Caches", "ms-playwright"), join23(homedir3(), ".cache", "ms-playwright"), "/opt/pw-browsers"].filter(
58773
+ const caches = [env.PLAYWRIGHT_BROWSERS_PATH, join24(homedir3(), "Library", "Caches", "ms-playwright"), join24(homedir3(), ".cache", "ms-playwright"), "/opt/pw-browsers"].filter(
58595
58774
  (path20) => path20 !== void 0 && path20 !== "" && existsSync15(path20)
58596
58775
  );
58597
58776
  const found = [];
58598
58777
  for (const cache of caches) {
58599
58778
  for (const build of safeList(cache).sort().reverse()) {
58600
- const home = join23(cache, build);
58601
- if (build.startsWith("chromium_headless_shell-")) for (const sub of safeList(home)) found.push(join23(home, sub, "chrome-headless-shell"));
58779
+ const home = join24(cache, build);
58780
+ if (build.startsWith("chromium_headless_shell-")) for (const sub of safeList(home)) found.push(join24(home, sub, "chrome-headless-shell"));
58602
58781
  else if (build.startsWith("chromium-")) {
58603
- found.push(join23(home, "chrome-linux", "chrome"), join23(home, "chrome-linux64", "chrome"));
58604
- for (const sub of safeList(home)) found.push(join23(home, sub, "Chromium.app", "Contents", "MacOS", "Chromium"));
58782
+ found.push(join24(home, "chrome-linux", "chrome"), join24(home, "chrome-linux64", "chrome"));
58783
+ for (const sub of safeList(home)) found.push(join24(home, sub, "Chromium.app", "Contents", "MacOS", "Chromium"));
58605
58784
  }
58606
58785
  }
58607
58786
  }
@@ -58638,22 +58817,11 @@ var CHROMIUM_ARGS = [
58638
58817
  function launch(binary, profile) {
58639
58818
  const keychain = process.platform === "darwin" ? ["--use-mock-keychain"] : [];
58640
58819
  const child2 = spawn4(binary, [...CHROMIUM_ARGS, ...keychain, "--user-data-dir=" + profile, "about:blank"], { stdio: ["ignore", "ignore", "pipe"] });
58641
- return new Promise((done2, fail6) => {
58642
- let said = "";
58643
- const timer = setTimeout(() => fail6(new Error("Chromium did not start within 30 s:\n" + said.slice(-2e3))), 3e4);
58644
- child2.stderr?.on("data", (chunk) => {
58645
- said += String(chunk);
58646
- const url = /DevTools listening on (ws:\/\/\S+)/.exec(said)?.[1];
58647
- if (url === void 0) return;
58648
- clearTimeout(timer);
58649
- done2({ child: child2, url });
58650
- });
58651
- child2.on("error", (error) => {
58652
- clearTimeout(timer);
58653
- fail6(error);
58654
- });
58655
- child2.on("exit", (code) => fail6(new Error("Chromium exited (" + String(code) + "):\n" + said.slice(-2e3))));
58820
+ let said = "";
58821
+ child2.stderr?.on("data", (chunk) => {
58822
+ said += String(chunk);
58656
58823
  });
58824
+ return { child: child2, url: waitForDevTools({ child: child2, profile, stderr: () => said, timeoutMs: 3e4, name: "Chromium" }) };
58657
58825
  }
58658
58826
  async function connect2(url) {
58659
58827
  const socket = new WebSocket(url);
@@ -58688,8 +58856,7 @@ async function connect2(url) {
58688
58856
  if (exceptionDetails) throw new Error(exceptionDetails.exception?.description ?? exceptionDetails.text);
58689
58857
  return result.value;
58690
58858
  },
58691
- async close() {
58692
- await send2("Browser.close").catch(() => void 0);
58859
+ close() {
58693
58860
  socket.close();
58694
58861
  }
58695
58862
  };
@@ -58710,10 +58877,10 @@ async function drawStills(request, toolsPage2, say = (line) => console.log(line)
58710
58877
  const view2 = { ...request.version !== void 0 ? { version: request.version } : {}, ...request.ratio !== void 0 ? { ratio: request.ratio } : {} };
58711
58878
  const files = { documents: stillsDocumentsFor(film.documents, view2), blobs: film.blobs, mode: request.mode };
58712
58879
  const binary = findChromium();
58713
- const work = mkdtempSync2(join23(tmpdir2(), "film-tools-"));
58714
- const out = request.out === null ? mkdtempSync2(join23(tmpdir2(), "film-stills-")) : resolve16(request.out);
58880
+ const work = mkdtempSync2(join24(tmpdir2(), "film-tools-"));
58881
+ const out = request.out === null ? mkdtempSync2(join24(tmpdir2(), "film-stills-")) : resolve16(request.out);
58715
58882
  mkdirSync6(out, { recursive: true });
58716
- const page2 = join23(work, "tools.html");
58883
+ const page2 = join24(work, "tools.html");
58717
58884
  writeFileSync8(page2, toolsPage2);
58718
58885
  const json = request.json === true;
58719
58886
  const report = { problems: [], film: null, view: { version: request.version ?? null, ratio: request.ratio ?? null }, stills: [], score: null, levels: null, log: [] };
@@ -58721,11 +58888,13 @@ async function drawStills(request, toolsPage2, say = (line) => console.log(line)
58721
58888
  if (!json) say(text);
58722
58889
  };
58723
58890
  let child2 = null;
58891
+ let url = null;
58724
58892
  let browser = null;
58725
58893
  try {
58726
- const launched = await launch(binary, join23(work, "profile"));
58894
+ const launched = launch(binary, join24(work, "profile"));
58727
58895
  child2 = launched.child;
58728
- browser = await connect2(launched.url);
58896
+ url = await launched.url;
58897
+ browser = await connect2(url);
58729
58898
  await browser.navigate(pathToFileURL2(page2).href);
58730
58899
  for (let i = 0; i < 100 && await browser.evaluate("typeof window.filmTools") !== "object"; i++) await new Promise((next) => setTimeout(next, 100));
58731
58900
  const loaded = await browser.evaluate("window.filmTools.load(" + JSON.stringify(files) + ")");
@@ -58738,7 +58907,7 @@ async function drawStills(request, toolsPage2, say = (line) => console.log(line)
58738
58907
  for (const t of request.times) {
58739
58908
  try {
58740
58909
  const png = await browser.evaluate("window.filmTools.frame(" + String(t) + ", { scale: " + String(request.scale) + " })");
58741
- const file = join23(out, stillFileName(t));
58910
+ const file = join24(out, stillFileName(t));
58742
58911
  writeFileSync8(file, Buffer.from(png.slice(png.indexOf(",") + 1), "base64"));
58743
58912
  report.stills.push({ t, file });
58744
58913
  line(file);
@@ -58760,14 +58929,10 @@ async function drawStills(request, toolsPage2, say = (line) => console.log(line)
58760
58929
  if (json) say(JSON.stringify({ ...report, error: messageOf(error) }));
58761
58930
  return 1;
58762
58931
  } finally {
58763
- await browser?.close();
58764
- const running = child2;
58765
- if (running !== null && running.exitCode === null)
58766
- await new Promise((done2) => {
58767
- running.once("exit", () => done2());
58768
- running.kill();
58769
- });
58770
- rmSync7(work, { recursive: true, force: true });
58932
+ browser?.close();
58933
+ if (url !== null) await closeBrowserAt(url);
58934
+ if (child2 !== null) await stopChild(child2, { graceMs: 3e3 });
58935
+ removeProfile(work);
58771
58936
  }
58772
58937
  }
58773
58938
 
@@ -58805,7 +58970,7 @@ function stillsRequest(positional, flags) {
58805
58970
  };
58806
58971
  }
58807
58972
  async function toolsPage() {
58808
- const beside = join24(dirname10(fileURLToPath3(import.meta.url)), STILLS_TOOLS_PAGE);
58973
+ const beside = join25(dirname10(fileURLToPath3(import.meta.url)), STILLS_TOOLS_PAGE);
58809
58974
  if (existsSync16(beside)) return readFile8(beside, "utf8");
58810
58975
  const build = "@openartifactsai/motion-stage/build";
58811
58976
  try {
@@ -59028,11 +59193,11 @@ var flag = (args, name) => {
59028
59193
  var UsageError = class extends Error {
59029
59194
  };
59030
59195
  function stateDir() {
59031
- return process.env.OPEN_ARTIFACTS_TYPE_SERVER_HOME || join25(homedir4(), ".open-artifacts");
59196
+ return process.env.OPEN_ARTIFACTS_TYPE_SERVER_HOME || join26(homedir4(), ".open-artifacts");
59032
59197
  }
59033
59198
  async function readRecord() {
59034
59199
  try {
59035
- return JSON.parse(await readFile9(join25(stateDir(), "server.json"), "utf8"));
59200
+ return JSON.parse(await readFile9(join26(stateDir(), "server.json"), "utf8"));
59036
59201
  } catch {
59037
59202
  return null;
59038
59203
  }
@@ -59061,7 +59226,7 @@ async function liveServer() {
59061
59226
  async function startServer(port) {
59062
59227
  const dir = stateDir();
59063
59228
  await mkdir6(dir, { recursive: true });
59064
- const logFile = openSync3(join25(dir, "server.log"), "a");
59229
+ const logFile = openSync3(join26(dir, "server.log"), "a");
59065
59230
  const child2 = spawn5(process.execPath, [SELF, "serve", "--record", ...port ? ["--port", String(port)] : []], {
59066
59231
  detached: true,
59067
59232
  stdio: ["ignore", logFile, logFile],
@@ -59073,7 +59238,7 @@ async function startServer(port) {
59073
59238
  const record = await liveServer();
59074
59239
  if (record && record.pid === child2.pid) return record;
59075
59240
  }
59076
- throw new UsageError(`The server did not start; see ${join25(dir, "server.log")}.`);
59241
+ throw new UsageError(`The server did not start; see ${join26(dir, "server.log")}.`);
59077
59242
  }
59078
59243
  function artifactRoot(args) {
59079
59244
  const dir = args.positional[1];
@@ -59144,7 +59309,7 @@ async function cmdGenerate(args) {
59144
59309
  let changed = 0;
59145
59310
  for (const [path20, content] of Object.entries(out)) {
59146
59311
  if (content === (files.get(path20) ?? null)) continue;
59147
- const file = join25(root, "project", ...path20.split("/"));
59312
+ const file = join26(root, "project", ...path20.split("/"));
59148
59313
  if (content === null) await rm8(file, { force: true });
59149
59314
  else await writeAtomic(file, content);
59150
59315
  console.log(`${content === null ? "removed" : "wrote "} project/${path20}`);
@@ -59206,13 +59371,13 @@ function installFolder(namespace) {
59206
59371
  }
59207
59372
  var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", "build", "_blobs", "_agent", "history"]);
59208
59373
  async function findSystems(dir, depth, out) {
59209
- const index = join25(dir, "project", "design-system.json");
59374
+ const index = join26(dir, "project", "design-system.json");
59210
59375
  if (existsSync17(index)) {
59211
59376
  try {
59212
59377
  const raw = JSON.parse(await readFile9(index, "utf8"));
59213
59378
  if (hasMarker(raw)) {
59214
59379
  const system = normalizeSystemIndex(raw);
59215
- const at2 = (path20) => existsSync17(join25(dir, "project", path20)) ? join25(dir, "project", path20) : null;
59380
+ const at2 = (path20) => existsSync17(join26(dir, "project", path20)) ? join26(dir, "project", path20) : null;
59216
59381
  const shown = relative4(process.cwd(), dir);
59217
59382
  out.set(dir, {
59218
59383
  title: system.title,
@@ -59236,7 +59401,7 @@ async function findSystems(dir, depth, out) {
59236
59401
  }
59237
59402
  for (const entry of entries) {
59238
59403
  if (!entry.isDirectory() || entry.name.startsWith(".") || SKIP_DIRS.has(entry.name)) continue;
59239
- await findSystems(join25(dir, entry.name), depth - 1, out);
59404
+ await findSystems(join26(dir, entry.name), depth - 1, out);
59240
59405
  }
59241
59406
  }
59242
59407
  async function cmdList(args) {
@@ -59438,11 +59603,11 @@ async function cmdStop() {
59438
59603
  } catch {
59439
59604
  console.log("The recorded server was not running.");
59440
59605
  }
59441
- await rm8(join25(stateDir(), "server.json"), { force: true });
59606
+ await rm8(join26(stateDir(), "server.json"), { force: true });
59442
59607
  }
59443
59608
  function defaultAssets() {
59444
59609
  const here = dirname11(SELF);
59445
- if (existsSync17(join25(here, "editors"))) return here;
59610
+ if (existsSync17(join26(here, "editors"))) return here;
59446
59611
  return resolve18(here, "../../../dist/server");
59447
59612
  }
59448
59613
  async function cmdServe(args) {
@@ -59457,7 +59622,7 @@ async function cmdServe(args) {
59457
59622
  await server?.stop().catch(() => void 0);
59458
59623
  if (record) {
59459
59624
  const current2 = await readRecord();
59460
- if (current2?.pid === process.pid) await rm8(join25(stateDir(), "server.json"), { force: true });
59625
+ if (current2?.pid === process.pid) await rm8(join26(stateDir(), "server.json"), { force: true });
59461
59626
  }
59462
59627
  process.exit(code);
59463
59628
  };
@@ -59480,7 +59645,7 @@ async function cmdServe(args) {
59480
59645
  if (record) {
59481
59646
  await mkdir6(stateDir(), { recursive: true });
59482
59647
  const value2 = { pid: process.pid, url, secret, version: 1 };
59483
- await writeFile5(join25(stateDir(), "server.json"), `${JSON.stringify(value2, null, 2)}
59648
+ await writeFile5(join26(stateDir(), "server.json"), `${JSON.stringify(value2, null, 2)}
59484
59649
  `, { mode: 384 });
59485
59650
  }
59486
59651
  const ready3 = { openArtifacts: "ready", url };