primitive-admin 1.2.0-alpha.1 → 1.2.0-alpha.11

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 (410) hide show
  1. package/README.md +105 -134
  2. package/assets/skill/skills/primitive-platform/SKILL.md +37 -4
  3. package/dist/bin/primitive.js +30 -35
  4. package/dist/bin/primitive.js.map +1 -1
  5. package/dist/src/commands/agent-sessions.d.ts +133 -0
  6. package/dist/src/commands/agent-sessions.js +792 -0
  7. package/dist/src/commands/agent-sessions.js.map +1 -0
  8. package/dist/src/commands/analytics.js +0 -148
  9. package/dist/src/commands/analytics.js.map +1 -1
  10. package/dist/src/commands/apps-children.d.ts +54 -0
  11. package/dist/src/commands/apps-children.js +631 -0
  12. package/dist/src/commands/apps-children.js.map +1 -0
  13. package/dist/src/commands/apps.d.ts +6 -0
  14. package/dist/src/commands/apps.js +131 -9
  15. package/dist/src/commands/apps.js.map +1 -1
  16. package/dist/src/commands/auth-sessions.d.ts +3 -3
  17. package/dist/src/commands/auth-sessions.js +117 -23
  18. package/dist/src/commands/auth-sessions.js.map +1 -1
  19. package/dist/src/commands/auth.js +460 -36
  20. package/dist/src/commands/auth.js.map +1 -1
  21. package/dist/src/commands/collections.js +316 -256
  22. package/dist/src/commands/collections.js.map +1 -1
  23. package/dist/src/commands/config.d.ts +1 -1
  24. package/dist/src/commands/config.js +60 -28
  25. package/dist/src/commands/config.js.map +1 -1
  26. package/dist/src/commands/connections.js +11 -12
  27. package/dist/src/commands/connections.js.map +1 -1
  28. package/dist/src/commands/database-type-configs.js +2 -76
  29. package/dist/src/commands/database-type-configs.js.map +1 -1
  30. package/dist/src/commands/databases.d.ts +9 -0
  31. package/dist/src/commands/databases.js +221 -457
  32. package/dist/src/commands/databases.js.map +1 -1
  33. package/dist/src/commands/db3-types.d.ts +15 -0
  34. package/dist/src/commands/db3-types.js +157 -0
  35. package/dist/src/commands/db3-types.js.map +1 -0
  36. package/dist/src/commands/db3.d.ts +12 -0
  37. package/dist/src/commands/db3.js +1052 -0
  38. package/dist/src/commands/db3.js.map +1 -0
  39. package/dist/src/commands/documents.d.ts +121 -2
  40. package/dist/src/commands/documents.js +1601 -1251
  41. package/dist/src/commands/documents.js.map +1 -1
  42. package/dist/src/commands/env.d.ts +9 -1
  43. package/dist/src/commands/env.js +164 -49
  44. package/dist/src/commands/env.js.map +1 -1
  45. package/dist/src/commands/function-trigger-commands.d.ts +28 -0
  46. package/dist/src/commands/function-trigger-commands.js +341 -0
  47. package/dist/src/commands/function-trigger-commands.js.map +1 -0
  48. package/dist/src/commands/functions.js +297 -24
  49. package/dist/src/commands/functions.js.map +1 -1
  50. package/dist/src/commands/groups.js +150 -49
  51. package/dist/src/commands/groups.js.map +1 -1
  52. package/dist/src/commands/guides.js +5 -5
  53. package/dist/src/commands/init.d.ts +7 -0
  54. package/dist/src/commands/init.js +23 -5
  55. package/dist/src/commands/init.js.map +1 -1
  56. package/dist/src/commands/integrations.js +14 -8
  57. package/dist/src/commands/integrations.js.map +1 -1
  58. package/dist/src/commands/metadata-category-configs.d.ts +2 -2
  59. package/dist/src/commands/metadata-category-configs.js +2 -2
  60. package/dist/src/commands/prompts.d.ts +7 -0
  61. package/dist/src/commands/prompts.js +48 -5
  62. package/dist/src/commands/prompts.js.map +1 -1
  63. package/dist/src/commands/scripts.d.ts +9 -17
  64. package/dist/src/commands/scripts.js +24 -479
  65. package/dist/src/commands/scripts.js.map +1 -1
  66. package/dist/src/commands/sync-app-settings.d.ts +36 -8
  67. package/dist/src/commands/sync-app-settings.js +109 -23
  68. package/dist/src/commands/sync-app-settings.js.map +1 -1
  69. package/dist/src/commands/sync.d.ts +360 -610
  70. package/dist/src/commands/sync.js +3151 -6697
  71. package/dist/src/commands/sync.js.map +1 -1
  72. package/dist/src/commands/tokens.js +3 -3
  73. package/dist/src/commands/tokens.js.map +1 -1
  74. package/dist/src/commands/users.js +77 -2
  75. package/dist/src/commands/users.js.map +1 -1
  76. package/dist/src/commands/workflows.d.ts +5 -83
  77. package/dist/src/commands/workflows.js +57 -2282
  78. package/dist/src/commands/workflows.js.map +1 -1
  79. package/dist/src/lib/aggregate-output.d.ts +25 -0
  80. package/dist/src/lib/aggregate-output.js +53 -0
  81. package/dist/src/lib/aggregate-output.js.map +1 -0
  82. package/dist/src/lib/api-client.d.ts +681 -551
  83. package/dist/src/lib/api-client.js +880 -814
  84. package/dist/src/lib/api-client.js.map +1 -1
  85. package/dist/src/lib/app-settings-descriptor.d.ts +47 -1
  86. package/dist/src/lib/app-settings-descriptor.js +114 -10
  87. package/dist/src/lib/app-settings-descriptor.js.map +1 -1
  88. package/dist/src/lib/auth-fixtures.d.ts +44 -0
  89. package/dist/src/lib/auth-fixtures.js +61 -0
  90. package/dist/src/lib/auth-fixtures.js.map +1 -0
  91. package/dist/src/lib/auth-flow.d.ts +41 -1
  92. package/dist/src/lib/auth-flow.js +70 -16
  93. package/dist/src/lib/auth-flow.js.map +1 -1
  94. package/dist/src/lib/block-layout.d.ts +12 -23
  95. package/dist/src/lib/block-layout.js +26 -92
  96. package/dist/src/lib/block-layout.js.map +1 -1
  97. package/dist/src/lib/block-selector.d.ts +2 -2
  98. package/dist/src/lib/block-selector.js +2 -2
  99. package/dist/src/lib/child-apps-local.d.ts +164 -0
  100. package/dist/src/lib/child-apps-local.js +258 -0
  101. package/dist/src/lib/child-apps-local.js.map +1 -0
  102. package/dist/src/lib/ci-session-request.d.ts +22 -0
  103. package/dist/src/lib/ci-session-request.js +51 -0
  104. package/dist/src/lib/ci-session-request.js.map +1 -0
  105. package/dist/src/lib/codegen-shared/generatedFiles.d.ts +10 -8
  106. package/dist/src/lib/codegen-shared/generatedFiles.js +21 -15
  107. package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -1
  108. package/dist/src/lib/codegen-shared/prettierStable.d.ts +1 -1
  109. package/dist/src/lib/codegen-shared/prettierStable.js +1 -1
  110. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +2 -2
  111. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +2 -2
  112. package/dist/src/lib/collection-export.d.ts +76 -15
  113. package/dist/src/lib/collection-export.js +116 -23
  114. package/dist/src/lib/collection-export.js.map +1 -1
  115. package/dist/src/lib/collection-principal.d.ts +22 -0
  116. package/dist/src/lib/collection-principal.js +35 -0
  117. package/dist/src/lib/collection-principal.js.map +1 -0
  118. package/dist/src/lib/config-object-descriptor.d.ts +3 -22
  119. package/dist/src/lib/config-object-descriptor.js +56 -290
  120. package/dist/src/lib/config-object-descriptor.js.map +1 -1
  121. package/dist/src/lib/config-payload.js +2 -3
  122. package/dist/src/lib/config-payload.js.map +1 -1
  123. package/dist/src/lib/config-surface.d.ts +5 -7
  124. package/dist/src/lib/config-surface.js +18 -40
  125. package/dist/src/lib/config-surface.js.map +1 -1
  126. package/dist/src/lib/connections-list.d.ts +10 -0
  127. package/dist/src/lib/connections-list.js +18 -0
  128. package/dist/src/lib/connections-list.js.map +1 -0
  129. package/dist/src/lib/credentials-home.d.ts +58 -0
  130. package/dist/src/lib/credentials-home.js +204 -0
  131. package/dist/src/lib/credentials-home.js.map +1 -0
  132. package/dist/src/lib/credentials-lock.d.ts +88 -0
  133. package/dist/src/lib/credentials-lock.js +302 -0
  134. package/dist/src/lib/credentials-lock.js.map +1 -0
  135. package/dist/src/lib/credentials-store.d.ts +179 -24
  136. package/dist/src/lib/credentials-store.js +712 -77
  137. package/dist/src/lib/credentials-store.js.map +1 -1
  138. package/dist/src/lib/csv.d.ts +8 -9
  139. package/dist/src/lib/csv.js +3 -4
  140. package/dist/src/lib/csv.js.map +1 -1
  141. package/dist/src/lib/custodian.d.ts +8 -0
  142. package/dist/src/lib/custodian.js +18 -0
  143. package/dist/src/lib/custodian.js.map +1 -0
  144. package/dist/src/lib/db-codegen/dbGenerator.js +5 -16
  145. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -1
  146. package/dist/src/lib/db-codegen/dbNaming.d.ts +5 -13
  147. package/dist/src/lib/db-codegen/dbNaming.js +5 -17
  148. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -1
  149. package/dist/src/lib/db-codegen/dbTemplates.d.ts +7 -56
  150. package/dist/src/lib/db-codegen/dbTemplates.js +25 -125
  151. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -1
  152. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +2 -2
  153. package/dist/src/lib/db-codegen/dbTsTypes.js +2 -2
  154. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +67 -2
  155. package/dist/src/lib/db-codegen/dbTypeIR.js +13 -2
  156. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
  157. package/dist/src/lib/db3-export.d.ts +231 -0
  158. package/dist/src/lib/db3-export.js +510 -0
  159. package/dist/src/lib/db3-export.js.map +1 -0
  160. package/dist/src/lib/db3-index-output.d.ts +27 -0
  161. package/dist/src/lib/db3-index-output.js +49 -0
  162. package/dist/src/lib/db3-index-output.js.map +1 -0
  163. package/dist/src/lib/document-export-lookups.d.ts +31 -0
  164. package/dist/src/lib/document-export-lookups.js +53 -0
  165. package/dist/src/lib/document-export-lookups.js.map +1 -0
  166. package/dist/src/lib/document-export-permissions.d.ts +7 -5
  167. package/dist/src/lib/document-export-permissions.js +7 -5
  168. package/dist/src/lib/document-export-permissions.js.map +1 -1
  169. package/dist/src/lib/document-export-record-log.d.ts +57 -0
  170. package/dist/src/lib/document-export-record-log.js +215 -0
  171. package/dist/src/lib/document-export-record-log.js.map +1 -0
  172. package/dist/src/lib/document-ingest-artifact.d.ts +26 -2
  173. package/dist/src/lib/document-ingest-artifact.js +42 -8
  174. package/dist/src/lib/document-ingest-artifact.js.map +1 -1
  175. package/dist/src/lib/document-ingest-format2.d.ts +36 -0
  176. package/dist/src/lib/document-ingest-format2.js +78 -0
  177. package/dist/src/lib/document-ingest-format2.js.map +1 -0
  178. package/dist/src/lib/document-ingest-input.d.ts +9 -0
  179. package/dist/src/lib/document-ingest-input.js +28 -1
  180. package/dist/src/lib/document-ingest-input.js.map +1 -1
  181. package/dist/src/lib/document-ingest-rows.d.ts +16 -0
  182. package/dist/src/lib/document-ingest-rows.js +17 -0
  183. package/dist/src/lib/document-ingest-rows.js.map +1 -1
  184. package/dist/src/lib/document-ingest.d.ts +33 -1
  185. package/dist/src/lib/document-ingest.js +49 -0
  186. package/dist/src/lib/document-ingest.js.map +1 -1
  187. package/dist/src/lib/document-schema-rows.d.ts +42 -0
  188. package/dist/src/lib/document-schema-rows.js +53 -0
  189. package/dist/src/lib/document-schema-rows.js.map +1 -0
  190. package/dist/src/lib/env-resolver-core.d.ts +70 -2
  191. package/dist/src/lib/env-resolver-core.js +137 -20
  192. package/dist/src/lib/env-resolver-core.js.map +1 -1
  193. package/dist/src/lib/env-resolver.d.ts +14 -2
  194. package/dist/src/lib/env-resolver.js +32 -10
  195. package/dist/src/lib/env-resolver.js.map +1 -1
  196. package/dist/src/lib/function-authorize-check.d.ts +142 -0
  197. package/dist/src/lib/function-authorize-check.js +310 -0
  198. package/dist/src/lib/function-authorize-check.js.map +1 -0
  199. package/dist/src/lib/function-authorize-view.d.ts +15 -0
  200. package/dist/src/lib/function-authorize-view.js +50 -0
  201. package/dist/src/lib/function-authorize-view.js.map +1 -0
  202. package/dist/src/lib/function-bundle.d.ts +38 -18
  203. package/dist/src/lib/function-bundle.js +96 -35
  204. package/dist/src/lib/function-bundle.js.map +1 -1
  205. package/dist/src/lib/function-collect.d.ts +75 -12
  206. package/dist/src/lib/function-collect.js +427 -12
  207. package/dist/src/lib/function-collect.js.map +1 -1
  208. package/dist/src/lib/function-db-types.d.ts +29 -0
  209. package/dist/src/lib/function-db-types.js +117 -7
  210. package/dist/src/lib/function-db-types.js.map +1 -1
  211. package/dist/src/lib/function-document-types.d.ts +5 -3
  212. package/dist/src/lib/function-document-types.js +10 -14
  213. package/dist/src/lib/function-document-types.js.map +1 -1
  214. package/dist/src/lib/function-lint.d.ts +34 -0
  215. package/dist/src/lib/function-lint.js +112 -0
  216. package/dist/src/lib/function-lint.js.map +1 -0
  217. package/dist/src/lib/function-log-row.js +21 -2
  218. package/dist/src/lib/function-log-row.js.map +1 -1
  219. package/dist/src/lib/function-run.d.ts +16 -21
  220. package/dist/src/lib/function-run.js +37 -30
  221. package/dist/src/lib/function-run.js.map +1 -1
  222. package/dist/src/lib/function-schema-codegen.d.ts +1 -1
  223. package/dist/src/lib/function-schema-codegen.js +5 -5
  224. package/dist/src/lib/function-schema-codegen.js.map +1 -1
  225. package/dist/src/lib/function-source-roots.d.ts +67 -0
  226. package/dist/src/lib/function-source-roots.js +148 -0
  227. package/dist/src/lib/function-source-roots.js.map +1 -0
  228. package/dist/src/lib/function-sync.d.ts +108 -22
  229. package/dist/src/lib/function-sync.js +127 -39
  230. package/dist/src/lib/function-sync.js.map +1 -1
  231. package/dist/src/lib/function-trigger-listing.d.ts +11 -6
  232. package/dist/src/lib/function-trigger-listing.js +32 -11
  233. package/dist/src/lib/function-trigger-listing.js.map +1 -1
  234. package/dist/src/lib/function-typecheck.d.ts +37 -2
  235. package/dist/src/lib/function-typecheck.js +210 -28
  236. package/dist/src/lib/function-typecheck.js.map +1 -1
  237. package/dist/src/lib/function-versions.d.ts +2 -0
  238. package/dist/src/lib/function-versions.js +1 -0
  239. package/dist/src/lib/function-versions.js.map +1 -1
  240. package/dist/src/lib/generated-allowlist.js +0 -20
  241. package/dist/src/lib/generated-allowlist.js.map +1 -1
  242. package/dist/src/lib/generated-config-surfaces.d.ts +703 -203
  243. package/dist/src/lib/generated-config-surfaces.js +2270 -2014
  244. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  245. package/dist/src/lib/generated-sdk-types.d.ts +1 -1
  246. package/dist/src/lib/generated-sdk-types.js +1 -1
  247. package/dist/src/lib/generated-sdk-types.js.map +1 -1
  248. package/dist/src/lib/init-adopt.js +12 -3
  249. package/dist/src/lib/init-adopt.js.map +1 -1
  250. package/dist/src/lib/init-login-note.d.ts +13 -0
  251. package/dist/src/lib/init-login-note.js +22 -0
  252. package/dist/src/lib/init-login-note.js.map +1 -0
  253. package/dist/src/lib/json-value.d.ts +6 -0
  254. package/dist/src/lib/json-value.js +13 -0
  255. package/dist/src/lib/json-value.js.map +1 -0
  256. package/dist/src/lib/load-routes.d.ts +33 -0
  257. package/dist/src/lib/load-routes.js +35 -0
  258. package/dist/src/lib/load-routes.js.map +1 -0
  259. package/dist/src/lib/local-state.d.ts +38 -7
  260. package/dist/src/lib/local-state.js +172 -49
  261. package/dist/src/lib/local-state.js.map +1 -1
  262. package/dist/src/lib/local-test-cases.d.ts +5 -2
  263. package/dist/src/lib/local-test-cases.js +7 -4
  264. package/dist/src/lib/local-test-cases.js.map +1 -1
  265. package/dist/src/lib/log-inspection.d.ts +42 -4
  266. package/dist/src/lib/log-inspection.js +37 -5
  267. package/dist/src/lib/log-inspection.js.map +1 -1
  268. package/dist/src/lib/login-exchange-check.d.ts +18 -0
  269. package/dist/src/lib/login-exchange-check.js +27 -0
  270. package/dist/src/lib/login-exchange-check.js.map +1 -0
  271. package/dist/src/lib/login-scope-lines.d.ts +25 -0
  272. package/dist/src/lib/login-scope-lines.js +45 -0
  273. package/dist/src/lib/login-scope-lines.js.map +1 -0
  274. package/dist/src/lib/logout-admin-session.d.ts +2 -1
  275. package/dist/src/lib/logout-admin-session.js +7 -1
  276. package/dist/src/lib/logout-admin-session.js.map +1 -1
  277. package/dist/src/lib/object-status-filter.d.ts +9 -1
  278. package/dist/src/lib/object-status-filter.js +9 -1
  279. package/dist/src/lib/object-status-filter.js.map +1 -1
  280. package/dist/src/lib/output.js +2 -0
  281. package/dist/src/lib/output.js.map +1 -1
  282. package/dist/src/lib/paginate.d.ts +0 -5
  283. package/dist/src/lib/paginate.js +0 -5
  284. package/dist/src/lib/paginate.js.map +1 -1
  285. package/dist/src/lib/pin-refusal-hint.d.ts +12 -0
  286. package/dist/src/lib/pin-refusal-hint.js +35 -0
  287. package/dist/src/lib/pin-refusal-hint.js.map +1 -0
  288. package/dist/src/lib/primitive-env-plugin.d.ts +99 -0
  289. package/dist/src/lib/primitive-env-plugin.js +408 -0
  290. package/dist/src/lib/primitive-env-plugin.js.map +1 -0
  291. package/dist/src/lib/project-config.d.ts +7 -0
  292. package/dist/src/lib/project-config.js +22 -1
  293. package/dist/src/lib/project-config.js.map +1 -1
  294. package/dist/src/lib/project-login-apps.d.ts +8 -0
  295. package/dist/src/lib/project-login-apps.js +27 -0
  296. package/dist/src/lib/project-login-apps.js.map +1 -0
  297. package/dist/src/lib/prompt-schema-codegen.d.ts +10 -3
  298. package/dist/src/lib/prompt-schema-codegen.js +52 -11
  299. package/dist/src/lib/prompt-schema-codegen.js.map +1 -1
  300. package/dist/src/lib/pull-write.d.ts +31 -0
  301. package/dist/src/lib/pull-write.js +49 -0
  302. package/dist/src/lib/pull-write.js.map +1 -0
  303. package/dist/src/lib/push-failure-report.d.ts +45 -0
  304. package/dist/src/lib/push-failure-report.js +57 -0
  305. package/dist/src/lib/push-failure-report.js.map +1 -0
  306. package/dist/src/lib/records-verbs.d.ts +69 -0
  307. package/dist/src/lib/records-verbs.js +40 -0
  308. package/dist/src/lib/records-verbs.js.map +1 -0
  309. package/dist/src/lib/refresh-admin-credentials.d.ts +7 -0
  310. package/dist/src/lib/refresh-admin-credentials.js +16 -4
  311. package/dist/src/lib/refresh-admin-credentials.js.map +1 -1
  312. package/dist/src/lib/root-import-decision.d.ts +65 -0
  313. package/dist/src/lib/root-import-decision.js +109 -0
  314. package/dist/src/lib/root-import-decision.js.map +1 -0
  315. package/dist/src/lib/run-status.d.ts +1 -1
  316. package/dist/src/lib/run-status.generated.d.ts +2 -2
  317. package/dist/src/lib/run-status.generated.js +3 -1
  318. package/dist/src/lib/run-status.generated.js.map +1 -1
  319. package/dist/src/lib/run-status.js +1 -1
  320. package/dist/src/lib/schema-codegen/generated-schema-descriptor.d.ts +129 -0
  321. package/dist/src/lib/schema-codegen/generated-schema-descriptor.js +269 -0
  322. package/dist/src/lib/schema-codegen/generated-schema-descriptor.js.map +1 -0
  323. package/dist/src/lib/schema-codegen/naming.d.ts +35 -0
  324. package/dist/src/lib/schema-codegen/naming.js +83 -0
  325. package/dist/src/lib/schema-codegen/naming.js.map +1 -0
  326. package/dist/src/lib/schema-codegen/schemaToTs.d.ts +82 -0
  327. package/dist/src/lib/schema-codegen/schemaToTs.js +305 -0
  328. package/dist/src/lib/schema-codegen/schemaToTs.js.map +1 -0
  329. package/dist/src/lib/scope-request.d.ts +84 -0
  330. package/dist/src/lib/scope-request.js +235 -0
  331. package/dist/src/lib/scope-request.js.map +1 -0
  332. package/dist/src/lib/session-id.d.ts +9 -0
  333. package/dist/src/lib/session-id.js +28 -0
  334. package/dist/src/lib/session-id.js.map +1 -0
  335. package/dist/src/lib/snapshot-build-rows.d.ts +21 -0
  336. package/dist/src/lib/snapshot-build-rows.js +22 -0
  337. package/dist/src/lib/snapshot-build-rows.js.map +1 -1
  338. package/dist/src/lib/snapshot-build.js +8 -3
  339. package/dist/src/lib/snapshot-build.js.map +1 -1
  340. package/dist/src/lib/snapshots.d.ts +17 -1
  341. package/dist/src/lib/snapshots.js +50 -2
  342. package/dist/src/lib/snapshots.js.map +1 -1
  343. package/dist/src/lib/swift-codegen/agentGenerator.d.ts +6 -2
  344. package/dist/src/lib/swift-codegen/agentGenerator.js +57 -5
  345. package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -1
  346. package/dist/src/lib/swift-codegen/banners.d.ts +34 -7
  347. package/dist/src/lib/swift-codegen/banners.js +37 -7
  348. package/dist/src/lib/swift-codegen/banners.js.map +1 -1
  349. package/dist/src/lib/swift-codegen/dbGenerator.d.ts +4 -3
  350. package/dist/src/lib/swift-codegen/dbGenerator.js +14 -117
  351. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -1
  352. package/dist/src/lib/swift-codegen/functionGenerator.d.ts +3 -3
  353. package/dist/src/lib/swift-codegen/functionGenerator.js +23 -18
  354. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
  355. package/dist/src/lib/swift-codegen/generator.d.ts +5 -5
  356. package/dist/src/lib/swift-codegen/generator.js +35 -40
  357. package/dist/src/lib/swift-codegen/generator.js.map +1 -1
  358. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +3 -3
  359. package/dist/src/lib/swift-codegen/schemaToSwift.js +4 -4
  360. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -1
  361. package/dist/src/lib/swift-codegen/swiftKeys.d.ts +19 -0
  362. package/dist/src/lib/swift-codegen/swiftKeys.js +31 -0
  363. package/dist/src/lib/swift-codegen/swiftKeys.js.map +1 -0
  364. package/dist/src/lib/sync-paths.d.ts +35 -0
  365. package/dist/src/lib/sync-paths.js +57 -5
  366. package/dist/src/lib/sync-paths.js.map +1 -1
  367. package/dist/src/lib/sync-resource-types.d.ts +26 -26
  368. package/dist/src/lib/sync-resource-types.js +61 -189
  369. package/dist/src/lib/sync-resource-types.js.map +1 -1
  370. package/dist/src/lib/sync-selectors.d.ts +5 -1
  371. package/dist/src/lib/sync-selectors.js +23 -13
  372. package/dist/src/lib/sync-selectors.js.map +1 -1
  373. package/dist/src/lib/test-case-file-names.d.ts +3 -5
  374. package/dist/src/lib/test-case-file-names.js +3 -5
  375. package/dist/src/lib/test-case-file-names.js.map +1 -1
  376. package/dist/src/lib/toml-database-config.d.ts +15 -75
  377. package/dist/src/lib/toml-database-config.js +17 -306
  378. package/dist/src/lib/toml-database-config.js.map +1 -1
  379. package/dist/src/lib/transient-retry.d.ts +43 -0
  380. package/dist/src/lib/transient-retry.js +94 -0
  381. package/dist/src/lib/transient-retry.js.map +1 -0
  382. package/dist/src/lib/vars-override.d.ts +105 -0
  383. package/dist/src/lib/vars-override.js +143 -0
  384. package/dist/src/lib/vars-override.js.map +1 -0
  385. package/dist/src/lib/webhook-capture.d.ts +43 -0
  386. package/dist/src/lib/webhook-capture.js +91 -0
  387. package/dist/src/lib/webhook-capture.js.map +1 -0
  388. package/dist/src/lib/webhook-deliver.d.ts +18 -20
  389. package/dist/src/lib/webhook-deliver.js +34 -89
  390. package/dist/src/lib/webhook-deliver.js.map +1 -1
  391. package/dist/src/lib/webhook-test-run.d.ts +32 -0
  392. package/dist/src/lib/webhook-test-run.js +108 -0
  393. package/dist/src/lib/webhook-test-run.js.map +1 -0
  394. package/dist/src/lib/workflow-codegen/generator.d.ts +7 -7
  395. package/dist/src/lib/workflow-codegen/generator.js +16 -23
  396. package/dist/src/lib/workflow-codegen/generator.js.map +1 -1
  397. package/dist/src/lib/workflow-codegen/invokerIR.d.ts +6 -12
  398. package/dist/src/lib/workflow-codegen/invokerIR.js +4 -5
  399. package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -1
  400. package/dist/src/lib/workflow-toml-validator.d.ts +2 -0
  401. package/dist/src/lib/workflow-toml-validator.js +28 -1
  402. package/dist/src/lib/workflow-toml-validator.js.map +1 -1
  403. package/dist/src/types/index.d.ts +30 -37
  404. package/dist/src/validators.d.ts +7 -55
  405. package/dist/src/validators.js +7 -53
  406. package/dist/src/validators.js.map +1 -1
  407. package/dist/src/vite.d.ts +17 -0
  408. package/dist/src/vite.js +18 -0
  409. package/dist/src/vite.js.map +1 -0
  410. package/package.json +20 -12
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # primitive-admin CLI
2
2
 
