primitive-admin 1.2.0-alpha.13 → 1.2.0-alpha.15

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 (324) hide show
  1. package/README.md +102 -78
  2. package/assets/skill/skills/primitive-platform/SKILL.md +87 -23
  3. package/dist/bin/primitive.js +11 -82
  4. package/dist/bin/primitive.js.map +1 -1
  5. package/dist/src/commands/admins.js +79 -17
  6. package/dist/src/commands/admins.js.map +1 -1
  7. package/dist/src/commands/agent-sessions.js +2 -0
  8. package/dist/src/commands/agent-sessions.js.map +1 -1
  9. package/dist/src/commands/analytics.js +220 -18
  10. package/dist/src/commands/analytics.js.map +1 -1
  11. package/dist/src/commands/apps-children.js +2 -0
  12. package/dist/src/commands/apps-children.js.map +1 -1
  13. package/dist/src/commands/apps.js +19 -2
  14. package/dist/src/commands/apps.js.map +1 -1
  15. package/dist/src/commands/auth.js +11 -1
  16. package/dist/src/commands/auth.js.map +1 -1
  17. package/dist/src/commands/collections.js +13 -0
  18. package/dist/src/commands/collections.js.map +1 -1
  19. package/dist/src/commands/config.d.ts +1 -1
  20. package/dist/src/commands/config.js +40 -9
  21. package/dist/src/commands/config.js.map +1 -1
  22. package/dist/src/commands/connections.js +2 -0
  23. package/dist/src/commands/connections.js.map +1 -1
  24. package/dist/src/commands/database-type-configs.js +5 -3
  25. package/dist/src/commands/database-type-configs.js.map +1 -1
  26. package/dist/src/commands/databases.js +6 -4
  27. package/dist/src/commands/databases.js.map +1 -1
  28. package/dist/src/commands/db3-types.js +2 -0
  29. package/dist/src/commands/db3-types.js.map +1 -1
  30. package/dist/src/commands/db3.d.ts +12 -0
  31. package/dist/src/commands/db3.js +345 -11
  32. package/dist/src/commands/db3.js.map +1 -1
  33. package/dist/src/commands/documents.d.ts +52 -12
  34. package/dist/src/commands/documents.js +120 -29
  35. package/dist/src/commands/documents.js.map +1 -1
  36. package/dist/src/commands/email-templates.js +72 -0
  37. package/dist/src/commands/email-templates.js.map +1 -1
  38. package/dist/src/commands/functions.js +47 -10
  39. package/dist/src/commands/functions.js.map +1 -1
  40. package/dist/src/commands/groups.js +18 -3
  41. package/dist/src/commands/groups.js.map +1 -1
  42. package/dist/src/commands/init.js +7 -1
  43. package/dist/src/commands/init.js.map +1 -1
  44. package/dist/src/commands/integrations.js +80 -47
  45. package/dist/src/commands/integrations.js.map +1 -1
  46. package/dist/src/commands/metadata-category-configs.js +2 -0
  47. package/dist/src/commands/metadata-category-configs.js.map +1 -1
  48. package/dist/src/commands/metadata.js +41 -0
  49. package/dist/src/commands/metadata.js.map +1 -1
  50. package/dist/src/commands/prompts.js +73 -47
  51. package/dist/src/commands/prompts.js.map +1 -1
  52. package/dist/src/commands/rule-sets.js +2 -0
  53. package/dist/src/commands/rule-sets.js.map +1 -1
  54. package/dist/src/commands/schemas.d.ts +15 -0
  55. package/dist/src/commands/schemas.js +122 -0
  56. package/dist/src/commands/schemas.js.map +1 -0
  57. package/dist/src/commands/secrets.js +45 -3
  58. package/dist/src/commands/secrets.js.map +1 -1
  59. package/dist/src/commands/sessions.js +2 -0
  60. package/dist/src/commands/sessions.js.map +1 -1
  61. package/dist/src/commands/sync-schemas.d.ts +202 -0
  62. package/dist/src/commands/sync-schemas.js +629 -0
  63. package/dist/src/commands/sync-schemas.js.map +1 -0
  64. package/dist/src/commands/sync-user-properties.d.ts +118 -0
  65. package/dist/src/commands/sync-user-properties.js +276 -0
  66. package/dist/src/commands/sync-user-properties.js.map +1 -0
  67. package/dist/src/commands/sync.d.ts +243 -12
  68. package/dist/src/commands/sync.js +1474 -314
  69. package/dist/src/commands/sync.js.map +1 -1
  70. package/dist/src/commands/user-properties.d.ts +14 -0
  71. package/dist/src/commands/user-properties.js +79 -0
  72. package/dist/src/commands/user-properties.js.map +1 -0
  73. package/dist/src/commands/users.js +912 -18
  74. package/dist/src/commands/users.js.map +1 -1
  75. package/dist/src/commands/waitlist.js +39 -4
  76. package/dist/src/commands/waitlist.js.map +1 -1
  77. package/dist/src/lib/analytics-query.d.ts +58 -0
  78. package/dist/src/lib/analytics-query.js +134 -0
  79. package/dist/src/lib/analytics-query.js.map +1 -0
  80. package/dist/src/lib/api-client.d.ts +779 -95
  81. package/dist/src/lib/api-client.js +369 -166
  82. package/dist/src/lib/api-client.js.map +1 -1
  83. package/dist/src/lib/block-selector.d.ts +9 -15
  84. package/dist/src/lib/block-selector.js +9 -20
  85. package/dist/src/lib/block-selector.js.map +1 -1
  86. package/dist/src/lib/cli-manifest.d.ts +8 -0
  87. package/dist/src/lib/cli-manifest.js +10 -1
  88. package/dist/src/lib/cli-manifest.js.map +1 -1
  89. package/dist/src/lib/cli-version.d.ts +14 -0
  90. package/dist/src/lib/cli-version.js +38 -0
  91. package/dist/src/lib/cli-version.js.map +1 -0
  92. package/dist/src/lib/codegen-shared/prettierStable.d.ts +41 -0
  93. package/dist/src/lib/codegen-shared/prettierStable.js +146 -24
  94. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -1
  95. package/dist/src/lib/command-status.d.ts +110 -0
  96. package/dist/src/lib/command-status.js +184 -0
  97. package/dist/src/lib/command-status.js.map +1 -0
  98. package/dist/src/lib/config-object-descriptor.d.ts +6 -0
  99. package/dist/src/lib/config-object-descriptor.js +71 -0
  100. package/dist/src/lib/config-object-descriptor.js.map +1 -1
  101. package/dist/src/lib/config-toml.d.ts +11 -2
  102. package/dist/src/lib/config-toml.js +25 -2
  103. package/dist/src/lib/config-toml.js.map +1 -1
  104. package/dist/src/lib/data-input.d.ts +1 -1
  105. package/dist/src/lib/data-input.js +1 -1
  106. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +1 -1
  107. package/dist/src/lib/db-codegen/dbTsTypes.js +3 -0
  108. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
  109. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +11 -1
  110. package/dist/src/lib/db-codegen/dbTypeIR.js +11 -5
  111. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
  112. package/dist/src/lib/db-type-records.d.ts +95 -0
  113. package/dist/src/lib/db-type-records.js +219 -0
  114. package/dist/src/lib/db-type-records.js.map +1 -0
  115. package/dist/src/lib/db3-export.d.ts +65 -9
  116. package/dist/src/lib/db3-export.js +159 -22
  117. package/dist/src/lib/db3-export.js.map +1 -1
  118. package/dist/src/lib/db3-index-output.d.ts +69 -3
  119. package/dist/src/lib/db3-index-output.js +142 -4
  120. package/dist/src/lib/db3-index-output.js.map +1 -1
  121. package/dist/src/lib/db3-type-models.d.ts +39 -7
  122. package/dist/src/lib/db3-type-models.js +138 -27
  123. package/dist/src/lib/db3-type-models.js.map +1 -1
  124. package/dist/src/lib/deprecation.d.ts +2 -2
  125. package/dist/src/lib/deprecation.js +2 -2
  126. package/dist/src/lib/experimental-apis.d.ts +36 -0
  127. package/dist/src/lib/experimental-apis.js +46 -0
  128. package/dist/src/lib/experimental-apis.js.map +1 -0
  129. package/dist/src/lib/file-attachment.d.ts +24 -0
  130. package/dist/src/lib/file-attachment.js +31 -0
  131. package/dist/src/lib/file-attachment.js.map +1 -0
  132. package/dist/src/lib/function-authorize-check.d.ts +1 -1
  133. package/dist/src/lib/function-authorize-check.js +2 -1
  134. package/dist/src/lib/function-authorize-check.js.map +1 -1
  135. package/dist/src/lib/function-authorize-view.js +4 -0
  136. package/dist/src/lib/function-authorize-view.js.map +1 -1
  137. package/dist/src/lib/function-bundle.d.ts +27 -5
  138. package/dist/src/lib/function-bundle.js +106 -7
  139. package/dist/src/lib/function-bundle.js.map +1 -1
  140. package/dist/src/lib/function-collect.d.ts +2 -0
  141. package/dist/src/lib/function-collect.js +36 -7
  142. package/dist/src/lib/function-collect.js.map +1 -1
  143. package/dist/src/lib/function-db-types.d.ts +57 -40
  144. package/dist/src/lib/function-db-types.js +246 -285
  145. package/dist/src/lib/function-db-types.js.map +1 -1
  146. package/dist/src/lib/function-document-types.d.ts +19 -7
  147. package/dist/src/lib/function-document-types.js +24 -12
  148. package/dist/src/lib/function-document-types.js.map +1 -1
  149. package/dist/src/lib/function-run.d.ts +1 -1
  150. package/dist/src/lib/function-run.js +1 -1
  151. package/dist/src/lib/function-run.js.map +1 -1
  152. package/dist/src/lib/function-schema-codegen.d.ts +58 -18
  153. package/dist/src/lib/function-schema-codegen.js +85 -74
  154. package/dist/src/lib/function-schema-codegen.js.map +1 -1
  155. package/dist/src/lib/function-schema-refs.d.ts +98 -0
  156. package/dist/src/lib/function-schema-refs.js +177 -0
  157. package/dist/src/lib/function-schema-refs.js.map +1 -0
  158. package/dist/src/lib/function-sync.d.ts +38 -4
  159. package/dist/src/lib/function-sync.js +83 -14
  160. package/dist/src/lib/function-sync.js.map +1 -1
  161. package/dist/src/lib/function-typecheck.d.ts +52 -0
  162. package/dist/src/lib/function-typecheck.js +171 -54
  163. package/dist/src/lib/function-typecheck.js.map +1 -1
  164. package/dist/src/lib/generated-build-flags.d.ts +13 -0
  165. package/dist/src/lib/generated-build-flags.js +14 -0
  166. package/dist/src/lib/generated-build-flags.js.map +1 -0
  167. package/dist/src/lib/generated-config-surfaces.d.ts +211 -11
  168. package/dist/src/lib/generated-config-surfaces.js +579 -69
  169. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  170. package/dist/src/lib/generated-sdk-types.d.ts +1 -1
  171. package/dist/src/lib/generated-sdk-types.js +1 -1
  172. package/dist/src/lib/generated-sdk-types.js.map +1 -1
  173. package/dist/src/lib/integration-test-request.d.ts +54 -0
  174. package/dist/src/lib/integration-test-request.js +207 -0
  175. package/dist/src/lib/integration-test-request.js.map +1 -0
  176. package/dist/src/lib/log-inspection.d.ts +3 -0
  177. package/dist/src/lib/log-inspection.js +1 -0
  178. package/dist/src/lib/log-inspection.js.map +1 -1
  179. package/dist/src/lib/metadata-report.d.ts +85 -0
  180. package/dist/src/lib/metadata-report.js +81 -0
  181. package/dist/src/lib/metadata-report.js.map +1 -0
  182. package/dist/src/lib/output.d.ts +1 -1
  183. package/dist/src/lib/output.js +1 -1
  184. package/dist/src/lib/platform-owned.js +5 -0
  185. package/dist/src/lib/platform-owned.js.map +1 -1
  186. package/dist/src/lib/primitive-declaration-names.d.ts +21 -0
  187. package/dist/src/lib/primitive-declaration-names.js +22 -0
  188. package/dist/src/lib/primitive-declaration-names.js.map +1 -0
  189. package/dist/src/lib/primitive-declaration.d.ts +143 -0
  190. package/dist/src/lib/primitive-declaration.js +658 -0
  191. package/dist/src/lib/primitive-declaration.js.map +1 -0
  192. package/dist/src/lib/prompt-schema-codegen.d.ts +36 -12
  193. package/dist/src/lib/prompt-schema-codegen.js +82 -98
  194. package/dist/src/lib/prompt-schema-codegen.js.map +1 -1
  195. package/dist/src/lib/prompt-schema-document.d.ts +35 -0
  196. package/dist/src/lib/prompt-schema-document.js +92 -0
  197. package/dist/src/lib/prompt-schema-document.js.map +1 -0
  198. package/dist/src/lib/prompt-schema-refs.d.ts +164 -0
  199. package/dist/src/lib/prompt-schema-refs.js +452 -0
  200. package/dist/src/lib/prompt-schema-refs.js.map +1 -0
  201. package/dist/src/lib/records-verbs.d.ts +12 -2
  202. package/dist/src/lib/records-verbs.js +7 -2
  203. package/dist/src/lib/records-verbs.js.map +1 -1
  204. package/dist/src/lib/register-commands.d.ts +28 -0
  205. package/dist/src/lib/register-commands.js +101 -0
  206. package/dist/src/lib/register-commands.js.map +1 -0
  207. package/dist/src/lib/retired-imports.d.ts +53 -0
  208. package/dist/src/lib/retired-imports.js +120 -0
  209. package/dist/src/lib/retired-imports.js.map +1 -0
  210. package/dist/src/lib/schema-codegen/compiledSpace.d.ts +62 -0
  211. package/dist/src/lib/schema-codegen/compiledSpace.js +103 -0
  212. package/dist/src/lib/schema-codegen/compiledSpace.js.map +1 -0
  213. package/dist/src/lib/schema-codegen/generated-db3-bridge.d.ts +86 -0
  214. package/dist/src/lib/schema-codegen/generated-db3-bridge.js +221 -0
  215. package/dist/src/lib/schema-codegen/generated-db3-bridge.js.map +1 -0
  216. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.d.ts +85 -0
  217. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js +86 -0
  218. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js.map +1 -0
  219. package/dist/src/lib/schema-codegen/generated-field-grammar.d.ts +209 -0
  220. package/dist/src/lib/schema-codegen/generated-field-grammar.js +379 -0
  221. package/dist/src/lib/schema-codegen/generated-field-grammar.js.map +1 -0
  222. package/dist/src/lib/schema-codegen/generated-field-table.d.ts +80 -0
  223. package/dist/src/lib/schema-codegen/generated-field-table.js +542 -0
  224. package/dist/src/lib/schema-codegen/generated-field-table.js.map +1 -0
  225. package/dist/src/lib/schema-codegen/generated-prompt-schemas.d.ts +195 -0
  226. package/dist/src/lib/schema-codegen/generated-prompt-schemas.js +503 -0
  227. package/dist/src/lib/schema-codegen/generated-prompt-schemas.js.map +1 -0
  228. package/dist/src/lib/schema-codegen/generated-schema-descriptor.d.ts +129 -0
  229. package/dist/src/lib/schema-codegen/generated-schema-descriptor.js +154 -1
  230. package/dist/src/lib/schema-codegen/generated-schema-descriptor.js.map +1 -1
  231. package/dist/src/lib/schema-codegen/generated-schema-file.d.ts +129 -0
  232. package/dist/src/lib/schema-codegen/generated-schema-file.js +475 -0
  233. package/dist/src/lib/schema-codegen/generated-schema-file.js.map +1 -0
  234. package/dist/src/lib/schema-codegen/generated-schema-provenance.d.ts +115 -0
  235. package/dist/src/lib/schema-codegen/generated-schema-provenance.js +274 -0
  236. package/dist/src/lib/schema-codegen/generated-schema-provenance.js.map +1 -0
  237. package/dist/src/lib/schema-codegen/generated-schema-refs.d.ts +366 -0
  238. package/dist/src/lib/schema-codegen/generated-schema-refs.js +1789 -0
  239. package/dist/src/lib/schema-codegen/generated-schema-refs.js.map +1 -0
  240. package/dist/src/lib/schema-codegen/namedRefs.d.ts +56 -0
  241. package/dist/src/lib/schema-codegen/namedRefs.js +143 -0
  242. package/dist/src/lib/schema-codegen/namedRefs.js.map +1 -0
  243. package/dist/src/lib/schema-codegen/schemaChanges.d.ts +74 -0
  244. package/dist/src/lib/schema-codegen/schemaChanges.js +277 -0
  245. package/dist/src/lib/schema-codegen/schemaChanges.js.map +1 -0
  246. package/dist/src/lib/schema-codegen/schemaDocs.d.ts +69 -0
  247. package/dist/src/lib/schema-codegen/schemaDocs.js +219 -0
  248. package/dist/src/lib/schema-codegen/schemaDocs.js.map +1 -0
  249. package/dist/src/lib/schema-codegen/schemaIR.d.ts +158 -0
  250. package/dist/src/lib/schema-codegen/schemaIR.js +279 -0
  251. package/dist/src/lib/schema-codegen/schemaIR.js.map +1 -0
  252. package/dist/src/lib/schema-codegen/schemaToTs.d.ts +40 -13
  253. package/dist/src/lib/schema-codegen/schemaToTs.js +124 -160
  254. package/dist/src/lib/schema-codegen/schemaToTs.js.map +1 -1
  255. package/dist/src/lib/schema-codegen/valuesLists.d.ts +35 -0
  256. package/dist/src/lib/schema-codegen/valuesLists.js +128 -0
  257. package/dist/src/lib/schema-codegen/valuesLists.js.map +1 -0
  258. package/dist/src/lib/schema-family-index.d.ts +228 -0
  259. package/dist/src/lib/schema-family-index.js +813 -0
  260. package/dist/src/lib/schema-family-index.js.map +1 -0
  261. package/dist/src/lib/schema-pins.d.ts +82 -0
  262. package/dist/src/lib/schema-pins.js +198 -0
  263. package/dist/src/lib/schema-pins.js.map +1 -0
  264. package/dist/src/lib/schema-preview.d.ts +244 -0
  265. package/dist/src/lib/schema-preview.js +498 -0
  266. package/dist/src/lib/schema-preview.js.map +1 -0
  267. package/dist/src/lib/skill-installer.d.ts +2 -2
  268. package/dist/src/lib/skill-installer.js +2 -21
  269. package/dist/src/lib/skill-installer.js.map +1 -1
  270. package/dist/src/lib/step-run-table.d.ts +1 -2
  271. package/dist/src/lib/step-run-table.js +1 -2
  272. package/dist/src/lib/step-run-table.js.map +1 -1
  273. package/dist/src/lib/swift-codegen/agentGenerator.d.ts +2 -1
  274. package/dist/src/lib/swift-codegen/agentGenerator.js +24 -22
  275. package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -1
  276. package/dist/src/lib/swift-codegen/banners.d.ts +12 -0
  277. package/dist/src/lib/swift-codegen/banners.js +12 -0
  278. package/dist/src/lib/swift-codegen/banners.js.map +1 -1
  279. package/dist/src/lib/swift-codegen/functionGenerator.d.ts +36 -1
  280. package/dist/src/lib/swift-codegen/functionGenerator.js +167 -50
  281. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
  282. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +31 -7
  283. package/dist/src/lib/swift-codegen/schemaToSwift.js +213 -177
  284. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -1
  285. package/dist/src/lib/swift-codegen/sharedGenerator.d.ts +45 -0
  286. package/dist/src/lib/swift-codegen/sharedGenerator.js +120 -0
  287. package/dist/src/lib/swift-codegen/sharedGenerator.js.map +1 -0
  288. package/dist/src/lib/swift-codegen/userPropertiesGenerator.d.ts +30 -0
  289. package/dist/src/lib/swift-codegen/userPropertiesGenerator.js +69 -0
  290. package/dist/src/lib/swift-codegen/userPropertiesGenerator.js.map +1 -0
  291. package/dist/src/lib/sync-resource-types.d.ts +37 -5
  292. package/dist/src/lib/sync-resource-types.js +53 -5
  293. package/dist/src/lib/sync-resource-types.js.map +1 -1
  294. package/dist/src/lib/sync-selectors.d.ts +7 -0
  295. package/dist/src/lib/sync-selectors.js +22 -2
  296. package/dist/src/lib/sync-selectors.js.map +1 -1
  297. package/dist/src/lib/test-runs.d.ts +45 -0
  298. package/dist/src/lib/test-runs.js +150 -0
  299. package/dist/src/lib/test-runs.js.map +1 -0
  300. package/dist/src/lib/test-users.d.ts +25 -0
  301. package/dist/src/lib/test-users.js +36 -0
  302. package/dist/src/lib/test-users.js.map +1 -0
  303. package/dist/src/lib/toml-database-config.d.ts +2 -1
  304. package/dist/src/lib/toml-database-config.js +4 -3
  305. package/dist/src/lib/toml-database-config.js.map +1 -1
  306. package/dist/src/lib/toml-scalar-edit.js +6 -4
  307. package/dist/src/lib/toml-scalar-edit.js.map +1 -1
  308. package/dist/src/lib/user-index.d.ts +80 -0
  309. package/dist/src/lib/user-index.js +166 -0
  310. package/dist/src/lib/user-index.js.map +1 -0
  311. package/dist/src/lib/user-properties/generated-properties-schema.d.ts +159 -0
  312. package/dist/src/lib/user-properties/generated-properties-schema.js +471 -0
  313. package/dist/src/lib/user-properties/generated-properties-schema.js.map +1 -0
  314. package/dist/src/lib/user-properties/user-properties-codegen.d.ts +55 -0
  315. package/dist/src/lib/user-properties/user-properties-codegen.js +129 -0
  316. package/dist/src/lib/user-properties/user-properties-codegen.js.map +1 -0
  317. package/dist/src/lib/user-walk.d.ts +31 -0
  318. package/dist/src/lib/user-walk.js +102 -0
  319. package/dist/src/lib/user-walk.js.map +1 -0
  320. package/dist/src/lib/worker-perf-format.d.ts +22 -0
  321. package/dist/src/lib/worker-perf-format.js +27 -0
  322. package/dist/src/lib/worker-perf-format.js.map +1 -0
  323. package/dist/src/types/index.d.ts +13 -34
  324. package/package.json +5 -3
