@patronage/factory-ci 1.0.0-alpha.4 → 1.0.0-alpha.40

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 (54) hide show
  1. package/README.md +712 -10
  2. package/dist/.build-fingerprint.json +3 -0
  3. package/dist/alchemy/index.d.ts +1174 -0
  4. package/dist/alchemy/index.js +2142 -0
  5. package/dist/bundle-alchemy-entry-CT5hCphA.js +112 -0
  6. package/dist/execute-alchemy-entry-B397GSk5.d.ts +134 -0
  7. package/dist/execute-alchemy-entry-CZ7Knz4q.js +160 -0
  8. package/dist/index.d.ts +1205 -87
  9. package/dist/index.js +2752 -317
  10. package/package.json +28 -10
  11. package/src/actions.ts +13 -0
  12. package/src/alchemy/child-diagnostics.ts +148 -0
  13. package/src/alchemy/credential-preflight.ts +428 -0
  14. package/src/alchemy/destroy-postcondition.ts +103 -0
  15. package/src/alchemy/evaluate-stack.ts +153 -0
  16. package/src/alchemy/first-deploy-authorization.ts +194 -0
  17. package/src/alchemy/index.ts +144 -0
  18. package/src/alchemy/lifecycle-failure.ts +174 -0
  19. package/src/alchemy/lifecycle.ts +1330 -0
  20. package/src/alchemy/local-emulation.ts +89 -0
  21. package/src/alchemy/plan-effects.ts +510 -0
  22. package/src/alchemy/retained-identity.ts +248 -0
  23. package/src/alchemy/secret-name-policy.ts +96 -0
  24. package/src/alchemy/stage-policy.ts +269 -0
  25. package/src/alchemy/state-tree.ts +168 -0
  26. package/src/alchemy/url-implies-auth.ts +264 -0
  27. package/src/alchemy-baseline.ts +75 -0
  28. package/src/bundle-alchemy-entry.ts +5 -0
  29. package/src/candidate-impact-workflow.ts +110 -0
  30. package/src/candidate-lifecycle.ts +29 -0
  31. package/src/cursor-oidc.ts +33 -0
  32. package/src/execute-alchemy-entry.ts +128 -8
  33. package/src/factory-workflow.ts +83 -40
  34. package/src/github-app-token.ts +92 -18
  35. package/src/github-transport.ts +186 -0
  36. package/src/impact-demand-condition.ts +67 -0
  37. package/src/index.ts +174 -0
  38. package/src/lifecycle-contract-lane.ts +113 -0
  39. package/src/merge-freeze-job.ts +253 -0
  40. package/src/pinned-action.ts +30 -0
  41. package/src/pr-status-hud-workflow.ts +96 -0
  42. package/src/preview-cleanup-topology.ts +115 -0
  43. package/src/preview-proof-inventory.ts +1092 -0
  44. package/src/preview-proof-lifecycle.ts +328 -0
  45. package/src/preview-receipt-workflow.ts +83 -0
  46. package/src/production-impact-workflow.ts +181 -0
  47. package/src/proof-reuse-gate.ts +223 -48
  48. package/src/proof-reuse-presentation.ts +131 -0
  49. package/src/push-identity-workflow.ts +463 -0
  50. package/src/runnable-cli.ts +27 -0
  51. package/src/verify-runner-policy.ts +290 -0
  52. package/src/vitest-profile-reader.test.ts +208 -0
  53. package/src/vitest-profile-reader.ts +225 -0
  54. package/src/vitest-profile.ts +631 -0