3
- Command-line interface for administering Primitive applications. This CLI provides full control over your Primitive apps, including user management, integrations, prompts, workflows, and configuration sync.
3
+ Command-line interface for administering Primitive applications. This CLI provides full control over your Primitive apps, including user management, integrations, prompts, server functions, and configuration sync.
4
4
 
5
5
  ## Installation
6
6
 
@@ -93,11 +93,15 @@ primitive logout
93
93
  ```
94
94
 
95
95
  Inside a project, credentials are stored per environment in the gitignored
96
- `<projectRoot>/.primitive/credentials.json`; a `login` run outside a project
97
- writes `~/.primitive/credentials.json`. Both are mode 0600. Only `login`,
98
- `logout`, `bootstrap` and `init` work outside a project — every other command
99
- stops with an error naming the missing `primitive/config.json`, rather than
100
- reading the global file (see [Outside a project](#outside-a-project)).
96
+ `<projectRoot>/.primitive/credentials.json`, each with the server that issued
97
+ it; a command refuses a stored login whose server is no longer the
98
+ environment's `apiUrl`. In a linked git worktree the file is the main
99
+ worktree's for the same project, so every worktree shares one login (and one
100
+ `logout`). A `login` run outside a project writes
101
+ `~/.primitive/credentials.json`. Both are mode 0600. Only `login`,
102
+ `logout`, `bootstrap`, `init` and `apps delete` work outside a project — every
103
+ other command stops with an error naming the missing `primitive/config.json`,
104
+ rather than reading the global file (see [Outside a project](#outside-a-project)).
101
105
 
102
106
  ## App Context
103
107
 
@@ -123,19 +127,32 @@ primitive users list 01HXYZ...
123
127
 
124
128
  Commands with other required arguments use `--app`:
125
129
  ```bash
