@wildo-ai/wildo-cli 1.1.12 → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/src/commands/config/sync.command.d.ts.map +1 -1
  2. package/dist/src/commands/config/sync.command.js +1 -0
  3. package/dist/src/commands/config/sync.command.js.map +1 -1
  4. package/dist/src/commands/context/journey.command.d.ts.map +1 -1
  5. package/dist/src/commands/context/journey.command.js +8 -0
  6. package/dist/src/commands/context/journey.command.js.map +1 -1
  7. package/dist/src/commands/creation/drive.command.d.ts.map +1 -1
  8. package/dist/src/commands/creation/drive.command.js +2 -0
  9. package/dist/src/commands/creation/drive.command.js.map +1 -1
  10. package/dist/src/commands/fwk/publish-all.command.d.ts.map +1 -1
  11. package/dist/src/commands/fwk/publish-all.command.js +8 -0
  12. package/dist/src/commands/fwk/publish-all.command.js.map +1 -1
  13. package/dist/src/commands/local/dev.command.d.ts +68 -0
  14. package/dist/src/commands/local/dev.command.d.ts.map +1 -1
  15. package/dist/src/commands/local/dev.command.js +216 -8
  16. package/dist/src/commands/local/dev.command.js.map +1 -1
  17. package/dist/src/commands/local/doctor.command.d.ts +22 -9
  18. package/dist/src/commands/local/doctor.command.d.ts.map +1 -1
  19. package/dist/src/commands/local/doctor.command.js +45 -42
  20. package/dist/src/commands/local/doctor.command.js.map +1 -1
  21. package/dist/src/commands/providers/connect.command.d.ts.map +1 -1
  22. package/dist/src/commands/providers/connect.command.js +11 -1
  23. package/dist/src/commands/providers/connect.command.js.map +1 -1
  24. package/dist/src/commands/seal/currency.command.d.ts +13 -0
  25. package/dist/src/commands/seal/currency.command.d.ts.map +1 -0
  26. package/dist/src/commands/seal/currency.command.js +52 -0
  27. package/dist/src/commands/seal/currency.command.js.map +1 -0
  28. package/dist/src/commands/seal/seal-admin-door.utils.d.ts.map +1 -1
  29. package/dist/src/commands/seal/seal-admin-door.utils.js +2 -0
  30. package/dist/src/commands/seal/seal-admin-door.utils.js.map +1 -1
  31. package/dist/src/commands/seal/verify.command.d.ts +5 -0
  32. package/dist/src/commands/seal/verify.command.d.ts.map +1 -1
  33. package/dist/src/commands/seal/verify.command.js +26 -2
  34. package/dist/src/commands/seal/verify.command.js.map +1 -1
  35. package/dist/src/services/application/content-guardrail-classifier.service.d.ts +19 -0
  36. package/dist/src/services/application/content-guardrail-classifier.service.d.ts.map +1 -1
  37. package/dist/src/services/application/content-guardrail-classifier.service.js +75 -11
  38. package/dist/src/services/application/content-guardrail-classifier.service.js.map +1 -1
  39. package/dist/src/services/application/local-provider-doubles.service.d.ts +98 -0
  40. package/dist/src/services/application/local-provider-doubles.service.d.ts.map +1 -0
  41. package/dist/src/services/application/local-provider-doubles.service.js +214 -0
  42. package/dist/src/services/application/local-provider-doubles.service.js.map +1 -0
  43. package/dist/src/services/application/system-of-record-simulators.service.d.ts +21 -2
  44. package/dist/src/services/application/system-of-record-simulators.service.d.ts.map +1 -1
  45. package/dist/src/services/application/system-of-record-simulators.service.js +21 -12
  46. package/dist/src/services/application/system-of-record-simulators.service.js.map +1 -1
  47. package/dist/src/services/companion/creation-drive.service.d.ts +32 -2
  48. package/dist/src/services/companion/creation-drive.service.d.ts.map +1 -1
  49. package/dist/src/services/companion/creation-drive.service.js +61 -4
  50. package/dist/src/services/companion/creation-drive.service.js.map +1 -1
  51. package/dist/src/services/credentials/credentials.schemas.d.ts +6 -0
  52. package/dist/src/services/credentials/credentials.schemas.d.ts.map +1 -1
  53. package/dist/src/services/credentials/credentials.schemas.js +7 -1
  54. package/dist/src/services/credentials/credentials.schemas.js.map +1 -1
  55. package/dist/src/services/credentials/provider-env-vars.utils.d.ts.map +1 -1
  56. package/dist/src/services/credentials/provider-env-vars.utils.js +11 -3
  57. package/dist/src/services/credentials/provider-env-vars.utils.js.map +1 -1
  58. package/dist/src/services/data-services/data-services.schemas.d.ts +9 -0
  59. package/dist/src/services/data-services/data-services.schemas.d.ts.map +1 -1
  60. package/dist/src/services/data-services/data-services.schemas.js +9 -0
  61. package/dist/src/services/data-services/data-services.schemas.js.map +1 -1
  62. package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts.map +1 -1
  63. package/dist/src/services/deployment/docker/docker-compose-generator.service.js +7 -2
  64. package/dist/src/services/deployment/docker/docker-compose-generator.service.js.map +1 -1
  65. package/dist/src/services/deployment/local-dev-session-lease.service.d.ts.map +1 -1
  66. package/dist/src/services/deployment/local-dev-session-lease.service.js +22 -1
  67. package/dist/src/services/deployment/local-dev-session-lease.service.js.map +1 -1
  68. package/dist/src/services/environment/authored-infra-config.utils.d.ts.map +1 -1
  69. package/dist/src/services/environment/authored-infra-config.utils.js +1 -0
  70. package/dist/src/services/environment/authored-infra-config.utils.js.map +1 -1
  71. package/dist/src/services/environment/authored-infra-member-authority.d.ts.map +1 -1
  72. package/dist/src/services/environment/authored-infra-member-authority.js +5 -0
  73. package/dist/src/services/environment/authored-infra-member-authority.js.map +1 -1
  74. package/dist/src/services/environment/env-configuration-generator.service.d.ts.map +1 -1
  75. package/dist/src/services/environment/env-configuration-generator.service.js +6 -3
  76. package/dist/src/services/environment/env-configuration-generator.service.js.map +1 -1
  77. package/dist/src/services/environment/env-vars-builder.service.d.ts +6 -0
  78. package/dist/src/services/environment/env-vars-builder.service.d.ts.map +1 -1
  79. package/dist/src/services/environment/env-vars-builder.service.js +24 -1
  80. package/dist/src/services/environment/env-vars-builder.service.js.map +1 -1
  81. package/dist/src/services/environment/environment-hydration.utils.d.ts.map +1 -1
  82. package/dist/src/services/environment/environment-hydration.utils.js +1 -0
  83. package/dist/src/services/environment/environment-hydration.utils.js.map +1 -1
  84. package/dist/src/services/environment/environment.schemas.d.ts +7 -1
  85. package/dist/src/services/environment/environment.schemas.d.ts.map +1 -1
  86. package/dist/src/services/environment/environment.schemas.js.map +1 -1
  87. package/dist/src/services/environment/runtime-bootstrap.service.d.ts +2 -0
  88. package/dist/src/services/environment/runtime-bootstrap.service.d.ts.map +1 -1
  89. package/dist/src/services/environment/runtime-bootstrap.service.js +4 -0
  90. package/dist/src/services/environment/runtime-bootstrap.service.js.map +1 -1
  91. package/dist/src/services/framework/framework-docker-publish.service.d.ts +13 -0
  92. package/dist/src/services/framework/framework-docker-publish.service.d.ts.map +1 -1
  93. package/dist/src/services/framework/framework-docker-publish.service.js +24 -7
  94. package/dist/src/services/framework/framework-docker-publish.service.js.map +1 -1
  95. package/dist/src/services/registry/provider-connect.service.d.ts +57 -1
  96. package/dist/src/services/registry/provider-connect.service.d.ts.map +1 -1
  97. package/dist/src/services/registry/provider-connect.service.js +63 -2
  98. package/dist/src/services/registry/provider-connect.service.js.map +1 -1
  99. package/dist/tsconfig.build.tsbuildinfo +1 -1
  100. package/package.json +18 -18
  101. package/scripts/app-dependency-alignment/propagated-engine-overrides.json +1 -1
  102. package/wildo-framework.info.json +1 -1
