@wildo-ai/wildo-cli 1.1.14 → 1.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/commands/generate/email-command.utils.d.ts +2 -0
- package/dist/src/commands/generate/email-command.utils.d.ts.map +1 -1
- package/dist/src/commands/generate/email-command.utils.js +5 -0
- package/dist/src/commands/generate/email-command.utils.js.map +1 -1
- package/dist/src/commands/init.command.d.ts.map +1 -1
- package/dist/src/commands/init.command.js +7 -2
- package/dist/src/commands/init.command.js.map +1 -1
- package/dist/src/commands/local/deregister.command.d.ts.map +1 -1
- package/dist/src/commands/local/deregister.command.js +4 -0
- package/dist/src/commands/local/deregister.command.js.map +1 -1
- package/dist/src/commands/local/dev.command.d.ts +6 -0
- package/dist/src/commands/local/dev.command.d.ts.map +1 -1
- package/dist/src/commands/local/dev.command.js +72 -0
- package/dist/src/commands/local/dev.command.js.map +1 -1
- package/dist/src/commands/local/jobs-command.utils.d.ts +24 -0
- package/dist/src/commands/local/jobs-command.utils.d.ts.map +1 -0
- package/dist/src/commands/local/jobs-command.utils.js +44 -0
- package/dist/src/commands/local/jobs-command.utils.js.map +1 -0
- package/dist/src/commands/local/jobs-run.command.d.ts +7 -0
- package/dist/src/commands/local/jobs-run.command.d.ts.map +1 -0
- package/dist/src/commands/local/jobs-run.command.js +92 -0
- package/dist/src/commands/local/jobs-run.command.js.map +1 -0
- package/dist/src/commands/local/jobs.command.d.ts +7 -0
- package/dist/src/commands/local/jobs.command.d.ts.map +1 -0
- package/dist/src/commands/local/jobs.command.js +59 -0
- package/dist/src/commands/local/jobs.command.js.map +1 -0
- package/dist/src/commands/local/tunnel.command.d.ts +84 -0
- package/dist/src/commands/local/tunnel.command.d.ts.map +1 -0
- package/dist/src/commands/local/tunnel.command.js +274 -0
- package/dist/src/commands/local/tunnel.command.js.map +1 -0
- package/dist/src/services/application/app-bootstrap.service.d.ts +41 -1
- package/dist/src/services/application/app-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/application/app-bootstrap.service.js +49 -3
- package/dist/src/services/application/app-bootstrap.service.js.map +1 -1
- package/dist/src/services/application/app-runtime-targets.service.d.ts.map +1 -1
- package/dist/src/services/application/app-runtime-targets.service.js +9 -1
- package/dist/src/services/application/app-runtime-targets.service.js.map +1 -1
- package/dist/src/services/application/application-dependency-alignment.service.d.ts +20 -0
- package/dist/src/services/application/application-dependency-alignment.service.d.ts.map +1 -1
- package/dist/src/services/application/application-dependency-alignment.service.js +32 -2
- package/dist/src/services/application/application-dependency-alignment.service.js.map +1 -1
- package/dist/src/services/application/local-tunnel.service.d.ts +153 -0
- package/dist/src/services/application/local-tunnel.service.d.ts.map +1 -0
- package/dist/src/services/application/local-tunnel.service.js +294 -0
- package/dist/src/services/application/local-tunnel.service.js.map +1 -0
- package/dist/src/services/application/provider-runtime-sync.service.d.ts.map +1 -1
- package/dist/src/services/application/provider-runtime-sync.service.js +3 -0
- package/dist/src/services/application/provider-runtime-sync.service.js.map +1 -1
- package/dist/src/services/application/saas-skeleton.service.d.ts +7 -0
- package/dist/src/services/application/saas-skeleton.service.d.ts.map +1 -1
- package/dist/src/services/application/saas-skeleton.service.js +2 -0
- package/dist/src/services/application/saas-skeleton.service.js.map +1 -1
- package/dist/src/services/catalog/service-address-resolver.service.d.ts +7 -1
- package/dist/src/services/catalog/service-address-resolver.service.d.ts.map +1 -1
- package/dist/src/services/catalog/service-address-resolver.service.js +6 -3
- package/dist/src/services/catalog/service-address-resolver.service.js.map +1 -1
- package/dist/src/services/credentials/application-secrets.service.d.ts +6 -0
- package/dist/src/services/credentials/application-secrets.service.d.ts.map +1 -1
- package/dist/src/services/credentials/application-secrets.service.js +1 -1
- package/dist/src/services/credentials/application-secrets.service.js.map +1 -1
- package/dist/src/services/credentials/provider-env-vars.utils.d.ts.map +1 -1
- package/dist/src/services/credentials/provider-env-vars.utils.js +3 -1
- package/dist/src/services/credentials/provider-env-vars.utils.js.map +1 -1
- package/dist/src/services/credentials/secrets-writer.service.d.ts +11 -2
- package/dist/src/services/credentials/secrets-writer.service.d.ts.map +1 -1
- package/dist/src/services/credentials/secrets-writer.service.js +12 -3
- package/dist/src/services/credentials/secrets-writer.service.js.map +1 -1
- package/dist/src/services/deployment/ci-deploy-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/ci-deploy-generator.service.js +3 -3
- package/dist/src/services/deployment/ci-deploy-generator.service.js.map +1 -1
- package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts +3 -3
- package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/docker/docker-compose-generator.service.js +16 -12
- package/dist/src/services/deployment/docker/docker-compose-generator.service.js.map +1 -1
- package/dist/src/services/deployment/framework-pod-network-membership.d.ts +6 -0
- package/dist/src/services/deployment/framework-pod-network-membership.d.ts.map +1 -1
- package/dist/src/services/deployment/framework-pod-network-membership.js +12 -3
- package/dist/src/services/deployment/framework-pod-network-membership.js.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.d.ts +4 -1
- package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.js +17 -7
- package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.js.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-manifest.schemas.d.ts +7 -0
- package/dist/src/services/deployment/k8s/k8s-manifest.schemas.d.ts.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-manifest.schemas.js.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.js +15 -9
- package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.js.map +1 -1
- package/dist/src/services/deployment/k8s/kind-pod-host-gateway.d.ts +43 -0
- package/dist/src/services/deployment/k8s/kind-pod-host-gateway.d.ts.map +1 -0
- package/dist/src/services/deployment/k8s/kind-pod-host-gateway.js +12 -0
- package/dist/src/services/deployment/k8s/kind-pod-host-gateway.js.map +1 -0
- package/dist/src/services/deployment/k8s/off-cluster-backing-services.d.ts +3 -1
- package/dist/src/services/deployment/k8s/off-cluster-backing-services.d.ts.map +1 -1
- package/dist/src/services/deployment/k8s/off-cluster-backing-services.js.map +1 -1
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts +124 -0
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts.map +1 -0
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.js +249 -0
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.js.map +1 -0
- package/dist/src/services/environment/authored-infra-config.utils.d.ts +9 -0
- package/dist/src/services/environment/authored-infra-config.utils.d.ts.map +1 -1
- package/dist/src/services/environment/authored-infra-config.utils.js +20 -1
- package/dist/src/services/environment/authored-infra-config.utils.js.map +1 -1
- package/dist/src/services/environment/container-host-gateway-listen-host.d.ts +6 -0
- package/dist/src/services/environment/container-host-gateway-listen-host.d.ts.map +1 -1
- package/dist/src/services/environment/container-host-gateway-listen-host.js +6 -0
- package/dist/src/services/environment/container-host-gateway-listen-host.js.map +1 -1
- package/dist/src/services/environment/env-configuration-generator.service.d.ts +12 -0
- package/dist/src/services/environment/env-configuration-generator.service.d.ts.map +1 -1
- package/dist/src/services/environment/env-configuration-generator.service.js +37 -5
- package/dist/src/services/environment/env-configuration-generator.service.js.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.d.ts +2 -1
- package/dist/src/services/environment/env-vars-builder.service.d.ts.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.js +47 -32
- package/dist/src/services/environment/env-vars-builder.service.js.map +1 -1
- package/dist/src/services/environment/environment-lifecycle.service.d.ts +7 -4
- package/dist/src/services/environment/environment-lifecycle.service.d.ts.map +1 -1
- package/dist/src/services/environment/environment-lifecycle.service.js +14 -18
- package/dist/src/services/environment/environment-lifecycle.service.js.map +1 -1
- package/dist/src/services/environment/environment-setup.service.d.ts.map +1 -1
- package/dist/src/services/environment/environment-setup.service.js +17 -6
- package/dist/src/services/environment/environment-setup.service.js.map +1 -1
- package/dist/src/services/environment/environment.service.d.ts +4 -3
- package/dist/src/services/environment/environment.service.d.ts.map +1 -1
- package/dist/src/services/environment/environment.service.js +0 -1
- package/dist/src/services/environment/environment.service.js.map +1 -1
- package/dist/src/services/framework/framework-docker-publish.service.d.ts +55 -15
- package/dist/src/services/framework/framework-docker-publish.service.d.ts.map +1 -1
- package/dist/src/services/framework/framework-docker-publish.service.js +115 -25
- package/dist/src/services/framework/framework-docker-publish.service.js.map +1 -1
- package/dist/src/services/security/csp-sync.service.d.ts.map +1 -1
- package/dist/src/services/security/csp-sync.service.js +21 -2
- package/dist/src/services/security/csp-sync.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +19 -19
- package/templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs +14 -7
- package/templates/infra/k8s/platform/platform-crontabs-batches-manager/deployment.yaml.hbs +13 -0
- package/templates/saas/skeleton/.wildo-saas/wildo-dev-companion/scripts/dev-supervised.sh +18 -4
- package/templates/saas/skeleton/frontend/nginx-config/default.conf.hbs +1 -1
- package/templates/saas/skeleton/frontend/src/generated/csp.generated.json.hbs +4 -4
- package/templates/saas/skeleton/infrastructure/local/wildo.infra.local.config.ts.hbs +2 -0
- package/wildo-framework.info.json +1 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/** A workspace member that runs a `dev` script, as `pnpm -r run dev` would start it. */
|
|
2
|
+
export interface WorkspaceDevMember {
|
|
3
|
+
/** Its package name: what `pnpm --filter` selects. */
|
|
4
|
+
readonly name: string;
|
|
5
|
+
/** Its directory, application-relative. */
|
|
6
|
+
readonly directory: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Every workspace member (the root excluded) whose `package.json` declares a `dev` script: the set `pnpm -r run dev`
|
|
10
|
+
* starts. A member whose manifest does not parse, or that has no name, is left out, as pnpm cannot select it either.
|
|
11
|
+
*/
|
|
12
|
+
export declare function listWorkspaceDevMembers(appRoot: string): WorkspaceDevMember[];
|
|
13
|
+
/** What the stack knows between two looks: the members it runs, and the install it last acted on. */
|
|
14
|
+
export interface LateWorkspaceMemberState {
|
|
15
|
+
readonly started: ReadonlySet<string>;
|
|
16
|
+
/** When pnpm last finished an install in the application, as last seen (`node_modules/.modules.yaml`). */
|
|
17
|
+
readonly installedAtMs: number | null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The members to start now, and the state to keep. Pure but for the reads, which a test replaces.
|
|
21
|
+
*
|
|
22
|
+
* Nothing starts while an install is IN FLIGHT (the member's dependencies are not there yet), and nothing is looked for
|
|
23
|
+
* until pnpm has finished an install since the last look: a member is added by an install, and listing the workspace on
|
|
24
|
+
* every tick would read every manifest every few seconds for nothing.
|
|
25
|
+
*/
|
|
26
|
+
export declare function decideLateWorkspaceMembers(appRoot: string, state: LateWorkspaceMemberState, reads?: {
|
|
27
|
+
readonly installedAtMs: (root: string) => number | null;
|
|
28
|
+
readonly installInFlight: (root: string) => boolean;
|
|
29
|
+
readonly members: (root: string) => readonly WorkspaceDevMember[];
|
|
30
|
+
}): {
|
|
31
|
+
readonly toStart: readonly WorkspaceDevMember[];
|
|
32
|
+
readonly state: LateWorkspaceMemberState;
|
|
33
|
+
};
|
|
34
|
+
/** Whether a dependency install is running in the application right now (the stack-event record, #3552). */
|
|
35
|
+
export declare function isDependencyInstallInFlight(appRoot: string): boolean;
|
|
36
|
+
/** The state at the stack's start: every member `pnpm -r run dev` is starting, and the install already on disk. */
|
|
37
|
+
export declare function initialLateWorkspaceMemberState(appRoot: string): LateWorkspaceMemberState;
|
|
38
|
+
/** How often the stack looks for a finished install. */
|
|
39
|
+
export declare const LATE_WORKSPACE_MEMBER_POLL_MS = 5000;
|
|
40
|
+
/**
|
|
41
|
+
* What the runtimes' env files are written from, out of a `wildo.saas.config.ts` (#3985): the WHOLE declaration. The
|
|
42
|
+
* runtime topology is the case measured — services, minions and workers become `APPLICATION_RUNTIME_ENDPOINTS`, and on
|
|
43
|
+
* reference run 43876218697 `add-website` declared a website at 14:51, the companion restarted at 16:52 and crash-looped on
|
|
44
|
+
* `frontendServices.<x> is declared but runtime.endPoints.<x> is missing` until the run ended. But the env writer also
|
|
45
|
+
* derives from providers, systems of record, data services and key management, so a hand-picked subset of fields would be
|
|
46
|
+
* a second list of what the writer reads, the kind that rots. Any change to the declaration therefore owes a regeneration,
|
|
47
|
+
* which is what restarting `wildo local dev` would do.
|
|
48
|
+
*
|
|
49
|
+
* A canonical string: keys sorted at every depth (an edit that only reorders is not a change), functions and cycles named
|
|
50
|
+
* rather than followed. It sees what is enumerable: a `Map`, a `Set` or a value kept on non-enumerable properties (a Zod
|
|
51
|
+
* schema) serialises without its contents, so a change held only there is not seen. A declaration is plain data today.
|
|
52
|
+
*/
|
|
53
|
+
export declare function declarationFingerprint(config: unknown): string;
|
|
54
|
+
/** The declaration the runtimes' env files were last written from, and the config file's state when it was read. */
|
|
55
|
+
export interface DeclarationState {
|
|
56
|
+
/** `null` when the starting read failed: the first declaration read later is then owed a regeneration. */
|
|
57
|
+
readonly fingerprint: string | null;
|
|
58
|
+
/** The config file's modification time at that read: an unchanged file is never re-read. */
|
|
59
|
+
readonly configModifiedAtMs: number | null;
|
|
60
|
+
}
|
|
61
|
+
/** The reads the reconcile pass makes, replaceable by a test. */
|
|
62
|
+
export interface WorkspaceReconcileReads {
|
|
63
|
+
readonly installInFlight: (root: string) => boolean;
|
|
64
|
+
readonly configModifiedAtMs: (root: string) => number | null;
|
|
65
|
+
readonly loadFingerprint: (root: string) => Promise<string | null>;
|
|
66
|
+
readonly installedAtMs: (root: string) => number | null;
|
|
67
|
+
readonly members: (root: string) => readonly WorkspaceDevMember[];
|
|
68
|
+
readonly now: () => number;
|
|
69
|
+
}
|
|
70
|
+
/** After a failed regeneration, how long before the next attempt. */
|
|
71
|
+
export declare const ENV_REGENERATION_RETRY_MS = 60000;
|
|
72
|
+
export declare const DEFAULT_WORKSPACE_RECONCILE_READS: WorkspaceReconcileReads;
|
|
73
|
+
/**
|
|
74
|
+
* One reconcile of the running stack with the workspace and the declaration (#3985, #3986), as `wildo local dev` runs it
|
|
75
|
+
* every few seconds. Single-flight; nothing at all while an install runs. In ORDER, because a member that is also a
|
|
76
|
+
* declared service needs a `.env` that knows it:
|
|
77
|
+
*
|
|
78
|
+
* 1. The declaration: when the config file changed and its fingerprint differs from what the env files were written from
|
|
79
|
+
* (or that is unknown), the env files are OWED, and `regenerate` (the startup bootstrap) runs. A failure keeps them
|
|
80
|
+
* owed and retries after {@link ENV_REGENERATION_RETRY_MS}. A declaration that does not load (an edit in progress)
|
|
81
|
+
* owes nothing yet and is read again on the next change.
|
|
82
|
+
* 2. The members: only when no regeneration is owed. Each member a finished install brought gets its dev process, once.
|
|
83
|
+
* Accepted cost, recorded on #3986: a regeneration that KEEPS failing holds back every new member, a provider package
|
|
84
|
+
* included (which reads no runtime `.env`). It is reported every minute, and restarting `wildo local dev` clears it;
|
|
85
|
+
* telling the members that need a `.env` from those that do not would take a second reading of the declaration.
|
|
86
|
+
*/
|
|
87
|
+
export declare function createWorkspaceReconciler(input: {
|
|
88
|
+
readonly appRoot: string;
|
|
89
|
+
/** Whether the env files can be regenerated at all (startup regenerates only with a framework path). */
|
|
90
|
+
readonly canRegenerate: boolean;
|
|
91
|
+
readonly regenerate: () => Promise<void>;
|
|
92
|
+
readonly startMember: (member: WorkspaceDevMember) => void;
|
|
93
|
+
readonly isStopping: () => boolean;
|
|
94
|
+
readonly reportRegenerationFailure: (error: unknown) => void;
|
|
95
|
+
readonly initial: {
|
|
96
|
+
readonly declaration: DeclarationState;
|
|
97
|
+
readonly members: LateWorkspaceMemberState;
|
|
98
|
+
};
|
|
99
|
+
readonly reads?: WorkspaceReconcileReads;
|
|
100
|
+
}): {
|
|
101
|
+
readonly reconcile: () => Promise<void>;
|
|
102
|
+
readonly regenerationOwed: () => boolean;
|
|
103
|
+
};
|
|
104
|
+
/** The declaration the stack started from: what its env files were written from moments ago. */
|
|
105
|
+
export declare function initialDeclarationState(appRoot: string, reads?: WorkspaceReconcileReads): Promise<DeclarationState>;
|
|
106
|
+
/**
|
|
107
|
+
* Regenerate the application's provider runtime artifacts after a declaration change (#3985), as `wildo config sync
|
|
108
|
+
* --domain config` writes them: the per-runtime provider lists, the generated provider modules, the CSP.
|
|
109
|
+
*
|
|
110
|
+
* The env files are not the only thing a declaration change leaves behind. Measured on reference run 43937787170: the
|
|
111
|
+
* foundation declared `email-preview` and `stripe` at 20:31, the backend's provider artifact still listed none (written by
|
|
112
|
+
* `wildo init` at 19:23), and the backend refused six times with "Required engine capabilities resolve no active provider:
|
|
113
|
+
* [BILLING, EMAIL_TRANSACTIONAL]" and paused, with the build about to start. The same class as Wonder Procurement's on
|
|
114
|
+
* 2026-10-07 (`findProviderRuntimeArtifactsBehindDeclaration`), which a restart repairs and a running stack never did.
|
|
115
|
+
*
|
|
116
|
+
* Run as a CHILD of this CLI: in this long-lived process the configuration loader's module cache still holds the
|
|
117
|
+
* declaration the stack started with, and a sync reading it would regenerate the very artifacts that are behind. Rejects
|
|
118
|
+
* when the child fails, so the reconcile keeps the regeneration owed and retries.
|
|
119
|
+
*/
|
|
120
|
+
export declare function syncProviderRuntimeArtifactsInChild(saasRoot: string, envName: string, run?: (file: string, args: readonly string[], options: {
|
|
121
|
+
cwd: string;
|
|
122
|
+
timeout: number;
|
|
123
|
+
}) => Promise<unknown>): Promise<void>;
|
|
124
|
+
//# sourceMappingURL=local-dev-late-workspace-members.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-dev-late-workspace-members.service.d.ts","sourceRoot":"","sources":["../../../../src/services/deployment/local-dev-late-workspace-members.service.ts"],"names":[],"mappings":"AA6BA,wFAAwF;AACxF,MAAM,WAAW,kBAAkB;IACjC,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC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AAC,OAAO,EAAE,wBAAwB,CAAA;KAAE,CAAC;IACzG,QAAQ,CAAC,KAAK,CAAC,EAAE,uBAAuB,CAAC;CAC1C,GAAG;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,OAAO,CAAA;CAAE,CA6CxF;AAED,gGAAgG;AAChG,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,uBAA2D,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAS5J;AAKD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mCAAmC,CACvD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,OAAO,CAAmB,GAC5H,OAAO,CAAC,IAAI,CAAC,CAOf"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace members that JOIN an application while `wildo local dev` runs, and the dev process each one is owed (#3986).
|
|
3
|
+
*
|
|
4
|
+
* The development tree is `pnpm dev`, which runs `pnpm -r run dev`: one `dev` process for every workspace member that
|
|
5
|
+
* has the script, enumerated ONCE, when the stack starts. A member added later never gets one. The members that arrive
|
|
6
|
+
* that way are real and routine: `wildo registry add` installs a provider as `providers/<ref>/backend`, and `wildo compose`
|
|
7
|
+
* adds a website, a documentation site, a minion or a worker. Measured on reference run 43876218697: a coding run
|
|
8
|
+
* installed the Brevo provider at 16:41, its package was never compiled, and the backend, which depends on it, sat paused
|
|
9
|
+
* on `dependency-output-not-ready` for the rest of the run. A person routes around it by restarting `wildo local dev`; an
|
|
10
|
+
* unattended creation cannot.
|
|
11
|
+
*
|
|
12
|
+
* So the stack watches for a FINISHED INSTALL (a new member is usable only once its dependencies are), and starts the dev
|
|
13
|
+
* script of every member with one that it has not started yet. A member that is also a declared SERVICE needs its `.env`
|
|
14
|
+
* first: {@link decideRuntimeTopologyRegeneration} says when the declared topology changed, and the command rewrites
|
|
15
|
+
* every runtime's env files BEFORE it starts the new members (#3985). The decision is pure and lives here; the spawning stays in
|
|
16
|
+
* the command. A member that LEAVES is not stopped: its process exits on its own when its files go, and a restart of the
|
|
17
|
+
* stack reads the workspace afresh.
|
|
18
|
+
*/
|
|
19
|
+
import { execFile } from 'node:child_process';
|
|
20
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
21
|
+
import { join } from 'node:path';
|
|
22
|
+
import { promisify } from 'node:util';
|
|
23
|
+
import { loadSaasConfig } from '@wildo-ai/platform-config-lib';
|
|
24
|
+
import { LocalDevDependencyInstallPhase } from '@wildo-ai/platform-core-shared';
|
|
25
|
+
import { classifyDependencyInstall, readDependencyInstallRecord, readNodeModulesInstalledAtMs } from '@wildo-ai/platform-core-shared/dev-runtime';
|
|
26
|
+
import { expandWorkspaceMemberPatterns, readWorkspacePackagePatterns } from '../../services/application/application-dependency-alignment.service.js';
|
|
27
|
+
/**
|
|
28
|
+
* Every workspace member (the root excluded) whose `package.json` declares a `dev` script: the set `pnpm -r run dev`
|
|
29
|
+
* starts. A member whose manifest does not parse, or that has no name, is left out, as pnpm cannot select it either.
|
|
30
|
+
*/
|
|
31
|
+
export function listWorkspaceDevMembers(appRoot) {
|
|
32
|
+
const { members } = expandWorkspaceMemberPatterns(appRoot, readWorkspacePackagePatterns(join(appRoot, 'pnpm-workspace.yaml')));
|
|
33
|
+
const found = [];
|
|
34
|
+
for (const directory of members) {
|
|
35
|
+
if (directory === '.')
|
|
36
|
+
continue;
|
|
37
|
+
const manifestPath = join(appRoot, directory, 'package.json');
|
|
38
|
+
if (!existsSync(manifestPath))
|
|
39
|
+
continue;
|
|
40
|
+
try {
|
|
41
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
42
|
+
if (typeof manifest.name === 'string' && manifest.name.length > 0 && typeof manifest.scripts?.dev === 'string') {
|
|
43
|
+
found.push({ name: manifest.name, directory });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// An unreadable manifest is one pnpm cannot run either.
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return found;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The members to start now, and the state to keep. Pure but for the reads, which a test replaces.
|
|
54
|
+
*
|
|
55
|
+
* Nothing starts while an install is IN FLIGHT (the member's dependencies are not there yet), and nothing is looked for
|
|
56
|
+
* until pnpm has finished an install since the last look: a member is added by an install, and listing the workspace on
|
|
57
|
+
* every tick would read every manifest every few seconds for nothing.
|
|
58
|
+
*/
|
|
59
|
+
export function decideLateWorkspaceMembers(appRoot, state, reads = DEFAULT_LATE_MEMBER_READS) {
|
|
60
|
+
if (reads.installInFlight(appRoot))
|
|
61
|
+
return { toStart: [], state };
|
|
62
|
+
const installedAtMs = reads.installedAtMs(appRoot);
|
|
63
|
+
if (installedAtMs === null || (state.installedAtMs !== null && installedAtMs <= state.installedAtMs))
|
|
64
|
+
return { toStart: [], state };
|
|
65
|
+
const toStart = reads.members(appRoot).filter((member) => !state.started.has(member.name));
|
|
66
|
+
return {
|
|
67
|
+
toStart,
|
|
68
|
+
state: { started: new Set([...state.started, ...toStart.map((member) => member.name)]), installedAtMs },
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Whether a dependency install is running in the application right now (the stack-event record, #3552). */
|
|
72
|
+
export function isDependencyInstallInFlight(appRoot) {
|
|
73
|
+
return classifyDependencyInstall(readDependencyInstallRecord(appRoot), Date.now()).phase === LocalDevDependencyInstallPhase.IN_FLIGHT;
|
|
74
|
+
}
|
|
75
|
+
const DEFAULT_LATE_MEMBER_READS = {
|
|
76
|
+
installedAtMs: readNodeModulesInstalledAtMs,
|
|
77
|
+
installInFlight: isDependencyInstallInFlight,
|
|
78
|
+
members: listWorkspaceDevMembers,
|
|
79
|
+
};
|
|
80
|
+
/** The state at the stack's start: every member `pnpm -r run dev` is starting, and the install already on disk. */
|
|
81
|
+
export function initialLateWorkspaceMemberState(appRoot) {
|
|
82
|
+
return {
|
|
83
|
+
started: new Set(listWorkspaceDevMembers(appRoot).map((member) => member.name)),
|
|
84
|
+
installedAtMs: readNodeModulesInstalledAtMs(appRoot),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** How often the stack looks for a finished install. */
|
|
88
|
+
export const LATE_WORKSPACE_MEMBER_POLL_MS = 5_000;
|
|
89
|
+
/**
|
|
90
|
+
* What the runtimes' env files are written from, out of a `wildo.saas.config.ts` (#3985): the WHOLE declaration. The
|
|
91
|
+
* runtime topology is the case measured — services, minions and workers become `APPLICATION_RUNTIME_ENDPOINTS`, and on
|
|
92
|
+
* reference run 43876218697 `add-website` declared a website at 14:51, the companion restarted at 16:52 and crash-looped on
|
|
93
|
+
* `frontendServices.<x> is declared but runtime.endPoints.<x> is missing` until the run ended. But the env writer also
|
|
94
|
+
* derives from providers, systems of record, data services and key management, so a hand-picked subset of fields would be
|
|
95
|
+
* a second list of what the writer reads, the kind that rots. Any change to the declaration therefore owes a regeneration,
|
|
96
|
+
* which is what restarting `wildo local dev` would do.
|
|
97
|
+
*
|
|
98
|
+
* A canonical string: keys sorted at every depth (an edit that only reorders is not a change), functions and cycles named
|
|
99
|
+
* rather than followed. It sees what is enumerable: a `Map`, a `Set` or a value kept on non-enumerable properties (a Zod
|
|
100
|
+
* schema) serialises without its contents, so a change held only there is not seen. A declaration is plain data today.
|
|
101
|
+
*/
|
|
102
|
+
export function declarationFingerprint(config) {
|
|
103
|
+
const seen = new WeakSet();
|
|
104
|
+
const canonical = (value) => {
|
|
105
|
+
if (typeof value === 'function')
|
|
106
|
+
return '[function]';
|
|
107
|
+
if (typeof value === 'bigint')
|
|
108
|
+
return value.toString();
|
|
109
|
+
if (value === null || typeof value !== 'object')
|
|
110
|
+
return value;
|
|
111
|
+
if (seen.has(value))
|
|
112
|
+
return '[circular]';
|
|
113
|
+
seen.add(value);
|
|
114
|
+
const result = Array.isArray(value)
|
|
115
|
+
? value.map(canonical)
|
|
116
|
+
: Object.fromEntries(Object.keys(value).sort().map((key) => [key, canonical(value[key])]));
|
|
117
|
+
seen.delete(value);
|
|
118
|
+
return result;
|
|
119
|
+
};
|
|
120
|
+
return JSON.stringify(canonical(config));
|
|
121
|
+
}
|
|
122
|
+
const SAAS_CONFIG_FILE = 'wildo.saas.config.ts';
|
|
123
|
+
/** After a failed regeneration, how long before the next attempt. */
|
|
124
|
+
export const ENV_REGENERATION_RETRY_MS = 60_000;
|
|
125
|
+
export const DEFAULT_WORKSPACE_RECONCILE_READS = {
|
|
126
|
+
installInFlight: isDependencyInstallInFlight,
|
|
127
|
+
configModifiedAtMs: (root) => {
|
|
128
|
+
try {
|
|
129
|
+
return statSync(join(root, SAAS_CONFIG_FILE)).mtimeMs;
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
// Fresh: jiti's module cache is process-wide, and this process would otherwise read the declaration it started with.
|
|
136
|
+
loadFingerprint: async (root) => {
|
|
137
|
+
const config = await loadSaasConfig(join(root, SAAS_CONFIG_FILE), { freshModuleCache: true });
|
|
138
|
+
return config === null ? null : declarationFingerprint(config);
|
|
139
|
+
},
|
|
140
|
+
installedAtMs: readNodeModulesInstalledAtMs,
|
|
141
|
+
members: listWorkspaceDevMembers,
|
|
142
|
+
now: () => Date.now(),
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* One reconcile of the running stack with the workspace and the declaration (#3985, #3986), as `wildo local dev` runs it
|
|
146
|
+
* every few seconds. Single-flight; nothing at all while an install runs. In ORDER, because a member that is also a
|
|
147
|
+
* declared service needs a `.env` that knows it:
|
|
148
|
+
*
|
|
149
|
+
* 1. The declaration: when the config file changed and its fingerprint differs from what the env files were written from
|
|
150
|
+
* (or that is unknown), the env files are OWED, and `regenerate` (the startup bootstrap) runs. A failure keeps them
|
|
151
|
+
* owed and retries after {@link ENV_REGENERATION_RETRY_MS}. A declaration that does not load (an edit in progress)
|
|
152
|
+
* owes nothing yet and is read again on the next change.
|
|
153
|
+
* 2. The members: only when no regeneration is owed. Each member a finished install brought gets its dev process, once.
|
|
154
|
+
* Accepted cost, recorded on #3986: a regeneration that KEEPS failing holds back every new member, a provider package
|
|
155
|
+
* included (which reads no runtime `.env`). It is reported every minute, and restarting `wildo local dev` clears it;
|
|
156
|
+
* telling the members that need a `.env` from those that do not would take a second reading of the declaration.
|
|
157
|
+
*/
|
|
158
|
+
export function createWorkspaceReconciler(input) {
|
|
159
|
+
const reads = input.reads ?? DEFAULT_WORKSPACE_RECONCILE_READS;
|
|
160
|
+
let declaration = input.initial.declaration;
|
|
161
|
+
let members = input.initial.members;
|
|
162
|
+
let owed = null; // the fingerprint whose env files are owed
|
|
163
|
+
let retryAtMs = 0;
|
|
164
|
+
let running = false;
|
|
165
|
+
const reconcile = async () => {
|
|
166
|
+
if (running || input.isStopping() || reads.installInFlight(input.appRoot))
|
|
167
|
+
return;
|
|
168
|
+
running = true;
|
|
169
|
+
try {
|
|
170
|
+
if (input.canRegenerate) {
|
|
171
|
+
const modifiedAtMs = reads.configModifiedAtMs(input.appRoot);
|
|
172
|
+
if (modifiedAtMs !== null && modifiedAtMs !== declaration.configModifiedAtMs) {
|
|
173
|
+
let fingerprint = null;
|
|
174
|
+
try {
|
|
175
|
+
fingerprint = await reads.loadFingerprint(input.appRoot);
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
fingerprint = null;
|
|
179
|
+
}
|
|
180
|
+
if (fingerprint !== null) {
|
|
181
|
+
if (fingerprint !== declaration.fingerprint)
|
|
182
|
+
owed = fingerprint;
|
|
183
|
+
declaration = { fingerprint, configModifiedAtMs: modifiedAtMs };
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (owed !== null && reads.now() >= retryAtMs) {
|
|
187
|
+
try {
|
|
188
|
+
await input.regenerate();
|
|
189
|
+
owed = null;
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
retryAtMs = reads.now() + ENV_REGENERATION_RETRY_MS;
|
|
193
|
+
input.reportRegenerationFailure(error);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// The env files first: a member started now would read a `.env` that may not know it.
|
|
197
|
+
if (owed !== null || input.isStopping())
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const decision = decideLateWorkspaceMembers(input.appRoot, members, reads);
|
|
201
|
+
members = decision.state;
|
|
202
|
+
for (const member of decision.toStart)
|
|
203
|
+
input.startMember(member);
|
|
204
|
+
}
|
|
205
|
+
finally {
|
|
206
|
+
running = false;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
return { reconcile, regenerationOwed: () => owed !== null };
|
|
210
|
+
}
|
|
211
|
+
/** The declaration the stack started from: what its env files were written from moments ago. */
|
|
212
|
+
export async function initialDeclarationState(appRoot, reads = DEFAULT_WORKSPACE_RECONCILE_READS) {
|
|
213
|
+
const configModifiedAtMs = reads.configModifiedAtMs(appRoot);
|
|
214
|
+
try {
|
|
215
|
+
const fingerprint = await reads.loadFingerprint(appRoot);
|
|
216
|
+
return fingerprint === null ? { fingerprint: null, configModifiedAtMs: null } : { fingerprint, configModifiedAtMs };
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
// Unknown: the first declaration read later is owed a regeneration rather than taken as the baseline.
|
|
220
|
+
return { fingerprint: null, configModifiedAtMs: null };
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/** Bound on the provider-artifact sync: it reads configuration and writes generated files, and must not hold the reconcile. */
|
|
224
|
+
const PROVIDER_ARTIFACT_SYNC_TIMEOUT_MS = 5 * 60 * 1000;
|
|
225
|
+
/**
|
|
226
|
+
* Regenerate the application's provider runtime artifacts after a declaration change (#3985), as `wildo config sync
|
|
227
|
+
* --domain config` writes them: the per-runtime provider lists, the generated provider modules, the CSP.
|
|
228
|
+
*
|
|
229
|
+
* The env files are not the only thing a declaration change leaves behind. Measured on reference run 43937787170: the
|
|
230
|
+
* foundation declared `email-preview` and `stripe` at 20:31, the backend's provider artifact still listed none (written by
|
|
231
|
+
* `wildo init` at 19:23), and the backend refused six times with "Required engine capabilities resolve no active provider:
|
|
232
|
+
* [BILLING, EMAIL_TRANSACTIONAL]" and paused, with the build about to start. The same class as Wonder Procurement's on
|
|
233
|
+
* 2026-10-07 (`findProviderRuntimeArtifactsBehindDeclaration`), which a restart repairs and a running stack never did.
|
|
234
|
+
*
|
|
235
|
+
* Run as a CHILD of this CLI: in this long-lived process the configuration loader's module cache still holds the
|
|
236
|
+
* declaration the stack started with, and a sync reading it would regenerate the very artifacts that are behind. Rejects
|
|
237
|
+
* when the child fails, so the reconcile keeps the regeneration owed and retries.
|
|
238
|
+
*/
|
|
239
|
+
export async function syncProviderRuntimeArtifactsInChild(saasRoot, envName, run = defaultRunChild) {
|
|
240
|
+
const cliEntry = process.argv[1];
|
|
241
|
+
if (cliEntry === undefined)
|
|
242
|
+
throw new Error('The wildo CLI entry point is unknown, so the provider artifacts cannot be regenerated.');
|
|
243
|
+
await run(process.execPath, [cliEntry, 'config', 'sync', '--domain', 'config', '--env', envName, '--non-interactive'], {
|
|
244
|
+
cwd: saasRoot,
|
|
245
|
+
timeout: PROVIDER_ARTIFACT_SYNC_TIMEOUT_MS,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
const defaultRunChild = (file, args, options) => promisify(execFile)(file, [...args], { ...options, maxBuffer: 16 * 1024 * 1024 });
|
|
249
|
+
//# sourceMappingURL=local-dev-late-workspace-members.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-dev-late-workspace-members.service.js","sourceRoot":"","sources":["../../../../src/services/deployment/local-dev-late-workspace-members.service.ts"],"names":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MAAM,CAAC;QACP,sGAAsG;QACtG,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC;IACzD,CAAC;AACH,CAAC;AAED,+HAA+H;AAC/H,MAAM,iCAAiC,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,mCAAmC,CACvD,QAAgB,EAChB,OAAe,EACf,MAA8G,eAAe;IAE7H,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjC,IAAI,QAAQ,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,wFAAwF,CAAC,CAAC;IACtI,MAAM,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,CAAC,EAAE;QACrH,GAAG,EAAE,QAAQ;QACb,OAAO,EAAE,iCAAiC;KAC3C,CAAC,CAAC;AACL,CAAC;AAED,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,IAAuB,EAAE,OAAyC,EAAoB,EAAE,CAC7H,SAAS,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC","sourcesContent":["/**\n * The workspace members that JOIN an application while `wildo local dev` runs, and the dev process each one is owed (#3986).\n *\n * The development tree is `pnpm dev`, which runs `pnpm -r run dev`: one `dev` process for every workspace member that\n * has the script, enumerated ONCE, when the stack starts. A member added later never gets one. The members that arrive\n * that way are real and routine: `wildo registry add` installs a provider as `providers/<ref>/backend`, and `wildo compose`\n * adds a website, a documentation site, a minion or a worker. Measured on reference run 43876218697: a coding run\n * installed the Brevo provider at 16:41, its package was never compiled, and the backend, which depends on it, sat paused\n * on `dependency-output-not-ready` for the rest of the run. A person routes around it by restarting `wildo local dev`; an\n * unattended creation cannot.\n *\n * So the stack watches for a FINISHED INSTALL (a new member is usable only once its dependencies are), and starts the dev\n * script of every member with one that it has not started yet. A member that is also a declared SERVICE needs its `.env`\n * first: {@link decideRuntimeTopologyRegeneration} says when the declared topology changed, and the command rewrites\n * every runtime's env files BEFORE it starts the new members (#3985). The decision is pure and lives here; the spawning stays in\n * the command. A member that LEAVES is not stopped: its process exits on its own when its files go, and a restart of the\n * stack reads the workspace afresh.\n */\nimport { execFile } from 'node:child_process';\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { promisify } from 'node:util';\n\nimport { loadSaasConfig } from '@wildo-ai/platform-config-lib';\nimport { LocalDevDependencyInstallPhase } from '@wildo-ai/platform-core-shared';\nimport { classifyDependencyInstall, readDependencyInstallRecord, readNodeModulesInstalledAtMs } from '@wildo-ai/platform-core-shared/dev-runtime';\n\nimport { expandWorkspaceMemberPatterns, readWorkspacePackagePatterns } from '~wildo-cli/services/application/application-dependency-alignment.service';\n\n/** A workspace member that runs a `dev` script, as `pnpm -r run dev` would start it. */\nexport interface WorkspaceDevMember {\n /** Its package name: what `pnpm --filter` selects. */\n readonly name: string;\n /** Its directory, application-relative. */\n readonly directory: string;\n}\n\n/**\n * Every workspace member (the root excluded) whose `package.json` declares a `dev` script: the set `pnpm -r run dev`\n * starts. A member whose manifest does not parse, or that has no name, is left out, as pnpm cannot select it either.\n */\nexport function listWorkspaceDevMembers(appRoot: string): WorkspaceDevMember[] {\n const { members } = expandWorkspaceMemberPatterns(appRoot, readWorkspacePackagePatterns(join(appRoot, 'pnpm-workspace.yaml')));\n const found: WorkspaceDevMember[] = [];\n for (const directory of members) {\n if (directory === '.') continue;\n const manifestPath = join(appRoot, directory, 'package.json');\n if (!existsSync(manifestPath)) continue;\n try {\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as { readonly name?: unknown; readonly scripts?: Record<string, unknown> };\n if (typeof manifest.name === 'string' && manifest.name.length > 0 && typeof manifest.scripts?.dev === 'string') {\n found.push({ name: manifest.name, directory });\n }\n } catch {\n // An unreadable manifest is one pnpm cannot run either.\n }\n }\n return found;\n}\n\n/** What the stack knows between two looks: the members it runs, and the install it last acted on. */\nexport interface LateWorkspaceMemberState {\n readonly started: ReadonlySet<string>;\n /** When pnpm last finished an install in the application, as last seen (`node_modules/.modules.yaml`). */\n readonly installedAtMs: number | null;\n}\n\n/**\n * The members to start now, and the state to keep. Pure but for the reads, which a test replaces.\n *\n * Nothing starts while an install is IN FLIGHT (the member's dependencies are not there yet), and nothing is looked for\n * until pnpm has finished an install since the last look: a member is added by an install, and listing the workspace on\n * every tick would read every manifest every few seconds for nothing.\n */\nexport function decideLateWorkspaceMembers(\n appRoot: string,\n state: LateWorkspaceMemberState,\n reads: {\n readonly installedAtMs: (root: string) => number | null;\n readonly installInFlight: (root: string) => boolean;\n readonly members: (root: string) => readonly WorkspaceDevMember[];\n } = DEFAULT_LATE_MEMBER_READS,\n): { readonly toStart: readonly WorkspaceDevMember[]; readonly state: LateWorkspaceMemberState } {\n if (reads.installInFlight(appRoot)) return { toStart: [], state };\n const installedAtMs = reads.installedAtMs(appRoot);\n if (installedAtMs === null || (state.installedAtMs !== null && installedAtMs <= state.installedAtMs)) return { toStart: [], state };\n const toStart = reads.members(appRoot).filter((member) => !state.started.has(member.name));\n return {\n toStart,\n state: { started: new Set([...state.started, ...toStart.map((member) => member.name)]), installedAtMs },\n };\n}\n\n/** Whether a dependency install is running in the application right now (the stack-event record, #3552). */\nexport function isDependencyInstallInFlight(appRoot: string): boolean {\n return classifyDependencyInstall(readDependencyInstallRecord(appRoot), Date.now()).phase === LocalDevDependencyInstallPhase.IN_FLIGHT;\n}\n\nconst DEFAULT_LATE_MEMBER_READS = {\n installedAtMs: readNodeModulesInstalledAtMs,\n installInFlight: isDependencyInstallInFlight,\n members: listWorkspaceDevMembers,\n} as const;\n\n/** The state at the stack's start: every member `pnpm -r run dev` is starting, and the install already on disk. */\nexport function initialLateWorkspaceMemberState(appRoot: string): LateWorkspaceMemberState {\n return {\n started: new Set(listWorkspaceDevMembers(appRoot).map((member) => member.name)),\n installedAtMs: readNodeModulesInstalledAtMs(appRoot),\n };\n}\n\n/** How often the stack looks for a finished install. */\nexport const LATE_WORKSPACE_MEMBER_POLL_MS = 5_000;\n\n/**\n * What the runtimes' env files are written from, out of a `wildo.saas.config.ts` (#3985): the WHOLE declaration. The\n * runtime topology is the case measured — services, minions and workers become `APPLICATION_RUNTIME_ENDPOINTS`, and on\n * reference run 43876218697 `add-website` declared a website at 14:51, the companion restarted at 16:52 and crash-looped on\n * `frontendServices.<x> is declared but runtime.endPoints.<x> is missing` until the run ended. But the env writer also\n * derives from providers, systems of record, data services and key management, so a hand-picked subset of fields would be\n * a second list of what the writer reads, the kind that rots. Any change to the declaration therefore owes a regeneration,\n * which is what restarting `wildo local dev` would do.\n *\n * A canonical string: keys sorted at every depth (an edit that only reorders is not a change), functions and cycles named\n * rather than followed. It sees what is enumerable: a `Map`, a `Set` or a value kept on non-enumerable properties (a Zod\n * schema) serialises without its contents, so a change held only there is not seen. A declaration is plain data today.\n */\nexport function declarationFingerprint(config: unknown): string {\n const seen = new WeakSet<object>();\n const canonical = (value: unknown): unknown => {\n if (typeof value === 'function') return '[function]';\n if (typeof value === 'bigint') return value.toString();\n if (value === null || typeof value !== 'object') return value;\n if (seen.has(value)) return '[circular]';\n seen.add(value);\n const result = Array.isArray(value)\n ? value.map(canonical)\n : Object.fromEntries(Object.keys(value as Record<string, unknown>).sort().map((key) => [key, canonical((value as Record<string, unknown>)[key])]));\n seen.delete(value);\n return result;\n };\n return JSON.stringify(canonical(config));\n}\n\n/** The declaration the runtimes' env files were last written from, and the config file's state when it was read. */\nexport interface DeclarationState {\n /** `null` when the starting read failed: the first declaration read later is then owed a regeneration. */\n readonly fingerprint: string | null;\n /** The config file's modification time at that read: an unchanged file is never re-read. */\n readonly configModifiedAtMs: number | null;\n}\n\n/** The reads the reconcile pass makes, replaceable by a test. */\nexport interface WorkspaceReconcileReads {\n readonly installInFlight: (root: string) => boolean;\n readonly configModifiedAtMs: (root: string) => number | null;\n readonly loadFingerprint: (root: string) => Promise<string | null>;\n readonly installedAtMs: (root: string) => number | null;\n readonly members: (root: string) => readonly WorkspaceDevMember[];\n readonly now: () => number;\n}\n\nconst SAAS_CONFIG_FILE = 'wildo.saas.config.ts';\n\n/** After a failed regeneration, how long before the next attempt. */\nexport const ENV_REGENERATION_RETRY_MS = 60_000;\n\nexport const DEFAULT_WORKSPACE_RECONCILE_READS: WorkspaceReconcileReads = {\n installInFlight: isDependencyInstallInFlight,\n configModifiedAtMs: (root) => {\n try {\n return statSync(join(root, SAAS_CONFIG_FILE)).mtimeMs;\n } catch {\n return null;\n }\n },\n // Fresh: jiti's module cache is process-wide, and this process would otherwise read the declaration it started with.\n loadFingerprint: async (root) => {\n const config = await loadSaasConfig(join(root, SAAS_CONFIG_FILE), { freshModuleCache: true });\n return config === null ? null : declarationFingerprint(config);\n },\n installedAtMs: readNodeModulesInstalledAtMs,\n members: listWorkspaceDevMembers,\n now: () => Date.now(),\n};\n\n/**\n * One reconcile of the running stack with the workspace and the declaration (#3985, #3986), as `wildo local dev` runs it\n * every few seconds. Single-flight; nothing at all while an install runs. In ORDER, because a member that is also a\n * declared service needs a `.env` that knows it:\n *\n * 1. The declaration: when the config file changed and its fingerprint differs from what the env files were written from\n * (or that is unknown), the env files are OWED, and `regenerate` (the startup bootstrap) runs. A failure keeps them\n * owed and retries after {@link ENV_REGENERATION_RETRY_MS}. A declaration that does not load (an edit in progress)\n * owes nothing yet and is read again on the next change.\n * 2. The members: only when no regeneration is owed. Each member a finished install brought gets its dev process, once.\n * Accepted cost, recorded on #3986: a regeneration that KEEPS failing holds back every new member, a provider package\n * included (which reads no runtime `.env`). It is reported every minute, and restarting `wildo local dev` clears it;\n * telling the members that need a `.env` from those that do not would take a second reading of the declaration.\n */\nexport function createWorkspaceReconciler(input: {\n readonly appRoot: string;\n /** Whether the env files can be regenerated at all (startup regenerates only with a framework path). */\n readonly canRegenerate: boolean;\n readonly regenerate: () => Promise<void>;\n readonly startMember: (member: WorkspaceDevMember) => void;\n readonly isStopping: () => boolean;\n readonly reportRegenerationFailure: (error: unknown) => void;\n readonly initial: { readonly declaration: DeclarationState; readonly members: LateWorkspaceMemberState };\n readonly reads?: WorkspaceReconcileReads;\n}): { readonly reconcile: () => Promise<void>; readonly regenerationOwed: () => boolean } {\n const reads = input.reads ?? DEFAULT_WORKSPACE_RECONCILE_READS;\n let declaration = input.initial.declaration;\n let members = input.initial.members;\n let owed: string | null = null; // the fingerprint whose env files are owed\n let retryAtMs = 0;\n let running = false;\n const reconcile = async (): Promise<void> => {\n if (running || input.isStopping() || reads.installInFlight(input.appRoot)) return;\n running = true;\n try {\n if (input.canRegenerate) {\n const modifiedAtMs = reads.configModifiedAtMs(input.appRoot);\n if (modifiedAtMs !== null && modifiedAtMs !== declaration.configModifiedAtMs) {\n let fingerprint: string | null = null;\n try {\n fingerprint = await reads.loadFingerprint(input.appRoot);\n } catch {\n fingerprint = null;\n }\n if (fingerprint !== null) {\n if (fingerprint !== declaration.fingerprint) owed = fingerprint;\n declaration = { fingerprint, configModifiedAtMs: modifiedAtMs };\n }\n }\n if (owed !== null && reads.now() >= retryAtMs) {\n try {\n await input.regenerate();\n owed = null;\n } catch (error) {\n retryAtMs = reads.now() + ENV_REGENERATION_RETRY_MS;\n input.reportRegenerationFailure(error);\n }\n }\n // The env files first: a member started now would read a `.env` that may not know it.\n if (owed !== null || input.isStopping()) return;\n }\n const decision = decideLateWorkspaceMembers(input.appRoot, members, reads);\n members = decision.state;\n for (const member of decision.toStart) input.startMember(member);\n } finally {\n running = false;\n }\n };\n return { reconcile, regenerationOwed: () => owed !== null };\n}\n\n/** The declaration the stack started from: what its env files were written from moments ago. */\nexport async function initialDeclarationState(appRoot: string, reads: WorkspaceReconcileReads = DEFAULT_WORKSPACE_RECONCILE_READS): Promise<DeclarationState> {\n const configModifiedAtMs = reads.configModifiedAtMs(appRoot);\n try {\n const fingerprint = await reads.loadFingerprint(appRoot);\n return fingerprint === null ? { fingerprint: null, configModifiedAtMs: null } : { fingerprint, configModifiedAtMs };\n } catch {\n // Unknown: the first declaration read later is owed a regeneration rather than taken as the baseline.\n return { fingerprint: null, configModifiedAtMs: null };\n }\n}\n\n/** Bound on the provider-artifact sync: it reads configuration and writes generated files, and must not hold the reconcile. */\nconst PROVIDER_ARTIFACT_SYNC_TIMEOUT_MS = 5 * 60 * 1000;\n\n/**\n * Regenerate the application's provider runtime artifacts after a declaration change (#3985), as `wildo config sync\n * --domain config` writes them: the per-runtime provider lists, the generated provider modules, the CSP.\n *\n * The env files are not the only thing a declaration change leaves behind. Measured on reference run 43937787170: the\n * foundation declared `email-preview` and `stripe` at 20:31, the backend's provider artifact still listed none (written by\n * `wildo init` at 19:23), and the backend refused six times with \"Required engine capabilities resolve no active provider:\n * [BILLING, EMAIL_TRANSACTIONAL]\" and paused, with the build about to start. The same class as Wonder Procurement's on\n * 2026-10-07 (`findProviderRuntimeArtifactsBehindDeclaration`), which a restart repairs and a running stack never did.\n *\n * Run as a CHILD of this CLI: in this long-lived process the configuration loader's module cache still holds the\n * declaration the stack started with, and a sync reading it would regenerate the very artifacts that are behind. Rejects\n * when the child fails, so the reconcile keeps the regeneration owed and retries.\n */\nexport async function syncProviderRuntimeArtifactsInChild(\n saasRoot: string,\n envName: string,\n run: (file: string, args: readonly string[], options: { cwd: string; timeout: number }) => Promise<unknown> = defaultRunChild,\n): Promise<void> {\n const cliEntry = process.argv[1];\n if (cliEntry === undefined) throw new Error('The wildo CLI entry point is unknown, so the provider artifacts cannot be regenerated.');\n await run(process.execPath, [cliEntry, 'config', 'sync', '--domain', 'config', '--env', envName, '--non-interactive'], {\n cwd: saasRoot,\n timeout: PROVIDER_ARTIFACT_SYNC_TIMEOUT_MS,\n });\n}\n\nconst defaultRunChild = (file: string, args: readonly string[], options: { cwd: string; timeout: number }): Promise<unknown> =>\n promisify(execFile)(file, [...args], { ...options, maxBuffer: 16 * 1024 * 1024 });\n"]}
|
|
@@ -23,6 +23,15 @@ export declare function resolveAuthoredInfraConfigPath(saasRoot: string, envName
|
|
|
23
23
|
* through the shared loader.
|
|
24
24
|
*/
|
|
25
25
|
export declare function loadAuthoredInfraEnvConfig(envName: string, saasRoot: string): Promise<LoadedAuthoredInfraEnvConfig | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the platform a HOST application owns runs a message broker, from its authored `local` descriptor (#2303
|
|
28
|
+
* slice D): `environmentServiceProfileRunsMessageBroker` of its `serviceProfile`. Read by `wildo init` before scaffolding
|
|
29
|
+
* a hosted application, whose descriptor must declare no RabbitMQ vhost on a host that runs no broker.
|
|
30
|
+
*
|
|
31
|
+
* A host with no readable `local` descriptor answers `true`, the broker every host ran before profiles existed: the
|
|
32
|
+
* scaffold keeps its previous shape, and the hosted resolution then names what is wrong with the host.
|
|
33
|
+
*/
|
|
34
|
+
export declare function readHostRunsMessageBroker(hostRoot: string): Promise<boolean>;
|
|
26
35
|
/** One authored environment: the directory name it lives under, and its loaded config. */
|
|
27
36
|
export interface LoadedNamedAuthoredInfraEnvConfig extends LoadedAuthoredInfraEnvConfig {
|
|
28
37
|
envName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored-infra-config.utils.d.ts","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-config.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"authored-infra-config.utils.d.ts","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-config.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAQL,KAAK,mBAAmB,EACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC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,CAAC,CAMnC;AAED;;;;GAIG;AACH,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,mBAAmB,GAC1B,qBAAqB,CAAC,UAAU,CAAC,CAenC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,CAEzE;AAED;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,mBAAmB,GAAG,qBAAqB,CAsEpG"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* ones `wildo config sync --domain manifest` would produce later.
|
|
11
11
|
*/
|
|
12
12
|
import { existsSync, readdirSync } from 'fs';
|
|
13
|
-
import { BackingServiceSource, DatabaseEngine, resolveApplicationDatabaseEngine, loadInfraEnvConfig, resolveAppLayout, resolveInfraEnvConfigPath, } from '@wildo-ai/platform-config-lib';
|
|
13
|
+
import { BackingServiceSource, DatabaseEngine, environmentServiceProfileRunsMessageBroker, resolveApplicationDatabaseEngine, loadInfraEnvConfig, resolveAppLayout, resolveInfraEnvConfigPath, } from '@wildo-ai/platform-config-lib';
|
|
14
14
|
import { DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION, DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION, } from '../../services/data-services/data-services.schemas.js';
|
|
15
15
|
/** The shared path rule (`resolveInfraEnvConfigPath` in platform-config-lib), kept under the CLI's historical name. */
|
|
16
16
|
export function resolveAuthoredInfraConfigPath(saasRoot, envName) {
|
|
@@ -24,6 +24,25 @@ export function resolveAuthoredInfraConfigPath(saasRoot, envName) {
|
|
|
24
24
|
export async function loadAuthoredInfraEnvConfig(envName, saasRoot) {
|
|
25
25
|
return loadInfraEnvConfig(saasRoot, envName);
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether the platform a HOST application owns runs a message broker, from its authored `local` descriptor (#2303
|
|
29
|
+
* slice D): `environmentServiceProfileRunsMessageBroker` of its `serviceProfile`. Read by `wildo init` before scaffolding
|
|
30
|
+
* a hosted application, whose descriptor must declare no RabbitMQ vhost on a host that runs no broker.
|
|
31
|
+
*
|
|
32
|
+
* A host with no readable `local` descriptor answers `true`, the broker every host ran before profiles existed: the
|
|
33
|
+
* scaffold keeps its previous shape, and the hosted resolution then names what is wrong with the host.
|
|
34
|
+
*/
|
|
35
|
+
export async function readHostRunsMessageBroker(hostRoot) {
|
|
36
|
+
try {
|
|
37
|
+
const loaded = await loadAuthoredInfraEnvConfig(HOST_LOCAL_ENVIRONMENT_NAME, hostRoot);
|
|
38
|
+
return environmentServiceProfileRunsMessageBroker(loaded?.config.serviceProfile);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** The environment a hosted scaffold is written for: the local one (`infrastructure/local/`). */
|
|
45
|
+
const HOST_LOCAL_ENVIRONMENT_NAME = 'local';
|
|
27
46
|
/**
|
|
28
47
|
* Every environment the application authors: each directory of its infrastructure home that carries an authored
|
|
29
48
|
* `wildo.infra.<local|remote>.config.ts`, loaded through {@link loadAuthoredInfraEnvConfig}. A directory without one is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored-infra-config.utils.js","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-config.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAE7C,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,gCAAgC,EAChC,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,GAE1B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,2CAA2C,EAC3C,yCAAyC,GAC1C,MAAM,yDAAyD,CAAC;AAOjE,uHAAuH;AACvH,MAAM,UAAU,8BAA8B,CAAC,QAAgB,EAAE,OAAe;IAC9E,OAAO,yBAAyB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC;AA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AY;QACjC,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;QACnD,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,UAAU,EAAE,MAAM,CAAC,UAAU;YAC3B,CAAC,CAAC;gBACE,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS;gBACtC,YAAY,EAAE,MAAM,CAAC,UAAU,CAAC,YAAY;gBAC5C,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ;aACrC;YACH,CAAC,CAAC,SAAS;QACb,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;QAC7C,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,sBAAsB,EAAE,MAAM,CAAC,sBAAsB;QACrD,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;QAC/C,+BAA+B,EAAE,MAAM,CAAC,+BAA+B;KACxE,CAAC;AACJ,CAAC","sourcesContent":["/**\n * authored-infra-config.utils — shared helpers for reading the authored\n * `wildo.infra.<env>.config.ts` descriptor and projecting it into the\n * platform-level `PlatformEnvConfigJson` shape.\n *\n * Originally lived as private helpers inside `commands/config/sync.command.ts`.\n * Extracted so the new runtime-bootstrap surface (used by `wildo local up`\n * pre-flight) can reuse the exact same projection — single source of truth\n * keeps the runtime artifacts written by `local up` byte-identical to the\n * ones `wildo config sync --domain manifest` would produce later.\n */\n\nimport { existsSync, readdirSync } from 'fs';\n\nimport {\n BackingServiceSource,\n DatabaseEngine,\n resolveApplicationDatabaseEngine,\n loadInfraEnvConfig,\n resolveAppLayout,\n resolveInfraEnvConfigPath,\n type WildoInfraEnvConfig,\n} from '@wildo-ai/platform-config-lib';\nimport type { PlatformEnvConfigJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport {\n DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION,\n DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION,\n} from '~wildo-cli/services/data-services/data-services.schemas';\n\nexport interface LoadedAuthoredInfraEnvConfig {\n path: string;\n config: WildoInfraEnvConfig;\n}\n\n/** The shared path rule (`resolveInfraEnvConfigPath` in platform-config-lib), kept under the CLI's historical name. */\nexport function resolveAuthoredInfraConfigPath(saasRoot: string, envName: string): string {\n return resolveInfraEnvConfigPath(saasRoot, envName);\n}\n\n/**\n * The shared loader (`loadInfraEnvConfig` in platform-config-lib), kept under the CLI's historical name and argument\n * order so its importers and the test that mocks this module are unchanged. The dev companion reads the same file\n * through the shared loader.\n */\nexport async function loadAuthoredInfraEnvConfig(\n envName: string,\n saasRoot: string,\n): Promise<LoadedAuthoredInfraEnvConfig | null> {\n return loadInfraEnvConfig(saasRoot, envName);\n}\n\n/** One authored environment: the directory name it lives under, and its loaded config. */\nexport interface LoadedNamedAuthoredInfraEnvConfig extends LoadedAuthoredInfraEnvConfig {\n envName: string;\n}\n\n/** An environment directory whose authored config failed to load, and why. */\nexport interface UnreadableAuthoredInfraEnvConfig {\n readonly envName: string;\n readonly error: unknown;\n}\n\n/**\n * One environment directory as {@link settleAllAuthoredInfraEnvConfigs} found it: loaded, or failing to load. Told apart\n * with `'error' in`, which narrows whether or not the compiling package checks nulls strictly.\n */\nexport type SettledAuthoredInfraEnvConfig = LoadedNamedAuthoredInfraEnvConfig | UnreadableAuthoredInfraEnvConfig;\n\n/**\n * Every environment the application authors: each directory of its infrastructure home that carries an authored\n * `wildo.infra.<local|remote>.config.ts`, loaded through {@link loadAuthoredInfraEnvConfig}. A directory without one is\n * not an environment and is skipped. Empty when the application has no infrastructure home.\n *\n * The ONE enumeration of an application's environments: the lockfile projections and the `config sync` servability\n * preflight (`loadAuthoredInfraEnvSelections`, #1693) and the schema planner's default adapter (#2708) all judge this\n * same population, so no reader can count one environment another misses. The dev companion cannot import this module\n * and restates the same walk for the same question (`assessApplicationSchemaPlanObligation`, #2724: is a baseline owed?);\n * change one, change both.\n *\n * SETTLED rather than thrown, so a reader that can still answer with the environments that did load decides that for\n * itself: the schema planner refuses only when an unreadable environment could change its answer.\n * {@link loadAllAuthoredInfraEnvConfigs} is the throwing form.\n */\nexport async function settleAllAuthoredInfraEnvConfigs(saasRoot: string): Promise<SettledAuthoredInfraEnvConfig[]> {\n const infraDir = resolveAppLayout(saasRoot).authoredInfrastructureHome;\n if (!existsSync(infraDir)) return [];\n const settled: SettledAuthoredInfraEnvConfig[] = [];\n for (const entry of readdirSync(infraDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n try {\n const authored = await loadAuthoredInfraEnvConfig(entry.name, saasRoot);\n if (authored) settled.push({ envName: entry.name, ...authored });\n } catch (error) {\n settled.push({ envName: entry.name, error });\n }\n }\n return settled;\n}\n\n/** {@link settleAllAuthoredInfraEnvConfigs}, throwing the first environment that failed to load. */\nexport async function loadAllAuthoredInfraEnvConfigs(saasRoot: string): Promise<LoadedNamedAuthoredInfraEnvConfig[]> {\n const loaded: LoadedNamedAuthoredInfraEnvConfig[] = [];\n for (const environment of await settleAllAuthoredInfraEnvConfigs(saasRoot)) {\n if ('error' in environment) throw environment.error;\n loaded.push(environment);\n }\n return loaded;\n}\n\n/**\n * Reason string when the authored infra config cannot serve as a config.json\n * fallback (currently: Atlas-backed environments require generated config.json\n * because authored infra config does not include Atlas API metadata or\n * external Mongo connection endpoints).\n */\nexport function getUnsupportedAuthoredConfigFallbackReason(\n envName: string,\n authoredConfigPath: string,\n authoredConfig: WildoInfraEnvConfig,\n): string | null {\n // Slice 4.B.0 (2026-05-07): Atlas detection now uses (source=MANAGED,\n // provider='atlas') instead of the legacy `source: ATLAS` enum value.\n // Same operational meaning — operator authored a managed Mongo whose\n // brand is Atlas; the generated config.json carries the Atlas API\n // metadata + external endpoints that the authored infra descriptor\n // doesn't include.\n const mongo = authoredConfig.backingServices.mongodb;\n if (mongo?.source === BackingServiceSource.MANAGED && mongo.provider === 'atlas') {\n return (\n `Cannot regenerate config for '${envName}' from authored infra descriptor at ${authoredConfigPath}: `\n + 'Atlas-backed environments require generated config.json because authored infra config '\n + 'does not include Atlas API metadata or external Mongo connection endpoints.'\n );\n }\n\n return null;\n}\n\n/**\n * Resolve the platform's database engine for an authored environment.\n *\n * **Precedence: an authored `database` block WINS; the inference below is the fallback.**\n *\n * The inference exists because the engine was historically not authorable at all — it lived only\n * as an answer to an interactive prompt in the machine-local `environments.json`. Every environment\n * predating the authored field relies on it, so it keeps its exact behaviour.\n *\n * What it cannot express, and why the authored field had to exist: the rule is\n * `postgresql && !mongodb`, while a PostgreSQL platform is REQUIRED to also declare\n * `backingServices.mongodb` (the bootstrap plane is Mongo-wired, and both this schema and\n * `env-vars-builder` refuse a PostgreSQL platform that renders no mongod). The intended state is\n * therefore `postgresql && mongodb`, which this function always resolves to MONGODB. It is not a\n * bug in the rule — it is a question the rule cannot be asked.\n *\n * This is the same inexpressibility Phase 5.1 fixed one layer down, where `needsLocalMongoDB` was\n * `engine === MONGODB && source === SELF` and became a union so that \"which containers render\"\n * stopped being collapsed into \"what engine is the platform\". The identical collapse survived here,\n * in \"what engine is the platform\" vs \"which services are declared\".\n *\n * **Deliberately NOT made smarter.** Widening it to \"postgresql present ⇒ PostgreSQL\" would flip\n * every environment that declares PostgreSQL as an APPLICATION-tier substrate — Wonder Todos'\n * `local` does exactly that today — into a PostgreSQL PLATFORM on its next `wildo config sync`.\n * A silent engine change on an existing environment is the worst outcome available here.\n */\nexport function resolveDatabaseChoiceFromInfraConfig(\n config: WildoInfraEnvConfig,\n): PlatformEnvConfigJson['database'] {\n if (config.database) {\n return config.database;\n }\n\n return inferDatabaseChoiceFromInfraConfig(config);\n}\n\n/**\n * The pre-authoring inference. Retained as the fallback for environments that author no `database`\n * block — see {@link resolveDatabaseChoiceFromInfraConfig} for the precedence and for why this\n * cannot express a PostgreSQL platform.\n */\nexport function inferDatabaseChoiceFromInfraConfig(\n config: WildoInfraEnvConfig,\n): PlatformEnvConfigJson['database'] {\n const postgresql = config.backingServices.postgresql;\n const mongodb = config.backingServices.mongodb;\n\n if (postgresql && !mongodb) {\n return {\n engine: DatabaseEngine.POSTGRESQL,\n source: postgresql.source,\n };\n }\n\n return {\n engine: DatabaseEngine.MONGODB,\n source: mongodb?.source ?? BackingServiceSource.SELF,\n };\n}\n\n/**\n * The bytes `config.json` holds: the one serialization every writer of the generated file uses (the local self-heal,\n * `config sync`, and the remote overlay of `loadConfigForSync`), so equal content is equal bytes and a file is\n * rewritten only when its content moves (#2311).\n */\nexport function serializeConfigJson(config: PlatformEnvConfigJson): string {\n return `${JSON.stringify(config, null, 2)}\\n`;\n}\n\n/**\n * Project a parsed `wildo.infra.<env>.config.ts` into the persisted\n * platform-level `environments/<env>/config.json` shape.\n *\n * `devCompanion` is intentionally NOT persisted here — see Slice 3 deep-review\n * M-5 note in `commands/config/sync.command.ts` for the dual-config-json\n * design rationale.\n */\nexport function buildConfigJsonFromInfraEnvConfig(config: WildoInfraEnvConfig): PlatformEnvConfigJson {\n const storage = config.backingServices.s3;\n const postgresql = config.backingServices.postgresql;\n\n return {\n type: config.locationType,\n runtime: config.runtime,\n runtimeEnvironment: config.runtimeEnvironment,\n /**\n * Always present here, never `undefined`: the authored schema resolves its own default from\n * `locationType` in the transform, so what reaches this projection is the environment's settled\n * answer rather than what the author happened to type.\n */\n localDataStorage: config.localDataStorage,\n /** Always present: the descriptor transform resolves `FULL` when nothing is authored (#2303). */\n serviceProfile: config.serviceProfile,\n database: resolveDatabaseChoiceFromInfraConfig(config),\n /**\n * The APPLICATION's engine — RESOLVED, never inferred and never left absent.\n *\n * Absence means PostgreSQL (`DEFAULT_APPLICATION_DATABASE_ENGINE`, #1571), and it is resolved HERE\n * so `config.json` always carries an explicit engine: every later reader of the file — the\n * bootstrap request, the e2e store probe — then sees the same answer without holding its own copy\n * of the default. Inferring it from which backing services are declared would resurrect exactly\n * the defect the authored field exists to remove, since `postgresql && mongodb` is both the normal\n * state and unresolvable by inference.\n *\n * ⚠️ THIS is the projection that writes `config.json`, not the `transform` in\n * `defineInfraEnvConfig`. Both exist and both must carry a new field: the transform feeds\n * in-process consumers, this one feeds the file every generator later reads. Adding the field to\n * only the transform (2026-08-19) produced a silently ABSENT key here — the reconcile reported\n * success and `applicationDatabase` simply was not in the written file.\n */\n applicationDatabase: { engine: resolveApplicationDatabaseEngine(config.applicationDatabase) },\n infrastructure: {\n storage: {\n provider: (storage?.provider ?? DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION.PROVIDER) as 'minio',\n useSsl: storage?.endpoint?.startsWith('https://') ?? false,\n bucket: storage?.bucket ?? DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION.BUCKET,\n },\n postgresql: {\n database: postgresql?.database ?? DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION.DATABASE,\n sslMode: DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION.SSL_MODE,\n },\n },\n publicDomain: config.publicDomain,\n serviceHosts: config.serviceHosts,\n cdn: config.cdn,\n platformStorage: config.platformStorage,\n platformKeyManagement: config.platformKeyManagement,\n systemsOfRecord: config.systemsOfRecord,\n kubernetes: config.kubernetes\n ? {\n namespace: config.kubernetes.namespace,\n ingressClass: config.kubernetes.ingressClass,\n services: config.kubernetes.services,\n }\n : undefined,\n remoteProvider: config.remoteProvider,\n infrastructureHost: config.infrastructureHost,\n backingServices: config.backingServices,\n serviceAuth: config.serviceAuth,\n logging: config.logging,\n observability: config.observability,\n providerSelection: config.providerSelection,\n email: config.email,\n agentContentGuardrails: config.agentContentGuardrails,\n ownershipDnsStandIn: config.ownershipDnsStandIn,\n applicationCreationVerification: config.applicationCreationVerification,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"authored-infra-config.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,CAAC,SAAS;QACb,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;QAC7C,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,sBAAsB,EAAE,MAAM,CAAC,sBAAsB;QACrD,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;QAC/C,+BAA+B,EAAE,MAAM,CAAC,+BAA+B;KACxE,CAAC;AACJ,CAAC","sourcesContent":["/**\n * authored-infra-config.utils — shared helpers for reading the authored\n * `wildo.infra.<env>.config.ts` descriptor and projecting it into the\n * platform-level `PlatformEnvConfigJson` shape.\n *\n * Originally lived as private helpers inside `commands/config/sync.command.ts`.\n * Extracted so the new runtime-bootstrap surface (used by `wildo local up`\n * pre-flight) can reuse the exact same projection — single source of truth\n * keeps the runtime artifacts written by `local up` byte-identical to the\n * ones `wildo config sync --domain manifest` would produce later.\n */\n\nimport { existsSync, readdirSync } from 'fs';\n\nimport {\n BackingServiceSource,\n DatabaseEngine,\n environmentServiceProfileRunsMessageBroker,\n resolveApplicationDatabaseEngine,\n loadInfraEnvConfig,\n resolveAppLayout,\n resolveInfraEnvConfigPath,\n type WildoInfraEnvConfig,\n} from '@wildo-ai/platform-config-lib';\nimport type { PlatformEnvConfigJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport {\n DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION,\n DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION,\n} from '~wildo-cli/services/data-services/data-services.schemas';\n\nexport interface LoadedAuthoredInfraEnvConfig {\n path: string;\n config: WildoInfraEnvConfig;\n}\n\n/** The shared path rule (`resolveInfraEnvConfigPath` in platform-config-lib), kept under the CLI's historical name. */\nexport function resolveAuthoredInfraConfigPath(saasRoot: string, envName: string): string {\n return resolveInfraEnvConfigPath(saasRoot, envName);\n}\n\n/**\n * The shared loader (`loadInfraEnvConfig` in platform-config-lib), kept under the CLI's historical name and argument\n * order so its importers and the test that mocks this module are unchanged. The dev companion reads the same file\n * through the shared loader.\n */\nexport async function loadAuthoredInfraEnvConfig(\n envName: string,\n saasRoot: string,\n): Promise<LoadedAuthoredInfraEnvConfig | null> {\n return loadInfraEnvConfig(saasRoot, envName);\n}\n\n/**\n * Whether the platform a HOST application owns runs a message broker, from its authored `local` descriptor (#2303\n * slice D): `environmentServiceProfileRunsMessageBroker` of its `serviceProfile`. Read by `wildo init` before scaffolding\n * a hosted application, whose descriptor must declare no RabbitMQ vhost on a host that runs no broker.\n *\n * A host with no readable `local` descriptor answers `true`, the broker every host ran before profiles existed: the\n * scaffold keeps its previous shape, and the hosted resolution then names what is wrong with the host.\n */\nexport async function readHostRunsMessageBroker(hostRoot: string): Promise<boolean> {\n try {\n const loaded = await loadAuthoredInfraEnvConfig(HOST_LOCAL_ENVIRONMENT_NAME, hostRoot);\n return environmentServiceProfileRunsMessageBroker(loaded?.config.serviceProfile);\n } catch {\n return true;\n }\n}\n\n/** The environment a hosted scaffold is written for: the local one (`infrastructure/local/`). */\nconst HOST_LOCAL_ENVIRONMENT_NAME = 'local';\n\n/** One authored environment: the directory name it lives under, and its loaded config. */\nexport interface LoadedNamedAuthoredInfraEnvConfig extends LoadedAuthoredInfraEnvConfig {\n envName: string;\n}\n\n/** An environment directory whose authored config failed to load, and why. */\nexport interface UnreadableAuthoredInfraEnvConfig {\n readonly envName: string;\n readonly error: unknown;\n}\n\n/**\n * One environment directory as {@link settleAllAuthoredInfraEnvConfigs} found it: loaded, or failing to load. Told apart\n * with `'error' in`, which narrows whether or not the compiling package checks nulls strictly.\n */\nexport type SettledAuthoredInfraEnvConfig = LoadedNamedAuthoredInfraEnvConfig | UnreadableAuthoredInfraEnvConfig;\n\n/**\n * Every environment the application authors: each directory of its infrastructure home that carries an authored\n * `wildo.infra.<local|remote>.config.ts`, loaded through {@link loadAuthoredInfraEnvConfig}. A directory without one is\n * not an environment and is skipped. Empty when the application has no infrastructure home.\n *\n * The ONE enumeration of an application's environments: the lockfile projections and the `config sync` servability\n * preflight (`loadAuthoredInfraEnvSelections`, #1693) and the schema planner's default adapter (#2708) all judge this\n * same population, so no reader can count one environment another misses. The dev companion cannot import this module\n * and restates the same walk for the same question (`assessApplicationSchemaPlanObligation`, #2724: is a baseline owed?);\n * change one, change both.\n *\n * SETTLED rather than thrown, so a reader that can still answer with the environments that did load decides that for\n * itself: the schema planner refuses only when an unreadable environment could change its answer.\n * {@link loadAllAuthoredInfraEnvConfigs} is the throwing form.\n */\nexport async function settleAllAuthoredInfraEnvConfigs(saasRoot: string): Promise<SettledAuthoredInfraEnvConfig[]> {\n const infraDir = resolveAppLayout(saasRoot).authoredInfrastructureHome;\n if (!existsSync(infraDir)) return [];\n const settled: SettledAuthoredInfraEnvConfig[] = [];\n for (const entry of readdirSync(infraDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n try {\n const authored = await loadAuthoredInfraEnvConfig(entry.name, saasRoot);\n if (authored) settled.push({ envName: entry.name, ...authored });\n } catch (error) {\n settled.push({ envName: entry.name, error });\n }\n }\n return settled;\n}\n\n/** {@link settleAllAuthoredInfraEnvConfigs}, throwing the first environment that failed to load. */\nexport async function loadAllAuthoredInfraEnvConfigs(saasRoot: string): Promise<LoadedNamedAuthoredInfraEnvConfig[]> {\n const loaded: LoadedNamedAuthoredInfraEnvConfig[] = [];\n for (const environment of await settleAllAuthoredInfraEnvConfigs(saasRoot)) {\n if ('error' in environment) throw environment.error;\n loaded.push(environment);\n }\n return loaded;\n}\n\n/**\n * Reason string when the authored infra config cannot serve as a config.json\n * fallback (currently: Atlas-backed environments require generated config.json\n * because authored infra config does not include Atlas API metadata or\n * external Mongo connection endpoints).\n */\nexport function getUnsupportedAuthoredConfigFallbackReason(\n envName: string,\n authoredConfigPath: string,\n authoredConfig: WildoInfraEnvConfig,\n): string | null {\n // Slice 4.B.0 (2026-05-07): Atlas detection now uses (source=MANAGED,\n // provider='atlas') instead of the legacy `source: ATLAS` enum value.\n // Same operational meaning — operator authored a managed Mongo whose\n // brand is Atlas; the generated config.json carries the Atlas API\n // metadata + external endpoints that the authored infra descriptor\n // doesn't include.\n const mongo = authoredConfig.backingServices.mongodb;\n if (mongo?.source === BackingServiceSource.MANAGED && mongo.provider === 'atlas') {\n return (\n `Cannot regenerate config for '${envName}' from authored infra descriptor at ${authoredConfigPath}: `\n + 'Atlas-backed environments require generated config.json because authored infra config '\n + 'does not include Atlas API metadata or external Mongo connection endpoints.'\n );\n }\n\n return null;\n}\n\n/**\n * Resolve the platform's database engine for an authored environment.\n *\n * **Precedence: an authored `database` block WINS; the inference below is the fallback.**\n *\n * The inference exists because the engine was historically not authorable at all — it lived only\n * as an answer to an interactive prompt in the machine-local `environments.json`. Every environment\n * predating the authored field relies on it, so it keeps its exact behaviour.\n *\n * What it cannot express, and why the authored field had to exist: the rule is\n * `postgresql && !mongodb`, while a PostgreSQL platform is REQUIRED to also declare\n * `backingServices.mongodb` (the bootstrap plane is Mongo-wired, and both this schema and\n * `env-vars-builder` refuse a PostgreSQL platform that renders no mongod). The intended state is\n * therefore `postgresql && mongodb`, which this function always resolves to MONGODB. It is not a\n * bug in the rule — it is a question the rule cannot be asked.\n *\n * This is the same inexpressibility Phase 5.1 fixed one layer down, where `needsLocalMongoDB` was\n * `engine === MONGODB && source === SELF` and became a union so that \"which containers render\"\n * stopped being collapsed into \"what engine is the platform\". The identical collapse survived here,\n * in \"what engine is the platform\" vs \"which services are declared\".\n *\n * **Deliberately NOT made smarter.** Widening it to \"postgresql present ⇒ PostgreSQL\" would flip\n * every environment that declares PostgreSQL as an APPLICATION-tier substrate — Wonder Todos'\n * `local` does exactly that today — into a PostgreSQL PLATFORM on its next `wildo config sync`.\n * A silent engine change on an existing environment is the worst outcome available here.\n */\nexport function resolveDatabaseChoiceFromInfraConfig(\n config: WildoInfraEnvConfig,\n): PlatformEnvConfigJson['database'] {\n if (config.database) {\n return config.database;\n }\n\n return inferDatabaseChoiceFromInfraConfig(config);\n}\n\n/**\n * The pre-authoring inference. Retained as the fallback for environments that author no `database`\n * block — see {@link resolveDatabaseChoiceFromInfraConfig} for the precedence and for why this\n * cannot express a PostgreSQL platform.\n */\nexport function inferDatabaseChoiceFromInfraConfig(\n config: WildoInfraEnvConfig,\n): PlatformEnvConfigJson['database'] {\n const postgresql = config.backingServices.postgresql;\n const mongodb = config.backingServices.mongodb;\n\n if (postgresql && !mongodb) {\n return {\n engine: DatabaseEngine.POSTGRESQL,\n source: postgresql.source,\n };\n }\n\n return {\n engine: DatabaseEngine.MONGODB,\n source: mongodb?.source ?? BackingServiceSource.SELF,\n };\n}\n\n/**\n * The bytes `config.json` holds: the one serialization every writer of the generated file uses (the local self-heal,\n * `config sync`, and the remote overlay of `loadConfigForSync`), so equal content is equal bytes and a file is\n * rewritten only when its content moves (#2311).\n */\nexport function serializeConfigJson(config: PlatformEnvConfigJson): string {\n return `${JSON.stringify(config, null, 2)}\\n`;\n}\n\n/**\n * Project a parsed `wildo.infra.<env>.config.ts` into the persisted\n * platform-level `environments/<env>/config.json` shape.\n *\n * `devCompanion` is intentionally NOT persisted here — see Slice 3 deep-review\n * M-5 note in `commands/config/sync.command.ts` for the dual-config-json\n * design rationale.\n */\nexport function buildConfigJsonFromInfraEnvConfig(config: WildoInfraEnvConfig): PlatformEnvConfigJson {\n const storage = config.backingServices.s3;\n const postgresql = config.backingServices.postgresql;\n\n return {\n type: config.locationType,\n runtime: config.runtime,\n runtimeEnvironment: config.runtimeEnvironment,\n /**\n * Always present here, never `undefined`: the authored schema resolves its own default from\n * `locationType` in the transform, so what reaches this projection is the environment's settled\n * answer rather than what the author happened to type.\n */\n localDataStorage: config.localDataStorage,\n /** Always present: the descriptor transform resolves `FULL` when nothing is authored (#2303). */\n serviceProfile: config.serviceProfile,\n database: resolveDatabaseChoiceFromInfraConfig(config),\n /**\n * The APPLICATION's engine — RESOLVED, never inferred and never left absent.\n *\n * Absence means PostgreSQL (`DEFAULT_APPLICATION_DATABASE_ENGINE`, #1571), and it is resolved HERE\n * so `config.json` always carries an explicit engine: every later reader of the file — the\n * bootstrap request, the e2e store probe — then sees the same answer without holding its own copy\n * of the default. Inferring it from which backing services are declared would resurrect exactly\n * the defect the authored field exists to remove, since `postgresql && mongodb` is both the normal\n * state and unresolvable by inference.\n *\n * ⚠️ THIS is the projection that writes `config.json`, not the `transform` in\n * `defineInfraEnvConfig`. Both exist and both must carry a new field: the transform feeds\n * in-process consumers, this one feeds the file every generator later reads. Adding the field to\n * only the transform (2026-08-19) produced a silently ABSENT key here — the reconcile reported\n * success and `applicationDatabase` simply was not in the written file.\n */\n applicationDatabase: { engine: resolveApplicationDatabaseEngine(config.applicationDatabase) },\n infrastructure: {\n storage: {\n provider: (storage?.provider ?? DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION.PROVIDER) as 'minio',\n useSsl: storage?.endpoint?.startsWith('https://') ?? false,\n bucket: storage?.bucket ?? DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION.BUCKET,\n },\n postgresql: {\n database: postgresql?.database ?? DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION.DATABASE,\n sslMode: DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION.SSL_MODE,\n },\n },\n publicDomain: config.publicDomain,\n serviceHosts: config.serviceHosts,\n cdn: config.cdn,\n platformStorage: config.platformStorage,\n platformKeyManagement: config.platformKeyManagement,\n systemsOfRecord: config.systemsOfRecord,\n kubernetes: config.kubernetes\n ? {\n namespace: config.kubernetes.namespace,\n ingressClass: config.kubernetes.ingressClass,\n services: config.kubernetes.services,\n }\n : undefined,\n remoteProvider: config.remoteProvider,\n infrastructureHost: config.infrastructureHost,\n backingServices: config.backingServices,\n serviceAuth: config.serviceAuth,\n logging: config.logging,\n observability: config.observability,\n providerSelection: config.providerSelection,\n email: config.email,\n agentContentGuardrails: config.agentContentGuardrails,\n ownershipDnsStandIn: config.ownershipDnsStandIn,\n applicationCreationVerification: config.applicationCreationVerification,\n };\n}\n"]}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The name a container of a LOCAL environment reaches a process on the host by, in BOTH container lanes: compose maps it
|
|
3
|
+
* to `host-gateway` (`COMPOSE_HOST_GATEWAY_EXTRA_HOST`), and a Kind scheduler pod resolves it through the cluster's DNS or
|
|
4
|
+
* a `hostAliases` entry (`resolveKindPodHostGateway`, #3957). Docker Desktop's own name for the host.
|
|
5
|
+
*/
|
|
6
|
+
export declare const CONTAINER_HOST_GATEWAY_HOSTNAME = "host.docker.internal";
|
|
1
7
|
/**
|
|
2
8
|
* What {@link resolveContainerHostGatewayListenHost} reads from the machine. Injected so the decision is testable on any
|
|
3
9
|
* host; {@link SYSTEM_CONTAINER_HOST_GATEWAY_PROBE} is the real one.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container-host-gateway-listen-host.d.ts","sourceRoot":"","sources":["../../../../src/services/environment/container-host-gateway-listen-host.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IACnC,2HAA2H;IAC3H,kBAAkB,IAAI,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAC/C;;;OAGG;IACH,uBAAuB,IAAI,SAAS,MAAM,EAAE,CAAC;CAC9C;AAQD,eAAO,MAAM,mCAAmC,EAAE,yBAmBjD,CAAC;AAKF;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,GAAE,MAAM,MAA8D,GAAG,SAAS,MAAM,EAAE,CAQ1I;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAY7E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qCAAqC,CAAC,KAAK,GAAE,yBAA+D,GAAG,MAAM,GAAG,SAAS,CAKhJ"}
|
|
1
|
+
{"version":3,"file":"container-host-gateway-listen-host.d.ts","sourceRoot":"","sources":["../../../../src/services/environment/container-host-gateway-listen-host.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,yBAAyB,CAAC;AAEtE;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IACnC,2HAA2H;IAC3H,kBAAkB,IAAI,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAC/C;;;OAGG;IACH,uBAAuB,IAAI,SAAS,MAAM,EAAE,CAAC;CAC9C;AAQD,eAAO,MAAM,mCAAmC,EAAE,yBAmBjD,CAAC;AAKF;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,GAAE,MAAM,MAA8D,GAAG,SAAS,MAAM,EAAE,CAQ1I;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAY7E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qCAAqC,CAAC,KAAK,GAAE,yBAA+D,GAAG,MAAM,GAAG,SAAS,CAKhJ"}
|
|
@@ -2,6 +2,12 @@ import { execFileSync } from 'node:child_process';
|
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { isIPv4 } from 'node:net';
|
|
4
4
|
import { networkInterfaces } from 'node:os';
|
|
5
|
+
/**
|
|
6
|
+
* The name a container of a LOCAL environment reaches a process on the host by, in BOTH container lanes: compose maps it
|
|
7
|
+
* to `host-gateway` (`COMPOSE_HOST_GATEWAY_EXTRA_HOST`), and a Kind scheduler pod resolves it through the cluster's DNS or
|
|
8
|
+
* a `hostAliases` entry (`resolveKindPodHostGateway`, #3957). Docker Desktop's own name for the host.
|
|
9
|
+
*/
|
|
10
|
+
export const CONTAINER_HOST_GATEWAY_HOSTNAME = 'host.docker.internal';
|
|
5
11
|
/**
|
|
6
12
|
* The deadline on the `docker` call. Generating environment files must not hang on a daemon that accepts the connection
|
|
7
13
|
* and never answers; a missing answer costs only the Linux compose runtimes' reach, which the backend's log then names.
|