126
- primitive workflows get <workflow-id> --app 01HXYZ...
130
+ primitive prompts get <prompt-id> --app 01HXYZ...
127
131
  ```
128
132
 
129
133
  ### Outside a project
130
134
 
131
135
  With no project config up the directory tree there is no environment, so there
132
136
  is nothing for an app-scoped command to target. Only `login`, `logout`,
133
- `bootstrap` and `init` work there; everything else (`whoami`, `apps list`,
134
- `env add`, `config pull`, …) exits non-zero with an error that names the
135
- missing `primitive/config.json` and points at `primitive init`. The CLI never
136
- falls back to `~/.primitive/credentials.json` for those commands, and no flag
137
- redirects a command at another project's tree — run it from inside the project
138
- whose environment names the app.
137
+ `bootstrap`, `init`, `apps delete` and `whoami` work there; everything else
138
+ (`apps list`, `apps get`, `env add`, `config pull`, …) exits non-zero with an
139
+ error that names the missing `primitive/config.json` and points at
140
+ `primitive init`. The CLI never falls back to `~/.primitive/credentials.json`
141
+ for those commands, and no flag redirects a command at another project's tree
142
+ — run it from inside the project whose environment names the app.
143
+
144
+ `apps delete <app-id>` deletes an app by id with the login and step-up held
145
+ for the server `PRIMITIVE_SERVER_URL` names, or the default server when it is
146
+ unset — the server `login` signs in to there. A stored login another server
147
+ issued is refused and its tokens are not sent. `whoami` reports that server,
148
+ where it came from, and the login or `PRIMITIVE_TOKEN` it would use:
149
+
150
+ ```bash
151
+ PRIMITIVE_SERVER_URL=https://api.example.com primitive login --app all
152
+ PRIMITIVE_SERVER_URL=https://api.example.com primitive login --step-up --scope admin --app 01HXY...
153
+ PRIMITIVE_SERVER_URL=https://api.example.com primitive whoami
154
+ PRIMITIVE_SERVER_URL=https://api.example.com primitive apps delete 01HXY... --confirm "My App"
155
+ ```
139
156
 
140
157
  ## Commands
141
158
 
@@ -169,10 +186,11 @@ Manage users within an app.
169
186
 
170
187
  ```bash
