@prisma/cli-engine 0.0.2 → 0.0.5

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.
@@ -1,8 +1,10 @@
1
1
  import { i as okVoid, n as notOk, t as CliStructuredError } from "./protocol-C1JQcGl9.js";
2
2
  import { createRequire } from "node:module";
3
3
  import { buildApplication, buildCommand, buildRouteMap, run, text_en } from "@stricli/core";
4
- import { resolve } from "node:path";
4
+ import { existsSync, realpathSync } from "node:fs";
5
+ import { dirname, join, resolve } from "node:path";
5
6
  import { Readable, Writable } from "node:stream";
7
+ import { Buffer } from "node:buffer";
6
8
  //#region src/args.ts
7
9
  function flagRuntime(spec) {
8
10
  return spec;
@@ -94,6 +96,70 @@ const positional = {
94
96
  }
95
97
  };
96
98
  //#endregion
99
+ //#region src/spawn.ts
100
+ const CHILD_STATUS = Symbol.for("@prisma/cli-engine.childStatus");
101
+ /** Marks a ChildResult the engine watched a real child produce. */
102
+ const ENGINE_SPAWNED = Symbol.for("@prisma/cli-engine.engineSpawned");
103
+ function markEngineSpawned(value) {
104
+ return Object.freeze(Object.defineProperty(value, ENGINE_SPAWNED, { value: true }));
105
+ }
106
+ function isEngineSpawned(value) {
107
+ return value[ENGINE_SPAWNED] === true;
108
+ }
109
+ /**
110
+ * The child result ctx.spawn hands back: the engine mints it from what
111
+ * the adapter reported, so a handler cannot pass off an invented one as
112
+ * a child's status. exitWithChildStatus carries the mark onto its
113
+ * settlement and the settlement refuses an unmarked one.
114
+ */
115
+ function engineSpawnedResult(result) {
116
+ return markEngineSpawned({
117
+ exitCode: result.exitCode,
118
+ signal: result.signal
119
+ });
120
+ }
121
+ /** Signal numbers shared by Linux, macOS and the BSDs. Numbers that
122
+ * differ by platform (SIGBUS, SIGUSR1, SIGUSR2, …) are deliberately
123
+ * absent — a wrong 128+n is worse than the unknown-signal fallback. */
124
+ const SIGNAL_NUMBERS = {
125
+ SIGHUP: 1,
126
+ SIGINT: 2,
127
+ SIGQUIT: 3,
128
+ SIGILL: 4,
129
+ SIGTRAP: 5,
130
+ SIGABRT: 6,
131
+ SIGFPE: 8,
132
+ SIGKILL: 9,
133
+ SIGSEGV: 11,
134
+ SIGPIPE: 13,
135
+ SIGALRM: 14,
136
+ SIGTERM: 15
137
+ };
138
+ /** A signal-killed child settles 128 + the signal number; otherwise the
139
+ * child's own exit code, verbatim. Unknown is never success: a signal
140
+ * outside the portable table, or an adapter that cannot say how the
141
+ * child ended (exitCode and signal both null), settles 1. */
142
+ function childExitCode(child) {
143
+ if (child.signal === null) return child.exitCode ?? 1;
144
+ const signalNumber = SIGNAL_NUMBERS[child.signal];
145
+ return signalNumber === void 0 ? 1 : 128 + signalNumber;
146
+ }
147
+ /** Settles the run with the status of the child `ctx.spawn` returned.
148
+ * A result the engine did not produce is a construction error at
149
+ * settlement: this is how a real child's status reaches the exit code,
150
+ * not how a handler picks one. */
151
+ function exitWithChildStatus(child, options) {
152
+ const settlement = {
153
+ [CHILD_STATUS]: true,
154
+ exitCode: childExitCode(child),
155
+ nextActions: Object.freeze([...options?.nextActions ?? []])
156
+ };
157
+ return isEngineSpawned(child) ? markEngineSpawned(settlement) : Object.freeze(settlement);
158
+ }
159
+ function isChildStatusSettlement(value) {
160
+ return typeof value === "object" && value !== null && value[CHILD_STATUS] === true;
161
+ }
162
+ //#endregion
97
163
  //#region src/presentation.ts
98
164
  const PRESENTED = Symbol.for("prisma.cli-engine.presented");
99
165
  //#endregion
@@ -109,13 +175,17 @@ const useSessionAction = {
109
175
  };
110
176
  /**
111
177
  * The single constructor of CLI.CREDENTIALS_REQUIRED. Raised
112
- * identically by the needs check, ctx.session, and the engine's
113
- * request path.
178
+ * identically by the needs check, ctx.activeCredential, and the
179
+ * engine's request path.
114
180
  */
115
181
  function credentialsRequiredError(reason = "unauthenticated") {
116
182
  switch (reason) {
117
183
  case "unauthenticated": return new CliStructuredError("CLI.CREDENTIALS_REQUIRED", "You must be signed in to run this command.", { nextActions: [signInAction] });
118
184
  case "expired": return new CliStructuredError("CLI.CREDENTIALS_REQUIRED", "Your session has expired — sign in again.", { nextActions: [signInAction] });
185
+ case "expiring-soon": return new CliStructuredError("CLI.CREDENTIALS_REQUIRED", "Your session expires too soon to run this command — sign in again.", {
186
+ why: "This command hands your credentials to another program, which cannot refresh them while it runs.",
187
+ nextActions: [signInAction]
188
+ });
119
189
  case "session-ended": return new CliStructuredError("CLI.CREDENTIALS_REQUIRED", "The workspace session this command was using has ended.", {
120
190
  why: "It was ended while the command was running (for example by another prisma process).",
121
191
  nextActions: [useSessionAction, signInAction]
@@ -149,9 +219,25 @@ function credentialRejectedError(origin, envVar) {
149
219
  return origin.source === "environment" ? serviceTokenRejectedError({ envVar }) : credentialsRequiredError("expired");
150
220
  }
151
221
  /**
222
+ * A credential's workspace_id claim disagrees with the workspace it is
223
+ * being stored under, or a rotated token would re-scope a session.
224
+ * Raised by every CredentialManager, so a test sees what production
225
+ * raises.
226
+ */
227
+ function credentialWorkspaceMismatchError(workspaceId) {
228
+ return new CliStructuredError("AUTH.CREDENTIAL_WORKSPACE_MISMATCH", "That credential belongs to a different workspace.", {
229
+ why: `The token's workspace_id claim does not name workspace '${workspaceId}'.`,
230
+ nextActions: [{
231
+ kind: "run-command",
232
+ label: "Sign in again and pick the workspace you want",
233
+ command: "prisma auth login"
234
+ }]
235
+ });
236
+ }
237
+ /**
152
238
  * The env var that supplies a session is set to a blank value. The one
153
- * structured error for it, raised identically by currentSession(), the
154
- * needs check, and the engine's request path.
239
+ * structured error for it, raised identically by activeCredential(),
240
+ * the needs check, and the engine's request path.
155
241
  */
156
242
  function emptyServiceTokenError(spec) {
157
243
  return new CliStructuredError("AUTH.SERVICE_TOKEN_EMPTY", `${spec.envVar} is set but empty.`, {
@@ -179,6 +265,10 @@ function noSessionForWorkspaceError(workspaceRef) {
179
265
  }] });
180
266
  }
181
267
  /**
268
+ * Module-private on purpose: `credentialRejectedError` is the one place
269
+ * wording differs by origin (§11.1), and exporting this would be a
270
+ * second door into the environment-specific text that bypasses it.
271
+ *
182
272
  * The management API rejected the env-supplied service token (401).
183
273
  * There is no refresh for it and nothing stored is cleared.
184
274
  */
@@ -189,6 +279,14 @@ function serviceTokenRejectedError(spec) {
189
279
  }] });
190
280
  }
191
281
  //#endregion
282
+ //#region src/credential-manager.ts
283
+ /** The environment variables that supply a credential to a process: a
284
+ * service token, plus the workspace it acts in when the token's own
285
+ * claims name none. EnvironmentCredentialManager reads the pair; the
286
+ * spawn path writes it into a child's environment. */
287
+ const SERVICE_TOKEN_ENV_VAR = "PRISMA_SERVICE_TOKEN";
288
+ const WORKSPACE_ID_ENV_VAR = "PRISMA_WORKSPACE_ID";
289
+ //#endregion
192
290
  //#region src/execution/debug.ts
193
291
  const DEBUG_ENV_VAR = "PRISMA_NEXT_DEBUG";
194
292
  /**
@@ -204,7 +302,6 @@ function makeDebugLog(runtime) {
204
302
  }
205
303
  //#endregion
206
304
  //#region src/execution/api-client.ts
207
- const SERVICE_TOKEN_ENV_VAR = "PRISMA_SERVICE_TOKEN";
208
305
  /**
209
306
  * ctx.api: the ENGINE constructs and owns the management API client —
210
307
  * ONE client for the active credential, once per run (process pinning
@@ -322,11 +419,18 @@ async function mapRequestFailure(invocation, debug, probe, pinned, cause) {
322
419
  return authServiceError();
323
420
  }
324
421
  if (cameFromRefresh) debug(`refresh failed: refreshTokenInvalid=${String(authError.refreshTokenInvalid === true)} error=${endpointVerdict(authError.message)}`);
325
- if (authError.refreshTokenInvalid === true) return credentialsRequiredError("expired");
326
422
  const manager = invocation.runtime.credentialManager;
327
- if (manager === void 0 || pinned === void 0) return authServiceError();
423
+ if (manager === void 0 || pinned === void 0) return authError.refreshTokenInvalid === true ? credentialsRequiredError("expired") : authServiceError();
424
+ const homeRecord = hasHomeRecord(pinned.active);
425
+ if (authError.refreshTokenInvalid === true) return homeRecord ? credentialsRequiredError("expired") : credentialRejectedError(pinned.active.origin, SERVICE_TOKEN_ENV_VAR);
328
426
  if (cameFromRefresh && await couldNeverHaveBeenRenewed(pinned.storage)) return credentialRejectedError(pinned.active.origin, SERVICE_TOKEN_ENV_VAR);
329
- return mapAgainstStoredState(manager, pinned.active, cause);
427
+ return homeRecord ? mapAgainstStoredState(manager, pinned.active, cause) : authServiceError();
428
+ }
429
+ /** Whether this credential is backed by a stored session. The origin
430
+ * is the only thing that answers it, which is why the credential-
431
+ * rejected error is allowed to read it (§11.1). */
432
+ function hasHomeRecord(active) {
433
+ return active.origin.source === "stored";
330
434
  }