@@ -61,6 +61,17 @@
61
61
  * work off the request path — had never run anywhere, and its failure modes
62
62
  * would have been discovered by an application author rather than by us.
63
63
  *
64
+ * # `--serve-built`: the same stack, without the development fleet (#3696)
65
+ *
66
+ * Steps 1–6 are unchanged; only the two trees differ. Instead of each root's `pnpm dev` (about thirty framework
67
+ * `tsc-watch` processes, a watcher per application package, the dev companion, the workbench and three dev servers),
68
+ * each tree runs `scripts/dev-orchestrator/dev-serve-built.mjs`, which starts the built runtimes through their own
69
+ * `dev:run` with the compile-status gate turned off: the three platform services, then the application's backend,
70
+ * minions and Node workers. `--serve-frontend` adds the interactive frontend's Vite server, for scenarios that drive
71
+ * the browser. The diagnostics observer and the memory guard are not started (both are about the development fleet).
72
+ * It is what the live-stack e2e lanes boot after CI has built every dist: on a 2-vCPU hosted runner the development
73
+ * fleet ran it out of memory, and on the QA VM it spent the first minutes recompiling what CI had just built.
74
+ *
64
75
  * # Output
65
76
  *
66
77
  * All combined stdout/stderr is tee'd to
@@ -100,6 +111,51 @@
100
111
  */
