@withgauge/cli 0.11.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +77 -0
  2. package/dist/index.js +1809 -593
  3. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -1883,7 +1883,9 @@ var updateEvalSetBodySchema = z20.object({
1883
1883
  }).extend(ownedConfigurationPatchShape).strict();
1884
1884
  var runEvalSetResponseSchema = z20.object({
1885
1885
  batchIds: z20.array(z20.string()),
1886
- runIds: z20.array(z20.string())
1886
+ runIds: z20.array(z20.string()),
1887
+ /** Durable launch request; absent for older and climb-trial launch paths. */
1888
+ runRequestId: z20.string().optional()
1887
1889
  });
1888
1890
  var evalSetRunSchema = z20.object({
1889
1891
  id: z20.string(),
@@ -2564,10 +2566,534 @@ var meResponseSchema = z27.object({
2564
2566
  });
2565
2567
 
2566
2568
  // ../packages/api-schemas/src/optimizations.ts
2567
- import { z as z30 } from "zod";
2569
+ import { z as z31 } from "zod";
2568
2570
 
2569
2571
  // ../packages/api-schemas/src/climb.ts
2570
- import { z as z29 } from "zod";
2572
+ import { z as z30 } from "zod";
2573
+
2574
+ // ../packages/api-schemas/src/cli-interventions.ts
2575
+ import { z as z28 } from "zod";
2576
+ var digest = z28.string().regex(/^[a-f0-9]{64}$/);
2577
+ var token = z28.string().min(1).max(4096);
2578
+ var optionFlag = z28.string().regex(/^--?[A-Za-z0-9][A-Za-z0-9-]*$/);
2579
+ var envKey = z28.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/);
2580
+ var relativePath = z28.string().min(1).max(1024).refine(
2581
+ (path2) => !path2.startsWith("/") && !path2.includes("\\") && !path2.includes("\0") && path2.split("/").every(
2582
+ (part) => part && part !== "." && part !== ".." && ![".git", "node_modules", ".pnpm", ".yarn", ".venv"].includes(part)
2583
+ ),
2584
+ "Use a workspace-relative path without traversal"
2585
+ );
2586
+ var sourcedValue = z28.discriminatedUnion("source", [
2587
+ z28.object({ source: z28.literal("literal"), value: z28.string().max(8192) }).strict(),
2588
+ z28.object({ source: z28.literal("localFact"), key: envKey }).strict()
2589
+ ]);
2590
+ var cliLaunchFormSchema = z28.enum([
2591
+ "native",
2592
+ "path",
2593
+ "symlink",
2594
+ "shebang",
2595
+ "node-script",
2596
+ "python-script",
2597
+ "python-module",
2598
+ "execveat-path",
2599
+ "execveat-fd"
2600
+ ]);
2601
+ var cliIoProfileSchema = z28.enum([
2602
+ "pipes",
2603
+ "redirected",
2604
+ "shared-descriptor",
2605
+ "pty"
2606
+ ]);
2607
+ var cliOperationKindSchema = z28.enum([
2608
+ "ensureOption",
2609
+ "replaceOption",
2610
+ "setEnv",
2611
+ "streamOutput",
2612
+ "completeOutput",
2613
+ "structuredStdin",
2614
+ "promptRecipe",
2615
+ "generatedFile"
2616
+ ]);
2617
+ var commandCapabilitiesSchema = z28.object({
2618
+ operations: z28.array(cliOperationKindSchema).max(8),
2619
+ options: z28.array(z28.object({ flag: optionFlag, takesValue: z28.boolean() }).strict()).max(100).default([]),
2620
+ settings: z28.array(envKey).max(100).default([]),
2621
+ localFacts: z28.array(envKey).max(30).default([]),
2622
+ generatedPaths: z28.array(relativePath).max(50).default([]),
2623
+ outputModes: z28.array(z28.enum(["streaming", "completed"])).max(2).default([]),
2624
+ stdinFormats: z28.array(z28.enum(["text", "json", "jsonl"])).max(3).default([]),
2625
+ recipeIds: z28.array(token).max(50).default([])
2626
+ }).strict();
2627
+ var cliTargetSchema = z28.object({
2628
+ id: token,
2629
+ vendor: token,
2630
+ package: token,
2631
+ version: token.nullable(),
2632
+ /** Published artifact identity and exact executable/entrypoint identity. */
2633
+ artifactSha256: digest.nullable(),
2634
+ entrypointSha256: digest.nullable(),
2635
+ /** Trace-derived recognition hints. Actual bytes are captured by record mode. */
2636
+ discovery: z28.object({
2637
+ ecosystem: token.nullable(),
2638
+ program: token,
2639
+ executables: z28.array(token).max(20)
2640
+ }).strict().optional(),
2641
+ ownershipEvidence: z28.string().min(1).max(2048),
2642
+ entrypoints: z28.array(z28.string().min(1).max(1024)).max(20),
2643
+ /** Flags accepted before the subcommand, with explicit value arity. */
2644
+ globalOptions: z28.array(z28.object({ flag: optionFlag, takesValue: z28.boolean() }).strict()).max(100),
2645
+ launchForms: z28.array(cliLaunchFormSchema).min(1),
2646
+ ioProfiles: z28.array(cliIoProfileSchema).min(1),
2647
+ commands: z28.array(
2648
+ z28.object({
2649
+ id: token,
2650
+ /** Tokens following global options, before a literal `--`. */
2651
+ subcommand: z28.array(token).max(8),
2652
+ capabilities: commandCapabilitiesSchema
2653
+ }).strict()
2654
+ ).min(1)
2655
+ }).strict().superRefine((target, ctx) => {
2656
+ if (!target.discovery && (!target.version || !target.artifactSha256 || !target.entrypointSha256 || !target.entrypoints.length))
2657
+ ctx.addIssue({
2658
+ code: "custom",
2659
+ message: "Registered targets need complete artifact identities"
2660
+ });
2661
+ if (target.discovery && (target.artifactSha256 !== null || target.entrypointSha256 !== null))
2662
+ ctx.addIssue({
2663
+ code: "custom",
2664
+ message: "Discovered targets learn bytes from baseline invocations"
2665
+ });
2666
+ for (const [index, command] of target.commands.entries()) {
2667
+ if (target.commands.findIndex((other) => other.id === command.id) !== index)
2668
+ ctx.addIssue({
2669
+ code: "custom",
2670
+ path: ["commands", index, "id"],
2671
+ message: "Duplicate command ID"
2672
+ });
2673
+ const { capabilities } = command;
2674
+ if (new Set(capabilities.operations).size !== capabilities.operations.length)
2675
+ ctx.addIssue({
2676
+ code: "custom",
2677
+ path: ["commands", index, "capabilities", "operations"],
2678
+ message: "Duplicate operation"
2679
+ });
2680
+ const requires = (kind, valid, message) => {
2681
+ if (capabilities.operations.includes(kind) && !valid)
2682
+ ctx.addIssue({
2683
+ code: "custom",
2684
+ path: ["commands", index, "capabilities", "operations"],
2685
+ message
2686
+ });
2687
+ };
2688
+ requires(
2689
+ "streamOutput",
2690
+ capabilities.outputModes.includes("streaming"),
2691
+ "Streaming output needs a qualified streaming mode"
2692
+ );
2693
+ requires(
2694
+ "completeOutput",
2695
+ capabilities.outputModes.includes("completed"),
2696
+ "Completed output needs a qualified completed mode"
2697
+ );
2698
+ requires(
2699
+ "structuredStdin",
2700
+ capabilities.stdinFormats.length > 0,
2701
+ "Structured stdin needs a qualified format"
2702
+ );
2703
+ requires(
2704
+ "promptRecipe",
2705
+ capabilities.recipeIds.length > 0,
2706
+ "Prompt recipes need qualified prompt IDs"
2707
+ );
2708
+ requires(
2709
+ "generatedFile",
2710
+ capabilities.generatedPaths.length > 0,
2711
+ "Generated files need attributed output paths"
2712
+ );
2713
+ requires(
2714
+ "setEnv",
2715
+ capabilities.settings.length > 0,
2716
+ "Environment changes need supported settings"
2717
+ );
2718
+ requires(
2719
+ "ensureOption",
2720
+ capabilities.options.length > 0,
2721
+ "Arguments need supported options"
2722
+ );
2723
+ requires(
2724
+ "replaceOption",
2725
+ capabilities.options.length > 0,
2726
+ "Arguments need supported options"
2727
+ );
2728
+ }
2729
+ });
2730
+ var CLI_CATALOG_MAX_TARGETS = 100;
2731
+ var cliCatalogSchema = z28.object({
2732
+ version: z28.union([z28.literal(1), z28.literal(2)]),
2733
+ engineVersion: token,
2734
+ digest,
2735
+ targets: z28.array(cliTargetSchema).max(CLI_CATALOG_MAX_TARGETS)
2736
+ }).strict().superRefine((catalog, ctx) => {
2737
+ if (catalog.version === 1 && (!catalog.targets.length || catalog.targets.some((target) => target.discovery)))
2738
+ ctx.addIssue({
2739
+ code: "custom",
2740
+ message: "Discovery requires catalog version 2"
2741
+ });
2742
+ catalog.targets.forEach((target, index) => {
2743
+ if (catalog.targets.findIndex((other) => other.id === target.id) !== index)
2744
+ ctx.addIssue({
2745
+ code: "custom",
2746
+ path: ["targets", index, "id"],
2747
+ message: "Duplicate target ID"
2748
+ });
2749
+ });
2750
+ });
2751
+ var exitPredicate = z28.discriminatedUnion("kind", [
2752
+ z28.object({ kind: z28.literal("any") }).strict(),
2753
+ z28.object({
2754
+ kind: z28.literal("code"),
2755
+ value: z28.number().int().min(0).max(255)
2756
+ }).strict()
2757
+ ]);
2758
+ var outputStream = z28.enum(["stdout", "stderr", "combined"]);
2759
+ var literalEdit = z28.object({ find: z28.string().min(1).max(8192), replace: z28.string().max(8192) }).strict();
2760
+ function boundedOutputPattern(pattern) {
2761
+ let at = pattern.startsWith("^") ? 1 : 0;
2762
+ const end = pattern.endsWith("$") && pattern.length > at ? pattern.length - 1 : pattern.length;
2763
+ let stars = 0;
2764
+ let literalBytes = 0;
2765
+ while (at < end) {
2766
+ const char = pattern[at];
2767
+ if (char === "\\") {
2768
+ if (++at >= end || !"\\.^$*+?[]{}()|".includes(pattern[at])) return false;
2769
+ literalBytes++;
2770
+ } else if (char === "." && pattern[at + 1] === "*") {
2771
+ if (++stars > 1) return false;
2772
+ at++;
2773
+ } else if (".^$*+?[]{}()|\n\r".includes(char)) {
2774
+ return false;
2775
+ } else {
2776
+ literalBytes++;
2777
+ }
2778
+ at++;
2779
+ }
2780
+ return literalBytes > 0;
2781
+ }
2782
+ var operationSchema = z28.discriminatedUnion("kind", [
2783
+ z28.object({
2784
+ kind: z28.literal("ensureOption"),
2785
+ option: optionFlag,
2786
+ value: sourcedValue.optional()
2787
+ }).strict(),
2788
+ z28.object({
2789
+ kind: z28.literal("replaceOption"),
2790
+ option: optionFlag,
2791
+ value: sourcedValue
2792
+ }).strict(),
2793
+ z28.object({
2794
+ kind: z28.literal("setEnv"),
2795
+ key: envKey,
2796
+ value: sourcedValue,
2797
+ whenAbsent: z28.boolean()
2798
+ }).strict(),
2799
+ z28.object({
2800
+ kind: z28.literal("streamOutput"),
2801
+ stream: outputStream,
2802
+ edit: literalEdit
2803
+ }).strict(),
2804
+ z28.object({
2805
+ kind: z28.literal("completeOutput"),
2806
+ stream: outputStream,
2807
+ matcher: z28.discriminatedUnion("kind", [
2808
+ z28.object({
2809
+ kind: z28.literal("literal"),
2810
+ text: z28.string().min(1).max(8192)
2811
+ }).strict(),
2812
+ z28.object({
2813
+ kind: z28.literal("re2"),
2814
+ pattern: z28.string().min(1).max(2048).refine(
2815
+ boundedOutputPattern,
2816
+ "Use literals, anchors, and at most one greedy .*; escape literal regex punctuation"
2817
+ )
2818
+ }).strict()
2819
+ ]),
2820
+ replace: z28.string().max(8192),
2821
+ exit: exitPredicate
2822
+ }).strict(),
2823
+ z28.object({
2824
+ kind: z28.literal("structuredStdin"),
2825
+ format: z28.enum(["text", "json", "jsonl"]),
2826
+ payload: sourcedValue,
2827
+ timing: z28.literal("onLaunch"),
2828
+ callerInput: z28.literal("replace"),
2829
+ eof: z28.literal("close")
2830
+ }).strict(),
2831
+ z28.object({
2832
+ kind: z28.literal("promptRecipe"),
2833
+ recipeId: token,
2834
+ steps: z28.array(
2835
+ z28.object({
2836
+ prompt: z28.string().min(1).max(4096),
2837
+ response: sourcedValue,
2838
+ timeoutMs: z28.number().int().min(1).max(12e4)
2839
+ }).strict()
2840
+ ).min(1).max(20),
2841
+ overallTimeoutMs: z28.number().int().min(1).max(6e5),
2842
+ completion: z28.string().min(1).max(4096)
2843
+ }).strict(),
2844
+ z28.object({
2845
+ kind: z28.literal("generatedFile"),
2846
+ path: relativePath,
2847
+ beforeSha256: digest.nullable(),
2848
+ generatedSha256: digest,
2849
+ outcome: exitPredicate,
2850
+ edit: literalEdit,
2851
+ required: z28.boolean()
2852
+ }).strict()
2853
+ ]);
2854
+ var cliBaselineRecordFileSchema = z28.object({
2855
+ pathIndex: z28.number().int().nonnegative().max(49),
2856
+ path: relativePath,
2857
+ status: z28.enum(["generated", "not-exercised"]),
2858
+ beforeSha256: digest.nullable(),
2859
+ generatedSha256: digest.nullable()
2860
+ }).strict();
2861
+ var baselineInvocationSchema = z28.object({
2862
+ runId: token,
2863
+ invocationId: token,
2864
+ targetId: token,
2865
+ commandId: token,
2866
+ artifactSha256: digest.nullable(),
2867
+ entrypointSha256: digest,
2868
+ engineSha256: digest.optional(),
2869
+ launchForm: cliLaunchFormSchema,
2870
+ ioProfile: cliIoProfileSchema,
2871
+ recordFiles: z28.array(cliBaselineRecordFileSchema).max(50).default([])
2872
+ }).strict();
2873
+ var cliInterventionSchema = z28.object({
2874
+ schemaVersion: z28.union([z28.literal(1), z28.literal(2)]),
2875
+ engineVersion: token,
2876
+ engineSha256: digest.nullable(),
2877
+ bundleSha256: digest,
2878
+ catalog: cliCatalogSchema,
2879
+ mode: z28.enum(["record", "trial"]),
2880
+ captureProfiles: z28.array(cliIoProfileSchema).min(1),
2881
+ activeTargetId: token.nullable(),
2882
+ activeCommandId: token.nullable(),
2883
+ selector: z28.object({
2884
+ optionPresent: z28.array(optionFlag).max(20),
2885
+ optionAbsent: z28.array(optionFlag).max(20)
2886
+ }).strict().nullable(),
2887
+ baselineInvocations: z28.array(baselineInvocationSchema).max(500),
2888
+ operations: z28.array(operationSchema).max(50),
2889
+ limits: z28.object({
2890
+ completedStreamBytes: z28.number().int().min(1).max(2 * 1024 * 1024),
2891
+ replacementBytes: z28.number().int().min(1).max(8192),
2892
+ generatedFileBytes: z28.number().int().min(1).max(2 * 1024 * 1024),
2893
+ generatedAggregateBytes: z28.number().int().min(1).max(8 * 1024 * 1024),
2894
+ generatedFileCount: z28.number().int().min(1).max(50)
2895
+ }).strict(),
2896
+ shippingIntent: z28.enum([
2897
+ "default",
2898
+ "message",
2899
+ "interaction",
2900
+ "invocation-guidance",
2901
+ "template"
2902
+ ]).nullable()
2903
+ }).strict().superRefine((bundle, ctx) => {
2904
+ const fail = (path2, message) => ctx.addIssue({ code: "custom", path: path2, message });
2905
+ if (bundle.schemaVersion !== bundle.catalog.version)
2906
+ fail(["schemaVersion"], "Bundle and catalog schema versions differ");
2907
+ if (!bundle.engineSha256 && (bundle.schemaVersion === 1 || bundle.mode !== "record"))
2908
+ fail(["engineSha256"], "A trial must pin the recorded engine bytes");
2909
+ if (!bundle.catalog.targets.length)
2910
+ fail(["catalog"], "A run needs at least one CLI target");
2911
+ if (bundle.schemaVersion === 2 && bundle.mode === "trial" && bundle.baselineInvocations.some(
2912
+ (item) => item.engineSha256 !== bundle.engineSha256
2913
+ ))
2914
+ fail(
2915
+ ["baselineInvocations"],
2916
+ "Baseline invocations must share the pinned engine"
2917
+ );
2918
+ bundle.baselineInvocations.forEach((invocation, index) => {
2919
+ const command2 = bundle.catalog.targets.find((target2) => target2.id === invocation.targetId)?.commands.find((item) => item.id === invocation.commandId);
2920
+ for (const [fileIndex, file] of invocation.recordFiles.entries()) {
2921
+ if (command2?.capabilities.generatedPaths[file.pathIndex] !== file.path || file.status === "generated" && !file.generatedSha256 || file.status === "not-exercised" && file.generatedSha256 !== file.beforeSha256)
2922
+ fail(
2923
+ ["baselineInvocations", index, "recordFiles", fileIndex],
2924
+ "Recorded file does not match the qualified command"
2925
+ );
2926
+ }
2927
+ });
2928
+ if (bundle.engineVersion !== bundle.catalog.engineVersion)
2929
+ fail(["engineVersion"], "Engine and catalog versions differ");
2930
+ if (bundle.mode === "record") {
2931
+ if (bundle.activeTargetId || bundle.activeCommandId || bundle.selector || bundle.operations.length || bundle.shippingIntent)
2932
+ fail(["mode"], "Record mode cannot select or modify a command");
2933
+ return;
2934
+ }
2935
+ const target = bundle.catalog.targets.find(
2936
+ (item) => item.id === bundle.activeTargetId
2937
+ );
2938
+ const command = target?.commands.find(
2939
+ (item) => item.id === bundle.activeCommandId
2940
+ );
2941
+ if (!target || !command) {
2942
+ fail(
2943
+ ["activeCommandId"],
2944
+ "Select a qualified command in the frozen catalog"
2945
+ );
2946
+ return;
2947
+ }
2948
+ if (!bundle.selector) fail(["selector"], "A trial needs token predicates");
2949
+ else {
2950
+ for (const flag of [
2951
+ ...bundle.selector.optionPresent,
2952
+ ...bundle.selector.optionAbsent
2953
+ ])
2954
+ if (!command.capabilities.options.some((option) => option.flag === flag))
2955
+ fail(["selector"], `Unsupported selector option: ${flag}`);
2956
+ if (bundle.selector.optionPresent.some(
2957
+ (flag) => bundle.selector?.optionAbsent.includes(flag)
2958
+ ))
2959
+ fail(
2960
+ ["selector"],
2961
+ "A selector cannot require and forbid the same option"
2962
+ );
2963
+ }
2964
+ if (!bundle.shippingIntent || !bundle.operations.length)
2965
+ fail(
2966
+ ["operations"],
2967
+ "A trial needs a shipping intent and at least one operation"
2968
+ );
2969
+ if (bundle.operations.some((item) => item.kind === "promptRecipe") && bundle.operations.some((item) => item.kind === "completeOutput"))
2970
+ fail(
2971
+ ["operations"],
2972
+ "Completed-output buffering cannot block an interactive prompt"
2973
+ );
2974
+ if (bundle.captureProfiles.includes("pty")) {
2975
+ for (const [index, operation] of bundle.operations.entries()) {
2976
+ if (operation.kind === "structuredStdin")
2977
+ fail(
2978
+ ["operations", index],
2979
+ "PTY structured stdin cannot prove the declared EOF; use a prompt recipe"
2980
+ );
2981
+ if ((operation.kind === "streamOutput" || operation.kind === "completeOutput") && operation.stream !== "combined")
2982
+ fail(["operations", index], "PTY output combines stdout and stderr");
2983
+ }
2984
+ }
2985
+ if (bundle.operations.some((item) => item.kind === "promptRecipe") && bundle.operations.some((item) => item.kind === "structuredStdin"))
2986
+ fail(
2987
+ ["operations"],
2988
+ "A prompt recipe and structured stdin cannot both control the same input stream"
2989
+ );
2990
+ if (bundle.operations.some(
2991
+ (item) => (item.kind === "streamOutput" || item.kind === "completeOutput") && item.stream === "combined"
2992
+ ) && !bundle.baselineInvocations.some(
2993
+ (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)
2994
+ ))
2995
+ fail(
2996
+ ["operations"],
2997
+ "Combined output requires a shared-descriptor or PTY baseline profile"
2998
+ );
2999
+ if (!bundle.baselineInvocations.some(
3000
+ (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)
3001
+ ))
3002
+ fail(
3003
+ ["baselineInvocations"],
3004
+ "No baseline invocation matches this exact command, artifact, launch form, and I/O profile"
3005
+ );
3006
+ const seen = /* @__PURE__ */ new Set();
3007
+ const changedEnvironment = new Set(
3008
+ bundle.operations.flatMap(
3009
+ (item) => item.kind === "setEnv" ? [item.key] : []
3010
+ )
3011
+ );
3012
+ bundle.operations.forEach((operation, index) => {
3013
+ const path2 = ["operations", index];
3014
+ if (!command.capabilities.operations.includes(operation.kind))
3015
+ fail(path2, `${operation.kind} is not qualified for this command`);
3016
+ if ("option" in operation && !command.capabilities.options.some(
3017
+ (option) => option.flag === operation.option
3018
+ ))
3019
+ fail(path2, "Option is not supported by this version");
3020
+ if (operation.kind === "ensureOption" || operation.kind === "replaceOption") {
3021
+ const option = command.capabilities.options.find(
3022
+ (item) => item.flag === operation.option
3023
+ );
3024
+ if (option && option.takesValue !== (operation.value !== void 0))
3025
+ fail(path2, "Option value does not match its qualified arity");
3026
+ }
3027
+ if (operation.kind === "setEnv" && !command.capabilities.settings.includes(operation.key))
3028
+ fail(path2, "Environment setting is not supported by this version");
3029
+ if (operation.kind === "structuredStdin" && !command.capabilities.stdinFormats.includes(operation.format))
3030
+ fail(path2, "Stdin format is not qualified");
3031
+ if (operation.kind === "structuredStdin" && operation.payload.source === "literal" && operation.format !== "text") {
3032
+ const records = operation.format === "json" ? [operation.payload.value] : operation.payload.value.trimEnd().split("\n");
3033
+ try {
3034
+ if (records.some((record) => !record.trim()))
3035
+ throw new Error("Empty structured stdin record");
3036
+ for (const record of records) JSON.parse(record);
3037
+ } catch {
3038
+ fail(
3039
+ path2,
3040
+ "Structured stdin payload does not match its declared JSON format"
3041
+ );
3042
+ }
3043
+ }
3044
+ if (operation.kind === "promptRecipe" && !command.capabilities.recipeIds.includes(operation.recipeId))
3045
+ fail(path2, "Prompt recipe is not qualified");
3046
+ if (operation.kind === "generatedFile" && !command.capabilities.generatedPaths.includes(operation.path))
3047
+ fail(path2, "Output path is not attributed to this command");
3048
+ if (operation.kind === "generatedFile" && !bundle.baselineInvocations.some(
3049
+ (invocation) => invocation.targetId === target.id && invocation.commandId === command.id && invocation.recordFiles.some(
3050
+ (file) => file.path === operation.path && file.status === "generated" && file.beforeSha256 === operation.beforeSha256 && file.generatedSha256 === operation.generatedSha256
3051
+ )
3052
+ ))
3053
+ fail(
3054
+ path2,
3055
+ "No attributed baseline file matches the preimage and real generated bytes"
3056
+ );
3057
+ if (operation.kind === "streamOutput" && !command.capabilities.outputModes.includes("streaming"))
3058
+ fail(path2, "Streaming output is not qualified");
3059
+ if (operation.kind === "completeOutput" && !command.capabilities.outputModes.includes("completed"))
3060
+ fail(path2, "Completed output is not qualified");
3061
+ 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)
3062
+ fail(path2, "A trial operation must change the matched content");
3063
+ const sources = [
3064
+ "value" in operation ? operation.value : null,
3065
+ operation.kind === "structuredStdin" ? operation.payload : null,
3066
+ ...operation.kind === "promptRecipe" ? operation.steps.map((step) => step.response) : []
3067
+ ];
3068
+ if (sources.some(
3069
+ (source) => source?.source === "localFact" && !command.capabilities.localFacts.includes(source.key)
3070
+ ))
3071
+ fail(path2, "Local fact is not declared non-secret for this command");
3072
+ if (sources.some(
3073
+ (source) => source?.source === "localFact" && changedEnvironment.has(source.key)
3074
+ ))
3075
+ fail(
3076
+ path2,
3077
+ "A local fact cannot be changed by another operation in the same trial"
3078
+ );
3079
+ 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;
3080
+ if (conflict && seen.has(conflict))
3081
+ fail(path2, "Conflicting operation on the same input or output");
3082
+ if (conflict) seen.add(conflict);
3083
+ });
3084
+ if (bundle.operations.filter((item) => item.kind === "generatedFile").length > bundle.limits.generatedFileCount)
3085
+ fail(
3086
+ ["limits", "generatedFileCount"],
3087
+ "Generated file count exceeds limit"
3088
+ );
3089
+ });
3090
+ var cliTrialChangeSchema = z28.object({
3091
+ targetId: token,
3092
+ commandId: token,
3093
+ selector: cliInterventionSchema.shape.selector.unwrap(),
3094
+ operations: cliInterventionSchema.shape.operations.min(1),
3095
+ shippingIntent: cliInterventionSchema.shape.shippingIntent.unwrap()
3096
+ }).strict();
2571
3097
 