@@ -0,0 +1,112 @@
1
+ import "node:module";
2
+ import { mkdir } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { build } from "esbuild";
5
+ //#region \0rolldown/runtime.js
6
+ var __defProp = Object.defineProperty;
7
+ var __exportAll = (all, no_symbols) => {
8
+ let target = {};
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
14
+ return target;
15
+ };
16
+ //#endregion
17
+ //#region src/bundle-alchemy-entry.ts
18
+ var bundle_alchemy_entry_exports = /* @__PURE__ */ __exportAll({ bundleAlchemyEntry: () => bundleAlchemyEntry });
19
+ /**
20
+ * Alchemy and Effect must resolve from the *consumer's* node_modules at run
21
+ * time, never from the bundle: Alchemy's resource registry and Effect's
22
+ * service tags are identity-sensitive, and a second copy silently breaks both.
23
+ */
24
+ const ALCHEMY_EXTERNALS = [
25
+ "alchemy",
26
+ "alchemy/*",
27
+ "effect",
28
+ "effect/*"
29
+ ];
30
+ /**
31
+ * The package names behind `ALCHEMY_EXTERNALS`, derived rather than restated so
32
+ * a future external can never be guarded by only one of two lists.
33
+ */
34
+ const RESERVED_ALIAS_PACKAGES = [...new Set(ALCHEMY_EXTERNALS.map((external) => external.replace(/\/\*$/u, "").toLowerCase()))];
35
+ const reservedAliasKey = (key) => RESERVED_ALIAS_PACKAGES.find((name) => key === name || key.startsWith(`${name}/`));
36
+ /**
37
+ * Refuse an alias *key* that is itself a reserved package or one of its
38
+ * subpaths. esbuild substitutes aliases before it decides what is external, so
39
+ * such a key defeats `external` outright. Keys are compared, never resolved,
40
+ * which is what makes string matching sound here.
41
+ */
42
+ const assertAliasKeysAreAdmissible = (alias) => {
43
+ for (const key of Object.keys(alias)) {
44
+ const reserved = reservedAliasKey(key);
45
+ if (reserved) throw new Error(`bundleAlchemyEntry cannot alias "${key}": ${reserved} must stay external because its identity is shared with the consumer's runtime, and esbuild applies aliases before external matching. Point the consumer's own resolution at one copy instead.`);
46
+ }
47
+ };
48
+ /**
49
+ * Whether a bundled input lives inside a reserved package.
50
+ *
51
+ * Metafile inputs are paths esbuild resolved and normalized itself, so
52
+ * comparing whole segments here answers what was *bundled* rather than how the
53
+ * config was spelled. Segments are compared case-insensitively: on a
54
+ * case-insensitive filesystem `node_modules/Effect/…` resolves to the real
55
+ * package and the metafile keeps the caller's spelling.
56
+ */
57
+ const isReservedInput = (input) => {
58
+ const segments = input.toLowerCase().split(/[/\\]+/u);
59
+ return segments.some((segment, position) => position > 0 && segments[position - 1] === "node_modules" && RESERVED_ALIAS_PACKAGES.includes(segment));
60
+ };
61
+ /**
62
+ * Assert the externals contract against the bundle esbuild actually produced.
63
+ *
64
+ * Checking alias *values* instead was unsound by construction: `..` segments,
65
+ * symlinks, and every other spelling of the same file each need another string
66
+ * rule, and the scanner loses. The metafile records the inputs after esbuild's
67
+ * own resolution and normalization, so one check closes the whole class —
68
+ * whatever route reached an identity-sensitive package, it shows up here.
69
+ */
70
+ const assertNoReservedInputs = (inputs) => {
71
+ const offenders = inputs.filter(isReservedInput);
72
+ if (offenders.length > 0) throw new Error(`bundleAlchemyEntry refused a bundle carrying a second copy of an identity-sensitive package: ${offenders.join(", ")}. Those packages must resolve from the consumer's runtime, so nothing may pull their files into the bundle — an alias that re-exports them by bare specifier stays external and is fine.`);
73
+ };
74
+ /**
75
+ * Pre-bundle an Alchemy entry to a single ESM file, keeping `alchemy` and
76
+ * `effect` external (#268).
77
+ *
78
+ * Both repos that deploy through Alchemy wrote this: the Alchemy CLI runs a
79
+ * JavaScript entry, so a TypeScript `alchemy.run.ts` has to be flattened
80
+ * first, and the flattening must not swallow the two packages whose identity
81
+ * matters. Firedup additionally resolved esbuild *through vite* because it had
82
+ * no direct dependency on it; here esbuild is a plain dependency of this
83
+ * package and that hack can be deleted.
84
+ *
85
+ * Returns the absolute path of the file written.
86
+ */
87
+ const bundleAlchemyEntry = async (options) => {
88
+ if (options.alias) assertAliasKeysAreAdmissible(options.alias);
89
+ const root = options.absWorkingDir ? path.resolve(options.absWorkingDir) : process.cwd();
90
+ const outfile = path.resolve(root, options.outfile);
91
+ await mkdir(path.dirname(outfile), { recursive: true });
92
+ const result = await build({
93
+ absWorkingDir: root,
94
+ bundle: true,
95
+ entryPoints: [path.resolve(root, options.entry)],
96
+ external: ALCHEMY_EXTERNALS,
97
+ format: "esm",
98
+ logLevel: "silent",
99
+ metafile: true,
100
+ outfile,
101
+ packages: options.packages ?? "external",
102
+ platform: "node",
103
+ sourcemap: options.sourcemap ?? false,
104
+ target: options.target ?? "node24",
105
+ ...options.alias ? { alias: { ...options.alias } } : {},
106
+ ...options.tsconfig ? { tsconfig: path.resolve(root, options.tsconfig) } : {}
107
+ });
108
+ assertNoReservedInputs(Object.keys(result.metafile.inputs));
109
+ return outfile;
110
+ };
111
+ //#endregion
112
+ export { bundle_alchemy_entry_exports as n, bundleAlchemyEntry as t };
@@ -0,0 +1,134 @@
1
+ //#region src/bundle-alchemy-entry.d.ts
2
+ interface BundleAlchemyEntryOptions {
3
+ /** The Alchemy entry to bundle, e.g. `alchemy.run.ts`. */
4
+ readonly entry: string;
5
+ /** Where to write the bundled ESM file, e.g. `.alchemy/deploy-entry.mjs`. */
6
+ readonly outfile: string;
7
+ /** esbuild's working directory; also the base for relative paths. */
8
+ readonly absWorkingDir?: string;
9
+ /**
10
+ * Import specifiers to rewrite before resolution, passed straight to
11
+ * esbuild's `alias`. Substitution happens before the `packages` and
12
+ * `external` decisions, so an aliased bare specifier is inlined even under
13
+ * `packages: "external"`. Values are resolved the way esbuild resolves any
14
+ * import, so give absolute paths or package names — which aliases a repo
15
+ * needs is the consumer's policy and this package bakes in none. A key on
16
+ * `alchemy`, `effect`, or a subpath of either is rejected outright, and the
17
+ * finished bundle is checked for files from those packages however they were
18
+ * reached.
19
+ */
20
+ readonly alias?: Readonly<Record<string, string>>;
21
+ /**
22
+ * `"external"` (default) leaves every bare import outside the entry's own
23
+ * source graph to Node's resolver at run time — the entry's TypeScript is
24
+ * still inlined, which is the whole point. `"bundle"` inlines dependencies
25
+ * too, minus the Alchemy/Effect externals, for a runner without the
26
+ * consumer's node_modules.
27
+ */
28
+ readonly packages?: "bundle" | "external";
29
+ /** Emit a sourcemap next to the outfile. Default `false`. */
30
+ readonly sourcemap?: boolean;
31
+ /** esbuild target. Default `node24`. */
32
+ readonly target?: string;
33
+ /** tsconfig to apply to the entry's sources. */
34
+ readonly tsconfig?: string;
35
+ }
36
+ /**
37
+ * Pre-bundle an Alchemy entry to a single ESM file, keeping `alchemy` and
38
+ * `effect` external (#268).
39
+ *
40
+ * Both repos that deploy through Alchemy wrote this: the Alchemy CLI runs a
41
+ * JavaScript entry, so a TypeScript `alchemy.run.ts` has to be flattened
42
+ * first, and the flattening must not swallow the two packages whose identity
43
+ * matters. Firedup additionally resolved esbuild *through vite* because it had
44
+ * no direct dependency on it; here esbuild is a plain dependency of this
45
+ * package and that hack can be deleted.
46
+ *
47
+ * Returns the absolute path of the file written.
48
+ */
49
+ declare const bundleAlchemyEntry: (options: BundleAlchemyEntryOptions) => Promise<string>;
50
+ //#endregion
51
+ //#region src/execute-alchemy-entry.d.ts
52
+ /** Node's spawnSync default is 1 MiB; Alchemy plans routinely exceed that. */
53
+ declare const EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER: number;
54
+ interface ExecuteAlchemyEntryCommon {
55
+ /**
56
+ * CLI arguments before the bundled entry. The absolute entry path is always
57
+ * appended as the final argument.
58
+ */
59
+ readonly args: readonly string[];
60
+ /** Child working directory. Defaults to the bundle root, then process.cwd. */
61
+ readonly cwd?: string;
62
+ /** Child environment. Defaults to process.env. */
63
+ readonly env?: NodeJS.ProcessEnv;
64
+ /** Consumer module context; normally the caller's import.meta.url. */
65
+ readonly from: string | URL;
66
+ /**
67
+ * Largest captured stdout or stderr, in bytes. Omitted unless the caller
68
+ * sets it, so Node's spawnSync default (1 MiB) stays in force. Has no
69
+ * effect when stdio is `"inherit"`. Callers that need a larger capture
70
+ * pass `EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER` or another explicit value.
71
+ */
72
+ readonly maxBuffer?: number;
73
+ /**
74
+ * Called once with the child's captured streams, after the child exits and
75
+ * **before its exit status is judged**, so a caller keeping a diagnostic
76
+ * record still receives the output of a child that failed. Unused when
77
+ * stdio is `"inherit"`.
78
+ *
79
+ * The text handed over is the raw capture: `redact` is not applied to it,
80
+ * because `redact` shapes what this function returns and a record is not a
81
+ * return value. A caller that writes this anywhere owns its own redaction.
82
+ *
83
+ * It must not throw. Its work is a side record, and a throw from it would
84
+ * be indistinguishable here from the child's own failure.
85
+ */
86
+ readonly onCaptured?: (captured: {
87
+ readonly stdout: string | null;
88
+ readonly stderr: string | null;
89
+ }) => void;
90
+ /**
91
+ * Applied to captured stdout and stderr before they are returned. Unused
92
+ * when stdio is `"inherit"`. This package does not supply a secret-name
93
+ * policy; the caller owns redaction.
94
+ */
95
+ readonly redact?: (text: string) => string;
96
+ /** Child stdio. Default "inherit". */
97
+ readonly stdio?: "inherit" | "pipe";
98
+ }
99
+ /**
100
+ * Exactly one entry source. The union refuses `bundle` and `bundledEntry`
101
+ * together, and refuses neither, so no runtime check is needed.
102
+ */
103
+ type ExecuteAlchemyEntryOptions = ExecuteAlchemyEntryCommon & ({
104
+ /** Bundle the consumer entry before execution. */readonly bundle: BundleAlchemyEntryOptions;
105
+ readonly bundledEntry?: never;
106
+ } | {
107
+ readonly bundle?: never;
108
+ /**
109
+ * Already-bundled entry path. Skips the internal bundle step and
110
+ * appends this path as the CLI's final argument.
111
+ */
112
+ readonly bundledEntry: string;
113
+ });
114
+ interface ExecuteAlchemyEntryResult {
115
+ readonly bundledEntry: string;
116
+ readonly stderr: string | null;
117
+ readonly stdout: string | null;
118
+ }
119
+ /**
120
+ * Bundle a consumer-owned Alchemy entry, resolve that consumer's Alchemy CLI,
121
+ * run it under the current Node binary, and return only on a successful exit.
122
+ *
123
+ * Options carry exactly one entry source: `bundle` to bundle now, or
124
+ * `bundledEntry` to reuse an already-bundled path. Captured stdout and stderr (`stdio: "pipe"`) can be redacted through
125
+ * `redact` before they are returned; `stdio: "inherit"` still streams the
126
+ * child unredacted. `onCaptured` receives the raw streams of every piped
127
+ * child, including one that then fails.
128
+ *
129
+ * Deploy/destroy/plan selection, stage admission, credentials, and every
130
+ * convergence or destructive-change policy remain the caller's responsibility.
131
+ */
132
+ declare const executeAlchemyEntry: (options: ExecuteAlchemyEntryOptions) => Promise<ExecuteAlchemyEntryResult>;
133
+ //#endregion
134
+ export { BundleAlchemyEntryOptions as a, executeAlchemyEntry as i, ExecuteAlchemyEntryOptions as n, bundleAlchemyEntry as o, ExecuteAlchemyEntryResult as r, EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER as t };
@@ -0,0 +1,160 @@
1
+ import { createRequire } from "node:module";
2
+ import path from "node:path";
3
+ import { spawnSync } from "node:child_process";
4
+ //#region src/alchemy-baseline.ts
5
+ /**
6
+ * The Alchemy fleet baseline (#985, #993). Every factory project that
7
+ * imports `@patronage/factory-ci/alchemy` pins `alchemy` and `effect` to
8
+ * these exact versions. The pair moves together, in the same lockstep
9
+ * release that bumps this constant.
10
+ *
11
+ * This module is a plain constant: it imports neither `alchemy` nor
12
+ * `effect`, so it ships from the root entry, not the `./alchemy` subpath.
13
+ */
14
+ const ALCHEMY_BASELINE = {
15
+ alchemy: "2.0.0-beta.77",
16
+ effect: "4.0.0-rc.112"
17
+ };
18
+ const BASELINE_PACKAGE_NAMES = Object.keys(ALCHEMY_BASELINE);
19
+ /**
20
+ * Fails when the consumer's `alchemy` or `effect` pin differs from
21
+ * {@link ALCHEMY_BASELINE}, or when only one of the pair is present.
22
+ * Alchemy peers on Effect, so an unpinned auto-installed Effect can drift
23
+ * outside the baseline while a lone `alchemy` pin would otherwise pass.
24
+ * Both packages remaining absent is not drift — they are optional peers of
25
+ * the `./alchemy` subpath, so a consumer that never touches it carries
26
+ * neither.
27
+ *
28
+ * Reads only the `packageJson` object it is handed; it never walks the
29
+ * filesystem.
30
+ */
31
+ const assertAlchemyBaseline = ({ packageJson }) => {
32
+ const drifted = [];
33
+ const pinOf = (name) => packageJson.dependencies?.[name] ?? packageJson.devDependencies?.[name];
34
+ const pairPresent = BASELINE_PACKAGE_NAMES.some((name) => pinOf(name) !== void 0);
35
+ for (const name of BASELINE_PACKAGE_NAMES) {
36
+ const pinned = pinOf(name);
37
+ const baseline = ALCHEMY_BASELINE[name];
38
+ if (pinned === void 0) {
39
+ if (pairPresent) drifted.push(`missing ${name} (baseline: ${name}@${baseline})`);
40
+ continue;
41
+ }
42
+ if (pinned !== baseline) drifted.push(`${name}@${pinned} (baseline: ${name}@${baseline})`);
43
+ }
44
+ if (drifted.length > 0) throw new Error(`Alchemy fleet baseline drift: ${drifted.join(", ")}. Bump to match ALCHEMY_BASELINE in @patronage/factory-ci, or wait for the next lockstep release.`);
45
+ };
46
+ //#endregion
47
+ //#region src/disposable-stage.ts
48
+ /**
49
+ * The disposable Alchemy stage a local preview deploy runs in:
50
+ * `local-pr-<pr>-<short sha>` (#268).
51
+ *
52
+ * Two repos invented this grammar independently and then had to agree on it
53
+ * anyway, because the same cleanup sweeps delete these stages. A stage that
54
+ * does not match is not disposable, and destructive operations must refuse it.
55
+ */
56
+ const LOCAL_PREVIEW_STAGE_PATTERN = /^local-pr-(?<pr>[1-9]\d*)-(?<sha>[0-9a-f]{7,40})$/u;
57
+ /**
58
+ * Interpret an untrusted stage name through the one disposable-stage grammar.
59
+ * Returns `null` rather than throwing when the value or expected ownership
60
+ * does not match.
61
+ */
62
+ const parseLocalPreviewStage = (stage, expected = {}) => {
63
+ const match = LOCAL_PREVIEW_STAGE_PATTERN.exec(stage);
64
+ if (!match?.groups) return null;
65
+ const pr = Number(match.groups.pr);
66
+ const headShaPrefix = match.groups.sha;
67
+ if (!Number.isSafeInteger(pr) || expected.pr !== void 0 && pr !== expected.pr) return null;
68
+ if (expected.headSha !== void 0) {
69
+ const headSha = expected.headSha.trim().toLowerCase();
70
+ if (!/^[0-9a-f]{40}$/u.test(headSha) || !headSha.startsWith(headShaPrefix)) return null;
71
+ }
72
+ return {
73
+ headShaPrefix,
74
+ pr,
75
+ stage
76
+ };
77
+ };
78
+ /**
79
+ * Whether `stage` is disposable. Pass `pr` to also require PR ownership.
80
+ */
81
+ const isLocalPreviewStage = (stage, pr) => parseLocalPreviewStage(stage, pr === void 0 ? {} : { pr }) !== null;
82
+ /**
83
+ * Build the disposable stage name for a pull request head.
84
+ *
85
+ * Throws when the inputs cannot produce a valid stage, so a caller can never
86
+ * deploy into a name the cleanup sweep will not recognise.
87
+ */
88
+ const localPreviewStage = (options) => {
89
+ const { headSha, pr, shaLength = 12 } = options;
90
+ if (!Number.isSafeInteger(pr) || pr < 1) throw new Error(`pr must be a positive safe integer, got ${pr}.`);
91
+ if (!Number.isInteger(shaLength) || shaLength < 7 || shaLength > 40) throw new Error(`shaLength must be an integer from 7 through 40, got ${shaLength}.`);
92
+ const normalizedHead = headSha.trim().toLowerCase();
93
+ if (!/^[0-9a-f]{40}$/u.test(normalizedHead)) throw new Error(`headSha must be exactly 40 hexadecimal characters, got "${headSha}".`);
94
+ return `local-pr-${pr}-${normalizedHead.slice(0, shaLength)}`;
95
+ };
96
+ //#endregion
97
+ //#region src/execute-alchemy-entry.ts
98
+ /** Node's spawnSync default is 1 MiB; Alchemy plans routinely exceed that. */
99
+ const EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER = 64 * 1024 * 1024;
100
+ let spawnImplementation = spawnSync;
101
+ /**
102
+ * The child's working directory: the caller's `cwd`, then the bundle root,
103
+ * then this process's. One chain, used by `executeAlchemyEntry` and by the
104
+ * lifecycle, which prepares the bundle itself and so must resolve the same
105
+ * directory the bundle would have.
106
+ */
107
+ const resolveAlchemyChildCwd = (options) => options.cwd ?? options.bundle?.absWorkingDir ?? process.cwd();
108
+ const resolveBundledEntry = async (options) => {
109
+ if (options.bundledEntry === void 0) {
110
+ const { bundleAlchemyEntry } = await import("./bundle-alchemy-entry-CT5hCphA.js").then((n) => n.n);
111
+ return await bundleAlchemyEntry(options.bundle);
112
+ }
113
+ return path.resolve(options.cwd ?? process.cwd(), options.bundledEntry);
114
+ };
115
+ const captured = (text, redact) => {
116
+ if (text === null || redact === void 0) return text;
117
+ return redact(text);
118
+ };
119
+ /**
120
+ * Bundle a consumer-owned Alchemy entry, resolve that consumer's Alchemy CLI,
121
+ * run it under the current Node binary, and return only on a successful exit.
122
+ *
123
+ * Options carry exactly one entry source: `bundle` to bundle now, or
124
+ * `bundledEntry` to reuse an already-bundled path. Captured stdout and stderr (`stdio: "pipe"`) can be redacted through
125
+ * `redact` before they are returned; `stdio: "inherit"` still streams the
126
+ * child unredacted. `onCaptured` receives the raw streams of every piped
127
+ * child, including one that then fails.
128
+ *
129
+ * Deploy/destroy/plan selection, stage admission, credentials, and every
130
+ * convergence or destructive-change policy remain the caller's responsibility.
131
+ */
132
+ const executeAlchemyEntry = async (options) => {
133
+ const cliEntry = createRequire(options.from).resolve("alchemy/bin/alchemy.js");
134
+ const bundledEntry = await resolveBundledEntry(options);
135
+ const result = spawnImplementation(process.execPath, [
136
+ cliEntry,
137
+ ...options.args,
138
+ bundledEntry
139
+ ], {
140
+ cwd: resolveAlchemyChildCwd(options),
141
+ encoding: "utf-8",
142
+ env: options.env ?? process.env,
143
+ ...options.maxBuffer === void 0 ? {} : { maxBuffer: options.maxBuffer },
144
+ stdio: options.stdio ?? "inherit"
145
+ });
146
+ options.onCaptured?.({
147
+ stderr: result.stderr,
148
+ stdout: result.stdout
149
+ });
150
+ if (result.error) throw new Error("Failed to start the Alchemy CLI.");
151
+ if (result.signal) throw new Error(`Alchemy CLI terminated by signal ${result.signal}.`);
152
+ if (result.status !== 0) throw new Error(result.status === null ? "Alchemy CLI exited without reporting a status." : `Alchemy CLI exited with status ${result.status}.`);
153
+ return {
154
+ bundledEntry,
155
+ stderr: captured(result.stderr, options.redact),
156
+ stdout: captured(result.stdout, options.redact)
157
+ };
158
+ };
159
+ //#endregion
160
+ export { localPreviewStage as a, assertAlchemyBaseline as c, isLocalPreviewStage as i, executeAlchemyEntry as n, parseLocalPreviewStage as o, resolveAlchemyChildCwd as r, ALCHEMY_BASELINE as s, EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER as t };