primitive-admin 1.1.0-alpha.9 → 1.1.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 (591) hide show
  1. package/README.md +523 -109
  2. package/assets/skill/skills/primitive-platform/SKILL.md +289 -0
  3. package/dist/bin/primitive.d.ts +2 -0
  4. package/dist/bin/primitive.js +372 -21
  5. package/dist/bin/primitive.js.map +1 -1
  6. package/dist/src/commands/admins.d.ts +2 -0
  7. package/dist/src/commands/admins.js +136 -30
  8. package/dist/src/commands/admins.js.map +1 -1
  9. package/dist/src/commands/analytics.d.ts +2 -0
  10. package/dist/src/commands/analytics.js +713 -55
  11. package/dist/src/commands/analytics.js.map +1 -1
  12. package/dist/src/commands/apps.d.ts +2 -0
  13. package/dist/src/commands/apps.js +65 -100
  14. package/dist/src/commands/apps.js.map +1 -1
  15. package/dist/src/commands/auth-sessions.d.ts +7 -0
  16. package/dist/src/commands/auth-sessions.js +144 -0
  17. package/dist/src/commands/auth-sessions.js.map +1 -0
  18. package/dist/src/commands/auth.d.ts +2 -0
  19. package/dist/src/commands/auth.js +238 -108
  20. package/dist/src/commands/auth.js.map +1 -1
  21. package/dist/src/commands/blob-buckets.d.ts +2 -0
  22. package/dist/src/commands/blob-buckets.js +331 -0
  23. package/dist/src/commands/blob-buckets.js.map +1 -0
  24. package/dist/src/commands/catalog.d.ts +2 -0
  25. package/dist/src/commands/catalog.js +63 -48
  26. package/dist/src/commands/catalog.js.map +1 -1
  27. package/dist/src/commands/collection-type-configs.d.ts +2 -0
  28. package/dist/src/commands/collection-type-configs.js +85 -0
  29. package/dist/src/commands/collection-type-configs.js.map +1 -0
  30. package/dist/src/commands/collections.d.ts +2 -0
  31. package/dist/src/commands/collections.js +1282 -0
  32. package/dist/src/commands/collections.js.map +1 -0
  33. package/dist/src/commands/comparisons.d.ts +2 -0
  34. package/dist/src/commands/comparisons.js +6 -6
  35. package/dist/src/commands/comparisons.js.map +1 -1
  36. package/dist/src/commands/config.d.ts +46 -0
  37. package/dist/src/commands/config.js +465 -0
  38. package/dist/src/commands/config.js.map +1 -0
  39. package/dist/src/commands/connections.d.ts +2 -0
  40. package/dist/src/commands/connections.js +99 -0
  41. package/dist/src/commands/connections.js.map +1 -0
  42. package/dist/src/commands/cron-triggers.d.ts +2 -0
  43. package/dist/src/commands/cron-triggers.js +266 -0
  44. package/dist/src/commands/cron-triggers.js.map +1 -0
  45. package/dist/src/commands/database-type-configs.d.ts +2 -0
  46. package/dist/src/commands/database-type-configs.js +164 -0
  47. package/dist/src/commands/database-type-configs.js.map +1 -0
  48. package/dist/src/commands/database-types.d.ts +2 -0
  49. package/dist/src/commands/database-types.js +471 -0
  50. package/dist/src/commands/database-types.js.map +1 -0
  51. package/dist/src/commands/databases.d.ts +65 -0
  52. package/dist/src/commands/databases.js +1887 -243
  53. package/dist/src/commands/databases.js.map +1 -1
  54. package/dist/src/commands/documents.d.ts +60 -0
  55. package/dist/src/commands/documents.js +2888 -22
  56. package/dist/src/commands/documents.js.map +1 -1
  57. package/dist/src/commands/email-templates.d.ts +2 -0
  58. package/dist/src/commands/email-templates.js +175 -0
  59. package/dist/src/commands/email-templates.js.map +1 -0
  60. package/dist/src/commands/env.d.ts +23 -0
  61. package/dist/src/commands/env.js +395 -0
  62. package/dist/src/commands/env.js.map +1 -0
  63. package/dist/src/commands/feature-flags.d.ts +14 -0
  64. package/dist/src/commands/feature-flags.js +117 -0
  65. package/dist/src/commands/feature-flags.js.map +1 -0
  66. package/dist/src/commands/functions.d.ts +20 -0
  67. package/dist/src/commands/functions.js +1630 -0
  68. package/dist/src/commands/functions.js.map +1 -0
  69. package/dist/src/commands/group-type-configs.d.ts +2 -0
  70. package/dist/src/commands/group-type-configs.js +87 -0
  71. package/dist/src/commands/group-type-configs.js.map +1 -0
  72. package/dist/src/commands/groups.d.ts +2 -0
  73. package/dist/src/commands/groups.js +65 -113
  74. package/dist/src/commands/groups.js.map +1 -1
  75. package/dist/src/commands/guides.d.ts +223 -0
  76. package/dist/src/commands/guides.js +627 -69
  77. package/dist/src/commands/guides.js.map +1 -1
  78. package/dist/src/commands/init.d.ts +37 -0
  79. package/dist/src/commands/init.js +1693 -208
  80. package/dist/src/commands/init.js.map +1 -1
  81. package/dist/src/commands/integrations.d.ts +2 -0
  82. package/dist/src/commands/integrations.js +428 -187
  83. package/dist/src/commands/integrations.js.map +1 -1
  84. package/dist/src/commands/llm.d.ts +2 -0
  85. package/dist/src/commands/llm.js +4 -2
  86. package/dist/src/commands/llm.js.map +1 -1
  87. package/dist/src/commands/locks.d.ts +8 -0
  88. package/dist/src/commands/locks.js +175 -0
  89. package/dist/src/commands/locks.js.map +1 -0
  90. package/dist/src/commands/metadata-category-configs.d.ts +12 -0
  91. package/dist/src/commands/metadata-category-configs.js +113 -0
  92. package/dist/src/commands/metadata-category-configs.js.map +1 -0
  93. package/dist/src/commands/metadata.d.ts +2 -0
  94. package/dist/src/commands/metadata.js +288 -0
  95. package/dist/src/commands/metadata.js.map +1 -0
  96. package/dist/src/commands/prompts.d.ts +2 -0
  97. package/dist/src/commands/prompts.js +322 -634
  98. package/dist/src/commands/prompts.js.map +1 -1
  99. package/dist/src/commands/rule-sets.d.ts +3 -0
  100. package/dist/src/commands/rule-sets.js +139 -148
  101. package/dist/src/commands/rule-sets.js.map +1 -1
  102. package/dist/src/commands/scripts.d.ts +30 -0
  103. package/dist/src/commands/scripts.js +688 -0
  104. package/dist/src/commands/scripts.js.map +1 -0
  105. package/dist/src/commands/secrets.d.ts +2 -0
  106. package/dist/src/commands/secrets.js +109 -0
  107. package/dist/src/commands/secrets.js.map +1 -0
  108. package/dist/src/commands/sessions.d.ts +2 -0
  109. package/dist/src/commands/sessions.js +76 -0
  110. package/dist/src/commands/sessions.js.map +1 -0
  111. package/dist/src/commands/skill.d.ts +2 -0
  112. package/dist/src/commands/skill.js +29 -0
  113. package/dist/src/commands/skill.js.map +1 -0
  114. package/dist/src/commands/sync-app-settings.d.ts +158 -0
  115. package/dist/src/commands/sync-app-settings.js +328 -0
  116. package/dist/src/commands/sync-app-settings.js.map +1 -0
  117. package/dist/src/commands/sync.d.ts +2670 -0
  118. package/dist/src/commands/sync.js +17144 -834
  119. package/dist/src/commands/sync.js.map +1 -1
  120. package/dist/src/commands/tokens.d.ts +2 -0
  121. package/dist/src/commands/tokens.js +132 -22
  122. package/dist/src/commands/tokens.js.map +1 -1
  123. package/dist/src/commands/users.d.ts +2 -0
  124. package/dist/src/commands/users.js +542 -24
  125. package/dist/src/commands/users.js.map +1 -1
  126. package/dist/src/commands/vars.d.ts +8 -0
  127. package/dist/src/commands/vars.js +97 -0
  128. package/dist/src/commands/vars.js.map +1 -0
  129. package/dist/src/commands/waitlist.d.ts +2 -0
  130. package/dist/src/commands/waitlist.js +12 -11
  131. package/dist/src/commands/waitlist.js.map +1 -1
  132. package/dist/src/commands/webhooks.d.ts +31 -0
  133. package/dist/src/commands/webhooks.js +633 -0
  134. package/dist/src/commands/webhooks.js.map +1 -0
  135. package/dist/src/commands/workflows.d.ts +88 -0
  136. package/dist/src/commands/workflows.js +1568 -742
  137. package/dist/src/commands/workflows.js.map +1 -1
  138. package/dist/src/lib/access-rule-display.d.ts +21 -0
  139. package/dist/src/lib/access-rule-display.js +34 -0
  140. package/dist/src/lib/access-rule-display.js.map +1 -0
  141. package/dist/src/lib/api-client.d.ts +2550 -0
  142. package/dist/src/lib/api-client.js +2503 -160
  143. package/dist/src/lib/api-client.js.map +1 -1
  144. package/dist/src/lib/app-settings-descriptor.d.ts +263 -0
  145. package/dist/src/lib/app-settings-descriptor.js +583 -0
  146. package/dist/src/lib/app-settings-descriptor.js.map +1 -0
  147. package/dist/src/lib/auth-flow.d.ts +8 -0
  148. package/dist/src/lib/batch.d.ts +26 -0
  149. package/dist/src/lib/batch.js +32 -0
  150. package/dist/src/lib/batch.js.map +1 -0
  151. package/dist/src/lib/block-layout.d.ts +160 -0
  152. package/dist/src/lib/block-layout.js +451 -0
  153. package/dist/src/lib/block-layout.js.map +1 -0
  154. package/dist/src/lib/block-selector.d.ts +58 -0
  155. package/dist/src/lib/block-selector.js +92 -0
  156. package/dist/src/lib/block-selector.js.map +1 -0
  157. package/dist/src/lib/canonical-json.d.ts +12 -0
  158. package/dist/src/lib/canonical-json.js +35 -0
  159. package/dist/src/lib/canonical-json.js.map +1 -0
  160. package/dist/src/lib/channel.d.ts +30 -0
  161. package/dist/src/lib/channel.js +68 -0
  162. package/dist/src/lib/channel.js.map +1 -0
  163. package/dist/src/lib/cli-manifest.d.ts +68 -0
  164. package/dist/src/lib/cli-manifest.js +71 -0
  165. package/dist/src/lib/cli-manifest.js.map +1 -0
  166. package/dist/src/lib/codegen-shared/generatedFiles.d.ts +101 -0
  167. package/dist/src/lib/codegen-shared/generatedFiles.js +191 -0
  168. package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -0
  169. package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
  170. package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
  171. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
  172. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +38 -0
  173. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +46 -0
  174. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -0
  175. package/dist/src/lib/collection-export.d.ts +184 -0
  176. package/dist/src/lib/collection-export.js +252 -0
  177. package/dist/src/lib/collection-export.js.map +1 -0
  178. package/dist/src/lib/config-json-field.d.ts +28 -0
  179. package/dist/src/lib/config-json-field.js +56 -0
  180. package/dist/src/lib/config-json-field.js.map +1 -0
  181. package/dist/src/lib/config-object-descriptor.d.ts +127 -0
  182. package/dist/src/lib/config-object-descriptor.js +740 -0
  183. package/dist/src/lib/config-object-descriptor.js.map +1 -0
  184. package/dist/src/lib/config-payload.d.ts +92 -0
  185. package/dist/src/lib/config-payload.js +161 -0
  186. package/dist/src/lib/config-payload.js.map +1 -0
  187. package/dist/src/lib/config-surface.d.ts +141 -0
  188. package/dist/src/lib/config-surface.js +368 -0
  189. package/dist/src/lib/config-surface.js.map +1 -0
  190. package/dist/src/lib/config-toml.d.ts +10 -0
  191. package/dist/src/lib/config-toml.js +42 -0
  192. package/dist/src/lib/config-toml.js.map +1 -0
  193. package/dist/src/lib/config.d.ts +71 -0
  194. package/dist/src/lib/config.js +71 -68
  195. package/dist/src/lib/config.js.map +1 -1
  196. package/dist/src/lib/confirm-prompt.d.ts +83 -0
  197. package/dist/src/lib/confirm-prompt.js +110 -0
  198. package/dist/src/lib/confirm-prompt.js.map +1 -0
  199. package/dist/src/lib/constants.d.ts +11 -0
  200. package/dist/src/lib/constants.js +12 -0
  201. package/dist/src/lib/constants.js.map +1 -0
  202. package/dist/src/lib/crash-handlers.d.ts +20 -0
  203. package/dist/src/lib/crash-handlers.js +49 -0
  204. package/dist/src/lib/crash-handlers.js.map +1 -0
  205. package/dist/src/lib/credentials-store.d.ts +104 -0
  206. package/dist/src/lib/credentials-store.js +336 -0
  207. package/dist/src/lib/credentials-store.js.map +1 -0
  208. package/dist/src/lib/csv.d.ts +47 -0
  209. package/dist/src/lib/csv.js +172 -0
  210. package/dist/src/lib/csv.js.map +1 -0
  211. package/dist/src/lib/data-input.d.ts +23 -0
  212. package/dist/src/lib/data-input.js +50 -0
  213. package/dist/src/lib/data-input.js.map +1 -0
  214. package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
  215. package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
  216. package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
  217. package/dist/src/lib/db-codegen/dbGenerator.d.ts +67 -0
  218. package/dist/src/lib/db-codegen/dbGenerator.js +170 -0
  219. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
  220. package/dist/src/lib/db-codegen/dbNaming.d.ts +87 -0
  221. package/dist/src/lib/db-codegen/dbNaming.js +180 -0
  222. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
  223. package/dist/src/lib/db-codegen/dbTemplates.d.ts +272 -0
  224. package/dist/src/lib/db-codegen/dbTemplates.js +480 -0
  225. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
  226. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +73 -0
  227. package/dist/src/lib/db-codegen/dbTsTypes.js +139 -0
  228. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
  229. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +146 -0
  230. package/dist/src/lib/db-codegen/dbTypeIR.js +525 -0
  231. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -0
  232. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +112 -0
  233. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +211 -0
  234. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -0
  235. package/dist/src/lib/deprecation.d.ts +22 -0
  236. package/dist/src/lib/deprecation.js +43 -0
  237. package/dist/src/lib/deprecation.js.map +1 -0
  238. package/dist/src/lib/document-export-permissions.d.ts +30 -0
  239. package/dist/src/lib/document-export-permissions.js +54 -0
  240. package/dist/src/lib/document-export-permissions.js.map +1 -0
  241. package/dist/src/lib/document-ingest-artifact.d.ts +120 -0
  242. package/dist/src/lib/document-ingest-artifact.js +505 -0
  243. package/dist/src/lib/document-ingest-artifact.js.map +1 -0
  244. package/dist/src/lib/document-ingest-input.d.ts +51 -0
  245. package/dist/src/lib/document-ingest-input.js +132 -0
  246. package/dist/src/lib/document-ingest-input.js.map +1 -0
  247. package/dist/src/lib/document-ingest-rows.d.ts +137 -0
  248. package/dist/src/lib/document-ingest-rows.js +181 -0
  249. package/dist/src/lib/document-ingest-rows.js.map +1 -0
  250. package/dist/src/lib/document-ingest.d.ts +101 -0
  251. package/dist/src/lib/document-ingest.js +384 -0
  252. package/dist/src/lib/document-ingest.js.map +1 -0
  253. package/dist/src/lib/env-resolver-core.d.ts +258 -0
  254. package/dist/src/lib/env-resolver-core.js +447 -0
  255. package/dist/src/lib/env-resolver-core.js.map +1 -0
  256. package/dist/src/lib/env-resolver.d.ts +99 -0
  257. package/dist/src/lib/env-resolver.js +153 -0
  258. package/dist/src/lib/env-resolver.js.map +1 -0
  259. package/dist/src/lib/fetch.d.ts +5 -0
  260. package/dist/src/lib/function-bundle.d.ts +147 -0
  261. package/dist/src/lib/function-bundle.js +341 -0
  262. package/dist/src/lib/function-bundle.js.map +1 -0
  263. package/dist/src/lib/function-collect.d.ts +123 -0
  264. package/dist/src/lib/function-collect.js +610 -0
  265. package/dist/src/lib/function-collect.js.map +1 -0
  266. package/dist/src/lib/function-db-types.d.ts +202 -0
  267. package/dist/src/lib/function-db-types.js +870 -0
  268. package/dist/src/lib/function-db-types.js.map +1 -0
  269. package/dist/src/lib/function-document-types.d.ts +144 -0
  270. package/dist/src/lib/function-document-types.js +370 -0
  271. package/dist/src/lib/function-document-types.js.map +1 -0
  272. package/dist/src/lib/function-grants-preflight.d.ts +64 -0
  273. package/dist/src/lib/function-grants-preflight.js +105 -0
  274. package/dist/src/lib/function-grants-preflight.js.map +1 -0
  275. package/dist/src/lib/function-log-lines.d.ts +76 -0
  276. package/dist/src/lib/function-log-lines.js +160 -0
  277. package/dist/src/lib/function-log-lines.js.map +1 -0
  278. package/dist/src/lib/function-log-row.d.ts +29 -0
  279. package/dist/src/lib/function-log-row.js +73 -0
  280. package/dist/src/lib/function-log-row.js.map +1 -0
  281. package/dist/src/lib/function-log-tail.d.ts +132 -0
  282. package/dist/src/lib/function-log-tail.js +262 -0
  283. package/dist/src/lib/function-log-tail.js.map +1 -0
  284. package/dist/src/lib/function-run.d.ts +289 -0
  285. package/dist/src/lib/function-run.js +389 -0
  286. package/dist/src/lib/function-run.js.map +1 -0
  287. package/dist/src/lib/function-schema-codegen.d.ts +143 -0
  288. package/dist/src/lib/function-schema-codegen.js +420 -0
  289. package/dist/src/lib/function-schema-codegen.js.map +1 -0
  290. package/dist/src/lib/function-sync.d.ts +459 -0
  291. package/dist/src/lib/function-sync.js +1258 -0
  292. package/dist/src/lib/function-sync.js.map +1 -0
  293. package/dist/src/lib/function-trigger-listing.d.ts +27 -0
  294. package/dist/src/lib/function-trigger-listing.js +70 -0
  295. package/dist/src/lib/function-trigger-listing.js.map +1 -0
  296. package/dist/src/lib/function-typecheck.d.ts +86 -0
  297. package/dist/src/lib/function-typecheck.js +370 -0
  298. package/dist/src/lib/function-typecheck.js.map +1 -0
  299. package/dist/src/lib/function-versions.d.ts +122 -0
  300. package/dist/src/lib/function-versions.js +182 -0
  301. package/dist/src/lib/function-versions.js.map +1 -0
  302. package/dist/src/lib/generated-allowlist.d.ts +28 -0
  303. package/dist/src/lib/generated-allowlist.js +281 -0
  304. package/dist/src/lib/generated-allowlist.js.map +1 -0
  305. package/dist/src/lib/generated-config-surfaces.d.ts +2936 -0
  306. package/dist/src/lib/generated-config-surfaces.js +10569 -0
  307. package/dist/src/lib/generated-config-surfaces.js.map +1 -0
  308. package/dist/src/lib/generated-sdk-types.d.ts +12 -0
  309. package/dist/src/lib/generated-sdk-types.js +13 -0
  310. package/dist/src/lib/generated-sdk-types.js.map +1 -0
  311. package/dist/src/lib/generated-template-lint.d.ts +212 -0
  312. package/dist/src/lib/generated-template-lint.js +624 -0
  313. package/dist/src/lib/generated-template-lint.js.map +1 -0
  314. package/dist/src/lib/init-adopt.d.ts +16 -0
  315. package/dist/src/lib/init-adopt.js +34 -0
  316. package/dist/src/lib/init-adopt.js.map +1 -0
  317. package/dist/src/lib/init-assets.d.ts +39 -0
  318. package/dist/src/lib/init-assets.js +97 -0
  319. package/dist/src/lib/init-assets.js.map +1 -0
  320. package/dist/src/lib/init-client-platforms.d.ts +14 -0
  321. package/dist/src/lib/init-client-platforms.js +71 -0
  322. package/dist/src/lib/init-client-platforms.js.map +1 -0
  323. package/dist/src/lib/init-config.d.ts +98 -0
  324. package/dist/src/lib/init-config.js +186 -0
  325. package/dist/src/lib/init-config.js.map +1 -0
  326. package/dist/src/lib/init-email-redirect-uris.d.ts +37 -0
  327. package/dist/src/lib/init-email-redirect-uris.js +46 -0
  328. package/dist/src/lib/init-email-redirect-uris.js.map +1 -0
  329. package/dist/src/lib/init-ios-links.d.ts +91 -0
  330. package/dist/src/lib/init-ios-links.js +219 -0
  331. package/dist/src/lib/init-ios-links.js.map +1 -0
  332. package/dist/src/lib/init-plan.d.ts +80 -0
  333. package/dist/src/lib/init-plan.js +95 -0
  334. package/dist/src/lib/init-plan.js.map +1 -0
  335. package/dist/src/lib/init-production-env.d.ts +48 -0
  336. package/dist/src/lib/init-production-env.js +59 -0
  337. package/dist/src/lib/init-production-env.js.map +1 -0
  338. package/dist/src/lib/init-schema.d.ts +74 -0
  339. package/dist/src/lib/init-schema.js +358 -0
  340. package/dist/src/lib/init-schema.js.map +1 -0
  341. package/dist/src/lib/init-xcode.d.ts +34 -0
  342. package/dist/src/lib/init-xcode.js +138 -0
  343. package/dist/src/lib/init-xcode.js.map +1 -0
  344. package/dist/src/lib/integration-request-config.d.ts +30 -0
  345. package/dist/src/lib/integration-request-config.js +145 -0
  346. package/dist/src/lib/integration-request-config.js.map +1 -0
  347. package/dist/src/lib/integration-selector.d.ts +42 -0
  348. package/dist/src/lib/integration-selector.js +46 -0
  349. package/dist/src/lib/integration-selector.js.map +1 -0
  350. package/dist/src/lib/ios-app-id.d.ts +34 -0
  351. package/dist/src/lib/ios-app-id.js +69 -0
  352. package/dist/src/lib/ios-app-id.js.map +1 -0
  353. package/dist/src/lib/list-options.d.ts +68 -0
  354. package/dist/src/lib/list-options.js +89 -0
  355. package/dist/src/lib/list-options.js.map +1 -0
  356. package/dist/src/lib/local-state.d.ts +55 -0
  357. package/dist/src/lib/local-state.js +167 -0
  358. package/dist/src/lib/local-state.js.map +1 -0
  359. package/dist/src/lib/local-test-cases.d.ts +63 -0
  360. package/dist/src/lib/local-test-cases.js +136 -0
  361. package/dist/src/lib/local-test-cases.js.map +1 -0
  362. package/dist/src/lib/log-inspection.d.ts +715 -0
  363. package/dist/src/lib/log-inspection.js +816 -0
  364. package/dist/src/lib/log-inspection.js.map +1 -0
  365. package/dist/src/lib/logout-admin-session.d.ts +33 -0
  366. package/dist/src/lib/logout-admin-session.js +70 -0
  367. package/dist/src/lib/logout-admin-session.js.map +1 -0
  368. package/dist/src/lib/migration-nag.d.ts +49 -0
  369. package/dist/src/lib/migration-nag.js +163 -0
  370. package/dist/src/lib/migration-nag.js.map +1 -0
  371. package/dist/src/lib/object-status-filter.d.ts +22 -0
  372. package/dist/src/lib/object-status-filter.js +45 -0
  373. package/dist/src/lib/object-status-filter.js.map +1 -0
  374. package/dist/src/lib/output.d.ts +124 -0
  375. package/dist/src/lib/output.js +219 -8
  376. package/dist/src/lib/output.js.map +1 -1
  377. package/dist/src/lib/package-manager.d.ts +140 -0
  378. package/dist/src/lib/package-manager.js +305 -0
  379. package/dist/src/lib/package-manager.js.map +1 -0
  380. package/dist/src/lib/paginate.d.ts +98 -0
  381. package/dist/src/lib/paginate.js +112 -0
  382. package/dist/src/lib/paginate.js.map +1 -0
  383. package/dist/src/lib/platform-owned.d.ts +63 -0
  384. package/dist/src/lib/platform-owned.js +85 -0
  385. package/dist/src/lib/platform-owned.js.map +1 -0
  386. package/dist/src/lib/project-config.d.ts +122 -0
  387. package/dist/src/lib/project-config.js +244 -0
  388. package/dist/src/lib/project-config.js.map +1 -0
  389. package/dist/src/lib/prompt-cost-format.d.ts +11 -0
  390. package/dist/src/lib/prompt-cost-format.js +41 -0
  391. package/dist/src/lib/prompt-cost-format.js.map +1 -0
  392. package/dist/src/lib/prompt-schema-codegen.d.ts +147 -0
  393. package/dist/src/lib/prompt-schema-codegen.js +462 -0
  394. package/dist/src/lib/prompt-schema-codegen.js.map +1 -0
  395. package/dist/src/lib/query-operators.d.ts +43 -0
  396. package/dist/src/lib/query-operators.js +80 -0
  397. package/dist/src/lib/query-operators.js.map +1 -0
  398. package/dist/src/lib/record-filter.d.ts +18 -0
  399. package/dist/src/lib/record-filter.js +55 -0
  400. package/dist/src/lib/record-filter.js.map +1 -0
  401. package/dist/src/lib/refresh-admin-credentials.d.ts +73 -0
  402. package/dist/src/lib/refresh-admin-credentials.js +123 -0
  403. package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
  404. package/dist/src/lib/resolve-init-dev-port.d.ts +56 -0
  405. package/dist/src/lib/resolve-init-dev-port.js +55 -0
  406. package/dist/src/lib/resolve-init-dev-port.js.map +1 -0
  407. package/dist/src/lib/resolve-init-server.d.ts +64 -0
  408. package/dist/src/lib/resolve-init-server.js +77 -0
  409. package/dist/src/lib/resolve-init-server.js.map +1 -0
  410. package/dist/src/lib/resolve-owner.d.ts +19 -0
  411. package/dist/src/lib/resolve-owner.js +20 -0
  412. package/dist/src/lib/resolve-owner.js.map +1 -0
  413. package/dist/src/lib/resolve-platform.d.ts +74 -0
  414. package/dist/src/lib/resolve-platform.js +105 -0
  415. package/dist/src/lib/resolve-platform.js.map +1 -0
  416. package/dist/src/lib/run-status.d.ts +19 -0
  417. package/dist/src/lib/run-status.generated.d.ts +39 -0
  418. package/dist/src/lib/run-status.generated.js +66 -0
  419. package/dist/src/lib/run-status.generated.js.map +1 -0
  420. package/dist/src/lib/run-status.js +19 -0
  421. package/dist/src/lib/run-status.js.map +1 -0
  422. package/dist/src/lib/server-text-normalization.d.ts +51 -0
  423. package/dist/src/lib/server-text-normalization.js +90 -0
  424. package/dist/src/lib/server-text-normalization.js.map +1 -0
  425. package/dist/src/lib/server-url.d.ts +22 -0
  426. package/dist/src/lib/server-url.js +33 -0
  427. package/dist/src/lib/server-url.js.map +1 -0
  428. package/dist/src/lib/signing-secret-status.d.ts +81 -0
  429. package/dist/src/lib/signing-secret-status.js +116 -0
  430. package/dist/src/lib/signing-secret-status.js.map +1 -0
  431. package/dist/src/lib/skill-installer.d.ts +71 -0
  432. package/dist/src/lib/skill-installer.js +441 -0
  433. package/dist/src/lib/skill-installer.js.map +1 -0
  434. package/dist/src/lib/snapshot-audit-source.d.ts +45 -0
  435. package/dist/src/lib/snapshot-audit-source.js +58 -0
  436. package/dist/src/lib/snapshot-audit-source.js.map +1 -0
  437. package/dist/src/lib/snapshot-audit-store.d.ts +52 -0
  438. package/dist/src/lib/snapshot-audit-store.js +196 -0
  439. package/dist/src/lib/snapshot-audit-store.js.map +1 -0
  440. package/dist/src/lib/snapshot-audit.d.ts +207 -0
  441. package/dist/src/lib/snapshot-audit.js +431 -0
  442. package/dist/src/lib/snapshot-audit.js.map +1 -0
  443. package/dist/src/lib/snapshot-build-rows.d.ts +60 -0
  444. package/dist/src/lib/snapshot-build-rows.js +87 -0
  445. package/dist/src/lib/snapshot-build-rows.js.map +1 -0
  446. package/dist/src/lib/snapshot-build.d.ts +50 -0
  447. package/dist/src/lib/snapshot-build.js +111 -0
  448. package/dist/src/lib/snapshot-build.js.map +1 -0
  449. package/dist/src/lib/snapshot-manifest-layout.d.ts +61 -0
  450. package/dist/src/lib/snapshot-manifest-layout.js +70 -0
  451. package/dist/src/lib/snapshot-manifest-layout.js.map +1 -0
  452. package/dist/src/lib/snapshots.d.ts +98 -0
  453. package/dist/src/lib/snapshots.js +294 -0
  454. package/dist/src/lib/snapshots.js.map +1 -0
  455. package/dist/src/lib/step-run-table.d.ts +43 -0
  456. package/dist/src/lib/step-run-table.js +129 -0
  457. package/dist/src/lib/step-run-table.js.map +1 -0
  458. package/dist/src/lib/storage-pending-retry.d.ts +26 -0
  459. package/dist/src/lib/storage-pending-retry.js +42 -0
  460. package/dist/src/lib/storage-pending-retry.js.map +1 -0
  461. package/dist/src/lib/swift-codegen/agentGenerator.d.ts +42 -0
  462. package/dist/src/lib/swift-codegen/agentGenerator.js +118 -0
  463. package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -0
  464. package/dist/src/lib/swift-codegen/banners.d.ts +24 -0
  465. package/dist/src/lib/swift-codegen/banners.js +25 -0
  466. package/dist/src/lib/swift-codegen/banners.js.map +1 -0
  467. package/dist/src/lib/swift-codegen/dbGenerator.d.ts +113 -0
  468. package/dist/src/lib/swift-codegen/dbGenerator.js +926 -0
  469. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -0
  470. package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +42 -0
  471. package/dist/src/lib/swift-codegen/dbSwiftTypes.js +100 -0
  472. package/dist/src/lib/swift-codegen/dbSwiftTypes.js.map +1 -0
  473. package/dist/src/lib/swift-codegen/functionGenerator.d.ts +139 -0
  474. package/dist/src/lib/swift-codegen/functionGenerator.js +462 -0
  475. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -0
  476. package/dist/src/lib/swift-codegen/generator.d.ts +100 -0
  477. package/dist/src/lib/swift-codegen/generator.js +457 -0
  478. package/dist/src/lib/swift-codegen/generator.js.map +1 -0
  479. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +87 -0
  480. package/dist/src/lib/swift-codegen/schemaToSwift.js +661 -0
  481. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -0
  482. package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +94 -0
  483. package/dist/src/lib/swift-codegen/siblingSymbols.js +155 -0
  484. package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
  485. package/dist/src/lib/swift-codegen/swiftNaming.d.ts +85 -0
  486. package/dist/src/lib/swift-codegen/swiftNaming.js +198 -0
  487. package/dist/src/lib/swift-codegen/swiftNaming.js.map +1 -0
  488. package/dist/src/lib/sync-dir-selector.d.ts +21 -0
  489. package/dist/src/lib/sync-dir-selector.js +30 -0
  490. package/dist/src/lib/sync-dir-selector.js.map +1 -0
  491. package/dist/src/lib/sync-paths.d.ts +128 -0
  492. package/dist/src/lib/sync-paths.js +195 -0
  493. package/dist/src/lib/sync-paths.js.map +1 -0
  494. package/dist/src/lib/sync-resource-types.d.ts +563 -0
  495. package/dist/src/lib/sync-resource-types.js +1073 -0
  496. package/dist/src/lib/sync-resource-types.js.map +1 -0
  497. package/dist/src/lib/sync-selectors.d.ts +138 -0
  498. package/dist/src/lib/sync-selectors.js +289 -0
  499. package/dist/src/lib/sync-selectors.js.map +1 -0
  500. package/dist/src/lib/template.d.ts +170 -0
  501. package/dist/src/lib/template.js +484 -68
  502. package/dist/src/lib/template.js.map +1 -1
  503. package/dist/src/lib/test-case-file-names.d.ts +40 -0
  504. package/dist/src/lib/test-case-file-names.js +91 -0
  505. package/dist/src/lib/test-case-file-names.js.map +1 -0
  506. package/dist/src/lib/test-case-keys.d.ts +29 -0
  507. package/dist/src/lib/test-case-keys.js +55 -0
  508. package/dist/src/lib/test-case-keys.js.map +1 -0
  509. package/dist/src/lib/test-case-variables.d.ts +29 -0
  510. package/dist/src/lib/test-case-variables.js +71 -0
  511. package/dist/src/lib/test-case-variables.js.map +1 -0
  512. package/dist/src/lib/token-inject.d.ts +56 -0
  513. package/dist/src/lib/token-inject.js +204 -0
  514. package/dist/src/lib/token-inject.js.map +1 -0
  515. package/dist/src/lib/toml-database-config.d.ts +123 -0
  516. package/dist/src/lib/toml-database-config.js +544 -0
  517. package/dist/src/lib/toml-database-config.js.map +1 -0
  518. package/dist/src/lib/toml-metadata-config.d.ts +151 -0
  519. package/dist/src/lib/toml-metadata-config.js +476 -0
  520. package/dist/src/lib/toml-metadata-config.js.map +1 -0
  521. package/dist/src/lib/toml-native-form.d.ts +46 -0
  522. package/dist/src/lib/toml-native-form.js +78 -0
  523. package/dist/src/lib/toml-native-form.js.map +1 -0
  524. package/dist/src/lib/toml-params-validator.d.ts +129 -0
  525. package/dist/src/lib/toml-params-validator.js +298 -0
  526. package/dist/src/lib/toml-params-validator.js.map +1 -0
  527. package/dist/src/lib/toml-scalar-edit.d.ts +43 -0
  528. package/dist/src/lib/toml-scalar-edit.js +283 -0
  529. package/dist/src/lib/toml-scalar-edit.js.map +1 -0
  530. package/dist/src/lib/user-selector.d.ts +24 -0
  531. package/dist/src/lib/user-selector.js +33 -0
  532. package/dist/src/lib/user-selector.js.map +1 -0
  533. package/dist/src/lib/version-check.d.ts +35 -0
  534. package/dist/src/lib/version-check.js +241 -0
  535. package/dist/src/lib/version-check.js.map +1 -0
  536. package/dist/src/lib/watch.d.ts +121 -0
  537. package/dist/src/lib/watch.js +169 -0
  538. package/dist/src/lib/watch.js.map +1 -0
  539. package/dist/src/lib/web-url.d.ts +40 -0
  540. package/dist/src/lib/web-url.js +76 -0
  541. package/dist/src/lib/web-url.js.map +1 -0
  542. package/dist/src/lib/webhook-deliver.d.ts +209 -0
  543. package/dist/src/lib/webhook-deliver.js +519 -0
  544. package/dist/src/lib/webhook-deliver.js.map +1 -0
  545. package/dist/src/lib/workflow-apply.d.ts +110 -0
  546. package/dist/src/lib/workflow-apply.js +164 -0
  547. package/dist/src/lib/workflow-apply.js.map +1 -0
  548. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.d.ts +129 -0
  549. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js +269 -0
  550. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js.map +1 -0
  551. package/dist/src/lib/workflow-codegen/generator.d.ts +96 -0
  552. package/dist/src/lib/workflow-codegen/generator.js +361 -0
  553. package/dist/src/lib/workflow-codegen/generator.js.map +1 -0
  554. package/dist/src/lib/workflow-codegen/invokerIR.d.ts +94 -0
  555. package/dist/src/lib/workflow-codegen/invokerIR.js +76 -0
  556. package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -0
  557. package/dist/src/lib/workflow-codegen/naming.d.ts +33 -0
  558. package/dist/src/lib/workflow-codegen/naming.js +81 -0
  559. package/dist/src/lib/workflow-codegen/naming.js.map +1 -0
  560. package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +80 -0
  561. package/dist/src/lib/workflow-codegen/schemaToTs.js +303 -0
  562. package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -0
  563. package/dist/src/lib/workflow-config-apply.d.ts +70 -0
  564. package/dist/src/lib/workflow-config-apply.js +137 -0
  565. package/dist/src/lib/workflow-config-apply.js.map +1 -0
  566. package/dist/src/lib/workflow-config-sidecar.d.ts +63 -0
  567. package/dist/src/lib/workflow-config-sidecar.js +96 -0
  568. package/dist/src/lib/workflow-config-sidecar.js.map +1 -0
  569. package/dist/src/lib/workflow-defaults.d.ts +29 -0
  570. package/dist/src/lib/workflow-defaults.js +41 -0
  571. package/dist/src/lib/workflow-defaults.js.map +1 -0
  572. package/dist/src/lib/workflow-fragments.d.ts +64 -0
  573. package/dist/src/lib/workflow-fragments.js +342 -0
  574. package/dist/src/lib/workflow-fragments.js.map +1 -0
  575. package/dist/src/lib/workflow-include-preserve.d.ts +76 -0
  576. package/dist/src/lib/workflow-include-preserve.js +286 -0
  577. package/dist/src/lib/workflow-include-preserve.js.map +1 -0
  578. package/dist/src/lib/workflow-payload.d.ts +98 -0
  579. package/dist/src/lib/workflow-payload.js +178 -0
  580. package/dist/src/lib/workflow-payload.js.map +1 -0
  581. package/dist/src/lib/workflow-toml-validator.d.ts +211 -0
  582. package/dist/src/lib/workflow-toml-validator.js +770 -0
  583. package/dist/src/lib/workflow-toml-validator.js.map +1 -0
  584. package/dist/src/lib/workflow-usage.d.ts +196 -0
  585. package/dist/src/lib/workflow-usage.js +310 -0
  586. package/dist/src/lib/workflow-usage.js.map +1 -0
  587. package/dist/src/types/index.d.ts +591 -0
  588. package/dist/src/validators.d.ts +65 -0
  589. package/dist/src/validators.js +64 -0
  590. package/dist/src/validators.js.map +1 -0
  591. package/package.json +34 -9
