@wildo-ai/wildo-cli 1.1.15 → 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 (102) 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/local/dev.command.d.ts +44 -0
  8. package/dist/src/commands/local/dev.command.d.ts.map +1 -1
  9. package/dist/src/commands/local/dev.command.js +74 -3
  10. package/dist/src/commands/local/dev.command.js.map +1 -1
  11. package/dist/src/commands/providers/grant-export.command.d.ts +16 -0
  12. package/dist/src/commands/providers/grant-export.command.d.ts.map +1 -0
  13. package/dist/src/commands/providers/grant-export.command.js +78 -0
  14. package/dist/src/commands/providers/grant-export.command.js.map +1 -0
  15. package/dist/src/commands/providers/grant-import.command.d.ts +15 -0
  16. package/dist/src/commands/providers/grant-import.command.d.ts.map +1 -0
  17. package/dist/src/commands/providers/grant-import.command.js +78 -0
  18. package/dist/src/commands/providers/grant-import.command.js.map +1 -0
  19. package/dist/src/kernel/command-runner.d.ts.map +1 -1
  20. package/dist/src/kernel/command-runner.js +4 -6
  21. package/dist/src/kernel/command-runner.js.map +1 -1
  22. package/dist/src/kernel/hooks.d.ts.map +1 -1
  23. package/dist/src/kernel/hooks.js +2 -1
  24. package/dist/src/kernel/hooks.js.map +1 -1
  25. package/dist/src/kernel/json-document-output.d.ts +7 -0
  26. package/dist/src/kernel/json-document-output.d.ts.map +1 -1
  27. package/dist/src/kernel/json-document-output.js +8 -0
  28. package/dist/src/kernel/json-document-output.js.map +1 -1
  29. package/dist/src/kernel/types.d.ts +8 -0
  30. package/dist/src/kernel/types.d.ts.map +1 -1
  31. package/dist/src/kernel/types.js.map +1 -1
  32. package/dist/src/services/application/app-bootstrap.service.d.ts +24 -6
  33. package/dist/src/services/application/app-bootstrap.service.d.ts.map +1 -1
  34. package/dist/src/services/application/app-bootstrap.service.js +46 -13
  35. package/dist/src/services/application/app-bootstrap.service.js.map +1 -1
  36. package/dist/src/services/application/app-local-runtime-addresses.service.d.ts +1 -1
  37. package/dist/src/services/application/app-local-runtime-addresses.service.d.ts.map +1 -1
  38. package/dist/src/services/application/app-local-runtime-addresses.service.js.map +1 -1
  39. package/dist/src/services/application/app-runtime-targets.service.d.ts.map +1 -1
  40. package/dist/src/services/application/app-runtime-targets.service.js +7 -1
  41. package/dist/src/services/application/app-runtime-targets.service.js.map +1 -1
  42. package/dist/src/services/application/application-runtime-bootstrap.service.d.ts +13 -0
  43. package/dist/src/services/application/application-runtime-bootstrap.service.d.ts.map +1 -1
  44. package/dist/src/services/application/application-runtime-bootstrap.service.js +32 -0
  45. package/dist/src/services/application/application-runtime-bootstrap.service.js.map +1 -1
  46. package/dist/src/services/application/environment-provider-configurations.service.d.ts +7 -0
  47. package/dist/src/services/application/environment-provider-configurations.service.d.ts.map +1 -1
  48. package/dist/src/services/application/environment-provider-configurations.service.js +1 -1
  49. package/dist/src/services/application/environment-provider-configurations.service.js.map +1 -1
  50. package/dist/src/services/application/local-tunnel.service.d.ts.map +1 -1
  51. package/dist/src/services/application/local-tunnel.service.js +2 -1
  52. package/dist/src/services/application/local-tunnel.service.js.map +1 -1
  53. package/dist/src/services/companion/companion-client.service.d.ts +17 -0
  54. package/dist/src/services/companion/companion-client.service.d.ts.map +1 -1
  55. package/dist/src/services/companion/companion-client.service.js +21 -0
  56. package/dist/src/services/companion/companion-client.service.js.map +1 -1
  57. package/dist/src/services/companion/creation-drive.service.d.ts +18 -0
  58. package/dist/src/services/companion/creation-drive.service.d.ts.map +1 -1
  59. package/dist/src/services/companion/creation-drive.service.js +70 -1
  60. package/dist/src/services/companion/creation-drive.service.js.map +1 -1
  61. package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts +10 -1
  62. package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts.map +1 -1
  63. package/dist/src/services/deployment/docker/docker-compose-generator.service.js +24 -10
  64. package/dist/src/services/deployment/docker/docker-compose-generator.service.js.map +1 -1
  65. package/dist/src/services/deployment/framework-pod-network-membership.d.ts.map +1 -1
  66. package/dist/src/services/deployment/framework-pod-network-membership.js +5 -0
  67. package/dist/src/services/deployment/framework-pod-network-membership.js.map +1 -1
  68. package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts +43 -4
  69. package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts.map +1 -1
  70. package/dist/src/services/deployment/local-dev-late-workspace-members.service.js +116 -9
  71. package/dist/src/services/deployment/local-dev-late-workspace-members.service.js.map +1 -1
  72. package/dist/src/services/environment/authored-infra-config.utils.d.ts +4 -3
  73. package/dist/src/services/environment/authored-infra-config.utils.d.ts.map +1 -1
  74. package/dist/src/services/environment/authored-infra-config.utils.js +4 -3
  75. package/dist/src/services/environment/authored-infra-config.utils.js.map +1 -1
  76. package/dist/src/services/framework/package-install.service.d.ts +7 -0
  77. package/dist/src/services/framework/package-install.service.d.ts.map +1 -1
  78. package/dist/src/services/framework/package-install.service.js +8 -1
  79. package/dist/src/services/framework/package-install.service.js.map +1 -1
  80. package/dist/src/services/registry/application-provider-connection.service.d.ts +16 -1
  81. package/dist/src/services/registry/application-provider-connection.service.d.ts.map +1 -1
  82. package/dist/src/services/registry/application-provider-connection.service.js +23 -0
  83. package/dist/src/services/registry/application-provider-connection.service.js.map +1 -1
  84. package/dist/src/services/registry/provider-grant-transfer.service.d.ts +48 -0
  85. package/dist/src/services/registry/provider-grant-transfer.service.d.ts.map +1 -0
  86. package/dist/src/services/registry/provider-grant-transfer.service.js +144 -0
  87. package/dist/src/services/registry/provider-grant-transfer.service.js.map +1 -0
  88. package/dist/src/services/registry/provider-module-scaffold.service.d.ts.map +1 -1
  89. package/dist/src/services/registry/provider-module-scaffold.service.js +10 -3
  90. package/dist/src/services/registry/provider-module-scaffold.service.js.map +1 -1
  91. package/dist/tsconfig.build.tsbuildinfo +1 -1
  92. package/package.json +19 -19
  93. package/templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs +2 -0
  94. package/templates/saas/i18n/email/system/remote-agent-task-updated/labels.en.ts +11 -0
  95. package/templates/saas/i18n/email/system/remote-agent-task-updated/template.tsx +56 -0
  96. package/templates/saas/i18n/engine/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.en.ts +61 -0
  97. package/templates/saas/i18n/engine/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.fr.ts +61 -0
  98. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/docusaurus.config.ts.hbs +5 -4
  99. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/package.json.hbs +1 -1
  100. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/scripts/substitute-api-origin.mjs +97 -32
  101. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/src/plugins/api-reference-pages.ts +7 -6
  102. package/wildo-framework.info.json +1 -1
@@ -47,6 +47,6 @@ export declare function loadAppLocalRuntimeServiceAddresses(appRoot: string,
47
47
  * copies; a real CLI process already holds them, so the configuration file is all it evaluates.
48
48
  */
49
49
  evaluation?: {
50
- readonly loadOptions: Pick<LoadConfigOptions, 'moduleResolution'> | undefined;
50
+ readonly loadOptions: Pick<LoadConfigOptions, 'moduleResolution' | 'freshModuleCache'> | undefined;
51
51
  }): Promise<Record<string, LocalRuntimeServiceAddress> | undefined>;
52
52
  //# sourceMappingURL=app-local-runtime-addresses.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-local-runtime-addresses.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/app-local-runtime-addresses.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwD,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAE7H,MAAM,WAAW,0BAA0B;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAuED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,mCAAmC,CACvD,OAAO,EAAE,MAAM;AACf;;;;;;;;;;;;;GAaG;AACH,UAAU,CAAC,EAAE;IAAE,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,GAAG,SAAS,CAAA;CAAE,GAC7F,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,GAAG,SAAS,CAAC,CAiCjE"}
