@cloudhal/cli 0.6.3 → 0.6.4

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 (155) hide show
  1. package/dist/assets/starters/blog/package.json +4 -4
  2. package/dist/assets/starters/blog/src/pages/[...path]/llms.txt.ts +2 -1
  3. package/dist/assets/starters/blog/src/pages/[...path]/rss.xml.ts +2 -1
  4. package/dist/assets/starters/blog/src/pages/[...path].astro +3 -1
  5. package/dist/assets/starters/blog/src/pages/llms.txt.ts +2 -1
  6. package/dist/assets/starters/blog/src/pages/rss.xml.ts +2 -1
  7. package/dist/assets/starters/blog/src/pages/sitemap.xml.ts +2 -1
  8. package/dist/assets/studio/assets/{AccountPage-Dgdy4H1z.js → AccountPage-H-WA4dGT.js} +2 -2
  9. package/dist/assets/studio/assets/{ActivityPage-Bu56R6E7.js → ActivityPage-Srypf6N4.js} +2 -2
  10. package/dist/assets/studio/assets/{AgentModes-D695kSbw.js → AgentModes-BpVQlSk6.js} +2 -2
  11. package/dist/assets/studio/assets/{AgentsPage-BWlLRFPH.js → AgentsPage-qv2YlGAV.js} +2 -2
  12. package/dist/assets/studio/assets/{AnalyticsPage-C0RPBuUR.js → AnalyticsPage-CLtrDh7Z.js} +2 -2
  13. package/dist/assets/studio/assets/{ApprovalsPage-B1398iby.js → ApprovalsPage-CUR9ed9S.js} +3 -3
  14. package/dist/assets/studio/assets/{ArticleEditorPage-jOUCZ_79.js → ArticleEditorPage-BDeeSrWu.js} +3 -3
  15. package/dist/assets/studio/assets/{ArticlesPage-CbpeF5qT.js → ArticlesPage-CbVEh_35.js} +3 -3
  16. package/dist/assets/studio/assets/{AssetPage-DZr_G7__.js → AssetPage-DlChJGnk.js} +2 -2
  17. package/dist/assets/studio/assets/{Audit-DrQvb5mu.js → Audit-Cu1AA_BU.js} +2 -2
  18. package/dist/assets/studio/assets/{AuditBadges-BVr05Xyt.js → AuditBadges-CAG3kk0E.js} +2 -2
  19. package/dist/assets/studio/assets/{AutomationsPage-CfS05QHu.js → AutomationsPage-B3FtFLH9.js} +2 -2
  20. package/dist/assets/studio/assets/{BlockSection-Cy4Qt5cS.js → BlockSection-Di7jTvtZ.js} +2 -2
  21. package/dist/assets/studio/assets/{BodyChanges-Kz6YliT_.js → BodyChanges-D0KudPII.js} +2 -2
  22. package/dist/assets/studio/assets/{BodyEditor-Dk-GQfp9.js → BodyEditor-CA9Mrbxr.js} +3 -3
  23. package/dist/assets/studio/assets/{BuildPage-ohS6E6nm.js → BuildPage-BRqgk24y.js} +2 -2
  24. package/dist/assets/studio/assets/{CodeHighlighted-uUDbvdKY.js → CodeHighlighted-DOw6b1bt.js} +2 -2
  25. package/dist/assets/studio/assets/{CollectionSettingsPage-3e_npZNv.js → CollectionSettingsPage-CYrVbSYX.js} +3 -3
  26. package/dist/assets/studio/assets/{CollectionsPage-DqM5_dJR.js → CollectionsPage-CS1VN18t.js} +2 -2
  27. package/dist/assets/studio/assets/{CommandMenu-Cedh4xtl.js → CommandMenu-C8yL2U9-.js} +2 -2
  28. package/dist/assets/studio/assets/{CommentThreadControls-CmD52U5z.js → CommentThreadControls-C0BWavL5.js} +2 -2
  29. package/dist/assets/studio/assets/{CommentThreadPage-CX87ADPi.js → CommentThreadPage-cYaOeczW.js} +2 -2
  30. package/dist/assets/studio/assets/{CommenterPage-C-Vv0BQK.js → CommenterPage-C523SRcJ.js} +2 -2
  31. package/dist/assets/studio/assets/{Comments-4cWUXtON.js → Comments-CvWYWy69.js} +2 -2
  32. package/dist/assets/studio/assets/{CommentsPage-Bc2nVm6x.js → CommentsPage-CRiP84dZ.js} +2 -2
  33. package/dist/assets/studio/assets/{ConfirmDialog-DH2jGk29.js → ConfirmDialog-CsHmHVMF.js} +2 -2
  34. package/dist/assets/studio/assets/{ContentListQuery-BuxxdIsz.js → ContentListQuery-BSHtfRw_.js} +2 -2
  35. package/dist/assets/studio/assets/{Crumbs-Bg-oOv-g.js → Crumbs-BtXRFlc6.js} +2 -2
  36. package/dist/assets/studio/assets/{DateTimeField-DlaSbbAW.js → DateTimeField-CFudnuoh.js} +2 -2
  37. package/dist/assets/studio/assets/{EditorLayout-Dp_3DB2G.js → EditorLayout-DxQ1u__q.js} +2 -2
  38. package/dist/assets/studio/assets/{EditorPreview-CLPIy9Da.js → EditorPreview-Bo99QOzI.js} +2 -2
  39. package/dist/assets/studio/assets/{Elevation-CpzbzjZ1.js → Elevation-CiKay2aG.js} +2 -2
  40. package/dist/assets/studio/assets/{ElevationRequest-DGZR_Qu7.js → ElevationRequest-BDSQJrIU.js} +2 -2
  41. package/dist/assets/studio/assets/{EndedBadge-CuESOF9v.js → EndedBadge-B6Zr5zNC.js} +2 -2
  42. package/dist/assets/studio/assets/{EntryFieldsCard-DpfwTRoT.js → EntryFieldsCard-vnCp1-sA.js} +2 -2
  43. package/dist/assets/studio/assets/{EntryPath-DBK2nqWS.js → EntryPath-C7FxCw7K.js} +2 -2
  44. package/dist/assets/studio/assets/{FieldsSection-B-_c-cLU.js → FieldsSection-DtZdExyR.js} +2 -2
  45. package/dist/assets/studio/assets/{ForgotPasswordPage-4T_xsZc7.js → ForgotPasswordPage-Dn07bnoC.js} +2 -2
  46. package/dist/assets/studio/assets/{Gating-BKw9x3OA.js → Gating-Dgf85WmM.js} +2 -2
  47. package/dist/assets/studio/assets/{GovernanceDialog-WI6muWSG.js → GovernanceDialog-BY_KYC1q.js} +2 -2
  48. package/dist/assets/studio/assets/{InvitePage-BWcoBszO.js → InvitePage-DrPRmzk5.js} +2 -2
  49. package/dist/assets/studio/assets/{ListFieldColumns-DLqDR_nL.js → ListFieldColumns-BTLtwnNa.js} +2 -2
  50. package/dist/assets/studio/assets/{ListToolbar-_lpYaeal.js → ListToolbar-B2reIfhH.js} +2 -2
  51. package/dist/assets/studio/assets/{ListingSections-lyTz_PaH.js → ListingSections-jx5ry8y3.js} +2 -2
  52. package/dist/assets/studio/assets/LoginPage-LRB8Hz6E.js +2 -0
  53. package/dist/assets/studio/assets/{MediaPage-DaCldFys.js → MediaPage-DxC-O72m.js} +2 -2
  54. package/dist/assets/studio/assets/{MediaPicker-DYJj3Gtp.js → MediaPicker-DyTkkW4K.js} +2 -2
  55. package/dist/assets/studio/assets/{MediaUpload-DuQnkN1u.js → MediaUpload-Cd9LNKs1.js} +2 -2
  56. package/dist/assets/studio/assets/{MembersPage-fMlwYa1x.js → MembersPage-BJTx93gb.js} +2 -2
  57. package/dist/assets/studio/assets/{Menus-Dym_0ijH.js → Menus-W8XZpgqq.js} +2 -2
  58. package/dist/assets/studio/assets/{NavigationPage-CTQt0njO.js → NavigationPage-4VQ3989y.js} +2 -2
  59. package/dist/assets/studio/assets/{NewSiteDialog-DVWeKGsw.js → NewSiteDialog-BgdpEYuC.js} +2 -2
  60. package/dist/assets/studio/assets/{NotificationItems--5FaR3tN.js → NotificationItems-x_CrRI18.js} +2 -2
  61. package/dist/assets/studio/assets/{PageEditorPage-BlG2sPAB.js → PageEditorPage-NTyB8eKT.js} +3 -3
  62. package/dist/assets/studio/assets/{PagesPage-BXU3jxTQ.js → PagesPage-Dra8wqhZ.js} +2 -2
  63. package/dist/assets/studio/assets/{PasswordField-1kzPgqLo.js → PasswordField-BwLcXkWe.js} +2 -2
  64. package/dist/assets/studio/assets/{PreviewPanel-3eVWgDDN.js → PreviewPanel-C3ouq_VT.js} +2 -2
  65. package/dist/assets/studio/assets/{ProjectPage-CdYFYMv3.js → ProjectPage-BZwBNht9.js} +2 -2
  66. package/dist/assets/studio/assets/{Readers-BwBWWzB-.js → Readers-Crbc6-d2.js} +3 -3
  67. package/dist/assets/studio/assets/{RedirectDialog-BqlclE-n.js → RedirectDialog-CVeubZoX.js} +2 -2
  68. package/dist/assets/studio/assets/{RedirectsPage-Bpnn14p_.js → RedirectsPage-CszTpqLO.js} +2 -2
  69. package/dist/assets/studio/assets/{RelativeTime-B3WDq_Ti.js → RelativeTime-Cz0kO5a6.js} +2 -2
  70. package/dist/assets/studio/assets/{ReleaseApproval-CEM7iJKI.js → ReleaseApproval-Cnv1iobY.js} +2 -2
  71. package/dist/assets/studio/assets/{ReleasePage-B9db-dEu.js → ReleasePage-D2VfXa8K.js} +2 -2
  72. package/dist/assets/studio/assets/{ReleaseParts-CI9sIfLw.js → ReleaseParts-D351Bl88.js} +2 -2
  73. package/dist/assets/studio/assets/{ResetPasswordPage-C24Mv9le.js → ResetPasswordPage-CHf_0zZv.js} +2 -2
  74. package/dist/assets/studio/assets/{RowMenu-CvvLvp2V.js → RowMenu-BlS9vXie.js} +2 -2
  75. package/dist/assets/studio/assets/{ScheduleCard-CTZ7DyA9.js → ScheduleCard-C87eLMht.js} +2 -2
  76. package/dist/assets/studio/assets/{ScheduleDialog-TQgKxIsr.js → ScheduleDialog-BwBYA6pc.js} +2 -2
  77. package/dist/assets/studio/assets/{ScheduleHistoryPage-9lUX1OC9.js → ScheduleHistoryPage-CL25zeNn.js} +2 -2
  78. package/dist/assets/studio/assets/{ScheduleStatusBadge-CLqNp1Rc.js → ScheduleStatusBadge-ChmmnC94.js} +2 -2
  79. package/dist/assets/studio/assets/{SchedulerStalled-mEbvw7Q_.js → SchedulerStalled-D-r-bG15.js} +2 -2
  80. package/dist/assets/studio/assets/{Schedules-7od0mh_y.js → Schedules-BcAUO3yt.js} +2 -2
  81. package/dist/assets/studio/assets/{SchedulesPage-Cj-QwGdy.js → SchedulesPage-CSUkrDNZ.js} +2 -2
  82. package/dist/assets/studio/assets/{ScopeBadge-J87LKFHA.js → ScopeBadge-DhZzXufT.js} +2 -2
  83. package/dist/assets/studio/assets/{Seo-YV7wVEPY.js → Seo-CNeksZ_k.js} +2 -2
  84. package/dist/assets/studio/assets/{SeoPreview-CAaNUyjg.js → SeoPreview-lOFM26fE.js} +2 -2
  85. package/dist/assets/studio/assets/{Settings-DX31HFBM.js → Settings-C-MzOZKZ.js} +2 -2
  86. package/dist/assets/studio/assets/{SiteAccessField-DQaQg5ez.js → SiteAccessField-B6QH60a2.js} +2 -2
  87. package/dist/assets/studio/assets/{SiteOverviewPage-lk4wap0q.js → SiteOverviewPage-CsBoUK1t.js} +3 -3
  88. package/dist/assets/studio/assets/{SiteSettingsPage-mCQPDJzA.js → SiteSettingsPage--dJ4ixUw.js} +2 -2
  89. package/dist/assets/studio/assets/{SitesPage-gxcSR0ad.js → SitesPage-vSr-9mb5.js} +2 -2
  90. package/dist/assets/studio/assets/{SkillsPage-_ZUdPF2E.js → SkillsPage-BVXLmxiw.js} +2 -2
  91. package/dist/assets/studio/assets/{SnapshotsPage-DLUbZ563.js → SnapshotsPage-Yh4XX1pY.js} +2 -2
  92. package/dist/assets/studio/assets/{StatTile-KhE3fINB.js → StatTile-3dmRmP7D.js} +2 -2
  93. package/dist/assets/studio/assets/{Status-W9nLsw86.js → Status-WIcIPfpv.js} +2 -2
  94. package/dist/assets/studio/assets/{StatusActions-CqCXSQ46.js → StatusActions-bOOicoBx.js} +3 -3
  95. package/dist/assets/studio/assets/{TableSkeleton-SmOOTzX3.js → TableSkeleton-DJFmIeGf.js} +2 -2
  96. package/dist/assets/studio/assets/{TagsMigration-rd5JiDwq.js → TagsMigration-BkgKXkPv.js} +2 -2
  97. package/dist/assets/studio/assets/{Taxonomy-CZjclj3o.js → Taxonomy-ClnBvp37.js} +2 -2
  98. package/dist/assets/studio/assets/{TaxonomyPage-DqlGIFcb.js → TaxonomyPage-BQ9-YC7N.js} +2 -2
  99. package/dist/assets/studio/assets/{TaxonomySettingsDialog-Bn2QdsNY.js → TaxonomySettingsDialog-wbik9O2h.js} +2 -2
  100. package/dist/assets/studio/assets/{TermEditorPage-BoW7eXoX.js → TermEditorPage-TlMOvCCe.js} +2 -2
  101. package/dist/assets/studio/assets/{TermPickers-BMXiPCa0.js → TermPickers-Blo4P5i0.js} +2 -2
  102. package/dist/assets/studio/assets/{TranslationList-7PC6LAd9.js → TranslationList-DBk1eLpg.js} +2 -2
  103. package/dist/assets/studio/assets/{TranslationsPage--a62-gT6.js → TranslationsPage-QM9l7PZ7.js} +2 -2
  104. package/dist/assets/studio/assets/{api-errors-tZYwLeo6.js → api-errors-CrlMh7Uh.js} +2 -2
  105. package/dist/assets/studio/assets/{ar-BUKtNVP6.js → ar-kwcrV10j.js} +2 -2
  106. package/dist/assets/studio/assets/auth-BzR8abXz.js +4 -0
  107. package/dist/assets/studio/assets/{charts-DS4cDmaj.js → charts-CfsBpX7Q.js} +2 -2
  108. package/dist/assets/studio/assets/{collapsible-l8g94on4w7qfosmn-ClVVSlmf.js → collapsible-l8g94on4w7qfosmn-HrcveUz2.js} +2 -2
  109. package/dist/assets/studio/assets/{collection-icons-D-IZFMkB.js → collection-icons-9ine0lwT.js} +2 -2
  110. package/dist/assets/studio/assets/{combobox-hdxtsm2gqcxxgfju-DhX6ZIcI.js → combobox-hdxtsm2gqcxxgfju-KnLrjt1Y.js} +2 -2
  111. package/dist/assets/studio/assets/{de-DWHO_HkU.js → de-C-Bbcibt.js} +2 -2
  112. package/dist/assets/studio/assets/{deleteLabels-DH7Oba8-.js → deleteLabels-BfWGeH4k.js} +2 -2
  113. package/dist/assets/studio/assets/{editor-BrVbznPe.js → editor-CimRuo-s.js} +66 -61
  114. package/dist/assets/studio/assets/{es-C07OD_XS.js → es-DRXEyf0l.js} +2 -2
  115. package/dist/assets/studio/assets/{fa-Cgls-bgZ.js → fa-C1MtIlym.js} +2 -2
  116. package/dist/assets/studio/assets/{fr-QRT6iq33.js → fr-B396areL.js} +2 -2
  117. package/dist/assets/studio/assets/{he-CBKpkqQI.js → he-CZwil4jG.js} +2 -2
  118. package/dist/assets/studio/assets/{hi-eQ3OUtm4.js → hi-Crgk0N23.js} +2 -2
  119. package/dist/assets/studio/assets/{i18n-BsaF_Usk.js → i18n-Dab0ajqW.js} +3 -3
  120. package/dist/assets/studio/assets/{id-C93G1k_A.js → id-Z3wSQ21N.js} +2 -2
  121. package/dist/assets/studio/assets/{index-CRaauoqY.js → index-E8BSdBPW.js} +3 -3
  122. package/dist/assets/studio/assets/{it-DYqXpRiP.js → it-D_e5w1W5.js} +2 -2
  123. package/dist/assets/studio/assets/{ja-D9n_rxyV.js → ja-XexIMFCE.js} +2 -2
  124. package/dist/assets/studio/assets/{ko-hS1dOTFu.js → ko-BphIzzGa.js} +2 -2
  125. package/dist/assets/studio/assets/{layer-dialog-j5ywmzs46ccg6oqy-a5UYrx-X.js → layer-dialog-j5ywmzs46ccg6oqy-_2cczT-K.js} +2 -2
  126. package/dist/assets/studio/assets/{nl-Dh6z5Vys.js → nl-D2pGOej6.js} +2 -2
  127. package/dist/assets/studio/assets/{pl-ClD48bGQ.js → pl-BdQ-KeLm.js} +2 -2
  128. package/dist/assets/studio/assets/{pt-BR-B1t2IuB6.js → pt-BR-lI2va4Ax.js} +2 -2
  129. package/dist/assets/studio/assets/{ru-1Ypf-SpC.js → ru-BuBa5alG.js} +2 -2
  130. package/dist/assets/studio/assets/{tag-input-ohfybx5dbxy3houy-Bfh3Yb-x.js → tag-input-ohfybx5dbxy3houy-Bosoy5du.js} +2 -2
  131. package/dist/assets/studio/assets/{tr-CYoHJpqA.js → tr-2tUDztjs.js} +2 -2
  132. package/dist/assets/studio/assets/{uk-UznF4_3D.js → uk-D-x13N_h.js} +2 -2
  133. package/dist/assets/studio/assets/{useAnalyticsCard-DkpiYb5T.js → useAnalyticsCard-3ehEghuO.js} +2 -2
  134. package/dist/assets/studio/assets/{useCollectionView-Cj_hlmHt.js → useCollectionView-BvImCfGW.js} +3 -3
  135. package/dist/assets/studio/assets/{useLiveSite-BCjxnCp4.js → useLiveSite-BXT7Tep7.js} +2 -2
  136. package/dist/assets/studio/assets/{useMe-CxI04z9a.js → useMe-BQDOgqHt.js} +2 -2
  137. package/dist/assets/studio/assets/{usePaging-4q9qSaT2.js → usePaging-Mr18xaY2.js} +2 -2
  138. package/dist/assets/studio/assets/{zh-Hans-3w2oZuI1.js → zh-Hans-hT5IaMLb.js} +2 -2
  139. package/dist/assets/studio/index.html +6 -6
  140. package/dist/src/cli/commands-local.js +4 -0
  141. package/dist/src/cli/help.d.ts +1 -2
  142. package/dist/src/cli/help.js +40 -13
  143. package/dist/src/commands/init.d.ts +12 -0
  144. package/dist/src/commands/init.js +28 -9
  145. package/dist/src/commands/studio-auth.d.ts +52 -0
  146. package/dist/src/commands/studio-auth.js +130 -0
  147. package/dist/src/commands/studio-options.d.ts +22 -6
  148. package/dist/src/commands/studio-options.js +79 -17
  149. package/dist/src/commands/studio.d.ts +17 -6
  150. package/dist/src/commands/studio.js +68 -22
  151. package/dist/src/index.d.ts +2 -1
  152. package/dist/src/index.js +2 -1
  153. package/package.json +13 -13
  154. package/dist/assets/studio/assets/LoginPage-blPVGXvN.js +0 -2
  155. package/dist/assets/studio/assets/auth-BsoY4NJQ.js +0 -4
