@withgauge/cli 0.16.0 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -824,40 +824,40 @@ var catalogManifestSchema = z9.object({
824
824
  const cells = /* @__PURE__ */ new Set();
825
825
  for (const model of manifest.models) {
826
826
  for (const harness of model.harnesses) {
827
- const id = `${model.slug}:${harness.slug}`;
828
- if (cells.has(id))
829
- ctx.addIssue({ code: "custom", message: `Duplicate cell ${id}` });
830
- cells.add(id);
827
+ const id2 = `${model.slug}:${harness.slug}`;
828
+ if (cells.has(id2))
829
+ ctx.addIssue({ code: "custom", message: `Duplicate cell ${id2}` });
830
+ cells.add(id2);
831
831
  const protocol = harness.slug === "claude-code" ? "ANTHROPIC_MESSAGES" : harness.slug === "codex" ? "OPENAI_RESPONSES" : "OPENAI_CHAT_COMPLETIONS";
832
832
  if (model.protocol !== protocol)
833
833
  ctx.addIssue({
834
834
  code: "custom",
835
- message: `Unsupported harness protocol for ${id}: expected ${protocol}`
835
+ message: `Unsupported harness protocol for ${id2}: expected ${protocol}`
836
836
  });
837
837
  if ((harness.contextWindowTokens ?? model.contextWindowTokens) > model.contextWindowTokens)
838
838
  ctx.addIssue({
839
839
  code: "custom",
840
- message: `Harness context exceeds deployment for ${id}`
840
+ message: `Harness context exceeds deployment for ${id2}`
841
841
  });
842
842
  if (model.maxOutputTokens !== null && harness.maxOutputTokens != null && harness.maxOutputTokens > model.maxOutputTokens)
843
843
  ctx.addIssue({
844
844
  code: "custom",
845
- message: `Harness output exceeds deployment for ${id}`
845
+ message: `Harness output exceeds deployment for ${id2}`
846
846
  });
847
847
  }
848
848
  }
849
849
  const releases = /* @__PURE__ */ new Set();
850
850
  for (const release of manifest.releases) {
851
- const id = `${release.harness}:${release.releaseVersion}`;
852
- if (releases.has(id))
853
- ctx.addIssue({ code: "custom", message: `Duplicate release ${id}` });
854
- releases.add(id);
851
+ const id2 = `${release.harness}:${release.releaseVersion}`;
852
+ if (releases.has(id2))
853
+ ctx.addIssue({ code: "custom", message: `Duplicate release ${id2}` });
854
+ releases.add(id2);
855
855
  if (!manifest.models.some(
856
856
  (m) => m.harnesses.some(
857
857
  (h) => h.slug === release.harness && h.releaseVersion === release.releaseVersion
858
858
  )
859
859
  ))
860
- ctx.addIssue({ code: "custom", message: `Unused release ${id}` });
860
+ ctx.addIssue({ code: "custom", message: `Unused release ${id2}` });
861
861
  }
862
862
  });