2572
3098
  // ../packages/api-schemas/src/climb-kinds.ts
2573
3099
  var LEVER_KINDS = [
@@ -2585,46 +3111,47 @@ var INTERVENTION_KINDS = [
2585
3111
  "REWRITE_DOCS",
2586
3112
  "PACKAGE_VERSION",
2587
3113
  "PACKAGE_CONTENT",
2588
- "CLI_VERSION"
3114
+ "CLI_VERSION",
3115
+ "CLI_INTERVENTION"
2589
3116
  ];
2590
3117
  var LEVER_INTERVENTIONS = {
2591
3118
  DOCS: ["REWRITE_DOCS"],
2592
3119
  MARKETING_SITE: ["REWRITE_DOCS"],
2593
3120
  SDK: ["PACKAGE_VERSION", "PACKAGE_CONTENT"],
2594
- CLI: ["CLI_VERSION"],
3121
+ CLI: ["CLI_INTERVENTION"],
2595
3122
  SKILL: ["ADD_SKILL", "REMOVE_SKILL", "EDIT_SKILL"]
2596
3123
  };
2597
3124
 
2598
3125
  // ../packages/api-schemas/src/sandbox-overrides.ts
2599
- import { z as z28 } from "zod";
3126
+ import { z as z29 } from "zod";
2600
3127
  var SANDBOX_OVERRIDE_KINDS = ["packages", "clis"];
2601
- var ecosystemSchema = z28.enum(["npm", "pypi", "cargo", "go", "gem"]);
2602
- var overrideFilesSchema = z28.array(
2603
- z28.object({
2604
- path: z28.string().min(1).refine(
3128
+ var ecosystemSchema = z29.enum(["npm", "pypi", "cargo", "go", "gem"]);
3129
+ var overrideFilesSchema = z29.array(
3130
+ z29.object({
3131
+ path: z29.string().min(1).refine(
2605
3132
  (path2) => !path2.startsWith("/") && !path2.includes("\\") && !path2.split("/").includes(".."),
2606
3133
  "Use a relative path within the target"
2607
3134
  ),
2608
- body: z28.string()
3135
+ body: z29.string()
2609
3136
  }).strict()
2610
3137
  ).min(1);
2611
3138
  var contentShape = {
2612
- version: z28.string().trim().min(1).optional(),
3139
+ version: z29.string().trim().min(1).optional(),
2613
3140
  files: overrideFilesSchema.optional()
2614
3141
  };
2615
3142
  var hasContent = (value) => value.version !== void 0 || value.files !== void 0;
2616
- var sandboxOverridesSchema = z28.object({
2617
- version: z28.literal(1),
2618
- packages: z28.array(
2619
- z28.object({
3143
+ var sandboxOverridesSchema = z29.object({
3144
+ version: z29.literal(1),
3145
+ packages: z29.array(
3146
+ z29.object({
2620
3147
  ecosystem: ecosystemSchema,
2621
- name: z28.string().trim().min(1),
3148
+ name: z29.string().trim().min(1),
2622
3149
  ...contentShape
2623
3150
  }).strict().refine(hasContent, "Specify a version or files")
2624
3151
  ).optional(),
2625
- clis: z28.array(
2626
- z28.object({
2627
- name: z28.string().trim().min(1),
3152
+ clis: z29.array(
3153
+ z29.object({
3154
+ name: z29.string().trim().min(1),
2628
3155
  ...contentShape
2629
3156
  }).strict().refine(hasContent, "Specify a version or files")
2630
3157
  ).optional()
@@ -2651,11 +3178,11 @@ var sandboxOverridesSchema = z28.object({
2651
3178
  });
2652
3179
 
2653
3180
  // ../packages/api-schemas/src/climb.ts
2654
- var climbSubjectKindSchema = z29.enum(["EVAL_SET", "VISIBILITY_PROMPT"]);
2655
- var leverKindSchema = z29.enum(LEVER_KINDS);
2656
- var interventionKindSchema = z29.enum(INTERVENTION_KINDS);
2657
- var skill = z29.object({ skillVersionId: z29.string().min(1) }).strict();
2658
- var empty = z29.object({}).strict();
3181
+ var climbSubjectKindSchema = z30.enum(["EVAL_SET", "VISIBILITY_PROMPT"]);
3182
+ var leverKindSchema = z30.enum(LEVER_KINDS);
3183
+ var interventionKindSchema = z30.enum(INTERVENTION_KINDS);
3184
+ var skill = z30.object({ skillVersionId: z30.string().min(1) }).strict();
3185
+ var empty = z30.object({}).strict();
2659
3186
  function validateFixtureIntervention(value, ctx) {
2660
3187
  const result = webFixtureSchema.safeParse({ version: 1, ...value });
2661
3188
  if (!result.success) {
@@ -2668,69 +3195,75 @@ function validateFixtureIntervention(value, ctx) {
2668
3195
  }
2669
3196
  }
2670
3197
  }
2671
- var interventionSchema = z29.discriminatedUnion("kind", [
2672
- z29.object({ kind: z29.literal("BASELINE"), after: empty }),
2673
- z29.object({ kind: z29.literal("ADD_SKILL"), after: skill }),
2674
- z29.object({ kind: z29.literal("REMOVE_SKILL"), before: skill, after: empty }),
2675
- z29.object({ kind: z29.literal("EDIT_SKILL"), before: skill, after: skill }),
2676
- z29.object({
2677
- kind: z29.literal("REWRITE_DOCS"),
2678
- before: z29.json().optional(),
2679
- after: z29.object({ pages: webFixtureSchema.shape.pages.unwrap().min(1) }).strict().superRefine(validateFixtureIntervention)
3198
+ var interventionSchema = z30.discriminatedUnion("kind", [
3199
+ z30.object({ kind: z30.literal("BASELINE"), after: empty }),
3200
+ z30.object({ kind: z30.literal("ADD_SKILL"), after: skill }),
3201
+ z30.object({ kind: z30.literal("REMOVE_SKILL"), before: skill, after: empty }),
3202
+ z30.object({ kind: z30.literal("EDIT_SKILL"), before: skill, after: skill }),
3203
+ z30.object({
3204
+ kind: z30.literal("REWRITE_DOCS"),
3205
+ before: z30.json().optional(),
3206
+ after: z30.object({ pages: webFixtureSchema.shape.pages.unwrap().min(1) }).strict().superRefine(validateFixtureIntervention)
2680
3207
  }),
2681
- z29.object({
2682
- kind: z29.literal("PACKAGE_VERSION"),
2683
- after: z29.object({
3208
+ z30.object({
3209
+ kind: z30.literal("PACKAGE_VERSION"),
3210
+ after: z30.object({
2684
3211
  ecosystem: ecosystemSchema,
2685
- name: z29.string().min(1),
2686
- version: z29.string().min(1)
3212
+ name: z30.string().min(1),
3213
+ version: z30.string().min(1)
2687
3214
  }).strict()
2688
3215
  }),
2689
- z29.object({
2690
- kind: z29.literal("PACKAGE_CONTENT"),
2691
- after: z29.object({
3216
+ z30.object({
3217
+ kind: z30.literal("PACKAGE_CONTENT"),
3218
+ after: z30.object({
2692
3219
  ecosystem: ecosystemSchema,
2693
- name: z29.string().min(1),
3220
+ name: z30.string().min(1),
2694
3221
  files: overrideFilesSchema
2695
3222
  }).strict()
2696
3223
  }),
2697
- z29.object({
2698
- kind: z29.literal("CLI_VERSION"),
2699
- after: z29.object({ name: z29.string().min(1), version: z29.string().min(1) }).strict()
3224
+ z30.object({
3225
+ kind: z30.literal("CLI_VERSION"),
3226
+ after: z30.object({ name: z30.string().min(1), version: z30.string().min(1) }).strict()
3227
+ }),
3228
+ z30.object({
3229
+ kind: z30.literal("CLI_INTERVENTION"),
3230
+ after: cliInterventionSchema.refine((bundle) => bundle.mode === "trial", {
3231
+ message: "A CLI trial requires a trial-mode bundle"
3232
+ })
2700
3233
  })
2701
3234
  ]);
2702
- var climbSettingsSchema = z29.object({
2703
- maxRounds: z29.number().int().positive().default(5),
2704
- sampleCount: z29.number().int().positive().default(1),
2705
- creditCap: z29.number().int().nonnegative(),
2706
- targetScore: z29.number().min(0).max(1).default(1),
3235
+ var climbSettingsSchema = z30.object({
3236
+ maxRounds: z30.number().int().positive().default(5),
3237
+ sampleCount: z30.number().int().positive().default(1),
3238
+ creditCap: z30.number().int().nonnegative(),
3239
+ targetScore: z30.number().min(0).max(1).default(1),
2707
3240
  // Narrow the subject's whole roster to one slot, for the baseline and every
2708
3241
  // trial alike. A subject rostering ten models otherwise multiplies every
2709
3242
  // trial by ten, and a one-model trial measured against a ten-model baseline
2710
3243
  // is not a comparison. `pinnedModel` empty means the agent's default model.
2711
3244
  pinnedAgent: schedulableAgentSchema.optional(),
2712
- pinnedModel: z29.string().optional(),
2713
- maxTrialsPerRound: z29.number().int().min(1).max(10).default(3),
3245
+ pinnedModel: z30.string().optional(),
3246
+ maxTrialsPerRound: z30.number().int().min(1).max(10).default(3),
2714
3247
  // The round a continuation started at; the no-improvement counter
2715
3248
  // restarts here.
2716
- continuedAtRound: z29.number().int().nonnegative().optional()
3249
+ continuedAtRound: z30.number().int().nonnegative().optional()
2717
3250
  }).strip().refine((value) => value.pinnedAgent !== void 0 || !value.pinnedModel, {
2718
3251
  path: ["pinnedAgent"],
2719
3252
  message: "Pin an agent with the model"
2720
3253
  });
2721
- var climbDirectionSchema = z29.object({
2722
- focus: z29.string().trim().max(2e3).nullable().default(null),
2723
- preserve: z29.array(z29.string().trim().min(1).max(500)).max(20).default([]),
2724
- exclude: z29.array(z29.string().trim().min(1).max(500)).max(20).default([]),
2725
- notes: z29.string().trim().max(4e3).nullable().default(null)
2726
- });
2727
- var climbDirectionPatchSchema = z29.object({
2728
- focus: z29.string().trim().max(2e3).nullable().optional(),
2729
- preserve: z29.array(z29.string().trim().min(1).max(500)).max(20).optional(),
2730
- exclude: z29.array(z29.string().trim().min(1).max(500)).max(20).optional(),
2731
- notes: z29.string().trim().max(4e3).nullable().optional(),
3254
+ var climbDirectionSchema = z30.object({
3255
+ focus: z30.string().trim().max(2e3).nullable().default(null),
3256
+ preserve: z30.array(z30.string().trim().min(1).max(500)).max(20).default([]),
3257
+ exclude: z30.array(z30.string().trim().min(1).max(500)).max(20).default([]),
3258
+ notes: z30.string().trim().max(4e3).nullable().default(null)
3259
+ });
3260
+ var climbDirectionPatchSchema = z30.object({
3261
+ focus: z30.string().trim().max(2e3).nullable().optional(),
3262
+ preserve: z30.array(z30.string().trim().min(1).max(500)).max(20).optional(),
3263
+ exclude: z30.array(z30.string().trim().min(1).max(500)).max(20).optional(),
3264
+ notes: z30.string().trim().max(4e3).nullable().optional(),
2732
3265
  /** One line on why this was recorded; becomes the DIRECTION row summary. */
2733
- rationale: z29.string().trim().max(500).optional()
3266
+ rationale: z30.string().trim().max(500).optional()
2734
3267
  }).strict();
2735
3268
  var CLIMB_ACTIVITY_KINDS = [
2736
3269
  "STARTED",
@@ -2749,73 +3282,74 @@ var CLIMB_ACTIVITY_KINDS = [
2749
3282
  "CONTINUED",
2750
3283
  "CANCELED"
2751
3284
  ];
2752
- var climbActivityKindSchema = z29.enum(CLIMB_ACTIVITY_KINDS);
2753
- var proposerTraceStepSchema = z29.object({
2754
- tool: z29.string(),
2755
- args: z29.string(),
2756
- result: z29.string().nullable(),
2757
- isError: z29.boolean().optional()
2758
- });
2759
- var proposerTraceSchema = z29.object({
2760
- steps: z29.array(proposerTraceStepSchema),
2761
- reasoning: z29.string(),
2762
- durationMs: z29.number().int().nonnegative(),
2763
- model: z29.string()
2764
- });
2765
- var climbActivitySchema = z29.object({
2766
- id: z29.string(),
2767
- climbId: z29.string(),
2768
- roundId: z29.string().nullable(),
2769
- trialId: z29.string().nullable(),
3285
+ var climbActivityKindSchema = z30.enum(CLIMB_ACTIVITY_KINDS);
3286
+ var proposerTraceStepSchema = z30.object({
3287
+ tool: z30.string(),
3288
+ args: z30.string(),
3289
+ result: z30.string().nullable(),
3290
+ isError: z30.boolean().optional()
3291
+ });
3292
+ var proposerTraceSchema = z30.object({
3293
+ steps: z30.array(proposerTraceStepSchema),
3294
+ reasoning: z30.string(),
3295
+ durationMs: z30.number().int().nonnegative(),
3296
+ model: z30.string()
3297
+ });
3298
+ var climbActivitySchema = z30.object({
3299
+ id: z30.string(),
3300
+ climbId: z30.string(),
3301
+ roundId: z30.string().nullable(),
3302
+ trialId: z30.string().nullable(),
2770
3303
  kind: climbActivityKindSchema,
2771
- actorUserId: z29.string().nullable(),
2772
- actorName: z29.string().nullable(),
2773
- summary: z29.string(),
2774
- detail: z29.unknown().nullable(),
2775
- createdAt: z29.string()
2776
- });
2777
- var activityQuerySchema = z29.object({
2778
- after: z29.string().datetime().optional(),
2779
- limit: z29.coerce.number().int().min(1).max(500).default(500)
2780
- });
2781
- var climbConfigSnapshotSchema = z29.object({
2782
- promptText: z29.string(),
2783
- scenario: z29.enum(["GREENFIELD", "MIGRATION"]),
2784
- repoUrl: z29.string().nullable(),
2785
- repoRef: z29.string().nullable(),
2786
- profileId: z29.string().nullable(),
2787
- profileName: z29.string().nullable(),
2788
- profileDescription: z29.string().nullable(),
2789
- profileModel: z29.string().nullable(),
2790
- limits: z29.json(),
2791
- agents: z29.array(agentConfigSchema).min(1),
2792
- skillRefs: z29.array(z29.string()),
2793
- mcpRefs: z29.array(z29.string()),
2794
- skillVersionIds: z29.array(z29.string()),
2795
- mcpServerVersionIds: z29.array(z29.string()),
2796
- skillSet: z29.json().nullable(),
2797
- mcpSet: z29.json().nullable(),
2798
- connectionIds: z29.array(z29.string()),
2799
- connectionSet: z29.json().nullable(),
2800
- agentContext: z29.json().nullable(),
2801
- agentContextDigest: z29.string().nullable(),
3304
+ actorUserId: z30.string().nullable(),
3305
+ actorName: z30.string().nullable(),
3306
+ summary: z30.string(),
3307
+ detail: z30.unknown().nullable(),
3308
+ createdAt: z30.string()
3309
+ });
3310
+ var activityQuerySchema = z30.object({
3311
+ after: z30.string().datetime().optional(),
3312
+ limit: z30.coerce.number().int().min(1).max(500).default(500)
3313
+ });
3314
+ var climbConfigSnapshotSchema = z30.object({
3315
+ promptText: z30.string(),
3316
+ scenario: z30.enum(["GREENFIELD", "MIGRATION"]),
3317
+ repoUrl: z30.string().nullable(),
3318
+ repoRef: z30.string().nullable(),
3319
+ profileId: z30.string().nullable(),
3320
+ profileName: z30.string().nullable(),
3321
+ profileDescription: z30.string().nullable(),
3322
+ profileModel: z30.string().nullable(),
3323
+ limits: z30.json(),
3324
+ agents: z30.array(agentConfigSchema).min(1),
3325
+ skillRefs: z30.array(z30.string()),
3326
+ mcpRefs: z30.array(z30.string()),
3327
+ skillVersionIds: z30.array(z30.string()),
3328
+ mcpServerVersionIds: z30.array(z30.string()),
3329
+ skillSet: z30.json().nullable(),
3330
+ mcpSet: z30.json().nullable(),
3331
+ connectionIds: z30.array(z30.string()),
3332
+ connectionSet: z30.json().nullable(),
3333
+ agentContext: z30.json().nullable(),
3334
+ agentContextDigest: z30.string().nullable(),
2802
3335
  webFixture: webFixtureSchema.nullable(),
3336
+ cliIntervention: cliInterventionSchema.nullable().default(null),
2803
3337
  sandboxOverrides: sandboxOverridesSchema.nullable(),
2804
- visibilityScenarioId: z29.string().nullable()
3338
+ visibilityScenarioId: z30.string().nullable()
2805
3339
  }).strict();
2806
- var targetRefSchema = z29.object({
2807
- kind: z29.string().min(1),
2808
- id: z29.string().optional(),
2809
- url: z29.url().optional(),
2810
- package: z29.string().optional()
3340
+ var targetRefSchema = z30.object({
3341
+ kind: z30.string().min(1),
3342
+ id: z30.string().optional(),
3343
+ url: z30.url().optional(),
3344
+ package: z30.string().optional()
2811
3345
  }).strict();
2812
- var trialInputSchema = z29.object({
2813
- title: z29.string().trim().min(1).max(200),
2814
- hypothesis: z29.string().max(4e3).optional(),
3346
+ var trialInputSchema = z30.object({
3347
+ title: z30.string().trim().min(1).max(200),
3348
+ hypothesis: z30.string().max(4e3).optional(),
2815
3349
  lever: leverKindSchema,
2816
3350
  targetRef: targetRefSchema.optional(),
2817
3351
  intervention: interventionSchema,
2818
- authorMode: z29.enum(["MANUAL", "DIRECT", "PROPOSE"]).default("MANUAL")
3352
+ authorMode: z30.enum(["MANUAL", "DIRECT", "PROPOSE"]).default("MANUAL")
2819
3353
  }).strict().superRefine((value, ctx) => {
2820
3354
  const allowed = LEVER_INTERVENTIONS[value.lever];
2821
3355
  if (!allowed.includes(value.intervention.kind))
@@ -2834,7 +3368,7 @@ var OPTIMIZATION_STATUSES = [
2834
3368
  "DONE",
2835
3369
  "ARCHIVED"
2836
3370
  ];
2837
- var optimizationStatusSchema = z30.enum(OPTIMIZATION_STATUSES);
3371
+ var optimizationStatusSchema = z31.enum(OPTIMIZATION_STATUSES);
2838
3372
  var ROUND_STATUSES = [
2839
3373
  "PROPOSING",
2840
3374
  "PROPOSED",
@@ -2863,61 +3397,61 @@ var OPTIMIZATION_EFFORTS = [
2863
3397
  { value: "HIGH", label: "Thorough", sampleCount: 2, maxRounds: 8 },
2864
3398
  { value: "XHIGH", label: "Exhaustive", sampleCount: 3, maxRounds: 12 }
2865
3399
  ];
2866
- var optimizationEffortSchema = z30.enum(
3400
+ var optimizationEffortSchema = z31.enum(
2867
3401
  OPTIMIZATION_EFFORTS.map((preset) => preset.value)
2868
3402
  );
2869
- var listOptimizationsQuerySchema = z30.object({
2870
- status: z30.string().optional().transform(
3403
+ var listOptimizationsQuerySchema = z31.object({
3404
+ status: z31.string().optional().transform(
2871
3405
  (value) => value ? value.split(",").map((part) => part.trim().toUpperCase()).filter(Boolean) : void 0
2872
- ).pipe(z30.array(optimizationStatusSchema).optional()),
3406
+ ).pipe(z31.array(optimizationStatusSchema).optional()),
2873
3407
  subjectKind: climbSubjectKindSchema.optional(),
2874
- subjectId: z30.string().min(1).optional(),
2875
- limit: z30.coerce.number().int().min(1).max(200).default(50),
3408
+ subjectId: z31.string().min(1).optional(),
3409
+ limit: z31.coerce.number().int().min(1).max(200).default(50),
2876
3410
  /** Drafts are workspaces, not runs; older clients never see them. */
2877
- includeDrafts: z30.union([z30.boolean(), z30.string()]).optional().transform((value) => value === true || value === "true" || value === "1")
3411
+ includeDrafts: z31.union([z31.boolean(), z31.string()]).optional().transform((value) => value === true || value === "true" || value === "1")
2878
3412
  });
2879
- var optimizationSummarySchema = z30.object({
2880
- id: z30.string(),
2881
- name: z30.string(),
3413
+ var optimizationSummarySchema = z31.object({
3414
+ id: z31.string(),
3415
+ name: z31.string(),
2882
3416
  status: optimizationStatusSchema,
2883
- mode: z30.enum(["MANUAL", "AUTO"]),
3417
+ mode: z31.enum(["MANUAL", "AUTO"]),
2884
3418
  /** Autonomous launches every proposed round; interactive waits for one. */
2885
- autonomous: z30.boolean(),
2886
- stopReason: z30.string().nullable(),
3419
+ autonomous: z31.boolean(),
3420
+ stopReason: z31.string().nullable(),
2887
3421
  subjectKind: climbSubjectKindSchema,
2888
- subjectId: z30.string(),
2889
- subjectName: z30.string(),
3422
+ subjectId: z31.string(),
3423
+ subjectName: z31.string(),
2890
3424
  lever: leverKindSchema.nullable(),
2891
- round: z30.number().int(),
2892
- maxRounds: z30.number().int(),
3425
+ round: z31.number().int(),
3426
+ maxRounds: z31.number().int(),
2893
3427
  /** Starting baseline score, 0..1. */
2894
- before: z30.number().nullable(),
3428
+ before: z31.number().nullable(),
2895
3429
  /** Score of the marked winner, or best BETTER trial, 0..1. */
2896
- after: z30.number().nullable(),
3430
+ after: z31.number().nullable(),
2897
3431
  /** Percentage-point change from the baseline to the winner or best BETTER trial. */
2898
- delta: z30.number().nullable(),
3432
+ delta: z31.number().nullable(),
2899
3433
  /** Score after each round, baseline first. */
2900
- path: z30.array(z30.number()),
2901
- creditsSpent: z30.number().int(),
2902
- creditsReserved: z30.number().int(),
2903
- summary: z30.string().nullable(),
2904
- href: z30.string(),
2905
- createdAt: z30.string(),
2906
- updatedAt: z30.string()
2907
- });
2908
- var listOptimizationsResponseSchema = z30.object({
2909
- items: z30.array(optimizationSummarySchema)
2910
- });
2911
- var targetSchema = z30.object({
3434
+ path: z31.array(z31.number()),
3435
+ creditsSpent: z31.number().int(),
3436
+ creditsReserved: z31.number().int(),
3437
+ summary: z31.string().nullable(),
3438
+ href: z31.string(),
3439
+ createdAt: z31.string(),
3440
+ updatedAt: z31.string()
3441
+ });
3442
+ var listOptimizationsResponseSchema = z31.object({
3443
+ items: z31.array(optimizationSummarySchema)
3444
+ });
3445
+ var targetSchema = z31.object({
2912
3446
  agent: schedulableAgentSchema.optional(),
2913
3447
  /** Empty or omitted means the agent's default model. */
2914
- model: z30.string().optional()
3448
+ model: z31.string().optional()
2915
3449
  });
2916
3450
  var planShape = {
2917
3451
  effort: optimizationEffortSchema.optional(),
2918
- sampleCount: z30.number().int().min(1).max(100).optional(),
2919
- maxRounds: z30.number().int().min(1).max(100).optional(),
2920
- maxTrialsPerRound: z30.number().int().min(1).max(10).optional()
3452
+ sampleCount: z31.number().int().min(1).max(100).optional(),
3453
+ maxRounds: z31.number().int().min(1).max(100).optional(),
3454
+ maxTrialsPerRound: z31.number().int().min(1).max(10).optional()
2921
3455
  };
2922
3456
  function refinePlan(value, ctx) {
2923
3457
  if (value.effort && (value.sampleCount || value.maxRounds))
@@ -2933,18 +3467,18 @@ function refinePlan(value, ctx) {
2933
3467
  message: "Pin an agent with the model"
2934
3468
  });
2935
3469
  }
2936
- var startOptimizationBodySchema = z30.object({
3470
+ var startOptimizationBodySchema = z31.object({
2937
3471
  subjectKind: climbSubjectKindSchema,
2938
- subjectId: z30.string().min(1),
2939
- name: z30.string().trim().min(1).max(200).optional(),
3472
+ subjectId: z31.string().min(1),
3473
+ name: z31.string().trim().min(1).max(200).optional(),
2940
3474
  ...planShape,
2941
- creditCap: z30.number().int().nonnegative().optional(),
2942
- targetScore: z30.number().min(0).max(1).optional(),
3475
+ creditCap: z31.number().int().nonnegative().optional(),
3476
+ targetScore: z31.number().min(0).max(1).optional(),
2943
3477
  target: targetSchema.extend({ agent: schedulableAgentSchema })
2944
3478
  }).strict().superRefine(refinePlan);
2945
- var estimateOptimizationBodySchema = z30.object({
3479
+ var estimateOptimizationBodySchema = z31.object({
2946
3480
  subjectKind: climbSubjectKindSchema,
2947
- subjectId: z30.string().min(1),
3481
+ subjectId: z31.string().min(1),
2948
3482
  ...planShape,
2949
3483
  target: targetSchema.optional()
2950
3484
  }).strict().superRefine(refinePlan);
@@ -2956,100 +3490,100 @@ var RUN_CREDIT_BASES = [
2956
3490
  "byok",
2957
3491
  "reserve"
2958
3492
  ];
2959
- var runCreditBasisSchema = z30.enum(RUN_CREDIT_BASES);
2960
- var optimizationEstimateSchema = z30.object({
2961
- sampleCount: z30.number().int(),
2962
- maxRounds: z30.number().int(),
2963
- runsPerTrial: z30.number(),
2964
- executionCredits: z30.number(),
2965
- judgeCredits: z30.number(),
2966
- leverPassCredits: z30.number(),
2967
- trialCredits: z30.number(),
3493
+ var runCreditBasisSchema = z31.enum(RUN_CREDIT_BASES);
3494
+ var optimizationEstimateSchema = z31.object({
3495
+ sampleCount: z31.number().int(),
3496
+ maxRounds: z31.number().int(),
3497
+ runsPerTrial: z31.number(),
3498
+ executionCredits: z31.number(),
3499
+ judgeCredits: z31.number(),
3500
+ leverPassCredits: z31.number(),
3501
+ trialCredits: z31.number(),
2968
3502
  /** Estimate, not a reservation or enforced spending cap. */
2969
- estimate: z30.number().int(),
3503
+ estimate: z31.number().int(),
2970
3504
  /** True when no price or history covered a model: a bound, not a forecast. */
2971
- approximate: z30.boolean().default(false),
3505
+ approximate: z31.boolean().default(false),
2972
3506
  /** Which rung priced the run, so the UI can say why a figure is what it is. */
2973
3507
  basis: runCreditBasisSchema.optional()
2974
3508
  });
2975
- var diagnoseBodySchema = z30.object({
3509
+ var diagnoseBodySchema = z31.object({
2976
3510
  subjectKind: climbSubjectKindSchema,
2977
- subjectId: z30.string().min(1)
3511
+ subjectId: z31.string().min(1)
2978
3512
  }).strict();
2979
- var diagnosisSchema = z30.object({
2980
- id: z30.string(),
2981
- status: z30.enum(["GENERATING", "READY", "FAILED"]),
3513
+ var diagnosisSchema = z31.object({
3514
+ id: z31.string(),
3515
+ status: z31.enum(["GENERATING", "READY", "FAILED"]),
2982
3516
  subjectKind: climbSubjectKindSchema,
2983
- subjectId: z30.string(),
2984
- runCount: z30.number().int(),
2985
- summary: z30.string().nullable(),
3517
+ subjectId: z31.string(),
3518
+ runCount: z31.number().int(),
3519
+ summary: z31.string().nullable(),
2986
3520
  recommendedLever: leverKindSchema.nullable(),
2987
- recommendedTarget: z30.unknown().nullable(),
2988
- clusters: z30.array(
2989
- z30.object({
2990
- title: z30.string(),
2991
- failureMode: z30.string(),
2992
- criterionIds: z30.array(z30.string()),
2993
- runIds: z30.array(z30.string()),
3521
+ recommendedTarget: z31.unknown().nullable(),
3522
+ clusters: z31.array(
3523
+ z31.object({
3524
+ title: z31.string(),
3525
+ failureMode: z31.string(),
3526
+ criterionIds: z31.array(z31.string()),
3527
+ runIds: z31.array(z31.string()),
2994
3528
  lever: leverKindSchema.nullable(),
2995
- targetRef: z30.unknown().nullable(),
2996
- confidence: z30.number()
3529
+ targetRef: z31.unknown().nullable(),
3530
+ confidence: z31.number()
2997
3531
  })
2998
3532
  ),
2999
- unsupportedLevers: z30.array(leverKindSchema).default([]),
3000
- createdAt: z30.string()
3001
- });
3002
- var trialRunSchema = z30.object({
3003
- id: z30.string(),
3004
- status: z30.string(),
3005
- passed: z30.boolean().nullable(),
3006
- criteria: z30.array(
3007
- z30.object({ name: z30.string(), passed: z30.boolean(), reasoning: z30.string() })
3533
+ unsupportedLevers: z31.array(leverKindSchema).default([]),
3534
+ createdAt: z31.string()
3535
+ });
3536
+ var trialRunSchema = z31.object({
3537
+ id: z31.string(),
3538
+ status: z31.string(),
3539
+ passed: z31.boolean().nullable(),
3540
+ criteria: z31.array(
3541
+ z31.object({ name: z31.string(), passed: z31.boolean(), reasoning: z31.string() })
3008
3542
  ),
3009
- levers: z30.array(
3010
- z30.object({
3011
- lever: z30.string(),
3012
- attributed: z30.boolean(),
3013
- note: z30.string().nullable()
3543
+ levers: z31.array(
3544
+ z31.object({
3545
+ lever: z31.string(),
3546
+ attributed: z31.boolean(),
3547
+ note: z31.string().nullable()
3014
3548
  })
3015
3549
  )
3016
3550
  });
3017
- var trialSchema = z30.object({
3018
- id: z30.string(),
3019
- climbId: z30.string(),
3020
- roundNumber: z30.number().int(),
3021
- key: z30.string(),
3551
+ var trialSchema = z31.object({
3552
+ id: z31.string(),
3553
+ climbId: z31.string(),
3554
+ roundNumber: z31.number().int(),
3555
+ key: z31.string(),
3022
3556
  /** @deprecated All trials branch from the baseline. */
3023
- parentTrialId: z30.string().nullable(),
3557
+ parentTrialId: z31.string().nullable(),
3024
3558
  /** @deprecated Always the baseline key for non-baseline trials. */
3025
- parentKey: z30.string().nullable(),
3026
- title: z30.string(),
3027
- hypothesis: z30.string().nullable(),
3559
+ parentKey: z31.string().nullable(),
3560
+ title: z31.string(),
3561
+ hypothesis: z31.string().nullable(),
3028
3562
  lever: leverKindSchema.nullable(),
3029
3563
  kind: interventionKindSchema,
3030
- status: z30.enum(TRIAL_STATUSES),
3031
- verdict: z30.enum(TRIAL_VERDICTS).nullable(),
3032
- score: z30.number().nullable(),
3033
- baselineScore: z30.number().nullable(),
3564
+ status: z31.enum(TRIAL_STATUSES),
3565
+ verdict: z31.enum(TRIAL_VERDICTS).nullable(),
3566
+ score: z31.number().nullable(),
3567
+ baselineScore: z31.number().nullable(),
3034
3568
  /** Judged sessions behind `score`. */
3035
- sessions: z30.number().int(),
3036
- isBaseline: z30.boolean(),
3569
+ sessions: z31.number().int(),
3570
+ isBaseline: z31.boolean(),
3037
3571
  /** The user marked this trial as the winner; it does not move the baseline. */
3038
- adopted: z30.boolean(),
3039
- adoptedAt: z30.string().nullable(),
3040
- outcome: z30.string().nullable(),
3572
+ adopted: z31.boolean(),
3573
+ adoptedAt: z31.string().nullable(),
3574
+ outcome: z31.string().nullable(),
3041
3575
  /** The kind-specific `after` payload (skill version id, pages, package). */
3042
- after: z30.unknown(),
3043
- before: z30.unknown(),
3044
- runs: z30.array(trialRunSchema),
3045
- createdAt: z30.string()
3046
- });
3047
- var roundSchema = z30.object({
3048
- id: z30.string(),
3049
- number: z30.number().int(),
3050
- status: z30.enum(ROUND_STATUSES),
3051
- narrative: z30.string().nullable(),
3052
- trials: z30.array(trialSchema)
3576
+ after: z31.unknown(),
3577
+ before: z31.unknown(),
3578
+ runs: z31.array(trialRunSchema),
3579
+ createdAt: z31.string()
3580
+ });
3581
+ var roundSchema = z31.object({
3582
+ id: z31.string(),
3583
+ number: z31.number().int(),
3584
+ status: z31.enum(ROUND_STATUSES),
3585
+ narrative: z31.string().nullable(),
3586
+ trials: z31.array(trialSchema)
3053
3587
  });
3054
3588
  var OPTIMIZATION_NEXT_ACTIONS = [
3055
3589
  "START",
@@ -3060,471 +3594,880 @@ var OPTIMIZATION_NEXT_ACTIONS = [
3060
3594
  "RESUME",
3061
3595
  "NONE"
3062
3596
  ];
3063
- var optimizationNextActionSchema = z30.enum(OPTIMIZATION_NEXT_ACTIONS);
3597
+ var optimizationNextActionSchema = z31.enum(OPTIMIZATION_NEXT_ACTIONS);
3064
3598
  var optimizationDetailSchema = optimizationSummarySchema.extend({
3065
- baselineTrialId: z30.string().nullable(),
3599
+ baselineTrialId: z31.string().nullable(),
3066
3600
  /** The one thing a client does next. WAIT and NONE need nobody. */
3067
3601
  nextAction: optimizationNextActionSchema,
3068
- settings: z30.object({
3069
- sampleCount: z30.number().int(),
3070
- maxRounds: z30.number().int(),
3071
- maxTrialsPerRound: z30.number().int(),
3072
- creditCap: z30.number().int(),
3073
- targetScore: z30.number(),
3074
- pinnedAgent: z30.string().nullable(),
3075
- pinnedModel: z30.string().nullable(),
3076
- continuedAtRound: z30.number().int().nullable()
3602
+ settings: z31.object({
3603
+ sampleCount: z31.number().int(),
3604
+ maxRounds: z31.number().int(),
3605
+ maxTrialsPerRound: z31.number().int(),
3606
+ creditCap: z31.number().int(),
3607
+ targetScore: z31.number(),
3608
+ pinnedAgent: z31.string().nullable(),
3609
+ pinnedModel: z31.string().nullable(),
3610
+ continuedAtRound: z31.number().int().nullable()
3077
3611
  }),
3078
3612
  direction: climbDirectionSchema,
3079
- rounds: z30.array(roundSchema)
3613
+ rounds: z31.array(roundSchema)
3080
3614
  });
3081
- var listTrialsResponseSchema = z30.object({
3082
- items: z30.array(trialSchema)
3615
+ var listTrialsResponseSchema = z31.object({
3616
+ items: z31.array(trialSchema)
3083
3617
  });
3084
- var trialDocumentSchema = z30.object({
3085
- path: z30.string(),
3086
- before: z30.string(),
3087
- after: z30.string()
3618
+ var trialDocumentSchema = z31.object({
3619
+ path: z31.string(),
3620
+ before: z31.string(),
3621
+ after: z31.string()
3088
3622
  });
3089
- var trialContentSchema = z30.object({
3090
- trialId: z30.string(),
3623
+ var trialContentSchema = z31.object({
3624
+ trialId: z31.string(),
3091
3625
  kind: interventionKindSchema,
3092
- documents: z30.array(trialDocumentSchema),
3626
+ documents: z31.array(trialDocumentSchema),
3093
3627
  /** Full page bodies for a docs rewrite, ready to paste; null otherwise. */
3094
- copyableBody: z30.string().nullable(),
3095
- configSnapshot: z30.unknown()
3628
+ copyableBody: z31.string().nullable(),
3629
+ configSnapshot: z31.unknown()
3096
3630
  });
3097
- var createTrialBodySchema = z30.object({
3631
+ var createTrialBodySchema = z31.object({
3098
3632
  trial: trialInputSchema,
3099
3633
  files: overrideFilesSchema.optional(),
3100
- fork: z30.object({ runId: z30.string().min(1), boundarySeq: z30.string().min(1) }).strict().optional(),
3101
- launch: z30.boolean().default(false),
3634
+ fork: z31.object({ runId: z31.string().min(1), boundarySeq: z31.string().min(1) }).strict().optional(),
3635
+ launch: z31.boolean().default(false),
3102
3636
  /** Replays return the trial the first call created instead of a second
3103
3637
  * one. Scoped to the optimization. */
3104
- idempotencyKey: z30.string().min(1).max(200).optional()
3638
+ idempotencyKey: z31.string().min(1).max(200).optional()
3105
3639
  }).strict();
3106
- var skillFilesResponseSchema = z30.object({
3107
- versionId: z30.string(),
3640
+ var skillFilesResponseSchema = z31.object({
3641
+ versionId: z31.string(),
3108
3642
  files: overrideFilesSchema
3109
3643
  });
3110
- var pageBodyResponseSchema = z30.object({
3111
- url: z30.string(),
3112
- body: z30.string(),
3113
- contentType: z30.string().optional()
3644
+ var pageBodyResponseSchema = z31.object({
3645
+ url: z31.string(),
3646
+ body: z31.string(),
3647
+ contentType: z31.string().optional()
3114
3648
  });
3115
- var launchTrialResponseSchema = z30.object({
3116
- trialId: z30.string(),
3117
- batchIds: z30.array(z30.string()),
3118
- runIds: z30.array(z30.string())
3649
+ var launchTrialResponseSchema = z31.object({
3650
+ trialId: z31.string(),
3651
+ batchIds: z31.array(z31.string()),
3652
+ runIds: z31.array(z31.string())
3119
3653
  });
3120
- var createDraftOptimizationBodySchema = z30.object({
3654
+ var createDraftOptimizationBodySchema = z31.object({
3121
3655
  subjectKind: climbSubjectKindSchema,
3122
- subjectId: z30.string().min(1),
3123
- name: z30.string().trim().min(1).max(200).optional(),
3656
+ subjectId: z31.string().min(1),
3657
+ name: z31.string().trim().min(1).max(200).optional(),
3124
3658
  ...planShape,
3125
3659
  target: targetSchema.optional(),
3126
- autonomous: z30.boolean().optional()
3660
+ autonomous: z31.boolean().optional()
3127
3661
  }).strict().superRefine(refinePlan);
3128
3662
  var planPatchShape = {
3129
- name: z30.string().trim().min(1).max(200).optional(),
3663
+ name: z31.string().trim().min(1).max(200).optional(),
3130
3664
  ...planShape,
3131
3665
  target: targetSchema.optional()
3132
3666
  };
3133
- var optimizationPlanPatchSchema = z30.object(planPatchShape).strict().superRefine(refinePlan);
3134
- var startDraftOptimizationBodySchema = z30.object({
3667
+ var optimizationPlanPatchSchema = z31.object(planPatchShape).strict().superRefine(refinePlan);
3668
+ var startDraftOptimizationBodySchema = z31.object({
3135
3669
  ...planPatchShape,
3136
- creditCap: z30.number().int().nonnegative().optional()
3670
+ creditCap: z31.number().int().nonnegative().optional()
3137
3671
  }).strict().superRefine(refinePlan);
3138
- var setModeBodySchema = z30.object({ autonomous: z30.boolean() }).strict();
3139
- var launchRoundResponseSchema = z30.object({
3140
- roundNumber: z30.number().int().nullable(),
3141
- launched: z30.array(z30.string()),
3672
+ var setModeBodySchema = z31.object({ autonomous: z31.boolean() }).strict();
3673
+ var launchRoundResponseSchema = z31.object({
3674
+ roundNumber: z31.number().int().nullable(),
3675
+ launched: z31.array(z31.string()),
3142
3676
  /** True when nothing was left to launch: someone else got there first. */
3143
- alreadyLaunched: z30.boolean()
3677
+ alreadyLaunched: z31.boolean()
3144
3678
  });
3145
- var resolveChatResponseSchema = z30.object({
3146
- chatId: z30.string(),
3147
- href: z30.string()
3679
+ var resolveChatResponseSchema = z31.object({
3680
+ chatId: z31.string(),
3681
+ href: z31.string()
3148
3682
  });
3149
- var continueOptimizationBodySchema = z30.object({
3150
- rounds: z30.number().int().min(1).max(20).default(1),
3151
- maxTrialsPerRound: z30.number().int().min(1).max(10).optional()
3683
+ var continueOptimizationBodySchema = z31.object({
3684
+ rounds: z31.number().int().min(1).max(20).default(1),
3685
+ maxTrialsPerRound: z31.number().int().min(1).max(10).optional()
3152
3686
  }).strict();
3153
- var patchOptimizationBodySchema = z30.object({
3687
+ var patchOptimizationBodySchema = z31.object({
3154
3688
  ...planPatchShape,
3155
3689
  direction: climbDirectionPatchSchema.optional(),
3156
- autonomous: z30.boolean().optional()
3690
+ autonomous: z31.boolean().optional()
3157
3691
  }).strict().superRefine(refinePlan);
3158
3692
 
3159
3693
  // ../packages/api-schemas/src/orgs.ts
3160
- import { z as z31 } from "zod";
3161
- var createOrgRequestSchema = z31.object({
3694
+ import { z as z32 } from "zod";
3695
+ var createOrgRequestSchema = z32.object({
3162
3696
  /** Workspace display name; the slug is derived server-side. */
3163
- name: z31.string().trim().min(1).max(200),
3697
+ name: z32.string().trim().min(1).max(200),
3164
3698
  /** Optional company site (logo source; stamped onto the org). */
3165
- website: z31.string().trim().max(300).optional()
3699
+ website: z32.string().trim().max(300).optional()
3166
3700
  });
3167
- var createOrgResponseSchema = z31.object({
3168
- slug: z31.string(),
3169
- name: z31.string(),
3701
+ var createOrgResponseSchema = z32.object({
3702
+ slug: z32.string(),
3703
+ name: z32.string(),
3170
3704
  // LOCAL orgs never have a Gauge publicId.
3171
- publicId: z31.string().nullable()
3705
+ publicId: z32.string().nullable()
3172
3706
  });
3173
- var orgSettingsSchema = z31.object({
3174
- slug: z31.string(),
3175
- name: z31.string(),
3176
- publicId: z31.string().nullable(),
3177
- website: z31.string().nullable(),
3707
+ var orgSettingsSchema = z32.object({
3708
+ slug: z32.string(),
3709
+ name: z32.string(),
3710
+ publicId: z32.string().nullable(),
3711
+ website: z32.string().nullable(),
3178
3712
  /** Per-run max-spend override in USD; null = the server default. */
3179
- maxSpendUsd: z31.number().nullable(),
3180
- overageEnabled: z31.boolean(),
3713
+ maxSpendUsd: z32.number().nullable(),
3714
+ overageEnabled: z32.boolean(),
3181
3715
  /** Per-cycle overage cap in credits; null = uncapped. */
3182
- overageCapCredits: z31.number().int().nullable(),
3716
+ overageCapCredits: z32.number().int().nullable(),
3183
3717
  /** Domain claimed for same-domain auto-join; null = off. */
3184
- autoJoinDomain: z31.string().nullable()
3718
+ autoJoinDomain: z32.string().nullable()
3185
3719
  });
3186
- var orgMemberSchema = z31.object({
3187
- userId: z31.string(),
3188
- name: z31.string().nullable(),
3189
- email: z31.string().nullable(),
3190
- joinedAt: z31.string()
3720
+ var orgMemberSchema = z32.object({
3721
+ userId: z32.string(),
3722
+ name: z32.string().nullable(),
3723
+ email: z32.string().nullable(),
3724
+ joinedAt: z32.string()
3191
3725
  });
3192
- var listMembersResponseSchema = z31.object({
3193
- items: z31.array(orgMemberSchema)
3726
+ var listMembersResponseSchema = z32.object({
3727
+ items: z32.array(orgMemberSchema)
3194
3728
  });
3195
3729
 
3196
3730
  // ../packages/api-schemas/src/personas.ts
3197
- import { z as z32 } from "zod";
3198
- var personaSchema = z32.object({
3199
- id: z32.string(),
3200
- name: z32.string(),
3201
- description: z32.string(),
3731
+ import { z as z33 } from "zod";
3732
+ var personaSchema = z33.object({
3733
+ id: z33.string(),
3734
+ name: z33.string(),
3735
+ description: z33.string(),
3202
3736
  /** The judge model this persona calls (Claude only). */
3203
- model: z32.string(),
3204
- createdAt: z32.string(),
3205
- updatedAt: z32.string()
3737
+ model: z33.string(),
3738
+ createdAt: z33.string(),
3739
+ updatedAt: z33.string()
3206
3740
  });
3207
- var listPersonasResponseSchema = z32.object({
3208
- items: z32.array(personaSchema)
3741
+ var listPersonasResponseSchema = z33.object({
3742
+ items: z33.array(personaSchema)
3209
3743
  });
3210
- var createPersonaBodySchema = z32.object({
3211
- name: z32.string().min(1).max(120),
3212
- description: z32.string().min(1)
3744
+ var createPersonaBodySchema = z33.object({
3745
+ name: z33.string().min(1).max(120),
3746
+ description: z33.string().min(1)
3213
3747
  });
3214
- var updatePersonaBodySchema = z32.object({
3215
- name: z32.string().min(1).max(120).optional(),
3216
- description: z32.string().min(1).optional()
3748
+ var updatePersonaBodySchema = z33.object({
3749
+ name: z33.string().min(1).max(120).optional(),
3750
+ description: z33.string().min(1).optional()
3217
3751
  });
3218
3752
 
3219
3753
  // ../packages/api-schemas/src/prompts.ts
3220
- import { z as z35 } from "zod";
3754
+ import { z as z36 } from "zod";
3221
3755
 
3222
3756
  // ../packages/api-schemas/src/tags.ts
3223
- import { z as z33 } from "zod";
3224
- var tagSchema = z33.object({
3225
- id: z33.string(),
3226
- name: z33.string(),
3757
+ import { z as z34 } from "zod";
3758
+ var tagSchema = z34.object({
3759
+ id: z34.string(),
3760
+ name: z34.string(),
3227
3761
  /** A Mantine palette name (e.g. "blue", "grape"); unknown values are
3228
3762
  * normalized server-side to the default ("gray"). */
3229
- color: z33.string()
3763
+ color: z34.string()
3230
3764
  });
3231
- var createTagBodySchema = z33.object({
3232
- name: z33.string().min(1),
3233
- color: z33.string().optional()
3765
+ var createTagBodySchema = z34.object({
3766
+ name: z34.string().min(1),
3767
+ color: z34.string().optional()
3234
3768
  });
3235
- var updateTagBodySchema = z33.object({
3236
- name: z33.string().min(1).optional(),
3237
- color: z33.string().optional()
3769
+ var updateTagBodySchema = z34.object({
3770
+ name: z34.string().min(1).optional(),
3771
+ color: z34.string().optional()
3238
3772
  });
3239
3773
  var tagListResponseSchema = listResponseSchema(tagSchema);
3240
3774
 
3241
3775
  // ../packages/api-schemas/src/topics.ts
3242
- import { z as z34 } from "zod";
3243
- var topicSchema = z34.object({
3244
- id: z34.string(),
3245
- name: z34.string()
3776
+ import { z as z35 } from "zod";
3777
+ var topicSchema = z35.object({
3778
+ id: z35.string(),
3779
+ name: z35.string()
3246
3780
  });
3247
- var createTopicBodySchema = z34.object({
3248
- name: z34.string().min(1, "name is required")
3781
+ var createTopicBodySchema = z35.object({
3782
+ name: z35.string().min(1, "name is required")
3249
3783
  });
3250
3784
  var topicListResponseSchema = listResponseSchema(topicSchema);
3251
3785
 
3252
3786
  // ../packages/api-schemas/src/prompts.ts
3253
- var promptSummarySchema = z35.object({
3254
- id: z35.string(),
3255
- text: z35.string(),
3256
- isBranded: z35.boolean(),
3787
+ var promptSummarySchema = z36.object({
3788
+ id: z36.string(),
3789
+ text: z36.string(),
3790
+ isBranded: z36.boolean(),
3257
3791
  /** Battery-spec identity (idempotent applies); null for UI/CLI-created prompts. */
3258
- externalKey: z35.string().nullable(),
3792
+ externalKey: z36.string().nullable(),
3259
3793
  topic: topicSchema.nullable(),
3260
- tags: z35.array(tagSchema),
3261
- createdAt: z35.string()
3794
+ tags: z36.array(tagSchema),
3795
+ createdAt: z36.string()
3262
3796
  });
3263
3797
  var promptListResponseSchema = listResponseSchema(promptSummarySchema);
3264
3798
  var listPromptsQuerySchema = listQuerySchema.extend({
3265
- topic: z35.string().min(1).optional(),
3266
- tag: z35.string().min(1).optional(),
3267
- q: z35.string().min(1).optional()
3268
- });
3269
- var createPromptBodySchema = z35.object({
3270
- text: z35.string().min(1, "text is required"),
3271
- isBranded: z35.boolean().default(false),
3272
- topic: z35.string().min(1).optional(),
3273
- tags: z35.array(z35.string().min(1)).default([])
3274
- });
3275
- var updatePromptBodySchema = z35.object({
3276
- text: z35.string().min(1).optional(),
3277
- isBranded: z35.boolean().optional(),
3278
- topicId: z35.string().min(1).nullish(),
3279
- tags: z35.array(z35.string().min(1)).optional()
3280
- });
3281
- var runPromptBodySchema = z35.object({
3799
+ topic: z36.string().min(1).optional(),
3800
+ tag: z36.string().min(1).optional(),
3801
+ q: z36.string().min(1).optional()
3802
+ });
3803
+ var createPromptBodySchema = z36.object({
3804
+ text: z36.string().min(1, "text is required"),
3805
+ isBranded: z36.boolean().default(false),
3806
+ topic: z36.string().min(1).optional(),
3807
+ tags: z36.array(z36.string().min(1)).default([])
3808
+ });
3809
+ var updatePromptBodySchema = z36.object({
3810
+ text: z36.string().min(1).optional(),
3811
+ isBranded: z36.boolean().optional(),
3812
+ topicId: z36.string().min(1).nullish(),
3813
+ tags: z36.array(z36.string().min(1)).optional()
3814
+ });
3815
+ var runPromptBodySchema = z36.object({
3282
3816
  /** Preferred paired representation; each agent may pin its own model tiers. */
3283
- agentConfigs: z35.array(agentConfigInputSchema).min(1).optional(),
3817
+ agentConfigs: z36.array(agentConfigInputSchema).min(1).optional(),
3284
3818
  /** Legacy agent set (no per-agent pins), kept during the API transition. */
3285
- agents: z35.array(z35.enum(["CLAUDE_CODE", "CODEX_CLI", "CURSOR"])).min(1, "Select at least one agent").default(["CLAUDE_CODE", "CODEX_CLI"]),
3286
- repoUrl: z35.string().min(1).nullish(),
3287
- repoRef: z35.string().min(1).nullish(),
3288
- samplesPerCycle: z35.number().int().min(1).max(10).default(1),
3819
+ agents: z36.array(z36.enum(["CLAUDE_CODE", "CODEX_CLI", "CURSOR"])).min(1, "Select at least one agent").default(["CLAUDE_CODE", "CODEX_CLI"]),
3820
+ repoUrl: z36.string().min(1).nullish(),
3821
+ repoRef: z36.string().min(1).nullish(),
3822
+ samplesPerCycle: z36.number().int().min(1).max(10).default(1),
3289
3823
  webFixture: webFixtureSchema.optional()
3290
3824
  });
3291
- var runPromptResponseSchema = z35.object({
3292
- batchIds: z35.array(z35.string()),
3293
- runIds: z35.array(z35.string()),
3294
- blocked: z35.enum(["insufficient_credits", "needs_provider_key"]).optional()
3825
+ var runPromptResponseSchema = z36.object({
3826
+ batchIds: z36.array(z36.string()),
3827
+ runIds: z36.array(z36.string()),
3828
+ blocked: z36.enum(["insufficient_credits", "needs_provider_key"]).optional()
3295
3829
  });
3296
3830
 
3297
3831
  // ../packages/api-schemas/src/repos.ts
3298
- import { z as z36 } from "zod";
3832
+ import { z as z37 } from "zod";
3299
3833
  var REPO_SIZE_BUCKETS = [
3300
3834
  "small",
3301
3835
  "medium",
3302
3836
  "large",
3303
3837
  "xlarge"
3304
3838
  ];
3305
- var repoSizeBucketSchema = z36.enum(REPO_SIZE_BUCKETS);
3306
- var repoSchema = z36.object({
3307
- url: z36.string(),
3308
- name: z36.string(),
3309
- isSystem: z36.boolean(),
3310
- languages: z36.array(z36.string()),
3311
- frameworks: z36.array(z36.string()),
3839
+ var repoSizeBucketSchema = z37.enum(REPO_SIZE_BUCKETS);
3840
+ var repoSchema = z37.object({
3841
+ url: z37.string(),
3842
+ name: z37.string(),
3843
+ isSystem: z37.boolean(),
3844
+ languages: z37.array(z37.string()),
3845
+ frameworks: z37.array(z37.string()),
3312
3846
  /** Faceted labels (complexity:L2, buildable:yes, stack:nextjs, …). */
3313
- tags: z36.array(z36.string()),
3314
- primaryLanguage: z36.string(),
3315
- sizeKb: z36.number(),
3847
+ tags: z37.array(z37.string()),
3848
+ primaryLanguage: z37.string(),
3849
+ sizeKb: z37.number(),
3316
3850
  sizeBucket: repoSizeBucketSchema.nullable(),
3317
- stars: z36.number()
3851
+ stars: z37.number()
3318
3852
  });
3319
3853
  var repoListResponseSchema = listResponseSchema(repoSchema);
3320
- var addRepoBodySchema = z36.object({
3321
- url: z36.string().min(1, "url is required"),
3854
+ var addRepoBodySchema = z37.object({
3855
+ url: z37.string().min(1, "url is required"),
3322
3856
  /**
3323
3857
  * Reserved (accepted, not yet persisted): the catalog keys repos by URL only
3324
3858
  * — `fact_repo` has no ref column and metadata sync always reads the default
3325
3859
  * branch. Kept in the wire format so `gauge repos add --ref` is stable once
3326
3860
  * the catalog learns refs.
3327
3861
  */
3328
- ref: z36.string().min(1).optional(),
3862
+ ref: z37.string().min(1).optional(),
3329
3863
  /** Display name; defaults to the `owner/repo` label of the URL. */
3330
- name: z36.string().min(1).optional(),
3864
+ name: z37.string().min(1).optional(),
3331
3865
  /** Manual override; defaults to frameworks detected from the repo's manifests. */
3332
- frameworks: z36.array(z36.string()).optional(),
3333
- tags: z36.array(z36.string()).optional()
3866
+ frameworks: z37.array(z37.string()).optional(),
3867
+ tags: z37.array(z37.string()).optional()
3334
3868
  });
3335
- var updateRepoBodySchema = z36.object({
3336
- url: z36.string().min(1, "url is required"),
3337
- name: z36.string().min(1).optional(),
3338
- frameworks: z36.array(z36.string()).optional(),
3339
- tags: z36.array(z36.string()).optional()
3869
+ var updateRepoBodySchema = z37.object({
3870
+ url: z37.string().min(1, "url is required"),
3871
+ name: z37.string().min(1).optional(),
3872
+ frameworks: z37.array(z37.string()).optional(),
3873
+ tags: z37.array(z37.string()).optional()
3340
3874
  });
3341
- var resyncRepoBodySchema = z36.object({
3342
- url: z36.string().min(1, "url is required")
3875
+ var resyncRepoBodySchema = z37.object({
3876
+ url: z37.string().min(1, "url is required")
3343
3877
  });
3344
- var deleteRepoQuerySchema = z36.object({
3345
- url: z36.string().min(1, "url is required")
3878
+ var deleteRepoQuerySchema = z37.object({
3879
+ url: z37.string().min(1, "url is required")
3346
3880
  });
3347
- var repoSyncResultSchema = z36.object({
3881
+ var repoSyncResultSchema = z37.object({
3348
3882
  repo: repoSchema,
3349
- synced: z36.boolean()
3883
+ synced: z37.boolean()
3884
+ });
3885
+
3886
+ // ../packages/api-schemas/src/runAddons.ts
3887
+ import { z as z38 } from "zod";
3888
+ var runAddonsSchema = z38.object({
3889
+ browser: z38.object({
3890
+ session: z38.string().min(1),
3891
+ projectId: z38.number().int().positive(),
3892
+ region: z38.literal("us").default("us")
3893
+ }).strict().optional()
3894
+ }).strict();
3895
+
3896
+ // ../packages/api-schemas/src/runDefinitions.ts
3897
+ import { z as z40 } from "zod";
3898
+
3899
+ // ../packages/api-schemas/src/runPlan.ts
3900
+ import { z as z39 } from "zod";
3901
+ var runPlanCriterionSchema = z39.object({
3902
+ id: z39.string().min(1),
3903
+ name: z39.string(),
3904
+ rubric: z39.string()
3905
+ });
3906
+ var criteriaSnapshotV1Schema = z39.object({
3907
+ version: z39.literal(1),
3908
+ // File-authored criteria have no saved EvalSet; their identity is frozen
3909
+ // in the request and result rows retain the criterion text without an FK.
3910
+ evalSetId: z39.string().min(1).nullable(),
3911
+ criteria: z39.array(runPlanCriterionSchema)
3912
+ });
3913
+ var runPlanCaseSchema = z39.object({
3914
+ id: z39.string().min(1),
3915
+ prompt: z39.object({ id: z39.string().min(1), text: z39.string() }),
3916
+ workspace: z39.object({
3917
+ repoUrl: z39.string().nullable(),
3918
+ repoRef: z39.string().nullable()
3919
+ }),
3920
+ agents: z39.array(
3921
+ agentConfigSchema.extend({
3922
+ // Validated against the current catalog request schema when lowered.
3923
+ catalogSelections: z39.record(z39.string(), z39.unknown()).optional()
3924
+ })
3925
+ ),
3926
+ samples: z39.number().int().min(1).max(50),
3927
+ evalSetId: z39.string().min(1).optional(),
3928
+ criteriaSnapshot: criteriaSnapshotV1Schema.optional(),
3929
+ sourceRepoCommit: z39.string().nullable().optional(),
3930
+ experiment: z39.string().nullable().optional(),
3931
+ membershipTagIds: z39.array(z39.string()).optional(),
3932
+ profile: z39.object({
3933
+ id: z39.string(),
3934
+ name: z39.string(),
3935
+ description: z39.string(),
3936
+ model: z39.string()
3937
+ }).nullable().optional(),
3938
+ skillSet: skillSetSchema.optional(),
3939
+ mcpSet: mcpSetSchema.optional(),
3940
+ connectionSet: connectionSetSchema.optional(),
3941
+ // The server's agentContextSnapshotV1Schema validates this at lowering.
3942
+ agentContext: z39.unknown().optional(),
3943
+ agentContextDigest: z39.string().nullable().optional(),
3944
+ addons: runAddonsSchema.optional(),
3945
+ /** Names of resources the coordinator must prepare before expansion. */
3946
+ inputs: z39.array(z39.string().min(1)).default([])
3947
+ });
3948
+ var builtDirectoryResourceSchema = z39.object({
3949
+ name: z39.string().min(1),
3950
+ type: z39.literal("built-directory"),
3951
+ source: z39.object({
3952
+ type: z39.literal("git-checkout"),
3953
+ repoUrl: z39.string().min(1),
3954
+ commit: z39.string().regex(/^[a-f0-9]{40}$/i)
3955
+ }),
3956
+ build: z39.object({
3957
+ runtime: z39.literal("node-24"),
3958
+ run: z39.string().min(1),
3959
+ output: z39.string().min(1),
3960
+ /** Declared command name plus args, invoked from a clean cwd before a session. */
3961
+ smoke: z39.array(z39.string().min(1)).min(1)
3962
+ }),
3963
+ expose: z39.object({
3964
+ type: z39.literal("command"),
3965
+ commands: z39.record(z39.string().min(1), z39.array(z39.string().min(1)).min(1))
3966
+ })
3967
+ }).superRefine((resource, ctx) => {
3968
+ if (!(resource.build.smoke[0] in resource.expose.commands))
3969
+ ctx.addIssue({
3970
+ code: "custom",
3971
+ path: ["build", "smoke", 0],
3972
+ message: "Smoke command must name an exposed command"
3973
+ });
3974
+ });
3975
+ var bundleRelativeScriptSchema = z39.string().min(1).refine(
3976
+ (path2) => !path2.startsWith("/") && !path2.includes("\\") && !path2.includes("\0") && !path2.split("/").includes("..") && path2.split("/").some((part) => part !== "" && part !== "."),
3977
+ "Install script must be a bundle-relative path without traversal"
3978
+ );
3979
+ var preparedDirectoryPrepareSchema = z39.union([
3980
+ z39.object({ run: z39.string().min(1) }).strict(),
3981
+ z39.object({
3982
+ type: z39.literal("npm-cli"),
3983
+ build: z39.string().min(1).optional()
3984
+ }).strict()
3985
+ ]);
3986
+ var preparedDirectoryResourceSchema = z39.object({
3987
+ name: z39.string().min(1),
3988
+ type: z39.literal("prepared-directory"),
3989
+ source: z39.object({
3990
+ type: z39.literal("git-checkout"),
3991
+ repoUrl: z39.string().min(1),
3992
+ commit: z39.string().regex(/^[a-f0-9]{40}$/i)
3993
+ }).strict(),
3994
+ prepare: preparedDirectoryPrepareSchema,
3995
+ install: bundleRelativeScriptSchema.optional()
3996
+ }).strict().superRefine((resource, ctx) => {
3997
+ if ("type" in resource.prepare && resource.install)
3998
+ ctx.addIssue({
3999
+ code: "custom",
4000
+ path: ["install"],
4001
+ message: "npm-cli products cannot declare an install script"
4002
+ });
4003
+ });
4004
+ var runPlanResourceSchema = z39.union([
4005
+ builtDirectoryResourceSchema,
4006
+ preparedDirectoryResourceSchema
4007
+ ]);
4008
+ var runPlanSchema = z39.object({
4009
+ version: z39.literal(1),
4010
+ /** Existing launches keep their current measurement semantics. */
4011
+ measurementMode: z39.enum(["EXISTING", "AGENT_EXPERIENCE"]),
4012
+ cases: z39.array(runPlanCaseSchema).min(1),
4013
+ resources: z39.array(runPlanResourceSchema).default([]),
4014
+ /** Server-populated context retained across deferred preparation. */
4015
+ launch: z39.object({
4016
+ origin: z39.object({
4017
+ initiator: z39.literal("API"),
4018
+ userId: z39.string().min(1),
4019
+ email: z39.string().nullable()
4020
+ }).strict(),
4021
+ funding: z39.enum(["ORG", "PLATFORM"]),
4022
+ queueClass: z39.literal("INTERACTIVE")
4023
+ }).strict().optional(),
4024
+ provenance: z39.object({
4025
+ definition: z39.object({
4026
+ repoUrl: z39.string().min(1),
4027
+ commit: z39.string().regex(/^[a-f0-9]{40}$/i),
4028
+ digest: z39.string().min(1),
4029
+ /** File submissions are asserted by the caller until server-side
4030
+ * committed-byte fetching is available. */
4031
+ verification: z39.literal("SUBMITTED_UNVERIFIED").optional()
4032
+ }).optional(),
4033
+ liveDependencies: z39.array(
4034
+ z39.object({
4035
+ name: z39.string().min(1),
4036
+ url: z39.string().url().optional()
4037
+ })
4038
+ ).default([])
4039
+ })
4040
+ }).superRefine((plan, ctx) => {
4041
+ const resourceNames = new Set(
4042
+ plan.resources.map((resource) => resource.name)
4043
+ );
4044
+ for (const [index, item] of plan.cases.entries()) {
4045
+ if (plan.measurementMode === "AGENT_EXPERIENCE" && !item.agents.length)
4046
+ ctx.addIssue({
4047
+ code: "custom",
4048
+ path: ["cases", index, "agents"],
4049
+ message: "Agent Experience cases require a selected agent"
4050
+ });
4051
+ if (plan.measurementMode === "AGENT_EXPERIENCE" && !item.criteriaSnapshot?.criteria.length)
4052
+ ctx.addIssue({
4053
+ code: "custom",
4054
+ path: ["cases", index, "criteriaSnapshot"],
4055
+ message: "Agent Experience cases require criteria"
4056
+ });
4057
+ if (item.criteriaSnapshot && item.criteriaSnapshot.evalSetId !== (item.evalSetId ?? null))
4058
+ ctx.addIssue({
4059
+ code: "custom",
4060
+ path: ["cases", index, "criteriaSnapshot", "evalSetId"],
4061
+ message: "Criteria snapshot must belong to the case's eval"
4062
+ });
4063
+ for (const input of item.inputs) {
4064
+ if (!resourceNames.has(input))
4065
+ ctx.addIssue({
4066
+ code: "custom",
4067
+ path: ["cases", index, "inputs"],
4068
+ message: `Unknown resource: ${input}`
4069
+ });
4070
+ }
4071
+ }
4072
+ if (new Set(plan.cases.map((item) => item.id)).size !== plan.cases.length)
4073
+ ctx.addIssue({
4074
+ code: "custom",
4075
+ path: ["cases"],
4076
+ message: "Case ids must be unique"
4077
+ });
4078
+ if (resourceNames.size !== plan.resources.length)
4079
+ ctx.addIssue({
4080
+ code: "custom",
4081
+ path: ["resources"],
4082
+ message: "Resource names must be unique"
4083
+ });
4084
+ });
4085
+
4086
+ // ../packages/api-schemas/src/runDefinitions.ts
4087
+ var uncredentialedRepoUrlSchema = z40.string().min(1).refine((raw) => {
4088
+ if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(raw)) return true;
4089
+ try {
4090
+ const url = new URL(raw);
4091
+ return (url.protocol === "ssh:" || !url.username) && !url.password && !url.search && !url.hash;
4092
+ } catch {
4093
+ return false;
4094
+ }
4095
+ }, "Repository URL must not contain embedded credentials or query parameters");
4096
+ var runDefinitionConfigSchema = z40.object({
4097
+ agents: z40.array(agentConfigInputSchema).min(1),
4098
+ sampleCount: z40.number().int().min(1).max(50).optional(),
4099
+ repoUrl: uncredentialedRepoUrlSchema.nullable().optional(),
4100
+ repoRef: z40.string().min(1).nullable().optional(),
4101
+ profileId: z40.string().min(1).nullable().optional(),
4102
+ skillRefs: assetRefListSchema.optional(),
4103
+ mcpRefs: assetRefListSchema.optional(),
4104
+ connectionIds: z40.array(z40.string().min(1)).max(32).optional(),
4105
+ addons: runAddonsSchema.optional()
4106
+ }).strict();
4107
+ var githubCasePathSchema = z40.string().regex(
4108
+ /^evals\/[A-Za-z0-9_./-]+\.md$/,
4109
+ "Expected an explicit evals/*.md path"
4110
+ ).refine(
4111
+ (path2) => path2.split("/").every((part) => part !== "" && part !== "." && part !== ".."),
4112
+ "Case path must not contain traversal or empty segments"
4113
+ );
4114
+ var runDefinitionFileConfigSchema = z40.object({
4115
+ version: z40.literal(1).default(1),
4116
+ org: z40.string().min(1).optional(),
4117
+ product: z40.object({
4118
+ type: z40.literal("npm-cli"),
4119
+ build: z40.string().min(1).optional()
4120
+ }).strict().optional(),
4121
+ prepare: z40.string().min(1).optional(),
4122
+ install: bundleRelativeScriptSchema.optional(),
4123
+ github: z40.object({
4124
+ enabled: z40.literal(true),
4125
+ files: z40.array(githubCasePathSchema).min(1).max(20).refine(
4126
+ (paths) => new Set(paths).size === paths.length,
4127
+ "Case paths must be unique"
4128
+ )
4129
+ }).strict().optional()
4130
+ }).strict().superRefine((config, ctx) => {
4131
+ if (config.product && config.prepare)
4132
+ ctx.addIssue({
4133
+ code: "custom",
4134
+ path: ["product"],
4135
+ message: "product and prepare are alternatives"
4136
+ });
4137
+ if (config.product && config.install)
4138
+ ctx.addIssue({
4139
+ code: "custom",
4140
+ path: ["install"],
4141
+ message: "npm-cli products cannot declare an install script"
4142
+ });
4143
+ });
4144
+ var runDefinitionCriterionSchema = z40.object({ name: z40.string().min(1), rubric: z40.string().min(1) }).strict();
4145
+ var runDefinitionFrontmatterSchema = z40.object({
4146
+ criteria: z40.array(runDefinitionCriterionSchema).min(1),
4147
+ config: runDefinitionConfigSchema
4148
+ }).strict();
4149
+ var runDefinitionCaseSchema = z40.object({
4150
+ path: z40.string().min(1),
4151
+ prompt: z40.string().min(1),
4152
+ criteria: z40.array(runDefinitionCriterionSchema).min(1),
4153
+ config: runDefinitionConfigSchema
4154
+ }).strict();
4155
+ var runDefinitionSubmissionSchema = z40.object({
4156
+ version: z40.literal(1),
4157
+ source: z40.object({
4158
+ repoUrl: uncredentialedRepoUrlSchema,
4159
+ commit: z40.string().regex(/^[a-f0-9]{40}$/i),
4160
+ digest: z40.string().regex(/^sha256:[a-f0-9]{64}$/),
4161
+ verification: z40.literal("SUBMITTED_UNVERIFIED")
4162
+ }).strict(),
4163
+ resources: z40.array(preparedDirectoryResourceSchema).max(1).default([]),
4164
+ cases: z40.array(runDefinitionCaseSchema).min(1)
4165
+ }).strict().superRefine((definition, ctx) => {
4166
+ const paths = /* @__PURE__ */ new Set();
4167
+ for (const [index, item] of definition.cases.entries()) {
4168
+ if (paths.has(item.path))
4169
+ ctx.addIssue({
4170
+ code: "custom",
4171
+ path: ["cases", index, "path"],
4172
+ message: "Case paths must be unique"
4173
+ });
4174
+ paths.add(item.path);
4175
+ }
4176
+ for (const [index, resource] of definition.resources.entries()) {
4177
+ if (resource.name !== "project")
4178
+ ctx.addIssue({
4179
+ code: "custom",
4180
+ path: ["resources", index, "name"],
4181
+ message: "The project preparation must use the reserved name project"
4182
+ });
4183
+ if (resource.source.repoUrl !== definition.source.repoUrl || resource.source.commit !== definition.source.commit)
4184
+ ctx.addIssue({
4185
+ code: "custom",
4186
+ path: ["resources", index, "source"],
4187
+ message: "Project preparation must use the definition repository and commit"
4188
+ });
4189
+ if (!resource.source.repoUrl.startsWith("https://"))
4190
+ ctx.addIssue({
4191
+ code: "custom",
4192
+ path: ["resources", index, "source", "repoUrl"],
4193
+ message: "Project preparation requires a public HTTPS Git source"
4194
+ });
4195
+ if (!uncredentialedRepoUrlSchema.safeParse(resource.source.repoUrl).success)
4196
+ ctx.addIssue({
4197
+ code: "custom",
4198
+ path: ["resources", index, "source", "repoUrl"],
4199
+ message: "Repository URL must not contain embedded credentials or query parameters"
4200
+ });
4201
+ }
4202
+ });
4203
+ var runDefinitionPlanResponseSchema = z40.object({
4204
+ source: runDefinitionSubmissionSchema.shape.source,
4205
+ measurementMode: z40.literal("AGENT_EXPERIENCE"),
4206
+ cases: z40.array(
4207
+ z40.object({
4208
+ path: z40.string(),
4209
+ agents: z40.array(agentConfigSchema),
4210
+ samples: z40.number().int().nonnegative(),
4211
+ expectedRuns: z40.number().int().nonnegative(),
4212
+ workspace: z40.object({
4213
+ repoUrl: z40.string().nullable(),
4214
+ repoRef: z40.string().nullable()
4215
+ }),
4216
+ criteriaCount: z40.number().int().nonnegative(),
4217
+ inputs: z40.array(z40.string())
4218
+ })
4219
+ ),
4220
+ resources: z40.array(
4221
+ z40.object({ name: z40.string(), type: z40.literal("prepared-directory") })
4222
+ ),
4223
+ expectedRuns: z40.number().int().nonnegative(),
4224
+ canRun: z40.boolean()
4225
+ });
4226
+ var runDefinitionRunResponseSchema = z40.object({
4227
+ runRequestId: z40.string(),
4228
+ batchIds: z40.array(z40.string()),
4229
+ runIds: z40.array(z40.string()),
4230
+ requestedRuns: z40.number().int().nonnegative(),
4231
+ createdRuns: z40.number().int().nonnegative(),
4232
+ aggregateUrl: z40.string()
4233
+ });
4234
+
4235
+ // ../packages/api-schemas/src/runRequests.ts
4236
+ import { z as z41 } from "zod";
4237
+ var runRequestStatusSchema = z41.enum([
4238
+ "PENDING",
4239
+ "PREPARING",
4240
+ "RUNNING",
4241
+ "COMPLETED",
4242
+ "FAILED",
4243
+ "CANCELED"
4244
+ ]);
4245
+ var runRequestResultSchema = z41.enum([
4246
+ "PENDING",
4247
+ "PASSED",
4248
+ "QUALITY_FAILED",
4249
+ "EXECUTION_FAILED",
4250
+ "PREPARATION_FAILED",
4251
+ "JUDGE_FAILED",
4252
+ "INCOMPLETE",
4253
+ "CANCELED"
4254
+ ]);
4255
+ var runRequestCriterionResultSchema = z41.object({
4256
+ criterionId: z41.string().nullable(),
4257
+ name: z41.string(),
4258
+ passed: z41.boolean(),
4259
+ reasoning: z41.string().nullable()
4260
+ });
4261
+ var runRequestRunSchema = z41.object({
4262
+ id: z41.string(),
4263
+ batchId: z41.string(),
4264
+ status: z41.string(),
4265
+ agent: agentSchema,
4266
+ model: z41.string(),
4267
+ result: runRequestResultSchema,
4268
+ judge: z41.object({ status: z41.string() }).nullable(),
4269
+ criterionResults: z41.array(runRequestCriterionResultSchema)
4270
+ });
4271
+ var runRequestResponseSchema = z41.object({
4272
+ id: z41.string(),
4273
+ status: runRequestStatusSchema,
4274
+ result: runRequestResultSchema,
4275
+ settled: z41.boolean(),
4276
+ counts: z41.object({
4277
+ requestedRuns: z41.number().int().nonnegative(),
4278
+ createdRuns: z41.number().int().nonnegative(),
4279
+ terminalRuns: z41.number().int().nonnegative(),
4280
+ judgedRuns: z41.number().int().nonnegative(),
4281
+ passedRuns: z41.number().int().nonnegative(),
4282
+ qualityFailedRuns: z41.number().int().nonnegative(),
4283
+ executionFailedRuns: z41.number().int().nonnegative(),
4284
+ judgeFailedRuns: z41.number().int().nonnegative(),
4285
+ pendingRuns: z41.number().int().nonnegative()
4286
+ }),
4287
+ batches: z41.array(
4288
+ z41.object({ id: z41.string(), runs: z41.array(runRequestRunSchema) })
4289
+ ),
4290
+ createdAt: z41.string(),
4291
+ updatedAt: z41.string(),
4292
+ finishedAt: z41.string().nullable()
3350
4293
  });
3351
4294
 
3352
4295
  // ../packages/api-schemas/src/summary.ts
3353
- import { z as z37 } from "zod";
4296
+ import { z as z42 } from "zod";
3354
4297
  function cardResultSchema(data) {
3355
- return z37.union([
3356
- z37.object({ ok: z37.literal(true), data }),
3357
- z37.object({ ok: z37.literal(false), error: z37.string() })
4298
+ return z42.union([
4299
+ z42.object({ ok: z42.literal(true), data }),
4300
+ z42.object({ ok: z42.literal(false), error: z42.string() })
3358
4301
  ]);
3359
4302
  }
3360
- var summaryActionSchema = z37.object({
3361
- id: z37.string(),
3362
- title: z37.string(),
3363
- priority: z37.string(),
3364
- status: z37.string(),
3365
- evidenceCount: z37.number().int()
3366
- });
3367
- var summaryAeCardSchema = z37.object({
3368
- id: z37.string(),
3369
- name: z37.string(),
3370
- judgedRuns: z37.number().int(),
3371
- passRate: z37.number().nullable(),
4303
+ var summaryActionSchema = z42.object({
4304
+ id: z42.string(),
4305
+ title: z42.string(),
4306
+ priority: z42.string(),
4307
+ status: z42.string(),
4308
+ evidenceCount: z42.number().int()
4309
+ });
4310
+ var summaryAeCardSchema = z42.object({
4311
+ id: z42.string(),
4312
+ name: z42.string(),
4313
+ judgedRuns: z42.number().int(),
4314
+ passRate: z42.number().nullable(),
3372
4315
  /** pp delta vs the prior 30d; null with no prior. */
3373
- deltaPP: z37.number().nullable()
3374
- });
3375
- var summaryVisibilityCardSchema = z37.object({
3376
- name: z37.string(),
3377
- owned: z37.object({
3378
- name: z37.string(),
3379
- rank: z37.number(),
3380
- chosenRate: z37.number(),
3381
- mentionRate: z37.number()
4316
+ deltaPP: z42.number().nullable()
4317
+ });
4318
+ var summaryVisibilityCardSchema = z42.object({
4319
+ name: z42.string(),
4320
+ owned: z42.object({
4321
+ name: z42.string(),
4322
+ rank: z42.number(),
4323
+ chosenRate: z42.number(),
4324
+ mentionRate: z42.number()
3382
4325
  }).nullable(),
3383
- chosenDeltaPP: z37.number().nullable()
4326
+ chosenDeltaPP: z42.number().nullable()
3384
4327
  });
3385
- var homeSummarySchema = z37.object({
3386
- hasAnyRuns: z37.boolean(),
3387
- lastSynthesisAt: z37.string().nullable(),
3388
- actions: cardResultSchema(z37.array(summaryActionSchema)),
4328
+ var homeSummarySchema = z42.object({
4329
+ hasAnyRuns: z42.boolean(),
4330
+ lastSynthesisAt: z42.string().nullable(),
4331
+ actions: cardResultSchema(z42.array(summaryActionSchema)),
3389
4332
  visibility: cardResultSchema(
3390
- z37.object({
3391
- cards: z37.array(summaryVisibilityCardSchema),
3392
- marketsTotal: z37.number().int(),
3393
- promptCount: z37.number().int()
4333
+ z42.object({
4334
+ cards: z42.array(summaryVisibilityCardSchema),
4335
+ marketsTotal: z42.number().int(),
4336
+ promptCount: z42.number().int()
3394
4337
  })
3395
4338
  ),
3396
4339
  agentExperience: cardResultSchema(
3397
- z37.object({
3398
- cards: z37.array(summaryAeCardSchema),
3399
- total: z37.number().int(),
3400
- setCount: z37.number().int()
4340
+ z42.object({
4341
+ cards: z42.array(summaryAeCardSchema),
4342
+ total: z42.number().int(),
4343
+ setCount: z42.number().int()
3401
4344
  })
3402
4345
  ),
3403
- notableSessions: cardResultSchema(z37.array(z37.unknown()))
4346
+ notableSessions: cardResultSchema(z42.array(z42.unknown()))
3404
4347
  });
3405
4348
 
3406
4349
  // ../packages/api-schemas/src/tokens.ts
3407
- import { z as z38 } from "zod";
3408
- var apiTokenSchema = z38.object({
3409
- id: z38.string(),
3410
- name: z38.string(),
4350
+ import { z as z43 } from "zod";
4351
+ var apiTokenSchema = z43.object({
4352
+ id: z43.string(),
4353
+ name: z43.string(),
3411
4354
  /** Last 4 chars of the plaintext, for recognizability (non-secret). */
3412
- last4: z38.string(),
3413
- expiresAt: z38.iso.datetime().nullable(),
3414
- lastUsedAt: z38.iso.datetime().nullable(),
3415
- createdAt: z38.iso.datetime(),
3416
- revokedAt: z38.iso.datetime().nullable()
3417
- });
3418
- var createTokenRequestSchema = z38.object({
3419
- name: z38.string().min(1).max(100),
4355
+ last4: z43.string(),
4356
+ expiresAt: z43.iso.datetime().nullable(),
4357
+ lastUsedAt: z43.iso.datetime().nullable(),
4358
+ createdAt: z43.iso.datetime(),
4359
+ revokedAt: z43.iso.datetime().nullable()
4360
+ });
4361
+ var createTokenRequestSchema = z43.object({
4362
+ name: z43.string().min(1).max(100),
3420
4363
  /** ISO-8601 datetime; omit for no expiry. */
3421
- expiresAt: z38.iso.datetime({ offset: true }).optional()
4364
+ expiresAt: z43.iso.datetime({ offset: true }).optional()
3422
4365
  });
3423
4366
  var createTokenResponseSchema = apiTokenSchema.extend({
3424
- token: z38.string()
4367
+ token: z43.string()
3425
4368
  });
3426
4369
  var listTokensResponseSchema = listResponseSchema(apiTokenSchema);
3427
4370
 
3428
4371
  // ../packages/api-schemas/src/visibility.ts
3429
- import { z as z39 } from "zod";
4372
+ import { z as z44 } from "zod";
3430
4373
  var VISIBILITY_PROMPT_KINDS = ["HEAD_TO_HEAD", "RECOMMEND"];
3431
- var visibilityPromptKindSchema = z39.enum(VISIBILITY_PROMPT_KINDS);
4374
+ var visibilityPromptKindSchema = z44.enum(VISIBILITY_PROMPT_KINDS);
3432
4375
  var visibilityPromptSchema = visibilityPromptSettingsSchema.extend({
3433
- id: z39.string(),
3434
- name: z39.string(),
4376
+ id: z44.string(),
4377
+ name: z44.string(),
3435
4378
  kind: visibilityPromptKindSchema,
3436
- promptText: z39.string(),
4379
+ promptText: z44.string(),
3437
4380
  /** HEAD_TO_HEAD is always branded; RECOMMEND may be either. */
3438
- branded: z39.boolean(),
3439
- brandA: z39.string().nullable(),
3440
- brandB: z39.string().nullable(),
3441
- market: z39.object({ id: z39.string(), slug: z39.string(), name: z39.string() }).nullable(),
3442
- position: z39.number().int(),
3443
- createdAt: z39.string(),
4381
+ branded: z44.boolean(),
4382
+ brandA: z44.string().nullable(),
4383
+ brandB: z44.string().nullable(),
4384
+ market: z44.object({ id: z44.string(), slug: z44.string(), name: z44.string() }).nullable(),
4385
+ position: z44.number().int(),
4386
+ createdAt: z44.string(),
3444
4387
  /** User tag names on the hidden backing prompt (Surface:* excluded). */
3445
- tags: z39.array(z39.string()),
3446
- runCount: z39.number().int(),
3447
- lastRunAt: z39.string().nullable(),
3448
- scenarios: z39.array(visibilityScenarioSchema)
4388
+ tags: z44.array(z44.string()),
4389
+ runCount: z44.number().int(),
4390
+ lastRunAt: z44.string().nullable(),
4391
+ scenarios: z44.array(visibilityScenarioSchema)
3449
4392
  });
3450
- var listVisibilityPromptsResponseSchema = z39.object({
3451
- items: z39.array(visibilityPromptSchema)
4393
+ var listVisibilityPromptsResponseSchema = z44.object({
4394
+ items: z44.array(visibilityPromptSchema)
3452
4395
  });
3453
- var createVisibilityPromptBodySchema = z39.object({
3454
- name: z39.string().min(1),
3455
- promptText: z39.string().min(1),
4396
+ var createVisibilityPromptBodySchema = z44.object({
4397
+ name: z44.string().min(1),
4398
+ promptText: z44.string().min(1),
3456
4399
  kind: visibilityPromptKindSchema,
3457
- branded: z39.boolean().optional(),
4400
+ branded: z44.boolean().optional(),
3458
4401
  /** Required pair for HEAD_TO_HEAD (order-independent). */
3459
- brandA: z39.string().nullish(),
3460
- brandB: z39.string().nullish(),
4402
+ brandA: z44.string().nullish(),
4403
+ brandB: z44.string().nullish(),
3461
4404
  /** Measured market id from the org's tracked set. */
3462
- marketId: z39.string().nullish(),
3463
- tags: z39.array(z39.string()).optional(),
4405
+ marketId: z44.string().nullish(),
4406
+ tags: z44.array(z44.string()).optional(),
3464
4407
  agents: visibilityPromptSettingsInputShape.agents.optional(),
3465
4408
  skillRefs: visibilityPromptSettingsInputShape.skillRefs,
3466
4409
  mcpRefs: visibilityPromptSettingsInputShape.mcpRefs,
3467
4410
  connectionIds: visibilityPromptSettingsInputShape.connectionIds,
3468
4411
  cadence: visibilityPromptSettingsInputShape.cadence,
3469
4412
  sampleCount: visibilityPromptSettingsInputShape.sampleCount,
3470
- scenarios: z39.array(visibilityScenarioInputSchema).optional().default([])
4413
+ scenarios: z44.array(visibilityScenarioInputSchema).optional().default([])
3471
4414
  }).strict();
3472
- var synthesizeResponseSchema = z39.object({
4415
+ var synthesizeResponseSchema = z44.object({
3473
4416
  /** False when the pre-check found no new evidence and nothing was queued. */
3474
- queued: z39.boolean()
3475
- });
3476
- var updateVisibilityPromptBodySchema = z39.object({
3477
- name: z39.string().min(1).optional(),
3478
- promptText: z39.string().min(1).optional(),
3479
- branded: z39.boolean().optional(),
3480
- brandA: z39.string().nullish(),
3481
- brandB: z39.string().nullish(),
3482
- marketId: z39.string().nullish(),
3483
- tags: z39.array(z39.string()).optional(),
4417
+ queued: z44.boolean()
4418
+ });
4419
+ var updateVisibilityPromptBodySchema = z44.object({
4420
+ name: z44.string().min(1).optional(),
4421
+ promptText: z44.string().min(1).optional(),
4422
+ branded: z44.boolean().optional(),
4423
+ brandA: z44.string().nullish(),
4424
+ brandB: z44.string().nullish(),
4425
+ marketId: z44.string().nullish(),
4426
+ tags: z44.array(z44.string()).optional(),
3484
4427
  ...visibilityPromptSettingsPatchShape,
3485
4428
  /** Replaces the whole scenario set when present. */
3486
- scenarios: z39.array(visibilityScenarioInputSchema).optional()
4429
+ scenarios: z44.array(visibilityScenarioInputSchema).optional()
3487
4430
  }).strict();
3488
- var runVisibilityPromptResponseSchema = z39.object({
3489
- batchIds: z39.array(z39.string()),
3490
- runIds: z39.array(z39.string())
4431
+ var runVisibilityPromptResponseSchema = z44.object({
4432
+ batchIds: z44.array(z44.string()),
4433
+ runIds: z44.array(z44.string())
3491
4434
  });
3492
- var visibilityPromptRunSchema = z39.object({
3493
- id: z39.string(),
3494
- status: z39.string(),
4435
+ var visibilityPromptRunSchema = z44.object({
4436
+ id: z44.string(),
4437
+ status: z44.string(),
3495
4438
  agent: agentSchema,
3496
- model: z39.string().nullable(),
3497
- resolvedModel: z39.string().nullable(),
3498
- createdAt: z39.string(),
3499
- startedAt: z39.string().nullable(),
3500
- finishedAt: z39.string().nullable(),
3501
- failureReason: z39.string().nullable(),
3502
- verdict: z39.object({
3503
- status: z39.string(),
3504
- error: z39.string().nullable(),
3505
- payload: z39.unknown().nullable()
4439
+ model: z44.string().nullable(),
4440
+ resolvedModel: z44.string().nullable(),
4441
+ createdAt: z44.string(),
4442
+ startedAt: z44.string().nullable(),
4443
+ finishedAt: z44.string().nullable(),
4444
+ failureReason: z44.string().nullable(),
4445
+ verdict: z44.object({
4446
+ status: z44.string(),
4447
+ error: z44.string().nullable(),
4448
+ payload: z44.unknown().nullable()
3506
4449
  }).nullable()
3507
4450
  });
3508
- var listVisibilityPromptRunsResponseSchema = z39.object({
3509
- items: z39.array(visibilityPromptRunSchema)
4451
+ var listVisibilityPromptRunsResponseSchema = z44.object({
4452
+ items: z44.array(visibilityPromptRunSchema)
3510
4453
  });
3511
- var orgMarketSchema = z39.object({
3512
- marketId: z39.string(),
3513
- slug: z39.string(),
3514
- name: z39.string(),
4454
+ var orgMarketSchema = z44.object({
4455
+ marketId: z44.string(),
4456
+ slug: z44.string(),
4457
+ name: z44.string(),
3515
4458
  /** The one line saying what the market measures. */
3516
- capability: z39.string(),
4459
+ capability: z44.string(),
3517
4460
  /** SUGGESTED (the matcher) | USER (a human picked it). */
3518
- source: z39.string()
4461
+ source: z44.string()
3519
4462
  });
3520
4463
  var addableMarketSchema = orgMarketSchema.omit({ source: true });
3521
- var listMarketsResponseSchema = z39.object({
3522
- tracked: z39.array(orgMarketSchema),
4464
+ var listMarketsResponseSchema = z44.object({
4465
+ tracked: z44.array(orgMarketSchema),
3523
4466
  /** Published markets the org does not track yet (closed set — no free-text
3524
4467
  * market creation). */
3525
- addable: z39.array(addableMarketSchema)
4468
+ addable: z44.array(addableMarketSchema)
3526
4469
  });
3527
- var addMarketBodySchema = z39.object({ marketId: z39.string().min(1) });
4470
+ var addMarketBodySchema = z44.object({ marketId: z44.string().min(1) });
3528
4471
 
3529
4472
  // src/version.ts
3530
4473
  import { createRequire } from "module";
@@ -3592,9 +4535,9 @@ function resolveToken() {
3592
4535
  return null;
3593
4536
  }
3594
4537
  }
3595
- function saveToken(token) {
4538
+ function saveToken(token2) {
3596
4539
  mkdirSync2(configDir(), { recursive: true, mode: 448 });
3597
- writeFileSync2(credentialsPath(), `${token.trim()}
4540
+ writeFileSync2(credentialsPath(), `${token2.trim()}
3598
4541
  `, {
3599
4542
  encoding: "utf8",
3600
4543
  mode: 384
@@ -3804,9 +4747,10 @@ function messageOf(error) {
3804
4747
  }
3805
4748
 
3806
4749
  // src/lib/context.ts
3807
- function resolveOrg(command) {
4750
+ function resolveOrg(command, fileOrg) {
3808
4751
  const { org } = command.optsWithGlobals();
3809
4752
  if (org) return org;
4753
+ if (fileOrg) return fileOrg;
3810
4754
  const { defaultOrg } = readConfig();
3811
4755
  if (defaultOrg) return defaultOrg;
3812
4756
  throw new CliError(
@@ -3908,7 +4852,7 @@ __export(apply_exports, {
3908
4852
  register: () => register2
3909
4853
  });
3910
4854
  import { readFileSync as readFileSync3 } from "fs";
3911
- import { z as z40 } from "zod";
4855
+ import { z as z45 } from "zod";
3912
4856
  function assertRequiredExperiment(spec, required) {
3913
4857
  if (required.length === 0) {
3914
4858
  throw new CliError(
@@ -4060,7 +5004,7 @@ function register2(program2) {
4060
5004
  ).option("--schema", "print the battery spec JSON Schema and exit").option("--example", "print a minimal example battery spec and exit").action(
4061
5005
  async (opts, command) => {
4062
5006
  if (opts.schema) {
4063
- printJson(z40.toJSONSchema(batteries_exports.batterySpecSchema));
5007
+ printJson(z45.toJSONSchema(batteries_exports.batterySpecSchema));
4064
5008
  return;
4065
5009
  }
4066
5010
  if (opts.example) {
@@ -4172,7 +5116,7 @@ async function browserLogin() {
4172
5116
  const codeVerifier = randomBytes(32).toString("base64url");
4173
5117
  const codeChallenge = createHash("sha256").update(codeVerifier).digest("base64url");
4174
5118
  const server = createServer();
4175
- const codePromise = new Promise((resolve, reject) => {
5119
+ const codePromise = new Promise((resolve2, reject) => {
4176
5120
  server.on("request", (req, res) => {
4177
5121
  const url = new URL(req.url ?? "/", "http://127.0.0.1");
4178
5122
  if (url.pathname !== "/callback") {
@@ -4195,15 +5139,15 @@ async function browserLogin() {
4195
5139
  "content-type": "text/plain; charset=utf-8"
4196
5140
  });
4197
5141
  res.end("Authorized. Return to your terminal.");
4198
- resolve(code);
5142
+ resolve2(code);
4199
5143
  });
4200
5144
  server.on(
4201
5145
  "error",
4202
5146
  (e) => reject(new CliError("network", `Loopback listener failed: ${e.message}`))
4203
5147
  );
4204
5148
  });
4205
- await new Promise((resolve) => {
4206
- server.listen(0, "127.0.0.1", resolve);
5149
+ await new Promise((resolve2) => {
5150
+ server.listen(0, "127.0.0.1", resolve2);
4207
5151
  });
4208
5152
  const address = server.address();
4209
5153
  if (!address || typeof address === "string") {
@@ -4254,9 +5198,9 @@ async function browserLogin() {
4254
5198
  );
4255
5199
  }
4256
5200
  const exchange = parsed.data;
4257
- const token = exchange.accessToken;
4258
- const me = await fetchMe(new ApiClient({ token }));
4259
- saveToken(token);
5201
+ const token2 = exchange.accessToken;
5202
+ const me = await fetchMe(new ApiClient({ token: token2 }));
5203
+ saveToken(token2);
4260
5204
  console.log(`Token saved to ${credentialsPath()}`);
4261
5205
  printIdentity(me);
4262
5206
  } finally {
@@ -4360,10 +5304,10 @@ async function deviceLogin(opts) {
4360
5304
  "The sign-in request expired before it was approved. Re-run it to try again."
4361
5305
  );
4362
5306
  case "approved": {
4363
- const token = result.accessToken;
5307
+ const token2 = result.accessToken;
4364
5308
  try {
4365
- const me = await fetchMe(new ApiClient({ token }));
4366
- return { token, me };
5309
+ const me = await fetchMe(new ApiClient({ token: token2 }));
5310
+ return { token: token2, me };
4367
5311
  } catch (e) {
4368
5312
  throw new CliError(
4369
5313
  "network",
@@ -4400,15 +5344,15 @@ async function withTokenLogin() {
4400
5344
  if (process.stdin.isTTY) {
4401
5345
  console.error("Paste your API token, then press Enter:");
4402
5346
  }
4403
- const token = (await readStdin()).trim();
4404
- if (!token.startsWith(TOKEN_PREFIX)) {
5347
+ const token2 = (await readStdin()).trim();
5348
+ if (!token2.startsWith(TOKEN_PREFIX)) {
4405
5349
  throw new CliError(
4406
5350
  "usage",
4407
5351
  `Expected a token starting with ${TOKEN_PREFIX} on stdin`
4408
5352
  );
4409
5353
  }
4410
- const me = await fetchMe(new ApiClient({ token }));
4411
- saveToken(token);
5354
+ const me = await fetchMe(new ApiClient({ token: token2 }));
5355
+ saveToken(token2);
4412
5356
  console.log(`Token saved to ${credentialsPath()}`);
4413
5357
  printIdentity(me);
4414
5358
  }
@@ -4476,8 +5420,8 @@ function register3(program2) {
4476
5420
  throw new CliError("usage", "--email requires --device.");
4477
5421
  }
4478
5422
  if (opts.device) {
4479
- const { token, me } = await deviceLogin({ email: opts.email });
4480
- saveToken(token);
5423
+ const { token: token2, me } = await deviceLogin({ email: opts.email });
5424
+ saveToken(token2);
4481
5425
  console.log(`Token saved to ${credentialsPath()}`);
4482
5426
  printIdentity(me);
4483
5427
  } else if (opts.withToken) {
@@ -4832,10 +5776,10 @@ function splitList(raw) {
4832
5776
  return raw.split(",").map((v) => v.trim()).filter(Boolean);
4833
5777
  }
4834
5778
  function parsePackage(raw) {
4835
- const sep2 = raw.lastIndexOf(":");
4836
- if (sep2 === -1) return { name: raw.trim(), ecosystem: null };
4837
- const name = raw.slice(0, sep2).trim();
4838
- const ecosystem = raw.slice(sep2 + 1).trim();
5779
+ const sep3 = raw.lastIndexOf(":");
5780
+ if (sep3 === -1) return { name: raw.trim(), ecosystem: null };
5781
+ const name = raw.slice(0, sep3).trim();
5782
+ const ecosystem = raw.slice(sep3 + 1).trim();
4839
5783
  if (!name) throw new CliError("usage", `Invalid package "${raw}"`);
4840
5784
  if (!ECOSYSTEMS.includes(ecosystem)) {
4841
5785
  throw new CliError(
@@ -4971,7 +5915,7 @@ async function waitForCanary(id) {
4971
5915
  while (true) {
4972
5916
  const canary = await client.get(`${path}/${id}`);
4973
5917
  if (terminal.has(canary.status)) return canary;
4974
- await new Promise((resolve) => setTimeout(resolve, 1e4));
5918
+ await new Promise((resolve2) => setTimeout(resolve2, 1e4));
4975
5919
  }
4976
5920
  }
4977
5921
  function register7(program2, opts = {}) {
@@ -5204,7 +6148,7 @@ async function confirmOrAbort(question, yes) {
5204
6148
  }
5205
6149
  const rl = createInterface2({ input: process.stdin, output: process.stderr });
5206
6150
  const answer = await new Promise(
5207
- (resolve) => rl.question(`${question} [y/N] `, resolve)
6151
+ (resolve2) => rl.question(`${question} [y/N] `, resolve2)
5208
6152
  );
5209
6153
  rl.close();
5210
6154
  if (!/^y(es)?$/i.test(answer.trim())) {
@@ -5212,11 +6156,6 @@ async function confirmOrAbort(question, yes) {
5212
6156
  }
5213
6157
  }
5214
6158
 
5215
- // src/lib/staff.ts
5216
- function staffCommandsVisible(config = readConfig()) {
5217
- return config.staff === true;
5218
- }
5219
-
5220
6159
  // src/lib/ownedConfig.ts
5221
6160
  function parseCadence(raw) {
5222
6161
  const cadence = (raw ?? "NONE").trim().toUpperCase();
@@ -5406,6 +6345,181 @@ function cadenceLabel(cadence) {
5406
6345
  return cadence === "NONE" ? "manual" : cadence.toLowerCase();
5407
6346
  }
5408
6347
 
6348
+ // src/lib/runDefinitionFiles.ts
6349
+ import { execFileSync } from "child_process";
6350
+ import { createHash as createHash2 } from "crypto";
6351
+ import { isAbsolute, relative, resolve, sep } from "path";
6352
+ import { parseDocument } from "yaml";
6353
+ function git(cwd, args) {
6354
+ try {
6355
+ return execFileSync("git", args, {
6356
+ cwd,
6357
+ encoding: "buffer",
6358
+ maxBuffer: 10 * 1024 * 1024,
6359
+ stdio: ["ignore", "pipe", "pipe"]
6360
+ });
6361
+ } catch (error) {
6362
+ const detail = error && typeof error === "object" && "stderr" in error ? String(error.stderr).trim() : String(error);
6363
+ throw new CliError("usage", `git ${args[0]} failed: ${detail}`);
6364
+ }
6365
+ }
6366
+ function committedBlob(root, commit, path2) {
6367
+ return git(root, ["show", `${commit}:${path2}`]);
6368
+ }
6369
+ function decode(blob, path2) {
6370
+ try {
6371
+ return new TextDecoder("utf-8", { fatal: true }).decode(blob);
6372
+ } catch {
6373
+ throw new CliError("usage", `${path2} is not UTF-8 text`);
6374
+ }
6375
+ }
6376
+ function parseYaml(text, path2) {
6377
+ const document = parseDocument(text, { uniqueKeys: true });
6378
+ if (document.errors.length) {
6379
+ throw new CliError(
6380
+ "usage",
6381
+ `${path2}: ${document.errors.map((error) => error.message).join("; ")}`
6382
+ );
6383
+ }
6384
+ return document.toJS();
6385
+ }
6386
+ function caseFromMarkdown(path2, source) {
6387
+ const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/.exec(source);
6388
+ if (!match)
6389
+ throw new CliError(
6390
+ "usage",
6391
+ `${path2}: expected YAML frontmatter between --- lines`
6392
+ );
6393
+ const parsed = runDefinitionFrontmatterSchema.safeParse(
6394
+ parseYaml(match[1], path2)
6395
+ );
6396
+ if (!parsed.success)
6397
+ throw new CliError("usage", `${path2}: ${parsed.error.message}`);
6398
+ const prompt = match[2].trim();
6399
+ if (!prompt) throw new CliError("usage", `${path2}: Markdown body is empty`);
6400
+ return { path: path2, prompt, ...parsed.data };
6401
+ }
6402
+ function relativeGitPath(root, cwd, input) {
6403
+ if (!input || input.includes("\0") || /[*?[\]{}]/.test(input))
6404
+ throw new CliError("usage", `expected an explicit case path: ${input}`);
6405
+ const absolute = resolve(cwd, input);
6406
+ const path2 = relative(root, absolute);
6407
+ if (!path2 || path2 === ".." || path2.startsWith(`..${sep}`) || isAbsolute(path2))
6408
+ throw new CliError(
6409
+ "usage",
6410
+ `case path is outside this Git repository: ${input}`
6411
+ );
6412
+ const gitPath = path2.split(sep).join("/");
6413
+ if (!gitPath.endsWith(".md"))
6414
+ throw new CliError("usage", `case path must end in .md: ${input}`);
6415
+ return gitPath;
6416
+ }
6417
+ function loadCommittedRunDefinitionWithContext(files, cwd = process.cwd()) {
6418
+ if (files.length === 0)
6419
+ throw new CliError("usage", "--files requires at least one Markdown path");
6420
+ const root = git(cwd, ["rev-parse", "--show-toplevel"]).toString("utf8").trim();
6421
+ const commit = git(root, ["rev-parse", "--verify", "HEAD^{commit}"]).toString("utf8").trim();
6422
+ let repoUrl;
6423
+ try {
6424
+ repoUrl = git(root, ["remote", "get-url", "origin"]).toString("utf8").trim();
6425
+ } catch {
6426
+ throw new CliError(
6427
+ "usage",
6428
+ "Git origin is required to identify the committed definition repository"
6429
+ );
6430
+ }
6431
+ if (!uncredentialedRepoUrlSchema.safeParse(repoUrl).success)
6432
+ throw new CliError(
6433
+ "usage",
6434
+ "Git origin must be a repository URL without embedded credentials or query parameters"
6435
+ );
6436
+ const paths = files.map((file) => relativeGitPath(root, cwd, file));
6437
+ if (new Set(paths).size !== paths.length)
6438
+ throw new CliError("usage", "case paths must be unique");
6439
+ const blobs = [];
6440
+ let config;
6441
+ const hasConfig = git(root, ["ls-tree", "--name-only", commit, "--", "gauge.json"]).toString("utf8").trim() === "gauge.json";
6442
+ if (hasConfig) {
6443
+ try {
6444
+ const bytes = committedBlob(root, commit, "gauge.json");
6445
+ blobs.push({ path: "gauge.json", bytes });
6446
+ config = runDefinitionFileConfigSchema.parse(
6447
+ JSON.parse(decode(bytes, "gauge.json"))
6448
+ );
6449
+ } catch (error) {
6450
+ throw new CliError(
6451
+ "usage",
6452
+ `gauge.json: ${error instanceof Error ? error.message : error}`
6453
+ );
6454
+ }
6455
+ }
6456
+ const hasConventionalPrepare = git(root, ["ls-tree", "--name-only", commit, "--", ".gauge/prepare.sh"]).toString("utf8").trim() === ".gauge/prepare.sh";
6457
+ if (hasConventionalPrepare) {
6458
+ blobs.push({
6459
+ path: ".gauge/prepare.sh",
6460
+ bytes: committedBlob(root, commit, ".gauge/prepare.sh")
6461
+ });
6462
+ }
6463
+ if (config?.product && hasConventionalPrepare)
6464
+ throw new CliError(
6465
+ "usage",
6466
+ "gauge.json: product and .gauge/prepare.sh are alternatives"
6467
+ );
6468
+ const prepare = config?.prepare ?? (hasConventionalPrepare ? "bash .gauge/prepare.sh" : void 0);
6469
+ const preparation = config?.product ?? (prepare ? { run: prepare } : void 0);
6470
+ if (config?.install && !prepare)
6471
+ throw new CliError("usage", "gauge.json: install requires prepare");
6472
+ if (preparation && !repoUrl.startsWith("https://"))
6473
+ throw new CliError(
6474
+ "usage",
6475
+ "Project preparation requires a public HTTPS Git origin"
6476
+ );
6477
+ const cases = paths.map((path2) => {
6478
+ const bytes = committedBlob(root, commit, path2);
6479
+ blobs.push({ path: path2, bytes });
6480
+ return caseFromMarkdown(path2, decode(bytes, path2));
6481
+ });
6482
+ const hash = createHash2("sha256");
6483
+ hash.update("gauge-run-definition-v1\0");
6484
+ for (const entry of blobs.sort(
6485
+ (a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0
6486
+ )) {
6487
+ hash.update(entry.path);
6488
+ hash.update("\0");
6489
+ hash.update(String(entry.bytes.length));
6490
+ hash.update("\0");
6491
+ hash.update(entry.bytes);
6492
+ hash.update("\0");
6493
+ }
6494
+ const submission = runDefinitionSubmissionSchema.safeParse({
6495
+ version: 1,
6496
+ source: {
6497
+ repoUrl,
6498
+ commit,
6499
+ digest: `sha256:${hash.digest("hex")}`,
6500
+ verification: "SUBMITTED_UNVERIFIED"
6501
+ },
6502
+ resources: preparation ? [
6503
+ {
6504
+ name: "project",
6505
+ type: "prepared-directory",
6506
+ source: { type: "git-checkout", repoUrl, commit },
6507
+ prepare: preparation,
6508
+ ...config?.install ? { install: config.install } : {}
6509
+ }
6510
+ ] : [],
6511
+ cases
6512
+ });
6513
+ if (!submission.success)
6514
+ throw new CliError("usage", submission.error.message);
6515
+ return { definition: submission.data, org: config?.org };
6516
+ }
6517
+
6518
+ // src/lib/staff.ts
6519
+ function staffCommandsVisible(config = readConfig()) {
6520
+ return config.staff === true;
6521
+ }
6522
+
5409
6523
  // src/commands/evals.ts
5410
6524
  function evalSetsPath(org) {
5411
6525
  return `/api/v1/orgs/${encodeURIComponent(org)}/eval-sets`;
@@ -5484,6 +6598,40 @@ function printDetail2(e) {
5484
6598
  }
5485
6599
  function register11(program2) {
5486
6600
  const group = program2.command("evals").description("Manage eval sets (judged agent-experience measurements)");
6601
+ group.command("plan").description(
6602
+ "Validate committed Markdown cases and preview a Git-native run"
6603
+ ).requiredOption("--files <paths...>", "explicit committed Markdown paths").action(async (opts, cmd) => {
6604
+ const { definition, org: fileOrg } = loadCommittedRunDefinitionWithContext(opts.files);
6605
+ const org = resolveOrg(cmd, fileOrg);
6606
+ const result = await createClient().post(
6607
+ `/api/v1/orgs/${encodeURIComponent(org)}/run-definitions/plan`,
6608
+ definition
6609
+ );
6610
+ if (resolveOutput(cmd) === "json") {
6611
+ printJson(result);
6612
+ return;
6613
+ }
6614
+ console.log(
6615
+ `Definition: ${result.source.commit} (${result.source.digest})`
6616
+ );
6617
+ console.log(
6618
+ "Provenance: submitted by CLI; server has not verified Git bytes"
6619
+ );
6620
+ console.log(`Expected sessions: ${result.expectedRuns}`);
6621
+ for (const item of result.cases)
6622
+ console.log(
6623
+ ` ${item.path}: ${item.expectedRuns} sessions, ${item.criteriaCount} criteria`
6624
+ );
6625
+ if (result.resources.length) {
6626
+ console.log(
6627
+ `Preparations: ${result.resources.map((r) => r.name).join(", ")}`
6628
+ );
6629
+ if (!result.canRun)
6630
+ console.log(
6631
+ "Resource-backed runs cannot launch until preparation is available."
6632
+ );
6633
+ }
6634
+ });
5487
6635
  group.command("list").description("List the org's eval sets with pass-rate stats").option(
5488
6636
  "--agents <agents>",
5489
6637
  "filter stats to these agents, e.g. claude-code,codex"
@@ -5603,15 +6751,40 @@ function register11(program2) {
5603
6751
  );
5604
6752
  if (resolveOutput(cmd) !== "json") console.log(`Deleted eval set ${id}`);
5605
6753
  });
5606
- group.command("run <id>").description(
6754
+ group.command("run [id]").description(
5607
6755
  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"
5608
6756
  ).addOption(
5609
6757
  new Option2(
5610
6758
  "--bill-to-org",
5611
6759
  "bill this run to the org's credits instead (superusers)"
5612
6760
  ).hideHelp(!staffCommandsVisible())
5613
- ).option("--yes", "skip the confirmation").action(
6761
+ ).option("--files <paths...>", "explicit committed Markdown paths").option("--yes", "skip the confirmation").action(
5614
6762
  async (id, opts, cmd) => {
6763
+ if (opts.files !== void 0) {
6764
+ if (id !== void 0)
6765
+ throw new CliError(
6766
+ "usage",
6767
+ "pass either an eval ID or --files, not both"
6768
+ );
6769
+ const { definition, org: fileOrg } = loadCommittedRunDefinitionWithContext(opts.files);
6770
+ const org2 = resolveOrg(cmd, fileOrg);
6771
+ await confirmOrAbort("Run these committed eval cases now?", opts.yes);
6772
+ const result2 = await createClient().post(
6773
+ `/api/v1/orgs/${encodeURIComponent(org2)}/run-definitions/run`,
6774
+ definition,
6775
+ opts.billToOrg ? { billToOrg: true } : void 0
6776
+ );
6777
+ if (resolveOutput(cmd) === "json") printJson(result2);
6778
+ else {
6779
+ console.log(
6780
+ `Started ${result2.createdRuns}/${result2.requestedRuns} sessions in request ${result2.runRequestId}`
6781
+ );
6782
+ console.log(`Wait: gauge run-requests wait ${result2.runRequestId}`);
6783
+ }
6784
+ return;
6785
+ }
6786
+ if (id === void 0)
6787
+ throw new CliError("usage", "pass an eval ID or --files <paths...>");
5615
6788
  const org = resolveOrg(cmd);
5616
6789
  await confirmOrAbort(
5617
6790
  "Run this eval's stored configuration now?",
@@ -5707,7 +6880,7 @@ function rewriteContentType(path2, explicit) {
5707
6880
  return REWRITE_FILE_CONTENT_TYPES[extname(path2).toLowerCase()];
5708
6881
  }
5709
6882
  function sleep2(ms) {
5710
- return new Promise((resolve) => setTimeout(resolve, ms));
6883
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
5711
6884
  }
5712
6885
  function toRow3(e) {
5713
6886
  return {
@@ -6716,10 +7889,11 @@ __export(optimizations_exports2, {
6716
7889
  readSkillDir: () => readSkillDir,
6717
7890
  register: () => register19,
6718
7891
  trialBodyFromOpts: () => trialBodyFromOpts,
6719
- trialTemplate: () => trialTemplate
7892
+ trialTemplate: () => trialTemplate,
7893
+ watchStops: () => watchStops
6720
7894
  });
6721
7895
  import { readdirSync, readFileSync as readFileSync9, statSync } from "fs";
6722
- import { join as join4, relative, sep } from "path";
7896
+ import { join as join4, relative as relative2, sep as sep2 } from "path";
6723
7897
  var TERMINAL2 = /* @__PURE__ */ new Set(["DONE", "ARCHIVED"]);
6724
7898
  var EFFORTS = ["low", "medium", "high", "xhigh"];
6725
7899
  function basePath(org) {
@@ -6735,7 +7909,7 @@ function readText2(path2) {
6735
7909
  return readFileSync9(path2 === "-" ? 0 : path2, "utf8");
6736
7910
  }
6737
7911
  function sleep3(ms) {
6738
- return new Promise((resolve) => setTimeout(resolve, ms));
7912
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
6739
7913
  }
6740
7914
  function parseSubject(opts) {
6741
7915
  if (opts.eval && opts.preference)
@@ -6788,11 +7962,14 @@ var NEXT_ACTION_HINT = {
6788
7962
  LAUNCH_ROUND: "launch the saved round: `gauge optimizations launch <id>`",
6789
7963
  ADOPT: "adopt the winning trial: `gauge optimizations adopt <id> <trial>`",
6790
7964
  RESUME: "resume it: `gauge optimizations resume <id>`",
6791
- NONE: "finished"
7965
+ NONE: "nothing to do in Gauge"
6792
7966
  };
6793
7967
  function awaitingInput(detail) {
6794
7968
  return detail.nextAction !== "WAIT" && detail.nextAction !== "NONE";
6795
7969
  }
7970
+ function watchStops(detail, follow) {
7971
+ return TERMINAL2.has(detail.status) || detail.nextAction === "NONE" || !follow && awaitingInput(detail);
7972
+ }
6796
7973
  function readObject(path2) {
6797
7974
  let value;
6798
7975
  try {
@@ -6834,7 +8011,7 @@ function readSkillDir(dir, read = readText2, walk = listFiles) {
6834
8011
  if (!paths.length)
6835
8012
  throw new CliError("usage", `no files under ${dir} to send`);
6836
8013
  const files = paths.map((path2) => ({
6837
- path: relative(dir, path2).split(sep).join("/"),
8014
+ path: relative2(dir, path2).split(sep2).join("/"),
6838
8015
  body: read(path2)
6839
8016
  }));
6840
8017
  if (!files.some((file) => file.path === "SKILL.md"))
@@ -7468,13 +8645,13 @@ function register19(program2) {
7468
8645
  for (; ; ) {
7469
8646
  const detail = await client.get(itemPath2(org, id));
7470
8647
  const trials2 = detail.rounds.flatMap((round) => round.trials);
7471
- const line = `${detail.status} \xB7 round ${detail.round}/${detail.maxRounds} \xB7 ${pct(detail.before)} \u2192 ${pct(detail.after)} \xB7 ${detail.creditsSpent} credits spent \xB7 ${trials2.filter((t) => t.status === "RUNNING").map((t) => t.key).join(",") || "idle"}`;
8648
+ const line = `${detail.status}${detail.stopReason ? ` (${detail.stopReason})` : ""} \xB7 round ${detail.round}/${detail.maxRounds} \xB7 ${pct(detail.before)} \u2192 ${pct(detail.after)} \xB7 ${detail.creditsSpent} credits spent \xB7 ${trials2.filter((t) => t.status === "RUNNING").map((t) => t.key).join(",") || "idle"}`;
7472
8649
  if (line !== last) {
7473
8650
  last = line;
7474
8651
  console.error(line);
7475
8652
  }
7476
8653
  const needsInput = awaitingInput(detail);
7477
- if (TERMINAL2.has(detail.status) || !opts.follow && needsInput) {
8654
+ if (watchStops(detail, !!opts.follow)) {
7478
8655
  if (resolveOutput(cmd) === "json") printJson(detail);
7479
8656
  else printDetail4(detail);
7480
8657
  if (needsInput) process.exitCode = NEEDS_INPUT_EXIT;
@@ -8159,10 +9336,48 @@ function register24(program2) {
8159
9336
  });
8160
9337
  }
8161
9338
 
9339
+ // src/commands/runRequests.ts
9340
+ var runRequests_exports2 = {};
9341
+ __export(runRequests_exports2, {
9342
+ register: () => register25
9343
+ });
9344
+ var pollIntervalMs = 5e3;
9345
+ function register25(program2) {
9346
+ 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) => {
9347
+ const org = resolveOrg(cmd);
9348
+ const path2 = `/api/v1/orgs/${encodeURIComponent(org)}/run-requests/${encodeURIComponent(id)}`;
9349
+ const client = createClient();
9350
+ let lastStatus = "";
9351
+ while (true) {
9352
+ const result = await client.get(path2);
9353
+ if (resolveOutput(cmd) !== "json" && result.status !== lastStatus) {
9354
+ console.error(`Run request ${id}: ${result.status}`);
9355
+ lastStatus = result.status;
9356
+ }
9357
+ if (result.settled) {
9358
+ if (resolveOutput(cmd) === "json") printJson(result);
9359
+ else {
9360
+ console.log(
9361
+ `${result.result}: ${result.counts.passedRuns}/${result.counts.createdRuns} passed sessions (${result.counts.judgedRuns} judged)`
9362
+ );
9363
+ console.log(`Request: ${result.id}`);
9364
+ }
9365
+ if (result.result !== "PASSED")
9366
+ throw new CliError(
9367
+ "internal",
9368
+ `Run request ${id}: ${result.result}`
9369
+ );
9370
+ return;
9371
+ }
9372
+ await new Promise((resolve2) => setTimeout(resolve2, pollIntervalMs));
9373
+ }
9374
+ });
9375
+ }
9376
+
8162
9377
  // src/commands/runs.ts
8163
9378
  var runs_exports2 = {};
8164
9379
  __export(runs_exports2, {
8165
- register: () => register25
9380
+ register: () => register26
8166
9381
  });
8167
9382
  function runPath(id) {
8168
9383
  return `/api/v1/runs/${encodeURIComponent(id)}`;
@@ -8422,7 +9637,7 @@ async function streamRun(id, json, opts) {
8422
9637
  if (drainTimer) clearTimeout(drainTimer);
8423
9638
  }
8424
9639
  }
8425
- function register25(program2) {
9640
+ function register26(program2) {
8426
9641
  const runs = program2.command("runs").description("Inspect and manage runs");
8427
9642
  runs.command("list").description("List runs (newest first)").option("--status <status>", "filter by status, e.g. running,queued").option("--batch <id>", "filter by batch").option("--prompt <id>", "filter by prompt").option("--experiment <experiment>", "filter by experiment label").option("--eval-set <id>", "filter by eval set").option("--since <window>", "e.g. 24h, 7d, or an ISO date").option("--limit <n>", "page size (1-200)", "50").option("--cursor <cursor>", "resume from a previous page's nextCursor").action(
8428
9643
  async (opts, command) => {
@@ -8561,7 +9776,7 @@ function register25(program2) {
8561
9776
  var skills_exports2 = {};
8562
9777
  __export(skills_exports2, {
8563
9778
  buildSkillEditBody: () => buildSkillEditBody,
8564
- register: () => register26
9779
+ register: () => register27
8565
9780
  });
8566
9781
  function skillsPath(org) {
8567
9782
  return `/api/v1/orgs/${encodeURIComponent(org)}/skills`;
@@ -8623,7 +9838,7 @@ async function buildSkillEditBody(opts, fetchCurrentSource) {
8623
9838
  throw new CliError("usage", "nothing to change");
8624
9839
  return body;
8625
9840
  }
8626
- function register26(program2) {
9841
+ function register27(program2) {
8627
9842
  const group = program2.command("skills").description("Manage agent skills used by eval and visibility runs");
8628
9843
  group.command("list").description("List the org's skills with their newest version").action(async (_opts, cmd) => {
8629
9844
  const org = resolveOrg(cmd);
@@ -8764,7 +9979,7 @@ function register26(program2) {
8764
9979
  // src/commands/stats.ts
8765
9980
  var stats_exports2 = {};
8766
9981
  __export(stats_exports2, {
8767
- register: () => register27
9982
+ register: () => register28
8768
9983
  });
8769
9984
  function addFilterOptions(cmd) {
8770
9985
  return cmd.option("--prompt <id>", "filter to a single prompt").option("--tag <ids>", "comma-separated tag ids").option("--repo <urls>", "comma-separated base repo urls").option("--language <langs>", "comma-separated repo languages").option("--framework <names>", "comma-separated repo frameworks").option("--size <buckets>", "comma-separated codebase-size buckets").option("--branded", "only branded prompts").option("--unbranded", "only non-branded prompts").option("--limit <n>", "max rows (default 50)").option("--full", "return all rows (up to 1000)");
@@ -8847,7 +10062,7 @@ var domainRow = (r) => ({
8847
10062
  rate: pct3(r.rate),
8848
10063
  requests: r.requests
8849
10064
  });
8850
- function register27(program2) {
10065
+ function register28(program2) {
8851
10066
  const group = program2.command("stats").description("Read-only analytics over your runs");
8852
10067
  addFilterOptions(
8853
10068
  group.command("rankings").description("Brands ranked by install rate")
@@ -8879,7 +10094,7 @@ function register27(program2) {
8879
10094
  // src/commands/status.ts
8880
10095
  var status_exports = {};
8881
10096
  __export(status_exports, {
8882
- register: () => register28
10097
+ register: () => register29
8883
10098
  });
8884
10099
  function pct4(rate) {
8885
10100
  return rate == null ? "\u2014" : `${Math.round(rate * 100)}%`;
@@ -8889,7 +10104,7 @@ function delta2(pp) {
8889
10104
  const rounded = Math.round(pp);
8890
10105
  return rounded === 0 ? "" : ` (${rounded > 0 ? "+" : ""}${rounded}pp)`;
8891
10106
  }
8892
- function register28(program2) {
10107
+ function register29(program2) {
8893
10108
  program2.command("status").description("One-shot org summary: actions, visibility, agent experience").action(async (_opts, cmd) => {
8894
10109
  const org = resolveOrg(cmd);
8895
10110
  const s = await createClient().get(
@@ -8951,12 +10166,12 @@ function register28(program2) {
8951
10166
  // src/commands/tags.ts
8952
10167
  var tags_exports2 = {};
8953
10168
  __export(tags_exports2, {
8954
- register: () => register29
10169
+ register: () => register30
8955
10170
  });
8956
10171
  function tagsPath(org) {
8957
10172
  return `/api/v1/orgs/${encodeURIComponent(org)}/tags`;
8958
10173
  }
8959
- function register29(program2) {
10174
+ function register30(program2) {
8960
10175
  const group = program2.command("tags").description("Manage org tags");
8961
10176
  group.command("list").description("List tags").action(async (_opts, cmd) => {
8962
10177
  const org = resolveOrg(cmd);
@@ -8999,9 +10214,9 @@ function register29(program2) {
8999
10214
  // src/commands/usage.ts
9000
10215
  var usage_exports = {};
9001
10216
  __export(usage_exports, {
9002
- register: () => register30
10217
+ register: () => register31
9003
10218
  });
9004
- function register30(program2) {
10219
+ function register31(program2) {
9005
10220
  program2.command("usage").description("List credit ledger entries").option("--since <window>", 'e.g. "30d", "24h", or an ISO date').option("--limit <n>", "page size (1-200)", parseLimit, 50).option("--cursor <cursor>", "resume from a previous page's nextCursor").action(
9006
10221
  async (opts, cmd) => {
9007
10222
  const org = resolveOrg(cmd);
@@ -9048,7 +10263,7 @@ function register30(program2) {
9048
10263
  // src/commands/visibility.ts
9049
10264
  var visibility_exports2 = {};
9050
10265
  __export(visibility_exports2, {
9051
- register: () => register31,
10266
+ register: () => register32,
9052
10267
  visibilityPath: () => visibilityPath
9053
10268
  });
9054
10269
  import { Option as Option3 } from "commander";
@@ -9404,7 +10619,7 @@ function registerPreferenceGroup(group) {
9404
10619
  );
9405
10620
  });
9406
10621
  }
9407
- function register31(program2) {
10622
+ function register32(program2) {
9408
10623
  const preference = program2.command("preference").description("Manage Agent Preference prompts and measured markets");
9409
10624
  registerPreferenceGroup(preference);
9410
10625
  const legacy = program2.command("visibility", { hidden: true });
@@ -9438,6 +10653,7 @@ for (const group of [
9438
10653
  connections_exports2,
9439
10654
  repos_exports2,
9440
10655
  runs_exports2,
10656
+ runRequests_exports2,
9441
10657
  optimizations_exports2,
9442
10658
  experiments_exports2,
9443
10659
  apply_exports,