331
435
  /**
332
436
  * A 401 that could never have been renewed: the SDK refused to reach
@@ -375,28 +479,571 @@ function structuredCause(error) {
375
479
  function sdkAuthErrorInCauseChain(error) {
376
480
  for (const current of causeChain(error)) if (current.name === "AuthError") return current;
377
481
  }
378
- /** The request failure carries the refresh attempt's own throw, so the
379
- * failure arose in the refresh path rather than in the request. */
380
- function refreshPathFailed(probe, cause) {
381
- if (probe.failure === void 0) return false;
382
- if (cause === probe.failure) return true;
383
- for (const current of causeChain(cause)) if (current === probe.failure) return true;
384
- return false;
482
+ /** The request failure carries the refresh attempt's own throw, so the
483
+ * failure arose in the refresh path rather than in the request. */
484
+ function refreshPathFailed(probe, cause) {
485
+ if (probe.failure === void 0) return false;
486
+ if (cause === probe.failure) return true;
487
+ for (const current of causeChain(cause)) if (current === probe.failure) return true;
488
+ return false;
489
+ }
490
+ function errorTypeOf(error) {
491
+ return error instanceof Error ? error.name : typeof error;
492
+ }
493
+ /**
494
+ * The endpoint's verdict, without its free text. The SDK builds a
495
+ * refresh AuthError's message either as `<error>: <error_description>`
496
+ * from the token endpoint's body or as one of its own fixed strings
497
+ * (which carry the HTTP status). Only the part before the description
498
+ * is logged: the description is text the auth service chose, and the
499
+ * debug valve must never become a way for it to reach a log.
500
+ */
501
+ function endpointVerdict(message) {
502
+ const description = message.indexOf(": ");
503
+ return description === -1 ? message : message.slice(0, description);
504
+ }
505
+ //#endregion
506
+ //#region src/runtime.ts
507
+ /**
508
+ * The config contract version defineConfig writes as the structural
509
+ * `$prismaConfig` marker; the loader checks it before interpreting
510
+ * anything.
511
+ */
512
+ const PRISMA_CONFIG_VERSION = 1;
513
+ //#endregion
514
+ //#region src/config-loader.ts
515
+ /**
516
+ * The prisma.config.ts loader behind Runtime.loadConfig: resolve the
517
+ * file (the one `--config` named, otherwise prisma.config.ts in cwd —
518
+ * cwd only, no walking up), evaluate it, check the defineConfig version
519
+ * marker, and produce LoadedConfig.
520
+ *
521
+ * Which section names a CLI recognises is not this module's business:
522
+ * it hands back every top-level key the file had, and the engine — not
523
+ * a Runtime member a host can replace — checks them against the
524
+ * sections the mounted commands declare.
525
+ *
526
+ * Absence of an undiscovered file is not an error: section validators
527
+ * own absence, so no prisma.config.ts in cwd yields no sections and no
528
+ * diagnostics.
529
+ * Absence of a file the user NAMED with --config is an error — they
530
+ * said which file to read and it was not there. An evaluated file
531
+ * WITHOUT the marker (a classic Prisma 7 config, which uses the same
532
+ * filename) fails early with one typed diagnostic — the loader never
533
+ * partially interprets an unmarked file, and never guesses.
534
+ *
535
+ * Evaluation goes through c12, the same loader prisma/prisma and
536
+ * prisma/composer use, because the shipped CLI runs on ordinary Node,
537
+ * which cannot import a .ts file. c12 transpiles it with jiti first.
538
+ * Every c12 feature beyond "evaluate this one file" is switched off
539
+ * below so discovery and merging stay exactly as they were.
540
+ */
541
+ const CONFIG_FILE_NAME = "prisma.config.ts";
542
+ const MARKER_KEY = "$prismaConfig";
543
+ /**
544
+ * Top-level keys the config file format keeps for itself, so no
545
+ * section may be named one of them; buildCommandTree rejects the
546
+ * declaration at construction.
547
+ *
548
+ * `$`-prefixed keys are metadata: `$prismaConfig` is the version
549
+ * marker, and config loaders read `$env`, `$<NODE_ENV>` and `$meta` —
550
+ * c12 deletes `$meta` from the config object whatever else it is told.
551
+ * `extends` is the key config loaders take as "merge another file into
552
+ * this one". This loader switches that off (`extend: false`), so a key
553
+ * by that name does reach the config object. It stays reserved anyway:
554
+ * the file format has no layering of its own, `extends` is the name it
555
+ * would want if it gained some, and a section called `extends` would
556
+ * disappear the moment anything switched merging back on.
557
+ *
558
+ * `__proto__` is reserved for the reason `$meta` is: c12 merges layers
559
+ * with defu, which drops the key rather than let a config file reach an
560
+ * object's prototype, so a section by that name could never be read.
561
+ */
562
+ function reservedConfigSectionName(name) {
563
+ return name === "extends" || name === "__proto__" || name.startsWith("$");
564
+ }
565
+ /**
566
+ * Attaches the version marker to a prisma.config.ts export. Each
567
+ * top-level key names a config section, and the recognised section
568
+ * names are exactly the ones the CLI's command families declare. Never
569
+ * throws — bad section values are the section validator's problem, not
570
+ * defineConfig's.
571
+ */
572
+ function defineConfig(config) {
573
+ return Object.freeze({
574
+ ...config,
575
+ $prismaConfig: 1
576
+ });
577
+ }
578
+ function hasVersionMarker(value) {
579
+ return typeof value === "object" && value !== null && typeof value[MARKER_KEY] === "number";
580
+ }
581
+ function fileLevelConfig(path, diagnostic) {
582
+ return {
583
+ path,
584
+ sections: {},
585
+ diagnostics: [{
586
+ section: null,
587
+ diagnostic
588
+ }]
589
+ };
590
+ }
591
+ function missingMarkerDiagnostic(path) {
592
+ return {
593
+ code: "CLI.CONFIG_MISSING_MARKER",
594
+ severity: "error",
595
+ summary: `${path} was not written for this version of the Prisma CLI, so it cannot be used.`,
596
+ why: "Configs for this CLI are created with defineConfig, which records a version marker on the exported object. This file's default export has no marker — it is most likely a Prisma 7 config, which uses the same filename — and the CLI stops rather than misread it.",
597
+ nextActions: [{
598
+ kind: "user-choice",
599
+ label: "Migrate the file: wrap the exported object in defineConfig from @prisma/cli-engine and export the result as the default export."
600
+ }],
601
+ where: { path }
602
+ };
603
+ }
604
+ function firstLine$1(text) {
605
+ const newline = text.indexOf("\n");
606
+ return (newline === -1 ? text : text.slice(0, newline)).trim();
607
+ }
608
+ function unsupportedVersionDiagnostic(path, found) {
609
+ return {
610
+ code: "CLI.CONFIG_VERSION_UNSUPPORTED",
611
+ severity: "error",
612
+ summary: `${path} declares config version ${found}, but this CLI supports only version 1.`,
613
+ nextActions: [{
614
+ kind: "user-choice",
615
+ label: "Regenerate the config with a defineConfig matching this CLI, or update the CLI to a version that supports the declared config version."
616
+ }],
617
+ where: { path }
618
+ };
619
+ }
620
+ function missingNamedFileDiagnostic(path) {
621
+ return {
622
+ code: "CLI.CONFIG_NOT_FOUND",
623
+ severity: "error",
624
+ summary: `--config named ${path}, and there is no file there.`,
625
+ why: "A config file found by discovery may be absent — the section validators supply their defaults. A config file named on the command line may not: the CLI would otherwise run against different settings than the ones asked for.",
626
+ nextActions: [{
627
+ kind: "user-choice",
628
+ label: "Correct the path passed to --config, or drop the flag to use the prisma.config.ts in the current directory."
629
+ }],
630
+ where: { path }
631
+ };
632
+ }
633
+ function unreadableDiagnostic(path, cause) {
634
+ return {
635
+ code: "CLI.CONFIG_UNREADABLE",
636
+ severity: "error",
637
+ summary: `${path} could not be evaluated: ${firstLine$1(cause instanceof Error ? cause.message : String(cause))}`,
638
+ nextActions: [{
639
+ kind: "user-choice",
640
+ label: "Fix the error in the file, then run the command again."
641
+ }],
642
+ where: { path }
643
+ };
644
+ }
645
+ /**
646
+ * Everything c12 does beyond evaluating the one file it was handed.
647
+ * Composer leaves the last five at their defaults and can afford to:
648
+ * its config has a fixed set of keys, where every top-level key here is
649
+ * a user-authored section name, so all five are reachable from an
650
+ * ordinary config file.
651
+ */
652
+ const EVALUATE_ONE_FILE_ONLY = {
653
+ rcFile: false,
654
+ globalRc: false,
655
+ packageJson: false,
656
+ /** Else `$production` blocks merge over the root under NODE_ENV. */
657
+ envName: false,
658
+ /** Else `$prismaConfig` is stripped and every config reads unmarked. */
659
+ omit$Keys: false,
660
+ /** Else `extends` is a merge directive rather than a section name. */
661
+ extend: false,
662
+ /** Else an `extends` URL is fetched over the network and evaluated. */
663
+ giget: false,
664
+ /** Else a neighbouring .env is read into process.env. */
665
+ dotenv: false
666
+ };
667
+ /**
668
+ * Evaluates the file at `path` and returns its default export. The call
669
+ * is prisma/composer's `loadAppConfig` with prisma/prisma's dynamic
670
+ * import, so a run with no config file never pays for c12 or jiti.
671
+ *
672
+ * The loaded-file check is in both references: c12 is asked for one
673
+ * exact path and must not answer with another.
674
+ */
675
+ async function evaluateConfigFile(path) {
676
+ const result = await (await import("c12")).loadConfig({
677
+ name: "prisma",
678
+ configFile: path,
679
+ cwd: dirname(path),
680
+ ...EVALUATE_ONE_FILE_ONLY
681
+ });
682
+ const loadedFile = result.configFile;
683
+ if (typeof loadedFile !== "string" || realpathSync(loadedFile) !== realpathSync(path)) throw new Error(`config loading resolved ${String(loadedFile)} instead of ${path}`);
684
+ return result.config;
685
+ }
686
+ /** Built with fromEntries rather than assigned key by key: assigning a
687
+ * key named `__proto__` runs Object.prototype's setter instead of
688
+ * creating an own property, so that one key would disappear from
689
+ * Object.keys and never be reported as unrecognised. */
690
+ function sectionsOf(exported) {
691
+ return Object.fromEntries(Object.entries(exported).filter(([key]) => key !== MARKER_KEY));
692
+ }
693
+ /**
694
+ * The file to read, always absolute: the one --config named, resolved
695
+ * against cwd, or prisma.config.ts in cwd.
696
+ *
697
+ * Absolute is not cosmetic, and it is one more thing than either
698
+ * reference repository does — both are handed an absolute path before
699
+ * they reach c12, so neither has to resolve one. Given a relative path,
700
+ * c12 resolves it a second time against its own cwd and looks for a
701
+ * file that is not there, and jiti cannot import a relative specifier
702
+ * at all. Resolving here also makes the file's path in every diagnostic
703
+ * absolute, and makes the loaded-file comparison compare like with
704
+ * like.
705
+ */
706
+ function fileToRead(cwd, configPath) {
707
+ const root = resolve(cwd);
708
+ return configPath === void 0 ? join(root, CONFIG_FILE_NAME) : resolve(root, configPath);
709
+ }
710
+ /**
711
+ * The real-disk loader behind Runtime.loadConfig. The bin binds it to
712
+ * the process cwd; tests hand in fixtures.
713
+ */
714
+ async function loadConfig(cwd, configPath) {
715
+ const path = fileToRead(cwd, configPath);
716
+ if (!existsSync(path)) return configPath === void 0 ? {
717
+ path,
718
+ sections: {},
719
+ diagnostics: []
720
+ } : fileLevelConfig(path, missingNamedFileDiagnostic(path));
721
+ let exported;
722
+ try {
723
+ exported = await evaluateConfigFile(path);
724
+ } catch (cause) {
725
+ return fileLevelConfig(path, unreadableDiagnostic(path, cause));
726
+ }
727
+ if (!hasVersionMarker(exported)) return fileLevelConfig(path, missingMarkerDiagnostic(path));
728
+ const version = exported[MARKER_KEY];
729
+ if (version !== 1) return fileLevelConfig(path, unsupportedVersionDiagnostic(path, version));
730
+ return {
731
+ path,
732
+ sections: sectionsOf(exported),
733
+ diagnostics: []
734
+ };
735
+ }
736
+ //#endregion
737
+ //#region src/execution/pre-parse-argv.ts
738
+ function flagTokens(argv) {
739
+ const terminator = argv.indexOf("--");
740
+ return terminator === -1 ? argv : argv.slice(0, terminator);
741
+ }
742
+ function versionFlagGiven(argv) {
743
+ return flagTokens(argv).includes("--version");
744
+ }
745
+ /**
746
+ * The one malformed `--config` shape the parser cannot see. stricli
747
+ * matches a flag-with-value against `/^--([a-z][a-z-.\d_]+)=(.+)$/`,
748
+ * which needs at least one character after the `=`, so the bare token
749
+ * `--config=` is not a flag to it at all and falls through to the
750
+ * command's positional arguments. prisma/prisma rejects that shape as a
751
+ * usage error (a user who wrote `--config=` meant to name a file), so
752
+ * the engine checks for the exact token before handing argv over.
753
+ *
754
+ * Running before parsing, this cannot tell a flag from data: it rejects
755
+ * `--config=` wherever it appears ahead of a bare `--`, including as
756
+ * another flag's value or a positional. prisma/prisma's scan does the
757
+ * same and does not stop at `--`; the token is an odd one to need as
758
+ * data, and `--` remains the way to pass it.
759
+ */
760
+ function configFlagGivenNoValue(argv) {
761
+ return flagTokens(argv).includes("--config=");
762
+ }
763
+ /** The format requested by --json / --format / --format=<value>, if
764
+ * any. */
765
+ function formatFlagGiven(argv) {
766
+ const tokens = flagTokens(argv);
767
+ for (const [index, token] of tokens.entries()) {
768
+ if (token === "--json" || token === "--format=json") return "json";
769
+ if (token === "--format=human") return "human";
770
+ if (token === "--format") {
771
+ const value = tokens[index + 1];
772
+ if (value === "json" || value === "human") return value;
773
+ }
774
+ }
775
+ }
776
+ //#endregion
777
+ //#region src/execution/shared-flags.ts
778
+ /** The engine-injected shared flag family. Commands cannot declare
779
+ * these names or aliases; handlers never see their values. */
780
+ const RESERVED_FLAG_NAMES = new Set([
781
+ "format",
782
+ "json",
783
+ "logLevel",
784
+ "verbose",
785
+ "quiet",
786
+ "yes",
787
+ "confirm",
788
+ "interactive",
789
+ "color",
790
+ "config",
791
+ "help",
792
+ "helpAll",
793
+ "version"
794
+ ]);
795
+ const RESERVED_ALIASES = new Set([
796
+ "v",
797
+ "q",
798
+ "y",
799
+ "h"
800
+ ]);
801
+ const SHARED_FLAG_PARAMETERS = {
802
+ format: {
803
+ kind: "enum",
804
+ values: ["human", "json"],
805
+ optional: true,
806
+ brief: "Output format"
807
+ },
808
+ json: {
809
+ kind: "boolean",
810
+ default: false,
811
+ brief: "Shorthand for --format json"
812
+ },
813
+ logLevel: {
814
+ kind: "enum",
815
+ values: [
816
+ "error",
817
+ "warn",
818
+ "info",
819
+ "verbose"
820
+ ],
821
+ optional: true,
822
+ brief: "Commentary verbosity"
823
+ },
824
+ verbose: {
825
+ kind: "boolean",
826
+ default: false,
827
+ brief: "Shorthand for --log-level verbose"
828
+ },
829
+ quiet: {
830
+ kind: "boolean",
831
+ default: false,
832
+ brief: "Shorthand for --log-level error"
833
+ },
834
+ yes: {
835
+ kind: "boolean",
836
+ default: false,
837
+ brief: "Accept prompt defaults without asking"
838
+ },
839
+ confirm: {
840
+ kind: "parsed",
841
+ parse: (input) => input,
842
+ placeholder: "value",
843
+ variadic: true,
844
+ optional: true,
845
+ brief: "Grant a consent prompt non-interactively by typing its token (repeatable)"
846
+ },
847
+ interactive: {
848
+ kind: "boolean",
849
+ optional: true,
850
+ withNegated: true,
851
+ brief: "Force interactive prompts on or off"
852
+ },
853
+ color: {
854
+ kind: "boolean",
855
+ optional: true,
856
+ withNegated: true,
857
+ brief: "Force ANSI color on or off"
858
+ },
859
+ config: {
860
+ kind: "parsed",
861
+ parse: parseConfigPath,
862
+ placeholder: "path",
863
+ optional: true,
864
+ brief: "Read this config file instead of ./prisma.config.ts"
865
+ }
866
+ };
867
+ /** Rejects `--config ""`, which a shell produces from
868
+ * `--config "$UNSET_VAR"`. prisma/prisma treats the empty value as a
869
+ * usage error rather than letting it reach the loader as an empty
870
+ * path, and so does this: the parser turns the throw into the run's
871
+ * usage error. */
872
+ function parseConfigPath(input) {
873
+ if (input === "") throw new Error("--config needs a path, and was given an empty value");
874
+ return input;
875
+ }
876
+ function configFlagGivenNoValueError() {
877
+ return new CliStructuredError("CLI.INVALID_ARGUMENTS", "--config needs a path, and was given an empty value", {
878
+ why: "`--config=` binds the flag to an empty value.",
879
+ nextActions: [{
880
+ kind: "user-choice",
881
+ label: "Pass a config path: --config <path> or --config=<path>."
882
+ }]
883
+ });
884
+ }
885
+ const SHARED_ALIASES = {
886
+ v: "verbose",
887
+ q: "quiet",
888
+ y: "yes"
889
+ };
890
+ /** The pre-parse format decision: json framing must be in effect before
891
+ * stricli parses (its own failure output is framed too), so the format
892
+ * flags are read from raw argv and a TTY stdout decides the rest. */
893
+ function sniffFormat(argv, runtime) {
894
+ return formatFlagGiven(argv) ?? (runtime.isTty.stdout ? "human" : "json");
895
+ }
896
+ function applySharedFlags(state, shared, runtime) {
897
+ state.format = shared.format ?? resolveAutoFormat(shared, runtime);
898
+ state.yes = shared.yes === true;
899
+ state.confirmValues = [...shared.confirm ?? []];
900
+ state.interactive = shared.interactive ?? defaultInteractive(runtime);
901
+ state.logLevel = resolveLogLevel(shared);
902
+ state.colorEnabled = shared.color ?? (runtime.isTty.stdout && runtime.env.NO_COLOR === void 0);
903
+ state.configPath = shared.config;
904
+ }
905
+ /** Interactive iff TTY stdin outside CI; --interactive and
906
+ * --no-interactive override in either direction. Format never decides
907
+ * interactivity (operator ruling, 2026-08-09): an interactive json run
908
+ * may prompt — the prompt UI writes to stderr, so stdout stays a clean
909
+ * frame stream. */
910
+ function defaultInteractive(runtime) {
911
+ return runtime.isTty.stdin && runtime.env.CI === void 0;
912
+ }
913
+ function resolveAutoFormat(shared, runtime) {
914
+ if (shared.json === true) return "json";
915
+ return runtime.isTty.stdout ? "human" : "json";
916
+ }
917
+ /** --quiet and --verbose are log-level shorthands; either one beats an
918
+ * explicit --log-level given alongside it. */
919
+ function resolveLogLevel(shared) {
920
+ if (shared.quiet === true) return "error";
921
+ if (shared.verbose === true) return "verbose";
922
+ return shared.logLevel ?? "info";
923
+ }
924
+ //#endregion
925
+ //#region src/execution/command-tree.ts
926
+ function constructionError(message) {
927
+ return /* @__PURE__ */ new Error(`@prisma/cli-engine: ${message}`);
928
+ }
929
+ const CAMEL_CASE = /^[a-z][a-zA-Z0-9]*$/;
930
+ const INTEGER_LIKE = /^\d+$/;
931
+ function validateFlags(path, def) {
932
+ const flags = def.args.flags;
933
+ const seenAliases = /* @__PURE__ */ new Set();
934
+ for (const [key, spec] of Object.entries(flags)) {
935
+ if (RESERVED_FLAG_NAMES.has(key)) throw constructionError(`command '${path}' declares reserved flag '${key}' (the shared flag family is engine-injected)`);
936
+ if (!CAMEL_CASE.test(key)) throw constructionError(`command '${path}' flag '${key}' must be camelCase (it transliterates to --kebab-case on the CLI)`);
937
+ const alias = flagRuntime(spec).alias;
938
+ if (alias === void 0) continue;
939
+ if (RESERVED_ALIASES.has(alias)) throw constructionError(`command '${path}' flag '${key}' uses reserved alias '-${alias}'`);
940
+ if (seenAliases.has(alias)) throw constructionError(`command '${path}' declares alias '-${alias}' twice`);
941
+ seenAliases.add(alias);
942
+ }
943
+ }
944
+ function validatePositionals(path, def) {
945
+ const entries = Object.entries(def.args.positionals);
946
+ let sawOptional = false;
947
+ for (const [index, [key, spec]] of entries.entries()) {
948
+ const runtime = positionalRuntime(spec);
949
+ if (INTEGER_LIKE.test(key)) throw constructionError(`command '${path}' positional key '${key}' must not be integer-like`);
950
+ if (runtime.type === "variadic" && index !== entries.length - 1) throw constructionError(`command '${path}' variadic positional '${key}' must be declared last`);
951
+ if (runtime.type === "optionalString") sawOptional = true;
952
+ if (runtime.type === "string" && sawOptional) throw constructionError(`command '${path}' required positional '${key}' may not follow an optional one`);
953
+ }
954
+ }
955
+ function validateExitCodes(path, def) {
956
+ if (def.kind !== "result-command") return;
957
+ for (const key of Object.keys(def.exitCodes)) {
958
+ const code = Number(key);
959
+ if (!Number.isInteger(code) || code < 4 || code > 99) throw constructionError(`command '${path}' documents exit code ${key}; documented codes must be integers in 4-99`);
960
+ }
961
+ }
962
+ function validateSpawnDeclarations(path, def) {
963
+ if (def.needs.credentials === "child" && !def.maySpawn) throw constructionError(`command '${path}' needs credentials for a child without declaring maySpawn (there is nothing to hand credentials to)`);
964
+ }
965
+ function emptyNode() {
966
+ return {
967
+ commands: /* @__PURE__ */ new Map(),
968
+ children: /* @__PURE__ */ new Map()
969
+ };
970
+ }
971
+ function insertCommand(root, path, def, docsBaseUrl) {
972
+ const segments = path.split(" ");
973
+ if (segments.some((segment) => segment.length === 0)) throw constructionError(`invalid command path '${path}'`);
974
+ let node = root;
975
+ for (const segment of segments.slice(0, -1)) {
976
+ if (node.commands.has(segment)) throw constructionError(`command path '${path}' collides with a command mounted at a prefix of it`);
977
+ let child = node.children.get(segment);
978
+ if (child === void 0) {
979
+ child = emptyNode();
980
+ node.children.set(segment, child);
981
+ }
982
+ node = child;
983
+ }
984
+ const leaf = segments[segments.length - 1];
985
+ if (node.commands.has(leaf) || node.children.has(leaf)) throw constructionError(`command path '${path}' collides with another mounted command`);
986
+ node.commands.set(leaf, {
987
+ def,
988
+ id: segments.join("."),
989
+ docsBaseUrl
990
+ });
991
+ }
992
+ /** A command belongs to the family whose commands record contains it
993
+ * (identity). Harness-mounted commands with no family are unowned. */
994
+ function commandFamilyOf(spec, def) {
995
+ return spec.commandFamilies.find((commandFamily) => Object.values(commandFamily.commands).includes(def));
996
+ }
997
+ function validateSectionOwnership(spec, path, def) {
998
+ const section = def.needs.config;
999
+ if (section === void 0) return;
1000
+ const commandFamily = commandFamilyOf(spec, def);
1001
+ if (commandFamily === void 0) return;
1002
+ if (commandFamily.configSection !== section) throw constructionError(`command '${path}' needs the '${section.name}' config section, which is not its command family's section`);
385
1003
  }
386
- function errorTypeOf(error) {
387
- return error instanceof Error ? error.name : typeof error;
1004
+ /** The config file's top-level keys are the declared section names, so
1005
+ * a section may only be named something the file format leaves free:
1006
+ * not `$`-prefixed (those are metadata — $prismaConfig is the version
1007
+ * marker, and a $meta key is deleted before the loader ever sees it),
1008
+ * and not `extends` (the key config loaders take as an instruction to
1009
+ * merge another file in). Both the families and the commands mounted
1010
+ * without one are checked: whoever declares the section, claiming a
1011
+ * reserved name is broken at build time, not at a user's runtime. */
1012
+ function validateConfigSectionNames(spec) {
1013
+ for (const commandFamily of spec.commandFamilies) rejectReservedSectionName("command family", commandFamily.configSection);
1014
+ for (const [path, def] of Object.entries(spec.commands)) rejectReservedSectionName(`command '${path}'`, def.needs.config);
1015
+ }
1016
+ function rejectReservedSectionName(owner, section) {
1017
+ if (section === void 0 || !reservedConfigSectionName(section.name)) return;
1018
+ throw constructionError(`${owner} declares config section '${section.name}', a name the config file reserves ('extends' is a config loader's merge directive, and '$'-prefixed keys are metadata)`);
388
1019
  }
389
- /**
390
- * The endpoint's verdict, without its free text. The SDK builds a
391
- * refresh AuthError's message either as `<error>: <error_description>`
392
- * from the token endpoint's body or as one of its own fixed strings
393
- * (which carry the HTTP status). Only the part before the description
394
- * is logged: the description is text the auth service chose, and the
395
- * debug valve must never become a way for it to reach a log.
396
- */
397
- function endpointVerdict(message) {
398
- const description = message.indexOf(": ");
399
- return description === -1 ? message : message.slice(0, description);
1020
+ function validateDocsBaseUrls(spec) {
1021
+ for (const commandFamily of spec.commandFamilies) {
1022
+ const base = commandFamily.docsBaseUrl;
1023
+ if (base !== void 0 && !URL.canParse(base)) throw constructionError(`command family docsBaseUrl '${base}' is not a valid URL`);
1024
+ }
1025
+ }
1026
+ function buildCommandTree(spec) {
1027
+ const paths = Object.keys(spec.commands);
1028
+ if (paths.length === 0) throw constructionError("createCli requires at least one mounted command");
1029
+ validateDocsBaseUrls(spec);
1030
+ validateConfigSectionNames(spec);
1031
+ const root = emptyNode();
1032
+ for (const path of paths) {
1033
+ const def = spec.commands[path];
1034
+ validateFlags(path, def);
1035
+ validatePositionals(path, def);
1036
+ validateExitCodes(path, def);
1037
+ validateSpawnDeclarations(path, def);
1038
+ validateSectionOwnership(spec, path, def);
1039
+ const segments = path.split(" ");
1040
+ for (let depth = 1; depth < segments.length; depth += 1) {
1041
+ const groupPath = segments.slice(0, depth).join(" ");
1042
+ if (spec.groups[groupPath] === void 0) throw constructionError(`command path '${path}' references unknown group '${groupPath}' (declare it in createCli's groups)`);
1043
+ }
1044
+ insertCommand(root, path, def, commandFamilyOf(spec, def)?.docsBaseUrl);
1045
+ }
1046
+ return root;
400
1047
  }
401
1048
  //#endregion
402
1049
  //#region src/execution/rendering.ts
@@ -518,8 +1165,6 @@ function renderCompletedHuman(invocation, presented) {
518
1165
  for (const diagnostic of presented.diagnostics) writeDiagnostic(runtime.stderr, withDocsUrl(state, diagnostic));
519
1166
  for (const line of presented.presentation.stdout) runtime.stdout.write(`${line}\n`);
520
1167
  }
521
- //#endregion
522
- //#region src/execution/reporting.ts
523
1168
  const SEVERITY_RANK = {
524
1169
  error: 0,
525
1170
  warn: 1,
@@ -546,6 +1191,15 @@ function reportEvent(invocation, event) {
546
1191
  reportAfterResolution(invocation);
547
1192
  return;
548
1193
  }
1194
+ const terminal = state.delegatedTerminal;
1195
+ if (terminal !== void 0) {
1196
+ if (terminal.buffered.length >= 1e3) {
1197
+ terminal.dropped += 1;
1198
+ return;
1199
+ }
1200
+ terminal.buffered.push(event);
1201
+ return;
1202
+ }
549
1203
  invocation.hooks.onEvent?.(event);
550
1204
  const severity = eventDisplaySeverity(event);
551
1205
  if (severity !== void 0 && SEVERITY_RANK[severity] > SEVERITY_RANK[state.logLevel]) return;
@@ -559,12 +1213,18 @@ function reportEvent(invocation, event) {
559
1213
  }
560
1214
  renderEventHuman(invocation, event);
561
1215
  }
1216
+ function flushBufferedEvents(invocation, terminal) {
1217
+ for (const event of terminal.buffered) reportEvent(invocation, event);
1218
+ if (terminal.dropped > 0) reportEvent(invocation, {
1219
+ kind: "message",
1220
+ severity: "warn",
1221
+ text: `${terminal.dropped} buffered event${terminal.dropped === 1 ? "" : "s"} dropped while a child owned the terminal`
1222
+ });
1223
+ }
562
1224
  function emitFrame(invocation, frame) {
563
1225
  invocation.runtime.stdout.write(`${JSON.stringify(frame)}\n`);
564
1226
  invocation.hooks.onStreamEvent?.(frame);
565
1227
  }
566
- //#endregion
567
- //#region src/execution/needs.ts
568
1228
  function needsErrored(error, diagnostics = []) {
569
1229
  return {
570
1230
  kind: "errored",
@@ -589,12 +1249,21 @@ function structuredErrorFromDiagnostic(diagnostic) {
589
1249
  * success it carries the validated section value for ctx.config. */
590
1250
  async function checkNeeds(def, invocation) {
591
1251
  const needs = def.needs;
592
- const failure = checkInteraction(needs, invocation) ?? checkDependencies(needs, invocation) ?? await checkCredentials(needs, invocation);
1252
+ const failure = checkInteraction(needs, invocation) ?? checkDependencies(needs, invocation);
593
1253
  if (failure !== void 0) return failure;
594
- if (needs.config !== void 0) return checkConfiguration(needs.config, invocation);
1254
+ const credentials = await checkCredentials(needs, invocation);
1255
+ if (credentials.failure !== void 0) return credentials.failure;
1256
+ if (needs.config !== void 0) {
1257
+ const outcome = await checkConfiguration(needs.config, invocation);
1258
+ return outcome.kind === "ok" ? {
1259
+ ...outcome,
1260
+ spawnCredential: credentials.spawnCredential
1261
+ } : outcome;
1262
+ }
595
1263
  return {
596
1264
  kind: "ok",
597
- config: void 0
1265
+ config: void 0,
1266
+ spawnCredential: credentials.spawnCredential
598
1267
  };
599
1268
  }
600
1269
  function checkInteraction(needs, invocation) {
@@ -617,29 +1286,80 @@ function checkDependencies(needs, invocation) {
617
1286
  * pass through verbatim so the needs check, ctx.activeCredential, and
618
1287
  * ctx.api raise identically. A host with no manager wired has no
619
1288
  * credentials at all.
1289
+ *
1290
+ * The `"child"` form resolves the same credential ONCE, additionally
1291
+ * refuses a session about to expire — before the handler runs, not
1292
+ * before the spawn: the work that precedes a spawn creates real
1293
+ * platform resources, and the child cannot refresh the snapshot it is
1294
+ * given — and carries the credential forward for the spawn path.
620
1295
  */
621
1296
  async function checkCredentials(needs, invocation) {
622
- if (!needs.credentials) return;
1297
+ if (needs.credentials === false) return {};
623
1298
  const manager = invocation.runtime.credentialManager;
624
- if (manager === void 0) return needsErrored(credentialsRequiredError());
1299
+ if (manager === void 0) return { failure: needsErrored(credentialsRequiredError()) };
1300
+ let credential;
625
1301
  try {
626
- if (await manager.activeCredential() === null) return needsErrored(credentialsRequiredError());
627
- return;
1302
+ credential = await manager.activeCredential();
628
1303
  } catch (cause) {
629
- if (CliStructuredError.is(cause)) return needsErrored(cause);
1304
+ if (CliStructuredError.is(cause)) return { failure: needsErrored(cause) };
630
1305
  throw cause;
631
1306
  }
1307
+ if (credential === null) return { failure: needsErrored(credentialsRequiredError()) };
1308
+ if (needs.credentials !== "child") return {};
1309
+ const expiry = nearExpiryFailure(credential, invocation);
1310
+ return expiry === void 0 ? { spawnCredential: credential } : { failure: expiry };
1311
+ }
1312
+ function nearExpiryFailure(credential, invocation) {
1313
+ if (credential.expiresAt === void 0) return;
1314
+ if (credential.expiresAt.getTime() - invocation.now().getTime() > 3e5) return;
1315
+ return needsErrored(credentialsRequiredError("expiring-soon"));
1316
+ }
1317
+ /**
1318
+ * A top-level key in the config file that is not one of the sections
1319
+ * the mounted commands and command families declare. The set is closed,
1320
+ * so an unrecognised key is a typo or a leftover, and staying silent
1321
+ * would mean quietly ignoring settings the user wrote.
1322
+ *
1323
+ * The check is the engine's rather than the loader's because the loader
1324
+ * is a Runtime member a host supplies: a check on the far side of that
1325
+ * seam holds only for as long as every host writes one.
1326
+ */
1327
+ function unknownSectionDiagnostic(path, key, configSections) {
1328
+ return {
1329
+ code: "CLI.CONFIG_UNKNOWN_SECTION",
1330
+ severity: "error",
1331
+ summary: `${path} has a top-level key '${key}', which is not a config section this CLI recognises.`,
1332
+ why: `The sections this CLI recognises are: ${[...configSections].sort().join(", ")}.`,
1333
+ nextActions: [{
1334
+ kind: "user-choice",
1335
+ label: "Remove the key, or rename it to one of the recognised section names."
1336
+ }],
1337
+ where: { path }
1338
+ };
632
1339
  }
633
- function checkConfiguration(section, invocation) {
634
- const fileLevel = invocation.runtime.config.diagnostics.filter((entry) => entry.section === null);
635
- if (fileLevel.length > 0) return needsErrored(structuredErrorFromDiagnostic(fileLevel[0].diagnostic), fileLevel.slice(1).map((entry) => entry.diagnostic));
636
- return validateConfigSection(section, invocation);
1340
+ function unknownSections(loaded, configSections) {
1341
+ const declared = new Set(configSections);
1342
+ return Object.keys(loaded.sections).filter((key) => !declared.has(key)).map((key) => unknownSectionDiagnostic(loaded.path, key, configSections));
1343
+ }
1344
+ /** The config file is read HERE and nowhere else, so a command with no
1345
+ * needs.config never touches it. The file `--config` named travels on
1346
+ * the run state; the closed set of section names comes from the
1347
+ * mounted command families, and every key outside it is reported here
1348
+ * whatever the loader did or did not check. */
1349
+ async function checkConfiguration(section, invocation) {
1350
+ const configPath = invocation.state.configPath;
1351
+ const loaded = await invocation.runtime.loadConfig(configPath);
1352
+ const fileLevel = [...loaded.diagnostics.filter((entry) => entry.section === null).map((entry) => entry.diagnostic), ...unknownSections(loaded, invocation.configSections)];
1353
+ if (fileLevel.length > 0) return needsErrored(structuredErrorFromDiagnostic(fileLevel[0]), fileLevel.slice(1));
1354
+ return validateConfigSection(section, loaded, invocation, configPath ?? "prisma.config.ts");
637
1355
  }
638
1356
  /** Validates the command's needed config section. The validator
639
1357
  * owns absence (it receives undefined when the section is missing) and
640
- * never throws — a throw is an engine-boundary bug, settled as one. */
641
- function validateConfigSection(section, invocation) {
642
- const raw = invocation.runtime.config.sections[section.name];
1358
+ * never throws — a throw is an engine-boundary bug, settled as one.
1359
+ * `configFile` is named in the error so a run under --config points at
1360
+ * the file it actually read. */
1361
+ function validateConfigSection(section, loaded, invocation, configFile) {
1362
+ const raw = loaded.sections[section.name];
643
1363
  let validation;
644
1364
  try {
645
1365
  validation = section.validate(raw);
@@ -649,14 +1369,15 @@ function validateConfigSection(section, invocation) {
649
1369
  cause: new Error(`@prisma/cli-engine: the '${section.name}' config section validator threw instead of returning diagnostics (a validator never throws)`, { cause })
650
1370
  };
651
1371
  }
652
- if (!validation.ok) return needsErrored(new CliStructuredError("CLI.CONFIG_INVALID", `The '${section.name}' section of prisma.config.ts is invalid.`, { nextActions: [{
1372
+ if (!validation.ok) return needsErrored(new CliStructuredError("CLI.CONFIG_SECTION_INVALID", `The '${section.name}' section of ${configFile} is invalid.`, { nextActions: [{
653
1373
  kind: "user-choice",
654
1374
  label: "Fix the reported problems in that section, then run the command again."
655
1375
  }] }), validation.diagnostics);
656
1376
  writeSectionWarnings(invocation, validation.diagnostics);
657
1377
  return {
658
1378
  kind: "ok",
659
- config: validation.value
1379
+ config: validation.value,
1380
+ spawnCredential: void 0
660
1381
  };
661
1382
  }
662
1383
  /** Diagnostics on an OK validation are warnings: written to stderr as
@@ -971,7 +1692,13 @@ function makePromptSurface(invocation) {
971
1692
  if (typeof typed !== "string" || typed.trim() !== token) throw consentTokenMismatch(question, token, String(typed));
972
1693
  return true;
973
1694
  };
974
- return {
1695
+ /** A prompt writes to stderr and reads the engine's stdin — the same
1696
+ * terminal a live child inherited. Like ctx.present, prompting while
1697
+ * a child owns the terminal is a construction error. */
1698
+ const requireOwnTerminal = () => {
1699
+ if (state.delegatedTerminal !== void 0) throw constructionError(`command '${state.commandId}' called ctx.prompt while a child owned the terminal`);
1700
+ };
1701
+ const surface = {
975
1702
  confirm: async (question, opts) => {
976
1703
  const fallback = opts?.default;
977
1704
  if (state.yes || !state.interactive) {
@@ -1046,212 +1773,267 @@ function makePromptSurface(invocation) {
1046
1773
  }
1047
1774
  }
1048
1775
  };
1049
- }
1050
- //#endregion
1051
- //#region src/execution/command-context.ts
1052
- function makeUi(colorEnabled) {
1053
- if (!colorEnabled) return {
1054
- emphasize: (text) => text,
1055
- dim: (text) => text,
1056
- code: (text) => `\`${text}\``
1776
+ /** The claim is taken synchronously, before the prompt's first await:
1777
+ * a handler that starts a prompt without awaiting it has already
1778
+ * begun reading stdin, so ctx.spawn must not hand the same terminal
1779
+ * to a child. */
1780
+ const claimTerminal = async (prompt) => {
1781
+ requireOwnTerminal();
1782
+ state.activePrompts += 1;
1783
+ try {
1784
+ return await prompt();
1785
+ } finally {
1786
+ state.activePrompts -= 1;
1787
+ }
1057
1788
  };
1058
1789
  return {
1059
- emphasize: (text) => `\u001b[1m${text}\u001b[22m`,
1060
- dim: (text) => `\u001b[2m${text}\u001b[22m`,
1061
- code: (text) => `\`${text}\``
1790
+ confirm: (question, opts) => claimTerminal(() => surface.confirm(question, opts)),
1791
+ consent: (question, opts) => claimTerminal(() => surface.consent(question, opts)),
1792
+ select: (question, options, opts) => claimTerminal(() => surface.select(question, options, opts)),
1793
+ text: (question, opts) => claimTerminal(() => surface.text(question, opts)),
1794
+ browserWait: (request) => claimTerminal(() => surface.browserWait(request))
1062
1795
  };
1063
1796
  }
1064
- /** Materializes ONLY the active format's presentation functions, at the
1065
- * return site: human → human + stdout + next; json → json + next. */
1066
- function materializePresentation(state, ui, presentations) {
1067
- if (state.format === "json") return {
1068
- human: [],
1069
- stdout: [],
1070
- json: presentations.json?.(),
1071
- next: presentations.next?.() ?? []
1072
- };
1073
- return {
1074
- human: presentations.human(ui),
1075
- stdout: presentations.stdout?.() ?? [],
1076
- json: void 0,
1077
- next: presentations.next?.() ?? []
1797
+ //#endregion
1798
+ //#region src/execution/spawn.ts
1799
+ /**
1800
+ * D1 ruling (S3): how long a child terminated by a programmatic abort
1801
+ * has to exit on its own after SIGTERM before the engine sends SIGKILL.
1802
+ */
1803
+ const CHILD_TERMINATION_GRACE_MS = 5e3;
1804
+ /** A signal delivered while a child owns the terminal: recorded for
1805
+ * replay, never acted on. SIGTERM has no native path to the child —
1806
+ * supervisors signal the engine's pid — so it is forwarded (a SIGTERM
1807
+ * recorded before the adapter has returned the child is forwarded the
1808
+ * moment it attaches). A SECOND recorded signal forwards SIGTERM too:
1809
+ * when the engine was signalled directly (no process group delivered
1810
+ * the first press to the child), the second press is the user's
1811
+ * escalation, and without the forward the child would be unreachable. */
1812
+ function recordSignalDuringSpawn(terminal, signal) {
1813
+ terminal.recorded.push(signal);
1814
+ if (signal === "SIGTERM" || terminal.recorded.length > 1) terminal.child?.kill("SIGTERM");
1815
+ }
1816
+ function makeSpawn(invocation, def) {
1817
+ return async (options) => {
1818
+ const state = invocation.state;
1819
+ if (!def.maySpawn) throw constructionError(`command '${state.commandId}' called ctx.spawn without declaring maySpawn`);
1820
+ if (state.delegatedTerminal !== void 0) throw constructionError(`command '${state.commandId}' called ctx.spawn while a child was still live (one live child per run)`);
1821
+ if (state.activePrompts > 0) throw constructionError(`command '${state.commandId}' called ctx.spawn while a prompt owned the terminal`);
1822
+ const spawnChild = invocation.runtime.spawn;
1823
+ if (spawnChild === void 0) throw new Error("@prisma/cli-engine: the command declares maySpawn but the Runtime supplies no spawn adapter");
1824
+ const terminal = {
1825
+ recorded: [],
1826
+ buffered: [],
1827
+ dropped: 0,
1828
+ child: void 0,
1829
+ termination: new AbortController(),
1830
+ ended: Promise.resolve()
1831
+ };
1832
+ state.delegatedTerminal = terminal;
1833
+ const running = runDelegated(invocation, def, terminal, spawnChild, options);
1834
+ terminal.ended = running.then(() => void 0, () => void 0);
1835
+ return await running;
1078
1836
  };
1079
1837
  }
1080
- function makeContext(invocation, config, managesCredentials) {
1838
+ async function runDelegated(invocation, def, terminal, spawnChild, options) {
1081
1839
  const state = invocation.state;
1082
- const ui = makeUi(state.colorEnabled);
1083
- const present = (outcome, presentations) => {
1084
- const exitCode = outcome.exitCode ?? 0;
1085
- const diagnostics = outcome.diagnostics ?? [];
1086
- if (exitCode === 0 && diagnostics.some((diagnostic) => diagnostic.severity === "error")) throw new Error("@prisma/cli-engine: a severity-'error' diagnostic requires a non-zero exitCode; a genuine could-not-complete belongs in notOk");
1087
- return Object.freeze({
1088
- [PRESENTED]: true,
1089
- data: outcome.data,
1090
- exitCode,
1091
- diagnostics,
1092
- presentation: materializePresentation(state, ui, presentations)
1093
- });
1094
- };
1095
- let api;
1096
- const context = {
1097
- config,
1098
- present,
1099
- activeCredential: () => invocation.runtime.credentialManager?.activeCredential() ?? Promise.resolve(null),
1100
- get api() {
1101
- api ??= invocation.hooks.managementApi?.client ?? buildManagementApiClient(invocation);
1102
- return api;
1103
- },
1104
- report: (event) => reportEvent(invocation, event),
1105
- prompt: makePromptSurface(invocation),
1106
- openUrl: (request) => announceUrl(invocation, request),
1107
- signal: invocation.signal,
1108
- cwd: invocation.runtime.cwd,
1109
- env: invocation.runtime.env,
1110
- requireDependency: async (specifier) => dependencyResolvable(specifier, invocation.runtime.cwd) ? okVoid() : notOk(missingDependencyError(specifier, invocation.runtime.packageManager))
1111
- };
1112
- if (managesCredentials) Object.defineProperty(context, "credentialManager", {
1113
- enumerable: true,
1114
- get() {
1115
- const manager = invocation.runtime.credentialManager;
1116
- if (manager === void 0) throw new Error("@prisma/cli-engine: the command declares managesCredentials but the Runtime supplies no credentialManager");
1117
- return manager;
1840
+ const debug = makeDebugLog(invocation.runtime);
1841
+ try {
1842
+ const request = {
1843
+ command: options.command,
1844
+ args: options.args ?? [],
1845
+ cwd: options.cwd ?? invocation.runtime.cwd,
1846
+ env: await composeChildEnv(invocation, def, options.env)
1847
+ };
1848
+ debug(`spawn: ${request.command} ${request.args.join(" ")} (cwd ${request.cwd})`);
1849
+ const result = await runChild(invocation, terminal, spawnChild, request);
1850
+ debug(`spawn ended: exitCode=${String(result.exitCode)} signal=${String(result.signal)} recorded=[${terminal.recorded.join(",")}]`);
1851
+ return result;
1852
+ } finally {
1853
+ state.delegatedTerminal = void 0;
1854
+ if (!state.resolved) {
1855
+ flushBufferedEvents(invocation, terminal);
1856
+ replayRecordedSignals(invocation, terminal.recorded);
1118
1857
  }
1119
- });
1120
- return context;
1858
+ }
1121
1859
  }
1122
- //#endregion
1123
- //#region src/execution/shared-flags.ts
1124
- /** The engine-injected shared flag family. Commands cannot declare
1125
- * these names or aliases; handlers never see their values. */
1126
- const RESERVED_FLAG_NAMES = new Set([
1127
- "format",
1128
- "json",
1129
- "logLevel",
1130
- "verbose",
1131
- "quiet",
1132
- "yes",
1133
- "confirm",
1134
- "interactive",
1135
- "color",
1136
- "help",
1137
- "helpAll",
1138
- "version"
1139
- ]);
1140
- const RESERVED_ALIASES = new Set([
1141
- "v",
1142
- "q",
1143
- "y",
1144
- "h"
1145
- ]);
1146
- const SHARED_FLAG_PARAMETERS = {
1147
- format: {
1148
- kind: "enum",
1149
- values: ["human", "json"],
1150
- optional: true,
1151
- brief: "Output format"
1152
- },
1153
- json: {
1154
- kind: "boolean",
1155
- default: false,
1156
- brief: "Shorthand for --format json"
1157
- },
1158
- logLevel: {
1159
- kind: "enum",
1160
- values: [
1161
- "error",
1162
- "warn",
1163
- "info",
1164
- "verbose"
1165
- ],
1166
- optional: true,
1167
- brief: "Commentary verbosity"
1168
- },
1169
- verbose: {
1170
- kind: "boolean",
1171
- default: false,
1172
- brief: "Shorthand for --log-level verbose"
1173
- },
1174
- quiet: {
1175
- kind: "boolean",
1176
- default: false,
1177
- brief: "Shorthand for --log-level error"
1178
- },
1179
- yes: {
1180
- kind: "boolean",
1181
- default: false,
1182
- brief: "Accept prompt defaults without asking"
1183
- },
1184
- confirm: {
1185
- kind: "parsed",
1186
- parse: (input) => input,
1187
- placeholder: "value",
1188
- variadic: true,
1189
- optional: true,
1190
- brief: "Grant a consent prompt non-interactively by typing its token (repeatable)"
1191
- },
1192
- interactive: {
1193
- kind: "boolean",
1194
- optional: true,
1195
- withNegated: true,
1196
- brief: "Force interactive prompts on or off"
1197
- },
1198
- color: {
1199
- kind: "boolean",
1200
- optional: true,
1201
- withNegated: true,
1202
- brief: "Force ANSI color on or off"
1860
+ /** A handler that resolved or threw with its child still live: the
1861
+ * engine ends the child on the abort ladder and waits for it, because
1862
+ * the engine outliving the child is not negotiable. */
1863
+ async function endAbandonedChild(terminal) {
1864
+ terminal.termination.abort();
1865
+ await terminal.ended;
1866
+ }
1867
+ async function runChild(invocation, terminal, spawnChild, request) {
1868
+ let child;
1869
+ try {
1870
+ child = spawnChild(request);
1871
+ } catch (cause) {
1872
+ throw spawnFailedError(request.command, cause);
1873
+ }
1874
+ terminal.child = child;
1875
+ if (terminal.recorded.includes("SIGTERM") || terminal.recorded.length > 1) child.kill("SIGTERM");
1876
+ const ended = new AbortController();
1877
+ armTerminationLadder(invocation, terminal, child, ended.signal);
1878
+ try {
1879
+ return engineSpawnedResult(await child.ended);
1880
+ } catch (cause) {
1881
+ throw spawnFailedError(request.command, cause);
1882
+ } finally {
1883
+ ended.abort();
1203
1884
  }
1204
- };
1205
- const SHARED_ALIASES = {
1206
- v: "verbose",
1207
- q: "quiet",
1208
- y: "yes"
1209
- };
1210
- /** The pre-parse format decision: json framing must be in effect before
1211
- * stricli parses (its own failure output is framed too), so the format
1212
- * flags are scanned from raw argv. */
1213
- function sniffFormat(argv, runtime) {
1214
- return explicitFormat(argv) ?? (runtime.isTty.stdout ? "human" : "json");
1215
1885
  }
1216
- /** The format requested by --json / --format / --format=<value>, if
1217
- * any. Arguments after a bare `--` are positionals, never flags. */
1218
- function explicitFormat(argv) {
1219
- for (const [index, argument] of argv.entries()) {
1220
- if (argument === "--") return;
1221
- if (argument === "--json" || argument === "--format=json") return "json";
1222
- if (argument === "--format=human") return "human";
1223
- if (argument === "--format") {
1224
- const value = argv[index + 1];
1225
- if (value === "json" || value === "human") return value;
1886
+ /** A programmatic abort of ctx.signal (a delivered signal is recorded
1887
+ * instead), or the engine ending a child the handler abandoned,
1888
+ * terminates the child: SIGTERM, the grace period, SIGKILL. */
1889
+ function armTerminationLadder(invocation, terminal, child, ended) {
1890
+ const debug = makeDebugLog(invocation.runtime);
1891
+ const terminate = async () => {
1892
+ if (ended.aborted) return;
1893
+ debug(`spawn abort ladder: SIGTERM, ${CHILD_TERMINATION_GRACE_MS}ms grace`);
1894
+ child.kill("SIGTERM");
1895
+ await invocation.delay(CHILD_TERMINATION_GRACE_MS, ended);
1896
+ if (!ended.aborted) {
1897
+ debug("spawn abort ladder: grace elapsed, SIGKILL");
1898
+ child.kill("SIGKILL");
1226
1899
  }
1900
+ };
1901
+ const trigger = AbortSignal.any([invocation.signal, terminal.termination.signal]);
1902
+ if (trigger.aborted) {
1903
+ terminate();
1904
+ return;
1905
+ }
1906
+ trigger.addEventListener("abort", () => void terminate(), {
1907
+ once: true,
1908
+ signal: ended
1909
+ });
1910
+ }
1911
+ /** The recorded signals enter the engine's normal ladder: the first
1912
+ * aborts ctx.signal as if just delivered, so the handler resumes from
1913
+ * ctx.spawn already aborted. A signal past that point arms the force
1914
+ * exit, which fires once the run has settled — the turn the handler's
1915
+ * cleanup was owed, with telemetry delivered. When ctx.signal already
1916
+ * aborted BEFORE the spawn, the first recorded signal is effectively
1917
+ * the second overall and arms the force exit the same way: no path
1918
+ * force-exits from inside ctx.spawn. */
1919
+ function replayRecordedSignals(invocation, recorded) {
1920
+ if (recorded.length === 0) return;
1921
+ const state = invocation.state;
1922
+ if (invocation.signal.aborted) {
1923
+ state.pendingForceExit ??= recorded[0];
1924
+ return;
1227
1925
  }
1926
+ invocation.deliverSignal(recorded[0]);
1927
+ if (recorded.length > 1) state.pendingForceExit = recorded[1];
1228
1928
  }
1229
- function applySharedFlags(state, shared, runtime) {
1230
- state.format = shared.format ?? resolveAutoFormat(shared, runtime);
1231
- state.yes = shared.yes === true;
1232
- state.confirmValues = [...shared.confirm ?? []];
1233
- state.interactive = shared.interactive ?? defaultInteractive(runtime);
1234
- state.logLevel = resolveLogLevel(shared);
1235
- state.colorEnabled = shared.color ?? (runtime.isTty.stdout && runtime.env.NO_COLOR === void 0);
1929
+ async function composeChildEnv(invocation, def, additions) {
1930
+ const env = {
1931
+ ...invocation.runtime.env,
1932
+ ...additions
1933
+ };
1934
+ if (def.needs.credentials !== "child") return env;
1935
+ const credential = invocation.state.spawnCredential;
1936
+ if (credential === void 0) throw credentialsRequiredError();
1937
+ env[SERVICE_TOKEN_ENV_VAR] = await spawnToken(invocation);
1938
+ if (credential.workspaceId !== void 0) env[WORKSPACE_ID_ENV_VAR] = credential.workspaceId;
1939
+ else delete env[WORKSPACE_ID_ENV_VAR];
1940
+ return env;
1236
1941
  }
1237
- /** Interactive iff TTY stdin outside CI; --interactive and
1238
- * --no-interactive override in either direction. Format never decides
1239
- * interactivity (operator ruling, 2026-08-09): an interactive json run
1240
- * may prompt — the prompt UI writes to stderr, so stdout stays a clean
1241
- * frame stream. */
1242
- function defaultInteractive(runtime) {
1243
- return runtime.isTty.stdin && runtime.env.CI === void 0;
1942
+ /**
1943
+ * The child's copy of the credential: the manager's activeAccessToken()
1944
+ * operation, read at spawn time. The refresh token is never injected:
1945
+ * the child runs on a snapshot it cannot refresh.
1946
+ */
1947
+ async function spawnToken(invocation) {
1948
+ const manager = invocation.runtime.credentialManager;
1949
+ if (manager === void 0) throw credentialsRequiredError();
1950
+ const accessToken = await manager.activeAccessToken();
1951
+ if (accessToken === null) throw credentialsRequiredError("session-ended");
1952
+ return accessToken;
1244
1953
  }
1245
- function resolveAutoFormat(shared, runtime) {
1246
- if (shared.json === true) return "json";
1247
- return runtime.isTty.stdout ? "human" : "json";
1954
+ function spawnFailedError(command, cause) {
1955
+ return new CliStructuredError("CLI.SPAWN_FAILED", `The program '${command}' could not be started.`, {
1956
+ why: firstLine(cause instanceof Error ? cause.message : String(cause)),
1957
+ nextActions: [{
1958
+ kind: "user-choice",
1959
+ label: `Make sure '${command}' is installed and on your PATH, then run the command again.`
1960
+ }],
1961
+ meta: { command }
1962
+ });
1248
1963
  }
1249
- /** --quiet and --verbose are log-level shorthands; either one beats an
1250
- * explicit --log-level given alongside it. */
1251
- function resolveLogLevel(shared) {
1252
- if (shared.quiet === true) return "error";
1253
- if (shared.verbose === true) return "verbose";
1254
- return shared.logLevel ?? "info";
1964
+ //#endregion
1965
+ //#region src/execution/command-context.ts
1966
+ function makeUi(colorEnabled) {
1967
+ if (!colorEnabled) return {
1968
+ emphasize: (text) => text,
1969
+ dim: (text) => text,
1970
+ code: (text) => `\`${text}\``
1971
+ };
1972
+ return {
1973
+ emphasize: (text) => `\u001b[1m${text}\u001b[22m`,
1974
+ dim: (text) => `\u001b[2m${text}\u001b[22m`,
1975
+ code: (text) => `\`${text}\``
1976
+ };
1977
+ }
1978
+ /** Materializes ONLY the active format's presentation functions, at the
1979
+ * return site: human → human + stdout + next; json → json + next. */
1980
+ function materializePresentation(state, ui, presentations) {
1981
+ if (state.format === "json") return {
1982
+ human: [],
1983
+ stdout: [],
1984
+ json: presentations.json?.(),
1985
+ next: presentations.next?.() ?? []
1986
+ };
1987
+ return {
1988
+ human: presentations.human(ui),
1989
+ stdout: presentations.stdout?.() ?? [],
1990
+ json: void 0,
1991
+ next: presentations.next?.() ?? []
1992
+ };
1993
+ }
1994
+ function makeContext(invocation, def, config, managesCredentials) {
1995
+ const state = invocation.state;
1996
+ const ui = makeUi(state.colorEnabled);
1997
+ const present = (outcome, presentations) => {
1998
+ if (state.delegatedTerminal !== void 0) throw constructionError(`command '${state.commandId}' called ctx.present while a child owned the terminal`);
1999
+ const exitCode = outcome.exitCode ?? 0;
2000
+ const diagnostics = outcome.diagnostics ?? [];
2001
+ if (exitCode === 0 && diagnostics.some((diagnostic) => diagnostic.severity === "error")) throw new Error("@prisma/cli-engine: a severity-'error' diagnostic requires a non-zero exitCode; a genuine could-not-complete belongs in notOk");
2002
+ return Object.freeze({
2003
+ [PRESENTED]: true,
2004
+ data: outcome.data,
2005
+ exitCode,
2006
+ diagnostics,
2007
+ presentation: materializePresentation(state, ui, presentations)
2008
+ });
2009
+ };
2010
+ let api;
2011
+ const context = {
2012
+ config,
2013
+ present,
2014
+ activeCredential: () => invocation.runtime.credentialManager?.activeCredential() ?? Promise.resolve(null),
2015
+ get api() {
2016
+ api ??= invocation.hooks.managementApi?.client ?? buildManagementApiClient(invocation);
2017
+ return api;
2018
+ },
2019
+ spawn: makeSpawn(invocation, def),
2020
+ report: (event) => reportEvent(invocation, event),
2021
+ prompt: makePromptSurface(invocation),
2022
+ openUrl: (request) => announceUrl(invocation, request),
2023
+ signal: invocation.signal,
2024
+ cwd: invocation.runtime.cwd,
2025
+ env: invocation.runtime.env,
2026
+ requireDependency: async (specifier) => dependencyResolvable(specifier, invocation.runtime.cwd) ? okVoid() : notOk(missingDependencyError(specifier, invocation.runtime.packageManager))
2027
+ };
2028
+ if (managesCredentials) Object.defineProperty(context, "credentialManager", {
2029
+ enumerable: true,
2030
+ get() {
2031
+ const manager = invocation.runtime.credentialManager;
2032
+ if (manager === void 0) throw new Error("@prisma/cli-engine: the command declares managesCredentials but the Runtime supplies no credentialManager");
2033
+ return manager;
2034
+ }
2035
+ });
2036
+ return context;
1255
2037
  }
1256
2038
  //#endregion
1257
2039
  //#region src/execution/command-snapshot.ts
@@ -1332,109 +2114,6 @@ function buildCommandSnapshot(entryId, def, argv, positionalValues) {
1332
2114
  };
1333
2115
  }
1334
2116
  //#endregion
1335
- //#region src/execution/command-tree.ts
1336
- function constructionError(message) {
1337
- return /* @__PURE__ */ new Error(`@prisma/cli-engine: ${message}`);
1338
- }
1339
- const CAMEL_CASE = /^[a-z][a-zA-Z0-9]*$/;
1340
- const INTEGER_LIKE = /^\d+$/;
1341
- function validateFlags(path, def) {
1342
- const flags = def.args.flags;
1343
- const seenAliases = /* @__PURE__ */ new Set();
1344
- for (const [key, spec] of Object.entries(flags)) {
1345
- if (RESERVED_FLAG_NAMES.has(key)) throw constructionError(`command '${path}' declares reserved flag '${key}' (the shared flag family is engine-injected)`);
1346
- if (!CAMEL_CASE.test(key)) throw constructionError(`command '${path}' flag '${key}' must be camelCase (it transliterates to --kebab-case on the CLI)`);
1347
- const alias = flagRuntime(spec).alias;
1348
- if (alias === void 0) continue;
1349
- if (RESERVED_ALIASES.has(alias)) throw constructionError(`command '${path}' flag '${key}' uses reserved alias '-${alias}'`);
1350
- if (seenAliases.has(alias)) throw constructionError(`command '${path}' declares alias '-${alias}' twice`);
1351
- seenAliases.add(alias);
1352
- }
1353
- }
1354
- function validatePositionals(path, def) {
1355
- const entries = Object.entries(def.args.positionals);
1356
- let sawOptional = false;
1357
- for (const [index, [key, spec]] of entries.entries()) {
1358
- const runtime = positionalRuntime(spec);
1359
- if (INTEGER_LIKE.test(key)) throw constructionError(`command '${path}' positional key '${key}' must not be integer-like`);
1360
- if (runtime.type === "variadic" && index !== entries.length - 1) throw constructionError(`command '${path}' variadic positional '${key}' must be declared last`);
1361
- if (runtime.type === "optionalString") sawOptional = true;
1362
- if (runtime.type === "string" && sawOptional) throw constructionError(`command '${path}' required positional '${key}' may not follow an optional one`);
1363
- }
1364
- }
1365
- function validateExitCodes(path, def) {
1366
- if (def.kind !== "result-command") return;
1367
- for (const key of Object.keys(def.exitCodes)) {
1368
- const code = Number(key);
1369
- if (!Number.isInteger(code) || code < 4 || code > 99) throw constructionError(`command '${path}' documents exit code ${key}; documented codes must be integers in 4-99`);
1370
- }
1371
- }
1372
- function emptyNode() {
1373
- return {
1374
- commands: /* @__PURE__ */ new Map(),
1375
- children: /* @__PURE__ */ new Map()
1376
- };
1377
- }
1378
- function insertCommand(root, path, def, docsBaseUrl) {
1379
- const segments = path.split(" ");
1380
- if (segments.some((segment) => segment.length === 0)) throw constructionError(`invalid command path '${path}'`);
1381
- let node = root;
1382
- for (const segment of segments.slice(0, -1)) {
1383
- if (node.commands.has(segment)) throw constructionError(`command path '${path}' collides with a command mounted at a prefix of it`);
1384
- let child = node.children.get(segment);
1385
- if (child === void 0) {
1386
- child = emptyNode();
1387
- node.children.set(segment, child);
1388
- }
1389
- node = child;
1390
- }
1391
- const leaf = segments[segments.length - 1];
1392
- if (node.commands.has(leaf) || node.children.has(leaf)) throw constructionError(`command path '${path}' collides with another mounted command`);
1393
- node.commands.set(leaf, {
1394
- def,
1395
- id: segments.join("."),
1396
- docsBaseUrl
1397
- });
1398
- }
1399
- /** A command belongs to the family whose commands record contains it
1400
- * (identity). Harness-mounted commands with no family are unowned. */
1401
- function commandFamilyOf(spec, def) {
1402
- return spec.commandFamilies.find((commandFamily) => Object.values(commandFamily.commands).includes(def));
1403
- }
1404
- function validateSectionOwnership(spec, path, def) {
1405
- const section = def.needs.config;
1406
- if (section === void 0) return;
1407
- const commandFamily = commandFamilyOf(spec, def);
1408
- if (commandFamily === void 0) return;
1409
- if (commandFamily.configSection !== section) throw constructionError(`command '${path}' needs the '${section.name}' config section, which is not its command family's section`);
1410
- }
1411
- function validateDocsBaseUrls(spec) {
1412
- for (const commandFamily of spec.commandFamilies) {
1413
- const base = commandFamily.docsBaseUrl;
1414
- if (base !== void 0 && !URL.canParse(base)) throw constructionError(`command family docsBaseUrl '${base}' is not a valid URL`);
1415
- }
1416
- }
1417
- function buildCommandTree(spec) {
1418
- const paths = Object.keys(spec.commands);
1419
- if (paths.length === 0) throw constructionError("createCli requires at least one mounted command");
1420
- validateDocsBaseUrls(spec);
1421
- const root = emptyNode();
1422
- for (const path of paths) {
1423
- const def = spec.commands[path];
1424
- validateFlags(path, def);
1425
- validatePositionals(path, def);
1426
- validateExitCodes(path, def);
1427
- validateSectionOwnership(spec, path, def);
1428
- const segments = path.split(" ");
1429
- for (let depth = 1; depth < segments.length; depth += 1) {
1430
- const groupPath = segments.slice(0, depth).join(" ");
1431
- if (spec.groups[groupPath] === void 0) throw constructionError(`command path '${path}' references unknown group '${groupPath}' (declare it in createCli's groups)`);
1432
- }
1433
- insertCommand(root, path, def, commandFamilyOf(spec, def)?.docsBaseUrl);
1434
- }
1435
- return root;
1436
- }
1437
- //#endregion
1438
2117
  //#region src/execution/stricli-adapter.ts
1439
2118
  /**
1440
2119
  * The stricli boundary — fully internal: no stricli type appears in the
@@ -1546,9 +2225,13 @@ function commandParameters(def) {
1546
2225
  function resolveExample(example, cliName) {
1547
2226
  return example.includes("{bin}") ? example.replaceAll("{bin}", cliName) : `${cliName} ${example}`;
1548
2227
  }
2228
+ /** The --json refusal is stated in help, so a machine consumer learns
2229
+ * it without running the command. */
2230
+ const NO_JSON_NOTE = "This command hands the terminal to another program and does not support --json.";
1549
2231
  function commandDocs(def, cliName) {
1550
2232
  const examples = def.help.examples.map((example) => resolveExample(example, cliName));
1551
- if (examples.length === 0) return {
2233
+ const notes = def.maySpawn ? ["", NO_JSON_NOTE] : [];
2234
+ if (examples.length === 0 && notes.length === 0) return {
1552
2235
  brief: def.help.summary,
1553
2236
  fullDescription: def.help.description
1554
2237
  };
@@ -1556,9 +2239,12 @@ function commandDocs(def, cliName) {
1556
2239
  brief: def.help.summary,
1557
2240
  fullDescription: [
1558
2241
  def.help.description ?? def.help.summary,
1559
- "",
1560
- "Examples:",
1561
- ...examples.map((example) => ` ${example}`)
2242
+ ...notes,
2243
+ ...examples.length === 0 ? [] : [
2244
+ "",
2245
+ "Examples:",
2246
+ ...examples.map((example) => ` ${example}`)
2247
+ ]
1562
2248
  ].join("\n")
1563
2249
  };
1564
2250
  }
@@ -1631,7 +2317,8 @@ function settleCompleted(invocation, def, presented) {
1631
2317
  }
1632
2318
  const state = invocation.state;
1633
2319
  invocation.hooks.onPresented?.(presented);
1634
- state.settledExitCode = presented.exitCode;
2320
+ const exitCode = runExitCode(invocation, presented.exitCode);
2321
+ state.settledExitCode = exitCode;
1635
2322
  if (state.format === "json") {
1636
2323
  emitFrame(invocation, {
1637
2324
  kind: "result",
@@ -1639,7 +2326,7 @@ function settleCompleted(invocation, def, presented) {
1639
2326
  ok: true,
1640
2327
  commandId: state.commandId,
1641
2328
  result: presented.presentation.json === void 0 ? presented.data : presented.presentation.json,
1642
- exitCode: presented.exitCode,
2329
+ exitCode,
1643
2330
  diagnostics: presented.diagnostics.map((diagnostic) => withDocsUrl(state, diagnostic)),
1644
2331
  nextActions: presented.presentation.next
1645
2332
  },
@@ -1665,10 +2352,26 @@ function settleErrored(invocation, error, diagnostics = []) {
1665
2352
  nextActions: error.nextActions
1666
2353
  });
1667
2354
  }
1668
- /** Signal exit codes: 130 SIGINT, 143 SIGTERM. The engine's own
1669
- * controller only ever aborts with a signal name. */
1670
- function signalExitCode(reason) {
1671
- return reason === "SIGTERM" ? 143 : 130;
2355
+ /** The conventional code for a delivered signal: 128 + its number, so
2356
+ * 130 for SIGINT and 143 for SIGTERM. */
2357
+ function signalExitCode(signal) {
2358
+ return signal === "SIGTERM" ? 143 : 130;
2359
+ }
2360
+ /**
2361
+ * The engine's own signal record decides how a run ends. A run a
2362
+ * delivered signal terminated settles 128 + that signal's number even
2363
+ * when its handler caught the signal, cleaned up, and returned
2364
+ * successfully: the exit code states how the RUN ended, and a handler
2365
+ * cannot author it — the documented codes stop at 99.
2366
+ *
2367
+ * Verbatim codes are the exception, because they were never this CLI's
2368
+ * to state: a real child's status (the child owned the terminal and the
2369
+ * signal reached it too) and a server command's protocol conclusion
2370
+ * both pass through untouched.
2371
+ */
2372
+ function runExitCode(invocation, completed) {
2373
+ const signal = invocation.state.deliveredSignal;
2374
+ return signal === void 0 ? completed : signalExitCode(signal);
1672
2375
  }
1673
2376
  function isAbortCause(cause, signal) {
1674
2377
  if (!signal.aborted) return false;
@@ -1682,7 +2385,8 @@ function settleThrown(invocation, cause) {
1682
2385
  }
1683
2386
  function settleAborted(invocation) {
1684
2387
  const state = invocation.state;
1685
- state.settledExitCode = signalExitCode(invocation.signal.reason);
2388
+ const signal = state.deliveredSignal;
2389
+ state.settledExitCode = signal === void 0 ? 3 : signalExitCode(signal);
1686
2390
  emitErrored(invocation, {
1687
2391
  ok: false,
1688
2392
  commandId: state.commandId,
@@ -1696,12 +2400,46 @@ function settleAborted(invocation) {
1696
2400
  nextActions: []
1697
2401
  });
1698
2402
  }
1699
- /** A session command that returned ok — including after the signal
1700
- * fired — shut down cleanly: exit 0, no presentation. In json mode the
1701
- * stream still terminates with exactly one result frame. */
2403
+ /**
2404
+ * Settle an exit code the engine did not author, verbatim, with no
2405
+ * envelope and no presentation: something other than this CLI's code
2406
+ * space produced it. The two callers are the child-status settlement
2407
+ * and the server-command handoff. A delivered signal does not overrule
2408
+ * it — a code from outside is reported as it was received.
2409
+ */
2410
+ function settleVerbatimExitCode(invocation, exitCode) {
2411
+ invocation.state.settledExitCode = exitCode;
2412
+ }
2413
+ /**
2414
+ * The child owned the terminal, so its status becomes the run's
2415
+ * verbatim: the one path on which a result command settles a code it
2416
+ * never documented, because the code is not the handler's own
2417
+ * conclusion, it is the child's.
2418
+ *
2419
+ * Two conditions fence it, both construction errors. The command must
2420
+ * hand the terminal to another program — reachable from a
2421
+ * non-declaring handler this would also end a json stream without its
2422
+ * terminal result frame. And the status must be one the engine watched
2423
+ * a real child produce: a handler that invents a child result is
2424
+ * choosing an exit code through a door meant for reporting one, and a
2425
+ * handler interrupted mid-run has no need to, because the engine
2426
+ * settles a signal-terminated run itself.
2427
+ */
2428
+ function settleChildStatus(invocation, def, settlement) {
2429
+ if (!def.maySpawn) throw new Error(`@prisma/cli-engine: command '${invocation.state.commandId}' returned exitWithChildStatus without declaring maySpawn — only a command that hands the terminal to another program may settle with that program's status`);
2430
+ if (!isEngineSpawned(settlement)) throw new Error(`@prisma/cli-engine: command '${invocation.state.commandId}' returned exitWithChildStatus for a child result the engine did not produce — only the result of a ctx.spawn carries a child's status`);
2431
+ for (const action of settlement.nextActions) invocation.runtime.stderr.write(`${renderNextAction(action)}\n`);
2432
+ settleVerbatimExitCode(invocation, settlement.exitCode);
2433
+ }
2434
+ /** A session command that returned ok shut down cleanly: no
2435
+ * presentation, and exit 0 — unless a signal ended the run, which
2436
+ * settles 130/143 from the engine's record even though the shutdown
2437
+ * itself succeeded. In json mode the stream still terminates with
2438
+ * exactly one result frame. */
1702
2439
  function settleSessionCompleted(invocation) {
1703
2440
  const state = invocation.state;
1704
- state.settledExitCode = 0;
2441
+ const exitCode = runExitCode(invocation, 0);
2442
+ state.settledExitCode = exitCode;
1705
2443
  if (state.format !== "json") return;
1706
2444
  emitFrame(invocation, {
1707
2445
  kind: "result",
@@ -1709,7 +2447,7 @@ function settleSessionCompleted(invocation) {
1709
2447
  ok: true,
1710
2448
  commandId: state.commandId,
1711
2449
  result: null,
1712
- exitCode: 0,
2450
+ exitCode,
1713
2451
  diagnostics: [],
1714
2452
  nextActions: []
1715
2453
  },
@@ -1830,10 +2568,12 @@ var EngineImpl = class {
1830
2568
  root;
1831
2569
  now;
1832
2570
  delay;
2571
+ configSections;
1833
2572
  constructor(spec, now = () => /* @__PURE__ */ new Date(), delay = waitFor) {
1834
2573
  this.spec = spec;
1835
2574
  this.now = now;
1836
2575
  this.delay = delay;
2576
+ this.configSections = declaredConfigSections(spec);
1837
2577
  this.root = buildRoutes(spec, buildCommandTree(spec), "", (invocation, entry, flags, values) => this.executeMounted(invocation, entry, flags, values));
1838
2578
  }
1839
2579
  async execute(argv, runtime, hooks) {
@@ -1847,6 +2587,7 @@ var EngineImpl = class {
1847
2587
  confirmValues: [],
1848
2588
  interactive: defaultInteractive(runtime),
1849
2589
  colorEnabled: false,
2590
+ configPath: void 0,
1850
2591
  resolved: false,
1851
2592
  settledExitCode: void 0,
1852
2593
  usageErrorText: void 0,
@@ -1854,31 +2595,50 @@ var EngineImpl = class {
1854
2595
  stricliStderr: "",
1855
2596
  stdinIterator: void 0,
1856
2597
  argv,
1857
- snapshot: void 0
2598
+ snapshot: void 0,
2599
+ delegatedTerminal: void 0,
2600
+ activePrompts: 0,
2601
+ deliveredSignal: void 0,
2602
+ pendingForceExit: void 0,
2603
+ spawnCredential: void 0
1858
2604
  };
1859
2605
  const startedAtMs = this.now().getTime();
1860
2606
  const controller = new AbortController();
1861
- let signalDelivered = false;
1862
- const unsubscribe = runtime.onSignal((signal) => {
1863
- if (signalDelivered) {
2607
+ /** The engine neither aborts nor exits while a child owns the
2608
+ * terminal: it records, and the affordance replays on child exit,
2609
+ * so the engine always outlives the child. */
2610
+ const deliverSignal = (signal) => {
2611
+ if (state.delegatedTerminal !== void 0) {
2612
+ recordSignalDuringSpawn(state.delegatedTerminal, signal);
2613
+ return;
2614
+ }
2615
+ if (state.deliveredSignal !== void 0) {
1864
2616
  runtime.exit(signal === "SIGTERM" ? 143 : 130);
1865
2617
  return;
1866
2618
  }
1867
- signalDelivered = true;
2619
+ state.deliveredSignal = signal;
1868
2620
  controller.abort(signal);
1869
- });
2621
+ };
2622
+ const unsubscribe = runtime.onSignal(deliverSignal);
1870
2623
  const invocation = {
1871
2624
  runtime,
1872
2625
  hooks: { ...hooks },
1873
2626
  now: this.now,
1874
2627
  delay: this.delay,
1875
2628
  state,
1876
- signal: controller.signal
2629
+ signal: controller.signal,
2630
+ configSections: this.configSections,
2631
+ deliverSignal
1877
2632
  };
1878
- if (versionRequested(argv)) {
2633
+ if (versionFlagGiven(argv)) {
1879
2634
  unsubscribe();
1880
2635
  return settleVersion(this.spec, invocation);
1881
2636
  }
2637
+ if (configFlagGivenNoValue(argv)) {
2638
+ unsubscribe();
2639
+ settleErrored(invocation, configFlagGivenNoValueError());
2640
+ return 2;
2641
+ }
1882
2642
  const stricliProcess = {
1883
2643
  /** stricli writes only help text here. In json mode stdout carries
1884
2644
  * exactly the frame stream, so help prose goes to stderr instead. */
@@ -1917,6 +2677,7 @@ var EngineImpl = class {
1917
2677
  }
1918
2678
  const exitCode = state.settledExitCode !== void 0 ? state.settledExitCode : settleUnhandled(this.spec, invocation, stricliProcess.exitCode);
1919
2679
  this.fireOnSettled(invocation, exitCode, startedAtMs);
2680
+ if (state.pendingForceExit !== void 0) runtime.exit(state.pendingForceExit === "SIGTERM" ? 143 : 130);
1920
2681
  return exitCode;
1921
2682
  }
1922
2683
  /** The onSettled delivery: once per run, after the exit code is
@@ -1945,9 +2706,20 @@ var EngineImpl = class {
1945
2706
  await this.executeServer(invocation, entry, rawFlags);
1946
2707
  return;
1947
2708
  }
2709
+ if (entry.def.maySpawn && formatFlagGiven(state.argv) === "json") {
2710
+ state.format = "human";
2711
+ settleErrored(invocation, jsonUnsupportedError(entry.id));
2712
+ return;
2713
+ }
2714
+ if (entry.def.maySpawn && invocation.runtime.spawn === void 0) {
2715
+ state.format = "human";
2716
+ settleBug(invocation, /* @__PURE__ */ new Error(`@prisma/cli-engine: command '${entry.id}' declares maySpawn but the Runtime supplies no spawn adapter`));
2717
+ return;
2718
+ }
1948
2719
  let needsOutcome;
1949
2720
  try {
1950
2721
  applySharedFlags(state, rawFlags, invocation.runtime);
2722
+ if (entry.def.maySpawn) state.format = "human";
1951
2723
  needsOutcome = await checkNeeds(entry.def, invocation);
1952
2724
  } catch (cause) {
1953
2725
  settleBug(invocation, cause);
@@ -1961,19 +2733,23 @@ var EngineImpl = class {
1961
2733
  settleBug(invocation, needsOutcome.cause);
1962
2734
  return;
1963
2735
  }
2736
+ state.spawnCredential = needsOutcome.spawnCredential;
1964
2737
  const handler = entry.def.handler;
1965
2738
  const args = {
1966
2739
  flags: declaredFlags(entry.def, rawFlags),
1967
2740
  positionals: distributePositionals(entry.def, values)
1968
2741
  };
1969
- const ctx = makeContext(invocation, needsOutcome.config, entry.def.kind === "result-command" && entry.def.managesCredentials);
2742
+ const ctx = makeContext(invocation, entry.def, needsOutcome.config, entry.def.kind === "result-command" && entry.def.managesCredentials);
1970
2743
  if (entry.def.kind === "session-command") {
1971
2744
  try {
1972
2745
  const result = await handler(args, ctx);
2746
+ if (await this.settleAbandonedChild(invocation, false)) return;
1973
2747
  state.resolved = true;
1974
- if (result.ok) settleSessionCompleted(invocation);
1975
- else settleErrored(invocation, result.failure);
2748
+ if (!result.ok) settleErrored(invocation, result.failure);
2749
+ else if (isChildStatusSettlement(result.value)) settleChildStatus(invocation, entry.def, result.value);
2750
+ else settleSessionCompleted(invocation);
1976
2751
  } catch (cause) {
2752
+ if (await this.settleAbandonedChild(invocation, true, cause)) return;
1977
2753
  state.resolved = true;
1978
2754
  settleThrown(invocation, cause);
1979
2755
  }
@@ -1981,14 +2757,31 @@ var EngineImpl = class {
1981
2757
  }
1982
2758
  try {
1983
2759
  const result = await handler(args, ctx);
2760
+ if (await this.settleAbandonedChild(invocation, false)) return;
1984
2761
  state.resolved = true;
1985
- if (result.ok) settleCompleted(invocation, entry.def, result.value);
1986
- else settleErrored(invocation, result.failure);
2762
+ if (!result.ok) settleErrored(invocation, result.failure);
2763
+ else if (isChildStatusSettlement(result.value)) settleChildStatus(invocation, entry.def, result.value);
2764
+ else settleCompleted(invocation, entry.def, result.value);
1987
2765
  } catch (cause) {
2766
+ if (await this.settleAbandonedChild(invocation, true, cause)) return;
1988
2767
  state.resolved = true;
1989
2768
  settleThrown(invocation, cause);
1990
2769
  }
1991
2770
  }
2771
+ /** The handler resolved or threw with its child still live. The
2772
+ * engine ends that child — SIGTERM, the ruled grace period, then
2773
+ * SIGKILL — and waits for it to exit before settling the run as a
2774
+ * construction error, so no run finishes under a live child. */
2775
+ async settleAbandonedChild(invocation, threw, cause) {
2776
+ const state = invocation.state;
2777
+ const terminal = state.delegatedTerminal;
2778
+ if (terminal === void 0) return false;
2779
+ await endAbandonedChild(terminal);
2780
+ state.resolved = true;
2781
+ const how = threw ? ` (the handler threw: ${String(cause instanceof Error ? cause.message : cause).split("\n")[0]})` : "";
2782
+ settleBug(invocation, /* @__PURE__ */ new Error(`@prisma/cli-engine: command '${state.commandId}' resolved while a child was still live — a handler must stay suspended on the ctx.spawn promise until the child ends${how}`));
2783
+ return true;
2784
+ }
1992
2785
  /** The stdio handoff: a foreign client owns the conversation, so the
1993
2786
  * engine hands over the streams and stays out of stdout. The handler
1994
2787
  * returns the exit code directly; there is no envelope. */
@@ -2030,18 +2823,32 @@ var EngineImpl = class {
2030
2823
  settleBug(invocation, /* @__PURE__ */ new Error(`@prisma/cli-engine: the '${entry.id}' server command returned exit code ${String(exitCode)}, which is not an integer in 0-255`));
2031
2824
  return;
2032
2825
  }
2033
- state.settledExitCode = exitCode;
2826
+ settleVerbatimExitCode(invocation, exitCode);
2034
2827
  } catch (cause) {
2035
2828
  settleThrown(invocation, cause);
2036
2829
  }
2037
2830
  }
2038
2831
  };
2039
- function versionRequested(argv) {
2040
- for (const argument of argv) {
2041
- if (argument === "--") return false;
2042
- if (argument === "--version") return true;
2043
- }
2044
- return false;
2832
+ /** The closed set of config section names. Every mounted command
2833
+ * contributes the section it needs, whether it reaches the tree
2834
+ * through a command family or on its own — the shell mounts its own
2835
+ * commands with no family, and a section the CLI cannot name is a
2836
+ * section its own command could never read. Every other top-level key
2837
+ * in prisma.config.ts is reported by the config needs check. */
2838
+ function declaredConfigSections(spec) {
2839
+ return [...new Set([...spec.commandFamilies.map((commandFamily) => commandFamily.configSection?.name), ...Object.values(spec.commands).map((def) => def.needs.config?.name)].filter((name) => name !== void 0))];
2840
+ }
2841
+ /** A command that may hand the terminal to a child cannot frame its
2842
+ * output, so json is refused as soon as the command is known — before
2843
+ * the needs check and before anything runs. */
2844
+ function jsonUnsupportedError(commandId) {
2845
+ return new CliStructuredError("CLI.JSON_UNSUPPORTED", `The '${commandId.replaceAll(".", " ")}' command does not support json output.`, {
2846
+ why: "It hands the terminal to another program, whose output cannot be framed as a json stream.",
2847
+ nextActions: [{
2848
+ kind: "user-choice",
2849
+ label: "Run it without --json or --format json."
2850
+ }]
2851
+ });
2045
2852
  }
2046
2853
  function declaredFlags(def, rawFlags) {
2047
2854
  const flags = {};
@@ -2061,4 +2868,70 @@ function distributePositionals(def, values) {
2061
2868
  return positionals;
2062
2869
  }
2063
2870
  //#endregion
2064
- export { emptyServiceTokenError as a, PRESENTED as c, credentialsRequiredError as i, flag as l, authServiceError as n, noSessionForWorkspaceError as o, credentialRejectedError as r, serviceTokenRejectedError as s, buildEngine as t, positional as u };
2871
+ //#region src/token-claims.ts
2872
+ /**
2873
+ * Reading a credential's own claims. This lives in the engine and is
2874
+ * shared rather than reimplemented, because both credential managers
2875
+ * need it and the two copies had already drifted: one knew a service
2876
+ * token names its workspace through `sub`, the other did not, so a
2877
+ * token that worked in production could not be reproduced in a test.
2878
+ *
2879
+ * Decoding only. Nothing here verifies a signature — the claims are the
2880
+ * issuer's word, used for display and for keying, never for authorizing.
2881
+ */
2882
+ /** A service token's subject is its workspace, not a person. */
2883
+ const WORKSPACE_SUBJECT_PREFIX = "workspace:";
2884
+ function decodeTokenClaims(token) {
2885
+ const payload = token.split(".")[1];
2886
+ if (payload === void 0) return void 0;
2887
+ try {
2888
+ const parsed = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
2889
+ return typeof parsed === "object" && parsed !== null ? parsed : void 0;
2890
+ } catch {
2891
+ return;
2892
+ }
2893
+ }
2894
+ function claimedString(claims, name) {
2895
+ const value = claims?.[name];
2896
+ return typeof value === "string" && value.length > 0 ? value : void 0;
2897
+ }
2898
+ /**
2899
+ * The workspace a credential names. One derivation, because a token
2900
+ * says it one of two ways and every caller wants the same answer: an
2901
+ * OAuth token carries `workspace_id`, while a service token names its
2902
+ * workspace through `sub` and carries no `workspace_id` at all. Reading
2903
+ * only the claim was a second path that happened to work because
2904
+ * service tokens reached it by a different route — a split nothing
2905
+ * enforced.
2906
+ */
2907
+ function credentialWorkspaceId(token) {
2908
+ const claims = decodeTokenClaims(token);
2909
+ const fromClaim = claimedString(claims, "workspace_id");
2910
+ if (fromClaim !== void 0) return fromClaim;
2911
+ const subject = claimedString(claims, "sub");
2912
+ if (subject === void 0 || !subject.startsWith(WORKSPACE_SUBJECT_PREFIX)) return;
2913
+ const derived = subject.slice(10).trim();
2914
+ return derived.length > 0 ? derived : void 0;
2915
+ }
2916
+ function claimedExpiresAt(token) {
2917
+ const exp = decodeTokenClaims(token)?.exp;
2918
+ return typeof exp === "number" ? /* @__PURE__ */ new Date(exp * 1e3) : void 0;
2919
+ }
2920
+ /**
2921
+ * Who a credential belongs to, from its own claims. A service token's
2922
+ * subject names a workspace rather than a person, so it yields no user
2923
+ * — reporting `workspace:ws_1` as a user id was a real defect.
2924
+ */
2925
+ function claimedIdentity(token) {
2926
+ const claims = decodeTokenClaims(token);
2927
+ const subject = claimedString(claims, "sub");
2928
+ const userId = subject?.startsWith(WORKSPACE_SUBJECT_PREFIX) ? void 0 : subject;
2929
+ const email = claimedString(claims, "email");
2930
+ return userId === void 0 && email === void 0 ? void 0 : {
2931
+ userId,
2932
+ email,
2933
+ name: void 0
2934
+ };
2935
+ }
2936
+ //#endregion
2937
+ export { PRESENTED as _, CONFIG_FILE_NAME as a, positional as b, PRISMA_CONFIG_VERSION as c, authServiceError as d, credentialRejectedError as f, noSessionForWorkspaceError as g, emptyServiceTokenError as h, buildEngine as i, SERVICE_TOKEN_ENV_VAR as l, credentialsRequiredError as m, claimedIdentity as n, defineConfig as o, credentialWorkspaceMismatchError as p, credentialWorkspaceId as r, loadConfig as s, claimedExpiresAt as t, WORKSPACE_ID_ENV_VAR as u, exitWithChildStatus as v, flag as y };