@withgauge/cli 0.11.2 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +95 -0
  2. package/dist/index.js +1966 -594
  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,578 @@ 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";
2570
+
2571
+ // ../packages/api-schemas/src/cli-interventions.ts
2572
+ import { z as z28 } from "zod";
2573
+ var digest = z28.string().regex(/^[a-f0-9]{64}$/);
2574
+ var token = z28.string().min(1).max(4096);
2575
+ var optionFlag = z28.string().regex(/^--?[A-Za-z0-9][A-Za-z0-9-]*$/);
2576
+ var envKey = z28.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/);
2577
+ var relativePath = z28.string().min(1).max(1024).refine(
2578
+ (path2) => !path2.startsWith("/") && !path2.includes("\\") && !path2.includes("\0") && path2.split("/").every(
2579
+ (part) => part && part !== "." && part !== ".." && ![".git", "node_modules", ".pnpm", ".yarn", ".venv"].includes(part)
2580
+ ),
2581
+ "Use a workspace-relative path without traversal"
2582
+ );
2583
+ var sourcedValue = z28.discriminatedUnion("source", [
2584
+ z28.object({ source: z28.literal("literal"), value: z28.string().max(8192) }).strict(),
2585
+ z28.object({ source: z28.literal("localFact"), key: envKey }).strict()
2586
+ ]);
2587
+ var cliLaunchFormSchema = z28.enum([
2588
+ "native",
2589
+ "path",
2590
+ "symlink",
2591
+ "shebang",
2592
+ "node-script",
2593
+ "python-script",
2594
+ "python-module",
2595
+ "execveat-path",
2596
+ "execveat-fd"
2597
+ ]);
2598
+ var cliObservationReasonSchema = z28.enum([
2599
+ "eligible",
2600
+ "other-target",
2601
+ "other-command",
2602
+ "selector-mismatch",
2603
+ "unknown-command",
2604
+ "identity-unresolved",
2605
+ "artifact-mismatch",
2606
+ "runtime-mismatch",
2607
+ "launch-form",
2608
+ "io-profile",
2609
+ "operation-profile",
2610
+ "descriptor-lifetime"
2611
+ ]);
2612
+ var cliIoProfileSchema = z28.enum([
2613
+ "pipes",
2614
+ "redirected",
2615
+ "shared-descriptor",
2616
+ "pty"
2617
+ ]);
2618
+ var cliObservationSchema = z28.object({
2619
+ invocationId: z28.string().regex(/^[a-f0-9]{32}$/),
2620
+ targetId: token,
2621
+ commandId: token.nullable(),
2622
+ entrypointSha256: digest,
2623
+ runtimeSha256: digest.nullable(),
2624
+ launchForm: cliLaunchFormSchema.nullable(),
2625
+ ioProfile: cliIoProfileSchema.nullable(),
2626
+ reason: cliObservationReasonSchema
2627
+ });
2628
+ var cliCoverageSchema = z28.object({
2629
+ attempt: z28.number().int().nonnegative(),
2630
+ observedInvocationCount: z28.number().int().nonnegative().nullable(),
2631
+ invocationCount: z28.number().int().nonnegative(),
2632
+ appliedInvocationCount: z28.number().int().nonnegative(),
2633
+ incompleteCount: z28.number().int().nonnegative(),
2634
+ unsupportedCount: z28.number().int().nonnegative(),
2635
+ instrumentationFailed: z28.boolean(),
2636
+ observations: z28.array(cliObservationSchema),
2637
+ unsupportedDiagnostics: z28.array(z28.string())
2638
+ });
2639
+ var cliOperationKindSchema = z28.enum([
2640
+ "ensureOption",
2641
+ "replaceOption",
2642
+ "setEnv",
2643
+ "streamOutput",
2644
+ "completeOutput",
2645
+ "structuredStdin",
2646
+ "promptRecipe",
2647
+ "generatedFile"
2648
+ ]);
2649
+ var commandCapabilitiesSchema = z28.object({
2650
+ operations: z28.array(cliOperationKindSchema).max(8),
2651
+ options: z28.array(z28.object({ flag: optionFlag, takesValue: z28.boolean() }).strict()).max(100).default([]),
2652
+ settings: z28.array(envKey).max(100).default([]),
2653
+ localFacts: z28.array(envKey).max(30).default([]),
2654
+ generatedPaths: z28.array(relativePath).max(50).default([]),
2655
+ outputModes: z28.array(z28.enum(["streaming", "completed"])).max(2).default([]),
2656
+ stdinFormats: z28.array(z28.enum(["text", "json", "jsonl"])).max(3).default([]),
2657
+ recipeIds: z28.array(token).max(50).default([])
2658
+ }).strict();
2659
+ var cliTargetSchema = z28.object({
2660
+ id: token,
2661
+ vendor: token,
2662
+ package: token,
2663
+ version: token.nullable(),
2664
+ /** Published artifact identity and exact executable/entrypoint identity. */
2665
+ artifactSha256: digest.nullable(),
2666
+ entrypointSha256: digest.nullable(),
2667
+ /** Trace-derived recognition hints. Actual bytes are captured by record mode. */
2668
+ discovery: z28.object({
2669
+ ecosystem: token.nullable(),
2670
+ program: token,
2671
+ executables: z28.array(token).max(20)
2672
+ }).strict().optional(),
2673
+ ownershipEvidence: z28.string().min(1).max(2048),
2674
+ entrypoints: z28.array(z28.string().min(1).max(1024)).max(20),
2675
+ /** Flags accepted before the subcommand, with explicit value arity. */
2676
+ globalOptions: z28.array(z28.object({ flag: optionFlag, takesValue: z28.boolean() }).strict()).max(100),
2677
+ launchForms: z28.array(cliLaunchFormSchema).min(1),
2678
+ ioProfiles: z28.array(cliIoProfileSchema).min(1),
2679
+ commands: z28.array(
2680
+ z28.object({
2681
+ id: token,
2682
+ /** Tokens following global options, before a literal `--`. */
2683
+ subcommand: z28.array(token).max(8),
2684
+ capabilities: commandCapabilitiesSchema
2685
+ }).strict()
2686
+ ).min(1)
2687
+ }).strict().superRefine((target, ctx) => {
2688
+ if (!target.discovery && (!target.version || !target.artifactSha256 || !target.entrypointSha256 || !target.entrypoints.length))
2689
+ ctx.addIssue({
2690
+ code: "custom",
2691
+ message: "Registered targets need complete artifact identities"
2692
+ });
2693
+ if (target.discovery && (target.artifactSha256 !== null || target.entrypointSha256 !== null))
2694
+ ctx.addIssue({
2695
+ code: "custom",
2696
+ message: "Discovered targets learn bytes from baseline invocations"
2697
+ });
2698
+ for (const [index, command] of target.commands.entries()) {
2699
+ if (target.commands.findIndex((other) => other.id === command.id) !== index)
2700
+ ctx.addIssue({
2701
+ code: "custom",
2702
+ path: ["commands", index, "id"],
2703
+ message: "Duplicate command ID"
2704
+ });
2705
+ const { capabilities } = command;
2706
+ if (new Set(capabilities.operations).size !== capabilities.operations.length)
2707
+ ctx.addIssue({
2708
+ code: "custom",
2709
+ path: ["commands", index, "capabilities", "operations"],
2710
+ message: "Duplicate operation"
2711
+ });
2712
+ const requires = (kind, valid, message) => {
2713
+ if (capabilities.operations.includes(kind) && !valid)
2714
+ ctx.addIssue({
2715
+ code: "custom",
2716
+ path: ["commands", index, "capabilities", "operations"],
2717
+ message
2718
+ });
2719
+ };
2720
+ requires(
2721
+ "streamOutput",
2722
+ capabilities.outputModes.includes("streaming"),
2723
+ "Streaming output needs a qualified streaming mode"
2724
+ );
2725
+ requires(
2726
+ "completeOutput",
2727
+ capabilities.outputModes.includes("completed"),
2728
+ "Completed output needs a qualified completed mode"
2729
+ );
2730
+ requires(
2731
+ "structuredStdin",
2732
+ capabilities.stdinFormats.length > 0,
2733
+ "Structured stdin needs a qualified format"
2734
+ );
2735
+ requires(
2736
+ "promptRecipe",
2737
+ capabilities.recipeIds.length > 0,
2738
+ "Prompt recipes need qualified prompt IDs"
2739
+ );
2740
+ requires(
2741
+ "generatedFile",
2742
+ capabilities.generatedPaths.length > 0,
2743
+ "Generated files need attributed output paths"
2744
+ );
2745
+ requires(
2746
+ "setEnv",
2747
+ capabilities.settings.length > 0,
2748
+ "Environment changes need supported settings"
2749
+ );
2750
+ requires(
2751
+ "ensureOption",
2752
+ capabilities.options.length > 0,
2753
+ "Arguments need supported options"
2754
+ );
2755
+ requires(
2756
+ "replaceOption",
2757
+ capabilities.options.length > 0,
2758
+ "Arguments need supported options"
2759
+ );
2760
+ }
2761
+ });
2762
+ var CLI_CATALOG_MAX_TARGETS = 100;
2763
+ var cliCatalogSchema = z28.object({
2764
+ version: z28.union([z28.literal(1), z28.literal(2)]),
2765
+ engineVersion: token,
2766
+ digest,
2767
+ targets: z28.array(cliTargetSchema).max(CLI_CATALOG_MAX_TARGETS)
2768
+ }).strict().superRefine((catalog, ctx) => {
2769
+ if (catalog.version === 1 && (!catalog.targets.length || catalog.targets.some((target) => target.discovery)))
2770
+ ctx.addIssue({
2771
+ code: "custom",
2772
+ message: "Discovery requires catalog version 2"
2773
+ });
2774
+ catalog.targets.forEach((target, index) => {
2775
+ if (catalog.targets.findIndex((other) => other.id === target.id) !== index)
2776
+ ctx.addIssue({
2777
+ code: "custom",
2778
+ path: ["targets", index, "id"],
2779
+ message: "Duplicate target ID"
2780
+ });
2781
+ });
2782
+ });
2783
+ var exitPredicate = z28.discriminatedUnion("kind", [
2784
+ z28.object({ kind: z28.literal("any") }).strict(),
2785
+ z28.object({
2786
+ kind: z28.literal("code"),
2787
+ value: z28.number().int().min(0).max(255)
2788
+ }).strict()
2789
+ ]);
2790
+ var outputStream = z28.enum(["stdout", "stderr", "combined"]);
2791
+ var literalEdit = z28.object({ find: z28.string().min(1).max(8192), replace: z28.string().max(8192) }).strict();
2792
+ function boundedOutputPattern(pattern) {
2793
+ let at = pattern.startsWith("^") ? 1 : 0;
2794
+ const end = pattern.endsWith("$") && pattern.length > at ? pattern.length - 1 : pattern.length;
2795
+ let stars = 0;
2796
+ let literalBytes = 0;
2797
+ while (at < end) {
2798
+ const char = pattern[at];
2799
+ if (char === "\\") {
2800
+ if (++at >= end || !"\\.^$*+?[]{}()|".includes(pattern[at])) return false;
2801
+ literalBytes++;
2802
+ } else if (char === "." && pattern[at + 1] === "*") {
2803
+ if (++stars > 1) return false;
2804
+ at++;
2805
+ } else if (".^$*+?[]{}()|\n\r".includes(char)) {
2806
+ return false;
2807
+ } else {
2808
+ literalBytes++;
2809
+ }
2810
+ at++;
2811
+ }
2812
+ return literalBytes > 0;
2813
+ }
2814
+ var operationSchema = z28.discriminatedUnion("kind", [
2815
+ z28.object({
2816
+ kind: z28.literal("ensureOption"),
2817
+ option: optionFlag,
2818
+ value: sourcedValue.optional()
2819
+ }).strict(),
2820
+ z28.object({
2821
+ kind: z28.literal("replaceOption"),
2822
+ option: optionFlag,
2823
+ value: sourcedValue
2824
+ }).strict(),
2825
+ z28.object({
2826
+ kind: z28.literal("setEnv"),
2827
+ key: envKey,
2828
+ value: sourcedValue,
2829
+ whenAbsent: z28.boolean()
2830
+ }).strict(),
2831
+ z28.object({
2832
+ kind: z28.literal("streamOutput"),
2833
+ stream: outputStream,
2834
+ edit: literalEdit
2835
+ }).strict(),
2836
+ z28.object({
2837
+ kind: z28.literal("completeOutput"),
2838
+ stream: outputStream,
2839
+ matcher: z28.discriminatedUnion("kind", [
2840
+ z28.object({
2841
+ kind: z28.literal("literal"),
2842
+ text: z28.string().min(1).max(8192)
2843
+ }).strict(),
2844
+ z28.object({
2845
+ kind: z28.literal("re2"),
2846
+ pattern: z28.string().min(1).max(2048).refine(
2847
+ boundedOutputPattern,
2848
+ "Use literals, anchors, and at most one greedy .*; escape literal regex punctuation"
2849
+ )
2850
+ }).strict()
2851
+ ]),
2852
+ replace: z28.string().max(8192),
2853
+ exit: exitPredicate
2854
+ }).strict(),
2855
+ z28.object({
2856
+ kind: z28.literal("structuredStdin"),
2857
+ format: z28.enum(["text", "json", "jsonl"]),
2858
+ payload: sourcedValue,
2859
+ timing: z28.literal("onLaunch"),
2860
+ callerInput: z28.literal("replace"),
2861
+ eof: z28.literal("close")
2862
+ }).strict(),
2863
+ z28.object({
2864
+ kind: z28.literal("promptRecipe"),
2865
+ recipeId: token,
2866
+ steps: z28.array(
2867
+ z28.object({
2868
+ prompt: z28.string().min(1).max(4096),
2869
+ response: sourcedValue,
2870
+ timeoutMs: z28.number().int().min(1).max(12e4)
2871
+ }).strict()
2872
+ ).min(1).max(20),
2873
+ overallTimeoutMs: z28.number().int().min(1).max(6e5),
2874
+ completion: z28.string().min(1).max(4096)
2875
+ }).strict(),
2876
+ z28.object({
2877
+ kind: z28.literal("generatedFile"),
2878
+ path: relativePath,
2879
+ beforeSha256: digest.nullable(),
2880
+ generatedSha256: digest,
2881
+ outcome: exitPredicate,
2882
+ edit: literalEdit,
2883
+ required: z28.boolean()
2884
+ }).strict()
2885
+ ]);
2886
+ var cliBaselineRecordFileSchema = z28.object({
2887
+ pathIndex: z28.number().int().nonnegative().max(49),
2888
+ path: relativePath,
2889
+ status: z28.enum(["generated", "not-exercised"]),
2890
+ beforeSha256: digest.nullable(),
2891
+ generatedSha256: digest.nullable()
2892
+ }).strict();
2893
+ var baselineInvocationSchema = z28.object({
2894
+ runId: token,
2895
+ invocationId: token,
2896
+ targetId: token,
2897
+ commandId: token,
2898
+ artifactSha256: digest.nullable(),
2899
+ entrypointSha256: digest,
2900
+ engineSha256: digest.optional(),
2901
+ runtimeSha256: digest.optional(),
2902
+ launchForm: cliLaunchFormSchema,
2903
+ ioProfile: cliIoProfileSchema,
2904
+ recordFiles: z28.array(cliBaselineRecordFileSchema).max(50).default([])
2905
+ }).strict();
2906
+ var cliInterventionSchema = z28.object({
2907
+ schemaVersion: z28.union([z28.literal(1), z28.literal(2)]),
2908
+ identityPolicy: z28.literal("artifact").optional(),
2909
+ engineVersion: token,
2910
+ engineSha256: digest.nullable(),
2911
+ bundleSha256: digest,
2912
+ catalog: cliCatalogSchema,
2913
+ mode: z28.enum(["record", "trial"]),
2914
+ captureProfiles: z28.array(cliIoProfileSchema).min(1),
2915
+ activeTargetId: token.nullable(),
2916
+ activeCommandId: token.nullable(),
2917
+ selector: z28.object({
2918
+ optionPresent: z28.array(optionFlag).max(20),
2919
+ optionAbsent: z28.array(optionFlag).max(20)
2920
+ }).strict().nullable(),
2921
+ baselineInvocations: z28.array(baselineInvocationSchema).max(500),
2922
+ operations: z28.array(operationSchema).max(50),
2923
+ limits: z28.object({
2924
+ completedStreamBytes: z28.number().int().min(1).max(2 * 1024 * 1024),
2925
+ replacementBytes: z28.number().int().min(1).max(8192),
2926
+ generatedFileBytes: z28.number().int().min(1).max(2 * 1024 * 1024),
2927
+ generatedAggregateBytes: z28.number().int().min(1).max(8 * 1024 * 1024),
2928
+ generatedFileCount: z28.number().int().min(1).max(50)
2929
+ }).strict(),
2930
+ shippingIntent: z28.enum([
2931
+ "default",
2932
+ "message",
2933
+ "interaction",
2934
+ "invocation-guidance",
2935
+ "template"
2936
+ ]).nullable()
2937
+ }).strict().superRefine((bundle, ctx) => {
2938
+ const fail = (path2, message) => ctx.addIssue({ code: "custom", path: path2, message });
2939
+ if (bundle.schemaVersion !== bundle.catalog.version)
2940
+ fail(["schemaVersion"], "Bundle and catalog schema versions differ");
2941
+ if (bundle.identityPolicy && bundle.schemaVersion !== 2)
2942
+ fail(["identityPolicy"], "Artifact identity requires schema version 2");
2943
+ if (bundle.identityPolicy && bundle.baselineInvocations.some((row2) => !row2.runtimeSha256))
2944
+ fail(
2945
+ ["baselineInvocations"],
2946
+ "Artifact identity requires the recorded runtime bytes"
2947
+ );
2948
+ if (!bundle.engineSha256 && (bundle.schemaVersion === 1 || bundle.mode !== "record"))
2949
+ fail(["engineSha256"], "A trial must pin the recorded engine bytes");
2950
+ if (!bundle.catalog.targets.length)
2951
+ fail(["catalog"], "A run needs at least one CLI target");
2952
+ if (bundle.schemaVersion === 2 && bundle.mode === "trial" && bundle.baselineInvocations.some(
2953
+ (item) => item.engineSha256 !== bundle.engineSha256
2954
+ ))
2955
+ fail(
2956
+ ["baselineInvocations"],
2957
+ "Baseline invocations must share the pinned engine"
2958
+ );
2959
+ bundle.baselineInvocations.forEach((invocation, index) => {
2960
+ const command2 = bundle.catalog.targets.find((target2) => target2.id === invocation.targetId)?.commands.find((item) => item.id === invocation.commandId);
2961
+ for (const [fileIndex, file] of invocation.recordFiles.entries()) {
2962
+ if (command2?.capabilities.generatedPaths[file.pathIndex] !== file.path || file.status === "generated" && !file.generatedSha256 || file.status === "not-exercised" && file.generatedSha256 !== file.beforeSha256)
2963
+ fail(
2964
+ ["baselineInvocations", index, "recordFiles", fileIndex],
2965
+ "Recorded file does not match the qualified command"
2966
+ );
2967
+ }
2968
+ });
2969
+ if (bundle.engineVersion !== bundle.catalog.engineVersion)
2970
+ fail(["engineVersion"], "Engine and catalog versions differ");
2971
+ if (bundle.mode === "record") {
2972
+ if (bundle.activeTargetId || bundle.activeCommandId || bundle.selector || bundle.operations.length || bundle.shippingIntent)
2973
+ fail(["mode"], "Record mode cannot select or modify a command");
2974
+ return;
2975
+ }
2976
+ const target = bundle.catalog.targets.find(
2977
+ (item) => item.id === bundle.activeTargetId
2978
+ );
2979
+ const command = target?.commands.find(
2980
+ (item) => item.id === bundle.activeCommandId
2981
+ );
2982
+ if (!target || !command) {
2983
+ fail(
2984
+ ["activeCommandId"],
2985
+ "Select a qualified command in the frozen catalog"
2986
+ );
2987
+ return;
2988
+ }
2989
+ if (!bundle.selector) fail(["selector"], "A trial needs token predicates");
2990
+ else {
2991
+ for (const flag of [
2992
+ ...bundle.selector.optionPresent,
2993
+ ...bundle.selector.optionAbsent
2994
+ ])
2995
+ if (!command.capabilities.options.some((option) => option.flag === flag))
2996
+ fail(["selector"], `Unsupported selector option: ${flag}`);
2997
+ if (bundle.selector.optionPresent.some(
2998
+ (flag) => bundle.selector?.optionAbsent.includes(flag)
2999
+ ))
3000
+ fail(
3001
+ ["selector"],
3002
+ "A selector cannot require and forbid the same option"
3003
+ );
3004
+ }
3005
+ if (!bundle.shippingIntent || !bundle.operations.length)
3006
+ fail(
3007
+ ["operations"],
3008
+ "A trial needs a shipping intent and at least one operation"
3009
+ );
3010
+ if (bundle.operations.some((item) => item.kind === "promptRecipe") && bundle.operations.some((item) => item.kind === "completeOutput"))
3011
+ fail(
3012
+ ["operations"],
3013
+ "Completed-output buffering cannot block an interactive prompt"
3014
+ );
3015
+ if (bundle.captureProfiles.includes("pty")) {
3016
+ for (const [index, operation] of bundle.operations.entries()) {
3017
+ if (operation.kind === "structuredStdin")
3018
+ fail(
3019
+ ["operations", index],
3020
+ "PTY structured stdin cannot prove the declared EOF; use a prompt recipe"
3021
+ );
3022
+ if ((operation.kind === "streamOutput" || operation.kind === "completeOutput") && operation.stream !== "combined")
3023
+ fail(["operations", index], "PTY output combines stdout and stderr");
3024
+ }
3025
+ }
3026
+ if (bundle.operations.some((item) => item.kind === "promptRecipe") && bundle.operations.some((item) => item.kind === "structuredStdin"))
3027
+ fail(
3028
+ ["operations"],
3029
+ "A prompt recipe and structured stdin cannot both control the same input stream"
3030
+ );
3031
+ if (bundle.operations.some(
3032
+ (item) => (item.kind === "streamOutput" || item.kind === "completeOutput") && item.stream === "combined"
3033
+ ) && !bundle.baselineInvocations.some(
3034
+ (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)
3035
+ ))
3036
+ fail(
3037
+ ["operations"],
3038
+ "Combined output requires a shared-descriptor or PTY baseline profile"
3039
+ );
3040
+ if (!bundle.baselineInvocations.some(
3041
+ (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)
3042
+ ))
3043
+ fail(
3044
+ ["baselineInvocations"],
3045
+ "No baseline invocation matches this exact command, artifact, launch form, and I/O profile"
3046
+ );
3047
+ const seen = /* @__PURE__ */ new Set();
3048
+ const changedEnvironment = new Set(
3049
+ bundle.operations.flatMap(
3050
+ (item) => item.kind === "setEnv" ? [item.key] : []
3051
+ )
3052
+ );
3053
+ bundle.operations.forEach((operation, index) => {
3054
+ const path2 = ["operations", index];
3055
+ if (!command.capabilities.operations.includes(operation.kind))
3056
+ fail(path2, `${operation.kind} is not qualified for this command`);
3057
+ if ("option" in operation && !command.capabilities.options.some(
3058
+ (option) => option.flag === operation.option
3059
+ ))
3060
+ fail(path2, "Option is not supported by this version");
3061
+ if (operation.kind === "ensureOption" || operation.kind === "replaceOption") {
3062
+ const option = command.capabilities.options.find(
3063
+ (item) => item.flag === operation.option
3064
+ );
3065
+ if (option && option.takesValue !== (operation.value !== void 0))
3066
+ fail(path2, "Option value does not match its qualified arity");
3067
+ }
3068
+ if (operation.kind === "setEnv" && !command.capabilities.settings.includes(operation.key))
3069
+ fail(path2, "Environment setting is not supported by this version");
3070
+ if (operation.kind === "structuredStdin" && !command.capabilities.stdinFormats.includes(operation.format))
3071
+ fail(path2, "Stdin format is not qualified");
3072
+ if (operation.kind === "structuredStdin" && operation.payload.source === "literal" && operation.format !== "text") {
3073
+ const records = operation.format === "json" ? [operation.payload.value] : operation.payload.value.trimEnd().split("\n");
3074
+ try {
3075
+ if (records.some((record) => !record.trim()))
3076
+ throw new Error("Empty structured stdin record");
3077
+ for (const record of records) JSON.parse(record);
3078
+ } catch {
3079
+ fail(
3080
+ path2,
3081
+ "Structured stdin payload does not match its declared JSON format"
3082
+ );
3083
+ }
3084
+ }
3085
+ if (operation.kind === "promptRecipe" && !command.capabilities.recipeIds.includes(operation.recipeId))
3086
+ fail(path2, "Prompt recipe is not qualified");
3087
+ if (operation.kind === "generatedFile" && !command.capabilities.generatedPaths.includes(operation.path))
3088
+ fail(path2, "Output path is not attributed to this command");
3089
+ if (operation.kind === "generatedFile" && !bundle.baselineInvocations.some(
3090
+ (invocation) => invocation.targetId === target.id && invocation.commandId === command.id && invocation.recordFiles.some(
3091
+ (file) => file.path === operation.path && file.status === "generated" && file.beforeSha256 === operation.beforeSha256 && file.generatedSha256 === operation.generatedSha256
3092
+ )
3093
+ ))
3094
+ fail(
3095
+ path2,
3096
+ "No attributed baseline file matches the preimage and real generated bytes"
3097
+ );
3098
+ if (operation.kind === "streamOutput" && !command.capabilities.outputModes.includes("streaming"))
3099
+ fail(path2, "Streaming output is not qualified");
3100
+ if (operation.kind === "completeOutput" && !command.capabilities.outputModes.includes("completed"))
3101
+ fail(path2, "Completed output is not qualified");
3102
+ 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)
3103
+ fail(path2, "A trial operation must change the matched content");
3104
+ const sources = [
3105
+ "value" in operation ? operation.value : null,
3106
+ operation.kind === "structuredStdin" ? operation.payload : null,
3107
+ ...operation.kind === "promptRecipe" ? operation.steps.map((step) => step.response) : []
3108
+ ];
3109
+ if (sources.some(
3110
+ (source) => source?.source === "localFact" && !command.capabilities.localFacts.includes(source.key)
3111
+ ))
3112
+ fail(path2, "Local fact is not declared non-secret for this command");
3113
+ if (sources.some(
3114
+ (source) => source?.source === "localFact" && changedEnvironment.has(source.key)
3115
+ ))
3116
+ fail(
3117
+ path2,
3118
+ "A local fact cannot be changed by another operation in the same trial"
3119
+ );
3120
+ 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;
3121
+ if (conflict && seen.has(conflict))
3122
+ fail(path2, "Conflicting operation on the same input or output");
3123
+ if (conflict) seen.add(conflict);
3124
+ });
3125
+ if (bundle.operations.filter((item) => item.kind === "generatedFile").length > bundle.limits.generatedFileCount)
3126
+ fail(
3127
+ ["limits", "generatedFileCount"],
3128
+ "Generated file count exceeds limit"
3129
+ );
3130
+ });
3131
+ var cliTrialChangeSchema = z28.object({
3132
+ targetId: token,
3133
+ commandId: token,
3134
+ selector: cliInterventionSchema.shape.selector.unwrap(),
3135
+ operations: cliInterventionSchema.shape.operations.min(1),
3136
+ shippingIntent: cliInterventionSchema.shape.shippingIntent.unwrap()
3137
+ }).strict();
2568
3138
 