171
188
  primitive users list [app-id] # List users
172
- primitive users create <email> [--role admin|member] # Create/add user by email
189
+ primitive users create <email> [--role admin|member] [--name <name>] [--avatar-url <url>] # Create/add user by email
173
190
  primitive users invite [app-id] <email> [--role admin] # Invite user
174
191
  primitive users remove [app-id] <user-id> # Remove user
175
192
  primitive users set-role [app-id] <user-id> <role> # Change role
193
+ primitive users set-profile [app-id] <user-id> [--name <name>] [--avatar-url <url> | --clear-avatar] # Set display name/avatar
176
194
  primitive users transfer-owner [app-id] <new-owner-id> # Transfer ownership
177
195
  primitive users mint-jwt <user-id> [--role <role>] # Mint test JWT (dev/test only)
178
196
  primitive users invitations [app-id] # List pending invitations
@@ -234,7 +252,7 @@ primitive secrets list --json
234
252
  primitive secrets delete STRIPE_SECRET
235
253
  ```
236
254
 
237
- Keys must be uppercase letters, digits, and underscores (e.g., `OPENAI_API_KEY`). Max 100 secrets per app, 2 KB per value. The `set` command is an upsert — it creates or updates automatically. Use `{{secrets.KEY}}` in workflows and `secrets.KEY` in CEL rules.
255
+ Keys must be uppercase letters, digits, and underscores (e.g., `OPENAI_API_KEY`). Max 100 secrets per app, 2 KB per value. The `set` command is an upsert — it creates or updates automatically. Use `{{secrets.KEY}}` in integration request templates and `secrets.KEY` in CEL rules.
238
256
 
239
257
  ### Prompts
240
258
 
@@ -263,68 +281,22 @@ primitive prompts configs list <prompt-id>
263
281
  primitive prompts configs get <prompt> <config>
264
282
  ```
