@pikku/cli 0.12.93 → 0.12.99

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 (346) hide show
  1. package/console-app/assets/abnfDiagram-VRR7QNED-CytV-CG1.js +1 -0
  2. package/console-app/assets/arc-C5PvmnaA.js +1 -0
  3. package/console-app/assets/architecture-TIHT7OUA-C1_ScvPX.js +1 -0
  4. package/console-app/assets/architectureDiagram-ZJ3FMSHR-CJ2xb7C-.js +36 -0
  5. package/console-app/assets/array-BifhSqXX.js +1 -0
  6. package/console-app/assets/blockDiagram-677ZJIJ3-CCecrBrk.js +132 -0
  7. package/console-app/assets/c4Diagram-LMCZKHZV-CBnpukvQ.js +10 -0
  8. package/console-app/assets/channel-CwDOkXGI.js +1 -0
  9. package/console-app/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  10. package/console-app/assets/chunk-32BRIVSS-D8qWWZRQ.js +1 -0
  11. package/console-app/assets/chunk-52WLFC77-BEpXHMsp.js +10 -0
  12. package/console-app/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
  13. package/console-app/assets/chunk-7BUUIJ7U-Bb538aSH.js +1 -0
  14. package/console-app/assets/chunk-C7G6YPKG-DsHUMkOp.js +1 -0
  15. package/console-app/assets/chunk-EX3LRPZG-mM7TjVx9.js +231 -0
  16. package/console-app/assets/chunk-FWX5IMBZ-CndRAn18.js +2 -0
  17. package/console-app/assets/chunk-HOUHSVGY-D1kT8umn.js +1 -0
  18. package/console-app/assets/chunk-ICXQ74PX-CeSaGyro.js +2 -0
  19. package/console-app/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  20. package/console-app/assets/chunk-KEIR6QF5-DNzq6p3w.js +161 -0
  21. package/console-app/assets/chunk-MOJQB5TN-CaZOCHYr.js +88 -0
  22. package/console-app/assets/chunk-OGEWGWER-CnB1CsPt.js +1 -0
  23. package/console-app/assets/chunk-PUDLZKDR-BbGulHJm.js +156 -0
  24. package/console-app/assets/chunk-Q4XR5HBZ-BywwzeeR.js +70 -0
  25. package/console-app/assets/chunk-RYQCIY6F-CV0R1Adv.js +1 -0
  26. package/console-app/assets/chunk-V7JOEXUC-DGFaAWzB.js +206 -0
  27. package/console-app/assets/chunk-VAUOI2AC-DxPUd8Yb.js +1 -0
  28. package/console-app/assets/chunk-VR4S4FIN-D4-UaW_J.js +1 -0
  29. package/console-app/assets/chunk-WYO6CB5R-D_TFN0d9.js +127 -0
  30. package/console-app/assets/chunk-XXDRQBXY-BzVuweA_.js +1 -0
  31. package/console-app/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  32. package/console-app/assets/chunk-ZGVPDNZ5-C6hdkGQb.js +62 -0
  33. package/console-app/assets/chunk-ZIRB5QZD-H-kepumB.js +32 -0
  34. package/console-app/assets/classDiagram-OUVF2IWQ-CTYJkTT0.js +1 -0
  35. package/console-app/assets/classDiagram-v2-EOCWNBFH-CTYJkTT0.js +1 -0
  36. package/console-app/assets/cose-bilkent-JH36ORCC-B6ZPxN6v.js +1 -0
  37. package/console-app/assets/cynefin-VYW2F7L2-D_nmxNz_.js +1 -0
  38. package/console-app/assets/cynefinDiagram-TSTJHNR4-CHy5QN0S.js +62 -0
  39. package/console-app/assets/cytoscape.esm-h6BdjjI9.js +321 -0
  40. package/console-app/assets/dagre-CXRCoUWR.js +1 -0
  41. package/console-app/assets/dagre-VKFMJZFB-DYfukM34.js +4 -0
  42. package/console-app/assets/defaultLocale-C8Fc0cco.js +1 -0
  43. package/console-app/assets/diagram-FQU43EPY-Dgb9TPSB.js +3 -0
  44. package/console-app/assets/diagram-G47NLZAW-CnFNZs9Z.js +24 -0
  45. package/console-app/assets/diagram-NH7WQ7WH-DN7h2DU-.js +24 -0
  46. package/console-app/assets/diagram-OA4YK3LP-RLaQaNtK.js +30 -0
  47. package/console-app/assets/diagram-WEI45ONY-DxHWhVGd.js +41 -0
  48. package/console-app/assets/dist-BaJNIo4I.js +1 -0
  49. package/console-app/assets/ebnfDiagram-CCIWWBDH-UN3Z81-l.js +1 -0
  50. package/console-app/assets/erDiagram-Q63AITRT-C9lGAY3i.js +85 -0
  51. package/console-app/assets/eventmodeling-45OFAUF4-Dc5wNSSK.js +1 -0
  52. package/console-app/assets/flowDiagram-23GEKE2U-zPyGHMi4.js +1 -0
  53. package/console-app/assets/ganttDiagram-NO4QXBWP-CvBjBcdK.js +292 -0
  54. package/console-app/assets/gitGraph-TEB2WS4Q-Cs5Z9jMo.js +1 -0
  55. package/console-app/assets/gitGraphDiagram-IHSO6WYX-B0i_IJ5r.js +106 -0
  56. package/console-app/assets/graphlib-B8gBHxth.js +1 -0
  57. package/console-app/assets/{index-CmAplHjZ.js → index-71U8EEj7.js} +155 -153
  58. package/console-app/assets/{index-BYj7ZbUU.css → index-BXMjqLQ5.css} +1 -1
  59. package/console-app/assets/info-DKCQHKI2-DHL0afNl.js +1 -0
  60. package/console-app/assets/infoDiagram-FWYZ7A6U-CBWykodX.js +2 -0
  61. package/console-app/assets/init-D6jRqBbL.js +1 -0
  62. package/console-app/assets/ishikawaDiagram-FXEZZL3T-DM377eW_.js +70 -0
  63. package/console-app/assets/journeyDiagram-5HDEW3XC-BpX_-Cns.js +139 -0
  64. package/console-app/assets/kanban-definition-HUTT4EX6-D3xFsQkO.js +89 -0
  65. package/console-app/assets/katex-Vhh-h91d.js +257 -0
  66. package/console-app/assets/line-CTSKHTE0.js +1 -0
  67. package/console-app/assets/linear-R5GlBvXT.js +1 -0
  68. package/console-app/assets/map-DsCK-0Cs.js +1 -0
  69. package/console-app/assets/mermaid-parser.core-CkHk4BPi.js +7 -0
  70. package/console-app/assets/mermaid.core-CcjGXuV6.js +11 -0
  71. package/console-app/assets/mindmap-definition-LN4V7U3C-CtolazqQ.js +96 -0
  72. package/console-app/assets/ordinal-hYBb2elL.js +1 -0
  73. package/console-app/assets/packet-7NZHBO7P-BxSOj_Ny.js +1 -0
  74. package/console-app/assets/path-BWPyau1x.js +1 -0
  75. package/console-app/assets/pegDiagram-2B236MQR-BNsMtxsM.js +1 -0
  76. package/console-app/assets/pie-RZYD4A2V-BbkKQBA5.js +1 -0
  77. package/console-app/assets/pieDiagram-ENE6RG2P-BAZLIz2f.js +39 -0
  78. package/console-app/assets/quadrantDiagram-ABIIQ3AL-Dpvn-1Fs.js +7 -0
  79. package/console-app/assets/radar-I7S5WNFK-B-uKXIAH.js +1 -0
  80. package/console-app/assets/railroad-3IZDKUUU-BHXXK04t.js +1 -0
  81. package/console-app/assets/railroad-abnf-AHOZXSZD-tXSQaBvY.js +1 -0
  82. package/console-app/assets/railroad-ebnf-EBAXGLYW-DG3aohR0.js +1 -0
  83. package/console-app/assets/railroad-peg-LSFZ7HO6-DY_gBA-x.js +1 -0
  84. package/console-app/assets/railroadDiagram-RFXS5EU6-DfUApEQj.js +1 -0
  85. package/console-app/assets/requirementDiagram-TGXJPOKE-B2zX0jqo.js +84 -0
  86. package/console-app/assets/rough.esm-CSKSodPl.js +1 -0
  87. package/console-app/assets/sankeyDiagram-HTMAVEWB-CbQ2zc7z.js +40 -0
  88. package/console-app/assets/sequenceDiagram-DBY2YBRQ-BLT8PXI_.js +162 -0
  89. package/console-app/assets/sizeCapture-X5ZJPWSS-B0uUizjq.js +1 -0
  90. package/console-app/assets/src-BLuPUFWW.js +1 -0
  91. package/console-app/assets/stateDiagram-2N3HPSRC-BvEyVp85.js +1 -0
  92. package/console-app/assets/stateDiagram-v2-6OUMAXLB-RGKS9iU4.js +1 -0
  93. package/console-app/assets/swimlanes-5IMT3BWC-1AZ459s6.js +2 -0
  94. package/console-app/assets/swimlanesDiagram-G3AALYLV-Ck_0-rfN.js +8 -0
  95. package/console-app/assets/timeline-definition-FHXFAJF6-dLuvH4s2.js +120 -0
  96. package/console-app/assets/treeView-QDETBFTQ-xL2msjo2.js +1 -0
  97. package/console-app/assets/treemap-6X3UGDF4-C98ichVP.js +1 -0
  98. package/console-app/assets/vennDiagram-L72KCM5P-HbUmidhv.js +34 -0
  99. package/console-app/assets/wardley-OPB4EBWU-C4gJS-m2.js +1 -0
  100. package/console-app/assets/wardleyDiagram-EHGQE667-B7b-LB02.js +78 -0
  101. package/console-app/assets/xychartDiagram-FW5EYKEG-Cm03zUGy.js +7 -0
  102. package/console-app/index.html +2 -2
  103. package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +1 -1
  104. package/dist/.pikku/auth/auth.types.d.ts +1 -1
  105. package/dist/.pikku/auth/auth.types.js +1 -1
  106. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +1 -1
  107. package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
  108. package/dist/.pikku/cli/pikku-cli-channel.d.ts +13 -15
  109. package/dist/.pikku/cli/pikku-cli-channel.js +62 -8
  110. package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +14 -4
  111. package/dist/.pikku/cli/pikku-cli-client.gen.js +55 -18
  112. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.d.ts +1 -1
  113. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.js +1 -1
  114. package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
  115. package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
  116. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +1 -1
  117. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +136 -10
  118. package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
  119. package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
  120. package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
  121. package/dist/.pikku/cli/pikku-cli.gen.js +18 -2
  122. package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
  123. package/dist/.pikku/function/pikku-function-types.gen.d.ts +64 -23
  124. package/dist/.pikku/function/pikku-function-types.gen.js +27 -1
  125. package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
  126. package/dist/.pikku/function/pikku-functions-meta.gen.json +171 -37
  127. package/dist/.pikku/function/pikku-functions.gen.js +13 -3
  128. package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
  129. package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
  130. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
  131. package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
  132. package/dist/.pikku/pikku-bootstrap-scenarios.gen.d.ts +1 -1
  133. package/dist/.pikku/pikku-bootstrap-scenarios.gen.js +1 -1
  134. package/dist/.pikku/pikku-bootstrap.gen.d.ts +1 -1
  135. package/dist/.pikku/pikku-bootstrap.gen.js +1 -1
  136. package/dist/.pikku/pikku-meta-service.gen.d.ts +1 -1
  137. package/dist/.pikku/pikku-meta-service.gen.js +1 -1
  138. package/dist/.pikku/pikku-services.gen.d.ts +2 -1
  139. package/dist/.pikku/pikku-services.gen.js +1 -0
  140. package/dist/.pikku/pikku-types.gen.d.ts +1 -1
  141. package/dist/.pikku/pikku-types.gen.js +1 -1
  142. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
  143. package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
  144. package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +1 -1
  145. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
  146. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
  147. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
  148. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +8 -1
  149. package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.js +1 -1
  150. package/dist/.pikku/scenarios/pikku-scenario-functions.gen.d.ts +1 -1
  151. package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.js +1 -1
  152. package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.d.ts +1 -1
  153. package/dist/.pikku/scenarios/schemas/register.gen.d.ts +1 -1
  154. package/dist/.pikku/scenarios/schemas/register.gen.js +1 -1
  155. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
  156. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
  157. package/dist/.pikku/schemas/register.gen.js +15 -5
  158. package/dist/.pikku/schemas/schemas/DbResetInput.schema.json +1 -1
  159. package/dist/.pikku/schemas/schemas/PersonaRunInput.schema.json +1 -0
  160. package/dist/.pikku/schemas/schemas/PersonaSyncInput.schema.json +1 -0
  161. package/dist/.pikku/schemas/schemas/PikkuPersonasInput.schema.json +1 -0
  162. package/dist/.pikku/schemas/schemas/PikkuRolesInput.schema.json +1 -0
  163. package/dist/.pikku/schemas/schemas/PikkuVirtualUserFunctionsOutput.schema.json +1 -0
  164. package/dist/.pikku/schemas/schemas/RolesPruneInput.schema.json +1 -0
  165. package/dist/.pikku/scopes/pikku-personas-meta.gen.json +1 -0
  166. package/dist/.pikku/scopes/pikku-personas.gen.d.ts +36 -0
  167. package/dist/.pikku/scopes/pikku-personas.gen.js +17 -0
  168. package/dist/.pikku/scopes/pikku-roles-meta.gen.json +1 -0
  169. package/dist/.pikku/scopes/pikku-roles.gen.d.ts +30 -0
  170. package/dist/.pikku/scopes/pikku-roles.gen.js +18 -0
  171. package/dist/.pikku/scopes/pikku-scope-types.gen.d.ts +4 -2
  172. package/dist/.pikku/scopes/pikku-scope-types.gen.js +3 -2
  173. package/dist/.pikku/scopes/pikku-scopes.gen.d.ts +1 -1
  174. package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +2 -2
  175. package/dist/.pikku/secrets/pikku-secret-types.gen.js +2 -2
  176. package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
  177. package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
  178. package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
  179. package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
  180. package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +2 -2
  181. package/dist/.pikku/variables/pikku-variable-types.gen.js +2 -2
  182. package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
  183. package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
  184. package/dist/.pikku/workflow/meta/allWorkflow.gen.json +46 -16
  185. package/dist/.pikku/workflow/pikku-personas.gen.d.ts +15 -0
  186. package/dist/.pikku/workflow/pikku-personas.gen.js +17 -0
  187. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +101 -24
  188. package/dist/.pikku/workflow/pikku-workflow-types.gen.js +22 -2
  189. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
  190. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
  191. package/dist/bin/pikku-bin.mjs +2 -2
  192. package/dist/bin/pikku.js +0 -0
  193. package/dist/src/cli.wiring.js +108 -8
  194. package/dist/src/deploy/analyzer/analyzer.js +14 -0
  195. package/dist/src/deploy/analyzer/manifest.d.ts +11 -0
  196. package/dist/src/fabric/functions/validate.function.js +77 -177
  197. package/dist/src/functions/commands/all.d.ts +1 -1
  198. package/dist/src/functions/commands/bootstrap.d.ts +1 -1
  199. package/dist/src/functions/commands/bootstrap.js +3 -0
  200. package/dist/src/functions/commands/db-audit.js +1 -1
  201. package/dist/src/functions/commands/db-baseline.js +1 -1
  202. package/dist/src/functions/commands/db-check.js +6 -5
  203. package/dist/src/functions/commands/db-codegen.js +1 -1
  204. package/dist/src/functions/commands/db-generate.js +1 -1
  205. package/dist/src/functions/commands/db-migrate.js +1 -1
  206. package/dist/src/functions/commands/db-reset.d.ts +15 -1
  207. package/dist/src/functions/commands/db-reset.js +18 -6
  208. package/dist/src/functions/commands/db-shared.d.ts +14 -0
  209. package/dist/src/functions/commands/deploy-info.d.ts +1 -1
  210. package/dist/src/functions/commands/dev-ai-runner.d.ts +16 -4
  211. package/dist/src/functions/commands/dev-ai-runner.js +63 -29
  212. package/dist/src/functions/commands/dev.js +10 -5
  213. package/dist/src/functions/commands/enable.d.ts +8 -8
  214. package/dist/src/functions/commands/enable.js +15 -19
  215. package/dist/src/functions/commands/{scenario-environment.d.ts → environment.d.ts} +9 -6
  216. package/dist/src/functions/commands/{scenario-environment.js → environment.js} +5 -4
  217. package/dist/src/functions/commands/new-addon.js +14 -14
  218. package/dist/src/functions/commands/persona-sync.d.ts +33 -0
  219. package/dist/src/functions/commands/persona-sync.js +151 -0
  220. package/dist/src/functions/commands/persona.d.ts +58 -0
  221. package/dist/src/functions/commands/persona.js +215 -0
  222. package/dist/src/functions/commands/roles-audit.d.ts +1 -0
  223. package/dist/src/functions/commands/roles-audit.js +37 -0
  224. package/dist/src/functions/commands/roles-prune.d.ts +16 -0
  225. package/dist/src/functions/commands/roles-prune.js +52 -0
  226. package/dist/src/functions/commands/roles-shared.d.ts +40 -0
  227. package/dist/src/functions/commands/roles-shared.js +77 -0
  228. package/dist/src/functions/commands/scenario-browser.d.ts +3 -3
  229. package/dist/src/functions/commands/scenario-browser.js +1 -1
  230. package/dist/src/functions/commands/scenario-ladder.d.ts +44 -2
  231. package/dist/src/functions/commands/scenario-ladder.js +52 -3
  232. package/dist/src/functions/commands/scenario.d.ts +7 -0
  233. package/dist/src/functions/commands/scenario.js +82 -18
  234. package/dist/src/functions/commands/scopes-shared.d.ts +12 -0
  235. package/dist/src/functions/commands/scopes-shared.js +2 -2
  236. package/dist/src/functions/commands/serve.js +8 -4
  237. package/dist/src/functions/commands/versions-check.js +3 -3
  238. package/dist/src/functions/commands/virtual-user-formatter.d.ts +30 -0
  239. package/dist/src/functions/commands/virtual-user-formatter.js +65 -0
  240. package/dist/src/functions/db/annotation-parser.d.ts +14 -0
  241. package/dist/src/functions/db/annotation-parser.js +50 -2
  242. package/dist/src/functions/db/better-auth-schema.js +2 -1
  243. package/dist/src/functions/db/db-codegen.d.ts +12 -0
  244. package/dist/src/functions/db/db-codegen.js +149 -16
  245. package/dist/src/functions/db/local-db.d.ts +87 -6
  246. package/dist/src/functions/db/local-db.js +239 -35
  247. package/dist/src/functions/db/sqlite/dev-seed.d.ts +12 -0
  248. package/dist/src/functions/db/sqlite/dev-seed.js +23 -0
  249. package/dist/src/functions/db/sqlite/sqlite-runtime-bun.js +1 -1
  250. package/dist/src/functions/validate/bootstrap-checks.d.ts +19 -0
  251. package/dist/src/functions/validate/bootstrap-checks.js +90 -0
  252. package/dist/src/functions/validate/persona-checks.d.ts +24 -0
  253. package/dist/src/functions/validate/persona-checks.js +136 -0
  254. package/dist/src/functions/validate/scenario-file-checks.d.ts +17 -0
  255. package/dist/src/functions/validate/scenario-file-checks.js +123 -0
  256. package/dist/src/functions/validate/shared-checks.d.ts +59 -0
  257. package/dist/src/functions/validate/shared-checks.js +311 -0
  258. package/dist/src/functions/validate/workspace-validate.d.ts +1 -2
  259. package/dist/src/functions/validate/workspace-validate.js +4 -196
  260. package/dist/src/functions/wirings/ai-agent/pikku-command-public-agent.js +2 -1
  261. package/dist/src/functions/wirings/ai-agent/serialize-public-agent.js +1 -0
  262. package/dist/src/functions/wirings/auth/serialize-auth-gen.d.ts +2 -2
  263. package/dist/src/functions/wirings/auth/serialize-auth-gen.js +24 -9
  264. package/dist/src/functions/wirings/auth/serialize-auth-types.d.ts +3 -1
  265. package/dist/src/functions/wirings/auth/serialize-auth-types.js +3 -1
  266. package/dist/src/functions/wirings/channels/pikku-channels.d.ts +1 -1
  267. package/dist/src/functions/wirings/channels/serialize-typed-channel-map.js +10 -2
  268. package/dist/src/functions/wirings/cli/pikku-command-cli-entry.js +9 -4
  269. package/dist/src/functions/wirings/cli/serialize-channel-cli-client.d.ts +7 -3
  270. package/dist/src/functions/wirings/cli/serialize-channel-cli-client.js +64 -28
  271. package/dist/src/functions/wirings/cli/serialize-channel-cli.js +63 -6
  272. package/dist/src/functions/wirings/cli/serialize-cli-entrypoint-guard.d.ts +12 -0
  273. package/dist/src/functions/wirings/cli/serialize-cli-entrypoint-guard.js +28 -0
  274. package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.js +4 -1
  275. package/dist/src/functions/wirings/console/serialize-console-functions.js +5 -8
  276. package/dist/src/functions/wirings/functions/serialize-addon-types.js +1 -1
  277. package/dist/src/functions/wirings/functions/serialize-function-types.js +106 -32
  278. package/dist/src/functions/wirings/middleware/serialize-middleware-imports.js +25 -9
  279. package/dist/src/functions/wirings/package/pikku-command-package-types.d.ts +3 -3
  280. package/dist/src/functions/wirings/package/serialize-package-types.js +5 -3
  281. package/dist/src/functions/wirings/personas/personas-secrets-file.d.ts +8 -0
  282. package/dist/src/functions/wirings/personas/personas-secrets-file.js +9 -0
  283. package/dist/src/functions/wirings/personas/pikku-command-personas.d.ts +7 -0
  284. package/dist/src/functions/wirings/personas/pikku-command-personas.js +57 -0
  285. package/dist/src/functions/wirings/personas/serialize-personas-secrets.d.ts +16 -0
  286. package/dist/src/functions/wirings/personas/serialize-personas-secrets.js +34 -0
  287. package/dist/src/functions/wirings/personas/serialize-personas-types.d.ts +18 -0
  288. package/dist/src/functions/wirings/personas/serialize-personas-types.js +76 -0
  289. package/dist/src/functions/wirings/queue/serialize-queue-map.js +2 -1
  290. package/dist/src/functions/wirings/queue/serialize-queue-wrapper.js +2 -1
  291. package/dist/src/functions/wirings/realtime/pikku-command-events-scaffold.js +2 -1
  292. package/dist/src/functions/wirings/roles/pikku-command-roles.d.ts +7 -0
  293. package/dist/src/functions/wirings/roles/pikku-command-roles.js +33 -0
  294. package/dist/src/functions/wirings/roles/serialize-roles-types.d.ts +14 -0
  295. package/dist/src/functions/wirings/roles/serialize-roles-types.js +55 -0
  296. package/dist/src/functions/wirings/rpc/pikku-command-public-rpc.js +2 -1
  297. package/dist/src/functions/wirings/scenarios/register-scenario-instrumentation.d.ts +3 -3
  298. package/dist/src/functions/wirings/scenarios/register-scenario-instrumentation.js +3 -3
  299. package/dist/src/functions/wirings/scopes/serialize-scopes-types.d.ts +1 -1
  300. package/dist/src/functions/wirings/scopes/serialize-scopes-types.js +1 -1
  301. package/dist/src/functions/wirings/user-admin/pikku-command-user-admin-functions.js +2 -1
  302. package/dist/src/functions/wirings/user-admin/serialize-user-admin-functions.js +2 -2
  303. package/dist/src/functions/wirings/virtual-user/pikku-command-virtual-user-functions.d.ts +1 -0
  304. package/dist/src/functions/wirings/virtual-user/pikku-command-virtual-user-functions.js +42 -0
  305. package/dist/src/functions/wirings/virtual-user/serialize-virtual-user-functions.d.ts +28 -0
  306. package/dist/src/functions/wirings/virtual-user/serialize-virtual-user-functions.js +439 -0
  307. package/dist/src/functions/wirings/workflow/pikku-command-workflow-routes.js +2 -1
  308. package/dist/src/functions/wirings/workflow/pikku-command-workflow.js +13 -13
  309. package/dist/src/functions/wirings/workflow/serialize-personas.d.ts +10 -0
  310. package/dist/src/functions/wirings/workflow/serialize-personas.js +46 -0
  311. package/dist/src/functions/wirings/workflow/serialize-scenario-step-map.js +13 -4
  312. package/dist/src/functions/wirings/workflow/serialize-workflow-types.js +170 -40
  313. package/dist/src/functions/workflows/all.workflow.js +55 -16
  314. package/dist/src/server/bun-server-runner.d.ts +2 -2
  315. package/dist/src/server/bun-server-runner.js +5 -1
  316. package/dist/src/server/content-signing-jwt.d.ts +13 -0
  317. package/dist/src/server/content-signing-jwt.js +51 -0
  318. package/dist/src/server/dev-server-runner.interface.d.ts +10 -2
  319. package/dist/src/server/node-server-runner.d.ts +2 -2
  320. package/dist/src/server/node-server-runner.js +2 -1
  321. package/dist/src/services/cli-logger.service.d.ts +28 -16
  322. package/dist/src/services/cli-logger.service.js +25 -16
  323. package/dist/src/services.d.ts +3 -1
  324. package/dist/src/services.js +10 -1
  325. package/dist/src/utils/file-import-path.js +9 -0
  326. package/dist/src/utils/pikku-cli-config.js +52 -2
  327. package/dist/src/utils/resolve-personas.d.ts +27 -0
  328. package/dist/src/utils/resolve-personas.js +35 -0
  329. package/dist/src/utils/resolve-scaffold-feature.d.ts +19 -0
  330. package/dist/src/utils/resolve-scaffold-feature.js +49 -0
  331. package/dist/tsconfig.tsbuildinfo +1 -1
  332. package/package.json +20 -17
  333. package/dist/.pikku/schemas/schemas/BootstrapInput.schema.json +0 -1
  334. package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +0 -1
  335. package/dist/.pikku/schemas/schemas/ScenarioRunInput.schema.json +0 -1
  336. package/dist/.pikku/workflow/pikku-scenario-actors.gen.d.ts +0 -19
  337. package/dist/.pikku/workflow/pikku-scenario-actors.gen.js +0 -17
  338. package/dist/src/functions/commands/db-seed.d.ts +0 -1
  339. package/dist/src/functions/commands/db-seed.js +0 -24
  340. package/dist/src/functions/db/sqlite/seed.d.ts +0 -11
  341. package/dist/src/functions/db/sqlite/seed.js +0 -22
  342. package/dist/src/functions/wirings/workflow/serialize-scenario-actors.d.ts +0 -2
  343. package/dist/src/functions/wirings/workflow/serialize-scenario-actors.js +0 -40
  344. package/dist/src/utils/resolve-scenario-actors.d.ts +0 -23
  345. package/dist/src/utils/resolve-scenario-actors.js +0 -74
  346. /package/dist/.pikku/schemas/schemas/{DbSeedInput.schema.json → RolesAuditInput.schema.json} +0 -0