@@ -1,24 +1,40 @@
1
- /** `cloudhal --help`; every command it names has an entry in `COMMANDS` (cli.ts). */
2
- export const HELP = `cloudhal — agent-native sites
3
-
4
- Usage:
5
- cloudhal init <dir> [--name <name>] [--starter blog] create a site project with a seeded local store
6
- cloudhal dev [--port <n>] [--host [<addr>]] live preview (drafts visible)
1
+ /**
2
+ * `cloudhal --help`; every command it names has an entry in `COMMANDS` (cli.ts). The usage text is
3
+ * in four pieces, each a readable size: the project on this machine, Cloudflare, content and sites,
4
+ * operations. `HELP` prints them in that order.
5
+ */
6
+ /** init, dev, snapshot, build, studio, mcp: the project on this machine. */
7
+ const PROJECT = ` cloudhal init <dir> [--name <name>] [--starter blog] create a site project with a seeded local store
8
+ cloudhal dev [--port <n>] [--host [<addr>]] live preview (drafts visible); --host alone is
9
+ 0.0.0.0, every IPv4 address (:: for IPv6 too)
7
10
  cloudhal snapshot [--label <text>] [--publish] freeze the current graph (optionally publish)
8
11
  cloudhal build [--snapshot <id>] static HTML from the published/latest snapshot