265
283
 
266
- ### Workflows
284
+ ### Workflows (retained history)
267
285
 
268
- Manage multi-step workflow definitions.
286
+ DSL workflows are retired (#3190): nothing creates, changes or runs one. Write
287
+ the logic as a server function (`primitive config create function <key>`). The
288
+ definitions, configurations and revisions an app stored stay readable until
289
+ their retention expires:
269
290
 
270
291
  ```bash
271
- primitive workflows list [app-id] # List workflows
272
- primitive workflows get <workflow-id> # Get details
273
- primitive workflows preview <id> --input '{}' # Preview execution
274
- primitive workflows disable <id> # Take it out of service now
275
- primitive workflows enable <id> # Put it back
292
+ primitive workflows list [app-id] # Retained definitions
293
+ primitive workflows get <workflow-id-or-key> # One, with configs and revisions
294
+ primitive workflows configs list <workflow-id-or-key> # Its configurations
295
+ primitive workflows configs get <workflow-id-or-key> <config-id>
276
296
  ```
277
297
 
278
- A workflow is authored in `workflows/<key>.toml` (named config bodies in
279
- `workflows/<key>.configs/<name>.toml`) and applied with `config push`:
280
-
281
- ```bash
282
- primitive config create workflow process-doc
283
- primitive config push --only workflow/process-doc
284
- ```
285
-
286
- Revisions are read-only history from the retired legacy path (issue #2768:
287
- `workflows publish` and its endpoint are gone). A workflow created before the
288
- configuration model — one with no active config — is migrated by authoring
289
- `workflows/<key>.configs/<name>.toml`, setting `activeConfigName = "<name>"` in
290
- `workflows/<key>.toml`, and pushing.
291
-
292
- **Run management:**
293
- ```bash
294
- primitive workflows runs list <workflow-id>
295
- primitive workflows runs status <workflow-id> <run-id>
296
- ```
297
-
298
- **Workflow TOML push-time validation (issue #685):** `primitive config push` —
299
- the only command that sends a workflow TOML since #2645 — runs the
300
- file through `cli/src/lib/workflow-toml-validator.ts` before sending it to
301
- the server. For a step whose `kind` the CLI knows about, the validator
302
- rejects any top-level field outside the allowlist — most commonly catching
303
- the footgun where `[steps.<id>.request]` is written under `[[steps]]` (TOML
304
- places the sub-table under `steps[N][<id>]`, not the intended
305
- `steps[N].request`, so the runtime silently runs the step with an empty
306
- `request` block). The correct form for the most-recent step is
307
- `[steps.request]`. For a step whose `kind` the CLI does NOT know (an older
308
- CLI run against a newer server that registered a new step kind), the
309
- per-field check is skipped — so a valid new-kind field is never falsely
310
- rejected — while the kind-agnostic misnested-header footgun detector still
311
- fires (issue #998).
312
-
313
- **The allowlist is generated, not hand-maintained (issue #998):** The field
314
- union and the known-kind set live in the committed artifact
315
- `cli/src/lib/generated-allowlist.ts`, generated from the server step runners
316
- (`src/workflows/steps/*.ts`) and the universal `BaseStepDefinition` shape by
317
- `cli/scripts/gen-allowlist.mjs`. The generator runs automatically at CLI
318
- `prebuild`; regenerate manually with `node cli/scripts/gen-allowlist.mjs`
319
- (or `pnpm -C cli gen:allowlist`). The union is derived from what each runner
320
- *reads* off the step config — not from what the `*StepDefinition` type
321
- declares (types over-declare and would weaken the footgun detector). A
322
- freshness guard (`node cli/scripts/gen-allowlist.mjs --check`, also asserted
323
- by `cli/tests/unit/workflow-toml-validator-drift-guard.test.ts`) fails if the
324
- committed artifact drifts from a fresh scan, so the historical hand-edit
325
- drift (#685/#802/#971) cannot recur. When you add a new step kind or a runner
326
- starts reading a new field, just regenerate and commit the artifact — there is
327
- no hand-maintained list to update.
298
+ A config tree that still holds `workflows/` or `transforms/` is refused by
299
+ `config push` and reported by `config diff`, naming the migration page.
328
300
 
329
301
  **A configuration object's field surface has ONE definition (issue #2644):**
330
302
  `src/config-surface/` on the server records, per configuration object, which
@@ -348,23 +320,6 @@ field to `models.yaml` and the CLI unit suite fails until you regenerate and
348
320
  classify it — so the CLI can no longer silently drop a new server-side field.
349
321
  This supersedes the workflow-only descriptor and generator from #2326.
350
322
 
351
- **Template expressions are linted at push time (issue #2689):** the validator
352
- also inspects every `{{ }}` expression on a step and rejects the ones that can
353
- never resolve — an unknown root (`{{ inputs.userId }}`; the valid roots are
354
- `input`, `steps`, `outputs`, `meta`, `secrets`, `vars`, plus the contextual
355
- `selected`/`user`/`md`, the built-ins `now`/`today`/`uuid`/`ulid`, and — inside a
356
- forEach step's body only — `iteration`/`loop` and the loop's binding name) or a
357
- reference to a `steps.<id>` / `outputs.<name>` the file does not declare. An
358
- expression that is only sometimes present is marked optional with
359
- `| default: ''` or a trailing `|| ''`, and anything statically undecidable (a
360
- dynamic bracket key) is left to the run-time check. The lint itself is a
361
- verbatim generated copy of the server module
362
- `src/workflows/runner/template-static-lint.ts` at
363
- `cli/src/lib/generated-template-lint.ts` (`cli/scripts/gen-template-lint.mjs`,
364
- run at `prebuild`, with a `--check` freshness mode asserted by
365
- `cli/tests/unit/template-lint-drift-guard.test.ts`), so the CLI's push-time
366
- verdict and the server's save-time verdict come from the same code.
367
-
368
323
 
369
324
  ### Tokens
370
325
 
@@ -440,7 +395,9 @@ primitive databases export [app-id] <database-id> --output <dir> # Export r
440
395
  primitive databases import [app-id] <path> --overwrite --dry-run # Import from export directory
441
396
  ```
442
397
 
443
- Export creates a directory with `metadata.json`, `records.jsonl`, `indexes.json`, and `constraints.json`. Import restores records and indexes into a new or existing database. Database type config (operations, triggers, access rules) is managed separately via `primitive config` — run `config push` on the target app before importing.
398
+ Export creates a directory with `metadata.json`, `records.jsonl`, `indexes.json`, and `constraints.json`. Import restores records, indexes, and constraints into a new or existing database; it reads every file first, so a malformed export fails without creating a database. Database type config (operations, triggers, access rules) is managed separately via `primitive config` — run `config push` on the target app before importing.
399
+
400
+ A database the target app doesn't have is created with a new id. `databases import --json` lists each database in `databases[]` with `sourceDatabaseId`, `title`, `action` (`created`, `updated`, `skipped`), `targetDatabaseId` (the id written to; absent for skipped entries and under `--dry-run`), and `reason` for a skip (`exists`, `no metadata.json`). The human output prints `Imported database <source> (<title>) as <target>` when the id changed.
444
401
 
445
402
  ### Documents
446
403
 
@@ -466,7 +423,7 @@ primitive documents export-all [app-id] --user-id <id> --owned-only # Expor
466
423
  primitive documents import [app-id] <path> --overwrite --aliases overwrite|skip --dry-run # Import from export
467
424
  ```
468
425
 
469
- Export creates a directory per document with `metadata.json`, `document.yjs` (Yjs state), `permissions.json` (for reference), and `blobs/` (attachments). Permissions are exported for reference but not restored during import — the importing admin is the new owner and manages sharing in the target app. Document IDs are preserved across import. User-scoped aliases can be restored with `--aliases overwrite` (update existing) or `--aliases skip` (keep existing, default).
426
+ Export creates a directory per document with `metadata.json`, `document.yjs` (Yjs state), `permissions.json` (for reference), and `blobs/` (attachments). Permissions are exported for reference but not restored during import — the importing admin is the new owner and manages sharing in the target app. Document IDs are preserved across import. User-scoped aliases can be restored with `--aliases overwrite` (update existing) or `--aliases skip` (keep existing, default). A document whose permissions, aliases or blob list can't be read (anything but a 404, after retrying transient failures) is not exported: the command names it and exits non-zero, and `export-all` still exports the rest and leaves it out of `manifest.json`.
470
427
 
471
428
  ### Collections
472
429
 
@@ -502,34 +459,36 @@ primitive collections import <path> --owner <userId-or-email> # one owner for e
502
459
 
503
460
  Both verbs are for admin tokens. Owners and members are recorded as emails, because app users are scoped to their app and a source app's user id means nothing in the target. The import reads before it writes: it resolves every owner, member, document and group, plans `create`/`merge`/`skip`/`refused` per collection, then applies group grants, members and documents in that order. Matching is by name; `--overwrite` merges only into a collection whose owner, type and context id match, since none of those can change after creation. A group grant the target holds at another level is updated to the level the file records, and effective access follows it — except above 200 documents, where the server refuses a collection-wide group change whole (`COLLECTION_FANOUT_LIMIT`) and the import reports it as a `group` problem. Per-item problems go to stderr and to `--json.problems`; the exit code is 1 when any was reported. Collection ids are not preserved, and the groups themselves, collection resource metadata and pending member invitations do not travel.
504
461
 
462
+ A group grant is resolved by the `groupId` the file records. Into the app it was exported from, that is the same group. Into another app, create the groups there first — each create returns that app's own id — then set each `groups[].groupId` in `collections.json` to the id the target app returned before you import; a grant whose group the target lacks is reported as a `group` problem and skipped.
463
+
505
464
  ### Groups
506
465
 
507
- Manage groups, members, and memberships.
466
+ Manage groups, members, and memberships. A group is named by its id, which the server assigns on `create` and prints (`--json` answers it as `groupId`); its custodian is the app or the user who holds its `owner` membership.
508
467
 
509
468
  ```bash
510
- primitive groups list [app-id] # List groups
511
- primitive groups create [app-id] --type <type> --id <id> --name <name> # Create group
512
- primitive groups get <group-type> <group-id> [app-id] # Get details
513
- primitive groups update <group-type> <group-id> [app-id] # Update group
514
- primitive groups delete <group-type> <group-id> [app-id] # Delete group
469
+ primitive groups list [app-id] [--custodian app|user:<user-id>] # List groups, or one custodian's
470
+ primitive groups create --name <name> [--owner <user-id>] [--member-list members|managers] # Create group
471
+ primitive groups get <group-id> # Get details
472
+ primitive groups update <group-id> [--name] [--description] [--member-list] # Update group
473
+ primitive groups delete <group-id> # Delete group
515
474
  ```
516
475
 
517
476
  **Members:**
518
477
  ```bash
519
- primitive groups members list <group-type> <group-id> [app-id]
520
- primitive groups members add <group-type> <group-id> <user-id> [app-id]
521
- primitive groups members remove <group-type> <group-id> <user-id> [app-id]
522
- primitive groups members set-role <group-type> <group-id> <user-id> <role> [app-id]
478
+ primitive groups members list <group-id> # With each member's role
479
+ primitive groups members add <group-id> <user-id> [--role manager|member]
480
+ primitive groups members set-role <group-id> <user-id> <role>
481
+ primitive groups members remove <group-id> <user-id>
523
482
  ```
524
483
 
525
484
  **Memberships:**
526
485
  ```bash
527
- primitive groups memberships <user-id> [app-id] # List user's group memberships
486
+ primitive groups memberships <user-id> [app-id] # List user's group memberships, with roles
528
487
  ```
529
488
 
530
489
  **Group resource access:**
531
490
  ```bash
532
- primitive groups documents <group-type> <group-id> # List documents a group can access
491
+ primitive groups documents <group-id> # List documents a group can access
533
492
  ```
534
493
 
535
494
  Group permissions on documents are managed via `primitive documents group-permissions` (see [Documents](#documents) above).
@@ -557,13 +516,12 @@ primitive analytics events-grouped [app-id] # Events grouped by dimen
557
516
 
558
517
  # Features
559
518
  primitive analytics integrations [app-id] # Integration usage metrics
560
- primitive analytics workflows [app-id] # Top workflows by runs
561
519
  primitive analytics prompts [app-id] # Top prompts by executions
562
520
  ```
563
521
 
564
522
  **Common options:**
565
523
  - `--window-days <n>` - Time window in days (default varies per command)
566
- - `--limit <n>` - Result limit (top-users, workflows, prompts)
524
+ - `--limit <n>` - Result limit (top-users, prompts)
567
525
  - `--group-by <dim>` - Dimension for events-grouped (action, feature, route, country, deviceType, plan, day)
568
526
  - `--page <n>` - Page number for events feed (0-based)
569
527
  - `--json` - Output raw JSON
@@ -634,8 +592,9 @@ primitive/<env>/
634
592
  weather-api.toml # Integration configs
635
593
  prompts/
636
594
  summarizer.toml # Prompt configs with all variations
637
- workflows/
638
- process-doc.toml # Workflow definitions
595
+ functions/
596
+ process-doc.toml # Server function declarations
597
+ process-doc.ts # …and the TypeScript their `entry` reaches
639
598
  ```
640
599
 
641
600
  ### Example: app.toml
@@ -854,47 +813,59 @@ CLI).
854
813
 
855
814
  ### `primitive-admin/validators` — TOML validators
856
815
 
857
- The TOML validators that `config push` runs as its load-bearing gate are exported
816
+ The operations validator that `config push` runs as its load-bearing gate is exported
858
817
  from the `primitive-admin/validators` subpath (ESM-only, with types) so external
859
818
  tooling can validate exactly the way the published CLI does — instead of
860
819
  re-implementing the flow and silently drifting.
861
820
 
862
821
  ```ts
863
822
  import {
864
- validateWorkflowTomlSource, // source-level wrapper (parse → expand → validate)
865
- validateWorkflowToml, // raw: pure fn over already-parsed TOML
866
- formatWorkflowTomlErrors,
867
823
  validateOperations, // raw: pure fn over already-parsed operations[]
868
824
  formatIssue,
869
825
  } from "primitive-admin/validators";
870
826
  ```
871
827
 
872
- Two contracts:
828
+ Both are **pure functions over already-parsed TOML** — they do *not* read files
829
+ or parse TOML. The consumer parses (e.g. with `smol-toml`); there is **no
830
+ coupling on a specific TOML parser version**: pass whatever `operations[]` you
831
+ already have. (The workflow validators the subpath also exported retired with
832
+ DSL workflows, #3190.)
873
833
 
874
- - **`validateWorkflowTomlSource(raw, filePath)`** — pass the **raw TOML source
875
- string** and the workflow's path. It runs the *identical* parse →
876
- `expandWorkflowTomlData()` (`include` fragment expansion) → `validateWorkflowToml`
877
- → `formatWorkflowTomlErrors` path that `config push` runs, so it cannot diverge
878
- from `config push` on workflow `include` fragments. Returns
879
- `{ errors, formatted }` (`formatted` is `null` when valid). Fragment files
880
- resolve relative to `<filePath>/../../workflow-fragments/`, matching the CLI.
834
+ Internal helpers (`collectParamRefs`, `declaredParamNames`,
835
+ `locateOperationLine`) are intentionally **not** exported.
881
836
 
882
- - **The raw validators** (`validateWorkflowToml`, `validateOperations`,
883
- `formatWorkflowTomlErrors`, `formatIssue`) are **pure functions over
884
- already-parsed TOML** — they do *not* read files or parse TOML. The consumer
885
- parses (e.g. with `smol-toml`) and, for workflows, performs any `include`
886
- expansion itself. There is **no coupling on a specific TOML parser version**:
887
- pass whatever parsed object / `operations[]` you already have.
837
+ ### `primitive-admin/vite` — the Primitive environment Vite plugin
888
838
 
889
- ```ts
890
- import * as TOML from "smol-toml";
891
- const data = TOML.parse(raw);
892
- const errs = validateWorkflowToml(data);
893
- if (errs.length) throw new Error(formatWorkflowTomlErrors(path, errs));
894
- ```
839
+ `primitiveEnv()` resolves the project's Primitive environment at Vite config
840
+ time, in the same order every `primitive` command uses (`--primitive-env` /
841
+ `PRIMITIVE_ENV`, then `primitive env use`, then `defaultEnvironment`, then the
842
+ sole environment), and fills the identity a web app reads:
895
843
 
896
- Internal helpers (`collectParamRefs`, `declaredParamNames`,
897
- `locateOperationLine`) are intentionally **not** exported.
844
+ ```ts
845
+ // vite.config.ts
846
+ import { defineConfig } from "vite";
847
+ import vue from "@vitejs/plugin-vue";
848
+ import { primitiveEnv } from "primitive-admin/vite";
849
+
850
+ export default defineConfig({
851
+ plugins: [primitiveEnv(), vue()],
852
+ });
853
+ ```
854
+
855
+ - It defines `import.meta.env.VITE_APP_ID`, `VITE_API_URL`, `VITE_WS_URL`,
856
+ `VITE_APP_NAME` and `VITE_PRIMITIVE_ENV`, and publishes the same keys into
857
+ `process.env` so vitest sees them too.
858
+ - An explicit `VITE_*` identity key in a `.env` file or the shell wins, with a
859
+ warning naming it.
860
+ - `VITE_EXPECTED_PRIMITIVE_ENV` in `.env.<mode>` pins that mode to one
861
+ Primitive environment; a run that resolves another stops at config time.
862
+
863
+ The subpath exports `primitiveEnv`, `resolvePrimitiveEnv` (the same resolution
864
+ for a script: `resolvePrimitiveEnv({ root, env, primitiveEnv })`) and
865
+ `PrimitiveEnvError` (its `kind` says what was wrong). It is built on the CLI's
866
+ own resolver, so the plugin and the `primitive` binary of one install always
867
+ agree. `vite` is an optional peer dependency: the plugin imports only its
868
+ types and never loads it at runtime.
898
869
 
899
870
  ## Exit Codes
900
871
 
@@ -904,7 +875,7 @@ Internal helpers (`collectParamRefs`, `declaredParamNames`,
904
875
 
905
876
  ## Environment Variables
906
877
 
907
- - `PRIMITIVE_SERVER_URL` - Server URL for `login` outside a project (defaults to `https://primitiveapi.com`)
878
+ - `PRIMITIVE_SERVER_URL` - Server URL for `login` and `apps delete` outside a project (defaults to `https://primitiveapi.com`); ignored inside a project
908
879
 
909
880
  **Login server resolution:**
910
881
  1. Project mode (`primitive/config.json` present): the active environment's
@@ -3,7 +3,7 @@ name: primitive-platform
3
3
  description: >
4
4
  Fetches the Primitive platform's agent guides and applies them. MUST be used whenever the user
5
5
  is writing or reviewing code that uses js-bao, js-bao-wss-client, primitive-app,
6
- primitive-functions, or any Primitive platform feature (documents, databases, server functions,
6
+ primitive-functions, or any Primitive platform feature (databases, server functions,
7
7
  prompts, integrations, blobs, authentication, users/groups), and before running any `primitive`
8
8
  CLI command. All development guidance lives in the guides this skill fetches; after writing or
9
9
  modifying code that touches Primitive APIs, it cross-references the code against those guides
@@ -49,7 +49,7 @@ primitive guides get <topic> # the topic's default variant
49
49
  - **Freshness.** Guides are cached under `~/.primitive/guides/` for 24 hours. After upgrading the
50
50
  CLI or the libraries, pass `--refresh` on the first `list` and `get`.
51
51
  - **Where to start.** `configuration` covers projects, environments, and pushing config;
52
- `data-modeling` covers choosing where data lives; `inspecting-and-debugging` covers reading a
52
+ `databases` covers storing and partitioning data; `inspecting-and-debugging` covers reading a
53
53
  running app. For a CLI command you have not used, fetch the guide for its feature first.
54
54
 
55
55
  ## Writing code
@@ -63,6 +63,32 @@ primitive guides get <topic> # the topic's default variant
63
63
  4. Before running a `primitive` command that changes server state, read the `Env | App | Server`
64
64
  header every command prints and confirm it names the environment you intend. The
65
65
  `configuration` guide explains projects and environments.
66
+ If the change needs a `config push` to test and that environment is shared — with other
67
+ developers, live users, or the user's own work in another worktree — recommend a child app
68
+ instead, and follow the `configuration` guide's "Child apps" workflow.
69
+ 5. A plain `primitive login` holds the default scope, which cannot delete apps other than
70
+ `internal` ones (every child app is `internal`), cannot delete databases or change roles,
71
+ and cannot write to an app whose protection level is `protected`. In a project it is pinned
72
+ to the project's apps on that server. When a command is refused with a 403, act on its
73
+ `code`, not on the command it prints:
74
+ - `INSUFFICIENT_SCOPE`: it prints the exact `primitive login …` command that grants the
75
+ missing scope (a missing `admin` prints `primitive login --step-up --scope … --app <id>`).
76
+ Ask the user to run it (a step-up opens the browser), then retry once.
77
+ - `PROTECTED_APP_STEP_UP_REQUIRED`: the app is protected. Ask the user to run the printed
78
+ `primitive login --step-up --scope … --app <id>` command, then retry once. Never lower the
79
+ app's `protection` to get past it.
80
+ - `APP_NOT_PINNED`: the login's pins do not reach the app or route the command named. First
81
+ confirm the command targets the app you intended (`primitive whoami` shows the pins); only
82
+ then ask the user to run the `primitive -e <env> login` the error names, or the printed
83
+ command. Never ask for `primitive login --app all` to get around a pin.
84
+ - `PROTECTION_OWNER_ONLY` or `PROTECTION_FIXED_ON_CHILD`: the push changes a protection level
85
+ this login may not change. Unless the user asked for the change, restore the `protection`
86
+ line that `primitive config pull --only app` writes.
87
+
88
+ If a command says *Your login predates scoped sessions*, ask the user to run
89
+ `primitive login`. An unattended run uses a CI session the user creates with
90
+ `primitive auth sessions create` and passes in `PRIMITIVE_TOKEN`; never create one yourself.
91
+ The `configuration` guide has the details.
66
92
 
67
93
  ## Reviewing code (automatic, after every change)
68
94
 
@@ -176,7 +202,11 @@ a grep:
176
202
  sources, not its dependencies.
177
203
  - **The configuration tree.** A deprecated key or spelling in the app's `primitive/`
178
204
  TOML is reported when the tree is pushed; the `configuration` guide explains how to
179
- check a tree without applying it.
205
+ check a tree without applying it. When the upgrade changes the tree and the
206
+ environment it is pushed to is shared — with other developers, live users, or the
207
+ user's own work in another worktree — push it to a child app first and verify it
208
+ there, following the `configuration` guide's "Child apps" workflow; push to the
209
+ shared environment once the upgrade is merged.
180
210
 
181
211
  A surface an earlier scan reported as deprecated may since have been removed, and a
182
212
  removed surface is not a lint warning but a build error, a refused request or a
@@ -249,7 +279,10 @@ guides for the app's feature areas. Compare against what the app actually does:
249
279
 
250
280
  Run the app's tests, apply the post-change review above to everything modified, and
251
281
  update the feedback doc's upgrade stamp (date, channel, versions, and the template
252
- commit synced in Step 6).
282
+ commit synced in Step 6). If the upgrade changed the configuration tree and the
283
+ environment is shared, verify against the child app from Step 4, not the shared
284
+ environment; the `configuration` guide's "Child apps" workflow covers applying the
285
+ merged tree to the parent and deleting the child.
253
286
 
254
287
  ### The platform feedback doc
255
288
 
@@ -9,10 +9,9 @@ import { registerAppsCommands } from "../src/commands/apps.js";
9
9
  import { registerUsersCommands } from "../src/commands/users.js";
10
10
  import { registerWaitlistCommands } from "../src/commands/waitlist.js";
11
11
  import { registerIntegrationsCommands } from "../src/commands/integrations.js";
12
- import { registerWebhooksCommands } from "../src/commands/webhooks.js";
13
12
  import { registerConnectionsCommands } from "../src/commands/connections.js";
14
13
  import { registerSessionsCommands } from "../src/commands/sessions.js";
15
- import { registerCronTriggersCommands } from "../src/commands/cron-triggers.js";
14
+ import { registerAgentSessionsCommands } from "../src/commands/agent-sessions.js";
16
15
  import { registerLocksCommands } from "../src/commands/locks.js";
17
16
  import { registerMetadataCommands } from "../src/commands/metadata.js";
18
17
  import { registerPromptsCommands } from "../src/commands/prompts.js";
@@ -30,14 +29,14 @@ import { registerTokensCommands } from "../src/commands/tokens.js";
30
29
  import { registerDatabasesCommands } from "../src/commands/databases.js";
31
30
  import { registerGroupsCommands } from "../src/commands/groups.js";
32
31
  import { registerRuleSetsCommands } from "../src/commands/rule-sets.js";
33
- import { registerGroupTypeConfigsCommands } from "../src/commands/group-type-configs.js";
34
32
  import { registerDatabaseTypeConfigsCommands } from "../src/commands/database-type-configs.js";
35
33
  import { registerGuidesCommands } from "../src/commands/guides.js";
36
34
  import { registerDocumentsCommands } from "../src/commands/documents.js";
35
+ import { registerDb3Commands } from "../src/commands/db3.js";
36
+ import { registerDb3TypesCommands } from "../src/commands/db3-types.js";
37
37
  import chalk from "chalk";
38
38
  import { registerEmailTemplatesCommands } from "../src/commands/email-templates.js";
39
39
  import { registerCollectionsCommands } from "../src/commands/collections.js";
40
- import { registerCollectionTypeConfigsCommands } from "../src/commands/collection-type-configs.js";
41
40
  import { registerMetadataCategoryConfigsCommands } from "../src/commands/metadata-category-configs.js";
42
41
  import { error } from "../src/lib/output.js";
43
42
  import { installGlobalCrashHandlers } from "../src/lib/crash-handlers.js";
@@ -50,7 +49,7 @@ import { registerSecretsCommands } from "../src/commands/secrets.js";
50
49
  import { registerVarsCommands } from "../src/commands/vars.js";
51
50
  import { registerBlobBucketsCommands } from "../src/commands/blob-buckets.js";
52
51
  import { registerEnvCommands } from "../src/commands/env.js";
53
- import { setCurrentEnvName, getCurrentEnvNameSafe, getProjectConfig, PrimitiveEnvError, } from "../src/lib/env-resolver.js";
52
+ import { setCurrentEnvName, getCurrentEnvNameSafe, getCurrentEnvironment, getProjectConfig, PrimitiveEnvError, } from "../src/lib/env-resolver.js";
54
53
  import { ProjectConfigError, PROJECT_CONFIG_DISPLAY_NAME, findProjectConfigPath } from "../src/lib/project-config.js";
55
54
  // Install global crash handlers first thing. Without these, an error that
56
55
  // escapes the top-level `.catch` below — e.g. ERR_USE_AFTER_CLOSE thrown from
@@ -183,6 +182,11 @@ catch (err) {
183
182
  // Skipped when the layout is refused: the file that would name the
184
183
  // environments is the one the CLI will not read, and the refusal below is the
185
184
  // answer to every command that cares.
185
+ //
186
+ // The check is the resolver's own, so `--env` reaches every environment the
187
+ // resolver knows — the committed ones and this machine's machine-local ones
188
+ // (#4117) — and an unknown name is refused with the one message that lists
189
+ // them all.
186
190
  if (preParsedEnv && !staleLayoutRefusal) {
187
191
  try {
188
192
  const project = getProjectConfig();
@@ -190,14 +194,10 @@ if (preParsedEnv && !staleLayoutRefusal) {
190
194
  error(`--env was given but no ${PROJECT_CONFIG_DISPLAY_NAME} was found in this directory or any parent.`);
191
195
  process.exit(1);
192
196
  }
193
- if (!project.environments[preParsedEnv]) {
194
- const available = Object.keys(project.environments).join(", ") || "(none)";
195
- error(`Environment "${preParsedEnv}" is not defined in ${PROJECT_CONFIG_DISPLAY_NAME}. Available: ${available}`);
196
- process.exit(1);
197
- }
197
+ getCurrentEnvironment();
198
198
  }
199
199
  catch (err) {
200
- if (err instanceof ProjectConfigError) {
200
+ if (err instanceof ProjectConfigError || err instanceof PrimitiveEnvError) {
201
201
  error(err.message);
202
202
  process.exit(1);
203
203
  }
@@ -213,16 +213,22 @@ if (!skipHeader) {
213
213
  // parsed (#3273's shape). In project mode the URL comes from the config;
214
214
  // outside a project there is nothing to show.
215
215
  //
216
- // The app is the environment's, and nothing else's (#3152) — read straight
217
- // from the config, so the header is right before login as well as after.
216
+ // The app is the environment's, and nothing else's (#3152) — read from the
217
+ // resolved environment, so the header is right before login as well as
218
+ // after, and a machine-local environment shows its own app and server
219
+ // (#4117). Every resolver error is swallowed: the command reports it.
218
220
  const envNameForHeader = getCurrentEnvNameSafe();
219
221
  let headerAppId;
220
222
  let headerAppName;
223
+ // The active environment's apiUrl, so the header stays correct even before
224
+ // you have logged in.
225
+ let server;
221
226
  if (envNameForHeader) {
222
227
  try {
223
- const envCfg = getProjectConfig()?.environments[envNameForHeader];
228
+ const envCfg = getCurrentEnvironment()?.config;
224
229
  headerAppId = envCfg?.appId;
225
230
  headerAppName = envCfg?.appName;
231
+ server = envCfg?.apiUrl;
226
232
  }
227
233
  catch {
228
234
  // ignore
@@ -231,19 +237,6 @@ if (!skipHeader) {
231
237
  const appInfo = headerAppName
232
238
  ? `${headerAppName} (${headerAppId})`
233
239
  : headerAppId || "None set";
234
- // The active environment's apiUrl, so the header stays correct even before
235
- // you have logged in.
236
- let server;
237
- if (envNameForHeader) {
238
- try {
239
- const env = getProjectConfig()?.environments[envNameForHeader];
240
- if (env)
241
- server = env.apiUrl;
242
- }
243
- catch {
244
- // fall through
245
- }
246
- }
247
240
  server = server || "Not configured";
248
241
  let projectConfigPath = null;
249
242
  try {
@@ -308,14 +301,17 @@ Project configuration (primitive/config.json):
308
301
  the CLI operates in project mode: each environment's committed configuration
309
302
  is at <projectRoot>/primitive/<env>/, this machine's credentials and
310
303
  selection live under <projectRoot>/.primitive/, and each named environment is
311
- isolated. Without a primitive/config.json only login, logout, bootstrap and
312
- init work; every other command stops and names the missing project config
313
- (create one with 'primitive init'). There is no global fallback.
304
+ isolated. Without a primitive/config.json only login, logout, bootstrap,
305
+ init and 'apps delete' work; every other command stops and names the missing
306
+ project config (create one with 'primitive init'). 'apps delete' there uses
307
+ the login for PRIMITIVE_SERVER_URL, or the default server when it is unset.
314
308
 
315
309
  Primitive environment selection (project mode):
316
310
  1. --env <name> flag
317
311
  2. PRIMITIVE_ENV env var
318
- 3. This machine's selection in .primitive/local.json ('primitive env use')
312
+ 3. This machine's selection in .primitive/local.json ('primitive env use'),
313
+ which may name a machine-local environment registered in the same file:
314
+ a child app that uses a committed environment's tree
319
315
  4. "defaultEnvironment" in primitive/config.json (the committed team default)
320
316
  5. The only environment, if there's exactly one
321
317
 
@@ -336,10 +332,9 @@ registerAppsCommands(program);
336
332
  registerUsersCommands(program);
337
333
  registerWaitlistCommands(program);
338
334
  registerIntegrationsCommands(program);
339
- registerWebhooksCommands(program);
340
335
  registerConnectionsCommands(program);
341
336
  registerSessionsCommands(program);
342
- registerCronTriggersCommands(program);
337
+ registerAgentSessionsCommands(program);
343
338
  registerLocksCommands(program);
344
339
  registerMetadataCommands(program);
345
340
  registerPromptsCommands(program);
@@ -359,13 +354,13 @@ registerTokensCommands(program);
359
354
  registerDatabasesCommands(program);
360
355
  registerGroupsCommands(program);
361
356
  registerRuleSetsCommands(program);
362
- registerGroupTypeConfigsCommands(program);
363
357
  registerDatabaseTypeConfigsCommands(program);
364
358
  registerGuidesCommands(program);
365
359
  registerDocumentsCommands(program);
360
+ registerDb3Commands(program);
361
+ registerDb3TypesCommands(program);
366
362
  registerEmailTemplatesCommands(program);
367
363
  registerCollectionsCommands(program);
368
- registerCollectionTypeConfigsCommands(program);
369
364
  registerMetadataCategoryConfigsCommands(program);
370
365
  registerSkillCommands(program);
371
366
  registerSecretsCommands(program);