@wildo-ai/platform-config-lib 1.1.2 → 1.1.3

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 (77) hide show
  1. package/dist/esm/bootstrap/bootstrap.schemas.d.ts +49 -1
  2. package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
  3. package/dist/esm/bootstrap/bootstrap.schemas.js +36 -2
  4. package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
  5. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +2 -3
  6. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
  7. package/dist/esm/bootstrap/platform-runtime-env.contracts.js +2 -3
  8. package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -1
  9. package/dist/esm/bootstrap/runtime-network-topology.d.ts +0 -1
  10. package/dist/esm/bootstrap/runtime-network-topology.d.ts.map +1 -1
  11. package/dist/esm/bootstrap/runtime-network-topology.js +0 -2
  12. package/dist/esm/bootstrap/runtime-network-topology.js.map +1 -1
  13. package/dist/esm/config-authoring.entry.d.ts +1 -2
  14. package/dist/esm/config-authoring.entry.d.ts.map +1 -1
  15. package/dist/esm/config-authoring.entry.js +35 -2
  16. package/dist/esm/config-authoring.entry.js.map +1 -1
  17. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts +0 -20
  18. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts.map +1 -1
  19. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js +0 -1
  20. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js.map +1 -1
  21. package/dist/esm/project-config/define-infra-env-config.d.ts +3 -39
  22. package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -1
  23. package/dist/esm/project-config/define-infra-env-config.js +2 -2
  24. package/dist/esm/project-config/define-infra-env-config.js.map +1 -1
  25. package/dist/esm/project-config/define-saas-config.d.ts +366 -14
  26. package/dist/esm/project-config/define-saas-config.d.ts.map +1 -1
  27. package/dist/esm/project-config/define-saas-config.js +121 -11
  28. package/dist/esm/project-config/define-saas-config.js.map +1 -1
  29. package/dist/esm/project-config/provider-companion-discovery.d.ts +74 -1
  30. package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
  31. package/dist/esm/project-config/provider-companion-discovery.js +203 -6
  32. package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
  33. package/dist/esm/project-config/provider-runtime-artifacts.d.ts +41 -15
  34. package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
  35. package/dist/esm/project-config/provider-runtime-artifacts.js +75 -6
  36. package/dist/esm/project-config/provider-runtime-artifacts.js.map +1 -1
  37. package/dist/esm/project-config/shared/backing-services.schemas.d.ts +7 -43
  38. package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
  39. package/dist/esm/project-config/shared/backing-services.schemas.js +13 -30
  40. package/dist/esm/project-config/shared/backing-services.schemas.js.map +1 -1
  41. package/dist/esm/project-config/shared/csp-emit.d.ts +36 -5
  42. package/dist/esm/project-config/shared/csp-emit.d.ts.map +1 -1
  43. package/dist/esm/project-config/shared/csp-emit.js +65 -5
  44. package/dist/esm/project-config/shared/csp-emit.js.map +1 -1
  45. package/dist/esm/project-config/shared/csp.schemas.d.ts +46 -10
  46. package/dist/esm/project-config/shared/csp.schemas.d.ts.map +1 -1
  47. package/dist/esm/project-config/shared/csp.schemas.js +45 -10
  48. package/dist/esm/project-config/shared/csp.schemas.js.map +1 -1
  49. package/dist/esm/project-config/shared/environment.schemas.d.ts +8 -6
  50. package/dist/esm/project-config/shared/environment.schemas.d.ts.map +1 -1
  51. package/dist/esm/project-config/shared/environment.schemas.js +7 -5
  52. package/dist/esm/project-config/shared/environment.schemas.js.map +1 -1
  53. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts +18 -3
  54. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts.map +1 -1
  55. package/dist/esm/project-config/shared/infra-providers.schemas.js +34 -2
  56. package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -1
  57. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts +0 -2
  58. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts.map +1 -1
  59. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js +0 -2
  60. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js.map +1 -1
  61. package/dist/esm/project-config/shared/k8s-utils.d.ts +70 -10
  62. package/dist/esm/project-config/shared/k8s-utils.d.ts.map +1 -1
  63. package/dist/esm/project-config/shared/k8s-utils.js +75 -11
  64. package/dist/esm/project-config/shared/k8s-utils.js.map +1 -1
  65. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.d.ts +15 -15
  66. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js +15 -15
  67. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js.map +1 -1
  68. package/dist/esm/project-config/shared/platform-services.schemas.d.ts +30 -0
  69. package/dist/esm/project-config/shared/platform-services.schemas.d.ts.map +1 -1
  70. package/dist/esm/project-config/shared/platform-services.schemas.js +31 -0
  71. package/dist/esm/project-config/shared/platform-services.schemas.js.map +1 -1
  72. package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts +14 -0
  73. package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts.map +1 -1
  74. package/dist/esm/workspace-scope/workspace-homes.schemas.js +2 -0
  75. package/dist/esm/workspace-scope/workspace-homes.schemas.js.map +1 -1
  76. package/dist/tsconfig.build.tsbuildinfo +1 -1
  77. package/package.json +7 -7
@@ -1,6 +1,58 @@
1
1
  import { type ProviderCompanionContribution } from '@wildo-ai/saas-models';
2
2
  import type { WildoSaasConfig } from './define-saas-config';