1
+ {"version":3,"file":"app-local-runtime-addresses.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/app-local-runtime-addresses.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwD,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAE7H,MAAM,WAAW,0BAA0B;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAuED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,mCAAmC,CACvD,OAAO,EAAE,MAAM;AACf;;;;;;;;;;;;;GAaG;AACH,UAAU,CAAC,EAAE;IAAE,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,kBAAkB,GAAG,kBAAkB,CAAC,GAAG,SAAS,CAAA;CAAE,GAClH,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,GAAG,SAAS,CAAC,CAiCjE"}
@@ -1 +1 @@
1
- {"version":3,"file":"app-local-runtime-addresses.service.js","sourceRoot":"","sources":["../../../../src/services/application/app-local-runtime-addresses.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,I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AAU,mCAAmC,CACvD,OAAe;AACf;;;;;;;;;;;;;GAaG;AACH,UAA8F;IAE9F,MAAM,oBAAoB,GAAG,UAAU,KAAK,SAAS;QACnD,CAAC,CAAC,EAAE,gBAAgB,EAAE,sBAAsB,CAAC,gBAAgB,EAAE;QAC/D,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC;IAC3B,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,mBAAmB,GAAG,IAAI,CAC9B,SAAS,CAAC,uBAAuB,EACjC,OAAO,EACP,WAAW,EACX,QAAQ,EACR,aAAa,CACd,CAAC;IACF,IAAI,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACpC,MAAM,kBAAkB,GAAG,wCAAwC,CAAC,mBAAmB,CAAC,CAAC;QACzF,IAAI,kBAAkB,EAAE,CAAC;YACvB,OAAO,kBAAkB,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,MAAM,kBAAkB,GAAG;QACzB,IAAI,CAAC,SAAS,CAAC,0BAA0B,EAAE,OAAO,EAAE,6BAA6B,CAAC;KACnF,CAAC;IACF,KAAK,MAAM,SAAS,IAAI,kBAAkB,EAAE,CAAC;QAC3C,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,SAAS;QACX,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,iCAAiC,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAC3F,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { existsSync, readFileSync } from 'fs';\nimport { join } from 'path';\nimport { ConfigModuleResolution, loadConfig, resolveAppLayout, type LoadConfigOptions } from '@wildo-ai/platform-config-lib';\n\nexport interface LocalRuntimeServiceAddress {\n host?: string;\n port?: number;\n url?: string;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction normalizeLocalRuntimeServiceAddress(raw: unknown): LocalRuntimeServiceAddress | null {\n if (!isRecord(raw)) {\n return null;\n }\n\n const host = typeof raw.host === 'string' ? raw.host : undefined;\n const port = typeof raw.port === 'number' ? raw.port : undefined;\n const url = typeof raw.url === 'string'\n ? raw.url\n : port !== undefined\n ? `http://${host && host !== '0.0.0.0' ? host : 'localhost'}:${port}`\n : undefined;\n\n if (!host && port === undefined && !url) {\n return null;\n }\n\n return { host, port, url };\n}\n\nfunction extractServiceAddresses(raw: unknown): Record<string, LocalRuntimeServiceAddress> | undefined {\n if (!isRecord(raw)) {\n return undefined;\n }\n\n const addresses: Record<string, LocalRuntimeServiceAddress> = {};\n\n if (isRecord(raw.services)) {\n for (const [serviceKey, serviceValue] of Object.entries(raw.services)) {\n const normalized = normalizeLocalRuntimeServiceAddress(serviceValue);\n if (normalized) {\n addresses[serviceKey] = normalized;\n }\n }\n }\n\n const devCompanion = normalizeLocalRuntimeServiceAddress(raw.devCompanion);\n if (devCompanion) {\n addresses.devCompanion = devCompanion;\n }\n\n return Object.keys(addresses).length > 0 ? addresses : undefined;\n}\n\nasync function tryLoadServiceAddressesFromConfig(\n configPath: string,\n loadOptions: Pick<LoadConfigOptions, 'moduleResolution'> | undefined,\n): Promise<Record<string, LocalRuntimeServiceAddress> | undefined> {\n try {\n const config = await loadConfig<unknown>(configPath, loadOptions);\n return extractServiceAddresses(config);\n } catch {\n return undefined;\n }\n}\n\nfunction tryLoadServiceAddressesFromGeneratedJson(configPath: string): Record<string, LocalRuntimeServiceAddress> | undefined {\n try {\n const raw = JSON.parse(readFileSync(configPath, 'utf8')) as unknown;\n return extractServiceAddresses(raw);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Resolve local runtime service addresses for a targeted app.\n *\n * Resolution order matters:\n * 1. generated app-owned runtime config under `.wildo-saas`\n * 2. authored flattened local infra descriptor under `infrastructure/local`\n *\n * **Slice 3 deep-review M-5 (2026-04-13) — dual-source contract.**\n *\n * `devCompanion` (along with the per-app `services.<key>` addresses) is\n * authored in `wildo.infra.<env>.config.ts` and resolved through the two\n * candidates above. It is intentionally NOT persisted into the\n * platform-level `wildo-secrets/environments/<env>/config.json` (handled\n * by `PlatformEnvConfigJson_Schema`) because dev companion topology is a\n * per-app local-execution concern that must NOT cross app boundaries.\n *\n * The two `config.json` files this CLI knows about have different owners:\n * - PLATFORM `<wildo-secrets>/environments/<env>/config.json` — shared\n * runtime posture (backing services, serviceAuth, logging, ...).\n * - APP `<appRoot>/.wildo-saas/runtime-environments/local/generated/config/config.json`\n * — per-app local service addresses (this function's first candidate).\n *\n * If a future change wants to consolidate, pin `devCompanion` to ONE\n * canonical location first (likely the app-level file, since the platform\n * file is shared) — silently writing it to both would create a\n * dual-source-of-truth that drifts over time.\n */\nexport async function loadAppLocalRuntimeServiceAddresses(\n appRoot: string,\n /**\n * How the authored infra configuration is evaluated, when it is.\n *\n * A caller that passes this object decides, and `loadOptions: undefined` keeps the loader's own inference\n * (`AppRuntimeTargetsService.resolve`, whose contract is to leave the default alone unless its caller asks, #3440).\n * A caller that passes nothing gets {@link ConfigModuleResolution.LOADER_INSTANCES}. Every such caller asks only what\n * the configuration DECLARES (a host, a port, a URL), from inside the CLI, which already runs the framework's built\n * packages: the reader that mode exists for. The inference answers `package` for an application outside the framework\n * checkout, and in a checkout where `platform-config-lib` carries its `src/` that still aliases the package to\n * `config-authoring.entry.ts`, so every cold read transpiled about 120 framework source modules to learn one port:\n * 2.3 s on a 12-core host and over 5 s on the CI runner, where `companionPost`'s test timed out (#3610). With the CLI's\n * own built modules the same read measured 1.0 s cold in a test process, which holds them only as Vite-transformed\n * copies; a real CLI process already holds them, so the configuration file is all it evaluates.\n */\n evaluation?: { readonly loadOptions: Pick<LoadConfigOptions, 'moduleResolution'> | undefined },\n): Promise<Record<string, LocalRuntimeServiceAddress> | undefined> {\n const effectiveLoadOptions = evaluation === undefined\n ? { moduleResolution: ConfigModuleResolution.LOADER_INSTANCES }\n : evaluation.loadOptions;\n const appLayout = resolveAppLayout(appRoot);\n const generatedConfigPath = join(\n appLayout.runtimeEnvironmentsHome,\n 'local',\n 'generated',\n 'config',\n 'config.json',\n );\n if (existsSync(generatedConfigPath)) {\n const generatedAddresses = tryLoadServiceAddressesFromGeneratedJson(generatedConfigPath);\n if (generatedAddresses) {\n return generatedAddresses;\n }\n }\n\n const authoredCandidates = [\n join(appLayout.authoredInfrastructureHome, 'local', 'wildo.infra.local.config.ts'),\n ];\n for (const candidate of authoredCandidates) {\n if (!existsSync(candidate)) {\n continue;\n }\n\n const addresses = await tryLoadServiceAddressesFromConfig(candidate, effectiveLoadOptions);\n if (addresses) {\n return addresses;\n }\n }\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"app-local-runtime-addresses.service.js","sourceRoot":"","sources":["../../../../src/services/application/app-local-runtime-addresses.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,gBAAgB,EAA0B,MAAM,+BAA+B,CAAC;AAQ7H,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,SAAS,mCAAmC,CAAC,GAAY;IACvD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,MAAM,IAAI,GAAG,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,C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AM,kBAAkB,GAAG;QACzB,IAAI,CAAC,SAAS,CAAC,0BAA0B,EAAE,OAAO,EAAE,6BAA6B,CAAC;KACnF,CAAC;IACF,KAAK,MAAM,SAAS,IAAI,kBAAkB,EAAE,CAAC;QAC3C,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,SAAS;QACX,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,iCAAiC,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAC3F,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { existsSync, readFileSync } from 'fs';\nimport { join } from 'path';\nimport { ConfigModuleResolution, loadConfig, resolveAppLayout, type LoadConfigOptions } from '@wildo-ai/platform-config-lib';\n\nexport interface LocalRuntimeServiceAddress {\n host?: string;\n port?: number;\n url?: string;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction normalizeLocalRuntimeServiceAddress(raw: unknown): LocalRuntimeServiceAddress | null {\n if (!isRecord(raw)) {\n return null;\n }\n\n const host = typeof raw.host === 'string' ? raw.host : undefined;\n const port = typeof raw.port === 'number' ? raw.port : undefined;\n const url = typeof raw.url === 'string'\n ? raw.url\n : port !== undefined\n ? `http://${host && host !== '0.0.0.0' ? host : 'localhost'}:${port}`\n : undefined;\n\n if (!host && port === undefined && !url) {\n return null;\n }\n\n return { host, port, url };\n}\n\nfunction extractServiceAddresses(raw: unknown): Record<string, LocalRuntimeServiceAddress> | undefined {\n if (!isRecord(raw)) {\n return undefined;\n }\n\n const addresses: Record<string, LocalRuntimeServiceAddress> = {};\n\n if (isRecord(raw.services)) {\n for (const [serviceKey, serviceValue] of Object.entries(raw.services)) {\n const normalized = normalizeLocalRuntimeServiceAddress(serviceValue);\n if (normalized) {\n addresses[serviceKey] = normalized;\n }\n }\n }\n\n const devCompanion = normalizeLocalRuntimeServiceAddress(raw.devCompanion);\n if (devCompanion) {\n addresses.devCompanion = devCompanion;\n }\n\n return Object.keys(addresses).length > 0 ? addresses : undefined;\n}\n\nasync function tryLoadServiceAddressesFromConfig(\n configPath: string,\n loadOptions: Pick<LoadConfigOptions, 'moduleResolution' | 'freshModuleCache'> | undefined,\n): Promise<Record<string, LocalRuntimeServiceAddress> | undefined> {\n try {\n const config = await loadConfig<unknown>(configPath, loadOptions);\n return extractServiceAddresses(config);\n } catch {\n return undefined;\n }\n}\n\nfunction tryLoadServiceAddressesFromGeneratedJson(configPath: string): Record<string, LocalRuntimeServiceAddress> | undefined {\n try {\n const raw = JSON.parse(readFileSync(configPath, 'utf8')) as unknown;\n return extractServiceAddresses(raw);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Resolve local runtime service addresses for a targeted app.\n *\n * Resolution order matters:\n * 1. generated app-owned runtime config under `.wildo-saas`\n * 2. authored flattened local infra descriptor under `infrastructure/local`\n *\n * **Slice 3 deep-review M-5 (2026-04-13) — dual-source contract.**\n *\n * `devCompanion` (along with the per-app `services.<key>` addresses) is\n * authored in `wildo.infra.<env>.config.ts` and resolved through the two\n * candidates above. It is intentionally NOT persisted into the\n * platform-level `wildo-secrets/environments/<env>/config.json` (handled\n * by `PlatformEnvConfigJson_Schema`) because dev companion topology is a\n * per-app local-execution concern that must NOT cross app boundaries.\n *\n * The two `config.json` files this CLI knows about have different owners:\n * - PLATFORM `<wildo-secrets>/environments/<env>/config.json` — shared\n * runtime posture (backing services, serviceAuth, logging, ...).\n * - APP `<appRoot>/.wildo-saas/runtime-environments/local/generated/config/config.json`\n * — per-app local service addresses (this function's first candidate).\n *\n * If a future change wants to consolidate, pin `devCompanion` to ONE\n * canonical location first (likely the app-level file, since the platform\n * file is shared) — silently writing it to both would create a\n * dual-source-of-truth that drifts over time.\n */\nexport async function loadAppLocalRuntimeServiceAddresses(\n appRoot: string,\n /**\n * How the authored infra configuration is evaluated, when it is.\n *\n * A caller that passes this object decides, and `loadOptions: undefined` keeps the loader's own inference\n * (`AppRuntimeTargetsService.resolve`, whose contract is to leave the default alone unless its caller asks, #3440).\n * A caller that passes nothing gets {@link ConfigModuleResolution.LOADER_INSTANCES}. Every such caller asks only what\n * the configuration DECLARES (a host, a port, a URL), from inside the CLI, which already runs the framework's built\n * packages: the reader that mode exists for. The inference answers `package` for an application outside the framework\n * checkout, and in a checkout where `platform-config-lib` carries its `src/` that still aliases the package to\n * `config-authoring.entry.ts`, so every cold read transpiled about 120 framework source modules to learn one port:\n * 2.3 s on a 12-core host and over 5 s on the CI runner, where `companionPost`'s test timed out (#3610). With the CLI's\n * own built modules the same read measured 1.0 s cold in a test process, which holds them only as Vite-transformed\n * copies; a real CLI process already holds them, so the configuration file is all it evaluates.\n */\n evaluation?: { readonly loadOptions: Pick<LoadConfigOptions, 'moduleResolution' | 'freshModuleCache'> | undefined },\n): Promise<Record<string, LocalRuntimeServiceAddress> | undefined> {\n const effectiveLoadOptions = evaluation === undefined\n ? { moduleResolution: ConfigModuleResolution.LOADER_INSTANCES }\n : evaluation.loadOptions;\n const appLayout = resolveAppLayout(appRoot);\n const generatedConfigPath = join(\n appLayout.runtimeEnvironmentsHome,\n 'local',\n 'generated',\n 'config',\n 'config.json',\n );\n if (existsSync(generatedConfigPath)) {\n const generatedAddresses = tryLoadServiceAddressesFromGeneratedJson(generatedConfigPath);\n if (generatedAddresses) {\n return generatedAddresses;\n }\n }\n\n const authoredCandidates = [\n join(appLayout.authoredInfrastructureHome, 'local', 'wildo.infra.local.config.ts'),\n ];\n for (const candidate of authoredCandidates) {\n if (!existsSync(candidate)) {\n continue;\n }\n\n const addresses = await tryLoadServiceAddressesFromConfig(candidate, effectiveLoadOptions);\n if (addresses) {\n return addresses;\n }\n }\n return undefined;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"app-runtime-targets.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/app-runtime-targets.service.ts"],"names":[],"mappings":"AAE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/F;;;;;;OAMG;IACH,yBAAyB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,4DAA4D;IAC5D,SAAS,EAAE,WAAW,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;IACrD,uEAAuE;IACvE,cAAc,CAAC,EAAE,eAAe,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC;IAC/D,2DAA2D;IAC3D,eAAe,EAAE,WAAW,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;IACzD,4DAA4D;IAC5D,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,wDAAwD;IACxD,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,qBAAa,wBAAwB;mBACd,mBAAmB;mBAiHnB,4BAA4B;IAiCjD;;;;;;;;;;;;;;OAcG;WACU,OAAO,CAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;QACP,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACtC,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;KACjD,GACA,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC;WAwC9B,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAQ1F"}
1
+ {"version":3,"file":"app-runtime-targets.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/app-runtime-targets.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAE3B,KAAK,0BAA0B,EAE/B,KAAK,0CAA0C,EAC/C,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAErB,MAAM,+BAA+B,CAAC;AAIvC,MAAM,WAAW,4BAA4B;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;I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Ae,EAAE,WAAW,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;IACzD,4DAA4D;IAC5D,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,wDAAwD;IACxD,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,qBAAa,wBAAwB;mBACd,mBAAmB;mBAqHnB,4BAA4B;IAiCjD;;;;;;;;;;;;;;OAcG;WACU,OAAO,CAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;QACP,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACtC,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;KACjD,GACA,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC;WA0C9B,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAQ1F"}
@@ -7,7 +7,11 @@ export class AppRuntimeTargetsService {
7
7
  static async buildResolvedTarget(appRoot, saasConfig, declaredServiceKeys,
8
8
  /** The application's provider configuration with the target environment's values laid over it. */
9
9
  providerConfigurations,
10
- /** How every per-folder and infra configuration read here is evaluated: the one `resolve` was asked for. */
10
+ /**
11
+ * How every per-folder and infra configuration read here is evaluated: the one `resolve` was asked for, FRESH
12
+ * included, so a minion's or worker's own configuration is read as it is now in a long-lived `wildo local dev`
13
+ * exactly as the declaration naming it is (#3985).
14
+ */
11
15
  loadOptions) {
12
16
  const workerConfigs = await loadWorkerConfigs(appRoot, saasConfig, loadOptions);
13
17
  const minionConfigs = await loadMinionConfigs(appRoot, saasConfig, loadOptions);
@@ -166,6 +170,8 @@ export class AppRuntimeTargetsService {
166
170
  saasRoot,
167
171
  applicationProviderConfigurations: saasConfig.providerConfigurations,
168
172
  environmentName: options.environmentName,
173
+ // The environment's overlay is part of the same declaration, so it is read the same way (fresh).
174
+ infraConfigLoadOptions: loadOptions,
169
175
  });
170
176
  return AppRuntimeTargetsService.buildResolvedTarget(saasRoot, saasConfig, new Set(Object.keys(saasConfig.services)), providerConfigurations, loadOptions);
171
177
  }
@@ -1 +1 @@
1
- {"version":3,"file":"app-runtime-targets.service.js","sourceRoot":"","sources":["../../../../src/services/application/app-runtime-targets.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EAKd,8BAA8B,EAI9B,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,wCAAwC,EAAE,MAAM,+CAA+C,CAAC;AAuEzG,MAAM,OAAO,wBAAwB;IAC3B,MAAM,CAAC,KAAK,CAAC,mBAAmB,CACtC,OAAe,EACf,UAA2B,EAC3B,mBAAgC;IAChC,kGAAkG;IAClG,sBAAiE;IACjE,4GAA4G;IAC5G,WAAoE;QAEpE,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAChF,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAChF,uEAAuE;QACvE,0DAA0D;QAC1D,iEAAiE;QACjE,kEAAkE;QAClE,wDAAwD;QACxD,qCAAqC;QACrC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAC/B,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAU,CAAC,CACjE,CAAC;QACF,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO;YAC3C,CAAC,CAAC,MAAM,CAAC,WAAW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AAC,CAAC,EACzC,sBAAsB,EACtB,WAAW,CACZ,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,QAAgB,EAAE,gBAAyB;QACrE,uDAAuD;QACvD,MAAM,MAAM,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC;QAC7G,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;QACnG,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;CACF","sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'path';\nimport {\n loadWorkerConfigs,\n loadMinionConfigs,\n loadSaasConfig,\n type AppBootstrapFirstAdminSeed,\n type ConfigModuleResolution,\n type LoadConfigOptions,\n type AdminAppManagedDeclaration,\n normalizeSaasRuntimeDescriptor,\n type NormalizedLocalServiceAddressingDescriptor,\n type RuntimeIsolation,\n type WildoSaasConfig,\n WORKSPACE_CONFIG_NAMES,\n} from '@wildo-ai/platform-config-lib';\nimport { loadAppLocalRuntimeServiceAddresses } from './app-local-runtime-addresses.service';\nimport { resolveEnvironmentProviderConfigurations } from './environment-provider-configurations.service';\n\nexport interface ResolvedBackendServiceTarget {\n key: string;\n path: string;\n serviceName: string;\n defaultPort?: number | undefined;\n /**\n * Effective container isolation, resolved at the config boundary by\n * `resolveAppServiceIsolation` (see the normalized descriptor). Passed through\n * unchanged to both deploy renderers.\n */\n isolation: RuntimeIsolation;\n}\n\nexport interface ResolvedFrontendServiceTarget {\n key: string;\n path: string;\n serviceName: string;\n defaultPort?: number | undefined;\n frontendType: string;\n /**\n * Effective container isolation, resolved at the config boundary by\n * `resolveAppServiceIsolation` (see the normalized descriptor). Passed through\n * unchanged to both deploy renderers.\n */\n isolation: RuntimeIsolation;\n}\n\nexport interface ResolvedAppRuntimeTarget {\n appSlug: string;\n appDisplayName: string;\n appRoot: string;\n saasConfigPath: string;\n appDatabaseName?: string | undefined;\n /**\n * Authored `wildo.saas.config.dataServices.redis.keyPrefix` (Slice 3.6).\n * Threaded through to per-app `.env` as `REDIS_KEY_PREFIX`.\n */\n redisKeyPrefix?: string | undefined;\n /**\n * Authored `wildo.saas.config.dataServices.s3.bucketPrefix` (Slice 3.6).\n * Threaded through to per-app `.env` as `STORAGE_BUCKET_PREFIX`.\n */\n storageBucketPrefix?: string | undefined;\n requiresJavaBackendBase: boolean;\n backendServices: ResolvedBackendServiceTarget[];\n frontendServices: ResolvedFrontendServiceTarget[];\n managedDeclaration: AdminAppManagedDeclaration;\n firstAdminSeed?: AppBootstrapFirstAdminSeed | undefined;\n localServiceAddresses?: Record<string, NormalizedLocalServiceAddressingDescriptor> | undefined;\n /**\n * Provider refs the BACKEND declares (`providers.scopes.backend.providers`).\n *\n * Resolved here, where the saas config is already parsed, rather than by a\n * second `loadConfig` in the env-target builder — one read, one source, and no\n * new filesystem requirement on callers that construct this target in tests.\n */\n backendScopedProviderRefs: readonly string[];\n /** Global library declarations from wildo.saas.config.ts */\n libraries: NonNullable<WildoSaasConfig['libraries']>;\n /** App specifications package declaration from wildo.saas.config.ts */\n specifications?: WildoSaasConfig['specifications'] | undefined;\n /** Declarative domain modules from wildo.saas.config.ts */\n declaredModules: NonNullable<WildoSaasConfig['modules']>;\n /** Derived module ids keyed by declared SaaS service key */\n moduleIdsByService: Record<string, string[]>;\n /** All declared module ids from wildo.saas.config.ts */\n moduleIds: string[];\n}\n\nexport class AppRuntimeTargetsService {\n private static async buildResolvedTarget(\n appRoot: string,\n saasConfig: WildoSaasConfig,\n declaredServiceKeys: Set<string>,\n /** The application's provider configuration with the target environment's values laid over it. */\n providerConfigurations: WildoSaasConfig['providerConfigurations'],\n /** How every per-folder and infra configuration read here is evaluated: the one `resolve` was asked for. */\n loadOptions: Pick<LoadConfigOptions, 'moduleResolution'> | undefined,\n ): Promise<ResolvedAppRuntimeTarget> {\n const workerConfigs = await loadWorkerConfigs(appRoot, saasConfig, loadOptions);\n const minionConfigs = await loadMinionConfigs(appRoot, saasConfig, loadOptions);\n // Merge per-folder `wildo.minion.config.ts` (`mode` + `schedule`) into\n // the runtime declaration alongside the saas-config-level\n // `resourceAccess`. KD-12 cron-tick path (Phase 3 closeout): the\n // backend-api's `cron-job-sync.backend.service.ts` reads these to\n // register `mode: 'cron'` minions as CronJob records on\n // platform-crontabs-batches-manager.\n const minionConfigByKey = new Map(\n minionConfigs.map((entry) => [entry.key, entry.config] as const),\n );\n const minionsWithRuntime = saasConfig.minions\n ? Object.fromEntries(\n Object.entries(saasConfig.minions).map(([key, saasEntry]) => {\n const folderConfig = minionConfigByKey.get(key);\n return [\n key,\n {\n ...saasEntry,\n ...(folderConfig\n ? {\n mode: folderConfig.mode,\n schedule: folderConfig.schedule,\n }\n : {}),\n },\n ];\n }),\n )\n : undefined;\n const normalized = normalizeSaasRuntimeDescriptor({\n name: saasConfig.name,\n slug: saasConfig.slug,\n displayName: saasConfig.displayName,\n description: saasConfig.description,\n type: saasConfig.type,\n services: saasConfig.services,\n minions: minionsWithRuntime,\n workers: Object.fromEntries(\n workerConfigs.map((entry) => [\n entry.key,\n {\n name: entry.config.name,\n displayName: entry.config.displayName,\n description: entry.config.description,\n runtime: entry.config.runtime,\n http: entry.config.http,\n auth: entry.config.auth,\n replicas: entry.config.replicas,\n resources: entry.config.resources,\n dataAccess: entry.config.dataAccess,\n },\n ]),\n ),\n engineCapabilities: saasConfig.engineCapabilities,\n providers: saasConfig.providers,\n providerConfigurations,\n // Carried to apps-manager so it can derive the type of the organization it seeds for the first\n // administrator (#1032).\n organizationTypes: saasConfig.organizationTypes,\n // Carried for the same reason one line up: apps-manager stores the declaration, and the CLI and\n // the backend both derive each instance's environment-variable names from it (#1055).\n systemsOfRecord: saasConfig.systemsOfRecord,\n // Carried with the types it is a statement about (#2722).\n organizationRelationships: saasConfig.organizationRelationships,\n // Carried with the people it is a statement about (#2967): a decision may require one of these kinds.\n professionalQualificationKinds: saasConfig.professionalQualificationKinds,\n // Carried to apps-manager, which signs with the keys these bindings name (#2891).\n keyManagement: saasConfig.keyManagement,\n dataServices: saasConfig.dataServices,\n modules: saasConfig.modules,\n libraries: saasConfig.libraries,\n specifications: saasConfig.specifications,\n bootstrap: saasConfig.bootstrap,\n });\n const localServiceAddresses = await AppRuntimeTargetsService.resolveLocalServiceAddresses(\n appRoot,\n declaredServiceKeys,\n loadOptions,\n );\n\n return {\n appSlug: normalized.appSlug,\n appDisplayName: normalized.appDisplayName,\n appRoot,\n saasConfigPath: join(appRoot, WORKSPACE_CONFIG_NAMES.SAAS),\n appDatabaseName: normalized.appDatabaseName,\n redisKeyPrefix: normalized.redisKeyPrefix,\n storageBucketPrefix: normalized.storageBucketPrefix,\n requiresJavaBackendBase: normalized.requiresJavaBackendBase,\n backendServices: normalized.backendServices,\n frontendServices: normalized.frontendServices,\n managedDeclaration: normalized.managedDeclaration,\n firstAdminSeed: normalized.firstAdminSeed,\n localServiceAddresses,\n backendScopedProviderRefs: Object.keys(saasConfig.providers?.scopes?.backend?.providers ?? {}),\n libraries: normalized.libraries,\n specifications: normalized.specifications,\n declaredModules: normalized.declaredModules,\n moduleIdsByService: normalized.moduleIdsByService,\n moduleIds: normalized.moduleIds,\n };\n }\n\n private static async resolveLocalServiceAddresses(\n appRoot: string,\n declaredServiceKeys: Set<string>,\n loadOptions: Pick<LoadConfigOptions, 'moduleResolution'> | undefined,\n ): Promise<Record<string, NormalizedLocalServiceAddressingDescriptor> | undefined> {\n const serviceAddresses = await loadAppLocalRuntimeServiceAddresses(appRoot, { loadOptions });\n if (!serviceAddresses) {\n return undefined;\n }\n\n // Local infra descriptors may contain executor-only services that are not\n // part of the SaaS runtime descriptor (for example the nested dev companion).\n // When a service key is already declared in `wildo.saas.config.ts`, the SaaS\n // descriptor remains the single source of truth for local backend/frontend\n // topology and we ignore the duplicate infra entry here.\n const localServiceAddresses = Object.fromEntries(\n Object.entries(serviceAddresses)\n .filter(([serviceKey]) => !declaredServiceKeys.has(serviceKey))\n .map(([serviceKey, service]) => [\n serviceKey,\n {\n host: service.host,\n port: service.port,\n url: service.url,\n } satisfies NormalizedLocalServiceAddressingDescriptor,\n ]),\n );\n\n return Object.keys(localServiceAddresses).length > 0\n ? localServiceAddresses\n : undefined;\n }\n\n /**\n * Resolve the application target, with its managed declaration bound to ONE environment.\n *\n * `environmentName` is required, and `null` is an answer rather than a default: the declaration carries the\n * application's provider configuration, and an environment's `wildo.infra.<env>.config.ts` lays its own values over\n * it (an OAuth client ID registered for that deployment). A caller that SENDS the declaration to an environment's\n * apps-manager — registration, reapply, the doctor's dry-run comparison — must name that environment, or it would\n * store (or compare against) another environment's values. A caller that only reads the services list passes `null`.\n *\n * `configModuleResolution` is how the framework packages are resolved while `wildo.saas.config.ts`, the per-folder\n * worker and minion configurations and the local infra configuration are evaluated ({@link ConfigModuleResolution});\n * omitted, the loader infers it. A caller that reads only what the\n * declaration states, inside a process that already runs the framework, passes `LOADER_INSTANCES`, so the evaluation\n * reuses this CLI's own framework modules instead of loading a second copy from source (#3440).\n */\n static async resolve(\n saasRoot: string,\n options: {\n environmentName: string | null;\n requestedAppSlug?: string | undefined;\n configModuleResolution?: ConfigModuleResolution;\n },\n ): Promise<ResolvedAppRuntimeTarget | null> {\n const saasConfigPath = join(saasRoot, WORKSPACE_CONFIG_NAMES.SAAS);\n if (!existsSync(saasConfigPath)) {\n return null;\n }\n\n /*\n * A FRESH read (#3985): `wildo local dev` resolves the targets again while it runs, when the declared topology changes,\n * and jiti's module cache is process-wide, so a cached read would project the topology the stack STARTED with and\n * regenerate the very env files that are missing the new service.\n */\n const loadOptions = {\n freshModuleCache: true,\n ...(options.configModuleResolution === undefined ? {} : { moduleResolution: options.configModuleResolution }),\n };\n const saasConfig = await loadSaasConfig(saasConfigPath, loadOptions);\n if (!saasConfig) {\n return null;\n }\n\n const authoredSlug = saasConfig.slug ?? saasConfig.name;\n if (options.requestedAppSlug && authoredSlug !== options.requestedAppSlug) {\n throw new Error(`App '${options.requestedAppSlug}' does not match the targeted app at ${saasRoot}`);\n }\n\n const providerConfigurations = await resolveEnvironmentProviderConfigurations({\n saasRoot,\n applicationProviderConfigurations: saasConfig.providerConfigurations,\n environmentName: options.environmentName,\n });\n\n return AppRuntimeTargetsService.buildResolvedTarget(\n saasRoot,\n saasConfig,\n new Set(Object.keys(saasConfig.services)),\n providerConfigurations,\n loadOptions,\n );\n }\n\n static async resolveRunRoot(saasRoot: string, requestedAppSlug?: string): Promise<string> {\n // Only the root is read, which no environment changes.\n const target = await AppRuntimeTargetsService.resolve(saasRoot, { environmentName: null, requestedAppSlug });\n if (!target) {\n throw new Error('No runnable SaaS application target found from the current targeted-app root.');\n }\n return target.appRoot;\n }\n}\n"]}
1
+ {"version":3,"file":"app-runtime-targets.service.js","sourceRoot":"","sources":["../../../../src/services/application/app-runtime-targets.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EAKd,8BAA8B,EAI9B,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,wCAAwC,EAAE,MAAM,+CAA+C,CAAC;AAuEzG,MAAM,OAAO,wBAAwB;IAC3B,MAAM,CAAC,KAAK,CAAC,mBAAmB,CACtC,OAAe,EACf,UAA2B,EAC3B,mBAAgC;IAChC,kGAAkG;IAClG,sBAAiE;IACjE;;;;OAIG;IACH,WAAyF;QAEzF,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAChF,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,C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AO,CAAC,gBAAgB,wCAAwC,QAAQ,EAAE,CAAC,CAAC;QACtG,CAAC;QAED,MAAM,sBAAsB,GAAG,MAAM,wCAAwC,CAAC;YAC5E,QAAQ;YACR,iCAAiC,EAAE,UAAU,CAAC,sBAAsB;YACpE,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,iGAAiG;YACjG,sBAAsB,EAAE,WAAW;SACpC,CAAC,CAAC;QAEH,OAAO,wBAAwB,CAAC,mBAAmB,CACjD,QAAQ,EACR,UAAU,EACV,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,EACzC,sBAAsB,EACtB,WAAW,CACZ,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,QAAgB,EAAE,gBAAyB;QACrE,uDAAuD;QACvD,MAAM,MAAM,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC;QAC7G,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;QACnG,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;CACF","sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'path';\nimport {\n loadWorkerConfigs,\n loadMinionConfigs,\n loadSaasConfig,\n type AppBootstrapFirstAdminSeed,\n type ConfigModuleResolution,\n type LoadConfigOptions,\n type AdminAppManagedDeclaration,\n normalizeSaasRuntimeDescriptor,\n type NormalizedLocalServiceAddressingDescriptor,\n type RuntimeIsolation,\n type WildoSaasConfig,\n WORKSPACE_CONFIG_NAMES,\n} from '@wildo-ai/platform-config-lib';\nimport { loadAppLocalRuntimeServiceAddresses } from './app-local-runtime-addresses.service';\nimport { resolveEnvironmentProviderConfigurations } from './environment-provider-configurations.service';\n\nexport interface ResolvedBackendServiceTarget {\n key: string;\n path: string;\n serviceName: string;\n defaultPort?: number | undefined;\n /**\n * Effective container isolation, resolved at the config boundary by\n * `resolveAppServiceIsolation` (see the normalized descriptor). Passed through\n * unchanged to both deploy renderers.\n */\n isolation: RuntimeIsolation;\n}\n\nexport interface ResolvedFrontendServiceTarget {\n key: string;\n path: string;\n serviceName: string;\n defaultPort?: number | undefined;\n frontendType: string;\n /**\n * Effective container isolation, resolved at the config boundary by\n * `resolveAppServiceIsolation` (see the normalized descriptor). Passed through\n * unchanged to both deploy renderers.\n */\n isolation: RuntimeIsolation;\n}\n\nexport interface ResolvedAppRuntimeTarget {\n appSlug: string;\n appDisplayName: string;\n appRoot: string;\n saasConfigPath: string;\n appDatabaseName?: string | undefined;\n /**\n * Authored `wildo.saas.config.dataServices.redis.keyPrefix` (Slice 3.6).\n * Threaded through to per-app `.env` as `REDIS_KEY_PREFIX`.\n */\n redisKeyPrefix?: string | undefined;\n /**\n * Authored `wildo.saas.config.dataServices.s3.bucketPrefix` (Slice 3.6).\n * Threaded through to per-app `.env` as `STORAGE_BUCKET_PREFIX`.\n */\n storageBucketPrefix?: string | undefined;\n requiresJavaBackendBase: boolean;\n backendServices: ResolvedBackendServiceTarget[];\n frontendServices: ResolvedFrontendServiceTarget[];\n managedDeclaration: AdminAppManagedDeclaration;\n firstAdminSeed?: AppBootstrapFirstAdminSeed | undefined;\n localServiceAddresses?: Record<string, NormalizedLocalServiceAddressingDescriptor> | undefined;\n /**\n * Provider refs the BACKEND declares (`providers.scopes.backend.providers`).\n *\n * Resolved here, where the saas config is already parsed, rather than by a\n * second `loadConfig` in the env-target builder — one read, one source, and no\n * new filesystem requirement on callers that construct this target in tests.\n */\n backendScopedProviderRefs: readonly string[];\n /** Global library declarations from wildo.saas.config.ts */\n libraries: NonNullable<WildoSaasConfig['libraries']>;\n /** App specifications package declaration from wildo.saas.config.ts */\n specifications?: WildoSaasConfig['specifications'] | undefined;\n /** Declarative domain modules from wildo.saas.config.ts */\n declaredModules: NonNullable<WildoSaasConfig['modules']>;\n /** Derived module ids keyed by declared SaaS service key */\n moduleIdsByService: Record<string, string[]>;\n /** All declared module ids from wildo.saas.config.ts */\n moduleIds: string[];\n}\n\nexport class AppRuntimeTargetsService {\n private static async buildResolvedTarget(\n appRoot: string,\n saasConfig: WildoSaasConfig,\n declaredServiceKeys: Set<string>,\n /** The application's provider configuration with the target environment's values laid over it. */\n providerConfigurations: WildoSaasConfig['providerConfigurations'],\n /**\n * How every per-folder and infra configuration read here is evaluated: the one `resolve` was asked for, FRESH\n * included, so a minion's or worker's own configuration is read as it is now in a long-lived `wildo local dev`\n * exactly as the declaration naming it is (#3985).\n */\n loadOptions: Pick<LoadConfigOptions, 'moduleResolution' | 'freshModuleCache'> | undefined,\n ): Promise<ResolvedAppRuntimeTarget> {\n const workerConfigs = await loadWorkerConfigs(appRoot, saasConfig, loadOptions);\n const minionConfigs = await loadMinionConfigs(appRoot, saasConfig, loadOptions);\n // Merge per-folder `wildo.minion.config.ts` (`mode` + `schedule`) into\n // the runtime declaration alongside the saas-config-level\n // `resourceAccess`. KD-12 cron-tick path (Phase 3 closeout): the\n // backend-api's `cron-job-sync.backend.service.ts` reads these to\n // register `mode: 'cron'` minions as CronJob records on\n // platform-crontabs-batches-manager.\n const minionConfigByKey = new Map(\n minionConfigs.map((entry) => [entry.key, entry.config] as const),\n );\n const minionsWithRuntime = saasConfig.minions\n ? Object.fromEntries(\n Object.entries(saasConfig.minions).map(([key, saasEntry]) => {\n const folderConfig = minionConfigByKey.get(key);\n return [\n key,\n {\n ...saasEntry,\n ...(folderConfig\n ? {\n mode: folderConfig.mode,\n schedule: folderConfig.schedule,\n }\n : {}),\n },\n ];\n }),\n )\n : undefined;\n const normalized = normalizeSaasRuntimeDescriptor({\n name: saasConfig.name,\n slug: saasConfig.slug,\n displayName: saasConfig.displayName,\n description: saasConfig.description,\n type: saasConfig.type,\n services: saasConfig.services,\n minions: minionsWithRuntime,\n workers: Object.fromEntries(\n workerConfigs.map((entry) => [\n entry.key,\n {\n name: entry.config.name,\n displayName: entry.config.displayName,\n description: entry.config.description,\n runtime: entry.config.runtime,\n http: entry.config.http,\n auth: entry.config.auth,\n replicas: entry.config.replicas,\n resources: entry.config.resources,\n dataAccess: entry.config.dataAccess,\n },\n ]),\n ),\n engineCapabilities: saasConfig.engineCapabilities,\n providers: saasConfig.providers,\n providerConfigurations,\n // Carried to apps-manager so it can derive the type of the organization it seeds for the first\n // administrator (#1032).\n organizationTypes: saasConfig.organizationTypes,\n // Carried for the same reason one line up: apps-manager stores the declaration, and the CLI and\n // the backend both derive each instance's environment-variable names from it (#1055).\n systemsOfRecord: saasConfig.systemsOfRecord,\n // Carried with the types it is a statement about (#2722).\n organizationRelationships: saasConfig.organizationRelationships,\n // Carried with the people it is a statement about (#2967): a decision may require one of these kinds.\n professionalQualificationKinds: saasConfig.professionalQualificationKinds,\n // Carried to apps-manager, which signs with the keys these bindings name (#2891).\n keyManagement: saasConfig.keyManagement,\n dataServices: saasConfig.dataServices,\n modules: saasConfig.modules,\n libraries: saasConfig.libraries,\n specifications: saasConfig.specifications,\n bootstrap: saasConfig.bootstrap,\n });\n const localServiceAddresses = await AppRuntimeTargetsService.resolveLocalServiceAddresses(\n appRoot,\n declaredServiceKeys,\n loadOptions,\n );\n\n return {\n appSlug: normalized.appSlug,\n appDisplayName: normalized.appDisplayName,\n appRoot,\n saasConfigPath: join(appRoot, WORKSPACE_CONFIG_NAMES.SAAS),\n appDatabaseName: normalized.appDatabaseName,\n redisKeyPrefix: normalized.redisKeyPrefix,\n storageBucketPrefix: normalized.storageBucketPrefix,\n requiresJavaBackendBase: normalized.requiresJavaBackendBase,\n backendServices: normalized.backendServices,\n frontendServices: normalized.frontendServices,\n managedDeclaration: normalized.managedDeclaration,\n firstAdminSeed: normalized.firstAdminSeed,\n localServiceAddresses,\n backendScopedProviderRefs: Object.keys(saasConfig.providers?.scopes?.backend?.providers ?? {}),\n libraries: normalized.libraries,\n specifications: normalized.specifications,\n declaredModules: normalized.declaredModules,\n moduleIdsByService: normalized.moduleIdsByService,\n moduleIds: normalized.moduleIds,\n };\n }\n\n private static async resolveLocalServiceAddresses(\n appRoot: string,\n declaredServiceKeys: Set<string>,\n loadOptions: Pick<LoadConfigOptions, 'moduleResolution' | 'freshModuleCache'> | undefined,\n ): Promise<Record<string, NormalizedLocalServiceAddressingDescriptor> | undefined> {\n const serviceAddresses = await loadAppLocalRuntimeServiceAddresses(appRoot, { loadOptions });\n if (!serviceAddresses) {\n return undefined;\n }\n\n // Local infra descriptors may contain executor-only services that are not\n // part of the SaaS runtime descriptor (for example the nested dev companion).\n // When a service key is already declared in `wildo.saas.config.ts`, the SaaS\n // descriptor remains the single source of truth for local backend/frontend\n // topology and we ignore the duplicate infra entry here.\n const localServiceAddresses = Object.fromEntries(\n Object.entries(serviceAddresses)\n .filter(([serviceKey]) => !declaredServiceKeys.has(serviceKey))\n .map(([serviceKey, service]) => [\n serviceKey,\n {\n host: service.host,\n port: service.port,\n url: service.url,\n } satisfies NormalizedLocalServiceAddressingDescriptor,\n ]),\n );\n\n return Object.keys(localServiceAddresses).length > 0\n ? localServiceAddresses\n : undefined;\n }\n\n /**\n * Resolve the application target, with its managed declaration bound to ONE environment.\n *\n * `environmentName` is required, and `null` is an answer rather than a default: the declaration carries the\n * application's provider configuration, and an environment's `wildo.infra.<env>.config.ts` lays its own values over\n * it (an OAuth client ID registered for that deployment). A caller that SENDS the declaration to an environment's\n * apps-manager — registration, reapply, the doctor's dry-run comparison — must name that environment, or it would\n * store (or compare against) another environment's values. A caller that only reads the services list passes `null`.\n *\n * `configModuleResolution` is how the framework packages are resolved while `wildo.saas.config.ts`, the per-folder\n * worker and minion configurations and the local infra configuration are evaluated ({@link ConfigModuleResolution});\n * omitted, the loader infers it. A caller that reads only what the\n * declaration states, inside a process that already runs the framework, passes `LOADER_INSTANCES`, so the evaluation\n * reuses this CLI's own framework modules instead of loading a second copy from source (#3440).\n */\n static async resolve(\n saasRoot: string,\n options: {\n environmentName: string | null;\n requestedAppSlug?: string | undefined;\n configModuleResolution?: ConfigModuleResolution;\n },\n ): Promise<ResolvedAppRuntimeTarget | null> {\n const saasConfigPath = join(saasRoot, WORKSPACE_CONFIG_NAMES.SAAS);\n if (!existsSync(saasConfigPath)) {\n return null;\n }\n\n /*\n * A FRESH read (#3985): `wildo local dev` resolves the targets again while it runs, when the declared topology changes,\n * and jiti's module cache is process-wide, so a cached read would project the topology the stack STARTED with and\n * regenerate the very env files that are missing the new service.\n */\n const loadOptions = {\n freshModuleCache: true,\n ...(options.configModuleResolution === undefined ? {} : { moduleResolution: options.configModuleResolution }),\n };\n const saasConfig = await loadSaasConfig(saasConfigPath, loadOptions);\n if (!saasConfig) {\n return null;\n }\n\n const authoredSlug = saasConfig.slug ?? saasConfig.name;\n if (options.requestedAppSlug && authoredSlug !== options.requestedAppSlug) {\n throw new Error(`App '${options.requestedAppSlug}' does not match the targeted app at ${saasRoot}`);\n }\n\n const providerConfigurations = await resolveEnvironmentProviderConfigurations({\n saasRoot,\n applicationProviderConfigurations: saasConfig.providerConfigurations,\n environmentName: options.environmentName,\n // The environment's overlay is part of the same declaration, so it is read the same way (fresh).\n infraConfigLoadOptions: loadOptions,\n });\n\n return AppRuntimeTargetsService.buildResolvedTarget(\n saasRoot,\n saasConfig,\n new Set(Object.keys(saasConfig.services)),\n providerConfigurations,\n loadOptions,\n );\n }\n\n static async resolveRunRoot(saasRoot: string, requestedAppSlug?: string): Promise<string> {\n // Only the root is read, which no environment changes.\n const target = await AppRuntimeTargetsService.resolve(saasRoot, { environmentName: null, requestedAppSlug });\n if (!target) {\n throw new Error('No runnable SaaS application target found from the current targeted-app root.');\n }\n return target.appRoot;\n }\n}\n"]}
@@ -37,6 +37,19 @@ export interface ApplicationRuntimeBootstrapResult {
37
37
  }
38
38
  export declare class ApplicationRuntimeBootstrapService {
39
39
  static initialize(input: ApplicationRuntimeBootstrapInput): Promise<ApplicationRuntimeBootstrapResult>;
40
+ /**
41
+ * Refuse to report materialization when a minion or worker the declaration names got no target.
42
+ *
43
+ * {@link assertRuntimeEnvOnDisk} checks the targets that were BUILT, so it cannot see one that never was: on reference
44
+ * run 44255624884 the target builders read a cached declaration with no minions, the check verified the five targets
45
+ * it was given, and the run reported "0 worker, 0 minion target(s)" as a success while apps-manager had just minted
46
+ * five minions and a worker from the declaration this run resolved. This compares against THAT declaration
47
+ * (`prepared.runtimeTarget.managedDeclaration`, the one registration sent), so the two cannot disagree in silence again.
48
+ *
49
+ * A degraded registration may skip a runtime whose own secret could not be reconstructed offline: that skip is the
50
+ * documented degraded behaviour (its runtime keeps its existing `.env`), so it is not counted as missing here.
51
+ */
52
+ private static assertEveryDeclaredRuntimeProjected;
40
53
  /**
41
54
  * Refuse to report materialization for a target whose `.env` is not on disk.
42
55
  *
@@ -1 +1 @@
1
- {"version":3,"file":"application-runtime-bootstrap.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/application-runtime-bootstrap.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAElG,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAM5G,MAAM,WAAW,gCAAgC;IAC/C,GAAG,EAAE,gCAAgC,CAAC;IACtC,WAAW,EAAE,sBAAsB,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iCAAiC;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,kCAAkC;WAChC,UAAU,CACrB,KAAK,EAAE,gCAAgC,GACtC,OAAO,CAAC,iCAAiC,CAAC;IA2J7C;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAoCtC"}
1
+ {"version":3,"file":"application-runtime-bootstrap.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/application-runtime-bootstrap.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAYH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAGlG,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAM5G,MAAM,WAAW,gCAAgC;IAC/C,GAAG,EAAE,gCAAgC,CAAC;IACtC,WAAW,EAAE,sBAAsB,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iCAAiC;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,kCAAkC;WAChC,UAAU,CACrB,KAAK,EAAE,gCAAgC,GACtC,OAAO,CAAC,iCAAiC,CAAC;IA4J7C;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM,CAAC,mCAAmC;IAwBlD;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAoCtC"}
@@ -18,6 +18,7 @@
18
18
  */
19
19
  import { existsSync } from 'node:fs';
20
20
  import { join, relative } from 'node:path';
21
+ import { ApplicationRuntimePrincipalKind, buildRuntimePrincipalKey, enumerateDeclaredRuntimePrincipals, } from '@wildo-ai/platform-config-lib';
21
22
  import { FILE_NAMES } from '../../infrastructure/io/io.schemas.js';
22
23
  import { AppBootstrapService } from '../../services/application/app-bootstrap.service.js';
23
24
  import { sync as envSync } from '../../services/environment/env-sync.service.js';
@@ -138,6 +139,7 @@ export class ApplicationRuntimeBootstrapService {
138
139
  * that never completed `wildo local init` now says so here instead of compiling happily and
139
140
  * running nothing.
140
141
  */
142
+ ApplicationRuntimeBootstrapService.assertEveryDeclaredRuntimeProjected(prepared, applicationWorkers, applicationMinions);
141
143
  ApplicationRuntimeBootstrapService.assertRuntimeEnvOnDisk([...applicationBackends, ...companionApis, ...applicationFrontends,
142
144
  ...applicationWorkers, ...applicationMinions], input.log);
143
145
  input.log.success(` Application runtime materialized: ${result.backendCount} backend, `
@@ -145,6 +147,36 @@ export class ApplicationRuntimeBootstrapService {
145
147
  + `${result.workerCount} worker, ${result.minionCount} minion target(s).`);
146
148
  return result;
147
149
  }
150
+ /**
151
+ * Refuse to report materialization when a minion or worker the declaration names got no target.
152
+ *
153
+ * {@link assertRuntimeEnvOnDisk} checks the targets that were BUILT, so it cannot see one that never was: on reference
154
+ * run 44255624884 the target builders read a cached declaration with no minions, the check verified the five targets
155
+ * it was given, and the run reported "0 worker, 0 minion target(s)" as a success while apps-manager had just minted
156
+ * five minions and a worker from the declaration this run resolved. This compares against THAT declaration
157
+ * (`prepared.runtimeTarget.managedDeclaration`, the one registration sent), so the two cannot disagree in silence again.
158
+ *
159
+ * A degraded registration may skip a runtime whose own secret could not be reconstructed offline: that skip is the
160
+ * documented degraded behaviour (its runtime keeps its existing `.env`), so it is not counted as missing here.
161
+ */
162
+ static assertEveryDeclaredRuntimeProjected(prepared, workers, minions) {
163
+ const projected = new Set([
164
+ ...workers.map((target) => buildRuntimePrincipalKey({ kind: ApplicationRuntimePrincipalKind.WORKER, name: target.workerName })),
165
+ ...minions.map((target) => buildRuntimePrincipalKey({ kind: ApplicationRuntimePrincipalKind.MINION, name: target.minionName })),
166
+ ]);
167
+ const missing = enumerateDeclaredRuntimePrincipals(prepared.runtimeTarget.managedDeclaration)
168
+ .filter((principal) => principal.kind === ApplicationRuntimePrincipalKind.MINION || principal.kind === ApplicationRuntimePrincipalKind.WORKER)
169
+ .map(buildRuntimePrincipalKey)
170
+ .filter((key) => !projected.has(key))
171
+ .filter((key) => !(prepared.degraded === true && prepared.runtimePrincipalCredentials?.[key] === undefined));
172
+ if (missing.length === 0)
173
+ return;
174
+ throw new Error(`The declaration names ${missing.length} runtime(s) that got no env target: ${missing.join(', ')}. `
175
+ + 'Their identities were minted from wildo.saas.config.ts as registration read it, but no `.env` was written for '
176
+ + 'them, so each would start without one and refuse its unset APPLICATION_ENV. The env targets were built from a '
177
+ + 'different reading of the declaration than the one registration sent (it changed during this run, or a reader '
178
+ + 'served an earlier evaluation of it); run the same command again.');
179
+ }
148
180
  /**
149
181
  * Refuse to report materialization for a target whose `.env` is not on disk.
150
182
  *
@@ -1 +1 @@
1
- {"version":3,"file":"application-runtime-bootstrap.service.js","sourceRoot":"","sources":["../../../../src/services/application/application-runtime-bootstrap.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAErE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAC;AAE5F,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,kDAAkD,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AACvF,OAAO,EAAE,4BAA4B,EAAE,MAAM,6DAA6D,CAAC;AAC3G,OAAO,EAAE,4CAA4C,EAAE,MA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AAe;cAC1F,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;cACzF,8FAA8F;cAC9F,qFAAqF;cACrF,6EAA6E,CAChF,CAAC;IACJ,CAAC;CACF","sourcesContent":["/**\n * Canonical application-runtime bootstrap orchestration.\n *\n * This service is the single local lifecycle seam that turns an authored SaaS\n * application declaration into runnable process configuration:\n *\n * apps-manager registration by stable slug\n * -> bootstrap credential fetch\n * -> derived APPLICATION_ID persistence\n * -> backend/companion/frontend/worker/minion target projection\n * -> generated env materialization\n * -> declaration convergence, when registration degraded and so did not apply it\n * -> postcondition: JWT door + stored config compared against the declaration\n *\n * Callers must make apps-manager ready before entering this service. Keeping\n * that boundary explicit prevents application processes from racing the\n * database-owned identity/config/secrets records they consume at startup.\n */\n\nimport { existsSync } from 'node:fs';\nimport { join, relative } from 'node:path';\n\nimport { FILE_NAMES } from '~wildo-cli/infrastructure/io/io.schemas';\nimport type { Logger } from '~wildo-cli/kernel/types';\nimport { AppBootstrapService } from '~wildo-cli/services/application/app-bootstrap.service';\nimport type { PlatformEnvSecretsJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport { sync as envSync } from '~wildo-cli/services/environment/env-sync.service';\nimport type { PlatformEnvironmentConfiguration } from '~wildo-cli/services/environment/environment.schemas';\nimport { EnvironmentUtils } from '~wildo-cli/services/environment/environment.service';\nimport { hydrateEnvironmentFromConfig } from '~wildo-cli/services/environment/environment-hydration.utils';\nimport { ApplicationInitializationVerificationService } from './application-initialization-verification.service';\nimport { DegradedRegistrationDeclarationConvergenceService } from './degraded-registration-declaration-convergence.service';\n\nexport interface ApplicationRuntimeBootstrapInput {\n env: PlatformEnvironmentConfiguration;\n credentials: PlatformEnvSecretsJson;\n frameworkPath: string;\n saasRoot: string;\n isFrameworkDeveloper: boolean;\n requestedAppSlug?: string | undefined;\n log: Logger;\n}\n\nexport interface ApplicationRuntimeBootstrapResult {\n backendCount: number;\n companionCount: number;\n frontendCount: number;\n workerCount: number;\n minionCount: number;\n}\n\nexport class ApplicationRuntimeBootstrapService {\n static async initialize(\n input: ApplicationRuntimeBootstrapInput,\n ): Promise<ApplicationRuntimeBootstrapResult> {\n const config = EnvironmentUtils.loadConfigJson(input.env.name);\n if (!config) {\n throw new Error(`No config for '${input.env.name}'. Run 'wildo setup' first.`);\n }\n\n /**\n * Reconcile the caller's environment record against `config.json` before any target is\n * projected from it. The record is a registry CACHE that persists only a subset of the\n * authored environment, so an identity field authored since the last write reads as\n * `undefined` here and every generator silently takes its default — see the contract on\n * {@link hydrateEnvironmentFromConfig} for what that cost when the default was `http`\n * against a TLS dev edge.\n */\n const resolvedEnv = hydrateEnvironmentFromConfig(input.env, config);\n\n const registeredTargetInput = {\n env: resolvedEnv,\n credentials: input.credentials,\n saasRoot: input.saasRoot,\n config,\n requestedAppSlug: input.requestedAppSlug,\n };\n\n input.log.info(' Registering application once and materializing every runtime target from one snapshot...');\n\n const prepared = await AppBootstrapService.prepareApplicationEnvTargets(registeredTargetInput);\n if (!prepared) {\n throw new Error(\n 'Application bootstrap resolved no application target. Check wildo.saas.config.ts and the selected application slug.',\n );\n }\n const projectionInput = { ...registeredTargetInput, prepared };\n\n // These builders are projections over the same prepared registration/credential generation. They no\n // longer make independent initialize + credential-fetch requests, so a single logical bootstrap cannot\n // mix observations from multiple control-plane generations.\n const applicationBackends = await AppBootstrapService.buildApplicationBackendTargets(\n projectionInput,\n );\n const companionApis = await AppBootstrapService.buildApplicationCompanionTargets(\n projectionInput,\n );\n const applicationWorkers = await AppBootstrapService.buildApplicationWorkerTargets(\n projectionInput,\n );\n const applicationMinions = await AppBootstrapService.buildApplicationMinionTargets(\n projectionInput,\n );\n const applicationFrontends = await AppBootstrapService.buildApplicationFrontendTargets({\n saasRoot: input.saasRoot,\n requestedAppSlug: input.requestedAppSlug,\n prepared,\n });\n\n const result: ApplicationRuntimeBootstrapResult = {\n backendCount: applicationBackends.length,\n companionCount: companionApis.length,\n frontendCount: applicationFrontends.length,\n workerCount: applicationWorkers.length,\n minionCount: applicationMinions.length,\n };\n const targetCount = Object.values(result).reduce((total, count) => total + count, 0);\n if (targetCount === 0) {\n throw new Error(\n 'Application bootstrap resolved no runtime targets. Check wildo.saas.config.ts and the selected application slug.',\n );\n }\n\n await envSync(\n resolvedEnv,\n input.credentials,\n {\n frameworkPath: input.frameworkPath,\n isFrameworkDeveloper: input.isFrameworkDeveloper,\n // Without it the foreign-owner skip in `envSync` can never apply, so `--register-only` — whose contract is\n // \"no shared substrate is touched\" — rewrote every platform service's env from THIS application (#1112).\n invokingAppRoot: input.saasRoot,\n applicationBackends,\n companionApis,\n applicationFrontends,\n applicationWorkers,\n applicationMinions,\n },\n input.log,\n );\n\n /*\n * Converge, then verify. A non-degraded registration has already applied the declaration through\n * `/initialize`; a DEGRADED one never called it, so the postcondition below would report the\n * author's own edit as drift. Apply the missing step first — see the service for exactly what it\n * will and will not apply unattended.\n */\n // Name what registration applied, so an edited declaration is never applied silently.\n if (prepared.declarationConvergedFields !== undefined && prepared.declarationConvergedFields.length > 0) {\n input.log.info(\n ` Applied wildo.saas.config.ts to the stored config of '${prepared.runtimeTarget.appSlug}' `\n + `— ${prepared.declarationConvergedFields.length} slice(s):`,\n );\n for (const field of prepared.declarationConvergedFields) {\n input.log.info(` • ${field}`);\n }\n }\n if (prepared.degraded) {\n await DegradedRegistrationDeclarationConvergenceService.converge({\n env: resolvedEnv,\n credentials: input.credentials,\n appSlug: prepared.runtimeTarget.appSlug,\n managedDeclaration: prepared.runtimeTarget.managedDeclaration,\n log: input.log,\n });\n }\n\n input.log.info(' Verifying the registered platform JWT door and managed application config...');\n await ApplicationInitializationVerificationService.assertCoherent({\n env: resolvedEnv,\n credentials: input.credentials,\n appSlug: prepared.runtimeTarget.appSlug,\n // The audience of apps-manager's signed answer (#2950): the id this run's registration returned.\n applicationId: prepared.bootstrapCredentials.APPLICATION_ID,\n // The declaration this run initialized against — what makes the postcondition a COMPARISON\n // rather than an existence assertion (issue #97).\n managedDeclaration: prepared.runtimeTarget.managedDeclaration,\n });\n\n /*\n * The claim below says \"materialized\". Make it TRUE rather than hopeful.\n *\n * Every target here is a process that reads its `.env` at startup and fails without it, so\n * \"materialized\" has to mean the file is on disk — not that a writer was invoked. Until\n * 2026-09-10 it meant the second: the application env writes were gated on framework-developer\n * mode, so an app-creator application was told \"1 backend, 1 companion, 1 frontend materialized\"\n * with zero `.env` files written, and the failure surfaced much later and somewhere else — the\n * companion dying on `APPLICATION_ID ... undefined` inside `pnpm --parallel`, which took the\n * rest of the stack down with it and named nothing.\n *\n * A postcondition here is worth more than a checker: it fires in the run that caused it, names\n * the files, and cannot be true-by-accident. It also guards the reverse direction — a project\n * that never completed `wildo local init` now says so here instead of compiling happily and\n * running nothing.\n */\n ApplicationRuntimeBootstrapService.assertRuntimeEnvOnDisk(\n [...applicationBackends, ...companionApis, ...applicationFrontends,\n ...applicationWorkers, ...applicationMinions],\n input.log,\n );\n\n input.log.success(\n ` Application runtime materialized: ${result.backendCount} backend, `\n + `${result.companionCount} companion, ${result.frontendCount} frontend, `\n + `${result.workerCount} worker, ${result.minionCount} minion target(s).`,\n );\n return result;\n }\n\n /**\n * Refuse to report materialization for a target whose `.env` is not on disk.\n *\n * @see the note at the call site for the defect this exists to prevent.\n */\n private static assertRuntimeEnvOnDisk(\n targets: readonly { applicationRoot: string; relativeDir: string }[],\n log: Logger,\n ): void {\n /*\n * Only targets that actually carry both path fields are checkable. The type requires them, so a\n * target without them is a test double rather than a real runtime target — this postcondition\n * must not turn a partial mock into a crash (`join(undefined, ...)` throws a TypeError that\n * reads as a bug in the thing being verified). Anything skipped is REPORTED rather than hidden,\n * so a real target that somehow lost its anchor is still visible.\n */\n const checkable = targets.filter(\n (target) => typeof target?.applicationRoot === 'string' && typeof target?.relativeDir === 'string',\n );\n const skipped = targets.length - checkable.length;\n const missing = checkable\n .map((target) => join(target.applicationRoot, target.relativeDir, FILE_NAMES.DOT_ENV))\n .filter((path) => !existsSync(path));\n\n if (missing.length === 0) {\n log.info(\n ` Runtime env verified on disk for ${checkable.length} target(s).`\n + (skipped > 0 ? ` (${skipped} target(s) carried no path anchor and were not checkable.)` : ''),\n );\n return;\n }\n\n const applicationRoot = targets[0]?.applicationRoot ?? process.cwd();\n throw new Error(\n `Application runtime env is missing for ${missing.length} of ${targets.length} target(s):\\n`\n + `${missing.map((path) => ` - ${relative(applicationRoot, path) || path}`).join('\\n')}\\n`\n + 'Each of these is read at process startup, so the application would compile and then fail to '\n + 'run with an unrelated-looking validation error. Re-run `wildo local init` for this '\n + 'application; if it persists, the env generator did not receive this target.',\n );\n }\n}\n"]}
1
+ {"version":3,"file":"application-runtime-bootstrap.service.js","sourceRoot":"","sources":["../../../../src/services/application/application-runtime-bootstrap.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,EACxB,kCAAkC,GACnC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAErE,OAAO,EAAE,mBAAmB,EAAsC,MAAM,uDAAuD,CAAC;AAEhI,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,kDAAkD,CAAC;AAGnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AACvF,OAAO,EAAE,4BAA4B,EAAE,MAAM,6DAA6D,CAAC;AAC3G,OAAO,EAAE,4CAA4C,EAAE,MAAM,mDAAmD,CAAC;AACjH,OAAO,EAAE,iDAAiD,EAAE,MAAM,yDAAyD,CAAC;AAoB5H,MAAM,OAAO,kCAAkC;IAC7C,MAAM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CAAC,MAAM,eAAe;cAC1F,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;cACzF,8FAA8F;cAC9F,qFAAqF;cACrF,6EAA6E,CAChF,CAAC;IACJ,CAAC;CACF","sourcesContent":["/**\n * Canonical application-runtime bootstrap orchestration.\n *\n * This service is the single local lifecycle seam that turns an authored SaaS\n * application declaration into runnable process configuration:\n *\n * apps-manager registration by stable slug\n * -> bootstrap credential fetch\n * -> derived APPLICATION_ID persistence\n * -> backend/companion/frontend/worker/minion target projection\n * -> generated env materialization\n * -> declaration convergence, when registration degraded and so did not apply it\n * -> postcondition: JWT door + stored config compared against the declaration\n *\n * Callers must make apps-manager ready before entering this service. Keeping\n * that boundary explicit prevents application processes from racing the\n * database-owned identity/config/secrets records they consume at startup.\n */\n\nimport { existsSync } from 'node:fs';\nimport { join, relative } from 'node:path';\n\nimport {\n ApplicationRuntimePrincipalKind,\n buildRuntimePrincipalKey,\n enumerateDeclaredRuntimePrincipals,\n} from '@wildo-ai/platform-config-lib';\n\nimport { FILE_NAMES } from '~wildo-cli/infrastructure/io/io.schemas';\nimport type { Logger } from '~wildo-cli/kernel/types';\nimport { AppBootstrapService, type PreparedApplicationEnvTargets } from '~wildo-cli/services/application/app-bootstrap.service';\nimport type { PlatformEnvSecretsJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport { sync as envSync } from '~wildo-cli/services/environment/env-sync.service';\nimport type { ApplicationMinionEnvTarget, ApplicationWorkerEnvTarget } from '~wildo-cli/services/environment/env-configuration-generator.service';\nimport type { PlatformEnvironmentConfiguration } from '~wildo-cli/services/environment/environment.schemas';\nimport { EnvironmentUtils } from '~wildo-cli/services/environment/environment.service';\nimport { hydrateEnvironmentFromConfig } from '~wildo-cli/services/environment/environment-hydration.utils';\nimport { ApplicationInitializationVerificationService } from './application-initialization-verification.service';\nimport { DegradedRegistrationDeclarationConvergenceService } from './degraded-registration-declaration-convergence.service';\n\nexport interface ApplicationRuntimeBootstrapInput {\n env: PlatformEnvironmentConfiguration;\n credentials: PlatformEnvSecretsJson;\n frameworkPath: string;\n saasRoot: string;\n isFrameworkDeveloper: boolean;\n requestedAppSlug?: string | undefined;\n log: Logger;\n}\n\nexport interface ApplicationRuntimeBootstrapResult {\n backendCount: number;\n companionCount: number;\n frontendCount: number;\n workerCount: number;\n minionCount: number;\n}\n\nexport class ApplicationRuntimeBootstrapService {\n static async initialize(\n input: ApplicationRuntimeBootstrapInput,\n ): Promise<ApplicationRuntimeBootstrapResult> {\n const config = EnvironmentUtils.loadConfigJson(input.env.name);\n if (!config) {\n throw new Error(`No config for '${input.env.name}'. Run 'wildo setup' first.`);\n }\n\n /**\n * Reconcile the caller's environment record against `config.json` before any target is\n * projected from it. The record is a registry CACHE that persists only a subset of the\n * authored environment, so an identity field authored since the last write reads as\n * `undefined` here and every generator silently takes its default — see the contract on\n * {@link hydrateEnvironmentFromConfig} for what that cost when the default was `http`\n * against a TLS dev edge.\n */\n const resolvedEnv = hydrateEnvironmentFromConfig(input.env, config);\n\n const registeredTargetInput = {\n env: resolvedEnv,\n credentials: input.credentials,\n saasRoot: input.saasRoot,\n config,\n requestedAppSlug: input.requestedAppSlug,\n };\n\n input.log.info(' Registering application once and materializing every runtime target from one snapshot...');\n\n const prepared = await AppBootstrapService.prepareApplicationEnvTargets(registeredTargetInput);\n if (!prepared) {\n throw new Error(\n 'Application bootstrap resolved no application target. Check wildo.saas.config.ts and the selected application slug.',\n );\n }\n const projectionInput = { ...registeredTargetInput, prepared };\n\n // These builders are projections over the same prepared registration/credential generation. They no\n // longer make independent initialize + credential-fetch requests, so a single logical bootstrap cannot\n // mix observations from multiple control-plane generations.\n const applicationBackends = await AppBootstrapService.buildApplicationBackendTargets(\n projectionInput,\n );\n const companionApis = await AppBootstrapService.buildApplicationCompanionTargets(\n projectionInput,\n );\n const applicationWorkers = await AppBootstrapService.buildApplicationWorkerTargets(\n projectionInput,\n );\n const applicationMinions = await AppBootstrapService.buildApplicationMinionTargets(\n projectionInput,\n );\n const applicationFrontends = await AppBootstrapService.buildApplicationFrontendTargets({\n saasRoot: input.saasRoot,\n requestedAppSlug: input.requestedAppSlug,\n prepared,\n });\n\n const result: ApplicationRuntimeBootstrapResult = {\n backendCount: applicationBackends.length,\n companionCount: companionApis.length,\n frontendCount: applicationFrontends.length,\n workerCount: applicationWorkers.length,\n minionCount: applicationMinions.length,\n };\n const targetCount = Object.values(result).reduce((total, count) => total + count, 0);\n if (targetCount === 0) {\n throw new Error(\n 'Application bootstrap resolved no runtime targets. Check wildo.saas.config.ts and the selected application slug.',\n );\n }\n\n await envSync(\n resolvedEnv,\n input.credentials,\n {\n frameworkPath: input.frameworkPath,\n isFrameworkDeveloper: input.isFrameworkDeveloper,\n // Without it the foreign-owner skip in `envSync` can never apply, so `--register-only` — whose contract is\n // \"no shared substrate is touched\" — rewrote every platform service's env from THIS application (#1112).\n invokingAppRoot: input.saasRoot,\n applicationBackends,\n companionApis,\n applicationFrontends,\n applicationWorkers,\n applicationMinions,\n },\n input.log,\n );\n\n /*\n * Converge, then verify. A non-degraded registration has already applied the declaration through\n * `/initialize`; a DEGRADED one never called it, so the postcondition below would report the\n * author's own edit as drift. Apply the missing step first — see the service for exactly what it\n * will and will not apply unattended.\n */\n // Name what registration applied, so an edited declaration is never applied silently.\n if (prepared.declarationConvergedFields !== undefined && prepared.declarationConvergedFields.length > 0) {\n input.log.info(\n ` Applied wildo.saas.config.ts to the stored config of '${prepared.runtimeTarget.appSlug}' `\n + `— ${prepared.declarationConvergedFields.length} slice(s):`,\n );\n for (const field of prepared.declarationConvergedFields) {\n input.log.info(` • ${field}`);\n }\n }\n if (prepared.degraded) {\n await DegradedRegistrationDeclarationConvergenceService.converge({\n env: resolvedEnv,\n credentials: input.credentials,\n appSlug: prepared.runtimeTarget.appSlug,\n managedDeclaration: prepared.runtimeTarget.managedDeclaration,\n log: input.log,\n });\n }\n\n input.log.info(' Verifying the registered platform JWT door and managed application config...');\n await ApplicationInitializationVerificationService.assertCoherent({\n env: resolvedEnv,\n credentials: input.credentials,\n appSlug: prepared.runtimeTarget.appSlug,\n // The audience of apps-manager's signed answer (#2950): the id this run's registration returned.\n applicationId: prepared.bootstrapCredentials.APPLICATION_ID,\n // The declaration this run initialized against — what makes the postcondition a COMPARISON\n // rather than an existence assertion (issue #97).\n managedDeclaration: prepared.runtimeTarget.managedDeclaration,\n });\n\n /*\n * The claim below says \"materialized\". Make it TRUE rather than hopeful.\n *\n * Every target here is a process that reads its `.env` at startup and fails without it, so\n * \"materialized\" has to mean the file is on disk — not that a writer was invoked. Until\n * 2026-09-10 it meant the second: the application env writes were gated on framework-developer\n * mode, so an app-creator application was told \"1 backend, 1 companion, 1 frontend materialized\"\n * with zero `.env` files written, and the failure surfaced much later and somewhere else — the\n * companion dying on `APPLICATION_ID ... undefined` inside `pnpm --parallel`, which took the\n * rest of the stack down with it and named nothing.\n *\n * A postcondition here is worth more than a checker: it fires in the run that caused it, names\n * the files, and cannot be true-by-accident. It also guards the reverse direction — a project\n * that never completed `wildo local init` now says so here instead of compiling happily and\n * running nothing.\n */\n ApplicationRuntimeBootstrapService.assertEveryDeclaredRuntimeProjected(prepared, applicationWorkers, applicationMinions);\n ApplicationRuntimeBootstrapService.assertRuntimeEnvOnDisk(\n [...applicationBackends, ...companionApis, ...applicationFrontends,\n ...applicationWorkers, ...applicationMinions],\n input.log,\n );\n\n input.log.success(\n ` Application runtime materialized: ${result.backendCount} backend, `\n + `${result.companionCount} companion, ${result.frontendCount} frontend, `\n + `${result.workerCount} worker, ${result.minionCount} minion target(s).`,\n );\n return result;\n }\n\n /**\n * Refuse to report materialization when a minion or worker the declaration names got no target.\n *\n * {@link assertRuntimeEnvOnDisk} checks the targets that were BUILT, so it cannot see one that never was: on reference\n * run 44255624884 the target builders read a cached declaration with no minions, the check verified the five targets\n * it was given, and the run reported \"0 worker, 0 minion target(s)\" as a success while apps-manager had just minted\n * five minions and a worker from the declaration this run resolved. This compares against THAT declaration\n * (`prepared.runtimeTarget.managedDeclaration`, the one registration sent), so the two cannot disagree in silence again.\n *\n * A degraded registration may skip a runtime whose own secret could not be reconstructed offline: that skip is the\n * documented degraded behaviour (its runtime keeps its existing `.env`), so it is not counted as missing here.\n */\n private static assertEveryDeclaredRuntimeProjected(\n prepared: Pick<PreparedApplicationEnvTargets, 'degraded' | 'runtimePrincipalCredentials' | 'runtimeTarget'>,\n workers: readonly Pick<ApplicationWorkerEnvTarget, 'workerName'>[],\n minions: readonly Pick<ApplicationMinionEnvTarget, 'minionName'>[],\n ): void {\n const projected = new Set([\n ...workers.map((target) => buildRuntimePrincipalKey({ kind: ApplicationRuntimePrincipalKind.WORKER, name: target.workerName })),\n ...minions.map((target) => buildRuntimePrincipalKey({ kind: ApplicationRuntimePrincipalKind.MINION, name: target.minionName })),\n ]);\n const missing = enumerateDeclaredRuntimePrincipals(prepared.runtimeTarget.managedDeclaration)\n .filter((principal) => principal.kind === ApplicationRuntimePrincipalKind.MINION || principal.kind === ApplicationRuntimePrincipalKind.WORKER)\n .map(buildRuntimePrincipalKey)\n .filter((key) => !projected.has(key))\n .filter((key) => !(prepared.degraded === true && prepared.runtimePrincipalCredentials?.[key] === undefined));\n if (missing.length === 0) return;\n throw new Error(\n `The declaration names ${missing.length} runtime(s) that got no env target: ${missing.join(', ')}. `\n + 'Their identities were minted from wildo.saas.config.ts as registration read it, but no `.env` was written for '\n + 'them, so each would start without one and refuse its unset APPLICATION_ENV. The env targets were built from a '\n + 'different reading of the declaration than the one registration sent (it changed during this run, or a reader '\n + 'served an earlier evaluation of it); run the same command again.',\n );\n }\n\n /**\n * Refuse to report materialization for a target whose `.env` is not on disk.\n *\n * @see the note at the call site for the defect this exists to prevent.\n */\n private static assertRuntimeEnvOnDisk(\n targets: readonly { applicationRoot: string; relativeDir: string }[],\n log: Logger,\n ): void {\n /*\n * Only targets that actually carry both path fields are checkable. The type requires them, so a\n * target without them is a test double rather than a real runtime target — this postcondition\n * must not turn a partial mock into a crash (`join(undefined, ...)` throws a TypeError that\n * reads as a bug in the thing being verified). Anything skipped is REPORTED rather than hidden,\n * so a real target that somehow lost its anchor is still visible.\n */\n const checkable = targets.filter(\n (target) => typeof target?.applicationRoot === 'string' && typeof target?.relativeDir === 'string',\n );\n const skipped = targets.length - checkable.length;\n const missing = checkable\n .map((target) => join(target.applicationRoot, target.relativeDir, FILE_NAMES.DOT_ENV))\n .filter((path) => !existsSync(path));\n\n if (missing.length === 0) {\n log.info(\n ` Runtime env verified on disk for ${checkable.length} target(s).`\n + (skipped > 0 ? ` (${skipped} target(s) carried no path anchor and were not checkable.)` : ''),\n );\n return;\n }\n\n const applicationRoot = targets[0]?.applicationRoot ?? process.cwd();\n throw new Error(\n `Application runtime env is missing for ${missing.length} of ${targets.length} target(s):\\n`\n + `${missing.map((path) => ` - ${relative(applicationRoot, path) || path}`).join('\\n')}\\n`\n + 'Each of these is read at process startup, so the application would compile and then fail to '\n + 'run with an unrelated-looking validation error. Re-run `wildo local init` for this '\n + 'application; if it persists, the env generator did not receive this target.',\n );\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { type LoadConfigOptions } from '@wildo-ai/platform-config-lib';
1
2
  type ProviderConfigurationsLayer = Readonly<Record<string, Readonly<Record<string, unknown>> | undefined>>;
2
3
  /**
3
4
  * The provider configuration an application runs with IN ONE ENVIRONMENT — the single door both environment-aware
@@ -24,6 +25,12 @@ export declare function resolveEnvironmentProviderConfigurations(input: {
24
25
  saasRoot: string;
25
26
  applicationProviderConfigurations: ProviderConfigurationsLayer | undefined;
26
27
  environmentName: string | null;
28
+ /**
29
+ * How the environment's `wildo.infra.<env>.config.ts` is evaluated. `AppRuntimeTargetsService.resolve` passes its own
30
+ * (fresh, #3985): its overlay goes into the declaration registration sends, and a cached evaluation inside a
31
+ * long-lived `wildo local dev` would send the file as that process first read it.
32
+ */
33
+ infraConfigLoadOptions?: Pick<LoadConfigOptions, 'freshModuleCache' | 'moduleResolution'> | undefined;
27
34
  }): Promise<Record<string, Record<string, unknown> | undefined>>;
28
35
  export {};
29
36
  //# sourceMappingURL=environment-provider-configurations.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment-provider-configurations.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/environment-provider-configurations.service.ts"],"names":[],"mappings":"AAKA,KAAK,2BAA2B,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;AAE3G;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,wCAAwC,CAAC,KAAK,EAAE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,iCAAiC,EAAE,2BAA2B,GAAG,SAAS,CAAC;IAC3E,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC,CAY/D"}
1
+ {"version":3,"file":"environment-provider-configurations.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/environment-provider-configurations.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAuE,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAI5I,KAAK,2BAA2B,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;AAE3G;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,wCAAwC,CAAC,KAAK,EAAE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,iCAAiC,EAAE,2BAA2B,GAAG,SAAS,CAAC;IAC3E,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,kBAAkB,GAAG,kBAAkB,CAAC,GAAG,SAAS,CAAC;CACvG,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC,CAY/D"}
@@ -29,7 +29,7 @@ export async function resolveEnvironmentProviderConfigurations(input) {
29
29
  if (input.environmentName === null) {
30
30
  return overlayEnvironmentProviderConfigurations(input.applicationProviderConfigurations, undefined);
31
31
  }
32
- const authored = await loadAuthoredInfraEnvConfig(input.environmentName, input.saasRoot);
32
+ const authored = await loadAuthoredInfraEnvConfig(input.environmentName, input.saasRoot, input.infraConfigLoadOptions);
33
33
  const environmentProviderConfigurations = authored?.config.providerConfigurations;
34
34
  assertNoProviderSecretKeys(environmentProviderConfigurations, authored?.path ?? `infrastructure/${input.environmentName}`);
35
35
  assertConfiguredSecretRefsDeclared(environmentProviderConfigurations, authored?.path ?? `infrastructure/${input.environmentName}`);
@@ -1 +1 @@
1
- {"version":3,"file":"environment-provider-configurations.service.js","sourceRoot":"","sources":["../../../../src/services/application/environment-provider-configurations.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,yCAAyC,EAAE,MAAM,sCAAsC,CAAC;AACvI,OAAO,EAAE,yBAAyB,EAAE,wCAAwC,EAAE,MAAM,+BAA+B,CAAC;AACpH,OAAO,EAAE,wBAAwB,EAAE,mCAAmC,EAAE,MAAM,6DAA6D,CAAC;AAC5I,OAAO,EAAE,0BAA0B,EAAE,MAAM,6DAA6D,CAAC;AAIzG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,wCAAwC,CAAC,KAI9D;IACC,0BAA0B,CAAC,KAAK,CAAC,iCAAiC,EAAE,sBAAsB,CAAC,CAAC;IAC5F,kCAAkC,CAAC,KAAK,CAAC,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AAC,OAAO,IAAI,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3H,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAC/B,MAAM,IAAI,KAAK,CACb,GAAG,EAAE,UAAU,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,4BAA4B;UACjJ,kIAAkI;UAClI,4FAA4F,CAC/F,CAAC;AACJ,CAAC","sourcesContent":["import { ProviderConfigurationCredentialField, readProviderConfigurationCredentialFields } from '@wildo-ai/external-connectors-models';\nimport { isRuntimeSecretEnvVarName, overlayEnvironmentProviderConfigurations } from '@wildo-ai/platform-config-lib';\nimport { getComposedProviderEntry, getComposedProviderSecretsCatalogue } from '~wildo-cli/services/credentials/composed-provider-catalogue';\nimport { loadAuthoredInfraEnvConfig } from '~wildo-cli/services/environment/authored-infra-config.utils';\n\ntype ProviderConfigurationsLayer = Readonly<Record<string, Readonly<Record<string, unknown>> | undefined>>;\n\n/**\n * The provider configuration an application runs with IN ONE ENVIRONMENT — the single door both environment-aware\n * producers go through.\n *\n * Two things carry a provider configuration out of the CLI, and before this existed both used\n * `wildo.saas.config.ts > providerConfigurations` verbatim, so every environment received one environment's values:\n *\n * | producer | consumer |\n * |---|---|\n * | the managed declaration (`AppRuntimeTargetsService.resolve`) | each environment's apps-manager, then the backend: OAuth2 client IDs, email/SMS senders, the provider registry |\n * | the provider runtime artifacts (`syncProviderRuntimeArtifactsForApp`) | baked into builds: frontend `publicConfig`, the backend's generated provider module |\n *\n * Both call this with the environment they are producing for, so the two cannot disagree about which value an\n * environment has.\n *\n * `environmentName: null` is a deliberate answer, not an omission: the caller produces nothing environment-bound (a\n * validation that reads only the services list). It yields the application layer alone.\n *\n * An environment with no authored `wildo.infra.<env>.config.ts` states no override, so it runs with the application\n * layer — the same reading every other per-environment block gets when absent.\n */\nexport async function resolveEnvironmentProviderConfigurations(input: {\n saasRoot: string;\n applicationProviderConfigurations: ProviderConfigurationsLayer | undefined;\n environmentName: string | null;\n}): Promise<Record<string, Record<string, unknown> | undefined>> {\n assertNoProviderSecretKeys(input.applicationProviderConfigurations, 'wildo.saas.config.ts');\n assertConfiguredSecretRefsDeclared(input.applicationProviderConfigurations, 'wildo.saas.config.ts');\n if (input.environmentName === null) {\n return overlayEnvironmentProviderConfigurations(input.applicationProviderConfigurations, undefined);\n }\n\n const authored = await loadAuthoredInfraEnvConfig(input.environmentName, input.saasRoot);\n const environmentProviderConfigurations = authored?.config.providerConfigurations;\n assertNoProviderSecretKeys(environmentProviderConfigurations, authored?.path ?? `infrastructure/${input.environmentName}`);\n assertConfiguredSecretRefsDeclared(environmentProviderConfigurations, authored?.path ?? `infrastructure/${input.environmentName}`);\n return overlayEnvironmentProviderConfigurations(input.applicationProviderConfigurations, environmentProviderConfigurations);\n}\n\n/**\n * Refuse a provider configuration key named like one of that provider's declared secrets.\n *\n * Both files carrying provider configuration are committed, and the key a leak would use is exactly the one an author\n * reaches for when a client ID and its client secret sit side by side in the vendor console\n * (`GOOGLE_OAUTH2_CLIENT_ID` → `GOOGLE_OAUTH2_CLIENT_SECRET`). The secret has one home, `secrets.json → providerEnv`,\n * and a value written here would be committed while the runtime kept reading the env var — a leak that also does\n * nothing.\n *\n * Matched on the secret's ENVIRONMENT-VARIABLE name only, from the composed provider catalogue — the same authority\n * the env writers use. Not on its contract slug: slugs are generic (`apiKey`), and a frontend SDK legitimately takes a\n * PUBLIC key under that same name (PostHog's `phc_` project key in `frontend_sdk.apiKey`), so a slug match would refuse\n * a correct configuration. The env-var name is the precise signal: it is exactly what an author copies out of the\n * secrets file. A provider the catalogue does not yet know (an application-owned package before discovery) is checked\n * on the call that runs after discovery — `syncProviderRuntimeArtifactsForApp` registers contributions before it\n * resolves — so `wildo config sync` covers it.\n */\nfunction assertNoProviderSecretKeys(layer: ProviderConfigurationsLayer | undefined, source: string): void {\n for (const [providerRef, protocols] of Object.entries(layer ?? {})) {\n const secrets = getComposedProviderEntry(providerRef)?.secrets ?? [];\n if (secrets.length === 0 || !protocols) continue;\n const secretNames = new Set(secrets.map((secret) => secret.envVarName));\n for (const [protocolKind, values] of Object.entries(protocols)) {\n if (!values || typeof values !== 'object' || Array.isArray(values)) continue;\n const leaked = Object.keys(values).filter((key) => secretNames.has(key));\n if (leaked.length > 0) {\n throw new Error(\n `${source}: providerConfigurations.${providerRef}.${protocolKind} names ${leaked.map((key) => `\"${key}\"`).join(', ')}, `\n + `which ${leaked.length === 1 ? 'is a secret' : 'are secrets'} of provider \"${providerRef}\". Secrets belong in `\n + '`infrastructure/<env>/secrets/secrets.json → providerEnv`, never in a committed configuration file.',\n );\n }\n }\n }\n}\n\n/**\n * Refuse a provider configuration that points a provider at a secret its module does not declare (#3002), or whose ACP\n * execution profile forwards a secret into the coding agent (#3018).\n *\n * The backend reads `authConfig.secretRef` as the variable sent to the vendor as the provider's key or client secret,\n * and an ACP execution profile's `secretEnvVarName` as the variable handed to the coding agent; it admits only a slot\n * the module's `secretsContract` declares, and refuses at startup and on every read. Refused here too, so `wildo config\n * sync` (and creation readiness, and every other caller of this door) stops before generating anything for a\n * configuration the backend would refuse to boot with, naming the file.\n *\n * The same reading as the backend: `authConfig.secretRef` names a slot by its variable or its slug; `secretEnvVarName`\n * names the variable the agent reads, so only a declared variable. Those two slot rules need the provider's declared\n * slots, so a provider the catalogue does not know yet is not held to them here, as above, and is held on the call that\n * runs after discovery registered it. The inherited-environment rule needs no provider and runs for every provider,\n * known or not ({@link assertInheritedEnvironmentVariablesAreNotSecrets}).\n *\n * The fields are read through `readProviderConfigurationCredentialFields` and branched on their\n * `ProviderConfigurationCredentialField`, the vocabulary the backend registry branches on too (#3022), so the two doors\n * cannot disagree about which fields name a credential or which bag carries execution profiles (the agent-client-protocol\n * bag, under its wire value or its member name).\n *\n * assurance-control: WILDO.SECRETS.CREDENTIAL_SCOPING — `wildo config sync`, creation readiness and every producer of an environment's provider configuration refuse a configuration naming a credential its provider module or the framework does not admit, naming the file.\n */\nfunction assertConfiguredSecretRefsDeclared(layer: ProviderConfigurationsLayer | undefined, source: string): void {\n for (const [providerRef, protocols] of Object.entries(layer ?? {})) {\n if (!protocols) continue;\n const entry = getComposedProviderEntry(providerRef);\n const envVarNames = new Set((entry?.secrets ?? []).map((secret) => secret.envVarName));\n const admitted = new Set([...envVarNames, ...(entry?.secrets ?? []).map((secret) => secret.slug)]);\n const declared = (entry?.secrets ?? []).map((secret) => `${secret.slug} (${secret.envVarName})`).sort().join(', ') || 'none';\n for (const [protocolKey, values] of Object.entries(protocols)) {\n const at = (path: string): string => `${source}: providerConfigurations.${providerRef}.${protocolKey}.${path}`;\n for (const reading of readProviderConfigurationCredentialFields(protocolKey, values)) {\n switch (reading.field) {\n case ProviderConfigurationCredentialField.EXECUTION_PROFILE_INHERITED_ENVIRONMENT:\n // A secret forwarded into the agent (#3018) is refused for every provider, known here or not: the forbidden set\n // does not depend on the provider.\n assertInheritedEnvironmentVariablesAreNotSecrets(reading.value, at(reading.path));\n break;\n case ProviderConfigurationCredentialField.AUTH_SECRET_REF:\n // The slot rules need the provider's declared slots: a provider the catalogue does not know yet is checked on the\n // call that runs after discovery registered it.\n if (entry === undefined || (typeof reading.value === 'string' && admitted.has(reading.value))) break;\n throw new Error(\n `${at(reading.path)} names '${String(reading.value)}', which provider `\n + `\"${providerRef}\" does not declare as a secret. A configuration may point a protocol only at a slot the provider declares, by its `\n + `variable or its slug (${declared}); the backend refuses this configuration and reads no such variable.`,\n );\n case ProviderConfigurationCredentialField.EXECUTION_PROFILE_SECRET_ENV_VAR_NAME:\n if (entry === undefined || (typeof reading.value === 'string' && envVarNames.has(reading.value))) break;\n throw new Error(\n `${at(reading.path)} names '${String(reading.value)}', which provider \"${providerRef}\" does not declare as a secret. `\n + `An execution profile may hand the agent only a variable the provider declares (${declared}); the backend refuses this `\n + 'configuration and reads no such variable.',\n );\n default: {\n const exhaustive: never = reading.field;\n return exhaustive;\n }\n }\n }\n }\n }\n}\n\n/**\n * Refuse an execution profile that forwards a secret into the coding agent (#3018), as the backend does at every read,\n * at startup and at dispatch (`assertAgentInheritedEnvironmentVariablesAreNotSecrets`).\n *\n * The same question as the backend's: a secret a Wildo runtime env declares (`isRuntimeSecretEnvVarName`: the runtime\n * env contracts' keys, every inbound endpoint secret, every system-of-record slot), or a secret any provider the CLI\n * can see declares (the composed catalogue, engine tier and discovered packages: a superset of one runtime's). A name\n * it admits is one the framework does not declare secret, which is not the same as harmless: a developer's own shell\n * may carry secrets the framework cannot know.\n *\n * assurance-control: WILDO.SECRETS.CREDENTIAL_SCOPING — the CLI refuses an execution profile forwarding a declared secret into a coding agent, before anything is generated.\n */\nfunction assertInheritedEnvironmentVariablesAreNotSecrets(inherited: unknown, at: string): void {\n if (!Array.isArray(inherited)) return;\n const providerSecrets = new Set<string>();\n for (const entry of getComposedProviderSecretsCatalogue().values()) {\n for (const secret of entry.secrets) providerSecrets.add(secret.envVarName);\n }\n const forbidden = (name: string): boolean => isRuntimeSecretEnvVarName(name) || providerSecrets.has(name);\n const named = [...new Set(inherited.filter((name): name is string => typeof name === 'string' && forbidden(name)))].sort();\n if (named.length === 0) return;\n throw new Error(\n `${at} names ${named.map((name) => `'${name}'`).join(', ')}, which ${named.length === 1 ? 'is a secret' : 'are secrets'} of this platform or of a `\n + 'provider. A coding agent may not inherit a secret the framework declares; a provider credential the agent needs is handed to it '\n + 'through the execution profile\\'s secretEnvVarName. The backend refuses this configuration.',\n );\n}\n"]}
1
+ {"version":3,"file":"environment-provider-configurations.service.js","sourceRoot":"","sources":["../../../../src/services/application/environment-provider-configurations.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,yCAAyC,EAAE,MAAM,sCAAsC,CA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AK,IAAI,mCAAmC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC;QACnE,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,OAAO;YAAE,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7E,CAAC;IACD,MAAM,SAAS,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1G,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3H,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAC/B,MAAM,IAAI,KAAK,CACb,GAAG,EAAE,UAAU,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,4BAA4B;UACjJ,kIAAkI;UAClI,4FAA4F,CAC/F,CAAC;AACJ,CAAC","sourcesContent":["import { ProviderConfigurationCredentialField, readProviderConfigurationCredentialFields } from '@wildo-ai/external-connectors-models';\nimport { isRuntimeSecretEnvVarName, overlayEnvironmentProviderConfigurations, type LoadConfigOptions } from '@wildo-ai/platform-config-lib';\nimport { getComposedProviderEntry, getComposedProviderSecretsCatalogue } from '~wildo-cli/services/credentials/composed-provider-catalogue';\nimport { loadAuthoredInfraEnvConfig } from '~wildo-cli/services/environment/authored-infra-config.utils';\n\ntype ProviderConfigurationsLayer = Readonly<Record<string, Readonly<Record<string, unknown>> | undefined>>;\n\n/**\n * The provider configuration an application runs with IN ONE ENVIRONMENT — the single door both environment-aware\n * producers go through.\n *\n * Two things carry a provider configuration out of the CLI, and before this existed both used\n * `wildo.saas.config.ts > providerConfigurations` verbatim, so every environment received one environment's values:\n *\n * | producer | consumer |\n * |---|---|\n * | the managed declaration (`AppRuntimeTargetsService.resolve`) | each environment's apps-manager, then the backend: OAuth2 client IDs, email/SMS senders, the provider registry |\n * | the provider runtime artifacts (`syncProviderRuntimeArtifactsForApp`) | baked into builds: frontend `publicConfig`, the backend's generated provider module |\n *\n * Both call this with the environment they are producing for, so the two cannot disagree about which value an\n * environment has.\n *\n * `environmentName: null` is a deliberate answer, not an omission: the caller produces nothing environment-bound (a\n * validation that reads only the services list). It yields the application layer alone.\n *\n * An environment with no authored `wildo.infra.<env>.config.ts` states no override, so it runs with the application\n * layer — the same reading every other per-environment block gets when absent.\n */\nexport async function resolveEnvironmentProviderConfigurations(input: {\n saasRoot: string;\n applicationProviderConfigurations: ProviderConfigurationsLayer | undefined;\n environmentName: string | null;\n /**\n * How the environment's `wildo.infra.<env>.config.ts` is evaluated. `AppRuntimeTargetsService.resolve` passes its own\n * (fresh, #3985): its overlay goes into the declaration registration sends, and a cached evaluation inside a\n * long-lived `wildo local dev` would send the file as that process first read it.\n */\n infraConfigLoadOptions?: Pick<LoadConfigOptions, 'freshModuleCache' | 'moduleResolution'> | undefined;\n}): Promise<Record<string, Record<string, unknown> | undefined>> {\n assertNoProviderSecretKeys(input.applicationProviderConfigurations, 'wildo.saas.config.ts');\n assertConfiguredSecretRefsDeclared(input.applicationProviderConfigurations, 'wildo.saas.config.ts');\n if (input.environmentName === null) {\n return overlayEnvironmentProviderConfigurations(input.applicationProviderConfigurations, undefined);\n }\n\n const authored = await loadAuthoredInfraEnvConfig(input.environmentName, input.saasRoot, input.infraConfigLoadOptions);\n const environmentProviderConfigurations = authored?.config.providerConfigurations;\n assertNoProviderSecretKeys(environmentProviderConfigurations, authored?.path ?? `infrastructure/${input.environmentName}`);\n assertConfiguredSecretRefsDeclared(environmentProviderConfigurations, authored?.path ?? `infrastructure/${input.environmentName}`);\n return overlayEnvironmentProviderConfigurations(input.applicationProviderConfigurations, environmentProviderConfigurations);\n}\n\n/**\n * Refuse a provider configuration key named like one of that provider's declared secrets.\n *\n * Both files carrying provider configuration are committed, and the key a leak would use is exactly the one an author\n * reaches for when a client ID and its client secret sit side by side in the vendor console\n * (`GOOGLE_OAUTH2_CLIENT_ID` → `GOOGLE_OAUTH2_CLIENT_SECRET`). The secret has one home, `secrets.json → providerEnv`,\n * and a value written here would be committed while the runtime kept reading the env var — a leak that also does\n * nothing.\n *\n * Matched on the secret's ENVIRONMENT-VARIABLE name only, from the composed provider catalogue — the same authority\n * the env writers use. Not on its contract slug: slugs are generic (`apiKey`), and a frontend SDK legitimately takes a\n * PUBLIC key under that same name (PostHog's `phc_` project key in `frontend_sdk.apiKey`), so a slug match would refuse\n * a correct configuration. The env-var name is the precise signal: it is exactly what an author copies out of the\n * secrets file. A provider the catalogue does not yet know (an application-owned package before discovery) is checked\n * on the call that runs after discovery — `syncProviderRuntimeArtifactsForApp` registers contributions before it\n * resolves — so `wildo config sync` covers it.\n */\nfunction assertNoProviderSecretKeys(layer: ProviderConfigurationsLayer | undefined, source: string): void {\n for (const [providerRef, protocols] of Object.entries(layer ?? {})) {\n const secrets = getComposedProviderEntry(providerRef)?.secrets ?? [];\n if (secrets.length === 0 || !protocols) continue;\n const secretNames = new Set(secrets.map((secret) => secret.envVarName));\n for (const [protocolKind, values] of Object.entries(protocols)) {\n if (!values || typeof values !== 'object' || Array.isArray(values)) continue;\n const leaked = Object.keys(values).filter((key) => secretNames.has(key));\n if (leaked.length > 0) {\n throw new Error(\n `${source}: providerConfigurations.${providerRef}.${protocolKind} names ${leaked.map((key) => `\"${key}\"`).join(', ')}, `\n + `which ${leaked.length === 1 ? 'is a secret' : 'are secrets'} of provider \"${providerRef}\". Secrets belong in `\n + '`infrastructure/<env>/secrets/secrets.json → providerEnv`, never in a committed configuration file.',\n );\n }\n }\n }\n}\n\n/**\n * Refuse a provider configuration that points a provider at a secret its module does not declare (#3002), or whose ACP\n * execution profile forwards a secret into the coding agent (#3018).\n *\n * The backend reads `authConfig.secretRef` as the variable sent to the vendor as the provider's key or client secret,\n * and an ACP execution profile's `secretEnvVarName` as the variable handed to the coding agent; it admits only a slot\n * the module's `secretsContract` declares, and refuses at startup and on every read. Refused here too, so `wildo config\n * sync` (and creation readiness, and every other caller of this door) stops before generating anything for a\n * configuration the backend would refuse to boot with, naming the file.\n *\n * The same reading as the backend: `authConfig.secretRef` names a slot by its variable or its slug; `secretEnvVarName`\n * names the variable the agent reads, so only a declared variable. Those two slot rules need the provider's declared\n * slots, so a provider the catalogue does not know yet is not held to them here, as above, and is held on the call that\n * runs after discovery registered it. The inherited-environment rule needs no provider and runs for every provider,\n * known or not ({@link assertInheritedEnvironmentVariablesAreNotSecrets}).\n *\n * The fields are read through `readProviderConfigurationCredentialFields` and branched on their\n * `ProviderConfigurationCredentialField`, the vocabulary the backend registry branches on too (#3022), so the two doors\n * cannot disagree about which fields name a credential or which bag carries execution profiles (the agent-client-protocol\n * bag, under its wire value or its member name).\n *\n * assurance-control: WILDO.SECRETS.CREDENTIAL_SCOPING — `wildo config sync`, creation readiness and every producer of an environment's provider configuration refuse a configuration naming a credential its provider module or the framework does not admit, naming the file.\n */\nfunction assertConfiguredSecretRefsDeclared(layer: ProviderConfigurationsLayer | undefined, source: string): void {\n for (const [providerRef, protocols] of Object.entries(layer ?? {})) {\n if (!protocols) continue;\n const entry = getComposedProviderEntry(providerRef);\n const envVarNames = new Set((entry?.secrets ?? []).map((secret) => secret.envVarName));\n const admitted = new Set([...envVarNames, ...(entry?.secrets ?? []).map((secret) => secret.slug)]);\n const declared = (entry?.secrets ?? []).map((secret) => `${secret.slug} (${secret.envVarName})`).sort().join(', ') || 'none';\n for (const [protocolKey, values] of Object.entries(protocols)) {\n const at = (path: string): string => `${source}: providerConfigurations.${providerRef}.${protocolKey}.${path}`;\n for (const reading of readProviderConfigurationCredentialFields(protocolKey, values)) {\n switch (reading.field) {\n case ProviderConfigurationCredentialField.EXECUTION_PROFILE_INHERITED_ENVIRONMENT:\n // A secret forwarded into the agent (#3018) is refused for every provider, known here or not: the forbidden set\n // does not depend on the provider.\n assertInheritedEnvironmentVariablesAreNotSecrets(reading.value, at(reading.path));\n break;\n case ProviderConfigurationCredentialField.AUTH_SECRET_REF:\n // The slot rules need the provider's declared slots: a provider the catalogue does not know yet is checked on the\n // call that runs after discovery registered it.\n if (entry === undefined || (typeof reading.value === 'string' && admitted.has(reading.value))) break;\n throw new Error(\n `${at(reading.path)} names '${String(reading.value)}', which provider `\n + `\"${providerRef}\" does not declare as a secret. A configuration may point a protocol only at a slot the provider declares, by its `\n + `variable or its slug (${declared}); the backend refuses this configuration and reads no such variable.`,\n );\n case ProviderConfigurationCredentialField.EXECUTION_PROFILE_SECRET_ENV_VAR_NAME:\n if (entry === undefined || (typeof reading.value === 'string' && envVarNames.has(reading.value))) break;\n throw new Error(\n `${at(reading.path)} names '${String(reading.value)}', which provider \"${providerRef}\" does not declare as a secret. `\n + `An execution profile may hand the agent only a variable the provider declares (${declared}); the backend refuses this `\n + 'configuration and reads no such variable.',\n );\n default: {\n const exhaustive: never = reading.field;\n return exhaustive;\n }\n }\n }\n }\n }\n}\n\n/**\n * Refuse an execution profile that forwards a secret into the coding agent (#3018), as the backend does at every read,\n * at startup and at dispatch (`assertAgentInheritedEnvironmentVariablesAreNotSecrets`).\n *\n * The same question as the backend's: a secret a Wildo runtime env declares (`isRuntimeSecretEnvVarName`: the runtime\n * env contracts' keys, every inbound endpoint secret, every system-of-record slot), or a secret any provider the CLI\n * can see declares (the composed catalogue, engine tier and discovered packages: a superset of one runtime's). A name\n * it admits is one the framework does not declare secret, which is not the same as harmless: a developer's own shell\n * may carry secrets the framework cannot know.\n *\n * assurance-control: WILDO.SECRETS.CREDENTIAL_SCOPING — the CLI refuses an execution profile forwarding a declared secret into a coding agent, before anything is generated.\n */\nfunction assertInheritedEnvironmentVariablesAreNotSecrets(inherited: unknown, at: string): void {\n if (!Array.isArray(inherited)) return;\n const providerSecrets = new Set<string>();\n for (const entry of getComposedProviderSecretsCatalogue().values()) {\n for (const secret of entry.secrets) providerSecrets.add(secret.envVarName);\n }\n const forbidden = (name: string): boolean => isRuntimeSecretEnvVarName(name) || providerSecrets.has(name);\n const named = [...new Set(inherited.filter((name): name is string => typeof name === 'string' && forbidden(name)))].sort();\n if (named.length === 0) return;\n throw new Error(\n `${at} names ${named.map((name) => `'${name}'`).join(', ')}, which ${named.length === 1 ? 'is a secret' : 'are secrets'} of this platform or of a `\n + 'provider. A coding agent may not inherit a secret the framework declares; a provider credential the agent needs is handed to it '\n + 'through the execution profile\\'s secretEnvVarName. The backend refuses this configuration.',\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"local-tunnel.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/local-tunnel.service.ts"],"names":[],"mappings":"AAmCA;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAGvD,CAAC;AAEF,uDAAuD;AACvD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,gFAAgF;AAChF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,iHAAiH;AACjH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,sFAAsF;IACtF,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,8GAA8G;IAC9G,QAAQ,CA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B,6BAA6B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,EAC7F,SAAS,EAAE,CAAC,EACZ,MAAM,EAAE,IAAI,CAAC,sBAAsB,EAAE,cAAc,GAAG,qBAAqB,CAAC,GAAG,IAAI,GAClF;IAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAgB5D"}
@@ -32,6 +32,7 @@ import { existsSync, mkdirSync, openSync, readFileSync, rmSync, writeFileSync }
32
32
  import { homedir } from 'os';
33
33
  import { dirname, join } from 'path';
34
34
  import { promisify } from 'util';
35
+ import { describeCaughtError } from '@wildo-ai/saas-models';
35
36
  /**
36
37
  * The backend paths an outside party must reach, forwarded through the tunnel; every other path answers 404.
37
38
  *
@@ -197,7 +198,7 @@ export async function routeHostname(runner, tunnelName, hostname) {
197
198
  await runner.exec(['tunnel', 'route', 'dns', tunnelName, hostname]);
198
199
  }
199
200
  catch (error) {
200
- const message = error instanceof Error ? error.message : String(error);
201
+ const message = describeCaughtError(error);
201
202
  const elsewhere = /already exists/i.test(message)
202
203
  ? ' A record that already exists points somewhere else; remove it or choose another hostname.'
203
204
  : '';