2569
3139
  // ../packages/api-schemas/src/climb.ts
2570
- import { z as z29 } from "zod";
3140
+ import { z as z30 } from "zod";
2571
3141
 
2572
3142
  // ../packages/api-schemas/src/climb-kinds.ts
2573
3143
  var LEVER_KINDS = [
@@ -2585,46 +3155,47 @@ var INTERVENTION_KINDS = [
2585
3155
  "REWRITE_DOCS",
2586
3156
  "PACKAGE_VERSION",
2587
3157
  "PACKAGE_CONTENT",
2588
- "CLI_VERSION"
3158
+ "CLI_VERSION",
3159
+ "CLI_INTERVENTION"
2589
3160
  ];
2590
3161
  var LEVER_INTERVENTIONS = {
2591
3162
  DOCS: ["REWRITE_DOCS"],
2592
3163
  MARKETING_SITE: ["REWRITE_DOCS"],
2593
3164
  SDK: ["PACKAGE_VERSION", "PACKAGE_CONTENT"],
2594
- CLI: ["CLI_VERSION"],
3165
+ CLI: ["CLI_INTERVENTION"],
2595
3166
  SKILL: ["ADD_SKILL", "REMOVE_SKILL", "EDIT_SKILL"]
2596
3167
  };
2597
3168
 
2598
3169
  // ../packages/api-schemas/src/sandbox-overrides.ts
2599
- import { z as z28 } from "zod";
3170
+ import { z as z29 } from "zod";
2600
3171
  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(
3172
+ var ecosystemSchema = z29.enum(["npm", "pypi", "cargo", "go", "gem"]);
3173
+ var overrideFilesSchema = z29.array(
3174
+ z29.object({
3175
+ path: z29.string().min(1).refine(
2605
3176
  (path2) => !path2.startsWith("/") && !path2.includes("\\") && !path2.split("/").includes(".."),
2606
3177
  "Use a relative path within the target"
2607
3178
  ),
2608
- body: z28.string()
3179
+ body: z29.string()
2609
3180
  }).strict()
2610
3181
  ).min(1);
2611
3182
  var contentShape = {
2612
- version: z28.string().trim().min(1).optional(),
3183
+ version: z29.string().trim().min(1).optional(),
2613
3184
  files: overrideFilesSchema.optional()
2614
3185
  };
2615
3186
  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({
3187
+ var sandboxOverridesSchema = z29.object({
3188
+ version: z29.literal(1),
3189
+ packages: z29.array(
3190
+ z29.object({
2620
3191
  ecosystem: ecosystemSchema,
2621
- name: z28.string().trim().min(1),
3192
+ name: z29.string().trim().min(1),
2622
3193
  ...contentShape
2623
3194
  }).strict().refine(hasContent, "Specify a version or files")
2624
3195
  ).optional(),
2625
- clis: z28.array(
2626
- z28.object({
2627
- name: z28.string().trim().min(1),
3196
+ clis: z29.array(
3197
+ z29.object({
3198
+ name: z29.string().trim().min(1),
2628
3199
  ...contentShape
2629
3200
  }).strict().refine(hasContent, "Specify a version or files")
2630
3201
  ).optional()
@@ -2651,11 +3222,11 @@ var sandboxOverridesSchema = z28.object({
2651
3222
  });
2652
3223
 
2653
3224
  // ../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();
3225
+ var climbSubjectKindSchema = z30.enum(["EVAL_SET", "VISIBILITY_PROMPT"]);
3226
+ var leverKindSchema = z30.enum(LEVER_KINDS);
3227
+ var interventionKindSchema = z30.enum(INTERVENTION_KINDS);
3228
+ var skill = z30.object({ skillVersionId: z30.string().min(1) }).strict();
3229
+ var empty = z30.object({}).strict();
2659
3230
  function validateFixtureIntervention(value, ctx) {
2660
3231
  const result = webFixtureSchema.safeParse({ version: 1, ...value });
2661
3232
  if (!result.success) {
@@ -2668,69 +3239,75 @@ function validateFixtureIntervention(value, ctx) {
2668
3239
  }
2669
3240
  }
2670
3241
  }
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)
3242
+ var interventionSchema = z30.discriminatedUnion("kind", [
3243
+ z30.object({ kind: z30.literal("BASELINE"), after: empty }),
3244
+ z30.object({ kind: z30.literal("ADD_SKILL"), after: skill }),
3245
+ z30.object({ kind: z30.literal("REMOVE_SKILL"), before: skill, after: empty }),
3246
+ z30.object({ kind: z30.literal("EDIT_SKILL"), before: skill, after: skill }),
3247
+ z30.object({
3248
+ kind: z30.literal("REWRITE_DOCS"),
3249
+ before: z30.json().optional(),
3250
+ after: z30.object({ pages: webFixtureSchema.shape.pages.unwrap().min(1) }).strict().superRefine(validateFixtureIntervention)
2680
3251
  }),
2681
- z29.object({
2682
- kind: z29.literal("PACKAGE_VERSION"),
2683
- after: z29.object({
3252
+ z30.object({
3253
+ kind: z30.literal("PACKAGE_VERSION"),
3254
+ after: z30.object({
2684
3255
  ecosystem: ecosystemSchema,
2685
- name: z29.string().min(1),
2686
- version: z29.string().min(1)
3256
+ name: z30.string().min(1),
3257
+ version: z30.string().min(1)
2687
3258
  }).strict()
2688
3259
  }),
2689
- z29.object({
2690
- kind: z29.literal("PACKAGE_CONTENT"),
2691
- after: z29.object({
3260
+ z30.object({
3261
+ kind: z30.literal("PACKAGE_CONTENT"),
3262
+ after: z30.object({
2692
3263
  ecosystem: ecosystemSchema,
2693
- name: z29.string().min(1),
3264
+ name: z30.string().min(1),
2694
3265
  files: overrideFilesSchema
2695
3266
  }).strict()
2696
3267
  }),
2697
- z29.object({
2698
- kind: z29.literal("CLI_VERSION"),
2699
- after: z29.object({ name: z29.string().min(1), version: z29.string().min(1) }).strict()
3268
+ z30.object({
3269
+ kind: z30.literal("CLI_VERSION"),
3270
+ after: z30.object({ name: z30.string().min(1), version: z30.string().min(1) }).strict()
3271
+ }),
3272
+ z30.object({
3273
+ kind: z30.literal("CLI_INTERVENTION"),
3274
+ after: cliInterventionSchema.refine((bundle) => bundle.mode === "trial", {
3275
+ message: "A CLI trial requires a trial-mode bundle"
3276
+ })
2700
3277
  })
2701
3278
  ]);
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),
3279
+ var climbSettingsSchema = z30.object({
3280
+ maxRounds: z30.number().int().positive().default(5),
3281
+ sampleCount: z30.number().int().positive().default(1),
3282
+ creditCap: z30.number().int().nonnegative(),
3283
+ targetScore: z30.number().min(0).max(1).default(1),
2707
3284
  // Narrow the subject's whole roster to one slot, for the baseline and every
2708
3285
  // trial alike. A subject rostering ten models otherwise multiplies every
2709
3286
  // trial by ten, and a one-model trial measured against a ten-model baseline
2710
3287
  // is not a comparison. `pinnedModel` empty means the agent's default model.
2711
3288
  pinnedAgent: schedulableAgentSchema.optional(),
2712
- pinnedModel: z29.string().optional(),
2713
- maxTrialsPerRound: z29.number().int().min(1).max(10).default(3),
3289
+ pinnedModel: z30.string().optional(),
3290
+ maxTrialsPerRound: z30.number().int().min(1).max(10).default(3),
2714
3291
  // The round a continuation started at; the no-improvement counter
2715
3292
  // restarts here.
2716
- continuedAtRound: z29.number().int().nonnegative().optional()
3293
+ continuedAtRound: z30.number().int().nonnegative().optional()
2717
3294
  }).strip().refine((value) => value.pinnedAgent !== void 0 || !value.pinnedModel, {
2718
3295
  path: ["pinnedAgent"],
2719
3296
  message: "Pin an agent with the model"
2720
3297
  });
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(),
3298
+ var climbDirectionSchema = z30.object({
3299
+ focus: z30.string().trim().max(2e3).nullable().default(null),
3300
+ preserve: z30.array(z30.string().trim().min(1).max(500)).max(20).default([]),
3301
+ exclude: z30.array(z30.string().trim().min(1).max(500)).max(20).default([]),
3302
+ notes: z30.string().trim().max(4e3).nullable().default(null)
3303
+ });
3304
+ var climbDirectionPatchSchema = z30.object({
3305
+ focus: z30.string().trim().max(2e3).nullable().optional(),
3306
+ preserve: z30.array(z30.string().trim().min(1).max(500)).max(20).optional(),
3307
+ exclude: z30.array(z30.string().trim().min(1).max(500)).max(20).optional(),
3308
+ notes: z30.string().trim().max(4e3).nullable().optional(),
2732
3309
  /** One line on why this was recorded; becomes the DIRECTION row summary. */
2733
- rationale: z29.string().trim().max(500).optional()
3310
+ rationale: z30.string().trim().max(500).optional()
2734
3311
  }).strict();
2735
3312
  var CLIMB_ACTIVITY_KINDS = [
2736
3313
  "STARTED",
@@ -2749,73 +3326,74 @@ var CLIMB_ACTIVITY_KINDS = [
2749
3326
  "CONTINUED",
2750
3327
  "CANCELED"
2751
3328
  ];
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(),
3329
+ var climbActivityKindSchema = z30.enum(CLIMB_ACTIVITY_KINDS);
3330
+ var proposerTraceStepSchema = z30.object({
3331
+ tool: z30.string(),
3332
+ args: z30.string(),
3333
+ result: z30.string().nullable(),
3334
+ isError: z30.boolean().optional()
3335
+ });
3336
+ var proposerTraceSchema = z30.object({
3337
+ steps: z30.array(proposerTraceStepSchema),
3338
+ reasoning: z30.string(),
3339
+ durationMs: z30.number().int().nonnegative(),
3340
+ model: z30.string()
3341
+ });
3342
+ var climbActivitySchema = z30.object({
3343
+ id: z30.string(),
3344
+ climbId: z30.string(),
3345
+ roundId: z30.string().nullable(),
3346
+ trialId: z30.string().nullable(),
2770
3347
  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(),
3348
+ actorUserId: z30.string().nullable(),
3349
+ actorName: z30.string().nullable(),
3350
+ summary: z30.string(),
3351
+ detail: z30.unknown().nullable(),
3352
+ createdAt: z30.string()
3353
+ });
3354
+ var activityQuerySchema = z30.object({
3355
+ after: z30.string().datetime().optional(),
3356
+ limit: z30.coerce.number().int().min(1).max(500).default(500)
3357
+ });
3358
+ var climbConfigSnapshotSchema = z30.object({
3359
+ promptText: z30.string(),
3360
+ scenario: z30.enum(["GREENFIELD", "MIGRATION"]),
3361
+ repoUrl: z30.string().nullable(),
3362
+ repoRef: z30.string().nullable(),
3363
+ profileId: z30.string().nullable(),
3364
+ profileName: z30.string().nullable(),
3365
+ profileDescription: z30.string().nullable(),
3366
+ profileModel: z30.string().nullable(),
3367
+ limits: z30.json(),
3368
+ agents: z30.array(agentConfigSchema).min(1),
3369
+ skillRefs: z30.array(z30.string()),
3370
+ mcpRefs: z30.array(z30.string()),
3371
+ skillVersionIds: z30.array(z30.string()),
3372
+ mcpServerVersionIds: z30.array(z30.string()),
3373
+ skillSet: z30.json().nullable(),
3374
+ mcpSet: z30.json().nullable(),
3375
+ connectionIds: z30.array(z30.string()),
3376
+ connectionSet: z30.json().nullable(),
3377
+ agentContext: z30.json().nullable(),
3378
+ agentContextDigest: z30.string().nullable(),
2802
3379
  webFixture: webFixtureSchema.nullable(),
3380
+ cliIntervention: cliInterventionSchema.nullable().default(null),
2803
3381
  sandboxOverrides: sandboxOverridesSchema.nullable(),
2804
- visibilityScenarioId: z29.string().nullable()
3382
+ visibilityScenarioId: z30.string().nullable()
2805
3383
  }).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()
3384
+ var targetRefSchema = z30.object({
3385
+ kind: z30.string().min(1),
3386
+ id: z30.string().optional(),
3387
+ url: z30.url().optional(),
3388
+ package: z30.string().optional()
2811
3389
  }).strict();
2812
- var trialInputSchema = z29.object({
2813
- title: z29.string().trim().min(1).max(200),
2814
- hypothesis: z29.string().max(4e3).optional(),
3390
+ var trialInputSchema = z30.object({
3391
+ title: z30.string().trim().min(1).max(200),
3392
+ hypothesis: z30.string().max(4e3).optional(),
2815
3393
  lever: leverKindSchema,
2816
3394
  targetRef: targetRefSchema.optional(),
2817
3395
  intervention: interventionSchema,
2818
- authorMode: z29.enum(["MANUAL", "DIRECT", "PROPOSE"]).default("MANUAL")
3396
+ authorMode: z30.enum(["MANUAL", "DIRECT", "PROPOSE"]).default("MANUAL")
2819
3397
  }).strict().superRefine((value, ctx) => {
2820
3398
  const allowed = LEVER_INTERVENTIONS[value.lever];
2821
3399
  if (!allowed.includes(value.intervention.kind))
@@ -2834,7 +3412,7 @@ var OPTIMIZATION_STATUSES = [
2834
3412
  "DONE",
2835
3413
  "ARCHIVED"
2836
3414
  ];
2837
- var optimizationStatusSchema = z30.enum(OPTIMIZATION_STATUSES);
3415
+ var optimizationStatusSchema = z31.enum(OPTIMIZATION_STATUSES);
2838
3416
  var ROUND_STATUSES = [
2839
3417
  "PROPOSING",
2840
3418
  "PROPOSED",
@@ -2863,61 +3441,61 @@ var OPTIMIZATION_EFFORTS = [
2863
3441
  { value: "HIGH", label: "Thorough", sampleCount: 2, maxRounds: 8 },
2864
3442
  { value: "XHIGH", label: "Exhaustive", sampleCount: 3, maxRounds: 12 }
2865
3443
  ];
2866
- var optimizationEffortSchema = z30.enum(
3444
+ var optimizationEffortSchema = z31.enum(
2867
3445
  OPTIMIZATION_EFFORTS.map((preset) => preset.value)
2868
3446
  );
2869
- var listOptimizationsQuerySchema = z30.object({
2870
- status: z30.string().optional().transform(
3447
+ var listOptimizationsQuerySchema = z31.object({
3448
+ status: z31.string().optional().transform(
2871
3449
  (value) => value ? value.split(",").map((part) => part.trim().toUpperCase()).filter(Boolean) : void 0
2872
- ).pipe(z30.array(optimizationStatusSchema).optional()),
3450
+ ).pipe(z31.array(optimizationStatusSchema).optional()),
2873
3451
  subjectKind: climbSubjectKindSchema.optional(),
2874
- subjectId: z30.string().min(1).optional(),
2875
- limit: z30.coerce.number().int().min(1).max(200).default(50),
3452
+ subjectId: z31.string().min(1).optional(),
3453
+ limit: z31.coerce.number().int().min(1).max(200).default(50),
2876
3454
  /** 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")
3455
+ includeDrafts: z31.union([z31.boolean(), z31.string()]).optional().transform((value) => value === true || value === "true" || value === "1")
2878
3456
  });
2879
- var optimizationSummarySchema = z30.object({
2880
- id: z30.string(),
2881
- name: z30.string(),
3457
+ var optimizationSummarySchema = z31.object({
3458
+ id: z31.string(),
3459
+ name: z31.string(),
2882
3460
  status: optimizationStatusSchema,
2883
- mode: z30.enum(["MANUAL", "AUTO"]),
3461
+ mode: z31.enum(["MANUAL", "AUTO"]),
2884
3462
  /** Autonomous launches every proposed round; interactive waits for one. */
2885
- autonomous: z30.boolean(),
2886
- stopReason: z30.string().nullable(),
3463
+ autonomous: z31.boolean(),
3464
+ stopReason: z31.string().nullable(),
2887
3465
  subjectKind: climbSubjectKindSchema,
2888
- subjectId: z30.string(),
2889
- subjectName: z30.string(),
3466
+ subjectId: z31.string(),
3467
+ subjectName: z31.string(),
2890
3468
  lever: leverKindSchema.nullable(),
2891
- round: z30.number().int(),
2892
- maxRounds: z30.number().int(),
3469
+ round: z31.number().int(),
3470
+ maxRounds: z31.number().int(),
2893
3471
  /** Starting baseline score, 0..1. */
2894
- before: z30.number().nullable(),
3472
+ before: z31.number().nullable(),
2895
3473
  /** Score of the marked winner, or best BETTER trial, 0..1. */
2896
- after: z30.number().nullable(),
3474
+ after: z31.number().nullable(),
2897
3475
  /** Percentage-point change from the baseline to the winner or best BETTER trial. */
2898
- delta: z30.number().nullable(),
3476
+ delta: z31.number().nullable(),
2899
3477
  /** 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({
3478
+ path: z31.array(z31.number()),
3479
+ creditsSpent: z31.number().int(),
3480
+ creditsReserved: z31.number().int(),
3481
+ summary: z31.string().nullable(),
3482
+ href: z31.string(),
3483
+ createdAt: z31.string(),
3484
+ updatedAt: z31.string()
3485
+ });
3486
+ var listOptimizationsResponseSchema = z31.object({
3487
+ items: z31.array(optimizationSummarySchema)
3488
+ });
3489
+ var targetSchema = z31.object({
2912
3490
  agent: schedulableAgentSchema.optional(),
2913
3491
  /** Empty or omitted means the agent's default model. */
2914
- model: z30.string().optional()
3492
+ model: z31.string().optional()
2915
3493
  });
2916
3494
  var planShape = {
2917
3495
  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()
3496
+ sampleCount: z31.number().int().min(1).max(100).optional(),
3497
+ maxRounds: z31.number().int().min(1).max(100).optional(),
3498
+ maxTrialsPerRound: z31.number().int().min(1).max(10).optional()
2921
3499
  };
2922
3500
  function refinePlan(value, ctx) {
2923
3501
  if (value.effort && (value.sampleCount || value.maxRounds))
@@ -2933,18 +3511,18 @@ function refinePlan(value, ctx) {
2933
3511
  message: "Pin an agent with the model"
2934
3512
  });
2935
3513
  }
2936
- var startOptimizationBodySchema = z30.object({
3514
+ var startOptimizationBodySchema = z31.object({
2937
3515
  subjectKind: climbSubjectKindSchema,
2938
- subjectId: z30.string().min(1),
2939
- name: z30.string().trim().min(1).max(200).optional(),
3516
+ subjectId: z31.string().min(1),
3517
+ name: z31.string().trim().min(1).max(200).optional(),
2940
3518
  ...planShape,
2941
- creditCap: z30.number().int().nonnegative().optional(),
2942
- targetScore: z30.number().min(0).max(1).optional(),
3519
+ creditCap: z31.number().int().nonnegative().optional(),
3520
+ targetScore: z31.number().min(0).max(1).optional(),
2943
3521
  target: targetSchema.extend({ agent: schedulableAgentSchema })
2944
3522
  }).strict().superRefine(refinePlan);
2945
- var estimateOptimizationBodySchema = z30.object({
3523
+ var estimateOptimizationBodySchema = z31.object({
2946
3524
  subjectKind: climbSubjectKindSchema,
2947
- subjectId: z30.string().min(1),
3525
+ subjectId: z31.string().min(1),
2948
3526
  ...planShape,
2949
3527
  target: targetSchema.optional()
2950
3528
  }).strict().superRefine(refinePlan);
@@ -2956,100 +3534,101 @@ var RUN_CREDIT_BASES = [
2956
3534
  "byok",
2957
3535
  "reserve"
2958
3536
  ];
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(),
3537
+ var runCreditBasisSchema = z31.enum(RUN_CREDIT_BASES);
3538
+ var optimizationEstimateSchema = z31.object({
3539
+ sampleCount: z31.number().int(),
3540
+ maxRounds: z31.number().int(),
3541
+ runsPerTrial: z31.number(),
3542
+ executionCredits: z31.number(),
3543
+ judgeCredits: z31.number(),
3544
+ leverPassCredits: z31.number(),
3545
+ trialCredits: z31.number(),
2968
3546
  /** Estimate, not a reservation or enforced spending cap. */
2969
- estimate: z30.number().int(),
3547
+ estimate: z31.number().int(),
2970
3548
  /** True when no price or history covered a model: a bound, not a forecast. */
2971
- approximate: z30.boolean().default(false),
3549
+ approximate: z31.boolean().default(false),
2972
3550
  /** Which rung priced the run, so the UI can say why a figure is what it is. */
2973
3551
  basis: runCreditBasisSchema.optional()
2974
3552
  });
2975
- var diagnoseBodySchema = z30.object({
3553
+ var diagnoseBodySchema = z31.object({
2976
3554
  subjectKind: climbSubjectKindSchema,
2977
- subjectId: z30.string().min(1)
3555
+ subjectId: z31.string().min(1)
2978
3556
  }).strict();
2979
- var diagnosisSchema = z30.object({
2980
- id: z30.string(),
2981
- status: z30.enum(["GENERATING", "READY", "FAILED"]),
3557
+ var diagnosisSchema = z31.object({
3558
+ id: z31.string(),
3559
+ status: z31.enum(["GENERATING", "READY", "FAILED"]),
2982
3560
  subjectKind: climbSubjectKindSchema,
2983
- subjectId: z30.string(),
2984
- runCount: z30.number().int(),
2985
- summary: z30.string().nullable(),
3561
+ subjectId: z31.string(),
3562
+ runCount: z31.number().int(),
3563
+ summary: z31.string().nullable(),
2986
3564
  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()),
3565
+ recommendedTarget: z31.unknown().nullable(),
3566
+ clusters: z31.array(
3567
+ z31.object({
3568
+ title: z31.string(),
3569
+ failureMode: z31.string(),
3570
+ criterionIds: z31.array(z31.string()),
3571
+ runIds: z31.array(z31.string()),
2994
3572
  lever: leverKindSchema.nullable(),
2995
- targetRef: z30.unknown().nullable(),
2996
- confidence: z30.number()
3573
+ targetRef: z31.unknown().nullable(),
3574
+ confidence: z31.number()
2997
3575
  })
2998
3576
  ),
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() })
3577
+ unsupportedLevers: z31.array(leverKindSchema).default([]),
3578
+ createdAt: z31.string()
3579
+ });
3580
+ var trialRunSchema = z31.object({
3581
+ id: z31.string(),
3582
+ status: z31.string(),
3583
+ cliCoverage: cliCoverageSchema.nullable().optional(),
3584
+ passed: z31.boolean().nullable(),
3585
+ criteria: z31.array(
3586
+ z31.object({ name: z31.string(), passed: z31.boolean(), reasoning: z31.string() })
3008
3587
  ),
3009
- levers: z30.array(
3010
- z30.object({
3011
- lever: z30.string(),
3012
- attributed: z30.boolean(),
3013
- note: z30.string().nullable()
3588
+ levers: z31.array(
3589
+ z31.object({
3590
+ lever: z31.string(),
3591
+ attributed: z31.boolean(),
3592
+ note: z31.string().nullable()
3014
3593
  })
3015
3594
  )
3016
3595
  });
3017
- var trialSchema = z30.object({
3018
- id: z30.string(),
3019
- climbId: z30.string(),
3020
- roundNumber: z30.number().int(),
3021
- key: z30.string(),
3596
+ var trialSchema = z31.object({
3597
+ id: z31.string(),
3598
+ climbId: z31.string(),
3599
+ roundNumber: z31.number().int(),
3600
+ key: z31.string(),
3022
3601
  /** @deprecated All trials branch from the baseline. */
3023
- parentTrialId: z30.string().nullable(),
3602
+ parentTrialId: z31.string().nullable(),
3024
3603
  /** @deprecated Always the baseline key for non-baseline trials. */
3025
- parentKey: z30.string().nullable(),
3026
- title: z30.string(),
3027
- hypothesis: z30.string().nullable(),
3604
+ parentKey: z31.string().nullable(),
3605
+ title: z31.string(),
3606
+ hypothesis: z31.string().nullable(),
3028
3607
  lever: leverKindSchema.nullable(),
3029
3608
  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(),
3609
+ status: z31.enum(TRIAL_STATUSES),
3610
+ verdict: z31.enum(TRIAL_VERDICTS).nullable(),
3611
+ score: z31.number().nullable(),
3612
+ baselineScore: z31.number().nullable(),
3034
3613
  /** Judged sessions behind `score`. */
3035
- sessions: z30.number().int(),
3036
- isBaseline: z30.boolean(),
3614
+ sessions: z31.number().int(),
3615
+ isBaseline: z31.boolean(),
3037
3616
  /** 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(),
3617
+ adopted: z31.boolean(),
3618
+ adoptedAt: z31.string().nullable(),
3619
+ outcome: z31.string().nullable(),
3041
3620
  /** 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)
3621
+ after: z31.unknown(),
3622
+ before: z31.unknown(),
3623
+ runs: z31.array(trialRunSchema),
3624
+ createdAt: z31.string()
3625
+ });
3626
+ var roundSchema = z31.object({
3627
+ id: z31.string(),
3628
+ number: z31.number().int(),
3629
+ status: z31.enum(ROUND_STATUSES),
3630
+ narrative: z31.string().nullable(),
3631
+ trials: z31.array(trialSchema)
3053
3632
  });
3054
3633
  var OPTIMIZATION_NEXT_ACTIONS = [
3055
3634
  "START",
@@ -3060,471 +3639,894 @@ var OPTIMIZATION_NEXT_ACTIONS = [
3060
3639
  "RESUME",
3061
3640
  "NONE"
3062
3641
  ];
3063
- var optimizationNextActionSchema = z30.enum(OPTIMIZATION_NEXT_ACTIONS);
3642
+ var optimizationNextActionSchema = z31.enum(OPTIMIZATION_NEXT_ACTIONS);
3064
3643
  var optimizationDetailSchema = optimizationSummarySchema.extend({
3065
- baselineTrialId: z30.string().nullable(),
3644
+ baselineTrialId: z31.string().nullable(),
3066
3645
  /** The one thing a client does next. WAIT and NONE need nobody. */
3067
3646
  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()
3647
+ settings: z31.object({
3648
+ sampleCount: z31.number().int(),
3649
+ maxRounds: z31.number().int(),
3650
+ maxTrialsPerRound: z31.number().int(),
3651
+ creditCap: z31.number().int(),
3652
+ targetScore: z31.number(),
3653
+ pinnedAgent: z31.string().nullable(),
3654
+ pinnedModel: z31.string().nullable(),
3655
+ continuedAtRound: z31.number().int().nullable()
3077
3656
  }),
3078
3657
  direction: climbDirectionSchema,
3079
- rounds: z30.array(roundSchema)
3658
+ rounds: z31.array(roundSchema)
3080
3659
  });
3081
- var listTrialsResponseSchema = z30.object({
3082
- items: z30.array(trialSchema)
3660
+ var listTrialsResponseSchema = z31.object({
3661
+ items: z31.array(trialSchema)
3083
3662
  });
3084
- var trialDocumentSchema = z30.object({
3085
- path: z30.string(),
3086
- before: z30.string(),
3087
- after: z30.string()
3663
+ var trialDocumentSchema = z31.object({
3664
+ path: z31.string(),
3665
+ before: z31.string(),
3666
+ after: z31.string()
3088
3667
  });
3089
- var trialContentSchema = z30.object({
3090
- trialId: z30.string(),
3668
+ var trialContentSchema = z31.object({
3669
+ trialId: z31.string(),
3091
3670
  kind: interventionKindSchema,
3092
- documents: z30.array(trialDocumentSchema),
3671
+ documents: z31.array(trialDocumentSchema),
3093
3672
  /** Full page bodies for a docs rewrite, ready to paste; null otherwise. */
3094
- copyableBody: z30.string().nullable(),
3095
- configSnapshot: z30.unknown()
3673
+ copyableBody: z31.string().nullable(),
3674
+ configSnapshot: z31.unknown()
3096
3675
  });
3097
- var createTrialBodySchema = z30.object({
3676
+ var createTrialBodySchema = z31.object({
3098
3677
  trial: trialInputSchema,
3099
3678
  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),
3679
+ fork: z31.object({ runId: z31.string().min(1), boundarySeq: z31.string().min(1) }).strict().optional(),
3680
+ launch: z31.boolean().default(false),
3102
3681
  /** Replays return the trial the first call created instead of a second
3103
3682
  * one. Scoped to the optimization. */
3104
- idempotencyKey: z30.string().min(1).max(200).optional()
3683
+ idempotencyKey: z31.string().min(1).max(200).optional()
3105
3684
  }).strict();
3106
- var skillFilesResponseSchema = z30.object({
3107
- versionId: z30.string(),
3685
+ var skillFilesResponseSchema = z31.object({
3686
+ versionId: z31.string(),
3108
3687
  files: overrideFilesSchema
3109
3688
  });
3110
- var pageBodyResponseSchema = z30.object({
3111
- url: z30.string(),
3112
- body: z30.string(),
3113
- contentType: z30.string().optional()
3689
+ var pageBodyResponseSchema = z31.object({
3690
+ url: z31.string(),
3691
+ body: z31.string(),
3692
+ contentType: z31.string().optional()
3114
3693
  });
3115
- var launchTrialResponseSchema = z30.object({
3116
- trialId: z30.string(),
3117
- batchIds: z30.array(z30.string()),
3118
- runIds: z30.array(z30.string())
3694
+ var launchTrialResponseSchema = z31.object({
3695
+ trialId: z31.string(),
3696
+ batchIds: z31.array(z31.string()),
3697
+ runIds: z31.array(z31.string())
3119
3698
  });
3120
- var createDraftOptimizationBodySchema = z30.object({
3699
+ var createDraftOptimizationBodySchema = z31.object({
3121
3700
  subjectKind: climbSubjectKindSchema,
3122
- subjectId: z30.string().min(1),
3123
- name: z30.string().trim().min(1).max(200).optional(),
3701
+ subjectId: z31.string().min(1),
3702
+ name: z31.string().trim().min(1).max(200).optional(),
3124
3703
  ...planShape,
3125
3704
  target: targetSchema.optional(),
3126
- autonomous: z30.boolean().optional()
3705
+ autonomous: z31.boolean().optional()
3127
3706
  }).strict().superRefine(refinePlan);
3128
3707
  var planPatchShape = {
3129
- name: z30.string().trim().min(1).max(200).optional(),
3708
+ name: z31.string().trim().min(1).max(200).optional(),
3130
3709
  ...planShape,
3131
3710
  target: targetSchema.optional()
3132
3711
  };
3133
- var optimizationPlanPatchSchema = z30.object(planPatchShape).strict().superRefine(refinePlan);
3134
- var startDraftOptimizationBodySchema = z30.object({
3712
+ var optimizationPlanPatchSchema = z31.object(planPatchShape).strict().superRefine(refinePlan);
3713
+ var startDraftOptimizationBodySchema = z31.object({
3135
3714
  ...planPatchShape,
3136
- creditCap: z30.number().int().nonnegative().optional()
3715
+ creditCap: z31.number().int().nonnegative().optional()
3137
3716
  }).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()),
3717
+ var setModeBodySchema = z31.object({ autonomous: z31.boolean() }).strict();
3718
+ var launchRoundResponseSchema = z31.object({
3719
+ roundNumber: z31.number().int().nullable(),
3720
+ launched: z31.array(z31.string()),
3142
3721
  /** True when nothing was left to launch: someone else got there first. */
3143
- alreadyLaunched: z30.boolean()
3722
+ alreadyLaunched: z31.boolean()
3144
3723
  });
3145
- var resolveChatResponseSchema = z30.object({
3146
- chatId: z30.string(),
3147
- href: z30.string()
3724
+ var resolveChatResponseSchema = z31.object({
3725
+ chatId: z31.string(),
3726
+ href: z31.string()
3148
3727
  });
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()
3728
+ var continueOptimizationBodySchema = z31.object({
3729
+ rounds: z31.number().int().min(1).max(20).default(1),
3730
+ maxTrialsPerRound: z31.number().int().min(1).max(10).optional()
3152
3731
  }).strict();
3153
- var patchOptimizationBodySchema = z30.object({
3732
+ var patchOptimizationBodySchema = z31.object({
3154
3733
  ...planPatchShape,
3155
3734
  direction: climbDirectionPatchSchema.optional(),
3156
- autonomous: z30.boolean().optional()
3735
+ autonomous: z31.boolean().optional()
3157
3736
  }).strict().superRefine(refinePlan);
3158
3737
 
3159
3738
  // ../packages/api-schemas/src/orgs.ts
3160
- import { z as z31 } from "zod";
3161
- var createOrgRequestSchema = z31.object({
3739
+ import { z as z32 } from "zod";
3740
+ var createOrgRequestSchema = z32.object({
3162
3741
  /** Workspace display name; the slug is derived server-side. */
3163
- name: z31.string().trim().min(1).max(200),
3742
+ name: z32.string().trim().min(1).max(200),
3164
3743
  /** Optional company site (logo source; stamped onto the org). */
3165
- website: z31.string().trim().max(300).optional()
3744
+ website: z32.string().trim().max(300).optional()
3166
3745
  });
3167
- var createOrgResponseSchema = z31.object({
3168
- slug: z31.string(),
3169
- name: z31.string(),
3746
+ var createOrgResponseSchema = z32.object({
3747
+ slug: z32.string(),
3748
+ name: z32.string(),
3170
3749
  // LOCAL orgs never have a Gauge publicId.
3171
- publicId: z31.string().nullable()
3750
+ publicId: z32.string().nullable()
3172
3751
  });
3173
- var orgSettingsSchema = z31.object({
3174
- slug: z31.string(),
3175
- name: z31.string(),
3176
- publicId: z31.string().nullable(),
3177
- website: z31.string().nullable(),
3752
+ var orgSettingsSchema = z32.object({
3753
+ slug: z32.string(),
3754
+ name: z32.string(),
3755
+ publicId: z32.string().nullable(),
3756
+ website: z32.string().nullable(),
3178
3757
  /** Per-run max-spend override in USD; null = the server default. */
3179
- maxSpendUsd: z31.number().nullable(),
3180
- overageEnabled: z31.boolean(),
3758
+ maxSpendUsd: z32.number().nullable(),
3759
+ overageEnabled: z32.boolean(),
3181
3760
  /** Per-cycle overage cap in credits; null = uncapped. */
3182
- overageCapCredits: z31.number().int().nullable(),
3761
+ overageCapCredits: z32.number().int().nullable(),
3183
3762
  /** Domain claimed for same-domain auto-join; null = off. */
3184
- autoJoinDomain: z31.string().nullable()
3763
+ autoJoinDomain: z32.string().nullable()
3185
3764
  });
3186
- var orgMemberSchema = z31.object({
3187
- userId: z31.string(),
3188
- name: z31.string().nullable(),
3189
- email: z31.string().nullable(),
3190
- joinedAt: z31.string()
3765
+ var orgMemberSchema = z32.object({
3766
+ userId: z32.string(),
3767
+ name: z32.string().nullable(),
3768
+ email: z32.string().nullable(),
3769
+ joinedAt: z32.string()
3191
3770
  });
3192
- var listMembersResponseSchema = z31.object({
3193
- items: z31.array(orgMemberSchema)
3771
+ var listMembersResponseSchema = z32.object({
3772
+ items: z32.array(orgMemberSchema)
3194
3773
  });
3195
3774
 
3196
3775
  // ../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(),
3776
+ import { z as z33 } from "zod";
3777
+ var personaSchema = z33.object({
3778
+ id: z33.string(),
3779
+ name: z33.string(),
3780
+ description: z33.string(),
3202
3781
  /** The judge model this persona calls (Claude only). */
3203
- model: z32.string(),
3204
- createdAt: z32.string(),
3205
- updatedAt: z32.string()
3782
+ model: z33.string(),
3783
+ createdAt: z33.string(),
3784
+ updatedAt: z33.string()
3206
3785
  });
3207
- var listPersonasResponseSchema = z32.object({
3208
- items: z32.array(personaSchema)
3786
+ var listPersonasResponseSchema = z33.object({
3787
+ items: z33.array(personaSchema)
3209
3788
  });
3210
- var createPersonaBodySchema = z32.object({
3211
- name: z32.string().min(1).max(120),
3212
- description: z32.string().min(1)
3789
+ var createPersonaBodySchema = z33.object({
3790
+ name: z33.string().min(1).max(120),
3791
+ description: z33.string().min(1)
3213
3792
  });
3214
- var updatePersonaBodySchema = z32.object({
3215
- name: z32.string().min(1).max(120).optional(),
3216
- description: z32.string().min(1).optional()
3793
+ var updatePersonaBodySchema = z33.object({
3794
+ name: z33.string().min(1).max(120).optional(),
3795
+ description: z33.string().min(1).optional()
3217
3796
  });
3218
3797
 
3219
3798
  // ../packages/api-schemas/src/prompts.ts
3220
- import { z as z35 } from "zod";
3799
+ import { z as z36 } from "zod";
3221
3800
 
3222
3801
  // ../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(),
3802
+ import { z as z34 } from "zod";
3803
+ var tagSchema = z34.object({
3804
+ id: z34.string(),
3805
+ name: z34.string(),
3227
3806
  /** A Mantine palette name (e.g. "blue", "grape"); unknown values are
3228
3807
  * normalized server-side to the default ("gray"). */
3229
- color: z33.string()
3808
+ color: z34.string()
3230
3809
  });
3231
- var createTagBodySchema = z33.object({
3232
- name: z33.string().min(1),
3233
- color: z33.string().optional()
3810
+ var createTagBodySchema = z34.object({
3811
+ name: z34.string().min(1),
3812
+ color: z34.string().optional()
3234
3813
  });
3235
- var updateTagBodySchema = z33.object({
3236
- name: z33.string().min(1).optional(),
3237
- color: z33.string().optional()
3814
+ var updateTagBodySchema = z34.object({
3815
+ name: z34.string().min(1).optional(),
3816
+ color: z34.string().optional()
3238
3817
  });
3239
3818
  var tagListResponseSchema = listResponseSchema(tagSchema);
3240
3819
 
3241
3820
  // ../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()
3821
+ import { z as z35 } from "zod";
3822
+ var topicSchema = z35.object({
3823
+ id: z35.string(),
3824
+ name: z35.string()
3246
3825
  });
3247
- var createTopicBodySchema = z34.object({
3248
- name: z34.string().min(1, "name is required")
3826
+ var createTopicBodySchema = z35.object({
3827
+ name: z35.string().min(1, "name is required")
3249
3828
  });
3250
3829
  var topicListResponseSchema = listResponseSchema(topicSchema);
3251
3830
 
3252
3831
  // ../packages/api-schemas/src/prompts.ts
3253
- var promptSummarySchema = z35.object({
3254
- id: z35.string(),
3255
- text: z35.string(),
3256
- isBranded: z35.boolean(),
3832
+ var promptSummarySchema = z36.object({
3833
+ id: z36.string(),
3834
+ text: z36.string(),
3835
+ isBranded: z36.boolean(),
3257
3836
  /** Battery-spec identity (idempotent applies); null for UI/CLI-created prompts. */
3258
- externalKey: z35.string().nullable(),
3837
+ externalKey: z36.string().nullable(),
3259
3838
  topic: topicSchema.nullable(),
3260
- tags: z35.array(tagSchema),
3261
- createdAt: z35.string()
3839
+ tags: z36.array(tagSchema),
3840
+ createdAt: z36.string()
3262
3841
  });
3263
3842
  var promptListResponseSchema = listResponseSchema(promptSummarySchema);
3264
3843
  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({
3844
+ topic: z36.string().min(1).optional(),
3845
+ tag: z36.string().min(1).optional(),
3846
+ q: z36.string().min(1).optional()
3847
+ });
3848
+ var createPromptBodySchema = z36.object({
3849
+ text: z36.string().min(1, "text is required"),
3850
+ isBranded: z36.boolean().default(false),
3851
+ topic: z36.string().min(1).optional(),
3852
+ tags: z36.array(z36.string().min(1)).default([])
3853
+ });
3854
+ var updatePromptBodySchema = z36.object({
3855
+ text: z36.string().min(1).optional(),
3856
+ isBranded: z36.boolean().optional(),
3857
+ topicId: z36.string().min(1).nullish(),
3858
+ tags: z36.array(z36.string().min(1)).optional()
3859
+ });
3860
+ var runPromptBodySchema = z36.object({
3282
3861
  /** Preferred paired representation; each agent may pin its own model tiers. */
3283
- agentConfigs: z35.array(agentConfigInputSchema).min(1).optional(),
3862
+ agentConfigs: z36.array(agentConfigInputSchema).min(1).optional(),
3284
3863
  /** 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),
3864
+ agents: z36.array(z36.enum(["CLAUDE_CODE", "CODEX_CLI", "CURSOR"])).min(1, "Select at least one agent").default(["CLAUDE_CODE", "CODEX_CLI"]),
3865
+ repoUrl: z36.string().min(1).nullish(),
3866
+ repoRef: z36.string().min(1).nullish(),
3867
+ samplesPerCycle: z36.number().int().min(1).max(10).default(1),
3289
3868
  webFixture: webFixtureSchema.optional()
3290
3869
  });
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()
3870
+ var runPromptResponseSchema = z36.object({
3871
+ batchIds: z36.array(z36.string()),
3872
+ runIds: z36.array(z36.string()),
3873
+ blocked: z36.enum(["insufficient_credits", "needs_provider_key"]).optional()
3295
3874
  });
3296
3875
 
3297
3876
  // ../packages/api-schemas/src/repos.ts
3298
- import { z as z36 } from "zod";
3877
+ import { z as z37 } from "zod";
3299
3878
  var REPO_SIZE_BUCKETS = [
3300
3879
  "small",
3301
3880
  "medium",
3302
3881
  "large",
3303
3882
  "xlarge"
3304
3883
  ];
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()),
3884
+ var repoSizeBucketSchema = z37.enum(REPO_SIZE_BUCKETS);
3885
+ var repoSchema = z37.object({
3886
+ url: z37.string(),
3887
+ name: z37.string(),
3888
+ isSystem: z37.boolean(),
3889
+ languages: z37.array(z37.string()),
3890
+ frameworks: z37.array(z37.string()),
3312
3891
  /** Faceted labels (complexity:L2, buildable:yes, stack:nextjs, …). */
3313
- tags: z36.array(z36.string()),
3314
- primaryLanguage: z36.string(),
3315
- sizeKb: z36.number(),
3892
+ tags: z37.array(z37.string()),
3893
+ primaryLanguage: z37.string(),
3894
+ sizeKb: z37.number(),
3316
3895
  sizeBucket: repoSizeBucketSchema.nullable(),
3317
- stars: z36.number()
3896
+ stars: z37.number()
3318
3897
  });
3319
3898
  var repoListResponseSchema = listResponseSchema(repoSchema);
3320
- var addRepoBodySchema = z36.object({
3321
- url: z36.string().min(1, "url is required"),
3899
+ var addRepoBodySchema = z37.object({
3900
+ url: z37.string().min(1, "url is required"),
3322
3901
  /**
3323
3902
  * Reserved (accepted, not yet persisted): the catalog keys repos by URL only
3324
3903
  * — `fact_repo` has no ref column and metadata sync always reads the default
3325
3904
  * branch. Kept in the wire format so `gauge repos add --ref` is stable once
3326
3905
  * the catalog learns refs.
3327
3906
  */
3328
- ref: z36.string().min(1).optional(),
3907
+ ref: z37.string().min(1).optional(),
3329
3908
  /** Display name; defaults to the `owner/repo` label of the URL. */
3330
- name: z36.string().min(1).optional(),
3909
+ name: z37.string().min(1).optional(),
3331
3910
  /** 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()
3911
+ frameworks: z37.array(z37.string()).optional(),
3912
+ tags: z37.array(z37.string()).optional()
3334
3913
  });
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()
3914
+ var updateRepoBodySchema = z37.object({
3915
+ url: z37.string().min(1, "url is required"),
3916
+ name: z37.string().min(1).optional(),
3917
+ frameworks: z37.array(z37.string()).optional(),
3918
+ tags: z37.array(z37.string()).optional()
3340
3919
  });
3341
- var resyncRepoBodySchema = z36.object({
3342
- url: z36.string().min(1, "url is required")
3920
+ var resyncRepoBodySchema = z37.object({
3921
+ url: z37.string().min(1, "url is required")
3343
3922
  });
3344
- var deleteRepoQuerySchema = z36.object({
3345
- url: z36.string().min(1, "url is required")
3923
+ var deleteRepoQuerySchema = z37.object({
3924
+ url: z37.string().min(1, "url is required")
3346
3925
  });
3347
- var repoSyncResultSchema = z36.object({
3926
+ var repoSyncResultSchema = z37.object({
3348
3927
  repo: repoSchema,
3349
- synced: z36.boolean()
3928
+ synced: z37.boolean()
3929
+ });
3930
+
3931
+ // ../packages/api-schemas/src/runAddons.ts
3932
+ import { z as z38 } from "zod";
3933
+ var runAddonsSchema = z38.object({
3934
+ browser: z38.object({
3935
+ session: z38.string().min(1),
3936
+ projectId: z38.number().int().positive(),
3937
+ region: z38.literal("us").default("us")
3938
+ }).strict().optional()
3939
+ }).strict();
3940
+
3941
+ // ../packages/api-schemas/src/runDefinitions.ts
3942
+ import { z as z40 } from "zod";
3943
+
3944
+ // ../packages/api-schemas/src/runPlan.ts
3945
+ import { z as z39 } from "zod";
3946
+ var runPlanCriterionSchema = z39.object({
3947
+ id: z39.string().min(1),
3948
+ name: z39.string(),
3949
+ rubric: z39.string()
3950
+ });
3951
+ var criteriaSnapshotV1Schema = z39.object({
3952
+ version: z39.literal(1),
3953
+ // File-authored criteria have no saved EvalSet; their identity is frozen
3954
+ // in the request and result rows retain the criterion text without an FK.
3955
+ evalSetId: z39.string().min(1).nullable(),
3956
+ criteria: z39.array(runPlanCriterionSchema)
3957
+ });
3958
+ var runPlanCaseSchema = z39.object({
3959
+ id: z39.string().min(1),
3960
+ prompt: z39.object({ id: z39.string().min(1), text: z39.string() }),
3961
+ workspace: z39.object({
3962
+ repoUrl: z39.string().nullable(),
3963
+ repoRef: z39.string().nullable()
3964
+ }),
3965
+ agents: z39.array(
3966
+ agentConfigSchema.extend({
3967
+ // Validated against the current catalog request schema when lowered.
3968
+ catalogSelections: z39.record(z39.string(), z39.unknown()).optional()
3969
+ })
3970
+ ),
3971
+ samples: z39.number().int().min(1).max(50),
3972
+ evalSetId: z39.string().min(1).optional(),
3973
+ criteriaSnapshot: criteriaSnapshotV1Schema.optional(),
3974
+ sourceRepoCommit: z39.string().nullable().optional(),
3975
+ experiment: z39.string().nullable().optional(),
3976
+ membershipTagIds: z39.array(z39.string()).optional(),
3977
+ profile: z39.object({
3978
+ id: z39.string(),
3979
+ name: z39.string(),
3980
+ description: z39.string(),
3981
+ model: z39.string()
3982
+ }).nullable().optional(),
3983
+ skillSet: skillSetSchema.optional(),
3984
+ mcpSet: mcpSetSchema.optional(),
3985
+ connectionSet: connectionSetSchema.optional(),
3986
+ // The server's agentContextSnapshotV1Schema validates this at lowering.
3987
+ agentContext: z39.unknown().optional(),
3988
+ agentContextDigest: z39.string().nullable().optional(),
3989
+ addons: runAddonsSchema.optional(),
3990
+ /** Names of resources the coordinator must prepare before expansion. */
3991
+ inputs: z39.array(z39.string().min(1)).default([])
3992
+ });
3993
+ var builtDirectoryResourceSchema = z39.object({
3994
+ name: z39.string().min(1),
3995
+ type: z39.literal("built-directory"),
3996
+ source: z39.object({
3997
+ type: z39.literal("git-checkout"),
3998
+ repoUrl: z39.string().min(1),
3999
+ commit: z39.string().regex(/^[a-f0-9]{40}$/i)
4000
+ }),
4001
+ build: z39.object({
4002
+ runtime: z39.literal("node-24"),
4003
+ run: z39.string().min(1),
4004
+ output: z39.string().min(1),
4005
+ /** Declared command name plus args, invoked from a clean cwd before a session. */
4006
+ smoke: z39.array(z39.string().min(1)).min(1)
4007
+ }),
4008
+ expose: z39.object({
4009
+ type: z39.literal("command"),
4010
+ commands: z39.record(z39.string().min(1), z39.array(z39.string().min(1)).min(1))
4011
+ })
4012
+ }).superRefine((resource, ctx) => {
4013
+ if (!(resource.build.smoke[0] in resource.expose.commands))
4014
+ ctx.addIssue({
4015
+ code: "custom",
4016
+ path: ["build", "smoke", 0],
4017
+ message: "Smoke command must name an exposed command"
4018
+ });
4019
+ });
4020
+ var bundleRelativeScriptSchema = z39.string().min(1).refine(
4021
+ (path2) => !path2.startsWith("/") && !path2.includes("\\") && !path2.includes("\0") && !path2.split("/").includes("..") && path2.split("/").some((part) => part !== "" && part !== "."),
4022
+ "Install script must be a bundle-relative path without traversal"
4023
+ );
4024
+ var preparedDirectoryPrepareSchema = z39.union([
4025
+ z39.object({ run: z39.string().min(1) }).strict(),
4026
+ z39.object({
4027
+ type: z39.literal("npm-cli"),
4028
+ build: z39.string().min(1).optional()
4029
+ }).strict()
4030
+ ]);
4031
+ var preparedDirectoryResourceSchema = z39.object({
4032
+ name: z39.string().min(1),
4033
+ type: z39.literal("prepared-directory"),
4034
+ source: z39.object({
4035
+ type: z39.literal("git-checkout"),
4036
+ repoUrl: z39.string().min(1),
4037
+ commit: z39.string().regex(/^[a-f0-9]{40}$/i)
4038
+ }).strict(),
4039
+ prepare: preparedDirectoryPrepareSchema,
4040
+ install: bundleRelativeScriptSchema.optional()
4041
+ }).strict().superRefine((resource, ctx) => {
4042
+ if ("type" in resource.prepare && resource.install)
4043
+ ctx.addIssue({
4044
+ code: "custom",
4045
+ path: ["install"],
4046
+ message: "npm-cli products cannot declare an install script"
4047
+ });
4048
+ });
4049
+ var runPlanResourceSchema = z39.union([
4050
+ builtDirectoryResourceSchema,
4051
+ preparedDirectoryResourceSchema
4052
+ ]);
4053
+ var runPlanSchema = z39.object({
4054
+ version: z39.literal(1),
4055
+ /** Existing launches keep their current measurement semantics. */
4056
+ measurementMode: z39.enum(["EXISTING", "AGENT_EXPERIENCE"]),
4057
+ cases: z39.array(runPlanCaseSchema).min(1),
4058
+ resources: z39.array(runPlanResourceSchema).default([]),
4059
+ /** Server-populated context retained across deferred preparation. */
4060
+ launch: z39.object({
4061
+ origin: z39.discriminatedUnion("initiator", [
4062
+ z39.object({
4063
+ initiator: z39.literal("API"),
4064
+ userId: z39.string().min(1),
4065
+ email: z39.string().nullable()
4066
+ }).strict(),
4067
+ z39.object({
4068
+ initiator: z39.literal("GITHUB"),
4069
+ userId: z39.null(),
4070
+ email: z39.null()
4071
+ }).strict()
4072
+ ]),
4073
+ funding: z39.enum(["ORG", "PLATFORM"]),
4074
+ queueClass: z39.literal("INTERACTIVE")
4075
+ }).strict().optional(),
4076
+ provenance: z39.object({
4077
+ definition: z39.object({
4078
+ repoUrl: z39.string().min(1),
4079
+ commit: z39.string().regex(/^[a-f0-9]{40}$/i),
4080
+ digest: z39.string().min(1),
4081
+ /** File submissions are asserted by the caller until server-side
4082
+ * committed-byte fetching is available. */
4083
+ verification: z39.enum(["SUBMITTED_UNVERIFIED", "GITHUB_VERIFIED"]).optional()
4084
+ }).optional(),
4085
+ liveDependencies: z39.array(
4086
+ z39.object({
4087
+ name: z39.string().min(1),
4088
+ url: z39.string().url().optional()
4089
+ })
4090
+ ).default([])
4091
+ })
4092
+ }).superRefine((plan, ctx) => {
4093
+ const resourceNames = new Set(
4094
+ plan.resources.map((resource) => resource.name)
4095
+ );
4096
+ for (const [index, item] of plan.cases.entries()) {
4097
+ if (plan.measurementMode === "AGENT_EXPERIENCE" && !item.agents.length)
4098
+ ctx.addIssue({
4099
+ code: "custom",
4100
+ path: ["cases", index, "agents"],
4101
+ message: "Agent Experience cases require a selected agent"
4102
+ });
4103
+ if (plan.measurementMode === "AGENT_EXPERIENCE" && !item.criteriaSnapshot?.criteria.length)
4104
+ ctx.addIssue({
4105
+ code: "custom",
4106
+ path: ["cases", index, "criteriaSnapshot"],
4107
+ message: "Agent Experience cases require criteria"
4108
+ });
4109
+ if (item.criteriaSnapshot && item.criteriaSnapshot.evalSetId !== (item.evalSetId ?? null))
4110
+ ctx.addIssue({
4111
+ code: "custom",
4112
+ path: ["cases", index, "criteriaSnapshot", "evalSetId"],
4113
+ message: "Criteria snapshot must belong to the case's eval"
4114
+ });
4115
+ for (const input of item.inputs) {
4116
+ if (!resourceNames.has(input))
4117
+ ctx.addIssue({
4118
+ code: "custom",
4119
+ path: ["cases", index, "inputs"],
4120
+ message: `Unknown resource: ${input}`
4121
+ });
4122
+ }
4123
+ }
4124
+ if (new Set(plan.cases.map((item) => item.id)).size !== plan.cases.length)
4125
+ ctx.addIssue({
4126
+ code: "custom",
4127
+ path: ["cases"],
4128
+ message: "Case ids must be unique"
4129
+ });
4130
+ if (resourceNames.size !== plan.resources.length)
4131
+ ctx.addIssue({
4132
+ code: "custom",
4133
+ path: ["resources"],
4134
+ message: "Resource names must be unique"
4135
+ });
4136
+ });
4137
+
4138
+ // ../packages/api-schemas/src/runDefinitions.ts
4139
+ var uncredentialedRepoUrlSchema = z40.string().min(1).refine((raw) => {
4140
+ if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(raw)) return true;
4141
+ try {
4142
+ const url = new URL(raw);
4143
+ return (url.protocol === "ssh:" || !url.username) && !url.password && !url.search && !url.hash;
4144
+ } catch {
4145
+ return false;
4146
+ }
4147
+ }, "Repository URL must not contain embedded credentials or query parameters");
4148
+ var runDefinitionConfigSchema = z40.object({
4149
+ agents: z40.array(agentConfigInputSchema).min(1),
4150
+ sampleCount: z40.number().int().min(1).max(50).optional(),
4151
+ repoUrl: uncredentialedRepoUrlSchema.nullable().optional(),
4152
+ repoRef: z40.string().min(1).nullable().optional(),
4153
+ profileId: z40.string().min(1).nullable().optional(),
4154
+ skillRefs: assetRefListSchema.optional(),
4155
+ mcpRefs: assetRefListSchema.optional(),
4156
+ connectionIds: z40.array(z40.string().min(1)).max(32).optional(),
4157
+ addons: runAddonsSchema.optional()
4158
+ }).strict();
4159
+ var githubCasePathSchema = z40.string().regex(
4160
+ /^evals\/[A-Za-z0-9_./-]+\.md$/,
4161
+ "Expected an explicit evals/*.md path"
4162
+ ).refine(
4163
+ (path2) => path2.split("/").every((part) => part !== "" && part !== "." && part !== ".."),
4164
+ "Case path must not contain traversal or empty segments"
4165
+ );
4166
+ var runDefinitionFileConfigSchema = z40.object({
4167
+ version: z40.literal(1).default(1),
4168
+ org: z40.string().min(1).optional(),
4169
+ product: z40.object({
4170
+ type: z40.literal("npm-cli"),
4171
+ build: z40.string().min(1).optional()
4172
+ }).strict().optional(),
4173
+ prepare: z40.string().min(1).optional(),
4174
+ install: bundleRelativeScriptSchema.optional(),
4175
+ github: z40.object({
4176
+ enabled: z40.literal(true),
4177
+ files: z40.array(githubCasePathSchema).min(1).max(20).refine(
4178
+ (paths) => new Set(paths).size === paths.length,
4179
+ "Case paths must be unique"
4180
+ )
4181
+ }).strict().optional()
4182
+ }).strict().superRefine((config, ctx) => {
4183
+ if (config.product && config.prepare)
4184
+ ctx.addIssue({
4185
+ code: "custom",
4186
+ path: ["product"],
4187
+ message: "product and prepare are alternatives"
4188
+ });
4189
+ if (config.product && config.install)
4190
+ ctx.addIssue({
4191
+ code: "custom",
4192
+ path: ["install"],
4193
+ message: "npm-cli products cannot declare an install script"
4194
+ });
4195
+ });
4196
+ var runDefinitionCriterionSchema = z40.object({ name: z40.string().min(1), rubric: z40.string().min(1) }).strict();
4197
+ var runDefinitionFrontmatterSchema = z40.object({
4198
+ criteria: z40.array(runDefinitionCriterionSchema).min(1),
4199
+ config: runDefinitionConfigSchema
4200
+ }).strict();
4201
+ var runDefinitionCaseSchema = z40.object({
4202
+ path: z40.string().min(1),
4203
+ prompt: z40.string().min(1),
4204
+ criteria: z40.array(runDefinitionCriterionSchema).min(1),
4205
+ config: runDefinitionConfigSchema
4206
+ }).strict();
4207
+ var runDefinitionSubmissionSchema = z40.object({
4208
+ version: z40.literal(1),
4209
+ source: z40.object({
4210
+ repoUrl: uncredentialedRepoUrlSchema,
4211
+ commit: z40.string().regex(/^[a-f0-9]{40}$/i),
4212
+ digest: z40.string().regex(/^sha256:[a-f0-9]{64}$/),
4213
+ verification: z40.enum(["SUBMITTED_UNVERIFIED", "GITHUB_VERIFIED"])
4214
+ }).strict(),
4215
+ resources: z40.array(preparedDirectoryResourceSchema).max(1).default([]),
4216
+ cases: z40.array(runDefinitionCaseSchema).min(1)
4217
+ }).strict().superRefine((definition, ctx) => {
4218
+ const paths = /* @__PURE__ */ new Set();
4219
+ for (const [index, item] of definition.cases.entries()) {
4220
+ if (paths.has(item.path))
4221
+ ctx.addIssue({
4222
+ code: "custom",
4223
+ path: ["cases", index, "path"],
4224
+ message: "Case paths must be unique"
4225
+ });
4226
+ paths.add(item.path);
4227
+ }
4228
+ for (const [index, resource] of definition.resources.entries()) {
4229
+ if (resource.name !== "project")
4230
+ ctx.addIssue({
4231
+ code: "custom",
4232
+ path: ["resources", index, "name"],
4233
+ message: "The project preparation must use the reserved name project"
4234
+ });
4235
+ if (resource.source.repoUrl !== definition.source.repoUrl || resource.source.commit !== definition.source.commit)
4236
+ ctx.addIssue({
4237
+ code: "custom",
4238
+ path: ["resources", index, "source"],
4239
+ message: "Project preparation must use the definition repository and commit"
4240
+ });
4241
+ if (!resource.source.repoUrl.startsWith("https://"))
4242
+ ctx.addIssue({
4243
+ code: "custom",
4244
+ path: ["resources", index, "source", "repoUrl"],
4245
+ message: "Project preparation requires a public HTTPS Git source"
4246
+ });
4247
+ if (!uncredentialedRepoUrlSchema.safeParse(resource.source.repoUrl).success)
4248
+ ctx.addIssue({
4249
+ code: "custom",
4250
+ path: ["resources", index, "source", "repoUrl"],
4251
+ message: "Repository URL must not contain embedded credentials or query parameters"
4252
+ });
4253
+ }
4254
+ });
4255
+ var runDefinitionPublicSubmissionSchema = runDefinitionSubmissionSchema.refine(
4256
+ (definition) => definition.source.verification === "SUBMITTED_UNVERIFIED",
4257
+ {
4258
+ path: ["source", "verification"],
4259
+ message: "Only the GitHub App may verify committed bytes"
4260
+ }
4261
+ );
4262
+ var runDefinitionPlanResponseSchema = z40.object({
4263
+ source: runDefinitionSubmissionSchema.shape.source,
4264
+ measurementMode: z40.literal("AGENT_EXPERIENCE"),
4265
+ cases: z40.array(
4266
+ z40.object({
4267
+ path: z40.string(),
4268
+ agents: z40.array(agentConfigSchema),
4269
+ samples: z40.number().int().nonnegative(),
4270
+ expectedRuns: z40.number().int().nonnegative(),
4271
+ workspace: z40.object({
4272
+ repoUrl: z40.string().nullable(),
4273
+ repoRef: z40.string().nullable()
4274
+ }),
4275
+ criteriaCount: z40.number().int().nonnegative(),
4276
+ inputs: z40.array(z40.string())
4277
+ })
4278
+ ),
4279
+ resources: z40.array(
4280
+ z40.object({ name: z40.string(), type: z40.literal("prepared-directory") })
4281
+ ),
4282
+ expectedRuns: z40.number().int().nonnegative(),
4283
+ canRun: z40.boolean()
4284
+ });
4285
+ var runDefinitionRunResponseSchema = z40.object({
4286
+ runRequestId: z40.string(),
4287
+ batchIds: z40.array(z40.string()),
4288
+ runIds: z40.array(z40.string()),
4289
+ requestedRuns: z40.number().int().nonnegative(),
4290
+ createdRuns: z40.number().int().nonnegative(),
4291
+ aggregateUrl: z40.string()
4292
+ });
4293
+
4294
+ // ../packages/api-schemas/src/runRequests.ts
4295
+ import { z as z41 } from "zod";
4296
+ var runRequestStatusSchema = z41.enum([
4297
+ "PENDING",
4298
+ "PREPARING",
4299
+ "RUNNING",
4300
+ "COMPLETED",
4301
+ "FAILED",
4302
+ "CANCELED"
4303
+ ]);
4304
+ var runRequestResultSchema = z41.enum([
4305
+ "PENDING",
4306
+ "PASSED",
4307
+ "QUALITY_FAILED",
4308
+ "EXECUTION_FAILED",
4309
+ "PREPARATION_FAILED",
4310
+ "JUDGE_FAILED",
4311
+ "INCOMPLETE",
4312
+ "CANCELED"
4313
+ ]);
4314
+ var runRequestCriterionResultSchema = z41.object({
4315
+ criterionId: z41.string().nullable(),
4316
+ name: z41.string(),
4317
+ passed: z41.boolean(),
4318
+ reasoning: z41.string().nullable()
4319
+ });
4320
+ var runRequestRunSchema = z41.object({
4321
+ id: z41.string(),
4322
+ batchId: z41.string(),
4323
+ status: z41.string(),
4324
+ agent: agentSchema,
4325
+ model: z41.string(),
4326
+ result: runRequestResultSchema,
4327
+ judge: z41.object({ status: z41.string() }).nullable(),
4328
+ criterionResults: z41.array(runRequestCriterionResultSchema)
4329
+ });
4330
+ var runRequestResponseSchema = z41.object({
4331
+ id: z41.string(),
4332
+ status: runRequestStatusSchema,
4333
+ result: runRequestResultSchema,
4334
+ settled: z41.boolean(),
4335
+ counts: z41.object({
4336
+ requestedRuns: z41.number().int().nonnegative(),
4337
+ createdRuns: z41.number().int().nonnegative(),
4338
+ terminalRuns: z41.number().int().nonnegative(),
4339
+ judgedRuns: z41.number().int().nonnegative(),
4340
+ passedRuns: z41.number().int().nonnegative(),
4341
+ qualityFailedRuns: z41.number().int().nonnegative(),
4342
+ executionFailedRuns: z41.number().int().nonnegative(),
4343
+ judgeFailedRuns: z41.number().int().nonnegative(),
4344
+ pendingRuns: z41.number().int().nonnegative()
4345
+ }),
4346
+ batches: z41.array(
4347
+ z41.object({ id: z41.string(), runs: z41.array(runRequestRunSchema) })
4348
+ ),
4349
+ createdAt: z41.string(),
4350
+ updatedAt: z41.string(),
4351
+ finishedAt: z41.string().nullable()
3350
4352
  });
3351
4353
 
3352
4354
  // ../packages/api-schemas/src/summary.ts
3353
- import { z as z37 } from "zod";
4355
+ import { z as z42 } from "zod";
3354
4356
  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() })
4357
+ return z42.union([
4358
+ z42.object({ ok: z42.literal(true), data }),
4359
+ z42.object({ ok: z42.literal(false), error: z42.string() })
3358
4360
  ]);
3359
4361
  }
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(),
4362
+ var summaryActionSchema = z42.object({
4363
+ id: z42.string(),
4364
+ title: z42.string(),
4365
+ priority: z42.string(),
4366
+ status: z42.string(),
4367
+ evidenceCount: z42.number().int()
4368
+ });
4369
+ var summaryAeCardSchema = z42.object({
4370
+ id: z42.string(),
4371
+ name: z42.string(),
4372
+ judgedRuns: z42.number().int(),
4373
+ passRate: z42.number().nullable(),
3372
4374
  /** 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()
4375
+ deltaPP: z42.number().nullable()
4376
+ });
4377
+ var summaryVisibilityCardSchema = z42.object({
4378
+ name: z42.string(),
4379
+ owned: z42.object({
4380
+ name: z42.string(),
4381
+ rank: z42.number(),
4382
+ chosenRate: z42.number(),
4383
+ mentionRate: z42.number()
3382
4384
  }).nullable(),
3383
- chosenDeltaPP: z37.number().nullable()
4385
+ chosenDeltaPP: z42.number().nullable()
3384
4386
  });
3385
- var homeSummarySchema = z37.object({
3386
- hasAnyRuns: z37.boolean(),
3387
- lastSynthesisAt: z37.string().nullable(),
3388
- actions: cardResultSchema(z37.array(summaryActionSchema)),
4387
+ var homeSummarySchema = z42.object({
4388
+ hasAnyRuns: z42.boolean(),
4389
+ lastSynthesisAt: z42.string().nullable(),
4390
+ actions: cardResultSchema(z42.array(summaryActionSchema)),
3389
4391
  visibility: cardResultSchema(
3390
- z37.object({
3391
- cards: z37.array(summaryVisibilityCardSchema),
3392
- marketsTotal: z37.number().int(),
3393
- promptCount: z37.number().int()
4392
+ z42.object({
4393
+ cards: z42.array(summaryVisibilityCardSchema),
4394
+ marketsTotal: z42.number().int(),
4395
+ promptCount: z42.number().int()
3394
4396
  })
3395
4397
  ),
3396
4398
  agentExperience: cardResultSchema(
3397
- z37.object({
3398
- cards: z37.array(summaryAeCardSchema),
3399
- total: z37.number().int(),
3400
- setCount: z37.number().int()
4399
+ z42.object({
4400
+ cards: z42.array(summaryAeCardSchema),
4401
+ total: z42.number().int(),
4402
+ setCount: z42.number().int()
3401
4403
  })
3402
4404
  ),
3403
- notableSessions: cardResultSchema(z37.array(z37.unknown()))
4405
+ notableSessions: cardResultSchema(z42.array(z42.unknown()))
3404
4406
  });
3405
4407
 
3406
4408
  // ../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(),
4409
+ import { z as z43 } from "zod";
4410
+ var apiTokenSchema = z43.object({
4411
+ id: z43.string(),
4412
+ name: z43.string(),
3411
4413
  /** 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),
4414
+ last4: z43.string(),
4415
+ expiresAt: z43.iso.datetime().nullable(),
4416
+ lastUsedAt: z43.iso.datetime().nullable(),
4417
+ createdAt: z43.iso.datetime(),
4418
+ revokedAt: z43.iso.datetime().nullable()
4419
+ });
4420
+ var createTokenRequestSchema = z43.object({
4421
+ name: z43.string().min(1).max(100),
3420
4422
  /** ISO-8601 datetime; omit for no expiry. */
3421
- expiresAt: z38.iso.datetime({ offset: true }).optional()
4423
+ expiresAt: z43.iso.datetime({ offset: true }).optional()
3422
4424
  });
3423
4425
  var createTokenResponseSchema = apiTokenSchema.extend({
3424
- token: z38.string()
4426
+ token: z43.string()
3425
4427
  });
3426
4428
  var listTokensResponseSchema = listResponseSchema(apiTokenSchema);
3427
4429
 
3428
4430
  // ../packages/api-schemas/src/visibility.ts
3429
- import { z as z39 } from "zod";
4431
+ import { z as z44 } from "zod";
3430
4432
  var VISIBILITY_PROMPT_KINDS = ["HEAD_TO_HEAD", "RECOMMEND"];
3431
- var visibilityPromptKindSchema = z39.enum(VISIBILITY_PROMPT_KINDS);
4433
+ var visibilityPromptKindSchema = z44.enum(VISIBILITY_PROMPT_KINDS);
3432
4434
  var visibilityPromptSchema = visibilityPromptSettingsSchema.extend({
3433
- id: z39.string(),
3434
- name: z39.string(),
4435
+ id: z44.string(),
4436
+ name: z44.string(),
3435
4437
  kind: visibilityPromptKindSchema,
3436
- promptText: z39.string(),
4438
+ promptText: z44.string(),
3437
4439
  /** 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(),
4440
+ branded: z44.boolean(),
4441
+ brandA: z44.string().nullable(),
4442
+ brandB: z44.string().nullable(),
4443
+ market: z44.object({ id: z44.string(), slug: z44.string(), name: z44.string() }).nullable(),
4444
+ position: z44.number().int(),
4445
+ createdAt: z44.string(),
3444
4446
  /** 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)
4447
+ tags: z44.array(z44.string()),
4448
+ runCount: z44.number().int(),
4449
+ lastRunAt: z44.string().nullable(),
4450
+ scenarios: z44.array(visibilityScenarioSchema)
3449
4451
  });
3450
- var listVisibilityPromptsResponseSchema = z39.object({
3451
- items: z39.array(visibilityPromptSchema)
4452
+ var listVisibilityPromptsResponseSchema = z44.object({
4453
+ items: z44.array(visibilityPromptSchema)
3452
4454
  });
3453
- var createVisibilityPromptBodySchema = z39.object({
3454
- name: z39.string().min(1),
3455
- promptText: z39.string().min(1),
4455
+ var createVisibilityPromptBodySchema = z44.object({
4456
+ name: z44.string().min(1),
4457
+ promptText: z44.string().min(1),
3456
4458
  kind: visibilityPromptKindSchema,
3457
- branded: z39.boolean().optional(),
4459
+ branded: z44.boolean().optional(),
3458
4460
  /** Required pair for HEAD_TO_HEAD (order-independent). */
3459
- brandA: z39.string().nullish(),
3460
- brandB: z39.string().nullish(),
4461
+ brandA: z44.string().nullish(),
4462
+ brandB: z44.string().nullish(),
3461
4463
  /** Measured market id from the org's tracked set. */
3462
- marketId: z39.string().nullish(),
3463
- tags: z39.array(z39.string()).optional(),
4464
+ marketId: z44.string().nullish(),
4465
+ tags: z44.array(z44.string()).optional(),
3464
4466
  agents: visibilityPromptSettingsInputShape.agents.optional(),
3465
4467
  skillRefs: visibilityPromptSettingsInputShape.skillRefs,
3466
4468
  mcpRefs: visibilityPromptSettingsInputShape.mcpRefs,
3467
4469
  connectionIds: visibilityPromptSettingsInputShape.connectionIds,
3468
4470
  cadence: visibilityPromptSettingsInputShape.cadence,
3469
4471
  sampleCount: visibilityPromptSettingsInputShape.sampleCount,
3470
- scenarios: z39.array(visibilityScenarioInputSchema).optional().default([])
4472
+ scenarios: z44.array(visibilityScenarioInputSchema).optional().default([])
3471
4473
  }).strict();
3472
- var synthesizeResponseSchema = z39.object({
4474
+ var synthesizeResponseSchema = z44.object({
3473
4475
  /** 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(),
4476
+ queued: z44.boolean()
4477
+ });
4478
+ var updateVisibilityPromptBodySchema = z44.object({
4479
+ name: z44.string().min(1).optional(),
4480
+ promptText: z44.string().min(1).optional(),
4481
+ branded: z44.boolean().optional(),
4482
+ brandA: z44.string().nullish(),
4483
+ brandB: z44.string().nullish(),
4484
+ marketId: z44.string().nullish(),
4485
+ tags: z44.array(z44.string()).optional(),
3484
4486
  ...visibilityPromptSettingsPatchShape,
3485
4487
  /** Replaces the whole scenario set when present. */
3486
- scenarios: z39.array(visibilityScenarioInputSchema).optional()
4488
+ scenarios: z44.array(visibilityScenarioInputSchema).optional()
3487
4489
  }).strict();
3488
- var runVisibilityPromptResponseSchema = z39.object({
3489
- batchIds: z39.array(z39.string()),
3490
- runIds: z39.array(z39.string())
4490
+ var runVisibilityPromptResponseSchema = z44.object({
4491
+ batchIds: z44.array(z44.string()),
4492
+ runIds: z44.array(z44.string())
3491
4493
  });
3492
- var visibilityPromptRunSchema = z39.object({
3493
- id: z39.string(),
3494
- status: z39.string(),
4494
+ var visibilityPromptRunSchema = z44.object({
4495
+ id: z44.string(),
4496
+ status: z44.string(),
3495
4497
  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()
4498
+ model: z44.string().nullable(),
4499
+ resolvedModel: z44.string().nullable(),
4500
+ createdAt: z44.string(),
4501
+ startedAt: z44.string().nullable(),
4502
+ finishedAt: z44.string().nullable(),
4503
+ failureReason: z44.string().nullable(),
4504
+ verdict: z44.object({
4505
+ status: z44.string(),
4506
+ error: z44.string().nullable(),
4507
+ payload: z44.unknown().nullable()
3506
4508
  }).nullable()
3507
4509
  });
3508
- var listVisibilityPromptRunsResponseSchema = z39.object({
3509
- items: z39.array(visibilityPromptRunSchema)
4510
+ var listVisibilityPromptRunsResponseSchema = z44.object({
4511
+ items: z44.array(visibilityPromptRunSchema)
3510
4512
  });
3511
- var orgMarketSchema = z39.object({
3512
- marketId: z39.string(),
3513
- slug: z39.string(),
3514
- name: z39.string(),
4513
+ var orgMarketSchema = z44.object({
4514
+ marketId: z44.string(),
4515
+ slug: z44.string(),
4516
+ name: z44.string(),
3515
4517
  /** The one line saying what the market measures. */
3516
- capability: z39.string(),
4518
+ capability: z44.string(),
3517
4519
  /** SUGGESTED (the matcher) | USER (a human picked it). */
3518
- source: z39.string()
4520
+ source: z44.string()
3519
4521
  });
3520
4522
  var addableMarketSchema = orgMarketSchema.omit({ source: true });
3521
- var listMarketsResponseSchema = z39.object({
3522
- tracked: z39.array(orgMarketSchema),
4523
+ var listMarketsResponseSchema = z44.object({
4524
+ tracked: z44.array(orgMarketSchema),
3523
4525
  /** Published markets the org does not track yet (closed set — no free-text
3524
4526
  * market creation). */
3525
- addable: z39.array(addableMarketSchema)
4527
+ addable: z44.array(addableMarketSchema)
3526
4528
  });
3527
- var addMarketBodySchema = z39.object({ marketId: z39.string().min(1) });
4529
+ var addMarketBodySchema = z44.object({ marketId: z44.string().min(1) });
3528
4530
 
3529
4531
  // src/version.ts
3530
4532
  import { createRequire } from "module";
@@ -3592,9 +4594,9 @@ function resolveToken() {
3592
4594
  return null;
3593
4595
  }
3594
4596
  }
3595
- function saveToken(token) {
4597
+ function saveToken(token2) {
3596
4598
  mkdirSync2(configDir(), { recursive: true, mode: 448 });
3597
- writeFileSync2(credentialsPath(), `${token.trim()}
4599
+ writeFileSync2(credentialsPath(), `${token2.trim()}
3598
4600
  `, {
3599
4601
  encoding: "utf8",
3600
4602
  mode: 384
@@ -3804,9 +4806,10 @@ function messageOf(error) {
3804
4806
  }
3805
4807
 
3806
4808
  // src/lib/context.ts
3807
- function resolveOrg(command) {
4809
+ function resolveOrg(command, fileOrg) {
3808
4810
  const { org } = command.optsWithGlobals();
3809
4811
  if (org) return org;
4812
+ if (fileOrg) return fileOrg;
3810
4813
  const { defaultOrg } = readConfig();
3811
4814
  if (defaultOrg) return defaultOrg;
3812
4815
  throw new CliError(
@@ -3908,7 +4911,7 @@ __export(apply_exports, {
3908
4911
  register: () => register2
3909
4912
  });
3910
4913
  import { readFileSync as readFileSync3 } from "fs";
3911
- import { z as z40 } from "zod";
4914
+ import { z as z45 } from "zod";
3912
4915
  function assertRequiredExperiment(spec, required) {
3913
4916
  if (required.length === 0) {
3914
4917
  throw new CliError(
@@ -4060,7 +5063,7 @@ function register2(program2) {
4060
5063
  ).option("--schema", "print the battery spec JSON Schema and exit").option("--example", "print a minimal example battery spec and exit").action(
4061
5064
  async (opts, command) => {
4062
5065
  if (opts.schema) {
4063
- printJson(z40.toJSONSchema(batteries_exports.batterySpecSchema));
5066
+ printJson(z45.toJSONSchema(batteries_exports.batterySpecSchema));
4064
5067
  return;
4065
5068
  }
4066
5069
  if (opts.example) {
@@ -4172,7 +5175,7 @@ async function browserLogin() {
4172
5175
  const codeVerifier = randomBytes(32).toString("base64url");
4173
5176
  const codeChallenge = createHash("sha256").update(codeVerifier).digest("base64url");
4174
5177
  const server = createServer();
4175
- const codePromise = new Promise((resolve, reject) => {
5178
+ const codePromise = new Promise((resolve2, reject) => {
4176
5179
  server.on("request", (req, res) => {
4177
5180
  const url = new URL(req.url ?? "/", "http://127.0.0.1");
4178
5181
  if (url.pathname !== "/callback") {
@@ -4195,15 +5198,15 @@ async function browserLogin() {
4195
5198
  "content-type": "text/plain; charset=utf-8"
4196
5199
  });
4197
5200
  res.end("Authorized. Return to your terminal.");
4198
- resolve(code);
5201
+ resolve2(code);
4199
5202
  });
4200
5203
  server.on(
4201
5204
  "error",
4202
5205
  (e) => reject(new CliError("network", `Loopback listener failed: ${e.message}`))
4203
5206
  );
4204
5207
  });
4205
- await new Promise((resolve) => {
4206
- server.listen(0, "127.0.0.1", resolve);
5208
+ await new Promise((resolve2) => {
5209
+ server.listen(0, "127.0.0.1", resolve2);
4207
5210
  });
4208
5211
  const address = server.address();
4209
5212
  if (!address || typeof address === "string") {
@@ -4254,9 +5257,9 @@ async function browserLogin() {
4254
5257
  );
4255
5258
  }
4256
5259
  const exchange = parsed.data;
4257
- const token = exchange.accessToken;
4258
- const me = await fetchMe(new ApiClient({ token }));
4259
- saveToken(token);
5260
+ const token2 = exchange.accessToken;
5261
+ const me = await fetchMe(new ApiClient({ token: token2 }));
5262
+ saveToken(token2);
4260
5263
  console.log(`Token saved to ${credentialsPath()}`);
4261
5264
  printIdentity(me);
4262
5265
  } finally {
@@ -4360,10 +5363,10 @@ async function deviceLogin(opts) {
4360
5363
  "The sign-in request expired before it was approved. Re-run it to try again."
4361
5364
  );
4362
5365
  case "approved": {
4363
- const token = result.accessToken;
5366
+ const token2 = result.accessToken;
4364
5367
  try {
4365
- const me = await fetchMe(new ApiClient({ token }));
4366
- return { token, me };
5368
+ const me = await fetchMe(new ApiClient({ token: token2 }));
5369
+ return { token: token2, me };
4367
5370
  } catch (e) {
4368
5371
  throw new CliError(
4369
5372
  "network",
@@ -4400,15 +5403,15 @@ async function withTokenLogin() {
4400
5403
  if (process.stdin.isTTY) {
4401
5404
  console.error("Paste your API token, then press Enter:");
4402
5405
  }
4403
- const token = (await readStdin()).trim();
4404
- if (!token.startsWith(TOKEN_PREFIX)) {
5406
+ const token2 = (await readStdin()).trim();
5407
+ if (!token2.startsWith(TOKEN_PREFIX)) {
4405
5408
  throw new CliError(
4406
5409
  "usage",
4407
5410
  `Expected a token starting with ${TOKEN_PREFIX} on stdin`
4408
5411
  );
4409
5412
  }
4410
- const me = await fetchMe(new ApiClient({ token }));
4411
- saveToken(token);
5413
+ const me = await fetchMe(new ApiClient({ token: token2 }));
5414
+ saveToken(token2);
4412
5415
  console.log(`Token saved to ${credentialsPath()}`);
4413
5416
  printIdentity(me);
4414
5417
  }
@@ -4476,8 +5479,8 @@ function register3(program2) {
4476
5479
  throw new CliError("usage", "--email requires --device.");
4477
5480
  }
4478
5481
  if (opts.device) {
4479
- const { token, me } = await deviceLogin({ email: opts.email });
4480
- saveToken(token);
5482
+ const { token: token2, me } = await deviceLogin({ email: opts.email });
5483
+ saveToken(token2);
4481
5484
  console.log(`Token saved to ${credentialsPath()}`);
4482
5485
  printIdentity(me);
4483
5486
  } else if (opts.withToken) {
@@ -4832,10 +5835,10 @@ function splitList(raw) {
4832
5835
  return raw.split(",").map((v) => v.trim()).filter(Boolean);
4833
5836
  }
4834
5837
  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();
5838
+ const sep3 = raw.lastIndexOf(":");
5839
+ if (sep3 === -1) return { name: raw.trim(), ecosystem: null };
5840
+ const name = raw.slice(0, sep3).trim();
5841
+ const ecosystem = raw.slice(sep3 + 1).trim();
4839
5842
  if (!name) throw new CliError("usage", `Invalid package "${raw}"`);
4840
5843
  if (!ECOSYSTEMS.includes(ecosystem)) {
4841
5844
  throw new CliError(
@@ -4971,7 +5974,7 @@ async function waitForCanary(id) {
4971
5974
  while (true) {
4972
5975
  const canary = await client.get(`${path}/${id}`);
4973
5976
  if (terminal.has(canary.status)) return canary;
4974
- await new Promise((resolve) => setTimeout(resolve, 1e4));
5977
+ await new Promise((resolve2) => setTimeout(resolve2, 1e4));
4975
5978
  }
4976
5979
  }
4977
5980
  function register7(program2, opts = {}) {
@@ -5204,7 +6207,7 @@ async function confirmOrAbort(question, yes) {
5204
6207
  }
5205
6208
  const rl = createInterface2({ input: process.stdin, output: process.stderr });
5206
6209
  const answer = await new Promise(
5207
- (resolve) => rl.question(`${question} [y/N] `, resolve)
6210
+ (resolve2) => rl.question(`${question} [y/N] `, resolve2)
5208
6211
  );
5209
6212
  rl.close();
5210
6213
  if (!/^y(es)?$/i.test(answer.trim())) {
@@ -5212,11 +6215,6 @@ async function confirmOrAbort(question, yes) {
5212
6215
  }
5213
6216
  }
5214
6217
 
5215
- // src/lib/staff.ts
5216
- function staffCommandsVisible(config = readConfig()) {
5217
- return config.staff === true;
5218
- }
5219
-
5220
6218
  // src/lib/ownedConfig.ts
5221
6219
  function parseCadence(raw) {
5222
6220
  const cadence = (raw ?? "NONE").trim().toUpperCase();
@@ -5406,6 +6404,202 @@ function cadenceLabel(cadence) {
5406
6404
  return cadence === "NONE" ? "manual" : cadence.toLowerCase();
5407
6405
  }
5408
6406
 
6407
+ // src/lib/runDefinitionFiles.ts
6408
+ import { execFileSync } from "child_process";
6409
+ import { isAbsolute, relative, resolve, sep } from "path";
6410
+
6411
+ // ../packages/api-schemas/src/compileRunDefinition.ts
6412
+ import { createHash as createHash2 } from "crypto";
6413
+ import { parseDocument } from "yaml";
6414
+ function utf8(bytes, path2) {
6415
+ try {
6416
+ return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
6417
+ } catch {
6418
+ throw new Error(`${path2} is not UTF-8 text`);
6419
+ }
6420
+ }
6421
+ function markdownCase(path2, bytes) {
6422
+ const source = utf8(bytes, path2);
6423
+ const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/.exec(source);
6424
+ if (!match)
6425
+ throw new Error(`${path2}: expected YAML frontmatter between --- lines`);
6426
+ const document = parseDocument(match[1], { uniqueKeys: true });
6427
+ if (document.errors.length)
6428
+ throw new Error(
6429
+ `${path2}: ${document.errors.map((error) => error.message).join("; ")}`
6430
+ );
6431
+ const parsed = runDefinitionFrontmatterSchema.safeParse(document.toJS());
6432
+ if (!parsed.success) throw new Error(`${path2}: ${parsed.error.message}`);
6433
+ const prompt = match[2].trim();
6434
+ if (!prompt) throw new Error(`${path2}: Markdown body is empty`);
6435
+ return { path: path2, prompt, ...parsed.data };
6436
+ }
6437
+ function compileRunDefinitionFromBlobs(input) {
6438
+ if (!uncredentialedRepoUrlSchema.safeParse(input.repoUrl).success)
6439
+ throw new Error("Git origin must not contain embedded credentials");
6440
+ if (!/^[a-f0-9]{40}$/i.test(input.commit))
6441
+ throw new Error("Expected a full Git commit SHA");
6442
+ if (input.casePaths.length === 0)
6443
+ throw new Error("At least one Markdown case is required");
6444
+ if (new Set(input.casePaths).size !== input.casePaths.length)
6445
+ throw new Error("Case paths must be unique");
6446
+ const configBytes = input.blobs.get("gauge.json");
6447
+ let config;
6448
+ if (configBytes) {
6449
+ try {
6450
+ config = runDefinitionFileConfigSchema.parse(
6451
+ JSON.parse(utf8(configBytes, "gauge.json"))
6452
+ );
6453
+ } catch (error) {
6454
+ throw new Error(
6455
+ `gauge.json: ${error instanceof Error ? error.message : error}`
6456
+ );
6457
+ }
6458
+ }
6459
+ const conventionalPrepare = input.blobs.has(".gauge/prepare.sh");
6460
+ if (config?.product && conventionalPrepare)
6461
+ throw new Error(
6462
+ "gauge.json: product and .gauge/prepare.sh are alternatives"
6463
+ );
6464
+ const prepare = config?.prepare ?? (conventionalPrepare ? "bash .gauge/prepare.sh" : void 0);
6465
+ const preparation = config?.product ?? (prepare ? { run: prepare } : void 0);
6466
+ if (config?.install && !prepare)
6467
+ throw new Error("gauge.json: install requires prepare");
6468
+ if (preparation && !input.repoUrl.startsWith("https://"))
6469
+ throw new Error("Project preparation requires a public HTTPS Git origin");
6470
+ const cases = input.casePaths.map((path2) => {
6471
+ const bytes = input.blobs.get(path2);
6472
+ if (!path2.endsWith(".md") || !bytes)
6473
+ throw new Error(`Missing committed Markdown case: ${path2}`);
6474
+ return markdownCase(path2, bytes);
6475
+ });
6476
+ const hash = createHash2("sha256");
6477
+ hash.update("gauge-run-definition-v1\0");
6478
+ for (const [path2, bytes] of [...input.blobs.entries()].sort(
6479
+ ([a], [b]) => a < b ? -1 : a > b ? 1 : 0
6480
+ )) {
6481
+ hash.update(path2);
6482
+ hash.update("\0");
6483
+ hash.update(String(bytes.length));
6484
+ hash.update("\0");
6485
+ hash.update(bytes);
6486
+ hash.update("\0");
6487
+ }
6488
+ const submission = runDefinitionSubmissionSchema.parse({
6489
+ version: 1,
6490
+ source: {
6491
+ repoUrl: input.repoUrl,
6492
+ commit: input.commit,
6493
+ digest: `sha256:${hash.digest("hex")}`,
6494
+ verification: input.verification
6495
+ },
6496
+ resources: preparation ? [
6497
+ {
6498
+ name: "project",
6499
+ type: "prepared-directory",
6500
+ source: {
6501
+ type: "git-checkout",
6502
+ repoUrl: input.repoUrl,
6503
+ commit: input.commit
6504
+ },
6505
+ prepare: preparation,
6506
+ ...config?.install ? { install: config.install } : {}
6507
+ }
6508
+ ] : [],
6509
+ cases
6510
+ });
6511
+ return { definition: submission, org: config?.org, github: config?.github };
6512
+ }
6513
+
6514
+ // src/lib/runDefinitionFiles.ts
6515
+ function git(cwd, args) {
6516
+ try {
6517
+ return execFileSync("git", args, {
6518
+ cwd,
6519
+ encoding: "buffer",
6520
+ maxBuffer: 10 * 1024 * 1024,
6521
+ stdio: ["ignore", "pipe", "pipe"]
6522
+ });
6523
+ } catch (error) {
6524
+ const detail = error && typeof error === "object" && "stderr" in error ? String(error.stderr).trim() : String(error);
6525
+ throw new CliError("usage", `git ${args[0]} failed: ${detail}`);
6526
+ }
6527
+ }
6528
+ function committedBlob(root, commit, path2) {
6529
+ return git(root, ["show", `${commit}:${path2}`]);
6530
+ }
6531
+ function relativeGitPath(root, cwd, input) {
6532
+ if (!input || input.includes("\0") || /[*?[\]{}]/.test(input))
6533
+ throw new CliError("usage", `expected an explicit case path: ${input}`);
6534
+ const absolute = resolve(cwd, input);
6535
+ const path2 = relative(root, absolute);
6536
+ if (!path2 || path2 === ".." || path2.startsWith(`..${sep}`) || isAbsolute(path2))
6537
+ throw new CliError(
6538
+ "usage",
6539
+ `case path is outside this Git repository: ${input}`
6540
+ );
6541
+ const gitPath = path2.split(sep).join("/");
6542
+ if (!gitPath.endsWith(".md"))
6543
+ throw new CliError("usage", `case path must end in .md: ${input}`);
6544
+ return gitPath;
6545
+ }
6546
+ function loadCommittedRunDefinitionWithContext(files, cwd = process.cwd()) {
6547
+ if (files.length === 0)
6548
+ throw new CliError("usage", "--files requires at least one Markdown path");
6549
+ const root = git(cwd, ["rev-parse", "--show-toplevel"]).toString("utf8").trim();
6550
+ const commit = git(root, ["rev-parse", "--verify", "HEAD^{commit}"]).toString("utf8").trim();
6551
+ let repoUrl;
6552
+ try {
6553
+ repoUrl = git(root, ["remote", "get-url", "origin"]).toString("utf8").trim();
6554
+ } catch {
6555
+ throw new CliError(
6556
+ "usage",
6557
+ "Git origin is required to identify the committed definition repository"
6558
+ );
6559
+ }
6560
+ if (!uncredentialedRepoUrlSchema.safeParse(repoUrl).success)
6561
+ throw new CliError(
6562
+ "usage",
6563
+ "Git origin must be a repository URL without embedded credentials or query parameters"
6564
+ );
6565
+ const paths = files.map((file) => relativeGitPath(root, cwd, file));
6566
+ if (new Set(paths).size !== paths.length)
6567
+ throw new CliError("usage", "case paths must be unique");
6568
+ const blobs = /* @__PURE__ */ new Map();
6569
+ const hasConfig = git(root, ["ls-tree", "--name-only", commit, "--", "gauge.json"]).toString("utf8").trim() === "gauge.json";
6570
+ if (hasConfig) {
6571
+ blobs.set("gauge.json", committedBlob(root, commit, "gauge.json"));
6572
+ }
6573
+ const hasConventionalPrepare = git(root, ["ls-tree", "--name-only", commit, "--", ".gauge/prepare.sh"]).toString("utf8").trim() === ".gauge/prepare.sh";
6574
+ if (hasConventionalPrepare) {
6575
+ blobs.set(
6576
+ ".gauge/prepare.sh",
6577
+ committedBlob(root, commit, ".gauge/prepare.sh")
6578
+ );
6579
+ }
6580
+ for (const path2 of paths) blobs.set(path2, committedBlob(root, commit, path2));
6581
+ try {
6582
+ const result = compileRunDefinitionFromBlobs({
6583
+ repoUrl,
6584
+ commit,
6585
+ casePaths: paths,
6586
+ blobs,
6587
+ verification: "SUBMITTED_UNVERIFIED"
6588
+ });
6589
+ return { definition: result.definition, org: result.org };
6590
+ } catch (error) {
6591
+ throw new CliError(
6592
+ "usage",
6593
+ error instanceof Error ? error.message : String(error)
6594
+ );
6595
+ }
6596
+ }
6597
+
6598
+ // src/lib/staff.ts
6599
+ function staffCommandsVisible(config = readConfig()) {
6600
+ return config.staff === true;
6601
+ }
6602
+
5409
6603
  // src/commands/evals.ts
5410
6604
  function evalSetsPath(org) {
5411
6605
  return `/api/v1/orgs/${encodeURIComponent(org)}/eval-sets`;
@@ -5484,6 +6678,40 @@ function printDetail2(e) {
5484
6678
  }
5485
6679
  function register11(program2) {
5486
6680
  const group = program2.command("evals").description("Manage eval sets (judged agent-experience measurements)");
6681
+ group.command("plan").description(
6682
+ "Validate committed Markdown cases and preview a Git-native run"
6683
+ ).requiredOption("--files <paths...>", "explicit committed Markdown paths").action(async (opts, cmd) => {
6684
+ const { definition, org: fileOrg } = loadCommittedRunDefinitionWithContext(opts.files);
6685
+ const org = resolveOrg(cmd, fileOrg);
6686
+ const result = await createClient().post(
6687
+ `/api/v1/orgs/${encodeURIComponent(org)}/run-definitions/plan`,
6688
+ definition
6689
+ );
6690
+ if (resolveOutput(cmd) === "json") {
6691
+ printJson(result);
6692
+ return;
6693
+ }
6694
+ console.log(
6695
+ `Definition: ${result.source.commit} (${result.source.digest})`
6696
+ );
6697
+ console.log(
6698
+ "Provenance: submitted by CLI; server has not verified Git bytes"
6699
+ );
6700
+ console.log(`Expected sessions: ${result.expectedRuns}`);
6701
+ for (const item of result.cases)
6702
+ console.log(
6703
+ ` ${item.path}: ${item.expectedRuns} sessions, ${item.criteriaCount} criteria`
6704
+ );
6705
+ if (result.resources.length) {
6706
+ console.log(
6707
+ `Preparations: ${result.resources.map((r) => r.name).join(", ")}`
6708
+ );
6709
+ if (!result.canRun)
6710
+ console.log(
6711
+ "Resource-backed runs cannot launch until preparation is available."
6712
+ );
6713
+ }
6714
+ });
5487
6715
  group.command("list").description("List the org's eval sets with pass-rate stats").option(
5488
6716
  "--agents <agents>",
5489
6717
  "filter stats to these agents, e.g. claude-code,codex"
@@ -5603,15 +6831,40 @@ function register11(program2) {
5603
6831
  );
5604
6832
  if (resolveOutput(cmd) !== "json") console.log(`Deleted eval set ${id}`);
5605
6833
  });
5606
- group.command("run <id>").description(
6834
+ group.command("run [id]").description(
5607
6835
  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
6836
  ).addOption(
5609
6837
  new Option2(
5610
6838
  "--bill-to-org",
5611
6839
  "bill this run to the org's credits instead (superusers)"
5612
6840
  ).hideHelp(!staffCommandsVisible())
5613
- ).option("--yes", "skip the confirmation").action(
6841
+ ).option("--files <paths...>", "explicit committed Markdown paths").option("--yes", "skip the confirmation").action(
5614
6842
  async (id, opts, cmd) => {
6843
+ if (opts.files !== void 0) {
6844
+ if (id !== void 0)
6845
+ throw new CliError(
6846
+ "usage",
6847
+ "pass either an eval ID or --files, not both"
6848
+ );
6849
+ const { definition, org: fileOrg } = loadCommittedRunDefinitionWithContext(opts.files);
6850
+ const org2 = resolveOrg(cmd, fileOrg);
6851
+ await confirmOrAbort("Run these committed eval cases now?", opts.yes);
6852
+ const result2 = await createClient().post(
6853
+ `/api/v1/orgs/${encodeURIComponent(org2)}/run-definitions/run`,
6854
+ definition,
6855
+ opts.billToOrg ? { billToOrg: true } : void 0
6856
+ );
6857
+ if (resolveOutput(cmd) === "json") printJson(result2);
6858
+ else {
6859
+ console.log(
6860
+ `Started ${result2.createdRuns}/${result2.requestedRuns} sessions in request ${result2.runRequestId}`
6861
+ );
6862
+ console.log(`Wait: gauge run-requests wait ${result2.runRequestId}`);
6863
+ }
6864
+ return;
6865
+ }
6866
+ if (id === void 0)
6867
+ throw new CliError("usage", "pass an eval ID or --files <paths...>");
5615
6868
  const org = resolveOrg(cmd);
5616
6869
  await confirmOrAbort(
5617
6870
  "Run this eval's stored configuration now?",
@@ -5707,7 +6960,7 @@ function rewriteContentType(path2, explicit) {
5707
6960
  return REWRITE_FILE_CONTENT_TYPES[extname(path2).toLowerCase()];
5708
6961
  }
5709
6962
  function sleep2(ms) {
5710
- return new Promise((resolve) => setTimeout(resolve, ms));
6963
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
5711
6964
  }
5712
6965
  function toRow3(e) {
5713
6966
  return {
@@ -6716,10 +7969,11 @@ __export(optimizations_exports2, {
6716
7969
  readSkillDir: () => readSkillDir,
6717
7970
  register: () => register19,
6718
7971
  trialBodyFromOpts: () => trialBodyFromOpts,
6719
- trialTemplate: () => trialTemplate
7972
+ trialTemplate: () => trialTemplate,
7973
+ watchStops: () => watchStops
6720
7974
  });
6721
7975
  import { readdirSync, readFileSync as readFileSync9, statSync } from "fs";
6722
- import { join as join4, relative, sep } from "path";
7976
+ import { join as join4, relative as relative2, sep as sep2 } from "path";
6723
7977
  var TERMINAL2 = /* @__PURE__ */ new Set(["DONE", "ARCHIVED"]);
6724
7978
  var EFFORTS = ["low", "medium", "high", "xhigh"];
6725
7979
  function basePath(org) {
@@ -6735,7 +7989,7 @@ function readText2(path2) {
6735
7989
  return readFileSync9(path2 === "-" ? 0 : path2, "utf8");
6736
7990
  }
6737
7991
  function sleep3(ms) {
6738
- return new Promise((resolve) => setTimeout(resolve, ms));
7992
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
6739
7993
  }
6740
7994
  function parseSubject(opts) {
6741
7995
  if (opts.eval && opts.preference)
@@ -6788,11 +8042,14 @@ var NEXT_ACTION_HINT = {
6788
8042
  LAUNCH_ROUND: "launch the saved round: `gauge optimizations launch <id>`",
6789
8043
  ADOPT: "adopt the winning trial: `gauge optimizations adopt <id> <trial>`",
6790
8044
  RESUME: "resume it: `gauge optimizations resume <id>`",
6791
- NONE: "finished"
8045
+ NONE: "nothing to do in Gauge"
6792
8046
  };
6793
8047
  function awaitingInput(detail) {
6794
8048
  return detail.nextAction !== "WAIT" && detail.nextAction !== "NONE";
6795
8049
  }
8050
+ function watchStops(detail, follow) {
8051
+ return TERMINAL2.has(detail.status) || detail.nextAction === "NONE" || !follow && awaitingInput(detail);
8052
+ }
6796
8053
  function readObject(path2) {
6797
8054
  let value;
6798
8055
  try {
@@ -6834,7 +8091,7 @@ function readSkillDir(dir, read = readText2, walk = listFiles) {
6834
8091
  if (!paths.length)
6835
8092
  throw new CliError("usage", `no files under ${dir} to send`);
6836
8093
  const files = paths.map((path2) => ({
6837
- path: relative(dir, path2).split(sep).join("/"),
8094
+ path: relative2(dir, path2).split(sep2).join("/"),
6838
8095
  body: read(path2)
6839
8096
  }));
6840
8097
  if (!files.some((file) => file.path === "SKILL.md"))
@@ -7092,6 +8349,18 @@ function printChange(content) {
7092
8349
  console.log(doc.after || "(empty)");
7093
8350
  }
7094
8351
  }
8352
+ function printRoundPreview(preview) {
8353
+ for (const trial of preview.trials) {
8354
+ console.log(trial.title);
8355
+ for (const change of trial.changes ?? []) {
8356
+ console.log(`=== ${change.path}`);
8357
+ console.log(change.hunks);
8358
+ }
8359
+ for (const path2 of trial.droppedFiles ?? [])
8360
+ console.log(` ${path2}: dropped`);
8361
+ }
8362
+ console.log(`previewDigest ${preview.previewDigest}`);
8363
+ }
7095
8364
  function printEstimate(e) {
7096
8365
  console.log(
7097
8366
  `plan: ${e.sampleCount} session${e.sampleCount === 1 ? "" : "s"} per trial \xD7 up to ${e.maxRounds} rounds`
@@ -7467,14 +8736,14 @@ function register19(program2) {
7467
8736
  let last = "";
7468
8737
  for (; ; ) {
7469
8738
  const detail = await client.get(itemPath2(org, id));
7470
- 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"}`;
8739
+ const trials2 = detail.rounds.flatMap((round2) => round2.trials);
8740
+ 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
8741
  if (line !== last) {
7473
8742
  last = line;
7474
8743
  console.error(line);
7475
8744
  }
7476
8745
  const needsInput = awaitingInput(detail);
7477
- if (TERMINAL2.has(detail.status) || !opts.follow && needsInput) {
8746
+ if (watchStops(detail, !!opts.follow)) {
7478
8747
  if (resolveOutput(cmd) === "json") printJson(detail);
7479
8748
  else printDetail4(detail);
7480
8749
  if (needsInput) process.exitCode = NEEDS_INPUT_EXIT;
@@ -7484,6 +8753,60 @@ function register19(program2) {
7484
8753
  }
7485
8754
  }
7486
8755
  );
8756
+ group.command("authoring <id>").description(
8757
+ "What the next round may change: kinds, CLI targets and commands, baseline invocations, revision"
8758
+ ).action(async (id, _opts, cmd) => {
8759
+ printJson(
8760
+ await createClient().get(`${itemPath2(resolveOrg(cmd), id)}/authoring`)
8761
+ );
8762
+ });
8763
+ group.command("invocation <id> <invocationId>").description(
8764
+ "One baseline CLI invocation from `authoring`, with its recorded command evidence"
8765
+ ).action(
8766
+ async (id, invocationId, _opts, cmd) => {
8767
+ printJson(
8768
+ await createClient().get(
8769
+ `${itemPath2(resolveOrg(cmd), id)}/authoring/target`,
8770
+ { cliInvocationId: invocationId }
8771
+ )
8772
+ );
8773
+ }
8774
+ );
8775
+ group.command("cli-change <id>").description(
8776
+ "Build a CLI_INTERVENTION bundle from {targetId, commandId, selector, operations, shippingIntent}; use the output as intervention.after in a round file. Saves nothing"
8777
+ ).requiredOption("--file <path>", "the change JSON; '-' for stdin").action(async (id, opts, cmd) => {
8778
+ printJson(
8779
+ await createClient().post(
8780
+ `${itemPath2(resolveOrg(cmd), id)}/cli-changes`,
8781
+ readObject(opts.file)
8782
+ )
8783
+ );
8784
+ });
8785
+ const round = group.command("round").description(
8786
+ "Preview and save the round waiting to launch. A round file is {revision, trials: [{trial: {title, hypothesis, lever, intervention}, files?}]}; revision comes from `authoring`"
8787
+ );
8788
+ round.command("preview <id>").description("Validate a round file and print its diff and previewDigest").requiredOption("--file <path>", "the round JSON; '-' for stdin").action(async (id, opts, cmd) => {
8789
+ const preview = await createClient().post(
8790
+ `${itemPath2(resolveOrg(cmd), id)}/rounds/current/preview`,
8791
+ readObject(opts.file)
8792
+ );
8793
+ if (resolveOutput(cmd) === "json") printJson(preview);
8794
+ else printRoundPreview(preview);
8795
+ });
8796
+ round.command("save <id>").description(
8797
+ "Save a previewed round as drafts, replacing every pending draft. Never launches"
8798
+ ).requiredOption("--file <path>", "the round JSON you previewed").requiredOption("--digest <digest>", "previewDigest from `round preview`").action(
8799
+ async (id, opts, cmd) => {
8800
+ const result = await createClient().put(
8801
+ `${itemPath2(resolveOrg(cmd), id)}/rounds/current`,
8802
+ { ...readObject(opts.file), previewDigest: opts.digest }
8803
+ );
8804
+ if (resolveOutput(cmd) === "json") printJson(result);
8805
+ else
8806
+ for (const trial of result.trials)
8807
+ console.log(`Saved ${trial.key} "${trial.title}"`);
8808
+ }
8809
+ );
7487
8810
  const trials = group.command("trials").description("List, author, and run trials");
7488
8811
  trials.command("list <id>").description("Every trial of an optimization with score and verdict").action(async (id, _opts, cmd) => {
7489
8812
  const org = resolveOrg(cmd);
@@ -7555,6 +8878,16 @@ function register19(program2) {
7555
8878
  );
7556
8879
  }
7557
8880
  );
8881
+ trials.command("remove <id> <trialId>").description("Drop one draft trial from the round waiting to launch").option("--yes", "skip the confirmation").action(
8882
+ async (id, trialId, opts, cmd) => {
8883
+ await confirmOrAbort(`Remove draft ${trialId} from ${id}?`, opts.yes);
8884
+ const detail = await createClient().delete(
8885
+ trialPath(resolveOrg(cmd), id, trialId)
8886
+ );
8887
+ if (resolveOutput(cmd) === "json") printJson(detail);
8888
+ else console.log(`Removed ${trialId}.`);
8889
+ }
8890
+ );
7558
8891
  group.command("trial <id> <trialId>").description("One trial by id or key (B0, R1.1, \u2026) with its sessions").action(
7559
8892
  async (id, trialId, _opts, cmd) => {
7560
8893
  const org = resolveOrg(cmd);
@@ -8159,10 +9492,48 @@ function register24(program2) {
8159
9492
  });
8160
9493
  }
8161
9494
 
9495
+ // src/commands/runRequests.ts
9496
+ var runRequests_exports2 = {};
9497
+ __export(runRequests_exports2, {
9498
+ register: () => register25
9499
+ });
9500
+ var pollIntervalMs = 5e3;
9501
+ function register25(program2) {
9502
+ 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) => {
9503
+ const org = resolveOrg(cmd);
9504
+ const path2 = `/api/v1/orgs/${encodeURIComponent(org)}/run-requests/${encodeURIComponent(id)}`;
9505
+ const client = createClient();
9506
+ let lastStatus = "";
9507
+ while (true) {
9508
+ const result = await client.get(path2);
9509
+ if (resolveOutput(cmd) !== "json" && result.status !== lastStatus) {
9510
+ console.error(`Run request ${id}: ${result.status}`);
9511
+ lastStatus = result.status;
9512
+ }
9513
+ if (result.settled) {
9514
+ if (resolveOutput(cmd) === "json") printJson(result);
9515
+ else {
9516
+ console.log(
9517
+ `${result.result}: ${result.counts.passedRuns}/${result.counts.createdRuns} passed sessions (${result.counts.judgedRuns} judged)`
9518
+ );
9519
+ console.log(`Request: ${result.id}`);
9520
+ }
9521
+ if (result.result !== "PASSED")
9522
+ throw new CliError(
9523
+ "internal",
9524
+ `Run request ${id}: ${result.result}`
9525
+ );
9526
+ return;
9527
+ }
9528
+ await new Promise((resolve2) => setTimeout(resolve2, pollIntervalMs));
9529
+ }
9530
+ });
9531
+ }
9532
+
8162
9533
  // src/commands/runs.ts
8163
9534
  var runs_exports2 = {};
8164
9535
  __export(runs_exports2, {
8165
- register: () => register25
9536
+ register: () => register26
8166
9537
  });
8167
9538
  function runPath(id) {
8168
9539
  return `/api/v1/runs/${encodeURIComponent(id)}`;
@@ -8422,7 +9793,7 @@ async function streamRun(id, json, opts) {
8422
9793
  if (drainTimer) clearTimeout(drainTimer);
8423
9794
  }
8424
9795
  }
8425
- function register25(program2) {
9796
+ function register26(program2) {
8426
9797
  const runs = program2.command("runs").description("Inspect and manage runs");
8427
9798
  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
9799
  async (opts, command) => {
@@ -8561,7 +9932,7 @@ function register25(program2) {
8561
9932
  var skills_exports2 = {};
8562
9933
  __export(skills_exports2, {
8563
9934
  buildSkillEditBody: () => buildSkillEditBody,
8564
- register: () => register26
9935
+ register: () => register27
8565
9936
  });
8566
9937
  function skillsPath(org) {
8567
9938
  return `/api/v1/orgs/${encodeURIComponent(org)}/skills`;
@@ -8623,7 +9994,7 @@ async function buildSkillEditBody(opts, fetchCurrentSource) {
8623
9994
  throw new CliError("usage", "nothing to change");
8624
9995
  return body;
8625
9996
  }
8626
- function register26(program2) {
9997
+ function register27(program2) {
8627
9998
  const group = program2.command("skills").description("Manage agent skills used by eval and visibility runs");
8628
9999
  group.command("list").description("List the org's skills with their newest version").action(async (_opts, cmd) => {
8629
10000
  const org = resolveOrg(cmd);
@@ -8764,7 +10135,7 @@ function register26(program2) {
8764
10135
  // src/commands/stats.ts
8765
10136
  var stats_exports2 = {};
8766
10137
  __export(stats_exports2, {
8767
- register: () => register27
10138
+ register: () => register28
8768
10139
  });
8769
10140
  function addFilterOptions(cmd) {
8770
10141
  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 +10218,7 @@ var domainRow = (r) => ({
8847
10218
  rate: pct3(r.rate),
8848
10219
  requests: r.requests
8849
10220
  });
8850
- function register27(program2) {
10221
+ function register28(program2) {
8851
10222
  const group = program2.command("stats").description("Read-only analytics over your runs");
8852
10223
  addFilterOptions(
8853
10224
  group.command("rankings").description("Brands ranked by install rate")
@@ -8879,7 +10250,7 @@ function register27(program2) {
8879
10250
  // src/commands/status.ts
8880
10251
  var status_exports = {};
8881
10252
  __export(status_exports, {
8882
- register: () => register28
10253
+ register: () => register29
8883
10254
  });
8884
10255
  function pct4(rate) {
8885
10256
  return rate == null ? "\u2014" : `${Math.round(rate * 100)}%`;
@@ -8889,7 +10260,7 @@ function delta2(pp) {
8889
10260
  const rounded = Math.round(pp);
8890
10261
  return rounded === 0 ? "" : ` (${rounded > 0 ? "+" : ""}${rounded}pp)`;
8891
10262
  }
8892
- function register28(program2) {
10263
+ function register29(program2) {
8893
10264
  program2.command("status").description("One-shot org summary: actions, visibility, agent experience").action(async (_opts, cmd) => {
8894
10265
  const org = resolveOrg(cmd);
8895
10266
  const s = await createClient().get(
@@ -8951,12 +10322,12 @@ function register28(program2) {
8951
10322
  // src/commands/tags.ts
8952
10323
  var tags_exports2 = {};
8953
10324
  __export(tags_exports2, {
8954
- register: () => register29
10325
+ register: () => register30
8955
10326
  });
8956
10327
  function tagsPath(org) {
8957
10328
  return `/api/v1/orgs/${encodeURIComponent(org)}/tags`;
8958
10329
  }
8959
- function register29(program2) {
10330
+ function register30(program2) {
8960
10331
  const group = program2.command("tags").description("Manage org tags");
8961
10332
  group.command("list").description("List tags").action(async (_opts, cmd) => {
8962
10333
  const org = resolveOrg(cmd);
@@ -8999,9 +10370,9 @@ function register29(program2) {
8999
10370
  // src/commands/usage.ts
9000
10371
  var usage_exports = {};
9001
10372
  __export(usage_exports, {
9002
- register: () => register30
10373
+ register: () => register31
9003
10374
  });
9004
- function register30(program2) {
10375
+ function register31(program2) {
9005
10376
  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
10377
  async (opts, cmd) => {
9007
10378
  const org = resolveOrg(cmd);
@@ -9048,7 +10419,7 @@ function register30(program2) {
9048
10419
  // src/commands/visibility.ts
9049
10420
  var visibility_exports2 = {};
9050
10421
  __export(visibility_exports2, {
9051
- register: () => register31,
10422
+ register: () => register32,
9052
10423
  visibilityPath: () => visibilityPath
9053
10424
  });
9054
10425
  import { Option as Option3 } from "commander";
@@ -9404,7 +10775,7 @@ function registerPreferenceGroup(group) {
9404
10775
  );
9405
10776
  });
9406
10777
  }
9407
- function register31(program2) {
10778
+ function register32(program2) {
9408
10779
  const preference = program2.command("preference").description("Manage Agent Preference prompts and measured markets");
9409
10780
  registerPreferenceGroup(preference);
9410
10781
  const legacy = program2.command("visibility", { hidden: true });
@@ -9438,6 +10809,7 @@ for (const group of [
9438
10809
  connections_exports2,
9439
10810
  repos_exports2,
9440
10811
  runs_exports2,
10812
+ runRequests_exports2,
9441
10813
  optimizations_exports2,
9442
10814
  experiments_exports2,
9443
10815
  apply_exports,