3
- type ProviderContributionOwnerKind = 'service' | 'library' | 'minion' | 'worker';
3
+ /**
4
+ * `providerPackage` was added by #330 and is the point of that slice on this file.
5
+ *
6
+ * The other four owner kinds are RUNTIME OWNERS declared in `wildo.saas.config.ts` — an application's
7
+ * own services, libraries, minions and workers. Walking only those is what made a provider shipped as
8
+ * its own npm package invisible to discovery (audit finding PL-1): the package is a DEPENDENCY, not a
9
+ * runtime owner, so nothing ever asked it what it contributes, and an application had to hand-author a
10
+ * contribution for a provider whose own package already knew everything about it.
11
+ */
12
+ export declare enum ProviderContributionOwnerKind {
13
+ /** A service package declared in `wildo.saas.config.ts` — the application's backend or a frontend. */
14
+ SERVICE = "service",
15
+ /** A shared library package of the application. */
16
+ LIBRARY = "library",
17
+ /** A minion runtime, keyed by its minion name. */
18
+ MINION = "minion",
19
+ /** A Node worker runtime, keyed by its worker name. */
20
+ WORKER = "worker",
21
+ /**
22
+ * A provider shipped as its own npm package (#330) — a DEPENDENCY rather than a runtime owner,
23
+ * which is why it needed its own walk and its own member. The value stays camelCase because it is
24
+ * substituted into operator-facing diagnostics beside the four above.
25
+ */
26
+ PROVIDER_PACKAGE = "providerPackage"
27
+ }
28
+ /**
29
+ * Package-name prefixes whose dependencies are treated as provider packages.
30
+ *
31
+ * `@wildo-ai/provider-` is the framework convention (#337 D3). An application's OWN provider packages
32
+ * are admitted through the scope of its root manifest — an application published as `@acme/…` gets
33
+ * `@acme/provider-…` for free — so a private provider needs no configuration to be discovered, and a
34
+ * dependency belonging to somebody else's scope is never executed by this walk.
35
+ */
36
+ export declare const FRAMEWORK_PROVIDER_PACKAGE_PREFIX = "@wildo-ai/provider-";
37
+ /**
38
+ * The framework's own scraped catalogue, admitted by exact NAME because it does not fit the prefix.
39
+ *
40
+ * Paul decided on 2026-09-06 that the transposed catalogue ships as ONE package with a subpath per
41
+ * vendor — `@wildo-ai/providers/slack` — rather than as 697 packages. The prefix above predates that
42
+ * decision and describes the shape it replaced, and `'@wildo-ai/providers'.startsWith('@wildo-ai/provider-')`
43
+ * is **false**: the `s` is not a `-`.
44
+ *
45
+ * So discovery could not see the catalogue at all. What it DID admit, measured 2026-09-07, was
46
+ * `@wildo-ai/provider-simulators` — the test doubles — and nothing else in the repository matches the
47
+ * prefix. A rule that admits only the simulator of a thing is worse than no rule, because it looks
48
+ * like coverage.
49
+ *
50
+ * An exact name rather than a loosened prefix (`@wildo-ai/provider`, no hyphen) on purpose: that
51
+ * would also admit any future `@wildo-ai/providerfoo`, and the catalogue is ONE known package, not a
52
+ * family. The prefix keeps serving the family it was written for — an application's own
53
+ * `@acme/provider-thing`.
54
+ */
55
+ export declare const FRAMEWORK_PROVIDER_CATALOGUE_PACKAGE = "@wildo-ai/providers";
4
56
  interface ProviderContributionOwner {
5
57
  kind: ProviderContributionOwnerKind;
6
58
  key: string;
@@ -16,6 +68,27 @@ export declare function discoverSaasProviderCompanionContributions(input: {
16
68
  saasRoot: string;
17
69
  saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>;
18
70
  }): Promise<DiscoverSaasProviderCompanionContributionsResult>;
71
+ /**
72
+ * Walk an application's provider contributions and VALIDATE them — one step, because the two must
73
+ * never come apart (#334).
74
+ *
75
+ * The walk was already shared; what was duplicated is the PAIRING. `wildo config sync` and
76
+ * `wildo lock check` each called the walker and then, separately, the validator — and the validator
77
+ * sits outside the walker, so a consumer that forgot it would compute a lockfile section from
78
+ * contributions nobody had checked against the authored scope. Three correct call sites with nothing
79
+ * making a fourth correct is the shape `.claude/rules/invariant-call-site-enumeration.md` is about.
80
+ *
81
+ * The caller still LOADS the config. That is deliberate rather than an omission: loading is one line
82
+ * each caller already owns with its own error handling, it is not the part that can silently come
83
+ * apart, and folding it in here would put the load behind a seam that the sync service's own tests
84
+ * mock — `loadSaasConfig` mocked as a module export is not seen by a caller INSIDE this module, so
85
+ * those tests would have had to mock this function instead and would then no longer exercise the real
86
+ * discovery and the real validation they exist to check.
87
+ */
88
+ export declare function resolveValidatedSaasProviderContributions(input: {
89
+ saasRoot: string;
90
+ saasConfig: Pick<WildoSaasConfig, 'modules' | 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>;
91
+ }): Promise<DiscoveredProviderCompanionContribution[]>;
19
92
  export declare function validateDiscoveredSaasProviderContributions(input: {
20
93
  saasConfig: Pick<WildoSaasConfig, 'modules' | 'providers' | 'services' | 'minions' | 'workers'>;
21
94
  discoveredContributions: DiscoveredProviderCompanionContribution[];
@@ -1 +1 @@
1
- {"version":3,"file":"provider-companion-discovery.d.ts","sourceRoot":"","sources":["../../../../src/project-config/provider-companion-discovery.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,6BAA6B,EAGnC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,KAAK,6BAA6B,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjF,UAAU,yBAAyB;IACjC,IAAI,EAAE,6BAA6B,CAAC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;CACrB;AAMD,MAAM,WAAW,uCAAwC,SAAQ,6BAA6B;IAC5F,KAAK,EAAE,yBAAyB,CAAC;CAClC;AAED,MAAM,WAAW,gDAAgD;IAC/D,aAAa,EAAE,uCAAuC,EAAE,CAAC;CAC1D;AAED,wBAAsB,0CAA0C,CAAC,KAAK,EAAE;IACtE,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC,CAAC;CACnG,GAAG,OAAO,CAAC,gDAAgD,CAAC,CA0B5D;AAED,wBAAgB,2CAA2C,CAAC,KAAK,EAAE;IACjE,UAAU,EAAE,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC;IAChG,uBAAuB,EAAE,uCAAuC,EAAE,CAAC;CACpE,GAAG,IAAI,CAmIP"}
1
+ {"version":3,"file":"provider-companion-discovery.d.ts","sourceRoot":"","sources":["../../../../src/project-config/provider-companion-discovery.ts"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C,EAAE,CAAC,CAOrD;AAED,wBAAgB,2CAA2C,CAAC,KAAK,EAAE;IACjE,UAAU,EAAE,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC;IAChG,uBAAuB,EAAE,uCAAuC,EAAE,CAAC;CACpE,GAAG,IAAI,CAmIP"}
@@ -1,10 +1,69 @@
1
+ import { createRequire } from 'node:module';
1
2
  import { existsSync, readFileSync } from 'node:fs';
2
- import { join, resolve } from 'node:path';
3
+ import { dirname, join, resolve } from 'node:path';
3
4
  import { ProviderCompanionContributionSchema, } from '@wildo-ai/saas-models';
4
5
  import { loadPackageCompanionExport, resolvePackageCompanionEntryPath } from './loader.js';
6
+ /**
7
+ * `providerPackage` was added by #330 and is the point of that slice on this file.
8
+ *
9
+ * The other four owner kinds are RUNTIME OWNERS declared in `wildo.saas.config.ts` — an application's
10
+ * own services, libraries, minions and workers. Walking only those is what made a provider shipped as
11
+ * its own npm package invisible to discovery (audit finding PL-1): the package is a DEPENDENCY, not a
12
+ * runtime owner, so nothing ever asked it what it contributes, and an application had to hand-author a
13
+ * contribution for a provider whose own package already knew everything about it.
14
+ */
15
+ export var ProviderContributionOwnerKind;
16
+ (function (ProviderContributionOwnerKind) {
17
+ /** A service package declared in `wildo.saas.config.ts` — the application's backend or a frontend. */
18
+ ProviderContributionOwnerKind["SERVICE"] = "service";
19
+ /** A shared library package of the application. */
20
+ ProviderContributionOwnerKind["LIBRARY"] = "library";
21
+ /** A minion runtime, keyed by its minion name. */
22
+ ProviderContributionOwnerKind["MINION"] = "minion";
23
+ /** A Node worker runtime, keyed by its worker name. */
24
+ ProviderContributionOwnerKind["WORKER"] = "worker";
25
+ /**
26
+ * A provider shipped as its own npm package (#330) — a DEPENDENCY rather than a runtime owner,
27
+ * which is why it needed its own walk and its own member. The value stays camelCase because it is
28
+ * substituted into operator-facing diagnostics beside the four above.
29
+ */
30
+ ProviderContributionOwnerKind["PROVIDER_PACKAGE"] = "providerPackage";
31
+ })(ProviderContributionOwnerKind || (ProviderContributionOwnerKind = {}));
32
+ /**
33
+ * Package-name prefixes whose dependencies are treated as provider packages.
34
+ *
35
+ * `@wildo-ai/provider-` is the framework convention (#337 D3). An application's OWN provider packages
36
+ * are admitted through the scope of its root manifest — an application published as `@acme/…` gets
37
+ * `@acme/provider-…` for free — so a private provider needs no configuration to be discovered, and a
38
+ * dependency belonging to somebody else's scope is never executed by this walk.
39
+ */
40
+ export const FRAMEWORK_PROVIDER_PACKAGE_PREFIX = '@wildo-ai/provider-';
41
+ /**
42
+ * The framework's own scraped catalogue, admitted by exact NAME because it does not fit the prefix.
43
+ *
44
+ * Paul decided on 2026-09-06 that the transposed catalogue ships as ONE package with a subpath per
45
+ * vendor — `@wildo-ai/providers/slack` — rather than as 697 packages. The prefix above predates that
46
+ * decision and describes the shape it replaced, and `'@wildo-ai/providers'.startsWith('@wildo-ai/provider-')`
47
+ * is **false**: the `s` is not a `-`.
48
+ *
49
+ * So discovery could not see the catalogue at all. What it DID admit, measured 2026-09-07, was
50
+ * `@wildo-ai/provider-simulators` — the test doubles — and nothing else in the repository matches the
51
+ * prefix. A rule that admits only the simulator of a thing is worse than no rule, because it looks
52
+ * like coverage.
53
+ *
54
+ * An exact name rather than a loosened prefix (`@wildo-ai/provider`, no hyphen) on purpose: that
55
+ * would also admit any future `@wildo-ai/providerfoo`, and the catalogue is ONE known package, not a
56
+ * family. The prefix keeps serving the family it was written for — an application's own
57
+ * `@acme/provider-thing`.
58
+ */
59
+ export const FRAMEWORK_PROVIDER_CATALOGUE_PACKAGE = '@wildo-ai/providers';
5
60
  export async function discoverSaasProviderCompanionContributions(input) {
6
61
  const contributions = [];
7
- for (const target of resolveContributionTargets(input.saasRoot, input.saasConfig)) {
62
+ const runtimeOwnerTargets = resolveContributionTargets(input.saasRoot, input.saasConfig);
63
+ for (const target of [
64
+ ...runtimeOwnerTargets,
65
+ ...resolveProviderPackageTargets(input.saasRoot, runtimeOwnerTargets),
66
+ ]) {
8
67
  const companionExports = await tryLoadRuntimeOwnerCompanionExports(target.packageRoot);
9
68
  if (!companionExports) {
10
69
  continue;
@@ -21,6 +80,31 @@ export async function discoverSaasProviderCompanionContributions(input) {
21
80
  }
22
81
  return { contributions };
23
82
  }
83
+ /**
84
+ * Walk an application's provider contributions and VALIDATE them — one step, because the two must
85
+ * never come apart (#334).
86
+ *
87
+ * The walk was already shared; what was duplicated is the PAIRING. `wildo config sync` and
88
+ * `wildo lock check` each called the walker and then, separately, the validator — and the validator
89
+ * sits outside the walker, so a consumer that forgot it would compute a lockfile section from
90
+ * contributions nobody had checked against the authored scope. Three correct call sites with nothing
91
+ * making a fourth correct is the shape `.claude/rules/invariant-call-site-enumeration.md` is about.
92
+ *
93
+ * The caller still LOADS the config. That is deliberate rather than an omission: loading is one line
94
+ * each caller already owns with its own error handling, it is not the part that can silently come
95
+ * apart, and folding it in here would put the load behind a seam that the sync service's own tests
96
+ * mock — `loadSaasConfig` mocked as a module export is not seen by a caller INSIDE this module, so
97
+ * those tests would have had to mock this function instead and would then no longer exercise the real
98
+ * discovery and the real validation they exist to check.
99
+ */
100
+ export async function resolveValidatedSaasProviderContributions(input) {
101
+ const { contributions } = await discoverSaasProviderCompanionContributions(input);
102
+ validateDiscoveredSaasProviderContributions({
103
+ saasConfig: input.saasConfig,
104
+ discoveredContributions: contributions,
105
+ });
106
+ return contributions;
107
+ }
24
108
  export function validateDiscoveredSaasProviderContributions(input) {
25
109
  const { saasConfig, discoveredContributions } = input;
26
110
  const errors = [];
@@ -145,13 +229,13 @@ function resolveContributionTargets(saasRoot, saasConfig) {
145
229
  ? frontendServiceProviderScopes.includes(key)
146
230
  : shouldIncludeBackendServices))
147
231
  .map(([key, definition]) => ({
148
- kind: 'service',
232
+ kind: ProviderContributionOwnerKind.SERVICE,
149
233
  key,
150
234
  ownerLabel: `service "${key}"`,
151
235
  packageRoot: resolve(saasRoot, definition.path),
152
236
  })),
153
237
  ...Object.entries(saasConfig.libraries ?? {}).map(([key, definition]) => ({
154
- kind: 'library',
238
+ kind: ProviderContributionOwnerKind.LIBRARY,
155
239
  key,
156
240
  ownerLabel: `library "${key}"`,
157
241
  packageRoot: resolve(saasRoot, definition.path),
@@ -159,7 +243,7 @@ function resolveContributionTargets(saasRoot, saasConfig) {
159
243
  ...Object.entries(saasConfig.minions ?? {})
160
244
  .filter(([key]) => minionProviderScopes.includes(key))
161
245
  .map(([key, definition]) => ({
162
- kind: 'minion',
246
+ kind: ProviderContributionOwnerKind.MINION,
163
247
  key,
164
248
  ownerLabel: `minion "${key}"`,
165
249
  packageRoot: resolve(saasRoot, definition.path),
@@ -167,13 +251,126 @@ function resolveContributionTargets(saasRoot, saasConfig) {
167
251
  ...Object.entries(saasConfig.workers ?? {})
168
252
  .filter(([key]) => workerProviderScopes.includes(key))
169
253
  .map(([key, definition]) => ({
170
- kind: 'worker',
254
+ kind: ProviderContributionOwnerKind.WORKER,
171
255
  key,
172
256
  ownerLabel: `worker "${key}"`,
173
257
  packageRoot: resolve(saasRoot, definition.path),
174
258
  })),
175
259
  ];
176
260
  }
261
+ /**
262
+ * Every provider PACKAGE this application depends on, as a contribution target.
263
+ *
264
+ * Candidates come from the application root manifest AND from each runtime owner's manifest, because
265
+ * both layouts are real: a scaffolded application declares its provider packages in the runtime owner
266
+ * that imports them (`backend-api`), while a workspace root may hoist them. The union is deduplicated
267
+ * by resolved package root, so a package declared in both places is walked once.
268
+ *
269
+ * A candidate that cannot be resolved on disk is SKIPPED rather than refused. The manifest is the
270
+ * declaration and `node_modules` is the install; a name declared but not installed is an install
271
+ * problem that `pnpm install` reports far better than a config-sync stack trace would, and refusing
272
+ * here would make `wildo config sync` unrunnable in exactly the state where an operator runs it to
273
+ * find out what is wrong.
274
+ */
275
+ function resolveProviderPackageTargets(saasRoot, runtimeOwnerTargets) {
276
+ const prefixes = resolveProviderPackagePrefixes(saasRoot);
277
+ const searchRoots = [saasRoot, ...runtimeOwnerTargets.map((target) => target.packageRoot)];
278
+ const candidateNames = new Set();
279
+ for (const searchRoot of searchRoots) {
280
+ for (const dependencyName of readRuntimeReachablePackageNames(searchRoot)) {
281
+ if (dependencyName === FRAMEWORK_PROVIDER_CATALOGUE_PACKAGE || prefixes.some((prefix) => dependencyName.startsWith(prefix))) {
282
+ candidateNames.add(dependencyName);
283
+ }
284
+ }
285
+ }
286
+ const targetsByRoot = new Map();
287
+ for (const packageName of [...candidateNames].sort()) {
288
+ const packageRoot = resolveProviderPackageRoot(packageName, searchRoots);
289
+ if (!packageRoot || targetsByRoot.has(packageRoot)) {
290
+ continue;
291
+ }
292
+ targetsByRoot.set(packageRoot, {
293
+ kind: ProviderContributionOwnerKind.PROVIDER_PACKAGE,
294
+ key: packageName,
295
+ ownerLabel: `provider package "${packageName}"`,
296
+ packageRoot,
297
+ });
298
+ }
299
+ return [...targetsByRoot.values()];
300
+ }
301
+ /**
302
+ * The framework prefix, plus the application's own scope when its root manifest has one.
303
+ *
304
+ * Deriving the second from the root package name rather than reading it from configuration keeps the
305
+ * "one declaration" promise of #330 intact: installing `@acme/provider-thing` in an `@acme` application
306
+ * and scoping the ref is the whole of it — there is no third place to remember.
307
+ */
308
+ function resolveProviderPackagePrefixes(saasRoot) {
309
+ const prefixes = [FRAMEWORK_PROVIDER_PACKAGE_PREFIX];
310
+ const rootPackageName = readPackageName(saasRoot);
311
+ const scope = rootPackageName?.startsWith('@') ? rootPackageName.split('/')[0] : undefined;
312
+ if (scope && scope !== '@wildo-ai') {
313
+ prefixes.push(`${scope}/provider-`);
314
+ }
315
+ return prefixes;
316
+ }
317
+ /**
318
+ * Locate an installed package's ROOT DIRECTORY, which is what the companion-entry resolver needs.
319
+ *
320
+ * The direct `node_modules` probe comes first because it is what pnpm actually produces — a symlink
321
+ * per importer — and because it works for a package whose `exports` map declares no `./package.json`,
322
+ * which `require.resolve` cannot see past. `createRequire` is the fallback for hoisted or otherwise
323
+ * unusual layouts; it resolves the companion subpath (the one door every provider package declares)
324
+ * and walks up to the manifest that names the package.
325
+ */
326
+ function resolveProviderPackageRoot(packageName, searchRoots) {
327
+ /*
328
+ * The name comes from a manifest and is spliced into a filesystem path, so a segment that is `.` or
329
+ * `..` would walk OUT of `node_modules` — and the prefix gate would not stop it, since
330
+ * `@wildo-ai/provider-x/../../elsewhere` starts with the framework prefix. npm forbids such a name,
331
+ * which is precisely why nothing downstream would question it; the check costs one line and is the
332
+ * only thing standing between an authored dependency name and an arbitrary directory whose
333
+ * companion entry this walk EXECUTES.
334
+ */
335
+ const segments = packageName.split('/');
336
+ if (segments.some((segment) => segment.length === 0 || segment === '.' || segment === '..')) {
337
+ return undefined;
338
+ }
339
+ for (const searchRoot of searchRoots) {
340
+ const candidate = join(searchRoot, 'node_modules', ...segments);
341
+ if (existsSync(join(candidate, 'package.json'))) {
342
+ return candidate;
343
+ }
344
+ }
345
+ for (const searchRoot of searchRoots) {
346
+ try {
347
+ const resolved = createRequire(join(searchRoot, 'package.json')).resolve(`${packageName}/companion`);
348
+ let directory = dirname(resolved);
349
+ while (directory !== dirname(directory)) {
350
+ if (readPackageName(directory) === packageName) {
351
+ return directory;
352
+ }
353
+ directory = dirname(directory);
354
+ }
355
+ }
356
+ catch {
357
+ // Not resolvable from this root; try the next one, then give up quietly (see the JSDoc above).
358
+ }
359
+ }
360
+ return undefined;
361
+ }
362
+ function readPackageName(packageRoot) {
363
+ const packageJsonPath = join(packageRoot, 'package.json');
364
+ if (!existsSync(packageJsonPath)) {
365
+ return undefined;
366
+ }
367
+ try {
368
+ return JSON.parse(readFileSync(packageJsonPath, 'utf-8')).name;
369
+ }
370
+ catch {
371
+ return undefined;
372
+ }
373
+ }
177
374
  async function tryLoadRuntimeOwnerCompanionExports(packageRoot) {
178
375
  try {
179
376
  resolvePackageCompanionEntryPath(packageRoot);
@@ -1 +1 @@
1
- {"version":3,"file":"provider-companion-discovery.js","sourceRoot":"","sources":["../../../../src/project-config/provider-companion-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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{ join, resolve } from 'node:path';\nimport {\n ProviderCompanionContributionSchema,\n type ProviderCompanionContribution,\n type ProviderCompanionRuntimeTarget,\n type RuntimeOwnerCompanionExports,\n} from '@wildo-ai/saas-models';\nimport type { WildoSaasConfig } from './define-saas-config';\nimport { loadPackageCompanionExport, resolvePackageCompanionEntryPath } from './loader';\n\ntype ProviderContributionOwnerKind = 'service' | 'library' | 'minion' | 'worker';\n\ninterface ProviderContributionOwner {\n kind: ProviderContributionOwnerKind;\n key: string;\n packageRoot: string;\n}\n\ninterface ProviderContributionTarget extends ProviderContributionOwner {\n ownerLabel: string;\n}\n\nexport interface DiscoveredProviderCompanionContribution extends ProviderCompanionContribution {\n owner: ProviderContributionOwner;\n}\n\nexport interface DiscoverSaasProviderCompanionContributionsResult {\n contributions: DiscoveredProviderCompanionContribution[];\n}\n\nexport async function discoverSaasProviderCompanionContributions(input: {\n saasRoot: string;\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>;\n}): Promise<DiscoverSaasProviderCompanionContributionsResult> {\n const contributions: DiscoveredProviderCompanionContribution[] = [];\n\n for (const target of resolveContributionTargets(input.saasRoot, input.saasConfig)) {\n const companionExports = await tryLoadRuntimeOwnerCompanionExports(target.packageRoot);\n if (!companionExports) {\n continue;\n }\n\n const parsedContributions = ProviderCompanionContributionSchema.array().parse(\n companionExports.providerContributions ?? [],\n );\n\n contributions.push(\n ...parsedContributions.map((contribution) => ({\n ...contribution,\n owner: {\n kind: target.kind,\n key: target.key,\n packageRoot: target.packageRoot,\n },\n })),\n );\n }\n\n return { contributions };\n}\n\nexport function validateDiscoveredSaasProviderContributions(input: {\n saasConfig: Pick<WildoSaasConfig, 'modules' | 'providers' | 'services' | 'minions' | 'workers'>;\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n}): void {\n const { saasConfig, discoveredContributions } = input;\n const errors: string[] = [];\n const declaredModuleIds = new Set(Object.keys(saasConfig.modules ?? {}));\n const declaredServiceKeys = new Set(Object.keys(saasConfig.services ?? {}));\n const serviceKeyToFrontendType = new Map<string, string>(\n Object.entries(saasConfig.services ?? {})\n .filter(([, definition]) => definition.frontendType !== undefined)\n .map(([serviceKey, definition]) => [serviceKey, definition.frontendType as string]),\n );\n const declaredFrontendServiceKeys = new Set(serviceKeyToFrontendType.keys());\n const declaredFrontendTypes = new Set(serviceKeyToFrontendType.values());\n const declaredMinionKeys = new Set(Object.keys(saasConfig.minions ?? {}));\n const declaredWorkerKeys = new Set(Object.keys(saasConfig.workers ?? {}));\n\n for (const contribution of discoveredContributions) {\n if (contribution.sourceModuleId && !declaredModuleIds.has(contribution.sourceModuleId)) {\n errors.push(\n `${describeContribution(contribution)} references sourceModuleId \"${contribution.sourceModuleId}\" ` +\n 'but that module is not declared in wildo.saas.config.ts.',\n );\n }\n\n const dependencyNames = readRuntimeReachablePackageNames(contribution.owner.packageRoot);\n const runtimePackageName = extractPackageName(contribution.runtimeImportPath);\n if (!dependencyNames.has(runtimePackageName)) {\n errors.push(\n `${describeContribution(contribution)} declares runtimeImportPath \"${contribution.runtimeImportPath}\" ` +\n `but ${contribution.owner.kind} \"${contribution.owner.key}\" does not depend on \"${runtimePackageName}\".`,\n );\n }\n\n for (const target of contribution.runtimeTargets) {\n switch (target.kind) {\n case 'frontendService':\n if (!declaredFrontendTypes.has(target.serviceType)) {\n errors.push(\n `${describeContribution(contribution)} targets frontendType \"${target.serviceType}\" ` +\n 'but no service with that frontendType is declared in wildo.saas.config.ts.',\n );\n } else if (!contribution.frontendEntry) {\n errors.push(\n `${describeContribution(contribution)} targets frontendType \"${target.serviceType}\" ` +\n 'but does not provide a frontendEntry payload for bootstrap materialization.',\n );\n }\n break;\n case 'minion':\n if (!declaredMinionKeys.has(target.minionKey)) {\n errors.push(\n `${describeContribution(contribution)} targets unknown minion \"${target.minionKey}\".`,\n );\n }\n break;\n case 'worker':\n if (!declaredWorkerKeys.has(target.workerKey)) {\n errors.push(\n `${describeContribution(contribution)} targets unknown worker \"${target.workerKey}\".`,\n );\n }\n break;\n case 'backend':\n case 'companion':\n break;\n }\n }\n }\n\n const runtimeScopes = saasConfig.providers.scopes;\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: 'backend',\n providers: runtimeScopes.backend?.providers ?? {},\n matchesTarget: (target) => target.kind === 'backend',\n });\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: 'companion',\n providers: runtimeScopes.companion?.providers ?? {},\n matchesTarget: (target) => target.kind === 'companion',\n });\n\n for (const [serviceKey, scope] of Object.entries(runtimeScopes.frontendServices ?? {})) {\n if (!declaredServiceKeys.has(serviceKey)) {\n errors.push(`Provider scope references unknown frontend service \"${serviceKey}\".`);\n continue;\n }\n if (!declaredFrontendServiceKeys.has(serviceKey)) {\n errors.push(\n `Provider scope references non-frontend service \"${serviceKey}\". ` +\n 'Only services with a frontendType may appear under providers.scopes.frontendServices.',\n );\n continue;\n }\n const serviceType = serviceKeyToFrontendType.get(serviceKey);\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `frontendServices.${serviceKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'frontendService' && target.serviceType === serviceType,\n });\n }\n\n for (const [minionKey, scope] of Object.entries(runtimeScopes.minions ?? {})) {\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `minions.${minionKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'minion' && target.minionKey === minionKey,\n });\n }\n\n for (const [workerKey, scope] of Object.entries(runtimeScopes.workers ?? {})) {\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `workers.${workerKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'worker' && target.workerKey === workerKey,\n });\n }\n\n if (errors.length > 0) {\n throw new Error(\n `Provider companion-export discovery validation failed:\\n- ${errors.join('\\n- ')}`,\n );\n }\n}\n\nfunction resolveContributionTargets(\n saasRoot: string,\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>,\n): ProviderContributionTarget[] {\n const shouldIncludeBackendServices = hasAnyProviders(saasConfig.providers.scopes.backend?.providers);\n const frontendServiceProviderScopes = Object.entries(saasConfig.providers.scopes.frontendServices ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([serviceKey]) => serviceKey);\n const minionProviderScopes = Object.entries(saasConfig.providers.scopes.minions ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([minionKey]) => minionKey);\n const workerProviderScopes = Object.entries(saasConfig.providers.scopes.workers ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([workerKey]) => workerKey);\n\n return [\n ...Object.entries(saasConfig.services)\n .filter(([key, definition]) => (\n definition.frontendType\n ? frontendServiceProviderScopes.includes(key)\n : shouldIncludeBackendServices\n ))\n .map(([key, definition]) => ({\n kind: 'service' as const,\n key,\n ownerLabel: `service \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.libraries ?? {}).map(([key, definition]) => ({\n kind: 'library' as const,\n key,\n ownerLabel: `library \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.minions ?? {})\n .filter(([key]) => minionProviderScopes.includes(key))\n .map(([key, definition]) => ({\n kind: 'minion' as const,\n key,\n ownerLabel: `minion \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.workers ?? {})\n .filter(([key]) => workerProviderScopes.includes(key))\n .map(([key, definition]) => ({\n kind: 'worker' as const,\n key,\n ownerLabel: `worker \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ];\n}\n\nasync function tryLoadRuntimeOwnerCompanionExports(\n packageRoot: string,\n): Promise<RuntimeOwnerCompanionExports | undefined> {\n try {\n resolvePackageCompanionEntryPath(packageRoot);\n } catch {\n return undefined;\n }\n\n return loadPackageCompanionExport<RuntimeOwnerCompanionExports>(packageRoot);\n}\n\nfunction validateRuntimeScopeAgainstDiscovery(input: {\n errors: string[];\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n scopeLabel: string;\n providers: NonNullable<WildoSaasConfig['providers']['scopes']['backend']>['providers'];\n matchesTarget: (target: ProviderCompanionRuntimeTarget) => boolean;\n}): void {\n const { errors, discoveredContributions, matchesTarget, providers, scopeLabel } = input;\n\n for (const [providerRef, authoredSelection] of Object.entries(providers)) {\n const matchingContributions = discoveredContributions.filter(\n (contribution) => contribution.ref === providerRef\n && contribution.runtimeTargets.some(matchesTarget),\n );\n\n if (matchingContributions.length === 0) {\n errors.push(\n `Provider \"${providerRef}\" is authored in scope \"${scopeLabel}\" but no companion export contributes it for that runtime.`,\n );\n continue;\n }\n\n const discoveredEngineCapabilities = new Set(\n matchingContributions.flatMap((contribution) => contribution.engineCapabilities),\n );\n const discoveredProviderCapabilities = new Set(\n matchingContributions.flatMap((contribution) => contribution.providerCapabilities),\n );\n const discoveredProtocols = new Set(\n matchingContributions.flatMap((contribution) => contribution.protocols),\n );\n\n for (const capability of authoredSelection.engineCapabilities) {\n if (!discoveredEngineCapabilities.has(capability)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares engine capability \"${capability}\" ` +\n 'but discovery does not report that capability for the same runtime.',\n );\n }\n }\n\n for (const capability of authoredSelection.providerCapabilities) {\n if (!discoveredProviderCapabilities.has(capability)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares provider capability \"${capability}\" ` +\n 'but discovery does not report that capability for the same runtime.',\n );\n }\n }\n\n for (const protocol of authoredSelection.protocols) {\n if (!discoveredProtocols.has(protocol)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares protocol \"${protocol}\" ` +\n 'but discovery does not report that protocol for the same runtime.',\n );\n }\n }\n }\n}\n\nfunction describeContribution(contribution: DiscoveredProviderCompanionContribution): string {\n return `Provider contribution \"${contribution.ref}\" from ${contribution.owner.kind} \"${contribution.owner.key}\"`;\n}\n\nfunction readRuntimeReachablePackageNames(packageRoot: string): Set<string> {\n const packageJsonPath = join(packageRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return new Set<string>();\n }\n\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {\n name?: string;\n dependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n optionalDependencies?: Record<string, string>;\n };\n\n return new Set([\n ...(packageJson.name ? [packageJson.name] : []),\n ...Object.keys(packageJson.dependencies ?? {}),\n ...Object.keys(packageJson.peerDependencies ?? {}),\n ...Object.keys(packageJson.optionalDependencies ?? {}),\n ]);\n}\n\nfunction extractPackageName(importPath: string): string {\n if (importPath.startsWith('@')) {\n const [scope, pkg] = importPath.split('/');\n return `${scope}/${pkg}`;\n }\n return importPath.split('/')[0] ?? importPath;\n}\n\nfunction hasAnyProviders(\n providers: Record<string, unknown> | undefined,\n): boolean {\n return Boolean(providers && Object.keys(providers).length > 0);\n}\n"]}
1
+ {"version":3,"file":"provider-companion-discovery.js","sourceRoot":"","sources":["../../../../src/project-config/provider-companion-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,mCAAmC,GAIpC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,0BAA0B,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAExF;;;;;;;;GAQG;AACH,MAAM,CAAN,IAAY,6BAeX;AAfD,WAAY,6BAA6B;IACvC,sGAAsG;IACtG,oDAAmB,CAAA;IACnB,mDAAmD;IACnD,oDAAmB,CAAA;IACnB,kDAAkD;IAClD,kDAAiB,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AAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { createRequire } from 'node:module';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport {\n ProviderCompanionContributionSchema,\n type ProviderCompanionContribution,\n type ProviderCompanionRuntimeTarget,\n type RuntimeOwnerCompanionExports,\n} from '@wildo-ai/saas-models';\nimport type { WildoSaasConfig } from './define-saas-config';\nimport { loadPackageCompanionExport, resolvePackageCompanionEntryPath } from './loader';\n\n/**\n * `providerPackage` was added by #330 and is the point of that slice on this file.\n *\n * The other four owner kinds are RUNTIME OWNERS declared in `wildo.saas.config.ts` — an application's\n * own services, libraries, minions and workers. Walking only those is what made a provider shipped as\n * its own npm package invisible to discovery (audit finding PL-1): the package is a DEPENDENCY, not a\n * runtime owner, so nothing ever asked it what it contributes, and an application had to hand-author a\n * contribution for a provider whose own package already knew everything about it.\n */\nexport enum ProviderContributionOwnerKind {\n /** A service package declared in `wildo.saas.config.ts` — the application's backend or a frontend. */\n SERVICE = 'service',\n /** A shared library package of the application. */\n LIBRARY = 'library',\n /** A minion runtime, keyed by its minion name. */\n MINION = 'minion',\n /** A Node worker runtime, keyed by its worker name. */\n WORKER = 'worker',\n /**\n * A provider shipped as its own npm package (#330) — a DEPENDENCY rather than a runtime owner,\n * which is why it needed its own walk and its own member. The value stays camelCase because it is\n * substituted into operator-facing diagnostics beside the four above.\n */\n PROVIDER_PACKAGE = 'providerPackage',\n}\n\n/**\n * Package-name prefixes whose dependencies are treated as provider packages.\n *\n * `@wildo-ai/provider-` is the framework convention (#337 D3). An application's OWN provider packages\n * are admitted through the scope of its root manifest — an application published as `@acme/…` gets\n * `@acme/provider-…` for free — so a private provider needs no configuration to be discovered, and a\n * dependency belonging to somebody else's scope is never executed by this walk.\n */\nexport const FRAMEWORK_PROVIDER_PACKAGE_PREFIX = '@wildo-ai/provider-';\n\n/**\n * The framework's own scraped catalogue, admitted by exact NAME because it does not fit the prefix.\n *\n * Paul decided on 2026-09-06 that the transposed catalogue ships as ONE package with a subpath per\n * vendor — `@wildo-ai/providers/slack` — rather than as 697 packages. The prefix above predates that\n * decision and describes the shape it replaced, and `'@wildo-ai/providers'.startsWith('@wildo-ai/provider-')`\n * is **false**: the `s` is not a `-`.\n *\n * So discovery could not see the catalogue at all. What it DID admit, measured 2026-09-07, was\n * `@wildo-ai/provider-simulators` — the test doubles — and nothing else in the repository matches the\n * prefix. A rule that admits only the simulator of a thing is worse than no rule, because it looks\n * like coverage.\n *\n * An exact name rather than a loosened prefix (`@wildo-ai/provider`, no hyphen) on purpose: that\n * would also admit any future `@wildo-ai/providerfoo`, and the catalogue is ONE known package, not a\n * family. The prefix keeps serving the family it was written for — an application's own\n * `@acme/provider-thing`.\n */\nexport const FRAMEWORK_PROVIDER_CATALOGUE_PACKAGE = '@wildo-ai/providers';\n\ninterface ProviderContributionOwner {\n kind: ProviderContributionOwnerKind;\n key: string;\n packageRoot: string;\n}\n\ninterface ProviderContributionTarget extends ProviderContributionOwner {\n ownerLabel: string;\n}\n\nexport interface DiscoveredProviderCompanionContribution extends ProviderCompanionContribution {\n owner: ProviderContributionOwner;\n}\n\nexport interface DiscoverSaasProviderCompanionContributionsResult {\n contributions: DiscoveredProviderCompanionContribution[];\n}\n\nexport async function discoverSaasProviderCompanionContributions(input: {\n saasRoot: string;\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>;\n}): Promise<DiscoverSaasProviderCompanionContributionsResult> {\n const contributions: DiscoveredProviderCompanionContribution[] = [];\n\n const runtimeOwnerTargets = resolveContributionTargets(input.saasRoot, input.saasConfig);\n\n for (const target of [\n ...runtimeOwnerTargets,\n ...resolveProviderPackageTargets(input.saasRoot, runtimeOwnerTargets),\n ]) {\n const companionExports = await tryLoadRuntimeOwnerCompanionExports(target.packageRoot);\n if (!companionExports) {\n continue;\n }\n\n const parsedContributions = ProviderCompanionContributionSchema.array().parse(\n companionExports.providerContributions ?? [],\n );\n\n contributions.push(\n ...parsedContributions.map((contribution) => ({\n ...contribution,\n owner: {\n kind: target.kind,\n key: target.key,\n packageRoot: target.packageRoot,\n },\n })),\n );\n }\n\n return { contributions };\n}\n\n/**\n * Walk an application's provider contributions and VALIDATE them — one step, because the two must\n * never come apart (#334).\n *\n * The walk was already shared; what was duplicated is the PAIRING. `wildo config sync` and\n * `wildo lock check` each called the walker and then, separately, the validator — and the validator\n * sits outside the walker, so a consumer that forgot it would compute a lockfile section from\n * contributions nobody had checked against the authored scope. Three correct call sites with nothing\n * making a fourth correct is the shape `.claude/rules/invariant-call-site-enumeration.md` is about.\n *\n * The caller still LOADS the config. That is deliberate rather than an omission: loading is one line\n * each caller already owns with its own error handling, it is not the part that can silently come\n * apart, and folding it in here would put the load behind a seam that the sync service's own tests\n * mock — `loadSaasConfig` mocked as a module export is not seen by a caller INSIDE this module, so\n * those tests would have had to mock this function instead and would then no longer exercise the real\n * discovery and the real validation they exist to check.\n */\nexport async function resolveValidatedSaasProviderContributions(input: {\n saasRoot: string;\n saasConfig: Pick<WildoSaasConfig, 'modules' | 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>;\n}): Promise<DiscoveredProviderCompanionContribution[]> {\n const { contributions } = await discoverSaasProviderCompanionContributions(input);\n validateDiscoveredSaasProviderContributions({\n saasConfig: input.saasConfig,\n discoveredContributions: contributions,\n });\n return contributions;\n}\n\nexport function validateDiscoveredSaasProviderContributions(input: {\n saasConfig: Pick<WildoSaasConfig, 'modules' | 'providers' | 'services' | 'minions' | 'workers'>;\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n}): void {\n const { saasConfig, discoveredContributions } = input;\n const errors: string[] = [];\n const declaredModuleIds = new Set(Object.keys(saasConfig.modules ?? {}));\n const declaredServiceKeys = new Set(Object.keys(saasConfig.services ?? {}));\n const serviceKeyToFrontendType = new Map<string, string>(\n Object.entries(saasConfig.services ?? {})\n .filter(([, definition]) => definition.frontendType !== undefined)\n .map(([serviceKey, definition]) => [serviceKey, definition.frontendType as string]),\n );\n const declaredFrontendServiceKeys = new Set(serviceKeyToFrontendType.keys());\n const declaredFrontendTypes = new Set(serviceKeyToFrontendType.values());\n const declaredMinionKeys = new Set(Object.keys(saasConfig.minions ?? {}));\n const declaredWorkerKeys = new Set(Object.keys(saasConfig.workers ?? {}));\n\n for (const contribution of discoveredContributions) {\n if (contribution.sourceModuleId && !declaredModuleIds.has(contribution.sourceModuleId)) {\n errors.push(\n `${describeContribution(contribution)} references sourceModuleId \"${contribution.sourceModuleId}\" ` +\n 'but that module is not declared in wildo.saas.config.ts.',\n );\n }\n\n const dependencyNames = readRuntimeReachablePackageNames(contribution.owner.packageRoot);\n const runtimePackageName = extractPackageName(contribution.runtimeImportPath);\n if (!dependencyNames.has(runtimePackageName)) {\n errors.push(\n `${describeContribution(contribution)} declares runtimeImportPath \"${contribution.runtimeImportPath}\" ` +\n `but ${contribution.owner.kind} \"${contribution.owner.key}\" does not depend on \"${runtimePackageName}\".`,\n );\n }\n\n for (const target of contribution.runtimeTargets) {\n switch (target.kind) {\n case 'frontendService':\n if (!declaredFrontendTypes.has(target.serviceType)) {\n errors.push(\n `${describeContribution(contribution)} targets frontendType \"${target.serviceType}\" ` +\n 'but no service with that frontendType is declared in wildo.saas.config.ts.',\n );\n } else if (!contribution.frontendEntry) {\n errors.push(\n `${describeContribution(contribution)} targets frontendType \"${target.serviceType}\" ` +\n 'but does not provide a frontendEntry payload for bootstrap materialization.',\n );\n }\n break;\n case 'minion':\n if (!declaredMinionKeys.has(target.minionKey)) {\n errors.push(\n `${describeContribution(contribution)} targets unknown minion \"${target.minionKey}\".`,\n );\n }\n break;\n case 'worker':\n if (!declaredWorkerKeys.has(target.workerKey)) {\n errors.push(\n `${describeContribution(contribution)} targets unknown worker \"${target.workerKey}\".`,\n );\n }\n break;\n case 'backend':\n case 'companion':\n break;\n }\n }\n }\n\n const runtimeScopes = saasConfig.providers.scopes;\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: 'backend',\n providers: runtimeScopes.backend?.providers ?? {},\n matchesTarget: (target) => target.kind === 'backend',\n });\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: 'companion',\n providers: runtimeScopes.companion?.providers ?? {},\n matchesTarget: (target) => target.kind === 'companion',\n });\n\n for (const [serviceKey, scope] of Object.entries(runtimeScopes.frontendServices ?? {})) {\n if (!declaredServiceKeys.has(serviceKey)) {\n errors.push(`Provider scope references unknown frontend service \"${serviceKey}\".`);\n continue;\n }\n if (!declaredFrontendServiceKeys.has(serviceKey)) {\n errors.push(\n `Provider scope references non-frontend service \"${serviceKey}\". ` +\n 'Only services with a frontendType may appear under providers.scopes.frontendServices.',\n );\n continue;\n }\n const serviceType = serviceKeyToFrontendType.get(serviceKey);\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `frontendServices.${serviceKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'frontendService' && target.serviceType === serviceType,\n });\n }\n\n for (const [minionKey, scope] of Object.entries(runtimeScopes.minions ?? {})) {\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `minions.${minionKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'minion' && target.minionKey === minionKey,\n });\n }\n\n for (const [workerKey, scope] of Object.entries(runtimeScopes.workers ?? {})) {\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `workers.${workerKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'worker' && target.workerKey === workerKey,\n });\n }\n\n if (errors.length > 0) {\n throw new Error(\n `Provider companion-export discovery validation failed:\\n- ${errors.join('\\n- ')}`,\n );\n }\n}\n\nfunction resolveContributionTargets(\n saasRoot: string,\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>,\n): ProviderContributionTarget[] {\n const shouldIncludeBackendServices = hasAnyProviders(saasConfig.providers.scopes.backend?.providers);\n const frontendServiceProviderScopes = Object.entries(saasConfig.providers.scopes.frontendServices ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([serviceKey]) => serviceKey);\n const minionProviderScopes = Object.entries(saasConfig.providers.scopes.minions ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([minionKey]) => minionKey);\n const workerProviderScopes = Object.entries(saasConfig.providers.scopes.workers ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([workerKey]) => workerKey);\n\n return [\n ...Object.entries(saasConfig.services)\n .filter(([key, definition]) => (\n definition.frontendType\n ? frontendServiceProviderScopes.includes(key)\n : shouldIncludeBackendServices\n ))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.SERVICE,\n key,\n ownerLabel: `service \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.libraries ?? {}).map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.LIBRARY,\n key,\n ownerLabel: `library \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.minions ?? {})\n .filter(([key]) => minionProviderScopes.includes(key))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.MINION,\n key,\n ownerLabel: `minion \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.workers ?? {})\n .filter(([key]) => workerProviderScopes.includes(key))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.WORKER,\n key,\n ownerLabel: `worker \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ];\n}\n\n/**\n * Every provider PACKAGE this application depends on, as a contribution target.\n *\n * Candidates come from the application root manifest AND from each runtime owner's manifest, because\n * both layouts are real: a scaffolded application declares its provider packages in the runtime owner\n * that imports them (`backend-api`), while a workspace root may hoist them. The union is deduplicated\n * by resolved package root, so a package declared in both places is walked once.\n *\n * A candidate that cannot be resolved on disk is SKIPPED rather than refused. The manifest is the\n * declaration and `node_modules` is the install; a name declared but not installed is an install\n * problem that `pnpm install` reports far better than a config-sync stack trace would, and refusing\n * here would make `wildo config sync` unrunnable in exactly the state where an operator runs it to\n * find out what is wrong.\n */\nfunction resolveProviderPackageTargets(\n saasRoot: string,\n runtimeOwnerTargets: ProviderContributionTarget[],\n): ProviderContributionTarget[] {\n const prefixes = resolveProviderPackagePrefixes(saasRoot);\n const searchRoots = [saasRoot, ...runtimeOwnerTargets.map((target) => target.packageRoot)];\n\n const candidateNames = new Set<string>();\n for (const searchRoot of searchRoots) {\n for (const dependencyName of readRuntimeReachablePackageNames(searchRoot)) {\n if (dependencyName === FRAMEWORK_PROVIDER_CATALOGUE_PACKAGE || prefixes.some((prefix) => dependencyName.startsWith(prefix))) {\n candidateNames.add(dependencyName);\n }\n }\n }\n\n const targetsByRoot = new Map<string, ProviderContributionTarget>();\n for (const packageName of [...candidateNames].sort()) {\n const packageRoot = resolveProviderPackageRoot(packageName, searchRoots);\n if (!packageRoot || targetsByRoot.has(packageRoot)) {\n continue;\n }\n targetsByRoot.set(packageRoot, {\n kind: ProviderContributionOwnerKind.PROVIDER_PACKAGE,\n key: packageName,\n ownerLabel: `provider package \"${packageName}\"`,\n packageRoot,\n });\n }\n\n return [...targetsByRoot.values()];\n}\n\n/**\n * The framework prefix, plus the application's own scope when its root manifest has one.\n *\n * Deriving the second from the root package name rather than reading it from configuration keeps the\n * \"one declaration\" promise of #330 intact: installing `@acme/provider-thing` in an `@acme` application\n * and scoping the ref is the whole of it — there is no third place to remember.\n */\nfunction resolveProviderPackagePrefixes(saasRoot: string): string[] {\n const prefixes = [FRAMEWORK_PROVIDER_PACKAGE_PREFIX];\n const rootPackageName = readPackageName(saasRoot);\n const scope = rootPackageName?.startsWith('@') ? rootPackageName.split('/')[0] : undefined;\n if (scope && scope !== '@wildo-ai') {\n prefixes.push(`${scope}/provider-`);\n }\n return prefixes;\n}\n\n/**\n * Locate an installed package's ROOT DIRECTORY, which is what the companion-entry resolver needs.\n *\n * The direct `node_modules` probe comes first because it is what pnpm actually produces — a symlink\n * per importer — and because it works for a package whose `exports` map declares no `./package.json`,\n * which `require.resolve` cannot see past. `createRequire` is the fallback for hoisted or otherwise\n * unusual layouts; it resolves the companion subpath (the one door every provider package declares)\n * and walks up to the manifest that names the package.\n */\nfunction resolveProviderPackageRoot(packageName: string, searchRoots: string[]): string | undefined {\n /*\n * The name comes from a manifest and is spliced into a filesystem path, so a segment that is `.` or\n * `..` would walk OUT of `node_modules` — and the prefix gate would not stop it, since\n * `@wildo-ai/provider-x/../../elsewhere` starts with the framework prefix. npm forbids such a name,\n * which is precisely why nothing downstream would question it; the check costs one line and is the\n * only thing standing between an authored dependency name and an arbitrary directory whose\n * companion entry this walk EXECUTES.\n */\n const segments = packageName.split('/');\n if (segments.some((segment) => segment.length === 0 || segment === '.' || segment === '..')) {\n return undefined;\n }\n\n for (const searchRoot of searchRoots) {\n const candidate = join(searchRoot, 'node_modules', ...segments);\n if (existsSync(join(candidate, 'package.json'))) {\n return candidate;\n }\n }\n\n for (const searchRoot of searchRoots) {\n try {\n const resolved = createRequire(join(searchRoot, 'package.json')).resolve(`${packageName}/companion`);\n let directory = dirname(resolved);\n while (directory !== dirname(directory)) {\n if (readPackageName(directory) === packageName) {\n return directory;\n }\n directory = dirname(directory);\n }\n } catch {\n // Not resolvable from this root; try the next one, then give up quietly (see the JSDoc above).\n }\n }\n\n return undefined;\n}\n\nfunction readPackageName(packageRoot: string): string | undefined {\n const packageJsonPath = join(packageRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return undefined;\n }\n try {\n return (JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as { name?: string }).name;\n } catch {\n return undefined;\n }\n}\n\nasync function tryLoadRuntimeOwnerCompanionExports(\n packageRoot: string,\n): Promise<RuntimeOwnerCompanionExports | undefined> {\n try {\n resolvePackageCompanionEntryPath(packageRoot);\n } catch {\n return undefined;\n }\n\n return loadPackageCompanionExport<RuntimeOwnerCompanionExports>(packageRoot);\n}\n\nfunction validateRuntimeScopeAgainstDiscovery(input: {\n errors: string[];\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n scopeLabel: string;\n providers: NonNullable<WildoSaasConfig['providers']['scopes']['backend']>['providers'];\n matchesTarget: (target: ProviderCompanionRuntimeTarget) => boolean;\n}): void {\n const { errors, discoveredContributions, matchesTarget, providers, scopeLabel } = input;\n\n for (const [providerRef, authoredSelection] of Object.entries(providers)) {\n const matchingContributions = discoveredContributions.filter(\n (contribution) => contribution.ref === providerRef\n && contribution.runtimeTargets.some(matchesTarget),\n );\n\n if (matchingContributions.length === 0) {\n errors.push(\n `Provider \"${providerRef}\" is authored in scope \"${scopeLabel}\" but no companion export contributes it for that runtime.`,\n );\n continue;\n }\n\n const discoveredEngineCapabilities = new Set(\n matchingContributions.flatMap((contribution) => contribution.engineCapabilities),\n );\n const discoveredProviderCapabilities = new Set(\n matchingContributions.flatMap((contribution) => contribution.providerCapabilities),\n );\n const discoveredProtocols = new Set(\n matchingContributions.flatMap((contribution) => contribution.protocols),\n );\n\n for (const capability of authoredSelection.engineCapabilities) {\n if (!discoveredEngineCapabilities.has(capability)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares engine capability \"${capability}\" ` +\n 'but discovery does not report that capability for the same runtime.',\n );\n }\n }\n\n for (const capability of authoredSelection.providerCapabilities) {\n if (!discoveredProviderCapabilities.has(capability)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares provider capability \"${capability}\" ` +\n 'but discovery does not report that capability for the same runtime.',\n );\n }\n }\n\n for (const protocol of authoredSelection.protocols) {\n if (!discoveredProtocols.has(protocol)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares protocol \"${protocol}\" ` +\n 'but discovery does not report that protocol for the same runtime.',\n );\n }\n }\n }\n}\n\nfunction describeContribution(contribution: DiscoveredProviderCompanionContribution): string {\n return `Provider contribution \"${contribution.ref}\" from ${contribution.owner.kind} \"${contribution.owner.key}\"`;\n}\n\nfunction readRuntimeReachablePackageNames(packageRoot: string): Set<string> {\n const packageJsonPath = join(packageRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return new Set<string>();\n }\n\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {\n name?: string;\n dependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n optionalDependencies?: Record<string, string>;\n };\n\n return new Set([\n ...(packageJson.name ? [packageJson.name] : []),\n ...Object.keys(packageJson.dependencies ?? {}),\n ...Object.keys(packageJson.peerDependencies ?? {}),\n ...Object.keys(packageJson.optionalDependencies ?? {}),\n ]);\n}\n\nfunction extractPackageName(importPath: string): string {\n if (importPath.startsWith('@')) {\n const [scope, pkg] = importPath.split('/');\n return `${scope}/${pkg}`;\n }\n return importPath.split('/')[0] ?? importPath;\n}\n\nfunction hasAnyProviders(\n providers: Record<string, unknown> | undefined,\n): boolean {\n return Boolean(providers && Object.keys(providers).length > 0);\n}\n"]}
@@ -78,12 +78,46 @@ declare const RuntimeProviderModulesArtifactSchema: z.ZodObject<{
78
78
  moduleIdsByService: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
79
79
  }, z.core.$strict>;
80
80
  export type RuntimeProviderModulesArtifact = z.infer<typeof RuntimeProviderModulesArtifactSchema>;
81
+ /**
82
+ * The per-service frontend bootstrap map, ANNOTATED through a nominal interface rather than inferred.
83
+ *
84
+ * `FrontendProvidersBlockSchema` transitively references three atoms that `@wildo-ai/saas-models`
85
+ * publishes from `/public-runtime` alone, so a consumer that resolves this package's dependency to
86
+ * SOURCE — the minion and worker libraries do, deliberately — has no public specifier through which
87
+ * to NAME them. While the artifact object stayed small TypeScript inlined the shape and nobody
88
+ * noticed; the moment it grew one member past the inline threshold it needed the name and refused:
89
+ * `TS2742 … cannot be named without a reference to
90
+ * node_modules/@wildo-ai/saas-models/src/external-providers/provider-frontend-surface.shared.schemas`.
91
+ *
92
+ * An INTERFACE is what stops the expansion — a type alias is written out structurally in the emitted
93
+ * declaration and takes the unnameable atoms with it, while an interface is written by name. The
94
+ * underlying defect is a root-exported contract depending on a subpath-only module
95
+ * (`package-public-entrypoints.md`, "The root barrel must not DEPEND on a subpath-only surface");
96
+ * that module is the frozen provider contract, so it is filed as #356 rather than fixed here. Runtime
97
+ * behaviour and the inferred field type are unchanged.
98
+ */
99
+ export interface RuntimeProviderFrontendBootstraps {
100
+ [serviceKey: string]: FrontendProvidersBlock;
101
+ }
81
102
  export declare const SaasRuntimeProvidersArtifactSchema: z.ZodObject<{
82
103
  __AUTOGENERATED__: z.ZodLiteral<"AUTO-GENERATED FILE. DO NOT EDIT. Regenerate with `wildo config sync`.">;
83
104
  generatedBy: z.ZodLiteral<"wildo provider-runtime-artifact">;
84
105
  generatedAt: z.ZodString;
85
106
  sourceDigest: z.ZodString;
86
107
  providerRefs: z.ZodDefault<z.ZodArray<z.ZodString>>;
108
+ /**
109
+ * `providerRef` -> the package specifier a host dynamic-imports to obtain that provider's backend
110
+ * module (#330).
111
+ *
112
+ * `providerRefs` says WHICH providers a process may expose; this says WHERE each one comes from,
113
+ * and it is what makes a provider shipped as its own npm package loadable at all. Derived from
114
+ * the discovered contribution whose `runtimeTargets` match the host — never authored.
115
+ *
116
+ * Optional, so an artifact written before this field existed still parses. Every ref such an
117
+ * artifact names is engine-shipped, and a host resolves those from the engine's own on-demand map
118
+ * without consulting this record, so an un-resynced application is unaffected.
119
+ */
120
+ providerRuntimeImports: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
87
121
  providerGraphDigest: z.ZodString;
88
122
  lockfileSectionDigest: z.ZodString;
89
123
  artifactKind: z.ZodEnum<{
@@ -106,10 +140,12 @@ export declare const SaasRuntimeProvidersArtifactSchema: z.ZodObject<{
106
140
  engineCapabilities: z.ZodDefault<z.ZodArray<z.ZodEnum<typeof import("@wildo-ai/saas-models").EngineCapability>>>;
107
141
  providerCapabilities: z.ZodDefault<z.ZodArray<z.ZodString>>;
108
142
  protocols: z.ZodDefault<z.ZodArray<z.ZodString>>;
143
+ tier: z.ZodOptional<z.ZodEnum<typeof import("@wildo-ai/saas-models").ProviderTier>>;
144
+ vendor: z.ZodOptional<z.ZodString>;
109
145
  }, z.core.$strict>>>;
110
146
  selection: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
111
147
  primary: z.ZodString;
112
- fallbacks: z.ZodDefault<z.ZodArray<z.ZodString>>;
148
+ whenUnavailable: z.ZodDefault<z.ZodArray<z.ZodString>>;
113
149
  }, z.core.$strict>>>;
114
150
  }, z.core.$strict>>;
115
151
  scopes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -117,25 +153,15 @@ export declare const SaasRuntimeProvidersArtifactSchema: z.ZodObject<{
117
153
  engineCapabilities: z.ZodDefault<z.ZodArray<z.ZodEnum<typeof import("@wildo-ai/saas-models").EngineCapability>>>;
118
154
  providerCapabilities: z.ZodDefault<z.ZodArray<z.ZodString>>;
119
155
  protocols: z.ZodDefault<z.ZodArray<z.ZodString>>;
156
+ tier: z.ZodOptional<z.ZodEnum<typeof import("@wildo-ai/saas-models").ProviderTier>>;
157
+ vendor: z.ZodOptional<z.ZodString>;
120
158
  }, z.core.$strict>>>;
121
159
  selection: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
122
160
  primary: z.ZodString;
123
- fallbacks: z.ZodDefault<z.ZodArray<z.ZodString>>;
161
+ whenUnavailable: z.ZodDefault<z.ZodArray<z.ZodString>>;
124
162
  }, z.core.$strict>>>;
125
163
  }, z.core.$strict>>>;
126
- frontendProviderBootstraps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
127
- providers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
128
- metadata: z.ZodObject<{
129
- ref: z.ZodString;
130
- displayNameLabelKey: z.ZodOptional<z.ZodString>;
131
- displayName: z.ZodOptional<z.ZodString>;
132
- iconRef: z.ZodOptional<z.ZodString>;
133
- }, z.core.$strip>;
134
- providerCapabilities: z.ZodArray<z.ZodString>;
135
- protocols: z.ZodArray<z.ZodString>;
136
- publicConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
137
- }, z.core.$strip>>>;
138
- }, z.core.$strip>>>;
164
+ frontendProviderBootstraps: z.ZodOptional<z.ZodType<RuntimeProviderFrontendBootstraps, unknown, z.core.$ZodTypeInternals<RuntimeProviderFrontendBootstraps, unknown>>>;
139
165
  }, z.core.$strict>;
140
166
  export type SaasRuntimeProvidersArtifact = z.infer<typeof SaasRuntimeProvidersArtifactSchema>;
141
167
  export interface MaterializedSaasProviderRuntimeArtifacts {
@@ -1 +1 @@
1
- {"version":3,"file":"provider-runtime-artifacts.d.ts","sourceRoot":"","sources":["../../../../src/project-config/provider-runtime-artifacts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,4BAA4B,EAElC,MAAM,4CAA4C,CAAC;AAMpD,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,gCAAgC,CAAC;AAE9F,eAAO,MAAM,+CAA+C,2EACc,CAAC;AAE3E,eAAO,MAAM,mCAAmC,oCAAoC,CAAC;AAErF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wCAAwC;;;;;;CAM3C,CAAC;AAEX;;;;;;GAMG;AACH,eAAO,MAAM,+CAA+C;;;;;;CAMlD,CAAC;AAEX,MAAM,MAAM,2BAA2B,GAAG,MAAM,OAAO,wCAAwC,CAAC;AAEhG,eAAO,MAAM,+CAA+C,sDACP,CAAC;AAEtD;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,EAAG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;IACjC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;QACxB,kBAAkB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC1C,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;KAClC,CAAC,CAAC;CACJ,CAAC"}
1
+ {"version":3,"file":"provider-runtime-artifacts.d.ts","sourceRoot":"","sources":["../../../../src/project-config/provider-runtime-artifacts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,4BAA4B,EAElC,MAAM,4CAA4C,CAAC;AAMpD,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,gCAAgC,CAAC;AAE9F,eAAO,MAAM,+CAA+C,2EACc,CAAC;AAE3E,eAAO,MAAM,mCAAmC,oCAAoC,CAAC;AAErF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wCAAwC;;;;;;CAM3C,CAAC;AAEX;;;;;;GAMG;AACH,eAAO,MAAM,+CAA+C;;;;;;CAMlD,CAAC;AAEX,MAAM,MAAM,2BAA2B,GAAG,MAAM,OAAO,wCAAwC,CAAC;AAEhG,eAAO,MAAM,+CAA+C,sDACP,CAAC;AAEtD;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,EAAG,kCAA2C,CAAC;AAEtF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,wCAAwC,yBAAyB,CAAC;AAa/E,QAAA,MAAM,oCAAoC;;;;;;;kBAUxC,CAAC;AACH,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oCAAoC,CAAC,CAAC;AAElG;;;;;;;;;;;;;;;;;GAiBG;AACH,M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