@wildo-ai/wildo-cli 1.1.14 → 1.1.16

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 (211) hide show
  1. package/dist/src/commands/context/journey.command.d.ts.map +1 -1
  2. package/dist/src/commands/context/journey.command.js +12 -0
  3. package/dist/src/commands/context/journey.command.js.map +1 -1
  4. package/dist/src/commands/creation/drive.command.d.ts.map +1 -1
  5. package/dist/src/commands/creation/drive.command.js +2 -1
  6. package/dist/src/commands/creation/drive.command.js.map +1 -1
  7. package/dist/src/commands/generate/email-command.utils.d.ts +2 -0
  8. package/dist/src/commands/generate/email-command.utils.d.ts.map +1 -1
  9. package/dist/src/commands/generate/email-command.utils.js +5 -0
  10. package/dist/src/commands/generate/email-command.utils.js.map +1 -1
  11. package/dist/src/commands/init.command.d.ts.map +1 -1
  12. package/dist/src/commands/init.command.js +7 -2
  13. package/dist/src/commands/init.command.js.map +1 -1
  14. package/dist/src/commands/local/deregister.command.d.ts.map +1 -1
  15. package/dist/src/commands/local/deregister.command.js +4 -0
  16. package/dist/src/commands/local/deregister.command.js.map +1 -1
  17. package/dist/src/commands/local/dev.command.d.ts +50 -0
  18. package/dist/src/commands/local/dev.command.d.ts.map +1 -1
  19. package/dist/src/commands/local/dev.command.js +144 -1
  20. package/dist/src/commands/local/dev.command.js.map +1 -1
  21. package/dist/src/commands/local/jobs-command.utils.d.ts +24 -0
  22. package/dist/src/commands/local/jobs-command.utils.d.ts.map +1 -0
  23. package/dist/src/commands/local/jobs-command.utils.js +44 -0
  24. package/dist/src/commands/local/jobs-command.utils.js.map +1 -0
  25. package/dist/src/commands/local/jobs-run.command.d.ts +7 -0
  26. package/dist/src/commands/local/jobs-run.command.d.ts.map +1 -0
  27. package/dist/src/commands/local/jobs-run.command.js +92 -0
  28. package/dist/src/commands/local/jobs-run.command.js.map +1 -0
  29. package/dist/src/commands/local/jobs.command.d.ts +7 -0
  30. package/dist/src/commands/local/jobs.command.d.ts.map +1 -0
  31. package/dist/src/commands/local/jobs.command.js +59 -0
  32. package/dist/src/commands/local/jobs.command.js.map +1 -0
  33. package/dist/src/commands/local/tunnel.command.d.ts +84 -0
  34. package/dist/src/commands/local/tunnel.command.d.ts.map +1 -0
  35. package/dist/src/commands/local/tunnel.command.js +274 -0
  36. package/dist/src/commands/local/tunnel.command.js.map +1 -0
  37. package/dist/src/commands/providers/grant-export.command.d.ts +16 -0
  38. package/dist/src/commands/providers/grant-export.command.d.ts.map +1 -0
  39. package/dist/src/commands/providers/grant-export.command.js +78 -0
  40. package/dist/src/commands/providers/grant-export.command.js.map +1 -0
  41. package/dist/src/commands/providers/grant-import.command.d.ts +15 -0
  42. package/dist/src/commands/providers/grant-import.command.d.ts.map +1 -0
  43. package/dist/src/commands/providers/grant-import.command.js +78 -0
  44. package/dist/src/commands/providers/grant-import.command.js.map +1 -0
  45. package/dist/src/kernel/command-runner.d.ts.map +1 -1
  46. package/dist/src/kernel/command-runner.js +4 -6
  47. package/dist/src/kernel/command-runner.js.map +1 -1
  48. package/dist/src/kernel/hooks.d.ts.map +1 -1
  49. package/dist/src/kernel/hooks.js +2 -1
  50. package/dist/src/kernel/hooks.js.map +1 -1
  51. package/dist/src/kernel/json-document-output.d.ts +7 -0
  52. package/dist/src/kernel/json-document-output.d.ts.map +1 -1
  53. package/dist/src/kernel/json-document-output.js +8 -0
  54. package/dist/src/kernel/json-document-output.js.map +1 -1
  55. package/dist/src/kernel/types.d.ts +8 -0
  56. package/dist/src/kernel/types.d.ts.map +1 -1
  57. package/dist/src/kernel/types.js.map +1 -1
  58. package/dist/src/services/application/app-bootstrap.service.d.ts +65 -7
  59. package/dist/src/services/application/app-bootstrap.service.d.ts.map +1 -1
  60. package/dist/src/services/application/app-bootstrap.service.js +94 -15
  61. package/dist/src/services/application/app-bootstrap.service.js.map +1 -1
  62. package/dist/src/services/application/app-local-runtime-addresses.service.d.ts +1 -1
  63. package/dist/src/services/application/app-local-runtime-addresses.service.d.ts.map +1 -1
  64. package/dist/src/services/application/app-local-runtime-addresses.service.js.map +1 -1
  65. package/dist/src/services/application/app-runtime-targets.service.d.ts.map +1 -1
  66. package/dist/src/services/application/app-runtime-targets.service.js +16 -2
  67. package/dist/src/services/application/app-runtime-targets.service.js.map +1 -1
  68. package/dist/src/services/application/application-dependency-alignment.service.d.ts +20 -0
  69. package/dist/src/services/application/application-dependency-alignment.service.d.ts.map +1 -1
  70. package/dist/src/services/application/application-dependency-alignment.service.js +32 -2
  71. package/dist/src/services/application/application-dependency-alignment.service.js.map +1 -1
  72. package/dist/src/services/application/application-runtime-bootstrap.service.d.ts +13 -0
  73. package/dist/src/services/application/application-runtime-bootstrap.service.d.ts.map +1 -1
  74. package/dist/src/services/application/application-runtime-bootstrap.service.js +32 -0
  75. package/dist/src/services/application/application-runtime-bootstrap.service.js.map +1 -1
  76. package/dist/src/services/application/environment-provider-configurations.service.d.ts +7 -0
  77. package/dist/src/services/application/environment-provider-configurations.service.d.ts.map +1 -1
  78. package/dist/src/services/application/environment-provider-configurations.service.js +1 -1
  79. package/dist/src/services/application/environment-provider-configurations.service.js.map +1 -1
  80. package/dist/src/services/application/local-tunnel.service.d.ts +153 -0
  81. package/dist/src/services/application/local-tunnel.service.d.ts.map +1 -0
  82. package/dist/src/services/application/local-tunnel.service.js +295 -0
  83. package/dist/src/services/application/local-tunnel.service.js.map +1 -0
  84. package/dist/src/services/application/provider-runtime-sync.service.d.ts.map +1 -1
  85. package/dist/src/services/application/provider-runtime-sync.service.js +3 -0
  86. package/dist/src/services/application/provider-runtime-sync.service.js.map +1 -1
  87. package/dist/src/services/application/saas-skeleton.service.d.ts +7 -0
  88. package/dist/src/services/application/saas-skeleton.service.d.ts.map +1 -1
  89. package/dist/src/services/application/saas-skeleton.service.js +2 -0
  90. package/dist/src/services/application/saas-skeleton.service.js.map +1 -1
  91. package/dist/src/services/catalog/service-address-resolver.service.d.ts +7 -1
  92. package/dist/src/services/catalog/service-address-resolver.service.d.ts.map +1 -1
  93. package/dist/src/services/catalog/service-address-resolver.service.js +6 -3
  94. package/dist/src/services/catalog/service-address-resolver.service.js.map +1 -1
  95. package/dist/src/services/companion/companion-client.service.d.ts +17 -0
  96. package/dist/src/services/companion/companion-client.service.d.ts.map +1 -1
  97. package/dist/src/services/companion/companion-client.service.js +21 -0
  98. package/dist/src/services/companion/companion-client.service.js.map +1 -1
  99. package/dist/src/services/companion/creation-drive.service.d.ts +18 -0
  100. package/dist/src/services/companion/creation-drive.service.d.ts.map +1 -1
  101. package/dist/src/services/companion/creation-drive.service.js +70 -1
  102. package/dist/src/services/companion/creation-drive.service.js.map +1 -1
  103. package/dist/src/services/credentials/application-secrets.service.d.ts +6 -0
  104. package/dist/src/services/credentials/application-secrets.service.d.ts.map +1 -1
  105. package/dist/src/services/credentials/application-secrets.service.js +1 -1
  106. package/dist/src/services/credentials/application-secrets.service.js.map +1 -1
  107. package/dist/src/services/credentials/provider-env-vars.utils.d.ts.map +1 -1
  108. package/dist/src/services/credentials/provider-env-vars.utils.js +3 -1
  109. package/dist/src/services/credentials/provider-env-vars.utils.js.map +1 -1
  110. package/dist/src/services/credentials/secrets-writer.service.d.ts +11 -2
  111. package/dist/src/services/credentials/secrets-writer.service.d.ts.map +1 -1
  112. package/dist/src/services/credentials/secrets-writer.service.js +12 -3
  113. package/dist/src/services/credentials/secrets-writer.service.js.map +1 -1
  114. package/dist/src/services/deployment/ci-deploy-generator.service.d.ts.map +1 -1
  115. package/dist/src/services/deployment/ci-deploy-generator.service.js +3 -3
  116. package/dist/src/services/deployment/ci-deploy-generator.service.js.map +1 -1
  117. package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts +12 -3
  118. package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts.map +1 -1
  119. package/dist/src/services/deployment/docker/docker-compose-generator.service.js +40 -22
  120. package/dist/src/services/deployment/docker/docker-compose-generator.service.js.map +1 -1
  121. package/dist/src/services/deployment/framework-pod-network-membership.d.ts +6 -0
  122. package/dist/src/services/deployment/framework-pod-network-membership.d.ts.map +1 -1
  123. package/dist/src/services/deployment/framework-pod-network-membership.js +17 -3
  124. package/dist/src/services/deployment/framework-pod-network-membership.js.map +1 -1
  125. package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.d.ts +4 -1
  126. package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.d.ts.map +1 -1
  127. package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.js +17 -7
  128. package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.js.map +1 -1
  129. package/dist/src/services/deployment/k8s/k8s-manifest.schemas.d.ts +7 -0
  130. package/dist/src/services/deployment/k8s/k8s-manifest.schemas.d.ts.map +1 -1
  131. package/dist/src/services/deployment/k8s/k8s-manifest.schemas.js.map +1 -1
  132. package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.d.ts.map +1 -1
  133. package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.js +15 -9
  134. package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.js.map +1 -1
  135. package/dist/src/services/deployment/k8s/kind-pod-host-gateway.d.ts +43 -0
  136. package/dist/src/services/deployment/k8s/kind-pod-host-gateway.d.ts.map +1 -0
  137. package/dist/src/services/deployment/k8s/kind-pod-host-gateway.js +12 -0
  138. package/dist/src/services/deployment/k8s/kind-pod-host-gateway.js.map +1 -0
  139. package/dist/src/services/deployment/k8s/off-cluster-backing-services.d.ts +3 -1
  140. package/dist/src/services/deployment/k8s/off-cluster-backing-services.d.ts.map +1 -1
  141. package/dist/src/services/deployment/k8s/off-cluster-backing-services.js.map +1 -1
  142. package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts +163 -0
  143. package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts.map +1 -0
  144. package/dist/src/services/deployment/local-dev-late-workspace-members.service.js +356 -0
  145. package/dist/src/services/deployment/local-dev-late-workspace-members.service.js.map +1 -0
  146. package/dist/src/services/environment/authored-infra-config.utils.d.ts +13 -3
  147. package/dist/src/services/environment/authored-infra-config.utils.d.ts.map +1 -1
  148. package/dist/src/services/environment/authored-infra-config.utils.js +24 -4
  149. package/dist/src/services/environment/authored-infra-config.utils.js.map +1 -1
  150. package/dist/src/services/environment/container-host-gateway-listen-host.d.ts +6 -0
  151. package/dist/src/services/environment/container-host-gateway-listen-host.d.ts.map +1 -1
  152. package/dist/src/services/environment/container-host-gateway-listen-host.js +6 -0
  153. package/dist/src/services/environment/container-host-gateway-listen-host.js.map +1 -1
  154. package/dist/src/services/environment/env-configuration-generator.service.d.ts +12 -0
  155. package/dist/src/services/environment/env-configuration-generator.service.d.ts.map +1 -1
  156. package/dist/src/services/environment/env-configuration-generator.service.js +37 -5
  157. package/dist/src/services/environment/env-configuration-generator.service.js.map +1 -1
  158. package/dist/src/services/environment/env-vars-builder.service.d.ts +2 -1
  159. package/dist/src/services/environment/env-vars-builder.service.d.ts.map +1 -1
  160. package/dist/src/services/environment/env-vars-builder.service.js +47 -32
  161. package/dist/src/services/environment/env-vars-builder.service.js.map +1 -1
  162. package/dist/src/services/environment/environment-lifecycle.service.d.ts +7 -4
  163. package/dist/src/services/environment/environment-lifecycle.service.d.ts.map +1 -1
  164. package/dist/src/services/environment/environment-lifecycle.service.js +14 -18
  165. package/dist/src/services/environment/environment-lifecycle.service.js.map +1 -1
  166. package/dist/src/services/environment/environment-setup.service.d.ts.map +1 -1
  167. package/dist/src/services/environment/environment-setup.service.js +17 -6
  168. package/dist/src/services/environment/environment-setup.service.js.map +1 -1
  169. package/dist/src/services/environment/environment.service.d.ts +4 -3
  170. package/dist/src/services/environment/environment.service.d.ts.map +1 -1
  171. package/dist/src/services/environment/environment.service.js +0 -1
  172. package/dist/src/services/environment/environment.service.js.map +1 -1
  173. package/dist/src/services/framework/framework-docker-publish.service.d.ts +55 -15
  174. package/dist/src/services/framework/framework-docker-publish.service.d.ts.map +1 -1
  175. package/dist/src/services/framework/framework-docker-publish.service.js +115 -25
  176. package/dist/src/services/framework/framework-docker-publish.service.js.map +1 -1
  177. package/dist/src/services/framework/package-install.service.d.ts +7 -0
  178. package/dist/src/services/framework/package-install.service.d.ts.map +1 -1
  179. package/dist/src/services/framework/package-install.service.js +8 -1
  180. package/dist/src/services/framework/package-install.service.js.map +1 -1
  181. package/dist/src/services/registry/application-provider-connection.service.d.ts +16 -1
  182. package/dist/src/services/registry/application-provider-connection.service.d.ts.map +1 -1
  183. package/dist/src/services/registry/application-provider-connection.service.js +23 -0
  184. package/dist/src/services/registry/application-provider-connection.service.js.map +1 -1
  185. package/dist/src/services/registry/provider-grant-transfer.service.d.ts +48 -0
  186. package/dist/src/services/registry/provider-grant-transfer.service.d.ts.map +1 -0
  187. package/dist/src/services/registry/provider-grant-transfer.service.js +144 -0
  188. package/dist/src/services/registry/provider-grant-transfer.service.js.map +1 -0
  189. package/dist/src/services/registry/provider-module-scaffold.service.d.ts.map +1 -1
  190. package/dist/src/services/registry/provider-module-scaffold.service.js +10 -3
  191. package/dist/src/services/registry/provider-module-scaffold.service.js.map +1 -1
  192. package/dist/src/services/security/csp-sync.service.d.ts.map +1 -1
  193. package/dist/src/services/security/csp-sync.service.js +21 -2
  194. package/dist/src/services/security/csp-sync.service.js.map +1 -1
  195. package/dist/tsconfig.build.tsbuildinfo +1 -1
  196. package/package.json +19 -19
  197. package/templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs +16 -7
  198. package/templates/infra/k8s/platform/platform-crontabs-batches-manager/deployment.yaml.hbs +13 -0
  199. package/templates/saas/i18n/email/system/remote-agent-task-updated/labels.en.ts +11 -0
  200. package/templates/saas/i18n/email/system/remote-agent-task-updated/template.tsx +56 -0
  201. package/templates/saas/i18n/engine/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.en.ts +61 -0
  202. package/templates/saas/i18n/engine/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.fr.ts +61 -0
  203. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/docusaurus.config.ts.hbs +5 -4
  204. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/package.json.hbs +1 -1
  205. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/scripts/substitute-api-origin.mjs +97 -32
  206. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/src/plugins/api-reference-pages.ts +7 -6
  207. package/templates/saas/skeleton/.wildo-saas/wildo-dev-companion/scripts/dev-supervised.sh +18 -4
  208. package/templates/saas/skeleton/frontend/nginx-config/default.conf.hbs +1 -1
  209. package/templates/saas/skeleton/frontend/src/generated/csp.generated.json.hbs +4 -4
  210. package/templates/saas/skeleton/infrastructure/local/wildo.infra.local.config.ts.hbs +2 -0
  211. package/wildo-framework.info.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"provider-env-vars.utils.js","sourceRoot":"","sources":["../../../../src/services/credentials/provider-env-vars.utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sCAAsC,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAC3H,OAAO,EACL,wBAAwB,EACxB,mCAAmC,EACnC,aAAa,EACb,oBAAoB,GACrB,MAAM,6DAA6D,CAAC;AAUrE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAN,IAAY,wBAcX;AAdD,WAAY,wBAAwB;IAClC;;;;OAIG;IACH,uFAA2D,CAAA;IAC3D;;;;;OAKG;IACH,iDAAqB,CAAA;AACvB,CAAC,EAdW,wBAAwB,KAAxB,wBAAwB,QAcnC;AAMD;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAA+B;IACnE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QACjC,8FAA8F;QAC9F,2FAA2F;QAC3F,2FAA2F;QAC3F,2FAA2F;QAC3F,4FAA4F;QAC5F,yDAAyD;QACzD,MAAM,IAAI,KAAK,CACb,gGAAgG;cAC9F,mFAAmF,CACtF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,wBAAwB,CAAC,QAAQ,EAAE,YA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E,UAAU,CAAC,CAAC,CAAC,qBAAqB,CAAC,sBAAsB,CAAC,CAAC,CAAC,qBAAqB,CAAC,gBAAgB;YAC3G,MAAM,EAAE,UAAU;gBAChB,CAAC,CAAC,aAAa,WAAW,uCAAuC,UAAU,IAAI;gBAC/E,CAAC,CAAC,aAAa,WAAW,cAAc,KAAK,CAAC,OAAO,CAAC,MAAM,gCAAgC;sBACxF,uDAAuD;SAC9D,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACrD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO;YACL,EAAE,EAAE,KAAK;YACT,WAAW;YACX,OAAO,EAAE,qBAAqB,CAAC,sBAAsB;YACrD,MAAM,EACJ,aAAa,WAAW,+BAA+B,cAAc,CAAC,IAAI,SAAS;kBACjF,GAAG,cAAc,CAAC,UAAU,yDAAyD;kBACrF,uBAAuB,cAAc,CAAC,UAAU,KAAK;SAC1D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,EAAE,EAAE,IAAI;QACR,WAAW;QACX,UAAU,EAAE,cAAc,CAAC,IAAI;QAC/B,UAAU,EAAE,cAAc,CAAC,UAAU;QACrC,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["import type { BackendProviderModule, BackendProtocolBinding } from '@wildo-ai/external-connectors-private/backend';\nimport { ExternalProvider_ExchangeProtocol_Kind, ProviderProtocolRuntimeKind } from '@wildo-ai/external-connectors-models';\nimport {\n getComposedProviderEntry,\n getComposedProviderSecretsCatalogue,\n LiveEnvKeySet,\n memoiseOverCatalogue,\n} from '~wildo-cli/services/credentials/composed-provider-catalogue';\n\nexport interface ProviderSecretEnvBinding {\n protocolKind: string;\n secretRef: string;\n envVarName: string;\n required?: boolean;\n executionProfileRef?: string;\n}\n\n/**\n * Which provider secrets a generated runtime environment is entitled to.\n *\n * ## Why this is a named vocabulary rather than `readonly string[] | null`\n *\n * The scope answers a fail-closed SECURITY question — \"may this process read the application's\n * Stripe key?\" — and the previous encoding made three distinct answers share two values:\n *\n * | Meaning | Old encoding | Problem |\n * |---|---|---|\n * | Platform tier: every provider secret | `null` | fine, but only by convention |\n * | Declares none, legitimately (`myRustWorker` authors `providers: {}`) | `[]` | — |\n * | Nobody threaded the value through | `undefined` → `?? []` | **collapses into the row above** |\n *\n * So a wiring omission and a valid configuration produced byte-identical output, and the failure\n * was invisible: a `.env` missing every provider secret looks exactly like a correctly-scoped one\n * for a runtime that needs none. That is how five of six call sites shipped without a scope, and\n * how a `wildo config sync` came to strip `STRIPE_SECRET_KEY`, `RESEND_API_KEY`, `OPENAI_API_KEY`\n * and the `IMMUDB_*` connection out of the Wonder Todos backend `.env` — the application then died\n * at startup resolving its billing provider, three layers away from the cause.\n *\n * Fail-closed is the correct posture for a DECISION. Applied to an OMISSION it is a silent outage.\n * This union removes the omission from the type system: there is no value meaning \"not stated\", so\n * a caller must decide, and a new call site cannot compile without deciding.\n *\n * @see {@link declaredProviderScope} / {@link platformTierAllProvidersScope} — the two constructors.\n */\nexport enum RuntimeProviderScopeKind {\n /**\n * Platform-tier runtime (apps-manager, the dev companion): receives every provider secret in the\n * environment. A deliberate, reviewable declaration — never the default, and never what an\n * application-tier runtime gets.\n */\n PLATFORM_TIER_ALL_PROVIDERS = 'platform_tier_all_providers',\n /**\n * Application-tier runtime: exactly the providers its `providers.scopes.{backend,workers.<name>,\n * minions.<name>}.providers` authors, and nothing else. An EMPTY set is a legitimate, explicit\n * answer here — it means the runtime declared no provider — which is precisely why it must not\n * double as the encoding for \"the caller forgot\".\n */\n DECLARED = 'declared',\n}\n\nexport type RuntimeProviderScope =\n | { readonly kind: RuntimeProviderScopeKind.PLATFORM_TIER_ALL_PROVIDERS }\n | { readonly kind: RuntimeProviderScopeKind.DECLARED; readonly providerRefs: readonly string[] };\n\n/**\n * The application-tier scope: exactly the authored provider refs.\n *\n * Pass the refs resolved from `providers.scopes.*` — an empty array is meaningful and accepted\n * (the runtime authored no provider), so this constructor deliberately does NOT treat `[]` as a\n * mistake to be corrected.\n */\nexport function declaredProviderScope(providerRefs: readonly string[]): RuntimeProviderScope {\n if (!Array.isArray(providerRefs)) {\n // The type system cannot reach every caller: env targets are built behind `as never` casts in\n // tests, and a JSON-shaped target could arrive without the field at all. In those paths an\n // absent value would flow straight through as `providerRefs: undefined` and be filtered as\n // \"declares nothing\" — reinstating, at runtime, exactly the silent-empty failure the union\n // removed from the type. Throwing keeps the two states distinguishable everywhere: an empty\n // scope has to be WRITTEN as `[]`, never merely omitted.\n throw new Error(\n 'declaredProviderScope() requires an explicit provider-ref array. Pass `[]` for a runtime that '\n + 'authors no provider — an omitted scope is not the same statement as an empty one.',\n );\n }\n return { kind: RuntimeProviderScopeKind.DECLARED, providerRefs };\n}\n\n/**\n * The platform-tier scope: every provider secret.\n *\n * A function rather than a shared constant so each call site reads as its own decision at the\n * point it is made, and so no consumer can retain a reference and hand it to an application-tier\n * builder later.\n */\nexport function platformTierAllProvidersScope(): RuntimeProviderScope {\n return { kind: RuntimeProviderScopeKind.PLATFORM_TIER_ALL_PROVIDERS };\n}\n\n/**\n * The authored `providerConfigurations` keys that can carry a provider module's declared protocol.\n *\n * Two spellings, because the two sides of this lookup name one vocabulary differently: a provider\n * module declares `protocol: 'LLM_PROVIDER'` — the enum MEMBER NAME — while an application authors\n * `[ExternalProvider_ExchangeProtocol_Kind.LLM_PROVIDER]`, which evaluates to the enum VALUE\n * `'llm_provider'`. Neither side is wrong; something has to translate.\n *\n * DERIVED from the enum rather than hand-listed, because the hand-listed table this replaces\n * drifted in both directions at once and neither direction could be seen. Typed\n * `Record<string, string[]>`, it kept a `CLI_RUNTIME` row after that kind was retired — an inert\n * entry no compiler could flag — and never gained `AGENT_CLIENT_PROTOCOL`, `IMAGE_PROVIDER` or\n * `DOCUMENT_EXTRACTION_PROVIDER`, because a missing entry resolves to `undefined` and the fallback\n * then tries only the uppercase member name, which no authored configuration ever uses. The live\n * consequence was that an ACP provider's authored `executionProfiles` were never found, so a\n * `SECRET_REF_ENV_INJECTION` profile bound no environment variable and failed at auth time with\n * nothing pointing back here.\n *\n * Reading the enum cannot omit a member and cannot retain a retired one.\n *\n * `backendProtocol` arrives as a bare `string` (`BackendProtocolBinding` is generic over it), so\n * the index cast is the boundary where an untyped value meets the enum. A string enum has no\n * reverse mapping, so a value that is not a member name reads back `undefined` — which is the\n * signal to fall back to the protocol string itself rather than to guess a second spelling.\n */\nfunction backendProtocolConfigKeys(backendProtocol: string): readonly string[] {\n const wireValue = (ExternalProvider_ExchangeProtocol_Kind as Record<string, string | undefined>)[\n backendProtocol\n ];\n return wireValue === undefined ? [backendProtocol] : [backendProtocol, wireValue];\n}\n\nfunction getConfiguredProtocol(\n configuredProtocols: Partial<Record<string, Record<string, unknown>>> | undefined,\n backendProtocol: string,\n): Record<string, unknown> | undefined {\n for (const key of backendProtocolConfigKeys(backendProtocol)) {\n const config = configuredProtocols?.[key];\n if (config) return config;\n }\n return undefined;\n}\n\n/**\n * EXPORTED since #341 so the per-protocol binding is reachable on its own.\n *\n * Since #329 the ref is resolved through the COMPOSED catalogue rather than the engine registry,\n * so a package-shipped provider's protocols reach this function as soon as discovery registers it.\n * A contribution-sourced entry carries no runtime contracts (a binding is code, a contribution is\n * data), so this function is reached for such a provider only when a caller holds a binding of its\n * own; its secret keys are attributed from the contract half instead, which is complete — see\n * `composed-provider-catalogue.ts`.\n */\nexport function getProtocolSecretEnvBindings(\n providerRef: string,\n protocol: BackendProtocolBinding,\n configuredProtocol?: Record<string, unknown>,\n): ProviderSecretEnvBinding[] {\n const bindings: ProviderSecretEnvBinding[] = [];\n\n const pushSecret = (secretRef: string | undefined) => {\n if (!secretRef) return;\n const matchingEntry = getComposedProviderEntry(providerRef)\n ?.secrets.find((entry) => entry.envVarName === secretRef);\n bindings.push({\n protocolKind: protocol.protocol,\n secretRef,\n envVarName: matchingEntry?.envVarName ?? secretRef,\n required: matchingEntry?.required,\n });\n };\n\n const runtimeContract = protocol.runtimeContract;\n\n switch (runtimeContract.kind) {\n case ProviderProtocolRuntimeKind.LLM:\n // An arm that signs each request instead (#3780, Amazon Bedrock with IAM credentials) holds its two halves and an\n // optional session token, exactly as a signed document-extraction arm does below.\n pushSecret(runtimeContract.apiKey?.secretRef);\n pushSecret(runtimeContract.requestSigning?.keyIdSecretRef);\n pushSecret(runtimeContract.requestSigning?.secretKeySecretRef);\n pushSecret(runtimeContract.requestSigning?.sessionTokenSecretRef);\n break;\n case ProviderProtocolRuntimeKind.REST:\n /*\n * Same shape as `llm` above: the contract's `apiKey.secretRef` names the env var carrying the\n * key. Absent, this switch's `default` THREW at module load — and because these bindings are\n * computed while the module is evaluated, that killed the ENTIRE CLI: `wildo help` and\n * `wildo config validate` both died with `Unsupported provider runtime contract kind: rest`,\n * so a single unhandled provider kind made every unrelated command unusable.\n */\n pushSecret(runtimeContract.apiKey?.secretRef);\n break;\n case ProviderProtocolRuntimeKind.IMAGE:\n // Image-generation transport (gpt-image) — same API-key secret shape as llm.\n pushSecret(runtimeContract.apiKey.secretRef);\n break;\n case ProviderProtocolRuntimeKind.EMBEDDINGS:\n // Embeddings transport (RAG drain/retrieval) — same secret shape as llm, signed arms included (#3780).\n pushSecret(runtimeContract.apiKey?.secretRef);\n pushSecret(runtimeContract.requestSigning?.keyIdSecretRef);\n pushSecret(runtimeContract.requestSigning?.secretKeySecretRef);\n pushSecret(runtimeContract.requestSigning?.sessionTokenSecretRef);\n break;\n case ProviderProtocolRuntimeKind.DOCUMENT_EXTRACTION:\n // Document-extraction transport (OCR) — same API-key secret shape as llm/image/embeddings,\n // even though this family builds its own HTTPS request instead of handing the key to an SDK.\n // What the binding needs is the env var NAME, which is identical either way. A contract that signs\n // each request instead (#3426, AWS Textract) holds its two halves and an optional session token.\n pushSecret(runtimeContract.apiKey?.secretRef);\n pushSecret(runtimeContract.requestSigning?.keyIdSecretRef);\n pushSecret(runtimeContract.requestSigning?.secretKeySecretRef);\n pushSecret(runtimeContract.requestSigning?.sessionTokenSecretRef);\n break;\n case ProviderProtocolRuntimeKind.CONTENT_SAFETY:\n // A content-safety classifier (#2292): the same API-key shape as document extraction.\n pushSecret(runtimeContract.apiKey.secretRef);\n break;\n case ProviderProtocolRuntimeKind.ELECTRONIC_SIGNATURE:\n // An electronic-signature vendor (#2293): one API key in a header, like the classifier above.\n pushSecret(runtimeContract.apiKey.secretRef);\n break;\n case ProviderProtocolRuntimeKind.EMAIL:\n // The `email` runtime contract is a discriminated union on `delivery`:\n // the network variant (real providers — Resend, Postmark, Mailgun, …)\n // carries an `apiKey.secretRef`, while the `delivery: 'log'` variant\n // (the `email-preview` local/dev provider) intentionally carries NO\n // credentials — a log sink needs no API key. Branch on the contract\n // field, never on the provider ref: a log provider has no secret to bind.\n if (runtimeContract.delivery !== 'log') {\n pushSecret(runtimeContract.apiKey.secretRef);\n }\n break;\n case ProviderProtocolRuntimeKind.OAUTH2_SSO:\n pushSecret(runtimeContract.clientSecretRef);\n if (typeof runtimeContract.extensions?.teamIdSecretRef === 'string') {\n pushSecret(runtimeContract.extensions.teamIdSecretRef);\n }\n if (typeof runtimeContract.extensions?.keyIdSecretRef === 'string') {\n pushSecret(runtimeContract.extensions.keyIdSecretRef);\n }\n break;\n case ProviderProtocolRuntimeKind.BILLING:\n case ProviderProtocolRuntimeKind.WEBHOOK_ORIGINATOR:\n pushSecret(runtimeContract.secretRef);\n break;\n case ProviderProtocolRuntimeKind.SMS:\n // A receiving-email provider: the API key its message and attachment fetches carry (#1630).\n case ProviderProtocolRuntimeKind.EMAIL_INBOUND:\n pushSecret(runtimeContract.auth.secretRef);\n break;\n case ProviderProtocolRuntimeKind.AGENT_CLIENT_PROTOCOL:\n // A coding agent under host-managed auth (the default) declares no\n // secretRef at all — `pushSecret` is a no-op for `undefined`, which is\n // the correct outcome: nothing to bind, and nothing to warn about.\n pushSecret(runtimeContract.secretRef);\n break;\n default: {\n // Exhaustive on purpose: every engine-side switch over `runtimeContract.kind` carries this\n // `never` check, and this site was the one that did not — which is exactly how the\n // `embeddings` kind shipped without a case here and crashed `wildo local dev` at module load\n // (2026-08-27). A new kind must fail COMPILATION here, not the next developer's startup.\n const exhaustiveCheck: never = runtimeContract;\n throw new Error(`Unsupported provider runtime contract kind: ${JSON.stringify(exhaustiveCheck)}`);\n }\n }\n\n // Execution-profile secret bindings.\n //\n // NOTE this is a SECOND dispatch on the same axis as the switch above, and it\n // is an `if` rather than a `case`, so the `never` check does NOT protect it:\n // a new execution-profile-bearing kind added to the switch and forgotten here\n // compiles perfectly and silently binds no environment variable, leaving the\n // agent to fail at auth time with no indication that a secret was authored.\n // Every kind that owns execution profiles must be listed.\n if (runtimeContract.kind === ProviderProtocolRuntimeKind.AGENT_CLIENT_PROTOCOL) {\n const agentClientProtocolConfig = configuredProtocol as\n | {\n executionProfiles?: Record<\n string,\n {\n authMode?: string;\n secretRef?: string;\n secretEnvVarName?: string;\n }\n >;\n }\n | undefined;\n const executionProfiles = agentClientProtocolConfig?.executionProfiles ?? {};\n for (const [executionProfileRef, executionProfile] of Object.entries(executionProfiles)) {\n if (\n executionProfile.authMode === 'secret_ref_env_injection'\n && executionProfile.secretRef\n && executionProfile.secretEnvVarName\n ) {\n bindings.push({\n protocolKind: protocol.protocol,\n secretRef: executionProfile.secretRef,\n envVarName: executionProfile.secretEnvVarName,\n executionProfileRef,\n });\n }\n }\n }\n\n return bindings.filter((binding, index, allBindings) => (\n allBindings.findIndex((candidate) => (\n candidate.protocolKind === binding.protocolKind\n && candidate.secretRef === binding.secretRef\n && candidate.envVarName === binding.envVarName\n && candidate.executionProfileRef === binding.executionProfileRef\n )) === index\n ));\n}\n\n/**\n * Every environment variable the named provider's PROTOCOL BINDINGS require.\n *\n * Resolves through the composed catalogue (#329). A provider known only from a companion\n * contribution has no runtime contracts, so this answers `[]` for it — deliberately, and without\n * loss: its secret keys are classified and allow-listed from its `secretsContract` shape, which\n * for every engine provider measured is a superset of what the bindings name.\n */\nexport function getProviderSecretEnvBindings(\n providerRef: string,\n configuredProtocols?: Partial<Record<string, Record<string, unknown>>>,\n): ProviderSecretEnvBinding[] {\n const entry = getComposedProviderEntry(providerRef);\n if (!entry) return [];\n\n return entry.protocolBindings.flatMap((protocol) => (\n getProtocolSecretEnvBindings(\n providerRef,\n protocol,\n getConfiguredProtocol(configuredProtocols, protocol.protocol),\n )\n ));\n}\n\n/**\n * Derives the canonical env var name for a provider's generic secret binding\n * from its protocol definitions.\n *\n * This is useful for setup flows that collect one provider secret value and\n * need to store it directly in the canonical `providerEnv` map. Transport-aware\n * callers should still prefer `getProviderSecretEnvBindings()`.\n */\nexport function getProviderSecretEnvVarName(\n providerRefOrModule: string | BackendProviderModule,\n): string | undefined {\n const providerRef =\n typeof providerRefOrModule === 'string'\n ? providerRefOrModule\n : providerRefOrModule.metadata.ref;\n const bindings = getProviderSecretEnvBindings(providerRef);\n return bindings.find((binding) => !binding.executionProfileRef)?.envVarName;\n}\n\n/**\n * Every provider-related env var name that must be classified as sensitive.\n *\n * Derived from the COMPOSED catalogue (#329) — engine tier plus whatever discovery registered —\n * so a package-shipped provider's key is classified like any other. It used to enumerate\n * `EngineBackendProviderRegistry` alone, which meant a package provider's key was attributable to\n * nobody: unclassified for the Secret/ConfigMap split, and kept by the confinement filter as\n * \"configuration\".\n *\n * Recomputed whenever composition changes rather than cached once, because discovery necessarily\n * runs after this module is imported.\n */\nexport const getProviderSensitiveEnvKeys: () => ReadonlySet<string> = memoiseOverCatalogue(() => {\n const keys = new Set<string>();\n for (const entry of getComposedProviderSecretsCatalogue().values()) {\n for (const secret of entry.secrets) keys.add(secret.envVarName);\n for (const binding of getProviderSecretEnvBindings(entry.providerRef)) keys.add(binding.envVarName);\n }\n return keys;\n});\n\n/** One secret a provider declares. */\nexport interface ProviderSelectionSecret {\n envVarName: string;\n description?: string;\n /** The provider refuses to boot without this var once the provider is enabled. */\n required: boolean;\n}\n\n/** One provider that declares at least one secret, with its operator-facing label. */\nexport interface ProviderSelectionCatalogEntry {\n providerRef: string;\n /** Operator-facing label (falls back to the ref when no display name is set). */\n label: string;\n /** Every secret this provider declares, in contract order. */\n secrets: ProviderSelectionSecret[];\n}\n\n/**\n * Every provider that declares a secret, derived from the COMPOSED provider catalogue (engine tier plus\n * whatever discovery registered — #329), sorted by label. `wildo setup`'s summary names the configured\n * providers from it.\n *\n * It used to power a setup step that offered this whole catalogue for credentials, grouped by a\n * presentation category. That step was removed (#1637): setup asks only for the companion's LLM key, and\n * every other secret is asked when its feature needs it (`wildo secrets`), derived from what the\n * application scopes rather than from everything that exists. The grouping went with it.\n *\n * Providers with an empty `secretsContract` (e.g. the `email-preview` log sink) are omitted.\n */\nexport function getProviderSelectionCatalog(): ProviderSelectionCatalogEntry[] {\n const entries: ProviderSelectionCatalogEntry[] = [];\n for (const provider of getComposedProviderSecretsCatalogue().values()) {\n const secrets: ProviderSelectionSecret[] = provider.secrets.map((secret) => ({\n envVarName: secret.envVarName,\n description: secret.description,\n required: secret.required,\n }));\n if (secrets.length === 0) continue;\n entries.push({ providerRef: provider.providerRef, label: provider.label, secrets });\n }\n return entries.sort((a, b) => a.label.localeCompare(b.label));\n}\n\n/**\n * All provider env-var names classified as sensitive, as a LIVE view.\n *\n * It was a module-load snapshot until #329, and a snapshot cannot work once composition is a\n * thing that happens: this module is imported by `credentials.schemas.ts` on the CLI's first\n * touch of the credential layer, which is always before an application's provider packages have\n * been discovered. A snapshot would therefore have been permanently blind to exactly the tier\n * this slice exists to classify. The exported NAME and the `.has()` shape are unchanged, so its\n * consumers need no edit.\n */\nexport const PROVIDER_SENSITIVE_ENV_KEYS: ReadonlySet<string> = new LiveEnvKeySet(getProviderSensitiveEnvKeys);\n\n// ============================================================================\n// Provider API-key resolution over the composed catalogue (seam for #331)\n// ============================================================================\n\n/**\n * Why a provider's credential could not be resolved.\n *\n * A closed vocabulary rather than a message string, because the caller BRANCHES on it: an\n * executor surfaces `SECRET_NOT_PROVISIONED` to an operator as \"run `wildo secrets set`\", and\n * `NOT_IN_SCOPE` to a developer as \"this runtime does not declare that provider\" — two very\n * different remedies that a single \"failed to resolve\" would have flattened.\n */\nexport enum ProviderApiKeyRefusal {\n /** No entry in the composed catalogue claims the ref — engine tier or discovered. */\n UNKNOWN_PROVIDER = 'unknown_provider',\n /** The runtime's declared provider scope does not carry this provider. */\n NOT_IN_SCOPE = 'not_in_scope',\n /** An operation named `requiredScopes` slugs the provider does not declare. */\n UNDECLARED_SCOPES = 'undeclared_scopes',\n /**\n * The caller named a `secretSlug` the provider does not declare.\n *\n * Distinct from `UNDECLARED_SCOPES` on purpose, even though both mean \"a slug that is not in the\n * contract\": one says an OPERATION requires a credential the package never ships (re-generate or\n * retire the operation), the other says THIS CALL asked for the wrong slug (a caller bug). A\n * caller branches differently on each, and merging two remedies under one member is exactly the\n * vocabulary collapse this repository's closed-vocabulary rule exists to prevent.\n */\n UNDECLARED_SECRET_SLUG = 'undeclared_secret_slug',\n /** The contract declares several candidate secrets and the caller named none. */\n AMBIGUOUS_SECRET = 'ambiguous_secret',\n /** The contract is satisfied; the value is simply not provisioned in this environment. */\n SECRET_NOT_PROVISIONED = 'secret_not_provisioned',\n}\n\nexport type ProviderApiKeyResolution =\n | { ok: true; providerRef: string; secretSlug: string; envVarName: string; value: string }\n | { ok: false; providerRef: string; refusal: ProviderApiKeyRefusal; detail: string };\n\nexport interface ProviderApiKeyRequest {\n providerRef: string;\n /**\n * What the runtime asking for the key is entitled to. Positional-equivalent to the scope\n * threaded through {@link declaredProviderScope} everywhere else in this layer, and required\n * for the same reason: an optional entitlement is one nobody decides, and the whole provider\n * bag reaching every runtime is what that produced last time.\n */\n runtimeScope: RuntimeProviderScope;\n /** Where values come from. Never `process.env` read by this function — the caller decides. */\n providerEnv: Record<string, string>;\n /**\n * Secret-contract SLUGS an operation requires, checked against the provider's contract.\n *\n * These are contract slugs, NOT OAuth scopes: a delegated-authorization scope check needs a\n * connected-account store and belongs to the delegated-auth slice. What is honestly checkable\n * here is that every credential a catalogue operation names is one the provider package\n * actually declares — so a generated operation asking for a credential its package never\n * ships is refused at resolution instead of at the vendor's 401.\n */\n requiredScopes?: readonly string[];\n /** Which contract slug carries the key. Defaults to the sole required (else sole) secret. */\n secretSlug?: string;\n}\n\n/**\n * Resolve one provider credential over the COMPOSED catalogue.\n *\n * The seam #331's operation executor consumes (plan, wave-1 seam table). Three properties are\n * what make it worth having over a bare `providerEnv[secretRef]`:\n *\n * 1. It resolves over the composed catalogue, so it answers for a package-shipped provider the\n * moment discovery registers one, and refuses `UNKNOWN_PROVIDER` BY NAME before that — rather\n * than silently reading an env var nothing claims.\n * 2. It checks entitlement against the same {@link RuntimeProviderScope} the confinement filter\n * uses, so \"the executor could read it\" and \"the env var was allowed into this runtime\" can\n * never disagree.\n * 3. It never touches `process.env`. The caller supplies the source, which keeps the function a\n * pure decision and therefore testable without an ambient environment.\n */\nexport function getProviderApiKey(input: ProviderApiKeyRequest): ProviderApiKeyResolution {\n const { providerRef, runtimeScope, providerEnv, requiredScopes = [], secretSlug } = input;\n\n const entry = getComposedProviderEntry(providerRef);\n if (!entry) {\n return {\n ok: false,\n providerRef,\n refusal: ProviderApiKeyRefusal.UNKNOWN_PROVIDER,\n detail:\n `No provider '${providerRef}' in the composed catalogue. Either the application does not `\n + 'declare its package, or discovery has not registered its companion contribution.',\n };\n }\n\n if (\n runtimeScope.kind === RuntimeProviderScopeKind.DECLARED\n && !runtimeScope.providerRefs.includes(providerRef)\n ) {\n return {\n ok: false,\n providerRef,\n refusal: ProviderApiKeyRefusal.NOT_IN_SCOPE,\n detail:\n `This runtime declares [${runtimeScope.providerRefs.join(', ') || 'none'}] and not `\n + `'${providerRef}', so its credential is deliberately absent from this environment.`,\n };\n }\n\n const declaredSlugs = new Set(entry.secrets.map((secret) => secret.slug));\n const missingScopes = requiredScopes.filter((slug) => !declaredSlugs.has(slug));\n if (missingScopes.length > 0) {\n return {\n ok: false,\n providerRef,\n refusal: ProviderApiKeyRefusal.UNDECLARED_SCOPES,\n detail:\n `Provider '${providerRef}' declares no secret-contract slug [${missingScopes.join(', ')}]; `\n + `its contract holds [${[...declaredSlugs].join(', ') || 'none'}].`,\n };\n }\n\n const candidates = entry.secrets.filter((secret) => secret.required);\n const resolvedSecret = secretSlug\n ? entry.secrets.find((secret) => secret.slug === secretSlug)\n : (candidates.length === 1 ? candidates[0] : (entry.secrets.length === 1 ? entry.secrets[0] : undefined));\n\n if (!resolvedSecret) {\n return {\n ok: false,\n providerRef,\n refusal: secretSlug ? ProviderApiKeyRefusal.UNDECLARED_SECRET_SLUG : ProviderApiKeyRefusal.AMBIGUOUS_SECRET,\n detail: secretSlug\n ? `Provider '${providerRef}' declares no secret-contract slug '${secretSlug}'.`\n : `Provider '${providerRef}' declares ${entry.secrets.length} secrets and none is uniquely `\n + 'required — name the slug that carries the credential.',\n };\n }\n\n const value = providerEnv[resolvedSecret.envVarName];\n if (!value) {\n return {\n ok: false,\n providerRef,\n refusal: ProviderApiKeyRefusal.SECRET_NOT_PROVISIONED,\n detail:\n `Provider '${providerRef}' is in scope and declares '${resolvedSecret.slug}', but `\n + `${resolvedSecret.envVarName} carries no value in this environment. Provide it with `\n + `\\`wildo secrets set ${resolvedSecret.envVarName}\\`.`,\n };\n }\n\n return {\n ok: true,\n providerRef,\n secretSlug: resolvedSecret.slug,\n envVarName: resolvedSecret.envVarName,\n value,\n };\n}\n"]}
1
+ {"version":3,"file":"provider-env-vars.utils.js","sourceRoot":"","sources":["../../../../src/services/credentials/provider-env-vars.utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sCAAsC,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAC3H,OAAO,EACL,wBAAwB,EACxB,mCAAmC,EACnC,aAAa,EACb,oBAAoB,GACrB,MAAM,6DAA6D,CAAC;AAUrE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAN,IAAY,wBAcX;AAdD,WAAY,wBAAwB;IAClC;;;;OAIG;IACH,uFAA2D,CAAA;IAC3D;;;;;OAKG;IACH,iDAAqB,CAAA;AACv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N,CAAC;AACJ,CAAC","sourcesContent":["import type { BackendProviderModule, BackendProtocolBinding } from '@wildo-ai/external-connectors-private/backend';\nimport { ExternalProvider_ExchangeProtocol_Kind, ProviderProtocolRuntimeKind } from '@wildo-ai/external-connectors-models';\nimport {\n getComposedProviderEntry,\n getComposedProviderSecretsCatalogue,\n LiveEnvKeySet,\n memoiseOverCatalogue,\n} from '~wildo-cli/services/credentials/composed-provider-catalogue';\n\nexport interface ProviderSecretEnvBinding {\n protocolKind: string;\n secretRef: string;\n envVarName: string;\n required?: boolean;\n executionProfileRef?: string;\n}\n\n/**\n * Which provider secrets a generated runtime environment is entitled to.\n *\n * ## Why this is a named vocabulary rather than `readonly string[] | null`\n *\n * The scope answers a fail-closed SECURITY question — \"may this process read the application's\n * Stripe key?\" — and the previous encoding made three distinct answers share two values:\n *\n * | Meaning | Old encoding | Problem |\n * |---|---|---|\n * | Platform tier: every provider secret | `null` | fine, but only by convention |\n * | Declares none, legitimately (`myRustWorker` authors `providers: {}`) | `[]` | — |\n * | Nobody threaded the value through | `undefined` → `?? []` | **collapses into the row above** |\n *\n * So a wiring omission and a valid configuration produced byte-identical output, and the failure\n * was invisible: a `.env` missing every provider secret looks exactly like a correctly-scoped one\n * for a runtime that needs none. That is how five of six call sites shipped without a scope, and\n * how a `wildo config sync` came to strip `STRIPE_SECRET_KEY`, `RESEND_API_KEY`, `OPENAI_API_KEY`\n * and the `IMMUDB_*` connection out of the Wonder Todos backend `.env` — the application then died\n * at startup resolving its billing provider, three layers away from the cause.\n *\n * Fail-closed is the correct posture for a DECISION. Applied to an OMISSION it is a silent outage.\n * This union removes the omission from the type system: there is no value meaning \"not stated\", so\n * a caller must decide, and a new call site cannot compile without deciding.\n *\n * @see {@link declaredProviderScope} / {@link platformTierAllProvidersScope} — the two constructors.\n */\nexport enum RuntimeProviderScopeKind {\n /**\n * Platform-tier runtime (apps-manager, the dev companion): receives every provider secret in the\n * environment. A deliberate, reviewable declaration — never the default, and never what an\n * application-tier runtime gets.\n */\n PLATFORM_TIER_ALL_PROVIDERS = 'platform_tier_all_providers',\n /**\n * Application-tier runtime: exactly the providers its `providers.scopes.{backend,workers.<name>,\n * minions.<name>}.providers` authors, and nothing else. An EMPTY set is a legitimate, explicit\n * answer here — it means the runtime declared no provider — which is precisely why it must not\n * double as the encoding for \"the caller forgot\".\n */\n DECLARED = 'declared',\n}\n\nexport type RuntimeProviderScope =\n | { readonly kind: RuntimeProviderScopeKind.PLATFORM_TIER_ALL_PROVIDERS }\n | { readonly kind: RuntimeProviderScopeKind.DECLARED; readonly providerRefs: readonly string[] };\n\n/**\n * The application-tier scope: exactly the authored provider refs.\n *\n * Pass the refs resolved from `providers.scopes.*` — an empty array is meaningful and accepted\n * (the runtime authored no provider), so this constructor deliberately does NOT treat `[]` as a\n * mistake to be corrected.\n */\nexport function declaredProviderScope(providerRefs: readonly string[]): RuntimeProviderScope {\n if (!Array.isArray(providerRefs)) {\n // The type system cannot reach every caller: env targets are built behind `as never` casts in\n // tests, and a JSON-shaped target could arrive without the field at all. In those paths an\n // absent value would flow straight through as `providerRefs: undefined` and be filtered as\n // \"declares nothing\" — reinstating, at runtime, exactly the silent-empty failure the union\n // removed from the type. Throwing keeps the two states distinguishable everywhere: an empty\n // scope has to be WRITTEN as `[]`, never merely omitted.\n throw new Error(\n 'declaredProviderScope() requires an explicit provider-ref array. Pass `[]` for a runtime that '\n + 'authors no provider — an omitted scope is not the same statement as an empty one.',\n );\n }\n return { kind: RuntimeProviderScopeKind.DECLARED, providerRefs };\n}\n\n/**\n * The platform-tier scope: every provider secret.\n *\n * A function rather than a shared constant so each call site reads as its own decision at the\n * point it is made, and so no consumer can retain a reference and hand it to an application-tier\n * builder later.\n */\nexport function platformTierAllProvidersScope(): RuntimeProviderScope {\n return { kind: RuntimeProviderScopeKind.PLATFORM_TIER_ALL_PROVIDERS };\n}\n\n/**\n * The authored `providerConfigurations` keys that can carry a provider module's declared protocol.\n *\n * Two spellings, because the two sides of this lookup name one vocabulary differently: a provider\n * module declares `protocol: 'LLM_PROVIDER'` — the enum MEMBER NAME — while an application authors\n * `[ExternalProvider_ExchangeProtocol_Kind.LLM_PROVIDER]`, which evaluates to the enum VALUE\n * `'llm_provider'`. Neither side is wrong; something has to translate.\n *\n * DERIVED from the enum rather than hand-listed, because the hand-listed table this replaces\n * drifted in both directions at once and neither direction could be seen. Typed\n * `Record<string, string[]>`, it kept a `CLI_RUNTIME` row after that kind was retired — an inert\n * entry no compiler could flag — and never gained `AGENT_CLIENT_PROTOCOL`, `IMAGE_PROVIDER` or\n * `DOCUMENT_EXTRACTION_PROVIDER`, because a missing entry resolves to `undefined` and the fallback\n * then tries only the uppercase member name, which no authored configuration ever uses. The live\n * consequence was that an ACP provider's authored `executionProfiles` were never found, so a\n * `SECRET_REF_ENV_INJECTION` profile bound no environment variable and failed at auth time with\n * nothing pointing back here.\n *\n * Reading the enum cannot omit a member and cannot retain a retired one.\n *\n * `backendProtocol` arrives as a bare `string` (`BackendProtocolBinding` is generic over it), so\n * the index cast is the boundary where an untyped value meets the enum. A string enum has no\n * reverse mapping, so a value that is not a member name reads back `undefined` — which is the\n * signal to fall back to the protocol string itself rather than to guess a second spelling.\n */\nfunction backendProtocolConfigKeys(backendProtocol: string): readonly string[] {\n const wireValue = (ExternalProvider_ExchangeProtocol_Kind as Record<string, string | undefined>)[\n backendProtocol\n ];\n return wireValue === undefined ? [backendProtocol] : [backendProtocol, wireValue];\n}\n\nfunction getConfiguredProtocol(\n configuredProtocols: Partial<Record<string, Record<string, unknown>>> | undefined,\n backendProtocol: string,\n): Record<string, unknown> | undefined {\n for (const key of backendProtocolConfigKeys(backendProtocol)) {\n const config = configuredProtocols?.[key];\n if (config) return config;\n }\n return undefined;\n}\n\n/**\n * EXPORTED since #341 so the per-protocol binding is reachable on its own.\n *\n * Since #329 the ref is resolved through the COMPOSED catalogue rather than the engine registry,\n * so a package-shipped provider's protocols reach this function as soon as discovery registers it.\n * A contribution-sourced entry carries no runtime contracts (a binding is code, a contribution is\n * data), so this function is reached for such a provider only when a caller holds a binding of its\n * own; its secret keys are attributed from the contract half instead, which is complete — see\n * `composed-provider-catalogue.ts`.\n */\nexport function getProtocolSecretEnvBindings(\n providerRef: string,\n protocol: BackendProtocolBinding,\n configuredProtocol?: Record<string, unknown>,\n): ProviderSecretEnvBinding[] {\n const bindings: ProviderSecretEnvBinding[] = [];\n\n const pushSecret = (secretRef: string | undefined) => {\n if (!secretRef) return;\n const matchingEntry = getComposedProviderEntry(providerRef)\n ?.secrets.find((entry) => entry.envVarName === secretRef);\n bindings.push({\n protocolKind: protocol.protocol,\n secretRef,\n envVarName: matchingEntry?.envVarName ?? secretRef,\n required: matchingEntry?.required,\n });\n };\n\n const runtimeContract = protocol.runtimeContract;\n\n switch (runtimeContract.kind) {\n case ProviderProtocolRuntimeKind.LLM:\n // An arm that signs each request instead (#3780, Amazon Bedrock with IAM credentials) holds its two halves and an\n // optional session token, exactly as a signed document-extraction arm does below.\n pushSecret(runtimeContract.apiKey?.secretRef);\n pushSecret(runtimeContract.requestSigning?.keyIdSecretRef);\n pushSecret(runtimeContract.requestSigning?.secretKeySecretRef);\n pushSecret(runtimeContract.requestSigning?.sessionTokenSecretRef);\n break;\n case ProviderProtocolRuntimeKind.REST:\n /*\n * Same shape as `llm` above: the contract's `apiKey.secretRef` names the env var carrying the\n * key. Absent, this switch's `default` THREW at module load — and because these bindings are\n * computed while the module is evaluated, that killed the ENTIRE CLI: `wildo help` and\n * `wildo config validate` both died with `Unsupported provider runtime contract kind: rest`,\n * so a single unhandled provider kind made every unrelated command unusable.\n */\n pushSecret(runtimeContract.apiKey?.secretRef);\n break;\n case ProviderProtocolRuntimeKind.IMAGE:\n // Image-generation transport (gpt-image) — same API-key secret shape as llm.\n pushSecret(runtimeContract.apiKey.secretRef);\n break;\n case ProviderProtocolRuntimeKind.EMBEDDINGS:\n // Embeddings transport (RAG drain/retrieval) — same secret shape as llm, signed arms included (#3780).\n pushSecret(runtimeContract.apiKey?.secretRef);\n pushSecret(runtimeContract.requestSigning?.keyIdSecretRef);\n pushSecret(runtimeContract.requestSigning?.secretKeySecretRef);\n pushSecret(runtimeContract.requestSigning?.sessionTokenSecretRef);\n break;\n case ProviderProtocolRuntimeKind.DOCUMENT_EXTRACTION:\n // Document-extraction transport (OCR) — same API-key secret shape as llm/image/embeddings,\n // even though this family builds its own HTTPS request instead of handing the key to an SDK.\n // What the binding needs is the env var NAME, which is identical either way. A contract that signs\n // each request instead (#3426, AWS Textract) holds its two halves and an optional session token.\n pushSecret(runtimeContract.apiKey?.secretRef);\n pushSecret(runtimeContract.requestSigning?.keyIdSecretRef);\n pushSecret(runtimeContract.requestSigning?.secretKeySecretRef);\n pushSecret(runtimeContract.requestSigning?.sessionTokenSecretRef);\n break;\n case ProviderProtocolRuntimeKind.CONTENT_SAFETY:\n // A content-safety classifier (#2292): the same API-key shape as document extraction.\n pushSecret(runtimeContract.apiKey.secretRef);\n break;\n case ProviderProtocolRuntimeKind.ELECTRONIC_SIGNATURE:\n // An electronic-signature vendor (#2293): one API key in a header, like the classifier above, or the JWT-grant key it\n // is exchanged from; and, for a vendor whose base URL differs per account (DocuSign), the slot that holds it.\n pushSecret(runtimeContract.apiKey.secretRef);\n pushSecret(runtimeContract.baseUrlEnvVarName);\n break;\n case ProviderProtocolRuntimeKind.EMAIL:\n // The `email` runtime contract is a discriminated union on `delivery`:\n // the network variant (real providers — Resend, Postmark, Mailgun, …)\n // carries an `apiKey.secretRef`, while the `delivery: 'log'` variant\n // (the `email-preview` local/dev provider) intentionally carries NO\n // credentials — a log sink needs no API key. Branch on the contract\n // field, never on the provider ref: a log provider has no secret to bind.\n if (runtimeContract.delivery !== 'log') {\n pushSecret(runtimeContract.apiKey.secretRef);\n }\n break;\n case ProviderProtocolRuntimeKind.OAUTH2_SSO:\n pushSecret(runtimeContract.clientSecretRef);\n if (typeof runtimeContract.extensions?.teamIdSecretRef === 'string') {\n pushSecret(runtimeContract.extensions.teamIdSecretRef);\n }\n if (typeof runtimeContract.extensions?.keyIdSecretRef === 'string') {\n pushSecret(runtimeContract.extensions.keyIdSecretRef);\n }\n break;\n case ProviderProtocolRuntimeKind.BILLING:\n case ProviderProtocolRuntimeKind.WEBHOOK_ORIGINATOR:\n pushSecret(runtimeContract.secretRef);\n break;\n case ProviderProtocolRuntimeKind.SMS:\n // A receiving-email provider: the API key its message and attachment fetches carry (#1630).\n case ProviderProtocolRuntimeKind.EMAIL_INBOUND:\n pushSecret(runtimeContract.auth.secretRef);\n break;\n case ProviderProtocolRuntimeKind.AGENT_CLIENT_PROTOCOL:\n // A coding agent under host-managed auth (the default) declares no\n // secretRef at all — `pushSecret` is a no-op for `undefined`, which is\n // the correct outcome: nothing to bind, and nothing to warn about.\n pushSecret(runtimeContract.secretRef);\n break;\n default: {\n // Exhaustive on purpose: every engine-side switch over `runtimeContract.kind` carries this\n // `never` check, and this site was the one that did not — which is exactly how the\n // `embeddings` kind shipped without a case here and crashed `wildo local dev` at module load\n // (2026-08-27). A new kind must fail COMPILATION here, not the next developer's startup.\n const exhaustiveCheck: never = runtimeContract;\n throw new Error(`Unsupported provider runtime contract kind: ${JSON.stringify(exhaustiveCheck)}`);\n }\n }\n\n // Execution-profile secret bindings.\n //\n // NOTE this is a SECOND dispatch on the same axis as the switch above, and it\n // is an `if` rather than a `case`, so the `never` check does NOT protect it:\n // a new execution-profile-bearing kind added to the switch and forgotten here\n // compiles perfectly and silently binds no environment variable, leaving the\n // agent to fail at auth time with no indication that a secret was authored.\n // Every kind that owns execution profiles must be listed.\n if (runtimeContract.kind === ProviderProtocolRuntimeKind.AGENT_CLIENT_PROTOCOL) {\n const agentClientProtocolConfig = configuredProtocol as\n | {\n executionProfiles?: Record<\n string,\n {\n authMode?: string;\n secretRef?: string;\n secretEnvVarName?: string;\n }\n >;\n }\n | undefined;\n const executionProfiles = agentClientProtocolConfig?.executionProfiles ?? {};\n for (const [executionProfileRef, executionProfile] of Object.entries(executionProfiles)) {\n if (\n executionProfile.authMode === 'secret_ref_env_injection'\n && executionProfile.secretRef\n && executionProfile.secretEnvVarName\n ) {\n bindings.push({\n protocolKind: protocol.protocol,\n secretRef: executionProfile.secretRef,\n envVarName: executionProfile.secretEnvVarName,\n executionProfileRef,\n });\n }\n }\n }\n\n return bindings.filter((binding, index, allBindings) => (\n allBindings.findIndex((candidate) => (\n candidate.protocolKind === binding.protocolKind\n && candidate.secretRef === binding.secretRef\n && candidate.envVarName === binding.envVarName\n && candidate.executionProfileRef === binding.executionProfileRef\n )) === index\n ));\n}\n\n/**\n * Every environment variable the named provider's PROTOCOL BINDINGS require.\n *\n * Resolves through the composed catalogue (#329). A provider known only from a companion\n * contribution has no runtime contracts, so this answers `[]` for it — deliberately, and without\n * loss: its secret keys are classified and allow-listed from its `secretsContract` shape, which\n * for every engine provider measured is a superset of what the bindings name.\n */\nexport function getProviderSecretEnvBindings(\n providerRef: string,\n configuredProtocols?: Partial<Record<string, Record<string, unknown>>>,\n): ProviderSecretEnvBinding[] {\n const entry = getComposedProviderEntry(providerRef);\n if (!entry) return [];\n\n return entry.protocolBindings.flatMap((protocol) => (\n getProtocolSecretEnvBindings(\n providerRef,\n protocol,\n getConfiguredProtocol(configuredProtocols, protocol.protocol),\n )\n ));\n}\n\n/**\n * Derives the canonical env var name for a provider's generic secret binding\n * from its protocol definitions.\n *\n * This is useful for setup flows that collect one provider secret value and\n * need to store it directly in the canonical `providerEnv` map. Transport-aware\n * callers should still prefer `getProviderSecretEnvBindings()`.\n */\nexport function getProviderSecretEnvVarName(\n providerRefOrModule: string | BackendProviderModule,\n): string | undefined {\n const providerRef =\n typeof providerRefOrModule === 'string'\n ? providerRefOrModule\n : providerRefOrModule.metadata.ref;\n const bindings = getProviderSecretEnvBindings(providerRef);\n return bindings.find((binding) => !binding.executionProfileRef)?.envVarName;\n}\n\n/**\n * Every provider-related env var name that must be classified as sensitive.\n *\n * Derived from the COMPOSED catalogue (#329) — engine tier plus whatever discovery registered —\n * so a package-shipped provider's key is classified like any other. It used to enumerate\n * `EngineBackendProviderRegistry` alone, which meant a package provider's key was attributable to\n * nobody: unclassified for the Secret/ConfigMap split, and kept by the confinement filter as\n * \"configuration\".\n *\n * Recomputed whenever composition changes rather than cached once, because discovery necessarily\n * runs after this module is imported.\n */\nexport const getProviderSensitiveEnvKeys: () => ReadonlySet<string> = memoiseOverCatalogue(() => {\n const keys = new Set<string>();\n for (const entry of getComposedProviderSecretsCatalogue().values()) {\n for (const secret of entry.secrets) keys.add(secret.envVarName);\n for (const binding of getProviderSecretEnvBindings(entry.providerRef)) keys.add(binding.envVarName);\n }\n return keys;\n});\n\n/** One secret a provider declares. */\nexport interface ProviderSelectionSecret {\n envVarName: string;\n description?: string;\n /** The provider refuses to boot without this var once the provider is enabled. */\n required: boolean;\n}\n\n/** One provider that declares at least one secret, with its operator-facing label. */\nexport interface ProviderSelectionCatalogEntry {\n providerRef: string;\n /** Operator-facing label (falls back to the ref when no display name is set). */\n label: string;\n /** Every secret this provider declares, in contract order. */\n secrets: ProviderSelectionSecret[];\n}\n\n/**\n * Every provider that declares a secret, derived from the COMPOSED provider catalogue (engine tier plus\n * whatever discovery registered — #329), sorted by label. `wildo setup`'s summary names the configured\n * providers from it.\n *\n * It used to power a setup step that offered this whole catalogue for credentials, grouped by a\n * presentation category. That step was removed (#1637): setup asks only for the companion's LLM key, and\n * every other secret is asked when its feature needs it (`wildo secrets`), derived from what the\n * application scopes rather than from everything that exists. The grouping went with it.\n *\n * Providers with an empty `secretsContract` (e.g. the `email-preview` log sink) are omitted.\n */\nexport function getProviderSelectionCatalog(): ProviderSelectionCatalogEntry[] {\n const entries: ProviderSelectionCatalogEntry[] = [];\n for (const provider of getComposedProviderSecretsCatalogue().values()) {\n const secrets: ProviderSelectionSecret[] = provider.secrets.map((secret) => ({\n envVarName: secret.envVarName,\n description: secret.description,\n required: secret.required,\n }));\n if (secrets.length === 0) continue;\n entries.push({ providerRef: provider.providerRef, label: provider.label, secrets });\n }\n return entries.sort((a, b) => a.label.localeCompare(b.label));\n}\n\n/**\n * All provider env-var names classified as sensitive, as a LIVE view.\n *\n * It was a module-load snapshot until #329, and a snapshot cannot work once composition is a\n * thing that happens: this module is imported by `credentials.schemas.ts` on the CLI's first\n * touch of the credential layer, which is always before an application's provider packages have\n * been discovered. A snapshot would therefore have been permanently blind to exactly the tier\n * this slice exists to classify. The exported NAME and the `.has()` shape are unchanged, so its\n * consumers need no edit.\n */\nexport const PROVIDER_SENSITIVE_ENV_KEYS: ReadonlySet<string> = new LiveEnvKeySet(getProviderSensitiveEnvKeys);\n\n// ============================================================================\n// Provider API-key resolution over the composed catalogue (seam for #331)\n// ============================================================================\n\n/**\n * Why a provider's credential could not be resolved.\n *\n * A closed vocabulary rather than a message string, because the caller BRANCHES on it: an\n * executor surfaces `SECRET_NOT_PROVISIONED` to an operator as \"run `wildo secrets set`\", and\n * `NOT_IN_SCOPE` to a developer as \"this runtime does not declare that provider\" — two very\n * different remedies that a single \"failed to resolve\" would have flattened.\n */\nexport enum ProviderApiKeyRefusal {\n /** No entry in the composed catalogue claims the ref — engine tier or discovered. */\n UNKNOWN_PROVIDER = 'unknown_provider',\n /** The runtime's declared provider scope does not carry this provider. */\n NOT_IN_SCOPE = 'not_in_scope',\n /** An operation named `requiredScopes` slugs the provider does not declare. */\n UNDECLARED_SCOPES = 'undeclared_scopes',\n /**\n * The caller named a `secretSlug` the provider does not declare.\n *\n * Distinct from `UNDECLARED_SCOPES` on purpose, even though both mean \"a slug that is not in the\n * contract\": one says an OPERATION requires a credential the package never ships (re-generate or\n * retire the operation), the other says THIS CALL asked for the wrong slug (a caller bug). A\n * caller branches differently on each, and merging two remedies under one member is exactly the\n * vocabulary collapse this repository's closed-vocabulary rule exists to prevent.\n */\n UNDECLARED_SECRET_SLUG = 'undeclared_secret_slug',\n /** The contract declares several candidate secrets and the caller named none. */\n AMBIGUOUS_SECRET = 'ambiguous_secret',\n /** The contract is satisfied; the value is simply not provisioned in this environment. */\n SECRET_NOT_PROVISIONED = 'secret_not_provisioned',\n}\n\nexport type ProviderApiKeyResolution =\n | { ok: true; providerRef: string; secretSlug: string; envVarName: string; value: string }\n | { ok: false; providerRef: string; refusal: ProviderApiKeyRefusal; detail: string };\n\nexport interface ProviderApiKeyRequest {\n providerRef: string;\n /**\n * What the runtime asking for the key is entitled to. Positional-equivalent to the scope\n * threaded through {@link declaredProviderScope} everywhere else in this layer, and required\n * for the same reason: an optional entitlement is one nobody decides, and the whole provider\n * bag reaching every runtime is what that produced last time.\n */\n runtimeScope: RuntimeProviderScope;\n /** Where values come from. Never `process.env` read by this function — the caller decides. */\n providerEnv: Record<string, string>;\n /**\n * Secret-contract SLUGS an operation requires, checked against the provider's contract.\n *\n * These are contract slugs, NOT OAuth scopes: a delegated-authorization scope check needs a\n * connected-account store and belongs to the delegated-auth slice. What is honestly checkable\n * here is that every credential a catalogue operation names is one the provider package\n * actually declares — so a generated operation asking for a credential its package never\n * ships is refused at resolution instead of at the vendor's 401.\n */\n requiredScopes?: readonly string[];\n /** Which contract slug carries the key. Defaults to the sole required (else sole) secret. */\n secretSlug?: string;\n}\n\n/**\n * Resolve one provider credential over the COMPOSED catalogue.\n *\n * The seam #331's operation executor consumes (plan, wave-1 seam table). Three properties are\n * what make it worth having over a bare `providerEnv[secretRef]`:\n *\n * 1. It resolves over the composed catalogue, so it answers for a package-shipped provider the\n * moment discovery registers one, and refuses `UNKNOWN_PROVIDER` BY NAME before that — rather\n * than silently reading an env var nothing claims.\n * 2. It checks entitlement against the same {@link RuntimeProviderScope} the confinement filter\n * uses, so \"the executor could read it\" and \"the env var was allowed into this runtime\" can\n * never disagree.\n * 3. It never touches `process.env`. The caller supplies the source, which keeps the function a\n * pure decision and therefore testable without an ambient environment.\n */\nexport function getProviderApiKey(input: ProviderApiKeyRequest): ProviderApiKeyResolution {\n const { providerRef, runtimeScope, providerEnv, requiredScopes = [], secretSlug } = input;\n\n const entry = getComposedProviderEntry(providerRef);\n if (!entry) {\n return {\n ok: false,\n providerRef,\n refusal: ProviderApiKeyRefusal.UNKNOWN_PROVIDER,\n detail:\n `No provider '${providerRef}' in the composed catalogue. Either the application does not `\n + 'declare its package, or discovery has not registered its companion contribution.',\n };\n }\n\n if (\n runtimeScope.kind === RuntimeProviderScopeKind.DECLARED\n && !runtimeScope.providerRefs.includes(providerRef)\n ) {\n return {\n ok: false,\n providerRef,\n refusal: ProviderApiKeyRefusal.NOT_IN_SCOPE,\n detail:\n `This runtime declares [${runtimeScope.providerRefs.join(', ') || 'none'}] and not `\n + `'${providerRef}', so its credential is deliberately absent from this environment.`,\n };\n }\n\n const declaredSlugs = new Set(entry.secrets.map((secret) => secret.slug));\n const missingScopes = requiredScopes.filter((slug) => !declaredSlugs.has(slug));\n if (missingScopes.length > 0) {\n return {\n ok: false,\n providerRef,\n refusal: ProviderApiKeyRefusal.UNDECLARED_SCOPES,\n detail:\n `Provider '${providerRef}' declares no secret-contract slug [${missingScopes.join(', ')}]; `\n + `its contract holds [${[...declaredSlugs].join(', ') || 'none'}].`,\n };\n }\n\n const candidates = entry.secrets.filter((secret) => secret.required);\n const resolvedSecret = secretSlug\n ? entry.secrets.find((secret) => secret.slug === secretSlug)\n : (candidates.length === 1 ? candidates[0] : (entry.secrets.length === 1 ? entry.secrets[0] : undefined));\n\n if (!resolvedSecret) {\n return {\n ok: false,\n providerRef,\n refusal: secretSlug ? ProviderApiKeyRefusal.UNDECLARED_SECRET_SLUG : ProviderApiKeyRefusal.AMBIGUOUS_SECRET,\n detail: secretSlug\n ? `Provider '${providerRef}' declares no secret-contract slug '${secretSlug}'.`\n : `Provider '${providerRef}' declares ${entry.secrets.length} secrets and none is uniquely `\n + 'required — name the slug that carries the credential.',\n };\n }\n\n const value = providerEnv[resolvedSecret.envVarName];\n if (!value) {\n return {\n ok: false,\n providerRef,\n refusal: ProviderApiKeyRefusal.SECRET_NOT_PROVISIONED,\n detail:\n `Provider '${providerRef}' is in scope and declares '${resolvedSecret.slug}', but `\n + `${resolvedSecret.envVarName} carries no value in this environment. Provide it with `\n + `\\`wildo secrets set ${resolvedSecret.envVarName}\\`.`,\n };\n }\n\n return {\n ok: true,\n providerRef,\n secretSlug: resolvedSecret.slug,\n envVarName: resolvedSecret.envVarName,\n value,\n };\n}\n"]}
@@ -9,8 +9,17 @@ import type { WildoInfraEnvConfig } from '@wildo-ai/platform-config-lib';
9
9
  * This deliberately bypasses the permissive environment registry cache, whose null result
10
10
  * cannot authorize creating replacement credentials. Only an absent directory entry permits
11
11
  * creation; a dangling symlink, read failure or malformed existing file is never absence.
12
+ *
13
+ * A HOSTED environment's own file holds only its application-owned sections (`ConfigSecretsUtils.writeSecretsJson`
14
+ * projects it), so it is read the same way: projected, then validated section by section with every section optional.
15
+ * Validating it against the whole schema refused every file setup itself had written: a second `wildo setup` in a
16
+ * hosted application failed on the host-owned `postgresql`, `rabbitmq`, `storage` and `platform` it must not hold
17
+ * (finalization run 44043512605, Wonder Ledger). A shared section left in a hosted file from before it was hosted is
18
+ * ignored here, as the effective-secrets reader ignores it.
12
19
  */
13
- export declare function readSetupSecrets(secretsDirectory: string): PlatformEnvSecretsJson | undefined;
20
+ export declare function readSetupSecrets(secretsDirectory: string, options?: {
21
+ hosted?: boolean;
22
+ }): Partial<PlatformEnvSecretsJson> | undefined;
14
23
  /**
15
24
  * Assemble the full credentials object from Phase 1 prompt answers.
16
25
  * Existing credentials are retained during setup reconfiguration; only missing generated material
@@ -32,7 +41,7 @@ export declare function readSetupSecrets(secretsDirectory: string): PlatformEnvS
32
41
  * audit store's substitution defense off). Sharing one registry with the idempotent
33
42
  * self-heal path means a material declared once is live everywhere.
34
43
  */
35
- export declare function buildCredentials(adminAnswers: AdminUserInput, dbAnswers: DatabaseInitializationInput, providerAnswers: ProviderKeysInput, approverAnswers: AdminUserInput | undefined, existingSecrets?: PlatformEnvSecretsJson): PlatformEnvSecretsJson;
44
+ export declare function buildCredentials(adminAnswers: AdminUserInput, dbAnswers: DatabaseInitializationInput, providerAnswers: ProviderKeysInput, approverAnswers: AdminUserInput | undefined, existingSecrets?: Partial<PlatformEnvSecretsJson>): PlatformEnvSecretsJson;
36
45
  /**
37
46
  * Phase 2 — secrets/config write.
38
47
  */
@@ -1 +1 @@
1
- {"version":3,"file":"secrets-writer.service.d.ts","sourceRoot":"","sources":["../../../../src/services/credentials/secrets-writer.service.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAC5G,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAC7G,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yDAAyD,CAAC;AAC3G,OAAO,EAAE,sBAAsB,EAAiC,MAAM,qDAAqD,CAAC;AAO5H,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS,CAmB7F;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,cAAc,EAC5B,SAAS,EAAE,2BAA2B,EACtC,eAAe,EAAE,iBAAiB,EAClC,eAAe,EAAE,cAAc,GAAG,SAAS,EAC3C,eAAe,CAAC,EAAE,sBAAsB,GACvC,sBAAsB,CAoCxB;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,gCAAgC,EACrC,WAAW,EAAE,sBAAsB,EACnC,SAAS,EAAE,2BAA2B,EACtC,GAAG,EAAE,MAAM;AACX,oHAAoH;AACpH,QAAQ,CAAC,EAAE,mBAAmB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAMf"}
1
+ {"version":3,"file":"secrets-writer.service.d.ts","sourceRoot":"","sources":["../../../../src/services/credentials/secrets-writer.service.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAC5G,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAC7G,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yDAAyD,CAAC;AAC3G,OAAO,EAAE,sBAAsB,EAAiE,MAAM,qDAAqD,CAAC;AAO5J,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,GAAG,SAAS,CAuB1I;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,cAAc,EAC5B,SAAS,EAAE,2BAA2B,EACtC,eAAe,EAAE,iBAAiB,EAClC,eAAe,EAAE,cAAc,GAAG,SAAS,EAC3C,eAAe,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAChD,sBAAsB,CAoCxB;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,gCAAgC,EACrC,WAAW,EAAE,sBAAsB,EACnC,SAAS,EAAE,2BAA2B,EACtC,GAAG,EAAE,MAAM;AACX,oHAAoH;AACpH,QAAQ,CAAC,EAAE,mBAAmB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAMf"}
@@ -1,7 +1,7 @@
1
1
  import chalk from 'chalk';
2
2
  import { lstatSync, readFileSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
- import { PlatformEnvSecretsJson_Schema } from '../../services/credentials/credentials.schemas.js';
4
+ import { PlatformEnvSecretsJson_Schema, projectApplicationOwnedSecrets } from '../../services/credentials/credentials.schemas.js';
5
5
  import { provisionFrameworkManagedSecrets, } from '../../services/credentials/framework-managed-secrets.js';
6
6
  import { ConfigSecretsUtils } from '../../services/credentials/credentials.service.js';
7
7
  import { FILE_NAMES } from '../../infrastructure/io/io.schemas.js';
@@ -10,8 +10,15 @@ import { FILE_NAMES } from '../../infrastructure/io/io.schemas.js';
10
10
  * This deliberately bypasses the permissive environment registry cache, whose null result
11
11
  * cannot authorize creating replacement credentials. Only an absent directory entry permits
12
12
  * creation; a dangling symlink, read failure or malformed existing file is never absence.
13
+ *
14
+ * A HOSTED environment's own file holds only its application-owned sections (`ConfigSecretsUtils.writeSecretsJson`
15
+ * projects it), so it is read the same way: projected, then validated section by section with every section optional.
16
+ * Validating it against the whole schema refused every file setup itself had written: a second `wildo setup` in a
17
+ * hosted application failed on the host-owned `postgresql`, `rabbitmq`, `storage` and `platform` it must not hold
18
+ * (finalization run 44043512605, Wonder Ledger). A shared section left in a hosted file from before it was hosted is
19
+ * ignored here, as the effective-secrets reader ignores it.
13
20
  */
14
- export function readSetupSecrets(secretsDirectory) {
21
+ export function readSetupSecrets(secretsDirectory, options = {}) {
15
22
  const filePath = join(secretsDirectory, FILE_NAMES.SECRETS_JSON);
16
23
  try {
17
24
  lstatSync(filePath);
@@ -28,7 +35,9 @@ export function readSetupSecrets(secretsDirectory) {
28
35
  catch {
29
36
  throw new Error(`Cannot read valid JSON from existing secrets at ${filePath}. Repair or restore that file before running setup; no credentials were replaced.`);
30
37
  }
31
- const parsed = PlatformEnvSecretsJson_Schema.safeParse(value);
38
+ const parsed = options.hosted
39
+ ? PlatformEnvSecretsJson_Schema.partial().safeParse(value !== null && typeof value === 'object' && !Array.isArray(value) ? projectApplicationOwnedSecrets(value) : value)
40
+ : PlatformEnvSecretsJson_Schema.safeParse(value);
32
41
  if (!parsed.success) {
33
42
  throw new Error(`Existing secrets at ${filePath} failed schema validation. Repair or restore that file before running setup; no credentials were replaced.`);
34
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"secrets-writer.service.js","sourceRoot":"","sources":["../../../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rD,CAAC,CAAC,eAAe,EAAE,WAAW;QAChC,MAAM,EAAE,eAAe,CAAC,YAAY;YAClC,CAAC,CAAC;gBACE,MAAM,EAAE,eAAe,CAAC,YAAY;gBACpC,SAAS,EAAE,eAAe,CAAC,eAAe;gBAC1C,UAAU,EAAE,eAAe,CAAC,gBAAgB;aAC7C;YACH,CAAC,CAAC,eAAe,EAAE,MAAM;KAC5B,CAAC;IAEF,OAAO,gCAAgC,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC;AACpE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,GAAqC,EACrC,WAAmC,EACnC,SAAsC,EACtC,GAAW;AACX,oHAAoH;AACpH,QAA8B;IAE9B,kBAAkB,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC3D,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,YAAY,UAAU,CAAC,CAAC,CAAC;IAEnE,kBAAkB,CAAC,eAAe,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7D,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,WAAW,UAAU,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { lstatSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\nimport type { PlatformEnvironmentConfiguration } from '~wildo-cli/services/environment/environment.schemas';\nimport type { AdminUserInput, ProviderKeysInput } from '~wildo-cli/services/credentials/credentials.schemas';\nimport type { DatabaseInitializationInput } from '~wildo-cli/services/data-services/data-services.schemas';\nimport { PlatformEnvSecretsJson, PlatformEnvSecretsJson_Schema } from '~wildo-cli/services/credentials/credentials.schemas';\nimport {\n provisionFrameworkManagedSecrets,\n type PlatformEnvSecretsDraft,\n} from '~wildo-cli/services/credentials/framework-managed-secrets';\nimport { ConfigSecretsUtils } from '~wildo-cli/services/credentials/credentials.service';\nimport { FILE_NAMES } from '~wildo-cli/infrastructure/io/io.schemas';\nimport type { Logger } from '~wildo-cli/kernel/types';\nimport type { WildoInfraEnvConfig } from '@wildo-ai/platform-config-lib';\n\n/**\n * Setup must distinguish an absent store from an unreadable or invalid existing store.\n * This deliberately bypasses the permissive environment registry cache, whose null result\n * cannot authorize creating replacement credentials. Only an absent directory entry permits\n * creation; a dangling symlink, read failure or malformed existing file is never absence.\n */\nexport function readSetupSecrets(secretsDirectory: string): PlatformEnvSecretsJson | undefined {\n const filePath = join(secretsDirectory, FILE_NAMES.SECRETS_JSON);\n try {\n lstatSync(filePath);\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return undefined;\n throw new Error(`Cannot inspect existing secrets at ${filePath}. Restore access before running setup; no credentials were replaced.`);\n }\n let value: unknown;\n try {\n value = JSON.parse(readFileSync(filePath, 'utf8'));\n } catch {\n throw new Error(`Cannot read valid JSON from existing secrets at ${filePath}. Repair or restore that file before running setup; no credentials were replaced.`);\n }\n const parsed = PlatformEnvSecretsJson_Schema.safeParse(value);\n if (!parsed.success) {\n throw new Error(`Existing secrets at ${filePath} failed schema validation. Repair or restore that file before running setup; no credentials were replaced.`);\n }\n return parsed.data;\n}\n\n/**\n * Assemble the full credentials object from Phase 1 prompt answers.\n * Existing credentials are retained during setup reconfiguration; only missing generated material\n * is added. Explicit provider/Atlas answers may update those operator-owned settings. Administrator\n * and approver identities/passwords are never rotated by setup, even with --force.\n * Pure computation — no persistence side effects.\n *\n * Split of responsibility. This function owns ONLY the operator-typed half of\n * `secrets.json` — the admin identity, provider API keys, Atlas API keys, GitHub\n * credentials. Every framework-GENERATED credential (service passwords, platform\n * secrets, the apps-manager / crontabs / immudb signing keypairs) is minted by\n * {@link provisionFrameworkManagedSecrets} from the single registry in\n * `framework-managed-secrets.ts`.\n *\n * That split is the root fix for a recurring class of silent degradation: when minting\n * lived inline here, a newly-introduced material reached ONLY brand-new environments —\n * every existing one stayed permanently without it (the crontabs P2P keypair\n * dead-lettering every scheduled tick, the immudb state-signing keypair leaving the\n * audit store's substitution defense off). Sharing one registry with the idempotent\n * self-heal path means a material declared once is live everywhere.\n */\nexport function buildCredentials(\n adminAnswers: AdminUserInput,\n dbAnswers: DatabaseInitializationInput,\n providerAnswers: ProviderKeysInput,\n approverAnswers: AdminUserInput | undefined,\n existingSecrets?: PlatformEnvSecretsJson,\n): PlatformEnvSecretsJson {\n // Every provider secret arrives already keyed by its exact env-var name from\n // the registry-derived setup selection — there is no per-provider convenience\n // field to fold in anymore.\n const providerEnv = Object.fromEntries(\n Object.entries(providerAnswers.providerEnv ?? {}).filter(([, secretValue]) => Boolean(secretValue)),\n );\n\n // Operator-typed material only. `admin.password` is passed through ONLY when the\n // operator supplied one — otherwise the ADMIN_PASSWORD material generates it, so the\n // \"who minted this?\" answer stays in one place.\n const operatorAuthored: PlatformEnvSecretsDraft = {\n ...existingSecrets,\n admin: existingSecrets?.admin ?? {\n email: adminAnswers.email,\n firstName: adminAnswers.firstName,\n lastName: adminAnswers.lastName,\n ...(adminAnswers.password ? { password: adminAnswers.password } : {}),\n },\n approver: existingSecrets?.approver ?? approverAnswers,\n atlas: dbAnswers.atlasApiPublicKey\n ? { apiPublicKey: dbAnswers.atlasApiPublicKey, apiPrivateKey: dbAnswers.atlasApiPrivateKey! }\n : existingSecrets?.atlas,\n providerEnv: Object.keys(providerEnv).length > 0\n ? { ...existingSecrets?.providerEnv, ...providerEnv }\n : existingSecrets?.providerEnv,\n github: providerAnswers.githubOrgUrl\n ? {\n orgUrl: providerAnswers.githubOrgUrl,\n adminUser: providerAnswers.githubAdminUser,\n adminToken: providerAnswers.githubAdminToken,\n }\n : existingSecrets?.github,\n };\n\n return provisionFrameworkManagedSecrets(operatorAuthored).secrets;\n}\n\n/**\n * Phase 2 — secrets/config write.\n */\nexport async function runSecretsWrite(\n env: PlatformEnvironmentConfiguration,\n credentials: PlatformEnvSecretsJson,\n dbAnswers: DatabaseInitializationInput,\n log: Logger,\n /** The environment's authored descriptor, when it has one: what it decides is laid over setup's answers (#2310). */\n authored?: WildoInfraEnvConfig,\n): Promise<void> {\n ConfigSecretsUtils.writeSecretsJson(env.name, credentials);\n log.success(chalk.green(` ✓ ${FILE_NAMES.SECRETS_JSON} written`));\n\n ConfigSecretsUtils.writeConfigJson(env, dbAnswers, authored);\n log.success(chalk.green(` ✓ ${FILE_NAMES.CONFIG_JSON} written`));\n}\n"]}
1
+ {"version":3,"file":"secrets-writer.service.js","sourceRoot":"","sources":["../../../../src/services/credentials/secrets-writer.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAKjC,OAAO,EAA0B,6BAA6B,EAAE,8BAA8B,EAAE,MAAM,qDAAqD,CAAC;AAC5J,OAAO,EACL,gCAAgC,GAEjC,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAIrE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,gBAAwB,EAAE,UAAgC,EAAE;IAC3F,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IACjE,IAAI,CAAC;QACH,SAAS,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QAC3F,MAAM,IAAI,KAAK,CAAC,sCAAsC,QAAQ,sEAAsE,CAAC,CAAC;IACxI,CAAC;IACD,IAAI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KAAK,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,YAAY,UAAU,CAAC,CAAC,CAAC;IAEnE,kBAAkB,CAAC,eAAe,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7D,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,WAAW,UAAU,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { lstatSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\nimport type { PlatformEnvironmentConfiguration } from '~wildo-cli/services/environment/environment.schemas';\nimport type { AdminUserInput, ProviderKeysInput } from '~wildo-cli/services/credentials/credentials.schemas';\nimport type { DatabaseInitializationInput } from '~wildo-cli/services/data-services/data-services.schemas';\nimport { PlatformEnvSecretsJson, PlatformEnvSecretsJson_Schema, projectApplicationOwnedSecrets } from '~wildo-cli/services/credentials/credentials.schemas';\nimport {\n provisionFrameworkManagedSecrets,\n type PlatformEnvSecretsDraft,\n} from '~wildo-cli/services/credentials/framework-managed-secrets';\nimport { ConfigSecretsUtils } from '~wildo-cli/services/credentials/credentials.service';\nimport { FILE_NAMES } from '~wildo-cli/infrastructure/io/io.schemas';\nimport type { Logger } from '~wildo-cli/kernel/types';\nimport type { WildoInfraEnvConfig } from '@wildo-ai/platform-config-lib';\n\n/**\n * Setup must distinguish an absent store from an unreadable or invalid existing store.\n * This deliberately bypasses the permissive environment registry cache, whose null result\n * cannot authorize creating replacement credentials. Only an absent directory entry permits\n * creation; a dangling symlink, read failure or malformed existing file is never absence.\n *\n * A HOSTED environment's own file holds only its application-owned sections (`ConfigSecretsUtils.writeSecretsJson`\n * projects it), so it is read the same way: projected, then validated section by section with every section optional.\n * Validating it against the whole schema refused every file setup itself had written: a second `wildo setup` in a\n * hosted application failed on the host-owned `postgresql`, `rabbitmq`, `storage` and `platform` it must not hold\n * (finalization run 44043512605, Wonder Ledger). A shared section left in a hosted file from before it was hosted is\n * ignored here, as the effective-secrets reader ignores it.\n */\nexport function readSetupSecrets(secretsDirectory: string, options: { hosted?: boolean } = {}): Partial<PlatformEnvSecretsJson> | undefined {\n const filePath = join(secretsDirectory, FILE_NAMES.SECRETS_JSON);\n try {\n lstatSync(filePath);\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return undefined;\n throw new Error(`Cannot inspect existing secrets at ${filePath}. Restore access before running setup; no credentials were replaced.`);\n }\n let value: unknown;\n try {\n value = JSON.parse(readFileSync(filePath, 'utf8'));\n } catch {\n throw new Error(`Cannot read valid JSON from existing secrets at ${filePath}. Repair or restore that file before running setup; no credentials were replaced.`);\n }\n const parsed = options.hosted\n ? PlatformEnvSecretsJson_Schema.partial().safeParse(\n value !== null && typeof value === 'object' && !Array.isArray(value) ? projectApplicationOwnedSecrets(value as Partial<PlatformEnvSecretsJson>) : value,\n )\n : PlatformEnvSecretsJson_Schema.safeParse(value);\n if (!parsed.success) {\n throw new Error(`Existing secrets at ${filePath} failed schema validation. Repair or restore that file before running setup; no credentials were replaced.`);\n }\n return parsed.data;\n}\n\n/**\n * Assemble the full credentials object from Phase 1 prompt answers.\n * Existing credentials are retained during setup reconfiguration; only missing generated material\n * is added. Explicit provider/Atlas answers may update those operator-owned settings. Administrator\n * and approver identities/passwords are never rotated by setup, even with --force.\n * Pure computation — no persistence side effects.\n *\n * Split of responsibility. This function owns ONLY the operator-typed half of\n * `secrets.json` — the admin identity, provider API keys, Atlas API keys, GitHub\n * credentials. Every framework-GENERATED credential (service passwords, platform\n * secrets, the apps-manager / crontabs / immudb signing keypairs) is minted by\n * {@link provisionFrameworkManagedSecrets} from the single registry in\n * `framework-managed-secrets.ts`.\n *\n * That split is the root fix for a recurring class of silent degradation: when minting\n * lived inline here, a newly-introduced material reached ONLY brand-new environments —\n * every existing one stayed permanently without it (the crontabs P2P keypair\n * dead-lettering every scheduled tick, the immudb state-signing keypair leaving the\n * audit store's substitution defense off). Sharing one registry with the idempotent\n * self-heal path means a material declared once is live everywhere.\n */\nexport function buildCredentials(\n adminAnswers: AdminUserInput,\n dbAnswers: DatabaseInitializationInput,\n providerAnswers: ProviderKeysInput,\n approverAnswers: AdminUserInput | undefined,\n existingSecrets?: Partial<PlatformEnvSecretsJson>,\n): PlatformEnvSecretsJson {\n // Every provider secret arrives already keyed by its exact env-var name from\n // the registry-derived setup selection — there is no per-provider convenience\n // field to fold in anymore.\n const providerEnv = Object.fromEntries(\n Object.entries(providerAnswers.providerEnv ?? {}).filter(([, secretValue]) => Boolean(secretValue)),\n );\n\n // Operator-typed material only. `admin.password` is passed through ONLY when the\n // operator supplied one — otherwise the ADMIN_PASSWORD material generates it, so the\n // \"who minted this?\" answer stays in one place.\n const operatorAuthored: PlatformEnvSecretsDraft = {\n ...existingSecrets,\n admin: existingSecrets?.admin ?? {\n email: adminAnswers.email,\n firstName: adminAnswers.firstName,\n lastName: adminAnswers.lastName,\n ...(adminAnswers.password ? { password: adminAnswers.password } : {}),\n },\n approver: existingSecrets?.approver ?? approverAnswers,\n atlas: dbAnswers.atlasApiPublicKey\n ? { apiPublicKey: dbAnswers.atlasApiPublicKey, apiPrivateKey: dbAnswers.atlasApiPrivateKey! }\n : existingSecrets?.atlas,\n providerEnv: Object.keys(providerEnv).length > 0\n ? { ...existingSecrets?.providerEnv, ...providerEnv }\n : existingSecrets?.providerEnv,\n github: providerAnswers.githubOrgUrl\n ? {\n orgUrl: providerAnswers.githubOrgUrl,\n adminUser: providerAnswers.githubAdminUser,\n adminToken: providerAnswers.githubAdminToken,\n }\n : existingSecrets?.github,\n };\n\n return provisionFrameworkManagedSecrets(operatorAuthored).secrets;\n}\n\n/**\n * Phase 2 — secrets/config write.\n */\nexport async function runSecretsWrite(\n env: PlatformEnvironmentConfiguration,\n credentials: PlatformEnvSecretsJson,\n dbAnswers: DatabaseInitializationInput,\n log: Logger,\n /** The environment's authored descriptor, when it has one: what it decides is laid over setup's answers (#2310). */\n authored?: WildoInfraEnvConfig,\n): Promise<void> {\n ConfigSecretsUtils.writeSecretsJson(env.name, credentials);\n log.success(chalk.green(` ✓ ${FILE_NAMES.SECRETS_JSON} written`));\n\n ConfigSecretsUtils.writeConfigJson(env, dbAnswers, authored);\n log.success(chalk.green(` ✓ ${FILE_NAMES.CONFIG_JSON} written`));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ci-deploy-generator.service.d.ts","sourceRoot":"","sources":["../../../../src/services/deployment/ci-deploy-generator.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AACjG,OAAO,KAAK,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,qEAAqE,CAAC;AAQ7E,OAAO,EAEL,sBAAsB,EAavB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAC5G,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AA6DtD,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,gCAAgC,CAAC;IACtC,WAAW,EAAE,sBAAsB,CAAC;IACpC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,OAAO,EAAE,sBAAsB,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,CAAC,EAAE,2BAA2B,EAAE,CAAC;IACpD,oGAAoG;IACpG,kBAAkB,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAClD,kBAAkB,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAClD;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,sBAAsB,CAAC;CACjC;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,uBAAuB,EAChC,GAAG,EAAE,MAAM,GACV,sBAAsB,CAqVxB"}
1
+ {"version":3,"file":"ci-deploy-generator.service.d.ts","sourceRoot":"","sources":["../../../../src/services/deployment/ci-deploy-generator.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AACjG,OAAO,KAAK,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,qEAAqE,CAAC;AAQ7E,OAAO,EAEL,sBAAsB,EAcvB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAC5G,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AA6DtD,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,gCAAgC,CAAC;IACtC,WAAW,EAAE,sBAAsB,CAAC;IACpC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,OAAO,EAAE,sBAAsB,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,CAAC,EAAE,2BAA2B,EAAE,CAAC;IACpD,oGAAoG;IACpG,kBAAkB,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAClD,kBAAkB,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAClD;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,sBAAsB,CAAC;CACjC;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,uBAAuB,EAChC,GAAG,EAAE,MAAM,GACV,sBAAsB,CAqVxB"}
@@ -26,7 +26,7 @@ import { generateK8sSecrets } from '../../services/deployment/k8s/k8s-secrets-ge
26
26
  import { K8sManifestGenerator } from '../../services/deployment/k8s/k8s-manifest-generator.service.js';
27
27
  import { InfrastructureHost } from '../../services/environment/infrastructure-host.service.js';
28
28
  import { TemplateProcessor } from '../../infrastructure/io/template-processor.js';
29
- import { resolveFrameworkLayout, WildoDeploymentRuntime, WildoLocationType, PlatformWildoServices, BackingServiceKind, RUNTIME_MANDATORY_WRITABLE_PATH, RUNTIME_DEFAULT_PIDS_LIMIT, APP_BACKEND_DEFAULT_RUNTIME_UID, APP_FRONTEND_DEFAULT_RUNTIME_UID, APP_FRONTEND_MANDATORY_WRITABLE_PATHS, ApplicationRuntimePrincipalKind, resolveApplicationDatabaseEngine, resolveRuntimeComposeNetworks, } from '@wildo-ai/platform-config-lib';
29
+ import { resolveFrameworkLayout, WildoDeploymentRuntime, WildoLocationType, PlatformWildoServices, BackingServiceKind, RUNTIME_MANDATORY_WRITABLE_PATH, RUNTIME_DEFAULT_PIDS_LIMIT, APP_BACKEND_DEFAULT_RUNTIME_UID, APP_FRONTEND_DEFAULT_RUNTIME_UID, APP_FRONTEND_MANDATORY_WRITABLE_PATHS, ApplicationRuntimePrincipalKind, resolveApplicationDatabaseEngine, resolveRuntimeApplicationStores, resolveRuntimeComposeNetworks, } from '@wildo-ai/platform-config-lib';
30
30
  import { IMMUDB_AUDIT_STATE_CONTAINER_DIR } from '../../services/data-services/data-services.schemas.js';
31
31
  import { declaredProviderScope } from '../../services/credentials/provider-env-vars.utils.js';
32
32
  /**
@@ -321,7 +321,7 @@ export function generateCiDeployArtifacts(options, log) {
321
321
  isBackend: true,
322
322
  envFile: `${appDeployTarget.serviceName}.env`,
323
323
  // Derived, never hand-listed (#3367): the backend's membership, bounded by the application's store.
324
- networks: resolveRuntimeComposeNetworks({ kind: ApplicationRuntimePrincipalKind.APPLICATION_BACKEND }, undefined, { servesHttp: true, applicationDatabaseEngine: resolveApplicationDatabaseEngine(options.config.applicationDatabase) }),
324
+ networks: resolveRuntimeComposeNetworks({ kind: ApplicationRuntimePrincipalKind.APPLICATION_BACKEND }, undefined, { servesHttp: true, ...resolveRuntimeApplicationStores(options.config) }),
325
325
  immudbAuditStateDir,
326
326
  ...composeIsolation(appDeployTarget.isolation, APP_BACKEND_DEFAULT_RUNTIME_UID, []),
327
327
  },
@@ -341,7 +341,7 @@ export function generateCiDeployArtifacts(options, log) {
341
341
  // A static frontend is no runtime principal: it joins the edge and nothing else.
342
342
  networks: resolveRuntimeComposeNetworks(undefined, undefined, {
343
343
  servesHttp: true,
344
- applicationDatabaseEngine: resolveApplicationDatabaseEngine(options.config.applicationDatabase),
344
+ ...resolveRuntimeApplicationStores(options.config),
345
345
  }),
346
346
  ...composeIsolation(fe.isolation, APP_FRONTEND_DEFAULT_RUNTIME_UID, APP_FRONTEND_MANDATORY_WRITABLE_PATHS),
347
347
  }]
@@ -1 +1 @@
1
- {"version":3,"file":"ci-deploy-generator.service.js","sourceRoot":"","sources":["../../../../src/services/deployment/ci-deploy-generator.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAQ5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;AAClG,OAAO,EAAE,uBAAuB,EAAE,MAAM,qEAAqE,CAAC;AAC9G,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAC1H,OAAO,EAAE,kBAAkB,EAAE,MAAM,kEAAkE,CAAC;AACtG,OAAO,EAAE,oBAAoB,EAAE,MAAM,mEAAmE,CAAC;AACzG,OAAO,EAAE,kBAAkB,EAAE,MAAM,6DAA6D,CAAC;AACjG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D,IAAI,EAAE,EAAE;gCACR,SAAS,EAAE,KAAK;gCAChB,iFAAiF;gCACjF,QAAQ,EAAE,6BAA6B,CAAC,SAAS,EAAE,SAAS,EAAE;oCAC5D,UAAU,EAAE,IAAI;oCAChB,yBAAyB,EAAE,gCAAgC,CAAC,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC;iCAChG,CAAC;gCACF,GAAG,gBAAgB,CACjB,EAAE,CAAC,SAAS,EACZ,gCAAgC,EAChC,qCAAqC,CACtC;6BACF,CAAC;wBACJ,CAAC,CAAC,EAAE,CAAC;gBACT,CAAC,CAAC;aACH,CAAC;YACF,MAAM,QAAQ,GAAG,EAAE,CAAC,eAAe,CAAC,4BAA4B,EAAE;gBAChE,OAAO,EAAE,eAAe,CAAC,OAAO;gBAChC,aAAa;gBACb,QAAQ,EAAE,GAAG,CAAC,cAAc,EAAE,gBAAgB,IAAI,EAAE;gBACpD,SAAS,EAAE,GAAG,CAAC,cAAc,EAAE,SAAS,IAAI,EAAE;gBAC9C,OAAO,EAAE,GAAG,CAAC,IAAI;gBACjB,0FAA0F;gBAC1F,8FAA8F;gBAC9F,iGAAiG;gBACjG,0BAA0B,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC;aAC7D,CAAC,CAAC;YACH,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAAC;YAClE,aAAa,CAAC,cAAc,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;YAChD,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACpC,CAAC;QAED,GAAG,CAAC,IAAI,CAAC,eAAe,YAAY,CAAC,MAAM,2BAA2B,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;AACnC,CAAC","sourcesContent":["/**\n * CiDeployGeneratorService — generate deployment artifacts in CI mode.\n *\n * Produces the files a CI pipeline needs to deploy a Wildo app:\n * - **Kubernetes**: K8s Secret + ConfigMap YAML, written to `<outputDir>/k8s/`\n * - **Docker Compose**: `.env` files for docker-compose services, written to `<outputDir>/compose/`\n *\n * `<outputDir>` is the env-scoped deploy zone\n * `<appRoot>/.wildo-saas/deploy/<env>/`, resolved by\n * `EnvironmentPaths.resolveScopedDeployArtifactsDir`. Every render also writes\n * an ignore-everything `.gitignore` there — see\n * {@link DEPLOY_ZONE_GITIGNORE_CONTENT}.\n *\n * In CI mode secrets are reconstructed from flat env vars (GitHub Secrets\n * injected via `WILDO_SECRET_*`) instead of reading `secrets.json` from disk.\n * The OUTPUT LOCATION is identical either way — a local\n * `wildo config sync --domain config` deposits the same secret-bearing files,\n * which is precisely why the ignore guard is unconditional.\n */\n\nimport { mkdirSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport type { PlatformEnvSecretsJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport type { PlatformEnvConfigJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport type {\n ApplicationBackendEnvTarget,\n ApplicationWorkerEnvTarget,\n ApplicationMinionEnvTarget,\n} from '~wildo-cli/services/environment/env-configuration-generator.service';\nimport { PlatformEnvVarsBuilder } from '~wildo-cli/services/environment/env-vars-builder.service';\nimport { loadInfraHydratedConfig } from '~wildo-cli/services/environment/env-configuration-generator.service';\nimport { ServiceAddressResolver, AddressPerspective } from '~wildo-cli/services/catalog/service-address-resolver.service';\nimport { generateK8sSecrets } from '~wildo-cli/services/deployment/k8s/k8s-secrets-generator.service';\nimport { K8sManifestGenerator } from '~wildo-cli/services/deployment/k8s/k8s-manifest-generator.service';\nimport { InfrastructureHost } from '~wildo-cli/services/environment/infrastructure-host.service';\nimport { TemplateProcessor } from '~wildo-cli/infrastructure/io/template-processor';\nimport {\n resolveFrameworkLayout,\n WildoDeploymentRuntime,\n WildoLocationType,\n PlatformWildoServices,\n BackingServiceKind,\n RUNTIME_MANDATORY_WRITABLE_PATH,\n RUNTIME_DEFAULT_PIDS_LIMIT,\n APP_BACKEND_DEFAULT_RUNTIME_UID,\n APP_FRONTEND_DEFAULT_RUNTIME_UID,\n APP_FRONTEND_MANDATORY_WRITABLE_PATHS,\n ApplicationRuntimePrincipalKind,\n type ApplicationRuntimePrincipal,\n resolveApplicationDatabaseEngine,\n resolveRuntimeComposeNetworks,\n} from '@wildo-ai/platform-config-lib';\nimport { IMMUDB_AUDIT_STATE_CONTAINER_DIR } from '~wildo-cli/services/data-services/data-services.schemas';\nimport type { PlatformEnvironmentConfiguration } from '~wildo-cli/services/environment/environment.schemas';\nimport type { Logger } from '~wildo-cli/kernel/types';\nimport { declaredProviderScope } from '~wildo-cli/services/credentials/provider-env-vars.utils';\n\n/**\n * Format a record of env vars into a `.env` file string.\n * Values containing spaces, `=`, `#`, or newlines are double-quoted.\n */\nfunction formatEnvFile(env: Record<string, string>): string {\n const lines: string[] = [];\n for (const [key, value] of Object.entries(env)) {\n const needsQuoting = /[\\s=#\"'\\\\]|\\n/.test(value);\n const formatted = needsQuoting\n ? `${key}=\"${value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"').replace(/\\r/g, '\\\\r').replace(/\\n/g, '\\\\n')}\"`\n : `${key}=${value}`;\n lines.push(formatted);\n }\n return lines.join('\\n') + '\\n';\n}\n\n/**\n * Ignore-everything guard written into each rendered deploy-artifact directory.\n *\n * EVERY file this generator emits is secret-bearing by construction — K8s\n * `Secret` manifests carry base64 credentials, the compose `.env` files carry\n * the platform admin secret, the apps-manager signing key and database URLs\n * with passwords. The zone lives inside `.wildo-saas/`, which is a PARTLY\n * TRACKED tree, so \"it's under a dot-directory\" is not protection.\n *\n * The framework does not generate an application's root `.gitignore`, so an\n * app-authored rule is a guarantee the framework cannot make on the app's\n * behalf. Writing the guard beside the artifacts makes the zone self-protecting\n * from its very first render, in every application, with no bootstrap step and\n * nothing for an app author to remember. The app's own root rule\n * (`.wildo-saas/deploy/`) stays as defense in depth.\n *\n * Bare `*` — deliberately no `!.gitignore` re-include. The guard is a generated\n * artifact regenerated on every render; it is not repository truth and must not\n * be committed either. It does not affect `kubectl apply` / `docker compose`,\n * which read the directory directly and know nothing about git.\n *\n * Precedent: `templates/infra/docker-compose/.gitignore` ships the same\n * shape next to its generated `.env`.\n */\nconst DEPLOY_ZONE_GITIGNORE_CONTENT = [\n '# Generated deploy artifacts — every file here carries credentials.',\n '# Written by `wildo config sync --domain config`; never commit any of it.',\n '*',\n '',\n].join('\\n');\n\n/**\n * Write the {@link DEPLOY_ZONE_GITIGNORE_CONTENT} guard into a rendered deploy\n * directory. Unconditional (not `existsSync`-gated) so a deleted or edited\n * guard self-heals on the next render and cannot silently drift.\n */\nfunction writeDeployZoneIgnoreGuard(outputDir: string): string {\n const guardPath = join(outputDir, '.gitignore');\n writeFileSync(guardPath, DEPLOY_ZONE_GITIGNORE_CONTENT, 'utf8');\n return guardPath;\n}\n\nexport interface CiDeployGenerateOptions {\n env: PlatformEnvironmentConfiguration;\n credentials: PlatformEnvSecretsJson;\n config: PlatformEnvConfigJson;\n runtime: WildoDeploymentRuntime;\n outputDir: string;\n applicationBackends?: ApplicationBackendEnvTarget[];\n /** App-owned worker/minion deploy targets — render per-worker/per-minion k8s manifests (REMOTE). */\n applicationWorkers?: ApplicationWorkerEnvTarget[];\n applicationMinions?: ApplicationMinionEnvTarget[];\n /**\n * Framework repository root — required to resolve `templates/infra/k8s/**`\n * when rendering the remote-cluster TLS manifests (ClusterIssuer, tls-config)\n * + Traefik Helm values, AND the per-app Deployment/Ingress/Service. When\n * omitted, only Secrets/ConfigMaps are emitted (the pre-remote-TLS behavior).\n */\n frameworkPath?: string;\n /**\n * Container image tag for the app Deployment (e.g. the CI git SHA / release\n * tag). Defaults to `DEFAULT_PLATFORM_IMAGE_TAG` when omitted.\n */\n imageTag?: string;\n}\n\nexport interface CiDeployGenerateResult {\n filesWritten: string[];\n runtime: WildoDeploymentRuntime;\n}\n\nexport function generateCiDeployArtifacts(\n options: CiDeployGenerateOptions,\n log: Logger,\n): CiDeployGenerateResult {\n const { env, credentials, runtime, outputDir, applicationBackends } = options;\n const filesWritten: string[] = [];\n\n mkdirSync(outputDir, { recursive: true });\n filesWritten.push(writeDeployZoneIgnoreGuard(outputDir));\n\n if (runtime === WildoDeploymentRuntime.KUBERNETES) {\n const replicaOverrides = options.config.kubernetes?.services ?? {};\n // The application's own store (#3367), which bounds every runtime's database network segments on both lanes.\n const applicationDatabaseEngine = resolveApplicationDatabaseEngine(options.config.applicationDatabase);\n const appliedReplicaKeys = new Set<string>();\n const replicaFor = (key: string | undefined): number | undefined => key ? replicaOverrides[key]?.replicas : undefined;\n const k8sDir = join(outputDir, 'k8s');\n mkdirSync(k8sDir, { recursive: true });\n\n // Minions and workers are passed for their PROVIDER SECRETS (#369), not merely for symmetry:\n // each application runtime now owns a Secret scoped to its own `providers.scopes` entry, and a\n // runtime whose targets are omitted here gets no Secret at all while its Deployment still\n // mounts one optionally — i.e. it would boot with no provider credentials. The same two lists\n // already drive the Deployment render below, so both sides read one population.\n const k8sResources = generateK8sSecrets(env, credentials, {\n applicationBackends,\n applicationMinions: options.applicationMinions,\n applicationWorkers: options.applicationWorkers,\n config: options.config,\n });\n\n for (const [name, resource] of Object.entries(k8sResources)) {\n const filePath = join(k8sDir, `${name}.yaml`);\n writeFileSync(filePath, resource.yaml, 'utf8');\n filesWritten.push(filePath);\n }\n\n // Remote-cluster TLS manifests (ClusterIssuer + Traefik ServersTransport)\n // and the namespace's NetworkPolicy set (#3511)\n // as FLAT siblings of the Secrets — CI's `kubectl apply -f k8s/` is\n // non-recursive — plus the provider-agnostic Traefik Helm values consumed\n // by the CI `helm install traefik -f traefik-values.yaml` step. No-ops for\n // LOCAL envs; requires `frameworkPath` to resolve the templates.\n if (options.frameworkPath) {\n // The ClusterIssuer and the Traefik install are the CLUSTER's, installed once by its infrastructure\n // host; a hosted application deploys its own workloads into that cluster and nothing cluster-wide.\n if (!InfrastructureHost.isHosted(env)) {\n filesWritten.push(\n ...K8sManifestGenerator.renderRemoteClusterInfra(env, options.frameworkPath, k8sDir),\n );\n const traefikValuesPath = K8sManifestGenerator.renderRemoteTraefikValues(\n env, options.frameworkPath, outputDir,\n );\n if (traefikValuesPath) filesWritten.push(traefikValuesPath);\n }\n\n // Per-service app manifests, as FLAT files: a backend Deployment+Service,\n // one nginx Deployment+Service per frontend, and one Ingress routing each\n // serviceHosts host → its per-service Service. This is the reachable remote\n // self-host app-deploy path (LOCAL-only renderAllManifests never runs the\n // app render). Deduped per app (the primary-first backend target carries\n // the shared appName/ingressRoutes/frontends context); the backend mounts\n // the canonical `{appSlug}-secret` emitted above.\n const renderedApps = new Set<string>();\n for (const target of applicationBackends ?? []) {\n if (!target.appName || !target.ingressRoutes?.length || renderedApps.has(target.appName)) {\n continue;\n }\n renderedApps.add(target.appName);\n const applicationManifests = K8sManifestGenerator.renderApplicationForTarget(\n env,\n options.frameworkPath,\n {\n applicationDatabaseEngine,\n appName: target.appName,\n backendServiceName: target.serviceName,\n backendReplicas: replicaFor(target.serviceKey),\n ingressRoutes: target.ingressRoutes,\n podPorts: target.podPorts,\n healthPort: target.healthPort,\n // `frontends` already carries each frontend's own resolved isolation.\n frontends: target.frontends?.map((frontend) => ({ ...frontend, replicas: replicaFor(frontend.serviceKey) })),\n isolation: target.isolation,\n },\n options.imageTag,\n );\n for (const { name, yaml } of applicationManifests) {\n // Count a key as applied only when its Deployment was actually emitted.\n for (const service of [target, ...(target.frontends ?? [])]) {\n if (service.serviceKey && name === `${service.serviceName}-deployment`) appliedReplicaKeys.add(service.serviceKey);\n }\n const appManifestPath = join(k8sDir, `${name}.yaml`);\n writeFileSync(appManifestPath, yaml, 'utf8');\n filesWritten.push(appManifestPath);\n }\n }\n\n // Per-app-owned worker Deployments + ClusterIP Services. Worker dispatch\n // addresses are supplied by the application target builder.\n for (const worker of options.applicationWorkers ?? []) {\n if (!worker.appName) continue;\n for (const { name, yaml } of K8sManifestGenerator.renderWorkerForTarget(\n env,\n options.frameworkPath,\n {\n applicationDatabaseEngine,\n appName: worker.appName,\n workerName: worker.workerName,\n httpPort: worker.http?.port,\n replicas: worker.replicas,\n healthPath: worker.http?.healthPath,\n readyPath: worker.http?.readyPath,\n isolation: worker.isolation,\n metricsPath: worker.http?.metricsPath,\n },\n options.imageTag,\n )) {\n const workerPath = join(k8sDir, `${name}.yaml`);\n writeFileSync(workerPath, yaml, 'utf8');\n filesWritten.push(workerPath);\n }\n }\n\n // Per-app-owned minion Deployments (KD-5 — singleton, shares app scope).\n for (const minion of options.applicationMinions ?? []) {\n if (!minion.appName) continue;\n for (const { name, yaml } of K8sManifestGenerator.renderMinionForTarget(\n env,\n options.frameworkPath,\n {\n applicationDatabaseEngine,\n appName: minion.appName,\n minionName: minion.minionName,\n // Forwarded verbatim, absence included — see `accessDeclaration` on\n // the target type. Defaulting it here would decide the minion's\n // network membership at a site that knows nothing about it.\n accessDeclaration: minion.accessDeclaration,\n reinstantiationPolicy: minion.reinstantiationPolicy,\n gracePeriodSec: minion.gracePeriodSec,\n liveness: minion.liveness,\n isolation: minion.isolation,\n },\n options.imageTag,\n )) {\n const minionPath = join(k8sDir, `${name}.yaml`);\n writeFileSync(minionPath, yaml, 'utf8');\n filesWritten.push(minionPath);\n }\n }\n }\n\n const platformKeys = new Set<string>(Object.values(PlatformWildoServices));\n for (const [key, override] of Object.entries(replicaOverrides)) {\n if (override.replicas !== undefined && !appliedReplicaKeys.has(key) && !platformKeys.has(key)) {\n log.warn(`Kubernetes replica override '${key}' was not applied: no matching application Deployment was emitted. Use the authored SaaS service key; CDN, unserved and absent targets have no Deployment.`);\n }\n }\n log.info(` Generated ${filesWritten.length} K8s resources`);\n }\n\n if (runtime === WildoDeploymentRuntime.DOCKER_COMPOSE) {\n const composeDir = join(outputDir, 'compose');\n mkdirSync(composeDir, { recursive: true });\n\n const addressCtx = ServiceAddressResolver.fromEnvironment(env, AddressPerspective.CONTAINER_INTERNAL);\n const addresses = ServiceAddressResolver.resolve(addressCtx);\n\n // Single load+hydrate seam — the REMOTE compose platform + app env this generator emits must\n // carry the infra posture (OTEL_*/LOG_LEVEL/provider-selection) the setup config.json omits.\n const config = loadInfraHydratedConfig(env, options.config);\n const infraEnv = PlatformEnvVarsBuilder.buildInfraCredentialEnv(credentials, config, env);\n const platformEnv = PlatformEnvVarsBuilder.buildAppsManagerFullEnv(\n credentials, addresses, config, env,\n );\n const mergedEnv = { ...infraEnv, ...platformEnv };\n // The platform compose env is the infrastructure host's deploy artifact; a hosted application ships\n // only its own runtime env files below.\n if (!InfrastructureHost.isHosted(env)) {\n const platformEnvPath = join(composeDir, '.env.wildo-platform');\n writeFileSync(platformEnvPath, formatEnvFile(mergedEnv), 'utf8');\n filesWritten.push(platformEnvPath);\n }\n\n if (applicationBackends) {\n for (const target of applicationBackends) {\n const appEnv = PlatformEnvVarsBuilder.buildApplicationBackendEnv(\n target.bootstrapCredentials,\n target.serviceName,\n credentials,\n addresses,\n config,\n env.name,\n // REMOTE compose lane — see the sibling k8s-secrets call site. Both were invisible to\n // the original enumeration because they build the same backend env from a different\n // generator, and neither is exercised by a local `wildo config sync`.\n declaredProviderScope(target.scopedProviderRefs),\n {\n appDatabaseName: target.appDatabaseName,\n redisKeyPrefix: target.redisKeyPrefix,\n storageBucketPrefix: target.storageBucketPrefix,\n deploymentLocationType: env.locationType,\n mongodbDirectConnection: env.locationType === WildoLocationType.LOCAL,\n // Serialized into APPLICATION_RUNTIME_ENDPOINTS so the compose app\n // reconstructs `runtime.endPoints`. For REMOTE these are the\n // serviceHosts-driven public URLs (matching the Traefik ingress\n // routes emitted below — the CORS invariant); omitting them left the\n // remote compose app with no runtime topology.\n runtimeEndpoints: target.runtimeEndpoints,\n // Backend→worker dispatch URLs (G-8 / MW4): emit `WILDO_WORKER_<NAME>_URL`\n // into the backend's `.env` so it can reach each declared worker on the\n // shared network (same `{appSlug}-worker-{name}` service name as k8s).\n workerUrls: target.workerUrls,\n },\n );\n const envPath = join(composeDir, `${target.serviceName}.env`);\n writeFileSync(envPath, formatEnvFile(appEnv), 'utf8');\n filesWritten.push(envPath);\n }\n }\n\n // Self-hosted app serving stack: the app image behind a Traefik reverse\n // proxy that TLS-terminates and routes each serviceHosts subdomain to its\n // port (the docker counterpart of the k8s ingress — SAME `ingressRoutes`).\n // Rendered only when the app carries a deploy context (REMOTE).\n const appDeployTarget = applicationBackends?.find(\n (t) => t.appName && t.ingressRoutes && t.ingressRoutes.length > 0,\n );\n if (options.frameworkPath && appDeployTarget?.appName && appDeployTarget.ingressRoutes) {\n const composeTemplatesHome = resolveFrameworkLayout(options.frameworkPath).dockerComposeTemplatesHome;\n const tp = new TemplateProcessor(composeTemplatesHome);\n // Traefik's Let's Encrypt resolver still registers with an empty contact\n // email (ACME v2 makes it optional), but the operator then gets no\n // expiry-warning mail — surface it so a self-hoster can set\n // `remoteProvider.acmeEmail` before certs silently near expiry.\n if (!env.remoteProvider?.acmeEmail) {\n log.warn(\n ' remoteProvider.acmeEmail is unset — the app Traefik stack will request TLS certs without a contact email (no expiry notifications).',\n );\n }\n // Per-service model: build the app CONTAINER list (the backend + one nginx\n // container per frontend), each with its serviceHosts host + the port\n // Traefik load-balances to. In compose Traefik routes straight to the\n // container's own port — the backend's API port; a frontend nginx's :80\n // (NOT the k8s Service port). The backend loads its `${serviceName}.env`;\n // static frontends load none (config baked at build time).\n const routeByService = new Map(\n appDeployTarget.ingressRoutes.map((r) => [r.serviceName, r]),\n );\n const backendRoute = routeByService.get(appDeployTarget.serviceName);\n // Durable immudb audit trust-anchor mount for the backend container — set when the env has an\n // immudb audit backing service configured (same gate as the k8s app-backend PVC). The compose\n // backend then gets IMMUDB_STATE_DIR + a named volume mounted at it; without a durable volume the\n // audit client runs EPHEMERAL and a cross-restart rollback of the ledger is silently re-adopted.\n const immudbAuditStateDir = env.backingServices?.[BackingServiceKind.IMMUDB]\n ? IMMUDB_AUDIT_STATE_CONTAINER_DIR\n : undefined;\n // Container isolation, projected identically for both kinds. `runAsUser`\n // is the combined `<uid>:<gid>` compose wants for `user:`; the numeric\n // pair rides alongside because every `tmpfs:` entry needs `uid=`/`gid=`\n // options — a bare tmpfs is root-owned 0755 and unwritable by the non-root\n // process this same block just declared.\n const composeIsolation = (\n isolation: { runAsUser: number; runAsGroup: number; writablePaths: string[] } | undefined,\n fallbackUid: number,\n fallbackWritablePaths: readonly string[],\n ) => {\n const uid = isolation?.runAsUser ?? fallbackUid;\n const gid = isolation?.runAsGroup ?? fallbackUid;\n return {\n runAsUser: `${uid}:${gid}`,\n runAsUserId: uid,\n runAsGroupId: gid,\n writablePaths: [\n RUNTIME_MANDATORY_WRITABLE_PATH,\n ...(isolation?.writablePaths ?? fallbackWritablePaths),\n ],\n pidsLimit: RUNTIME_DEFAULT_PIDS_LIMIT,\n };\n };\n const appContainers = [\n ...(backendRoute\n ? [\n {\n serviceName: appDeployTarget.serviceName,\n host: backendRoute.host,\n port: backendRoute.port,\n isBackend: true,\n envFile: `${appDeployTarget.serviceName}.env`,\n // Derived, never hand-listed (#3367): the backend's membership, bounded by the application's store.\n networks: resolveRuntimeComposeNetworks(\n { kind: ApplicationRuntimePrincipalKind.APPLICATION_BACKEND } as ApplicationRuntimePrincipal,\n undefined,\n { servesHttp: true, applicationDatabaseEngine: resolveApplicationDatabaseEngine(options.config.applicationDatabase) },\n ),\n immudbAuditStateDir,\n ...composeIsolation(appDeployTarget.isolation, APP_BACKEND_DEFAULT_RUNTIME_UID, []),\n },\n ]\n : []),\n ...(appDeployTarget.frontends ?? []).flatMap((fe) => {\n const r = routeByService.get(fe.serviceName);\n return r\n ? [{\n serviceName: fe.serviceName,\n host: r.host,\n // Traefik routes to the container's own port. nginx keeps :80 —\n // containers set `ip_unprivileged_port_start=0`, so binding it\n // as a non-root user works (measured, not assumed).\n port: 80,\n isBackend: false,\n // A static frontend is no runtime principal: it joins the edge and nothing else.\n networks: resolveRuntimeComposeNetworks(undefined, undefined, {\n servesHttp: true,\n applicationDatabaseEngine: resolveApplicationDatabaseEngine(options.config.applicationDatabase),\n }),\n ...composeIsolation(\n fe.isolation,\n APP_FRONTEND_DEFAULT_RUNTIME_UID,\n APP_FRONTEND_MANDATORY_WRITABLE_PATHS,\n ),\n }]\n : [];\n }),\n ];\n const rendered = tp.processTemplate('docker-compose.app.yml.hbs', {\n appName: appDeployTarget.appName,\n appContainers,\n registry: env.remoteProvider?.registryEndpoint ?? '',\n acmeEmail: env.remoteProvider?.acmeEmail ?? '',\n envName: env.name,\n // The edge — the reverse proxy, :80/:443 and the ACME store — belongs to whoever owns the\n // infrastructure. A hosted environment renders its services and labels only; the host's proxy\n // already binds those ports and discovers these containers over the shared `wildo-edge` network.\n hostedByAnotherApplication: InfrastructureHost.isHosted(env),\n });\n const appComposePath = join(composeDir, 'docker-compose.app.yml');\n writeFileSync(appComposePath, rendered, 'utf8');\n filesWritten.push(appComposePath);\n }\n\n log.info(` Generated ${filesWritten.length} Docker Compose env files`);\n }\n\n return { filesWritten, runtime };\n}\n"]}
1
+ {"version":3,"file":"ci-deploy-generator.service.js","sourceRoot":"","sources":["../../../../src/services/deployment/ci-deploy-generator.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAQ5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;AAClG,OAAO,EAAE,uBAAuB,EAAE,MAAM,qEAAqE,CAAC;AAC9G,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAC1H,OAAO,EAAE,kBAAkB,EAAE,MAAM,kEAAkE,CAAC;AACtG,OAAO,EAAE,oBAAoB,EAAE,MAAM,mEAAmE,CAAC;AACzG,OAAO,EAAE,kBAAkB,EAAE,MAAM,6DAA6D,CAAC;AACjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AACpF,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,E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S,EAAE;oCAC5D,UAAU,EAAE,IAAI;oCAChB,GAAG,+BAA+B,CAAC,OAAO,CAAC,MAAM,CAAC;iCACnD,CAAC;gCACF,GAAG,gBAAgB,CACjB,EAAE,CAAC,SAAS,EACZ,gCAAgC,EAChC,qCAAqC,CACtC;6BACF,CAAC;wBACJ,CAAC,CAAC,EAAE,CAAC;gBACT,CAAC,CAAC;aACH,CAAC;YACF,MAAM,QAAQ,GAAG,EAAE,CAAC,eAAe,CAAC,4BAA4B,EAAE;gBAChE,OAAO,EAAE,eAAe,CAAC,OAAO;gBAChC,aAAa;gBACb,QAAQ,EAAE,GAAG,CAAC,cAAc,EAAE,gBAAgB,IAAI,EAAE;gBACpD,SAAS,EAAE,GAAG,CAAC,cAAc,EAAE,SAAS,IAAI,EAAE;gBAC9C,OAAO,EAAE,GAAG,CAAC,IAAI;gBACjB,0FAA0F;gBAC1F,8FAA8F;gBAC9F,iGAAiG;gBACjG,0BAA0B,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC;aAC7D,CAAC,CAAC;YACH,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAAC;YAClE,aAAa,CAAC,cAAc,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;YAChD,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACpC,CAAC;QAED,GAAG,CAAC,IAAI,CAAC,eAAe,YAAY,CAAC,MAAM,2BAA2B,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;AACnC,CAAC","sourcesContent":["/**\n * CiDeployGeneratorService — generate deployment artifacts in CI mode.\n *\n * Produces the files a CI pipeline needs to deploy a Wildo app:\n * - **Kubernetes**: K8s Secret + ConfigMap YAML, written to `<outputDir>/k8s/`\n * - **Docker Compose**: `.env` files for docker-compose services, written to `<outputDir>/compose/`\n *\n * `<outputDir>` is the env-scoped deploy zone\n * `<appRoot>/.wildo-saas/deploy/<env>/`, resolved by\n * `EnvironmentPaths.resolveScopedDeployArtifactsDir`. Every render also writes\n * an ignore-everything `.gitignore` there — see\n * {@link DEPLOY_ZONE_GITIGNORE_CONTENT}.\n *\n * In CI mode secrets are reconstructed from flat env vars (GitHub Secrets\n * injected via `WILDO_SECRET_*`) instead of reading `secrets.json` from disk.\n * The OUTPUT LOCATION is identical either way — a local\n * `wildo config sync --domain config` deposits the same secret-bearing files,\n * which is precisely why the ignore guard is unconditional.\n */\n\nimport { mkdirSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport type { PlatformEnvSecretsJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport type { PlatformEnvConfigJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport type {\n ApplicationBackendEnvTarget,\n ApplicationWorkerEnvTarget,\n ApplicationMinionEnvTarget,\n} from '~wildo-cli/services/environment/env-configuration-generator.service';\nimport { PlatformEnvVarsBuilder } from '~wildo-cli/services/environment/env-vars-builder.service';\nimport { loadInfraHydratedConfig } from '~wildo-cli/services/environment/env-configuration-generator.service';\nimport { ServiceAddressResolver, AddressPerspective } from '~wildo-cli/services/catalog/service-address-resolver.service';\nimport { generateK8sSecrets } from '~wildo-cli/services/deployment/k8s/k8s-secrets-generator.service';\nimport { K8sManifestGenerator } from '~wildo-cli/services/deployment/k8s/k8s-manifest-generator.service';\nimport { InfrastructureHost } from '~wildo-cli/services/environment/infrastructure-host.service';\nimport { TemplateProcessor } from '~wildo-cli/infrastructure/io/template-processor';\nimport {\n resolveFrameworkLayout,\n WildoDeploymentRuntime,\n WildoLocationType,\n PlatformWildoServices,\n BackingServiceKind,\n RUNTIME_MANDATORY_WRITABLE_PATH,\n RUNTIME_DEFAULT_PIDS_LIMIT,\n APP_BACKEND_DEFAULT_RUNTIME_UID,\n APP_FRONTEND_DEFAULT_RUNTIME_UID,\n APP_FRONTEND_MANDATORY_WRITABLE_PATHS,\n ApplicationRuntimePrincipalKind,\n type ApplicationRuntimePrincipal,\n resolveApplicationDatabaseEngine,\n resolveRuntimeApplicationStores,\n resolveRuntimeComposeNetworks,\n} from '@wildo-ai/platform-config-lib';\nimport { IMMUDB_AUDIT_STATE_CONTAINER_DIR } from '~wildo-cli/services/data-services/data-services.schemas';\nimport type { PlatformEnvironmentConfiguration } from '~wildo-cli/services/environment/environment.schemas';\nimport type { Logger } from '~wildo-cli/kernel/types';\nimport { declaredProviderScope } from '~wildo-cli/services/credentials/provider-env-vars.utils';\n\n/**\n * Format a record of env vars into a `.env` file string.\n * Values containing spaces, `=`, `#`, or newlines are double-quoted.\n */\nfunction formatEnvFile(env: Record<string, string>): string {\n const lines: string[] = [];\n for (const [key, value] of Object.entries(env)) {\n const needsQuoting = /[\\s=#\"'\\\\]|\\n/.test(value);\n const formatted = needsQuoting\n ? `${key}=\"${value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"').replace(/\\r/g, '\\\\r').replace(/\\n/g, '\\\\n')}\"`\n : `${key}=${value}`;\n lines.push(formatted);\n }\n return lines.join('\\n') + '\\n';\n}\n\n/**\n * Ignore-everything guard written into each rendered deploy-artifact directory.\n *\n * EVERY file this generator emits is secret-bearing by construction — K8s\n * `Secret` manifests carry base64 credentials, the compose `.env` files carry\n * the platform admin secret, the apps-manager signing key and database URLs\n * with passwords. The zone lives inside `.wildo-saas/`, which is a PARTLY\n * TRACKED tree, so \"it's under a dot-directory\" is not protection.\n *\n * The framework does not generate an application's root `.gitignore`, so an\n * app-authored rule is a guarantee the framework cannot make on the app's\n * behalf. Writing the guard beside the artifacts makes the zone self-protecting\n * from its very first render, in every application, with no bootstrap step and\n * nothing for an app author to remember. The app's own root rule\n * (`.wildo-saas/deploy/`) stays as defense in depth.\n *\n * Bare `*` — deliberately no `!.gitignore` re-include. The guard is a generated\n * artifact regenerated on every render; it is not repository truth and must not\n * be committed either. It does not affect `kubectl apply` / `docker compose`,\n * which read the directory directly and know nothing about git.\n *\n * Precedent: `templates/infra/docker-compose/.gitignore` ships the same\n * shape next to its generated `.env`.\n */\nconst DEPLOY_ZONE_GITIGNORE_CONTENT = [\n '# Generated deploy artifacts — every file here carries credentials.',\n '# Written by `wildo config sync --domain config`; never commit any of it.',\n '*',\n '',\n].join('\\n');\n\n/**\n * Write the {@link DEPLOY_ZONE_GITIGNORE_CONTENT} guard into a rendered deploy\n * directory. Unconditional (not `existsSync`-gated) so a deleted or edited\n * guard self-heals on the next render and cannot silently drift.\n */\nfunction writeDeployZoneIgnoreGuard(outputDir: string): string {\n const guardPath = join(outputDir, '.gitignore');\n writeFileSync(guardPath, DEPLOY_ZONE_GITIGNORE_CONTENT, 'utf8');\n return guardPath;\n}\n\nexport interface CiDeployGenerateOptions {\n env: PlatformEnvironmentConfiguration;\n credentials: PlatformEnvSecretsJson;\n config: PlatformEnvConfigJson;\n runtime: WildoDeploymentRuntime;\n outputDir: string;\n applicationBackends?: ApplicationBackendEnvTarget[];\n /** App-owned worker/minion deploy targets — render per-worker/per-minion k8s manifests (REMOTE). */\n applicationWorkers?: ApplicationWorkerEnvTarget[];\n applicationMinions?: ApplicationMinionEnvTarget[];\n /**\n * Framework repository root — required to resolve `templates/infra/k8s/**`\n * when rendering the remote-cluster TLS manifests (ClusterIssuer, tls-config)\n * + Traefik Helm values, AND the per-app Deployment/Ingress/Service. When\n * omitted, only Secrets/ConfigMaps are emitted (the pre-remote-TLS behavior).\n */\n frameworkPath?: string;\n /**\n * Container image tag for the app Deployment (e.g. the CI git SHA / release\n * tag). Defaults to `DEFAULT_PLATFORM_IMAGE_TAG` when omitted.\n */\n imageTag?: string;\n}\n\nexport interface CiDeployGenerateResult {\n filesWritten: string[];\n runtime: WildoDeploymentRuntime;\n}\n\nexport function generateCiDeployArtifacts(\n options: CiDeployGenerateOptions,\n log: Logger,\n): CiDeployGenerateResult {\n const { env, credentials, runtime, outputDir, applicationBackends } = options;\n const filesWritten: string[] = [];\n\n mkdirSync(outputDir, { recursive: true });\n filesWritten.push(writeDeployZoneIgnoreGuard(outputDir));\n\n if (runtime === WildoDeploymentRuntime.KUBERNETES) {\n const replicaOverrides = options.config.kubernetes?.services ?? {};\n // The application's own store (#3367), which bounds every runtime's database network segments on both lanes.\n const applicationDatabaseEngine = resolveApplicationDatabaseEngine(options.config.applicationDatabase);\n const appliedReplicaKeys = new Set<string>();\n const replicaFor = (key: string | undefined): number | undefined => key ? replicaOverrides[key]?.replicas : undefined;\n const k8sDir = join(outputDir, 'k8s');\n mkdirSync(k8sDir, { recursive: true });\n\n // Minions and workers are passed for their PROVIDER SECRETS (#369), not merely for symmetry:\n // each application runtime now owns a Secret scoped to its own `providers.scopes` entry, and a\n // runtime whose targets are omitted here gets no Secret at all while its Deployment still\n // mounts one optionally — i.e. it would boot with no provider credentials. The same two lists\n // already drive the Deployment render below, so both sides read one population.\n const k8sResources = generateK8sSecrets(env, credentials, {\n applicationBackends,\n applicationMinions: options.applicationMinions,\n applicationWorkers: options.applicationWorkers,\n config: options.config,\n });\n\n for (const [name, resource] of Object.entries(k8sResources)) {\n const filePath = join(k8sDir, `${name}.yaml`);\n writeFileSync(filePath, resource.yaml, 'utf8');\n filesWritten.push(filePath);\n }\n\n // Remote-cluster TLS manifests (ClusterIssuer + Traefik ServersTransport)\n // and the namespace's NetworkPolicy set (#3511)\n // as FLAT siblings of the Secrets — CI's `kubectl apply -f k8s/` is\n // non-recursive — plus the provider-agnostic Traefik Helm values consumed\n // by the CI `helm install traefik -f traefik-values.yaml` step. No-ops for\n // LOCAL envs; requires `frameworkPath` to resolve the templates.\n if (options.frameworkPath) {\n // The ClusterIssuer and the Traefik install are the CLUSTER's, installed once by its infrastructure\n // host; a hosted application deploys its own workloads into that cluster and nothing cluster-wide.\n if (!InfrastructureHost.isHosted(env)) {\n filesWritten.push(\n ...K8sManifestGenerator.renderRemoteClusterInfra(env, options.frameworkPath, k8sDir),\n );\n const traefikValuesPath = K8sManifestGenerator.renderRemoteTraefikValues(\n env, options.frameworkPath, outputDir,\n );\n if (traefikValuesPath) filesWritten.push(traefikValuesPath);\n }\n\n // Per-service app manifests, as FLAT files: a backend Deployment+Service,\n // one nginx Deployment+Service per frontend, and one Ingress routing each\n // serviceHosts host → its per-service Service. This is the reachable remote\n // self-host app-deploy path (LOCAL-only renderAllManifests never runs the\n // app render). Deduped per app (the primary-first backend target carries\n // the shared appName/ingressRoutes/frontends context); the backend mounts\n // the canonical `{appSlug}-secret` emitted above.\n const renderedApps = new Set<string>();\n for (const target of applicationBackends ?? []) {\n if (!target.appName || !target.ingressRoutes?.length || renderedApps.has(target.appName)) {\n continue;\n }\n renderedApps.add(target.appName);\n const applicationManifests = K8sManifestGenerator.renderApplicationForTarget(\n env,\n options.frameworkPath,\n {\n applicationDatabaseEngine,\n appName: target.appName,\n backendServiceName: target.serviceName,\n backendReplicas: replicaFor(target.serviceKey),\n ingressRoutes: target.ingressRoutes,\n podPorts: target.podPorts,\n healthPort: target.healthPort,\n // `frontends` already carries each frontend's own resolved isolation.\n frontends: target.frontends?.map((frontend) => ({ ...frontend, replicas: replicaFor(frontend.serviceKey) })),\n isolation: target.isolation,\n },\n options.imageTag,\n );\n for (const { name, yaml } of applicationManifests) {\n // Count a key as applied only when its Deployment was actually emitted.\n for (const service of [target, ...(target.frontends ?? [])]) {\n if (service.serviceKey && name === `${service.serviceName}-deployment`) appliedReplicaKeys.add(service.serviceKey);\n }\n const appManifestPath = join(k8sDir, `${name}.yaml`);\n writeFileSync(appManifestPath, yaml, 'utf8');\n filesWritten.push(appManifestPath);\n }\n }\n\n // Per-app-owned worker Deployments + ClusterIP Services. Worker dispatch\n // addresses are supplied by the application target builder.\n for (const worker of options.applicationWorkers ?? []) {\n if (!worker.appName) continue;\n for (const { name, yaml } of K8sManifestGenerator.renderWorkerForTarget(\n env,\n options.frameworkPath,\n {\n applicationDatabaseEngine,\n appName: worker.appName,\n workerName: worker.workerName,\n httpPort: worker.http?.port,\n replicas: worker.replicas,\n healthPath: worker.http?.healthPath,\n readyPath: worker.http?.readyPath,\n isolation: worker.isolation,\n metricsPath: worker.http?.metricsPath,\n },\n options.imageTag,\n )) {\n const workerPath = join(k8sDir, `${name}.yaml`);\n writeFileSync(workerPath, yaml, 'utf8');\n filesWritten.push(workerPath);\n }\n }\n\n // Per-app-owned minion Deployments (KD-5 — singleton, shares app scope).\n for (const minion of options.applicationMinions ?? []) {\n if (!minion.appName) continue;\n for (const { name, yaml } of K8sManifestGenerator.renderMinionForTarget(\n env,\n options.frameworkPath,\n {\n applicationDatabaseEngine,\n appName: minion.appName,\n minionName: minion.minionName,\n // Forwarded verbatim, absence included — see `accessDeclaration` on\n // the target type. Defaulting it here would decide the minion's\n // network membership at a site that knows nothing about it.\n accessDeclaration: minion.accessDeclaration,\n reinstantiationPolicy: minion.reinstantiationPolicy,\n gracePeriodSec: minion.gracePeriodSec,\n liveness: minion.liveness,\n isolation: minion.isolation,\n },\n options.imageTag,\n )) {\n const minionPath = join(k8sDir, `${name}.yaml`);\n writeFileSync(minionPath, yaml, 'utf8');\n filesWritten.push(minionPath);\n }\n }\n }\n\n const platformKeys = new Set<string>(Object.values(PlatformWildoServices));\n for (const [key, override] of Object.entries(replicaOverrides)) {\n if (override.replicas !== undefined && !appliedReplicaKeys.has(key) && !platformKeys.has(key)) {\n log.warn(`Kubernetes replica override '${key}' was not applied: no matching application Deployment was emitted. Use the authored SaaS service key; CDN, unserved and absent targets have no Deployment.`);\n }\n }\n log.info(` Generated ${filesWritten.length} K8s resources`);\n }\n\n if (runtime === WildoDeploymentRuntime.DOCKER_COMPOSE) {\n const composeDir = join(outputDir, 'compose');\n mkdirSync(composeDir, { recursive: true });\n\n const addressCtx = ServiceAddressResolver.fromEnvironment(env, AddressPerspective.CONTAINER_INTERNAL);\n const addresses = ServiceAddressResolver.resolve(addressCtx);\n\n // Single load+hydrate seam — the REMOTE compose platform + app env this generator emits must\n // carry the infra posture (OTEL_*/LOG_LEVEL/provider-selection) the setup config.json omits.\n const config = loadInfraHydratedConfig(env, options.config);\n const infraEnv = PlatformEnvVarsBuilder.buildInfraCredentialEnv(credentials, config, env);\n const platformEnv = PlatformEnvVarsBuilder.buildAppsManagerFullEnv(\n credentials, addresses, config, env,\n );\n const mergedEnv = { ...infraEnv, ...platformEnv };\n // The platform compose env is the infrastructure host's deploy artifact; a hosted application ships\n // only its own runtime env files below.\n if (!InfrastructureHost.isHosted(env)) {\n const platformEnvPath = join(composeDir, '.env.wildo-platform');\n writeFileSync(platformEnvPath, formatEnvFile(mergedEnv), 'utf8');\n filesWritten.push(platformEnvPath);\n }\n\n if (applicationBackends) {\n for (const target of applicationBackends) {\n const appEnv = PlatformEnvVarsBuilder.buildApplicationBackendEnv(\n target.bootstrapCredentials,\n target.serviceName,\n credentials,\n addresses,\n config,\n env.name,\n // REMOTE compose lane — see the sibling k8s-secrets call site. Both were invisible to\n // the original enumeration because they build the same backend env from a different\n // generator, and neither is exercised by a local `wildo config sync`.\n declaredProviderScope(target.scopedProviderRefs),\n {\n appDatabaseName: target.appDatabaseName,\n redisKeyPrefix: target.redisKeyPrefix,\n storageBucketPrefix: target.storageBucketPrefix,\n deploymentLocationType: env.locationType,\n mongodbDirectConnection: env.locationType === WildoLocationType.LOCAL,\n // Serialized into APPLICATION_RUNTIME_ENDPOINTS so the compose app\n // reconstructs `runtime.endPoints`. For REMOTE these are the\n // serviceHosts-driven public URLs (matching the Traefik ingress\n // routes emitted below — the CORS invariant); omitting them left the\n // remote compose app with no runtime topology.\n runtimeEndpoints: target.runtimeEndpoints,\n // Backend→worker dispatch URLs (G-8 / MW4): emit `WILDO_WORKER_<NAME>_URL`\n // into the backend's `.env` so it can reach each declared worker on the\n // shared network (same `{appSlug}-worker-{name}` service name as k8s).\n workerUrls: target.workerUrls,\n },\n );\n const envPath = join(composeDir, `${target.serviceName}.env`);\n writeFileSync(envPath, formatEnvFile(appEnv), 'utf8');\n filesWritten.push(envPath);\n }\n }\n\n // Self-hosted app serving stack: the app image behind a Traefik reverse\n // proxy that TLS-terminates and routes each serviceHosts subdomain to its\n // port (the docker counterpart of the k8s ingress — SAME `ingressRoutes`).\n // Rendered only when the app carries a deploy context (REMOTE).\n const appDeployTarget = applicationBackends?.find(\n (t) => t.appName && t.ingressRoutes && t.ingressRoutes.length > 0,\n );\n if (options.frameworkPath && appDeployTarget?.appName && appDeployTarget.ingressRoutes) {\n const composeTemplatesHome = resolveFrameworkLayout(options.frameworkPath).dockerComposeTemplatesHome;\n const tp = new TemplateProcessor(composeTemplatesHome);\n // Traefik's Let's Encrypt resolver still registers with an empty contact\n // email (ACME v2 makes it optional), but the operator then gets no\n // expiry-warning mail — surface it so a self-hoster can set\n // `remoteProvider.acmeEmail` before certs silently near expiry.\n if (!env.remoteProvider?.acmeEmail) {\n log.warn(\n ' remoteProvider.acmeEmail is unset — the app Traefik stack will request TLS certs without a contact email (no expiry notifications).',\n );\n }\n // Per-service model: build the app CONTAINER list (the backend + one nginx\n // container per frontend), each with its serviceHosts host + the port\n // Traefik load-balances to. In compose Traefik routes straight to the\n // container's own port — the backend's API port; a frontend nginx's :80\n // (NOT the k8s Service port). The backend loads its `${serviceName}.env`;\n // static frontends load none (config baked at build time).\n const routeByService = new Map(\n appDeployTarget.ingressRoutes.map((r) => [r.serviceName, r]),\n );\n const backendRoute = routeByService.get(appDeployTarget.serviceName);\n // Durable immudb audit trust-anchor mount for the backend container — set when the env has an\n // immudb audit backing service configured (same gate as the k8s app-backend PVC). The compose\n // backend then gets IMMUDB_STATE_DIR + a named volume mounted at it; without a durable volume the\n // audit client runs EPHEMERAL and a cross-restart rollback of the ledger is silently re-adopted.\n const immudbAuditStateDir = env.backingServices?.[BackingServiceKind.IMMUDB]\n ? IMMUDB_AUDIT_STATE_CONTAINER_DIR\n : undefined;\n // Container isolation, projected identically for both kinds. `runAsUser`\n // is the combined `<uid>:<gid>` compose wants for `user:`; the numeric\n // pair rides alongside because every `tmpfs:` entry needs `uid=`/`gid=`\n // options — a bare tmpfs is root-owned 0755 and unwritable by the non-root\n // process this same block just declared.\n const composeIsolation = (\n isolation: { runAsUser: number; runAsGroup: number; writablePaths: string[] } | undefined,\n fallbackUid: number,\n fallbackWritablePaths: readonly string[],\n ) => {\n const uid = isolation?.runAsUser ?? fallbackUid;\n const gid = isolation?.runAsGroup ?? fallbackUid;\n return {\n runAsUser: `${uid}:${gid}`,\n runAsUserId: uid,\n runAsGroupId: gid,\n writablePaths: [\n RUNTIME_MANDATORY_WRITABLE_PATH,\n ...(isolation?.writablePaths ?? fallbackWritablePaths),\n ],\n pidsLimit: RUNTIME_DEFAULT_PIDS_LIMIT,\n };\n };\n const appContainers = [\n ...(backendRoute\n ? [\n {\n serviceName: appDeployTarget.serviceName,\n host: backendRoute.host,\n port: backendRoute.port,\n isBackend: true,\n envFile: `${appDeployTarget.serviceName}.env`,\n // Derived, never hand-listed (#3367): the backend's membership, bounded by the application's store.\n networks: resolveRuntimeComposeNetworks(\n { kind: ApplicationRuntimePrincipalKind.APPLICATION_BACKEND } as ApplicationRuntimePrincipal,\n undefined,\n { servesHttp: true, ...resolveRuntimeApplicationStores(options.config) },\n ),\n immudbAuditStateDir,\n ...composeIsolation(appDeployTarget.isolation, APP_BACKEND_DEFAULT_RUNTIME_UID, []),\n },\n ]\n : []),\n ...(appDeployTarget.frontends ?? []).flatMap((fe) => {\n const r = routeByService.get(fe.serviceName);\n return r\n ? [{\n serviceName: fe.serviceName,\n host: r.host,\n // Traefik routes to the container's own port. nginx keeps :80 —\n // containers set `ip_unprivileged_port_start=0`, so binding it\n // as a non-root user works (measured, not assumed).\n port: 80,\n isBackend: false,\n // A static frontend is no runtime principal: it joins the edge and nothing else.\n networks: resolveRuntimeComposeNetworks(undefined, undefined, {\n servesHttp: true,\n ...resolveRuntimeApplicationStores(options.config),\n }),\n ...composeIsolation(\n fe.isolation,\n APP_FRONTEND_DEFAULT_RUNTIME_UID,\n APP_FRONTEND_MANDATORY_WRITABLE_PATHS,\n ),\n }]\n : [];\n }),\n ];\n const rendered = tp.processTemplate('docker-compose.app.yml.hbs', {\n appName: appDeployTarget.appName,\n appContainers,\n registry: env.remoteProvider?.registryEndpoint ?? '',\n acmeEmail: env.remoteProvider?.acmeEmail ?? '',\n envName: env.name,\n // The edge — the reverse proxy, :80/:443 and the ACME store — belongs to whoever owns the\n // infrastructure. A hosted environment renders its services and labels only; the host's proxy\n // already binds those ports and discovers these containers over the shared `wildo-edge` network.\n hostedByAnotherApplication: InfrastructureHost.isHosted(env),\n });\n const appComposePath = join(composeDir, 'docker-compose.app.yml');\n writeFileSync(appComposePath, rendered, 'utf8');\n filesWritten.push(appComposePath);\n }\n\n log.info(` Generated ${filesWritten.length} Docker Compose env files`);\n }\n\n return { filesWritten, runtime };\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { PlatformEnvConfigJson, PlatformEnvSecretsJson } from '../../../services/credentials/credentials.schemas';
2
2
  import type { PlatformEnvironmentConfiguration } from '../../../services/environment/environment.schemas';
3
- import { WildoLocalDataStorage, type MinionLiveness, type DatabaseEngine } from '@wildo-ai/platform-config-lib';
3
+ import { loadMinionConfigs, loadWorkerConfigs, type WildoSaasConfig, WildoLocalDataStorage, type MinionLiveness, type RuntimeApplicationStores } from '@wildo-ai/platform-config-lib';
4
4
  import { type PlatformServiceMemoryProfile } from '../../../services/catalog/service-catalog.schemas';
5
5
  import type { ApplicationMinionEnvTarget, ApplicationWorkerEnvTarget } from '../../../services/environment/env-configuration-generator.service';
6
6
  /** What the two apps-manager services (INIT and serving) render for a vendor PKCS#11 client (#3019). */
@@ -382,7 +382,7 @@ export declare function composeMinionNetworks(minionKey: string, declaration: {
382
382
  write?: readonly string[];
383
383
  };
384
384
  requiresInternetEgress?: boolean;
385
- }, applicationDatabaseEngine: DatabaseEngine): string[];
385
+ }, applicationStores: RuntimeApplicationStores): string[];
386
386
  /**
387
387
  * A minion's compose `healthcheck`, the mirror of its k8s `livenessProbe` + `startupProbe`. Docker REPORTS an
388
388
  * unhealthy container and does not restart it (`restart: unless-stopped` acts on exit only), so locally this
@@ -441,7 +441,7 @@ export interface DockerComposeAppWorkerEntry {
441
441
  * publishes its HTTP port. The hand-written list this replaced gave every worker MongoDB, Redis, RabbitMQ and object
442
442
  * storage, none of which it holds a credential or topology for.
443
443
  */
444
- export declare function composeWorkerNetworks(workerKey: string, applicationDatabaseEngine: DatabaseEngine): string[];
444
+ export declare function composeWorkerNetworks(workerKey: string, applicationStores: RuntimeApplicationStores): string[];
445
445
  /** The suffix of one app runtime's own compose env file, beside the compose file (#2955). */
446
446
  export declare const COMPOSE_RUNTIME_ENV_FILE_SUFFIX = ".runtime.env";
447
447
  /** Where one minion's or worker's own environment lives for the compose `app-runtimes` profile (#2955). */
@@ -490,6 +490,15 @@ export declare function composeRuntimeEnvFilePaths(environmentName: string, mini
490
490
  * (degraded mode) must leave the existing files of declared runtimes alone.
491
491
  */
492
492
  export declare function pruneUndeclaredComposeRuntimeEnvFiles(environmentName: string, declaredRuntimeServiceNames: ReadonlySet<string>): void;
493
+ /**
494
+ * The application's declaration and its minions' and workers' own configurations, as the compose render reads them:
495
+ * see {@link COMPOSE_RUNTIME_CONFIG_LOAD_OPTIONS}. Exported so the read can be pinned without a full render.
496
+ */
497
+ export declare function loadComposeRuntimeDeclarations(saasRoot: string): Promise<{
498
+ readonly saasConfig: WildoSaasConfig;
499
+ readonly minionEntries: Awaited<ReturnType<typeof loadMinionConfigs>>;
500
+ readonly workerEntries: Awaited<ReturnType<typeof loadWorkerConfigs>>;
501
+ } | null>;
493
502
  /**
494
503
  * Render `docker-compose.wildo-platform.yml` and write it when its content differs from what is on disk.
495
504
  *