@@ -0,0 +1,92 @@
1
+ /**
2
+ * A prompt file's schemas, as the compile and the dependency graph read them
3
+ * (#5534, project `unified-schemas` phase 3).
4
+ *
5
+ * A `prompts/<key>.toml` holds schemas in `[prompt].inputSchema`,
6
+ * `[prompt].outputSchema`, the `[prompt.agent]` declaration's slots, and each
7
+ * `[[configs]]` entry's `[configs.chat].outputSchema`. Each sits at a
8
+ * location in the prompt (`input`, `output`, `tools/<name>/input`,
9
+ * `events/<kind>`, `turnContext`, `configs/<name>/output`), which is how a
10
+ * ref chain names where a ref was written.
11
+ */
12
+ import { basename } from "path";
13
+ import { agentSchemaSlots } from "./schema-codegen/generated-prompt-schemas.js";
14
+ function isPlainObject(value) {
15
+ return value !== null && typeof value === "object" && !Array.isArray(value);
16
+ }
17
+ /** A value as authored: a JSON-string spelling parsed, anything else as it is. */
18
+ export function authoredSchemaValue(value) {
19
+ if (typeof value !== "string")
20
+ return value;
21
+ try {
22
+ return JSON.parse(value);
23
+ }
24
+ catch {
25
+ return value;
26
+ }
27
+ }
28
+ /** The key a prompt file pushes as: `[prompt].key`, else the file name. */
29
+ export function promptFileKey(file, parsed) {
30
+ const key = parsed?.prompt?.key;
31
+ return typeof key === "string" && key !== "" ? key : basename(file, ".toml");
32
+ }
33
+ /** The name a `[[configs]]` entry is pushed under, or its position when it names none. */
34
+ export function promptConfigName(entry, index) {
35
+ return typeof entry?.name === "string" && entry.name !== "" ? entry.name : `configs[${index}]`;
36
+ }
37
+ /** The schemas a parsed prompt file carries, as `compilePromptSchemas` reads them; a field the file omits is not carried. */
38
+ export function promptSchemaDocumentOf(parsed) {
39
+ const prompt = isPlainObject(parsed?.prompt) ? parsed.prompt : {};
40
+ const document = {};
41
+ if (prompt.inputSchema !== undefined)
42
+ document.inputSchema = prompt.inputSchema;
43
+ if (prompt.outputSchema !== undefined)
44
+ document.outputSchema = prompt.outputSchema;
45
+ if (prompt.agent !== undefined)
46
+ document.agent = prompt.agent;
47
+ const configs = Array.isArray(parsed?.configs) ? parsed.configs : [];
48
+ if (configs.length > 0) {
49
+ document.configs = configs.map((entry, index) => ({
50
+ name: promptConfigName(entry, index),
51
+ outputSchema: isPlainObject(entry?.chat) ? entry.chat.outputSchema : undefined,
52
+ }));
53
+ }
54
+ return document;
55
+ }
56
+ /** Every schema a prompt document carries, at its location. */
57
+ export function promptSchemaLocations(document) {
58
+ const out = [];
59
+ if (document.inputSchema !== undefined)
60
+ out.push({ location: "input", field: "inputSchema", prefix: "", document: authoredSchemaValue(document.inputSchema) });
61
+ if (document.outputSchema !== undefined)
62
+ out.push({ location: "output", field: "outputSchema", prefix: "", document: authoredSchemaValue(document.outputSchema) });
63
+ if (document.agent !== undefined) {
64
+ for (const slot of agentSchemaSlots(document.agent)) {
65
+ out.push({ location: slot.target ?? "turnContext", field: "agent", prefix: slot.pointer, document: slot.schema });
66
+ }
67
+ }
68
+ for (const config of document.configs ?? []) {
69
+ if (config.outputSchema !== undefined)
70
+ out.push({ location: `configs/${config.name}/output`, field: "outputSchema", prefix: "", document: authoredSchemaValue(config.outputSchema) });
71
+ }
72
+ return out;
73
+ }
74
+ /** The server tools a declaration (a table or one JSON string) names: tool name → function key. */
75
+ export function agentServerTools(agent) {
76
+ const parsed = authoredSchemaValue(agent);
77
+ const tools = new Map();
78
+ if (!isPlainObject(parsed) || !Array.isArray(parsed.tools))
79
+ return tools;
80
+ for (const tool of parsed.tools) {
81
+ if (isPlainObject(tool) && typeof tool.name === "string" && typeof tool.function === "string" && !tools.has(tool.name))
82
+ tools.set(tool.name, tool.function);
83
+ }
84
+ return tools;
85
+ }
86
+ /** The tree-relative spelling of a prompt file (`prompts/<key>.toml`), for messages. */
87
+ export function promptFileLabel(filePath) {
88
+ const posix = filePath.replace(/\\/g, "/");
89
+ const at = posix.lastIndexOf("/prompts/");
90
+ return at >= 0 ? posix.slice(at + 1) : posix;
91
+ }
92
+ //# sourceMappingURL=prompt-schema-document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-schema-document.js","sourceRoot":"","sources":["../../../src/lib/prompt-schema-document.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAA6B,MAAM,8CAA8C,CAAC;AAE3G,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,MAAW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AC,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,164 @@
1
+ /**
2
+ * A prompt file's schemas, compiled the way the server compiles them (#5534,
3
+ * project `unified-schemas` phase 3, spec DSO-5534-009).
4
+ *
5
+ * A prompt's `[prompt].inputSchema`, `[prompt].outputSchema`, every slot of
6
+ * its `[prompt.agent]` declaration and each `[[configs]]` entry's
7
+ * `outputSchema` may carry `$defs`, local refs, and refs to the tree's
8
+ * `schemas/` defs, to another prompt's schemas and to a function's. The
9
+ * server compiles each write against its stored rows and stores the compiled
10
+ * schema, so every LOCAL reader that pushes or compares a prompt file reads
11
+ * the compiled document `compilePromptToml` answers: the local side of
12
+ * `config diff` and the push gate, the semantic hash, the preflight. The push
13
+ * bodies carry the AUTHORED schemas, with the compile and its provenance
14
+ * beside them (`promptSchemaPayload`), which the server recompiles and
15
+ * compares. Codegen keeps reading the authored file.
16
+ *
17
+ * Never run it on a document built from a stored row: the stored side is
18
+ * compared exactly as stored.
19
+ */
20
+ import { type PromptSchemaCompile, type PromptSchemaField } from "./schema-codegen/generated-prompt-schemas.js";
21
+ import { type SchemaFamilyIndex } from "./schema-codegen/generated-schema-refs.js";
22
+ import { type SchemaProvenance } from "./schema-codegen/generated-schema-provenance.js";
23
+ import { type SyncSelection } from "./sync-selectors.js";
24
+ /** The index a prompt compile reads, or the loader that reads it when a schema needs it. */
25
+ export type PromptFamilySource = SchemaFamilyIndex | (() => SchemaFamilyIndex);
26
+ /** A prompt file's parsed document with its schemas compiled. */
27
+ export interface CompiledPromptToml {
28
+ /**
29
+ * The parsed document, with each schema field (and each config's
30
+ * `outputSchema`) replaced by its compiled form where the compile changed
31
+ * it; the same object as the input when nothing changed.
32
+ */
33
+ parsed: any;
34
+ /** One line per inert `$ref`: `<file>: <field> #<path>: $ref "<ref>" stays inert (<reason>)`. */
35
+ warnings: string[];
36
+ /** The compile refusal, naming the file, or null. */
37
+ refusal: string | null;
38
+ /** The compile itself, for the payload; null for a document with no `[prompt]` table. */
39
+ compile: PromptSchemaCompile | null;
40
+ }
41
+ /** The authored document a compiled one came from, or the document itself. */
42
+ export declare function authoredPromptDocument(document: any): any;
43
+ /**
44
+ * Compile the schemas of a parsed `prompts/<key>.toml` (see the module note).
45
+ * With `families`, refs resolve against the tree's index; a loader is called
46
+ * only when a schema writes a family-spelled ref. A field the compile leaves
47
+ * unchanged keeps its authored spelling.
48
+ */
49
+ export declare function compilePromptToml(file: string, parsed: any, families?: PromptFamilySource): CompiledPromptToml;
50
+ /** What a prompt create or update carries beside the authored schemas: each field's compile and provenance. */
51
+ export interface PromptSchemaPayload {
52
+ compiled: Partial<Record<PromptSchemaField, unknown>>;
53
+ provenance: Partial<Record<PromptSchemaField, SchemaProvenance>>;
54
+ }
55
+ /** What a config create or update carries beside its authored `outputSchema`. */
56
+ export interface PromptConfigSchemaPayload {
57
+ compiled: {
58
+ outputSchema: unknown;
59
+ };
60
+ provenance: {
61
+ outputSchema: SchemaProvenance;
62
+ };
63
+ }
64
+ /**
65
+ * The compiled payload for a compiled prompt file's `[prompt]` fields: each
66
+ * field the file carries, compiled, and its provenance. The compile must have
67
+ * run with a family index.
68
+ */
69
+ export declare function promptSchemaPayload(compiled: CompiledPromptToml): Promise<PromptSchemaPayload>;
70
+ /** The compiled payload for a compiled prompt file's `[[configs]]` entry at `index`, or null when it carries no `outputSchema`. */
71
+ export declare function promptConfigSchemaPayload(compiled: CompiledPromptToml, index: number): Promise<PromptConfigSchemaPayload | null>;
72
+ /**
73
+ * Attach a compiled payload to a push body: `compiled` and `provenance` for
74
+ * each schema field the body carries with a value, and neither key when it
75
+ * carries none.
76
+ */
77
+ export declare function withSchemaPayload(body: Record<string, any>, payload: {
78
+ compiled: Record<string, unknown>;
79
+ provenance: Record<string, unknown>;
80
+ } | null | undefined): Record<string, any>;
81
+ /**
82
+ * The preflight for prompt schemas: one line per selected prompt file the
83
+ * compile refuses, a cycle of prompts included, naming the file. A ref to a
84
+ * prompt, function or `schemas/` file the tree (and, once told, the server)
85
+ * lacks is such a refusal.
86
+ */
87
+ export declare function collectPromptSchemaPreflight(configDir: string, selection: SyncSelection | null): string[];
88
+ /**
89
+ * The cycle refusal of the prompt file at `filePath`, naming the chain, when
90
+ * the file is one of a cycle of prompts in its tree; null otherwise. A cycle
91
+ * member's own compile names only the dependency it cannot read.
92
+ */
93
+ export declare function promptSchemaCycleError(filePath: string): string | null;
94
+ /** The keys a tree's prompt files ref that the tree has no file for: what the push asks the server about. */
95
+ export declare function promptRefsMissingFromTree(configDir: string): {
96
+ prompts: string[];
97
+ functions: string[];
98
+ };
99
+ /** Where `config push` must place each prompt file (DSO-5534-014). */
100
+ export interface PromptPushDependencies {
101
+ /** Each file's prompt files, among those pushed, that it refs (any spelling). */
102
+ dependsOn: ReadonlyMap<string, readonly string[]>;
103
+ /** Each file that must follow the functions leg on its own account, with why: a function this push changes, or a server tool. */
104
+ functionReasons: ReadonlyMap<string, readonly string[]>;
105
+ /** Each file's kind. */
106
+ kinds: ReadonlyMap<string, string>;
107
+ }
108
+ /** #5540 — what the db3 legs of a push apply: the types (each with its file) and the `schemas/` files deferred after them (each with those files). */
109
+ export interface PromptPushDb3 {
110
+ applied: ReadonlyMap<string, string>;
111
+ deferredSchemas: ReadonlyMap<string, readonly string[]>;
112
+ }
113
+ /**
114
+ * The dependencies among prompt `files` (names under `prompts/`) a push
115
+ * places them by: the prompt files each one refs, and whether it refs a
116
+ * function in `changedFunctions` (one this push creates or changes) or a
117
+ * server tool, which puts it after the functions leg. #5540 — so does a ref
118
+ * to a db3 type this push applies, or to a `schemas/` file deferred after the
119
+ * db3 legs (`db3`), the type's file as the reason.
120
+ */
121
+ export declare function promptPushDependencies(configDir: string, files: readonly string[], changedFunctions: ReadonlySet<string>, db3?: PromptPushDb3): PromptPushDependencies;
122
+ /**
123
+ * The preflight for the #4441 exception (DSO-5534-014): an agent file the
124
+ * function-change preflight applies before the functions leg cannot depend on
125
+ * a prompt file applied after it, or on a function this push changes.
126
+ */
127
+ export declare function promptPlacementErrors(dependencies: PromptPushDependencies, agentFilesFirst: readonly string[]): string[];
128
+ /**
129
+ * What a selection of prompt files reaches through its refs: the other
130
+ * prompt files (by key, transitively), and the functions they ref directly or
131
+ * through a server tool. With no selection, every prompt file is a start.
132
+ */
133
+ export declare function promptDependenciesOf(configDir: string, selection: SyncSelection | null): {
134
+ prompts: string[];
135
+ functions: string[];
136
+ };
137
+ /** The reads `preparePromptSchemaRefs` makes. */
138
+ export interface PromptSchemaRefsClient {
139
+ listPromptRecords(): Promise<any[]>;
140
+ getPrompt(promptId: string): Promise<any>;
141
+ listFunctions(): Promise<any[]>;
142
+ listSchemaFiles(): Promise<Array<{
143
+ file: string;
144
+ version: number;
145
+ tombstone: boolean;
146
+ }>>;
147
+ }
148
+ /**
149
+ * Before a push compiles its prompt files (#5534, DSO-5534-009): tell the
150
+ * tree's index what the server holds for every prompt, function and
151
+ * `schemas/` file a prompt refs that the tree lacks, and compile refs to a
152
+ * function this push does not select against the server's stored version. A
153
+ * `<key>.<part>` short ref first reads the server's prompt and function keys.
154
+ * Reads nothing when every ref is a long or explicit form naming a file in
155
+ * the tree and the push selects every function it names. Answers one error per function a selected prompt
156
+ * refs that the push neither selects nor finds on the server.
157
+ */
158
+ export declare function preparePromptSchemaRefs(input: {
159
+ configDir: string;
160
+ selection: SyncSelection | null;
161
+ /** The function keys this push applies. */
162
+ selectedFunctions: ReadonlySet<string>;
163
+ client: PromptSchemaRefsClient;
164
+ }): Promise<string[]>;