@runa-ai/runa-cli 0.5.52 → 0.5.53

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 +1 @@
1
- {"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../../../src/commands/build/machine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAU,KAAK,YAAY,EAAS,MAAM,QAAQ,CAAC;AAe1D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAe,MAAM,YAAY,CAAC;AAmPpF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAIL,UAAU;cAAY,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6nB9C,CAAC;AAMH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC;AAC/C,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;AAM9D;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAa5D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAE3D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAE/D"}
1
+ {"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../../../src/commands/build/machine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAU,KAAK,YAAY,EAAS,MAAM,QAAQ,CAAC;AAoB1D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAe,MAAM,YAAY,CAAC;AAmPpF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAIL,UAAU;cAAY,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6nB9C,CAAC;AAMH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC;AAC/C,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;AAM9D;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAE5D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAE3D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAE/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"ci-local.d.ts","sourceRoot":"","sources":["../../../../../src/commands/ci/machine/commands/ci-local.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgNpC,eAAO,MAAM,qBAAqB,SAe9B,CAAC"}
1
+ {"version":3,"file":"ci-local.d.ts","sourceRoot":"","sources":["../../../../../src/commands/ci/machine/commands/ci-local.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkNpC,eAAO,MAAM,qBAAqB,SAe9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ci-pr.d.ts","sourceRoot":"","sources":["../../../../../src/commands/ci/machine/commands/ci-pr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmbpC,eAAO,MAAM,kBAAkB,SAmBN,CAAC"}
1
+ {"version":3,"file":"ci-pr.d.ts","sourceRoot":"","sources":["../../../../../src/commands/ci/machine/commands/ci-pr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqbpC,eAAO,MAAM,kBAAkB,SAmBN,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Capture process environment as a plain string map.
3
+ *
4
+ * Filters out undefined values so callers can pass the result directly
5
+ * to command actor env inputs without widening types.
6
+ */
7
+ export declare function captureRuntimeEnv(source?: NodeJS.ProcessEnv): Record<string, string>;
8
+ //# sourceMappingURL=runtime-env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-env.d.ts","sourceRoot":"","sources":["../../../../../src/commands/ci/machine/commands/runtime-env.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQjG"}
@@ -80,6 +80,7 @@ export declare const CiInputSchema: z.ZodObject<{
80
80
  verbose: z.ZodOptional<z.ZodBoolean>;
81
81
  productionDatabaseUrl: z.ZodOptional<z.ZodString>;
82
82
  databaseUrl: z.ZodOptional<z.ZodString>;
83
+ runtimeEnv: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
83
84
  githubRef: z.ZodOptional<z.ZodString>;
84
85
  githubEventAction: z.ZodOptional<z.ZodString>;
85
86
  githubSha: z.ZodOptional<z.ZodString>;
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../../src/commands/ci/machine/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC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MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAMlE;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;iBAK5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;iBAY7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAqBhB,CAAC;AAEZ,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAMtD;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;iBAKnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAM1E;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;iBAM1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAMxD;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;iBAI3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAM1D;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;;;iBAK5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
@@ -90,6 +90,19 @@ export declare function getSupabaseUrlWithFallback(context: CiContext): string;
90
90
  * @returns Supabase anon key (from context or local default)
91
91
  */
92
92
  export declare function getSupabaseAnonKeyWithFallback(context: CiContext): string;
93
+ export interface RuntimeEnvOptions {
94
+ enablePublicE2EFlag?: boolean;
95
+ enableServerE2EFlag?: boolean;
96
+ baseUrl?: string;
97
+ }
98
+ /**
99
+ * Build actor runtime env from captured input.
100
+ *
101
+ * The machine never reads process.env directly. Command entry points
102
+ * capture environment into CiInput.runtimeEnv and helpers compose
103
+ * per-state overrides here.
104
+ */
105
+ export declare function buildRuntimeEnv(context: CiContext, options?: RuntimeEnvOptions): Record<string, string>;
93
106
  /**
94
107
  * Compute exit code based on layer results and classification.
95
108
  *
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/commands/ci/machine/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAM5C,sCAAsC;AACtC,eAAO,MAAM,WAAW,oBAAqB,CAAC;AAE9C,6BAA6B;AAC7B,eAAO,MAAM,SAAS,IAAI,CAAC;AAM3B;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAOtF;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,OAAO,CAE7D;AAMD,+BAA+B;AAC/B,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEjF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAC/B,MAAM,EACN;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MA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Bd;AAMD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,SAAS,GAAG,MAAM,CAGnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,SAAS,GAAG,MAAM,CAGrE;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,SAAS,GAAG,MAAM,CAEzE;AAED,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,EAClB,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBxB;AAMD;;;;;;;GAOG;AACH,wBAAgB,+BAA+B,CAC7C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,GACjE,CAAC,GAAG,CAAC,GAAG,CAAC,CAyBX"}
@@ -184,6 +184,7 @@ export declare const ciMachine: import("xstate").StateMachine<CiContext, CiEvent
184
184
  verbose?: boolean | undefined;
185
185
  productionDatabaseUrl?: string | undefined;
186
186
  databaseUrl?: string | undefined;
187
+ runtimeEnv?: Record<string, string> | undefined;
187
188
  githubRef?: string | undefined;
188
189
  githubEventAction?: string | undefined;
189
190
  githubSha?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../../../../src/commands/ci/machine/machine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAU,KAAK,YAAY,EAAS,MAAM,QAAQ,CAAC;AA8C1D,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,E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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAslCpB,CAAC;AAMH,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC;AACzC,MAAM,MAAM,UAAU,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,CAAC;AAMxD;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO,CAExD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAE5D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,UAAU,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAE3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"schema-detector.d.ts","sourceRoot":"","sources":["../../../../src/commands/db/utils/schema-detector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;GAEG;AACH,eAAO,MAAM,gBAAgB,aAsB3B,CAAC;AAEH;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,EAAE,CAoC/E;AAQD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAW7D"}
1
+ {"version":3,"file":"schema-detector.d.ts","sourceRoot":"","sources":["../../../../src/commands/db/utils/schema-detector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;GAEG;AACH,eAAO,MAAM,gBAAgB,aAsB3B,CAAC;AA0GH;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,EAAE,CAmC/E;AAQD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAW7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"sql-table-extractor.d.ts","sourceRoot":"","sources":["../../../../src/commands/db/utils/sql-table-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,KAAK,EAKV,UAAU,EACX,MAAM,yBAAyB,CAAC;AAghBjC,MAAM,WAAW,cAAc;IAC7B,iCAAiC;IACjC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,2BAA2B;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,sBAAsB;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,2BAA2B;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAyHD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,UAAU,EAAE,CAAC,CAkBvB;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,UAAU,EAAE,CAAC,CAKvB"}
1
+ {"version":3,"file":"sql-table-extractor.d.ts","sourceRoot":"","sources":["../../../../src/commands/db/utils/sql-table-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,KAAK,EAKV,UAAU,EACX,MAAM,yBAAyB,CAAC;AAm1BjC,MAAM,WAAW,cAAc;IAC7B,iCAAiC;IACjC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,2BAA2B;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,sBAAsB;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,2BAA2B;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AA0HD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,UAAU,EAAE,CAAC,CAkBvB;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,UAAU,EAAE,CAAC,CAKvB"}
package/dist/index.js CHANGED
@@ -1161,7 +1161,7 @@ var CLI_VERSION, HAS_ADMIN_COMMAND;
1161
1161
  var init_version = __esm({
1162
1162
  "src/version.ts"() {
1163
1163
  init_esm_shims();
1164
- CLI_VERSION = "0.5.52";
1164
+ CLI_VERSION = "0.5.53";
1165
1165
  HAS_ADMIN_COMMAND = false;
1166
1166
  }
1167
1167
  });
@@ -5351,6 +5351,87 @@ var BuildOutputSchema = z.object({
5351
5351
  // src/commands/build/machine.ts
5352
5352
  init_esm_shims();
5353
5353
 
5354
+ // src/internal/machines/index.ts
5355
+ init_esm_shims();
5356
+
5357
+ // src/internal/machines/machine-runner.ts
5358
+ init_esm_shims();
5359
+ function getOutputOrThrow(snapshot2) {
5360
+ const s = snapshot2;
5361
+ if (s.output === void 0) {
5362
+ throw new CLIError("Machine completed without output", "MACHINE_NO_OUTPUT", [
5363
+ "Ensure the machine defines an `output:` function."
5364
+ ]);
5365
+ }
5366
+ return s.output;
5367
+ }
5368
+ async function runMachine(params) {
5369
+ const timeoutMs = params.timeoutMs ?? 10 * 60 * 1e3;
5370
+ return new Promise((resolve12, reject) => {
5371
+ const actor = createActor(params.machine, { input: params.input });
5372
+ const timer = setTimeout(() => {
5373
+ try {
5374
+ actor.stop?.();
5375
+ } catch {
5376
+ }
5377
+ reject(
5378
+ new CLIError("Machine execution timed out", "MACHINE_TIMEOUT", [
5379
+ `Timeout: ${timeoutMs}ms`,
5380
+ "Consider increasing timeoutMs for long-running operations."
5381
+ ])
5382
+ );
5383
+ }, timeoutMs);
5384
+ const sub = actor.subscribe((snapshot2) => {
5385
+ try {
5386
+ params.onSnapshot?.(snapshot2);
5387
+ const stateName = params.helpers.getStateName(snapshot2);
5388
+ params.onTransition?.(stateName);
5389
+ if (params.helpers.isComplete(snapshot2)) {
5390
+ clearTimeout(timer);
5391
+ sub.unsubscribe();
5392
+ const out = getOutputOrThrow(snapshot2);
5393
+ resolve12(out);
5394
+ }
5395
+ } catch (err) {
5396
+ clearTimeout(timer);
5397
+ sub.unsubscribe();
5398
+ reject(err);
5399
+ }
5400
+ });
5401
+ try {
5402
+ actor.start();
5403
+ actor.send({ type: "START" });
5404
+ } catch (err) {
5405
+ clearTimeout(timer);
5406
+ sub.unsubscribe();
5407
+ reject(err);
5408
+ }
5409
+ });
5410
+ }
5411
+
5412
+ // src/internal/machines/snapshot-helpers.ts
5413
+ init_esm_shims();
5414
+ function getSnapshotStateName(snapshot2) {
5415
+ if (typeof snapshot2.value === "string") {
5416
+ return snapshot2.value;
5417
+ }
5418
+ if (!snapshot2.value || typeof snapshot2.value !== "object") {
5419
+ return "unknown";
5420
+ }
5421
+ const entries = Object.entries(snapshot2.value);
5422
+ if (entries.length === 0) {
5423
+ return "unknown";
5424
+ }
5425
+ const [parent, child] = entries[0];
5426
+ if (typeof child === "string") {
5427
+ return `${parent}.${child}`;
5428
+ }
5429
+ return parent;
5430
+ }
5431
+ function isSnapshotComplete(snapshot2) {
5432
+ return snapshot2.status === "done";
5433
+ }
5434
+
5354
5435
  // src/commands/build/actors/index.ts
5355
5436
  init_esm_shims();
5356
5437
 
@@ -7350,20 +7431,10 @@ var buildMachine = setup({
7350
7431
  output: ({ context }) => createOutput(context)
7351
7432
  });
7352
7433
  function getStateName(snapshot2) {
7353
- if (typeof snapshot2.value === "string") {
7354
- return snapshot2.value;
7355
- }
7356
- const topLevel = Object.keys(snapshot2.value)[0];
7357
- if (topLevel && typeof snapshot2.value === "object") {
7358
- const nested = snapshot2.value[topLevel];
7359
- if (nested && typeof nested === "string") {
7360
- return `${topLevel}.${nested}`;
7361
- }
7362
- }
7363
- return topLevel ?? "unknown";
7434
+ return getSnapshotStateName(snapshot2);
7364
7435
  }
7365
7436
  function isComplete(snapshot2) {
7366
- return snapshot2.status === "done";
7437
+ return isSnapshotComplete(snapshot2);
7367
7438
  }
7368
7439
 
7369
7440
  // src/commands/build/commands/build.ts
@@ -9741,6 +9812,89 @@ var EXCLUDED_SCHEMAS = /* @__PURE__ */ new Set([
9741
9812
  "pgbouncer",
9742
9813
  "cron"
9743
9814
  ]);
9815
+ function stripSqlCommentsPreserveStrings(content) {
9816
+ let result = "";
9817
+ let i = 0;
9818
+ let inSingleQuote = false;
9819
+ let inDoubleQuote = false;
9820
+ let inDollarQuote = false;
9821
+ let dollarTag = "";
9822
+ while (i < content.length) {
9823
+ const char = content[i] ?? "";
9824
+ const next = content[i + 1] ?? "";
9825
+ if (!inSingleQuote && !inDoubleQuote && !inDollarQuote && char === "-" && next === "-") {
9826
+ while (i < content.length && content[i] !== "\n") {
9827
+ result += " ";
9828
+ i++;
9829
+ }
9830
+ continue;
9831
+ }
9832
+ if (!inSingleQuote && !inDoubleQuote && !inDollarQuote && char === "/" && next === "*") {
9833
+ result += " ";
9834
+ result += " ";
9835
+ i += 2;
9836
+ while (i < content.length) {
9837
+ const blockChar = content[i] ?? "";
9838
+ const blockNext = content[i + 1] ?? "";
9839
+ if (blockChar === "*" && blockNext === "/") {
9840
+ result += " ";
9841
+ result += " ";
9842
+ i += 2;
9843
+ break;
9844
+ }
9845
+ result += blockChar === "\n" ? "\n" : " ";
9846
+ i++;
9847
+ }
9848
+ continue;
9849
+ }
9850
+ if (!inSingleQuote && !inDoubleQuote && char === "$") {
9851
+ if (inDollarQuote) {
9852
+ const closeTag = `$${dollarTag}$`;
9853
+ if (content.slice(i).startsWith(closeTag)) {
9854
+ result += closeTag;
9855
+ i += closeTag.length;
9856
+ inDollarQuote = false;
9857
+ dollarTag = "";
9858
+ continue;
9859
+ }
9860
+ } else {
9861
+ const tagMatch = content.slice(i).match(/^\$([a-zA-Z_][a-zA-Z0-9_]*)?\$/);
9862
+ if (tagMatch) {
9863
+ inDollarQuote = true;
9864
+ dollarTag = tagMatch[1] ?? "";
9865
+ result += tagMatch[0];
9866
+ i += tagMatch[0].length;
9867
+ continue;
9868
+ }
9869
+ }
9870
+ }
9871
+ if (!inDoubleQuote && !inDollarQuote && char === "'") {
9872
+ if (inSingleQuote && next === "'") {
9873
+ result += "''";
9874
+ i += 2;
9875
+ continue;
9876
+ }
9877
+ inSingleQuote = !inSingleQuote;
9878
+ result += char;
9879
+ i++;
9880
+ continue;
9881
+ }
9882
+ if (!inSingleQuote && !inDollarQuote && char === '"') {
9883
+ if (inDoubleQuote && next === '"') {
9884
+ result += '""';
9885
+ i += 2;
9886
+ continue;
9887
+ }
9888
+ inDoubleQuote = !inDoubleQuote;
9889
+ result += char;
9890
+ i++;
9891
+ continue;
9892
+ }
9893
+ result += char;
9894
+ i++;
9895
+ }
9896
+ return result;
9897
+ }
9744
9898
  function detectAppSchemas(schemasDir, verbose) {
9745
9899
  const schemas = /* @__PURE__ */ new Set(["public"]);
9746
9900
  if (!existsSync(schemasDir)) {
@@ -9749,12 +9903,13 @@ function detectAppSchemas(schemasDir, verbose) {
9749
9903
  const files = readdirSync(schemasDir).filter((f) => f.endsWith(".sql"));
9750
9904
  for (const file of files) {
9751
9905
  const content = readFileSync(join(schemasDir, file), "utf-8");
9752
- const contentWithoutComments = content.replace(/--[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
9906
+ const contentWithoutComments = stripSqlCommentsPreserveStrings(content);
9753
9907
  const matches = contentWithoutComments.matchAll(
9754
- /^\s*CREATE\s+SCHEMA\s+(?:IF\s+NOT\s+EXISTS\s+)?(\w+)/gim
9908
+ /^\s*CREATE\s+SCHEMA\s+(?:IF\s+NOT\s+EXISTS\s+)?(?:"((?:[^"]|"")*)"|([a-zA-Z_][a-zA-Z0-9_]*))/gim
9755
9909
  );
9756
9910
  for (const match of Array.from(matches)) {
9757
- const schemaName = match[1].toLowerCase();
9911
+ const schemaNameRaw = (match[1] ?? match[2] ?? "").replace(/""/g, '"');
9912
+ const schemaName = schemaNameRaw.toLowerCase();
9758
9913
  if (!EXCLUDED_SCHEMAS.has(schemaName)) {
9759
9914
  schemas.add(schemaName);
9760
9915
  }
@@ -15067,6 +15222,24 @@ function getSupabaseUrlWithFallback(context) {
15067
15222
  function getSupabaseAnonKeyWithFallback(context) {
15068
15223
  return context.supabase?.anonKey || DEFAULT_LOCAL_ANON_KEY;
15069
15224
  }
15225
+ function buildRuntimeEnv(context, options = {}) {
15226
+ const env2 = {
15227
+ ...context.input.runtimeEnv ?? {},
15228
+ DATABASE_URL: getDatabaseUrlForRuntime(context),
15229
+ NEXT_PUBLIC_SUPABASE_URL: getSupabaseUrlWithFallback(context),
15230
+ NEXT_PUBLIC_SUPABASE_ANON_KEY: getSupabaseAnonKeyWithFallback(context)
15231
+ };
15232
+ if (options.enablePublicE2EFlag) {
15233
+ env2.NEXT_PUBLIC_E2E_TEST = "true";
15234
+ }
15235
+ if (options.enableServerE2EFlag) {
15236
+ env2.E2E_TEST = "true";
15237
+ }
15238
+ if (options.baseUrl) {
15239
+ env2.BASE_URL = options.baseUrl;
15240
+ }
15241
+ return env2;
15242
+ }
15070
15243
  function computeExitCodeFromLayerResults(layerResults) {
15071
15244
  const classification = getClassificationForProfile("runa-strict");
15072
15245
  const classificationMap = new Map(classification.map((c) => [c.layer, c.level]));
@@ -15555,7 +15728,7 @@ ${generateProgressCommentBody(progressInput)}`;
15555
15728
  tmpDir: assertTmpDir(context),
15556
15729
  // Execute if GH_DATABASE_URL_ADMIN is set (dry-run will determine if changes exist)
15557
15730
  // PRD: GH_DATABASE_URL_ADMIN = postgres role (DDL capable)
15558
- shouldExecute: !!(process.env.GH_DATABASE_URL_ADMIN || process.env.GH_DATABASE_URL)
15731
+ shouldExecute: Boolean(context.input.productionDatabaseUrl?.trim())
15559
15732
  }),
15560
15733
  onDone: {
15561
15734
  target: "collectSchemaStats",
@@ -15747,14 +15920,10 @@ ${generateProgressCommentBody(progressInput)}`;
15747
15920
  input: ({ context }) => ({
15748
15921
  repoRoot: assertRepoRoot(context),
15749
15922
  tmpDir: assertTmpDir(context),
15750
- env: {
15751
- ...process.env,
15752
- DATABASE_URL: getDatabaseUrlForRuntime(context),
15753
- NEXT_PUBLIC_SUPABASE_URL: getSupabaseUrlWithFallback(context),
15754
- NEXT_PUBLIC_SUPABASE_ANON_KEY: getSupabaseAnonKeyWithFallback(context),
15755
- // CRITICAL: Required for XState Test Plugin to inject data-state attributes
15756
- NEXT_PUBLIC_E2E_TEST: "true"
15757
- },
15923
+ env: buildRuntimeEnv(context, {
15924
+ // Required for XState Test Plugin to inject data-state attributes.
15925
+ enablePublicE2EFlag: true
15926
+ }),
15758
15927
  isCI: context.input.isCI ?? false,
15759
15928
  skipPlaywright: shouldSkipPlaywrightInstall(context)
15760
15929
  }),
@@ -15805,16 +15974,11 @@ ${generateProgressCommentBody(progressInput)}`;
15805
15974
  tmpDir: assertTmpDir(context),
15806
15975
  appDir: context.app?.appDir ?? assertRepoRoot(context),
15807
15976
  port: context.app?.port ?? 3e3,
15808
- env: {
15809
- ...process.env,
15810
- DATABASE_URL: getDatabaseUrlForRuntime(context),
15811
- NEXT_PUBLIC_SUPABASE_URL: getSupabaseUrlWithFallback(context),
15812
- NEXT_PUBLIC_SUPABASE_ANON_KEY: getSupabaseAnonKeyWithFallback(context),
15813
- // CRITICAL: Required for middleware to bypass auth in E2E tests
15814
- // E2E_TEST is server-only (proxy.ts), NEXT_PUBLIC_E2E_TEST is for build-time (xstate-test-plugin)
15815
- E2E_TEST: "true",
15816
- NEXT_PUBLIC_E2E_TEST: "true"
15817
- }
15977
+ env: buildRuntimeEnv(context, {
15978
+ // E2E_TEST is server-only (proxy.ts), NEXT_PUBLIC_E2E_TEST is for build-time.
15979
+ enableServerE2EFlag: true,
15980
+ enablePublicE2EFlag: true
15981
+ })
15818
15982
  }),
15819
15983
  onDone: [
15820
15984
  {
@@ -15919,12 +16083,7 @@ ${generateProgressCommentBody(progressInput)}`;
15919
16083
  // ci-local: all selected layers, ci-pr: only core layers (1,2,3)
15920
16084
  layers: getLayersForCorePhase(context.selectedLayers, context.mode),
15921
16085
  baseUrl: context.baseUrl ?? `http://localhost:${context.app?.port ?? 3e3}`,
15922
- env: {
15923
- ...process.env,
15924
- DATABASE_URL: getDatabaseUrlForRuntime(context),
15925
- NEXT_PUBLIC_SUPABASE_URL: getSupabaseUrlWithFallback(context),
15926
- NEXT_PUBLIC_SUPABASE_ANON_KEY: getSupabaseAnonKeyWithFallback(context)
15927
- },
16086
+ env: buildRuntimeEnv(context),
15928
16087
  failFast: true
15929
16088
  }),
15930
16089
  onDone: [
@@ -16078,15 +16237,10 @@ ${generateCommentBody(commentInput)}`;
16078
16237
  tmpDir: assertTmpDir(context),
16079
16238
  layers: [E2E_LAYER],
16080
16239
  baseUrl: e2eBaseUrl,
16081
- env: {
16082
- ...process.env,
16083
- DATABASE_URL: getDatabaseUrlForRuntime(context),
16084
- NEXT_PUBLIC_SUPABASE_URL: getSupabaseUrlWithFallback(context),
16085
- NEXT_PUBLIC_SUPABASE_ANON_KEY: getSupabaseAnonKeyWithFallback(context),
16086
- // CRITICAL: Set BASE_URL for Playwright config and test fixtures
16087
- // This ensures cookies are set on the same domain Playwright uses
16088
- BASE_URL: e2eBaseUrl
16089
- },
16240
+ env: buildRuntimeEnv(context, {
16241
+ // Ensures cookies are set on the same domain Playwright uses.
16242
+ baseUrl: e2eBaseUrl
16243
+ }),
16090
16244
  failFast: false
16091
16245
  // Don't fail-fast for E2E (warning-only)
16092
16246
  };
@@ -16280,19 +16434,10 @@ ${generateCommentBody(commentInput)}`;
16280
16434
  output: ({ context }) => createOutput3(context)
16281
16435
  });
16282
16436
  function getStateName3(snapshot2) {
16283
- const value = snapshot2.value;
16284
- if (typeof value === "string") return value;
16285
- const keys = Object.keys(value);
16286
- if (keys.length > 0) {
16287
- const parent = keys[0];
16288
- const child = value[parent];
16289
- if (typeof child === "string") return `${parent}.${child}`;
16290
- return parent;
16291
- }
16292
- return "unknown";
16437
+ return getSnapshotStateName(snapshot2);
16293
16438
  }
16294
16439
  function isComplete3(snapshot2) {
16295
- return snapshot2.status === "done";
16440
+ return isSnapshotComplete(snapshot2);
16296
16441
  }
16297
16442
 
16298
16443
  // src/commands/ci/machine/commands/machine-runner.ts
@@ -16541,6 +16686,18 @@ async function flushAndExit(exitCode) {
16541
16686
  process.exit(exitCode);
16542
16687
  }
16543
16688
 
16689
+ // src/commands/ci/machine/commands/runtime-env.ts
16690
+ init_esm_shims();
16691
+ function captureRuntimeEnv(source = process.env) {
16692
+ const captured = {};
16693
+ for (const [key, value] of Object.entries(source)) {
16694
+ if (value !== void 0) {
16695
+ captured[key] = value;
16696
+ }
16697
+ }
16698
+ return captured;
16699
+ }
16700
+
16544
16701
  // src/commands/ci/machine/commands/ci-local.ts
16545
16702
  var isGitHubActionsMode = false;
16546
16703
  var currentGroup = null;
@@ -16662,7 +16819,8 @@ function buildMachineInput(options) {
16662
16819
  dbMode: void 0,
16663
16820
  // PRD: GH_DATABASE_URL_ADMIN = postgres role (DDL capable, for pg_dump)
16664
16821
  productionDatabaseUrl: process.env.GH_DATABASE_URL_ADMIN || process.env.GH_DATABASE_URL,
16665
- databaseUrl: process.env.DATABASE_URL
16822
+ databaseUrl: process.env.DATABASE_URL,
16823
+ runtimeEnv: captureRuntimeEnv()
16666
16824
  };
16667
16825
  }
16668
16826
  function handleCiError(error, logger16) {
@@ -16728,6 +16886,8 @@ z.object({
16728
16886
  productionDatabaseUrl: z.string().optional(),
16729
16887
  /** Local database URL */
16730
16888
  databaseUrl: z.string().optional(),
16889
+ /** Sanitized process.env captured at entry point */
16890
+ runtimeEnv: z.record(z.string(), z.string()).optional(),
16731
16891
  // === GitHub Actions Environment ===
16732
16892
  /** GitHub ref (e.g., refs/pull/123/merge) */
16733
16893
  githubRef: z.string().optional(),
@@ -17179,6 +17339,7 @@ function optionsToMachineInput(options) {
17179
17339
  databaseUrl: process.env.DATABASE_URL,
17180
17340
  // PRD: GH_DATABASE_URL_ADMIN = postgres role (DDL capable, for pg-schema-diff dry-run)
17181
17341
  productionDatabaseUrl: process.env.GH_DATABASE_URL_ADMIN || process.env.GH_DATABASE_URL,
17342
+ runtimeEnv: captureRuntimeEnv(),
17182
17343
  githubRef: process.env.GITHUB_REF,
17183
17344
  // FIX: Read action from GITHUB_EVENT_PATH JSON, not non-existent GITHUB_EVENT_ACTION env var
17184
17345
  githubEventAction: getGitHubEventAction(),
@@ -17425,21 +17586,35 @@ async function getSqlParserUtils() {
17425
17586
  await isAstParserAvailable();
17426
17587
  return sqlParserUtils;
17427
17588
  }
17589
+ var SQL_IDENTIFIER = String.raw`(?:"(?:[^"]|"")*"|[a-zA-Z_][a-zA-Z0-9_]*)`;
17428
17590
  var SQL_PATTERNS = {
17429
17591
  // CREATE TABLE [IF NOT EXISTS] schema.table_name (
17430
- createTable: /CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?(\w+)\.(\w+)\s*\(/gi,
17592
+ createTable: new RegExp(
17593
+ `CREATE\\s+TABLE\\s+(?:IF\\s+NOT\\s+EXISTS\\s+)?(${SQL_IDENTIFIER})\\.(${SQL_IDENTIFIER})\\s*\\(`,
17594
+ "gi"
17595
+ ),
17431
17596
  // PRIMARY KEY (columns)
17432
17597
  primaryKey: /PRIMARY\s+KEY\s*\(([^)]+)\)/gi,
17433
17598
  // FOREIGN KEY (column) REFERENCES schema.table(column) [ON DELETE|UPDATE ...]
17434
- foreignKey: /FOREIGN\s+KEY\s*\((\w+)\)\s*REFERENCES\s+(\w+)\.(\w+)\s*\((\w+)\)(?:\s+ON\s+DELETE\s+(\w+(?:\s+\w+)?))?(?:\s+ON\s+UPDATE\s+(\w+(?:\s+\w+)?))?/gi,
17599
+ foreignKey: new RegExp(
17600
+ `FOREIGN\\s+KEY\\s*\\((${SQL_IDENTIFIER})\\)\\s*REFERENCES\\s+(${SQL_IDENTIFIER})\\.(${SQL_IDENTIFIER})\\s*\\((${SQL_IDENTIFIER})\\)(?:\\s+ON\\s+DELETE\\s+(\\w+(?:\\s+\\w+)?))?(?:\\s+ON\\s+UPDATE\\s+(\\w+(?:\\s+\\w+)?))?`,
17601
+ "gi"
17602
+ ),
17435
17603
  // REFERENCES schema.table(column) - inline column constraint
17436
- inlineReference: /(\w+)\s+\w+[^,]*REFERENCES\s+(\w+)\.(\w+)\s*\((\w+)\)/gi,
17604
+ inlineReference: new RegExp(
17605
+ `(${SQL_IDENTIFIER})\\s+\\w+[\\w\\s()]*REFERENCES\\s+(${SQL_IDENTIFIER})\\.(${SQL_IDENTIFIER})\\s*\\((${SQL_IDENTIFIER})\\)`,
17606
+ "gi"
17607
+ ),
17437
17608
  // CREATE [UNIQUE] INDEX name ON schema.table (columns)
17438
- createIndex: /CREATE\s+(UNIQUE\s+)?INDEX\s+(?:IF\s+NOT\s+EXISTS\s+)?(\w+)\s+ON\s+(\w+)\.(\w+)\s*\(([^)]+)\)/gi,
17609
+ createIndex: new RegExp(
17610
+ `CREATE\\s+(UNIQUE\\s+)?INDEX\\s+(?:IF\\s+NOT\\s+EXISTS\\s+)?(${SQL_IDENTIFIER})\\s+ON\\s+(${SQL_IDENTIFIER})\\.(${SQL_IDENTIFIER})\\s*\\(([^)]+)\\)`,
17611
+ "gi"
17612
+ ),
17439
17613
  // ALTER TABLE ... ENABLE ROW LEVEL SECURITY
17440
- enableRls: /ALTER\s+TABLE\s+(\w+)\.(\w+)\s+ENABLE\s+ROW\s+LEVEL\s+SECURITY/gi,
17441
- // CREATE POLICY name ON schema.table FOR command USING (...) [WITH CHECK (...)]
17442
- createPolicy: /CREATE\s+POLICY\s+"?(\w+)"?\s+ON\s+(\w+)\.(\w+)\s+(?:AS\s+\w+\s+)?FOR\s+(\w+)\s+(?:TO\s+\w+\s+)?(?:USING\s*\(([^)]+)\))?(?:\s+WITH\s+CHECK\s*\(([^)]+)\))?/gi
17614
+ enableRls: new RegExp(
17615
+ `ALTER\\s+TABLE\\s+(${SQL_IDENTIFIER})\\.(${SQL_IDENTIFIER})\\s+ENABLE\\s+ROW\\s+LEVEL\\s+SECURITY`,
17616
+ "gi"
17617
+ )
17443
17618
  };
17444
17619
  function snakeToCamel2(str) {
17445
17620
  return str.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
@@ -17474,6 +17649,96 @@ function extractTableBody(content, startPos) {
17474
17649
  function normalizeType(type) {
17475
17650
  return type.trim().replace(/\s+/g, " ").toLowerCase().replace("character varying", "varchar").replace("timestamp with time zone", "timestamptz").replace("timestamp without time zone", "timestamp");
17476
17651
  }
17652
+ function unquoteIdentifier(identifier) {
17653
+ const trimmed = identifier.trim();
17654
+ if (trimmed.startsWith('"') && trimmed.endsWith('"')) {
17655
+ return trimmed.slice(1, -1).replace(/""/g, '"');
17656
+ }
17657
+ return trimmed;
17658
+ }
17659
+ function stripSqlCommentsPreserveStrings2(content) {
17660
+ let result = "";
17661
+ let i = 0;
17662
+ let inSingleQuote = false;
17663
+ let inDoubleQuote = false;
17664
+ let inDollarQuote = false;
17665
+ let dollarTag = "";
17666
+ while (i < content.length) {
17667
+ const char = content[i] ?? "";
17668
+ const next = content[i + 1] ?? "";
17669
+ if (!inSingleQuote && !inDoubleQuote && !inDollarQuote && char === "-" && next === "-") {
17670
+ while (i < content.length && content[i] !== "\n") {
17671
+ result += " ";
17672
+ i++;
17673
+ }
17674
+ continue;
17675
+ }
17676
+ if (!inSingleQuote && !inDoubleQuote && !inDollarQuote && char === "/" && next === "*") {
17677
+ result += " ";
17678
+ result += " ";
17679
+ i += 2;
17680
+ while (i < content.length) {
17681
+ const blockChar = content[i] ?? "";
17682
+ const blockNext = content[i + 1] ?? "";
17683
+ if (blockChar === "*" && blockNext === "/") {
17684
+ result += " ";
17685
+ result += " ";
17686
+ i += 2;
17687
+ break;
17688
+ }
17689
+ result += blockChar === "\n" ? "\n" : " ";
17690
+ i++;
17691
+ }
17692
+ continue;
17693
+ }
17694
+ if (!inSingleQuote && !inDoubleQuote && char === "$") {
17695
+ if (inDollarQuote) {
17696
+ const closeTag = `$${dollarTag}$`;
17697
+ if (content.slice(i).startsWith(closeTag)) {
17698
+ result += closeTag;
17699
+ i += closeTag.length;
17700
+ inDollarQuote = false;
17701
+ dollarTag = "";
17702
+ continue;
17703
+ }
17704
+ } else {
17705
+ const tagMatch = content.slice(i).match(/^\$([a-zA-Z_][a-zA-Z0-9_]*)?\$/);
17706
+ if (tagMatch) {
17707
+ inDollarQuote = true;
17708
+ dollarTag = tagMatch[1] ?? "";
17709
+ result += tagMatch[0];
17710
+ i += tagMatch[0].length;
17711
+ continue;
17712
+ }
17713
+ }
17714
+ }
17715
+ if (!inDoubleQuote && !inDollarQuote && char === "'") {
17716
+ if (inSingleQuote && next === "'") {
17717
+ result += "''";
17718
+ i += 2;
17719
+ continue;
17720
+ }
17721
+ inSingleQuote = !inSingleQuote;
17722
+ result += char;
17723
+ i++;
17724
+ continue;
17725
+ }
17726
+ if (!inSingleQuote && !inDollarQuote && char === '"') {
17727
+ if (inDoubleQuote && next === '"') {
17728
+ result += '""';
17729
+ i += 2;
17730
+ continue;
17731
+ }
17732
+ inDoubleQuote = !inDoubleQuote;
17733
+ result += char;
17734
+ i++;
17735
+ continue;
17736
+ }
17737
+ result += char;
17738
+ i++;
17739
+ }
17740
+ return result;
17741
+ }
17477
17742
  function parseIndexColumns(rawColumns) {
17478
17743
  return rawColumns.split(",").map((col) => {
17479
17744
  const trimmed = col.trim();
@@ -17510,8 +17775,8 @@ function findTablesRegex(ctx) {
17510
17775
  const tables = [];
17511
17776
  const regex = new RegExp(SQL_PATTERNS.createTable.source, "gi");
17512
17777
  for (const match of ctx.content.matchAll(regex)) {
17513
- const schema = match[1] ?? "";
17514
- const name = match[2] ?? "";
17778
+ const schema = unquoteIdentifier(match[1] ?? "");
17779
+ const name = unquoteIdentifier(match[2] ?? "");
17515
17780
  if (!schema || !name) continue;
17516
17781
  const lineNumber = getLineNumber(ctx.content, match.index ?? 0);
17517
17782
  const tableBody = extractTableBody(ctx.content, match.index ?? 0);
@@ -17533,10 +17798,10 @@ function parseColumnsRegex(tableBody) {
17533
17798
  const trimmed = line.trim();
17534
17799
  if (shouldSkipColumnLine(trimmed)) continue;
17535
17800
  const columnMatch = trimmed.match(
17536
- /^(\w+)\s+([\w\s()]+?)(?:\s+(NOT\s+NULL|NULL))?(?:\s+DEFAULT\s+[^,]+)?(?:\s+REFERENCES)?(?:,|$)/i
17801
+ /^((?:"(?:[^"]|"")*"|[a-zA-Z_][a-zA-Z0-9_]*))\s+([\w\s()]+?)(?:\s+(NOT\s+NULL|NULL))?(?:\s+DEFAULT\s+[^,]+)?(?:\s+REFERENCES)?(?:,|$)/i
17537
17802
  );
17538
17803
  if (columnMatch) {
17539
- const name = columnMatch[1] ?? "";
17804
+ const name = unquoteIdentifier(columnMatch[1] ?? "");
17540
17805
  if (!name || seen.has(name) || isReservedKeyword(name)) continue;
17541
17806
  seen.add(name);
17542
17807
  const rawType = columnMatch[2] ?? "";
@@ -17558,7 +17823,7 @@ function parsePrimaryKeyRegex(tableBody) {
17558
17823
  const regex = new RegExp(SQL_PATTERNS.primaryKey.source, "gi");
17559
17824
  const match = regex.exec(tableBody);
17560
17825
  if (match) {
17561
- return match[1]?.split(",").map((col) => col.trim());
17826
+ return match[1]?.split(",").map((col) => unquoteIdentifier(col.trim())).filter(Boolean) ?? [];
17562
17827
  }
17563
17828
  return [];
17564
17829
  }
@@ -17566,12 +17831,12 @@ function parseExplicitForeignKeys(tableBody) {
17566
17831
  const fks = [];
17567
17832
  const fkRegex = new RegExp(SQL_PATTERNS.foreignKey.source, "gi");
17568
17833
  for (const match of tableBody.matchAll(fkRegex)) {
17569
- const column = match[1] ?? "";
17570
- const refTable = match[4] ?? "";
17834
+ const column = unquoteIdentifier(match[1] ?? "");
17835
+ const refTable = unquoteIdentifier(match[4] ?? "");
17571
17836
  if (!column || !refTable) continue;
17572
17837
  fks.push({
17573
17838
  column,
17574
- referencesTable: `${match[2] ?? ""}.${match[3] ?? ""}`,
17839
+ referencesTable: `${unquoteIdentifier(match[2] ?? "")}.${unquoteIdentifier(match[3] ?? "")}`,
17575
17840
  referencesColumn: refTable,
17576
17841
  onDelete: normalizeOnAction(match[5]),
17577
17842
  onUpdate: normalizeOnAction(match[6])
@@ -17583,13 +17848,13 @@ function parseInlineForeignKeys(tableBody, existingColumns) {
17583
17848
  const fks = [];
17584
17849
  const inlineRegex = new RegExp(SQL_PATTERNS.inlineReference.source, "gi");
17585
17850
  for (const match of tableBody.matchAll(inlineRegex)) {
17586
- const inlineCol = match[1] ?? "";
17851
+ const inlineCol = unquoteIdentifier(match[1] ?? "");
17587
17852
  if (existingColumns.has(inlineCol)) continue;
17588
- const inlineRefCol = match[4] ?? "";
17853
+ const inlineRefCol = unquoteIdentifier(match[4] ?? "");
17589
17854
  if (!inlineCol || !inlineRefCol) continue;
17590
17855
  fks.push({
17591
17856
  column: inlineCol,
17592
- referencesTable: `${match[2] ?? ""}.${match[3] ?? ""}`,
17857
+ referencesTable: `${unquoteIdentifier(match[2] ?? "")}.${unquoteIdentifier(match[3] ?? "")}`,
17593
17858
  referencesColumn: inlineRefCol
17594
17859
  });
17595
17860
  }
@@ -17605,8 +17870,10 @@ function parseIndexesRegex(content, schema, tableName) {
17605
17870
  const indexes = [];
17606
17871
  const regex = new RegExp(SQL_PATTERNS.createIndex.source, "gi");
17607
17872
  for (const match of content.matchAll(regex)) {
17608
- if (match[3] === schema && match[4] === tableName) {
17609
- const indexName = match[2] ?? "";
17873
+ const indexSchema = unquoteIdentifier(match[3] ?? "");
17874
+ const indexTable = unquoteIdentifier(match[4] ?? "");
17875
+ if (indexSchema === schema && indexTable === tableName) {
17876
+ const indexName = unquoteIdentifier(match[2] ?? "");
17610
17877
  if (!indexName) continue;
17611
17878
  const rawColumns = match[5] ?? "";
17612
17879
  indexes.push({
@@ -17621,26 +17888,200 @@ function parseIndexesRegex(content, schema, tableName) {
17621
17888
  function hasRlsEnabledRegex(content, schema, tableName) {
17622
17889
  const regex = new RegExp(SQL_PATTERNS.enableRls.source, "gi");
17623
17890
  for (const match of content.matchAll(regex)) {
17624
- if (match[1] === schema && match[2] === tableName) {
17891
+ const matchSchema = unquoteIdentifier(match[1] ?? "");
17892
+ const matchTable = unquoteIdentifier(match[2] ?? "");
17893
+ if (matchSchema === schema && matchTable === tableName) {
17625
17894
  return true;
17626
17895
  }
17627
17896
  }
17628
17897
  return false;
17629
17898
  }
17899
+ function extractCreatePolicyStatements(content) {
17900
+ const statements = [];
17901
+ const startRegex = /\bCREATE\s+POLICY\b/gi;
17902
+ let match;
17903
+ while ((match = startRegex.exec(content)) !== null) {
17904
+ const startIndex = match.index ?? 0;
17905
+ const endIndex = findSqlStatementEndForPolicy(content, startIndex);
17906
+ statements.push(content.slice(startIndex, endIndex).trim());
17907
+ }
17908
+ return statements;
17909
+ }
17910
+ function findSqlStatementEndForPolicy(content, startIndex) {
17911
+ let inSingleQuote = false;
17912
+ let inDoubleQuote = false;
17913
+ let inDollarQuote = false;
17914
+ let dollarTag = "";
17915
+ for (let i = startIndex; i < content.length; i++) {
17916
+ const char = content[i] ?? "";
17917
+ const next = content[i + 1] ?? "";
17918
+ if (!inSingleQuote && !inDoubleQuote && !inDollarQuote) {
17919
+ if (char === "-" && next === "-") {
17920
+ const newlineIndex = content.indexOf("\n", i);
17921
+ if (newlineIndex === -1) return content.length;
17922
+ i = newlineIndex;
17923
+ continue;
17924
+ }
17925
+ if (char === "/" && next === "*") {
17926
+ const closeIndex = content.indexOf("*/", i + 2);
17927
+ if (closeIndex === -1) return content.length;
17928
+ i = closeIndex + 1;
17929
+ continue;
17930
+ }
17931
+ }
17932
+ if (!inSingleQuote && !inDoubleQuote && char === "$") {
17933
+ if (inDollarQuote) {
17934
+ const closeTag = `$${dollarTag}$`;
17935
+ if (content.slice(i).startsWith(closeTag)) {
17936
+ i += closeTag.length - 1;
17937
+ inDollarQuote = false;
17938
+ dollarTag = "";
17939
+ continue;
17940
+ }
17941
+ } else {
17942
+ const tagMatch = content.slice(i).match(/^\$([a-zA-Z_][a-zA-Z0-9_]*)?\$/);
17943
+ if (tagMatch) {
17944
+ inDollarQuote = true;
17945
+ dollarTag = tagMatch[1] ?? "";
17946
+ i += tagMatch[0].length - 1;
17947
+ continue;
17948
+ }
17949
+ }
17950
+ }
17951
+ if (!inDoubleQuote && !inDollarQuote && char === "'") {
17952
+ if (inSingleQuote) {
17953
+ if (next === "'") {
17954
+ i++;
17955
+ continue;
17956
+ }
17957
+ inSingleQuote = false;
17958
+ } else {
17959
+ inSingleQuote = true;
17960
+ }
17961
+ continue;
17962
+ }
17963
+ if (!inSingleQuote && !inDollarQuote && char === '"') {
17964
+ if (inDoubleQuote) {
17965
+ if (next === '"') {
17966
+ i++;
17967
+ continue;
17968
+ }
17969
+ inDoubleQuote = false;
17970
+ } else {
17971
+ inDoubleQuote = true;
17972
+ }
17973
+ continue;
17974
+ }
17975
+ if (!inSingleQuote && !inDoubleQuote && !inDollarQuote && char === ";") {
17976
+ return i + 1;
17977
+ }
17978
+ }
17979
+ return content.length;
17980
+ }
17981
+ function extractBalancedClause(statement, startIndex) {
17982
+ const openParenIndex = statement.indexOf("(", startIndex);
17983
+ if (openParenIndex === -1) return void 0;
17984
+ let depth = 0;
17985
+ let clauseStart = -1;
17986
+ let inSingleQuote = false;
17987
+ let inDoubleQuote = false;
17988
+ let inDollarQuote = false;
17989
+ let dollarTag = "";
17990
+ for (let i = openParenIndex; i < statement.length; i++) {
17991
+ const char = statement[i] ?? "";
17992
+ const next = statement[i + 1] ?? "";
17993
+ if (!inSingleQuote && !inDoubleQuote && !inDollarQuote) {
17994
+ if (char === "-" && next === "-") {
17995
+ const newlineIndex = statement.indexOf("\n", i);
17996
+ if (newlineIndex === -1) break;
17997
+ i = newlineIndex;
17998
+ continue;
17999
+ }
18000
+ if (char === "/" && next === "*") {
18001
+ const closeIndex = statement.indexOf("*/", i + 2);
18002
+ if (closeIndex === -1) break;
18003
+ i = closeIndex + 1;
18004
+ continue;
18005
+ }
18006
+ }
18007
+ if (!inSingleQuote && !inDoubleQuote && char === "$") {
18008
+ if (inDollarQuote) {
18009
+ const closeTag = `$${dollarTag}$`;
18010
+ if (statement.slice(i).startsWith(closeTag)) {
18011
+ i += closeTag.length - 1;
18012
+ inDollarQuote = false;
18013
+ dollarTag = "";
18014
+ continue;
18015
+ }
18016
+ } else {
18017
+ const tagMatch = statement.slice(i).match(/^\$([a-zA-Z_][a-zA-Z0-9_]*)?\$/);
18018
+ if (tagMatch) {
18019
+ inDollarQuote = true;
18020
+ dollarTag = tagMatch[1] ?? "";
18021
+ i += tagMatch[0].length - 1;
18022
+ continue;
18023
+ }
18024
+ }
18025
+ }
18026
+ if (!inDoubleQuote && !inDollarQuote && char === "'") {
18027
+ if (inSingleQuote) {
18028
+ if (next === "'") {
18029
+ i++;
18030
+ continue;
18031
+ }
18032
+ inSingleQuote = false;
18033
+ } else {
18034
+ inSingleQuote = true;
18035
+ }
18036
+ continue;
18037
+ }
18038
+ if (!inSingleQuote && !inDollarQuote && char === '"') {
18039
+ if (inDoubleQuote) {
18040
+ if (next === '"') {
18041
+ i++;
18042
+ continue;
18043
+ }
18044
+ inDoubleQuote = false;
18045
+ } else {
18046
+ inDoubleQuote = true;
18047
+ }
18048
+ continue;
18049
+ }
18050
+ if (inSingleQuote || inDoubleQuote || inDollarQuote) continue;
18051
+ if (char === "(") {
18052
+ if (depth === 0) clauseStart = i + 1;
18053
+ depth++;
18054
+ } else if (char === ")") {
18055
+ depth--;
18056
+ if (depth === 0 && clauseStart !== -1) {
18057
+ return statement.slice(clauseStart, i).trim();
18058
+ }
18059
+ }
18060
+ }
18061
+ return void 0;
18062
+ }
17630
18063
  function parsePoliciesRegex(content, schema, tableName) {
17631
18064
  const policies = [];
17632
- const regex = new RegExp(SQL_PATTERNS.createPolicy.source, "gi");
17633
- for (const match of content.matchAll(regex)) {
17634
- const policyName = match[1] ?? "";
17635
- if (!policyName) continue;
17636
- if (match[2] === schema && match[3] === tableName) {
17637
- policies.push({
17638
- name: policyName,
17639
- command: match[4]?.toUpperCase(),
17640
- using: match[5] || void 0,
17641
- withCheck: match[6] || void 0
17642
- });
17643
- }
18065
+ const statements = extractCreatePolicyStatements(content);
18066
+ const headerRegex = new RegExp(
18067
+ `^\\s*CREATE\\s+POLICY\\s+(?:"((?:[^"]|"")*)"|([a-zA-Z_][a-zA-Z0-9_]*))\\s+ON\\s+(${SQL_IDENTIFIER})\\.(${SQL_IDENTIFIER})(?:\\s+AS\\s+\\w+)?(?:\\s+FOR\\s+(\\w+))?`,
18068
+ "i"
18069
+ );
18070
+ for (const statement of statements) {
18071
+ const match = statement.match(headerRegex);
18072
+ if (!match) continue;
18073
+ const policyName = unquoteIdentifier(match[1] ?? match[2] ?? "");
18074
+ const policySchema = unquoteIdentifier(match[3] ?? "");
18075
+ const policyTable = unquoteIdentifier(match[4] ?? "");
18076
+ if (!policyName || policySchema !== schema || policyTable !== tableName) continue;
18077
+ const usingIndex = statement.search(/\bUSING\s*\(/i);
18078
+ const withCheckIndex = statement.search(/\bWITH\s+CHECK\s*\(/i);
18079
+ policies.push({
18080
+ name: policyName,
18081
+ command: (match[5] || "ALL").toUpperCase(),
18082
+ using: usingIndex !== -1 ? extractBalancedClause(statement, usingIndex) : void 0,
18083
+ withCheck: withCheckIndex !== -1 ? extractBalancedClause(statement, withCheckIndex) : void 0
18084
+ });
17644
18085
  }
17645
18086
  return policies;
17646
18087
  }
@@ -17741,7 +18182,8 @@ function buildTableEntryRegex(table, content, filePath, opts) {
17741
18182
  };
17742
18183
  }
17743
18184
  function processTablesFromFileRegex(filePath, opts, seen) {
17744
- const content = readFileSync(filePath, "utf-8");
18185
+ const rawContent = readFileSync(filePath, "utf-8");
18186
+ const content = stripSqlCommentsPreserveStrings2(rawContent);
17745
18187
  const ctx = { content, lines: content.split("\n") };
17746
18188
  const tables = findTablesRegex(ctx);
17747
18189
  const entries = [];
@@ -20938,64 +21380,6 @@ var diffVisualCommand = new Command("diff-visual").description("Visualize schema
20938
21380
  // src/commands/db/commands/db-drizzle.ts
20939
21381
  init_esm_shims();
20940
21382
 
20941
- // src/internal/machines/index.ts
20942
- init_esm_shims();
20943
-
20944
- // src/internal/machines/machine-runner.ts
20945
- init_esm_shims();
20946
- function getOutputOrThrow(snapshot2) {
20947
- const s = snapshot2;
20948
- if (s.output === void 0) {
20949
- throw new CLIError("Machine completed without output", "MACHINE_NO_OUTPUT", [
20950
- "Ensure the machine defines an `output:` function."
20951
- ]);
20952
- }
20953
- return s.output;
20954
- }
20955
- async function runMachine(params) {
20956
- const timeoutMs = params.timeoutMs ?? 10 * 60 * 1e3;
20957
- return new Promise((resolve12, reject) => {
20958
- const actor = createActor(params.machine, { input: params.input });
20959
- const timer = setTimeout(() => {
20960
- try {
20961
- actor.stop?.();
20962
- } catch {
20963
- }
20964
- reject(
20965
- new CLIError("Machine execution timed out", "MACHINE_TIMEOUT", [
20966
- `Timeout: ${timeoutMs}ms`,
20967
- "Consider increasing timeoutMs for long-running operations."
20968
- ])
20969
- );
20970
- }, timeoutMs);
20971
- const sub = actor.subscribe((snapshot2) => {
20972
- try {
20973
- params.onSnapshot?.(snapshot2);
20974
- const stateName = params.helpers.getStateName(snapshot2);
20975
- params.onTransition?.(stateName);
20976
- if (params.helpers.isComplete(snapshot2)) {
20977
- clearTimeout(timer);
20978
- sub.unsubscribe();
20979
- const out = getOutputOrThrow(snapshot2);
20980
- resolve12(out);
20981
- }
20982
- } catch (err) {
20983
- clearTimeout(timer);
20984
- sub.unsubscribe();
20985
- reject(err);
20986
- }
20987
- });
20988
- try {
20989
- actor.start();
20990
- actor.send({ type: "START" });
20991
- } catch (err) {
20992
- clearTimeout(timer);
20993
- sub.unsubscribe();
20994
- reject(err);
20995
- }
20996
- });
20997
- }
20998
-
20999
21383
  // src/utils/execution-plan.ts
21000
21384
  init_esm_shims();
21001
21385
  function getChangeIcon(type) {
@@ -21266,6 +21650,10 @@ var RISK_PATTERNS = [
21266
21650
  function normalizeContent(content) {
21267
21651
  return content.replace(/--[^\n]*/g, " ").replace(/\/\*[\s\S]*?\*\//g, " ").replace(/\s+/g, " ").trim();
21268
21652
  }
21653
+ function stripSqlCommentsPreserveLines(content) {
21654
+ const lineMasked = content.replace(/--[^\n]*/g, (match) => " ".repeat(match.length));
21655
+ return lineMasked.replace(/\/\*[\s\S]*?\*\//g, (match) => match.replace(/[^\n]/g, " "));
21656
+ }
21269
21657
  function maskWrapperFunctions(content) {
21270
21658
  const wrapperPattern = /CREATE\s+(?:OR\s+REPLACE\s+)?FUNCTION\s+(?:public\.)?runa_auth_\w+\s*\([^)]*\)[^$]*(\$[a-zA-Z_]*\$)[\s\S]*?\1;?/gi;
21271
21659
  return content.replace(wrapperPattern, "/* WRAPPER_FUNCTION_MASKED */");
@@ -21280,6 +21668,9 @@ function findLineNumber(originalContent, matchText) {
21280
21668
  const beforeMatch = originalContent.substring(0, match.index);
21281
21669
  return beforeMatch.split("\n").length;
21282
21670
  }
21671
+ function lineNumberFromIndex(content, index) {
21672
+ return content.substring(0, Math.max(0, index)).split("\n").length;
21673
+ }
21283
21674
  function detectRisksFromContent(normalizedContent, originalContent) {
21284
21675
  const risks = [];
21285
21676
  const seenDescriptions = /* @__PURE__ */ new Set();
@@ -21302,18 +21693,18 @@ function detectRisksFromContent(normalizedContent, originalContent) {
21302
21693
  }
21303
21694
  return risks;
21304
21695
  }
21305
- function detectForeignKeyRisks(lines) {
21696
+ function detectForeignKeyRisks(originalContent) {
21306
21697
  const risks = [];
21307
- const fkPattern = /REFERENCES\s+[\w."]+\s*\(/i;
21308
- for (let i = 0; i < lines.length; i++) {
21309
- if (fkPattern.test(lines[i])) {
21310
- risks.push({
21311
- level: "low",
21312
- description: "Foreign key columns should have indexes",
21313
- mitigation: "Add index on foreign key column for better performance",
21314
- line: i + 1
21315
- });
21316
- }
21698
+ const fkPattern = /REFERENCES\s+[\w."]+\s*\(/gi;
21699
+ const contentWithoutComments = stripSqlCommentsPreserveLines(originalContent);
21700
+ let match;
21701
+ while ((match = fkPattern.exec(contentWithoutComments)) !== null) {
21702
+ risks.push({
21703
+ level: "low",
21704
+ description: "Foreign key columns should have indexes",
21705
+ mitigation: "Add index on foreign key column for better performance",
21706
+ line: lineNumberFromIndex(originalContent, match.index ?? 0)
21707
+ });
21317
21708
  }
21318
21709
  return risks;
21319
21710
  }
@@ -21325,9 +21716,8 @@ async function detectSchemaRisks(filePath) {
21325
21716
  const content = await readFile(filePath, "utf-8");
21326
21717
  const maskedContent = maskWrapperFunctions(content);
21327
21718
  const normalizedContent = normalizeContent(maskedContent);
21328
- const lines = content.split("\n");
21329
21719
  const contentRisks = detectRisksFromContent(normalizedContent, content);
21330
- const fkRisks = detectForeignKeyRisks(lines);
21720
+ const fkRisks = detectForeignKeyRisks(content);
21331
21721
  return [...contentRisks, ...fkRisks];
21332
21722
  } catch (_error) {
21333
21723
  return [];
@@ -6,5 +6,6 @@
6
6
  * - Keep command handlers thin and consistent.
7
7
  */
8
8
  export { runMachine } from './machine-runner.js';
9
+ export { getSnapshotError, getSnapshotStateName, isSnapshotComplete } from './snapshot-helpers.js';
9
10
  export type { StateE2EMeta } from './types.js';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/machines/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/machines/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACnG,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Shared snapshot helpers for CLI XState machines.
3
+ */
4
+ type SnapshotWithValue = {
5
+ value: unknown;
6
+ };
7
+ type SnapshotWithStatus = {
8
+ status: string;
9
+ };
10
+ type SnapshotWithError = {
11
+ context: {
12
+ error: string | null;
13
+ };
14
+ };
15
+ /**
16
+ * Convert snapshot value to a stable state name.
17
+ *
18
+ * Supports flat states ("idle") and compound states ({ setup: "depsInstall" }).
19
+ */
20
+ export declare function getSnapshotStateName(snapshot: SnapshotWithValue): string;
21
+ /**
22
+ * Check if a snapshot has reached final status.
23
+ */
24
+ export declare function isSnapshotComplete(snapshot: SnapshotWithStatus): boolean;
25
+ /**
26
+ * Extract normalized machine error from snapshot context.
27
+ */
28
+ export declare function getSnapshotError(snapshot: SnapshotWithError): string | null;
29
+ export {};
30
+ //# sourceMappingURL=snapshot-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot-helpers.d.ts","sourceRoot":"","sources":["../../../src/internal/machines/snapshot-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,KAAK,iBAAiB,GAAG;IACvB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;KACtB,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAmBxE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAExE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAE3E"}
@@ -1 +1 @@
1
- {"version":3,"file":"risk-detector.d.ts","sourceRoot":"","sources":["../../src/validators/risk-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAElD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAoOD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAwB/E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG;IACpD,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,GAAG,EAAE,UAAU,EAAE,CAAC;CACnB,CAMA"}
1
+ {"version":3,"file":"risk-detector.d.ts","sourceRoot":"","sources":["../../src/validators/risk-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAElD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAuPD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAuB/E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG;IACpD,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,GAAG,EAAE,UAAU,EAAE,CAAC;CACnB,CAMA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runa-ai/runa-cli",
3
- "version": "0.5.52",
3
+ "version": "0.5.53",
4
4
  "private": false,
5
5
  "description": "AI-powered DevOps CLI",
6
6
  "type": "module",
@@ -53,8 +53,8 @@
53
53
  "typescript": "5.9.3",
54
54
  "xstate": "5.25.0",
55
55
  "zod": "4.3.5",
56
- "@runa-ai/runa": "0.5.44",
57
- "@runa-ai/runa-xstate-test-plugin": "0.5.35"
56
+ "@runa-ai/runa-xstate-test-plugin": "0.5.35",
57
+ "@runa-ai/runa": "0.5.44"
58
58
  },
59
59
  "engines": {
60
60
  "node": ">=20.0.0"