863
863
  var catalogRequestSchema = z9.object({
@@ -1755,6 +1755,22 @@ var observedProviderSchema = z19.object({
1755
1755
  slug: z19.string(),
1756
1756
  source: observedProviderSourceSchema
1757
1757
  });
1758
+ var RUN_TRIGGER_SOURCES = [
1759
+ "UNKNOWN",
1760
+ "UI",
1761
+ "API",
1762
+ "CADENCE",
1763
+ "STAFF",
1764
+ "OPERATOR",
1765
+ "GITHUB"
1766
+ ];
1767
+ var runTriggerSourceSchema = z19.enum(RUN_TRIGGER_SOURCES);
1768
+ var runTriggeredBySchema = z19.object({
1769
+ source: runTriggerSourceSchema,
1770
+ userId: z19.string().nullable(),
1771
+ email: z19.string().nullable()
1772
+ });
1773
+ var runCreditsChargedSchema = z19.number().int().nullable();
1758
1774
  var runStatusFilterSchema = z19.string().transform(
1759
1775
  (raw) => raw.split(",").map((s) => s.trim().toUpperCase()).filter(Boolean)
1760
1776
  ).pipe(z19.array(runStatusSchema).min(1));
@@ -1791,6 +1807,8 @@ var runListItemSchema = z19.object({
1791
1807
  evalSetId: z19.string().nullable(),
1792
1808
  turns: z19.number().int().nullable(),
1793
1809
  usdCost: z19.number().nullable(),
1810
+ creditsCharged: runCreditsChargedSchema.optional(),
1811
+ triggeredBy: runTriggeredBySchema.optional(),
1794
1812
  durationMs: z19.number().int().nullable(),
1795
1813
  exitReason: z19.string().nullable(),
1796
1814
  createdAt: z19.string(),
@@ -2178,6 +2196,8 @@ var evalSetRunSchema = z22.object({
2178
2196
  startedAt: z22.string().nullable(),
2179
2197
  finishedAt: z22.string().nullable(),
2180
2198
  failureReason: z22.string().nullable(),
2199
+ creditsCharged: runCreditsChargedSchema.optional(),
2200
+ triggeredBy: runTriggeredBySchema.optional(),
2181
2201
  judge: z22.object({ status: z22.string(), error: z22.string().nullable() }).nullable(),
2182
2202
  criterionResults: z22.array(
2183
2203
  z22.object({
@@ -2188,9 +2208,7 @@ var evalSetRunSchema = z22.object({
2188
2208
  })
2189
2209
  )
2190
2210
  });
2191
- var listEvalSetRunsResponseSchema = z22.object({
2192
- items: z22.array(evalSetRunSchema)
2193
- });
2211
+ var listEvalSetRunsResponseSchema = listResponseSchema(evalSetRunSchema);
2194
2212
 
2195
2213
  // ../packages/api-schemas/src/executionTargets.ts
2196
2214
  import { z as z23 } from "zod";
@@ -2572,578 +2590,468 @@ var meResponseSchema = z28.object({
2572
2590
  });
2573
2591
 
2574
2592
  // ../packages/api-schemas/src/optimizations.ts
2575
- import { z as z32 } from "zod";
2593
+ import { z as z33 } from "zod";
2576
2594
 
2577
- // ../packages/api-schemas/src/cli-interventions.ts
2595
+ // ../packages/api-schemas/src/cli-rule-evidence.ts
2578
2596
  import { z as z29 } from "zod";
2579
- var digest = z29.string().regex(/^[a-f0-9]{64}$/);
2580
- var token = z29.string().min(1).max(4096);
2581
- var optionFlag = z29.string().regex(/^--?[A-Za-z0-9][A-Za-z0-9-]*$/);
2582
- var envKey = z29.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/);
2583
- var relativePath = z29.string().min(1).max(1024).refine(
2584
- (path3) => !path3.startsWith("/") && !path3.includes("\\") && !path3.includes("\0") && path3.split("/").every(
2585
- (part) => part && part !== "." && part !== ".." && ![".git", "node_modules", ".pnpm", ".yarn", ".venv"].includes(part)
2586
- ),
2587
- "Use a workspace-relative path without traversal"
2588
- );
2589
- var sourcedValue = z29.discriminatedUnion("source", [
2590
- z29.object({ source: z29.literal("literal"), value: z29.string().max(8192) }).strict(),
2591
- z29.object({ source: z29.literal("localFact"), key: envKey }).strict()
2592
- ]);
2593
- var cliLaunchFormSchema = z29.enum([
2594
- "native",
2595
- "path",
2596
- "symlink",
2597
- "shebang",
2598
- "node-script",
2599
- "python-script",
2600
- "python-module",
2601
- "execveat-path",
2602
- "execveat-fd"
2603
- ]);
2604
- var cliObservationReasonSchema = z29.enum([
2605
- "eligible",
2606
- "other-target",
2607
- "other-command",
2608
- "selector-mismatch",
2609
- "unknown-command",
2610
- "identity-unresolved",
2611
- "artifact-mismatch",
2612
- "runtime-mismatch",
2613
- "launch-form",
2614
- "io-profile",
2615
- "operation-profile",
2616
- "descriptor-lifetime"
2617
- ]);
2618
- var cliIoProfileSchema = z29.enum([
2619
- "pipes",
2620
- "redirected",
2621
- "shared-descriptor",
2622
- "pty"
2623
- ]);
2624
- var cliObservationSchema = z29.object({
2625
- invocationId: z29.string().regex(/^[a-f0-9]{32}$/),
2626
- targetId: token,
2627
- commandId: token.nullable(),
2628
- entrypointSha256: digest,
2629
- runtimeSha256: digest.nullable(),
2630
- launchForm: cliLaunchFormSchema.nullable(),
2631
- ioProfile: cliIoProfileSchema.nullable(),
2632
- reason: cliObservationReasonSchema
2633
- });
2634
- var cliCoverageSchema = z29.object({
2635
- attempt: z29.number().int().nonnegative(),
2636
- observedInvocationCount: z29.number().int().nonnegative().nullable(),
2637
- invocationCount: z29.number().int().nonnegative(),
2638
- appliedInvocationCount: z29.number().int().nonnegative(),
2639
- incompleteCount: z29.number().int().nonnegative(),
2640
- unsupportedCount: z29.number().int().nonnegative(),
2641
- instrumentationFailed: z29.boolean(),
2642
- observations: z29.array(cliObservationSchema),
2643
- unsupportedDiagnostics: z29.array(z29.string())
2644
- });
2645
- var cliOperationKindSchema = z29.enum([
2646
- "ensureOption",
2647
- "replaceOption",
2648
- "setEnv",
2649
- "streamOutput",
2650
- "completeOutput",
2651
- "structuredStdin",
2652
- "promptRecipe",
2653
- "generatedFile"
2597
+ var cliRuleDeliverySchema = z29.enum([
2598
+ "applied",
2599
+ "matched_unchanged",
2600
+ "not_exercised",
2601
+ "failed",
2602
+ "partial",
2603
+ "unavailable"
2654
2604
  ]);
2655
- var commandCapabilitiesSchema = z29.object({
2656
- operations: z29.array(cliOperationKindSchema).max(8),
2657
- options: z29.array(z29.object({ flag: optionFlag, takesValue: z29.boolean() }).strict()).max(100).default([]),
2658
- settings: z29.array(envKey).max(100).default([]),
2659
- localFacts: z29.array(envKey).max(30).default([]),
2660
- generatedPaths: z29.array(relativePath).max(50).default([]),
2661
- outputModes: z29.array(z29.enum(["streaming", "completed"])).max(2).default([]),
2662
- stdinFormats: z29.array(z29.enum(["text", "json", "jsonl"])).max(3).default([]),
2663
- recipeIds: z29.array(token).max(50).default([])
2664
- }).strict();
2665
- var cliTargetSchema = z29.object({
2666
- id: token,
2667
- vendor: token,
2668
- package: token,
2669
- version: token.nullable(),
2670
- /** Published artifact identity and exact executable/entrypoint identity. */
2671
- artifactSha256: digest.nullable(),
2672
- entrypointSha256: digest.nullable(),
2673
- /** Trace-derived recognition hints. Actual bytes are captured by record mode. */
2674
- discovery: z29.object({
2675
- ecosystem: token.nullable(),
2676
- program: token,
2677
- executables: z29.array(token).max(20)
2678
- }).strict().optional(),
2679
- ownershipEvidence: z29.string().min(1).max(2048),
2680
- entrypoints: z29.array(z29.string().min(1).max(1024)).max(20),
2681
- /** Flags accepted before the subcommand, with explicit value arity. */
2682
- globalOptions: z29.array(z29.object({ flag: optionFlag, takesValue: z29.boolean() }).strict()).max(100),
2683
- launchForms: z29.array(cliLaunchFormSchema).min(1),
2684
- ioProfiles: z29.array(cliIoProfileSchema).min(1),
2685
- commands: z29.array(
2605
+ var cliRuleInvocationResultSchema = z29.object({
2606
+ invocationId: z29.string(),
2607
+ ruleId: z29.string(),
2608
+ engineSha256: z29.string(),
2609
+ entrypointSha256: z29.string(),
2610
+ outcome: z29.number().nullable(),
2611
+ complete: z29.boolean(),
2612
+ deliveryFailure: z29.boolean().nullable(),
2613
+ failureReason: z29.string().nullable().optional(),
2614
+ inputs: z29.array(
2686
2615
  z29.object({
2687
- id: token,
2688
- /** Tokens following global options, before a literal `--`. */
2689
- subcommand: z29.array(token).max(8),
2690
- capabilities: commandCapabilitiesSchema
2691
- }).strict()
2692
- ).min(1)
2693
- }).strict().superRefine((target, ctx) => {
2694
- if (!target.discovery && (!target.version || !target.artifactSha256 || !target.entrypointSha256 || !target.entrypoints.length))
2695
- ctx.addIssue({
2696
- code: "custom",
2697
- message: "Registered targets need complete artifact identities"
2698
- });
2699
- if (target.discovery && (target.artifactSha256 !== null || target.entrypointSha256 !== null))
2700
- ctx.addIssue({
2701
- code: "custom",
2702
- message: "Discovered targets learn bytes from baseline invocations"
2703
- });
2704
- for (const [index, command] of target.commands.entries()) {
2705
- if (target.commands.findIndex((other) => other.id === command.id) !== index)
2706
- ctx.addIssue({
2707
- code: "custom",
2708
- path: ["commands", index, "id"],
2709
- message: "Duplicate command ID"
2710
- });
2711
- const { capabilities: capabilities2 } = command;
2712
- if (new Set(capabilities2.operations).size !== capabilities2.operations.length)
2713
- ctx.addIssue({
2714
- code: "custom",
2715
- path: ["commands", index, "capabilities", "operations"],
2716
- message: "Duplicate operation"
2616
+ operationId: z29.string(),
2617
+ kind: z29.string(),
2618
+ key: z29.string(),
2619
+ source: z29.string(),
2620
+ sourceKey: z29.string(),
2621
+ present: z29.boolean(),
2622
+ sourceBytes: z29.number(),
2623
+ applied: z29.boolean(),
2624
+ preflight: z29.boolean(),
2625
+ deliveredBytes: z29.number(),
2626
+ originalStdin: z29.literal("not_read")
2627
+ })
2628
+ ).max(50).default([]),
2629
+ operations: z29.array(
2630
+ z29.object({
2631
+ id: z29.string(),
2632
+ kind: z29.string(),
2633
+ count: z29.number().nullable()
2634
+ })
2635
+ ).max(50),
2636
+ excerpts: z29.array(
2637
+ z29.object({
2638
+ stream: z29.enum(["stdout", "stderr", "combined", "stdin"]),
2639
+ before: z29.string().max(4096),
2640
+ after: z29.string().max(4096),
2641
+ originalBytes: z29.number().nullable(),
2642
+ deliveredBytes: z29.number().nullable(),
2643
+ omitted: z29.boolean(),
2644
+ redacted: z29.boolean().optional(),
2645
+ beforeTruncated: z29.boolean().optional(),
2646
+ afterTruncated: z29.boolean().optional(),
2647
+ omissionReason: z29.string().max(128).optional()
2648
+ })
2649
+ ).max(4)
2650
+ });
2651
+ var cliRuleSummarySchema = z29.object({
2652
+ protocolVersion: z29.literal(3),
2653
+ bundleSha256: z29.string(),
2654
+ journalSha256: z29.string().nullable(),
2655
+ journalComplete: z29.boolean(),
2656
+ journalLimited: z29.boolean(),
2657
+ delivery: cliRuleDeliverySchema,
2658
+ appliedInvocations: z29.number(),
2659
+ matchedInvocations: z29.number(),
2660
+ recognizedInvocations: z29.number().optional(),
2661
+ unmatchedInvocations: z29.number().optional(),
2662
+ unsupportedInvocations: z29.number(),
2663
+ retainedExcerptBytes: z29.number(),
2664
+ diagnostics: z29.array(z29.string().max(256)).max(50),
2665
+ observations: z29.array(
2666
+ z29.object({
2667
+ invocationId: z29.string(),
2668
+ ruleId: z29.string().nullable(),
2669
+ reason: z29.string(),
2670
+ entrypointSha256: z29.string().nullable(),
2671
+ launchForm: z29.string().nullable(),
2672
+ ioProfile: z29.string().nullable()
2673
+ })
2674
+ ).max(200).optional()
2675
+ });
2676
+ var cliRuleCoverageSchema = z29.object({
2677
+ invocationCount: z29.number(),
2678
+ observedInvocationCount: z29.number().nullable(),
2679
+ appliedInvocationCount: z29.number(),
2680
+ incompleteCount: z29.number(),
2681
+ unsupportedCount: z29.number(),
2682
+ instrumentationFailed: z29.boolean(),
2683
+ unsupportedDiagnostics: z29.array(z29.string()),
2684
+ v3: cliRuleSummarySchema,
2685
+ invocations: z29.array(cliRuleInvocationResultSchema).default([])
2686
+ });
2687
+
2688
+ // ../packages/api-schemas/src/climb.ts
2689
+ import { z as z32 } from "zod";
2690
+
2691
+ // ../packages/api-schemas/src/cli-rules.ts
2692
+ import { z as z30 } from "zod";
2693
+
2694
+ // ../packages/api-schemas/src/cli-rule-arguments.ts
2695
+ function parseCliRuleArguments(argv, arity) {
2696
+ const value = {
2697
+ positionals: [],
2698
+ options: /* @__PURE__ */ new Map(),
2699
+ endOptions: argv.length
2700
+ };
2701
+ for (let i = 0; i < argv.length; i++) {
2702
+ const token = argv[i];
2703
+ if (token === "--") {
2704
+ value.endOptions = i;
2705
+ value.positionals.push(...argv.slice(i + 1));
2706
+ break;
2707
+ }
2708
+ if (!token.startsWith("-") || token === "-") {
2709
+ value.positionals.push(token);
2710
+ continue;
2711
+ }
2712
+ const equal = token.indexOf("=");
2713
+ const flag2 = equal < 0 ? token : token.slice(0, equal);
2714
+ if (!Object.hasOwn(arity, flag2) || !flag2.startsWith("--") && flag2.length !== 2)
2715
+ return { kind: "ambiguous", reason: "unknown_option" };
2716
+ if (arity[flag2] === 0) {
2717
+ if (equal >= 0) return { kind: "ambiguous", reason: "unexpected_value" };
2718
+ value.options.set(flag2, { index: i, width: 1 });
2719
+ } else if (equal >= 0) {
2720
+ value.options.set(flag2, {
2721
+ index: i,
2722
+ width: 1,
2723
+ value: token.slice(equal + 1)
2717
2724
  });
2718
- const requires = (kind, valid, message2) => {
2719
- if (capabilities2.operations.includes(kind) && !valid)
2720
- ctx.addIssue({
2721
- code: "custom",
2722
- path: ["commands", index, "capabilities", "operations"],
2723
- message: message2
2724
- });
2725
- };
2726
- requires(
2727
- "streamOutput",
2728
- capabilities2.outputModes.includes("streaming"),
2729
- "Streaming output needs a qualified streaming mode"
2730
- );
2731
- requires(
2732
- "completeOutput",
2733
- capabilities2.outputModes.includes("completed"),
2734
- "Completed output needs a qualified completed mode"
2735
- );
2736
- requires(
2737
- "structuredStdin",
2738
- capabilities2.stdinFormats.length > 0,
2739
- "Structured stdin needs a qualified format"
2740
- );
2741
- requires(
2742
- "promptRecipe",
2743
- capabilities2.recipeIds.length > 0,
2744
- "Prompt recipes need qualified prompt IDs"
2745
- );
2746
- requires(
2747
- "generatedFile",
2748
- capabilities2.generatedPaths.length > 0,
2749
- "Generated files need attributed output paths"
2750
- );
2751
- requires(
2752
- "setEnv",
2753
- capabilities2.settings.length > 0,
2754
- "Environment changes need supported settings"
2755
- );
2756
- requires(
2757
- "ensureOption",
2758
- capabilities2.options.length > 0,
2759
- "Arguments need supported options"
2760
- );
2761
- requires(
2762
- "replaceOption",
2763
- capabilities2.options.length > 0,
2764
- "Arguments need supported options"
2765
- );
2766
- }
2767
- });
2768
- var CLI_CATALOG_MAX_TARGETS = 100;
2769
- var cliCatalogSchema = z29.object({
2770
- version: z29.union([z29.literal(1), z29.literal(2)]),
2771
- engineVersion: token,
2772
- digest,
2773
- targets: z29.array(cliTargetSchema).max(CLI_CATALOG_MAX_TARGETS)
2774
- }).strict().superRefine((catalog, ctx) => {
2775
- if (catalog.version === 1 && (!catalog.targets.length || catalog.targets.some((target) => target.discovery)))
2725
+ } else {
2726
+ if (i + 1 === argv.length || argv[i + 1] === "--")
2727
+ return { kind: "ambiguous", reason: "missing_value" };
2728
+ value.options.set(flag2, { index: i, width: 2, value: argv[i + 1] });
2729
+ i++;
2730
+ }
2731
+ }
2732
+ return { kind: "parsed", value };
2733
+ }
2734
+
2735
+ // ../packages/api-schemas/src/cli-rules.ts
2736
+ var CLI_RULE_LIMITS = {
2737
+ bundleBytes: 2 * 1024 * 1024,
2738
+ jsonTokens: 4e4,
2739
+ rules: 50,
2740
+ operations: 50,
2741
+ arguments: 256,
2742
+ argumentBytes: 4095,
2743
+ literalBytes: 8192,
2744
+ bufferBytes: 2 * 1024 * 1024,
2745
+ bufferWaitMs: 5e3,
2746
+ maxBufferWaitMs: 12e4,
2747
+ expansionBytes: 64 * 1024 * 1024,
2748
+ excerptBytes: 4096,
2749
+ attemptExcerptBytes: 256 * 1024,
2750
+ journalBytes: 4 * 1024 * 1024,
2751
+ supervisorTasks: 4096
2752
+ };
2753
+ var encoder = new TextEncoder();
2754
+ var cliUtf8Bytes = (value) => encoder.encode(value).length;
2755
+ var text = (max, nonempty = false) => z30.string().superRefine((value, ctx) => {
2756
+ if (nonempty && !value.length || cliUtf8Bytes(value) > max || /\0|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(
2757
+ value
2758
+ ))
2776
2759
  ctx.addIssue({
2777
2760
  code: "custom",
2778
- message: "Discovery requires catalog version 2"
2761
+ message: `Use valid non-NUL UTF-8 text of at most ${max} bytes${nonempty ? ", not empty" : ""}`
2779
2762
  });
2780
- catalog.targets.forEach((target, index) => {
2781
- if (catalog.targets.findIndex((other) => other.id === target.id) !== index)
2782
- ctx.addIssue({
2783
- code: "custom",
2784
- path: ["targets", index, "id"],
2785
- message: "Duplicate target ID"
2786
- });
2787
- });
2788
2763
  });
2789
- var exitPredicate = z29.discriminatedUnion("kind", [
2790
- z29.object({ kind: z29.literal("any") }).strict(),
2791
- z29.object({
2792
- kind: z29.literal("code"),
2793
- value: z29.number().int().min(0).max(255)
2764
+ var id = z30.string().regex(/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/);
2765
+ var flag = z30.string().regex(/^(?:-[A-Za-z0-9]|--[A-Za-z0-9][A-Za-z0-9-]{0,125})$/);
2766
+ var envKey = z30.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,126}$/);
2767
+ var arg = text(CLI_RULE_LIMITS.argumentBytes);
2768
+ var literal = text(CLI_RULE_LIMITS.literalBytes);
2769
+ var stream = z30.enum(["stdout", "stderr", "combined"]);
2770
+ var exit = z30.discriminatedUnion("kind", [
2771
+ z30.object({ kind: z30.literal("any") }).strict(),
2772
+ z30.object({
2773
+ kind: z30.literal("code"),
2774
+ value: z30.number().int().min(0).max(255)
2794
2775
  }).strict()
2795
2776
  ]);
2796
- var outputStream = z29.enum(["stdout", "stderr", "combined"]);
2797
- var literalEdit = z29.object({ find: z29.string().min(1).max(8192), replace: z29.string().max(8192) }).strict();
2798
- function boundedOutputPattern(pattern) {
2777
+ var buffer = {
2778
+ maxBufferBytes: z30.number().int().min(1).max(CLI_RULE_LIMITS.bufferBytes).default(CLI_RULE_LIMITS.bufferBytes),
2779
+ maxWaitMs: z30.number().int().min(1).max(CLI_RULE_LIMITS.maxBufferWaitMs).default(CLI_RULE_LIMITS.bufferWaitMs)
2780
+ };
2781
+ var source = (value) => z30.discriminatedUnion("source", [
2782
+ z30.object({ source: z30.literal("literal"), value }).strict(),
2783
+ z30.object({ source: z30.literal("localFact"), key: envKey }).strict()
2784
+ ]);
2785
+ function cliBoundedPattern(pattern) {
2799
2786
  let at = pattern.startsWith("^") ? 1 : 0;
2800
2787
  const end = pattern.endsWith("$") && pattern.length > at ? pattern.length - 1 : pattern.length;
2801
2788
  let stars = 0;
2802
- let literalBytes = 0;
2789
+ let literals = 0;
2803
2790
  while (at < end) {
2804
2791
  const char = pattern[at];
2805
2792
  if (char === "\\") {
2806
2793
  if (++at >= end || !"\\.^$*+?[]{}()|".includes(pattern[at])) return false;
2807
- literalBytes++;
2794
+ literals++;
2808
2795
  } else if (char === "." && pattern[at + 1] === "*") {
2809
2796
  if (++stars > 1) return false;
2810
2797
  at++;
2811
- } else if (".^$*+?[]{}()|\n\r".includes(char)) {
2812
- return false;
2813
- } else {
2814
- literalBytes++;
2815
- }
2798
+ } else if (".^$*+?[]{}()|\n\r".includes(char)) return false;
2799
+ else literals++;
2816
2800
  at++;
2817
2801
  }
2818
- return literalBytes > 0;
2802
+ return literals > 0;
2819
2803
  }
2820
- var operationSchema = z29.discriminatedUnion("kind", [
2821
- z29.object({
2822
- kind: z29.literal("ensureOption"),
2823
- option: optionFlag,
2824
- value: sourcedValue.optional()
2804
+ var cliRuleTargetSchema = z30.discriminatedUnion("kind", [
2805
+ z30.object({
2806
+ kind: z30.literal("npmBin"),
2807
+ packageName: z30.string().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/),
2808
+ program: z30.string().max(128).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/)
2825
2809
  }).strict(),
2826
- z29.object({
2827
- kind: z29.literal("replaceOption"),
2828
- option: optionFlag,
2829
- value: sourcedValue
2810
+ z30.object({
2811
+ kind: z30.literal("path"),
2812
+ path: text(1024, true).refine(
2813
+ (value) => !value.includes("\\") && !value.split("/").includes(".."),
2814
+ "Use a sandbox path without traversal"
2815
+ )
2816
+ }).strict()
2817
+ ]);
2818
+ var cliRuleSelectorSchema = z30.discriminatedUnion("kind", [
2819
+ z30.object({
2820
+ kind: z30.literal("exact"),
2821
+ argv: z30.array(arg).max(CLI_RULE_LIMITS.arguments - 1)
2830
2822
  }).strict(),
2831
- z29.object({
2832
- kind: z29.literal("setEnv"),
2833
- key: envKey,
2834
- value: sourcedValue,
2835
- whenAbsent: z29.boolean()
2823
+ z30.object({
2824
+ kind: z30.literal("command"),
2825
+ positionals: z30.object({
2826
+ mode: z30.enum(["exact", "prefix"]),
2827
+ tokens: z30.array(arg).max(CLI_RULE_LIMITS.arguments - 1)
2828
+ }).strict(),
2829
+ optionsPresent: z30.array(flag).max(100).default([]),
2830
+ optionsAbsent: z30.array(flag).max(100).default([]),
2831
+ optionValues: z30.record(flag, arg).default({})
2832
+ }).strict()
2833
+ ]);
2834
+ var cliRuleOperationSchema = z30.discriminatedUnion("kind", [
2835
+ z30.object({
2836
+ id,
2837
+ kind: z30.literal("replaceOutput"),
2838
+ stream,
2839
+ exit,
2840
+ replacement: literal,
2841
+ ...buffer
2836
2842
  }).strict(),
2837
- z29.object({
2838
- kind: z29.literal("streamOutput"),
2839
- stream: outputStream,
2840
- edit: literalEdit
2843
+ z30.object({
2844
+ id,
2845
+ kind: z30.literal("streamOutput"),
2846
+ stream,
2847
+ edit: z30.object({ find: text(8192, true), replace: literal }).strict()
2841
2848
  }).strict(),
2842
- z29.object({
2843
- kind: z29.literal("completeOutput"),
2844
- stream: outputStream,
2845
- matcher: z29.discriminatedUnion("kind", [
2846
- z29.object({
2847
- kind: z29.literal("literal"),
2848
- text: z29.string().min(1).max(8192)
2849
- }).strict(),
2850
- z29.object({
2851
- kind: z29.literal("re2"),
2852
- pattern: z29.string().min(1).max(2048).refine(
2853
- boundedOutputPattern,
2854
- "Use literals, anchors, and at most one greedy .*; escape literal regex punctuation"
2849
+ z30.object({
2850
+ id,
2851
+ kind: z30.literal("completeOutput"),
2852
+ stream,
2853
+ exit,
2854
+ replace: literal,
2855
+ ...buffer,
2856
+ matcher: z30.discriminatedUnion("kind", [
2857
+ z30.object({ kind: z30.literal("literal"), text: text(8192, true) }).strict(),
2858
+ z30.object({
2859
+ kind: z30.literal("re2"),
2860
+ pattern: text(2048, true).refine(
2861
+ cliBoundedPattern,
2862
+ "Use literals, optional anchors, and at most one greedy .*"
2855
2863
  )
2856
2864
  }).strict()
2857
- ]),
2858
- replace: z29.string().max(8192),
2859
- exit: exitPredicate
2865
+ ])
2860
2866
  }).strict(),
2861
- z29.object({
2862
- kind: z29.literal("structuredStdin"),
2863
- format: z29.enum(["text", "json", "jsonl"]),
2864
- payload: sourcedValue,
2865
- timing: z29.literal("onLaunch"),
2866
- callerInput: z29.literal("replace"),
2867
- eof: z29.literal("close")
2867
+ z30.object({
2868
+ id,
2869
+ kind: z30.literal("ensureOption"),
2870
+ option: flag,
2871
+ value: source(arg).optional()
2868
2872
  }).strict(),
2869
- z29.object({
2870
- kind: z29.literal("promptRecipe"),
2871
- recipeId: token,
2872
- steps: z29.array(
2873
- z29.object({
2874
- prompt: z29.string().min(1).max(4096),
2875
- response: sourcedValue,
2876
- timeoutMs: z29.number().int().min(1).max(12e4)
2877
- }).strict()
2878
- ).min(1).max(20),
2879
- overallTimeoutMs: z29.number().int().min(1).max(6e5),
2880
- completion: z29.string().min(1).max(4096)
2873
+ z30.object({
2874
+ id,
2875
+ kind: z30.literal("replaceOption"),
2876
+ option: flag,
2877
+ value: source(arg)
2881
2878
  }).strict(),
2882
- z29.object({
2883
- kind: z29.literal("generatedFile"),
2884
- path: relativePath,
2885
- beforeSha256: digest.nullable(),
2886
- generatedSha256: digest,
2887
- outcome: exitPredicate,
2888
- edit: literalEdit,
2889
- required: z29.boolean()
2879
+ z30.object({
2880
+ id,
2881
+ kind: z30.literal("setEnv"),
2882
+ key: envKey,
2883
+ value: source(arg),
2884
+ whenAbsent: z30.boolean()
2885
+ }).strict(),
2886
+ z30.object({
2887
+ id,
2888
+ kind: z30.literal("structuredStdin"),
2889
+ format: z30.enum(["text", "json", "jsonl"]),
2890
+ payload: source(literal),
2891
+ timing: z30.literal("onLaunch"),
2892
+ callerInput: z30.literal("replace"),
2893
+ eof: z30.literal("close")
2890
2894
  }).strict()
2891
2895
  ]);
2892
- var cliBaselineRecordFileSchema = z29.object({
2893
- pathIndex: z29.number().int().nonnegative().max(49),
2894
- path: relativePath,
2895
- status: z29.enum(["generated", "not-exercised"]),
2896
- beforeSha256: digest.nullable(),
2897
- generatedSha256: digest.nullable()
2898
- }).strict();
2899
- var baselineInvocationSchema = z29.object({
2900
- runId: token,
2901
- invocationId: token,
2902
- targetId: token,
2903
- commandId: token,
2904
- artifactSha256: digest.nullable(),
2905
- entrypointSha256: digest,
2906
- engineSha256: digest.optional(),
2907
- runtimeSha256: digest.optional(),
2908
- launchForm: cliLaunchFormSchema,
2909
- ioProfile: cliIoProfileSchema,
2910
- recordFiles: z29.array(cliBaselineRecordFileSchema).max(50).default([])
2911
- }).strict();
2912
- var cliInterventionSchema = z29.object({
2913
- schemaVersion: z29.union([z29.literal(1), z29.literal(2)]),
2914
- identityPolicy: z29.literal("artifact").optional(),
2915
- engineVersion: token,
2916
- engineSha256: digest.nullable(),
2917
- bundleSha256: digest,
2918
- catalog: cliCatalogSchema,
2919
- mode: z29.enum(["record", "trial"]),
2920
- captureProfiles: z29.array(cliIoProfileSchema).min(1),
2921
- activeTargetId: token.nullable(),
2922
- activeCommandId: token.nullable(),
2923
- selector: z29.object({
2924
- optionPresent: z29.array(optionFlag).max(20),
2925
- optionAbsent: z29.array(optionFlag).max(20)
2926
- }).strict().nullable(),
2927
- baselineInvocations: z29.array(baselineInvocationSchema).max(500),
2928
- operations: z29.array(operationSchema).max(50),
2929
- limits: z29.object({
2930
- completedStreamBytes: z29.number().int().min(1).max(2 * 1024 * 1024),
2931
- replacementBytes: z29.number().int().min(1).max(8192),
2932
- generatedFileBytes: z29.number().int().min(1).max(2 * 1024 * 1024),
2933
- generatedAggregateBytes: z29.number().int().min(1).max(8 * 1024 * 1024),
2934
- generatedFileCount: z29.number().int().min(1).max(50)
2935
- }).strict(),
2936
- shippingIntent: z29.enum([
2937
- "default",
2938
- "message",
2939
- "interaction",
2940
- "invocation-guidance",
2941
- "template"
2942
- ]).nullable()
2943
- }).strict().superRefine((bundle, ctx) => {
2896
+ function cliStructuredInputValid(format, payload) {
2897
+ if (format === "text") return true;
2898
+ const records = format === "json" ? [payload] : payload.replace(/\r?\n$/, "").split("\n");
2899
+ try {
2900
+ return records.every((record2) => {
2901
+ if (!record2.trim()) return false;
2902
+ JSON.parse(record2);
2903
+ return true;
2904
+ });
2905
+ } catch {
2906
+ return false;
2907
+ }
2908
+ }
2909
+ var cliRuleSchema = z30.object({
2910
+ id,
2911
+ selector: cliRuleSelectorSchema,
2912
+ optionArity: z30.record(flag, z30.union([z30.literal(0), z30.literal(1)])).default({}),
2913
+ operations: z30.array(cliRuleOperationSchema).min(1).max(CLI_RULE_LIMITS.operations)
2914
+ }).strict().superRefine((rule, ctx) => {
2944
2915
  const fail = (path3, message2) => ctx.addIssue({ code: "custom", path: path3, message: message2 });
2945
- if (bundle.schemaVersion !== bundle.catalog.version)
2946
- fail(["schemaVersion"], "Bundle and catalog schema versions differ");
2947
- if (bundle.identityPolicy && bundle.schemaVersion !== 2)
2948
- fail(["identityPolicy"], "Artifact identity requires schema version 2");
2949
- if (bundle.identityPolicy && bundle.baselineInvocations.some((row2) => !row2.runtimeSha256))
2950
- fail(
2951
- ["baselineInvocations"],
2952
- "Artifact identity requires the recorded runtime bytes"
2953
- );
2954
- if (!bundle.engineSha256 && (bundle.schemaVersion === 1 || bundle.mode !== "record"))
2955
- fail(["engineSha256"], "A trial must pin the recorded engine bytes");
2956
- if (!bundle.catalog.targets.length)
2957
- fail(["catalog"], "A run needs at least one CLI target");
2958
- if (bundle.schemaVersion === 2 && bundle.mode === "trial" && bundle.baselineInvocations.some(
2959
- (item) => item.engineSha256 !== bundle.engineSha256
2960
- ))
2961
- fail(
2962
- ["baselineInvocations"],
2963
- "Baseline invocations must share the pinned engine"
2964
- );
2965
- bundle.baselineInvocations.forEach((invocation, index) => {
2966
- const command2 = bundle.catalog.targets.find((target2) => target2.id === invocation.targetId)?.commands.find((item) => item.id === invocation.commandId);
2967
- for (const [fileIndex, file] of invocation.recordFiles.entries()) {
2968
- if (command2?.capabilities.generatedPaths[file.pathIndex] !== file.path || file.status === "generated" && !file.generatedSha256 || file.status === "not-exercised" && file.generatedSha256 !== file.beforeSha256)
2969
- fail(
2970
- ["baselineInvocations", index, "recordFiles", fileIndex],
2971
- "Recorded file does not match the qualified command"
2972
- );
2973
- }
2974
- });
2975
- if (bundle.engineVersion !== bundle.catalog.engineVersion)
2976
- fail(["engineVersion"], "Engine and catalog versions differ");
2977
- if (bundle.mode === "record") {
2978
- if (bundle.activeTargetId || bundle.activeCommandId || bundle.selector || bundle.operations.length || bundle.shippingIntent)
2979
- fail(["mode"], "Record mode cannot select or modify a command");
2980
- return;
2916
+ if (Object.keys(rule.optionArity).length > 100)
2917
+ fail(["optionArity"], "At most 100 option arities per rule");
2918
+ const arity = (key2, expected) => Object.hasOwn(rule.optionArity, key2) && (expected === void 0 || rule.optionArity[key2] === expected);
2919
+ if (rule.selector.kind === "command") {
2920
+ const selector = rule.selector;
2921
+ for (const [field, flags] of [
2922
+ ["optionsPresent", selector.optionsPresent],
2923
+ ["optionsAbsent", selector.optionsAbsent],
2924
+ ["optionValues", Object.keys(selector.optionValues)]
2925
+ ]) {
2926
+ if (new Set(flags).size !== flags.length)
2927
+ fail(["selector", field], "Duplicate option predicate");
2928
+ for (const key2 of flags)
2929
+ if (!arity(key2, field === "optionValues" ? 1 : void 0))
2930
+ fail(["selector", field], `Declare ${key2}'s option arity`);
2931
+ }
2932
+ if (selector.optionsAbsent.some(
2933
+ (key2) => selector.optionsPresent.includes(key2) || Object.hasOwn(selector.optionValues, key2)
2934
+ ))
2935
+ fail(["selector"], "An absent option cannot also be required");
2981
2936
  }
2982
- const target = bundle.catalog.targets.find(
2983
- (item) => item.id === bundle.activeTargetId
2984
- );
2985
- const command = target?.commands.find(
2986
- (item) => item.id === bundle.activeCommandId
2987
- );
2988
- if (!target || !command) {
2989
- fail(
2990
- ["activeCommandId"],
2991
- "Select a qualified command in the frozen catalog"
2937
+ if (rule.selector.kind === "exact" && rule.operations.some(
2938
+ (op) => op.kind === "ensureOption" || op.kind === "replaceOption"
2939
+ )) {
2940
+ const parsed = parseCliRuleArguments(
2941
+ rule.selector.argv,
2942
+ rule.optionArity
2992
2943
  );
2993
- return;
2994
- }
2995
- if (!bundle.selector) fail(["selector"], "A trial needs token predicates");
2996
- else {
2997
- for (const flag of [
2998
- ...bundle.selector.optionPresent,
2999
- ...bundle.selector.optionAbsent
3000
- ])
3001
- if (!command.capabilities.options.some((option) => option.flag === flag))
3002
- fail(["selector"], `Unsupported selector option: ${flag}`);
3003
- if (bundle.selector.optionPresent.some(
3004
- (flag) => bundle.selector?.optionAbsent.includes(flag)
3005
- ))
2944
+ if (parsed.kind === "ambiguous")
3006
2945
  fail(
3007
- ["selector"],
3008
- "A selector cannot require and forbid the same option"
2946
+ ["optionArity"],
2947
+ `Exact rules with argument edits must parse their argv (${parsed.reason}); declare each option's arity and supply its required value`
3009
2948
  );
3010
2949
  }
3011
- if (!bundle.shippingIntent || !bundle.operations.length)
3012
- fail(
3013
- ["operations"],
3014
- "A trial needs a shipping intent and at least one operation"
3015
- );
3016
- if (bundle.operations.some((item) => item.kind === "promptRecipe") && bundle.operations.some((item) => item.kind === "completeOutput"))
3017
- fail(
3018
- ["operations"],
3019
- "Completed-output buffering cannot block an interactive prompt"
3020
- );
3021
- if (bundle.captureProfiles.includes("pty")) {
3022
- for (const [index, operation] of bundle.operations.entries()) {
3023
- if (operation.kind === "structuredStdin")
2950
+ const ids = /* @__PURE__ */ new Set();
2951
+ const outputs = /* @__PURE__ */ new Map();
2952
+ let stdin = false;
2953
+ for (const [index, op] of rule.operations.entries()) {
2954
+ const path3 = ["operations", index];
2955
+ if (ids.has(op.id))
2956
+ fail([...path3, "id"], "Duplicate operation ID within rule");
2957
+ ids.add(op.id);
2958
+ if (op.kind === "ensureOption" || op.kind === "replaceOption") {
2959
+ if (!arity(op.option, op.value === void 0 ? 0 : 1))
3024
2960
  fail(
3025
- ["operations", index],
3026
- "PTY structured stdin cannot prove the declared EOF; use a prompt recipe"
2961
+ path3,
2962
+ "Argument operation value must agree with declared option arity"
3027
2963
  );
3028
- if ((operation.kind === "streamOutput" || operation.kind === "completeOutput") && operation.stream !== "combined")
3029
- fail(["operations", index], "PTY output combines stdout and stderr");
3030
- }
3031
- }
3032
- if (bundle.operations.some((item) => item.kind === "promptRecipe") && bundle.operations.some((item) => item.kind === "structuredStdin"))
3033
- fail(
3034
- ["operations"],
3035
- "A prompt recipe and structured stdin cannot both control the same input stream"
3036
- );
3037
- if (bundle.operations.some(
3038
- (item) => (item.kind === "streamOutput" || item.kind === "completeOutput") && item.stream === "combined"
3039
- ) && !bundle.baselineInvocations.some(
3040
- (item) => item.targetId === target.id && item.commandId === command.id && item.artifactSha256 === target.artifactSha256 && (target.discovery !== void 0 || item.entrypointSha256 === target.entrypointSha256) && target.launchForms.includes(item.launchForm) && (item.ioProfile === "shared-descriptor" || item.ioProfile === "pty") && target.ioProfiles.includes(item.ioProfile) && bundle.captureProfiles.includes(item.ioProfile)
3041
- ))
3042
- fail(
3043
- ["operations"],
3044
- "Combined output requires a shared-descriptor or PTY baseline profile"
3045
- );
3046
- if (!bundle.baselineInvocations.some(
3047
- (item) => item.targetId === target.id && item.commandId === command.id && item.artifactSha256 === target.artifactSha256 && (target.discovery !== void 0 || item.entrypointSha256 === target.entrypointSha256) && target.launchForms.includes(item.launchForm) && target.ioProfiles.includes(item.ioProfile) && bundle.captureProfiles.includes(item.ioProfile)
3048
- ))
3049
- fail(
3050
- ["baselineInvocations"],
3051
- "No baseline invocation matches this exact command, artifact, launch form, and I/O profile"
3052
- );
3053
- const seen = /* @__PURE__ */ new Set();
3054
- const changedEnvironment = new Set(
3055
- bundle.operations.flatMap(
3056
- (item) => item.kind === "setEnv" ? [item.key] : []
3057
- )
3058
- );
3059
- bundle.operations.forEach((operation, index) => {
3060
- const path3 = ["operations", index];
3061
- if (!command.capabilities.operations.includes(operation.kind))
3062
- fail(path3, `${operation.kind} is not qualified for this command`);
3063
- if ("option" in operation && !command.capabilities.options.some(
3064
- (option) => option.flag === operation.option
3065
- ))
3066
- fail(path3, "Option is not supported by this version");
3067
- if (operation.kind === "ensureOption" || operation.kind === "replaceOption") {
3068
- const option = command.capabilities.options.find(
3069
- (item) => item.flag === operation.option
3070
- );
3071
- if (option && option.takesValue !== (operation.value !== void 0))
3072
- fail(path3, "Option value does not match its qualified arity");
3073
- }
3074
- if (operation.kind === "setEnv" && !command.capabilities.settings.includes(operation.key))
3075
- fail(path3, "Environment setting is not supported by this version");
3076
- if (operation.kind === "structuredStdin" && !command.capabilities.stdinFormats.includes(operation.format))
3077
- fail(path3, "Stdin format is not qualified");
3078
- if (operation.kind === "structuredStdin" && operation.payload.source === "literal" && operation.format !== "text") {
3079
- const records = operation.format === "json" ? [operation.payload.value] : operation.payload.value.trimEnd().split("\n");
3080
- try {
3081
- if (records.some((record2) => !record2.trim()))
3082
- throw new Error("Empty structured stdin record");
3083
- for (const record2 of records) JSON.parse(record2);
3084
- } catch {
2964
+ } else if (op.kind === "structuredStdin") {
2965
+ if (stdin) fail(path3, "Only one structured stdin operation per rule");
2966
+ stdin = true;
2967
+ if (op.payload.source === "literal" && !cliStructuredInputValid(op.format, op.payload.value))
2968
+ fail(path3, "Payload does not match its declared JSON/JSONL format");
2969
+ } else if ("stream" in op) {
2970
+ const previous = outputs.get(op.stream);
2971
+ if (previous && (previous.kind !== op.kind || op.kind === "replaceOutput"))
3085
2972
  fail(
3086
2973
  path3,
3087
- "Structured stdin payload does not match its declared JSON format"
2974
+ "Use one whole replacement or a chain of one output kind per stream"
3088
2975
  );
3089
- }
2976
+ if (previous && op.kind === "completeOutput" && (previous.bytes !== op.maxBufferBytes || previous.wait !== op.maxWaitMs))
2977
+ fail(
2978
+ path3,
2979
+ "Completed operations on one stream must share buffer bounds"
2980
+ );
2981
+ outputs.set(op.stream, {
2982
+ kind: op.kind,
2983
+ ..."maxBufferBytes" in op ? { bytes: op.maxBufferBytes, wait: op.maxWaitMs } : {}
2984
+ });
3090
2985
  }
3091
- if (operation.kind === "promptRecipe" && !command.capabilities.recipeIds.includes(operation.recipeId))
3092
- fail(path3, "Prompt recipe is not qualified");
3093
- if (operation.kind === "generatedFile" && !command.capabilities.generatedPaths.includes(operation.path))
3094
- fail(path3, "Output path is not attributed to this command");
3095
- if (operation.kind === "generatedFile" && !bundle.baselineInvocations.some(
3096
- (invocation) => invocation.targetId === target.id && invocation.commandId === command.id && invocation.recordFiles.some(
3097
- (file) => file.path === operation.path && file.status === "generated" && file.beforeSha256 === operation.beforeSha256 && file.generatedSha256 === operation.generatedSha256
3098
- )
3099
- ))
3100
- fail(
3101
- path3,
3102
- "No attributed baseline file matches the preimage and real generated bytes"
3103
- );
3104
- if (operation.kind === "streamOutput" && !command.capabilities.outputModes.includes("streaming"))
3105
- fail(path3, "Streaming output is not qualified");
3106
- if (operation.kind === "completeOutput" && !command.capabilities.outputModes.includes("completed"))
3107
- fail(path3, "Completed output is not qualified");
3108
- if (operation.kind === "streamOutput" && operation.edit.find === operation.edit.replace || operation.kind === "generatedFile" && operation.edit.find === operation.edit.replace || operation.kind === "completeOutput" && operation.matcher.kind === "literal" && operation.matcher.text === operation.replace)
3109
- fail(path3, "A trial operation must change the matched content");
3110
- const sources = [
3111
- "value" in operation ? operation.value : null,
3112
- operation.kind === "structuredStdin" ? operation.payload : null,
3113
- ...operation.kind === "promptRecipe" ? operation.steps.map((step) => step.response) : []
3114
- ];
3115
- if (sources.some(
3116
- (source) => source?.source === "localFact" && !command.capabilities.localFacts.includes(source.key)
3117
- ))
3118
- fail(path3, "Local fact is not declared non-secret for this command");
3119
- if (sources.some(
3120
- (source) => source?.source === "localFact" && changedEnvironment.has(source.key)
3121
- ))
3122
- fail(
3123
- path3,
3124
- "A local fact cannot be changed by another operation in the same trial"
3125
- );
3126
- const conflict = operation.kind === "ensureOption" || operation.kind === "replaceOption" ? `option:${operation.option}` : operation.kind === "setEnv" ? `env:${operation.key}` : operation.kind === "structuredStdin" ? "stdin" : operation.kind === "promptRecipe" ? `prompt:${operation.recipeId}` : operation.kind === "generatedFile" ? `file:${operation.path}` : null;
3127
- if (conflict && seen.has(conflict))
3128
- fail(path3, "Conflicting operation on the same input or output");
3129
- if (conflict) seen.add(conflict);
3130
- });
3131
- if (bundle.operations.filter((item) => item.kind === "generatedFile").length > bundle.limits.generatedFileCount)
2986
+ }
2987
+ if (outputs.has("combined") && outputs.size > 1)
3132
2988
  fail(
3133
- ["limits", "generatedFileCount"],
3134
- "Generated file count exceeds limit"
2989
+ ["operations"],
2990
+ "Combined output cannot be mixed with separate-stream output"
3135
2991
  );
3136
2992
  });
3137
- var cliTrialChangeSchema = z29.object({
3138
- targetId: token,
3139
- commandId: token,
3140
- selector: cliInterventionSchema.shape.selector.unwrap(),
3141
- operations: cliInterventionSchema.shape.operations.min(1),
3142
- shippingIntent: cliInterventionSchema.shape.shippingIntent.unwrap()
3143
- }).strict();
3144
-
3145
- // ../packages/api-schemas/src/climb.ts
3146
- import { z as z31 } from "zod";
2993
+ var body = {
2994
+ schemaVersion: z30.literal(3),
2995
+ target: cliRuleTargetSchema,
2996
+ rules: z30.array(cliRuleSchema).min(1).max(CLI_RULE_LIMITS.rules),
2997
+ shippingIntent: z30.enum([
2998
+ "default",
2999
+ "message",
3000
+ "interaction",
3001
+ "invocation-guidance",
3002
+ "template"
3003
+ ])
3004
+ };
3005
+ function jsonTokenCount(value) {
3006
+ if (Array.isArray(value))
3007
+ return 1 + value.reduce((sum, item) => sum + jsonTokenCount(item), 0);
3008
+ if (value && typeof value === "object")
3009
+ return 1 + Object.values(value).reduce(
3010
+ (sum, item) => sum + 1 + jsonTokenCount(item),
3011
+ 0
3012
+ );
3013
+ return 1;
3014
+ }
3015
+ function validateBundle(value, ctx) {
3016
+ if (new Set(value.rules.map((rule) => rule.id)).size !== value.rules.length)
3017
+ ctx.addIssue({
3018
+ code: "custom",
3019
+ path: ["rules"],
3020
+ message: "Duplicate rule ID"
3021
+ });
3022
+ if (value.rules.reduce((count, rule) => count + rule.operations.length, 0) > CLI_RULE_LIMITS.operations)
3023
+ ctx.addIssue({
3024
+ code: "custom",
3025
+ path: ["rules"],
3026
+ message: "At most 50 operations across the bundle"
3027
+ });
3028
+ if (cliUtf8Bytes(JSON.stringify(value)) > CLI_RULE_LIMITS.bundleBytes)
3029
+ ctx.addIssue({ code: "custom", message: "CLI bundle exceeds 2 MiB" });
3030
+ if (jsonTokenCount(value) > CLI_RULE_LIMITS.jsonTokens)
3031
+ ctx.addIssue({
3032
+ code: "custom",
3033
+ message: "CLI bundle exceeds the native JSON token bound"
3034
+ });
3035
+ }
3036
+ var cliRuleAuthorInputSchema = z30.object(body).strict().superRefine(validateBundle);
3037
+ var normalizedLimits = z30.object({
3038
+ expansionBytes: z30.literal(CLI_RULE_LIMITS.expansionBytes),
3039
+ excerptBytes: z30.literal(CLI_RULE_LIMITS.excerptBytes),
3040
+ attemptExcerptBytes: z30.literal(CLI_RULE_LIMITS.attemptExcerptBytes),
3041
+ journalBytes: z30.literal(CLI_RULE_LIMITS.journalBytes),
3042
+ supervisorTasks: z30.literal(CLI_RULE_LIMITS.supervisorTasks)
3043
+ }).strict().default({
3044
+ expansionBytes: CLI_RULE_LIMITS.expansionBytes,
3045
+ excerptBytes: CLI_RULE_LIMITS.excerptBytes,
3046
+ attemptExcerptBytes: CLI_RULE_LIMITS.attemptExcerptBytes,
3047
+ journalBytes: CLI_RULE_LIMITS.journalBytes,
3048
+ supervisorTasks: CLI_RULE_LIMITS.supervisorTasks
3049
+ });
3050
+ var cliRuleBundleSchema = z30.object({
3051
+ ...body,
3052
+ limits: normalizedLimits,
3053
+ bundleSha256: z30.string().regex(/^[a-f0-9]{64}$/)
3054
+ }).strict().superRefine(validateBundle);
3147
3055
 
3148
3056
  // ../packages/api-schemas/src/climb-kinds.ts
3149
3057
  var LEVER_KINDS = [
@@ -3173,35 +3081,35 @@ var LEVER_INTERVENTIONS = {
3173
3081
  };
3174
3082
 
3175
3083
  // ../packages/api-schemas/src/sandbox-overrides.ts
3176
- import { z as z30 } from "zod";
3084
+ import { z as z31 } from "zod";
3177
3085
  var SANDBOX_OVERRIDE_KINDS = ["packages", "clis"];
3178
- var ecosystemSchema = z30.enum(["npm", "pypi", "cargo", "go", "gem"]);
3179
- var overrideFilesSchema = z30.array(
3180
- z30.object({
3181
- path: z30.string().min(1).refine(
3086
+ var ecosystemSchema = z31.enum(["npm", "pypi", "cargo", "go", "gem"]);
3087
+ var overrideFilesSchema = z31.array(
3088
+ z31.object({
3089
+ path: z31.string().min(1).refine(
3182
3090
  (path3) => !path3.startsWith("/") && !path3.includes("\\") && !path3.split("/").includes(".."),
3183
3091
  "Use a relative path within the target"
3184
3092
  ),
3185
- body: z30.string()
3093
+ body: z31.string()
3186
3094
  }).strict()
3187
3095
  ).min(1);
3188
3096
  var contentShape = {
3189
- version: z30.string().trim().min(1).optional(),
3097
+ version: z31.string().trim().min(1).optional(),
3190
3098
  files: overrideFilesSchema.optional()
3191
3099
  };
3192
3100
  var hasContent = (value) => value.version !== void 0 || value.files !== void 0;
3193
- var sandboxOverridesSchema = z30.object({
3194
- version: z30.literal(1),
3195
- packages: z30.array(
3196
- z30.object({
3101
+ var sandboxOverridesSchema = z31.object({
3102
+ version: z31.literal(1),
3103
+ packages: z31.array(
3104
+ z31.object({
3197
3105
  ecosystem: ecosystemSchema,
3198
- name: z30.string().trim().min(1),
3106
+ name: z31.string().trim().min(1),
3199
3107
  ...contentShape
3200
3108
  }).strict().refine(hasContent, "Specify a version or files")
3201
3109
  ).optional(),
3202
- clis: z30.array(
3203
- z30.object({
3204
- name: z30.string().trim().min(1),
3110
+ clis: z31.array(
3111
+ z31.object({
3112
+ name: z31.string().trim().min(1),
3205
3113
  ...contentShape
3206
3114
  }).strict().refine(hasContent, "Specify a version or files")
3207
3115
  ).optional()
@@ -3228,11 +3136,11 @@ var sandboxOverridesSchema = z30.object({
3228
3136
  });
3229
3137
 
3230
3138
  // ../packages/api-schemas/src/climb.ts
3231
- var climbSubjectKindSchema = z31.enum(["EVAL_SET", "VISIBILITY_PROMPT"]);
3232
- var leverKindSchema = z31.enum(LEVER_KINDS);
3233
- var interventionKindSchema = z31.enum(INTERVENTION_KINDS);
3234
- var skill = z31.object({ skillVersionId: z31.string().min(1) }).strict();
3235
- var empty = z31.object({}).strict();
3139
+ var climbSubjectKindSchema = z32.enum(["EVAL_SET", "VISIBILITY_PROMPT"]);
3140
+ var leverKindSchema = z32.enum(LEVER_KINDS);
3141
+ var interventionKindSchema = z32.enum(INTERVENTION_KINDS);
3142
+ var skill = z32.object({ skillVersionId: z32.string().min(1) }).strict();
3143
+ var empty = z32.object({}).strict();
3236
3144
  function validateFixtureIntervention(value, ctx) {
3237
3145
  const result = webFixtureSchema.safeParse({ version: 1, ...value });
3238
3146
  if (!result.success) {
@@ -3245,75 +3153,73 @@ function validateFixtureIntervention(value, ctx) {
3245
3153
  }
3246
3154
  }
3247
3155
  }
3248
- var interventionSchema = z31.discriminatedUnion("kind", [
3249
- z31.object({ kind: z31.literal("BASELINE"), after: empty }),
3250
- z31.object({ kind: z31.literal("ADD_SKILL"), after: skill }),
3251
- z31.object({ kind: z31.literal("REMOVE_SKILL"), before: skill, after: empty }),
3252
- z31.object({ kind: z31.literal("EDIT_SKILL"), before: skill, after: skill }),
3253
- z31.object({
3254
- kind: z31.literal("REWRITE_DOCS"),
3255
- before: z31.json().optional(),
3256
- after: z31.object({ pages: webFixtureSchema.shape.pages.unwrap().min(1) }).strict().superRefine(validateFixtureIntervention)
3156
+ var interventionSchema = z32.discriminatedUnion("kind", [
3157
+ z32.object({ kind: z32.literal("BASELINE"), after: empty }),
3158
+ z32.object({ kind: z32.literal("ADD_SKILL"), after: skill }),
3159
+ z32.object({ kind: z32.literal("REMOVE_SKILL"), before: skill, after: empty }),
3160
+ z32.object({ kind: z32.literal("EDIT_SKILL"), before: skill, after: skill }),
3161
+ z32.object({
3162
+ kind: z32.literal("REWRITE_DOCS"),
3163
+ before: z32.json().optional(),
3164
+ after: z32.object({ pages: webFixtureSchema.shape.pages.unwrap().min(1) }).strict().superRefine(validateFixtureIntervention)
3257
3165
  }),
3258
- z31.object({
3259
- kind: z31.literal("PACKAGE_VERSION"),
3260
- after: z31.object({
3166
+ z32.object({
3167
+ kind: z32.literal("PACKAGE_VERSION"),
3168
+ after: z32.object({
3261
3169
  ecosystem: ecosystemSchema,
3262
- name: z31.string().min(1),
3263
- version: z31.string().min(1)
3170
+ name: z32.string().min(1),
3171
+ version: z32.string().min(1)
3264
3172
  }).strict()
3265
3173
  }),
3266
- z31.object({
3267
- kind: z31.literal("PACKAGE_CONTENT"),
3268
- after: z31.object({
3174
+ z32.object({
3175
+ kind: z32.literal("PACKAGE_CONTENT"),
3176
+ after: z32.object({
3269
3177
  ecosystem: ecosystemSchema,
3270
- name: z31.string().min(1),
3178
+ name: z32.string().min(1),
3271
3179
  files: overrideFilesSchema
3272
3180
  }).strict()
3273
3181
  }),
3274
- z31.object({
3275
- kind: z31.literal("CLI_VERSION"),
3276
- after: z31.object({ name: z31.string().min(1), version: z31.string().min(1) }).strict()
3182
+ z32.object({
3183
+ kind: z32.literal("CLI_VERSION"),
3184
+ after: z32.object({ name: z32.string().min(1), version: z32.string().min(1) }).strict()
3277
3185
  }),
3278
- z31.object({
3279
- kind: z31.literal("CLI_INTERVENTION"),
3280
- after: cliInterventionSchema.refine((bundle) => bundle.mode === "trial", {
3281
- message: "A CLI trial requires a trial-mode bundle"
3282
- })
3186
+ z32.object({
3187
+ kind: z32.literal("CLI_INTERVENTION"),
3188
+ after: cliRuleBundleSchema
3283
3189
  })
3284
3190
  ]);
3285
- var climbSettingsSchema = z31.object({
3286
- maxRounds: z31.number().int().positive().default(5),
3287
- sampleCount: z31.number().int().positive().default(1),
3288
- creditCap: z31.number().int().nonnegative(),
3289
- targetScore: z31.number().min(0).max(1).default(1),
3191
+ var climbSettingsSchema = z32.object({
3192
+ maxRounds: z32.number().int().positive().default(5),
3193
+ sampleCount: z32.number().int().positive().default(1),
3194
+ creditCap: z32.number().int().nonnegative(),
3195
+ targetScore: z32.number().min(0).max(1).default(1),
3290
3196
  // Narrow the subject's whole roster to one slot, for the baseline and every
3291
3197
  // trial alike. A subject rostering ten models otherwise multiplies every
3292
3198
  // trial by ten, and a one-model trial measured against a ten-model baseline
3293
3199
  // is not a comparison. `pinnedModel` empty means the agent's default model.
3294
3200
  pinnedAgent: schedulableAgentSchema.optional(),
3295
- pinnedModel: z31.string().optional(),
3296
- maxTrialsPerRound: z31.number().int().min(1).max(10).default(3),
3201
+ pinnedModel: z32.string().optional(),
3202
+ maxTrialsPerRound: z32.number().int().min(1).max(10).default(3),
3297
3203
  // The round a continuation started at; the no-improvement counter
3298
3204
  // restarts here.
3299
- continuedAtRound: z31.number().int().nonnegative().optional()
3205
+ continuedAtRound: z32.number().int().nonnegative().optional()
3300
3206
  }).strip().refine((value) => value.pinnedAgent !== void 0 || !value.pinnedModel, {
3301
3207
  path: ["pinnedAgent"],
3302
3208
  message: "Pin an agent with the model"
3303
3209
  });
3304
- var climbDirectionSchema = z31.object({
3305
- focus: z31.string().trim().max(2e3).nullable().default(null),
3306
- preserve: z31.array(z31.string().trim().min(1).max(500)).max(20).default([]),
3307
- exclude: z31.array(z31.string().trim().min(1).max(500)).max(20).default([]),
3308
- notes: z31.string().trim().max(4e3).nullable().default(null)
3309
- });
3310
- var climbDirectionPatchSchema = z31.object({
3311
- focus: z31.string().trim().max(2e3).nullable().optional(),
3312
- preserve: z31.array(z31.string().trim().min(1).max(500)).max(20).optional(),
3313
- exclude: z31.array(z31.string().trim().min(1).max(500)).max(20).optional(),
3314
- notes: z31.string().trim().max(4e3).nullable().optional(),
3210
+ var climbDirectionSchema = z32.object({
3211
+ focus: z32.string().trim().max(2e3).nullable().default(null),
3212
+ preserve: z32.array(z32.string().trim().min(1).max(500)).max(20).default([]),
3213
+ exclude: z32.array(z32.string().trim().min(1).max(500)).max(20).default([]),
3214
+ notes: z32.string().trim().max(4e3).nullable().default(null)
3215
+ });
3216
+ var climbDirectionPatchSchema = z32.object({
3217
+ focus: z32.string().trim().max(2e3).nullable().optional(),
3218
+ preserve: z32.array(z32.string().trim().min(1).max(500)).max(20).optional(),
3219
+ exclude: z32.array(z32.string().trim().min(1).max(500)).max(20).optional(),
3220
+ notes: z32.string().trim().max(4e3).nullable().optional(),
3315
3221
  /** One line on why this was recorded; becomes the DIRECTION row summary. */
3316
- rationale: z31.string().trim().max(500).optional()
3222
+ rationale: z32.string().trim().max(500).optional()
3317
3223
  }).strict();
3318
3224
  var CLIMB_ACTIVITY_KINDS = [
3319
3225
  "STARTED",
@@ -3332,74 +3238,74 @@ var CLIMB_ACTIVITY_KINDS = [
3332
3238
  "CONTINUED",
3333
3239
  "CANCELED"
3334
3240
  ];
3335
- var climbActivityKindSchema = z31.enum(CLIMB_ACTIVITY_KINDS);
3336
- var proposerTraceStepSchema = z31.object({
3337
- tool: z31.string(),
3338
- args: z31.string(),
3339
- result: z31.string().nullable(),
3340
- isError: z31.boolean().optional()
3341
- });
3342
- var proposerTraceSchema = z31.object({
3343
- steps: z31.array(proposerTraceStepSchema),
3344
- reasoning: z31.string(),
3345
- durationMs: z31.number().int().nonnegative(),
3346
- model: z31.string()
3347
- });
3348
- var climbActivitySchema = z31.object({
3349
- id: z31.string(),
3350
- climbId: z31.string(),
3351
- roundId: z31.string().nullable(),
3352
- trialId: z31.string().nullable(),
3241
+ var climbActivityKindSchema = z32.enum(CLIMB_ACTIVITY_KINDS);
3242
+ var proposerTraceStepSchema = z32.object({
3243
+ tool: z32.string(),
3244
+ args: z32.string(),
3245
+ result: z32.string().nullable(),
3246
+ isError: z32.boolean().optional()
3247
+ });
3248
+ var proposerTraceSchema = z32.object({
3249
+ steps: z32.array(proposerTraceStepSchema),
3250
+ reasoning: z32.string(),
3251
+ durationMs: z32.number().int().nonnegative(),
3252
+ model: z32.string()
3253
+ });
3254
+ var climbActivitySchema = z32.object({
3255
+ id: z32.string(),
3256
+ climbId: z32.string(),
3257
+ roundId: z32.string().nullable(),
3258
+ trialId: z32.string().nullable(),
3353
3259
  kind: climbActivityKindSchema,
3354
- actorUserId: z31.string().nullable(),
3355
- actorName: z31.string().nullable(),
3356
- summary: z31.string(),
3357
- detail: z31.unknown().nullable(),
3358
- createdAt: z31.string()
3359
- });
3360
- var activityQuerySchema = z31.object({
3361
- after: z31.string().datetime().optional(),
3362
- limit: z31.coerce.number().int().min(1).max(500).default(500)
3363
- });
3364
- var climbConfigSnapshotSchema = z31.object({
3365
- promptText: z31.string(),
3366
- scenario: z31.enum(["GREENFIELD", "MIGRATION"]),
3367
- repoUrl: z31.string().nullable(),
3368
- repoRef: z31.string().nullable(),
3369
- profileId: z31.string().nullable(),
3370
- profileName: z31.string().nullable(),
3371
- profileDescription: z31.string().nullable(),
3372
- profileModel: z31.string().nullable(),
3373
- limits: z31.json(),
3374
- agents: z31.array(agentConfigSchema).min(1),
3375
- skillRefs: z31.array(z31.string()),
3376
- mcpRefs: z31.array(z31.string()),
3377
- skillVersionIds: z31.array(z31.string()),
3378
- mcpServerVersionIds: z31.array(z31.string()),
3379
- skillSet: z31.json().nullable(),
3380
- mcpSet: z31.json().nullable(),
3381
- connectionIds: z31.array(z31.string()),
3382
- connectionSet: z31.json().nullable(),
3383
- agentContext: z31.json().nullable(),
3384
- agentContextDigest: z31.string().nullable(),
3260
+ actorUserId: z32.string().nullable(),
3261
+ actorName: z32.string().nullable(),
3262
+ summary: z32.string(),
3263
+ detail: z32.unknown().nullable(),
3264
+ createdAt: z32.string()
3265
+ });
3266
+ var activityQuerySchema = z32.object({
3267
+ after: z32.string().datetime().optional(),
3268
+ limit: z32.coerce.number().int().min(1).max(500).default(500)
3269
+ });
3270
+ var climbConfigSnapshotSchema = z32.object({
3271
+ promptText: z32.string(),
3272
+ scenario: z32.enum(["GREENFIELD", "MIGRATION"]),
3273
+ repoUrl: z32.string().nullable(),
3274
+ repoRef: z32.string().nullable(),
3275
+ profileId: z32.string().nullable(),
3276
+ profileName: z32.string().nullable(),
3277
+ profileDescription: z32.string().nullable(),
3278
+ profileModel: z32.string().nullable(),
3279
+ limits: z32.json(),
3280
+ agents: z32.array(agentConfigSchema).min(1),
3281
+ skillRefs: z32.array(z32.string()),
3282
+ mcpRefs: z32.array(z32.string()),
3283
+ skillVersionIds: z32.array(z32.string()),
3284
+ mcpServerVersionIds: z32.array(z32.string()),
3285
+ skillSet: z32.json().nullable(),
3286
+ mcpSet: z32.json().nullable(),
3287
+ connectionIds: z32.array(z32.string()),
3288
+ connectionSet: z32.json().nullable(),
3289
+ agentContext: z32.json().nullable(),
3290
+ agentContextDigest: z32.string().nullable(),
3385
3291
  webFixture: webFixtureSchema.nullable(),
3386
- cliIntervention: cliInterventionSchema.nullable().default(null),
3292
+ cliIntervention: cliRuleBundleSchema.nullable().default(null),
3387
3293
  sandboxOverrides: sandboxOverridesSchema.nullable(),
3388
- visibilityScenarioId: z31.string().nullable()
3294
+ visibilityScenarioId: z32.string().nullable()
3389
3295
  }).strict();
3390
- var targetRefSchema = z31.object({
3391
- kind: z31.string().min(1),
3392
- id: z31.string().optional(),
3393
- url: z31.url().optional(),
3394
- package: z31.string().optional()
3296
+ var targetRefSchema = z32.object({
3297
+ kind: z32.string().min(1),
3298
+ id: z32.string().optional(),
3299
+ url: z32.url().optional(),
3300
+ package: z32.string().optional()
3395
3301
  }).strict();
3396
- var trialInputSchema = z31.object({
3397
- title: z31.string().trim().min(1).max(200),
3398
- hypothesis: z31.string().max(4e3).optional(),
3302
+ var trialInputSchema = z32.object({
3303
+ title: z32.string().trim().min(1).max(200),
3304
+ hypothesis: z32.string().max(4e3).optional(),
3399
3305
  lever: leverKindSchema,
3400
3306
  targetRef: targetRefSchema.optional(),
3401
3307
  intervention: interventionSchema,
3402
- authorMode: z31.enum(["MANUAL", "DIRECT", "PROPOSE"]).default("MANUAL")
3308
+ authorMode: z32.enum(["MANUAL", "DIRECT", "PROPOSE"]).default("MANUAL")
3403
3309
  }).strict().superRefine((value, ctx) => {
3404
3310
  const allowed = LEVER_INTERVENTIONS[value.lever];
3405
3311
  if (!allowed.includes(value.intervention.kind))
@@ -3418,7 +3324,7 @@ var OPTIMIZATION_STATUSES = [
3418
3324
  "DONE",
3419
3325
  "ARCHIVED"
3420
3326
  ];
3421
- var optimizationStatusSchema = z32.enum(OPTIMIZATION_STATUSES);
3327
+ var optimizationStatusSchema = z33.enum(OPTIMIZATION_STATUSES);
3422
3328
  var ROUND_STATUSES = [
3423
3329
  "PROPOSING",
3424
3330
  "PROPOSED",
@@ -3447,61 +3353,61 @@ var OPTIMIZATION_EFFORTS = [
3447
3353
  { value: "HIGH", label: "Thorough", sampleCount: 2, maxRounds: 8 },
3448
3354
  { value: "XHIGH", label: "Exhaustive", sampleCount: 3, maxRounds: 12 }
3449
3355
  ];
3450
- var optimizationEffortSchema = z32.enum(
3356
+ var optimizationEffortSchema = z33.enum(
3451
3357
  OPTIMIZATION_EFFORTS.map((preset) => preset.value)
3452
3358
  );
3453
- var listOptimizationsQuerySchema = z32.object({
3454
- status: z32.string().optional().transform(
3359
+ var listOptimizationsQuerySchema = z33.object({
3360
+ status: z33.string().optional().transform(
3455
3361
  (value) => value ? value.split(",").map((part) => part.trim().toUpperCase()).filter(Boolean) : void 0
3456
- ).pipe(z32.array(optimizationStatusSchema).optional()),
3362
+ ).pipe(z33.array(optimizationStatusSchema).optional()),
3457
3363
  subjectKind: climbSubjectKindSchema.optional(),
3458
- subjectId: z32.string().min(1).optional(),
3459
- limit: z32.coerce.number().int().min(1).max(200).default(50),
3364
+ subjectId: z33.string().min(1).optional(),
3365
+ limit: z33.coerce.number().int().min(1).max(200).default(50),
3460
3366
  /** Drafts are workspaces, not runs; older clients never see them. */
3461
- includeDrafts: z32.union([z32.boolean(), z32.string()]).optional().transform((value) => value === true || value === "true" || value === "1")
3367
+ includeDrafts: z33.union([z33.boolean(), z33.string()]).optional().transform((value) => value === true || value === "true" || value === "1")
3462
3368
  });
3463
- var optimizationSummarySchema = z32.object({
3464
- id: z32.string(),
3465
- name: z32.string(),
3369
+ var optimizationSummarySchema = z33.object({
3370
+ id: z33.string(),
3371
+ name: z33.string(),
3466
3372
  status: optimizationStatusSchema,
3467
- mode: z32.enum(["MANUAL", "AUTO"]),
3373
+ mode: z33.enum(["MANUAL", "AUTO"]),
3468
3374
  /** Autonomous launches every proposed round; interactive waits for one. */
3469
- autonomous: z32.boolean(),
3470
- stopReason: z32.string().nullable(),
3375
+ autonomous: z33.boolean(),
3376
+ stopReason: z33.string().nullable(),
3471
3377
  subjectKind: climbSubjectKindSchema,
3472
- subjectId: z32.string(),
3473
- subjectName: z32.string(),
3378
+ subjectId: z33.string(),
3379
+ subjectName: z33.string(),
3474
3380
  lever: leverKindSchema.nullable(),
3475
- round: z32.number().int(),
3476
- maxRounds: z32.number().int(),
3381
+ round: z33.number().int(),
3382
+ maxRounds: z33.number().int(),
3477
3383
  /** Starting baseline score, 0..1. */
3478
- before: z32.number().nullable(),
3384
+ before: z33.number().nullable(),
3479
3385
  /** Score of the marked winner, or best BETTER trial, 0..1. */
3480
- after: z32.number().nullable(),
3386
+ after: z33.number().nullable(),
3481
3387
  /** Percentage-point change from the baseline to the winner or best BETTER trial. */
3482
- delta: z32.number().nullable(),
3388
+ delta: z33.number().nullable(),
3483
3389
  /** Score after each round, baseline first. */
3484
- path: z32.array(z32.number()),
3485
- creditsSpent: z32.number().int(),
3486
- creditsReserved: z32.number().int(),
3487
- summary: z32.string().nullable(),
3488
- href: z32.string(),
3489
- createdAt: z32.string(),
3490
- updatedAt: z32.string()
3491
- });
3492
- var listOptimizationsResponseSchema = z32.object({
3493
- items: z32.array(optimizationSummarySchema)
3494
- });
3495
- var targetSchema = z32.object({
3390
+ path: z33.array(z33.number()),
3391
+ creditsSpent: z33.number().int(),
3392
+ creditsReserved: z33.number().int(),
3393
+ summary: z33.string().nullable(),
3394
+ href: z33.string(),
3395
+ createdAt: z33.string(),
3396
+ updatedAt: z33.string()
3397
+ });
3398
+ var listOptimizationsResponseSchema = z33.object({
3399
+ items: z33.array(optimizationSummarySchema)
3400
+ });
3401
+ var targetSchema = z33.object({
3496
3402
  agent: schedulableAgentSchema.optional(),
3497
3403
  /** Empty or omitted means the agent's default model. */
3498
- model: z32.string().optional()
3404
+ model: z33.string().optional()
3499
3405
  });
3500
3406
  var planShape = {
3501
3407
  effort: optimizationEffortSchema.optional(),
3502
- sampleCount: z32.number().int().min(1).max(100).optional(),
3503
- maxRounds: z32.number().int().min(1).max(100).optional(),
3504
- maxTrialsPerRound: z32.number().int().min(1).max(10).optional()
3408
+ sampleCount: z33.number().int().min(1).max(100).optional(),
3409
+ maxRounds: z33.number().int().min(1).max(100).optional(),
3410
+ maxTrialsPerRound: z33.number().int().min(1).max(10).optional()
3505
3411
  };
3506
3412
  function refinePlan(value, ctx) {
3507
3413
  if (value.effort && (value.sampleCount || value.maxRounds))
@@ -3517,18 +3423,18 @@ function refinePlan(value, ctx) {
3517
3423
  message: "Pin an agent with the model"
3518
3424
  });
3519
3425
  }
3520
- var startOptimizationBodySchema = z32.object({
3426
+ var startOptimizationBodySchema = z33.object({
3521
3427
  subjectKind: climbSubjectKindSchema,
3522
- subjectId: z32.string().min(1),
3523
- name: z32.string().trim().min(1).max(200).optional(),
3428
+ subjectId: z33.string().min(1),
3429
+ name: z33.string().trim().min(1).max(200).optional(),
3524
3430
  ...planShape,
3525
- creditCap: z32.number().int().nonnegative().optional(),
3526
- targetScore: z32.number().min(0).max(1).optional(),
3431
+ creditCap: z33.number().int().nonnegative().optional(),
3432
+ targetScore: z33.number().min(0).max(1).optional(),
3527
3433
  target: targetSchema.extend({ agent: schedulableAgentSchema })
3528
3434
  }).strict().superRefine(refinePlan);
3529
- var estimateOptimizationBodySchema = z32.object({
3435
+ var estimateOptimizationBodySchema = z33.object({
3530
3436
  subjectKind: climbSubjectKindSchema,
3531
- subjectId: z32.string().min(1),
3437
+ subjectId: z33.string().min(1),
3532
3438
  ...planShape,
3533
3439
  target: targetSchema.optional()
3534
3440
  }).strict().superRefine(refinePlan);
@@ -3540,105 +3446,105 @@ var RUN_CREDIT_BASES = [
3540
3446
  "byok",
3541
3447
  "reserve"
3542
3448
  ];
3543
- var runCreditBasisSchema = z32.enum(RUN_CREDIT_BASES);
3544
- var optimizationEstimateSchema = z32.object({
3545
- sampleCount: z32.number().int(),
3546
- maxRounds: z32.number().int(),
3547
- runsPerTrial: z32.number(),
3548
- executionCredits: z32.number(),
3549
- judgeCredits: z32.number(),
3550
- leverPassCredits: z32.number(),
3551
- trialCredits: z32.number(),
3449
+ var runCreditBasisSchema = z33.enum(RUN_CREDIT_BASES);
3450
+ var optimizationEstimateSchema = z33.object({
3451
+ sampleCount: z33.number().int(),
3452
+ maxRounds: z33.number().int(),
3453
+ runsPerTrial: z33.number(),
3454
+ executionCredits: z33.number(),
3455
+ judgeCredits: z33.number(),
3456
+ leverPassCredits: z33.number(),
3457
+ trialCredits: z33.number(),
3552
3458
  /** Estimate, not a reservation or enforced spending cap. */
3553
- estimate: z32.number().int(),
3459
+ estimate: z33.number().int(),
3554
3460
  /** True when no price or history covered a model: a bound, not a forecast. */
3555
- approximate: z32.boolean().default(false),
3461
+ approximate: z33.boolean().default(false),
3556
3462
  /** Which rung priced the run, so the UI can say why a figure is what it is. */
3557
3463
  basis: runCreditBasisSchema.optional()
3558
3464
  });
3559
- var diagnoseBodySchema = z32.object({
3465
+ var diagnoseBodySchema = z33.object({
3560
3466
  subjectKind: climbSubjectKindSchema,
3561
- subjectId: z32.string().min(1)
3467
+ subjectId: z33.string().min(1)
3562
3468
  }).strict();
3563
- var diagnosisSchema = z32.object({
3564
- id: z32.string(),
3565
- status: z32.enum(["GENERATING", "READY", "FAILED"]),
3469
+ var diagnosisSchema = z33.object({
3470
+ id: z33.string(),
3471
+ status: z33.enum(["GENERATING", "READY", "FAILED"]),
3566
3472
  subjectKind: climbSubjectKindSchema,
3567
- subjectId: z32.string(),
3568
- runCount: z32.number().int(),
3569
- summary: z32.string().nullable(),
3473
+ subjectId: z33.string(),
3474
+ runCount: z33.number().int(),
3475
+ summary: z33.string().nullable(),
3570
3476
  recommendedLever: leverKindSchema.nullable(),
3571
- recommendedTarget: z32.unknown().nullable(),
3572
- clusters: z32.array(
3573
- z32.object({
3574
- title: z32.string(),
3575
- failureMode: z32.string(),
3576
- criterionIds: z32.array(z32.string()),
3577
- runIds: z32.array(z32.string()),
3477
+ recommendedTarget: z33.unknown().nullable(),
3478
+ clusters: z33.array(
3479
+ z33.object({
3480
+ title: z33.string(),
3481
+ failureMode: z33.string(),
3482
+ criterionIds: z33.array(z33.string()),
3483
+ runIds: z33.array(z33.string()),
3578
3484
  lever: leverKindSchema.nullable(),
3579
- targetRef: z32.unknown().nullable(),
3580
- confidence: z32.number()
3485
+ targetRef: z33.unknown().nullable(),
3486
+ confidence: z33.number()
3581
3487
  })
3582
3488
  ),
3583
- unsupportedLevers: z32.array(leverKindSchema).default([]),
3584
- createdAt: z32.string()
3585
- });
3586
- var trialRunSchema = z32.object({
3587
- id: z32.string(),
3588
- status: z32.string(),
3589
- failureReason: z32.string().nullable(),
3590
- exitReason: z32.string().nullable(),
3591
- cliCoverage: cliCoverageSchema.nullable().optional(),
3592
- passed: z32.boolean().nullable(),
3593
- criteria: z32.array(
3594
- z32.object({ name: z32.string(), passed: z32.boolean(), reasoning: z32.string() })
3489
+ unsupportedLevers: z33.array(leverKindSchema).default([]),
3490
+ createdAt: z33.string()
3491
+ });
3492
+ var trialRunSchema = z33.object({
3493
+ id: z33.string(),
3494
+ status: z33.string(),
3495
+ failureReason: z33.string().nullable(),
3496
+ exitReason: z33.string().nullable(),
3497
+ cliCoverage: cliRuleCoverageSchema.nullable().optional(),
3498
+ passed: z33.boolean().nullable(),
3499
+ criteria: z33.array(
3500
+ z33.object({ name: z33.string(), passed: z33.boolean(), reasoning: z33.string() })
3595
3501
  ),
3596
- levers: z32.array(
3597
- z32.object({
3598
- lever: z32.string(),
3599
- attributed: z32.boolean(),
3600
- note: z32.string().nullable()
3502
+ levers: z33.array(
3503
+ z33.object({
3504
+ lever: z33.string(),
3505
+ attributed: z33.boolean(),
3506
+ note: z33.string().nullable()
3601
3507
  })
3602
3508
  )
3603
3509
  });
3604
- var trialSchema = z32.object({
3605
- id: z32.string(),
3606
- climbId: z32.string(),
3607
- roundNumber: z32.number().int(),
3608
- key: z32.string(),
3510
+ var trialSchema = z33.object({
3511
+ id: z33.string(),
3512
+ climbId: z33.string(),
3513
+ roundNumber: z33.number().int(),
3514
+ key: z33.string(),
3609
3515
  /** @deprecated All trials branch from the baseline. */
3610
- parentTrialId: z32.string().nullable(),
3516
+ parentTrialId: z33.string().nullable(),
3611
3517
  /** @deprecated Always the baseline key for non-baseline trials. */
3612
- parentKey: z32.string().nullable(),
3613
- title: z32.string(),
3614
- hypothesis: z32.string().nullable(),
3518
+ parentKey: z33.string().nullable(),
3519
+ title: z33.string(),
3520
+ hypothesis: z33.string().nullable(),
3615
3521
  lever: leverKindSchema.nullable(),
3616
3522
  kind: interventionKindSchema,
3617
- status: z32.enum(TRIAL_STATUSES),
3618
- verdict: z32.enum(TRIAL_VERDICTS).nullable(),
3619
- score: z32.number().nullable(),
3620
- baselineScore: z32.number().nullable(),
3523
+ status: z33.enum(TRIAL_STATUSES),
3524
+ verdict: z33.enum(TRIAL_VERDICTS).nullable(),
3525
+ score: z33.number().nullable(),
3526
+ baselineScore: z33.number().nullable(),
3621
3527
  /** Judged sessions behind `score`. */
3622
- sessions: z32.number().int(),
3528
+ sessions: z33.number().int(),
3623
3529
  /** Sessions that FAILED or TIMED_OUT; `score` leaves them out. */
3624
- failedSessions: z32.number().int(),
3625
- isBaseline: z32.boolean(),
3530
+ failedSessions: z33.number().int(),
3531
+ isBaseline: z33.boolean(),
3626
3532
  /** The user marked this trial as the winner; it does not move the baseline. */
3627
- adopted: z32.boolean(),
3628
- adoptedAt: z32.string().nullable(),
3629
- outcome: z32.string().nullable(),
3533
+ adopted: z33.boolean(),
3534
+ adoptedAt: z33.string().nullable(),
3535
+ outcome: z33.string().nullable(),
3630
3536
  /** The kind-specific `after` payload (skill version id, pages, package). */
3631
- after: z32.unknown(),
3632
- before: z32.unknown(),
3633
- runs: z32.array(trialRunSchema),
3634
- createdAt: z32.string()
3635
- });
3636
- var roundSchema = z32.object({
3637
- id: z32.string(),
3638
- number: z32.number().int(),
3639
- status: z32.enum(ROUND_STATUSES),
3640
- narrative: z32.string().nullable(),
3641
- trials: z32.array(trialSchema)
3537
+ after: z33.unknown(),
3538
+ before: z33.unknown(),
3539
+ runs: z33.array(trialRunSchema),
3540
+ createdAt: z33.string()
3541
+ });
3542
+ var roundSchema = z33.object({
3543
+ id: z33.string(),
3544
+ number: z33.number().int(),
3545
+ status: z33.enum(ROUND_STATUSES),
3546
+ narrative: z33.string().nullable(),
3547
+ trials: z33.array(trialSchema)
3642
3548
  });
3643
3549
  var OPTIMIZATION_NEXT_ACTIONS = [
3644
3550
  "START",
@@ -3649,366 +3555,420 @@ var OPTIMIZATION_NEXT_ACTIONS = [
3649
3555
  "RESUME",
3650
3556
  "NONE"
3651
3557
  ];
3652
- var optimizationNextActionSchema = z32.enum(OPTIMIZATION_NEXT_ACTIONS);
3558
+ var optimizationNextActionSchema = z33.enum(OPTIMIZATION_NEXT_ACTIONS);
3653
3559
  var optimizationDetailSchema = optimizationSummarySchema.extend({
3654
- baselineTrialId: z32.string().nullable(),
3560
+ baselineTrialId: z33.string().nullable(),
3655
3561
  /** The one thing a client does next. WAIT and NONE need nobody. */
3656
3562
  nextAction: optimizationNextActionSchema,
3657
- settings: z32.object({
3658
- sampleCount: z32.number().int(),
3659
- maxRounds: z32.number().int(),
3660
- maxTrialsPerRound: z32.number().int(),
3661
- creditCap: z32.number().int(),
3662
- targetScore: z32.number(),
3663
- pinnedAgent: z32.string().nullable(),
3664
- pinnedModel: z32.string().nullable(),
3665
- continuedAtRound: z32.number().int().nullable()
3563
+ settings: z33.object({
3564
+ sampleCount: z33.number().int(),
3565
+ maxRounds: z33.number().int(),
3566
+ maxTrialsPerRound: z33.number().int(),
3567
+ creditCap: z33.number().int(),
3568
+ targetScore: z33.number(),
3569
+ pinnedAgent: z33.string().nullable(),
3570
+ pinnedModel: z33.string().nullable(),
3571
+ continuedAtRound: z33.number().int().nullable()
3666
3572
  }),
3667
3573
  direction: climbDirectionSchema,
3668
- rounds: z32.array(roundSchema)
3574
+ rounds: z33.array(roundSchema)
3669
3575
  });
3670
- var optimizationHandoffSchema = z32.object({
3671
- trialId: z32.string(),
3672
- trialKey: z32.string(),
3673
- prompt: z32.string()
3576
+ var optimizationHandoffSchema = z33.object({
3577
+ trialId: z33.string(),
3578
+ trialKey: z33.string(),
3579
+ prompt: z33.string()
3674
3580
  });
3675
- var listTrialsResponseSchema = z32.object({
3676
- items: z32.array(trialSchema)
3581
+ var listTrialsResponseSchema = z33.object({
3582
+ items: z33.array(trialSchema)
3677
3583
  });
3678
- var trialDocumentSchema = z32.object({
3679
- path: z32.string(),
3680
- before: z32.string(),
3681
- after: z32.string()
3584
+ var trialDocumentSchema = z33.object({
3585
+ path: z33.string(),
3586
+ before: z33.string(),
3587
+ after: z33.string()
3682
3588
  });
3683
- var trialContentSchema = z32.object({
3684
- trialId: z32.string(),
3589
+ var trialContentSchema = z33.object({
3590
+ trialId: z33.string(),
3685
3591
  kind: interventionKindSchema,
3686
- documents: z32.array(trialDocumentSchema),
3592
+ documents: z33.array(trialDocumentSchema),
3687
3593
  /** Full page bodies for a docs rewrite, ready to paste; null otherwise. */
3688
- copyableBody: z32.string().nullable(),
3689
- configSnapshot: z32.unknown()
3594
+ copyableBody: z33.string().nullable(),
3595
+ configSnapshot: z33.unknown()
3690
3596
  });
3691
- var createTrialBodySchema = z32.object({
3597
+ var createTrialBodySchema = z33.object({
3692
3598
  trial: trialInputSchema,
3693
3599
  files: overrideFilesSchema.optional(),
3694
- fork: z32.object({ runId: z32.string().min(1), boundarySeq: z32.string().min(1) }).strict().optional(),
3695
- launch: z32.boolean().default(false),
3600
+ fork: z33.object({ runId: z33.string().min(1), boundarySeq: z33.string().min(1) }).strict().optional(),
3601
+ launch: z33.boolean().default(false),
3696
3602
  /** Replays return the trial the first call created instead of a second
3697
3603
  * one. Scoped to the optimization. */
3698
- idempotencyKey: z32.string().min(1).max(200).optional()
3604
+ idempotencyKey: z33.string().min(1).max(200).optional()
3699
3605
  }).strict();
3700
- var skillFilesResponseSchema = z32.object({
3701
- versionId: z32.string(),
3606
+ var skillFilesResponseSchema = z33.object({
3607
+ versionId: z33.string(),
3702
3608
  files: overrideFilesSchema
3703
3609
  });
3704
- var pageBodyResponseSchema = z32.object({
3705
- url: z32.string(),
3706
- body: z32.string(),
3707
- contentType: z32.string().optional()
3610
+ var pageBodyResponseSchema = z33.object({
3611
+ url: z33.string(),
3612
+ body: z33.string(),
3613
+ contentType: z33.string().optional()
3708
3614
  });
3709
- var launchTrialResponseSchema = z32.object({
3710
- trialId: z32.string(),
3711
- batchIds: z32.array(z32.string()),
3712
- runIds: z32.array(z32.string())
3615
+ var launchTrialResponseSchema = z33.object({
3616
+ trialId: z33.string(),
3617
+ batchIds: z33.array(z33.string()),
3618
+ runIds: z33.array(z33.string())
3713
3619
  });
3714
- var createDraftOptimizationBodySchema = z32.object({
3620
+ var createDraftOptimizationBodySchema = z33.object({
3715
3621
  subjectKind: climbSubjectKindSchema,
3716
- subjectId: z32.string().min(1),
3717
- name: z32.string().trim().min(1).max(200).optional(),
3622
+ subjectId: z33.string().min(1),
3623
+ name: z33.string().trim().min(1).max(200).optional(),
3718
3624
  ...planShape,
3719
3625
  target: targetSchema.optional(),
3720
- autonomous: z32.boolean().optional()
3626
+ autonomous: z33.boolean().optional()
3721
3627
  }).strict().superRefine(refinePlan);
3722
3628
  var planPatchShape = {
3723
- name: z32.string().trim().min(1).max(200).optional(),
3629
+ name: z33.string().trim().min(1).max(200).optional(),
3724
3630
  ...planShape,
3725
3631
  target: targetSchema.optional()
3726
3632
  };
3727
- var optimizationPlanPatchSchema = z32.object(planPatchShape).strict().superRefine(refinePlan);
3728
- var startDraftOptimizationBodySchema = z32.object({
3633
+ var optimizationPlanPatchSchema = z33.object(planPatchShape).strict().superRefine(refinePlan);
3634
+ var startDraftOptimizationBodySchema = z33.object({
3729
3635
  ...planPatchShape,
3730
- creditCap: z32.number().int().nonnegative().optional()
3636
+ creditCap: z33.number().int().nonnegative().optional()
3731
3637
  }).strict().superRefine(refinePlan);
3732
- var setModeBodySchema = z32.object({ autonomous: z32.boolean() }).strict();
3733
- var launchRoundResponseSchema = z32.object({
3734
- roundNumber: z32.number().int().nullable(),
3735
- launched: z32.array(z32.string()),
3638
+ var setModeBodySchema = z33.object({ autonomous: z33.boolean() }).strict();
3639
+ var launchRoundResponseSchema = z33.object({
3640
+ roundNumber: z33.number().int().nullable(),
3641
+ launched: z33.array(z33.string()),
3736
3642
  /** True when nothing was left to launch: someone else got there first. */
3737
- alreadyLaunched: z32.boolean()
3643
+ alreadyLaunched: z33.boolean()
3738
3644
  });
3739
- var resolveChatResponseSchema = z32.object({
3740
- chatId: z32.string(),
3741
- href: z32.string()
3645
+ var resolveChatResponseSchema = z33.object({
3646
+ chatId: z33.string(),
3647
+ href: z33.string()
3742
3648
  });
3743
- var continueOptimizationBodySchema = z32.object({
3744
- rounds: z32.number().int().min(1).max(20).default(1),
3745
- maxTrialsPerRound: z32.number().int().min(1).max(10).optional()
3649
+ var continueOptimizationBodySchema = z33.object({
3650
+ rounds: z33.number().int().min(1).max(20).default(1),
3651
+ maxTrialsPerRound: z33.number().int().min(1).max(10).optional()
3746
3652
  }).strict();
3747
- var patchOptimizationBodySchema = z32.object({
3653
+ var patchOptimizationBodySchema = z33.object({
3748
3654
  ...planPatchShape,
3749
3655
  direction: climbDirectionPatchSchema.optional(),
3750
- autonomous: z32.boolean().optional()
3656
+ autonomous: z33.boolean().optional()
3751
3657
  }).strict().superRefine(refinePlan);
3752
3658
 
3753
3659
  // ../packages/api-schemas/src/orgs.ts
3754
- import { z as z33 } from "zod";
3755
- var createOrgRequestSchema = z33.object({
3660
+ import { z as z34 } from "zod";
3661
+ var createOrgRequestSchema = z34.object({
3756
3662
  /** Workspace display name; the slug is derived server-side. */
3757
- name: z33.string().trim().min(1).max(200),
3663
+ name: z34.string().trim().min(1).max(200),
3758
3664
  /** Optional company site (logo source; stamped onto the org). */
3759
- website: z33.string().trim().max(300).optional()
3665
+ website: z34.string().trim().max(300).optional()
3760
3666
  });
3761
- var createOrgResponseSchema = z33.object({
3762
- slug: z33.string(),
3763
- name: z33.string(),
3667
+ var createOrgResponseSchema = z34.object({
3668
+ slug: z34.string(),
3669
+ name: z34.string(),
3764
3670
  // LOCAL orgs never have a Gauge publicId.
3765
- publicId: z33.string().nullable()
3671
+ publicId: z34.string().nullable()
3766
3672
  });
3767
- var orgSettingsSchema = z33.object({
3768
- slug: z33.string(),
3769
- name: z33.string(),
3770
- publicId: z33.string().nullable(),
3771
- website: z33.string().nullable(),
3673
+ var orgSettingsSchema = z34.object({
3674
+ slug: z34.string(),
3675
+ name: z34.string(),
3676
+ publicId: z34.string().nullable(),
3677
+ website: z34.string().nullable(),
3772
3678
  /** Per-run max-spend override in USD; null = the server default. */
3773
- maxSpendUsd: z33.number().nullable(),
3774
- overageEnabled: z33.boolean(),
3679
+ maxSpendUsd: z34.number().nullable(),
3680
+ overageEnabled: z34.boolean(),
3775
3681
  /** Per-cycle overage cap in credits; null = uncapped. */
3776
- overageCapCredits: z33.number().int().nullable(),
3682
+ overageCapCredits: z34.number().int().nullable(),
3777
3683
  /** Domain claimed for same-domain auto-join; null = off. */
3778
- autoJoinDomain: z33.string().nullable()
3684
+ autoJoinDomain: z34.string().nullable()
3779
3685
  });
3780
- var orgMemberSchema = z33.object({
3781
- userId: z33.string(),
3782
- name: z33.string().nullable(),
3783
- email: z33.string().nullable(),
3784
- joinedAt: z33.string()
3686
+ var orgMemberSchema = z34.object({
3687
+ userId: z34.string(),
3688
+ name: z34.string().nullable(),
3689
+ email: z34.string().nullable(),
3690
+ joinedAt: z34.string()
3785
3691
  });
3786
- var listMembersResponseSchema = z33.object({
3787
- items: z33.array(orgMemberSchema)
3692
+ var listMembersResponseSchema = z34.object({
3693
+ items: z34.array(orgMemberSchema)
3788
3694
  });
3789
3695
 
3790
3696
  // ../packages/api-schemas/src/personas.ts
3791
- import { z as z34 } from "zod";
3792
- var personaSchema = z34.object({
3793
- id: z34.string(),
3794
- name: z34.string(),
3795
- description: z34.string(),
3697
+ import { z as z35 } from "zod";
3698
+ var personaSchema = z35.object({
3699
+ id: z35.string(),
3700
+ name: z35.string(),
3701
+ description: z35.string(),
3796
3702
  /** The judge model this persona calls (Claude only). */
3797
- model: z34.string(),
3798
- createdAt: z34.string(),
3799
- updatedAt: z34.string()
3703
+ model: z35.string(),
3704
+ createdAt: z35.string(),
3705
+ updatedAt: z35.string()
3800
3706
  });
3801
- var listPersonasResponseSchema = z34.object({
3802
- items: z34.array(personaSchema)
3707
+ var listPersonasResponseSchema = z35.object({
3708
+ items: z35.array(personaSchema)
3803
3709
  });
3804
- var createPersonaBodySchema = z34.object({
3805
- name: z34.string().min(1).max(120),
3806
- description: z34.string().min(1)
3710
+ var createPersonaBodySchema = z35.object({
3711
+ name: z35.string().min(1).max(120),
3712
+ description: z35.string().min(1)
3807
3713
  });
3808
- var updatePersonaBodySchema = z34.object({
3809
- name: z34.string().min(1).max(120).optional(),
3810
- description: z34.string().min(1).optional()
3714
+ var updatePersonaBodySchema = z35.object({
3715
+ name: z35.string().min(1).max(120).optional(),
3716
+ description: z35.string().min(1).optional()
3811
3717
  });
3812
3718
 
3813
3719
  // ../packages/api-schemas/src/prompts.ts
3814
- import { z as z37 } from "zod";
3720
+ import { z as z38 } from "zod";
3815
3721
 
3816
3722
  // ../packages/api-schemas/src/tags.ts
3817
- import { z as z35 } from "zod";
3818
- var tagSchema = z35.object({
3819
- id: z35.string(),
3820
- name: z35.string(),
3723
+ import { z as z36 } from "zod";
3724
+ var tagSchema = z36.object({
3725
+ id: z36.string(),
3726
+ name: z36.string(),
3821
3727
  /** A Mantine palette name (e.g. "blue", "grape"); unknown values are
3822
3728
  * normalized server-side to the default ("gray"). */
3823
- color: z35.string()
3729
+ color: z36.string()
3824
3730
  });
3825
- var createTagBodySchema = z35.object({
3826
- name: z35.string().min(1),
3827
- color: z35.string().optional()
3731
+ var createTagBodySchema = z36.object({
3732
+ name: z36.string().min(1),
3733
+ color: z36.string().optional()
3828
3734
  });
3829
- var updateTagBodySchema = z35.object({
3830
- name: z35.string().min(1).optional(),
3831
- color: z35.string().optional()
3735
+ var updateTagBodySchema = z36.object({
3736
+ name: z36.string().min(1).optional(),
3737
+ color: z36.string().optional()
3832
3738
  });
3833
3739
  var tagListResponseSchema = listResponseSchema(tagSchema);
3834
3740
 
3835
3741
  // ../packages/api-schemas/src/topics.ts
3836
- import { z as z36 } from "zod";
3837
- var topicSchema = z36.object({
3838
- id: z36.string(),
3839
- name: z36.string()
3742
+ import { z as z37 } from "zod";
3743
+ var topicSchema = z37.object({
3744
+ id: z37.string(),
3745
+ name: z37.string()
3840
3746
  });
3841
- var createTopicBodySchema = z36.object({
3842
- name: z36.string().min(1, "name is required")
3747
+ var createTopicBodySchema = z37.object({
3748
+ name: z37.string().min(1, "name is required")
3843
3749
  });
3844
3750
  var topicListResponseSchema = listResponseSchema(topicSchema);
3845
3751
 
3846
3752
  // ../packages/api-schemas/src/prompts.ts
3847
- var promptSummarySchema = z37.object({
3848
- id: z37.string(),
3849
- text: z37.string(),
3850
- isBranded: z37.boolean(),
3753
+ var promptSummarySchema = z38.object({
3754
+ id: z38.string(),
3755
+ text: z38.string(),
3756
+ isBranded: z38.boolean(),
3851
3757
  /** Battery-spec identity (idempotent applies); null for UI/CLI-created prompts. */
3852
- externalKey: z37.string().nullable(),
3758
+ externalKey: z38.string().nullable(),
3853
3759
  topic: topicSchema.nullable(),
3854
- tags: z37.array(tagSchema),
3855
- createdAt: z37.string()
3760
+ tags: z38.array(tagSchema),
3761
+ createdAt: z38.string()
3856
3762
  });
3857
3763
  var promptListResponseSchema = listResponseSchema(promptSummarySchema);
3858
3764
  var listPromptsQuerySchema = listQuerySchema.extend({
3859
- topic: z37.string().min(1).optional(),
3860
- tag: z37.string().min(1).optional(),
3861
- q: z37.string().min(1).optional()
3862
- });
3863
- var createPromptBodySchema = z37.object({
3864
- text: z37.string().min(1, "text is required"),
3865
- isBranded: z37.boolean().default(false),
3866
- topic: z37.string().min(1).optional(),
3867
- tags: z37.array(z37.string().min(1)).default([])
3868
- });
3869
- var updatePromptBodySchema = z37.object({
3870
- text: z37.string().min(1).optional(),
3871
- isBranded: z37.boolean().optional(),
3872
- topicId: z37.string().min(1).nullish(),
3873
- tags: z37.array(z37.string().min(1)).optional()
3874
- });
3875
- var runPromptBodySchema = z37.object({
3765
+ topic: z38.string().min(1).optional(),
3766
+ tag: z38.string().min(1).optional(),
3767
+ q: z38.string().min(1).optional()
3768
+ });
3769
+ var createPromptBodySchema = z38.object({
3770
+ text: z38.string().min(1, "text is required"),
3771
+ isBranded: z38.boolean().default(false),
3772
+ topic: z38.string().min(1).optional(),
3773
+ tags: z38.array(z38.string().min(1)).default([])
3774
+ });
3775
+ var updatePromptBodySchema = z38.object({
3776
+ text: z38.string().min(1).optional(),
3777
+ isBranded: z38.boolean().optional(),
3778
+ topicId: z38.string().min(1).nullish(),
3779
+ tags: z38.array(z38.string().min(1)).optional()
3780
+ });
3781
+ var runPromptBodySchema = z38.object({
3876
3782
  /** Preferred paired representation; each agent may pin its own model tiers. */
3877
- agentConfigs: z37.array(agentConfigInputSchema).min(1).optional(),
3783
+ agentConfigs: z38.array(agentConfigInputSchema).min(1).optional(),
3878
3784
  /** Legacy agent set (no per-agent pins), kept during the API transition. */
3879
- agents: z37.array(z37.enum(["CLAUDE_CODE", "CODEX_CLI", "CURSOR"])).min(1, "Select at least one agent").default(["CLAUDE_CODE", "CODEX_CLI"]),
3880
- repoUrl: z37.string().min(1).nullish(),
3881
- repoRef: z37.string().min(1).nullish(),
3882
- samplesPerCycle: z37.number().int().min(1).max(10).default(1),
3785
+ agents: z38.array(z38.enum(["CLAUDE_CODE", "CODEX_CLI", "CURSOR"])).min(1, "Select at least one agent").default(["CLAUDE_CODE", "CODEX_CLI"]),
3786
+ repoUrl: z38.string().min(1).nullish(),
3787
+ repoRef: z38.string().min(1).nullish(),
3788
+ samplesPerCycle: z38.number().int().min(1).max(10).default(1),
3883
3789
  webFixture: webFixtureSchema.optional()
3884
3790
  });
3885
- var runPromptResponseSchema = z37.object({
3886
- batchIds: z37.array(z37.string()),
3887
- runIds: z37.array(z37.string()),
3888
- blocked: z37.enum(["insufficient_credits", "needs_provider_key"]).optional()
3791
+ var runPromptResponseSchema = z38.object({
3792
+ batchIds: z38.array(z38.string()),
3793
+ runIds: z38.array(z38.string()),
3794
+ blocked: z38.enum(["insufficient_credits", "needs_provider_key"]).optional()
3889
3795
  });
3890
3796
 
3891
3797
  // ../packages/api-schemas/src/repos.ts
3892
- import { z as z38 } from "zod";
3798
+ import { z as z39 } from "zod";
3893
3799
  var REPO_SIZE_BUCKETS = [
3894
3800
  "small",
3895
3801
  "medium",
3896
3802
  "large",
3897
3803
  "xlarge"
3898
3804
  ];
3899
- var repoSizeBucketSchema = z38.enum(REPO_SIZE_BUCKETS);
3900
- var repoSchema = z38.object({
3901
- url: z38.string(),
3902
- name: z38.string(),
3903
- isSystem: z38.boolean(),
3904
- languages: z38.array(z38.string()),
3905
- frameworks: z38.array(z38.string()),
3805
+ var repoSizeBucketSchema = z39.enum(REPO_SIZE_BUCKETS);
3806
+ var repoSchema = z39.object({
3807
+ url: z39.string(),
3808
+ name: z39.string(),
3809
+ isSystem: z39.boolean(),
3810
+ languages: z39.array(z39.string()),
3811
+ frameworks: z39.array(z39.string()),
3906
3812
  /** Faceted labels (complexity:L2, buildable:yes, stack:nextjs, …). */
3907
- tags: z38.array(z38.string()),
3908
- primaryLanguage: z38.string(),
3909
- sizeKb: z38.number(),
3813
+ tags: z39.array(z39.string()),
3814
+ primaryLanguage: z39.string(),
3815
+ sizeKb: z39.number(),
3910
3816
  sizeBucket: repoSizeBucketSchema.nullable(),
3911
- stars: z38.number()
3817
+ stars: z39.number()
3912
3818
  });
3913
3819
  var repoListResponseSchema = listResponseSchema(repoSchema);
3914
- var addRepoBodySchema = z38.object({
3915
- url: z38.string().min(1, "url is required"),
3820
+ var addRepoBodySchema = z39.object({
3821
+ url: z39.string().min(1, "url is required"),
3916
3822
  /**
3917
3823
  * Reserved (accepted, not yet persisted): the catalog keys repos by URL only
3918
3824
  * — `fact_repo` has no ref column and metadata sync always reads the default
3919
3825
  * branch. Kept in the wire format so `gauge repos add --ref` is stable once
3920
3826
  * the catalog learns refs.
3921
3827
  */
3922
- ref: z38.string().min(1).optional(),
3828
+ ref: z39.string().min(1).optional(),
3923
3829
  /** Display name; defaults to the `owner/repo` label of the URL. */
3924
- name: z38.string().min(1).optional(),
3830
+ name: z39.string().min(1).optional(),
3925
3831
  /** Manual override; defaults to frameworks detected from the repo's manifests. */
3926
- frameworks: z38.array(z38.string()).optional(),
3927
- tags: z38.array(z38.string()).optional()
3832
+ frameworks: z39.array(z39.string()).optional(),
3833
+ tags: z39.array(z39.string()).optional()
3928
3834
  });
3929
- var updateRepoBodySchema = z38.object({
3930
- url: z38.string().min(1, "url is required"),
3931
- name: z38.string().min(1).optional(),
3932
- frameworks: z38.array(z38.string()).optional(),
3933
- tags: z38.array(z38.string()).optional()
3835
+ var updateRepoBodySchema = z39.object({
3836
+ url: z39.string().min(1, "url is required"),
3837
+ name: z39.string().min(1).optional(),
3838
+ frameworks: z39.array(z39.string()).optional(),
3839
+ tags: z39.array(z39.string()).optional()
3934
3840
  });
3935
- var resyncRepoBodySchema = z38.object({
3936
- url: z38.string().min(1, "url is required")
3841
+ var resyncRepoBodySchema = z39.object({
3842
+ url: z39.string().min(1, "url is required")
3937
3843
  });
3938
- var deleteRepoQuerySchema = z38.object({
3939
- url: z38.string().min(1, "url is required")
3844
+ var deleteRepoQuerySchema = z39.object({
3845
+ url: z39.string().min(1, "url is required")
3940
3846
  });
3941
- var repoSyncResultSchema = z38.object({
3847
+ var repoSyncResultSchema = z39.object({
3942
3848
  repo: repoSchema,
3943
- synced: z38.boolean()
3849
+ synced: z39.boolean()
3944
3850
  });
3945
3851
 
3946
3852
  // ../packages/api-schemas/src/runAddons.ts
3947
- import { z as z39 } from "zod";
3948
- var runAddonsSchema = z39.object({
3949
- browser: z39.object({
3950
- session: z39.string().min(1),
3951
- projectId: z39.number().int().positive(),
3952
- region: z39.literal("us").default("us")
3853
+ import { z as z40 } from "zod";
3854
+ var runAddonsSchema = z40.object({
3855
+ browser: z40.object({
3856
+ session: z40.string().min(1),
3857
+ projectId: z40.number().int().positive(),
3858
+ region: z40.literal("us").default("us")
3953
3859
  }).strict().optional()
3954
3860
  }).strict();
3955
3861
 
3956
3862
  // ../packages/api-schemas/src/runDefinitions.ts
3957
- import { z as z42 } from "zod";
3863
+ import { z as z44 } from "zod";
3958
3864
 
3959
- // ../packages/api-schemas/src/runDefinitionInputs.ts
3865
+ // ../packages/api-schemas/src/preference.ts
3960
3866
  import { z as z41 } from "zod";
3867
+ var preferenceDefinitionSchema = z41.discriminatedUnion("kind", [
3868
+ z41.object({
3869
+ kind: z41.literal("open-ended"),
3870
+ branded: z41.boolean().default(false)
3871
+ }).strict(),
3872
+ z41.object({
3873
+ kind: z41.literal("head-to-head"),
3874
+ brandA: z41.string().trim().min(1),
3875
+ brandB: z41.string().trim().min(1)
3876
+ }).strict().refine(
3877
+ (p) => p.brandA.toLowerCase() !== p.brandB.toLowerCase(),
3878
+ "A head-to-head needs two different brands"
3879
+ )
3880
+ ]);
3881
+ var preferenceSnapshotSchema = z41.object({ version: z41.literal(1), preference: preferenceDefinitionSchema }).strict();
3882
+ var headToHeadSchema = z41.object({
3883
+ kind: z41.literal("HEAD_TO_HEAD"),
3884
+ winner: z41.enum(["A", "B", "neither"]),
3885
+ brandA: z41.string(),
3886
+ brandB: z41.string(),
3887
+ rationale: z41.string(),
3888
+ brandAReasoning: z41.string(),
3889
+ brandBReasoning: z41.string(),
3890
+ brandAWhyRaised: z41.string().optional(),
3891
+ brandBWhyRaised: z41.string().optional()
3892
+ });
3893
+ var recommendPickSchema = z41.object({
3894
+ brand: z41.string(),
3895
+ rank: z41.number().int(),
3896
+ adopted: z41.boolean(),
3897
+ reasoning: z41.string().optional(),
3898
+ whyRaised: z41.string().optional()
3899
+ });
3900
+ var recommendSchema = z41.object({
3901
+ kind: z41.literal("RECOMMEND"),
3902
+ picks: z41.array(recommendPickSchema).default([]),
3903
+ singlePick: z41.boolean(),
3904
+ complianceNote: z41.string()
3905
+ });
3906
+ var visibilityVerdictSchema = z41.discriminatedUnion("kind", [
3907
+ headToHeadSchema,
3908
+ recommendSchema
3909
+ ]);
3910
+ function preferenceSelectionLabel(verdict) {
3911
+ if (verdict.kind === "HEAD_TO_HEAD")
3912
+ return verdict.winner === "A" ? verdict.brandA : verdict.winner === "B" ? verdict.brandB : "Neither";
3913
+ if (!verdict.singlePick)
3914
+ return verdict.picks.length ? "No clear selection" : "No selection";
3915
+ return verdict.picks.find((pick) => pick.rank === 1)?.brand ?? "No selection";
3916
+ }
3917
+
3918
+ // ../packages/api-schemas/src/runDefinitionInputs.ts
3919
+ import { z as z43 } from "zod";
3961
3920
 
3962
3921
  // ../packages/api-schemas/src/runPlan.ts
3963
- import { z as z40 } from "zod";
3964
- var runPlanCriterionSchema = z40.object({
3965
- id: z40.string().min(1),
3966
- name: z40.string(),
3967
- rubric: z40.string()
3922
+ import { z as z42 } from "zod";
3923
+ var runPlanCriterionSchema = z42.object({
3924
+ id: z42.string().min(1),
3925
+ name: z42.string(),
3926
+ rubric: z42.string()
3968
3927
  });
3969
- var criteriaSnapshotV1Schema = z40.object({
3970
- version: z40.literal(1),
3928
+ var criteriaSnapshotV1Schema = z42.object({
3929
+ version: z42.literal(1),
3971
3930
  // File-authored criteria have no saved EvalSet; their identity is frozen
3972
3931
  // in the request and result rows retain the criterion text without an FK.
3973
- evalSetId: z40.string().min(1).nullable(),
3974
- criteria: z40.array(runPlanCriterionSchema)
3975
- });
3976
- var runPlanCaseSchema = z40.object({
3977
- id: z40.string().min(1),
3978
- prompt: z40.object({ id: z40.string().min(1), text: z40.string() }),
3979
- workspace: z40.object({
3980
- repoUrl: z40.string().nullable(),
3981
- repoRef: z40.string().nullable()
3932
+ evalSetId: z42.string().min(1).nullable(),
3933
+ criteria: z42.array(runPlanCriterionSchema)
3934
+ });
3935
+ var runPlanCaseSchema = z42.object({
3936
+ id: z42.string().min(1),
3937
+ prompt: z42.object({ id: z42.string().min(1), text: z42.string() }),
3938
+ workspace: z42.object({
3939
+ repoUrl: z42.string().nullable(),
3940
+ repoRef: z42.string().nullable()
3982
3941
  }),
3983
- agents: z40.array(
3942
+ agents: z42.array(
3984
3943
  agentConfigSchema.extend({
3985
3944
  // Validated against the current catalog request schema when lowered.
3986
- catalogSelections: z40.record(z40.string(), z40.unknown()).optional()
3945
+ catalogSelections: z42.record(z42.string(), z42.unknown()).optional()
3987
3946
  })
3988
3947
  ),
3989
- samples: z40.number().int().min(1).max(50),
3990
- evalSetId: z40.string().min(1).optional(),
3948
+ samples: z42.number().int().min(1).max(50),
3949
+ evalSetId: z42.string().min(1).optional(),
3991
3950
  criteriaSnapshot: criteriaSnapshotV1Schema.optional(),
3992
- sourceRepoCommit: z40.string().nullable().optional(),
3993
- experiment: z40.string().nullable().optional(),
3994
- membershipTagIds: z40.array(z40.string()).optional(),
3995
- profile: z40.object({
3996
- id: z40.string(),
3997
- name: z40.string(),
3998
- description: z40.string(),
3999
- model: z40.string()
3951
+ preferenceSnapshot: preferenceSnapshotSchema.optional(),
3952
+ sourceRepoCommit: z42.string().nullable().optional(),
3953
+ experiment: z42.string().nullable().optional(),
3954
+ membershipTagIds: z42.array(z42.string()).optional(),
3955
+ profile: z42.object({
3956
+ id: z42.string(),
3957
+ name: z42.string(),
3958
+ description: z42.string(),
3959
+ model: z42.string()
4000
3960
  }).nullable().optional(),
4001
3961
  skillSet: skillSetSchema.optional(),
4002
3962
  mcpSet: mcpSetSchema.optional(),
4003
3963
  connectionSet: connectionSetSchema.optional(),
4004
3964
  // The server's agentContextSnapshotV1Schema validates this at lowering.
4005
- agentContext: z40.unknown().optional(),
4006
- agentContextDigest: z40.string().nullable().optional(),
3965
+ agentContext: z42.unknown().optional(),
3966
+ agentContextDigest: z42.string().nullable().optional(),
4007
3967
  addons: runAddonsSchema.optional(),
4008
3968
  /** Names of resources the coordinator must prepare before expansion. */
4009
- inputs: z40.array(z40.string().min(1)).default([])
3969
+ inputs: z42.array(z42.string().min(1)).default([])
4010
3970
  });
4011
- var inputPathSchema = z40.string().min(1).max(256).regex(
3971
+ var inputPathSchema = z42.string().min(1).max(256).regex(
4012
3972
  // biome-ignore lint/suspicious/noControlCharactersInRegex: Reject unsafe control characters in authored paths.
4013
3973
  /^(?![!/])(?!.*[\\\x00-\x1f\x7f])(?!.*(?:^|\/)\.{1,2}(?:\/|$))(?!.*\/\/)(?!.*\/$).+$/,
4014
3974
  "Expected a repository-relative path or glob without traversal"
@@ -4043,20 +4003,20 @@ var reservedBinaryCommands = [
4043
4003
  "pi",
4044
4004
  "wizard"
4045
4005
  ];
4046
- var binaryCommandSchema = z40.string().max(128).regex(
4006
+ var binaryCommandSchema = z42.string().max(128).regex(
4047
4007
  /^[A-Za-z0-9_][A-Za-z0-9_.+-]*$/,
4048
4008
  "Expected a command name without paths or shell syntax"
4049
4009
  ).refine(
4050
4010
  (name) => !reservedBinaryCommands.includes(name),
4051
4011
  "Command is reserved for Gauge workspace setup or the agent harness; choose another command name"
4052
4012
  );
4053
- var binaryUseSchema = z40.object({
4054
- type: z40.literal("binary"),
4055
- paths: z40.array(inputPathSchema).min(1).max(32),
4056
- platform: z40.literal("linux-x64").describe(
4013
+ var binaryUseSchema = z42.object({
4014
+ type: z42.literal("binary"),
4015
+ paths: z42.array(inputPathSchema).min(1).max(32),
4016
+ platform: z42.literal("linux-x64").describe(
4057
4017
  "Linux x86-64 ELF executables compatible with the consumer sandbox. No system packages are installed."
4058
4018
  ),
4059
- commands: z40.record(
4019
+ commands: z42.record(
4060
4020
  binaryCommandSchema,
4061
4021
  inputPathSchema.regex(
4062
4022
  /^[^*?{}[\]]+$/,
@@ -4067,62 +4027,62 @@ var binaryUseSchema = z40.object({
4067
4027
  "Declare between 1 and 32 commands"
4068
4028
  ).meta({ minProperties: 1, maxProperties: 32 })
4069
4029
  }).strict();
4070
- var inputUseSchema = z40.discriminatedUnion("type", [
4030
+ var inputUseSchema = z42.discriminatedUnion("type", [
4071
4031
  binaryUseSchema,
4072
4032
  websiteUseSchema,
4073
- z40.object({
4074
- type: z40.literal("files"),
4075
- paths: z40.array(inputPathSchema).min(1).max(32).optional()
4033
+ z42.object({
4034
+ type: z42.literal("files"),
4035
+ paths: z42.array(inputPathSchema).min(1).max(32).optional()
4076
4036
  }).strict(),
4077
- z40.object({
4078
- type: z40.literal("npm-cli"),
4037
+ z42.object({
4038
+ type: z42.literal("npm-cli"),
4079
4039
  package: inputPathSchema,
4080
- install: z40.enum(["environment", "workspace"]).optional()
4040
+ install: z42.enum(["environment", "workspace"]).optional()
4081
4041
  }).strict(),
4082
- z40.object({
4083
- type: z40.literal("npm-package"),
4042
+ z42.object({
4043
+ type: z42.literal("npm-package"),
4084
4044
  package: inputPathSchema,
4085
- install: z40.enum(["environment", "workspace"]).optional()
4045
+ install: z42.enum(["environment", "workspace"]).optional()
4086
4046
  }).strict(),
4087
- z40.object({
4088
- type: z40.literal("skill"),
4089
- root: z40.union([z40.literal("."), inputPathSchema]).refine(
4047
+ z42.object({
4048
+ type: z42.literal("skill"),
4049
+ root: z42.union([z42.literal("."), inputPathSchema]).refine(
4090
4050
  (path3) => !/[*?{}[\]]/.test(path3),
4091
4051
  "Skill root must be an explicit directory"
4092
4052
  )
4093
4053
  }).strict()
4094
4054
  ]);
4095
- var inputSourceSchema = z40.discriminatedUnion("type", [
4096
- z40.object({
4097
- type: z40.literal("git"),
4098
- paths: z40.array(inputPathSchema).min(1).max(32)
4055
+ var inputSourceSchema = z42.discriminatedUnion("type", [
4056
+ z42.object({
4057
+ type: z42.literal("git"),
4058
+ paths: z42.array(inputPathSchema).min(1).max(32)
4099
4059
  }).strict(),
4100
- z40.object({
4101
- type: z40.literal("github-actions"),
4060
+ z42.object({
4061
+ type: z42.literal("github-actions"),
4102
4062
  // Omit to discover the sole artifact from the selected workflow run.
4103
4063
  // Names are supplied by CI and need not encode the PR head revision.
4104
- artifact: z40.string().min(1).max(256).optional()
4064
+ artifact: z42.string().min(1).max(256).optional()
4105
4065
  }).strict()
4106
4066
  ]);
4107
- var runPlanResourceSchema = z40.object({
4108
- name: z40.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(64),
4109
- type: z40.literal("input"),
4110
- source: z40.discriminatedUnion("type", [
4067
+ var runPlanResourceSchema = z42.object({
4068
+ name: z42.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(64),
4069
+ type: z42.literal("input"),
4070
+ source: z42.discriminatedUnion("type", [
4111
4071
  commentSourceSchema.extend({
4112
- repoUrl: z40.string(),
4113
- commit: z40.string().regex(/^[a-f0-9]{40}$/i)
4072
+ repoUrl: z42.string(),
4073
+ commit: z42.string().regex(/^[a-f0-9]{40}$/i)
4114
4074
  }).strict(),
4115
4075
  deploymentSourceSchema.extend({
4116
- repoUrl: z40.string(),
4117
- commit: z40.string().regex(/^[a-f0-9]{40}$/i)
4076
+ repoUrl: z42.string(),
4077
+ commit: z42.string().regex(/^[a-f0-9]{40}$/i)
4118
4078
  }).strict(),
4119
4079
  inputSourceSchema.options[0].extend({
4120
- repoUrl: z40.string(),
4121
- commit: z40.string().regex(/^[a-f0-9]{40}$/i)
4080
+ repoUrl: z42.string(),
4081
+ commit: z42.string().regex(/^[a-f0-9]{40}$/i)
4122
4082
  }).strict(),
4123
4083
  inputSourceSchema.options[1].extend({
4124
- repoUrl: z40.string(),
4125
- commit: z40.string().regex(/^[a-f0-9]{40}$/i),
4084
+ repoUrl: z42.string(),
4085
+ commit: z42.string().regex(/^[a-f0-9]{40}$/i),
4126
4086
  workflow: inputPathSchema
4127
4087
  }).strict()
4128
4088
  ]),
@@ -4131,42 +4091,47 @@ var runPlanResourceSchema = z40.object({
4131
4091
  (r) => r.use.type === "website" === (r.source.type === "github-deployment" || r.source.type === "github-pr-comment"),
4132
4092
  "Website inputs require a deployment or PR comment source; file inputs require git or Actions"
4133
4093
  );
4134
- var runPlanSchema = z40.object({
4135
- version: z40.literal(1),
4094
+ var runPlanSchema = z42.object({
4095
+ version: z42.literal(1),
4136
4096
  /** Existing launches keep their current measurement semantics. */
4137
- measurementMode: z40.enum(["EXISTING", "AGENT_EXPERIENCE"]),
4138
- cases: z40.array(runPlanCaseSchema).min(1),
4139
- resources: z40.array(runPlanResourceSchema).default([]),
4097
+ measurementMode: z42.enum([
4098
+ "EXISTING",
4099
+ "AGENT_EXPERIENCE",
4100
+ "AGENT_PREFERENCE",
4101
+ "MIXED"
4102
+ ]),
4103
+ cases: z42.array(runPlanCaseSchema).min(1),
4104
+ resources: z42.array(runPlanResourceSchema).default([]),
4140
4105
  /** Server-populated context retained across deferred preparation. */
4141
- launch: z40.object({
4142
- origin: z40.discriminatedUnion("initiator", [
4143
- z40.object({
4144
- initiator: z40.literal("API"),
4145
- userId: z40.string().min(1),
4146
- email: z40.string().nullable()
4106
+ launch: z42.object({
4107
+ origin: z42.discriminatedUnion("initiator", [
4108
+ z42.object({
4109
+ initiator: z42.literal("API"),
4110
+ userId: z42.string().min(1),
4111
+ email: z42.string().nullable()
4147
4112
  }).strict(),
4148
- z40.object({
4149
- initiator: z40.literal("GITHUB"),
4150
- userId: z40.null(),
4151
- email: z40.null()
4113
+ z42.object({
4114
+ initiator: z42.literal("GITHUB"),
4115
+ userId: z42.null(),
4116
+ email: z42.null()
4152
4117
  }).strict()
4153
4118
  ]),
4154
- funding: z40.enum(["ORG", "PLATFORM"]),
4155
- queueClass: z40.literal("INTERACTIVE")
4119
+ funding: z42.enum(["ORG", "PLATFORM"]),
4120
+ queueClass: z42.literal("INTERACTIVE")
4156
4121
  }).strict().optional(),
4157
- provenance: z40.object({
4158
- definition: z40.object({
4159
- repoUrl: z40.string().min(1),
4160
- commit: z40.string().regex(/^[a-f0-9]{40}$/i),
4161
- digest: z40.string().min(1),
4122
+ provenance: z42.object({
4123
+ definition: z42.object({
4124
+ repoUrl: z42.string().min(1),
4125
+ commit: z42.string().regex(/^[a-f0-9]{40}$/i),
4126
+ digest: z42.string().min(1),
4162
4127
  /** File submissions are asserted by the caller until server-side
4163
4128
  * committed-byte fetching is available. */
4164
- verification: z40.enum(["SUBMITTED_UNVERIFIED", "GITHUB_VERIFIED"]).optional()
4129
+ verification: z42.enum(["SUBMITTED_UNVERIFIED", "GITHUB_VERIFIED"]).optional()
4165
4130
  }).optional(),
4166
- liveDependencies: z40.array(
4167
- z40.object({
4168
- name: z40.string().min(1),
4169
- url: z40.string().url().optional()
4131
+ liveDependencies: z42.array(
4132
+ z42.object({
4133
+ name: z42.string().min(1),
4134
+ url: z42.string().url().optional()
4170
4135
  })
4171
4136
  ).default([])
4172
4137
  })
@@ -4190,17 +4155,23 @@ var runPlanSchema = z40.object({
4190
4155
  commandOwners.set(command, resource.name);
4191
4156
  }
4192
4157
  }
4193
- if (plan.measurementMode === "AGENT_EXPERIENCE" && !item.agents.length)
4158
+ if (plan.measurementMode !== "EXISTING" && !item.agents.length)
4194
4159
  ctx.addIssue({
4195
4160
  code: "custom",
4196
4161
  path: ["cases", index, "agents"],
4197
- message: "Agent Experience cases require a selected agent"
4162
+ message: "File cases require a selected agent"
4198
4163
  });
4199
- if (plan.measurementMode === "AGENT_EXPERIENCE" && !item.criteriaSnapshot?.criteria.length)
4164
+ if (plan.measurementMode !== "EXISTING" && !item.preferenceSnapshot && !item.criteriaSnapshot?.criteria.length)
4200
4165
  ctx.addIssue({
4201
4166
  code: "custom",
4202
4167
  path: ["cases", index, "criteriaSnapshot"],
4203
- message: "Agent Experience cases require criteria"
4168
+ message: "File cases require criteria or preference"
4169
+ });
4170
+ if (item.preferenceSnapshot && (item.criteriaSnapshot || item.evalSetId))
4171
+ ctx.addIssue({
4172
+ code: "custom",
4173
+ path: ["cases", index],
4174
+ message: "Specify exactly one measurement per case"
4204
4175
  });
4205
4176
  if (item.criteriaSnapshot && item.criteriaSnapshot.evalSetId !== (item.evalSetId ?? null))
4206
4177
  ctx.addIssue({
@@ -4232,43 +4203,43 @@ var runPlanSchema = z40.object({
4232
4203
  });
4233
4204
 
4234
4205
  // ../packages/api-schemas/src/runDefinitionInputs.ts
4235
- var definitionInputSourceSchema = z41.discriminatedUnion("type", [
4236
- z41.object({ type: z41.literal("git") }).strict(),
4237
- z41.object({
4238
- type: z41.literal("github-actions"),
4206
+ var definitionInputSourceSchema = z43.discriminatedUnion("type", [
4207
+ z43.object({ type: z43.literal("git") }).strict(),
4208
+ z43.object({
4209
+ type: z43.literal("github-actions"),
4239
4210
  workflow: inputPathSchema.regex(/^\.github\/workflows\/[^/*?{}[\]]+\.ya?ml$/).describe(
4240
4211
  "Workflow file in this repository, for example .github/workflows/build.yml."
4241
4212
  ),
4242
- artifact: z41.string().min(1).max(256).optional().describe(
4213
+ artifact: z43.string().min(1).max(256).optional().describe(
4243
4214
  "Upload name or pattern. Omit only when the workflow produces exactly one artifact."
4244
4215
  )
4245
4216
  }).strict()
4246
4217
  ]);
4247
- var skillInputPathSchema = z41.union([z41.literal("."), inputPathSchema.regex(/^[^*?{}[\]]+$/)]).describe(
4218
+ var skillInputPathSchema = z43.union([z43.literal("."), inputPathSchema.regex(/^[^*?{}[\]]+$/)]).describe(
4248
4219
  "Explicit Skill directory or ZIP/tar.gz file containing SKILL.md at its root."
4249
4220
  );
4250
- var runDefinitionInputSchema = z41.discriminatedUnion("type", [
4221
+ var runDefinitionInputSchema = z43.discriminatedUnion("type", [
4251
4222
  binaryUseSchema.extend({ source: definitionInputSourceSchema }).strict(),
4252
4223
  websiteUseSchema.extend({ source: websiteSourceSchema }).strict(),
4253
- z41.object({
4254
- type: z41.literal("npm-package"),
4224
+ z43.object({
4225
+ type: z43.literal("npm-package"),
4255
4226
  source: definitionInputSourceSchema,
4256
4227
  path: inputPathSchema.describe(
4257
4228
  "Path or glob selecting exactly one packed npm .tgz file."
4258
4229
  ),
4259
- install: z41.enum(["environment", "workspace"]).default("environment").describe(
4230
+ install: z43.enum(["environment", "workspace"]).default("environment").describe(
4260
4231
  "environment exposes the package's commands on PATH; workspace adds a consumer application dependency."
4261
4232
  )
4262
4233
  }).strict(),
4263
- z41.object({
4264
- type: z41.literal("skill"),
4234
+ z43.object({
4235
+ type: z43.literal("skill"),
4265
4236
  source: definitionInputSourceSchema,
4266
4237
  path: skillInputPathSchema
4267
4238
  }).strict(),
4268
- z41.object({
4269
- type: z41.literal("files"),
4239
+ z43.object({
4240
+ type: z43.literal("files"),
4270
4241
  source: definitionInputSourceSchema,
4271
- paths: z41.array(inputPathSchema).min(1).max(32).describe(
4242
+ paths: z43.array(inputPathSchema).min(1).max(32).describe(
4272
4243
  "Files or globs selected from the committed Git tree or the uploaded artifact."
4273
4244
  )
4274
4245
  }).strict()
@@ -4302,7 +4273,7 @@ function compileDefinitionInput(name, input, repoUrl, commit) {
4302
4273
  }
4303
4274
 
4304
4275
  // ../packages/api-schemas/src/runDefinitions.ts
4305
- var uncredentialedRepoUrlSchema = z42.string().min(1).refine((raw) => {
4276
+ var uncredentialedRepoUrlSchema = z44.string().min(1).refine((raw) => {
4306
4277
  if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(raw)) return true;
4307
4278
  try {
4308
4279
  const url = new URL(raw);
@@ -4311,54 +4282,67 @@ var uncredentialedRepoUrlSchema = z42.string().min(1).refine((raw) => {
4311
4282
  return false;
4312
4283
  }
4313
4284
  }, "Repository URL must not contain embedded credentials or query parameters");
4314
- var runDefinitionChecksSchema = z42.object({ paths: z42.array(inputPathSchema).min(1).max(32) }).strict();
4315
- var runDefinitionConfigSchema = z42.object({
4316
- agents: z42.array(agentConfigInputSchema).min(1),
4317
- sampleCount: z42.number().int().min(1).max(50).optional(),
4285
+ var runDefinitionChecksSchema = z44.object({ paths: z44.array(inputPathSchema).min(1).max(32) }).strict();
4286
+ var runDefinitionConfigSchema = z44.object({
4287
+ agents: z44.array(agentConfigInputSchema).min(1),
4288
+ sampleCount: z44.number().int().min(1).max(50).optional(),
4318
4289
  repoUrl: uncredentialedRepoUrlSchema.nullable().optional(),
4319
- repoRef: z42.string().min(1).nullable().optional(),
4320
- profileId: z42.string().min(1).nullable().optional(),
4290
+ repoRef: z44.string().min(1).nullable().optional(),
4291
+ profileId: z44.string().min(1).nullable().optional(),
4321
4292
  skillRefs: assetRefListSchema.optional(),
4322
4293
  mcpRefs: assetRefListSchema.optional(),
4323
- connectionIds: z42.array(z42.string().min(1)).max(32).optional(),
4294
+ connectionIds: z44.array(z44.string().min(1)).max(32).optional(),
4324
4295
  addons: runAddonsSchema.optional(),
4325
- inputs: z42.array(z42.string()).optional(),
4296
+ inputs: z44.array(z44.string()).optional(),
4326
4297
  checks: runDefinitionChecksSchema.optional()
4327
4298
  }).strict();
4328
- var runDefinitionFileConfigSchema = z42.object({
4329
- version: z42.literal(2).default(2),
4330
- org: z42.string().min(1).optional(),
4299
+ var runDefinitionFileConfigSchema = z44.object({
4300
+ version: z44.literal(2).default(2),
4301
+ org: z44.string().min(1).optional(),
4331
4302
  checks: runDefinitionChecksSchema.optional(),
4332
- cases: z42.array(inputPathSchema).min(1).max(32).default(["gauge-evals/**/*.md"]),
4333
- inputs: z42.record(
4334
- z42.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(64),
4303
+ cases: z44.array(inputPathSchema).min(1).max(32).default(["gauge-evals/**/*.md"]),
4304
+ inputs: z44.record(
4305
+ z44.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(64),
4335
4306
  runDefinitionInputSchema
4336
4307
  ).refine(
4337
4308
  (inputs) => Object.keys(inputs).length <= 32,
4338
4309
  "At most 32 inputs are allowed"
4339
4310
  ).meta({ maxProperties: 32 }).default({})
4340
4311
  }).strict();
4341
- var runDefinitionCriterionSchema = z42.object({ name: z42.string().min(1), rubric: z42.string().min(1) }).strict();
4342
- var runDefinitionFrontmatterSchema = z42.object({
4343
- criteria: z42.array(runDefinitionCriterionSchema).min(1),
4312
+ var runDefinitionCriterionSchema = z44.object({ name: z44.string().min(1), rubric: z44.string().min(1) }).strict();
4313
+ var caseMeasurement = {
4314
+ criteria: z44.array(runDefinitionCriterionSchema).min(1).optional(),
4315
+ preference: preferenceDefinitionSchema.optional()
4316
+ };
4317
+ function exactlyOneMeasurement(item) {
4318
+ return item.criteria !== void 0 !== (item.preference !== void 0);
4319
+ }
4320
+ var runDefinitionFrontmatterSchema = z44.object({
4321
+ ...caseMeasurement,
4344
4322
  config: runDefinitionConfigSchema
4345
- }).strict();
4346
- var runDefinitionCaseSchema = z42.object({
4347
- path: z42.string().min(1),
4348
- prompt: z42.string().min(1),
4349
- criteria: z42.array(runDefinitionCriterionSchema).min(1),
4323
+ }).strict().refine(
4324
+ exactlyOneMeasurement,
4325
+ "Specify exactly one of criteria or preference"
4326
+ );
4327
+ var runDefinitionCaseSchema = z44.object({
4328
+ path: z44.string().min(1),
4329
+ prompt: z44.string().min(1),
4330
+ ...caseMeasurement,
4350
4331
  config: runDefinitionConfigSchema
4351
- }).strict();
4352
- var runDefinitionSubmissionSchema = z42.object({
4353
- version: z42.literal(2),
4354
- source: z42.object({
4332
+ }).strict().refine(
4333
+ exactlyOneMeasurement,
4334
+ "Specify exactly one of criteria or preference"
4335
+ );
4336
+ var runDefinitionSubmissionSchema = z44.object({
4337
+ version: z44.literal(2),
4338
+ source: z44.object({
4355
4339
  repoUrl: uncredentialedRepoUrlSchema,
4356
- commit: z42.string().regex(/^[a-f0-9]{40}$/i),
4357
- digest: z42.string().regex(/^sha256:[a-f0-9]{64}$/),
4358
- verification: z42.enum(["SUBMITTED_UNVERIFIED", "GITHUB_VERIFIED"])
4340
+ commit: z44.string().regex(/^[a-f0-9]{40}$/i),
4341
+ digest: z44.string().regex(/^sha256:[a-f0-9]{64}$/),
4342
+ verification: z44.enum(["SUBMITTED_UNVERIFIED", "GITHUB_VERIFIED"])
4359
4343
  }).strict(),
4360
- resources: z42.array(runPlanResourceSchema).max(32).default([]),
4361
- cases: z42.array(runDefinitionCaseSchema).min(1).max(20)
4344
+ resources: z44.array(runPlanResourceSchema).max(32).default([]),
4345
+ cases: z44.array(runDefinitionCaseSchema).min(1).max(20)
4362
4346
  }).strict().superRefine((definition, ctx) => {
4363
4347
  const paths = /* @__PURE__ */ new Set();
4364
4348
  for (const [index, item] of definition.cases.entries()) {
@@ -4401,54 +4385,55 @@ var runDefinitionPublicSubmissionSchema = runDefinitionSubmissionSchema.refine(
4401
4385
  message: "Only the GitHub App may verify committed bytes"
4402
4386
  }
4403
4387
  );
4404
- var runDefinitionPlanResponseSchema = z42.object({
4388
+ var runDefinitionPlanResponseSchema = z44.object({
4405
4389
  source: runDefinitionSubmissionSchema.shape.source,
4406
- measurementMode: z42.literal("AGENT_EXPERIENCE"),
4407
- cases: z42.array(
4408
- z42.object({
4409
- path: z42.string(),
4410
- agents: z42.array(agentConfigSchema),
4411
- samples: z42.number().int().nonnegative(),
4412
- expectedRuns: z42.number().int().nonnegative(),
4413
- workspace: z42.object({
4414
- repoUrl: z42.string().nullable(),
4415
- repoRef: z42.string().nullable()
4390
+ measurementMode: z44.enum(["AGENT_EXPERIENCE", "AGENT_PREFERENCE", "MIXED"]),
4391
+ cases: z44.array(
4392
+ z44.object({
4393
+ path: z44.string(),
4394
+ agents: z44.array(agentConfigSchema),
4395
+ samples: z44.number().int().nonnegative(),
4396
+ expectedRuns: z44.number().int().nonnegative(),
4397
+ workspace: z44.object({
4398
+ repoUrl: z44.string().nullable(),
4399
+ repoRef: z44.string().nullable()
4416
4400
  }),
4417
- criteriaCount: z42.number().int().nonnegative(),
4418
- inputs: z42.array(z42.string())
4401
+ criteriaCount: z44.number().int().nonnegative(),
4402
+ preference: preferenceDefinitionSchema.optional(),
4403
+ inputs: z44.array(z44.string())
4419
4404
  })
4420
4405
  ),
4421
- resources: z42.array(
4422
- z42.object({
4423
- name: z42.string(),
4424
- type: z42.literal("input"),
4425
- source: z42.enum([
4406
+ resources: z44.array(
4407
+ z44.object({
4408
+ name: z44.string(),
4409
+ type: z44.literal("input"),
4410
+ source: z44.enum([
4426
4411
  "git",
4427
4412
  "github-actions",
4428
4413
  "github-deployment",
4429
4414
  "github-pr-comment"
4430
4415
  ]),
4431
4416
  use: inputUseSchema,
4432
- readiness: z42.enum(["READY", "WAITING", "FAILED"]),
4433
- detail: z42.string().optional(),
4434
- commands: z42.array(z42.string()).optional()
4417
+ readiness: z44.enum(["READY", "WAITING", "FAILED"]),
4418
+ detail: z44.string().optional(),
4419
+ commands: z44.array(z44.string()).optional()
4435
4420
  })
4436
4421
  ),
4437
- expectedRuns: z42.number().int().nonnegative(),
4438
- canRun: z42.boolean()
4422
+ expectedRuns: z44.number().int().nonnegative(),
4423
+ canRun: z44.boolean()
4439
4424
  });
4440
- var runDefinitionRunResponseSchema = z42.object({
4441
- runRequestId: z42.string(),
4442
- batchIds: z42.array(z42.string()),
4443
- runIds: z42.array(z42.string()),
4444
- requestedRuns: z42.number().int().nonnegative(),
4445
- createdRuns: z42.number().int().nonnegative(),
4446
- aggregateUrl: z42.string()
4425
+ var runDefinitionRunResponseSchema = z44.object({
4426
+ runRequestId: z44.string(),
4427
+ batchIds: z44.array(z44.string()),
4428
+ runIds: z44.array(z44.string()),
4429
+ requestedRuns: z44.number().int().nonnegative(),
4430
+ createdRuns: z44.number().int().nonnegative(),
4431
+ aggregateUrl: z44.string()
4447
4432
  });
4448
4433
 
4449
4434
  // ../packages/api-schemas/src/runRequests.ts
4450
- import { z as z43 } from "zod";
4451
- var runRequestStatusSchema = z43.enum([
4435
+ import { z as z45 } from "zod";
4436
+ var runRequestStatusSchema = z45.enum([
4452
4437
  "PENDING",
4453
4438
  "PREPARING",
4454
4439
  "RUNNING",
@@ -4456,9 +4441,10 @@ var runRequestStatusSchema = z43.enum([
4456
4441
  "FAILED",
4457
4442
  "CANCELED"
4458
4443
  ]);
4459
- var runRequestResultSchema = z43.enum([
4444
+ var runRequestResultSchema = z45.enum([
4460
4445
  "PENDING",
4461
4446
  "PASSED",
4447
+ "MEASURED",
4462
4448
  "QUALITY_FAILED",
4463
4449
  "EXECUTION_FAILED",
4464
4450
  "INPUT_FAILED",
@@ -4466,224 +4452,229 @@ var runRequestResultSchema = z43.enum([
4466
4452
  "INCOMPLETE",
4467
4453
  "CANCELED"
4468
4454
  ]);
4469
- var runRequestCriterionResultSchema = z43.object({
4470
- criterionId: z43.string().nullable(),
4471
- name: z43.string(),
4472
- passed: z43.boolean(),
4473
- reasoning: z43.string().nullable()
4474
- });
4475
- var runRequestRunSchema = z43.object({
4476
- id: z43.string(),
4477
- batchId: z43.string(),
4478
- status: z43.string(),
4455
+ var runRequestCriterionResultSchema = z45.object({
4456
+ criterionId: z45.string().nullable(),
4457
+ name: z45.string(),
4458
+ passed: z45.boolean(),
4459
+ reasoning: z45.string().nullable()
4460
+ });
4461
+ var runRequestRunSchema = z45.object({
4462
+ id: z45.string(),
4463
+ batchId: z45.string(),
4464
+ status: z45.string(),
4479
4465
  agent: agentSchema,
4480
- model: z43.string(),
4466
+ model: z45.string(),
4481
4467
  result: runRequestResultSchema,
4482
- judge: z43.object({ status: z43.string() }).nullable(),
4483
- criterionResults: z43.array(runRequestCriterionResultSchema)
4468
+ judge: z45.object({ status: z45.string() }).nullable(),
4469
+ criterionResults: z45.array(runRequestCriterionResultSchema),
4470
+ preference: visibilityVerdictSchema.nullable().optional(),
4471
+ measurement: z45.enum(["experience", "preference"]).optional()
4484
4472
  });
4485
- var runRequestResponseSchema = z43.object({
4486
- id: z43.string(),
4473
+ var runRequestResponseSchema = z45.object({
4474
+ id: z45.string(),
4487
4475
  status: runRequestStatusSchema,
4488
4476
  result: runRequestResultSchema,
4489
- error: z43.string().nullable().optional(),
4490
- inputs: z43.unknown().optional(),
4491
- settled: z43.boolean(),
4492
- counts: z43.object({
4493
- requestedRuns: z43.number().int().nonnegative(),
4494
- createdRuns: z43.number().int().nonnegative(),
4495
- terminalRuns: z43.number().int().nonnegative(),
4496
- judgedRuns: z43.number().int().nonnegative(),
4497
- passedRuns: z43.number().int().nonnegative(),
4498
- qualityFailedRuns: z43.number().int().nonnegative(),
4499
- executionFailedRuns: z43.number().int().nonnegative(),
4500
- judgeFailedRuns: z43.number().int().nonnegative(),
4501
- pendingRuns: z43.number().int().nonnegative()
4477
+ error: z45.string().nullable().optional(),
4478
+ inputs: z45.unknown().optional(),
4479
+ settled: z45.boolean(),
4480
+ counts: z45.object({
4481
+ requestedRuns: z45.number().int().nonnegative(),
4482
+ createdRuns: z45.number().int().nonnegative(),
4483
+ terminalRuns: z45.number().int().nonnegative(),
4484
+ judgedRuns: z45.number().int().nonnegative(),
4485
+ passedRuns: z45.number().int().nonnegative(),
4486
+ measuredRuns: z45.number().int().nonnegative().optional(),
4487
+ qualityFailedRuns: z45.number().int().nonnegative(),
4488
+ executionFailedRuns: z45.number().int().nonnegative(),
4489
+ judgeFailedRuns: z45.number().int().nonnegative(),
4490
+ pendingRuns: z45.number().int().nonnegative()
4502
4491
  }),
4503
- batches: z43.array(
4504
- z43.object({ id: z43.string(), runs: z43.array(runRequestRunSchema) })
4492
+ batches: z45.array(
4493
+ z45.object({ id: z45.string(), runs: z45.array(runRequestRunSchema) })
4505
4494
  ),
4506
- createdAt: z43.string(),
4507
- updatedAt: z43.string(),
4508
- finishedAt: z43.string().nullable()
4495
+ createdAt: z45.string(),
4496
+ updatedAt: z45.string(),
4497
+ finishedAt: z45.string().nullable()
4509
4498
  });
4510
4499
 
4511
4500
  // ../packages/api-schemas/src/summary.ts
4512
- import { z as z44 } from "zod";
4501
+ import { z as z46 } from "zod";
4513
4502
  function cardResultSchema(data) {
4514
- return z44.union([
4515
- z44.object({ ok: z44.literal(true), data }),
4516
- z44.object({ ok: z44.literal(false), error: z44.string() })
4503
+ return z46.union([
4504
+ z46.object({ ok: z46.literal(true), data }),
4505
+ z46.object({ ok: z46.literal(false), error: z46.string() })
4517
4506
  ]);
4518
4507
  }
4519
- var summaryActionSchema = z44.object({
4520
- id: z44.string(),
4521
- title: z44.string(),
4522
- priority: z44.string(),
4523
- status: z44.string(),
4524
- evidenceCount: z44.number().int()
4525
- });
4526
- var summaryAeCardSchema = z44.object({
4527
- id: z44.string(),
4528
- name: z44.string(),
4529
- judgedRuns: z44.number().int(),
4530
- passRate: z44.number().nullable(),
4508
+ var summaryActionSchema = z46.object({
4509
+ id: z46.string(),
4510
+ title: z46.string(),
4511
+ priority: z46.string(),
4512
+ status: z46.string(),
4513
+ evidenceCount: z46.number().int()
4514
+ });
4515
+ var summaryAeCardSchema = z46.object({
4516
+ id: z46.string(),
4517
+ name: z46.string(),
4518
+ judgedRuns: z46.number().int(),
4519
+ passRate: z46.number().nullable(),
4531
4520
  /** pp delta vs the prior 30d; null with no prior. */
4532
- deltaPP: z44.number().nullable()
4533
- });
4534
- var summaryVisibilityCardSchema = z44.object({
4535
- name: z44.string(),
4536
- owned: z44.object({
4537
- name: z44.string(),
4538
- rank: z44.number(),
4539
- chosenRate: z44.number(),
4540
- mentionRate: z44.number()
4521
+ deltaPP: z46.number().nullable()
4522
+ });
4523
+ var summaryVisibilityCardSchema = z46.object({
4524
+ name: z46.string(),
4525
+ owned: z46.object({
4526
+ name: z46.string(),
4527
+ rank: z46.number(),
4528
+ chosenRate: z46.number(),
4529
+ mentionRate: z46.number()
4541
4530
  }).nullable(),
4542
- chosenDeltaPP: z44.number().nullable()
4531
+ chosenDeltaPP: z46.number().nullable()
4543
4532
  });
4544
- var homeSummarySchema = z44.object({
4545
- hasAnyRuns: z44.boolean(),
4546
- lastSynthesisAt: z44.string().nullable(),
4547
- actions: cardResultSchema(z44.array(summaryActionSchema)),
4533
+ var homeSummarySchema = z46.object({
4534
+ hasAnyRuns: z46.boolean(),
4535
+ lastSynthesisAt: z46.string().nullable(),
4536
+ actions: cardResultSchema(z46.array(summaryActionSchema)),
4548
4537
  visibility: cardResultSchema(
4549
- z44.object({
4550
- cards: z44.array(summaryVisibilityCardSchema),
4551
- marketsTotal: z44.number().int(),
4552
- promptCount: z44.number().int()
4538
+ z46.object({
4539
+ cards: z46.array(summaryVisibilityCardSchema),
4540
+ marketsTotal: z46.number().int(),
4541
+ promptCount: z46.number().int()
4553
4542
  })
4554
4543
  ),
4555
4544
  agentExperience: cardResultSchema(
4556
- z44.object({
4557
- cards: z44.array(summaryAeCardSchema),
4558
- total: z44.number().int(),
4559
- setCount: z44.number().int()
4545
+ z46.object({
4546
+ cards: z46.array(summaryAeCardSchema),
4547
+ total: z46.number().int(),
4548
+ setCount: z46.number().int()
4560
4549
  })
4561
4550
  ),
4562
- notableSessions: cardResultSchema(z44.array(z44.unknown()))
4551
+ notableSessions: cardResultSchema(z46.array(z46.unknown()))
4563
4552
  });
4564
4553
 
4565
4554
  // ../packages/api-schemas/src/tokens.ts
4566
- import { z as z45 } from "zod";
4567
- var apiTokenSchema = z45.object({
4568
- id: z45.string(),
4569
- name: z45.string(),
4555
+ import { z as z47 } from "zod";
4556
+ var apiTokenSchema = z47.object({
4557
+ id: z47.string(),
4558
+ name: z47.string(),
4570
4559
  /** Last 4 chars of the plaintext, for recognizability (non-secret). */
4571
- last4: z45.string(),
4572
- expiresAt: z45.iso.datetime().nullable(),
4573
- lastUsedAt: z45.iso.datetime().nullable(),
4574
- createdAt: z45.iso.datetime(),
4575
- revokedAt: z45.iso.datetime().nullable()
4576
- });
4577
- var createTokenRequestSchema = z45.object({
4578
- name: z45.string().min(1).max(100),
4560
+ last4: z47.string(),
4561
+ expiresAt: z47.iso.datetime().nullable(),
4562
+ lastUsedAt: z47.iso.datetime().nullable(),
4563
+ createdAt: z47.iso.datetime(),
4564
+ revokedAt: z47.iso.datetime().nullable()
4565
+ });
4566
+ var createTokenRequestSchema = z47.object({
4567
+ name: z47.string().min(1).max(100),
4579
4568
  /** ISO-8601 datetime; omit for no expiry. */
4580
- expiresAt: z45.iso.datetime({ offset: true }).optional()
4569
+ expiresAt: z47.iso.datetime({ offset: true }).optional()
4581
4570
  });
4582
4571
  var createTokenResponseSchema = apiTokenSchema.extend({
4583
- token: z45.string()
4572
+ token: z47.string()
4584
4573
  });
4585
4574
  var listTokensResponseSchema = listResponseSchema(apiTokenSchema);
4586
4575
 
4587
4576
  // ../packages/api-schemas/src/visibility.ts
4588
- import { z as z46 } from "zod";
4577
+ import { z as z48 } from "zod";
4589
4578
  var VISIBILITY_PROMPT_KINDS = ["HEAD_TO_HEAD", "RECOMMEND"];
4590
- var visibilityPromptKindSchema = z46.enum(VISIBILITY_PROMPT_KINDS);
4579
+ var visibilityPromptKindSchema = z48.enum(VISIBILITY_PROMPT_KINDS);
4591
4580
  var visibilityPromptSchema = visibilityPromptSettingsSchema.extend({
4592
- id: z46.string(),
4593
- name: z46.string(),
4581
+ id: z48.string(),
4582
+ name: z48.string(),
4594
4583
  kind: visibilityPromptKindSchema,
4595
- promptText: z46.string(),
4584
+ promptText: z48.string(),
4596
4585
  /** HEAD_TO_HEAD is always branded; RECOMMEND may be either. */
4597
- branded: z46.boolean(),
4598
- brandA: z46.string().nullable(),
4599
- brandB: z46.string().nullable(),
4600
- market: z46.object({ id: z46.string(), slug: z46.string(), name: z46.string() }).nullable(),
4601
- position: z46.number().int(),
4602
- createdAt: z46.string(),
4586
+ branded: z48.boolean(),
4587
+ brandA: z48.string().nullable(),
4588
+ brandB: z48.string().nullable(),
4589
+ market: z48.object({ id: z48.string(), slug: z48.string(), name: z48.string() }).nullable(),
4590
+ position: z48.number().int(),
4591
+ createdAt: z48.string(),
4603
4592
  /** User tag names on the hidden backing prompt (Surface:* excluded). */
4604
- tags: z46.array(z46.string()),
4605
- runCount: z46.number().int(),
4606
- lastRunAt: z46.string().nullable(),
4607
- scenarios: z46.array(visibilityScenarioSchema)
4593
+ tags: z48.array(z48.string()),
4594
+ runCount: z48.number().int(),
4595
+ lastRunAt: z48.string().nullable(),
4596
+ scenarios: z48.array(visibilityScenarioSchema)
4608
4597
  });
4609
- var listVisibilityPromptsResponseSchema = z46.object({
4610
- items: z46.array(visibilityPromptSchema)
4598
+ var listVisibilityPromptsResponseSchema = z48.object({
4599
+ items: z48.array(visibilityPromptSchema)
4611
4600
  });
4612
- var createVisibilityPromptBodySchema = z46.object({
4613
- name: z46.string().min(1),
4614
- promptText: z46.string().min(1),
4601
+ var createVisibilityPromptBodySchema = z48.object({
4602
+ name: z48.string().min(1),
4603
+ promptText: z48.string().min(1),
4615
4604
  kind: visibilityPromptKindSchema,
4616
- branded: z46.boolean().optional(),
4605
+ branded: z48.boolean().optional(),
4617
4606
  /** Required pair for HEAD_TO_HEAD (order-independent). */
4618
- brandA: z46.string().nullish(),
4619
- brandB: z46.string().nullish(),
4607
+ brandA: z48.string().nullish(),
4608
+ brandB: z48.string().nullish(),
4620
4609
  /** Measured market id from the org's tracked set. */
4621
- marketId: z46.string().nullish(),
4622
- tags: z46.array(z46.string()).optional(),
4610
+ marketId: z48.string().nullish(),
4611
+ tags: z48.array(z48.string()).optional(),
4623
4612
  agents: visibilityPromptSettingsInputShape.agents.optional(),
4624
4613
  skillRefs: visibilityPromptSettingsInputShape.skillRefs,
4625
4614
  mcpRefs: visibilityPromptSettingsInputShape.mcpRefs,
4626
4615
  connectionIds: visibilityPromptSettingsInputShape.connectionIds,
4627
4616
  cadence: visibilityPromptSettingsInputShape.cadence,
4628
4617
  sampleCount: visibilityPromptSettingsInputShape.sampleCount,
4629
- scenarios: z46.array(visibilityScenarioInputSchema).optional().default([])
4618
+ scenarios: z48.array(visibilityScenarioInputSchema).optional().default([])
4630
4619
  }).strict();
4631
- var synthesizeResponseSchema = z46.object({
4620
+ var synthesizeResponseSchema = z48.object({
4632
4621
  /** False when the pre-check found no new evidence and nothing was queued. */
4633
- queued: z46.boolean()
4634
- });
4635
- var updateVisibilityPromptBodySchema = z46.object({
4636
- name: z46.string().min(1).optional(),
4637
- promptText: z46.string().min(1).optional(),
4638
- branded: z46.boolean().optional(),
4639
- brandA: z46.string().nullish(),
4640
- brandB: z46.string().nullish(),
4641
- marketId: z46.string().nullish(),
4642
- tags: z46.array(z46.string()).optional(),
4622
+ queued: z48.boolean()
4623
+ });
4624
+ var updateVisibilityPromptBodySchema = z48.object({
4625
+ name: z48.string().min(1).optional(),
4626
+ promptText: z48.string().min(1).optional(),
4627
+ branded: z48.boolean().optional(),
4628
+ brandA: z48.string().nullish(),
4629
+ brandB: z48.string().nullish(),
4630
+ marketId: z48.string().nullish(),
4631
+ tags: z48.array(z48.string()).optional(),
4643
4632
  ...visibilityPromptSettingsPatchShape,
4644
4633
  /** Replaces the whole scenario set when present. */
4645
- scenarios: z46.array(visibilityScenarioInputSchema).optional()
4634
+ scenarios: z48.array(visibilityScenarioInputSchema).optional()
4646
4635
  }).strict();
4647
- var runVisibilityPromptResponseSchema = z46.object({
4648
- batchIds: z46.array(z46.string()),
4649
- runIds: z46.array(z46.string())
4636
+ var runVisibilityPromptResponseSchema = z48.object({
4637
+ batchIds: z48.array(z48.string()),
4638
+ runIds: z48.array(z48.string())
4650
4639
  });
4651
- var visibilityPromptRunSchema = z46.object({
4652
- id: z46.string(),
4653
- status: z46.string(),
4640
+ var visibilityPromptRunSchema = z48.object({
4641
+ id: z48.string(),
4642
+ status: z48.string(),
4654
4643
  agent: agentSchema,
4655
- model: z46.string().nullable(),
4656
- resolvedModel: z46.string().nullable(),
4657
- createdAt: z46.string(),
4658
- startedAt: z46.string().nullable(),
4659
- finishedAt: z46.string().nullable(),
4660
- failureReason: z46.string().nullable(),
4661
- verdict: z46.object({
4662
- status: z46.string(),
4663
- error: z46.string().nullable(),
4664
- payload: z46.unknown().nullable()
4644
+ model: z48.string().nullable(),
4645
+ resolvedModel: z48.string().nullable(),
4646
+ createdAt: z48.string(),
4647
+ startedAt: z48.string().nullable(),
4648
+ finishedAt: z48.string().nullable(),
4649
+ failureReason: z48.string().nullable(),
4650
+ creditsCharged: runCreditsChargedSchema.optional(),
4651
+ triggeredBy: runTriggeredBySchema.optional(),
4652
+ verdict: z48.object({
4653
+ status: z48.string(),
4654
+ error: z48.string().nullable(),
4655
+ payload: z48.unknown().nullable()
4665
4656
  }).nullable()
4666
4657
  });
4667
- var listVisibilityPromptRunsResponseSchema = z46.object({
4668
- items: z46.array(visibilityPromptRunSchema)
4669
- });
4670
- var orgMarketSchema = z46.object({
4671
- marketId: z46.string(),
4672
- slug: z46.string(),
4673
- name: z46.string(),
4658
+ var listVisibilityPromptRunsResponseSchema = listResponseSchema(
4659
+ visibilityPromptRunSchema
4660
+ );
4661
+ var orgMarketSchema = z48.object({
4662
+ marketId: z48.string(),
4663
+ slug: z48.string(),
4664
+ name: z48.string(),
4674
4665
  /** The one line saying what the market measures. */
4675
- capability: z46.string(),
4666
+ capability: z48.string(),
4676
4667
  /** SUGGESTED (the matcher) | USER (a human picked it). */
4677
- source: z46.string()
4668
+ source: z48.string()
4678
4669
  });
4679
4670
  var addableMarketSchema = orgMarketSchema.omit({ source: true });
4680
- var listMarketsResponseSchema = z46.object({
4681
- tracked: z46.array(orgMarketSchema),
4671
+ var listMarketsResponseSchema = z48.object({
4672
+ tracked: z48.array(orgMarketSchema),
4682
4673
  /** Published markets the org does not track yet (closed set — no free-text
4683
4674
  * market creation). */
4684
- addable: z46.array(addableMarketSchema)
4675
+ addable: z48.array(addableMarketSchema)
4685
4676
  });
4686
- var addMarketBodySchema = z46.object({ marketId: z46.string().min(1) });
4677
+ var addMarketBodySchema = z48.object({ marketId: z48.string().min(1) });
4687
4678
 
4688
4679
  // src/version.ts
4689
4680
  import { createRequire } from "module";
@@ -4751,9 +4742,9 @@ function resolveToken() {
4751
4742
  return null;
4752
4743
  }
4753
4744
  }
4754
- function saveToken(token2) {
4745
+ function saveToken(token) {
4755
4746
  mkdirSync2(configDir(), { recursive: true, mode: 448 });
4756
- writeFileSync2(credentialsPath(), `${token2.trim()}
4747
+ writeFileSync2(credentialsPath(), `${token.trim()}
4757
4748
  `, {
4758
4749
  encoding: "utf8",
4759
4750
  mode: 384
@@ -4802,14 +4793,14 @@ var ApiClient = class {
4802
4793
  async get(path3, query) {
4803
4794
  return this.request("GET", path3, { query });
4804
4795
  }
4805
- async post(path3, body, query) {
4806
- return this.request("POST", path3, { body, query });
4796
+ async post(path3, body2, query) {
4797
+ return this.request("POST", path3, { body: body2, query });
4807
4798
  }
4808
- async patch(path3, body, query) {
4809
- return this.request("PATCH", path3, { body, query });
4799
+ async patch(path3, body2, query) {
4800
+ return this.request("PATCH", path3, { body: body2, query });
4810
4801
  }
4811
- async put(path3, body, query) {
4812
- return this.request("PUT", path3, { body, query });
4802
+ async put(path3, body2, query) {
4803
+ return this.request("PUT", path3, { body: body2, query });
4813
4804
  }
4814
4805
  async delete(path3, query) {
4815
4806
  return this.request("DELETE", path3, { query });
@@ -4831,20 +4822,20 @@ var ApiClient = class {
4831
4822
  }
4832
4823
  const reader = res.body.getReader();
4833
4824
  const decoder = new TextDecoder();
4834
- let buffer = "";
4825
+ let buffer2 = "";
4835
4826
  try {
4836
4827
  while (true) {
4837
4828
  const { done, value } = await reader.read();
4838
4829
  if (done) break;
4839
- buffer += decoder.decode(value, { stream: true });
4840
- let boundary = buffer.indexOf("\n\n");
4830
+ buffer2 += decoder.decode(value, { stream: true });
4831
+ let boundary = buffer2.indexOf("\n\n");
4841
4832
  while (boundary !== -1) {
4842
- const raw = buffer.slice(0, boundary);
4833
+ const raw = buffer2.slice(0, boundary);
4843
4834
  const event = parseSseFrame(raw);
4844
- buffer = buffer.slice(boundary + 2);
4835
+ buffer2 = buffer2.slice(boundary + 2);
4845
4836
  if (event) onEvent(event);
4846
4837
  else if (raw.trimStart().startsWith(":")) options.onComment?.();
4847
- boundary = buffer.indexOf("\n\n");
4838
+ boundary = buffer2.indexOf("\n\n");
4848
4839
  }
4849
4840
  }
4850
4841
  } catch (error) {
@@ -4895,13 +4886,13 @@ var ApiClient = class {
4895
4886
  });
4896
4887
  if (!res.ok) throw await this.toError(res);
4897
4888
  if (res.status === 204) return void 0;
4898
- const text = await res.text();
4899
- if (!text) return void 0;
4889
+ const text2 = await res.text();
4890
+ if (!text2) return void 0;
4900
4891
  const contentType = res.headers.get("content-type") ?? "";
4901
4892
  if (contentType.includes("application/json")) {
4902
- return JSON.parse(text);
4893
+ return JSON.parse(text2);
4903
4894
  }
4904
- return text;
4895
+ return text2;
4905
4896
  }
4906
4897
  async toError(res) {
4907
4898
  try {
@@ -5049,10 +5040,10 @@ function register(program2) {
5049
5040
  );
5050
5041
  });
5051
5042
  group.command("status <id> <status>").description("Transition an action: open | resolved | dismissed").option("--note <text>", "resolution note (recorded when closing)").action(
5052
- async (id, status, opts, cmd) => {
5043
+ async (id2, status, opts, cmd) => {
5053
5044
  const org = resolveOrg(cmd);
5054
5045
  const updated = await createClient().patch(
5055
- `${actionsPath(org)}/${encodeURIComponent(id)}`,
5046
+ `${actionsPath(org)}/${encodeURIComponent(id2)}`,
5056
5047
  { status: parseStatus(status), note: opts.note }
5057
5048
  );
5058
5049
  if (resolveOutput(cmd) === "json") printJson(updated);
@@ -5068,7 +5059,7 @@ __export(apply_exports, {
5068
5059
  register: () => register2
5069
5060
  });
5070
5061
  import { readFileSync as readFileSync3 } from "fs";
5071
- import { z as z47 } from "zod";
5062
+ import { z as z49 } from "zod";
5072
5063
  function assertRequiredExperiment(spec, required) {
5073
5064
  if (required.length === 0) {
5074
5065
  throw new CliError(
@@ -5201,7 +5192,7 @@ function printApplied(res) {
5201
5192
  console.log(
5202
5193
  `Applied${res.experiment ? ` (experiment: ${res.experiment})` : ""} \u2014 ${res.batchIds.length} batch(es), ${res.runIds.length} run(s) enqueued`
5203
5194
  );
5204
- for (const id of res.runIds) console.log(` run ${id}`);
5195
+ for (const id2 of res.runIds) console.log(` run ${id2}`);
5205
5196
  if (res.runIds.length > 0) {
5206
5197
  console.error(`(watch one live: gauge runs watch ${res.runIds[0]})`);
5207
5198
  }
@@ -5220,7 +5211,7 @@ function register2(program2) {
5220
5211
  ).option("--schema", "print the battery spec JSON Schema and exit").option("--example", "print a minimal example battery spec and exit").action(
5221
5212
  async (opts, command) => {
5222
5213
  if (opts.schema) {
5223
- printJson(z47.toJSONSchema(batteries_exports.batterySpecSchema));
5214
+ printJson(z49.toJSONSchema(batteries_exports.batterySpecSchema));
5224
5215
  return;
5225
5216
  }
5226
5217
  if (opts.example) {
@@ -5414,9 +5405,9 @@ async function browserLogin() {
5414
5405
  );
5415
5406
  }
5416
5407
  const exchange = parsed.data;
5417
- const token2 = exchange.accessToken;
5418
- const me = await fetchMe(new ApiClient({ token: token2 }));
5419
- saveToken(token2);
5408
+ const token = exchange.accessToken;
5409
+ const me = await fetchMe(new ApiClient({ token }));
5410
+ saveToken(token);
5420
5411
  console.log(`Token saved to ${credentialsPath()}`);
5421
5412
  printIdentity(me);
5422
5413
  } finally {
@@ -5426,7 +5417,7 @@ async function browserLogin() {
5426
5417
  }
5427
5418
  }
5428
5419
  var DEVICE_ENDPOINT = "/api/v1/device";
5429
- async function bootstrapPost(path3, body) {
5420
+ async function bootstrapPost(path3, body2) {
5430
5421
  const base = resolveBaseUrl().replace(/\/+$/, "");
5431
5422
  let res;
5432
5423
  try {
@@ -5437,7 +5428,7 @@ async function bootstrapPost(path3, body) {
5437
5428
  Accept: "application/json",
5438
5429
  "User-Agent": USER_AGENT
5439
5430
  },
5440
- body: JSON.stringify(body)
5431
+ body: JSON.stringify(body2)
5441
5432
  });
5442
5433
  } catch (e) {
5443
5434
  throw new CliError(
@@ -5445,10 +5436,10 @@ async function bootstrapPost(path3, body) {
5445
5436
  `Request to ${base} failed: ${e instanceof Error ? e.message : String(e)}`
5446
5437
  );
5447
5438
  }
5448
- const text = await res.text();
5439
+ const text2 = await res.text();
5449
5440
  if (!res.ok) {
5450
5441
  try {
5451
- const parsed = errorEnvelopeSchema.safeParse(JSON.parse(text));
5442
+ const parsed = errorEnvelopeSchema.safeParse(JSON.parse(text2));
5452
5443
  if (parsed.success) {
5453
5444
  throw new CliError(parsed.data.error.code, parsed.data.error.message);
5454
5445
  }
@@ -5460,7 +5451,7 @@ async function bootstrapPost(path3, body) {
5460
5451
  `Authentication request failed: HTTP ${res.status} ${res.statusText}`.trim()
5461
5452
  );
5462
5453
  }
5463
- return JSON.parse(text);
5454
+ return JSON.parse(text2);
5464
5455
  }
5465
5456
  async function deviceLogin(opts) {
5466
5457
  const start = await bootstrapPost(
@@ -5520,10 +5511,10 @@ async function deviceLogin(opts) {
5520
5511
  "The sign-in request expired before it was approved. Re-run it to try again."
5521
5512
  );
5522
5513
  case "approved": {
5523
- const token2 = result.accessToken;
5514
+ const token = result.accessToken;
5524
5515
  try {
5525
- const me = await fetchMe(new ApiClient({ token: token2 }));
5526
- return { token: token2, me };
5516
+ const me = await fetchMe(new ApiClient({ token }));
5517
+ return { token, me };
5527
5518
  } catch (e) {
5528
5519
  throw new CliError(
5529
5520
  "network",
@@ -5560,15 +5551,15 @@ async function withTokenLogin() {
5560
5551
  if (process.stdin.isTTY) {
5561
5552
  console.error("Paste your API token, then press Enter:");
5562
5553
  }
5563
- const token2 = (await readStdin()).trim();
5564
- if (!token2.startsWith(TOKEN_PREFIX)) {
5554
+ const token = (await readStdin()).trim();
5555
+ if (!token.startsWith(TOKEN_PREFIX)) {
5565
5556
  throw new CliError(
5566
5557
  "usage",
5567
5558
  `Expected a token starting with ${TOKEN_PREFIX} on stdin`
5568
5559
  );
5569
5560
  }
5570
- const me = await fetchMe(new ApiClient({ token: token2 }));
5571
- saveToken(token2);
5561
+ const me = await fetchMe(new ApiClient({ token }));
5562
+ saveToken(token);
5572
5563
  console.log(`Token saved to ${credentialsPath()}`);
5573
5564
  printIdentity(me);
5574
5565
  }
@@ -5636,8 +5627,8 @@ function register3(program2) {
5636
5627
  throw new CliError("usage", "--email requires --device.");
5637
5628
  }
5638
5629
  if (opts.device) {
5639
- const { token: token2, me } = await deviceLogin({ email: opts.email });
5640
- saveToken(token2);
5630
+ const { token, me } = await deviceLogin({ email: opts.email });
5631
+ saveToken(token);
5641
5632
  console.log(`Token saved to ${credentialsPath()}`);
5642
5633
  printIdentity(me);
5643
5634
  } else if (opts.withToken) {
@@ -5659,8 +5650,8 @@ function register3(program2) {
5659
5650
  });
5660
5651
  auth.command("status").description("Show the current auth state").action(async (_opts, command) => {
5661
5652
  const output = resolveOutput(command);
5662
- const source = tokenSource();
5663
- if (source === "none") {
5653
+ const source2 = tokenSource();
5654
+ if (source2 === "none") {
5664
5655
  throw new CliError(
5665
5656
  "unauthorized",
5666
5657
  "Not logged in. Run `gauge auth login` or set GAUGE_API_TOKEN."
@@ -5673,7 +5664,7 @@ function register3(program2) {
5673
5664
  if (e instanceof CliError && e.code === "unauthorized") {
5674
5665
  throw new CliError(
5675
5666
  "unauthorized",
5676
- `Token (source: ${source}) was rejected \u2014 it may be revoked or expired. Run \`gauge auth login\`.`
5667
+ `Token (source: ${source2}) was rejected \u2014 it may be revoked or expired. Run \`gauge auth login\`.`
5677
5668
  );
5678
5669
  }
5679
5670
  throw e;
@@ -5681,7 +5672,7 @@ function register3(program2) {
5681
5672
  if (output === "json") {
5682
5673
  printJson({
5683
5674
  authenticated: true,
5684
- source,
5675
+ source: source2,
5685
5676
  apiUrl: resolveBaseUrl(),
5686
5677
  ...me
5687
5678
  });
@@ -5689,7 +5680,7 @@ function register3(program2) {
5689
5680
  }
5690
5681
  printIdentity(me);
5691
5682
  console.log(
5692
- `Token source: ${source === "env" ? "GAUGE_API_TOKEN environment variable" : credentialsPath()}`
5683
+ `Token source: ${source2 === "env" ? "GAUGE_API_TOKEN environment variable" : credentialsPath()}`
5693
5684
  );
5694
5685
  });
5695
5686
  const tokens2 = auth.command("tokens").description("Manage API tokens");
@@ -5723,11 +5714,11 @@ function register3(program2) {
5723
5714
  console.log("Store it now \u2014 it won't be shown again.");
5724
5715
  }
5725
5716
  );
5726
- tokens2.command("revoke <id>").description("Revoke an API token").action(async (id, _opts, command) => {
5717
+ tokens2.command("revoke <id>").description("Revoke an API token").action(async (id2, _opts, command) => {
5727
5718
  await createClient().delete(
5728
- `${TOKENS_PATH}/${encodeURIComponent(id)}`
5719
+ `${TOKENS_PATH}/${encodeURIComponent(id2)}`
5729
5720
  );
5730
- if (resolveOutput(command) !== "json") console.log(`Revoked ${id}`);
5721
+ if (resolveOutput(command) !== "json") console.log(`Revoked ${id2}`);
5731
5722
  });
5732
5723
  program2.command("whoami").description("Show the authenticated user and their orgs").action(async (_opts, command) => {
5733
5724
  await whoami(resolveOutput(command));
@@ -5836,12 +5827,12 @@ function readPromptText(opts) {
5836
5827
  throw new CliError("usage", "pass exactly one of --text or --file");
5837
5828
  }
5838
5829
  if (opts.text !== void 0) return opts.text;
5839
- const text = readFileSync4(
5830
+ const text2 = readFileSync4(
5840
5831
  opts.file === "-" ? 0 : opts.file,
5841
5832
  "utf8"
5842
5833
  ).trim();
5843
- if (!text) throw new CliError("usage", "prompt file is empty");
5844
- return text;
5834
+ if (!text2) throw new CliError("usage", "prompt file is empty");
5835
+ return text2;
5845
5836
  }
5846
5837
 
5847
5838
  // src/commands/batches.ts
@@ -5884,9 +5875,9 @@ function register4(program2) {
5884
5875
  }
5885
5876
  }
5886
5877
  );
5887
- batches.command("get <id>").description("Show a batch and its runs").action(async (id, _opts, command) => {
5878
+ batches.command("get <id>").description("Show a batch and its runs").action(async (id2, _opts, command) => {
5888
5879
  const batch = await createClient().get(
5889
- `/api/v1/batches/${encodeURIComponent(id)}`
5880
+ `/api/v1/batches/${encodeURIComponent(id2)}`
5890
5881
  );
5891
5882
  if (resolveOutput(command) === "json") {
5892
5883
  printJson(batch);
@@ -6063,7 +6054,7 @@ function register6(program2) {
6063
6054
  "replace packages, repeatable",
6064
6055
  collect2
6065
6056
  ).option("--clear-packages", "remove all packages").action(
6066
- async (id, opts, cmd) => {
6057
+ async (id2, opts, cmd) => {
6067
6058
  const patch = {};
6068
6059
  if (opts.name !== void 0) patch.name = opts.name;
6069
6060
  if (opts.kind !== void 0) patch.kind = opts.kind.toUpperCase();
@@ -6081,19 +6072,19 @@ function register6(program2) {
6081
6072
  }
6082
6073
  const org = resolveOrg(cmd);
6083
6074
  const row2 = await createClient().patch(
6084
- `${brandsPath(org)}/${encodeURIComponent(id)}`,
6075
+ `${brandsPath(org)}/${encodeURIComponent(id2)}`,
6085
6076
  patch
6086
6077
  );
6087
6078
  if (resolveOutput(cmd) === "json") printJson(row2);
6088
6079
  else console.log(`Updated brand ${row2.id} (${row2.name})`);
6089
6080
  }
6090
6081
  );
6091
- group.command("rm <id>").description("Delete a brand").action(async (id, _opts, cmd) => {
6082
+ group.command("rm <id>").description("Delete a brand").action(async (id2, _opts, cmd) => {
6092
6083
  const org = resolveOrg(cmd);
6093
6084
  await createClient().delete(
6094
- `${brandsPath(org)}/${encodeURIComponent(id)}`
6085
+ `${brandsPath(org)}/${encodeURIComponent(id2)}`
6095
6086
  );
6096
- if (resolveOutput(cmd) !== "json") console.log(`Deleted brand ${id}`);
6087
+ if (resolveOutput(cmd) !== "json") console.log(`Deleted brand ${id2}`);
6097
6088
  });
6098
6089
  }
6099
6090
 
@@ -6126,10 +6117,10 @@ function printDetail(canary, json) {
6126
6117
  );
6127
6118
  }
6128
6119
  }
6129
- async function waitForCanary(id) {
6120
+ async function waitForCanary(id2) {
6130
6121
  const client = createClient();
6131
6122
  while (true) {
6132
- const canary = await client.get(`${path}/${id}`);
6123
+ const canary = await client.get(`${path}/${id2}`);
6133
6124
  if (terminal.has(canary.status)) return canary;
6134
6125
  await new Promise((resolve3) => setTimeout(resolve3, 1e4));
6135
6126
  }
@@ -6150,9 +6141,9 @@ function register7(program2, opts = {}) {
6150
6141
  process.exitCode = 1;
6151
6142
  }
6152
6143
  );
6153
- canary.command("get <id>").option("--json", "print JSON").action(async (id, opts2) => {
6144
+ canary.command("get <id>").option("--json", "print JSON").action(async (id2, opts2) => {
6154
6145
  printDetail(
6155
- await createClient().get(`${path}/${id}`),
6146
+ await createClient().get(`${path}/${id2}`),
6156
6147
  Boolean(opts2.json)
6157
6148
  );
6158
6149
  });
@@ -6696,8 +6687,8 @@ function utf8(bytes, path3) {
6696
6687
  }
6697
6688
  }
6698
6689
  function parseRunDefinitionCase(path3, bytes) {
6699
- const source = utf8(bytes, path3);
6700
- const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/.exec(source);
6690
+ const source2 = utf8(bytes, path3);
6691
+ const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/.exec(source2);
6701
6692
  if (!match)
6702
6693
  throw new Error(`${path3}: expected YAML frontmatter between --- lines`);
6703
6694
  const document = parseDocument(match[1], { uniqueKeys: true });
@@ -6867,7 +6858,7 @@ import { minimatch as minimatch2 } from "minimatch";
6867
6858
  import { parseDocument as parseDocument2 } from "yaml";
6868
6859
  var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
6869
6860
  var message = (error) => error instanceof Error ? error.message : String(error);
6870
- var check = (id, state, detail) => ({ id, state, detail });
6861
+ var check = (id2, state, detail) => ({ id: id2, state, detail });
6871
6862
  var dynamic = (value) => typeof value !== "string" || value.includes("${{");
6872
6863
  var condition = (value) => {
6873
6864
  if (value === void 0 || value === true) return true;
@@ -6945,12 +6936,12 @@ function workingFiles(root) {
6945
6936
  }
6946
6937
  function workflowChecks(root, input) {
6947
6938
  if (input.source.type !== "github-actions") return [];
6948
- const source = input.source;
6939
+ const source2 = input.source;
6949
6940
  const checks = [];
6950
6941
  let workflow;
6951
6942
  try {
6952
6943
  const document = parseDocument2(
6953
- read(root, source.workflow).toString("utf8"),
6944
+ read(root, source2.workflow).toString("utf8"),
6954
6945
  { uniqueKeys: true }
6955
6946
  );
6956
6947
  if (document.errors.length)
@@ -6962,7 +6953,7 @@ function workflowChecks(root, input) {
6962
6953
  check(
6963
6954
  "workflow",
6964
6955
  "yes",
6965
- `${source.workflow} exists with a parseable YAML jobs mapping`
6956
+ `${source2.workflow} exists with a parseable YAML jobs mapping`
6966
6957
  )
6967
6958
  );
6968
6959
  } catch (error) {
@@ -6984,14 +6975,14 @@ function workflowChecks(root, input) {
6984
6975
  );
6985
6976
  const candidates = uploads.filter(({ step }) => {
6986
6977
  const name = record(step.with).name ?? "artifact";
6987
- return !source.artifact || dynamic(name) || minimatch2(String(name), source.artifact, { nonegate: true });
6978
+ return !source2.artifact || dynamic(name) || minimatch2(String(name), source2.artifact, { nonegate: true });
6988
6979
  });
6989
6980
  const recognizedUpload = candidates.length === 1 && !dynamic(record(candidates[0].step.with).name ?? "artifact");
6990
6981
  checks.push(
6991
6982
  check(
6992
6983
  "artifact-upload",
6993
6984
  recognizedUpload ? "yes" : "unknown",
6994
- recognizedUpload ? `One direct upload step declares the matching artifact ${String(record(candidates[0].step.with).name ?? "artifact")}` : candidates.length ? `Found ${candidates.length} potentially matching upload step(s); resolve dynamic artifact names or overlapping uploads to establish a unique selection` : `No direct upload step matches ${source.artifact ?? "the configured artifact"}; ${opaque ? "inspect the referenced reusable workflows or custom actions" : "inspect build scripts or declare a matching actions/upload-artifact step"}`
6985
+ recognizedUpload ? `One direct upload step declares the matching artifact ${String(record(candidates[0].step.with).name ?? "artifact")}` : candidates.length ? `Found ${candidates.length} potentially matching upload step(s); resolve dynamic artifact names or overlapping uploads to establish a unique selection` : `No direct upload step matches ${source2.artifact ?? "the configured artifact"}; ${opaque ? "inspect the referenced reusable workflows or custom actions" : "inspect build scripts or declare a matching actions/upload-artifact step"}`
6995
6986
  )
6996
6987
  );
6997
6988
  for (const [index, { job, jobCondition, step }] of candidates.entries()) {
@@ -7000,10 +6991,10 @@ function workflowChecks(root, input) {
7000
6991
  String(step.uses)
7001
6992
  );
7002
6993
  const major = version ? Number(version[1]) : void 0;
7003
- let state = source.artifact && dynamic(options.name ?? "artifact") ? "unknown" : major === 7 ? options.archive === true || options.archive === "true" ? "yes" : options.archive === void 0 || options.archive === false || options.archive === "false" ? "no" : "unknown" : major !== void 0 && major >= 4 && major <= 6 ? "yes" : "unknown";
6994
+ let state = source2.artifact && dynamic(options.name ?? "artifact") ? "unknown" : major === 7 ? options.archive === true || options.archive === "true" ? "yes" : options.archive === void 0 || options.archive === false || options.archive === "false" ? "no" : "unknown" : major !== void 0 && major >= 4 && major <= 6 ? "yes" : "unknown";
7004
6995
  const conditional = jobCondition === void 0 || condition(step.if) === void 0;
7005
6996
  if (state === "no" && conditional) state = "unknown";
7006
- const detail = source.artifact && dynamic(options.name ?? "artifact") ? "Resolve the artifact name expression to determine whether this upload is selected" : major === 7 ? options.archive === true || options.archive === "true" ? "archive: true declares a ZIP artifact" : options.archive === void 0 || options.archive === false || options.archive === "false" ? `archive: true is required for Gauge's ZIP download${conditional ? "; resolve the upload condition to determine whether this incompatible upload is selected" : ""}` : "Resolve the archive expression; Gauge requires archive: true" : major !== void 0 && major >= 4 && major <= 6 ? "This action version produces ZIP artifacts" : "Resolve the pinned action version; ZIP format is recognized for upload-artifact v4\u2013v7 (v7 requires archive: true)";
6997
+ const detail = source2.artifact && dynamic(options.name ?? "artifact") ? "Resolve the artifact name expression to determine whether this upload is selected" : major === 7 ? options.archive === true || options.archive === "true" ? "archive: true declares a ZIP artifact" : options.archive === void 0 || options.archive === false || options.archive === "false" ? `archive: true is required for Gauge's ZIP download${conditional ? "; resolve the upload condition to determine whether this incompatible upload is selected" : ""}` : "Resolve the archive expression; Gauge requires archive: true" : major !== void 0 && major >= 4 && major <= 6 ? "This action version produces ZIP artifacts" : "Resolve the pinned action version; ZIP format is recognized for upload-artifact v4\u2013v7 (v7 requires archive: true)";
7007
6998
  checks.push(
7008
6999
  check(
7009
7000
  `artifact-format.${index}`,
@@ -7392,7 +7383,7 @@ function register12(program2) {
7392
7383
  console.log(`Expected sessions: ${result.expectedRuns}`);
7393
7384
  for (const item of result.cases)
7394
7385
  console.log(
7395
- ` ${item.path}: ${item.expectedRuns} sessions, ${item.criteriaCount} criteria`
7386
+ ` ${item.path}: ${item.expectedRuns} sessions, ${item.preference ? `${item.preference.kind} preference (advisory)` : `${item.criteriaCount} criteria`}`
7396
7387
  );
7397
7388
  for (const resource of result.resources) {
7398
7389
  const use = resource.use;
@@ -7442,10 +7433,10 @@ function register12(program2) {
7442
7433
  else printItems(res.items.map(toRow2), "table");
7443
7434
  }
7444
7435
  );
7445
- group.command("get <id>").description("Show one eval set: configuration, criteria, cadence").action(async (id, _opts, cmd) => {
7436
+ group.command("get <id>").description("Show one eval set: configuration, criteria, cadence").action(async (id2, _opts, cmd) => {
7446
7437
  const org = resolveOrg(cmd);
7447
7438
  const evalSet = await createClient().get(
7448
- `${evalSetsPath(org)}/${encodeURIComponent(id)}`
7439
+ `${evalSetsPath(org)}/${encodeURIComponent(id2)}`
7449
7440
  );
7450
7441
  if (resolveOutput(cmd) === "json") printJson(evalSet);
7451
7442
  else printDetail2(evalSet);
@@ -7474,7 +7465,7 @@ function register12(program2) {
7474
7465
  "usage",
7475
7466
  "at least one --criterion (or --criteria-file) is required"
7476
7467
  );
7477
- const body = {
7468
+ const body2 = {
7478
7469
  name: opts.name,
7479
7470
  promptText: readPromptText(opts),
7480
7471
  ...ownedConfigFromOpts(opts),
@@ -7487,7 +7478,7 @@ function register12(program2) {
7487
7478
  );
7488
7479
  const created = await createClient().post(
7489
7480
  evalSetsPath(org),
7490
- body
7481
+ body2
7491
7482
  );
7492
7483
  if (resolveOutput(cmd) === "json") printJson(created);
7493
7484
  else console.log(`Created eval set ${created.id}`);
@@ -7514,34 +7505,34 @@ function register12(program2) {
7514
7505
  collect,
7515
7506
  []
7516
7507
  ).option("--clear-tags", "remove all user tags").action(
7517
- async (id, opts, cmd) => {
7508
+ async (id2, opts, cmd) => {
7518
7509
  const org = resolveOrg(cmd);
7519
- const body = ownedConfigPatchFromOpts(opts);
7520
- if (opts.name !== void 0) body.name = opts.name;
7510
+ const body2 = ownedConfigPatchFromOpts(opts);
7511
+ if (opts.name !== void 0) body2.name = opts.name;
7521
7512
  if (opts.text !== void 0 || opts.file !== void 0)
7522
- body.promptText = readPromptText(opts);
7513
+ body2.promptText = readPromptText(opts);
7523
7514
  const criteria = criteriaFromOpts(opts);
7524
- if (criteria) body.criteria = criteria;
7515
+ if (criteria) body2.criteria = criteria;
7525
7516
  if (opts.tag.length > 0 && opts.clearTags)
7526
7517
  throw new CliError("usage", "--tag and --clear-tags conflict");
7527
- if (opts.clearTags) body.tags = [];
7528
- else if (opts.tag.length > 0) body.tags = opts.tag;
7529
- if (Object.keys(body).length === 0)
7518
+ if (opts.clearTags) body2.tags = [];
7519
+ else if (opts.tag.length > 0) body2.tags = opts.tag;
7520
+ if (Object.keys(body2).length === 0)
7530
7521
  throw new CliError("usage", "nothing to change");
7531
7522
  const updated = await createClient().patch(
7532
- `${evalSetsPath(org)}/${encodeURIComponent(id)}`,
7533
- body
7523
+ `${evalSetsPath(org)}/${encodeURIComponent(id2)}`,
7524
+ body2
7534
7525
  );
7535
7526
  if (resolveOutput(cmd) === "json") printJson(updated);
7536
7527
  else console.log(`Updated eval set ${updated.id}`);
7537
7528
  }
7538
7529
  );
7539
- group.command("rm <id>").description("Delete an eval set (its run history survives)").action(async (id, _opts, cmd) => {
7530
+ group.command("rm <id>").description("Delete an eval set (its run history survives)").action(async (id2, _opts, cmd) => {
7540
7531
  const org = resolveOrg(cmd);
7541
7532
  await createClient().delete(
7542
- `${evalSetsPath(org)}/${encodeURIComponent(id)}`
7533
+ `${evalSetsPath(org)}/${encodeURIComponent(id2)}`
7543
7534
  );
7544
- if (resolveOutput(cmd) !== "json") console.log(`Deleted eval set ${id}`);
7535
+ if (resolveOutput(cmd) !== "json") console.log(`Deleted eval set ${id2}`);
7545
7536
  });
7546
7537
  group.command("run [id]").description(
7547
7538
  staffCommandsVisible() ? "Run an eval set now with its stored configuration (superusers run without billing the org by default)" : "Run an eval set now with its stored configuration"
@@ -7554,9 +7545,9 @@ function register12(program2) {
7554
7545
  "--files <paths...>",
7555
7546
  "committed Markdown paths or globs (default gauge-evals/**/*.md)"
7556
7547
  ).option("--yes", "skip the confirmation").action(
7557
- async (id, opts, cmd) => {
7558
- if (opts.files !== void 0 || id === void 0) {
7559
- if (id !== void 0)
7548
+ async (id2, opts, cmd) => {
7549
+ if (opts.files !== void 0 || id2 === void 0) {
7550
+ if (id2 !== void 0)
7560
7551
  throw new CliError(
7561
7552
  "usage",
7562
7553
  "pass either an eval ID or --files, not both"
@@ -7584,7 +7575,7 @@ function register12(program2) {
7584
7575
  opts.yes
7585
7576
  );
7586
7577
  const result = await createClient().post(
7587
- `${evalSetsPath(org)}/${encodeURIComponent(id)}/run`,
7578
+ `${evalSetsPath(org)}/${encodeURIComponent(id2)}/run`,
7588
7579
  opts.billToOrg ? { billToOrg: true } : {}
7589
7580
  );
7590
7581
  if (resolveOutput(cmd) === "json") printJson(result);
@@ -7594,36 +7585,45 @@ function register12(program2) {
7594
7585
  );
7595
7586
  }
7596
7587
  );
7597
- group.command("runs <id>").description("The eval set's run log with per-criterion verdicts").option("--limit <n>", "max runs (default 100)").action(async (id, opts, cmd) => {
7598
- const org = resolveOrg(cmd);
7599
- const res = await createClient().get(
7600
- `${evalSetsPath(org)}/${encodeURIComponent(id)}/runs`,
7601
- { limit: opts.limit }
7602
- );
7603
- if (resolveOutput(cmd) === "json") {
7604
- printJson(res.items);
7605
- return;
7588
+ group.command("runs <id>").description("The eval set's run log with per-criterion verdicts").option("--limit <n>", "page size (1-500, default 100)").option("--cursor <cursor>", "resume from a previous page's nextCursor").action(
7589
+ async (id2, opts, cmd) => {
7590
+ const org = resolveOrg(cmd);
7591
+ const res = await createClient().get(
7592
+ `${evalSetsPath(org)}/${encodeURIComponent(id2)}/runs`,
7593
+ { limit: opts.limit, cursor: opts.cursor }
7594
+ );
7595
+ if (resolveOutput(cmd) === "json") {
7596
+ printJson(res);
7597
+ return;
7598
+ }
7599
+ printItems(
7600
+ res.items.map((r) => ({
7601
+ id: r.id,
7602
+ status: r.status,
7603
+ agent: r.agent,
7604
+ model: r.resolvedModel ?? r.model ?? "",
7605
+ source: r.triggeredBy?.source ?? "",
7606
+ credits: r.creditsCharged ?? "",
7607
+ created: r.createdAt,
7608
+ judge: r.judge?.status ?? "-",
7609
+ verdicts: r.criterionResults.length === 0 ? "-" : `${r.criterionResults.filter((c) => c.passed).length}/${r.criterionResults.length} passed`
7610
+ })),
7611
+ "table"
7612
+ );
7613
+ if (res.nextCursor) {
7614
+ console.error(
7615
+ `(more results \u2014 rerun with --cursor ${res.nextCursor})`
7616
+ );
7617
+ }
7606
7618
  }
7607
- printItems(
7608
- res.items.map((r) => ({
7609
- id: r.id,
7610
- status: r.status,
7611
- agent: r.agent,
7612
- model: r.resolvedModel ?? r.model ?? "",
7613
- created: r.createdAt,
7614
- judge: r.judge?.status ?? "-",
7615
- verdicts: r.criterionResults.length === 0 ? "-" : `${r.criterionResults.filter((c) => c.passed).length}/${r.criterionResults.length} passed`
7616
- })),
7617
- "table"
7618
- );
7619
- });
7619
+ );
7620
7620
  group.command("tag <id>").description("Replace an eval set's user tags (Surface:* is preserved)").option(
7621
7621
  "--tag <name>",
7622
7622
  "tag name, create-on-type (repeatable)",
7623
7623
  collect,
7624
7624
  []
7625
7625
  ).option("--clear", "remove all user tags").action(
7626
- async (id, opts, cmd) => {
7626
+ async (id2, opts, cmd) => {
7627
7627
  const org = resolveOrg(cmd);
7628
7628
  if (opts.tag.length > 0 && opts.clear)
7629
7629
  throw new CliError("usage", "--tag and --clear conflict");
@@ -7633,7 +7633,7 @@ function register12(program2) {
7633
7633
  "pass --tag <name> (repeatable) or --clear"
7634
7634
  );
7635
7635
  const updated = await createClient().patch(
7636
- `${evalSetsPath(org)}/${encodeURIComponent(id)}`,
7636
+ `${evalSetsPath(org)}/${encodeURIComponent(id2)}`,
7637
7637
  { tags: opts.clear ? [] : opts.tag }
7638
7638
  );
7639
7639
  if (resolveOutput(cmd) === "json") printJson(updated);
@@ -7681,6 +7681,10 @@ Choose a roster for the question and budget. For exploratory testing, start with
7681
7681
 
7682
7682
  Background: [Open models as preference proxies](https://www.withgauge.com/blog/open-models-useful-proxies-data-from-1000-sessions/).
7683
7683
 
7684
+ ## Git-authored Agent Preference
7685
+ Replace \`criteria\` with \`preference: { kind: open-ended }\`, adding \`branded: true\` when the prompt names brands. For a comparison use \`preference: { kind: head-to-head, brandA: PostHog, brandB: Amplitude }\`. Specify exactly one of criteria/preference; the body remains the task and must name the comparison brands itself.
7686
+ Existing per-case settings, inputs, and path filters apply. The app's preference analyst reports advisory choices; competitor selections never fail criteria. Preference-only checks finish neutral; mixed suites retain experience gating. The wait command succeeds for MEASURED/PASSED and fails on operational errors. No base/head delta is inferred.
7687
+
7684
7688
  ## Migration prompt and criteria
7685
7689
 
7686
7690
  This example tests migration of an existing feature-flag application across browser and server workflows. Its starting repository contains the application, while attached connections supply destination credentials. The source account's targeting configuration is unavailable.
@@ -7728,7 +7732,7 @@ Explain product choices in their task context, then identify changes worth testi
7728
7732
 
7729
7733
  ## Establish the measurement
7730
7734
 
7731
- Define the question, product role, cohort, and time window. Record prompts, repository revisions, personas, model/harness targets, attached resources, and interventions so comparisons remain interpretable. Open-ended choices and forced head-to-head comparisons answer different questions.
7735
+ Define the question, product role, cohort, and time window. Record prompts, repository revisions, personas, model/harness targets, attached resources, and interventions so comparisons remain interpretable. Open-ended choices and forced head-to-head comparisons answer different questions. Git-authored Markdown cases replace criteria with a preference block: kind open-ended (optionally branded: true), or kind head-to-head with brandA and brandB. The body is the prompt. Use gauge evals verify/plan/run; PR selections are advisory and use the app analyst.
7732
7736
 
7733
7737
  Use \`gauge preference list -o json\` and \`gauge preference get <id> -o json\` to orient, \`gauge runs list --prompt <id> -o json\` for sessions, and \`gauge runs insight <run-id> -o json\` plus \`gauge runs logs <run-id> -o json\` for judgments and trace evidence. Follow \`nextCursor\` across list pages; one page is not the whole cohort. Inspect command help for available filters and configuration.
7734
7738
 
@@ -8192,15 +8196,15 @@ function register15(program2) {
8192
8196
  const org = resolveOrg(cmd);
8193
8197
  if (opts.note !== void 0 && opts.clearNote)
8194
8198
  throw new CliError("usage", "--note and --clear-note conflict");
8195
- const body = {};
8196
- if (opts.rename !== void 0) body.name = opts.rename;
8197
- if (opts.clearNote) body.note = null;
8198
- else if (opts.note !== void 0) body.note = opts.note;
8199
- if (Object.keys(body).length === 0)
8199
+ const body2 = {};
8200
+ if (opts.rename !== void 0) body2.name = opts.rename;
8201
+ if (opts.clearNote) body2.note = null;
8202
+ else if (opts.note !== void 0) body2.note = opts.note;
8203
+ if (Object.keys(body2).length === 0)
8200
8204
  throw new CliError("usage", "nothing to change");
8201
8205
  const updated = await createClient().patch(
8202
8206
  serverPath(org, ref),
8203
- body
8207
+ body2
8204
8208
  );
8205
8209
  if (resolveOutput(cmd) === "json") printJson(updated);
8206
8210
  else console.log(`Updated MCP server ${updated.name}`);
@@ -8425,11 +8429,11 @@ var TERMINAL = /* @__PURE__ */ new Set(["DONE", "ARCHIVED"]);
8425
8429
  function basePath(org) {
8426
8430
  return `/api/v1/orgs/${encodeURIComponent(org)}/optimizations`;
8427
8431
  }
8428
- function itemPath(org, id) {
8429
- return `${basePath(org)}/${encodeURIComponent(id)}`;
8432
+ function itemPath(org, id2) {
8433
+ return `${basePath(org)}/${encodeURIComponent(id2)}`;
8430
8434
  }
8431
- function trialPath(org, id, trialId) {
8432
- return `${itemPath(org, id)}/trials/${encodeURIComponent(trialId)}`;
8435
+ function trialPath(org, id2, trialId) {
8436
+ return `${itemPath(org, id2)}/trials/${encodeURIComponent(trialId)}`;
8433
8437
  }
8434
8438
  var FAILED_RUN = /* @__PURE__ */ new Set(["FAILED", "TIMED_OUT"]);
8435
8439
  function readText(path3) {
@@ -8455,13 +8459,13 @@ function parseTarget(raw) {
8455
8459
  );
8456
8460
  return spec.models.length ? { agent: spec.agent, model: spec.models[0] } : { agent: spec.agent };
8457
8461
  }
8458
- function parseCount(raw, flag, max = 100) {
8462
+ function parseCount(raw, flag2, max = 100) {
8459
8463
  if (raw === void 0) return void 0;
8460
8464
  const n = Number(raw);
8461
8465
  if (!Number.isInteger(n) || n < 1 || n > max)
8462
8466
  throw new CliError(
8463
8467
  "usage",
8464
- `${flag} must be a positive integer no greater than ${max}`
8468
+ `${flag2} must be a positive integer no greater than ${max}`
8465
8469
  );
8466
8470
  return n;
8467
8471
  }
@@ -8571,9 +8575,9 @@ function trialBodyFromOpts(opts, read2 = readText, walk) {
8571
8575
  "the trial file must contain an object or a non-empty array of objects"
8572
8576
  );
8573
8577
  const record2 = chosen;
8574
- const body = "trial" in record2 ? record2 : { trial: record2 };
8578
+ const body2 = "trial" in record2 ? record2 : { trial: record2 };
8575
8579
  return {
8576
- ...body,
8580
+ ...body2,
8577
8581
  ...fork ? { fork } : {},
8578
8582
  ...idempotencyKey ? { idempotencyKey } : {},
8579
8583
  launch
@@ -8737,8 +8741,8 @@ function printDetail3(o) {
8737
8741
  console.log(`round ${round.number}: ${round.narrative}`);
8738
8742
  for (const line of trials.flatMap(trialWarnings)) console.error(line);
8739
8743
  }
8740
- function runDetails(id) {
8741
- return `(details: \`gauge runs get ${id}\`, \`gauge runs logs ${id}\`)`;
8744
+ function runDetails(id2) {
8745
+ return `(details: \`gauge runs get ${id2}\`, \`gauge runs logs ${id2}\`)`;
8742
8746
  }
8743
8747
  function trialWarnings(t) {
8744
8748
  const total = `${t.runs.length} session${t.runs.length === 1 ? "" : "s"}`;
@@ -8860,9 +8864,9 @@ function register19(program2) {
8860
8864
  else printItems(res.items.map(toRow3), "table");
8861
8865
  }
8862
8866
  );
8863
- group.command("get <id>").description("One optimization: settings, score, and its trial ladder").action(async (id, _opts, cmd) => {
8867
+ group.command("get <id>").description("One optimization: settings, score, and its trial ladder").action(async (id2, _opts, cmd) => {
8864
8868
  const org = resolveOrg(cmd);
8865
- const detail = await createClient().get(itemPath(org, id));
8869
+ const detail = await createClient().get(itemPath(org, id2));
8866
8870
  if (resolveOutput(cmd) === "json") printJson(detail);
8867
8871
  else printDetail3(detail);
8868
8872
  });
@@ -8911,14 +8915,14 @@ function register19(program2) {
8911
8915
  }
8912
8916
  }
8913
8917
  );
8914
- group.command("cancel <id>").description("Cancel an optimization and stop its in-flight sessions").option("--yes", "skip the confirmation").action(async (id, opts, cmd) => {
8918
+ group.command("cancel <id>").description("Cancel an optimization and stop its in-flight sessions").option("--yes", "skip the confirmation").action(async (id2, opts, cmd) => {
8915
8919
  const org = resolveOrg(cmd);
8916
8920
  await confirmOrAbort(
8917
- `Cancel optimization ${id}? In-flight sessions stop; completed usage remains billed.`,
8921
+ `Cancel optimization ${id2}? In-flight sessions stop; completed usage remains billed.`,
8918
8922
  opts.yes
8919
8923
  );
8920
8924
  const detail = await createClient().post(
8921
- `${itemPath(org, id)}/cancel`,
8925
+ `${itemPath(org, id2)}/cancel`,
8922
8926
  {}
8923
8927
  );
8924
8928
  if (resolveOutput(cmd) === "json") printJson(detail);
@@ -8951,17 +8955,17 @@ function register19(program2) {
8951
8955
  "--file <path>",
8952
8956
  "PATCH body JSON (name, direction, target); '-' for stdin"
8953
8957
  ).action(
8954
- async (id, opts, cmd) => {
8955
- const body = {
8958
+ async (id2, opts, cmd) => {
8959
+ const body2 = {
8956
8960
  ...opts.file ? readObject(opts.file) : {},
8957
8961
  ...targetFromOpts(opts),
8958
8962
  ...opts.name ? { name: opts.name } : {}
8959
8963
  };
8960
- if (!Object.keys(body).length)
8964
+ if (!Object.keys(body2).length)
8961
8965
  throw new CliError("usage", "pass --target, --name, or --file");
8962
8966
  const detail = await createClient().patch(
8963
- itemPath(resolveOrg(cmd), id),
8964
- body
8967
+ itemPath(resolveOrg(cmd), id2),
8968
+ body2
8965
8969
  );
8966
8970
  if (resolveOutput(cmd) === "json") printJson(detail);
8967
8971
  else printDetail3(detail);
@@ -8970,11 +8974,11 @@ function register19(program2) {
8970
8974
  addTargetOption(
8971
8975
  group.command("start-draft <id>").description("Start an existing draft's baseline (spends credits)")
8972
8976
  ).option("--name <name>", "optimization name").option("--yes", "skip the confirmation").action(
8973
- async (id, opts, cmd) => {
8977
+ async (id2, opts, cmd) => {
8974
8978
  const org = resolveOrg(cmd);
8975
8979
  const client = createClient();
8976
8980
  const plan = targetFromOpts(opts);
8977
- const current = await client.get(itemPath(org, id));
8981
+ const current = await client.get(itemPath(org, id2));
8978
8982
  if (current.status !== "DRAFT")
8979
8983
  throw new CliError(
8980
8984
  "usage",
@@ -8986,10 +8990,10 @@ function register19(program2) {
8986
8990
  "--target is required until the draft has an agent/model"
8987
8991
  );
8988
8992
  await confirmOrAbort(
8989
- `Start the baseline for ${id}? It spends credits now.`,
8993
+ `Start the baseline for ${id2}? It spends credits now.`,
8990
8994
  opts.yes
8991
8995
  );
8992
- const detail = await client.post(`${itemPath(org, id)}/start`, {
8996
+ const detail = await client.post(`${itemPath(org, id2)}/start`, {
8993
8997
  ...plan,
8994
8998
  name: opts.name
8995
8999
  });
@@ -8999,13 +9003,13 @@ function register19(program2) {
8999
9003
  );
9000
9004
  group.command("launch <id>").description(
9001
9005
  "Launch all saved trials in the current round (spends credits)"
9002
- ).option("--yes", "skip the confirmation").action(async (id, opts, cmd) => {
9006
+ ).option("--yes", "skip the confirmation").action(async (id2, opts, cmd) => {
9003
9007
  await confirmOrAbort(
9004
- `Launch the current round of ${id}? Spends credits.`,
9008
+ `Launch the current round of ${id2}? Spends credits.`,
9005
9009
  opts.yes
9006
9010
  );
9007
9011
  const result = await createClient().post(
9008
- `${itemPath(resolveOrg(cmd), id)}/rounds/current/launch`,
9012
+ `${itemPath(resolveOrg(cmd), id2)}/rounds/current/launch`,
9009
9013
  {}
9010
9014
  );
9011
9015
  if (resolveOutput(cmd) === "json") printJson(result);
@@ -9016,21 +9020,21 @@ function register19(program2) {
9016
9020
  });
9017
9021
  group.command("continue <id>").description(
9018
9022
  "Reopen a finished optimization for another round against its fixed baseline"
9019
- ).option("--yes", "skip the confirmation").action(async (id, opts, cmd) => {
9023
+ ).option("--yes", "skip the confirmation").action(async (id2, opts, cmd) => {
9020
9024
  await confirmOrAbort(
9021
- `Reopen ${id} for another round? Saved trials still require launch.`,
9025
+ `Reopen ${id2} for another round? Saved trials still require launch.`,
9022
9026
  opts.yes
9023
9027
  );
9024
9028
  const detail = await createClient().post(
9025
- `${itemPath(resolveOrg(cmd), id)}/continue`,
9029
+ `${itemPath(resolveOrg(cmd), id2)}/continue`,
9026
9030
  {}
9027
9031
  );
9028
9032
  if (resolveOutput(cmd) === "json") printJson(detail);
9029
9033
  else printDetail3(detail);
9030
9034
  });
9031
9035
  group.command("activity <id>").description("Read the optimization's decision log").option("--after <timestamp>", "entries after this ISO timestamp").option("--limit <n>", "maximum entries (1\u2013500)").action(
9032
- async (id, opts, cmd) => {
9033
- const res = await createClient().get(`${itemPath(resolveOrg(cmd), id)}/activity`, {
9036
+ async (id2, opts, cmd) => {
9037
+ const res = await createClient().get(`${itemPath(resolveOrg(cmd), id2)}/activity`, {
9034
9038
  after: opts.after,
9035
9039
  limit: parseCount(opts.limit, "--limit", 500)
9036
9040
  });
@@ -9047,32 +9051,32 @@ function register19(program2) {
9047
9051
  );
9048
9052
  }
9049
9053
  );
9050
- group.command("chat <id>").description("Resolve your optimization chat and print its URL path").action(async (id, _opts, cmd) => {
9054
+ group.command("chat <id>").description("Resolve your optimization chat and print its URL path").action(async (id2, _opts, cmd) => {
9051
9055
  const res = await createClient().post(
9052
- `${itemPath(resolveOrg(cmd), id)}/chat`,
9056
+ `${itemPath(resolveOrg(cmd), id2)}/chat`,
9053
9057
  {}
9054
9058
  );
9055
9059
  if (resolveOutput(cmd) === "json") printJson(res);
9056
9060
  else console.log(res.href);
9057
9061
  });
9058
- group.command("delete <id>").description("Delete an optimization, retaining billed session history").option("--yes", "skip the confirmation").action(async (id, opts, cmd) => {
9062
+ group.command("delete <id>").description("Delete an optimization, retaining billed session history").option("--yes", "skip the confirmation").action(async (id2, opts, cmd) => {
9059
9063
  await confirmOrAbort(
9060
- `Delete optimization ${id}, its rounds, trials, and activity? Session history is kept.`,
9064
+ `Delete optimization ${id2}, its rounds, trials, and activity? Session history is kept.`,
9061
9065
  opts.yes
9062
9066
  );
9063
- await createClient().delete(itemPath(resolveOrg(cmd), id));
9064
- if (resolveOutput(cmd) === "json") printJson({ deleted: id });
9065
- else console.log(`Deleted ${id}.`);
9067
+ await createClient().delete(itemPath(resolveOrg(cmd), id2));
9068
+ if (resolveOutput(cmd) === "json") printJson({ deleted: id2 });
9069
+ else console.log(`Deleted ${id2}.`);
9066
9070
  });
9067
9071
  group.command("complete <id>").description("Complete an optimization: it reads as Finished, not canceled").option("--adopt <trialId>", "mark this settled trial as the winner").option("--yes", "skip the confirmation").action(
9068
- async (id, opts, cmd) => {
9072
+ async (id2, opts, cmd) => {
9069
9073
  const org = resolveOrg(cmd);
9070
9074
  await confirmOrAbort(
9071
- `Complete optimization ${id}? No further rounds run; unspent credits are released.`,
9075
+ `Complete optimization ${id2}? No further rounds run; unspent credits are released.`,
9072
9076
  opts.yes
9073
9077
  );
9074
9078
  const detail = await createClient().post(
9075
- `${itemPath(org, id)}/complete`,
9079
+ `${itemPath(org, id2)}/complete`,
9076
9080
  opts.adopt ? { adoptTrialId: opts.adopt } : {}
9077
9081
  );
9078
9082
  if (resolveOutput(cmd) === "json") printJson(detail);
@@ -9083,7 +9087,7 @@ function register19(program2) {
9083
9087
  group.command("watch <id>").description(
9084
9088
  `Follow until finished or awaiting input (exit ${NEEDS_INPUT_EXIT} when it needs you); --follow keeps waiting`
9085
9089
  ).option("--interval <seconds>", "poll interval (default 15)").option("--follow", "keep polling while awaiting authoring or launch").action(
9086
- async (id, opts, cmd) => {
9090
+ async (id2, opts, cmd) => {
9087
9091
  const org = resolveOrg(cmd);
9088
9092
  const client = createClient();
9089
9093
  const interval = Number(opts.interval ?? 15);
@@ -9095,7 +9099,7 @@ function register19(program2) {
9095
9099
  const intervalMs = Math.max(interval * 1e3, 2e3);
9096
9100
  let last = "";
9097
9101
  for (; ; ) {
9098
- const detail = await client.get(itemPath(org, id));
9102
+ const detail = await client.get(itemPath(org, id2));
9099
9103
  const trials2 = detail.rounds.flatMap((round2) => round2.trials);
9100
9104
  const failed = trials2.reduce(
9101
9105
  (sum, trial) => sum + trial.failedSessions,
@@ -9119,18 +9123,18 @@ function register19(program2) {
9119
9123
  );
9120
9124
  group.command("authoring <id>").description(
9121
9125
  "What the next round may change: kinds, CLI targets and commands, baseline invocations, revision"
9122
- ).action(async (id, _opts, cmd) => {
9126
+ ).action(async (id2, _opts, cmd) => {
9123
9127
  printJson(
9124
- await createClient().get(`${itemPath(resolveOrg(cmd), id)}/authoring`)
9128
+ await createClient().get(`${itemPath(resolveOrg(cmd), id2)}/authoring`)
9125
9129
  );
9126
9130
  });
9127
9131
  group.command("invocation <id> <invocationId>").description(
9128
9132
  "One baseline CLI invocation from `authoring`, with its recorded command evidence"
9129
9133
  ).action(
9130
- async (id, invocationId, _opts, cmd) => {
9134
+ async (id2, invocationId, _opts, cmd) => {
9131
9135
  printJson(
9132
9136
  await createClient().get(
9133
- `${itemPath(resolveOrg(cmd), id)}/authoring/target`,
9137
+ `${itemPath(resolveOrg(cmd), id2)}/authoring/target`,
9134
9138
  { cliInvocationId: invocationId }
9135
9139
  )
9136
9140
  );
@@ -9138,10 +9142,10 @@ function register19(program2) {
9138
9142
  );
9139
9143
  group.command("cli-change <id>").description(
9140
9144
  "Build a CLI_INTERVENTION bundle from {targetId, commandId, selector, operations, shippingIntent}; use the output as intervention.after in a round file. Saves nothing"
9141
- ).requiredOption("--file <path>", "the change JSON; '-' for stdin").action(async (id, opts, cmd) => {
9145
+ ).requiredOption("--file <path>", "the change JSON; '-' for stdin").action(async (id2, opts, cmd) => {
9142
9146
  printJson(
9143
9147
  await createClient().post(
9144
- `${itemPath(resolveOrg(cmd), id)}/cli-changes`,
9148
+ `${itemPath(resolveOrg(cmd), id2)}/cli-changes`,
9145
9149
  readObject(opts.file)
9146
9150
  )
9147
9151
  );
@@ -9149,9 +9153,9 @@ function register19(program2) {
9149
9153
  const round = group.command("round").description(
9150
9154
  "Preview and save the round waiting to launch. A round file is {revision, trials: [{trial: {title, hypothesis, lever, intervention}, files?}]}; revision comes from `authoring`"
9151
9155
  );
9152
- round.command("preview <id>").description("Validate a round file and print its diff and previewDigest").requiredOption("--file <path>", "the round JSON; '-' for stdin").action(async (id, opts, cmd) => {
9156
+ round.command("preview <id>").description("Validate a round file and print its diff and previewDigest").requiredOption("--file <path>", "the round JSON; '-' for stdin").action(async (id2, opts, cmd) => {
9153
9157
  const preview = await createClient().post(
9154
- `${itemPath(resolveOrg(cmd), id)}/rounds/current/preview`,
9158
+ `${itemPath(resolveOrg(cmd), id2)}/rounds/current/preview`,
9155
9159
  readObject(opts.file)
9156
9160
  );
9157
9161
  if (resolveOutput(cmd) === "json") printJson(preview);
@@ -9160,9 +9164,9 @@ function register19(program2) {
9160
9164
  round.command("save <id>").description(
9161
9165
  "Save a previewed round as drafts, replacing every pending draft. Never launches"
9162
9166
  ).requiredOption("--file <path>", "the round JSON you previewed").requiredOption("--digest <digest>", "previewDigest from `round preview`").action(
9163
- async (id, opts, cmd) => {
9167
+ async (id2, opts, cmd) => {
9164
9168
  const result = await createClient().put(
9165
- `${itemPath(resolveOrg(cmd), id)}/rounds/current`,
9169
+ `${itemPath(resolveOrg(cmd), id2)}/rounds/current`,
9166
9170
  { ...readObject(opts.file), previewDigest: opts.digest }
9167
9171
  );
9168
9172
  if (resolveOutput(cmd) === "json") printJson(result);
@@ -9172,10 +9176,10 @@ function register19(program2) {
9172
9176
  }
9173
9177
  );
9174
9178
  const trials = group.command("trials").description("List, author, and run trials");
9175
- trials.command("list <id>").description("Every trial of an optimization with score and verdict").action(async (id, _opts, cmd) => {
9179
+ trials.command("list <id>").description("Every trial of an optimization with score and verdict").action(async (id2, _opts, cmd) => {
9176
9180
  const org = resolveOrg(cmd);
9177
9181
  const res = await createClient().get(
9178
- `${itemPath(org, id)}/trials`
9182
+ `${itemPath(org, id2)}/trials`
9179
9183
  );
9180
9184
  if (resolveOutput(cmd) === "json") printJson(res.items);
9181
9185
  else printItems(res.items.map(trialRow), "table");
@@ -9201,15 +9205,15 @@ function register19(program2) {
9201
9205
  "--idempotency-key <key>",
9202
9206
  "a retry with this key returns the first call's trial instead of a second one"
9203
9207
  ).option("--yes", "skip the confirmation").action(
9204
- async (id, opts, cmd) => {
9208
+ async (id2, opts, cmd) => {
9205
9209
  const org = resolveOrg(cmd);
9206
- const body = trialBodyFromOpts(opts);
9207
- if (body.launch !== false)
9210
+ const body2 = trialBodyFromOpts(opts);
9211
+ if (body2.launch !== false)
9208
9212
  await confirmOrAbort(
9209
- `Run trial "${body.trial.title}" on ${id} now? Spends credits.`,
9213
+ `Run trial "${body2.trial.title}" on ${id2} now? Spends credits.`,
9210
9214
  opts.yes
9211
9215
  );
9212
- const result = await createClient().post(`${itemPath(org, id)}/trials`, body);
9216
+ const result = await createClient().post(`${itemPath(org, id2)}/trials`, body2);
9213
9217
  if (resolveOutput(cmd) === "json") printJson(result);
9214
9218
  else if (result.replayed)
9215
9219
  console.log(
@@ -9225,14 +9229,14 @@ function register19(program2) {
9225
9229
  printJson(trialTemplate(opts.kind));
9226
9230
  });
9227
9231
  trials.command("run <id> <trialId>").description("Run a draft trial now (spends credits)").option("--yes", "skip the confirmation").action(
9228
- async (id, trialId, opts, cmd) => {
9232
+ async (id2, trialId, opts, cmd) => {
9229
9233
  const org = resolveOrg(cmd);
9230
9234
  await confirmOrAbort(
9231
9235
  `Run trial ${trialId} now? Spends credits.`,
9232
9236
  opts.yes
9233
9237
  );
9234
9238
  const result = await createClient().post(
9235
- `${trialPath(org, id, trialId)}/launch`,
9239
+ `${trialPath(org, id2, trialId)}/launch`,
9236
9240
  {}
9237
9241
  );
9238
9242
  if (resolveOutput(cmd) === "json") printJson(result);
@@ -9243,30 +9247,30 @@ function register19(program2) {
9243
9247
  }
9244
9248
  );
9245
9249
  trials.command("remove <id> <trialId>").description("Drop one draft trial from the round waiting to launch").option("--yes", "skip the confirmation").action(
9246
- async (id, trialId, opts, cmd) => {
9247
- await confirmOrAbort(`Remove draft ${trialId} from ${id}?`, opts.yes);
9250
+ async (id2, trialId, opts, cmd) => {
9251
+ await confirmOrAbort(`Remove draft ${trialId} from ${id2}?`, opts.yes);
9248
9252
  const detail = await createClient().delete(
9249
- trialPath(resolveOrg(cmd), id, trialId)
9253
+ trialPath(resolveOrg(cmd), id2, trialId)
9250
9254
  );
9251
9255
  if (resolveOutput(cmd) === "json") printJson(detail);
9252
9256
  else console.log(`Removed ${trialId}.`);
9253
9257
  }
9254
9258
  );
9255
9259
  group.command("trial <id> <trialId>").description("One trial by id or key (B0, R1.1, \u2026) with its sessions").action(
9256
- async (id, trialId, _opts, cmd) => {
9260
+ async (id2, trialId, _opts, cmd) => {
9257
9261
  const org = resolveOrg(cmd);
9258
9262
  const trial = await createClient().get(
9259
- trialPath(org, id, trialId)
9263
+ trialPath(org, id2, trialId)
9260
9264
  );
9261
9265
  if (resolveOutput(cmd) === "json") printJson(trial);
9262
9266
  else printTrial(trial);
9263
9267
  }
9264
9268
  );
9265
9269
  group.command("change <id> <trialId>").description("The change a trial made: before and after text per document").option("--body", "print only the pasteable page body of a docs rewrite").action(
9266
- async (id, trialId, opts, cmd) => {
9270
+ async (id2, trialId, opts, cmd) => {
9267
9271
  const org = resolveOrg(cmd);
9268
9272
  const content = await createClient().get(
9269
- `${trialPath(org, id, trialId)}/content`
9273
+ `${trialPath(org, id2, trialId)}/content`
9270
9274
  );
9271
9275
  if (resolveOutput(cmd) === "json") printJson(content);
9272
9276
  else if (opts.body) {
@@ -9282,14 +9286,14 @@ function register19(program2) {
9282
9286
  group.command("adopt <id> <trialId>").description(
9283
9287
  "Mark a settled trial as the winner without changing the baseline"
9284
9288
  ).option("--yes", "skip the confirmation").action(
9285
- async (id, trialId, opts, cmd) => {
9289
+ async (id2, trialId, opts, cmd) => {
9286
9290
  const org = resolveOrg(cmd);
9287
9291
  await confirmOrAbort(
9288
- `Mark ${trialId} as the winner on ${id}?`,
9292
+ `Mark ${trialId} as the winner on ${id2}?`,
9289
9293
  opts.yes
9290
9294
  );
9291
9295
  const detail = await createClient().post(
9292
- `${trialPath(org, id, trialId)}/adopt`,
9296
+ `${trialPath(org, id2, trialId)}/adopt`,
9293
9297
  {}
9294
9298
  );
9295
9299
  if (resolveOutput(cmd) === "json") printJson(detail);
@@ -9298,9 +9302,9 @@ function register19(program2) {
9298
9302
  );
9299
9303
  group.command("handoff <id>").description(
9300
9304
  "The instructions a coding agent follows to land the winning trial in your source, as the web app's Copy instructions for agent"
9301
- ).action(async (id, _opts, cmd) => {
9305
+ ).action(async (id2, _opts, cmd) => {
9302
9306
  const handoff = await createClient().get(
9303
- `${itemPath(resolveOrg(cmd), id)}/handoff`
9307
+ `${itemPath(resolveOrg(cmd), id2)}/handoff`
9304
9308
  );
9305
9309
  if (resolveOutput(cmd) === "json") printJson(handoff);
9306
9310
  else process.stdout.write(handoff.prompt);
@@ -9321,10 +9325,10 @@ function register19(program2) {
9321
9325
  });
9322
9326
  group.command("page <id>").description(
9323
9327
  "The baseline body of a docs page, the base a docs-rewrite trial edits"
9324
- ).requiredOption("--url <url>", "the page URL").action(async (id, opts, cmd) => {
9328
+ ).requiredOption("--url <url>", "the page URL").action(async (id2, opts, cmd) => {
9325
9329
  const org = resolveOrg(cmd);
9326
9330
  const res = await createClient().get(
9327
- `${itemPath(org, id)}/page`,
9331
+ `${itemPath(org, id2)}/page`,
9328
9332
  { url: opts.url }
9329
9333
  );
9330
9334
  if (resolveOutput(cmd) === "json") printJson(res);
@@ -9465,10 +9469,10 @@ function register22(program2) {
9465
9469
  "table"
9466
9470
  );
9467
9471
  });
9468
- group.command("get <id>").description("Show one persona").action(async (id, _opts, cmd) => {
9472
+ group.command("get <id>").description("Show one persona").action(async (id2, _opts, cmd) => {
9469
9473
  const org = resolveOrg(cmd);
9470
9474
  const persona = await createClient().get(
9471
- `${personasPath(org)}/${encodeURIComponent(id)}`
9475
+ `${personasPath(org)}/${encodeURIComponent(id2)}`
9472
9476
  );
9473
9477
  if (resolveOutput(cmd) === "json") {
9474
9478
  printJson(persona);
@@ -9494,12 +9498,12 @@ function register22(program2) {
9494
9498
  }
9495
9499
  );
9496
9500
  group.command("edit <id>").description("Update a persona").option("--name <name>", "rename the persona").option("--description <text>", "replace the notes").action(
9497
- async (id, opts, cmd) => {
9501
+ async (id2, opts, cmd) => {
9498
9502
  const org = resolveOrg(cmd);
9499
9503
  if (opts.name === void 0 && opts.description === void 0)
9500
9504
  throw new CliError("usage", "nothing to change");
9501
9505
  const updated = await createClient().patch(
9502
- `${personasPath(org)}/${encodeURIComponent(id)}`,
9506
+ `${personasPath(org)}/${encodeURIComponent(id2)}`,
9503
9507
  { name: opts.name, description: opts.description }
9504
9508
  );
9505
9509
  if (resolveOutput(cmd) === "json") printJson(updated);
@@ -9508,12 +9512,12 @@ function register22(program2) {
9508
9512
  );
9509
9513
  group.command("rm <id>").description(
9510
9514
  "Delete a persona (run configurations fall back to the default persona)"
9511
- ).action(async (id, _opts, cmd) => {
9515
+ ).action(async (id2, _opts, cmd) => {
9512
9516
  const org = resolveOrg(cmd);
9513
9517
  await createClient().delete(
9514
- `${personasPath(org)}/${encodeURIComponent(id)}`
9518
+ `${personasPath(org)}/${encodeURIComponent(id2)}`
9515
9519
  );
9516
- if (resolveOutput(cmd) !== "json") console.log(`Deleted persona ${id}`);
9520
+ if (resolveOutput(cmd) !== "json") console.log(`Deleted persona ${id2}`);
9517
9521
  });
9518
9522
  }
9519
9523
 
@@ -9825,15 +9829,15 @@ function register24(program2) {
9825
9829
  );
9826
9830
  if (opts.tag.length > 0 && opts.clearTags)
9827
9831
  throw new CliError("usage", "--tag and --clear-tags conflict");
9828
- const body = { url };
9829
- if (opts.name !== void 0) body.name = opts.name;
9830
- if (opts.clearFrameworks) body.frameworks = [];
9831
- else if (opts.framework.length > 0) body.frameworks = opts.framework;
9832
- if (opts.clearTags) body.tags = [];
9833
- else if (opts.tag.length > 0) body.tags = opts.tag;
9834
- if (Object.keys(body).length === 1)
9832
+ const body2 = { url };
9833
+ if (opts.name !== void 0) body2.name = opts.name;
9834
+ if (opts.clearFrameworks) body2.frameworks = [];
9835
+ else if (opts.framework.length > 0) body2.frameworks = opts.framework;
9836
+ if (opts.clearTags) body2.tags = [];
9837
+ else if (opts.tag.length > 0) body2.tags = opts.tag;
9838
+ if (Object.keys(body2).length === 1)
9835
9839
  throw new CliError("usage", "nothing to change");
9836
- const repo = await createClient().patch(reposPath(org), body);
9840
+ const repo = await createClient().patch(reposPath(org), body2);
9837
9841
  if (resolveOutput(command) === "json") printJson(repo);
9838
9842
  else console.log(`Updated ${repo.name} (${repo.url})`);
9839
9843
  }
@@ -9872,29 +9876,36 @@ __export(runRequests_exports2, {
9872
9876
  });
9873
9877
  var pollIntervalMs = 5e3;
9874
9878
  function register25(program2) {
9875
- program2.command("run-requests").description("Read a durable launch and its aggregate verdict").command("wait <id>").description("Wait for all sessions and judging in a launch request").action(async (id, _opts, cmd) => {
9879
+ program2.command("run-requests").description("Read a durable launch and its aggregate verdict").command("wait <id>").description("Wait for all sessions and judging in a launch request").action(async (id2, _opts, cmd) => {
9876
9880
  const org = resolveOrg(cmd);
9877
- const path3 = `/api/v1/orgs/${encodeURIComponent(org)}/run-requests/${encodeURIComponent(id)}`;
9881
+ const path3 = `/api/v1/orgs/${encodeURIComponent(org)}/run-requests/${encodeURIComponent(id2)}`;
9878
9882
  const client = createClient();
9879
9883
  let lastStatus = "";
9880
9884
  while (true) {
9881
9885
  const result = await client.get(path3);
9882
9886
  if (resolveOutput(cmd) !== "json" && result.status !== lastStatus) {
9883
- console.error(`Run request ${id}: ${result.status}`);
9887
+ console.error(`Run request ${id2}: ${result.status}`);
9884
9888
  lastStatus = result.status;
9885
9889
  }
9886
9890
  if (result.settled) {
9887
9891
  if (resolveOutput(cmd) === "json") printJson(result);
9888
9892
  else {
9893
+ const measured = result.counts.measuredRuns ?? 0;
9889
9894
  console.log(
9890
- `${result.result}: ${result.counts.passedRuns}/${result.counts.createdRuns} passed sessions (${result.counts.judgedRuns} judged)`
9895
+ measured > 0 ? `${result.result}: ${measured} preference sessions measured${result.counts.passedRuns ? `; ${result.counts.passedRuns} experience sessions passed` : ""}` : `${result.result}: ${result.counts.passedRuns}/${result.counts.createdRuns} passed sessions (${result.counts.judgedRuns} judged)`
9891
9896
  );
9897
+ for (const batch of result.batches)
9898
+ for (const run of batch.runs)
9899
+ if (run.preference)
9900
+ console.log(
9901
+ ` ${run.id}: ${preferenceSelectionLabel(run.preference)} (advisory)`
9902
+ );
9892
9903
  console.log(`Request: ${result.id}`);
9893
9904
  }
9894
- if (result.result !== "PASSED")
9905
+ if (result.result !== "PASSED" && result.result !== "MEASURED")
9895
9906
  throw new CliError(
9896
9907
  "internal",
9897
- `Run request ${id}: ${result.result}`
9908
+ `Run request ${id2}: ${result.result}`
9898
9909
  );
9899
9910
  return;
9900
9911
  }
@@ -9908,11 +9919,11 @@ var runs_exports2 = {};
9908
9919
  __export(runs_exports2, {
9909
9920
  register: () => register26
9910
9921
  });
9911
- function runPath(id) {
9912
- return `/api/v1/runs/${encodeURIComponent(id)}`;
9922
+ function runPath(id2) {
9923
+ return `/api/v1/runs/${encodeURIComponent(id2)}`;
9913
9924
  }
9914
- function streamPath(id) {
9915
- return `/api/runs/${encodeURIComponent(id)}/stream`;
9925
+ function streamPath(id2) {
9926
+ return `/api/runs/${encodeURIComponent(id2)}/stream`;
9916
9927
  }
9917
9928
  function fmtDuration(ms) {
9918
9929
  if (ms == null) return "";
@@ -9922,6 +9933,10 @@ function fmtDuration(ms) {
9922
9933
  function fmtUsd(v) {
9923
9934
  return v == null ? "" : `$${v.toFixed(2)}`;
9924
9935
  }
9936
+ function fmtTriggeredBy(t) {
9937
+ if (!t) return "";
9938
+ return t.email ? `${t.source} (${t.email})` : t.source;
9939
+ }
9925
9940
  function compact(value, max = 140) {
9926
9941
  const s = typeof value === "string" ? value : JSON.stringify(value) ?? "null";
9927
9942
  const one = s.replace(/\s+/g, " ").trim();
@@ -9937,8 +9952,10 @@ function toRow5(run) {
9937
9952
  model: run.modelDisplayName ?? run.resolvedModel ?? run.model,
9938
9953
  provider: observed && observed !== selected ? `${selected || "?"} \u2192 ${observed}` : selected || observed || "",
9939
9954
  experiment: run.experiment ?? "",
9955
+ source: run.triggeredBy?.source ?? "",
9940
9956
  turns: run.turns ?? "",
9941
9957
  cost: fmtUsd(run.usdCost),
9958
+ credits: run.creditsCharged ?? "",
9942
9959
  duration: fmtDuration(run.durationMs),
9943
9960
  created: run.createdAt,
9944
9961
  prompt: compact(run.promptSnippet, 48)
@@ -9975,7 +9992,9 @@ function detailLines(run) {
9975
9992
  ],
9976
9993
  ["Attempt", String(run.attempt)],
9977
9994
  ["Turns", run.turns == null ? "\u2014" : String(run.turns)],
9995
+ ["Triggered by", fmtTriggeredBy(run.triggeredBy) || "\u2014"],
9978
9996
  ["Cost", fmtUsd(run.usdCost) || "\u2014"],
9997
+ ["Credits", run.creditsCharged == null ? "\u2014" : String(run.creditsCharged)],
9979
9998
  ["Duration", fmtDuration(run.durationMs) || "\u2014"],
9980
9999
  ["Exit reason", run.exitReason ?? "\u2014"],
9981
10000
  ["Failure reason", run.failureReason ?? "\u2014"],
@@ -10099,7 +10118,7 @@ var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
10099
10118
  ]);
10100
10119
  var STATUS_POLL_MS = 5e3;
10101
10120
  var TERMINAL_DRAIN_MS = 2e3;
10102
- async function streamRun(id, json, opts) {
10121
+ async function streamRun(id2, json, opts) {
10103
10122
  const client = createClient();
10104
10123
  const controller = new AbortController();
10105
10124
  let timer;
@@ -10117,7 +10136,7 @@ async function streamRun(id, json, opts) {
10117
10136
  poller = setInterval(() => {
10118
10137
  if (inFlight || drainTimer) return;
10119
10138
  inFlight = true;
10120
- client.get(runPath(id)).then((run) => {
10139
+ client.get(runPath(id2)).then((run) => {
10121
10140
  if (drainTimer || !TERMINAL_STATUSES.has(run.status)) return;
10122
10141
  if (poller) clearInterval(poller);
10123
10142
  drainTimer = setTimeout(() => {
@@ -10134,7 +10153,7 @@ async function streamRun(id, json, opts) {
10134
10153
  }
10135
10154
  try {
10136
10155
  await client.sse(
10137
- streamPath(id),
10156
+ streamPath(id2),
10138
10157
  (frame) => {
10139
10158
  const event = parseEvent(frame.data);
10140
10159
  if (!event) return;
@@ -10197,8 +10216,10 @@ function register26(program2) {
10197
10216
  }
10198
10217
  }
10199
10218
  );
10200
- runs.command("get <id>").description("Show a run (status, cost, turns, exit reason)").action(async (id, _opts, command) => {
10201
- const run = await createClient().get(runPath(id));
10219
+ runs.command("get <id>").description(
10220
+ "Show a run (status, trigger source, cost, credits, turns, exit reason)"
10221
+ ).action(async (id2, _opts, command) => {
10222
+ const run = await createClient().get(runPath(id2));
10202
10223
  if (resolveOutput(command) === "json") {
10203
10224
  printJson(run);
10204
10225
  return;
@@ -10209,9 +10230,9 @@ function register26(program2) {
10209
10230
  console.log(`${label.padEnd(width)} ${value}`);
10210
10231
  }
10211
10232
  });
10212
- runs.command("insight <id>").description("Show the run's LLM analysis (decisions)").action(async (id, _opts, command) => {
10233
+ runs.command("insight <id>").description("Show the run's LLM analysis (decisions)").action(async (id2, _opts, command) => {
10213
10234
  const insight = await createClient().get(
10214
- `${runPath(id)}/insight`
10235
+ `${runPath(id2)}/insight`
10215
10236
  );
10216
10237
  if (resolveOutput(command) === "json") {
10217
10238
  printJson(insight);
@@ -10221,9 +10242,9 @@ function register26(program2) {
10221
10242
  });
10222
10243
  runs.command("regrade <id>").description(
10223
10244
  "Re-judge the run against its eval set's current criteria (no new session)"
10224
- ).action(async (id, _opts, command) => {
10245
+ ).action(async (id2, _opts, command) => {
10225
10246
  const result = await createClient().post(
10226
- `${runPath(id)}/regrade`
10247
+ `${runPath(id2)}/regrade`
10227
10248
  );
10228
10249
  if (resolveOutput(command) === "json") {
10229
10250
  printJson(result);
@@ -10236,31 +10257,31 @@ function register26(program2) {
10236
10257
  });
10237
10258
  runs.command("watch <id>").description(
10238
10259
  "Stream normalized trace events live (SSE; exits when the run finishes)"
10239
- ).action(async (id, _opts, command) => {
10240
- await streamRun(id, resolveOutput(command) === "json", {
10260
+ ).action(async (id2, _opts, command) => {
10261
+ await streamRun(id2, resolveOutput(command) === "json", {
10241
10262
  idleMs: 0,
10242
10263
  firstEventMs: 0,
10243
10264
  pollStatus: true
10244
10265
  });
10245
10266
  });
10246
- runs.command("logs <id>").description("Dump the run's trace events so far, then exit (non-follow)").action(async (id, _opts, command) => {
10247
- await streamRun(id, resolveOutput(command) === "json", {
10267
+ runs.command("logs <id>").description("Dump the run's trace events so far, then exit (non-follow)").action(async (id2, _opts, command) => {
10268
+ await streamRun(id2, resolveOutput(command) === "json", {
10248
10269
  idleMs: 2e3,
10249
10270
  firstEventMs: 15e3,
10250
10271
  stopAtLiveMs: Date.now() - 2e3
10251
10272
  });
10252
10273
  });
10253
- runs.command("diff <id>").description("Print the run's working-tree diff to stdout").action(async (id) => {
10254
- const diff = await createClient().get(`${runPath(id)}/diff`);
10274
+ runs.command("diff <id>").description("Print the run's working-tree diff to stdout").action(async (id2) => {
10275
+ const diff = await createClient().get(`${runPath(id2)}/diff`);
10255
10276
  if (!diff) {
10256
10277
  console.error("(no diff)");
10257
10278
  return;
10258
10279
  }
10259
10280
  process.stdout.write(diff);
10260
10281
  });
10261
- runs.command("fork <id>").description("Fork a finished run from its latest conversation checkpoint").requiredOption("--prompt <text>", "continuation prompt for the child run").action(async (id, opts, command) => {
10282
+ runs.command("fork <id>").description("Fork a finished run from its latest conversation checkpoint").requiredOption("--prompt <text>", "continuation prompt for the child run").action(async (id2, opts, command) => {
10262
10283
  const result = await createClient().post(
10263
- `${runPath(id)}/fork`,
10284
+ `${runPath(id2)}/fork`,
10264
10285
  { prompt: opts.prompt }
10265
10286
  );
10266
10287
  if (resolveOutput(command) === "json") {
@@ -10274,9 +10295,9 @@ function register26(program2) {
10274
10295
  });
10275
10296
  runs.command("fork-boundaries <id>").description(
10276
10297
  "The run's forkable fetch boundaries + checkpoint availability"
10277
- ).action(async (id) => {
10298
+ ).action(async (id2) => {
10278
10299
  const result = await createClient().get(
10279
- `${runPath(id)}/fork-boundaries`
10300
+ `${runPath(id2)}/fork-boundaries`
10280
10301
  );
10281
10302
  printJson(result);
10282
10303
  });
@@ -10286,9 +10307,9 @@ function register26(program2) {
10286
10307
  );
10287
10308
  printJson(result);
10288
10309
  });
10289
- runs.command("cancel <id>").description("Request cancellation of a run").action(async (id, _opts, command) => {
10310
+ runs.command("cancel <id>").description("Request cancellation of a run").action(async (id2, _opts, command) => {
10290
10311
  const result = await createClient().post(
10291
- `${runPath(id)}/cancel`
10312
+ `${runPath(id2)}/cancel`
10292
10313
  );
10293
10314
  if (resolveOutput(command) === "json") {
10294
10315
  printJson(result);
@@ -10331,11 +10352,11 @@ async function buildSkillEditBody(opts, fetchCurrentSource) {
10331
10352
  throw new CliError("usage", "--auto-ingest expects true or false");
10332
10353
  autoIngest = opts.autoIngest === "true";
10333
10354
  }
10334
- const body = {};
10335
- if (opts.rename !== void 0) body.name = opts.rename;
10336
- if (opts.clearNote) body.note = null;
10337
- else if (opts.note !== void 0) body.note = opts.note;
10338
- if (opts.clearSource) body.source = null;
10355
+ const body2 = {};
10356
+ if (opts.rename !== void 0) body2.name = opts.rename;
10357
+ if (opts.clearNote) body2.note = null;
10358
+ else if (opts.note !== void 0) body2.note = opts.note;
10359
+ if (opts.clearSource) body2.source = null;
10339
10360
  else if (opts.source !== void 0) {
10340
10361
  const m = opts.source.match(/^([^#]+\/[^#/]+)#([^/]+)(?:\/(.+))?$/);
10341
10362
  if (!m)
@@ -10343,7 +10364,7 @@ async function buildSkillEditBody(opts, fetchCurrentSource) {
10343
10364
  "usage",
10344
10365
  'invalid --source (expected "owner/repo#branch" or "owner/repo#branch/subpath")'
10345
10366
  );
10346
- body.source = {
10367
+ body2.source = {
10347
10368
  repoFullName: m[1],
10348
10369
  ref: m[2],
10349
10370
  subpath: m[3],
@@ -10356,16 +10377,16 @@ async function buildSkillEditBody(opts, fetchCurrentSource) {
10356
10377
  "usage",
10357
10378
  "this skill has no tracked source \u2014 set one first with --source owner/repo#branch"
10358
10379
  );
10359
- body.source = {
10380
+ body2.source = {
10360
10381
  repoFullName: current.repoFullName,
10361
10382
  ref: current.ref,
10362
10383
  subpath: current.subpath || void 0,
10363
10384
  autoIngest
10364
10385
  };
10365
10386
  }
10366
- if (Object.keys(body).length === 0)
10387
+ if (Object.keys(body2).length === 0)
10367
10388
  throw new CliError("usage", "nothing to change");
10368
- return body;
10389
+ return body2;
10369
10390
  }
10370
10391
  function register27(program2) {
10371
10392
  const group = program2.command("skills").description("Manage agent skills used by eval and visibility runs");
@@ -10447,13 +10468,13 @@ function register27(program2) {
10447
10468
  ).action(async (ref, opts, cmd) => {
10448
10469
  const org = resolveOrg(cmd);
10449
10470
  const client = createClient();
10450
- const body = await buildSkillEditBody(opts, async () => {
10471
+ const body2 = await buildSkillEditBody(opts, async () => {
10451
10472
  const skill2 = await client.get(skillPath(org, ref));
10452
10473
  return skill2.source;
10453
10474
  });
10454
10475
  const updated = await client.patch(
10455
10476
  skillPath(org, ref),
10456
- body
10477
+ body2
10457
10478
  );
10458
10479
  if (resolveOutput(cmd) === "json") printJson(updated);
10459
10480
  else console.log(`Updated skill ${updated.name}`);
@@ -10852,9 +10873,9 @@ function scenarioRow(scenario) {
10852
10873
  persona: scenario.profile?.name ?? "(default)"
10853
10874
  };
10854
10875
  }
10855
- var KIND_CHOICES = ["head-to-head", "recommend"];
10876
+ var KIND_CHOICES = ["head-to-head", "open-ended"];
10856
10877
  function parseKind(raw) {
10857
- const upper = raw.trim().toUpperCase().replace(/-/g, "_");
10878
+ const upper = raw === "open-ended" ? "RECOMMEND" : raw.trim().toUpperCase().replace(/-/g, "_");
10858
10879
  if (upper !== "HEAD_TO_HEAD" && upper !== "RECOMMEND")
10859
10880
  throw new CliError(
10860
10881
  "usage",
@@ -10870,7 +10891,7 @@ function toRow6(v) {
10870
10891
  return {
10871
10892
  id: v.id,
10872
10893
  name: v.name,
10873
- kind: v.kind,
10894
+ kind: v.kind === "RECOMMEND" ? "open-ended" : "head-to-head",
10874
10895
  brands: brandsLabel(v),
10875
10896
  market: v.market?.slug ?? "",
10876
10897
  tags: v.tags.join(", "),
@@ -10881,7 +10902,9 @@ function toRow6(v) {
10881
10902
  function printDetail4(v) {
10882
10903
  console.log(`id: ${v.id}`);
10883
10904
  console.log(`name: ${v.name}`);
10884
- console.log(`kind: ${v.kind}`);
10905
+ console.log(
10906
+ `kind: ${v.kind === "RECOMMEND" ? "open-ended" : "head-to-head"}`
10907
+ );
10885
10908
  console.log(`brands: ${brandsLabel(v)}`);
10886
10909
  console.log(
10887
10910
  `market: ${v.market ? `${v.market.name} (${v.market.slug})` : "(none)"}`
@@ -10915,10 +10938,10 @@ function registerPreferenceGroup(group) {
10915
10938
  if (resolveOutput(cmd) === "json") printJson(res.items);
10916
10939
  else printItems(res.items.map(toRow6), "table");
10917
10940
  });
10918
- group.command("get <id>").description("Show one preference prompt").action(async (id, _opts, cmd) => {
10941
+ group.command("get <id>").description("Show one preference prompt").action(async (id2, _opts, cmd) => {
10919
10942
  const org = resolveOrg(cmd);
10920
10943
  const vp = await createClient().get(
10921
- `${visibilityPath(org)}/${encodeURIComponent(id)}`
10944
+ `${visibilityPath(org)}/${encodeURIComponent(id2)}`
10922
10945
  );
10923
10946
  if (resolveOutput(cmd) === "json") printJson(vp);
10924
10947
  else printDetail4(vp);
@@ -10926,7 +10949,7 @@ function registerPreferenceGroup(group) {
10926
10949
  addRunSettingsCreateOptions(
10927
10950
  group.command("create").description(
10928
10951
  "Create a preference prompt. Run-settings flags set its roster, resources, cadence, and samples; --repo/--ref/--persona add its first scenario. Omit them all for a bare definition on the org's default roster."
10929
- ).requiredOption("--name <name>", "preference prompt name").requiredOption("--kind <kind>", KIND_CHOICES.join(" | ")).option("--text <text>", "prompt text inline").option("--file <path>", 'prompt text from a file ("-" for stdin)').option("--brand-a <name>", "first brand (required for head-to-head)").option("--brand-b <name>", "second brand (required for head-to-head)").option("--branded", "a branded RECOMMEND measurement").option(
10952
+ ).requiredOption("--name <name>", "preference prompt name").requiredOption("--kind <kind>", KIND_CHOICES.join(" | ")).option("--text <text>", "prompt text inline").option("--file <path>", 'prompt text from a file ("-" for stdin)').option("--brand-a <name>", "first brand (required for head-to-head)").option("--brand-b <name>", "second brand (required for head-to-head)").option("--branded", "an open-ended prompt that names a brand").option(
10930
10953
  "--repo <url>",
10931
10954
  "first scenario's repository (default: empty project)"
10932
10955
  ).option("--ref <ref>", "branch, tag, or commit (with --repo)").option("--persona <profileId>", "first scenario's persona profile id")
@@ -10944,7 +10967,7 @@ function registerPreferenceGroup(group) {
10944
10967
  if (opts.ref !== void 0 && opts.repo === void 0)
10945
10968
  throw new CliError("usage", "--ref requires --repo");
10946
10969
  const hasScenario = opts.repo !== void 0 || opts.persona !== void 0;
10947
- const body = {
10970
+ const body2 = {
10948
10971
  name: opts.name,
10949
10972
  promptText: readPromptText(opts),
10950
10973
  kind: parseKind(opts.kind),
@@ -10964,7 +10987,7 @@ function registerPreferenceGroup(group) {
10964
10987
  };
10965
10988
  const created = await createClient().post(
10966
10989
  visibilityPath(org),
10967
- body
10990
+ body2
10968
10991
  );
10969
10992
  if (resolveOutput(cmd) === "json") printJson(created);
10970
10993
  else console.log(`Created preference prompt ${created.id}`);
@@ -10983,51 +11006,51 @@ function registerPreferenceGroup(group) {
10983
11006
  []
10984
11007
  ).option("--clear-tags", "remove all user tags")
10985
11008
  ).action(
10986
- async (id, opts, cmd) => {
11009
+ async (id2, opts, cmd) => {
10987
11010
  const org = resolveOrg(cmd);
10988
- const body = {
11011
+ const body2 = {
10989
11012
  ...runSettingsPatchFromOpts(opts)
10990
11013
  };
10991
- if (opts.name !== void 0) body.name = opts.name;
11014
+ if (opts.name !== void 0) body2.name = opts.name;
10992
11015
  if (opts.text !== void 0 || opts.file !== void 0)
10993
- body.promptText = readPromptText(opts);
10994
- if (opts.brandA !== void 0) body.brandA = opts.brandA;
10995
- if (opts.brandB !== void 0) body.brandB = opts.brandB;
11016
+ body2.promptText = readPromptText(opts);
11017
+ if (opts.brandA !== void 0) body2.brandA = opts.brandA;
11018
+ if (opts.brandB !== void 0) body2.brandB = opts.brandB;
10996
11019
  if (opts.branded && opts.organic)
10997
11020
  throw new CliError("usage", "--branded and --organic conflict");
10998
- if (opts.branded) body.branded = true;
10999
- else if (opts.organic) body.branded = false;
11021
+ if (opts.branded) body2.branded = true;
11022
+ else if (opts.organic) body2.branded = false;
11000
11023
  if (opts.market !== void 0 && opts.clearMarket)
11001
11024
  throw new CliError("usage", "--market and --clear-market conflict");
11002
- if (opts.clearMarket) body.marketId = null;
11003
- else if (opts.market !== void 0) body.marketId = opts.market;
11025
+ if (opts.clearMarket) body2.marketId = null;
11026
+ else if (opts.market !== void 0) body2.marketId = opts.market;
11004
11027
  if (opts.tag.length > 0 && opts.clearTags)
11005
11028
  throw new CliError("usage", "--tag and --clear-tags conflict");
11006
- if (opts.clearTags) body.tags = [];
11007
- else if (opts.tag.length > 0) body.tags = opts.tag;
11008
- if (Object.keys(body).length === 0)
11029
+ if (opts.clearTags) body2.tags = [];
11030
+ else if (opts.tag.length > 0) body2.tags = opts.tag;
11031
+ if (Object.keys(body2).length === 0)
11009
11032
  throw new CliError("usage", "nothing to change");
11010
11033
  const updated = await createClient().patch(
11011
- `${visibilityPath(org)}/${encodeURIComponent(id)}`,
11012
- body
11034
+ `${visibilityPath(org)}/${encodeURIComponent(id2)}`,
11035
+ body2
11013
11036
  );
11014
11037
  if (resolveOutput(cmd) === "json") printJson(updated);
11015
11038
  else console.log(`Updated preference prompt ${updated.id}`);
11016
11039
  }
11017
11040
  );
11018
- group.command("rm <id>").description("Delete a preference prompt (its run history survives)").action(async (id, _opts, cmd) => {
11041
+ group.command("rm <id>").description("Delete a preference prompt (its run history survives)").action(async (id2, _opts, cmd) => {
11019
11042
  const org = resolveOrg(cmd);
11020
11043
  await createClient().delete(
11021
- `${visibilityPath(org)}/${encodeURIComponent(id)}`
11044
+ `${visibilityPath(org)}/${encodeURIComponent(id2)}`
11022
11045
  );
11023
11046
  if (resolveOutput(cmd) !== "json")
11024
- console.log(`Deleted preference prompt ${id}`);
11047
+ console.log(`Deleted preference prompt ${id2}`);
11025
11048
  });
11026
11049
  const scenarios = group.command("scenarios").description("The repo \xD7 persona scenarios a preference prompt runs in");
11027
- scenarios.command("list <id>").description("List a preference prompt's scenarios").action(async (id, _opts, cmd) => {
11050
+ scenarios.command("list <id>").description("List a preference prompt's scenarios").action(async (id2, _opts, cmd) => {
11028
11051
  const org = resolveOrg(cmd);
11029
11052
  const vp = await createClient().get(
11030
- `${visibilityPath(org)}/${encodeURIComponent(id)}`
11053
+ `${visibilityPath(org)}/${encodeURIComponent(id2)}`
11031
11054
  );
11032
11055
  if (resolveOutput(cmd) === "json") printJson(vp.scenarios);
11033
11056
  else printItems(vp.scenarios.map(scenarioRow), "table");
@@ -11036,12 +11059,12 @@ function registerPreferenceGroup(group) {
11036
11059
  "--persona <profileId>",
11037
11060
  "persona profile id (default persona if omitted)"
11038
11061
  ).action(
11039
- async (id, opts, cmd) => {
11062
+ async (id2, opts, cmd) => {
11040
11063
  const org = resolveOrg(cmd);
11041
11064
  if (opts.ref !== void 0 && opts.repo === void 0)
11042
11065
  throw new CliError("usage", "--ref requires --repo");
11043
11066
  const created = await createClient().post(
11044
- scenariosPath(org, id),
11067
+ scenariosPath(org, id2),
11045
11068
  {
11046
11069
  repoUrl: opts.repo ?? null,
11047
11070
  repoRef: opts.ref ?? null,
@@ -11052,10 +11075,10 @@ function registerPreferenceGroup(group) {
11052
11075
  else console.log(`Added scenario ${created.id}`);
11053
11076
  }
11054
11077
  );
11055
- scenarios.command("rm <id>").description("Remove one scenario").requiredOption("--scenario <scenarioId>", "scenario id to remove").action(async (id, opts, cmd) => {
11078
+ scenarios.command("rm <id>").description("Remove one scenario").requiredOption("--scenario <scenarioId>", "scenario id to remove").action(async (id2, opts, cmd) => {
11056
11079
  const org = resolveOrg(cmd);
11057
11080
  await createClient().delete(
11058
- `${scenariosPath(org, id)}/${encodeURIComponent(opts.scenario)}`
11081
+ `${scenariosPath(org, id2)}/${encodeURIComponent(opts.scenario)}`
11059
11082
  );
11060
11083
  if (resolveOutput(cmd) !== "json")
11061
11084
  console.log(`Removed scenario ${opts.scenario}`);
@@ -11071,14 +11094,14 @@ function registerPreferenceGroup(group) {
11071
11094
  "bill this run to the org's credits instead (superusers)"
11072
11095
  ).hideHelp(!staffCommandsVisible())
11073
11096
  ).option("--yes", "skip the confirmation").action(
11074
- async (id, opts, cmd) => {
11097
+ async (id2, opts, cmd) => {
11075
11098
  const org = resolveOrg(cmd);
11076
11099
  await confirmOrAbort(
11077
11100
  opts.scenario.length > 0 ? `Run ${opts.scenario.length} selected scenario${opts.scenario.length === 1 ? "" : "s"} with the stored settings now?` : "Run every scenario of this prompt with the stored settings now?",
11078
11101
  opts.yes
11079
11102
  );
11080
11103
  const result = await createClient().post(
11081
- `${visibilityPath(org)}/${encodeURIComponent(id)}/run`,
11104
+ `${visibilityPath(org)}/${encodeURIComponent(id2)}/run`,
11082
11105
  {
11083
11106
  ...opts.billToOrg ? { billToOrg: true } : {},
11084
11107
  visibilityScenarioIds: opts.scenario.length > 0 ? opts.scenario : void 0
@@ -11107,35 +11130,44 @@ function registerPreferenceGroup(group) {
11107
11130
  result.queued ? "Synthesis queued \u2014 insights land on the Agent Preference page shortly" : "Nothing new since the last pass \u2014 no synthesis queued"
11108
11131
  );
11109
11132
  });
11110
- group.command("runs <id>").description("The prompt's run log with Agent Preference verdicts").option("--limit <n>", "max runs (default 100)").action(async (id, opts, cmd) => {
11111
- const org = resolveOrg(cmd);
11112
- const res = await createClient().get(
11113
- `${visibilityPath(org)}/${encodeURIComponent(id)}/runs`,
11114
- { limit: opts.limit }
11115
- );
11116
- if (resolveOutput(cmd) === "json") {
11117
- printJson(res.items);
11118
- return;
11133
+ group.command("runs <id>").description("The prompt's run log with Agent Preference verdicts").option("--limit <n>", "page size (1-500, default 100)").option("--cursor <cursor>", "resume from a previous page's nextCursor").action(
11134
+ async (id2, opts, cmd) => {
11135
+ const org = resolveOrg(cmd);
11136
+ const res = await createClient().get(
11137
+ `${visibilityPath(org)}/${encodeURIComponent(id2)}/runs`,
11138
+ { limit: opts.limit, cursor: opts.cursor }
11139
+ );
11140
+ if (resolveOutput(cmd) === "json") {
11141
+ printJson(res);
11142
+ return;
11143
+ }
11144
+ printItems(
11145
+ res.items.map((r) => ({
11146
+ id: r.id,
11147
+ status: r.status,
11148
+ agent: r.agent,
11149
+ model: r.resolvedModel ?? r.model ?? "",
11150
+ source: r.triggeredBy?.source ?? "",
11151
+ credits: r.creditsCharged ?? "",
11152
+ created: r.createdAt,
11153
+ verdict: r.verdict?.status ?? "-"
11154
+ })),
11155
+ "table"
11156
+ );
11157
+ if (res.nextCursor) {
11158
+ console.error(
11159
+ `(more results \u2014 rerun with --cursor ${res.nextCursor})`
11160
+ );
11161
+ }
11119
11162
  }
11120
- printItems(
11121
- res.items.map((r) => ({
11122
- id: r.id,
11123
- status: r.status,
11124
- agent: r.agent,
11125
- model: r.resolvedModel ?? r.model ?? "",
11126
- created: r.createdAt,
11127
- verdict: r.verdict?.status ?? "-"
11128
- })),
11129
- "table"
11130
- );
11131
- });
11163
+ );
11132
11164
  group.command("tag <id>").description("Replace a preference prompt's user tags").option(
11133
11165
  "--tag <name>",
11134
11166
  "tag name, create-on-type (repeatable)",
11135
11167
  collect,
11136
11168
  []
11137
11169
  ).option("--clear", "remove all user tags").action(
11138
- async (id, opts, cmd) => {
11170
+ async (id2, opts, cmd) => {
11139
11171
  const org = resolveOrg(cmd);
11140
11172
  if (opts.tag.length > 0 && opts.clear)
11141
11173
  throw new CliError("usage", "--tag and --clear conflict");
@@ -11145,7 +11177,7 @@ function registerPreferenceGroup(group) {
11145
11177
  "pass --tag <name> (repeatable) or --clear"
11146
11178
  );
11147
11179
  const updated = await createClient().patch(
11148
- `${visibilityPath(org)}/${encodeURIComponent(id)}`,
11180
+ `${visibilityPath(org)}/${encodeURIComponent(id2)}`,
11149
11181
  { tags: opts.clear ? [] : opts.tag }
11150
11182
  );
11151
11183
  if (resolveOutput(cmd) === "json") printJson(updated);