@@ -0,0 +1,384 @@
1
+ /**
2
+ * Driving one bulk-load session: create, upload, commit, poll.
3
+ *
4
+ * The artifact is already built and checked by the time anything here runs
5
+ * (`document-ingest-artifact`), so every refusal this module reports comes
6
+ * from the server. What it decides is what to do about one:
7
+ *
8
+ * - a create the server refuses uploads nothing;
9
+ * - an upload that fails ABORTS the session rather than retrying a slot whose
10
+ * reservation this side cannot see — the artifact is deterministic and a
11
+ * re-run is cheap;
12
+ * - Ctrl-C during the uploads aborts too, because the session it was filling
13
+ * is not going to be committed; Ctrl-C while POLLING leaves the session
14
+ * alone, because by then the document is already being changed and giving up
15
+ * on watching is not giving up on the load;
16
+ * - a session READ that fails while polling is retried on a bounded schedule
17
+ * (#3597), for the same reason: the read failing says nothing about the load,
18
+ * and a multi-hour load will meet transient reads. When the bound is spent
19
+ * the wait stops and says the session is still running — it never reports it
20
+ * as cancelled or failed.
21
+ *
22
+ * Exit codes follow `functions runs wait`/`invoke`, as `docs/cli-design.md`
23
+ * records them: 0 completed, 1 failed or refused, 124 a wait that gave up,
24
+ * 130 Ctrl-C. Both ways of giving up on the WATCHING are 124 and both say the
25
+ * session keeps running; only the load itself failing is 1.
26
+ */
27
+ import fs from "fs";
28
+ /** A plan the operator did not confirm, or cannot be asked about. */
29
+ export class IngestRefusedError extends Error {
30
+ constructor(message) {
31
+ super(message);
32
+ this.name = "IngestRefusedError";
33
+ }
34
+ }
35
+ const POLL_FAST_MS = 2_000;
36
+ const POLL_SLOW_MS = 5_000;
37
+ const POLL_SLOWS_AFTER_MS = 60_000;
38
+ /**
39
+ * How long CONSECUTIVE failed session reads may run before the wait gives up
40
+ * (#3597), and the backoff between them.
41
+ *
42
+ * A bound measured in attempts would have been wrong for the load this is for:
43
+ * the 2026-09-18 2 GB validation attempts met reads that failed for MINUTES
44
+ * together through the same route while the session stayed alive and
45
+ * advancing. So the bound is a wall-clock window, and any successful read
46
+ * resets it — an isolated blip costs a multi-hour load nothing at all, and
47
+ * only an outage that never lifts ends the watching.
48
+ *
49
+ * Module constants like the poll cadence above, deliberately: there is no flag
50
+ * for them. The backoff caps rather than doubling forever, because a backoff
51
+ * that silently stops backing off is a poll storm (`function-run.ts`).
52
+ */
53
+ const POLL_READ_RETRY_WINDOW_MS = 10 * 60_000;
54
+ const POLL_READ_BACKOFF_MS = 1_000;
55
+ const POLL_READ_BACKOFF_CAP_MS = 15_000;
56
+ /**
57
+ * Whether a thrown session read is worth retrying.
58
+ *
59
+ * `ApiClient.request` throws an `ApiError` carrying `statusCode` on any
60
+ * non-2xx, and the fetch under it rejects with no status at all on a dropped
61
+ * connection — so a transport failure, a 5xx, a 408 and a 429 all describe a
62
+ * server that may well answer the next read, and the session goes on either
63
+ * way. Any OTHER 4xx is definitive: the session is gone, or unreadable to this
64
+ * caller, and retrying it only to call it "still running" would misstate it.
65
+ */
66
+ function isTransientReadError(error) {
67
+ const status = error?.statusCode ?? error?.status;
68
+ if (typeof status !== "number")
69
+ return true;
70
+ if (status >= 500)
71
+ return true;
72
+ return status === 408 || status === 429;
73
+ }
74
+ /** The capped doubling between consecutive failed reads. */
75
+ function readBackoffMs(failures) {
76
+ return Math.min(POLL_READ_BACKOFF_MS * 2 ** (failures - 1), POLL_READ_BACKOFF_CAP_MS);
77
+ }
78
+ /** The plan summary an operator confirms, one line per row. */
79
+ export function summariseIngestPlan(plan) {
80
+ const lines = plan.models.map((model) => ` ${model.model}: ${model.rows} rows, ${model.chunks} chunks, ` +
81
+ `${model.bytes} bytes` +
82
+ (model.deletes > 0 ? `, ${model.deletes} deletes` : ""));
83
+ return [
84
+ `${plan.rows} rows across ${plan.models.length} model(s), ` +
85
+ `${plan.chunks.length} chunks, ${plan.bytes} bytes` +
86
+ (plan.deletes > 0 ? `, ${plan.deletes} deletes` : ""),
87
+ ...lines,
88
+ ];
89
+ }
90
+ /**
91
+ * Refuse a run that cannot ask, before it asks the server anything.
92
+ *
93
+ * A bulk load deletes and overwrites a live document's records with no undo,
94
+ * which is what the CLI design's destructive default is for. A pipeline that
95
+ * meant to run one says so with `-y`.
96
+ */
97
+ export function assertIngestConfirmable(options) {
98
+ if (options.yes || options.isTTY)
99
+ return;
100
+ throw new IngestRefusedError("A bulk load replaces records in a live document and cannot be undone. " +
101
+ "Re-run with -y to confirm it without a prompt.");
102
+ }
103
+ export async function driveDocumentIngest(options) {
104
+ const { client, documentId, plan, concurrency = 4, wait = true, timeoutMs = null, signal, onProgress = () => { }, readChunk = async (chunk) => fs.readFileSync(chunk.file), now = () => Date.now(), sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), } = options;
105
+ // A phase appears only once it has FINISHED (#3598). A create that threw
106
+ // cost time, but not a measurable amount of anything an operator can act
107
+ // on; half an upload has no rate; and a phase the run never reached has
108
+ // nothing to say rather than a zero to say it with.
109
+ const timings = {};
110
+ /** A whole number of milliseconds, never negative. */
111
+ const since = (at) => Math.max(0, now() - at);
112
+ // ── create ──
113
+ let session;
114
+ const createdAt = now();
115
+ try {
116
+ session = await client.createIngest(documentId);
117
+ }
118
+ catch (error) {
119
+ if (error?.code === "DOCUMENT_INGEST_ACTIVE") {
120
+ const active = (error.details && error.details.sessionId) ?? "the active session";
121
+ return {
122
+ exitCode: 1,
123
+ sessionId: null,
124
+ session: null,
125
+ timings,
126
+ message: `${error.message}\nThis document already has bulk load ${active}. ` +
127
+ `Watch it with \`primitive documents ingests get ${documentId} ${active}\`, ` +
128
+ `or give it up with \`primitive documents ingests abort\`.`,
129
+ };
130
+ }
131
+ return {
132
+ exitCode: 1,
133
+ sessionId: null,
134
+ session: null,
135
+ timings,
136
+ message: String(error?.message ?? error),
137
+ };
138
+ }
139
+ timings.createMs = since(createdAt);
140
+ const sessionId = String(session.sessionId);
141
+ onProgress(`Session ${sessionId} opened.`);
142
+ const giveUp = async (message, exitCode) => {
143
+ try {
144
+ await client.abortIngest(documentId, sessionId);
145
+ onProgress(`Session ${sessionId} aborted; nothing was applied.`);
146
+ }
147
+ catch (error) {
148
+ onProgress(`Session ${sessionId} could not be aborted: ${error?.message ?? error}`);
149
+ }
150
+ return { exitCode, sessionId, session: null, timings, message };
151
+ };
152
+ // ── upload ──
153
+ const uploadStartedAt = now();
154
+ const queue = [...plan.chunks];
155
+ let uploaded = 0;
156
+ let failure = null;
157
+ const worker = async () => {
158
+ for (;;) {
159
+ if (failure !== null || signal?.aborted)
160
+ return;
161
+ const chunk = queue.shift();
162
+ if (!chunk)
163
+ return;
164
+ try {
165
+ const body = await readChunk(chunk);
166
+ await client.uploadIngestChunk(documentId, sessionId, { ...chunk, body });
167
+ uploaded += 1;
168
+ onProgress(`Uploaded ${uploaded}/${plan.chunks.length} chunks ` +
169
+ `(${chunk.model} ${chunk.index}).`);
170
+ }
171
+ catch (error) {
172
+ // The first failure wins: the others are the same session going away.
173
+ if (failure === null)
174
+ failure = String(error?.message ?? error);
175
+ return;
176
+ }
177
+ }
178
+ };
179
+ await Promise.all(Array.from({ length: Math.max(1, Math.min(concurrency, queue.length || 1)) }, worker));
180
+ if (failure !== null)
181
+ return giveUp(failure, 1);
182
+ if (signal?.aborted) {
183
+ return giveUp("Interrupted while uploading; the session was aborted and nothing was applied.", 130);
184
+ }
185
+ // Every chunk is up, so there is a rate to state. It is measured over the
186
+ // PLAN's stored chunk sizes — what actually went over the wire — rather
187
+ // than over the decompressed total, which is not what was sent.
188
+ const uploadMs = since(uploadStartedAt);
189
+ const uploadedBytes = plan.chunks.reduce((sum, chunk) => sum + chunk.bytes, 0);
190
+ timings.uploadMs = uploadMs;
191
+ timings.uploadedBytes = uploadedBytes;
192
+ onProgress(`Uploaded ${plan.chunks.length} chunks (${uploadedBytes} bytes) in ` +
193
+ `${seconds(uploadMs)}` +
194
+ (uploadMs > 0 ? ` (${megabytesPerSecond(uploadedBytes, uploadMs)}).` : "."));
195
+ // ── commit ──
196
+ const committedAt = now();
197
+ try {
198
+ session = await client.commitIngest(documentId, sessionId);
199
+ }
200
+ catch (error) {
201
+ return giveUp(String(error?.message ?? error), 1);
202
+ }
203
+ const commitMs = since(committedAt);
204
+ timings.commitMs = commitMs;
205
+ onProgress(`Session ${sessionId} committed.`);
206
+ onProgress(`Committed in ${seconds(commitMs)}.`);
207
+ if (!wait) {
208
+ // Nothing was waited for, so the wait is zero rather than unknown: the
209
+ // session keeps running and `ingests get` is where its own time is.
210
+ timings.waitMs = 0;
211
+ return { exitCode: 0, sessionId, session, timings, message: undefined };
212
+ }
213
+ // ── poll ──
214
+ //
215
+ // Past this point the session is the server's business: the copy has begun
216
+ // and the document's tables will be swapped whatever this process does. So
217
+ // neither a timeout nor a Ctrl-C nor a read that keeps failing aborts it —
218
+ // each says so and leaves.
219
+ const started = now();
220
+ let reported = null;
221
+ let reportedProgress = "";
222
+ // The current run of consecutive failed reads: how many, when it started on
223
+ // the injected clock, and the last thing the server said. All three reset on
224
+ // any read that answers.
225
+ let readFailures = 0;
226
+ let failingSince = 0;
227
+ let lastReadError = "";
228
+ const stillRunning = () => `The bulk load is still running on the server; read it with ` +
229
+ `\`primitive documents ingests get ${documentId} ${sessionId}\`.`;
230
+ // Every door out of the WATCHING records the wait it is ending (#3598): the
231
+ // time was really spent on the server whichever way the watching stopped,
232
+ // and a load that gave up is exactly when somebody needs that number.
233
+ const interrupted = (view) => {
234
+ timings.waitMs = since(started);
235
+ return {
236
+ exitCode: 130,
237
+ sessionId,
238
+ session: view,
239
+ timings,
240
+ message: `Interrupted. The session keeps running; watch it with ` +
241
+ `\`primitive documents ingests get ${documentId} ${sessionId}\`.`,
242
+ };
243
+ };
244
+ const timedOut = (view, elapsed) => {
245
+ timings.waitMs = elapsed;
246
+ return {
247
+ exitCode: 124,
248
+ sessionId,
249
+ session: view,
250
+ timings,
251
+ message: `Gave up waiting after ${Math.round(elapsed / 1000)}s. The session ` +
252
+ `keeps running; watch it with \`primitive documents ingests get ` +
253
+ `${documentId} ${sessionId}\`.`,
254
+ };
255
+ };
256
+ for (;;) {
257
+ let view;
258
+ try {
259
+ view = await client.getIngest(documentId, sessionId);
260
+ if (readFailures > 0) {
261
+ onProgress(`Session ${sessionId} answered again after ${readFailures} ` +
262
+ `unanswered read(s); polling resumed.`);
263
+ readFailures = 0;
264
+ lastReadError = "";
265
+ }
266
+ }
267
+ catch (error) {
268
+ const message = String(error?.message ?? error);
269
+ // A refusal is a refusal: it is reported now, exactly as before — and
270
+ // it still carries the wait that preceded it (finding 3598-FROZEN-01),
271
+ // because a load that polled for minutes before the reads stopped
272
+ // answering really did spend those minutes waiting on the server.
273
+ if (!isTransientReadError(error)) {
274
+ timings.waitMs = since(started);
275
+ return { exitCode: 1, sessionId, session: null, timings, message };
276
+ }
277
+ if (readFailures === 0)
278
+ failingSince = now();
279
+ readFailures += 1;
280
+ lastReadError = message;
281
+ const failingFor = now() - failingSince;
282
+ if (failingFor >= POLL_READ_RETRY_WINDOW_MS) {
283
+ // 124, the documented "a wait that gave up" code — never 1. Giving up
284
+ // on the watching is not the load failing, and the operator has to be
285
+ // able to tell them apart by the exit code alone.
286
+ timings.waitMs = since(started);
287
+ return {
288
+ exitCode: 124,
289
+ sessionId,
290
+ session: null,
291
+ timings,
292
+ message: `Stopped watching after ${Math.round(failingFor / 1000)}s of ` +
293
+ `unanswered session reads (${readFailures} attempts). ` +
294
+ `${stillRunning()} Last read error: ${lastReadError}`,
295
+ };
296
+ }
297
+ onProgress(`Session ${sessionId} did not answer (attempt ${readFailures}, ` +
298
+ `unanswered for ${Math.round(failingFor / 1000)}s); retrying` +
299
+ (readFailures === 1 ? `: ${message}` : "."));
300
+ await sleep(readBackoffMs(readFailures));
301
+ // The backoff sleep is part of the wait, so it honours the same two
302
+ // doors the success path does and with the same words: neither aborts.
303
+ if (signal?.aborted)
304
+ return interrupted(null);
305
+ const waited = now() - started;
306
+ if (timeoutMs !== null && waited >= timeoutMs)
307
+ return timedOut(null, waited);
308
+ continue;
309
+ }
310
+ if (view?.state !== reported) {
311
+ reported = view?.state ?? null;
312
+ onProgress(`Session ${sessionId} is ${reported}.`);
313
+ }
314
+ const progress = describeProgress(view?.progress);
315
+ if (progress && progress !== reportedProgress) {
316
+ reportedProgress = progress;
317
+ onProgress(` ${progress}`);
318
+ }
319
+ if (view?.state === "complete") {
320
+ const waitMs = since(started);
321
+ timings.waitMs = waitMs;
322
+ // What the PLATFORM spent, separable from what this side did. The
323
+ // session's own `timings` say where inside the platform it went.
324
+ onProgress(`Server finished in ${seconds(waitMs)}.`);
325
+ return { exitCode: 0, sessionId, session: view, timings };
326
+ }
327
+ if (view?.state === "failed" || view?.state === "aborted") {
328
+ const waitMs = since(started);
329
+ timings.waitMs = waitMs;
330
+ onProgress(`Server finished in ${seconds(waitMs)}.`);
331
+ return {
332
+ exitCode: 1,
333
+ sessionId,
334
+ session: view,
335
+ timings,
336
+ message: describeFailure(view),
337
+ };
338
+ }
339
+ const elapsed = now() - started;
340
+ if (timeoutMs !== null && elapsed >= timeoutMs)
341
+ return timedOut(view, elapsed);
342
+ await sleep(elapsed >= POLL_SLOWS_AFTER_MS ? POLL_SLOW_MS : POLL_FAST_MS);
343
+ if (signal?.aborted)
344
+ return interrupted(view);
345
+ }
346
+ }
347
+ /** A duration an operator reads at a glance, never a bare millisecond count. */
348
+ function seconds(ms) {
349
+ return ms < 1000 ? `${Math.round(ms)}ms` : `${(ms / 1000).toFixed(1)}s`;
350
+ }
351
+ /** The unit a bulk load's speed is discussed in. */
352
+ function megabytesPerSecond(bytes, ms) {
353
+ return `${((bytes / 1_000_000 / ms) * 1000).toFixed(2)} MB/s`;
354
+ }
355
+ /** The session's own words for why it stopped. */
356
+ function describeFailure(view) {
357
+ if (view?.state === "aborted")
358
+ return "The session was aborted.";
359
+ const failure = view?.failure;
360
+ if (!failure)
361
+ return "The session failed.";
362
+ // A failure's rows are `{ model, id }` on the wire, and a bounded sample of
363
+ // them; a string is accepted too so a stub or an older server still reads.
364
+ const rows = Array.isArray(failure.rows) && failure.rows.length > 0
365
+ ? `\n ${failure.rows
366
+ .map((row) => typeof row === "string" ? row : `${row?.model} ${row?.id}`)
367
+ .join("\n ")}`
368
+ : "";
369
+ return `${failure.code}: ${failure.reason}${rows}`;
370
+ }
371
+ /** One line of counters, or nothing while they are all still zero. */
372
+ function describeProgress(progress) {
373
+ if (!progress)
374
+ return "";
375
+ const copied = progress.rowsCopied ?? 0;
376
+ const chunks = progress.chunksApplied ?? 0;
377
+ const rows = progress.rowsApplied ?? 0;
378
+ const reconciled = progress.recordsReconciled ?? 0;
379
+ if (copied + chunks + rows + reconciled === 0)
380
+ return "";
381
+ return (`copied ${copied} rows, applied ${chunks} chunks / ${rows} rows, ` +
382
+ `reconciled ${reconciled} records`);
383
+ }
384
+ //# sourceMappingURL=document-ingest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-ingest.js","sourceRoot":"","sources":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AC,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;QACpD,CAAC,CAAC,OAAO,OAAO,CAAC,IAAI;aAChB,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CAChB,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,IAAI,GAAG,EAAE,EAAE,EAAE,CAC3D;aACA,IAAI,CAAC,MAAM,CAAC,EAAE;QACnB,CAAC,CAAC,EAAE,CAAC;IACT,OAAO,GAAG,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC;AACrD,CAAC;AAED,sEAAsE;AACtE,SAAS,gBAAgB,CAAC,QAAa;IACrC,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,CAAC;IACzB,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,IAAI,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,IAAI,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,IAAI,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,QAAQ,CAAC,iBAAiB,IAAI,CAAC,CAAC;IACnD,IAAI,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,UAAU,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACzD,OAAO,CACL,UAAU,MAAM,kBAAkB,MAAM,aAAa,IAAI,SAAS;QAClE,cAAc,UAAU,UAAU,CACnC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,258 @@
1
+ /**
2
+ * The shared Primitive environment resolver (#2873).
3
+ *
4
+ * Three surfaces have to agree on which backend/app a project is pointed at:
5
+ * the CLI, the Vue build (`primitive-app`'s `primitiveEnv()` plugin), and the
6
+ * Swift template's pre-build script. This module is the single algorithm they
7
+ * share. The CLI owns it; `packages/primitive-app` carries a byte-identical
8
+ * GENERATED copy (`cli/scripts/gen-primitive-env-resolver.mjs`, checked for
9
+ * freshness by `cli/tests/unit/env-resolver-copy-drift-guard.test.ts`); the
10
+ * Swift script is an independent bash+python3 port pinned by a parity test.
11
+ *
12
+ * ── COPYABILITY (load-bearing) ────────────────────────────────────────────
13
+ * This file MUST stay self-contained: node builtins only, ZERO relative
14
+ * imports. The generator copies it verbatim into a package that cannot depend
15
+ * on the CLI, so any `./x.js` import here would break that copy at runtime.
16
+ * The drift guard asserts this.
17
+ *
18
+ * Scope: config discovery, the schema `version` check, structural validation,
19
+ * the local selection, the precedence, and the http→ws scheme swap. It
20
+ * deliberately does NOT duplicate the CLI's full field-level validation
21
+ * (`validateProjectConfig` in `project-config.ts`) — the CLI wrapper runs that
22
+ * first, and the other readers only need "version understood, shape sane, fail
23
+ * loudly otherwise".
24
+ *
25
+ * Precedence (one order, everywhere):
26
+ * 1. an explicit name (`--env` / `--primitive-env`)
27
+ * 2. PRIMITIVE_ENV (per-invocation intent, keeps CI working)
28
+ * 3. .primitive/local.json (this machine's `primitive env use`)
29
+ * 4. defaultEnvironment (the committed team default)
30
+ * 5. the sole environment, if there is exactly one
31
+ */
32
+ /** Schema version of `primitive/config.json` this core understands. */
33
+ export declare const PRIMITIVE_CONFIG_VERSION = 1;
34
+ /** Schema version of `.primitive/local.json` this core writes and reads. */
35
+ export declare const PRIMITIVE_LOCAL_STATE_VERSION = 1;
36
+ /**
37
+ * The two directories, split apart by #3153 so one name never means two
38
+ * things: `primitive/` is the COMMITTED tree (the config and every
39
+ * environment's TOML), `.primitive/` is MACHINE-LOCAL state (credentials, this
40
+ * machine's selection, snapshot backups) and is gitignored whole.
41
+ */
42
+ export declare const PROJECT_TREE_DIR = "primitive";
43
+ export declare const PROJECT_LOCAL_STATE_DIR = ".primitive";
44
+ export declare const PROJECT_CONFIG_FILENAME = "config.json";
45
+ export declare const LOCAL_STATE_FILENAME = "local.json";
46
+ export declare const PROJECT_CONFIG_DISPLAY_NAME = "primitive/config.json";
47
+ export declare const LOCAL_STATE_DISPLAY_NAME = ".primitive/local.json";
48
+ /**
49
+ * The one refusal for a project that never migrated off the pre-#3153 layout:
50
+ * a `.primitive/config.json` with no `primitive/config.json` beside it.
51
+ *
52
+ * That shape is refused rather than walked past because the walk's next stop
53
+ * is the parent directory, and in a nested checkout the parent may be a
54
+ * DIFFERENT project — a command run in the unmigrated one would silently act
55
+ * on the other's app. Nothing else is refused (#3392): anything left under
56
+ * `.primitive/` beside a migrated tree is machine-local junk, not signal.
57
+ *
58
+ * One sentence, naming both halves — the file that was found and the file
59
+ * that is expected — and no document. The migration page this once pointed
60
+ * at was never published (#3155, won't-fix), and every reader that shares
61
+ * this refusal — this core, the generated Vite-plugin copy, the Swift
62
+ * pre-build script, the Vue template's deploy script — says the same thing.
63
+ */
64
+ export declare function unmigratedProjectMessage(found: string, expected: string): string;
65
+ /**
66
+ * The one refusal for a command run outside a Primitive project (#3154,
67
+ * intent criterion 5).
68
+ *
69
+ * There is exactly one way to resolve the configuration tree, the credentials
70
+ * and the app: the environment named by `primitive/config.json`. Outside a
71
+ * project there is no such thing, and the CLI says so once, in these words,
72
+ * wherever the question is asked — the resolver core, the CLI's
73
+ * `requireCurrentEnvironment()`, and the credentials store.
74
+ *
75
+ * Two constraints on the wording, both test-asserted:
76
+ *
77
+ * - it names `primitive init`, the one command that creates what is missing;
78
+ * - it never names `primitive env add`, which after this change also fails
79
+ * outside a project — an error may only offer an invocation it does not
80
+ * itself block.
81
+ */
82
+ export declare function missingConfigMessage(where: string): string;
83
+ /**
84
+ * Error kinds callers branch on. Every failure is one of these — no reader is
85
+ * ever left guessing what a broken config meant.
86
+ */
87
+ export type PrimitiveEnvErrorKind = "missing-config" | "malformed-config" | "unsupported-version" | "corrupt-local-state" | "unknown-environment" | "no-selection" | "missing-app-id" | "stale-layout";
88
+ export declare class PrimitiveEnvError extends Error {
89
+ readonly kind: PrimitiveEnvErrorKind;
90
+ readonly path?: string;
91
+ constructor(kind: PrimitiveEnvErrorKind, message: string, path?: string);
92
+ }
93
+ export interface CoreEnvironmentEntry {
94
+ apiUrl: string;
95
+ /**
96
+ * The one app this environment names (#3152). Required: selecting an
97
+ * environment selects exactly one app, so there is no per-machine "current
98
+ * app" for a second reader to disagree with.
99
+ */
100
+ appId: string;
101
+ appName?: string;
102
+ /**
103
+ * The app's web counterpart for this environment, as a normalized origin
104
+ * (#2982). Read through `normalizeWebOrigin`, so a value this reader carries
105
+ * is always an origin — see that function for why the typed read other
106
+ * fields get is not enough here.
107
+ */
108
+ webUrl?: string;
109
+ description?: string;
110
+ }
111
+ /**
112
+ * The app's web counterpart as a normalized ORIGIN, or undefined when the
113
+ * value cannot be one (#2982).
114
+ *
115
+ * Unlike `appId`/`appName`, a typed read is not enough. This value is not
116
+ * merely carried: the Swift app points its emailed sign-in link at
117
+ * `<webUrl>/oauth/callback` and trusts incoming universal links from the same
118
+ * origin, and BOTH jobs need an origin —
119
+ *
120
+ * - https except loopback, the rule the server applies to every redirect URI
121
+ * (`src/auth/redirect-uri.ts`): an origin that cannot be allow-listed turns
122
+ * every sign-in request into a 400, and a plain-http link would carry the
123
+ * magic token in clear;
124
+ * - no path, query or fragment: the web client serves its callback on its own
125
+ * origin plus `/oauth/callback`, which is also the exact path the
126
+ * `apple-app-site-association` component claims;
127
+ * - no credentials, which have no business in a link that goes out by email.
128
+ *
129
+ * `primitive env add --web-url` and the project-config validation reject those
130
+ * shapes with a field-named error, but neither is on the path from a
131
+ * hand-edited `primitive/config.json` to an Xcode build: the Swift template's
132
+ * pre-build script reads the file directly. So every reader that feeds
133
+ * `primitive.json` applies the contract, and a value that misses it is read as
134
+ * "this environment has no web counterpart" — code-only email, no trusted
135
+ * origin, nothing silently pointed at the wrong URL.
136
+ *
137
+ * The message-producing twin of this rule lives in `cli/src/lib/web-url.ts`;
138
+ * this file cannot import it (see COPYABILITY above), and a test pins that the
139
+ * two agree.
140
+ */
141
+ export declare function normalizeWebOrigin(value: unknown): string | undefined;
142
+ /**
143
+ * The one remedy for an environment that names no app (#3152), shared by every
144
+ * reader that can hit it: this core, the CLI's `validateProjectConfig`, the
145
+ * Swift template's pre-build script, and the Vue template's cf-deploy.
146
+ *
147
+ * Two constraints on the wording, both test-asserted:
148
+ *
149
+ * - it never says `primitive env add <name>`, which REFUSES an environment
150
+ * name that already exists — the shape this error is always about;
151
+ * - it names no command the failure itself blocks. The CLI validates the
152
+ * project config before any command parses, so every `primitive` command
153
+ * run inside the broken project fails with this same error. The only
154
+ * invocation it may offer is one it says out loud to run elsewhere.
155
+ */
156
+ export declare function missingAppIdMessage(name: string, configPath?: string): string;
157
+ export interface CoreProjectConfig {
158
+ version: number;
159
+ defaultEnvironment?: string;
160
+ environments: Record<string, CoreEnvironmentEntry>;
161
+ }
162
+ /** Which precedence step picked the environment. Printed in the build banner. */
163
+ export type PrimitiveEnvSource = "explicit" | "env-var" | "local" | "default" | "sole";
164
+ export interface ResolvedPrimitiveEnv {
165
+ name: string;
166
+ apiUrl: string;
167
+ /** Derived from apiUrl by scheme swap — never authored separately. */
168
+ wsUrl: string;
169
+ /** The app this environment names. Always present — see #3152. */
170
+ appId: string;
171
+ appName?: string;
172
+ /** The app's web counterpart for the SELECTED environment, if it has one. */
173
+ webUrl?: string;
174
+ description?: string;
175
+ source: PrimitiveEnvSource;
176
+ configPath: string;
177
+ localStatePath: string;
178
+ projectRoot: string;
179
+ }
180
+ export interface ResolveOptions {
181
+ /** Directory to start the upward walk from. Defaults to process.cwd(). */
182
+ cwd?: string;
183
+ /** Environment variables to read. Defaults to process.env. */
184
+ env?: Record<string, string | undefined>;
185
+ /** An explicit `--env` / `--primitive-env` value, if the caller has one. */
186
+ explicitEnvName?: string | null;
187
+ /** Use this config file instead of discovering one. */
188
+ configPath?: string;
189
+ }
190
+ /**
191
+ * Derives the WebSocket URL from the API URL. Every apiUrl/wsUrl pair in
192
+ * practice is the same host with the scheme swapped, so it is derived rather
193
+ * than authored — one less thing to get out of sync.
194
+ */
195
+ export declare function deriveWsUrl(apiUrl: string): string;
196
+ /**
197
+ * Finds `primitive/config.json` by walking up from `cwd`, or returns the
198
+ * PRIMITIVE_PROJECT_CONFIG override when it is set (and exists).
199
+ *
200
+ * The override is checked for provenance BEFORE the file is read (#3153, F2):
201
+ * it bypasses the walk, so without this an old-layout config could be handed
202
+ * straight to a reader and defeat the cutover. An override that points inside
203
+ * a `.primitive/` directory IS the old layout, named explicitly.
204
+ *
205
+ * This is the one function every reader goes through — `resolvePrimitiveEnv`
206
+ * and the CLI's own `loadProjectConfig`/`findProjectRoot` alike — so the
207
+ * unmigrated-project refusal lives HERE, in the walk, or the commands that
208
+ * never call `resolvePrimitiveEnv` would walk past the old anchor into the
209
+ * parent directory's project.
210
+ */
211
+ export declare function findPrimitiveConfigPath(options?: {
212
+ cwd?: string;
213
+ env?: Record<string, string | undefined>;
214
+ }): string | null;
215
+ /**
216
+ * The project root for a config path: the parent of `primitive/`, or the
217
+ * containing directory when the config was pointed at directly (a fixture via
218
+ * PRIMITIVE_PROJECT_CONFIG, which is not inside a `primitive/` directory).
219
+ */
220
+ export declare function projectRootForConfigPath(configPath: string): string;
221
+ /**
222
+ * Machine-local state lives under the project root's `.primitive/`, not beside
223
+ * the config — the config is committed now, and the two must not share a
224
+ * directory. A fixture-pointed bare config still gets its own `.primitive/`
225
+ * in its own directory, so it never picks up a real project's selection.
226
+ */
227
+ export declare function localStatePathForConfigPath(configPath: string): string;
228
+ /**
229
+ * Reads and structurally validates `primitive/config.json`. Throws rather
230
+ * than guessing: a config that cannot be understood is always louder than a
231
+ * silent fallback to the wrong backend.
232
+ */
233
+ export declare function readCoreProjectConfig(configPath: string): CoreProjectConfig;
234
+ /**
235
+ * Reads this machine's selection from `.primitive/local.json`. Returns null
236
+ * when there is no file or no selection in it; throws when the file exists but
237
+ * cannot be read as the shape `primitive env use` writes.
238
+ */
239
+ export declare function readLocalSelection(configPath: string): string | null;
240
+ /**
241
+ * Applies the precedence to an already-loaded config. Exposed separately so
242
+ * the CLI wrapper can run its own field-level validation first and still share
243
+ * one ordering with every other reader.
244
+ */
245
+ export declare function selectEnvironmentName(config: CoreProjectConfig, options: {
246
+ explicitEnvName?: string | null;
247
+ envVarName?: string | null;
248
+ localSelection?: string | null;
249
+ configPath?: string;
250
+ }): {
251
+ name: string;
252
+ source: PrimitiveEnvSource;
253
+ };
254
+ /**
255
+ * The whole algorithm end to end: discover the config, read the selection,
256
+ * apply the precedence, derive the WebSocket URL.
257
+ */
258
+ export declare function resolvePrimitiveEnv(options?: ResolveOptions): ResolvedPrimitiveEnv;