@@ -7,7 +7,7 @@ export const serializeFunctionTypes = (userSessionTypeImport, userSessionTypeNam
7
7
  ? nodeCategories.map((c) => `'${c}'`).join(' | ')
8
8
  : 'string';
9
9
  const workflowImport = workflowTypesImport ||
10
- `import type { TypedWorkflow, TypedScenario, TypedScenarioActors } from '../workflow/pikku-workflow-types.gen.js'`;
10
+ `import type { TypedWorkflow, TypedScenario, TypedPersonas } from '../workflow/pikku-workflow-types.gen.js'`;
11
11
  // Falls back to `string` when a project has no scopes codegen, so that
12
12
  // `scopes` stays usable rather than resolving to an unbound type name.
13
13
  const scopesImport = scopesTypeImport || `type ScopeId = string`;
@@ -15,8 +15,8 @@ export const serializeFunctionTypes = (userSessionTypeImport, userSessionTypeNam
15
15
  * Core function, middleware, and permission types for all wirings
16
16
  */
17
17
 
18
- import type { CorePikkuMiddleware, CorePermissionGroup, ListInput, ListOutput, PikkuWire, PickRequired } from '@pikku/core'
19
- import type { CorePikkuFunctionConfig, CorePikkuAuth, CorePikkuAuthConfig, CorePikkuPermission } from '@pikku/core/function'
18
+ import type { CorePikkuMiddleware, CorePermissionGroup, ListInput, ListOutput, PikkuWire, PickRequired, SecretlessServices, SecretService } from '@pikku/core'
19
+ import type { CorePikkuFunctionConfig, CorePikkuSessionlessFunctionConfig, CorePikkuAuth, CorePikkuAuthConfig, CorePikkuPermission } from '@pikku/core/function'
20
20
  import { pikkuAuth as pikkuAuthCore } from '@pikku/core/function'
21
21
  import {
22
22
  addTagMiddleware as addTagMiddlewareCore,
@@ -51,7 +51,20 @@ ${configTypeImport.includes('Config type not found') ? 'export type Config = any
51
51
  * why an \`if (!service)\` guard inside a function body is always dead code.
52
52
  */
53
53
  export type WiredSingletonServices = RequiredSingletonServices & SingletonServices
54
- export type WiredServices = RequiredSingletonServices & Services
54
+ export type WiredServices = SecretlessServices<RequiredSingletonServices & Services>
55
+
56
+ /** \`WiredSingletonServices\` without \`secrets\`, for auth gates. */
57
+ export type WiredAuthServices = SecretlessServices<WiredSingletonServices>
58
+
59
+ /**
60
+ * \`WiredServices\` with \`secrets\` restored, for the console's secret-admin
61
+ * functions. Reached by declaring \`secretBroker: true\` on a \`pikkuFunc\` config.
62
+ *
63
+ * Declaring it does not grant the service. The runner hands out the real
64
+ * \`SecretService\` only to the functions the inspector marks as secret brokers;
65
+ * every other function still receives the throwing accessor.
66
+ */
67
+ export type WiredSecretBrokerServices = WiredServices & { secrets: SecretService }
55
68
 
56
69
  /**
57
70
  * Inline node configuration for function definitions.
@@ -70,7 +83,7 @@ export type NodeConfig = {
70
83
  * @template In - The input type that the permission check will receive
71
84
  * @template RequiredServices - The services required for this permission check
72
85
  */
73
- export type PikkuPermission<In = unknown, RequiredServices extends Services = WiredServices> = CorePikkuPermission<In, RequiredServices, PikkuWire<In, never, false, Session>>
86
+ export type PikkuPermission<In = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices> = CorePikkuPermission<In, RequiredServices, PikkuWire<In, never, false, Session>>
74
87
 
75
88
  /**
76
89
  * Type-safe middleware definition that can access your application's services and session.
@@ -83,7 +96,7 @@ export type PikkuMiddleware<RequiredServices extends SingletonServices = WiredSi
83
96
  /**
84
97
  * Configuration object for creating a permission with metadata
85
98
  */
86
- export type PikkuPermissionConfig<In = unknown, RequiredServices extends Services = WiredServices> = {
99
+ export type PikkuPermissionConfig<In = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices> = {
87
100
  /** The permission function */
88
101
  func: PikkuPermission<In, RequiredServices>
89
102
  /** Optional human-readable name for the permission */
@@ -128,12 +141,12 @@ export const pikkuPermission = <In>(
128
141
  *
129
142
  * @template RequiredServices - The services required for this auth check
130
143
  */
131
- export type PikkuAuth<RequiredServices extends SingletonServices = WiredSingletonServices> = CorePikkuAuth<RequiredServices, Session>
144
+ export type PikkuAuth<RequiredServices extends SecretlessServices<SingletonServices> = WiredAuthServices> = CorePikkuAuth<RequiredServices, Session>
132
145
 
133
146
  /**
134
147
  * Configuration object for creating an auth permission with metadata
135
148
  */
136
- export type PikkuAuthConfig<RequiredServices extends SingletonServices = WiredSingletonServices> = CorePikkuAuthConfig<RequiredServices, Session>
149
+ export type PikkuAuthConfig<RequiredServices extends SecretlessServices<SingletonServices> = WiredAuthServices> = CorePikkuAuthConfig<RequiredServices, Session>
137
150
 
138
151
  /**
139
152
  * Factory function for creating auth-only permissions with tree-shaking support.
@@ -155,7 +168,7 @@ export type PikkuAuthConfig<RequiredServices extends SingletonServices = WiredSi
155
168
  * })
156
169
  * \\\`\\\`\\\`
157
170
  */
158
- export const pikkuAuth = <RequiredServices extends SingletonServices = WiredSingletonServices>(
171
+ export const pikkuAuth = <RequiredServices extends SecretlessServices<SingletonServices> = WiredAuthServices>(
159
172
  auth: PikkuAuth<RequiredServices> | PikkuAuthConfig<RequiredServices>
160
173
  ): PikkuPermission<any, any> => {
161
174
  return pikkuAuthCore(auth as any) as any
@@ -257,7 +270,7 @@ export const pikkuPermissionFactory = <In = any>(
257
270
  * @template In - The input type (same as the function it describes)
258
271
  * @template RequiredServices - The services required for this description function
259
272
  */
260
- export type PikkuApprovalDescription<In = unknown, RequiredServices extends Services = WiredServices> = (
273
+ export type PikkuApprovalDescription<In = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices> = (
261
274
  services: RequiredServices,
262
275
  data: In
263
276
  ) => Promise<string>
@@ -275,7 +288,7 @@ export type PikkuApprovalDescription<In = unknown, RequiredServices extends Serv
275
288
  * )
276
289
  * \`\`\`
277
290
  */
278
- export const pikkuApprovalDescription = <In = unknown, RequiredServices extends Services = WiredServices>(
291
+ export const pikkuApprovalDescription = <In = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices>(
279
292
  fn: PikkuApprovalDescription<In, RequiredServices>
280
293
  ): PikkuApprovalDescription<In, RequiredServices> => {
281
294
  return fn
@@ -293,13 +306,13 @@ export type PikkuFunctionSessionless<
293
306
  In = unknown,
294
307
  Out = never,
295
308
  RequiredWires extends keyof PikkuWire = never,
296
- RequiredServices extends Services = WiredServices
309
+ RequiredServices extends SecretlessServices<Services> = WiredServices
297
310
  > = CorePikkuFunctionSessionless<
298
311
  In,
299
312
  Out,
300
313
  RequiredServices,
301
314
  Session,
302
- PickRequired<PikkuWire<In, Out, false, Session, TypedPikkuRPC, null, any, TypedWorkflow, unknown, TypedScenario, TypedScenarioActors>, RequiredWires>
315
+ PickRequired<PikkuWire<In, Out, false, Session, TypedPikkuRPC, null, any, TypedWorkflow, unknown, TypedScenario, TypedPersonas>, RequiredWires>
303
316
  >
304
317
 
305
318
  /**
@@ -314,13 +327,13 @@ export type PikkuFunction<
314
327
  In = unknown,
315
328
  Out = never,
316
329
  RequiredWires extends keyof PikkuWire = 'session',
317
- RequiredServices extends Services = WiredServices
330
+ RequiredServices extends SecretlessServices<Services> = WiredServices
318
331
  > = CorePikkuFunction<
319
332
  In,
320
333
  Out,
321
334
  RequiredServices,
322
335
  Session,
323
- PickRequired<PikkuWire<In, Out, true, Session, TypedPikkuRPC, null, any, TypedWorkflow, unknown, TypedScenario, TypedScenarioActors>, RequiredWires>
336
+ PickRequired<PikkuWire<In, Out, true, Session, TypedPikkuRPC, null, any, TypedWorkflow, unknown, TypedScenario, TypedPersonas>, RequiredWires>
324
337
  >
325
338
 
326
339
  /**
@@ -340,11 +353,24 @@ export type PikkuFunctionConfig<
340
353
  In = unknown,
341
354
  Out = unknown,
342
355
  RequiredWires extends keyof PikkuWire = never,
343
- PikkuFunc extends PikkuFunction<In, Out, RequiredWires> | PikkuFunctionSessionless<In, Out, RequiredWires> = PikkuFunction<In, Out, RequiredWires> | PikkuFunctionSessionless<In, Out, RequiredWires>,
356
+ PikkuFunc extends PikkuFunction<In, Out, RequiredWires, any> | PikkuFunctionSessionless<In, Out, RequiredWires, any> = PikkuFunction<In, Out, RequiredWires> | PikkuFunctionSessionless<In, Out, RequiredWires>,
344
357
  InputSchema extends StandardSchemaV1 | undefined = undefined,
345
358
  OutputSchema extends StandardSchemaV1 | undefined = undefined
346
359
  > = CorePikkuFunctionConfig<PikkuFunc, PikkuPermission<In>, PikkuMiddleware, InputSchema, OutputSchema, ScopeId>
347
360
 
361
+ /**
362
+ * {@link PikkuFunctionConfig} for a function that runs without a session.
363
+ * Has no \`scopes\`: an anonymous caller holds none, so none can ever be met.
364
+ */
365
+ export type PikkuFunctionSessionlessConfig<
366
+ In = unknown,
367
+ Out = unknown,
368
+ RequiredWires extends keyof PikkuWire = never,
369
+ PikkuFunc extends PikkuFunctionSessionless<In, Out, RequiredWires, any> = PikkuFunctionSessionless<In, Out, RequiredWires>,
370
+ InputSchema extends StandardSchemaV1 | undefined = undefined,
371
+ OutputSchema extends StandardSchemaV1 | undefined = undefined
372
+ > = CorePikkuSessionlessFunctionConfig<PikkuFunc, PikkuPermission<In>, PikkuMiddleware, InputSchema, OutputSchema>
373
+
348
374
  /**
349
375
  * Configuration object for Pikku functions with Zod schema validation.
350
376
  * Use this when you want to define input/output schemas using Zod.
@@ -361,11 +387,12 @@ type SchemaInferred<S, Fallback = unknown> = S extends StandardSchemaV1
361
387
  export type PikkuFunctionConfigWithSchema<
362
388
  InputSchema extends StandardSchemaV1 | undefined = undefined,
363
389
  OutputSchema extends StandardSchemaV1 | undefined = undefined,
364
- RequiredWires extends keyof PikkuWire = never
390
+ RequiredWires extends keyof PikkuWire = never,
391
+ RequiredServices extends SecretlessServices<Services> = WiredServices
365
392
  > = Omit<
366
393
  CorePikkuFunctionConfig<
367
- | PikkuFunction<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>
368
- | PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>,
394
+ | PikkuFunction<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>
395
+ | PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>,
369
396
  CorePikkuPermission<any>,
370
397
  PikkuMiddleware,
371
398
  undefined,
@@ -375,8 +402,8 @@ export type PikkuFunctionConfigWithSchema<
375
402
  'func' | 'input' | 'output' | 'permissions' | 'approvalDescription'
376
403
  > & {
377
404
  func:
378
- | PikkuFunction<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>
379
- | PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>
405
+ | PikkuFunction<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>
406
+ | PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>
380
407
  input?: InputSchema
381
408
  output?: OutputSchema
382
409
  permissions?: InputSchema extends StandardSchemaV1
@@ -413,6 +440,12 @@ export type PikkuFunctionConfigWithSchema<
413
440
  * })
414
441
  * \`\`\`
415
442
  */
443
+ export function pikkuFunc<
444
+ InputSchema extends StandardSchemaV1 | undefined = undefined,
445
+ OutputSchema extends StandardSchemaV1 | undefined = undefined
446
+ >(
447
+ config: PikkuFunctionConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc', WiredSecretBrokerServices> & { secretBroker: true }
448
+ ): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'session' | 'rpc'>
416
449
  export function pikkuFunc<
417
450
  InputSchema extends StandardSchemaV1 | undefined = undefined,
418
451
  OutputSchema extends StandardSchemaV1 | undefined = undefined
@@ -459,22 +492,25 @@ export const pikkuListFunc = <
459
492
  */
460
493
  /**
461
494
  * Schema-overload variant for pikkuSessionlessFunc. Derived from
462
- * CorePikkuFunctionConfig to stay in sync with the generic-typed config.
495
+ * CorePikkuSessionlessFunctionConfig to stay in sync with the generic-typed
496
+ * config — so it has no \`scopes\` either.
463
497
  */
464
498
  export type PikkuFunctionSessionlessConfigWithSchema<
465
499
  InputSchema extends StandardSchemaV1 | undefined = undefined,
466
500
  OutputSchema extends StandardSchemaV1 | undefined = undefined,
467
- RequiredWires extends keyof PikkuWire = never
501
+ RequiredWires extends keyof PikkuWire = never,
502
+ RequiredServices extends SecretlessServices<Services> = WiredServices
468
503
  > = Omit<
469
- CorePikkuFunctionConfig<
470
- PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>
504
+ CorePikkuSessionlessFunctionConfig<
505
+ PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>
471
506
  >,
472
507
  'func' | 'input' | 'output' | 'permissions' | 'approvalDescription'
473
508
  > & {
474
509
  func: PikkuFunctionSessionless<
475
510
  SchemaInferred<InputSchema>,
476
511
  SchemaInferred<OutputSchema>,
477
- RequiredWires
512
+ RequiredWires,
513
+ RequiredServices
478
514
  >
479
515
  input?: InputSchema
480
516
  output?: OutputSchema
@@ -512,14 +548,15 @@ export type PikkuFunctionSessionlessConfigWithSchema<
512
548
  */
513
549
  export function pikkuSessionlessFunc<
514
550
  InputSchema extends StandardSchemaV1 | undefined = undefined,
515
- OutputSchema extends StandardSchemaV1 | undefined = undefined
551
+ OutputSchema extends StandardSchemaV1 | undefined = undefined,
552
+ RequiredServices extends SecretlessServices<Services> = WiredServices
516
553
  >(
517
- config: PikkuFunctionSessionlessConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc'>
554
+ config: PikkuFunctionSessionlessConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc', RequiredServices>
518
555
  ): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'session' | 'rpc'>
519
- export function pikkuSessionlessFunc<In, Out = unknown>(
556
+ export function pikkuSessionlessFunc<In, Out = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices>(
520
557
  func:
521
- | PikkuFunctionSessionless<In, Out, 'session' | 'rpc'>
522
- | PikkuFunctionConfig<In, Out, 'session' | 'rpc'>
558
+ | PikkuFunctionSessionless<In, Out, 'session' | 'rpc', RequiredServices>
559
+ | PikkuFunctionSessionlessConfig<In, Out, 'session' | 'rpc', PikkuFunctionSessionless<In, Out, 'session' | 'rpc', RequiredServices>>
523
560
  ): PikkuFunctionConfig<In, Out, 'session' | 'rpc'>
524
561
  export function pikkuSessionlessFunc(func: any) {
525
562
  return typeof func === 'function' ? { func } : func
@@ -544,7 +581,7 @@ export function pikkuSessionlessFunc(func: any) {
544
581
  export const pikkuVoidFunc = (
545
582
  func:
546
583
  | PikkuFunctionSessionless<void, void, 'session' | 'rpc'>
547
- | PikkuFunctionConfig<void, void, 'session' | 'rpc'>
584
+ | PikkuFunctionSessionlessConfig<void, void, 'session' | 'rpc'>
548
585
  ) => {
549
586
  return typeof func === 'function' ? { func } : func
550
587
  }
@@ -584,6 +621,43 @@ export const ref = <Name extends keyof FlattenedRPCMap>(
584
621
  >
585
622
  }
586
623
 
624
+ /**
625
+ * Declares a capability the connected client answers, reachable from any
626
+ * \`wireChannel\` function as \`channel.remote(name, input)\`.
627
+ *
628
+ * There is no \`func\`: this side owns the contract, the client owns the body.
629
+ * The \`description\` is what a person is shown when asked to approve the call,
630
+ * so write it for them rather than for the caller.
631
+ *
632
+ * @example
633
+ * \`\`\`typescript
634
+ * export const localCheckoutOutput = z.object({ sha: z.string(), branch: z.string() })
635
+ *
636
+ * export const localCheckout = pikkuRemoteChannelFunc({
637
+ * description: 'Read the current commit and branch of your working tree',
638
+ * output: localCheckoutOutput,
639
+ * })
640
+ * \`\`\`
641
+ */
642
+ export function pikkuRemoteChannelFunc<
643
+ InputSchema extends StandardSchemaV1 | undefined = undefined,
644
+ OutputSchema extends StandardSchemaV1 | undefined = undefined
645
+ >(
646
+ config: Omit<
647
+ PikkuFunctionSessionlessConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc'>,
648
+ 'func'
649
+ >
650
+ ): PikkuFunctionConfig<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, 'session' | 'rpc'> {
651
+ return {
652
+ ...config,
653
+ func: async (_services: any, _data: any, _wire: any) => {
654
+ throw new Error(
655
+ \`\${config.title ?? 'This'} is a remote channel capability and has no local implementation — reach it with channel.remote() on the channel whose client exposes it.\`
656
+ )
657
+ },
658
+ } as any
659
+ }
660
+
587
661
  /**
588
662
  * Creates a Pikku config factory.
589
663
  * Use this to define your application's configuration factory.
@@ -2,16 +2,30 @@ import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
2
2
  const collectFactories = (groupMap, outputPath, packageMappings) => {
3
3
  const factories = new Map();
4
4
  for (const [, groupMeta] of groupMap.entries()) {
5
- if (groupMeta.exportName && groupMeta.isFactory) {
6
- const filePath = getFileImportRelativePath(outputPath, groupMeta.sourceFile, packageMappings);
7
- factories.set(groupMeta.exportName, {
8
- exportName: groupMeta.exportName,
9
- filePath,
10
- });
5
+ for (const registration of registrationsOf(groupMeta)) {
6
+ if (registration.exportName && registration.isFactory) {
7
+ const filePath = getFileImportRelativePath(outputPath, registration.sourceFile, packageMappings);
8
+ factories.set(registration.exportName, {
9
+ exportName: registration.exportName,
10
+ filePath,
11
+ });
12
+ }
11
13
  }
12
14
  }
13
15
  return factories;
14
16
  };
17
+ /**
18
+ * Every `add*Middleware` call recorded under one pattern or tag.
19
+ *
20
+ * A group is keyed by its pattern, and more than one file may register for the
21
+ * same one. Emitting only the primary registration meant the other file was
22
+ * never imported, so its middleware never registered — which for a session
23
+ * bridge or an auth gate fails open and fails silently.
24
+ */
25
+ const registrationsOf = (groupMeta) => [
26
+ groupMeta,
27
+ ...(groupMeta.additionalRegistrations ?? []),
28
+ ];
15
29
  export const serializeMiddlewareImports = (outputPath, middlewareState, httpState, packageMappings = {}, fullState) => {
16
30
  const serializedImports = [];
17
31
  const serializedFactoryCalls = [];
@@ -24,9 +38,11 @@ export const serializeMiddlewareImports = (outputPath, middlewareState, httpStat
24
38
  const directImports = new Set();
25
39
  const collectDirectImports = (groupMap) => {
26
40
  for (const [, groupMeta] of groupMap.entries()) {
27
- if (!groupMeta.isFactory) {
28
- const filePath = getFileImportRelativePath(outputPath, groupMeta.sourceFile, packageMappings);
29
- directImports.add(filePath);
41
+ for (const registration of registrationsOf(groupMeta)) {
42
+ if (!registration.isFactory) {
43
+ const filePath = getFileImportRelativePath(outputPath, registration.sourceFile, packageMappings);
44
+ directImports.add(filePath);
45
+ }
30
46
  }
31
47
  }
32
48
  };
@@ -1,3 +1,3 @@
1
- export declare const pikkuSecretDefinitionTypes: import("#pikku").PikkuFunctionConfig<void, void, "rpc" | "session", import("#pikku").PikkuFunctionSessionless<void, void, "rpc" | "session", import("#pikku").WiredServices> | import("#pikku").PikkuFunction<void, void, "rpc" | "session", import("#pikku").WiredServices>, undefined, undefined>;
2
- export declare const pikkuScopeDefinitionTypes: import("#pikku").PikkuFunctionConfig<void, void, "rpc" | "session", import("#pikku").PikkuFunctionSessionless<void, void, "rpc" | "session", import("#pikku").WiredServices> | import("#pikku").PikkuFunction<void, void, "rpc" | "session", import("#pikku").WiredServices>, undefined, undefined>;
3
- export declare const pikkuVariableDefinitionTypes: import("#pikku").PikkuFunctionConfig<void, void, "rpc" | "session", import("#pikku").PikkuFunctionSessionless<void, void, "rpc" | "session", import("#pikku").WiredServices> | import("#pikku").PikkuFunction<void, void, "rpc" | "session", import("#pikku").WiredServices>, undefined, undefined>;
1
+ export declare const pikkuSecretDefinitionTypes: import("#pikku").PikkuFunctionSessionlessConfig<void, void, "rpc" | "session", import("#pikku").PikkuFunctionSessionless<void, void, "rpc" | "session", import("#pikku").WiredServices>, undefined, undefined>;
2
+ export declare const pikkuScopeDefinitionTypes: import("#pikku").PikkuFunctionSessionlessConfig<void, void, "rpc" | "session", import("#pikku").PikkuFunctionSessionless<void, void, "rpc" | "session", import("#pikku").WiredServices>, undefined, undefined>;
3
+ export declare const pikkuVariableDefinitionTypes: import("#pikku").PikkuFunctionSessionlessConfig<void, void, "rpc" | "session", import("#pikku").PikkuFunctionSessionless<void, void, "rpc" | "session", import("#pikku").WiredServices>, undefined, undefined>;
@@ -1,15 +1,17 @@
1
1
  export const serializeSecretDefinitionTypes = () => {
2
- return `export { wireSecret } from '@pikku/core/secret'
2
+ return `export { defineSecret } from '@pikku/core/secret'
3
3
  export type { CoreSecret, SecretDefinitionMeta, SecretDefinitionsMeta } from '@pikku/core/secret'
4
4
  `;
5
5
  };
6
6
  export const serializeScopeDefinitionTypes = () => {
7
- return `export { wireScope } from '@pikku/core/scope'
7
+ return `export { defineScope } from '@pikku/core/scope'
8
8
  export type { CoreScopes, CoreScopeNode, FlatScope, ScopeDefinitionMeta, ScopeDefinitionsMeta } from '@pikku/core/scope'
9
+ export { defineSystemRole } from '@pikku/core/role'
10
+ export type { CoreSystemRole, CoreSystemRoles, SystemRole, SystemRoleDefinitionMeta, SystemRoleDefinitionsMeta } from '@pikku/core/role'
9
11
  `;
10
12
  };
11
13
  export const serializeVariableDefinitionTypes = () => {
12
- return `export { wireVariable } from '@pikku/core/variable'
14
+ return `export { defineVariable } from '@pikku/core/variable'
13
15
  export type { CoreVariable, VariableDefinitionMeta, VariableDefinitionsMeta } from '@pikku/core/variable'
14
16
  `;
15
17
  };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Where the generated `SCENARIO_ACTOR_SECRET` declaration lives — beside the
3
+ * personas file, like `auth-secrets.gen.ts` sits beside the auth scaffold.
4
+ *
5
+ * Shared with the inspector's scaffold-file list: nothing imports this file, so
6
+ * it is unreachable through the import graph and has to be inspected explicitly.
7
+ */
8
+ export declare const personasSecretsFilePath: (personasFile: string) => string;
@@ -0,0 +1,9 @@
1
+ import { join, dirname } from 'node:path';
2
+ /**
3
+ * Where the generated `SCENARIO_ACTOR_SECRET` declaration lives — beside the
4
+ * personas file, like `auth-secrets.gen.ts` sits beside the auth scaffold.
5
+ *
6
+ * Shared with the inspector's scaffold-file list: nothing imports this file, so
7
+ * it is unreachable through the import graph and has to be inspected explicitly.
8
+ */
9
+ export const personasSecretsFilePath = (personasFile) => join(dirname(personasFile), 'pikku-personas-secrets.gen.ts');
@@ -0,0 +1,7 @@
1
+ export declare const pikkuPersonas: import("#pikku").PikkuFunctionConfig<{
2
+ bootstrap?: boolean;
3
+ }, void, "rpc" | "session", import("#pikku").PikkuFunctionSessionless<{
4
+ bootstrap?: boolean;
5
+ }, void, "rpc" | "session", import("#pikku").WiredServices> | import("#pikku").PikkuFunction<{
6
+ bootstrap?: boolean;
7
+ }, void, "rpc" | "session", import("#pikku").WiredServices>, undefined, undefined>;
@@ -0,0 +1,57 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { rm } from 'node:fs/promises';
3
+ import { pikkuSessionlessFunc } from '#pikku';
4
+ import { writeFileInDir } from '../../../utils/file-writer.js';
5
+ import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
6
+ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
7
+ import { serializePersonasTypes } from './serialize-personas-types.js';
8
+ import { serializePersonasSecrets } from './serialize-personas-secrets.js';
9
+ import { personasSecretsFilePath } from './personas-secrets-file.js';
10
+ import { personaEnvironmentErrors, validateAndBuildPersonasMeta, } from '@pikku/core/persona';
11
+ export const pikkuPersonas = pikkuSessionlessFunc({
12
+ func: async ({ logger, config, getInspectorState }, data) => {
13
+ const { personasFile, personasMetaJsonFile, rolesFile, packageMappings } = config;
14
+ if (!personasFile) {
15
+ return;
16
+ }
17
+ // Same cold-start reasoning as Scopes and Roles: on a bare .pikku this
18
+ // runs before the app's own types exist, so it takes the zero state. The
19
+ // file only has to exist so a persona file can import definePersonas.
20
+ const bootstrap = data?.bootstrap ?? false;
21
+ const state = await getInspectorState(false, bootstrap, bootstrap);
22
+ const environments = config.environments ?? {};
23
+ // Before anything is written. A persona that may not run where it says it
24
+ // runs is a declaration to fix, not a file to generate — and generating
25
+ // it anyway would leave a `.pikku` that typechecks while lying.
26
+ const errors = state.personas.definitions.flatMap((persona) => personaEnvironmentErrors(persona.id, persona, environments));
27
+ if (errors.length) {
28
+ throw new Error(errors.join('\n'));
29
+ }
30
+ const content = serializePersonasTypes({
31
+ definitions: state.personas.definitions,
32
+ rolesImportPath: getFileImportRelativePath(personasFile, rolesFile, packageMappings),
33
+ environmentNames: Object.keys(environments),
34
+ });
35
+ await writeFileInDir(logger, personasFile, content);
36
+ // The actor sign-in secret only means anything once someone is declared
37
+ // to sign in. Drop the file again when the last persona goes, so a stale
38
+ // declaration can't keep asking a deploy for a value nothing reads.
39
+ const secretsFile = personasSecretsFilePath(personasFile);
40
+ if (state.personas.definitions.length > 0) {
41
+ await writeFileInDir(logger, secretsFile, serializePersonasSecrets());
42
+ }
43
+ else if (existsSync(secretsFile)) {
44
+ await rm(secretsFile);
45
+ }
46
+ if (personasMetaJsonFile) {
47
+ const meta = validateAndBuildPersonasMeta(state.personas.definitions);
48
+ await writeFileInDir(logger, personasMetaJsonFile, JSON.stringify(meta, null, 2));
49
+ }
50
+ },
51
+ middleware: [
52
+ logCommandInfoAndTime({
53
+ commandStart: 'Creating PikkuPersonas types',
54
+ commandEnd: 'Created PikkuPersonas types',
55
+ }),
56
+ ],
57
+ });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Generates the sibling secrets file for a project that declares personas.
3
+ *
4
+ * `SCENARIO_ACTOR_SECRET` is the platform's, not the application's: nothing in
5
+ * app code reads it. It is consumed by the scenario service when it signs an
6
+ * actor in, by `pikku scenario` / `pikku persona` / `pikku persona sync`, and by
7
+ * the Playwright provider. Declaring it here — rather than leaving every project
8
+ * to hand-write the same `defineSecret` — is the same reasoning that puts
9
+ * `BETTER_AUTH_SECRET` in the auth scaffold: a value the framework requires
10
+ * regardless of what the user wired should be collected by the platform, not
11
+ * discovered missing at the first sign-in.
12
+ *
13
+ * The schema is a named const because the inspector only accepts a variable
14
+ * reference for `schema`, never an inline expression.
15
+ */
16
+ export declare const serializePersonasSecrets: () => string;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Generates the sibling secrets file for a project that declares personas.
3
+ *
4
+ * `SCENARIO_ACTOR_SECRET` is the platform's, not the application's: nothing in
5
+ * app code reads it. It is consumed by the scenario service when it signs an
6
+ * actor in, by `pikku scenario` / `pikku persona` / `pikku persona sync`, and by
7
+ * the Playwright provider. Declaring it here — rather than leaving every project
8
+ * to hand-write the same `defineSecret` — is the same reasoning that puts
9
+ * `BETTER_AUTH_SECRET` in the auth scaffold: a value the framework requires
10
+ * regardless of what the user wired should be collected by the platform, not
11
+ * discovered missing at the first sign-in.
12
+ *
13
+ * The schema is a named const because the inspector only accepts a variable
14
+ * reference for `schema`, never an inline expression.
15
+ */
16
+ export const serializePersonasSecrets = () => {
17
+ return `/**
18
+ * This file was generated by the @pikku/cli
19
+ */
20
+ import { defineSecret } from '@pikku/core/secret'
21
+ import { z } from 'zod'
22
+
23
+ export const ScenarioActorSecretSchema = z.string()
24
+
25
+ defineSecret({
26
+ name: 'scenarioActorSecret',
27
+ displayName: 'Scenario Actor Secret',
28
+ description:
29
+ 'Signing secret that lets scenarios and virtual users sign in as a declared persona',
30
+ secretId: 'SCENARIO_ACTOR_SECRET',
31
+ schema: ScenarioActorSecretSchema,
32
+ })
33
+ `;
34
+ };
@@ -0,0 +1,18 @@
1
+ import type { PersonaDefinitions } from '@pikku/core/persona';
2
+ export interface SerializePersonasOptions {
3
+ definitions: PersonaDefinitions;
4
+ /** Relative import path to the generated roles file. */
5
+ rolesImportPath: string;
6
+ /** Keys of `environments` in pikku.config.json. */
7
+ environmentNames: string[];
8
+ }
9
+ /**
10
+ * Generates the `PersonaId` union and a `definePersonas` whose `roles` are
11
+ * checked against the declared system roles.
12
+ *
13
+ * The wrapper is why this is generated rather than re-exported: `roles` typed
14
+ * as `string[]` would let a persona name a role nobody declared, and the
15
+ * failure — a scatter of 403s in a run days later — looks nothing like the
16
+ * mistake. Typed as `SystemRoleName[]`, it is a red squiggle in the editor.
17
+ */
18
+ export declare const serializePersonasTypes: ({ definitions, rolesImportPath, environmentNames, }: SerializePersonasOptions) => string;
@@ -0,0 +1,76 @@
1
+ const quote = (value) => `'${value.replace(/'/g, "\\'")}'`;
2
+ /**
3
+ * Generates the `PersonaId` union and a `definePersonas` whose `roles` are
4
+ * checked against the declared system roles.
5
+ *
6
+ * The wrapper is why this is generated rather than re-exported: `roles` typed
7
+ * as `string[]` would let a persona name a role nobody declared, and the
8
+ * failure — a scatter of 403s in a run days later — looks nothing like the
9
+ * mistake. Typed as `SystemRoleName[]`, it is a red squiggle in the editor.
10
+ */
11
+ export const serializePersonasTypes = ({ definitions, rolesImportPath, environmentNames, }) => {
12
+ const ids = [...new Set(definitions.map((d) => d.id))].sort();
13
+ const environmentUnion = environmentNames.length > 0
14
+ ? `\n${[...environmentNames].sort().map((name) => ` | ${quote(name)}`).join('\n')}`
15
+ : ' never';
16
+ const union = ids.length > 0
17
+ ? `\n${ids.map((id) => ` | ${quote(id)}`).join('\n')}`
18
+ : ' never';
19
+ const runnable = definitions
20
+ .filter((d) => d.runnable)
21
+ .map((d) => d.id)
22
+ .sort();
23
+ const runnableUnion = runnable.length > 0
24
+ ? `\n${runnable.map((id) => ` | ${quote(id)}`).join('\n')}`
25
+ : ' never';
26
+ return `/**
27
+ * This file was generated by the @pikku/cli
28
+ */
29
+ import { definePersonas as definePersonasCore } from '@pikku/core/persona'
30
+ import type { CorePersona, PersonaMeta, PersonasMeta } from '@pikku/core/persona'
31
+ import type { SystemRoleName } from '${rolesImportPath}'
32
+ import definitions from './pikku-personas-meta.gen.json' with { type: 'json' }
33
+
34
+ /** Every declared persona. */
35
+ export type PersonaId =${union}
36
+
37
+ /**
38
+ * The personas a virtual user can actually be.
39
+ *
40
+ * Excludes anyone whose only login is a provider account — driving a consent
41
+ * screen needs a human — and anyone declared \`runnable: false\`, who exists to
42
+ * be acted upon rather than to act.
43
+ */
44
+ export type RunnablePersonaId =${runnableUnion}
45
+
46
+ /** Every environment configured in pikku.config.json. */
47
+ export type EnvironmentName =${environmentUnion}
48
+
49
+ /**
50
+ * A persona whose roles are checked against \`defineSystemRole\` and whose
51
+ * environments are checked against the config.
52
+ *
53
+ * Omitting \`environments\` means every environment except the ones flagged
54
+ * \`production: true\`. Naming a production one additionally requires
55
+ * \`disposition: 'accountable'\`, which the type cannot express and \`pikku\`
56
+ * refuses at build time.
57
+ */
58
+ export type TypedPersona = Omit<CorePersona, 'roles' | 'environments'> & {
59
+ roles?: SystemRoleName[]
60
+ environments?: EnvironmentName[]
61
+ }
62
+
63
+ /**
64
+ * Declare the people who use this application.
65
+ *
66
+ * A persona while running is a virtual user; there is no second declaration.
67
+ */
68
+ export const definePersonas = (personas: Record<string, TypedPersona>): void =>
69
+ definePersonasCore(personas)
70
+
71
+ /** Declared personas, keyed by id. Read by the console and \`pikku persona\`. */
72
+ export const PERSONAS: PersonasMeta = definitions as unknown as PersonasMeta
73
+
74
+ export const PERSONA_LIST: PersonaMeta[] = Object.values(PERSONAS)
75
+ `;
76
+ };
@@ -13,6 +13,7 @@ ${serializedImportMap}
13
13
  ${serializedCustomTypes}
14
14
 
15
15
  import type { QueueJob } from '@pikku/core/queue'
16
+ import type { Safe } from '@pikku/core'
16
17
 
17
18
  interface QueueHandler<I, O> {
18
19
  input: I;
@@ -23,7 +24,7 @@ ${serializedQueues}
23
24
 
24
25
  type QueueAdd = <Name extends keyof QueueMap>(
25
26
  name: Name,
26
- data: QueueMap[Name]['input'],
27
+ data: Safe<QueueMap[Name]['input']>,
27
28
  options?: {
28
29
  priority?: number
29
30
  delay?: number