@withgauge/cli 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +2459 -1011
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -37,6 +37,8 @@ __export(batteries_exports, {
37
37
  batteryPlanSchema: () => batteryPlanSchema,
38
38
  batteryPromptSpecSchema: () => batteryPromptSpecSchema,
39
39
  batteryScheduleSpecSchema: () => batteryScheduleSpecSchema,
40
+ batterySkillRefSchema: () => batterySkillRefSchema,
41
+ batterySkillsSchema: () => batterySkillsSchema,
40
42
  batterySpecSchema: () => batterySpecSchema
41
43
  });
42
44
  import { z as z2 } from "zod";
@@ -52,7 +54,11 @@ var ERROR_CODES = [
52
54
  "needs_provider_key",
53
55
  "rate_limited",
54
56
  "conflict",
55
- "internal"
57
+ "internal",
58
+ // Recognized by CLI >= 0.6.0 only; the server sends `forbidden` with an
59
+ // instructive message until the older install base is negligible, because
60
+ // pre-0.6 clients drop the message on any code outside their enum.
61
+ "upgrade_required"
56
62
  ];
57
63
  var errorCodeSchema = z.enum(ERROR_CODES);
58
64
  var errorEnvelopeSchema = z.object({
@@ -93,6 +99,11 @@ var batteryLimitsSchema = z2.object({
93
99
  wallClockS: z2.number().positive().max(BATTERY_MAX_LIMITS.wallClockS).optional(),
94
100
  maxUsd: z2.number().positive().max(BATTERY_MAX_LIMITS.maxUsd).optional()
95
101
  });
102
+ var batterySkillRefSchema = z2.string().regex(
103
+ /^[A-Za-z0-9][A-Za-z0-9._-]*@\S+$/,
104
+ 'skills entries must be "name@label" (a bare name is a search, not a reference)'
105
+ );
106
+ var batterySkillsSchema = z2.array(batterySkillRefSchema);
96
107
  var batteryScheduleSpecSchema = z2.object({
97
108
  repoUrl: z2.string().nullish(),
98
109
  repoRef: z2.string().nullish(),
@@ -104,7 +115,10 @@ var batteryScheduleSpecSchema = z2.object({
104
115
  cadence: z2.enum(BATTERY_CADENCES).optional(),
105
116
  daysPerWeek: z2.number().int().min(1).max(7).optional(),
106
117
  experiment: z2.string().optional(),
107
- limits: batteryLimitsSchema.optional()
118
+ limits: batteryLimitsSchema.optional(),
119
+ /** ALG-217 — ordered `name@label` skill references staged into this target's
120
+ * runs. `cadence: NONE` targets only in v1. */
121
+ skills: batterySkillsSchema.optional()
108
122
  });
109
123
  var batteryDefaultsSchema = z2.object({
110
124
  isBranded: z2.boolean().optional(),
@@ -114,7 +128,9 @@ var batteryDefaultsSchema = z2.object({
114
128
  agents: z2.array(batteryAgentSchema).optional(),
115
129
  samplesPerCycle: z2.number().int().min(1).max(MAX_SAMPLES_PER_CYCLE).optional(),
116
130
  cadence: z2.enum(BATTERY_CADENCES).optional(),
117
- limits: batteryLimitsSchema.optional()
131
+ limits: batteryLimitsSchema.optional(),
132
+ /** ALG-217 — the skill set every target inherits unless it names its own. */
133
+ skills: batterySkillsSchema.optional()
118
134
  });
119
135
  var batteryPromptSpecSchema = z2.object({
120
136
  /** Idempotency key, unique per org (→ Prompt.externalKey). */
@@ -554,66 +570,227 @@ var cliAuthorizationTokenResponseSchema = z6.object({
554
570
  expiresAt: z6.string().nullable()
555
571
  });
556
572
 
573
+ // ../packages/api-schemas/src/cycles.ts
574
+ import { z as z8 } from "zod";
575
+
576
+ // ../packages/api-schemas/src/schedules.ts
577
+ import { z as z7 } from "zod";
578
+ var AGENTS = ["CLAUDE_CODE", "CODEX_CLI", "CURSOR"];
579
+ var agentSchema = z7.enum(AGENTS);
580
+ var CADENCES = [
581
+ "NONE",
582
+ "DAILY",
583
+ "WEEKLY",
584
+ "MONTHLY",
585
+ "DAYS_PER_WEEK"
586
+ ];
587
+ var cadenceSchema = z7.enum(CADENCES);
588
+ var daysPerWeekSchema = z7.number().int().min(1).max(7);
589
+ var scheduleRepoSchema = z7.object({
590
+ repoUrl: z7.string().nullable(),
591
+ /** Branch/ref; null = the repo's default branch (always null for greenfield). */
592
+ repoRef: z7.string().nullable()
593
+ });
594
+ var scheduleAgentConfigSchema = z7.object({
595
+ agent: agentSchema,
596
+ models: z7.array(z7.string().min(1)).default([])
597
+ });
598
+ var scheduleAgentConfigInputSchema = z7.object({
599
+ agent: agentSchema,
600
+ models: z7.array(z7.string().min(1)).optional(),
601
+ model: z7.string().min(1).nullish()
602
+ }).transform(({ agent, models, model }) => ({
603
+ agent,
604
+ models: models ?? (model ? [model] : [])
605
+ }));
606
+ var scheduleSchema = z7.object({
607
+ id: z7.string(),
608
+ name: z7.string(),
609
+ cadence: cadenceSchema,
610
+ /** Only set when cadence is DAYS_PER_WEEK (1–7). */
611
+ daysPerWeek: z7.number().int().nullable(),
612
+ samplesPerCycle: z7.number().int(),
613
+ /** Authoritative per-agent configuration. */
614
+ agentConfigs: z7.array(scheduleAgentConfigSchema),
615
+ /** Deprecated compatibility projection of agentConfigs. */
616
+ agents: z7.array(agentSchema),
617
+ /** Deprecated: null for schedules with per-agent pins. */
618
+ model: z7.string().nullable(),
619
+ /** Repo targets in stable expansion order; empty = the default scaffold. A
620
+ * null-repoUrl entry is greenfield alongside named repos. */
621
+ repos: z7.array(scheduleRepoSchema),
622
+ /** Cohort label for experiment analysis; null outside labeled experiments. */
623
+ experiment: z7.string().nullable(),
624
+ enabled: z7.boolean(),
625
+ lastExpandedAt: z7.string().nullable(),
626
+ /** Membership tag ids — the schedule runs the live union of these tags'
627
+ * prompts (resolved at dispatch, not stored). */
628
+ tagIds: z7.array(z7.string()),
629
+ tagCount: z7.number().int(),
630
+ /** Persona matrix (ALG-155): member UserProfile ids, in stable expansion
631
+ * order. Empty = the default, unconfigured HaikuJudge (no persona). */
632
+ profileIds: z7.array(z7.string()),
633
+ /** ALG-155.1: when profileIds is non-empty, also expand once per (prompt ×
634
+ * repo) with no persona alongside the persona batches. Ignored when
635
+ * profileIds is empty (always the implicit default judge). */
636
+ includeDefaultPersona: z7.boolean(),
637
+ createdAt: z7.string(),
638
+ updatedAt: z7.string()
639
+ });
640
+ var scheduleListResponseSchema = listResponseSchema(scheduleSchema);
641
+ var scheduleRepoInputSchema = z7.object({
642
+ /** null/omitted = the greenfield scaffold as an explicit target. */
643
+ repoUrl: z7.string().min(1).nullish(),
644
+ repoRef: z7.string().min(1).nullish()
645
+ });
646
+ var createScheduleBodyObject = z7.object({
647
+ name: z7.string().min(1, "name is required"),
648
+ cadence: cadenceSchema.default("NONE"),
649
+ daysPerWeek: daysPerWeekSchema.optional(),
650
+ samplesPerCycle: z7.number().int().min(1).default(1),
651
+ /** Preferred paired representation (per-agent model tiers). */
652
+ agentConfigs: z7.array(scheduleAgentConfigInputSchema).min(1).optional(),
653
+ /** Legacy shared-model input, accepted during the API transition. */
654
+ agents: z7.array(agentSchema).min(1, "Select at least one agent").optional(),
655
+ model: z7.string().min(1).nullish(),
656
+ /** Repo targets; empty = the default scaffold (greenfield). Add a
657
+ * null-repoUrl entry to run greenfield alongside named repos. */
658
+ repos: z7.array(scheduleRepoInputSchema).default([]),
659
+ /** Membership tag ids — the schedule runs the live union of these tags'
660
+ * prompts (specs/schedules-tags-migration.md). Must belong to the org. */
661
+ tagIds: z7.array(z7.string().min(1)).default([]),
662
+ /** Persona matrix (ALG-155): member UserProfile ids. Empty/omitted = the
663
+ * default, unconfigured HaikuJudge (no persona). */
664
+ profileIds: z7.array(z7.string().min(1)).default([]),
665
+ /** ALG-155.1: also expand once per (prompt × repo) with no persona
666
+ * alongside the persona batches, when profileIds is non-empty. Ignored
667
+ * when profileIds is empty. */
668
+ includeDefaultPersona: z7.boolean().default(false),
669
+ enabled: z7.boolean().default(true)
670
+ });
671
+ var createScheduleBodySchema = createScheduleBodyObject.refine(
672
+ (body) => body.agentConfigs !== void 0 || body.agents !== void 0,
673
+ {
674
+ message: "Select at least one agent (agentConfigs or agents)",
675
+ path: ["agentConfigs"]
676
+ }
677
+ );
678
+ var updateScheduleBodySchema = z7.object({
679
+ name: z7.string().min(1).optional(),
680
+ cadence: cadenceSchema.optional(),
681
+ daysPerWeek: daysPerWeekSchema.optional(),
682
+ samplesPerCycle: z7.number().int().min(1).optional(),
683
+ /** Full replacement of the enabled agent/model set (per-agent model tiers). */
684
+ agentConfigs: z7.array(scheduleAgentConfigInputSchema).min(1).optional(),
685
+ /** Legacy shared-model input, accepted during the API transition. */
686
+ agents: z7.array(agentSchema).min(1, "Select at least one agent").optional(),
687
+ model: z7.string().min(1).nullish(),
688
+ repos: z7.array(scheduleRepoInputSchema).optional(),
689
+ tagIds: z7.array(z7.string().min(1)).optional(),
690
+ profileIds: z7.array(z7.string().min(1)).optional(),
691
+ includeDefaultPersona: z7.boolean().optional(),
692
+ enabled: z7.boolean().optional()
693
+ });
694
+ var runScheduleResponseSchema = z7.object({
695
+ batchIds: z7.array(z7.string()),
696
+ runIds: z7.array(z7.string()),
697
+ blocked: z7.enum(["insufficient_credits", "needs_provider_key"]).optional(),
698
+ notReady: z7.array(
699
+ z7.object({
700
+ repoUrl: z7.string(),
701
+ status: z7.enum(["building", "failed", "none"])
702
+ })
703
+ ).optional()
704
+ });
705
+
706
+ // ../packages/api-schemas/src/cycles.ts
707
+ var cycleAgentSchema = z8.object({
708
+ agent: agentSchema,
709
+ /** Model pins; empty = the agent's platform default. */
710
+ models: z8.array(z8.string())
711
+ });
712
+ var cycleSchema = z8.object({
713
+ id: z8.string(),
714
+ name: z8.string(),
715
+ cadence: cadenceSchema,
716
+ samplesPerCycle: z8.number().int(),
717
+ enabled: z8.boolean(),
718
+ agents: z8.array(cycleAgentSchema)
719
+ });
720
+ var cycleWithCountsSchema = cycleSchema.extend({
721
+ evalSetCount: z8.number().int(),
722
+ visibilityPromptCount: z8.number().int()
723
+ });
724
+ var listCyclesResponseSchema = z8.object({
725
+ items: z8.array(cycleWithCountsSchema)
726
+ });
727
+ var CYCLE_CADENCES = ["NONE", "DAILY", "WEEKLY", "MONTHLY"];
728
+ var cycleCadenceSchema = z8.enum(CYCLE_CADENCES);
729
+ var updateCycleBodySchema = z8.object({
730
+ cadence: cycleCadenceSchema,
731
+ agents: z8.array(agentSchema).min(1)
732
+ });
733
+
557
734
  // ../packages/api-schemas/src/dashboards.ts
558
- import { z as z9 } from "zod";
735
+ import { z as z11 } from "zod";
559
736
 
560
737
  // ../packages/api-schemas/src/query.ts
561
- import { z as z8 } from "zod";
738
+ import { z as z10 } from "zod";
562
739
 
563
740
  // ../packages/api-schemas/src/stats.ts
564
- import { z as z7 } from "zod";
741
+ import { z as z9 } from "zod";
565
742
  var BRAND_KINDS2 = ["OWNED", "COMPETITOR", "OTHER"];
566
- var brandKindSchema2 = z7.enum(BRAND_KINDS2);
567
- var brandRankingSchema = z7.object({
568
- rank: z7.number().int(),
569
- brandId: z7.string(),
570
- brandName: z7.string(),
743
+ var brandKindSchema2 = z9.enum(BRAND_KINDS2);
744
+ var brandRankingSchema = z9.object({
745
+ rank: z9.number().int(),
746
+ brandId: z9.string(),
747
+ brandName: z9.string(),
571
748
  kind: brandKindSchema2,
572
- installs: z7.number().int(),
573
- installRate: z7.number(),
574
- mentionRate: z7.number(),
749
+ installs: z9.number().int(),
750
+ installRate: z9.number(),
751
+ mentionRate: z9.number(),
575
752
  /** Movement between the two most recent batch windows; null if not ranked in both. */
576
- deltaRank: z7.number().int().nullable()
753
+ deltaRank: z9.number().int().nullable()
577
754
  });
578
- var packageRateSchema = z7.object({
579
- ecosystem: z7.string(),
580
- name: z7.string(),
581
- brandName: z7.string().optional(),
755
+ var packageRateSchema = z9.object({
756
+ ecosystem: z9.string(),
757
+ name: z9.string(),
758
+ brandName: z9.string().optional(),
582
759
  kind: brandKindSchema2.optional(),
583
- installs: z7.number().int(),
584
- rate: z7.number()
760
+ installs: z9.number().int(),
761
+ rate: z9.number()
585
762
  });
586
- var brandRateSchema = z7.object({
587
- brandId: z7.string(),
588
- brandName: z7.string(),
763
+ var brandRateSchema = z9.object({
764
+ brandId: z9.string(),
765
+ brandName: z9.string(),
589
766
  kind: brandKindSchema2,
590
- installs: z7.number().int(),
591
- rate: z7.number()
767
+ installs: z9.number().int(),
768
+ rate: z9.number()
592
769
  });
593
- var brandFunnelRowSchema = z7.object({
594
- brandId: z7.string(),
595
- brandName: z7.string(),
770
+ var brandFunnelRowSchema = z9.object({
771
+ brandId: z9.string(),
772
+ brandName: z9.string(),
596
773
  kind: brandKindSchema2,
597
- mentionRate: z7.number(),
598
- installRate: z7.number()
599
- });
600
- var domainRateSchema = z7.object({
601
- domain: z7.string(),
602
- runs: z7.number().int(),
603
- rate: z7.number(),
604
- requests: z7.number().int(),
605
- brandName: z7.string().optional(),
606
- owned: z7.boolean().optional()
607
- });
608
- var statsFreshnessSchema = z7.object({
774
+ mentionRate: z9.number(),
775
+ installRate: z9.number()
776
+ });
777
+ var domainRateSchema = z9.object({
778
+ domain: z9.string(),
779
+ runs: z9.number().int(),
780
+ rate: z9.number(),
781
+ requests: z9.number().int(),
782
+ brandName: z9.string().optional(),
783
+ owned: z9.boolean().optional()
784
+ });
785
+ var statsFreshnessSchema = z9.object({
609
786
  /** Newest run-ingest time across the org (ISO), or null if nothing ingested. */
610
- watermark: z7.string().nullable(),
787
+ watermark: z9.string().nullable(),
611
788
  /** Runs that succeeded recently but haven't landed in the warehouse yet. */
612
- pending: z7.number().int(),
789
+ pending: z9.number().int(),
613
790
  /** False when the freshness read itself failed (distinguish from genuine zero). */
614
- available: z7.boolean()
791
+ available: z9.boolean()
615
792
  });
616
- var statsResponseSchema = (item) => z7.object({ items: z7.array(item), freshness: statsFreshnessSchema });
793
+ var statsResponseSchema = (item) => z9.object({ items: z9.array(item), freshness: statsFreshnessSchema });
617
794
  var rankingsResponseSchema = statsResponseSchema(brandRankingSchema);
618
795
  var installsResponseSchema = statsResponseSchema(packageRateSchema);
619
796
  var brandsResponseSchema = statsResponseSchema(brandRateSchema);
@@ -632,7 +809,7 @@ var DATASETS = [
632
809
  "tokens",
633
810
  "brand_rollup"
634
811
  ];
635
- var datasetSchema = z8.enum(DATASETS);
812
+ var datasetSchema = z10.enum(DATASETS);
636
813
  var WHERE_OPS = [
637
814
  "eq",
638
815
  "neq",
@@ -644,213 +821,320 @@ var WHERE_OPS = [
644
821
  "lt",
645
822
  "lte"
646
823
  ];
647
- var whereOpSchema = z8.enum(WHERE_OPS);
824
+ var whereOpSchema = z10.enum(WHERE_OPS);
648
825
  var GRANULARITIES = ["day", "week", "month"];
649
- var granularitySchema = z8.enum(GRANULARITIES);
826
+ var granularitySchema = z10.enum(GRANULARITIES);
650
827
  var DEFAULT_QUERY_LIMIT = 50;
651
828
  var MAX_QUERY_LIMIT = 1e3;
652
- var scalar = z8.union([z8.string(), z8.number(), z8.boolean()]);
653
- var whereClauseSchema = z8.object({
654
- dimension: z8.string().min(1),
829
+ var scalar = z10.union([z10.string(), z10.number(), z10.boolean()]);
830
+ var whereClauseSchema = z10.object({
831
+ dimension: z10.string().min(1),
655
832
  op: whereOpSchema,
656
- value: z8.union([scalar, z8.array(scalar)])
657
- });
658
- var queryFiltersSchema = z8.object({
659
- prompt: z8.string(),
660
- topic: z8.array(z8.string()),
661
- tag: z8.array(z8.string()),
662
- repo: z8.array(z8.string()),
663
- language: z8.array(z8.string()),
664
- framework: z8.array(z8.string()),
665
- size: z8.array(z8.string()),
666
- agent: z8.array(z8.string()),
833
+ value: z10.union([scalar, z10.array(scalar)])
834
+ });
835
+ var queryFiltersSchema = z10.object({
836
+ prompt: z10.string(),
837
+ topic: z10.array(z10.string()),
838
+ tag: z10.array(z10.string()),
839
+ repo: z10.array(z10.string()),
840
+ language: z10.array(z10.string()),
841
+ framework: z10.array(z10.string()),
842
+ size: z10.array(z10.string()),
843
+ agent: z10.array(z10.string()),
667
844
  /** Persona UserProfile ids; the NO_PERSONA sentinel = default judge. */
668
- persona: z8.array(z8.string()),
669
- model: z8.array(z8.string()),
670
- scenario: z8.array(z8.string()),
671
- experiment: z8.array(z8.string()),
672
- branded: z8.boolean()
845
+ persona: z10.array(z10.string()),
846
+ model: z10.array(z10.string()),
847
+ scenario: z10.array(z10.string()),
848
+ experiment: z10.array(z10.string()),
849
+ branded: z10.boolean()
673
850
  }).partial();
674
- var dateRangeSchema = z8.object({
675
- since: z8.string(),
676
- until: z8.string(),
677
- lastDays: z8.number().int().positive()
851
+ var dateRangeSchema = z10.object({
852
+ since: z10.string(),
853
+ until: z10.string(),
854
+ lastDays: z10.number().int().positive()
678
855
  }).partial();
679
- var orderBySchema = z8.object({
856
+ var orderBySchema = z10.object({
680
857
  /** A selected dimension or metric name. */
681
- key: z8.string().min(1),
682
- dir: z8.enum(["asc", "desc"]).default("desc")
858
+ key: z10.string().min(1),
859
+ dir: z10.enum(["asc", "desc"]).default("desc")
683
860
  });
684
- var querySpecSchema = z8.object({
861
+ var querySpecSchema = z10.object({
685
862
  dataset: datasetSchema.default("runs"),
686
- dimensions: z8.array(z8.string()).default([]),
687
- metrics: z8.array(z8.string()).min(1, "at least one metric is required"),
863
+ dimensions: z10.array(z10.string()).default([]),
864
+ metrics: z10.array(z10.string()).min(1, "at least one metric is required"),
688
865
  filters: queryFiltersSchema.default({}),
689
- where: z8.array(whereClauseSchema).default([]),
866
+ where: z10.array(whereClauseSchema).default([]),
690
867
  dateRange: dateRangeSchema.optional(),
691
- orderBy: z8.array(orderBySchema).default([]),
692
- limit: z8.number().int().min(1).max(MAX_QUERY_LIMIT).default(DEFAULT_QUERY_LIMIT),
868
+ orderBy: z10.array(orderBySchema).default([]),
869
+ limit: z10.number().int().min(1).max(MAX_QUERY_LIMIT).default(DEFAULT_QUERY_LIMIT),
693
870
  granularity: granularitySchema.default("day"),
694
871
  /** When true, the response echoes the compiled SQL (params bound, not inlined). */
695
- explain: z8.boolean().default(false)
872
+ explain: z10.boolean().default(false)
696
873
  });
697
- var columnKindSchema = z8.enum(["dimension", "metric"]);
698
- var queryColumnSchema = z8.object({
699
- key: z8.string(),
874
+ var columnKindSchema = z10.enum(["dimension", "metric"]);
875
+ var queryColumnSchema = z10.object({
876
+ key: z10.string(),
700
877
  kind: columnKindSchema
701
878
  });
702
- var queryRowSchema = z8.record(
703
- z8.string(),
704
- z8.union([z8.string(), z8.number(), z8.boolean(), z8.null()])
879
+ var queryRowSchema = z10.record(
880
+ z10.string(),
881
+ z10.union([z10.string(), z10.number(), z10.boolean(), z10.null()])
705
882
  );
706
- var queryResponseSchema = z8.object({
707
- columns: z8.array(queryColumnSchema),
708
- rows: z8.array(queryRowSchema),
883
+ var queryResponseSchema = z10.object({
884
+ columns: z10.array(queryColumnSchema),
885
+ rows: z10.array(queryRowSchema),
709
886
  /** Present only when the request set explain=true. */
710
- sql: z8.string().optional(),
887
+ sql: z10.string().optional(),
711
888
  freshness: statsFreshnessSchema
712
889
  });
713
- var fieldTypeSchema = z8.enum([
890
+ var fieldTypeSchema = z10.enum([
714
891
  "string",
715
892
  "number",
716
893
  "rate",
717
894
  "date",
718
895
  "boolean"
719
896
  ]);
720
- var fieldSchema = z8.object({
721
- name: z8.string(),
897
+ var fieldSchema = z10.object({
898
+ name: z10.string(),
722
899
  type: fieldTypeSchema,
723
900
  /** One-line human/agent hint. */
724
- description: z8.string().optional()
901
+ description: z10.string().optional()
725
902
  });
726
- var datasetMetaSchema = z8.object({
903
+ var datasetMetaSchema = z10.object({
727
904
  name: datasetSchema,
728
- grain: z8.string(),
729
- dimensions: z8.array(fieldSchema),
730
- metrics: z8.array(fieldSchema)
905
+ grain: z10.string(),
906
+ dimensions: z10.array(fieldSchema),
907
+ metrics: z10.array(fieldSchema)
731
908
  });
732
- var metadataResponseSchema = z8.object({
733
- datasets: z8.array(datasetMetaSchema)
909
+ var metadataResponseSchema = z10.object({
910
+ datasets: z10.array(datasetMetaSchema)
734
911
  });
735
912
 
736
913
  // ../packages/api-schemas/src/dashboards.ts
737
914
  var VIZ_TYPES = ["line", "bar", "table", "kpi"];
738
- var vizTypeSchema = z9.enum(VIZ_TYPES);
739
- var widgetEncodingSchema = z9.object({
740
- x: z9.string(),
915
+ var vizTypeSchema = z11.enum(VIZ_TYPES);
916
+ var widgetEncodingSchema = z11.object({
917
+ x: z11.string(),
741
918
  // dimension key for the x axis (line)
742
- series: z9.string(),
919
+ series: z11.string(),
743
920
  // dimension key split into one series per value (line)
744
- y: z9.array(z9.string())
921
+ y: z11.array(z11.string())
745
922
  // metric keys for the value axis
746
923
  }).partial();
747
924
  var widgetFields = {
748
- id: z9.string().min(1),
749
- title: z9.string(),
925
+ id: z11.string().min(1),
926
+ title: z11.string(),
750
927
  viz: vizTypeSchema,
751
928
  spec: querySpecSchema,
752
929
  // 12-col grid placement.
753
- x: z9.number().int().min(0).max(11),
754
- y: z9.number().int().min(0),
755
- w: z9.number().int().min(1).max(12),
756
- h: z9.number().int().min(1),
930
+ x: z11.number().int().min(0).max(11),
931
+ y: z11.number().int().min(0),
932
+ w: z11.number().int().min(1).max(12),
933
+ h: z11.number().int().min(1),
757
934
  encoding: widgetEncodingSchema.optional()
758
935
  };
759
- var widgetSchema = z9.object(widgetFields).refine((w) => w.x + w.w <= 12, {
936
+ var widgetSchema = z11.object(widgetFields).refine((w) => w.x + w.w <= 12, {
760
937
  message: "widget spills past the 12-column grid (x + w must be \u2264 12)"
761
938
  });
762
- var widgetPatchSchema = z9.object(widgetFields).partial();
763
- var dashboardFiltersSchema = z9.object({
939
+ var widgetPatchSchema = z11.object(widgetFields).partial();
940
+ var dashboardFiltersSchema = z11.object({
764
941
  filters: queryFiltersSchema,
765
942
  dateRange: dateRangeSchema
766
943
  }).partial();
767
- var overlayPatchSchema = z9.object({
768
- name: z9.string(),
944
+ var overlayPatchSchema = z11.object({
945
+ name: z11.string(),
769
946
  defaultFilters: dashboardFiltersSchema,
770
- widgets: z9.record(z9.string(), widgetPatchSchema.nullable()),
947
+ widgets: z11.record(z11.string(), widgetPatchSchema.nullable()),
771
948
  // Explicit widget-id ordering (for reordering and from-scratch widgets).
772
- order: z9.array(z9.string())
949
+ order: z11.array(z11.string())
773
950
  }).partial();
774
- var resolvedDashboardSchema = z9.object({
775
- key: z9.string(),
776
- name: z9.string(),
777
- widgets: z9.array(widgetSchema),
951
+ var resolvedDashboardSchema = z11.object({
952
+ key: z11.string(),
953
+ name: z11.string(),
954
+ widgets: z11.array(widgetSchema),
778
955
  defaultFilters: dashboardFiltersSchema,
779
- hasOrgOverlay: z9.boolean(),
780
- hasUserOverlay: z9.boolean()
781
- });
782
- var dashboardTemplateSchema = z9.object({
783
- key: z9.string().min(1),
784
- name: z9.string(),
785
- description: z9.string().optional(),
786
- widgets: z9.array(widgetSchema),
956
+ hasOrgOverlay: z11.boolean(),
957
+ hasUserOverlay: z11.boolean()
958
+ });
959
+ var dashboardTemplateSchema = z11.object({
960
+ key: z11.string().min(1),
961
+ name: z11.string(),
962
+ description: z11.string().optional(),
963
+ widgets: z11.array(widgetSchema),
787
964
  defaultFilters: dashboardFiltersSchema.optional()
788
965
  });
789
- var dashboardSummarySchema = z9.object({
790
- key: z9.string(),
791
- name: z9.string(),
792
- source: z9.enum(["template", "org", "user"]),
793
- isUserDefault: z9.boolean(),
794
- isOrgDefault: z9.boolean()
966
+ var dashboardSummarySchema = z11.object({
967
+ key: z11.string(),
968
+ name: z11.string(),
969
+ source: z11.enum(["template", "org", "user"]),
970
+ isUserDefault: z11.boolean(),
971
+ isOrgDefault: z11.boolean()
795
972
  });
796
973
 
797
974
  // ../packages/api-schemas/src/device.ts
798
- import { z as z10 } from "zod";
799
- var deviceAuthorizeRequestSchema = z10.object({
975
+ import { z as z12 } from "zod";
976
+ var deviceAuthorizeRequestSchema = z12.object({
800
977
  /** Device label (the CLI's hostname) for display + token naming. */
801
- deviceName: z10.string().trim().max(64).optional(),
978
+ deviceName: z12.string().trim().max(64).optional(),
802
979
  /** Optional: email a magic-link that lands on the approval page pre-scoped
803
980
  * to this device (best-effort — the printed URL always works regardless). */
804
- email: z10.string().trim().email().max(320).optional()
981
+ email: z12.string().trim().email().max(320).optional()
805
982
  });
806
- var deviceAuthorizeResponseSchema = z10.object({
983
+ var deviceAuthorizeResponseSchema = z12.object({
807
984
  /** The one-time secret the CLI polls with (never shown again). */
808
- deviceCode: z10.string(),
985
+ deviceCode: z12.string(),
809
986
  /** Short human-typed code the user confirms in the browser (e.g. WXYZ-1234). */
810
- userCode: z10.string(),
987
+ userCode: z12.string(),
811
988
  /** Where the user approves (e.g. https://…/cli/authorize). */
812
- verificationUri: z10.string(),
989
+ verificationUri: z12.string(),
813
990
  /** verificationUri with the code pre-filled, for one-click / QR. */
814
- verificationUriComplete: z10.string(),
991
+ verificationUriComplete: z12.string(),
815
992
  /** Minimum seconds between polls. */
816
- interval: z10.number().int().positive(),
993
+ interval: z12.number().int().positive(),
817
994
  /** Seconds until the device code expires. */
818
- expiresIn: z10.number().int().positive(),
995
+ expiresIn: z12.number().int().positive(),
819
996
  /** Whether a magic-link email was dispatched (best-effort). */
820
- emailSent: z10.boolean()
997
+ emailSent: z12.boolean()
821
998
  });
822
- var deviceTokenRequestSchema = z10.object({
823
- deviceCode: z10.string().min(1)
999
+ var deviceTokenRequestSchema = z12.object({
1000
+ deviceCode: z12.string().min(1)
824
1001
  });
825
- var deviceTokenApprovedSchema = z10.object({
826
- status: z10.literal("approved"),
1002
+ var deviceTokenApprovedSchema = z12.object({
1003
+ status: z12.literal("approved"),
827
1004
  /** The `gauge_…` bearer secret. Store it now — never returned again. */
828
- accessToken: z10.string(),
829
- tokenType: z10.literal("bearer"),
1005
+ accessToken: z12.string(),
1006
+ tokenType: z12.literal("bearer"),
830
1007
  /** ISO-8601 expiry, or null for no expiry. */
831
- expiresAt: z10.string().nullable()
1008
+ expiresAt: z12.string().nullable()
832
1009
  });
833
- var deviceTokenResultSchema = z10.discriminatedUnion("status", [
1010
+ var deviceTokenResultSchema = z12.discriminatedUnion("status", [
834
1011
  // Not yet approved — keep polling at `interval`.
835
- z10.object({ status: z10.literal("pending") }),
1012
+ z12.object({ status: z12.literal("pending") }),
836
1013
  // Polled faster than `interval` — back off by `interval` seconds.
837
- z10.object({ status: z10.literal("slow_down"), interval: z10.number().int() }),
1014
+ z12.object({ status: z12.literal("slow_down"), interval: z12.number().int() }),
838
1015
  // The user explicitly denied the request. Stop.
839
- z10.object({ status: z10.literal("denied") }),
1016
+ z12.object({ status: z12.literal("denied") }),
840
1017
  // The device code expired or is unknown/already-redeemed. Stop and restart.
841
- z10.object({ status: z10.literal("expired") }),
1018
+ z12.object({ status: z12.literal("expired") }),
842
1019
  deviceTokenApprovedSchema
843
1020
  ]);
844
1021
 
845
- // ../packages/api-schemas/src/experiments.ts
846
- import { z as z11 } from "zod";
847
- var contentExperimentIntentSchema = z11.object({
848
- sourceRunId: z11.string().min(1),
849
- problemText: z11.string().trim().min(1)
1022
+ // ../packages/api-schemas/src/evals.ts
1023
+ import { z as z13 } from "zod";
1024
+ var criterionSchema = z13.object({
1025
+ id: z13.string(),
1026
+ name: z13.string(),
1027
+ rubric: z13.string(),
1028
+ position: z13.number().int()
1029
+ });
1030
+ var criterionInputSchema = z13.object({
1031
+ /** Present = update in place; absent = create. */
1032
+ id: z13.string().optional(),
1033
+ name: z13.string().min(1),
1034
+ rubric: z13.string().min(1)
1035
+ });
1036
+ var evalSetSchema = z13.object({
1037
+ id: z13.string(),
1038
+ name: z13.string(),
1039
+ promptText: z13.string(),
1040
+ /** null = the greenfield scaffold. */
1041
+ repoUrl: z13.string().nullable(),
1042
+ repoRef: z13.string().nullable(),
1043
+ /** Persona judging the runs; null = the default judge. */
1044
+ profile: z13.object({ id: z13.string(), name: z13.string() }).nullable(),
1045
+ enabled: z13.boolean(),
1046
+ createdAt: z13.string(),
1047
+ cycle: cycleSchema,
1048
+ criteria: z13.array(criterionSchema),
1049
+ /** User tag names on the hidden backing prompt (Surface:* excluded). */
1050
+ tags: z13.array(z13.string())
1051
+ });
1052
+ var agentPassRateSchema = z13.object({
1053
+ agent: agentSchema,
1054
+ model: z13.string(),
1055
+ runId: z13.string(),
1056
+ finishedAt: z13.string().nullable(),
1057
+ passed: z13.number().int(),
1058
+ total: z13.number().int()
1059
+ });
1060
+ var evalSetStatSchema = z13.object({
1061
+ passRates: z13.array(agentPassRateSchema),
1062
+ runCount: z13.number().int(),
1063
+ /** Run-level aggregate: a run passes only when every criterion passed. */
1064
+ judgedRuns: z13.number().int(),
1065
+ passedRuns: z13.number().int()
1066
+ });
1067
+ var csv = z13.string().transform(
1068
+ (s) => s.split(",").map((x) => x.trim()).filter(Boolean)
1069
+ );
1070
+ var listEvalSetsQuerySchema = z13.object({
1071
+ agents: csv.pipe(z13.array(agentSchema)).optional(),
1072
+ models: csv.optional(),
1073
+ since: z13.coerce.date().optional()
1074
+ });
1075
+ var evalSetListItemSchema = evalSetSchema.extend({
1076
+ stats: evalSetStatSchema
1077
+ });
1078
+ var listEvalSetsResponseSchema = z13.object({
1079
+ items: z13.array(evalSetListItemSchema)
1080
+ });
1081
+ var createEvalSetBodySchema = z13.object({
1082
+ name: z13.string().min(1),
1083
+ promptText: z13.string().min(1),
1084
+ /** Omit/null = the greenfield scaffold. */
1085
+ repoUrl: z13.string().nullish(),
1086
+ repoRef: z13.string().nullish(),
1087
+ /** Persona id; must belong to the org. */
1088
+ profileId: z13.string().nullish(),
1089
+ criteria: z13.array(criterionInputSchema).min(1),
1090
+ enabled: z13.boolean().optional(),
1091
+ /** User tag names, create-on-type (Surface:* rejected/dropped). */
1092
+ tags: z13.array(z13.string()).optional()
1093
+ });
1094
+ var updateEvalSetBodySchema = z13.object({
1095
+ name: z13.string().min(1).optional(),
1096
+ promptText: z13.string().min(1).optional(),
1097
+ repoUrl: z13.string().nullish(),
1098
+ repoRef: z13.string().nullish(),
1099
+ profileId: z13.string().nullish(),
1100
+ criteria: z13.array(criterionInputSchema).min(1).optional(),
1101
+ enabled: z13.boolean().optional(),
1102
+ tags: z13.array(z13.string()).optional()
1103
+ });
1104
+ var runEvalSetResponseSchema = z13.object({
1105
+ batchId: z13.string(),
1106
+ runIds: z13.array(z13.string())
1107
+ });
1108
+ var evalSetRunSchema = z13.object({
1109
+ id: z13.string(),
1110
+ status: z13.string(),
1111
+ agent: agentSchema,
1112
+ model: z13.string().nullable(),
1113
+ resolvedModel: z13.string().nullable(),
1114
+ createdAt: z13.string(),
1115
+ startedAt: z13.string().nullable(),
1116
+ finishedAt: z13.string().nullable(),
1117
+ failureReason: z13.string().nullable(),
1118
+ judge: z13.object({ status: z13.string(), error: z13.string().nullable() }).nullable(),
1119
+ criterionResults: z13.array(
1120
+ z13.object({
1121
+ criterionId: z13.string().nullable(),
1122
+ name: z13.string(),
1123
+ passed: z13.boolean(),
1124
+ reasoning: z13.string().nullable()
1125
+ })
1126
+ )
850
1127
  });
1128
+ var listEvalSetRunsResponseSchema = z13.object({
1129
+ items: z13.array(evalSetRunSchema)
1130
+ });
1131
+
1132
+ // ../packages/api-schemas/src/experiments.ts
1133
+ import { z as z14 } from "zod";
851
1134
  var EXPERIMENT_STATUSES = [
852
1135
  "DRAFT",
853
1136
  "GENERATING",
1137
+ "LAUNCHING",
854
1138
  "RUNNING",
855
1139
  "SYNTHESIZING",
856
1140
  "COMPLETE",
@@ -858,135 +1142,194 @@ var EXPERIMENT_STATUSES = [
858
1142
  "FAILED",
859
1143
  "CANCELED"
860
1144
  ];
861
- var experimentStatusSchema = z11.enum(EXPERIMENT_STATUSES);
862
- var EXPERIMENT_ORIGINS = ["USER_NAMED", "DETECTED"];
863
- var experimentOriginSchema = z11.enum(EXPERIMENT_ORIGINS);
864
- var VARIANT_KINDS = ["CANDIDATE"];
865
- var variantKindSchema = z11.enum(VARIANT_KINDS);
1145
+ var experimentStatusSchema = z14.enum(EXPERIMENT_STATUSES);
866
1146
  var SUPPORT_CLASSES = [
867
1147
  "RECOMMENDED",
868
1148
  "PROMISING",
869
1149
  "NOT_SUPPORTED",
870
1150
  "NOT_EVALUABLE"
871
1151
  ];
872
- var supportClassSchema = z11.enum(SUPPORT_CLASSES);
873
- var createExperimentBodySchema = contentExperimentIntentSchema.extend({
874
- candidates: z11.number().int().optional(),
875
- samples: z11.number().int().optional()
876
- });
877
- var launchExperimentBodySchema = z11.object({
878
- samples: z11.number().int().optional()
1152
+ var supportClassSchema = z14.enum(SUPPORT_CLASSES);
1153
+ var jsonValue = z14.unknown();
1154
+ var createExperimentBodySchema = z14.object({
1155
+ runId: z14.string().min(1),
1156
+ boundarySeq: z14.string().min(1),
1157
+ problemText: z14.string().trim().min(1).optional()
1158
+ });
1159
+ var createExperimentResponseSchema = z14.object({
1160
+ experimentId: z14.string(),
1161
+ /** false = an existing draft for this (run, boundary) was resumed. */
1162
+ created: z14.boolean(),
1163
+ /** What is persisted — a resume keeps the statement it was opened with. */
1164
+ problemText: z14.string()
1165
+ });
1166
+ var experimentListQuerySchema = z14.object({
1167
+ status: z14.string().transform(
1168
+ (s) => s.split(",").map((x) => x.trim().toUpperCase()).filter(Boolean)
1169
+ ).pipe(z14.array(experimentStatusSchema)).optional(),
1170
+ limit: z14.coerce.number().int().min(1).max(100).default(25)
1171
+ });
1172
+ var experimentSummarySchema = z14.object({
1173
+ id: z14.string(),
1174
+ status: experimentStatusSchema,
1175
+ problem: z14.string(),
1176
+ boundaryUrl: z14.string().nullable(),
1177
+ sourceRunId: z14.string(),
1178
+ variantCount: z14.number().int(),
1179
+ createdAt: z14.string()
879
1180
  });
880
- var experimentListQuerySchema = z11.object({
881
- status: experimentStatusSchema.optional(),
882
- since: z11.string().optional(),
883
- limit: z11.coerce.number().int().min(1).max(100).default(50)
1181
+ var experimentListResponseSchema = z14.object({
1182
+ items: z14.array(experimentSummarySchema)
884
1183
  });
885
- var experimentSummarySchema = z11.object({
886
- id: z11.string(),
1184
+ var eligibleExperimentRunSchema = z14.object({
1185
+ runId: z14.string(),
1186
+ agent: agentSchema,
1187
+ promptText: z14.string(),
1188
+ createdAt: z14.string(),
1189
+ verdict: z14.string().nullable(),
1190
+ boundaryCount: z14.number().int()
1191
+ });
1192
+ var experimentBoundarySchema = z14.object({
1193
+ boundarySeq: z14.union([z14.string(), z14.number()]),
1194
+ turn: z14.number().int().nullable(),
1195
+ url: z14.string(),
1196
+ domain: z14.string().nullable(),
1197
+ fetchPrompt: z14.string().nullable(),
1198
+ source: z14.string(),
1199
+ boundaryCheckpointId: z14.string().nullable(),
1200
+ boundaryOrdinal: z14.number().int().nullable(),
1201
+ capturedOccurrence: z14.number().int().nullable()
1202
+ });
1203
+ var variantRunSchema = z14.object({
1204
+ runId: z14.string(),
1205
+ status: z14.string(),
1206
+ failureReason: z14.string().nullable(),
1207
+ integrations: z14.array(jsonValue)
1208
+ });
1209
+ var experimentVariantSchema = z14.object({
1210
+ variantId: z14.string(),
1211
+ key: z14.string(),
1212
+ title: z14.string(),
1213
+ hypothesis: z14.string(),
1214
+ rewriteChars: z14.number().int(),
1215
+ hasRewrite: z14.boolean(),
1216
+ invalidReason: z14.string().nullable(),
1217
+ planStatus: z14.string().nullable(),
1218
+ planError: z14.string().nullable(),
1219
+ runs: z14.array(variantRunSchema),
1220
+ /** Arm verdict / finding counts / EXPERIMENT_DELTA output — server-owned
1221
+ * analytic JSON, null until computable. */
1222
+ verdict: jsonValue.nullable(),
1223
+ findings: jsonValue.nullable(),
1224
+ delta: jsonValue.nullable()
1225
+ });
1226
+ var experimentDetailSchema = z14.object({
1227
+ id: z14.string(),
887
1228
  status: experimentStatusSchema,
888
- sourceRunId: z11.string(),
889
- problemText: z11.string(),
890
- origin: experimentOriginSchema,
891
- cohortLabel: z11.string(),
892
- createdAt: z11.string()
893
- });
894
- var experimentListResponseSchema = listResponseSchema(
895
- experimentSummarySchema
896
- );
897
- var variantSummarySchema = z11.object({
898
- id: z11.string(),
899
- key: z11.string(),
900
- kind: variantKindSchema,
901
- title: z11.string(),
902
- hypothesis: z11.string(),
903
- supportClass: supportClassSchema.nullable(),
904
- effect: z11.number().nullable(),
905
- invalidReason: z11.string().nullable(),
906
- batchId: z11.string().nullable()
907
- });
908
- var variantRefSchema = z11.object({
909
- key: z11.string(),
910
- title: z11.string(),
911
- effect: z11.number().nullable(),
912
- consistency: z11.string().nullable(),
913
- note: z11.string().nullable()
914
- });
915
- var recommendationSchema = z11.object({
916
- evaluatorVersion: z11.string(),
917
- summary: z11.string(),
918
- groups: z11.object({
919
- recommended: z11.array(variantRefSchema),
920
- promising: z11.array(variantRefSchema),
921
- notSupported: z11.array(variantRefSchema),
922
- notEvaluable: z11.array(variantRefSchema)
1229
+ problem: z14.string(),
1230
+ boundaryUrl: z14.string().nullable(),
1231
+ createdAt: z14.string(),
1232
+ editable: z14.boolean(),
1233
+ roundInFlight: z14.boolean(),
1234
+ launching: z14.boolean(),
1235
+ launchError: z14.string().nullable(),
1236
+ planned: z14.boolean(),
1237
+ livePage: jsonValue.nullable(),
1238
+ sourceRun: z14.object({
1239
+ runId: z14.string(),
1240
+ agent: agentSchema,
1241
+ status: z14.string(),
1242
+ task: z14.string(),
1243
+ repoUrl: z14.string().nullable(),
1244
+ verdict: jsonValue.nullable(),
1245
+ integrations: z14.array(jsonValue)
923
1246
  }),
924
- tradeoffs: z11.array(z11.string())
1247
+ variants: z14.array(experimentVariantSchema),
1248
+ /** The settled comparison (winners vs baseline) — null until launched. */
1249
+ summary: jsonValue.nullable()
925
1250
  });
926
- var jsonValue = z11.unknown();
927
- var experimentDetailSchema = z11.object({
928
- id: z11.string(),
929
- status: experimentStatusSchema,
930
- sourceRunId: z11.string(),
931
- problemText: z11.string(),
932
- origin: experimentOriginSchema,
933
- evaluationContract: jsonValue,
934
- recommendation: recommendationSchema.nullable(),
935
- cohortLabel: z11.string(),
936
- createdAt: z11.string(),
937
- variants: z11.array(variantSummarySchema)
938
- });
939
- var createdExperimentSchema = z11.object({
940
- id: z11.string(),
1251
+ var experimentStatusResponseSchema = z14.object({
1252
+ id: z14.string(),
941
1253
  status: experimentStatusSchema,
942
- cohortLabel: z11.string(),
943
- sourceCheckpointId: z11.string().nullable(),
944
- checkpointTurn: z11.number().int().nullable(),
945
- contract: jsonValue,
946
- variants: z11.array(
947
- z11.object({
948
- id: z11.string(),
949
- key: z11.string(),
950
- kind: variantKindSchema,
951
- invalidReason: z11.string().nullable()
952
- })
953
- )
954
- });
955
- var plannedVariantSchema = z11.object({
956
- key: z11.string(),
957
- kind: variantKindSchema,
958
- title: z11.string(),
959
- hypothesis: z11.string(),
960
- webFixtureSha256: z11.string(),
961
- invalidReason: z11.string().nullable()
962
- });
963
- var experimentPlanSchema = z11.object({
964
- sourceRunId: z11.string(),
965
- organizationId: z11.string(),
966
- problemText: z11.string(),
967
- origin: experimentOriginSchema,
968
- contract: jsonValue,
969
- variants: z11.array(plannedVariantSchema),
970
- samples: z11.number().int(),
971
- estimatedForks: z11.number().int()
972
- });
973
- var launchResultSchema = z11.object({
974
- experimentId: z11.string(),
975
- forks: z11.array(
976
- z11.object({
977
- variantId: z11.string(),
978
- key: z11.string(),
979
- batchId: z11.string(),
980
- runIds: z11.array(z11.string())
981
- })
982
- ),
983
- skipped: z11.array(
984
- z11.object({
985
- variantId: z11.string(),
986
- key: z11.string(),
987
- reason: z11.string()
988
- })
989
- )
1254
+ planned: z14.boolean(),
1255
+ writeStartedAt: z14.string().nullable(),
1256
+ launchStartedAt: z14.string().nullable(),
1257
+ launchError: z14.string().nullable(),
1258
+ shippedVariantId: z14.string().nullable(),
1259
+ shippedAt: z14.string().nullable()
1260
+ });
1261
+ var addVariantBodySchema = z14.object({
1262
+ title: z14.string().optional(),
1263
+ hypothesis: z14.string().optional()
1264
+ });
1265
+ var patchVariantBodySchema = z14.object({
1266
+ title: z14.string().optional(),
1267
+ hypothesis: z14.string().optional()
1268
+ });
1269
+ var fixerEditSchema = z14.object({
1270
+ find: z14.string().min(1),
1271
+ replace: z14.string()
1272
+ });
1273
+ var writeVariantContentBodySchema = z14.object({
1274
+ content: z14.string().optional(),
1275
+ edits: z14.array(fixerEditSchema).optional()
1276
+ });
1277
+ var writeVariantContentResponseSchema = z14.object({
1278
+ variantId: z14.string(),
1279
+ chars: z14.number().int(),
1280
+ truncated: z14.boolean(),
1281
+ applied: z14.number().int(),
1282
+ skipped: z14.number().int()
1283
+ });
1284
+ var experimentContentQuerySchema = z14.object({
1285
+ variantId: z14.string().optional(),
1286
+ offset: z14.coerce.number().int().min(0).default(0),
1287
+ maxChars: z14.coerce.number().int().min(1).max(4e4).default(2e4)
1288
+ });
1289
+ var experimentContentResponseSchema = z14.object({
1290
+ source: z14.string(),
1291
+ totalChars: z14.number().int(),
1292
+ offset: z14.number().int(),
1293
+ returnedChars: z14.number().int(),
1294
+ nextOffset: z14.number().int().nullable(),
1295
+ content: z14.string()
1296
+ });
1297
+ var writeRoundResponseSchema = z14.object({
1298
+ queued: z14.number().int(),
1299
+ reason: z14.enum(["round_in_flight", "nothing_pending"]).optional()
1300
+ });
1301
+ var launchResultSchema = z14.object({
1302
+ experimentId: z14.string(),
1303
+ status: z14.literal("LAUNCHING")
1304
+ });
1305
+ var shipBodySchema = z14.object({ variantId: z14.string().min(1) });
1306
+ var cancelResponseSchema = z14.object({
1307
+ id: z14.string(),
1308
+ status: z14.literal("CANCELED")
1309
+ });
1310
+ var variantDeltaSchema = z14.object({
1311
+ changed: z14.boolean().nullable(),
1312
+ hypothesisSupported: z14.enum(["supported", "refuted", "inconclusive"]).nullable(),
1313
+ summary: z14.string().nullable()
1314
+ });
1315
+ var variantRefSchema = z14.object({
1316
+ key: z14.string(),
1317
+ title: z14.string(),
1318
+ effect: z14.number().nullable(),
1319
+ consistency: z14.string().nullable(),
1320
+ note: z14.string().nullable(),
1321
+ delta: variantDeltaSchema.nullable().optional()
1322
+ });
1323
+ var recommendationSchema = z14.object({
1324
+ evaluatorVersion: z14.string(),
1325
+ summary: z14.string(),
1326
+ groups: z14.object({
1327
+ recommended: z14.array(variantRefSchema),
1328
+ promising: z14.array(variantRefSchema),
1329
+ notSupported: z14.array(variantRefSchema),
1330
+ notEvaluable: z14.array(variantRefSchema)
1331
+ }),
1332
+ tradeoffs: z14.array(z14.string())
990
1333
  });
991
1334
 
992
1335
  // ../packages/api-schemas/src/keys.ts
@@ -999,222 +1342,92 @@ __export(keys_exports, {
999
1342
  setProviderKeyBodySchema: () => setProviderKeyBodySchema,
1000
1343
  setProviderKeyResponseSchema: () => setProviderKeyResponseSchema
1001
1344
  });
1002
- import { z as z12 } from "zod";
1345
+ import { z as z15 } from "zod";
1003
1346
  var PROVIDER_TYPES = ["anthropic", "openai"];
1004
- var providerTypeSchema = z12.enum(PROVIDER_TYPES);
1005
- var setProviderKeyBodySchema = z12.object({
1347
+ var providerTypeSchema = z15.enum(PROVIDER_TYPES);
1348
+ var setProviderKeyBodySchema = z15.object({
1006
1349
  /** The raw provider API key. Verified + stored server-side (AWS Secrets
1007
1350
  * Manager); never persisted in the app DB and never echoed back. */
1008
- key: z12.string().min(1)
1351
+ key: z15.string().min(1)
1009
1352
  });
1010
- var setProviderKeyResponseSchema = z12.object({
1353
+ var setProviderKeyResponseSchema = z15.object({
1011
1354
  providerType: providerTypeSchema,
1012
- last4: z12.string()
1355
+ last4: z15.string()
1013
1356
  });
1014
- var providerKeySchema = z12.object({
1357
+ var providerKeySchema = z15.object({
1015
1358
  providerType: providerTypeSchema,
1016
- last4: z12.string(),
1017
- createdAt: z12.string(),
1359
+ last4: z15.string(),
1360
+ createdAt: z15.string(),
1018
1361
  /** When the key was last saved/rotated. */
1019
- updatedAt: z12.string()
1362
+ updatedAt: z15.string()
1020
1363
  });
1021
1364
  var providerKeyListResponseSchema = listResponseSchema(providerKeySchema);
1022
1365
 
1023
1366
  // ../packages/api-schemas/src/me.ts
1024
- import { z as z13 } from "zod";
1025
- var meUserSchema = z13.object({
1026
- id: z13.string(),
1027
- email: z13.string().nullable(),
1028
- isSuperuser: z13.boolean()
1367
+ import { z as z16 } from "zod";
1368
+ var meUserSchema = z16.object({
1369
+ id: z16.string(),
1370
+ email: z16.string().nullable(),
1371
+ isSuperuser: z16.boolean()
1029
1372
  });
1030
- var meOrgSchema = z13.object({
1031
- slug: z13.string(),
1373
+ var meOrgSchema = z16.object({
1374
+ slug: z16.string(),
1032
1375
  // Gauge's immutable Organization.public_id; null for LOCAL orgs.
1033
- publicId: z13.string().nullable(),
1034
- name: z13.string()
1376
+ publicId: z16.string().nullable(),
1377
+ name: z16.string()
1035
1378
  });
1036
- var meResponseSchema = z13.object({
1379
+ var meResponseSchema = z16.object({
1037
1380
  user: meUserSchema,
1038
1381
  // Membership-scoped for normal users; superusers see every org (mirrors the
1039
1382
  // web tier's userOrgs).
1040
- orgs: z13.array(meOrgSchema)
1383
+ orgs: z16.array(meOrgSchema)
1041
1384
  });
1042
1385
 
1043
1386
  // ../packages/api-schemas/src/orgs.ts
1044
- import { z as z14 } from "zod";
1045
- var createOrgRequestSchema = z14.object({
1387
+ import { z as z17 } from "zod";
1388
+ var createOrgRequestSchema = z17.object({
1046
1389
  /** Workspace display name; the slug is derived server-side. */
1047
- name: z14.string().trim().min(1).max(200),
1390
+ name: z17.string().trim().min(1).max(200),
1048
1391
  /** Optional company site (logo source; stamped onto the org). */
1049
- website: z14.string().trim().max(300).optional()
1392
+ website: z17.string().trim().max(300).optional()
1050
1393
  });
1051
- var createOrgResponseSchema = z14.object({
1052
- slug: z14.string(),
1053
- name: z14.string(),
1394
+ var createOrgResponseSchema = z17.object({
1395
+ slug: z17.string(),
1396
+ name: z17.string(),
1054
1397
  // LOCAL orgs never have a Gauge publicId.
1055
- publicId: z14.string().nullable()
1398
+ publicId: z17.string().nullable()
1056
1399
  });
1057
1400
 
1058
1401
  // ../packages/api-schemas/src/prompts.ts
1059
- import { z as z19 } from "zod";
1060
-
1061
- // ../packages/api-schemas/src/schedules.ts
1062
- import { z as z15 } from "zod";
1063
- var AGENTS = ["CLAUDE_CODE", "CODEX_CLI", "CURSOR"];
1064
- var agentSchema = z15.enum(AGENTS);
1065
- var CADENCES = [
1066
- "NONE",
1067
- "DAILY",
1068
- "WEEKLY",
1069
- "MONTHLY",
1070
- "DAYS_PER_WEEK"
1071
- ];
1072
- var cadenceSchema = z15.enum(CADENCES);
1073
- var daysPerWeekSchema = z15.number().int().min(1).max(7);
1074
- var scheduleRepoSchema = z15.object({
1075
- repoUrl: z15.string().nullable(),
1076
- /** Branch/ref; null = the repo's default branch (always null for greenfield). */
1077
- repoRef: z15.string().nullable()
1078
- });
1079
- var scheduleAgentConfigSchema = z15.object({
1080
- agent: agentSchema,
1081
- models: z15.array(z15.string().min(1)).default([])
1082
- });
1083
- var scheduleAgentConfigInputSchema = z15.object({
1084
- agent: agentSchema,
1085
- models: z15.array(z15.string().min(1)).optional(),
1086
- model: z15.string().min(1).nullish()
1087
- }).transform(({ agent, models, model }) => ({
1088
- agent,
1089
- models: models ?? (model ? [model] : [])
1090
- }));
1091
- var scheduleSchema = z15.object({
1092
- id: z15.string(),
1093
- name: z15.string(),
1094
- cadence: cadenceSchema,
1095
- /** Only set when cadence is DAYS_PER_WEEK (1–7). */
1096
- daysPerWeek: z15.number().int().nullable(),
1097
- samplesPerCycle: z15.number().int(),
1098
- /** Authoritative per-agent configuration. */
1099
- agentConfigs: z15.array(scheduleAgentConfigSchema),
1100
- /** Deprecated compatibility projection of agentConfigs. */
1101
- agents: z15.array(agentSchema),
1102
- /** Deprecated: null for schedules with per-agent pins. */
1103
- model: z15.string().nullable(),
1104
- /** Repo targets in stable expansion order; empty = the default scaffold. A
1105
- * null-repoUrl entry is greenfield alongside named repos. */
1106
- repos: z15.array(scheduleRepoSchema),
1107
- /** Cohort label for experiment analysis; null outside labeled experiments. */
1108
- experiment: z15.string().nullable(),
1109
- enabled: z15.boolean(),
1110
- lastExpandedAt: z15.string().nullable(),
1111
- /** Membership tag ids — the schedule runs the live union of these tags'
1112
- * prompts (resolved at dispatch, not stored). */
1113
- tagIds: z15.array(z15.string()),
1114
- tagCount: z15.number().int(),
1115
- /** Persona matrix (ALG-155): member UserProfile ids, in stable expansion
1116
- * order. Empty = the default, unconfigured HaikuJudge (no persona). */
1117
- profileIds: z15.array(z15.string()),
1118
- /** ALG-155.1: when profileIds is non-empty, also expand once per (prompt ×
1119
- * repo) with no persona alongside the persona batches. Ignored when
1120
- * profileIds is empty (always the implicit default judge). */
1121
- includeDefaultPersona: z15.boolean(),
1122
- createdAt: z15.string(),
1123
- updatedAt: z15.string()
1124
- });
1125
- var scheduleListResponseSchema = listResponseSchema(scheduleSchema);
1126
- var scheduleRepoInputSchema = z15.object({
1127
- /** null/omitted = the greenfield scaffold as an explicit target. */
1128
- repoUrl: z15.string().min(1).nullish(),
1129
- repoRef: z15.string().min(1).nullish()
1130
- });
1131
- var createScheduleBodyObject = z15.object({
1132
- name: z15.string().min(1, "name is required"),
1133
- cadence: cadenceSchema.default("NONE"),
1134
- daysPerWeek: daysPerWeekSchema.optional(),
1135
- samplesPerCycle: z15.number().int().min(1).default(1),
1136
- /** Preferred paired representation (per-agent model tiers). */
1137
- agentConfigs: z15.array(scheduleAgentConfigInputSchema).min(1).optional(),
1138
- /** Legacy shared-model input, accepted during the API transition. */
1139
- agents: z15.array(agentSchema).min(1, "Select at least one agent").optional(),
1140
- model: z15.string().min(1).nullish(),
1141
- /** Repo targets; empty = the default scaffold (greenfield). Add a
1142
- * null-repoUrl entry to run greenfield alongside named repos. */
1143
- repos: z15.array(scheduleRepoInputSchema).default([]),
1144
- /** Membership tag ids — the schedule runs the live union of these tags'
1145
- * prompts (specs/schedules-tags-migration.md). Must belong to the org. */
1146
- tagIds: z15.array(z15.string().min(1)).default([]),
1147
- /** Persona matrix (ALG-155): member UserProfile ids. Empty/omitted = the
1148
- * default, unconfigured HaikuJudge (no persona). */
1149
- profileIds: z15.array(z15.string().min(1)).default([]),
1150
- /** ALG-155.1: also expand once per (prompt × repo) with no persona
1151
- * alongside the persona batches, when profileIds is non-empty. Ignored
1152
- * when profileIds is empty. */
1153
- includeDefaultPersona: z15.boolean().default(false),
1154
- enabled: z15.boolean().default(true)
1155
- });
1156
- var createScheduleBodySchema = createScheduleBodyObject.refine(
1157
- (body) => body.agentConfigs !== void 0 || body.agents !== void 0,
1158
- {
1159
- message: "Select at least one agent (agentConfigs or agents)",
1160
- path: ["agentConfigs"]
1161
- }
1162
- );
1163
- var updateScheduleBodySchema = z15.object({
1164
- name: z15.string().min(1).optional(),
1165
- cadence: cadenceSchema.optional(),
1166
- daysPerWeek: daysPerWeekSchema.optional(),
1167
- samplesPerCycle: z15.number().int().min(1).optional(),
1168
- /** Full replacement of the enabled agent/model set (per-agent model tiers). */
1169
- agentConfigs: z15.array(scheduleAgentConfigInputSchema).min(1).optional(),
1170
- /** Legacy shared-model input, accepted during the API transition. */
1171
- agents: z15.array(agentSchema).min(1, "Select at least one agent").optional(),
1172
- model: z15.string().min(1).nullish(),
1173
- repos: z15.array(scheduleRepoInputSchema).optional(),
1174
- tagIds: z15.array(z15.string().min(1)).optional(),
1175
- profileIds: z15.array(z15.string().min(1)).optional(),
1176
- includeDefaultPersona: z15.boolean().optional(),
1177
- enabled: z15.boolean().optional()
1178
- });
1179
- var runScheduleResponseSchema = z15.object({
1180
- batchIds: z15.array(z15.string()),
1181
- runIds: z15.array(z15.string()),
1182
- blocked: z15.enum(["insufficient_credits", "needs_provider_key"]).optional(),
1183
- notReady: z15.array(
1184
- z15.object({
1185
- repoUrl: z15.string(),
1186
- status: z15.enum(["building", "failed", "none"])
1187
- })
1188
- ).optional()
1189
- });
1402
+ import { z as z21 } from "zod";
1190
1403
 
1191
1404
  // ../packages/api-schemas/src/tags.ts
1192
- import { z as z16 } from "zod";
1193
- var tagSchema = z16.object({
1194
- id: z16.string(),
1195
- name: z16.string(),
1405
+ import { z as z18 } from "zod";
1406
+ var tagSchema = z18.object({
1407
+ id: z18.string(),
1408
+ name: z18.string(),
1196
1409
  /** A Mantine palette name (e.g. "blue", "grape"); unknown values are
1197
1410
  * normalized server-side to the default ("gray"). */
1198
- color: z16.string()
1411
+ color: z18.string()
1199
1412
  });
1200
- var createTagBodySchema = z16.object({
1201
- name: z16.string().min(1),
1202
- color: z16.string().optional()
1413
+ var createTagBodySchema = z18.object({
1414
+ name: z18.string().min(1),
1415
+ color: z18.string().optional()
1203
1416
  });
1204
- var updateTagBodySchema = z16.object({
1205
- name: z16.string().min(1).optional(),
1206
- color: z16.string().optional()
1417
+ var updateTagBodySchema = z18.object({
1418
+ name: z18.string().min(1).optional(),
1419
+ color: z18.string().optional()
1207
1420
  });
1208
1421
  var tagListResponseSchema = listResponseSchema(tagSchema);
1209
1422
 
1210
1423
  // ../packages/api-schemas/src/topics.ts
1211
- import { z as z17 } from "zod";
1212
- var topicSchema = z17.object({
1213
- id: z17.string(),
1214
- name: z17.string()
1424
+ import { z as z19 } from "zod";
1425
+ var topicSchema = z19.object({
1426
+ id: z19.string(),
1427
+ name: z19.string()
1215
1428
  });
1216
- var createTopicBodySchema = z17.object({
1217
- name: z17.string().min(1, "name is required")
1429
+ var createTopicBodySchema = z19.object({
1430
+ name: z19.string().min(1, "name is required")
1218
1431
  });
1219
1432
  var topicListResponseSchema = listResponseSchema(topicSchema);
1220
1433
 
@@ -1224,31 +1437,31 @@ __export(web_fixtures_exports, {
1224
1437
  MAX_WEB_FIXTURE_BYTES: () => MAX_WEB_FIXTURE_BYTES,
1225
1438
  webFixtureSchema: () => webFixtureSchema
1226
1439
  });
1227
- import { z as z18 } from "zod";
1440
+ import { z as z20 } from "zod";
1228
1441
  var MAX_WEB_FIXTURE_BYTES = 1e6;
1229
1442
  function withoutFragment(raw) {
1230
1443
  const fragment = raw.indexOf("#");
1231
1444
  return fragment === -1 ? raw : raw.slice(0, fragment);
1232
1445
  }
1233
- var searchResultSchema = z18.object({
1234
- title: z18.string().min(1),
1235
- url: z18.url().transform(withoutFragment),
1236
- snippet: z18.string()
1237
- });
1238
- var searchFixtureSchema = z18.object({
1239
- query: z18.string().trim().min(1),
1240
- results: z18.array(searchResultSchema)
1241
- });
1242
- var pageFixtureSchema = z18.object({
1243
- url: z18.url().transform(withoutFragment),
1244
- status: z18.int().min(100).max(599).default(200),
1245
- contentType: z18.string().trim().min(1).default("text/html"),
1246
- body: z18.string()
1247
- });
1248
- var webFixtureSchema = z18.object({
1249
- version: z18.literal(1),
1250
- searches: z18.array(searchFixtureSchema).default([]),
1251
- pages: z18.array(pageFixtureSchema).default([])
1446
+ var searchResultSchema = z20.object({
1447
+ title: z20.string().min(1),
1448
+ url: z20.url().transform(withoutFragment),
1449
+ snippet: z20.string()
1450
+ });
1451
+ var searchFixtureSchema = z20.object({
1452
+ query: z20.string().trim().min(1),
1453
+ results: z20.array(searchResultSchema)
1454
+ });
1455
+ var pageFixtureSchema = z20.object({
1456
+ url: z20.url().transform(withoutFragment),
1457
+ status: z20.int().min(100).max(599).default(200),
1458
+ contentType: z20.string().trim().min(1).default("text/html"),
1459
+ body: z20.string()
1460
+ });
1461
+ var webFixtureSchema = z20.object({
1462
+ version: z20.literal(1),
1463
+ searches: z20.array(searchFixtureSchema).default([]),
1464
+ pages: z20.array(pageFixtureSchema).default([])
1252
1465
  }).superRefine((fixture, ctx) => {
1253
1466
  const queries = /* @__PURE__ */ new Set();
1254
1467
  fixture.searches.forEach((entry, index) => {
@@ -1282,118 +1495,124 @@ var webFixtureSchema = z18.object({
1282
1495
  });
1283
1496
 
1284
1497
  // ../packages/api-schemas/src/prompts.ts
1285
- var promptSummarySchema = z19.object({
1286
- id: z19.string(),
1287
- text: z19.string(),
1288
- isBranded: z19.boolean(),
1498
+ var promptSummarySchema = z21.object({
1499
+ id: z21.string(),
1500
+ text: z21.string(),
1501
+ isBranded: z21.boolean(),
1289
1502
  /** Battery-spec identity (idempotent applies); null for UI/CLI-created prompts. */
1290
- externalKey: z19.string().nullable(),
1503
+ externalKey: z21.string().nullable(),
1291
1504
  topic: topicSchema.nullable(),
1292
- tags: z19.array(tagSchema),
1293
- scheduleCount: z19.number().int(),
1294
- createdAt: z19.string()
1505
+ tags: z21.array(tagSchema),
1506
+ scheduleCount: z21.number().int(),
1507
+ createdAt: z21.string()
1295
1508
  });
1296
- var promptScheduleRefSchema = z19.object({
1297
- id: z19.string(),
1298
- name: z19.string(),
1509
+ var promptScheduleRefSchema = z21.object({
1510
+ id: z21.string(),
1511
+ name: z21.string(),
1299
1512
  cadence: cadenceSchema,
1300
- daysPerWeek: z19.number().int().nullable(),
1301
- enabled: z19.boolean()
1513
+ daysPerWeek: z21.number().int().nullable(),
1514
+ enabled: z21.boolean()
1302
1515
  });
1303
1516
  var promptDetailSchema = promptSummarySchema.extend({
1304
- schedules: z19.array(promptScheduleRefSchema)
1517
+ schedules: z21.array(promptScheduleRefSchema)
1305
1518
  });
1306
1519
  var promptListResponseSchema = listResponseSchema(promptSummarySchema);
1307
1520
  var listPromptsQuerySchema = listQuerySchema.extend({
1308
- topic: z19.string().min(1).optional(),
1309
- tag: z19.string().min(1).optional(),
1310
- q: z19.string().min(1).optional()
1311
- });
1312
- var createPromptBodySchema = z19.object({
1313
- text: z19.string().min(1, "text is required"),
1314
- isBranded: z19.boolean().default(false),
1315
- topic: z19.string().min(1).optional(),
1316
- tags: z19.array(z19.string().min(1)).default([])
1317
- });
1318
- var updatePromptBodySchema = z19.object({
1319
- text: z19.string().min(1).optional(),
1320
- isBranded: z19.boolean().optional(),
1321
- topicId: z19.string().min(1).nullish(),
1322
- tags: z19.array(z19.string().min(1)).optional()
1323
- });
1324
- var runPromptBodySchema = z19.object({
1521
+ topic: z21.string().min(1).optional(),
1522
+ tag: z21.string().min(1).optional(),
1523
+ q: z21.string().min(1).optional()
1524
+ });
1525
+ var createPromptBodySchema = z21.object({
1526
+ text: z21.string().min(1, "text is required"),
1527
+ isBranded: z21.boolean().default(false),
1528
+ topic: z21.string().min(1).optional(),
1529
+ tags: z21.array(z21.string().min(1)).default([])
1530
+ });
1531
+ var updatePromptBodySchema = z21.object({
1532
+ text: z21.string().min(1).optional(),
1533
+ isBranded: z21.boolean().optional(),
1534
+ topicId: z21.string().min(1).nullish(),
1535
+ tags: z21.array(z21.string().min(1)).optional()
1536
+ });
1537
+ var runPromptBodySchema = z21.object({
1325
1538
  /** Preferred paired representation; each agent may pin its own model tiers. */
1326
- agentConfigs: z19.array(scheduleAgentConfigInputSchema).min(1).optional(),
1539
+ agentConfigs: z21.array(scheduleAgentConfigInputSchema).min(1).optional(),
1327
1540
  /** Legacy agent set (no per-agent pins), kept during the API transition. */
1328
- agents: z19.array(agentSchema).min(1, "Select at least one agent").default(["CLAUDE_CODE", "CODEX_CLI"]),
1329
- repoUrl: z19.string().min(1).nullish(),
1330
- repoRef: z19.string().min(1).nullish(),
1331
- samplesPerCycle: z19.number().int().min(1).max(10).default(1),
1332
- webFixture: webFixtureSchema.optional()
1333
- });
1334
- var runPromptResponseSchema = z19.object({
1335
- batchIds: z19.array(z19.string()),
1336
- runIds: z19.array(z19.string()),
1337
- blocked: z19.enum(["insufficient_credits", "needs_provider_key"]).optional()
1541
+ agents: z21.array(agentSchema).min(1, "Select at least one agent").default(["CLAUDE_CODE", "CODEX_CLI"]),
1542
+ repoUrl: z21.string().min(1).nullish(),
1543
+ repoRef: z21.string().min(1).nullish(),
1544
+ samplesPerCycle: z21.number().int().min(1).max(10).default(1),
1545
+ webFixture: webFixtureSchema.optional(),
1546
+ /** Ordered `name@label` skill references (ALG-311 §6.7) — the SAME schema the
1547
+ * battery spec uses, so the bare-name refusal and the comma rule are shared,
1548
+ * not restated. One ordered set per launch (never a matrix dimension);
1549
+ * resolution against the org's pushed versions happens in `runPrompt`, where
1550
+ * an unresolvable reference is a 400 at launch. Empty/omitted = no skills. */
1551
+ skills: batterySkillsSchema.optional()
1552
+ });
1553
+ var runPromptResponseSchema = z21.object({
1554
+ batchIds: z21.array(z21.string()),
1555
+ runIds: z21.array(z21.string()),
1556
+ blocked: z21.enum(["insufficient_credits", "needs_provider_key"]).optional()
1338
1557
  });
1339
1558
 
1340
1559
  // ../packages/api-schemas/src/repos.ts
1341
- import { z as z20 } from "zod";
1560
+ import { z as z22 } from "zod";
1342
1561
  var REPO_SIZE_BUCKETS = [
1343
1562
  "small",
1344
1563
  "medium",
1345
1564
  "large",
1346
1565
  "xlarge"
1347
1566
  ];
1348
- var repoSizeBucketSchema = z20.enum(REPO_SIZE_BUCKETS);
1349
- var repoSchema = z20.object({
1350
- url: z20.string(),
1351
- name: z20.string(),
1352
- isSystem: z20.boolean(),
1353
- languages: z20.array(z20.string()),
1354
- frameworks: z20.array(z20.string()),
1567
+ var repoSizeBucketSchema = z22.enum(REPO_SIZE_BUCKETS);
1568
+ var repoSchema = z22.object({
1569
+ url: z22.string(),
1570
+ name: z22.string(),
1571
+ isSystem: z22.boolean(),
1572
+ languages: z22.array(z22.string()),
1573
+ frameworks: z22.array(z22.string()),
1355
1574
  /** Faceted labels (complexity:L2, buildable:yes, stack:nextjs, …). */
1356
- tags: z20.array(z20.string()),
1357
- primaryLanguage: z20.string(),
1358
- sizeKb: z20.number(),
1575
+ tags: z22.array(z22.string()),
1576
+ primaryLanguage: z22.string(),
1577
+ sizeKb: z22.number(),
1359
1578
  sizeBucket: repoSizeBucketSchema.nullable(),
1360
- stars: z20.number()
1579
+ stars: z22.number()
1361
1580
  });
1362
1581
  var repoListResponseSchema = listResponseSchema(repoSchema);
1363
- var addRepoBodySchema = z20.object({
1364
- url: z20.string().min(1, "url is required"),
1582
+ var addRepoBodySchema = z22.object({
1583
+ url: z22.string().min(1, "url is required"),
1365
1584
  /**
1366
1585
  * Reserved (accepted, not yet persisted): the catalog keys repos by URL only
1367
1586
  * — `fact_repo` has no ref column and metadata sync always reads the default
1368
1587
  * branch. Kept in the wire format so `gauge repos add --ref` is stable once
1369
1588
  * the catalog learns refs.
1370
1589
  */
1371
- ref: z20.string().min(1).optional(),
1590
+ ref: z22.string().min(1).optional(),
1372
1591
  /** Display name; defaults to the `owner/repo` label of the URL. */
1373
- name: z20.string().min(1).optional(),
1592
+ name: z22.string().min(1).optional(),
1374
1593
  /** Manual override; defaults to frameworks detected from the repo's manifests. */
1375
- frameworks: z20.array(z20.string()).optional(),
1376
- tags: z20.array(z20.string()).optional()
1594
+ frameworks: z22.array(z22.string()).optional(),
1595
+ tags: z22.array(z22.string()).optional()
1377
1596
  });
1378
- var updateRepoBodySchema = z20.object({
1379
- url: z20.string().min(1, "url is required"),
1380
- name: z20.string().min(1).optional(),
1381
- frameworks: z20.array(z20.string()).optional(),
1382
- tags: z20.array(z20.string()).optional()
1597
+ var updateRepoBodySchema = z22.object({
1598
+ url: z22.string().min(1, "url is required"),
1599
+ name: z22.string().min(1).optional(),
1600
+ frameworks: z22.array(z22.string()).optional(),
1601
+ tags: z22.array(z22.string()).optional()
1383
1602
  });
1384
- var resyncRepoBodySchema = z20.object({
1385
- url: z20.string().min(1, "url is required")
1603
+ var resyncRepoBodySchema = z22.object({
1604
+ url: z22.string().min(1, "url is required")
1386
1605
  });
1387
- var deleteRepoQuerySchema = z20.object({
1388
- url: z20.string().min(1, "url is required")
1606
+ var deleteRepoQuerySchema = z22.object({
1607
+ url: z22.string().min(1, "url is required")
1389
1608
  });
1390
- var repoSyncResultSchema = z20.object({
1609
+ var repoSyncResultSchema = z22.object({
1391
1610
  repo: repoSchema,
1392
- synced: z20.boolean()
1611
+ synced: z22.boolean()
1393
1612
  });
1394
1613
 
1395
1614
  // ../packages/api-schemas/src/runs.ts
1396
- import { z as z21 } from "zod";
1615
+ import { z as z23 } from "zod";
1397
1616
  var RUN_STATUSES = [
1398
1617
  "QUEUED",
1399
1618
  "CLAIMED",
@@ -1404,104 +1623,115 @@ var RUN_STATUSES = [
1404
1623
  "TIMED_OUT",
1405
1624
  "CANCELED"
1406
1625
  ];
1407
- var runStatusSchema = z21.enum(RUN_STATUSES);
1626
+ var runStatusSchema = z23.enum(RUN_STATUSES);
1408
1627
  var AGENTS2 = ["CLAUDE_CODE", "CODEX_CLI", "CURSOR"];
1409
- var agentSchema2 = z21.enum(AGENTS2);
1410
- var runStatusFilterSchema = z21.string().transform(
1628
+ var agentSchema2 = z23.enum(AGENTS2);
1629
+ var runStatusFilterSchema = z23.string().transform(
1411
1630
  (raw) => raw.split(",").map((s) => s.trim().toUpperCase()).filter(Boolean)
1412
- ).pipe(z21.array(runStatusSchema).min(1));
1631
+ ).pipe(z23.array(runStatusSchema).min(1));
1413
1632
  var runListQuerySchema = listQuerySchema.extend({
1414
1633
  status: runStatusFilterSchema.optional(),
1415
- batch: z21.string().optional(),
1416
- prompt: z21.string().optional(),
1417
- experiment: z21.string().optional(),
1418
- since: z21.string().optional()
1634
+ batch: z23.string().optional(),
1635
+ prompt: z23.string().optional(),
1636
+ experiment: z23.string().optional(),
1637
+ since: z23.string().optional()
1419
1638
  });
1420
- var runListItemSchema = z21.object({
1421
- id: z21.string(),
1639
+ var runListItemSchema = z23.object({
1640
+ id: z23.string(),
1422
1641
  status: runStatusSchema,
1423
1642
  agent: agentSchema2,
1424
- model: z21.string(),
1425
- promptId: z21.string(),
1643
+ model: z23.string(),
1644
+ promptId: z23.string(),
1426
1645
  /** First ~80 chars of the batch's prompt snapshot, whitespace-collapsed. */
1427
- promptSnippet: z21.string(),
1428
- batchId: z21.string(),
1429
- experiment: z21.string().nullable(),
1430
- turns: z21.number().int().nullable(),
1431
- usdCost: z21.number().nullable(),
1432
- durationMs: z21.number().int().nullable(),
1433
- exitReason: z21.string().nullable(),
1434
- createdAt: z21.string(),
1435
- startedAt: z21.string().nullable(),
1436
- finishedAt: z21.string().nullable(),
1646
+ promptSnippet: z23.string(),
1647
+ batchId: z23.string(),
1648
+ experiment: z23.string().nullable(),
1649
+ turns: z23.number().int().nullable(),
1650
+ usdCost: z23.number().nullable(),
1651
+ durationMs: z23.number().int().nullable(),
1652
+ exitReason: z23.string().nullable(),
1653
+ createdAt: z23.string(),
1654
+ startedAt: z23.string().nullable(),
1655
+ finishedAt: z23.string().nullable(),
1437
1656
  /** Fork lineage (fork-simulations WS1): the source run this was forked from,
1438
1657
  * or null for an organic run. Forks are excluded from aggregate analytics but
1439
1658
  * kept visible; consumers badge on these fields. */
1440
- parentRunId: z21.string().nullable(),
1659
+ parentRunId: z23.string().nullable(),
1441
1660
  /** Set when this run is a fetch-fork simulation variant (injected web
1442
1661
  * content); null otherwise. Distinguishes a "Simulation" badge from a plain
1443
1662
  * conversation fork. */
1444
- fetchForkPlanId: z21.string().nullable()
1663
+ fetchForkPlanId: z23.string().nullable()
1445
1664
  });
1446
1665
  var runListResponseSchema = listResponseSchema(runListItemSchema);
1447
1666
  var runDetailSchema = runListItemSchema.omit({ promptSnippet: true }).extend({
1448
- promptText: z21.string(),
1449
- attempt: z21.number().int(),
1450
- cancelRequested: z21.boolean(),
1451
- failureReason: z21.string().nullable(),
1452
- repoUrl: z21.string().nullable(),
1453
- repoRef: z21.string().nullable(),
1454
- scenario: z21.string(),
1455
- funding: z21.string(),
1667
+ promptText: z23.string(),
1668
+ attempt: z23.number().int(),
1669
+ cancelRequested: z23.boolean(),
1670
+ failureReason: z23.string().nullable(),
1671
+ repoUrl: z23.string().nullable(),
1672
+ repoRef: z23.string().nullable(),
1673
+ scenario: z23.string(),
1674
+ funding: z23.string(),
1456
1675
  /** Raw harness usage write-back (token counts etc.); shape may evolve. */
1457
- usage: z21.unknown().nullable(),
1676
+ usage: z23.unknown().nullable(),
1458
1677
  /** Artifact pointer: a working-tree diff exists at GET /runs/{id}/diff. */
1459
- hasDiff: z21.boolean(),
1460
- claimedAt: z21.string().nullable()
1678
+ hasDiff: z23.boolean(),
1679
+ claimedAt: z23.string().nullable(),
1680
+ /** Judged criteria verdicts for eval-set runs (empty otherwise). `name`
1681
+ * is the judge-time snapshot; `criterionId` is null once the criterion
1682
+ * was deleted from its set. */
1683
+ criterionResults: z23.array(
1684
+ z23.object({
1685
+ criterionId: z23.string().nullable(),
1686
+ name: z23.string(),
1687
+ passed: z23.boolean(),
1688
+ reasoning: z23.string().nullable()
1689
+ })
1690
+ )
1461
1691
  });
1462
- var cancelRunResponseSchema = z21.object({
1463
- id: z21.string(),
1692
+ var cancelRunResponseSchema = z23.object({
1693
+ id: z23.string(),
1464
1694
  status: runStatusSchema,
1465
- cancelRequested: z21.boolean(),
1466
- note: z21.string().optional()
1695
+ cancelRequested: z23.boolean(),
1696
+ note: z23.string().optional()
1467
1697
  });
1468
- var forkRunBodySchema = z21.object({
1469
- prompt: z21.string().trim().min(1).max(2e4),
1470
- turn: z21.number().int().min(0).optional(),
1698
+ var forkRunBodySchema = z23.object({
1699
+ prompt: z23.string().trim().min(1).max(2e4),
1700
+ turn: z23.number().int().min(0).optional(),
1471
1701
  webFixture: webFixtureSchema.optional()
1472
1702
  });
1473
- var forkRunResponseSchema = z21.object({
1474
- runId: z21.string(),
1475
- batchId: z21.string(),
1476
- parentRunId: z21.string(),
1477
- checkpointId: z21.string(),
1478
- turn: z21.number().int().min(0)
1703
+ var forkRunResponseSchema = z23.object({
1704
+ runId: z23.string(),
1705
+ batchId: z23.string(),
1706
+ parentRunId: z23.string(),
1707
+ checkpointId: z23.string(),
1708
+ turn: z23.number().int().min(0)
1479
1709
  });
1480
- var fetchForkAtFetchBodySchema = z21.object({
1481
- boundarySeq: z21.string().min(1),
1482
- injectedContent: z21.string(),
1483
- prompts: z21.array(z21.string()).min(1)
1710
+ var fetchForkAtFetchBodySchema = z23.object({
1711
+ boundarySeq: z23.string().min(1),
1712
+ injectedContent: z23.string(),
1713
+ prompts: z23.array(z23.string()).min(1)
1484
1714
  });
1485
- var fetchForkAtFetchResponseSchema = z21.object({
1486
- planId: z21.string()
1715
+ var fetchForkAtFetchResponseSchema = z23.object({
1716
+ planId: z23.string()
1487
1717
  });
1488
- var fetchForkPlanStatusSchema = z21.enum([
1718
+ var fetchForkPlanStatusSchema = z23.enum([
1489
1719
  "DRAFT",
1490
1720
  "SURGERY_RUNNING",
1491
1721
  "SURGERY_READY",
1492
1722
  "FORKED",
1493
1723
  "FAILED"
1494
1724
  ]);
1495
- var fetchForkPlanResponseSchema = z21.object({
1496
- id: z21.string(),
1725
+ var fetchForkPlanResponseSchema = z23.object({
1726
+ id: z23.string(),
1497
1727
  status: fetchForkPlanStatusSchema,
1498
- boundaryUrl: z21.string(),
1499
- boundaryTurn: z21.number().int(),
1500
- prompts: z21.array(z21.string()),
1501
- surgicalCheckpointId: z21.string().nullable(),
1502
- forkBatchId: z21.string().nullable(),
1503
- errorText: z21.string().nullable(),
1504
- forkedRunIds: z21.array(z21.string())
1728
+ boundaryUrl: z23.string(),
1729
+ boundaryTurn: z23.number().int(),
1730
+ prompts: z23.array(z23.string()),
1731
+ surgicalCheckpointId: z23.string().nullable(),
1732
+ forkBatchId: z23.string().nullable(),
1733
+ errorText: z23.string().nullable(),
1734
+ forkedRunIds: z23.array(z23.string())
1505
1735
  });
1506
1736
  var RUN_INSIGHT_STATUSES = [
1507
1737
  "PENDING",
@@ -1510,72 +1740,212 @@ var RUN_INSIGHT_STATUSES = [
1510
1740
  "FAILED",
1511
1741
  "SKIPPED"
1512
1742
  ];
1513
- var runInsightStatusSchema = z21.enum(RUN_INSIGHT_STATUSES);
1514
- var insightPassSchema = z21.object({
1743
+ var runInsightStatusSchema = z23.enum(RUN_INSIGHT_STATUSES);
1744
+ var insightPassSchema = z23.object({
1515
1745
  status: runInsightStatusSchema,
1516
- model: z21.string().nullable(),
1517
- inputTokens: z21.number().int().nullable(),
1518
- outputTokens: z21.number().int().nullable(),
1519
- usdCost: z21.number().nullable(),
1520
- error: z21.string().nullable()
1521
- });
1522
- var runDecisionSchema = z21.object({
1523
- index: z21.number().int(),
1524
- category: z21.string(),
1525
- categoryRaw: z21.string().nullable(),
1526
- chosenName: z21.string(),
1527
- chosenEcosystem: z21.string().nullable(),
1528
- chosenPackage: z21.string().nullable(),
1529
- reversed: z21.boolean(),
1530
- detail: z21.unknown()
1531
- });
1532
- var runImplementationSchema = z21.object({
1533
- brandName: z21.string(),
1534
- ecosystem: z21.string().nullable(),
1535
- package: z21.string().nullable(),
1536
- verdict: z21.string(),
1537
- docConsulted: z21.boolean(),
1538
- detail: z21.unknown()
1539
- });
1540
- var runInsightResponseSchema = z21.object({
1541
- runId: z21.string(),
1746
+ model: z23.string().nullable(),
1747
+ inputTokens: z23.number().int().nullable(),
1748
+ outputTokens: z23.number().int().nullable(),
1749
+ usdCost: z23.number().nullable(),
1750
+ error: z23.string().nullable()
1751
+ });
1752
+ var runDecisionSchema = z23.object({
1753
+ index: z23.number().int(),
1754
+ category: z23.string(),
1755
+ categoryRaw: z23.string().nullable(),
1756
+ chosenName: z23.string(),
1757
+ chosenEcosystem: z23.string().nullable(),
1758
+ chosenPackage: z23.string().nullable(),
1759
+ reversed: z23.boolean(),
1760
+ detail: z23.unknown()
1761
+ });
1762
+ var runImplementationSchema = z23.object({
1763
+ brandName: z23.string(),
1764
+ ecosystem: z23.string().nullable(),
1765
+ package: z23.string().nullable(),
1766
+ verdict: z23.string(),
1767
+ docConsulted: z23.boolean(),
1768
+ detail: z23.unknown()
1769
+ });
1770
+ var RUN_INSIGHT_PASS_KINDS = [
1771
+ "INSTALL",
1772
+ "DECISION",
1773
+ "EVAL",
1774
+ "INTEGRATION",
1775
+ "EXPERIMENT_DELTA",
1776
+ "VISIBILITY"
1777
+ ];
1778
+ var runInsightPassKindSchema = z23.enum(RUN_INSIGHT_PASS_KINDS);
1779
+ var insightPipelinePassSchema = insightPassSchema.extend({
1780
+ kind: runInsightPassKindSchema
1781
+ });
1782
+ var runInsightResponseSchema = z23.object({
1783
+ runId: z23.string(),
1542
1784
  decision: insightPassSchema,
1543
1785
  implementation: insightPassSchema,
1544
- decisions: z21.array(runDecisionSchema),
1545
- implementations: z21.array(runImplementationSchema)
1786
+ passes: z23.array(insightPipelinePassSchema),
1787
+ decisions: z23.array(runDecisionSchema),
1788
+ implementations: z23.array(runImplementationSchema),
1789
+ experimentDelta: z23.unknown().nullable(),
1790
+ /** The VISIBILITY pass's output (winners/picks) — loose server JSON, null
1791
+ * for non-visibility runs or before the pass completes. */
1792
+ visibilityVerdict: z23.unknown().nullable()
1793
+ });
1794
+ var runEventSchema = z23.looseObject({
1795
+ run_id: z23.string(),
1796
+ seq: z23.number(),
1797
+ turn: z23.number(),
1798
+ ts: z23.string(),
1799
+ type: z23.string()
1546
1800
  });
1547
- var runEventSchema = z21.looseObject({
1548
- run_id: z21.string(),
1549
- seq: z21.number(),
1550
- turn: z21.number(),
1551
- ts: z21.string(),
1552
- type: z21.string()
1801
+
1802
+ // ../packages/api-schemas/src/skills.ts
1803
+ import { z as z24 } from "zod";
1804
+ var sha256Hex = sha256DigestSchema;
1805
+ var skillHandleSchema = z24.string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/, "invalid skill handle").refine((name) => name !== "." && name !== "..", "invalid skill handle");
1806
+ var skillSetEntrySchema = z24.object({
1807
+ skillId: z24.string().min(1),
1808
+ name: skillHandleSchema,
1809
+ label: z24.string().min(1),
1810
+ contentDigest: sha256Hex,
1811
+ blobDigest: sha256Hex,
1812
+ /** `cas/v2/<scope>/skills/sha256/<ab>/<blobDigest>.tar.zst`. */
1813
+ blobKey: z24.string().min(1),
1814
+ /** Raw canonical-tar size. Bounds the decompression allocation when present. */
1815
+ rawBytes: z24.number().int().positive().optional(),
1816
+ /** Stored compressed size, verified against the object when present. */
1817
+ storedBytes: z24.number().int().positive().optional(),
1818
+ /**
1819
+ * What the MODEL sees, parsed from the frontmatter at push time
1820
+ * (`{ name, description, descriptionChars, bodyBytes }`). Carried through to
1821
+ * the trace for the record; the staging path never branches on it.
1822
+ */
1823
+ exposure: z24.record(z24.string(), z24.unknown()).optional()
1553
1824
  });
1825
+ var MAX_SKILL_SET_ENTRIES = 32;
1826
+ var skillSetSchema = z24.array(skillSetEntrySchema).max(
1827
+ MAX_SKILL_SET_ENTRIES,
1828
+ `a run may stage at most ${MAX_SKILL_SET_ENTRIES} skills`
1829
+ );
1554
1830
 
1555
1831
  // ../packages/api-schemas/src/tokens.ts
1556
- import { z as z22 } from "zod";
1557
- var apiTokenSchema = z22.object({
1558
- id: z22.string(),
1559
- name: z22.string(),
1832
+ import { z as z25 } from "zod";
1833
+ var apiTokenSchema = z25.object({
1834
+ id: z25.string(),
1835
+ name: z25.string(),
1560
1836
  /** Last 4 chars of the plaintext, for recognizability (non-secret). */
1561
- last4: z22.string(),
1562
- expiresAt: z22.iso.datetime().nullable(),
1563
- lastUsedAt: z22.iso.datetime().nullable(),
1564
- createdAt: z22.iso.datetime(),
1565
- revokedAt: z22.iso.datetime().nullable()
1566
- });
1567
- var createTokenRequestSchema = z22.object({
1568
- name: z22.string().min(1).max(100),
1837
+ last4: z25.string(),
1838
+ expiresAt: z25.iso.datetime().nullable(),
1839
+ lastUsedAt: z25.iso.datetime().nullable(),
1840
+ createdAt: z25.iso.datetime(),
1841
+ revokedAt: z25.iso.datetime().nullable()
1842
+ });
1843
+ var createTokenRequestSchema = z25.object({
1844
+ name: z25.string().min(1).max(100),
1569
1845
  /** ISO-8601 datetime; omit for no expiry. */
1570
- expiresAt: z22.iso.datetime({ offset: true }).optional()
1846
+ expiresAt: z25.iso.datetime({ offset: true }).optional()
1571
1847
  });
1572
1848
  var createTokenResponseSchema = apiTokenSchema.extend({
1573
- token: z22.string()
1849
+ token: z25.string()
1574
1850
  });
1575
1851
  var listTokensResponseSchema = listResponseSchema(apiTokenSchema);
1576
1852
 
1853
+ // ../packages/api-schemas/src/visibility.ts
1854
+ import { z as z26 } from "zod";
1855
+ var VISIBILITY_PROMPT_KINDS = ["HEAD_TO_HEAD", "RECOMMEND"];
1856
+ var visibilityPromptKindSchema = z26.enum(VISIBILITY_PROMPT_KINDS);
1857
+ var visibilityPromptSchema = z26.object({
1858
+ id: z26.string(),
1859
+ kind: visibilityPromptKindSchema,
1860
+ promptText: z26.string(),
1861
+ /** HEAD_TO_HEAD is always branded; RECOMMEND may be either. */
1862
+ branded: z26.boolean(),
1863
+ brandA: z26.string().nullable(),
1864
+ brandB: z26.string().nullable(),
1865
+ /** null = the greenfield scaffold. */
1866
+ repoUrl: z26.string().nullable(),
1867
+ repoRef: z26.string().nullable(),
1868
+ market: z26.object({ id: z26.string(), slug: z26.string(), name: z26.string() }).nullable(),
1869
+ position: z26.number().int(),
1870
+ enabled: z26.boolean(),
1871
+ createdAt: z26.string(),
1872
+ cycle: cycleSchema,
1873
+ /** User tag names on the hidden backing prompt (Surface:* excluded). */
1874
+ tags: z26.array(z26.string()),
1875
+ runCount: z26.number().int(),
1876
+ lastRunAt: z26.string().nullable()
1877
+ });
1878
+ var listVisibilityPromptsResponseSchema = z26.object({
1879
+ items: z26.array(visibilityPromptSchema)
1880
+ });
1881
+ var createVisibilityPromptBodySchema = z26.object({
1882
+ promptText: z26.string().min(1),
1883
+ kind: visibilityPromptKindSchema,
1884
+ branded: z26.boolean().optional(),
1885
+ /** Required pair for HEAD_TO_HEAD (order-independent). */
1886
+ brandA: z26.string().nullish(),
1887
+ brandB: z26.string().nullish(),
1888
+ repoUrl: z26.string().nullish(),
1889
+ repoRef: z26.string().nullish(),
1890
+ /** Measured market id from the org's tracked set. */
1891
+ marketId: z26.string().nullish(),
1892
+ enabled: z26.boolean().optional(),
1893
+ tags: z26.array(z26.string()).optional()
1894
+ });
1895
+ var updateVisibilityPromptBodySchema = z26.object({
1896
+ promptText: z26.string().min(1).optional(),
1897
+ branded: z26.boolean().optional(),
1898
+ brandA: z26.string().nullish(),
1899
+ brandB: z26.string().nullish(),
1900
+ repoUrl: z26.string().nullish(),
1901
+ repoRef: z26.string().nullish(),
1902
+ marketId: z26.string().nullish(),
1903
+ enabled: z26.boolean().optional(),
1904
+ tags: z26.array(z26.string()).optional()
1905
+ });
1906
+ var runVisibilityPromptResponseSchema = z26.object({
1907
+ batchIds: z26.array(z26.string()),
1908
+ runIds: z26.array(z26.string())
1909
+ });
1910
+ var visibilityPromptRunSchema = z26.object({
1911
+ id: z26.string(),
1912
+ status: z26.string(),
1913
+ agent: agentSchema,
1914
+ model: z26.string().nullable(),
1915
+ resolvedModel: z26.string().nullable(),
1916
+ createdAt: z26.string(),
1917
+ startedAt: z26.string().nullable(),
1918
+ finishedAt: z26.string().nullable(),
1919
+ failureReason: z26.string().nullable(),
1920
+ verdict: z26.object({
1921
+ status: z26.string(),
1922
+ error: z26.string().nullable(),
1923
+ payload: z26.unknown().nullable()
1924
+ }).nullable()
1925
+ });
1926
+ var listVisibilityPromptRunsResponseSchema = z26.object({
1927
+ items: z26.array(visibilityPromptRunSchema)
1928
+ });
1929
+ var orgMarketSchema = z26.object({
1930
+ marketId: z26.string(),
1931
+ slug: z26.string(),
1932
+ name: z26.string(),
1933
+ /** The one line saying what the market measures. */
1934
+ capability: z26.string(),
1935
+ /** SUGGESTED (the matcher) | USER (a human picked it). */
1936
+ source: z26.string()
1937
+ });
1938
+ var addableMarketSchema = orgMarketSchema.omit({ source: true });
1939
+ var listMarketsResponseSchema = z26.object({
1940
+ tracked: z26.array(orgMarketSchema),
1941
+ /** Published markets the org does not track yet (closed set — no free-text
1942
+ * market creation). */
1943
+ addable: z26.array(addableMarketSchema)
1944
+ });
1945
+ var addMarketBodySchema = z26.object({ marketId: z26.string().min(1) });
1946
+
1577
1947
  // src/commands/apply.ts
1578
- import { z as z23 } from "zod";
1948
+ import { z as z27 } from "zod";
1579
1949
 
1580
1950
  // src/version.ts
1581
1951
  import { createRequire } from "module";
@@ -2023,7 +2393,7 @@ function register(program2) {
2023
2393
  ).option("-f, --file <path>", "battery spec JSON file").option("--dry-run", "print the plan without applying").option("--schema", "print the battery spec JSON Schema and exit").option("--example", "print a minimal example battery spec and exit").action(
2024
2394
  async (opts, command) => {
2025
2395
  if (opts.schema) {
2026
- printJson(z23.toJSONSchema(batteries_exports.batterySpecSchema));
2396
+ printJson(z27.toJSONSchema(batteries_exports.batterySpecSchema));
2027
2397
  return;
2028
2398
  }
2029
2399
  if (opts.example) {
@@ -2110,6 +2480,7 @@ function printIdentity(me) {
2110
2480
  const su = me.user.isSuperuser ? " (superuser)" : "";
2111
2481
  console.log(`Logged in as ${me.user.email ?? me.user.id}${su}`);
2112
2482
  console.log(`Orgs: ${orgs}`);
2483
+ console.log(`API URL: ${resolveBaseUrl()}`);
2113
2484
  }
2114
2485
  function openBrowser(url) {
2115
2486
  const [cmd, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url]] : ["xdg-open", [url]];
@@ -2408,7 +2779,7 @@ function parseExpiresIn(raw) {
2408
2779
  async function whoami(output) {
2409
2780
  const me = await fetchMe(createClient());
2410
2781
  if (output === "json") {
2411
- printJson(me);
2782
+ printJson({ apiUrl: resolveBaseUrl(), ...me });
2412
2783
  return;
2413
2784
  }
2414
2785
  printIdentity(me);
@@ -2475,7 +2846,12 @@ function register2(program2) {
2475
2846
  throw e;
2476
2847
  }
2477
2848
  if (output === "json") {
2478
- printJson({ authenticated: true, source, ...me });
2849
+ printJson({
2850
+ authenticated: true,
2851
+ source,
2852
+ apiUrl: resolveBaseUrl(),
2853
+ ...me
2854
+ });
2479
2855
  return;
2480
2856
  }
2481
2857
  printIdentity(me);
@@ -2828,252 +3204,11 @@ function register6(program2) {
2828
3204
  });
2829
3205
  }
2830
3206
 
2831
- // src/commands/keys.ts
2832
- var keys_exports2 = {};
2833
- __export(keys_exports2, {
2834
- register: () => register7
3207
+ // src/commands/cycles.ts
3208
+ var cycles_exports2 = {};
3209
+ __export(cycles_exports2, {
3210
+ register: () => register8
2835
3211
  });
2836
- function keysPath(org) {
2837
- return `/api/v1/orgs/${encodeURIComponent(org)}/provider-keys`;
2838
- }
2839
- function providerArg(raw) {
2840
- const provider = raw.toLowerCase();
2841
- if (!keys_exports.PROVIDER_TYPES.includes(provider)) {
2842
- throw new CliError(
2843
- "usage",
2844
- `Unknown provider "${raw}" (expected ${keys_exports.PROVIDER_TYPES.join("|")})`
2845
- );
2846
- }
2847
- return provider;
2848
- }
2849
- async function readKeyInput(opts) {
2850
- if (opts.key !== void 0) {
2851
- process.stderr.write(
2852
- "warning: --key exposes the secret to shell history and process listings; prefer piping it to stdin or setting GAUGE_PROVIDER_KEY.\n"
2853
- );
2854
- const key2 = opts.key.trim();
2855
- if (key2) return key2;
2856
- throw new CliError("usage", "Empty --key value");
2857
- }
2858
- if (!opts.stdin) {
2859
- const env = process.env.GAUGE_PROVIDER_KEY?.trim();
2860
- if (env) return env;
2861
- }
2862
- if (process.stdin.isTTY) {
2863
- process.stderr.write("Paste the API key, press Enter, then Ctrl-D:\n");
2864
- }
2865
- process.stdin.setEncoding("utf8");
2866
- let data = "";
2867
- for await (const chunk of process.stdin) data += chunk;
2868
- const key = data.trim();
2869
- if (!key) {
2870
- throw new CliError(
2871
- "usage",
2872
- "No key provided. Pipe it to stdin (e.g. `gauge keys set anthropic < key.txt`) or set GAUGE_PROVIDER_KEY."
2873
- );
2874
- }
2875
- return key;
2876
- }
2877
- function register7(program2) {
2878
- const group = program2.command("keys").description("Manage BYOK provider keys (write-only; reads show last4)");
2879
- group.command("set <provider>").description(
2880
- "Set a provider key (anthropic|openai); reads it from stdin or GAUGE_PROVIDER_KEY"
2881
- ).option("--stdin", "read the key from stdin (ignores GAUGE_PROVIDER_KEY)").option(
2882
- "--key <key>",
2883
- "pass the key inline (discouraged \u2014 lands in shell history)"
2884
- ).action(
2885
- async (provider, opts, cmd) => {
2886
- const type = providerArg(provider);
2887
- const org = resolveOrg(cmd);
2888
- const key = await readKeyInput(opts);
2889
- const res = await createClient().put(
2890
- `${keysPath(org)}/${type}`,
2891
- { key }
2892
- );
2893
- if (resolveOutput(cmd) === "json") printJson(res);
2894
- else console.log(`Saved ${res.providerType} key (\u2026${res.last4})`);
2895
- }
2896
- );
2897
- group.command("list").description("List configured provider keys").action(async (_opts, cmd) => {
2898
- const org = resolveOrg(cmd);
2899
- const res = await createClient().get(
2900
- keysPath(org)
2901
- );
2902
- if (resolveOutput(cmd) === "json") printJson(res.items);
2903
- else
2904
- printItems(
2905
- res.items.map((k) => ({
2906
- providerType: k.providerType,
2907
- last4: `\u2026${k.last4}`,
2908
- createdAt: k.createdAt,
2909
- updatedAt: k.updatedAt
2910
- })),
2911
- "table"
2912
- );
2913
- });
2914
- group.command("rm <provider>").description("Remove a provider key").action(async (provider, _opts, cmd) => {
2915
- const type = providerArg(provider);
2916
- const org = resolveOrg(cmd);
2917
- await createClient().delete(`${keysPath(org)}/${type}`);
2918
- if (resolveOutput(cmd) !== "json") console.log(`Removed ${type} key`);
2919
- });
2920
- }
2921
-
2922
- // src/commands/onboard.ts
2923
- var onboard_exports = {};
2924
- __export(onboard_exports, {
2925
- register: () => register8
2926
- });
2927
- function orgNameFromEmail(email) {
2928
- const domain = email?.split("@")[1] ?? "";
2929
- const base = domain.split(".")[0] ?? "";
2930
- if (!base) return "My Workspace";
2931
- return base.charAt(0).toUpperCase() + base.slice(1);
2932
- }
2933
- function register8(program2) {
2934
- program2.command("onboard").description(
2935
- "Self-serve onboarding: sign in (device flow) and create your first workspace"
2936
- ).option("--email <email>", "email a sign-in link (device-flow convenience)").option("--org-name <name>", "workspace name (default: from your email)").option("--website <url>", "company site (logo source)").option("--new", "create a new workspace even if you already belong to one").action(
2937
- async (opts, command) => {
2938
- const output = resolveOutput(command);
2939
- let client;
2940
- let me;
2941
- if (resolveToken()) {
2942
- client = new ApiClient();
2943
- me = await client.get("/api/v1/me");
2944
- if (output !== "json") {
2945
- console.log(`Already signed in as ${me.user.email ?? me.user.id}.`);
2946
- }
2947
- } else {
2948
- const login = await deviceLogin({ email: opts.email });
2949
- saveToken(login.token);
2950
- me = login.me;
2951
- client = new ApiClient({ token: login.token });
2952
- if (output !== "json") {
2953
- console.log(
2954
- `
2955
- Signed in as ${me.user.email ?? me.user.id} \u2014 token saved to ${credentialsPath()}.`
2956
- );
2957
- }
2958
- }
2959
- const wantNewOrg = opts.new === true || opts.orgName !== void 0 || me.orgs.length === 0;
2960
- let orgSlug;
2961
- let createdOrg = null;
2962
- if (wantNewOrg) {
2963
- const name = opts.orgName?.trim() || orgNameFromEmail(me.user.email);
2964
- createdOrg = await client.post("/api/v1/orgs", {
2965
- name,
2966
- website: opts.website
2967
- });
2968
- orgSlug = createdOrg.slug;
2969
- } else {
2970
- orgSlug = readConfig().defaultOrg ?? me.orgs[0]?.slug ?? "";
2971
- if (!orgSlug) {
2972
- throw new CliError(
2973
- "internal",
2974
- "No workspace available; re-run with --org-name to create one."
2975
- );
2976
- }
2977
- }
2978
- updateConfig({ defaultOrg: orgSlug });
2979
- if (output === "json") {
2980
- printJson({
2981
- user: me.user,
2982
- org: createdOrg ?? { slug: orgSlug },
2983
- defaultOrg: orgSlug
2984
- });
2985
- return;
2986
- }
2987
- console.log(
2988
- createdOrg ? `
2989
- Created workspace ${createdOrg.name} (${orgSlug}).` : `
2990
- Using workspace ${orgSlug}.`
2991
- );
2992
- console.log(`Default org set to ${orgSlug}. You're ready:`);
2993
- console.log(
2994
- " gauge apply --example > battery.json # scaffold a run"
2995
- );
2996
- console.log(" gauge apply -f battery.json # launch it");
2997
- console.log(" gauge runs list # watch results");
2998
- }
2999
- );
3000
- }
3001
-
3002
- // src/commands/orgs.ts
3003
- var orgs_exports2 = {};
3004
- __export(orgs_exports2, {
3005
- register: () => register9
3006
- });
3007
- function isDefault(org, defaultOrg) {
3008
- return defaultOrg !== void 0 && (org.slug === defaultOrg || org.publicId === defaultOrg);
3009
- }
3010
- function register9(program2) {
3011
- const orgs = program2.command("orgs").description("Organizations");
3012
- orgs.command("list").description("List orgs you belong to").action(async (_opts, command) => {
3013
- const output = resolveOutput(command);
3014
- const me = await createClient().get("/api/v1/me");
3015
- const { defaultOrg } = readConfig();
3016
- if (output === "json") {
3017
- printJson(
3018
- me.orgs.map((org) => ({
3019
- ...org,
3020
- isDefault: isDefault(org, defaultOrg)
3021
- }))
3022
- );
3023
- return;
3024
- }
3025
- printItems(
3026
- me.orgs.map((org) => ({
3027
- slug: org.slug,
3028
- name: org.name,
3029
- publicId: org.publicId ?? "",
3030
- default: isDefault(org, defaultOrg) ? "*" : ""
3031
- })),
3032
- "table"
3033
- );
3034
- });
3035
- orgs.command("create <name>").description("Create a new LOCAL workspace and set it as the default org").option("--website <url>", "company site (used as the logo source)").option("--no-use", "don't set the new org as the default").action(
3036
- async (name, opts, command) => {
3037
- const created = await createClient().post(
3038
- "/api/v1/orgs",
3039
- { name, website: opts.website }
3040
- );
3041
- if (opts.use !== false) updateConfig({ defaultOrg: created.slug });
3042
- if (resolveOutput(command) === "json") {
3043
- printJson(created);
3044
- return;
3045
- }
3046
- console.log(`Created workspace ${created.name} (${created.slug})`);
3047
- if (opts.use !== false) {
3048
- console.log(`Default org set to ${created.slug}`);
3049
- }
3050
- }
3051
- );
3052
- orgs.command("use <org>").description("Set the default org (slug or public id) in local config").action(async (org, _opts, command) => {
3053
- const me = await createClient().get("/api/v1/me");
3054
- const match = me.orgs.find((o) => o.slug === org || o.publicId === org);
3055
- if (!match && !me.user.isSuperuser) {
3056
- throw new CliError(
3057
- "not_found",
3058
- `You are not a member of "${org}". Run \`gauge orgs list\`.`
3059
- );
3060
- }
3061
- const value = match ? match.slug : org;
3062
- updateConfig({ defaultOrg: value });
3063
- if (resolveOutput(command) === "json") {
3064
- printJson({ defaultOrg: value });
3065
- return;
3066
- }
3067
- console.log(
3068
- `Default org set to ${value}${match ? ` (${match.name})` : ""}`
3069
- );
3070
- if (!match) {
3071
- console.error(
3072
- "warning: not in your memberships \u2014 accepted because you are a superuser."
3073
- );
3074
- }
3075
- });
3076
- }
3077
3212
 
3078
3213
  // src/commands/prompts.ts
3079
3214
  var prompts_exports2 = {};
@@ -3083,7 +3218,7 @@ __export(prompts_exports2, {
3083
3218
  promptsPath: () => promptsPath,
3084
3219
  readPromptText: () => readPromptText,
3085
3220
  readWebFixture: () => readWebFixture,
3086
- register: () => register10,
3221
+ register: () => register7,
3087
3222
  resolveOrCreateTopicId: () => resolveOrCreateTopicId
3088
3223
  });
3089
3224
  import { readFileSync as readFileSync4 } from "fs";
@@ -3203,7 +3338,7 @@ function parseSamples(raw, max) {
3203
3338
  );
3204
3339
  return n;
3205
3340
  }
3206
- function register10(program2) {
3341
+ function register7(program2) {
3207
3342
  const group = program2.command("prompts").description("Manage prompts");
3208
3343
  group.command("list").description("List prompts").option("--topic <topic>", "filter by topic (id or name)").option("--tag <tag>", "filter by tag (id or name)").option("-q, --query <text>", "text search").action(
3209
3344
  async (opts, cmd) => {
@@ -3312,74 +3447,1053 @@ function register10(program2) {
3312
3447
  if (resolveOutput(cmd) === "json") printJson(prompt);
3313
3448
  else console.log(`Updated prompt ${prompt.id}`);
3314
3449
  }
3315
- );
3316
- group.command("delete <id>").description("Delete a prompt (cascades to its schedules and runs)").action(async (id, _opts, cmd) => {
3317
- const org = resolveOrg(cmd);
3318
- await createClient().delete(
3319
- `${promptsPath(org)}/${encodeURIComponent(id)}`
3450
+ );
3451
+ group.command("delete <id>").description("Delete a prompt (cascades to its schedules and runs)").action(async (id, _opts, cmd) => {
3452
+ const org = resolveOrg(cmd);
3453
+ await createClient().delete(
3454
+ `${promptsPath(org)}/${encodeURIComponent(id)}`
3455
+ );
3456
+ if (resolveOutput(cmd) !== "json") console.log(`Deleted prompt ${id}`);
3457
+ });
3458
+ group.command("run <id>").description(
3459
+ "Run a prompt now \u2014 an ad-hoc agents x repo x samples spec (ORG funding, credit-gated)"
3460
+ ).option(
3461
+ "--agent <agents>",
3462
+ "comma-separated agents, e.g. claude-code,codex (default: claude-code,codex)"
3463
+ ).option("--repo <url>", "base repo to run against (default: the scaffold)").option("--ref <ref>", "branch, tag, or commit (with --repo)").option("--samples <n>", "samples per agent, 1-10 (default: 1)").option(
3464
+ "--web-fixture <path>",
3465
+ "web fixture JSON; pages are injected transparently into native WebFetch (misses pass through live)"
3466
+ ).action(
3467
+ async (id, opts, cmd) => {
3468
+ const org = resolveOrg(cmd);
3469
+ if (opts.ref !== void 0 && opts.repo === void 0)
3470
+ throw new CliError("usage", "--ref requires --repo");
3471
+ if (opts.repo === void 0)
3472
+ console.error(
3473
+ "note: no --repo \u2014 this run targets the default Gauge scaffold, NOT your repository. Pass --repo <url> to measure your repo."
3474
+ );
3475
+ const body = {
3476
+ agents: opts.agent !== void 0 ? parseAgents(opts.agent) : DEFAULT_RUN_AGENTS,
3477
+ samplesPerCycle: opts.samples !== void 0 ? parseSamples(opts.samples, 10) : 1
3478
+ };
3479
+ if (opts.repo !== void 0) body.repoUrl = opts.repo;
3480
+ if (opts.ref !== void 0) body.repoRef = opts.ref;
3481
+ if (opts.webFixture !== void 0) {
3482
+ body.webFixture = readWebFixture(opts.webFixture);
3483
+ }
3484
+ const result = await createClient().post(
3485
+ `${promptsPath(org)}/${encodeURIComponent(id)}/run`,
3486
+ body
3487
+ );
3488
+ if (resolveOutput(cmd) === "json") {
3489
+ printJson(result);
3490
+ return;
3491
+ }
3492
+ if (result.runIds.length === 0) {
3493
+ console.log("No runs enqueued");
3494
+ return;
3495
+ }
3496
+ console.log(
3497
+ `Enqueued ${result.runIds.length} run(s) in ${result.batchIds.length} batch(es)`
3498
+ );
3499
+ for (const runId of result.runIds) console.log(runId);
3500
+ console.error("Tip: `gauge runs watch <id>` streams a run live");
3501
+ }
3502
+ );
3503
+ }
3504
+
3505
+ // src/commands/cycles.ts
3506
+ var CADENCE_CHOICES = ["none", "daily", "weekly", "monthly"];
3507
+ function parseCadence(raw) {
3508
+ const upper = raw.trim().toUpperCase().replace(/-/g, "_");
3509
+ if (!["NONE", "DAILY", "WEEKLY", "MONTHLY"].includes(upper))
3510
+ throw new CliError(
3511
+ "usage",
3512
+ `invalid --cadence "${raw}" (expected: ${CADENCE_CHOICES.join(" | ")})`
3513
+ );
3514
+ return upper;
3515
+ }
3516
+ function cyclesPath(org) {
3517
+ return `/api/v1/orgs/${encodeURIComponent(org)}/cycles`;
3518
+ }
3519
+ function toRow3(c) {
3520
+ return {
3521
+ id: c.id,
3522
+ name: c.name,
3523
+ cadence: c.cadence,
3524
+ samples: c.samplesPerCycle,
3525
+ agents: c.agents.map(
3526
+ (a) => a.models.length ? `${a.agent}(${a.models.join(",")})` : a.agent
3527
+ ).join(", "),
3528
+ evals: c.evalSetCount,
3529
+ visibility: c.visibilityPromptCount,
3530
+ enabled: c.enabled ? "yes" : "no"
3531
+ };
3532
+ }
3533
+ function register8(program2) {
3534
+ const group = program2.command("cycles").description("View and edit the org's execution cycles (new world)");
3535
+ group.command("list").description("List cycles with cadence, agents, and membership counts").action(async (_opts, cmd) => {
3536
+ const org = resolveOrg(cmd);
3537
+ const res = await createClient().get(
3538
+ cyclesPath(org)
3539
+ );
3540
+ if (resolveOutput(cmd) === "json") printJson(res.items);
3541
+ else printItems(res.items.map(toRow3), "table");
3542
+ });
3543
+ group.command("edit <id>").description(
3544
+ "Set a cycle's cadence and agent roster (visibility cycles only)"
3545
+ ).requiredOption("--cadence <cadence>", CADENCE_CHOICES.join(" | ")).requiredOption(
3546
+ "--agent <agents>",
3547
+ "comma-separated agents, e.g. claude-code,codex"
3548
+ ).action(
3549
+ async (id, opts, cmd) => {
3550
+ const org = resolveOrg(cmd);
3551
+ const body = {
3552
+ cadence: parseCadence(opts.cadence),
3553
+ agents: parseAgents(opts.agent)
3554
+ };
3555
+ const updated = await createClient().patch(
3556
+ `${cyclesPath(org)}/${encodeURIComponent(id)}`,
3557
+ body
3558
+ );
3559
+ if (resolveOutput(cmd) === "json") printJson(updated);
3560
+ else console.log(`Updated cycle ${updated.id}`);
3561
+ }
3562
+ );
3563
+ }
3564
+
3565
+ // src/commands/evals.ts
3566
+ var evals_exports2 = {};
3567
+ __export(evals_exports2, {
3568
+ evalSetsPath: () => evalSetsPath,
3569
+ parseCriterion: () => parseCriterion,
3570
+ register: () => register9
3571
+ });
3572
+ import { readFileSync as readFileSync5 } from "fs";
3573
+ function evalSetsPath(org) {
3574
+ return `/api/v1/orgs/${encodeURIComponent(org)}/eval-sets`;
3575
+ }
3576
+ function collect3(value, previous) {
3577
+ return [...previous, value];
3578
+ }
3579
+ function parseCriterion(raw) {
3580
+ const idx = raw.indexOf(":");
3581
+ if (idx <= 0 || !raw.slice(idx + 1).trim()) {
3582
+ throw new CliError(
3583
+ "usage",
3584
+ `invalid --criterion "${raw}" (expected "Name: rubric text")`
3585
+ );
3586
+ }
3587
+ return { name: raw.slice(0, idx).trim(), rubric: raw.slice(idx + 1).trim() };
3588
+ }
3589
+ function readCriteriaFile(path) {
3590
+ let parsed;
3591
+ try {
3592
+ parsed = JSON.parse(readFileSync5(path === "-" ? 0 : path, "utf8"));
3593
+ } catch (e) {
3594
+ throw new CliError(
3595
+ "usage",
3596
+ `could not read --criteria-file: ${e instanceof Error ? e.message : e}`
3597
+ );
3598
+ }
3599
+ if (!Array.isArray(parsed) || parsed.length === 0)
3600
+ throw new CliError(
3601
+ "usage",
3602
+ "--criteria-file must be a non-empty JSON array of {id?, name, rubric}"
3603
+ );
3604
+ return parsed;
3605
+ }
3606
+ function criteriaFromOpts(opts) {
3607
+ if (opts.criterion.length > 0 && opts.criteriaFile !== void 0)
3608
+ throw new CliError("usage", "--criterion and --criteria-file conflict");
3609
+ if (opts.criteriaFile !== void 0)
3610
+ return readCriteriaFile(opts.criteriaFile);
3611
+ if (opts.criterion.length > 0) return opts.criterion.map(parseCriterion);
3612
+ return void 0;
3613
+ }
3614
+ function repoLabel2(e) {
3615
+ if (!e.repoUrl) return "(default scaffold)";
3616
+ return e.repoRef ? `${e.repoUrl}@${e.repoRef}` : e.repoUrl;
3617
+ }
3618
+ function passRateLabel(stats) {
3619
+ if (stats.judgedRuns === 0) return "-";
3620
+ return `${Math.round(stats.passedRuns / stats.judgedRuns * 100)}% (${stats.passedRuns}/${stats.judgedRuns})`;
3621
+ }
3622
+ function toRow4(e) {
3623
+ return {
3624
+ id: e.id,
3625
+ name: e.name,
3626
+ repo: repoLabel2(e),
3627
+ criteria: e.criteria.length,
3628
+ tags: e.tags.join(", "),
3629
+ enabled: e.enabled ? "yes" : "no",
3630
+ "pass rate": passRateLabel(e.stats),
3631
+ runs: e.stats.runCount
3632
+ };
3633
+ }
3634
+ function printDetail(e) {
3635
+ console.log(`id: ${e.id}`);
3636
+ console.log(`name: ${e.name}`);
3637
+ console.log(`repo: ${repoLabel2(e)}`);
3638
+ console.log(`persona: ${e.profile ? e.profile.name : "(default judge)"}`);
3639
+ console.log(`enabled: ${e.enabled ? "yes" : "no"}`);
3640
+ console.log(`tags: ${e.tags.join(", ") || "(none)"}`);
3641
+ console.log(
3642
+ `cycle: ${e.cycle.name} \u2014 ${e.cycle.cadence.toLowerCase()}, agents: ${e.cycle.agents.map((a) => a.agent).join(", ")}`
3643
+ );
3644
+ console.log(`prompt: ${e.promptText}`);
3645
+ console.log("criteria:");
3646
+ for (const c of e.criteria) console.log(` [${c.id}] ${c.name}: ${c.rubric}`);
3647
+ }
3648
+ function register9(program2) {
3649
+ const group = program2.command("evals").description("Manage eval sets (judged agent-experience measurements)");
3650
+ group.command("list").description("List the org's eval sets with pass-rate stats").option(
3651
+ "--agents <agents>",
3652
+ "filter stats to these agents, e.g. claude-code,codex"
3653
+ ).option("--models <models>", "filter stats to these model slugs (csv)").option("--since <date>", "only count runs since this ISO date").action(
3654
+ async (opts, cmd) => {
3655
+ const org = resolveOrg(cmd);
3656
+ const res = await createClient().get(
3657
+ evalSetsPath(org),
3658
+ {
3659
+ agents: opts.agents === void 0 ? void 0 : parseAgents(opts.agents).join(","),
3660
+ models: opts.models,
3661
+ since: opts.since
3662
+ }
3663
+ );
3664
+ if (resolveOutput(cmd) === "json") printJson(res.items);
3665
+ else printItems(res.items.map(toRow4), "table");
3666
+ }
3667
+ );
3668
+ group.command("get <id>").description("Show one eval set: config, criteria, cycle").action(async (id, _opts, cmd) => {
3669
+ const org = resolveOrg(cmd);
3670
+ const evalSet = await createClient().get(
3671
+ `${evalSetsPath(org)}/${encodeURIComponent(id)}`
3672
+ );
3673
+ if (resolveOutput(cmd) === "json") printJson(evalSet);
3674
+ else printDetail(evalSet);
3675
+ });
3676
+ group.command("create").description("Create an eval set (criteria are judged per run)").requiredOption("--name <name>", "eval set name").option("--text <text>", "prompt text inline").option("--file <path>", 'prompt text from a file ("-" for stdin)').option("--repo <url>", "repository URL (default: the Gauge scaffold)").option("--ref <ref>", "branch, tag, or commit (with --repo)").option(
3677
+ "--persona <profileId>",
3678
+ "persona profile id (default judge if omitted)"
3679
+ ).option(
3680
+ "--criterion <spec>",
3681
+ 'judged criterion as "Name: rubric text" (repeatable)',
3682
+ collect3,
3683
+ []
3684
+ ).option(
3685
+ "--criteria-file <path>",
3686
+ 'JSON array of {name, rubric} ("-" for stdin)'
3687
+ ).option(
3688
+ "--tag <name>",
3689
+ "user tag name, create-on-type (repeatable)",
3690
+ collect3,
3691
+ []
3692
+ ).option("--disabled", "create the eval set paused").action(
3693
+ async (opts, cmd) => {
3694
+ const org = resolveOrg(cmd);
3695
+ if (opts.ref !== void 0 && opts.repo === void 0)
3696
+ throw new CliError("usage", "--ref requires --repo");
3697
+ const criteria = criteriaFromOpts(opts);
3698
+ if (!criteria)
3699
+ throw new CliError(
3700
+ "usage",
3701
+ "at least one --criterion (or --criteria-file) is required"
3702
+ );
3703
+ const body = {
3704
+ name: opts.name,
3705
+ promptText: readPromptText(opts),
3706
+ repoUrl: opts.repo ?? null,
3707
+ repoRef: opts.ref ?? null,
3708
+ profileId: opts.persona ?? null,
3709
+ criteria,
3710
+ enabled: !opts.disabled,
3711
+ tags: opts.tag.length > 0 ? opts.tag : void 0
3712
+ };
3713
+ if (opts.repo === void 0)
3714
+ console.error(
3715
+ "note: no --repo \u2014 this eval set will run against the default Gauge scaffold, NOT your repository. Use `gauge evals edit <id> --repo <url>` to retarget."
3716
+ );
3717
+ const created = await createClient().post(
3718
+ evalSetsPath(org),
3719
+ body
3720
+ );
3721
+ if (resolveOutput(cmd) === "json") printJson(created);
3722
+ else console.log(`Created eval set ${created.id}`);
3723
+ }
3724
+ );
3725
+ group.command("edit <id>").description(
3726
+ "Update an eval set. A provided criteria list REPLACES the whole set (use --criteria-file with ids to edit criteria in place)."
3727
+ ).option("--name <name>", "rename the eval set").option("--text <text>", "replace the prompt text inline").option("--file <path>", 'replace the prompt text from a file ("-" stdin)').option(
3728
+ "--repo <url>",
3729
+ "set the repository URL (keeps an existing ref pin)"
3730
+ ).option("--ref <ref>", "set the branch, tag, or commit pin").option("--clear-ref", "drop the ref pin (use the default branch)").option("--clear-repo", "reset to the default scaffold").option("--persona <profileId>", "set the persona profile id").option("--clear-persona", "use the default judge").option(
3731
+ "--criterion <spec>",
3732
+ 'criterion as "Name: rubric" \u2014 replaces the whole set (repeatable)',
3733
+ collect3,
3734
+ []
3735
+ ).option(
3736
+ "--criteria-file <path>",
3737
+ "JSON array of {id?, name, rubric}; entries with id update in place"
3738
+ ).option(
3739
+ "--tag <name>",
3740
+ "replace the user tag set (repeatable)",
3741
+ collect3,
3742
+ []
3743
+ ).option("--clear-tags", "remove all user tags").action(
3744
+ async (id, opts, cmd) => {
3745
+ const org = resolveOrg(cmd);
3746
+ const body = {};
3747
+ if (opts.name !== void 0) body.name = opts.name;
3748
+ if (opts.text !== void 0 || opts.file !== void 0)
3749
+ body.promptText = readPromptText(opts);
3750
+ if ((opts.repo !== void 0 || opts.ref !== void 0) && opts.clearRepo)
3751
+ throw new CliError("usage", "--repo/--ref and --clear-repo conflict");
3752
+ if (opts.ref !== void 0 && opts.clearRef)
3753
+ throw new CliError("usage", "--ref and --clear-ref conflict");
3754
+ if (opts.clearRepo) {
3755
+ body.repoUrl = null;
3756
+ body.repoRef = null;
3757
+ } else {
3758
+ if (opts.repo !== void 0) body.repoUrl = opts.repo;
3759
+ if (opts.clearRef) body.repoRef = null;
3760
+ else if (opts.ref !== void 0) body.repoRef = opts.ref;
3761
+ }
3762
+ if (opts.persona !== void 0 && opts.clearPersona)
3763
+ throw new CliError("usage", "--persona and --clear-persona conflict");
3764
+ if (opts.clearPersona) body.profileId = null;
3765
+ else if (opts.persona !== void 0) body.profileId = opts.persona;
3766
+ const criteria = criteriaFromOpts(opts);
3767
+ if (criteria) body.criteria = criteria;
3768
+ if (opts.tag.length > 0 && opts.clearTags)
3769
+ throw new CliError("usage", "--tag and --clear-tags conflict");
3770
+ if (opts.clearTags) body.tags = [];
3771
+ else if (opts.tag.length > 0) body.tags = opts.tag;
3772
+ if (Object.keys(body).length === 0)
3773
+ throw new CliError("usage", "nothing to change");
3774
+ const updated = await createClient().patch(
3775
+ `${evalSetsPath(org)}/${encodeURIComponent(id)}`,
3776
+ body
3777
+ );
3778
+ if (resolveOutput(cmd) === "json") printJson(updated);
3779
+ else console.log(`Updated eval set ${updated.id}`);
3780
+ }
3781
+ );
3782
+ group.command("rm <id>").description("Delete an eval set (its run history survives)").action(async (id, _opts, cmd) => {
3783
+ const org = resolveOrg(cmd);
3784
+ await createClient().delete(
3785
+ `${evalSetsPath(org)}/${encodeURIComponent(id)}`
3786
+ );
3787
+ if (resolveOutput(cmd) !== "json") console.log(`Deleted eval set ${id}`);
3788
+ });
3789
+ group.command("run <id>").description(
3790
+ "Run an eval set now \u2014 one run per cycle agent (ORG funding, credit-gated)"
3791
+ ).action(async (id, _opts, cmd) => {
3792
+ const org = resolveOrg(cmd);
3793
+ const result = await createClient().post(
3794
+ `${evalSetsPath(org)}/${encodeURIComponent(id)}/run`,
3795
+ {}
3796
+ );
3797
+ if (resolveOutput(cmd) === "json") {
3798
+ printJson(result);
3799
+ return;
3800
+ }
3801
+ console.log(
3802
+ `Enqueued ${result.runIds.length} run(s) in batch ${result.batchId}`
3803
+ );
3804
+ for (const runId of result.runIds) console.log(runId);
3805
+ console.error("Tip: `gauge runs watch <id>` streams a run live");
3806
+ });
3807
+ group.command("runs <id>").description("The eval set's run log with per-criterion verdicts").option("--limit <n>", "max runs (default 100)").action(async (id, opts, cmd) => {
3808
+ const org = resolveOrg(cmd);
3809
+ const res = await createClient().get(
3810
+ `${evalSetsPath(org)}/${encodeURIComponent(id)}/runs`,
3811
+ { limit: opts.limit }
3812
+ );
3813
+ if (resolveOutput(cmd) === "json") {
3814
+ printJson(res.items);
3815
+ return;
3816
+ }
3817
+ printItems(
3818
+ res.items.map((r) => ({
3819
+ id: r.id,
3820
+ status: r.status,
3821
+ agent: r.agent,
3822
+ model: r.resolvedModel ?? r.model ?? "",
3823
+ created: r.createdAt,
3824
+ judge: r.judge?.status ?? "-",
3825
+ verdicts: r.criterionResults.length === 0 ? "-" : `${r.criterionResults.filter((c) => c.passed).length}/${r.criterionResults.length} passed`
3826
+ })),
3827
+ "table"
3828
+ );
3829
+ });
3830
+ group.command("pause <id>").description("Pause an eval set (skipped by cycle expansion)").action(async (id, _opts, cmd) => {
3831
+ const org = resolveOrg(cmd);
3832
+ await createClient().patch(
3833
+ `${evalSetsPath(org)}/${encodeURIComponent(id)}`,
3834
+ { enabled: false }
3835
+ );
3836
+ if (resolveOutput(cmd) !== "json") console.log(`Paused eval set ${id}`);
3837
+ });
3838
+ group.command("resume <id>").description("Resume a paused eval set").action(async (id, _opts, cmd) => {
3839
+ const org = resolveOrg(cmd);
3840
+ await createClient().patch(
3841
+ `${evalSetsPath(org)}/${encodeURIComponent(id)}`,
3842
+ { enabled: true }
3843
+ );
3844
+ if (resolveOutput(cmd) !== "json") console.log(`Resumed eval set ${id}`);
3845
+ });
3846
+ group.command("tag <id>").description("Replace an eval set's user tags (Surface:* is preserved)").option(
3847
+ "--tag <name>",
3848
+ "tag name, create-on-type (repeatable)",
3849
+ collect3,
3850
+ []
3851
+ ).option("--clear", "remove all user tags").action(
3852
+ async (id, opts, cmd) => {
3853
+ const org = resolveOrg(cmd);
3854
+ if (opts.tag.length > 0 && opts.clear)
3855
+ throw new CliError("usage", "--tag and --clear conflict");
3856
+ if (opts.tag.length === 0 && !opts.clear)
3857
+ throw new CliError(
3858
+ "usage",
3859
+ "pass --tag <name> (repeatable) or --clear"
3860
+ );
3861
+ const updated = await createClient().patch(
3862
+ `${evalSetsPath(org)}/${encodeURIComponent(id)}`,
3863
+ { tags: opts.clear ? [] : opts.tag }
3864
+ );
3865
+ if (resolveOutput(cmd) === "json") printJson(updated);
3866
+ else console.log(`Tags: ${updated.tags.join(", ") || "(none)"}`);
3867
+ }
3868
+ );
3869
+ }
3870
+
3871
+ // src/commands/experiments.ts
3872
+ var experiments_exports2 = {};
3873
+ __export(experiments_exports2, {
3874
+ register: () => register10
3875
+ });
3876
+ import { readFileSync as readFileSync6 } from "fs";
3877
+ var TERMINAL = /* @__PURE__ */ new Set(["COMPLETE", "PARTIAL", "FAILED", "CANCELED"]);
3878
+ function experimentsPath(org) {
3879
+ return `/api/v1/orgs/${encodeURIComponent(org)}/experiments`;
3880
+ }
3881
+ function itemPath(org, id) {
3882
+ return `${experimentsPath(org)}/${encodeURIComponent(id)}`;
3883
+ }
3884
+ function readText(path) {
3885
+ return readFileSync6(path === "-" ? 0 : path, "utf8");
3886
+ }
3887
+ function sleep2(ms) {
3888
+ return new Promise((resolve) => setTimeout(resolve, ms));
3889
+ }
3890
+ function toRow5(e) {
3891
+ return {
3892
+ id: e.id,
3893
+ status: e.status,
3894
+ problem: e.problem.length > 60 ? `${e.problem.slice(0, 57)}...` : e.problem,
3895
+ page: e.boundaryUrl ?? "",
3896
+ variants: e.variantCount,
3897
+ "source run": e.sourceRunId,
3898
+ created: e.createdAt
3899
+ };
3900
+ }
3901
+ function printDetail2(e) {
3902
+ console.log(`id: ${e.id}`);
3903
+ console.log(`status: ${e.status}`);
3904
+ console.log(`problem: ${e.problem}`);
3905
+ console.log(`page: ${e.boundaryUrl ?? "(none)"}`);
3906
+ console.log(`source run: ${e.sourceRun.runId} (${e.sourceRun.agent})`);
3907
+ if (e.launchError) console.log(`launch err: ${e.launchError}`);
3908
+ console.log("variants:");
3909
+ for (const v of e.variants) {
3910
+ const rewrite = v.hasRewrite ? `${v.rewriteChars} chars` : "no rewrite yet";
3911
+ const state = v.invalidReason ? `invalid: ${v.invalidReason}` : v.planStatus ?? "draft";
3912
+ console.log(
3913
+ ` [${v.key}] ${v.title || "(untitled)"} \u2014 ${rewrite}, ${state}`
3914
+ );
3915
+ if (v.hypothesis) console.log(` hypothesis: ${v.hypothesis}`);
3916
+ for (const r of v.runs) {
3917
+ console.log(
3918
+ ` run ${r.runId}: ${r.status}${r.failureReason ? ` (${r.failureReason})` : ""}`
3919
+ );
3920
+ }
3921
+ }
3922
+ }
3923
+ function register10(program2) {
3924
+ const group = program2.command("experiments").description("Author, launch, and read Fixer content experiments");
3925
+ group.command("list").description("List the org's experiments").option(
3926
+ "--status <statuses>",
3927
+ "comma-separated statuses (e.g. RUNNING,COMPLETE)"
3928
+ ).option("--limit <n>", "max rows (default 25)").action(async (opts, cmd) => {
3929
+ const org = resolveOrg(cmd);
3930
+ const res = await createClient().get(
3931
+ experimentsPath(org),
3932
+ { status: opts.status, limit: opts.limit }
3933
+ );
3934
+ if (resolveOutput(cmd) === "json") printJson(res.items);
3935
+ else printItems(res.items.map(toRow5), "table");
3936
+ });
3937
+ group.command("eligible").description("Recent runs worth experimenting on (worst verdicts first)").action(async (_opts, cmd) => {
3938
+ const org = resolveOrg(cmd);
3939
+ const res = await createClient().get(`${experimentsPath(org)}/eligible-runs`);
3940
+ if (resolveOutput(cmd) === "json") printJson(res.items);
3941
+ else
3942
+ printItems(
3943
+ res.items.map((r) => ({
3944
+ "run id": r.runId,
3945
+ agent: r.agent,
3946
+ verdict: r.verdict ?? "-",
3947
+ boundaries: r.boundaryCount,
3948
+ created: r.createdAt
3949
+ })),
3950
+ "table"
3951
+ );
3952
+ });
3953
+ group.command("boundaries").description("The forkable fetches of a run (pass boundarySeq to create)").requiredOption("--run <runId>", "source run id").action(async (opts, cmd) => {
3954
+ const org = resolveOrg(cmd);
3955
+ const res = await createClient().get(`${experimentsPath(org)}/boundaries`, { runId: opts.run });
3956
+ if (resolveOutput(cmd) === "json") printJson(res.items);
3957
+ else
3958
+ printItems(
3959
+ res.items.map((b) => ({
3960
+ boundarySeq: String(b.boundarySeq),
3961
+ turn: b.turn ?? "?",
3962
+ url: b.url,
3963
+ prompt: b.fetchPrompt ?? ""
3964
+ })),
3965
+ "table"
3966
+ );
3967
+ });
3968
+ group.command("create").description(
3969
+ "Open (or resume) an experiment draft and start the Fixer plan round"
3970
+ ).requiredOption("--run <runId>", "source run id").requiredOption(
3971
+ "--boundary <seq>",
3972
+ "opaque boundarySeq from `experiments boundaries`"
3973
+ ).option("--problem <text>", "problem statement (derived if omitted)").action(
3974
+ async (opts, cmd) => {
3975
+ const org = resolveOrg(cmd);
3976
+ const body = {
3977
+ runId: opts.run,
3978
+ boundarySeq: opts.boundary,
3979
+ ...opts.problem !== void 0 ? { problemText: opts.problem } : {}
3980
+ };
3981
+ const result = await createClient().post(
3982
+ experimentsPath(org),
3983
+ body
3984
+ );
3985
+ if (resolveOutput(cmd) === "json") {
3986
+ printJson(result);
3987
+ return;
3988
+ }
3989
+ console.log(
3990
+ `${result.created ? "Created" : "Resumed"} experiment ${result.experimentId}`
3991
+ );
3992
+ console.log(`Problem: ${result.problemText}`);
3993
+ console.error(
3994
+ `Tip: \`gauge experiments watch ${result.experimentId}\` follows the plan round`
3995
+ );
3996
+ }
3997
+ );
3998
+ group.command("get <id>").description("Full detail: directions, rewrites, arms, verdicts").action(async (id, _opts, cmd) => {
3999
+ const org = resolveOrg(cmd);
4000
+ const detail = await createClient().get(
4001
+ itemPath(org, id)
4002
+ );
4003
+ if (resolveOutput(cmd) === "json") printJson(detail);
4004
+ else printDetail2(detail);
4005
+ });
4006
+ group.command("status <id>").description("The async round/launch state (carries launchError)").action(async (id, _opts, cmd) => {
4007
+ const org = resolveOrg(cmd);
4008
+ const status = await createClient().get(
4009
+ `${itemPath(org, id)}/status`
4010
+ );
4011
+ if (resolveOutput(cmd) === "json") printJson(status);
4012
+ else {
4013
+ console.log(`status: ${status.status}`);
4014
+ if (status.launchError)
4015
+ console.log(`launch error: ${status.launchError}`);
4016
+ if (status.shippedVariantId)
4017
+ console.log(
4018
+ `shipped: ${status.shippedVariantId} at ${status.shippedAt}`
4019
+ );
4020
+ }
4021
+ });
4022
+ const variants = group.command("variants").description("Manage a draft's rewrite directions");
4023
+ variants.command("add <experimentId>").description("Add a direction (a candidate rewrite slot)").option("--title <title>", "direction title").option("--hypothesis <text>", "what this rewrite should change").action(
4024
+ async (experimentId, opts, cmd) => {
4025
+ const org = resolveOrg(cmd);
4026
+ const created = await createClient().post(
4027
+ `${itemPath(org, experimentId)}/variants`,
4028
+ opts
4029
+ );
4030
+ if (resolveOutput(cmd) === "json") printJson(created);
4031
+ else console.log(`Added variant ${created.key} (${created.id})`);
4032
+ }
4033
+ );
4034
+ variants.command("edit <experimentId> <variantId>").description("Retitle / re-hypothesize a direction").option("--title <title>", "direction title").option("--hypothesis <text>", "hypothesis").action(
4035
+ async (experimentId, variantId, opts, cmd) => {
4036
+ if (opts.title === void 0 && opts.hypothesis === void 0)
4037
+ throw new CliError("usage", "nothing to change");
4038
+ const org = resolveOrg(cmd);
4039
+ await createClient().patch(
4040
+ `${itemPath(org, experimentId)}/variants/${encodeURIComponent(variantId)}`,
4041
+ opts
4042
+ );
4043
+ if (resolveOutput(cmd) !== "json") console.log("Updated");
4044
+ }
4045
+ );
4046
+ variants.command("rm <experimentId> <variantId>").description("Remove a direction from the draft").action(
4047
+ async (experimentId, variantId, _o, cmd) => {
4048
+ const org = resolveOrg(cmd);
4049
+ await createClient().delete(
4050
+ `${itemPath(org, experimentId)}/variants/${encodeURIComponent(variantId)}`
4051
+ );
4052
+ if (resolveOutput(cmd) !== "json") console.log("Removed");
4053
+ }
4054
+ );
4055
+ group.command("content <id>").description("Read the live page (or a rewrite) in bounded windows").option("--variant <variantId>", "read this variant's rewrite instead").option("--offset <n>", "start offset (default 0)").option("--max-chars <n>", "window size (default 20000, max 40000)").action(
4056
+ async (id, opts, cmd) => {
4057
+ const org = resolveOrg(cmd);
4058
+ const result = await createClient().get(
4059
+ `${itemPath(org, id)}/content`,
4060
+ {
4061
+ variantId: opts.variant,
4062
+ offset: opts.offset,
4063
+ maxChars: opts.maxChars
4064
+ }
4065
+ );
4066
+ if (resolveOutput(cmd) === "json") {
4067
+ printJson(result);
4068
+ return;
4069
+ }
4070
+ process.stdout.write(result.content);
4071
+ if (result.nextOffset != null)
4072
+ console.error(
4073
+ `
4074
+ --- ${result.returnedChars}/${result.totalChars} chars; continue with --offset ${result.nextOffset}`
4075
+ );
4076
+ }
4077
+ );
4078
+ group.command("rewrite <id> <variantId>").description(
4079
+ "Write a variant's page: --file replaces it; --edits-file applies {find, replace} ops"
4080
+ ).option("--file <path>", 'full content ("-" for stdin)').option(
4081
+ "--edits-file <path>",
4082
+ 'JSON array of {find, replace} ops ("-" for stdin)'
4083
+ ).action(
4084
+ async (id, variantId, opts, cmd) => {
4085
+ if (opts.file === void 0 === (opts.editsFile === void 0))
4086
+ throw new CliError(
4087
+ "usage",
4088
+ "pass exactly one of --file or --edits-file"
4089
+ );
4090
+ const org = resolveOrg(cmd);
4091
+ const body = {};
4092
+ if (opts.file !== void 0) body.content = readText(opts.file);
4093
+ else {
4094
+ let parsed;
4095
+ try {
4096
+ parsed = JSON.parse(readText(opts.editsFile));
4097
+ } catch (e) {
4098
+ throw new CliError(
4099
+ "usage",
4100
+ `could not read --edits-file: ${e instanceof Error ? e.message : e}`
4101
+ );
4102
+ }
4103
+ if (!Array.isArray(parsed) || parsed.length === 0)
4104
+ throw new CliError(
4105
+ "usage",
4106
+ "--edits-file must be a non-empty JSON array of {find, replace}"
4107
+ );
4108
+ body.edits = parsed;
4109
+ }
4110
+ const result = await createClient().put(
4111
+ `${itemPath(org, id)}/variants/${encodeURIComponent(variantId)}/content`,
4112
+ body
4113
+ );
4114
+ if (resolveOutput(cmd) === "json") printJson(result);
4115
+ else {
4116
+ console.log(`Wrote ${result.chars} chars`);
4117
+ if (body.edits)
4118
+ console.log(
4119
+ `Edits: ${result.applied} applied, ${result.skipped} skipped`
4120
+ );
4121
+ if (result.truncated) console.error("warning: content was truncated");
4122
+ }
4123
+ }
4124
+ );
4125
+ group.command("replan <id>").description("Discard the directions and have the Fixer propose fresh ones").action(async (id, _opts, cmd) => {
4126
+ const org = resolveOrg(cmd);
4127
+ await createClient().post(`${itemPath(org, id)}/replan`, {});
4128
+ if (resolveOutput(cmd) !== "json")
4129
+ console.log("Replanning \u2014 follow with `gauge experiments watch`");
4130
+ });
4131
+ group.command("write <id>").description("Have the Fixer write rewrites for directions that lack one").action(async (id, _opts, cmd) => {
4132
+ const org = resolveOrg(cmd);
4133
+ const result = await createClient().post(
4134
+ `${itemPath(org, id)}/write`,
4135
+ {}
4136
+ );
4137
+ if (resolveOutput(cmd) === "json") {
4138
+ printJson(result);
4139
+ return;
4140
+ }
4141
+ if (result.queued > 0) console.log(`Queued ${result.queued} rewrite(s)`);
4142
+ else if (result.reason === "round_in_flight")
4143
+ console.log("A round is already running");
4144
+ else console.log("Nothing pending \u2014 every direction has a rewrite");
4145
+ });
4146
+ group.command("launch <id>").description("Claim the draft for launch (spends credits; async fan-out)").action(async (id, _opts, cmd) => {
4147
+ const org = resolveOrg(cmd);
4148
+ const result = await createClient().post(
4149
+ `${itemPath(org, id)}/launch`,
4150
+ {}
4151
+ );
4152
+ if (resolveOutput(cmd) === "json") printJson(result);
4153
+ else
4154
+ console.log(
4155
+ `Launching ${result.experimentId} \u2014 \`gauge experiments watch ${result.experimentId}\` follows it`
4156
+ );
4157
+ });
4158
+ group.command("watch <id>").description(
4159
+ "Follow the running round or launch; prints the recommendation on settle"
4160
+ ).option("--interval <seconds>", "poll interval (default 10)").action(async (id, opts, cmd) => {
4161
+ const org = resolveOrg(cmd);
4162
+ const client = createClient();
4163
+ const intervalMs = Math.max(Number(opts.interval ?? 10) * 1e3, 2e3);
4164
+ const GRACE_POLLS = 3;
4165
+ let sawActive = false;
4166
+ let draftPolls = 0;
4167
+ let last = "";
4168
+ for (; ; ) {
4169
+ const status = await client.get(
4170
+ `${itemPath(org, id)}/status`
4171
+ );
4172
+ if (status.status !== last) {
4173
+ last = status.status;
4174
+ console.error(`status: ${status.status}`);
4175
+ if (status.launchError)
4176
+ console.error(`launch error: ${status.launchError}`);
4177
+ }
4178
+ if (TERMINAL.has(status.status)) break;
4179
+ if (status.status === "DRAFT") {
4180
+ if (status.launchError) {
4181
+ process.exitCode = 1;
4182
+ return;
4183
+ }
4184
+ if (sawActive) {
4185
+ console.error(
4186
+ `Round finished \u2014 \`gauge experiments get ${id}\` shows the directions and rewrites.`
4187
+ );
4188
+ return;
4189
+ }
4190
+ draftPolls += 1;
4191
+ if (draftPolls >= GRACE_POLLS) {
4192
+ console.error(
4193
+ `Nothing is running \u2014 \`gauge experiments get ${id}\` shows the draft.`
4194
+ );
4195
+ return;
4196
+ }
4197
+ } else {
4198
+ sawActive = true;
4199
+ }
4200
+ await sleep2(intervalMs);
4201
+ }
4202
+ const rec = await client.get(
4203
+ `${itemPath(org, id)}/recommendation`
4204
+ );
4205
+ printJson(rec);
4206
+ });
4207
+ group.command("export <id>").description("Print the settled recommendation (JSON)").action(async (id, _opts, cmd) => {
4208
+ const org = resolveOrg(cmd);
4209
+ const rec = await createClient().get(
4210
+ `${itemPath(org, id)}/recommendation`
4211
+ );
4212
+ printJson(rec);
4213
+ });
4214
+ group.command("ship <id> <variantId>").description("Mark a variant as shipped to your live docs").action(
4215
+ async (id, variantId, _o, cmd) => {
4216
+ const org = resolveOrg(cmd);
4217
+ await createClient().post(`${itemPath(org, id)}/ship`, { variantId });
4218
+ if (resolveOutput(cmd) !== "json") console.log("Marked shipped");
4219
+ }
4220
+ );
4221
+ group.command("unship <id>").description("Clear the shipped mark").action(async (id, _opts, cmd) => {
4222
+ const org = resolveOrg(cmd);
4223
+ await createClient().delete(`${itemPath(org, id)}/ship`);
4224
+ if (resolveOutput(cmd) !== "json") console.log("Cleared");
4225
+ });
4226
+ group.command("cancel <id>").description("Cancel a draft/generating/launching experiment").action(async (id, _opts, cmd) => {
4227
+ const org = resolveOrg(cmd);
4228
+ await createClient().post(`${itemPath(org, id)}/cancel`, {});
4229
+ if (resolveOutput(cmd) !== "json") console.log(`Canceled ${id}`);
4230
+ });
4231
+ }
4232
+
4233
+ // src/commands/keys.ts
4234
+ var keys_exports2 = {};
4235
+ __export(keys_exports2, {
4236
+ register: () => register11
4237
+ });
4238
+ function keysPath(org) {
4239
+ return `/api/v1/orgs/${encodeURIComponent(org)}/provider-keys`;
4240
+ }
4241
+ function providerArg(raw) {
4242
+ const provider = raw.toLowerCase();
4243
+ if (!keys_exports.PROVIDER_TYPES.includes(provider)) {
4244
+ throw new CliError(
4245
+ "usage",
4246
+ `Unknown provider "${raw}" (expected ${keys_exports.PROVIDER_TYPES.join("|")})`
4247
+ );
4248
+ }
4249
+ return provider;
4250
+ }
4251
+ async function readKeyInput(opts) {
4252
+ if (opts.key !== void 0) {
4253
+ process.stderr.write(
4254
+ "warning: --key exposes the secret to shell history and process listings; prefer piping it to stdin or setting GAUGE_PROVIDER_KEY.\n"
4255
+ );
4256
+ const key2 = opts.key.trim();
4257
+ if (key2) return key2;
4258
+ throw new CliError("usage", "Empty --key value");
4259
+ }
4260
+ if (!opts.stdin) {
4261
+ const env = process.env.GAUGE_PROVIDER_KEY?.trim();
4262
+ if (env) return env;
4263
+ }
4264
+ if (process.stdin.isTTY) {
4265
+ process.stderr.write("Paste the API key, press Enter, then Ctrl-D:\n");
4266
+ }
4267
+ process.stdin.setEncoding("utf8");
4268
+ let data = "";
4269
+ for await (const chunk of process.stdin) data += chunk;
4270
+ const key = data.trim();
4271
+ if (!key) {
4272
+ throw new CliError(
4273
+ "usage",
4274
+ "No key provided. Pipe it to stdin (e.g. `gauge keys set anthropic < key.txt`) or set GAUGE_PROVIDER_KEY."
4275
+ );
4276
+ }
4277
+ return key;
4278
+ }
4279
+ function register11(program2) {
4280
+ const group = program2.command("keys").description("Manage BYOK provider keys (write-only; reads show last4)");
4281
+ group.command("set <provider>").description(
4282
+ "Set a provider key (anthropic|openai); reads it from stdin or GAUGE_PROVIDER_KEY"
4283
+ ).option("--stdin", "read the key from stdin (ignores GAUGE_PROVIDER_KEY)").option(
4284
+ "--key <key>",
4285
+ "pass the key inline (discouraged \u2014 lands in shell history)"
4286
+ ).action(
4287
+ async (provider, opts, cmd) => {
4288
+ const type = providerArg(provider);
4289
+ const org = resolveOrg(cmd);
4290
+ const key = await readKeyInput(opts);
4291
+ const res = await createClient().put(
4292
+ `${keysPath(org)}/${type}`,
4293
+ { key }
4294
+ );
4295
+ if (resolveOutput(cmd) === "json") printJson(res);
4296
+ else console.log(`Saved ${res.providerType} key (\u2026${res.last4})`);
4297
+ }
4298
+ );
4299
+ group.command("list").description("List configured provider keys").action(async (_opts, cmd) => {
4300
+ const org = resolveOrg(cmd);
4301
+ const res = await createClient().get(
4302
+ keysPath(org)
4303
+ );
4304
+ if (resolveOutput(cmd) === "json") printJson(res.items);
4305
+ else
4306
+ printItems(
4307
+ res.items.map((k) => ({
4308
+ providerType: k.providerType,
4309
+ last4: `\u2026${k.last4}`,
4310
+ createdAt: k.createdAt,
4311
+ updatedAt: k.updatedAt
4312
+ })),
4313
+ "table"
4314
+ );
4315
+ });
4316
+ group.command("rm <provider>").description("Remove a provider key").action(async (provider, _opts, cmd) => {
4317
+ const type = providerArg(provider);
4318
+ const org = resolveOrg(cmd);
4319
+ await createClient().delete(`${keysPath(org)}/${type}`);
4320
+ if (resolveOutput(cmd) !== "json") console.log(`Removed ${type} key`);
4321
+ });
4322
+ }
4323
+
4324
+ // src/commands/onboard.ts
4325
+ var onboard_exports = {};
4326
+ __export(onboard_exports, {
4327
+ register: () => register12
4328
+ });
4329
+ function orgNameFromEmail(email) {
4330
+ const domain = email?.split("@")[1] ?? "";
4331
+ const base = domain.split(".")[0] ?? "";
4332
+ if (!base) return "My Workspace";
4333
+ return base.charAt(0).toUpperCase() + base.slice(1);
4334
+ }
4335
+ function register12(program2) {
4336
+ program2.command("onboard").description(
4337
+ "Self-serve onboarding: sign in (device flow) and create your first workspace"
4338
+ ).option("--email <email>", "email a sign-in link (device-flow convenience)").option("--org-name <name>", "workspace name (default: from your email)").option("--website <url>", "company site (logo source)").option("--new", "create a new workspace even if you already belong to one").action(
4339
+ async (opts, command) => {
4340
+ const output = resolveOutput(command);
4341
+ let client;
4342
+ let me;
4343
+ if (resolveToken()) {
4344
+ client = new ApiClient();
4345
+ me = await client.get("/api/v1/me");
4346
+ if (output !== "json") {
4347
+ console.log(`Already signed in as ${me.user.email ?? me.user.id}.`);
4348
+ }
4349
+ } else {
4350
+ const login = await deviceLogin({ email: opts.email });
4351
+ saveToken(login.token);
4352
+ me = login.me;
4353
+ client = new ApiClient({ token: login.token });
4354
+ if (output !== "json") {
4355
+ console.log(
4356
+ `
4357
+ Signed in as ${me.user.email ?? me.user.id} \u2014 token saved to ${credentialsPath()}.`
4358
+ );
4359
+ }
4360
+ }
4361
+ const wantNewOrg = opts.new === true || opts.orgName !== void 0 || me.orgs.length === 0;
4362
+ let orgSlug;
4363
+ let createdOrg = null;
4364
+ if (wantNewOrg) {
4365
+ const name = opts.orgName?.trim() || orgNameFromEmail(me.user.email);
4366
+ createdOrg = await client.post("/api/v1/orgs", {
4367
+ name,
4368
+ website: opts.website
4369
+ });
4370
+ orgSlug = createdOrg.slug;
4371
+ } else {
4372
+ orgSlug = readConfig().defaultOrg ?? me.orgs[0]?.slug ?? "";
4373
+ if (!orgSlug) {
4374
+ throw new CliError(
4375
+ "internal",
4376
+ "No workspace available; re-run with --org-name to create one."
4377
+ );
4378
+ }
4379
+ }
4380
+ updateConfig({ defaultOrg: orgSlug });
4381
+ if (output === "json") {
4382
+ printJson({
4383
+ user: me.user,
4384
+ org: createdOrg ?? { slug: orgSlug },
4385
+ defaultOrg: orgSlug
4386
+ });
4387
+ return;
4388
+ }
4389
+ console.log(
4390
+ createdOrg ? `
4391
+ Created workspace ${createdOrg.name} (${orgSlug}).` : `
4392
+ Using workspace ${orgSlug}.`
4393
+ );
4394
+ console.log(`Default org set to ${orgSlug}. You're ready:`);
4395
+ console.log(
4396
+ " gauge apply --example > battery.json # scaffold a run"
4397
+ );
4398
+ console.log(" gauge apply -f battery.json # launch it");
4399
+ console.log(" gauge runs list # watch results");
4400
+ }
4401
+ );
4402
+ }
4403
+
4404
+ // src/commands/orgs.ts
4405
+ var orgs_exports2 = {};
4406
+ __export(orgs_exports2, {
4407
+ register: () => register13
4408
+ });
4409
+ function isDefault(org, defaultOrg) {
4410
+ return defaultOrg !== void 0 && (org.slug === defaultOrg || org.publicId === defaultOrg);
4411
+ }
4412
+ function register13(program2) {
4413
+ const orgs = program2.command("orgs").description("Organizations");
4414
+ orgs.command("list").description("List orgs you belong to").action(async (_opts, command) => {
4415
+ const output = resolveOutput(command);
4416
+ const me = await createClient().get("/api/v1/me");
4417
+ const { defaultOrg } = readConfig();
4418
+ if (output === "json") {
4419
+ printJson(
4420
+ me.orgs.map((org) => ({
4421
+ ...org,
4422
+ isDefault: isDefault(org, defaultOrg)
4423
+ }))
4424
+ );
4425
+ return;
4426
+ }
4427
+ printItems(
4428
+ me.orgs.map((org) => ({
4429
+ slug: org.slug,
4430
+ name: org.name,
4431
+ publicId: org.publicId ?? "",
4432
+ default: isDefault(org, defaultOrg) ? "*" : ""
4433
+ })),
4434
+ "table"
3320
4435
  );
3321
- if (resolveOutput(cmd) !== "json") console.log(`Deleted prompt ${id}`);
3322
4436
  });
3323
- group.command("run <id>").description(
3324
- "Run a prompt now \u2014 an ad-hoc agents x repo x samples spec (ORG funding, credit-gated)"
3325
- ).option(
3326
- "--agent <agents>",
3327
- "comma-separated agents, e.g. claude-code,codex (default: claude-code,codex)"
3328
- ).option("--repo <url>", "base repo to run against (default: the scaffold)").option("--ref <ref>", "branch, tag, or commit (with --repo)").option("--samples <n>", "samples per agent, 1-10 (default: 1)").option(
3329
- "--web-fixture <path>",
3330
- "web fixture JSON; pages are injected transparently into native WebFetch (misses pass through live)"
3331
- ).action(
3332
- async (id, opts, cmd) => {
3333
- const org = resolveOrg(cmd);
3334
- if (opts.ref !== void 0 && opts.repo === void 0)
3335
- throw new CliError("usage", "--ref requires --repo");
3336
- const body = {
3337
- agents: opts.agent !== void 0 ? parseAgents(opts.agent) : DEFAULT_RUN_AGENTS,
3338
- samplesPerCycle: opts.samples !== void 0 ? parseSamples(opts.samples, 10) : 1
3339
- };
3340
- if (opts.repo !== void 0) body.repoUrl = opts.repo;
3341
- if (opts.ref !== void 0) body.repoRef = opts.ref;
3342
- if (opts.webFixture !== void 0) {
3343
- body.webFixture = readWebFixture(opts.webFixture);
3344
- }
3345
- const result = await createClient().post(
3346
- `${promptsPath(org)}/${encodeURIComponent(id)}/run`,
3347
- body
4437
+ orgs.command("create <name>").description("Create a new LOCAL workspace and set it as the default org").option("--website <url>", "company site (used as the logo source)").option("--no-use", "don't set the new org as the default").action(
4438
+ async (name, opts, command) => {
4439
+ const created = await createClient().post(
4440
+ "/api/v1/orgs",
4441
+ { name, website: opts.website }
3348
4442
  );
3349
- if (resolveOutput(cmd) === "json") {
3350
- printJson(result);
4443
+ if (opts.use !== false) updateConfig({ defaultOrg: created.slug });
4444
+ if (resolveOutput(command) === "json") {
4445
+ printJson(created);
3351
4446
  return;
3352
4447
  }
3353
- if (result.runIds.length === 0) {
3354
- console.log("No runs enqueued");
3355
- return;
4448
+ console.log(`Created workspace ${created.name} (${created.slug})`);
4449
+ if (opts.use !== false) {
4450
+ console.log(`Default org set to ${created.slug}`);
3356
4451
  }
3357
- console.log(
3358
- `Enqueued ${result.runIds.length} run(s) in ${result.batchIds.length} batch(es)`
3359
- );
3360
- for (const runId of result.runIds) console.log(runId);
3361
- console.error("Tip: `gauge runs watch <id>` streams a run live");
3362
4452
  }
3363
4453
  );
4454
+ orgs.command("use <org>").description("Set the default org (slug or public id) in local config").action(async (org, _opts, command) => {
4455
+ const me = await createClient().get("/api/v1/me");
4456
+ const match = me.orgs.find((o) => o.slug === org || o.publicId === org);
4457
+ if (!match && !me.user.isSuperuser) {
4458
+ throw new CliError(
4459
+ "not_found",
4460
+ `You are not a member of "${org}". Run \`gauge orgs list\`.`
4461
+ );
4462
+ }
4463
+ const value = match ? match.slug : org;
4464
+ updateConfig({ defaultOrg: value });
4465
+ if (resolveOutput(command) === "json") {
4466
+ printJson({ defaultOrg: value });
4467
+ return;
4468
+ }
4469
+ console.log(
4470
+ `Default org set to ${value}${match ? ` (${match.name})` : ""}`
4471
+ );
4472
+ if (!match) {
4473
+ console.error(
4474
+ "warning: not in your memberships \u2014 accepted because you are a superuser."
4475
+ );
4476
+ }
4477
+ });
3364
4478
  }
3365
4479
 
3366
4480
  // src/commands/query.ts
3367
4481
  var query_exports2 = {};
3368
4482
  __export(query_exports2, {
3369
- register: () => register11
4483
+ register: () => register14
3370
4484
  });
3371
- var collect3 = (value, prev = []) => [
4485
+ var collect4 = (value, prev = []) => [
3372
4486
  ...prev,
3373
4487
  value
3374
4488
  ];
3375
- var csv = (raw) => raw.split(",").map((s) => s.trim()).filter(Boolean);
4489
+ var csv2 = (raw) => raw.split(",").map((s) => s.trim()).filter(Boolean);
3376
4490
  function parseWhere(expr) {
3377
4491
  const inMatch = expr.match(/^\s*(\w+)\s+(in|contains)\s+(.*)$/i);
3378
4492
  if (inMatch) {
3379
4493
  const [, dimension2, opRaw, rest2] = inMatch;
3380
4494
  const op = opRaw.toLowerCase();
3381
4495
  if (op === "in") {
3382
- return { dimension: dimension2, op: "in", value: csv(rest2) };
4496
+ return { dimension: dimension2, op: "in", value: csv2(rest2) };
3383
4497
  }
3384
4498
  return { dimension: dimension2, op: "contains", value: rest2.trim() };
3385
4499
  }
@@ -3424,8 +4538,8 @@ async function buildSpec(opts) {
3424
4538
  }
3425
4539
  }
3426
4540
  if (opts.dataset) spec.dataset = opts.dataset;
3427
- if (opts.dimensions !== void 0) spec.dimensions = csv(opts.dimensions);
3428
- if (opts.metrics !== void 0) spec.metrics = csv(opts.metrics);
4541
+ if (opts.dimensions !== void 0) spec.dimensions = csv2(opts.dimensions);
4542
+ if (opts.metrics !== void 0) spec.metrics = csv2(opts.metrics);
3429
4543
  if (opts.where?.length) spec.where = opts.where.map(parseWhere);
3430
4544
  if (opts.orderBy?.length) spec.orderBy = opts.orderBy.map(parseOrderBy);
3431
4545
  if (opts.limit !== void 0) spec.limit = Number(opts.limit);
@@ -3451,16 +4565,16 @@ async function buildSpec(opts) {
3451
4565
  ...spec.filters ?? {}
3452
4566
  };
3453
4567
  if (opts.prompt) filters.prompt = opts.prompt;
3454
- if (opts.topic) filters.topic = csv(opts.topic);
3455
- if (opts.tag) filters.tag = csv(opts.tag);
3456
- if (opts.repo) filters.repo = csv(opts.repo);
3457
- if (opts.language) filters.language = csv(opts.language);
3458
- if (opts.framework) filters.framework = csv(opts.framework);
3459
- if (opts.size) filters.size = csv(opts.size);
3460
- if (opts.agent) filters.agent = csv(opts.agent);
3461
- if (opts.model) filters.model = csv(opts.model);
3462
- if (opts.scenario) filters.scenario = csv(opts.scenario);
3463
- if (opts.experiment) filters.experiment = csv(opts.experiment);
4568
+ if (opts.topic) filters.topic = csv2(opts.topic);
4569
+ if (opts.tag) filters.tag = csv2(opts.tag);
4570
+ if (opts.repo) filters.repo = csv2(opts.repo);
4571
+ if (opts.language) filters.language = csv2(opts.language);
4572
+ if (opts.framework) filters.framework = csv2(opts.framework);
4573
+ if (opts.size) filters.size = csv2(opts.size);
4574
+ if (opts.agent) filters.agent = csv2(opts.agent);
4575
+ if (opts.model) filters.model = csv2(opts.model);
4576
+ if (opts.scenario) filters.scenario = csv2(opts.scenario);
4577
+ if (opts.experiment) filters.experiment = csv2(opts.experiment);
3464
4578
  if (opts.branded) filters.branded = true;
3465
4579
  if (opts.unbranded) filters.branded = false;
3466
4580
  if (Object.keys(filters).length) spec.filters = filters;
@@ -3559,7 +4673,7 @@ async function showMetadata(command, mode, dataset) {
3559
4673
  console.error(`dataset: ${ds.name} \u2014 ${ds.grain}`);
3560
4674
  printItems(rows, "table");
3561
4675
  }
3562
- function register11(program2) {
4676
+ function register14(program2) {
3563
4677
  const group = program2.command("query").description(
3564
4678
  "Flexible reports over your event warehouse (run a report, or discover the catalog)"
3565
4679
  );
@@ -3572,11 +4686,11 @@ function register11(program2) {
3572
4686
  ).option("-d, --dimensions <names>", "comma-separated GROUP BY dimensions").option("-m, --metrics <names>", "comma-separated metrics (at least one)").option(
3573
4687
  "--where <expr>",
3574
4688
  'predicate, e.g. "action=install" (repeatable)',
3575
- collect3
4689
+ collect4
3576
4690
  ).option("--since <val>", "date range start \u2014 ISO date or window (30d, 24h)").option("--until <val>", "date range end \u2014 ISO date or window").option("--last-days <n>", "shorthand for --since <n> days ago").option(
3577
4691
  "--order-by <key:dir>",
3578
4692
  "sort by a selected key, e.g. installs:desc (repeatable)",
3579
- collect3
4693
+ collect4
3580
4694
  ).option("--limit <n>", "max rows (default 50, max 1000)").option(
3581
4695
  "--granularity <g>",
3582
4696
  "date bucket: day | week | month (default day)"
@@ -3595,7 +4709,7 @@ function register11(program2) {
3595
4709
  // src/commands/repos.ts
3596
4710
  var repos_exports2 = {};
3597
4711
  __export(repos_exports2, {
3598
- register: () => register12
4712
+ register: () => register15
3599
4713
  });
3600
4714
  function reposPath(org) {
3601
4715
  return `/api/v1/orgs/${encodeURIComponent(org)}/repos`;
@@ -3603,7 +4717,7 @@ function reposPath(org) {
3603
4717
  async function fetchAllRepos(client, org) {
3604
4718
  return fetchAllPages(client, reposPath(org));
3605
4719
  }
3606
- function toRow3(repo) {
4720
+ function toRow6(repo) {
3607
4721
  return {
3608
4722
  name: repo.name,
3609
4723
  url: repo.url,
@@ -3618,7 +4732,7 @@ function toRow3(repo) {
3618
4732
  function syncWarning(repo) {
3619
4733
  return `warning: GitHub metadata sync failed; retry with \`gauge repos resync ${repo.url}\``;
3620
4734
  }
3621
- function register12(program2) {
4735
+ function register15(program2) {
3622
4736
  const repos = program2.command("repos").description("Manage repositories");
3623
4737
  repos.command("list").description("List repositories (yours + read-only Gauge-provided ones)").action(async (_opts, command) => {
3624
4738
  const org = resolveOrg(command);
@@ -3628,7 +4742,7 @@ function register12(program2) {
3628
4742
  printJson(items);
3629
4743
  return;
3630
4744
  }
3631
- printItems(items.map(toRow3), "table");
4745
+ printItems(items.map(toRow6), "table");
3632
4746
  });
3633
4747
  repos.command("add <url>").description("Add a repository (pulls languages/size/stars from GitHub)").option(
3634
4748
  "--ref <ref>",
@@ -3682,7 +4796,7 @@ function register12(program2) {
3682
4796
  // src/commands/runs.ts
3683
4797
  var runs_exports2 = {};
3684
4798
  __export(runs_exports2, {
3685
- register: () => register13
4799
+ register: () => register16
3686
4800
  });
3687
4801
  function runPath(id) {
3688
4802
  return `/api/v1/runs/${encodeURIComponent(id)}`;
@@ -3703,7 +4817,7 @@ function compact(value, max = 140) {
3703
4817
  const one = s.replace(/\s+/g, " ").trim();
3704
4818
  return one.length > max ? `${one.slice(0, max - 1)}\u2026` : one;
3705
4819
  }
3706
- function toRow4(run) {
4820
+ function toRow7(run) {
3707
4821
  return {
3708
4822
  id: run.id,
3709
4823
  status: run.status,
@@ -3765,9 +4879,22 @@ function decisionVia(detail) {
3765
4879
  }
3766
4880
  return types.join(", ");
3767
4881
  }
4882
+ var PASS_LABELS = {
4883
+ INSTALL: "Install pass",
4884
+ DECISION: "Decision pass",
4885
+ EVAL: "Criteria pass",
4886
+ INTEGRATION: "Implementation pass",
4887
+ EXPERIMENT_DELTA: "Experiment delta"
4888
+ };
3768
4889
  function printInsight(insight) {
3769
- console.log(passLine("Decision pass", insight.decision));
3770
- console.log(passLine("Implementation pass", insight.implementation));
4890
+ if (insight.passes.length > 0) {
4891
+ for (const pass of insight.passes) {
4892
+ console.log(passLine(PASS_LABELS[pass.kind] ?? pass.kind, pass));
4893
+ }
4894
+ } else {
4895
+ console.log(passLine("Decision pass", insight.decision));
4896
+ console.log(passLine("Implementation pass", insight.implementation));
4897
+ }
3771
4898
  console.log(`
3772
4899
  Decisions (${insight.decisions.length})`);
3773
4900
  if (insight.decisions.length === 0) {
@@ -3801,6 +4928,17 @@ Implementation quality (${insight.implementations.length})`);
3801
4928
  "table"
3802
4929
  );
3803
4930
  }
4931
+ const delta2 = insight.experimentDelta;
4932
+ if (delta2 && typeof delta2 === "object") {
4933
+ console.log("\nExperiment delta");
4934
+ console.log(
4935
+ [
4936
+ delta2.changed == null ? "" : delta2.changed ? "changed" : "no change",
4937
+ delta2.hypothesisSupported ?? ""
4938
+ ].filter(Boolean).join(" ")
4939
+ );
4940
+ if (delta2.summary) console.log(compact(delta2.summary, 300));
4941
+ }
3804
4942
  if (insight.decisions.length > 0 || insight.implementations.length > 0) {
3805
4943
  console.error("\n(full detail: rerun with -o json)");
3806
4944
  }
@@ -3920,7 +5058,7 @@ async function streamRun(id, json, opts) {
3920
5058
  if (drainTimer) clearTimeout(drainTimer);
3921
5059
  }
3922
5060
  }
3923
- function register13(program2) {
5061
+ function register16(program2) {
3924
5062
  const runs = program2.command("runs").description("Inspect and manage runs");
3925
5063
  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("--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(
3926
5064
  async (opts, command) => {
@@ -3942,7 +5080,7 @@ function register13(program2) {
3942
5080
  printJson(page);
3943
5081
  return;
3944
5082
  }
3945
- printItems(page.items.map(toRow4), "table");
5083
+ printItems(page.items.map(toRow7), "table");
3946
5084
  if (page.nextCursor) {
3947
5085
  console.error(
3948
5086
  `(more results \u2014 rerun with --cursor ${page.nextCursor})`
@@ -4012,6 +5150,20 @@ function register13(program2) {
4012
5150
  );
4013
5151
  console.error(`Watch it with: gauge runs watch ${result.runId}`);
4014
5152
  });
5153
+ runs.command("fork-boundaries <id>").description(
5154
+ "The run's forkable fetch boundaries + checkpoint availability"
5155
+ ).action(async (id) => {
5156
+ const result = await createClient().get(
5157
+ `${runPath(id)}/fork-boundaries`
5158
+ );
5159
+ printJson(result);
5160
+ });
5161
+ runs.command("fork-plan <planId>").description("Inspect a fetch-fork plan (status, forked run ids)").action(async (planId) => {
5162
+ const result = await createClient().get(
5163
+ `/api/v1/fork-plans/${encodeURIComponent(planId)}`
5164
+ );
5165
+ printJson(result);
5166
+ });
4015
5167
  runs.command("cancel <id>").description("Request cancellation of a run").action(async (id, _opts, command) => {
4016
5168
  const result = await createClient().post(
4017
5169
  `${runPath(id)}/cancel`
@@ -4030,21 +5182,21 @@ function register13(program2) {
4030
5182
  // src/commands/schedules.ts
4031
5183
  var schedules_exports2 = {};
4032
5184
  __export(schedules_exports2, {
4033
- register: () => register14
5185
+ register: () => register17
4034
5186
  });
4035
- var CADENCE_CHOICES = [
5187
+ var CADENCE_CHOICES2 = [
4036
5188
  "none",
4037
5189
  "daily",
4038
5190
  "weekly",
4039
5191
  "monthly",
4040
5192
  "days-per-week"
4041
5193
  ];
4042
- function parseCadence(raw) {
5194
+ function parseCadence2(raw) {
4043
5195
  const upper = raw.trim().toUpperCase().replace(/-/g, "_");
4044
5196
  if (!["NONE", "DAILY", "WEEKLY", "MONTHLY", "DAYS_PER_WEEK"].includes(upper)) {
4045
5197
  throw new CliError(
4046
5198
  "usage",
4047
- `invalid --cadence "${raw}" (expected: ${CADENCE_CHOICES.join(" | ")})`
5199
+ `invalid --cadence "${raw}" (expected: ${CADENCE_CHOICES2.join(" | ")})`
4048
5200
  );
4049
5201
  }
4050
5202
  return upper;
@@ -4055,7 +5207,7 @@ function parseDays(raw) {
4055
5207
  throw new CliError("usage", "--days-per-week must be an integer 1-7");
4056
5208
  return n;
4057
5209
  }
4058
- function collect4(value, previous) {
5210
+ function collect5(value, previous) {
4059
5211
  return [...previous, value];
4060
5212
  }
4061
5213
  function reposLabel(repos) {
@@ -4070,7 +5222,7 @@ function reposLabel(repos) {
4070
5222
  function reposFromOpts(repo, ref) {
4071
5223
  return [{ repoUrl: repo, repoRef: ref ?? null }];
4072
5224
  }
4073
- function toRow5(s) {
5225
+ function toRow8(s) {
4074
5226
  return {
4075
5227
  id: s.id,
4076
5228
  name: s.name,
@@ -4096,7 +5248,7 @@ var RUN_BLOCK_WARNINGS = {
4096
5248
  insufficient_credits: "warning: some targets were skipped or truncated: out of credits",
4097
5249
  needs_provider_key: "warning: some targets were skipped: no provider key for the selected agents"
4098
5250
  };
4099
- function register14(program2) {
5251
+ function register17(program2) {
4100
5252
  const group = program2.command("schedules").description("Manage org schedules (named prompt sets on a cadence)");
4101
5253
  group.command("list").description(
4102
5254
  "List schedules for the org, or (with --prompt) the schedules a prompt is in"
@@ -4116,7 +5268,7 @@ function register14(program2) {
4116
5268
  `/api/v1/orgs/${encodeURIComponent(org)}/schedules`
4117
5269
  );
4118
5270
  if (json) printJson(res.items);
4119
- else printItems(res.items.map(toRow5), "table");
5271
+ else printItems(res.items.map(toRow8), "table");
4120
5272
  });
4121
5273
  group.command("create").description(
4122
5274
  "Create an org schedule: a named tag set + agents + cadence + repo"
@@ -4126,9 +5278,9 @@ function register14(program2) {
4126
5278
  ).option(
4127
5279
  "--tag <id>",
4128
5280
  "membership tag id \u2014 the schedule runs the union of its tags (repeatable)",
4129
- collect4,
5281
+ collect5,
4130
5282
  []
4131
- ).option("--repo <url>", "repository URL (default: the Gauge scaffold)").option("--ref <ref>", "branch, tag, or commit (with --repo)").option("--cadence <cadence>", CADENCE_CHOICES.join(" | "), "none").option("--days-per-week <n>", "1-7 (with --cadence days-per-week)").option("--samples <n>", "samples per cycle (default: 1)").option("--model <id>", "pin a model id (default: the agent's default)").option("--disabled", "create the schedule disabled").action(
5283
+ ).option("--repo <url>", "repository URL (default: the Gauge scaffold)").option("--ref <ref>", "branch, tag, or commit (with --repo)").option("--cadence <cadence>", CADENCE_CHOICES2.join(" | "), "none").option("--days-per-week <n>", "1-7 (with --cadence days-per-week)").option("--samples <n>", "samples per cycle (default: 1)").option("--model <id>", "pin a model id (default: the agent's default)").option("--disabled", "create the schedule disabled").action(
4132
5284
  async (opts, cmd) => {
4133
5285
  const org = resolveOrg(cmd);
4134
5286
  if (opts.ref !== void 0 && opts.repo === void 0)
@@ -4136,7 +5288,7 @@ function register14(program2) {
4136
5288
  const body = {
4137
5289
  name: opts.name,
4138
5290
  agents: parseAgents(opts.agent),
4139
- cadence: parseCadence(opts.cadence),
5291
+ cadence: parseCadence2(opts.cadence),
4140
5292
  samplesPerCycle: opts.samples !== void 0 ? parseSamples(opts.samples) : 1,
4141
5293
  repos: opts.repo !== void 0 ? reposFromOpts(opts.repo, opts.ref) : [],
4142
5294
  tagIds: opts.tag,
@@ -4156,15 +5308,15 @@ function register14(program2) {
4156
5308
  group.command("edit <id>").description("Update a schedule (repos and tags are full replacements)").option("--name <name>", "rename the schedule").option("--agent <agents>", "comma-separated agents").option(
4157
5309
  "--tag <id>",
4158
5310
  "membership tag id \u2014 replaces the whole set (repeatable)",
4159
- collect4,
5311
+ collect5,
4160
5312
  []
4161
- ).option("--clear-tags", "remove all membership tags").option("--repo <url>", "set a single repo target").option("--ref <ref>", "branch, tag, or commit (with --repo)").option("--clear-repos", "reset to the default scaffold (no repos)").option("--cadence <cadence>", CADENCE_CHOICES.join(" | ")).option("--days-per-week <n>", "1-7 (with cadence days-per-week)").option("--samples <n>", "samples per cycle").option("--model <id>", "pin a model id").option("--clear-model", "use the agent's default model").option("--enable", "enable the schedule").option("--disable", "disable the schedule").action(
5313
+ ).option("--clear-tags", "remove all membership tags").option("--repo <url>", "set a single repo target").option("--ref <ref>", "branch, tag, or commit (with --repo)").option("--clear-repos", "reset to the default scaffold (no repos)").option("--cadence <cadence>", CADENCE_CHOICES2.join(" | ")).option("--days-per-week <n>", "1-7 (with cadence days-per-week)").option("--samples <n>", "samples per cycle").option("--model <id>", "pin a model id").option("--clear-model", "use the agent's default model").option("--enable", "enable the schedule").option("--disable", "disable the schedule").action(
4162
5314
  async (id, opts, cmd) => {
4163
5315
  const body = {};
4164
5316
  if (opts.name !== void 0) body.name = opts.name;
4165
5317
  if (opts.agent !== void 0) body.agents = parseAgents(opts.agent);
4166
5318
  if (opts.cadence !== void 0)
4167
- body.cadence = parseCadence(opts.cadence);
5319
+ body.cadence = parseCadence2(opts.cadence);
4168
5320
  if (opts.daysPerWeek !== void 0)
4169
5321
  body.daysPerWeek = parseDays(opts.daysPerWeek);
4170
5322
  if (opts.samples !== void 0)
@@ -4237,7 +5389,7 @@ function register14(program2) {
4237
5389
  // src/commands/stats.ts
4238
5390
  var stats_exports2 = {};
4239
5391
  __export(stats_exports2, {
4240
- register: () => register15
5392
+ register: () => register18
4241
5393
  });
4242
5394
  function addFilterOptions(cmd) {
4243
5395
  return cmd.option("--prompt <id>", "filter to a single prompt").option("--topic <ids>", "comma-separated topic ids").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)");
@@ -4271,7 +5423,7 @@ function noteFreshness2(f) {
4271
5423
  );
4272
5424
  }
4273
5425
  }
4274
- async function runStats(command, resource, opts, toRow6) {
5426
+ async function runStats(command, resource, opts, toRow10) {
4275
5427
  const org = resolveOrg(command);
4276
5428
  const output = resolveOutput(command);
4277
5429
  const res = await createClient().get(
@@ -4282,7 +5434,7 @@ async function runStats(command, resource, opts, toRow6) {
4282
5434
  printJson(res);
4283
5435
  return;
4284
5436
  }
4285
- printItems(res.items.map(toRow6), "table");
5437
+ printItems(res.items.map(toRow10), "table");
4286
5438
  noteFreshness2(res.freshness);
4287
5439
  }
4288
5440
  var rankingRow = (r) => ({
@@ -4321,7 +5473,7 @@ var domainRow = (r) => ({
4321
5473
  rate: pct2(r.rate),
4322
5474
  requests: r.requests
4323
5475
  });
4324
- function register15(program2) {
5476
+ function register18(program2) {
4325
5477
  const group = program2.command("stats").description("Read-only analytics over your runs");
4326
5478
  addFilterOptions(
4327
5479
  group.command("rankings").description("Brands ranked by install rate")
@@ -4353,12 +5505,12 @@ function register15(program2) {
4353
5505
  // src/commands/tags.ts
4354
5506
  var tags_exports2 = {};
4355
5507
  __export(tags_exports2, {
4356
- register: () => register16
5508
+ register: () => register19
4357
5509
  });
4358
5510
  function tagsPath(org) {
4359
5511
  return `/api/v1/orgs/${encodeURIComponent(org)}/tags`;
4360
5512
  }
4361
- function register16(program2) {
5513
+ function register19(program2) {
4362
5514
  const group = program2.command("tags").description("Manage org tags");
4363
5515
  group.command("list").description("List tags").action(async (_opts, cmd) => {
4364
5516
  const org = resolveOrg(cmd);
@@ -4401,12 +5553,12 @@ function register16(program2) {
4401
5553
  // src/commands/topics.ts
4402
5554
  var topics_exports2 = {};
4403
5555
  __export(topics_exports2, {
4404
- register: () => register17
5556
+ register: () => register20
4405
5557
  });
4406
5558
  function topicsPath(org) {
4407
5559
  return `/api/v1/orgs/${encodeURIComponent(org)}/topics`;
4408
5560
  }
4409
- function register17(program2) {
5561
+ function register20(program2) {
4410
5562
  const group = program2.command("topics").description("Manage org topics");
4411
5563
  group.command("list").description("List topics").action(async (_opts, cmd) => {
4412
5564
  const org = resolveOrg(cmd);
@@ -4427,9 +5579,9 @@ function register17(program2) {
4427
5579
  // src/commands/usage.ts
4428
5580
  var usage_exports = {};
4429
5581
  __export(usage_exports, {
4430
- register: () => register18
5582
+ register: () => register21
4431
5583
  });
4432
- function register18(program2) {
5584
+ function register21(program2) {
4433
5585
  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(
4434
5586
  async (opts, cmd) => {
4435
5587
  const org = resolveOrg(cmd);
@@ -4473,6 +5625,295 @@ function register18(program2) {
4473
5625
  );
4474
5626
  }
4475
5627
 
5628
+ // src/commands/visibility.ts
5629
+ var visibility_exports2 = {};
5630
+ __export(visibility_exports2, {
5631
+ register: () => register22,
5632
+ visibilityPath: () => visibilityPath
5633
+ });
5634
+ function visibilityPath(org) {
5635
+ return `/api/v1/orgs/${encodeURIComponent(org)}/visibility-prompts`;
5636
+ }
5637
+ function collect6(value, previous) {
5638
+ return [...previous, value];
5639
+ }
5640
+ var KIND_CHOICES = ["head-to-head", "recommend"];
5641
+ function parseKind(raw) {
5642
+ const upper = raw.trim().toUpperCase().replace(/-/g, "_");
5643
+ if (upper !== "HEAD_TO_HEAD" && upper !== "RECOMMEND")
5644
+ throw new CliError(
5645
+ "usage",
5646
+ `invalid --kind "${raw}" (expected: ${KIND_CHOICES.join(" | ")})`
5647
+ );
5648
+ return upper;
5649
+ }
5650
+ function brandsLabel(v) {
5651
+ if (v.kind === "HEAD_TO_HEAD") return `${v.brandA} vs ${v.brandB}`;
5652
+ return v.branded ? v.brandA ?? "branded" : "organic";
5653
+ }
5654
+ function toRow9(v) {
5655
+ return {
5656
+ id: v.id,
5657
+ kind: v.kind,
5658
+ brands: brandsLabel(v),
5659
+ market: v.market?.slug ?? "",
5660
+ tags: v.tags.join(", "),
5661
+ enabled: v.enabled ? "yes" : "no",
5662
+ runs: v.runCount,
5663
+ "last run": v.lastRunAt ?? "-"
5664
+ };
5665
+ }
5666
+ function printDetail3(v) {
5667
+ console.log(`id: ${v.id}`);
5668
+ console.log(`kind: ${v.kind}`);
5669
+ console.log(`brands: ${brandsLabel(v)}`);
5670
+ console.log(
5671
+ `market: ${v.market ? `${v.market.name} (${v.market.slug})` : "(none)"}`
5672
+ );
5673
+ console.log(
5674
+ `repo: ${v.repoUrl ? v.repoRef ? `${v.repoUrl}@${v.repoRef}` : v.repoUrl : "(default scaffold)"}`
5675
+ );
5676
+ console.log(`enabled: ${v.enabled ? "yes" : "no"}`);
5677
+ console.log(`tags: ${v.tags.join(", ") || "(none)"}`);
5678
+ console.log(
5679
+ `cycle: ${v.cycle.name} \u2014 ${v.cycle.cadence.toLowerCase()}, agents: ${v.cycle.agents.map((a) => a.agent).join(", ")}`
5680
+ );
5681
+ console.log(`runs: ${v.runCount} (last: ${v.lastRunAt ?? "never"})`);
5682
+ console.log(`prompt: ${v.promptText}`);
5683
+ }
5684
+ function register22(program2) {
5685
+ const group = program2.command("visibility").description("Manage visibility prompts (brand-visibility measurements)");
5686
+ group.command("list").description("List the org's visibility prompts").action(async (_opts, cmd) => {
5687
+ const org = resolveOrg(cmd);
5688
+ const res = await createClient().get(
5689
+ visibilityPath(org)
5690
+ );
5691
+ if (resolveOutput(cmd) === "json") printJson(res.items);
5692
+ else printItems(res.items.map(toRow9), "table");
5693
+ });
5694
+ group.command("get <id>").description("Show one visibility prompt").action(async (id, _opts, cmd) => {
5695
+ const org = resolveOrg(cmd);
5696
+ const vp = await createClient().get(
5697
+ `${visibilityPath(org)}/${encodeURIComponent(id)}`
5698
+ );
5699
+ if (resolveOutput(cmd) === "json") printJson(vp);
5700
+ else printDetail3(vp);
5701
+ });
5702
+ group.command("create").description(
5703
+ "Create a visibility prompt (kind is immutable after creation)"
5704
+ ).requiredOption("--kind <kind>", KIND_CHOICES.join(" | ")).option("--text <text>", "prompt text inline").option("--file <path>", 'prompt text from a file ("-" for stdin)').option("--brand-a <name>", "first brand (required for head-to-head)").option("--brand-b <name>", "second brand (required for head-to-head)").option("--branded", "a branded RECOMMEND measurement").option("--repo <url>", "repository URL (default: the Gauge scaffold)").option("--ref <ref>", "branch, tag, or commit (with --repo)").option(
5705
+ "--market <marketId>",
5706
+ "tracked market id (see `visibility markets`)"
5707
+ ).option(
5708
+ "--tag <name>",
5709
+ "user tag name, create-on-type (repeatable)",
5710
+ collect6,
5711
+ []
5712
+ ).option("--disabled", "create the prompt paused").action(
5713
+ async (opts, cmd) => {
5714
+ const org = resolveOrg(cmd);
5715
+ if (opts.ref !== void 0 && opts.repo === void 0)
5716
+ throw new CliError("usage", "--ref requires --repo");
5717
+ const body = {
5718
+ promptText: readPromptText(opts),
5719
+ kind: parseKind(opts.kind),
5720
+ branded: opts.branded,
5721
+ brandA: opts.brandA ?? null,
5722
+ brandB: opts.brandB ?? null,
5723
+ repoUrl: opts.repo ?? null,
5724
+ repoRef: opts.ref ?? null,
5725
+ marketId: opts.market ?? null,
5726
+ enabled: !opts.disabled,
5727
+ tags: opts.tag.length > 0 ? opts.tag : void 0
5728
+ };
5729
+ if (opts.repo === void 0)
5730
+ console.error(
5731
+ "note: no --repo \u2014 this prompt will run against the default Gauge scaffold, NOT your repository. Use `gauge visibility edit <id> --repo <url>` to retarget."
5732
+ );
5733
+ const created = await createClient().post(
5734
+ visibilityPath(org),
5735
+ body
5736
+ );
5737
+ if (resolveOutput(cmd) === "json") printJson(created);
5738
+ else console.log(`Created visibility prompt ${created.id}`);
5739
+ }
5740
+ );
5741
+ group.command("edit <id>").description("Update a visibility prompt (kind can't change)").option("--text <text>", "replace the prompt text inline").option("--file <path>", 'replace the prompt text from a file ("-" stdin)').option("--brand-a <name>", "first brand").option("--brand-b <name>", "second brand").option("--branded", "mark branded (RECOMMEND only)").option("--organic", "mark organic (RECOMMEND only)").option(
5742
+ "--repo <url>",
5743
+ "set the repository URL (keeps an existing ref pin)"
5744
+ ).option("--ref <ref>", "set the branch, tag, or commit pin").option("--clear-ref", "drop the ref pin (use the default branch)").option("--clear-repo", "reset to the default scaffold").option("--market <marketId>", "set the measured market").option("--clear-market", "unscope from any market").option(
5745
+ "--tag <name>",
5746
+ "replace the user tag set (repeatable)",
5747
+ collect6,
5748
+ []
5749
+ ).option("--clear-tags", "remove all user tags").action(
5750
+ async (id, opts, cmd) => {
5751
+ const org = resolveOrg(cmd);
5752
+ const body = {};
5753
+ if (opts.text !== void 0 || opts.file !== void 0)
5754
+ body.promptText = readPromptText(opts);
5755
+ if (opts.brandA !== void 0) body.brandA = opts.brandA;
5756
+ if (opts.brandB !== void 0) body.brandB = opts.brandB;
5757
+ if (opts.branded && opts.organic)
5758
+ throw new CliError("usage", "--branded and --organic conflict");
5759
+ if (opts.branded) body.branded = true;
5760
+ else if (opts.organic) body.branded = false;
5761
+ if ((opts.repo !== void 0 || opts.ref !== void 0) && opts.clearRepo)
5762
+ throw new CliError("usage", "--repo/--ref and --clear-repo conflict");
5763
+ if (opts.ref !== void 0 && opts.clearRef)
5764
+ throw new CliError("usage", "--ref and --clear-ref conflict");
5765
+ if (opts.clearRepo) {
5766
+ body.repoUrl = null;
5767
+ body.repoRef = null;
5768
+ } else {
5769
+ if (opts.repo !== void 0) body.repoUrl = opts.repo;
5770
+ if (opts.clearRef) body.repoRef = null;
5771
+ else if (opts.ref !== void 0) body.repoRef = opts.ref;
5772
+ }
5773
+ if (opts.market !== void 0 && opts.clearMarket)
5774
+ throw new CliError("usage", "--market and --clear-market conflict");
5775
+ if (opts.clearMarket) body.marketId = null;
5776
+ else if (opts.market !== void 0) body.marketId = opts.market;
5777
+ if (opts.tag.length > 0 && opts.clearTags)
5778
+ throw new CliError("usage", "--tag and --clear-tags conflict");
5779
+ if (opts.clearTags) body.tags = [];
5780
+ else if (opts.tag.length > 0) body.tags = opts.tag;
5781
+ if (Object.keys(body).length === 0)
5782
+ throw new CliError("usage", "nothing to change");
5783
+ const updated = await createClient().patch(
5784
+ `${visibilityPath(org)}/${encodeURIComponent(id)}`,
5785
+ body
5786
+ );
5787
+ if (resolveOutput(cmd) === "json") printJson(updated);
5788
+ else console.log(`Updated visibility prompt ${updated.id}`);
5789
+ }
5790
+ );
5791
+ group.command("rm <id>").description("Delete a visibility prompt (its run history survives)").action(async (id, _opts, cmd) => {
5792
+ const org = resolveOrg(cmd);
5793
+ await createClient().delete(
5794
+ `${visibilityPath(org)}/${encodeURIComponent(id)}`
5795
+ );
5796
+ if (resolveOutput(cmd) !== "json")
5797
+ console.log(`Deleted visibility prompt ${id}`);
5798
+ });
5799
+ group.command("run <id>").description(
5800
+ "Run a visibility prompt now \u2014 one run per cycle agent (ORG funding)"
5801
+ ).action(async (id, _opts, cmd) => {
5802
+ const org = resolveOrg(cmd);
5803
+ const result = await createClient().post(
5804
+ `${visibilityPath(org)}/${encodeURIComponent(id)}/run`,
5805
+ {}
5806
+ );
5807
+ if (resolveOutput(cmd) === "json") {
5808
+ printJson(result);
5809
+ return;
5810
+ }
5811
+ console.log(`Enqueued ${result.runIds.length} run(s)`);
5812
+ for (const runId of result.runIds) console.log(runId);
5813
+ console.error("Tip: `gauge runs watch <id>` streams a run live");
5814
+ });
5815
+ group.command("runs <id>").description("The prompt's run log with visibility verdicts").option("--limit <n>", "max runs (default 100)").action(async (id, opts, cmd) => {
5816
+ const org = resolveOrg(cmd);
5817
+ const res = await createClient().get(
5818
+ `${visibilityPath(org)}/${encodeURIComponent(id)}/runs`,
5819
+ { limit: opts.limit }
5820
+ );
5821
+ if (resolveOutput(cmd) === "json") {
5822
+ printJson(res.items);
5823
+ return;
5824
+ }
5825
+ printItems(
5826
+ res.items.map((r) => ({
5827
+ id: r.id,
5828
+ status: r.status,
5829
+ agent: r.agent,
5830
+ model: r.resolvedModel ?? r.model ?? "",
5831
+ created: r.createdAt,
5832
+ verdict: r.verdict?.status ?? "-"
5833
+ })),
5834
+ "table"
5835
+ );
5836
+ });
5837
+ group.command("pause <id>").description("Pause a visibility prompt (skipped by cycle expansion)").action(async (id, _opts, cmd) => {
5838
+ const org = resolveOrg(cmd);
5839
+ await createClient().patch(
5840
+ `${visibilityPath(org)}/${encodeURIComponent(id)}`,
5841
+ { enabled: false }
5842
+ );
5843
+ if (resolveOutput(cmd) !== "json")
5844
+ console.log(`Paused visibility prompt ${id}`);
5845
+ });
5846
+ group.command("resume <id>").description("Resume a paused visibility prompt").action(async (id, _opts, cmd) => {
5847
+ const org = resolveOrg(cmd);
5848
+ await createClient().patch(
5849
+ `${visibilityPath(org)}/${encodeURIComponent(id)}`,
5850
+ { enabled: true }
5851
+ );
5852
+ if (resolveOutput(cmd) !== "json")
5853
+ console.log(`Resumed visibility prompt ${id}`);
5854
+ });
5855
+ group.command("tag <id>").description("Replace a visibility prompt's user tags").option(
5856
+ "--tag <name>",
5857
+ "tag name, create-on-type (repeatable)",
5858
+ collect6,
5859
+ []
5860
+ ).option("--clear", "remove all user tags").action(
5861
+ async (id, opts, cmd) => {
5862
+ const org = resolveOrg(cmd);
5863
+ if (opts.tag.length > 0 && opts.clear)
5864
+ throw new CliError("usage", "--tag and --clear conflict");
5865
+ if (opts.tag.length === 0 && !opts.clear)
5866
+ throw new CliError(
5867
+ "usage",
5868
+ "pass --tag <name> (repeatable) or --clear"
5869
+ );
5870
+ const updated = await createClient().patch(
5871
+ `${visibilityPath(org)}/${encodeURIComponent(id)}`,
5872
+ { tags: opts.clear ? [] : opts.tag }
5873
+ );
5874
+ if (resolveOutput(cmd) === "json") printJson(updated);
5875
+ else console.log(`Tags: ${updated.tags.join(", ") || "(none)"}`);
5876
+ }
5877
+ );
5878
+ group.command("markets").description("List tracked + addable markets, or track one more with --add").option("--add <marketId>", "track a published market").action(async (opts, cmd) => {
5879
+ const org = resolveOrg(cmd);
5880
+ const client = createClient();
5881
+ const base = `/api/v1/orgs/${encodeURIComponent(org)}/markets`;
5882
+ if (opts.add !== void 0) {
5883
+ const market = await client.post(base, {
5884
+ marketId: opts.add
5885
+ });
5886
+ if (resolveOutput(cmd) === "json") printJson(market);
5887
+ else console.log(`Tracking market ${market.name} (${market.slug})`);
5888
+ return;
5889
+ }
5890
+ const res = await client.get(base);
5891
+ if (resolveOutput(cmd) === "json") {
5892
+ printJson(res);
5893
+ return;
5894
+ }
5895
+ printItems(
5896
+ [
5897
+ ...res.tracked.map((m) => ({
5898
+ id: m.marketId,
5899
+ slug: m.slug,
5900
+ name: m.name,
5901
+ tracked: "yes",
5902
+ source: m.source
5903
+ })),
5904
+ ...res.addable.map((m) => ({
5905
+ id: m.marketId,
5906
+ slug: m.slug,
5907
+ name: m.name,
5908
+ tracked: "no",
5909
+ source: ""
5910
+ }))
5911
+ ],
5912
+ "table"
5913
+ );
5914
+ });
5915
+ }
5916
+
4476
5917
  // src/index.ts
4477
5918
  var program = new Command();
4478
5919
  program.name("gauge").description(
@@ -4487,10 +5928,14 @@ for (const group of [
4487
5928
  auth_exports,
4488
5929
  onboard_exports,
4489
5930
  orgs_exports2,
5931
+ evals_exports2,
5932
+ visibility_exports2,
5933
+ cycles_exports2,
4490
5934
  prompts_exports2,
4491
5935
  schedules_exports2,
4492
5936
  repos_exports2,
4493
5937
  runs_exports2,
5938
+ experiments_exports2,
4494
5939
  apply_exports,
4495
5940
  batches_exports,
4496
5941
  brands_exports2,
@@ -4514,6 +5959,9 @@ try {
4514
5959
  }
4515
5960
  if (error instanceof CliError) {
4516
5961
  let message2 = error.message;
5962
+ if (error.code === "upgrade_required" && !/npm install/i.test(message2)) {
5963
+ message2 += "\nRun: npm install -g @withgauge/cli";
5964
+ }
4517
5965
  if (error.code === "not_found" && /organization/i.test(message2) && !program.opts().org) {
4518
5966
  message2 += "\nThat is your configured default organization. Run `gauge orgs list` to see yours, then `gauge orgs use <org>` to update it.";
4519
5967
  }