@xano/sdk 1.0.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 (336) hide show
  1. package/CHANGELOG.md +788 -0
  2. package/LICENSE +21 -0
  3. package/README.md +541 -0
  4. package/dist/.build-fingerprint +1 -0
  5. package/dist/agent-file-refresh-ZEMK33AX.js +38 -0
  6. package/dist/answer-shape-K67TAAPY.js +33 -0
  7. package/dist/backend-dir-2U53CIAL.js +39 -0
  8. package/dist/backend-slot-7QXW2QYC.js +28 -0
  9. package/dist/bin.d.ts +1 -0
  10. package/dist/bin.js +255 -0
  11. package/dist/branch-NCRNWQBQ.js +61 -0
  12. package/dist/branch-commands-ACIRCEQJ.js +79 -0
  13. package/dist/bundle.d.ts +223 -0
  14. package/dist/bundle.js +153 -0
  15. package/dist/capture-WAXPD7DR.js +41 -0
  16. package/dist/chunk-27GWNP2I.js +23 -0
  17. package/dist/chunk-2CMJZDCL.js +177 -0
  18. package/dist/chunk-2EZ3ZJZZ.js +302 -0
  19. package/dist/chunk-2GNFDZA2.js +390 -0
  20. package/dist/chunk-2MNLRIOX.js +11 -0
  21. package/dist/chunk-2TFRR6JV.js +104 -0
  22. package/dist/chunk-2ZUEE4EK.js +408 -0
  23. package/dist/chunk-36JUQZVQ.js +22 -0
  24. package/dist/chunk-3DRXWLJ5.js +83 -0
  25. package/dist/chunk-3JDU4VRL.js +137 -0
  26. package/dist/chunk-3KZCLN4Z.js +241 -0
  27. package/dist/chunk-3LDULPRE.js +168 -0
  28. package/dist/chunk-3M4LFYNQ.js +111 -0
  29. package/dist/chunk-3XI5CTUE.js +22 -0
  30. package/dist/chunk-3YW23UFH.js +50 -0
  31. package/dist/chunk-45UIT5T2.js +862 -0
  32. package/dist/chunk-4BW2SG2N.js +46 -0
  33. package/dist/chunk-4KHEMC32.js +79 -0
  34. package/dist/chunk-4POWHT2K.js +321 -0
  35. package/dist/chunk-4Q2GN7NW.js +192 -0
  36. package/dist/chunk-5A2PLKZB.js +70 -0
  37. package/dist/chunk-5FBYXK5P.js +159 -0
  38. package/dist/chunk-5HVXPTU4.js +323 -0
  39. package/dist/chunk-5QU2P5CA.js +304 -0
  40. package/dist/chunk-5V5XU32D.js +191 -0
  41. package/dist/chunk-5ZSO4T2G.js +10 -0
  42. package/dist/chunk-622HUCZT.js +10 -0
  43. package/dist/chunk-65HWOMGV.js +177 -0
  44. package/dist/chunk-6ELFRN3P.js +365 -0
  45. package/dist/chunk-6HO3NCSJ.js +1055 -0
  46. package/dist/chunk-6IUMKYWI.js +457 -0
  47. package/dist/chunk-6KEB3C3U.js +65 -0
  48. package/dist/chunk-6MR5TI5V.js +987 -0
  49. package/dist/chunk-6NNTNXN7.js +157 -0
  50. package/dist/chunk-6PBR37LN.js +97 -0
  51. package/dist/chunk-6QXLMMT3.js +155 -0
  52. package/dist/chunk-6ZGJCBZS.js +224 -0
  53. package/dist/chunk-73IVBKMA.js +250 -0
  54. package/dist/chunk-7G3CTU7I.js +286 -0
  55. package/dist/chunk-A3UDOZB6.js +222 -0
  56. package/dist/chunk-A6E77GDW.js +85 -0
  57. package/dist/chunk-AHJWCYQO.js +660 -0
  58. package/dist/chunk-AKNCFVKZ.js +36 -0
  59. package/dist/chunk-AM4FKL4J.js +237 -0
  60. package/dist/chunk-AN6BL47T.js +26 -0
  61. package/dist/chunk-AOSYVMUS.js +147 -0
  62. package/dist/chunk-APWXY5SL.js +182 -0
  63. package/dist/chunk-AWEIIR2U.js +218 -0
  64. package/dist/chunk-AWQ7BQTQ.js +73 -0
  65. package/dist/chunk-BAUZOWGX.js +393 -0
  66. package/dist/chunk-BHACRS6R.js +940 -0
  67. package/dist/chunk-BWPNT55T.js +680 -0
  68. package/dist/chunk-C6RIMRU4.js +187 -0
  69. package/dist/chunk-CGVQZXYG.js +263 -0
  70. package/dist/chunk-CIMQZRRE.js +162 -0
  71. package/dist/chunk-CJHQKJU4.js +113 -0
  72. package/dist/chunk-CTMO46PK.js +1897 -0
  73. package/dist/chunk-D53J55C5.js +106 -0
  74. package/dist/chunk-D7VGG3WS.js +90 -0
  75. package/dist/chunk-DAD3ONIS.js +245 -0
  76. package/dist/chunk-DGWHAVRG.js +162 -0
  77. package/dist/chunk-DX4QR4B2.js +483 -0
  78. package/dist/chunk-EHP3WPEG.js +21 -0
  79. package/dist/chunk-ELP2HMXC.js +432 -0
  80. package/dist/chunk-ERVIASGL.js +21 -0
  81. package/dist/chunk-ET4Y4XCB.js +865 -0
  82. package/dist/chunk-ETO6LGLD.js +4750 -0
  83. package/dist/chunk-EUUUMY7J.js +24 -0
  84. package/dist/chunk-FQJ2TTHP.js +218 -0
  85. package/dist/chunk-FQOF7E2E.js +133 -0
  86. package/dist/chunk-FWD7AL6N.js +21 -0
  87. package/dist/chunk-FXFV3KU6.js +138 -0
  88. package/dist/chunk-FXRQOWTE.js +171 -0
  89. package/dist/chunk-G554NZNI.js +210 -0
  90. package/dist/chunk-GSGDWJB5.js +13 -0
  91. package/dist/chunk-H2V3N23D.js +66 -0
  92. package/dist/chunk-H5C7MBCR.js +159 -0
  93. package/dist/chunk-HHN734BU.js +371 -0
  94. package/dist/chunk-HRVBLCVJ.js +243 -0
  95. package/dist/chunk-HVRUQXGD.js +1264 -0
  96. package/dist/chunk-I4F5TCJH.js +130 -0
  97. package/dist/chunk-IDOTCMDV.js +57 -0
  98. package/dist/chunk-IGOLHKWF.js +427 -0
  99. package/dist/chunk-JGE7CAWB.js +148 -0
  100. package/dist/chunk-JTUKLCXS.js +92 -0
  101. package/dist/chunk-JZGVVJSI.js +66 -0
  102. package/dist/chunk-K4WX6UUU.js +923 -0
  103. package/dist/chunk-K5BBGTYZ.js +217 -0
  104. package/dist/chunk-K6RXBGUB.js +427 -0
  105. package/dist/chunk-KTSDSD36.js +165 -0
  106. package/dist/chunk-L5JYN3NM.js +1038 -0
  107. package/dist/chunk-LIEOKXKD.js +354 -0
  108. package/dist/chunk-LLNZGEFK.js +51 -0
  109. package/dist/chunk-LPECSJ2J.js +55 -0
  110. package/dist/chunk-LQCMKAJ7.js +413 -0
  111. package/dist/chunk-LRN4ZJCQ.js +1145 -0
  112. package/dist/chunk-MJ4ZVHKN.js +17 -0
  113. package/dist/chunk-MXHSQOC4.js +3061 -0
  114. package/dist/chunk-N5GKCWE5.js +367 -0
  115. package/dist/chunk-NA3PXMEF.js +10 -0
  116. package/dist/chunk-NAQDMEHV.js +76 -0
  117. package/dist/chunk-NWKXM5RD.js +109 -0
  118. package/dist/chunk-NZOWWHU5.js +196 -0
  119. package/dist/chunk-OHX6MIUZ.js +184 -0
  120. package/dist/chunk-OOXWYAA4.js +15 -0
  121. package/dist/chunk-OPHB5ORL.js +1990 -0
  122. package/dist/chunk-OXA6PSZT.js +1725 -0
  123. package/dist/chunk-P2HAGF6H.js +73 -0
  124. package/dist/chunk-PTHVMXZI.js +3036 -0
  125. package/dist/chunk-PZ5AY32C.js +10 -0
  126. package/dist/chunk-Q325JKYB.js +189 -0
  127. package/dist/chunk-Q7DGTQ5G.js +255 -0
  128. package/dist/chunk-QCNYHBL7.js +601 -0
  129. package/dist/chunk-QO6BVGS5.js +145 -0
  130. package/dist/chunk-QXTKSOFI.js +76 -0
  131. package/dist/chunk-ROY4YAEQ.js +66 -0
  132. package/dist/chunk-RTJRZFFY.js +447 -0
  133. package/dist/chunk-SAVJUS2X.js +128 -0
  134. package/dist/chunk-SFLHVCKX.js +173 -0
  135. package/dist/chunk-STSFNCY4.js +127 -0
  136. package/dist/chunk-SWBF2LTK.js +170 -0
  137. package/dist/chunk-T5KELPAR.js +109 -0
  138. package/dist/chunk-TFFGOFVZ.js +1481 -0
  139. package/dist/chunk-TLHIFK4M.js +256 -0
  140. package/dist/chunk-TLQE7ZN3.js +156 -0
  141. package/dist/chunk-TPHWJ7UG.js +1981 -0
  142. package/dist/chunk-TRJCALW3.js +291 -0
  143. package/dist/chunk-TTEIYD5P.js +133 -0
  144. package/dist/chunk-U64O2MXY.js +407 -0
  145. package/dist/chunk-UCQ2VUTG.js +630 -0
  146. package/dist/chunk-UTI5G6OJ.js +44 -0
  147. package/dist/chunk-UVHDMMIP.js +188 -0
  148. package/dist/chunk-UZ6QQWJT.js +120 -0
  149. package/dist/chunk-VAX3UZOY.js +686 -0
  150. package/dist/chunk-W3HBUKFO.js +57 -0
  151. package/dist/chunk-WKQLGKCL.js +2823 -0
  152. package/dist/chunk-WQFNASK4.js +560 -0
  153. package/dist/chunk-WRBKLYSJ.js +224 -0
  154. package/dist/chunk-WTPZRR4I.js +17 -0
  155. package/dist/chunk-WZDJ2LLX.js +2385 -0
  156. package/dist/chunk-X2NL4KUO.js +14 -0
  157. package/dist/chunk-X4DVXBFY.js +38 -0
  158. package/dist/chunk-X677DMZM.js +7050 -0
  159. package/dist/chunk-XBKMWY7F.js +612 -0
  160. package/dist/chunk-XNCP4KYO.js +78 -0
  161. package/dist/chunk-XVBGLISP.js +35 -0
  162. package/dist/chunk-XW6KISBB.js +1192 -0
  163. package/dist/chunk-YGZHHAAB.js +8156 -0
  164. package/dist/chunk-YHEFQUQB.js +186 -0
  165. package/dist/chunk-YLDALTWZ.js +653 -0
  166. package/dist/chunk-YU4HSQW7.js +229 -0
  167. package/dist/chunk-ZDPP6RKB.js +27 -0
  168. package/dist/chunk-ZFDZKNGG.js +194 -0
  169. package/dist/chunk-ZIY7RNUT.js +49 -0
  170. package/dist/chunk-ZYJP6BOO.js +30 -0
  171. package/dist/cli.d.ts +1111 -0
  172. package/dist/cli.js +165 -0
  173. package/dist/codegen-command-VR2GWR6C.js +173 -0
  174. package/dist/codegen.d.ts +115 -0
  175. package/dist/codegen.js +19 -0
  176. package/dist/commands-GJMJ4XYZ.js +76 -0
  177. package/dist/completion-ZQLO6PB6.js +738 -0
  178. package/dist/config-MBYGCAFK.js +136 -0
  179. package/dist/deploy-command-JVZPWHMK.js +180 -0
  180. package/dist/deploy-source-3W45CXMP.js +81 -0
  181. package/dist/dev-env-sync-HN44K4D5.js +188 -0
  182. package/dist/diagnostics-UEAAHWVF.js +30 -0
  183. package/dist/display-name-hint-ABBPVQIR.js +46 -0
  184. package/dist/emit-CyhBDxli.d.ts +7007 -0
  185. package/dist/env-example-refresh-ET5HMMDW.js +126 -0
  186. package/dist/env-pull-command-TNMNB3CV.js +323 -0
  187. package/dist/env-target-O4HRKTGZ.js +40 -0
  188. package/dist/env-var-command-ZIRDCAZA.js +427 -0
  189. package/dist/ephemeral-P7F3PMAD.js +54 -0
  190. package/dist/ephemeral-command-CLJJKOFT.js +592 -0
  191. package/dist/ephemeral-state-PYCBSOGX.js +61 -0
  192. package/dist/file-lock-PT74GWYW.js +10 -0
  193. package/dist/generate-command-AYEOLA26.js +510 -0
  194. package/dist/gitignore-3SJ3WNRG.js +51 -0
  195. package/dist/guards-4EBNCZDC.js +162 -0
  196. package/dist/hosted-file-PSHJB3HX.js +28 -0
  197. package/dist/impersonate-command-5JAS3WSV.js +152 -0
  198. package/dist/import-EQSFU6JC.js +19 -0
  199. package/dist/index.d.ts +5470 -0
  200. package/dist/index.js +371 -0
  201. package/dist/init-command-X2FR4UAK.js +125 -0
  202. package/dist/init-modules-RY7UHAOL.js +50 -0
  203. package/dist/init-web-M4YZSZK6.js +42 -0
  204. package/dist/internal.d.ts +179 -0
  205. package/dist/internal.js +2634 -0
  206. package/dist/io-RC56QSN5.js +26 -0
  207. package/dist/keep-data-merge-7MPLVAVI.js +1119 -0
  208. package/dist/lambda-config-reconcile-OUZ4OYAB.js +116 -0
  209. package/dist/landed-753YLJ5H.js +40 -0
  210. package/dist/landing-record-SU52SKXU.js +61 -0
  211. package/dist/live-diff-YONW2VI3.js +65 -0
  212. package/dist/local-engine-choice-CH5X3W7E.js +79 -0
  213. package/dist/local-engine-command-Z3OL7VOD.js +766 -0
  214. package/dist/local-engine-config-5U3SC434.js +39 -0
  215. package/dist/local-engine-deploy-PCQ4SNPB.js +39 -0
  216. package/dist/local-engine-process-EHTE5LLU.js +63 -0
  217. package/dist/local-engine-state-A4FTRFAF.js +32 -0
  218. package/dist/local-engine-update-check-6L645VBL.js +162 -0
  219. package/dist/lock-MRRHW5GS.js +87 -0
  220. package/dist/lock-commands-2QG25HL7.js +963 -0
  221. package/dist/login-command-QPYRWOXZ.js +538 -0
  222. package/dist/logout-command-WOIQLDP6.js +56 -0
  223. package/dist/loop-ALIZLOSX.js +191 -0
  224. package/dist/marketplace-command-K5YL42NO.js +977 -0
  225. package/dist/marketplace-resolve-LY32JES5.js +40 -0
  226. package/dist/meta-client-YXGPW53C.js +244 -0
  227. package/dist/module-manifest-JFGHU2TC.js +38 -0
  228. package/dist/near-key.d.ts +13 -0
  229. package/dist/near-key.js +8 -0
  230. package/dist/node.d.ts +95 -0
  231. package/dist/node.js +969 -0
  232. package/dist/operation-outcome-TZSESNC7.js +51 -0
  233. package/dist/output-target-AL3I44GG.js +47 -0
  234. package/dist/package-manager-PRAHUSCN.js +34 -0
  235. package/dist/plan-disclosure-6G4MLZKD.js +114 -0
  236. package/dist/plugin-contributions-WRNY5ABG.js +28 -0
  237. package/dist/plugin-prompt-4VA3B4FF.js +20 -0
  238. package/dist/plugin-questions-JTSYA74Q.js +24 -0
  239. package/dist/plugin.d.ts +396 -0
  240. package/dist/plugin.js +1 -0
  241. package/dist/preflight-command-2T5Z36MI.js +321 -0
  242. package/dist/profile-command-AH3PIM4X.js +800 -0
  243. package/dist/profile-pointer-GRWJU3YD.js +31 -0
  244. package/dist/profile-select-74TRDEPD.js +23 -0
  245. package/dist/project-dependency-KSH63ODT.js +35 -0
  246. package/dist/project-sdk-REPPOIBD.js +24 -0
  247. package/dist/promote-command-PCWT5N6S.js +140 -0
  248. package/dist/prompt-II3F3LND.js +27 -0
  249. package/dist/publish-command-TTDUUJI5.js +414 -0
  250. package/dist/pull-command-VBO7C4S3.js +161 -0
  251. package/dist/pull-superseded-GJWLG7XO.js +20 -0
  252. package/dist/release-command-N4ZPKMHR.js +146 -0
  253. package/dist/release-ns-command-3KFDMZ6G.js +1745 -0
  254. package/dist/response-HlXahv4K.d.ts +925 -0
  255. package/dist/retry-command-AS5EVREX.js +34 -0
  256. package/dist/routes-manifest-SNWUVBT6.js +43 -0
  257. package/dist/runtime-XETHVF33.js +14 -0
  258. package/dist/scaffold.d.ts +1911 -0
  259. package/dist/scaffold.js +107 -0
  260. package/dist/secrets-file-LVZD6IIM.js +56 -0
  261. package/dist/secrets-fill-command-TTCPSVXN.js +218 -0
  262. package/dist/seed-VU7C3QYS.js +46 -0
  263. package/dist/sent-writes-N7X4OVXT.js +22 -0
  264. package/dist/source-resolve-S2XA3XZF.js +83 -0
  265. package/dist/static-host-B2Y6AG3W.js +352 -0
  266. package/dist/status-command-RUDXTF7I.js +554 -0
  267. package/dist/store-6VNCD4D7.js +20 -0
  268. package/dist/store-ARM6VMO5.js +98 -0
  269. package/dist/store-DuYfzKlW.d.ts +3144 -0
  270. package/dist/suggest-6FOOYKHG.js +12 -0
  271. package/dist/sveltekit.d.ts +154 -0
  272. package/dist/sveltekit.js +109 -0
  273. package/dist/sync-contributions-UCEROO26.js +415 -0
  274. package/dist/table-ENAVMITR.js +42 -0
  275. package/dist/tables-command-GUPXXSB5.js +156 -0
  276. package/dist/tenant-IIHPOHGP.js +42 -0
  277. package/dist/tenant-command-D5HGI2X4.js +965 -0
  278. package/dist/test-command-TIKZMDPZ.js +476 -0
  279. package/dist/tests-BGGIOK3L.js +26 -0
  280. package/dist/token-NICJUTMT.js +72 -0
  281. package/dist/toolchain-hooks-GHKLUJOH.js +96 -0
  282. package/dist/toolchain-modules-5EAZUONB.js +24 -0
  283. package/dist/tracked-backend-EIBUMDZA.js +80 -0
  284. package/dist/update-check-2W2NLDTC.js +136 -0
  285. package/dist/upgrade-command-QHNFWM7O.js +531 -0
  286. package/dist/verify-rollout-DRCK5TDD.js +61 -0
  287. package/dist/whoami-command-STGINTXH.js +51 -0
  288. package/dist/workspace-2CLHU2LK.js +93 -0
  289. package/dist/workspace-binding-56PIIPCP.js +54 -0
  290. package/dist/workspace-command-JEXQETJD.js +535 -0
  291. package/dist/workspace-env-F2RFMSC5.js +70 -0
  292. package/dist/workspace-export-OJSH2HIW.js +21 -0
  293. package/dist/writable-VA7OISSK.js +25 -0
  294. package/dist/xano-ICFUSPFR.js +42 -0
  295. package/dist/xanosdk-import-GN42TO2B.js +56 -0
  296. package/dist/xanosdk-project-S6DXJONQ.js +41 -0
  297. package/dist/xdo-CxDr2Q1C.d.ts +1371 -0
  298. package/guides/README.md +33 -0
  299. package/guides/authoring.md +921 -0
  300. package/guides/cli.md +401 -0
  301. package/guides/codegen.md +177 -0
  302. package/guides/codes.md +404 -0
  303. package/guides/coverage.md +74 -0
  304. package/guides/deploying.md +1525 -0
  305. package/guides/environment.md +400 -0
  306. package/guides/marketplace.md +415 -0
  307. package/guides/module-contract.md +558 -0
  308. package/guides/object-kinds.md +433 -0
  309. package/guides/project-structure.md +43 -0
  310. package/guides/scaffold.md +351 -0
  311. package/guides/typed-frontend.md +242 -0
  312. package/llms/client.md +63 -0
  313. package/llms/errors.md +56 -0
  314. package/llms/fields.md +176 -0
  315. package/llms/filters.md +183 -0
  316. package/llms/kinds-agent-mcp.md +30 -0
  317. package/llms/kinds-core.md +100 -0
  318. package/llms/kinds-knowledge.md +20 -0
  319. package/llms/kinds-realtime.md +76 -0
  320. package/llms/lambda.md +94 -0
  321. package/llms/legacy.md +44 -0
  322. package/llms/lock.md +40 -0
  323. package/llms/object-kinds.md +34 -0
  324. package/llms/statements-calls.md +62 -0
  325. package/llms/statements-catalog.md +320 -0
  326. package/llms/statements-data.md +66 -0
  327. package/llms/statements-runtime.md +68 -0
  328. package/llms/tests.md +59 -0
  329. package/llms/toolchain.md +16 -0
  330. package/llms/triggers.md +36 -0
  331. package/llms/values.md +29 -0
  332. package/llms-full.txt +2085 -0
  333. package/llms.txt +493 -0
  334. package/manifest.json +11224 -0
  335. package/package.json +162 -0
  336. package/types/lambda-globals.d.ts +129 -0