101
112
  import { BaseCommand } from '../../kernel/base-command';
102
113
  import type { CommandMeta, CommandContext, CommandResult } from '../../kernel/types';
114
+ /** The process one tree of the stack runs: a command and its arguments, spawned in the tree's root. */
115
+ export interface LocalDevTreeCommand {
116
+ readonly command: string;
117
+ readonly args: readonly string[];
118
+ }
119
+ /** The development fleet: each root's own `pnpm dev` (compile watchers, dev servers, supervised runtimes). */
120
+ export declare const DEVELOPMENT_TREE_COMMAND: LocalDevTreeCommand;
121
+ /**
122
+ * The two trees `--serve-built` runs through `scripts/dev-orchestrator/dev-serve-built.mjs`. The values are that
123
+ * script's `--tree` vocabulary (`ServedTree` there); a test holds the two to the same members.
124
+ */
125
+ export declare enum ServedTreeKind {
126
+ /** The framework root's platform services, each from its built dist. */
127
+ PLATFORM = "platform",
128
+ /** The application's runtimes (backend, minions, Node workers) from their dists, and on request its interactive frontend. */
129
+ APP = "app"
130
+ }
131
+ /** Where the served-stack script lives, relative to the framework checkout. */
132
+ export declare const SERVED_STACK_SCRIPT_PATH = "scripts/dev-orchestrator/dev-serve-built.mjs";
133
+ /**
134
+ * The command a served tree runs instead of `pnpm dev` (#3696): the built runtimes of that tree and nothing that
135
+ * compiles. The script derives WHICH runtimes from the trees' own declarations (the framework root's `dev:run`
136
+ * targets, the application members that declare a `dev:run`) and refuses, before starting anything, a runtime whose
137
+ * dist was never built.
138
+ */
139
+ export declare function servedTreeCommand(input: {
140
+ readonly frameworkRoot: string;
141
+ readonly tree: ServedTreeKind;
142
+ readonly appRoot?: string;
143
+ readonly frontendPaths?: readonly string[];
144
+ }): LocalDevTreeCommand;
145
+ /**
146
+ * Why a `--serve-built` / `--serve-frontend` request cannot be honoured, or `null` when it can.
147
+ *
148
+ * Serving built processes is a FRAMEWORK-DEVELOPER mode: the platform services run from the framework checkout's
149
+ * dists and the application runtimes through the framework's runtime supervisor. An application creator's platform
150
+ * is already the published containers, with no watcher fleet to leave out, so the mode has nothing to change there
151
+ * and refusing says so instead of quietly starting the development fleet.
152
+ */
153
+ export declare function refuseServedStackRequest(input: {
154
+ readonly serveBuilt: boolean;
155
+ readonly serveFrontend: boolean;
156
+ readonly frameworkPath: string | null | undefined;
157
+ readonly isFrameworkDeveloper: boolean;
158
+ }): string | null;
103
159
  export default class LocalDevCommand extends BaseCommand {
104
160
  readonly meta: CommandMeta;
105
161
  run(ctx: CommandContext): Promise<CommandResult>;
@@ -152,8 +208,20 @@ export default class LocalDevCommand extends BaseCommand {
152
208
  * backgrounded sync daemon repairs on its own compile-ready-gated pass.
153
209
  */
154
210
  private reconcileInjectedSnapshots;
211
+ /**
212
+ * The paths of the application's interactive (`SAAS_APP`) frontends, as `wildo.saas.config.ts` declares them —
213
+ * what `--serve-frontend` asks the served app tree to run a dev server for.
214
+ */
215
+ private interactiveFrontendPaths;
155
216
  private spawnTree;
156
217
  private spawnDiagnosticsObserver;
218
+ /**
219
+ * Keep every local double the environment's `providerEnv` points a provider at served for as long as this stack runs
220
+ * (`local-provider-doubles.service.ts`): a port another process already serves is watched, and this stack's double
221
+ * is started the moment it stops answering. A double whose simulators cannot be found is reported once with the remedy
222
+ * and what is lost without it; nothing here stops the stack.
223
+ */
224
+ private startLocalProviderDoubles;
157
225
  /**
158
226
  * Starts the framework checkout's memory guard in watch mode: reap disconnected orphans and sample
159
227
  * memory every five minutes, printing only reaps and pressure warnings. Absent from an installed
@@ -1 +1 @@
1
- {"version":3,"file":"dev.command.d.ts","sourceRoot":"","sources":["../../../../src/commands/local/dev.command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmGG;AAMH,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAG7D,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AA0D1F,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,WAAW;IACtD,QAAQ,CAAC,IAAI,EAAE,WAAW,CAwBxB;IAEI,GAAG,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAqkBtD;;;;;;;;;;;OAWG;YACW,8BAA8B;IAsB5C;;;;;;;;;;;;;;;;;;;;OAoBG;YACW,wBAAwB;IAqCtC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,0BAA0B;IAqClC,OAAO,CAAC,SAAS;IAwBjB,OAAO,CAAC,wBAAwB;IA0BhC;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,YAAY;IA+EpB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,oBAAoB;CAqB7B"}
1
+ {"version":3,"file":"dev.command.d.ts","sourceRoot":"","sources":["../../../../src/commands/local/dev.command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8GG;AAMH,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAG7D,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAoE1F,uGAAuG;AACvG,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED,8GAA8G;AAC9G,eAAO,MAAM,wBAAwB,EAAE,mBAAwD,CAAC;AAEhG;;;GAGG;AACH,oBAAY,cAAc;IACxB,wEAAwE;IACxE,QAAQ,aAAa;IACrB,6HAA6H;IAC7H,GAAG,QAAQ;CACZ;AAED,+EAA+E;AAC/E,eAAO,MAAM,wBAAwB,iDAAiD,CAAC;AAEvF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C,GAAG,mBAAmB,CAQtB;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAC9C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClD,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;CACxC,GAAG,MAAM,GAAG,IAAI,CAWhB;AAED,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,WAAW;IACtD,QAAQ,CAAC,IAAI,EAAE,WAAW,CAmCxB;IAEI,GAAG,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAyoBtD;;;;;;;;;;;OAWG;YACW,8BAA8B;IAsB5C;;;;;;;;;;;;;;;;;;;;OAoBG;YACW,wBAAwB;IAqCtC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,0BAA0B;IAqClC;;;OAGG;YACW,wBAAwB;IAOtC,OAAO,CAAC,SAAS;IAyBjB,OAAO,CAAC,wBAAwB;IA0BhC;;;;;OAKG;YACW,yBAAyB;IAqEvC;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,YAAY;IA+EpB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,oBAAoB;CAqB7B"}
@@ -61,6 +61,17 @@
61
61
  * work off the request path — had never run anywhere, and its failure modes
62
62
  * would have been discovered by an application author rather than by us.
63
63
  *
64
+ * # `--serve-built`: the same stack, without the development fleet (#3696)
65
+ *
66
+ * Steps 1–6 are unchanged; only the two trees differ. Instead of each root's `pnpm dev` (about thirty framework
67
+ * `tsc-watch` processes, a watcher per application package, the dev companion, the workbench and three dev servers),
68
+ * each tree runs `scripts/dev-orchestrator/dev-serve-built.mjs`, which starts the built runtimes through their own
69
+ * `dev:run` with the compile-status gate turned off: the three platform services, then the application's backend,
70
+ * minions and Node workers. `--serve-frontend` adds the interactive frontend's Vite server, for scenarios that drive
71
+ * the browser. The diagnostics observer and the memory guard are not started (both are about the development fleet).
72
+ * It is what the live-stack e2e lanes boot after CI has built every dist: on a 2-vCPU hosted runner the development
73
+ * fleet ran it out of memory, and on the QA VM it spent the first minutes recompiling what CI had just built.
74
+ *
64
75
  * # Output
65
76
  *
66
77
  * All combined stdout/stderr is tee'd to
@@ -105,7 +116,7 @@ import { join } from 'path';
105
116
  import { BaseCommand } from '../../kernel/base-command.js';
106
117
  import { CommandCategory } from '../../kernel/types.js';
107
118
  import { ErrorUtils } from '../../infrastructure/errors/error.utils.js';
108
- import { WildoDeploymentRuntime, WildoLocationType, WorkspaceScope } from '@wildo-ai/platform-config-lib';
119
+ import { AppFrontendType, loadSaasConfig, WildoDeploymentRuntime, WildoLocationType, WorkspaceScope } from '@wildo-ai/platform-config-lib';
109
120
  import { ContextManager } from '../../services/context/context-manager.service.js';
110
121
  import { InfrastructureHost } from '../../services/environment/infrastructure-host.service.js';
111
122
  import { DockerUtils } from '../../services/deployment/docker/docker.service.js';
@@ -125,6 +136,8 @@ import { LocalDevSessionLeaseService, SharedPlatformAccess, SharedPlatformIntent
125
136
  import { SpawnUtils } from '../../infrastructure/process/spawn.utils.js';
126
137
  import { createLocalDevShutdownCoordinator, LocalDevShutdownCauseKind, } from '../../services/deployment/local-dev-shutdown-coordinator.js';
127
138
  import { createLocalDevObserverLifecycle } from '../../services/deployment/local-dev-observer-lifecycle.js';
139
+ import { isLoopbackPortAnswering, LocalProviderDoubleEvent, planLocalProviderDoubles, resolveLocalProviderDoubleLaunch, superviseLocalProviderDouble, } from '../../services/application/local-provider-doubles.service.js';
140
+ import { EnvironmentProviderEnvReadingKind, readEnvironmentProviderEnv } from '../../services/application/content-guardrail-classifier.service.js';
128
141
  import { LOCAL_DEV_LOG_RETENTION_DAYS, retainLocalDevLogs } from '../../services/deployment/local-dev-log-retention.service.js';
129
142
  import { LocalDevOutputFlowController, LocalDevOutputBoundary, LocalDevOutputSink, LocalDevOutputStream, resolveLocalDevConsoleRendering, } from '../../services/deployment/local-dev-output-boundary.js';
130
143
  /**
@@ -134,6 +147,56 @@ import { LocalDevOutputFlowController, LocalDevOutputBoundary, LocalDevOutputSin
134
147
  * whichever of the two wins the race.
135
148
  */
136
149
  const LOCAL_DEV_OWNERSHIP_LOST_REASON = 'local development ownership was taken by another session';
150
+ /** The development fleet: each root's own `pnpm dev` (compile watchers, dev servers, supervised runtimes). */
151
+ export const DEVELOPMENT_TREE_COMMAND = { command: 'pnpm', args: ['dev'] };
152
+ /**
153
+ * The two trees `--serve-built` runs through `scripts/dev-orchestrator/dev-serve-built.mjs`. The values are that
154
+ * script's `--tree` vocabulary (`ServedTree` there); a test holds the two to the same members.
155
+ */
156
+ export var ServedTreeKind;
157
+ (function (ServedTreeKind) {
158
+ /** The framework root's platform services, each from its built dist. */
159
+ ServedTreeKind["PLATFORM"] = "platform";
160
+ /** The application's runtimes (backend, minions, Node workers) from their dists, and on request its interactive frontend. */
161
+ ServedTreeKind["APP"] = "app";
162
+ })(ServedTreeKind || (ServedTreeKind = {}));
163
+ /** Where the served-stack script lives, relative to the framework checkout. */
164
+ export const SERVED_STACK_SCRIPT_PATH = 'scripts/dev-orchestrator/dev-serve-built.mjs';
165
+ /**
166
+ * The command a served tree runs instead of `pnpm dev` (#3696): the built runtimes of that tree and nothing that
167
+ * compiles. The script derives WHICH runtimes from the trees' own declarations (the framework root's `dev:run`
168
+ * targets, the application members that declare a `dev:run`) and refuses, before starting anything, a runtime whose
169
+ * dist was never built.
170
+ */
171
+ export function servedTreeCommand(input) {
172
+ const args = [join(input.frameworkRoot, SERVED_STACK_SCRIPT_PATH), '--framework-root', input.frameworkRoot, '--tree', input.tree];
173
+ if (input.tree === ServedTreeKind.APP) {
174
+ if (!input.appRoot)
175
+ throw new Error('A served application tree needs the application root.');
176
+ args.push('--app-root', input.appRoot);
177
+ for (const frontendPath of input.frontendPaths ?? [])
178
+ args.push('--frontend', frontendPath);
179
+ }
180
+ return { command: process.execPath, args };
181
+ }
182
+ /**
183
+ * Why a `--serve-built` / `--serve-frontend` request cannot be honoured, or `null` when it can.
184
+ *
185
+ * Serving built processes is a FRAMEWORK-DEVELOPER mode: the platform services run from the framework checkout's
186
+ * dists and the application runtimes through the framework's runtime supervisor. An application creator's platform
187
+ * is already the published containers, with no watcher fleet to leave out, so the mode has nothing to change there
188
+ * and refusing says so instead of quietly starting the development fleet.
189
+ */
190
+ export function refuseServedStackRequest(input) {
191
+ if (input.serveFrontend && !input.serveBuilt) {
192
+ return '--serve-frontend only applies with --serve-built: the development stack already runs every frontend.';
193
+ }
194
+ if (input.serveBuilt && (!input.frameworkPath || !input.isFrameworkDeveloper)) {
195
+ return ('--serve-built needs a framework checkout in framework-developer mode: it serves the platform and the application ' +
196
+ 'runtimes from the checkout\'s built dists. An application-creator stack already runs the published platform images.');
197
+ }
198
+ return null;
199
+ }
137
200
  export default class LocalDevCommand extends BaseCommand {
138
201
  meta = {
139
202
  name: 'local dev',
@@ -157,6 +220,16 @@ export default class LocalDevCommand extends BaseCommand {
157
220
  description: 'Run the stale-process cleanup step and exit. Does NOT start any process.',
158
221
  default: false,
159
222
  },
223
+ 'serve-built': {
224
+ type: 'boolean',
225
+ description: 'Serve the BUILT stack: the platform services and the application runtimes from their dists, with no compile watcher, companion or dev server. For a live-stack e2e lane, after a full build (framework-dev mode only).',
226
+ default: false,
227
+ },
228
+ 'serve-frontend': {
229
+ type: 'boolean',
230
+ description: 'With --serve-built, also run the interactive frontend\'s Vite server, for scenarios that drive the browser.',
231
+ default: false,
232
+ },
160
233
  },
161
234
  };
162
235
  async run(ctx) {
@@ -201,6 +274,13 @@ export default class LocalDevCommand extends BaseCommand {
201
274
  const skipPlatform = ctx.flags.skipPlatform === true || ctx.flags['skip-platform'] === true;
202
275
  const skipDoctor = ctx.flags.skipDoctor === true || ctx.flags['skip-doctor'] === true;
203
276
  const killOnly = ctx.flags.killOnly === true || ctx.flags['kill-only'] === true;
277
+ const serveBuilt = ctx.flags.serveBuilt === true || ctx.flags['serve-built'] === true;
278
+ const serveFrontend = ctx.flags.serveFrontend === true || ctx.flags['serve-frontend'] === true;
279
+ const servedStackRefusal = refuseServedStackRequest({ serveBuilt, serveFrontend, frameworkPath, isFrameworkDeveloper });
280
+ if (servedStackRefusal) {
281
+ ctx.log.error(` ${servedStackRefusal}`);
282
+ return { success: false };
283
+ }
204
284
  /*
205
285
  * Whose infrastructure is this? Read from the AUTHORED descriptor, before any generated artifact is
206
286
  * reconciled — a hosted application must never start the platform or converge the shared containers,
@@ -493,8 +573,10 @@ export default class LocalDevCommand extends BaseCommand {
493
573
  await this.closeLogStream(logStream);
494
574
  return { success: false };
495
575
  }
496
- ctx.log.info(chalk.cyan(' Starting platform stack (apps-manager + crontabs-batches-manager + module-registry)...\n'));
497
- children.push(this.spawnTree('platform', frameworkPath, logStream, chalk.blue, consoleRendering));
576
+ ctx.log.info(chalk.cyan(serveBuilt
577
+ ? ' Serving the built platform services (no compile watchers)...\n'
578
+ : ' Starting platform stack (apps-manager + crontabs-batches-manager + module-registry)...\n'));
579
+ children.push(this.spawnTree('platform', frameworkPath, serveBuilt ? servedTreeCommand({ frameworkRoot: frameworkPath, tree: ServedTreeKind.PLATFORM }) : DEVELOPMENT_TREE_COMMAND, logStream, chalk.blue, consoleRendering));
498
580
  }
499
581
  else if (frameworkPath && isFrameworkDeveloper) {
500
582
  ctx.log.info(chalk.yellow(' --skip-platform: platform stack NOT started by this command (expected to be already running).\n'));
@@ -502,6 +584,7 @@ export default class LocalDevCommand extends BaseCommand {
502
584
  let shuttingDown = false;
503
585
  let diagnosticsLifecycle = null;
504
586
  let memoryGuardLifecycle = null;
587
+ const providerDoubleSupervisors = [];
505
588
  const shutdown = createLocalDevShutdownCoordinator({
506
589
  getTrees: () => children,
507
590
  terminateTree: async (pid, signal) => {
@@ -518,6 +601,8 @@ export default class LocalDevCommand extends BaseCommand {
518
601
  readinessAbort?.abort();
519
602
  diagnosticsLifecycle?.stop();
520
603
  memoryGuardLifecycle?.stop();
604
+ for (const supervisor of providerDoubleSupervisors)
605
+ supervisor.stop();
521
606
  backingServiceHealthWatch?.stop();
522
607
  // Name the TRIGGER, not the signal forwarded to the children. Every
523
608
  // teardown used to announce itself as "Received SIGTERM", so a stack
@@ -552,7 +637,10 @@ export default class LocalDevCommand extends BaseCommand {
552
637
  // runtime gate is unhealthy, so starting it after registered-app bootstrap
553
638
  // would hide the causal facts until they were no longer needed. Its own
554
639
  // exit remains non-fatal, while every early-return shutdown below reaps it.
555
- if (frameworkPath && isFrameworkDeveloper) {
640
+ // Not for a served stack: the observer reports compile status and watcher facts, which nothing in that mode
641
+ // produces (every runtime would read as blocked by a missing compile status), and the memory guard reaps
642
+ // orphaned development sessions on a developer's machine, which a CI VM does not have.
643
+ if (frameworkPath && isFrameworkDeveloper && !serveBuilt) {
556
644
  diagnosticsLifecycle = createLocalDevObserverLifecycle({
557
645
  spawn: () => this.spawnDiagnosticsObserver(frameworkPath, saasRoot, logStream, consoleRendering),
558
646
  onGenerationStarted: (generation) => children.push(generation),
@@ -686,9 +774,51 @@ export default class LocalDevCommand extends BaseCommand {
686
774
  // remains the backstop, and a broken diagnostic must not be why a stack cannot start.
687
775
  ctx.log.warn(` Schema-drift check failed to run (continuing): ${ErrorUtils.extractErrorMessage(error)}`);
688
776
  }
777
+ // ─── Step 6.75: the local doubles the application's secrets point at ───
778
+ //
779
+ // Both audiences, and before the app processes, so a guarded agent's first turn finds its classifier. A provider
780
+ // whose LOCAL host slot names this machine is served by a simulators double; until this step that double was
781
+ // started by hand and was gone after every reboot, so every guarded agent reply was withheld as
782
+ // OUTPUT_NOT_MODERATED. Non-fatal like the observers: a double that cannot start is reported and the stack runs.
783
+ if (!shuttingDown) {
784
+ await this.startLocalProviderDoubles({
785
+ ctx,
786
+ envName: env.name,
787
+ saasRoot,
788
+ frameworkRoot: frameworkPath ?? null,
789
+ logStream,
790
+ consoleRendering,
791
+ children,
792
+ supervisors: providerDoubleSupervisors,
793
+ });
794
+ }
689
795
  // ─── Step 7: app processes may start only after bootstrap ─────────
690
- ctx.log.info(chalk.cyan(` Starting app stack from ${chalk.dim(saasRoot)}...\n`));
691
- children.push(this.spawnTree('app', saasRoot, logStream, chalk.green, consoleRendering));
796
+ let appTreeCommand = DEVELOPMENT_TREE_COMMAND;
797
+ if (serveBuilt && frameworkPath) {
798
+ let frontendPaths = [];
799
+ if (serveFrontend) {
800
+ try {
801
+ frontendPaths = await this.interactiveFrontendPaths(saasRoot);
802
+ if (frontendPaths.length === 0) {
803
+ throw new Error('wildo.saas.config.ts declares no service with frontendType SAAS_APP, so there is no frontend to serve');
804
+ }
805
+ }
806
+ catch (error) {
807
+ ctx.log.error(` Cannot read the application's interactive frontends: ${ErrorUtils.extractErrorMessage(error)}`);
808
+ await shutdown('SIGTERM', {
809
+ kind: LocalDevShutdownCauseKind.INTERNAL_FAILURE,
810
+ description: 'the interactive frontends to serve could not be read',
811
+ });
812
+ return { success: false };
813
+ }
814
+ }
815
+ appTreeCommand = servedTreeCommand({ frameworkRoot: frameworkPath, tree: ServedTreeKind.APP, appRoot: saasRoot, frontendPaths });
816
+ ctx.log.info(chalk.cyan(` Serving the built app stack from ${chalk.dim(saasRoot)} (no compile watchers)...\n`));
817
+ }
818
+ else {
819
+ ctx.log.info(chalk.cyan(` Starting app stack from ${chalk.dim(saasRoot)}...\n`));
820
+ }
821
+ children.push(this.spawnTree('app', saasRoot, appTreeCommand, logStream, chalk.green, consoleRendering));
692
822
  // ─── Step 8: wait for any child to exit, then propagate exit ──────
693
823
  const exitCode = await Promise.race(children.filter((tree) => tree.affectsStackLifetime).map((tree) => tree.exit));
694
824
  await shutdown('SIGTERM', {
@@ -847,8 +977,18 @@ export default class LocalDevCommand extends BaseCommand {
847
977
  ctx.log.warn(` ⚠ Snapshot reconcile did not fully converge (continuing; sync daemon will retry):\n ${chalk.dim(detail.split('\n').join('\n '))}\n`);
848
978
  }
849
979
  }
850
- spawnTree(label, cwd, logStream, color, consoleRendering) {
851
- const child = spawn('pnpm', ['dev'], {
980
+ /**
981
+ * The paths of the application's interactive (`SAAS_APP`) frontends, as `wildo.saas.config.ts` declares them —
982
+ * what `--serve-frontend` asks the served app tree to run a dev server for.
983
+ */
984
+ async interactiveFrontendPaths(saasRoot) {
985
+ const saasConfig = await loadSaasConfig(join(saasRoot, 'wildo.saas.config.ts'));
986
+ return Object.values(saasConfig.services ?? {})
987
+ .filter((service) => service.frontendType === AppFrontendType.SAAS_APP)
988
+ .map((service) => service.path);
989
+ }
990
+ spawnTree(label, cwd, treeCommand, logStream, color, consoleRendering) {
991
+ const child = spawn(treeCommand.command, [...treeCommand.args], {
852
992
  cwd,
853
993
  env: { ...process.env, FORCE_COLOR: '1' },
854
994
  stdio: ['ignore', 'pipe', 'pipe'],
@@ -882,6 +1022,74 @@ export default class LocalDevCommand extends BaseCommand {
882
1022
  affectsStackLifetime: false,
883
1023
  });
884
1024
  }
1025
+ /**
1026
+ * Keep every local double the environment's `providerEnv` points a provider at served for as long as this stack runs
1027
+ * (`local-provider-doubles.service.ts`): a port another process already serves is watched, and this stack's double
1028
+ * is started the moment it stops answering. A double whose simulators cannot be found is reported once with the remedy
1029
+ * and what is lost without it; nothing here stops the stack.
1030
+ */
1031
+ async startLocalProviderDoubles(input) {
1032
+ const { ctx } = input;
1033
+ let secretsPath;
1034
+ try {
1035
+ secretsPath = join(EnvironmentUtils.resolveSecretsDir(input.envName), 'secrets.json');
1036
+ }
1037
+ catch {
1038
+ return;
1039
+ }
1040
+ const reading = readEnvironmentProviderEnv(secretsPath);
1041
+ if (reading.kind !== EnvironmentProviderEnvReadingKind.READ)
1042
+ return;
1043
+ for (const planned of planLocalProviderDoubles(reading.providerEnv)) {
1044
+ const { definition, port } = planned;
1045
+ let launch;
1046
+ try {
1047
+ launch = resolveLocalProviderDoubleLaunch({ saasRoot: input.saasRoot, frameworkRoot: input.frameworkRoot, planned });
1048
+ }
1049
+ catch (error) {
1050
+ if (await isLoopbackPortAnswering(port))
1051
+ continue;
1052
+ ctx.log.warn(` ${definition.providerRef}: ${definition.hostEnvVarName} points at 127.0.0.1:${port}, and its local double cannot be started: `
1053
+ + `${ErrorUtils.extractErrorMessage(error)} Until something answers there, ${definition.withoutIt}.`);
1054
+ continue;
1055
+ }
1056
+ input.supervisors.push(superviseLocalProviderDouble({
1057
+ port,
1058
+ start: () => this.observeChild({
1059
+ label: `double:${definition.providerRef}`,
1060
+ child: spawn(launch.command, launch.args, {
1061
+ cwd: launch.cwd,
1062
+ env: launch.env,
1063
+ stdio: ['ignore', 'pipe', 'pipe'],
1064
+ detached: SpawnUtils.shouldUseProcessGroups(),
1065
+ }),
1066
+ logStream: input.logStream,
1067
+ color: chalk.gray,
1068
+ consoleRendering: input.consoleRendering,
1069
+ affectsStackLifetime: false,
1070
+ }),
1071
+ onStarted: (generation) => input.children.push(generation),
1072
+ onEnded: (generation) => {
1073
+ const index = input.children.indexOf(generation);
1074
+ if (index >= 0)
1075
+ input.children.splice(index, 1);
1076
+ },
1077
+ onEvent: (event, { exitCode, consecutiveFailures }) => {
1078
+ if (event === LocalProviderDoubleEvent.SERVED_ELSEWHERE) {
1079
+ ctx.log.info(` ${definition.providerRef}: 127.0.0.1:${port} is already served; this stack starts its double if that stops.`);
1080
+ }
1081
+ else if (event === LocalProviderDoubleEvent.STARTING) {
1082
+ ctx.log.info(chalk.cyan(` Starting the ${definition.providerRef} double on 127.0.0.1:${port} (${definition.hostEnvVarName}).`));
1083
+ }
1084
+ else if (consecutiveFailures > 1) {
1085
+ // A single exit is usually another stack winning the port, which the next probe sees; repeated ones are not.
1086
+ ctx.log.warn(` The ${definition.providerRef} double exited (code ${exitCode}) ${consecutiveFailures} times in a row; it is retried while`
1087
+ + ` nothing answers on 127.0.0.1:${port}. Until it answers, ${definition.withoutIt}.`);
1088
+ }
1089
+ },
1090
+ }));
1091
+ }
1092
+ }
885
1093
  /**
886
1094
  * Starts the framework checkout's memory guard in watch mode: reap disconnected orphans and sample
887
1095
  * memory every five minutes, printing only reaps and pressure warnings. Absent from an installed