9
12
  cloudhal studio [--port <n>] [--host [<addr>]] [--base-url <url>] [--behind-proxy] [--no-auth]
10
13
  [--init-if-empty [--starter blog] [--name <name>]]
11
14
  API + Studio UI for this project (default :8787);
15
+ while nobody has an account it prints a one-time
16
+ setup link for the owner (or set CLOUDHAL_SETUP_TOKEN:
17
+ 32+ characters of A-Z a-z 0-9 - . _ ~); --no-auth
18
+ skips sign-in for local scripts and is refused
19
+ unless --host is loopback and --behind-proxy is off;
12
20
  self-hosting: --host 0.0.0.0 (CLOUDHAL_HOST) listens
13
- beyond this machine, --base-url (CLOUDHAL_BASE_URL)
14
- is the public origin behind a reverse proxy,
21
+ beyond this machine (alone: every IPv4 address),
22
+ --base-url (CLOUDHAL_BASE_URL) is the origin browsers
23
+ open Studio at, required behind a reverse proxy and
24
+ recommended whenever --host is not loopback (without
25
+ it sign-in accepts each request's own origin),
15
26
  --behind-proxy (CLOUDHAL_BEHIND_PROXY=1) trusts its
16
- X-Forwarded-Proto/Host, --init-if-empty
27
+ X-Forwarded-Proto/Host and the last X-Forwarded-For
28
+ hop and needs --base-url, --init-if-empty
17
29
  (CLOUDHAL_INIT=<starter>) creates the project first
18
- when the folder has no cloudhal.json
30
+ when the folder is empty (lost+found aside) and has
31
+ no cloudhal.json
19
32
  cloudhal mcp [--mode plan|manual|edits|auto|bypass] [--scopes a,b] [--skills <dir>] [--preview-url <url>]
20
33
  MCP server over stdio for this project
21
- cloudhal deploy [--name <base>] [--dry-run] [--jurisdiction eu] [--scheduler cron|alarm] [--plan free|paid]
34
+ `;
35
+
36
+ /** deploy, domain, push, pull: the Cloudflare deployment. */
37
+ const CLOUDFLARE = ` cloudhal deploy [--name <base>] [--dry-run] [--jurisdiction eu] [--scheduler cron|alarm] [--plan free|paid]
22
38
  [--force-downgrade] [--no-build-studio]
23
39
  site + admin Workers on Cloudflare (uses wrangler login);
24
40
  --jurisdiction eu keeps a newly created D1 database
@@ -36,7 +52,10 @@ Usage:
36
52
  local site → deployment (refused while releases are
37
53
  open unless --cancel-schedules cancels them)
38
54
  cloudhal pull [--replace] [--admin-url <url>] deployment → local site
39
- cloudhal export [--out <file>] [--site <id>] [--no-media] [--latest-only]
55
+ `;
56
+
57
+ /** export, import, owner, site, migrate, fields: content and sites. */
58
+ const CONTENT = ` cloudhal export [--out <file>] [--site <id>] [--no-media] [--latest-only]
40
59
  one site as a .cloudhal file (RFC-0039): its graph,
41
60
  snapshots and media; never user accounts, comments,
42
61
  analytics or secrets (its history names who made each
@@ -76,7 +95,10 @@ Usage:
76
95
  change a collection's typed fields with their values
77
96
  (RFC-0041): snapshotted, resumable; --dry-run reports
78
97
  and greps the theme; revert <id> undoes a run
79
- cloudhal media import-urls [--dry-run] [--include-markdown] [--allow-host <host>]… | --revert <id>
98
+ `;
99
+
100
+ /** media, analytics, comments, schedules, ai, render, motion, tokens, chrome, search. */
101
+ const OPERATIONS = ` cloudhal media import-urls [--dry-run] [--include-markdown] [--allow-host <host>]… | --revert <id>
80
102
  copy linked images into the media library
81
103
  (RFC-0004); revertible
82
104
  cloudhal media verify [<assetId>] recompute media checksums
@@ -120,3 +142,8 @@ Usage:
120
142
  (publishing keeps it current; for restored backups)
121
143
  cloudhal --help
122
144
  `;
145
+
146
+ export const HELP = `cloudhal — agent-native sites
147
+
148
+ Usage:
149
+ ${PROJECT}${CLOUDFLARE}${CONTENT}${OPERATIONS}`;
@@ -3,9 +3,21 @@ export interface InitOptions {
3
3
  readonly name?: string;
4
4
  readonly starter?: string;
5
5
  readonly log?: (line: string) => void;
6
+ /**
7
+ * The folder the project will live in when `dir` is only a staging folder it is moved from
8
+ * (`cloudhal studio --init-if-empty`): relative `link:` paths to a source checkout are computed
9
+ * from here. Default: `dir`.
10
+ */
11
+ readonly finalDir?: string;
6
12
  }
7
13
  /** Walks up from `dir` to find a pnpm workspace root (so copied starters keep `workspace:*` links). */
8
14
  export declare function findWorkspaceRoot(dir: string): Promise<string | undefined>;
15
+ /**
16
+ * A package name from a site name: lowercase, every run of other characters one `-`, no `-` at
17
+ * either end, at most 64 characters. One pass, linear in the input (no backtracking regex: CodeQL
18
+ * js/polynomial-redos).
19
+ */
20
+ export declare function slugify(s: string): string;
9
21
  export interface InitResult {
10
22
  readonly projectDir: string;
11
23
  readonly siteId: string;
@@ -20,6 +20,12 @@ import { starterFilter } from "../starter-files.js";
20
20
 
21
21
 
22
22
 
23
+
24
+
25
+
26
+
27
+
28
+
23
29
 
24
30
 
25
31
  async function exists(p ) {
@@ -42,14 +48,27 @@ export async function findWorkspaceRoot(dir )
42
48
  }
43
49
  }
44
50
 
45
- function slugify(s ) {
46
- return (
47
- s
48
- .toLowerCase()
49
- .replace(/[^a-z0-9]+/g, "-")
50
- .replace(/^-+|-+$/g, "")
51
- .slice(0, 64) || "site"
52
- );
51
+ /**
52
+ * A package name from a site name: lowercase, every run of other characters one `-`, no `-` at
53
+ * either end, at most 64 characters. One pass, linear in the input (no backtracking regex: CodeQL
54
+ * js/polynomial-redos).
55
+ */
56
+ export function slugify(s ) {
57
+ let out = "";
58
+ let dash = false;
59
+ for (const ch of s.toLowerCase()) {
60
+ if ((ch >= "a" && ch <= "z") || (ch >= "0" && ch <= "9")) {
61
+ if (dash && out) {
62
+ // a dash only when the character after it fits too: never a trailing "-"
63
+ if (out.length + 2 > 64) break;
64
+ out += "-";
65
+ }
66
+ dash = false;
67
+ out += ch;
68
+ if (out.length >= 64) break;
69
+ } else dash = true;
70
+ }
71
+ return out || "site";
53
72
  }
54
73
 
55
74
 
@@ -96,7 +115,7 @@ export async function init(options ) {
96
115
  const out = repo
97
116
  ? materializeDependencies(pkg, await monorepoVersions(repo), {
98
117
  // real paths, so the relative link survives symlinked folders (macOS /var → /private/var)
99
- linkFrom: await realpath(projectDir),
118
+ linkFrom: await realpath(options.finalDir ?? projectDir),
100
119
  })
101
120
  : pkg;
102
121
  await writeFile(pkgPath, `${JSON.stringify(out, null, 2)}\n`);
@@ -0,0 +1,52 @@
1
+ /**
2
+ * What `cloudhal studio` does about authentication where it does not run on the author's own
3
+ * machine (#165): `--no-auth` stays on this machine, the first account needs a one-time setup
4
+ * token (RFC-0005 §7; `CLOUDHAL_SETUP_TOKEN`, or one printed at start) so a fresh Studio on a
5
+ * network cannot be claimed by whoever reaches it first, and a Studio reachable beyond loopback
6
+ * without a public origin is warned about.
7
+ */
8
+ import type { SqlDriver } from "@cloudhal/storage";
9
+ import type { StudioServer } from "./studio-options.js";
10
+ type Env = Readonly<Record<string, string | undefined>>;
11
+ /** Loopback addresses: the default bind (`127.0.0.1`), and the only ones `--no-auth` may use. */
12
+ export declare function isLoopbackHost(host: string | undefined): boolean;
13
+ /**
14
+ * `--no-auth` publishes every scope to whoever reaches the port (its only guard is a `Host` allow
15
+ * list any client can satisfy), so it is for this machine only: a loopback address and no proxy in
16
+ * front (#165).
17
+ */
18
+ export declare function assertNoAuthLocal(server: StudioServer): void;
19
+ /** The token the first account must present, and where it came from. */
20
+ export interface SetupToken {
21
+ readonly token: string;
22
+ readonly source: "env" | "generated";
23
+ }
24
+ /**
25
+ * The one-time token the first account must present (header `x-cloudhal-setup-token`; RFC-0005 §7,
26
+ * #165): `CLOUDHAL_SETUP_TOKEN` when set, else a fresh random one for this process. It is only
27
+ * asked for while nobody has an account.
28
+ */
29
+ export declare function resolveSetupToken(env?: Env): SetupToken;
30
+ /** Whether anybody has an account yet (Better Auth's `user` table, storage migration 0002). */
31
+ export declare function hasAccounts(sql: Pick<SqlDriver, "get">): Promise<boolean>;
32
+ /** The setup link `studio()` reports while nobody has an account. */
33
+ export interface StudioSetup {
34
+ /** `<studio url>login#setup=<token>`: the token travels in the fragment, never to a server. */
35
+ readonly url: string;
36
+ readonly tokenSource: "env" | "generated";
37
+ }
38
+ /**
39
+ * What `cloudhal studio` prints for a `StudioSetup` (an operator reads it from the container's
40
+ * log). A token the operator set themselves is not repeated: logs may be kept.
41
+ */
42
+ export declare function describeSetup(setup: StudioSetup): string;
43
+ /**
44
+ * Behind a reverse proxy the public origin is known, and Better Auth needs it as its base URL: for
45
+ * `Secure` session cookies on https and for the one origin sign-in accepts. Without it the server
46
+ * would trust whatever origin the forwarded headers name, or (on loopback) refuse every sign-in, so
47
+ * `--behind-proxy` without `--base-url` is refused at start (#165).
48
+ */
49
+ export declare function assertProxyHasBaseUrl(server: StudioServer): void;
50
+ /** One line for a Studio reachable beyond this machine without a public origin (#165). */
51
+ export declare function noBaseUrlWarning(server: StudioServer): string | undefined;
52
+ export {};
@@ -0,0 +1,130 @@
1
+ /**
2
+ * What `cloudhal studio` does about authentication where it does not run on the author's own
3
+ * machine (#165): `--no-auth` stays on this machine, the first account needs a one-time setup
4
+ * token (RFC-0005 §7; `CLOUDHAL_SETUP_TOKEN`, or one printed at start) so a fresh Studio on a
5
+ * network cannot be claimed by whoever reaches it first, and a Studio reachable beyond loopback
6
+ * without a public origin is warned about.
7
+ */
8
+
9
+
10
+
11
+
12
+
13
+ /** Loopback addresses: the default bind (`127.0.0.1`), and the only ones `--no-auth` may use. */
14
+ export function isLoopbackHost(host ) {
15
+ if (host === undefined) return true;
16
+ const h = host
17
+ .trim()
18
+ .toLowerCase()
19
+ .replace(/^\[(.*)\]$/, "$1");
20
+ return (
21
+ h === "localhost" ||
22
+ h === "::1" ||
23
+ h === "::ffff:127.0.0.1" ||
24
+ /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(h)
25
+ );
26
+ }
27
+
28
+ /**
29
+ * `--no-auth` publishes every scope to whoever reaches the port (its only guard is a `Host` allow
30
+ * list any client can satisfy), so it is for this machine only: a loopback address and no proxy in
31
+ * front (#165).
32
+ */
33
+ export function assertNoAuthLocal(server ) {
34
+ if (isLoopbackHost(server.hostname) && !server.behindProxy) return;
35
+ const why = server.behindProxy ? "--behind-proxy is set" : `--host is ${server.hostname}`;
36
+ throw new Error(
37
+ `--no-auth is for this machine only: it needs a loopback --host (127.0.0.1, the default, or ::1) and no --behind-proxy, but ${why}. Run with authentication to serve Studio beyond localhost.`,
38
+ );
39
+ }
40
+
41
+ /** The token the first account must present, and where it came from. */
42
+
43
+
44
+
45
+
46
+
47
+ /** A `CLOUDHAL_SETUP_TOKEN` must be hard to guess (the same floor `cloudhal deploy` asks for). */
48
+ const MIN_SETUP_TOKEN_LENGTH = 32;
49
+ /**
50
+ * The characters a token may use: it travels in a URL fragment, where Studio's login page reads
51
+ * `+` as a space and `%`, `&` or `#` change the value (base64url, hex and UUIDs fit).
52
+ */
53
+ const SETUP_TOKEN_CHARS = /^[A-Za-z0-9._~-]+$/;
54
+
55
+ /**
56
+ * The one-time token the first account must present (header `x-cloudhal-setup-token`; RFC-0005 §7,
57
+ * #165): `CLOUDHAL_SETUP_TOKEN` when set, else a fresh random one for this process. It is only
58
+ * asked for while nobody has an account.
59
+ */
60
+ export function resolveSetupToken(env = process.env) {
61
+ const given = env.CLOUDHAL_SETUP_TOKEN?.trim();
62
+ if (given) {
63
+ if (given.length < MIN_SETUP_TOKEN_LENGTH)
64
+ throw new Error(
65
+ `CLOUDHAL_SETUP_TOKEN must be at least ${MIN_SETUP_TOKEN_LENGTH} characters (a random value); unset it and cloudhal studio prints a setup link instead`,
66
+ );
67
+ if (!SETUP_TOKEN_CHARS.test(given))
68
+ throw new Error(
69
+ "CLOUDHAL_SETUP_TOKEN may only use letters, digits and - . _ ~ (it travels in the setup link): use e.g. `openssl rand -hex 32`",
70
+ );
71
+ return { token: given, source: "env" };
72
+ }
73
+ const bytes = crypto.getRandomValues(new Uint8Array(32));
74
+ return { token: Buffer.from(bytes).toString("base64url"), source: "generated" };
75
+ }
76
+
77
+ /** Whether anybody has an account yet (Better Auth's `user` table, storage migration 0002). */
78
+ export async function hasAccounts(sql ) {
79
+ const row = await sql.get ('SELECT COUNT(*) AS n FROM "user"');
80
+ return (row?.n ?? 0) > 0;
81
+ }
82
+
83
+ /** The setup link `studio()` reports while nobody has an account. */
84
+
85
+
86
+
87
+
88
+
89
+
90
+ /** The setup link with the token replaced by its variable's name (a string search, no regex). */
91
+ function withoutToken(url ) {
92
+ const at = url.indexOf("#setup=");
93
+ return `${at === -1 ? url : url.slice(0, at)}#setup=<CLOUDHAL_SETUP_TOKEN>`;
94
+ }
95
+
96
+ /**
97
+ * What `cloudhal studio` prints for a `StudioSetup` (an operator reads it from the container's
98
+ * log). A token the operator set themselves is not repeated: logs may be kept.
99
+ */
100
+ export function describeSetup(setup ) {
101
+ const fromEnv = setup.tokenSource === "env";
102
+ const link = fromEnv ? withoutToken(setup.url) : setup.url;
103
+ return [
104
+ "No account yet. Create the owner account (once) at this one-time setup link:",
105
+ ` ${link}`,
106
+ fromEnv
107
+ ? " (the token is the value of CLOUDHAL_SETUP_TOKEN; it is not printed)"
108
+ : " (printed only here; without it nobody can sign up)",
109
+ " If you open Studio at another address, keep the #setup=… part of the link.",
110
+ ].join("\n");
111
+ }
112
+
113
+ /**
114
+ * Behind a reverse proxy the public origin is known, and Better Auth needs it as its base URL: for
115
+ * `Secure` session cookies on https and for the one origin sign-in accepts. Without it the server
116
+ * would trust whatever origin the forwarded headers name, or (on loopback) refuse every sign-in, so
117
+ * `--behind-proxy` without `--base-url` is refused at start (#165).
118
+ */
119
+ export function assertProxyHasBaseUrl(server ) {
120
+ if (!server.behindProxy || server.baseUrl !== undefined) return;
121
+ throw new Error(
122
+ "--behind-proxy (CLOUDHAL_BEHIND_PROXY) needs --base-url: set CLOUDHAL_BASE_URL to the public origin browsers open Studio at, e.g. https://studio.example.com",
123
+ );
124
+ }
125
+
126
+ /** One line for a Studio reachable beyond this machine without a public origin (#165). */
127
+ export function noBaseUrlWarning(server ) {
128
+ if (server.baseUrl !== undefined || isLoopbackHost(server.hostname)) return undefined;
129
+ return `--host ${server.hostname} without --base-url: sign-in accepts the origin of each request; set --base-url (CLOUDHAL_BASE_URL) to the origin browsers open Studio at, e.g. http://<this machine's address>:${server.port}`;
130
+ }
@@ -2,9 +2,13 @@ type Env = Readonly<Record<string, string | undefined>>;
2
2
  /** The flags `cloudhal studio` takes for where and how it is served. */
3
3
  export interface StudioServerFlags {
4
4
  readonly port?: number;
5
- /** `--host`: the address to listen on (default `127.0.0.1`; `0.0.0.0` for every interface). */
5
+ /** `--host`: the address to listen on (default `127.0.0.1`; `0.0.0.0` for every IPv4 address). */
6
6
  readonly host?: string;
7
- /** `--base-url`: the public origin (scheme, host, port), e.g. `https://studio.example.com`. */
7
+ /**
8
+ * `--base-url`: the origin browsers open Studio at (scheme, host, port), e.g.
9
+ * `https://studio.example.com`; required behind a reverse proxy, recommended whenever `--host`
10
+ * is not loopback. Without it sign-in accepts each request's own origin (#165).
11
+ */
8
12
  readonly baseUrl?: string;
9
13
  /** `--behind-proxy`: trust `X-Forwarded-Proto` / `X-Forwarded-Host`. */
10
14
  readonly behindProxy?: boolean;
@@ -31,11 +35,16 @@ export declare function studioUrl(server: StudioServer, port: number): string;
31
35
  * Better Auth's `baseURL` (the origin browsers use; its cookies are `Secure` for https) and the
32
36
  * origins the API accepts state-changing requests from: the Studio dev server, the public origin
33
37
  * (so a proxy that keeps the request on http still passes the API's CSRF check), and
34
- * `CLOUDHAL_TRUSTED_ORIGINS`.
38
+ * `CLOUDHAL_TRUSTED_ORIGINS`. Without a public origin (#165) Better Auth also trusts the origin
39
+ * each request was made to, as the API's CSRF check does: any (`"any"`, a server listening beyond
40
+ * loopback, reached at `http://<lan-ip>:8787`), or on a loopback server only this machine's names
41
+ * (`"loopback"`: `localhost`, `127.0.0.1`, `[::1]`, so a rebound DNS name is not). With a public
42
+ * origin (`false`) only it and the list may sign in.
35
43
  */
36
44
  export declare function studioAuthOrigins(server: StudioServer, env?: Env): {
37
45
  baseURL: string;
38
46
  trustedOrigins: string[];
47
+ trustRequestOrigin: "any" | "loopback" | false;
39
48
  };
40
49
  /** `--init-if-empty` and its `--starter` / `--name`; from the environment, `CLOUDHAL_INIT=<starter>`. */
41
50
  export interface StudioInitFlags {
@@ -48,11 +57,18 @@ export declare function resolveStudioInit(flags: StudioInitFlags, env?: Env): {
48
57
  starter: string;
49
58
  name: string | undefined;
50
59
  } | undefined;
60
+ /** The folder inside the project where `--init-if-empty` stages the scaffold before moving it up. */
61
+ export declare const INIT_STAGING_DIR = ".cloudhal-init";
51
62
  /**
52
63
  * Creates the project the way `cloudhal init` does when the folder has no `cloudhal.json` (a
53
- * container starting on an empty volume). A folder that has other files but no config is left
54
- * alone: `init` refuses it, so a volume mounted at the wrong path is never written over.
55
- * Returns whether a project was created.
64
+ * container starting on an empty volume). A folder that has other files but no config is refused,
65
+ * as `init` refuses it, so a volume mounted at the wrong path is never written over. The scaffold
66
+ * is staged in `.cloudhal-init` inside the folder and moved up entry by entry, `cloudhal.json`
67
+ * last, so a container stopped at any point starts again cleanly: a staging folder without a
68
+ * complete config (missing, cut off, no `siteId`) is redone, one with a complete config is moved
69
+ * the rest of the way (#165; before, a stop mid-scaffold crash-looped on "is not empty"). A fresh
70
+ * ext4 volume's `lost+found` does not make the folder non-empty. Returns whether a project was
71
+ * created.
56
72
  */
57
73
  export declare function initIfEmpty(projectDir: string, options: {
58
74
  starter: string;
@@ -5,19 +5,24 @@
5
5
  * Flags win over the environment: `CLOUDHAL_HOST`, `CLOUDHAL_BASE_URL`, `CLOUDHAL_BEHIND_PROXY`,
6
6
  * `CLOUDHAL_INIT` (a starter name), `CLOUDHAL_SITE_NAME`.
7
7
  */
8
- import { access } from "node:fs/promises";
8
+ import { access, mkdir, readdir, readFile, rename, rm } from "node:fs/promises";
9
9
  import path from "node:path";
10
10
  import { CONFIG_FILE } from "../config.js";
11
11
  import { init } from "./init.js";
12
+ import { isLoopbackHost } from "./studio-auth.js";
12
13
 
13
14
 
14
15
 
15
16
  /** The flags `cloudhal studio` takes for where and how it is served. */
16
17
 
17
18
 
18
-
19
+
19
20
 
21
+
22
+
20
23
 
24
+
25
+
21
26
 
22
27
 
23
28
 
@@ -96,12 +101,16 @@ export function studioUrl(server , port ) {
96
101
  * Better Auth's `baseURL` (the origin browsers use; its cookies are `Secure` for https) and the
97
102
  * origins the API accepts state-changing requests from: the Studio dev server, the public origin
98
103
  * (so a proxy that keeps the request on http still passes the API's CSRF check), and
99
- * `CLOUDHAL_TRUSTED_ORIGINS`.
104
+ * `CLOUDHAL_TRUSTED_ORIGINS`. Without a public origin (#165) Better Auth also trusts the origin
105
+ * each request was made to, as the API's CSRF check does: any (`"any"`, a server listening beyond
106
+ * loopback, reached at `http://<lan-ip>:8787`), or on a loopback server only this machine's names
107
+ * (`"loopback"`: `localhost`, `127.0.0.1`, `[::1]`, so a rebound DNS name is not). With a public
108
+ * origin (`false`) only it and the list may sign in.
100
109
  */
101
110
  export function studioAuthOrigins(
102
111
  server ,
103
112
  env = process.env,
104
- ) {
113
+ ) {
105
114
  const baseURL = server.baseUrl ?? `http://localhost:${server.port}`;
106
115
  const trustedOrigins = [
107
116
  // The Studio dev server (vite, :5173) proxies /api here during Studio development.
@@ -112,6 +121,8 @@ export function studioAuthOrigins(
112
121
  return {
113
122
  baseURL,
114
123
  trustedOrigins: [...new Set(trustedOrigins.map((o) => o.trim()))].filter(Boolean),
124
+ trustRequestOrigin:
125
+ server.baseUrl !== undefined ? false : isLoopbackHost(server.hostname) ? "loopback" : "any",
115
126
  };
116
127
  }
117
128
 
@@ -135,27 +146,78 @@ export function resolveStudioInit(
135
146
  };
136
147
  }
137
148
 
149
+ async function exists(p ) {
150
+ try {
151
+ await access(p);
152
+ return true;
153
+ } catch {
154
+ return false;
155
+ }
156
+ }
157
+
158
+ /** The folder inside the project where `--init-if-empty` stages the scaffold before moving it up. */
159
+ export const INIT_STAGING_DIR = ".cloudhal-init";
160
+
138
161
  /**
139
162
  * Creates the project the way `cloudhal init` does when the folder has no `cloudhal.json` (a
140
- * container starting on an empty volume). A folder that has other files but no config is left
141
- * alone: `init` refuses it, so a volume mounted at the wrong path is never written over.
142
- * Returns whether a project was created.
163
+ * container starting on an empty volume). A folder that has other files but no config is refused,
164
+ * as `init` refuses it, so a volume mounted at the wrong path is never written over. The scaffold
165
+ * is staged in `.cloudhal-init` inside the folder and moved up entry by entry, `cloudhal.json`
166
+ * last, so a container stopped at any point starts again cleanly: a staging folder without a
167
+ * complete config (missing, cut off, no `siteId`) is redone, one with a complete config is moved
168
+ * the rest of the way (#165; before, a stop mid-scaffold crash-looped on "is not empty"). A fresh
169
+ * ext4 volume's `lost+found` does not make the folder non-empty. Returns whether a project was
170
+ * created.
143
171
  */
144
172
  export async function initIfEmpty(
145
173
  projectDir ,
146
174
  options ,
147
175
  ) {
176
+ if (await exists(path.join(projectDir, CONFIG_FILE))) return false;
177
+ await mkdir(projectDir, { recursive: true });
178
+ const staging = path.join(projectDir, INIT_STAGING_DIR);
179
+ const staged = await completeConfig(path.join(staging, CONFIG_FILE));
180
+ const others = (await readdir(projectDir)).filter(
181
+ (entry) => entry !== INIT_STAGING_DIR && entry !== LOST_AND_FOUND,
182
+ );
183
+ if (others.length > 0 && !staged) throw new Error(`${projectDir} is not empty`);
184
+ if (!staged) {
185
+ // whatever an earlier start left unfinished, then a fresh scaffold
186
+ await rm(staging, { recursive: true, force: true });
187
+ await init({
188
+ dir: staging,
189
+ finalDir: projectDir,
190
+ starter: options.starter,
191
+ name: options.name ?? path.basename(path.resolve(projectDir)),
192
+ ...(options.log ? { log: options.log } : {}),
193
+ });
194
+ }
195
+ for (const entry of (await readdir(staging)).filter((entry) => entry !== CONFIG_FILE))
196
+ await moveUp(staging, projectDir, entry);
197
+ await moveUp(staging, projectDir, CONFIG_FILE);
198
+ await rm(staging, { recursive: true, force: true });
199
+ return true;
200
+ }
201
+
202
+ /** What `mkfs.ext4` leaves at the root of a new file system (a Docker volume on a fresh disk). */
203
+ const LOST_AND_FOUND = "lost+found";
204
+
205
+ /**
206
+ * Whether a staged `cloudhal.json` is the finished one `init` writes last: it parses and names a
207
+ * site. A file cut off by a stop while it was written (or empty) means the scaffold is redone.
208
+ */
209
+ async function completeConfig(file ) {
148
210
  try {
149
- await access(path.join(projectDir, CONFIG_FILE));
150
- return false;
211
+ const cfg = JSON.parse(await readFile(file, "utf8")) ;
212
+ return typeof cfg.siteId === "string" && cfg.siteId.length > 0;
151
213
  } catch {
152
- // no project yet
214
+ return false;
153
215
  }
154
- await init({
155
- dir: projectDir,
156
- starter: options.starter,
157
- ...(options.name ? { name: options.name } : {}),
158
- ...(options.log ? { log: options.log } : {}),
159
- });
160
- return true;
216
+ }
217
+
218
+ /** One staged entry into the project; one that an earlier start already moved stays as it is. */
219
+ async function moveUp(staging , projectDir , entry ) {
220
+ const target = path.join(projectDir, entry);
221
+ if (await exists(target)) await rm(path.join(staging, entry), { recursive: true, force: true });
222
+ else await rename(path.join(staging, entry), target);
161
223
  }
@@ -1,4 +1,5 @@
1
1
  import { restTransport } from "@cloudhal/api";
2
+ import { type StudioSetup } from "./studio-auth.js";
2
3
  import { type StudioInitFlags, type StudioServerFlags } from "./studio-options.js";
3
4
  export interface StudioOptions extends StudioServerFlags, StudioInitFlags {
4
5
  readonly projectDir: string;
@@ -6,7 +7,7 @@ export interface StudioOptions extends StudioServerFlags, StudioInitFlags {
6
7
  readonly log?: (line: string) => void;
7
8
  /** Directory of a built Studio (`apps/studio/dist`). Defaults to the monorepo build when present. */
8
9
  readonly studioDist?: string;
9
- /** Skip authentication (local scripts only). */
10
+ /** Skip authentication (local scripts only: a loopback `host` and no `behindProxy`, #165). */
10
11
  readonly noAuth?: boolean;
11
12
  /** Where printed mail goes (tests); default stdout (RFC-0011). */
12
13
  readonly mailOut?: (text: string) => void;
@@ -14,6 +15,20 @@ export interface StudioOptions extends StudioServerFlags, StudioInitFlags {
14
15
  readonly scheduler?: boolean;
15
16
  /** @deprecated the comments job runs on the scheduler's tick; `false` skips the ticker. */
16
17
  readonly commentsJob?: boolean;
18
+ /** The environment `CLOUDHAL_*` is read from (tests); default `process.env`. */
19
+ readonly env?: Readonly<Record<string, string | undefined>>;
20
+ /** Tests: run Better Auth's Origin check under `NODE_ENV=test` too (`AuthOptions.originCheck`). */
21
+ readonly authOriginCheck?: "always";
22
+ }
23
+ /** A running `cloudhal studio`. */
24
+ export interface StudioHandle {
25
+ readonly url: string;
26
+ readonly port: number;
27
+ /** While nobody has an account: the one-time link that creates the owner (RFC-0005 §7, #165). */
28
+ readonly setup?: StudioSetup;
29
+ /** For the operator: a Studio reachable beyond this machine without `--base-url` (#165). */
30
+ readonly warnings: readonly string[];
31
+ stop(): Promise<void>;
17
32
  }
18
33
  /** Paths the API owns; never answered with the Studio SPA. */
19
34
  export declare function isApiPath(pathname: string): boolean;
@@ -21,11 +36,7 @@ export declare function isApiPath(pathname: string): boolean;
21
36
  * Runs the Cloudhal API (and, when built, the Studio UI) for the project on Node.
22
37
  * Authentication is wired by `createAuthFor()` from `@cloudhal/api/auth` when available.
23
38
  */
24
- export declare function studio(options: StudioOptions): Promise<{
25
- url: string;
26
- port: number;
27
- stop(): Promise<void>;
28
- }>;
39
+ export declare function studio(options: StudioOptions): Promise<StudioHandle>;
29
40
  /** Workers AI over REST from `CLOUDFLARE_ACCOUNT_ID` and `CLOUDHAL_AI_TOKEN` (RFC-0016 §1). */
30
41
  export declare function localAiTransport(env?: Record<string, string | undefined>): {
31
42
  transport?: ReturnType<typeof restTransport>;