@@ -0,0 +1,612 @@
1
+ import {
2
+ engineVersion,
3
+ engineVersionToken,
4
+ listEngines,
5
+ resolveRecordedEngine,
6
+ startEngine,
7
+ stopEngineNamed,
8
+ stopOrphanedEngineProcesses
9
+ } from "./chunk-BAUZOWGX.js";
10
+ import {
11
+ RELEASE_VERSION,
12
+ readEngineEntry,
13
+ stageEngine,
14
+ verifiedEngineExecutable
15
+ } from "./chunk-6ELFRN3P.js";
16
+ import {
17
+ sha256Hex
18
+ } from "./chunk-NA3PXMEF.js";
19
+ import {
20
+ normalizeEngineVersion,
21
+ resolveEngineRelease,
22
+ usesCustomReleaseManager
23
+ } from "./chunk-APWXY5SL.js";
24
+ import {
25
+ compareSemver,
26
+ parseSemver
27
+ } from "./chunk-2TFRR6JV.js";
28
+ import {
29
+ recordDeployed
30
+ } from "./chunk-LPECSJ2J.js";
31
+ import {
32
+ ImportHttpError
33
+ } from "./chunk-AN6BL47T.js";
34
+ import {
35
+ engineNameForProject,
36
+ getEngineRecord,
37
+ setEngineRecord
38
+ } from "./chunk-3M4LFYNQ.js";
39
+ import {
40
+ SUPPORTED_PLATFORMS,
41
+ assertLoopbackUrl,
42
+ expandArchivePath,
43
+ isTrustedEngineUrl,
44
+ resolveEnginePlatform
45
+ } from "./chunk-AM4FKL4J.js";
46
+ import {
47
+ registerSecret,
48
+ tokenTextProblem
49
+ } from "./chunk-AWQ7BQTQ.js";
50
+ import {
51
+ TransportError,
52
+ fetchOrExplain
53
+ } from "./chunk-YLDALTWZ.js";
54
+ import {
55
+ readEnvVar
56
+ } from "./chunk-X2NL4KUO.js";
57
+ import {
58
+ UsageError
59
+ } from "./chunk-PTHVMXZI.js";
60
+
61
+ // src/deploy/local-engine-release.ts
62
+ import { readFileSync } from "fs";
63
+ import { gunzipSync } from "zlib";
64
+ var LOCAL_ENGINE_TOKEN_ENV = "XANOSDK_LOCAL_ENGINE_TOKEN";
65
+ var MAX_ENGINE_BYTES = 256 * 1024 * 1024;
66
+ var DOWNLOAD_TIMEOUT_MS = 6e5;
67
+ var MAX_REDIRECTS = 5;
68
+ function displayDownloadUrl(url) {
69
+ try {
70
+ const u = new URL(url);
71
+ return `${u.origin}${u.pathname}${u.search !== "" ? "?\u2026" : ""}`;
72
+ } catch {
73
+ return "the engine download URL";
74
+ }
75
+ }
76
+ var defaultFetch = (url, init) => fetchOrExplain(url, init, "The local engine download", DOWNLOAD_TIMEOUT_MS, displayDownloadUrl(url));
77
+ function isRedirect(status) {
78
+ return status === 301 || status === 302 || status === 303 || status === 307 || status === 308;
79
+ }
80
+ async function fetchFollowingRedirects(url, opts) {
81
+ const origin = safeOrigin(url);
82
+ let current = url;
83
+ for (let hop = 0; hop <= MAX_REDIRECTS; hop++) {
84
+ const headers = { accept: "application/octet-stream" };
85
+ if (opts.token !== void 0 && safeOrigin(current) === origin) {
86
+ headers.Authorization = `Bearer ${opts.token}`;
87
+ }
88
+ const res = await opts.fetch(current, {
89
+ method: "GET",
90
+ headers,
91
+ // Manual, or `fetch` would follow the hop with the header still attached.
92
+ redirect: "manual",
93
+ signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
94
+ });
95
+ if (!isRedirect(res.status)) return res;
96
+ const location = res.headers.get("location");
97
+ if (location === null || location === "") return res;
98
+ current = new URL(location, current).href;
99
+ }
100
+ throw new Error(
101
+ `The engine download redirected more than ${MAX_REDIRECTS} times, so it was abandoned.
102
+ ` + (opts.release === void 0 ? `Check the URL passed to \`--local-engine\` addresses the artifact itself.` : `Re-run in a moment; if it keeps failing, engine ${opts.release}'s archive is unavailable \u2014 \`xanosdk local-engine update\` moves to another release.`)
103
+ );
104
+ }
105
+ function safeOrigin(url) {
106
+ try {
107
+ return new URL(url).origin;
108
+ } catch {
109
+ return url;
110
+ }
111
+ }
112
+ function releaseDownloadRefusal(status, version) {
113
+ return unresolvedOn5xx(
114
+ status,
115
+ new Error(
116
+ `The download of engine ${version} failed (HTTP ${status}), so nothing was written.
117
+ Re-run in a moment; if it keeps failing, that release's archive is unavailable \u2014 \`xanosdk local-engine update\` moves to another release.`
118
+ )
119
+ );
120
+ }
121
+ function unresolvedOn5xx(status, err) {
122
+ if (status >= 500) Object.defineProperty(err, "exitCode", { value: EXIT_ENGINE_UNREACHABLE, enumerable: true });
123
+ return err;
124
+ }
125
+ function downloadRefusal(status, hasToken) {
126
+ if (status === 404) {
127
+ return new Error(
128
+ `The engine download found nothing at that URL (HTTP 404 Not Found).
129
+ Check the URL passed to \`--local-engine\` addresses the artifact` + (hasToken ? ` and that ${LOCAL_ENGINE_TOKEN_ENV} can read it` : `; if it is a private release, which also answers 404 without a credential, set ${LOCAL_ENGINE_TOKEN_ENV} to one that can read it`) + `, then re-run.`
130
+ );
131
+ }
132
+ if (status === 401 || status === 403) {
133
+ return new Error(
134
+ `The engine download was refused (HTTP ${status}), which is what an engine release answers when the credential is missing or no longer authorized \u2014 not that the artifact is absent.
135
+ Set ${LOCAL_ENGINE_TOKEN_ENV} to a credential that can read the release and re-run.`
136
+ );
137
+ }
138
+ if (status >= 500) {
139
+ return unresolvedOn5xx(
140
+ status,
141
+ new Error(
142
+ `The engine download failed (HTTP ${status}) \u2014 the server hosting it erred, so nothing was written.
143
+ Re-run in a moment; if it keeps failing, check the URL passed to \`--local-engine\` is still served.`
144
+ )
145
+ );
146
+ }
147
+ return new Error(
148
+ `The engine download failed (HTTP ${status}).
149
+ Check the URL passed to \`--local-engine\` still addresses the artifact` + (hasToken ? ` and that ${LOCAL_ENGINE_TOKEN_ENV} can read it` : ``) + `, then re-run.`
150
+ );
151
+ }
152
+ function artifactName(url) {
153
+ try {
154
+ const last = new URL(url).pathname.split("/").pop();
155
+ return last === void 0 || last === "" ? void 0 : decodeURIComponent(last);
156
+ } catch {
157
+ return void 0;
158
+ }
159
+ }
160
+ function checksumCandidates(url) {
161
+ try {
162
+ const sidecar = new URL(url);
163
+ sidecar.pathname = `${sidecar.pathname}.sha256`;
164
+ const siblings = new URL(url);
165
+ const parts = siblings.pathname.split("/");
166
+ parts[parts.length - 1] = "SHA256SUMS";
167
+ siblings.pathname = parts.join("/");
168
+ return [sidecar.href, siblings.href];
169
+ } catch {
170
+ return [];
171
+ }
172
+ }
173
+ function parsePublishedChecksum(text, name) {
174
+ const rows = [...text.matchAll(/^([0-9a-f]{64})[ \t]+[*]?(\S+)[ \t]*$/gm)].map((m) => ({
175
+ digest: m[1],
176
+ file: m[2].replace(/^\.\//, "").split("/").pop()
177
+ }));
178
+ if (rows.length === 0) {
179
+ const bare = /^[ \t]*([0-9a-f]{64})[ \t]*$/m.exec(text);
180
+ return bare?.[1];
181
+ }
182
+ if (name === void 0) return void 0;
183
+ const matched = rows.filter((r) => r.file === name);
184
+ return matched.length === 1 ? matched[0].digest : void 0;
185
+ }
186
+ async function publishedChecksum(url, opts) {
187
+ const name = artifactName(url);
188
+ for (const candidate of checksumCandidates(url)) {
189
+ try {
190
+ const res = await fetchFollowingRedirects(candidate, opts);
191
+ if (!res.ok) continue;
192
+ const digest = parsePublishedChecksum(await res.text(), name);
193
+ if (digest !== void 0) return digest;
194
+ } catch {
195
+ }
196
+ }
197
+ return void 0;
198
+ }
199
+ function octal(buf) {
200
+ const text = new TextDecoder().decode(buf).replace(/\0.*$/s, "").trim();
201
+ const n = Number.parseInt(text, 8);
202
+ return Number.isFinite(n) ? n : 0;
203
+ }
204
+ function headerName(block) {
205
+ return new TextDecoder().decode(block.subarray(0, 100)).replace(/\0.*$/s, "");
206
+ }
207
+ function headerChecksumOk(block) {
208
+ const stored = octal(block.subarray(148, 156));
209
+ let sum = 0;
210
+ for (let i = 0; i < 512; i++) sum += i >= 148 && i < 156 ? 32 : block[i];
211
+ return sum === stored;
212
+ }
213
+ var badArchive = (why, release) => new Error(
214
+ `The engine archive ${why}.
215
+ It is not the artifact this expects, so nothing was written. ` + (release === void 0 ? `Check the URL or path passed to \`--local-engine\` addresses the engine archive itself \u2014 a partial download, a login page and a release listing all save as ordinary files.` : `Engine ${release}'s published archive is unusable; \`xanosdk local-engine update\` moves to another release.`)
216
+ );
217
+ function extractEngineExecutable(archive, opts = {}) {
218
+ const maxBytes = opts.maxBytes ?? MAX_ENGINE_BYTES;
219
+ const refuse = (why) => badArchive(why, opts.release);
220
+ let tar;
221
+ try {
222
+ tar = gunzipSync(archive, { maxOutputLength: maxBytes });
223
+ } catch (err) {
224
+ if (err.code === "ERR_BUFFER_TOO_LARGE") {
225
+ throw refuse(`decompresses to more than the ${maxBytes}-byte bound and is too large`);
226
+ }
227
+ throw refuse("is not a gzip archive");
228
+ }
229
+ const found = [];
230
+ for (let offset = 0; offset + 512 <= tar.length; ) {
231
+ const block = tar.subarray(offset, offset + 512);
232
+ if (block.every((b) => b === 0)) break;
233
+ if (!headerChecksumOk(block)) throw refuse("is not a tar archive");
234
+ const type = String.fromCharCode(block[156]);
235
+ if (type !== "0" && type !== "\0") {
236
+ throw refuse(`holds a ${type === "5" ? "directory" : "link"} where a regular file belongs`);
237
+ }
238
+ const mode = octal(block.subarray(100, 108));
239
+ if ((mode & 3584) !== 0) {
240
+ throw refuse("stores a setuid, setgid or sticky mode bit on its contents");
241
+ }
242
+ const name = headerName(block);
243
+ const prefix = new TextDecoder().decode(block.subarray(345, 500)).replace(/\0.*$/s, "");
244
+ if (name === "" || name.startsWith("/") || name.includes("/") || name.includes("\\") || prefix !== "") {
245
+ throw refuse(`holds a member whose name addresses a location ("${prefix}${name}")`);
246
+ }
247
+ const size = octal(block.subarray(124, 136));
248
+ const start = offset + 512;
249
+ if (start + size > tar.length) throw refuse("is truncated");
250
+ found.push(new Uint8Array(tar.subarray(start, start + size)));
251
+ if (found.length > 1) throw refuse("holds more than the one file it should");
252
+ offset = start + Math.ceil(size / 512) * 512;
253
+ }
254
+ const only = found[0];
255
+ if (only === void 0) throw refuse("holds no files, where it should hold one file");
256
+ return only;
257
+ }
258
+ function isDownloadUrl(source) {
259
+ return /^https?:\/\//i.test(source);
260
+ }
261
+ function resolveArchivePath(source, env) {
262
+ return expandArchivePath(source, env);
263
+ }
264
+ function readArchiveFile(path) {
265
+ try {
266
+ return new Uint8Array(readFileSync(path));
267
+ } catch {
268
+ throw new Error(
269
+ `There is no engine archive to read at ${path}.
270
+ Check the path \u2014 it is read exactly as passed to \`--local-engine\`, with \`~\` and relative paths resolved from where the command ran.`
271
+ );
272
+ }
273
+ }
274
+ async function acquireEngine(opts) {
275
+ try {
276
+ return await acquireEngineUnclassified(opts);
277
+ } catch (err) {
278
+ let transport = false;
279
+ for (let e = err; e instanceof Error && !transport; e = e.cause) transport = e instanceof TransportError;
280
+ if (transport) Object.defineProperty(err, "exitCode", { value: EXIT_ENGINE_UNREACHABLE, enumerable: true });
281
+ if (opts.rerun !== void 0 && err instanceof Error) {
282
+ const named = namingRerun(err.message, opts.rerun);
283
+ err.message = named !== err.message && opts.rerunNote !== void 0 ? `${named}${opts.rerunNote}` : named;
284
+ }
285
+ throw err;
286
+ }
287
+ }
288
+ function namingRerun(message, command) {
289
+ return message.replace(/\bRe-run in a moment/g, `Run \`${command}\` again in a moment`).replace(/(,? then| and) re-run\./g, `$1 run \`${command}\` again.`);
290
+ }
291
+ var EXIT_ENGINE_UNREACHABLE = 8;
292
+ async function acquireEngineUnclassified(opts) {
293
+ const env = opts.env ?? process.env;
294
+ const platform = resolveEnginePlatform(opts.platform ?? process.platform, opts.arch ?? process.arch);
295
+ if (platform === void 0) {
296
+ throw new Error(
297
+ `There is no local engine build for ${opts.platform ?? process.platform} ${opts.arch ?? process.arch} \u2014 it runs on ${SUPPORTED_PLATFORMS.join(", ")} and nothing else.
298
+ Deploy from one of those machines, or drop \`--local-engine\`: \`xanosdk deploy\` reaches an ephemeral from anywhere.`
299
+ );
300
+ }
301
+ if (opts.spec.kind === "release") {
302
+ return acquireRelease(opts.spec.version, platform, env, opts.fetch);
303
+ }
304
+ const entry = await acquireOverride(opts.spec.source, env, opts.fetch ?? defaultFetch);
305
+ return { entry, version: void 0 };
306
+ }
307
+ async function acquireRelease(requested, platform, env, fetch) {
308
+ const pinned = requested === void 0 || requested === "latest" ? void 0 : normalizeEngineVersion(requested);
309
+ const cacheByVersion = !usesCustomReleaseManager(env);
310
+ if (pinned !== void 0 && cacheByVersion) {
311
+ const hit = readEngineEntry({ version: pinned }, env);
312
+ if (hit !== void 0) {
313
+ verifiedEngineExecutable(hit, env);
314
+ return { entry: hit, version: pinned };
315
+ }
316
+ }
317
+ let asset;
318
+ try {
319
+ asset = await resolveEngineRelease({
320
+ ...pinned === void 0 ? {} : { version: pinned },
321
+ platform,
322
+ env,
323
+ ...fetch === void 0 ? {} : { fetch }
324
+ });
325
+ } catch (err) {
326
+ const message = err.message;
327
+ if (pinned === void 0 || message.includes(pinned)) throw err;
328
+ const wrapped = new Error(
329
+ `Engine ${pinned} is not cached on this machine, and getting it needs one download:
330
+ ${message}`,
331
+ { cause: err }
332
+ );
333
+ const exitCode = err.exitCode;
334
+ if (typeof exitCode === "number") Object.defineProperty(wrapped, "exitCode", { value: exitCode, enumerable: true });
335
+ throw wrapped;
336
+ }
337
+ const cached = cacheByVersion ? readEngineEntry({ version: asset.version }, env) : void 0;
338
+ if (cached !== void 0) {
339
+ verifiedEngineExecutable(cached, env);
340
+ return { entry: cached, version: asset.version };
341
+ }
342
+ const res = await fetchFollowingRedirects(asset.downloadUrl, {
343
+ token: void 0,
344
+ fetch: fetch ?? defaultFetch,
345
+ release: asset.version
346
+ });
347
+ if (!res.ok) throw releaseDownloadRefusal(res.status, asset.version);
348
+ const archive = new Uint8Array(await res.arrayBuffer());
349
+ const archiveDigest = sha256Hex(archive);
350
+ if (archiveDigest !== asset.sha256) {
351
+ throw new Error(
352
+ `The engine ${asset.version} archive's sha256 disagrees with the one its release recorded, so nothing was written.
353
+ Re-run to rule out a truncated download; if it disagrees again, the archive is not the one the release published and should not be run.`
354
+ );
355
+ }
356
+ const executable = extractEngineExecutable(archive, { release: asset.version });
357
+ const entry = stageEngine({
358
+ url: asset.downloadUrl,
359
+ ...cacheByVersion ? { version: asset.version } : {},
360
+ executable,
361
+ digest: sha256Hex(executable),
362
+ archiveDigest,
363
+ env
364
+ });
365
+ verifiedEngineExecutable(entry, env);
366
+ return { entry, version: asset.version };
367
+ }
368
+ async function acquireOverride(source, env, fetch) {
369
+ if (!isDownloadUrl(source)) {
370
+ const path = resolveArchivePath(source, env);
371
+ const archive2 = readArchiveFile(path);
372
+ const archiveDigest2 = sha256Hex(archive2);
373
+ const cached = readEngineEntry({ source: path }, env);
374
+ if (cached !== void 0 && cached.archiveDigest === archiveDigest2) {
375
+ verifiedEngineExecutable(cached, env);
376
+ return cached;
377
+ }
378
+ const executable2 = extractEngineExecutable(archive2);
379
+ const staged = stageEngine({
380
+ url: path,
381
+ executable: executable2,
382
+ digest: sha256Hex(executable2),
383
+ archiveDigest: archiveDigest2,
384
+ env
385
+ });
386
+ verifiedEngineExecutable(staged, env);
387
+ return staged;
388
+ }
389
+ const hit = readEngineEntry({ source }, env);
390
+ if (hit !== void 0) {
391
+ verifiedEngineExecutable(hit, env);
392
+ return hit;
393
+ }
394
+ const url = source;
395
+ if (!isTrustedEngineUrl(url)) {
396
+ throw new Error(
397
+ `The engine download URL is plain http on a host that is not this machine, so nothing was requested.
398
+ Serve the archive over https://, or over http:// from loopback.`
399
+ );
400
+ }
401
+ const rawToken = readEnvVar(LOCAL_ENGINE_TOKEN_ENV, env);
402
+ registerSecret(rawToken);
403
+ const token = rawToken?.trim();
404
+ const problem = token === void 0 ? void 0 : tokenTextProblem(token);
405
+ if (problem !== void 0) {
406
+ throw new UsageError(
407
+ `\`${LOCAL_ENGINE_TOKEN_ENV}\` in the environment ${problem}, which no request can carry, so nothing was requested. Set it to the token alone \u2014 one line, nothing else.`
408
+ );
409
+ }
410
+ const res = await fetchFollowingRedirects(url, { token, fetch });
411
+ if (!res.ok) throw downloadRefusal(res.status, token !== void 0);
412
+ const archive = new Uint8Array(await res.arrayBuffer());
413
+ const archiveDigest = sha256Hex(archive);
414
+ const published = await publishedChecksum(url, { token, fetch });
415
+ if (published !== void 0 && published !== archiveDigest) {
416
+ throw new Error(
417
+ `The engine archive's bytes disagree with the checksum published beside it, so nothing was written.
418
+ Re-run to rule out a truncated download; if it disagrees again, the artifact is not the one the release recorded and should not be run.`
419
+ );
420
+ }
421
+ const executable = extractEngineExecutable(archive);
422
+ const entry = stageEngine({
423
+ url,
424
+ executable,
425
+ digest: sha256Hex(executable),
426
+ archiveDigest,
427
+ env
428
+ });
429
+ verifiedEngineExecutable(entry, env);
430
+ return entry;
431
+ }
432
+
433
+ // src/deploy/local-engine-deploy.ts
434
+ async function ensureProjectEngine(opts) {
435
+ try {
436
+ return await ensureProjectEngineUnnoted(opts);
437
+ } catch (err) {
438
+ throw withDeployFallbackNote(err);
439
+ }
440
+ }
441
+ var DEPLOY_FALLBACK_NOTE = "Meanwhile `xanosdk deploy` still deploys to an ephemeral.";
442
+ function withDeployFallbackNote(err) {
443
+ if (!(err instanceof Error) || err.message.includes(DEPLOY_FALLBACK_NOTE)) return err;
444
+ err.message = `${err.message.trimEnd()}
445
+ ${DEPLOY_FALLBACK_NOTE}`;
446
+ return err;
447
+ }
448
+ async function ensureProjectEngineUnnoted(opts) {
449
+ const env = opts.env ?? process.env;
450
+ const acquired = await acquireEngine({
451
+ spec: opts.source,
452
+ env,
453
+ ...opts.rerun === void 0 ? {} : { rerun: opts.rerun },
454
+ ...opts.rerunNote === void 0 || opts.rerunNote === "" ? {} : { rerunNote: opts.rerunNote },
455
+ ...opts.fetch === void 0 ? {} : { fetch: opts.fetch }
456
+ });
457
+ const { entry, version } = acquired;
458
+ opts.onAcquired?.(acquired);
459
+ const shownVersion = version ?? overrideVersion(entry, env, opts.run);
460
+ const { record, name, live, replaced } = reconcileLive(opts.dir, entry, shownVersion, env, opts.run);
461
+ const sweep = opts.sweepOrphans ?? (opts.spawn === void 0 ? () => stopOrphanedEngineProcesses({ env }).stopped : void 0);
462
+ const sweptOrphans = live === void 0 && sweep !== void 0 ? sweep() : [];
463
+ const engine = live ?? await startEngine({
464
+ entry,
465
+ name,
466
+ env,
467
+ ...shownVersion === void 0 ? {} : { version: shownVersion },
468
+ ...opts.spawn === void 0 ? {} : { spawn: opts.spawn }
469
+ });
470
+ const reused = live !== void 0;
471
+ const hadRecord = record !== void 0;
472
+ const priorFilled = record?.filled;
473
+ const carry = opts.carryFilled?.({ reused, hadRecord, priorFilled, url: engine.url }) === true;
474
+ writeRecord(opts.dir, engine, entry, shownVersion, reused && carry ? priorFilled : void 0, env);
475
+ if (!reused) recordDeployed(opts.dir, "local-engine");
476
+ return {
477
+ engine,
478
+ reused,
479
+ previousUrl: record?.url,
480
+ entry,
481
+ version,
482
+ engineVersion: shownVersion,
483
+ ...replaced === void 0 ? {} : { replaced },
484
+ ...sweptOrphans.length === 0 ? {} : { sweptOrphans },
485
+ hadRecord,
486
+ priorFilled
487
+ };
488
+ }
489
+ async function restartMismatchedEngine(opts) {
490
+ const env = opts.env ?? process.env;
491
+ const { entry, version } = opts.acquired;
492
+ const shownVersion = version ?? overrideVersion(entry, env, opts.run);
493
+ const { record, name, replaced } = reconcileLive(opts.dir, entry, shownVersion, env, opts.run);
494
+ if (replaced === void 0) return void 0;
495
+ const engine = await startEngine({
496
+ entry,
497
+ name,
498
+ env,
499
+ ...shownVersion === void 0 ? {} : { version: shownVersion },
500
+ ...opts.spawn === void 0 ? {} : { spawn: opts.spawn }
501
+ });
502
+ writeRecord(opts.dir, engine, entry, shownVersion, void 0, env);
503
+ return { ...replaced, url: engine.url, previousUrl: record?.url };
504
+ }
505
+ function reconcileLive(dir, entry, shownVersion, env, run) {
506
+ const record = getEngineRecord(dir, env);
507
+ const name = record?.name ?? engineNameForProject(dir);
508
+ const running = listEngines({ entry, env, ...run === void 0 ? {} : { run } });
509
+ const found = reuseCandidate(name, record, running);
510
+ if (found === void 0 || record?.engineDigest === entry.digest) return { record, name, live: found };
511
+ stopMismatched(found.name, record, entry, env, run);
512
+ return { record, name, live: void 0, replaced: { name: found.name, from: record?.engineVersion, to: shownVersion } };
513
+ }
514
+ function writeRecord(dir, engine, entry, shownVersion, filled, env) {
515
+ setEngineRecord(
516
+ dir,
517
+ {
518
+ name: engine.name,
519
+ url: engine.url,
520
+ workspaceId: engine.workspaceId,
521
+ project: dir,
522
+ engineUrl: entry.url,
523
+ engineDigest: entry.digest,
524
+ ...shownVersion === void 0 ? {} : { engineVersion: shownVersion },
525
+ startedAt: Date.now(),
526
+ ...filled === void 0 ? {} : { filled }
527
+ },
528
+ env
529
+ );
530
+ }
531
+ function overrideVersion(entry, env, run) {
532
+ let out;
533
+ try {
534
+ out = engineVersion({ entry, env, ...run === void 0 ? {} : { run } });
535
+ } catch {
536
+ return void 0;
537
+ }
538
+ return engineVersionToken(out);
539
+ }
540
+ function stopMismatched(name, record, entry, env, run) {
541
+ const seam = run === void 0 ? {} : { run };
542
+ const attempt = (binary) => {
543
+ try {
544
+ return stopEngineNamed(name, { entry: binary, env, ...seam }).stopped;
545
+ } catch {
546
+ return false;
547
+ }
548
+ };
549
+ if (attempt(entry)) return;
550
+ const previous = recordedBinary(record, env);
551
+ if (previous !== void 0 && previous.digest !== entry.digest && attempt(previous)) return;
552
+ throw new Error(
553
+ `The local engine "${name}" already serving this project is not the engine this deploy resolved to, and it could not be stopped` + (previous === void 0 ? `` : ` by either engine version`) + `.
554
+ Stop it with \`xanosdk local-engine stop ${name}\` (or end the process), then deploy again.`
555
+ );
556
+ }
557
+ function recordedBinary(record, env) {
558
+ const version = record?.engineVersion;
559
+ if (version === void 0 || !RELEASE_VERSION.test(version)) return void 0;
560
+ try {
561
+ return readEngineEntry({ version }, env);
562
+ } catch {
563
+ return void 0;
564
+ }
565
+ }
566
+ function reuseCandidate(name, record, running) {
567
+ if (record !== void 0) {
568
+ const resolved = resolveRecordedEngine(record, running);
569
+ if (resolved.state === "unusable") throw new Error(resolved.reason);
570
+ return resolved.state === "live" ? resolved.engine : void 0;
571
+ }
572
+ const engine = running.find((e) => e.name === name);
573
+ if (engine === void 0) return void 0;
574
+ assertLoopbackUrl(engine.url, "The engine already serving this project");
575
+ return engine;
576
+ }
577
+ function explainUnsupportedEngineImport(err, engineVersion2, ctx = {}) {
578
+ if (!(err instanceof ImportHttpError) || err.status !== 501) return void 0;
579
+ const which = engineVersion2 === void 0 ? "The local engine" : `Local engine ${engineVersion2}`;
580
+ const newer = newerRelease(engineVersion2, ctx.latest);
581
+ if (newer !== void 0) {
582
+ return new Error(
583
+ `${which} does not support this import (HTTP 501): it is older than this SDK needs. Nothing was written. Deploy with ${newer} \u2014 \`xanosdk local-engine update\` moves this project's pin to it, or pass \`--local-engine=${newer}\` for one deploy.`,
584
+ { cause: err }
585
+ );
586
+ }
587
+ if (ctx.resetRerun !== void 0) {
588
+ return new Error(
589
+ `${which} cannot apply this merge (HTTP 501): keeping the rows through this schema change is not available on the local engine yet. Nothing was written. Deploy with \`${ctx.resetRerun}\` instead \u2014 it replaces the workspace and writes every table's seed rows, so rows entered since the last deploy are lost.`,
590
+ { cause: err }
591
+ );
592
+ }
593
+ return new Error(
594
+ `${which} does not support this import (HTTP 501). Nothing was written. \`xanosdk deploy\` deploys to an ephemeral meanwhile.`,
595
+ { cause: err }
596
+ );
597
+ }
598
+ function newerRelease(current, latest) {
599
+ if (current === void 0 || latest === void 0) return void 0;
600
+ const a = parseSemver(current);
601
+ const b = parseSemver(latest);
602
+ return a !== null && b !== null && compareSemver(b, a) > 0 ? latest : void 0;
603
+ }
604
+
605
+ export {
606
+ acquireEngine,
607
+ ensureProjectEngine,
608
+ DEPLOY_FALLBACK_NOTE,
609
+ restartMismatchedEngine,
610
+ explainUnsupportedEngineImport
611
+ };
612
+ //# sourceMappingURL=chunk-XBKMWY7F.js.map
@@ -0,0 +1,78 @@
1
+ // src/fields/hosted-file.ts
2
+ var HOSTED_FILE = /* @__PURE__ */ Symbol.for("xanosdk.hosted.file");
3
+ function hostedFile(path, base, opts = {}) {
4
+ return {
5
+ [HOSTED_FILE]: { path, base: typeof base === "string" ? base : base.href, access: opts.access ?? "public" }
6
+ };
7
+ }
8
+ function isHostedFile(value) {
9
+ return typeof value === "object" && value !== null && HOSTED_FILE in value;
10
+ }
11
+ var HOSTED_FILE_SCHEME = "xanosdk-file://";
12
+ function isPrivateLibraryRow(row) {
13
+ return !(typeof row === "object" && row !== null && row.access === "public");
14
+ }
15
+ var HOSTED_ICON_KINDS = ["tool", "prompt", "resource"];
16
+ function hostedIconOwners(payload) {
17
+ const out = [];
18
+ for (const kind of HOSTED_ICON_KINDS) {
19
+ const rows = payload[kind];
20
+ if (!Array.isArray(rows)) continue;
21
+ for (const row of rows) {
22
+ const icons = row !== null && typeof row === "object" && Array.isArray(row.icons) ? row.icons : [];
23
+ const hosted = icons.some(
24
+ (icon) => typeof icon === "object" && icon !== null && String(icon.src).startsWith(HOSTED_FILE_SCHEME)
25
+ );
26
+ if (hosted) out.push(`${kind} "${String(row.name ?? "")}"`);
27
+ }
28
+ }
29
+ return out;
30
+ }
31
+ function uncarriedHostedIcons(payload, carried) {
32
+ const out = [];
33
+ for (const kind of HOSTED_ICON_KINDS) {
34
+ const rows = payload[kind];
35
+ if (!Array.isArray(rows)) continue;
36
+ for (const row of rows) {
37
+ const icons = row !== null && typeof row === "object" && Array.isArray(row.icons) ? row.icons : [];
38
+ icons.forEach((icon, index) => {
39
+ const src = typeof icon === "object" && icon !== null ? icon.src : void 0;
40
+ if (typeof src !== "string" || !src.startsWith(HOSTED_FILE_SCHEME)) return;
41
+ const [canonical = "", file = ""] = src.slice(HOSTED_FILE_SCHEME.length).split("/");
42
+ if (carried.has(canonical)) return;
43
+ let name = file;
44
+ try {
45
+ name = decodeURIComponent(file);
46
+ } catch {
47
+ }
48
+ out.push({ owner: `${kind} "${String(row.name ?? "")}"`, index, src, name });
49
+ });
50
+ }
51
+ }
52
+ return out;
53
+ }
54
+ var HOSTED_ROW_PATH_PREFIX = "/vault/_/";
55
+ var pending = /* @__PURE__ */ new WeakMap();
56
+ function pendingHostedSrc(holder, ref, rules) {
57
+ pending.set(holder, { ref, rules });
58
+ const name = ref[HOSTED_FILE].path.split(/[\\/]/).pop() ?? "";
59
+ return `${HOSTED_FILE_SCHEME}pending/${encodeURIComponent(name)}`;
60
+ }
61
+ function pendingHostedFile(holder) {
62
+ return pending.get(holder);
63
+ }
64
+
65
+ export {
66
+ HOSTED_FILE,
67
+ hostedFile,
68
+ isHostedFile,
69
+ HOSTED_FILE_SCHEME,
70
+ isPrivateLibraryRow,
71
+ HOSTED_ICON_KINDS,
72
+ hostedIconOwners,
73
+ uncarriedHostedIcons,
74
+ HOSTED_ROW_PATH_PREFIX,
75
+ pendingHostedSrc,
76
+ pendingHostedFile
77
+ };
78
+ //# sourceMappingURL=chunk-XNCP4KYO.js.map