@withgauge/cli 0.3.0 → 0.4.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.
- package/dist/index.js +1034 -387
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -141,10 +141,10 @@ var batterySpecSchema = z2.object({
|
|
|
141
141
|
prompts: z2.array(batteryPromptSpecSchema).min(1)
|
|
142
142
|
});
|
|
143
143
|
var batteryPlanScheduleSchema = z2.object({
|
|
144
|
-
action: z2.enum(["create", "update"]),
|
|
144
|
+
action: z2.enum(["create", "update", "none"]),
|
|
145
145
|
repoUrl: z2.string().nullable(),
|
|
146
146
|
repoRef: z2.string().nullable(),
|
|
147
|
-
/** Runs this
|
|
147
|
+
/** Runs this target would enqueue (agents × samples; 0 unless `expand`). */
|
|
148
148
|
runs: z2.number().int()
|
|
149
149
|
});
|
|
150
150
|
var batteryPlanPromptSchema = z2.object({
|
|
@@ -342,6 +342,54 @@ var listBrandsQuerySchema = listQuerySchema.extend({
|
|
|
342
342
|
});
|
|
343
343
|
var brandListResponseSchema = listResponseSchema(brandSchema);
|
|
344
344
|
|
|
345
|
+
// ../packages/api-schemas/src/device.ts
|
|
346
|
+
import { z as z5 } from "zod";
|
|
347
|
+
var deviceAuthorizeRequestSchema = z5.object({
|
|
348
|
+
/** Device label (the CLI's hostname) for display + token naming. */
|
|
349
|
+
deviceName: z5.string().trim().max(64).optional(),
|
|
350
|
+
/** Optional: email a magic-link that lands on the approval page pre-scoped
|
|
351
|
+
* to this device (best-effort — the printed URL always works regardless). */
|
|
352
|
+
email: z5.string().trim().email().max(320).optional()
|
|
353
|
+
});
|
|
354
|
+
var deviceAuthorizeResponseSchema = z5.object({
|
|
355
|
+
/** The one-time secret the CLI polls with (never shown again). */
|
|
356
|
+
deviceCode: z5.string(),
|
|
357
|
+
/** Short human-typed code the user confirms in the browser (e.g. WXYZ-1234). */
|
|
358
|
+
userCode: z5.string(),
|
|
359
|
+
/** Where the user approves (e.g. https://…/cli/authorize). */
|
|
360
|
+
verificationUri: z5.string(),
|
|
361
|
+
/** verificationUri with the code pre-filled, for one-click / QR. */
|
|
362
|
+
verificationUriComplete: z5.string(),
|
|
363
|
+
/** Minimum seconds between polls. */
|
|
364
|
+
interval: z5.number().int().positive(),
|
|
365
|
+
/** Seconds until the device code expires. */
|
|
366
|
+
expiresIn: z5.number().int().positive(),
|
|
367
|
+
/** Whether a magic-link email was dispatched (best-effort). */
|
|
368
|
+
emailSent: z5.boolean()
|
|
369
|
+
});
|
|
370
|
+
var deviceTokenRequestSchema = z5.object({
|
|
371
|
+
deviceCode: z5.string().min(1)
|
|
372
|
+
});
|
|
373
|
+
var deviceTokenApprovedSchema = z5.object({
|
|
374
|
+
status: z5.literal("approved"),
|
|
375
|
+
/** The `gauge_…` bearer secret. Store it now — never returned again. */
|
|
376
|
+
accessToken: z5.string(),
|
|
377
|
+
tokenType: z5.literal("bearer"),
|
|
378
|
+
/** ISO-8601 expiry, or null for no expiry. */
|
|
379
|
+
expiresAt: z5.string().nullable()
|
|
380
|
+
});
|
|
381
|
+
var deviceTokenResultSchema = z5.discriminatedUnion("status", [
|
|
382
|
+
// Not yet approved — keep polling at `interval`.
|
|
383
|
+
z5.object({ status: z5.literal("pending") }),
|
|
384
|
+
// Polled faster than `interval` — back off by `interval` seconds.
|
|
385
|
+
z5.object({ status: z5.literal("slow_down"), interval: z5.number().int() }),
|
|
386
|
+
// The user explicitly denied the request. Stop.
|
|
387
|
+
z5.object({ status: z5.literal("denied") }),
|
|
388
|
+
// The device code expired or is unknown/already-redeemed. Stop and restart.
|
|
389
|
+
z5.object({ status: z5.literal("expired") }),
|
|
390
|
+
deviceTokenApprovedSchema
|
|
391
|
+
]);
|
|
392
|
+
|
|
345
393
|
// ../packages/api-schemas/src/keys.ts
|
|
346
394
|
var keys_exports = {};
|
|
347
395
|
__export(keys_exports, {
|
|
@@ -352,54 +400,69 @@ __export(keys_exports, {
|
|
|
352
400
|
setProviderKeyBodySchema: () => setProviderKeyBodySchema,
|
|
353
401
|
setProviderKeyResponseSchema: () => setProviderKeyResponseSchema
|
|
354
402
|
});
|
|
355
|
-
import { z as
|
|
403
|
+
import { z as z6 } from "zod";
|
|
356
404
|
var PROVIDER_TYPES = ["anthropic", "openai"];
|
|
357
|
-
var providerTypeSchema =
|
|
358
|
-
var setProviderKeyBodySchema =
|
|
405
|
+
var providerTypeSchema = z6.enum(PROVIDER_TYPES);
|
|
406
|
+
var setProviderKeyBodySchema = z6.object({
|
|
359
407
|
/** The raw provider API key. Verified + stored server-side (AWS Secrets
|
|
360
408
|
* Manager); never persisted in the app DB and never echoed back. */
|
|
361
|
-
key:
|
|
409
|
+
key: z6.string().min(1)
|
|
362
410
|
});
|
|
363
|
-
var setProviderKeyResponseSchema =
|
|
411
|
+
var setProviderKeyResponseSchema = z6.object({
|
|
364
412
|
providerType: providerTypeSchema,
|
|
365
|
-
last4:
|
|
413
|
+
last4: z6.string()
|
|
366
414
|
});
|
|
367
|
-
var providerKeySchema =
|
|
415
|
+
var providerKeySchema = z6.object({
|
|
368
416
|
providerType: providerTypeSchema,
|
|
369
|
-
last4:
|
|
370
|
-
createdAt:
|
|
417
|
+
last4: z6.string(),
|
|
418
|
+
createdAt: z6.string(),
|
|
371
419
|
/** When the key was last saved/rotated. */
|
|
372
|
-
updatedAt:
|
|
420
|
+
updatedAt: z6.string()
|
|
373
421
|
});
|
|
374
422
|
var providerKeyListResponseSchema = listResponseSchema(providerKeySchema);
|
|
375
423
|
|
|
376
424
|
// ../packages/api-schemas/src/me.ts
|
|
377
|
-
import { z as
|
|
378
|
-
var meUserSchema =
|
|
379
|
-
id:
|
|
380
|
-
email:
|
|
381
|
-
isSuperuser:
|
|
425
|
+
import { z as z7 } from "zod";
|
|
426
|
+
var meUserSchema = z7.object({
|
|
427
|
+
id: z7.string(),
|
|
428
|
+
email: z7.string().nullable(),
|
|
429
|
+
isSuperuser: z7.boolean()
|
|
382
430
|
});
|
|
383
|
-
var meOrgSchema =
|
|
384
|
-
slug:
|
|
431
|
+
var meOrgSchema = z7.object({
|
|
432
|
+
slug: z7.string(),
|
|
385
433
|
// Gauge's immutable Organization.public_id; null for LOCAL orgs.
|
|
386
|
-
publicId:
|
|
387
|
-
name:
|
|
434
|
+
publicId: z7.string().nullable(),
|
|
435
|
+
name: z7.string()
|
|
388
436
|
});
|
|
389
|
-
var meResponseSchema =
|
|
437
|
+
var meResponseSchema = z7.object({
|
|
390
438
|
user: meUserSchema,
|
|
391
439
|
// Membership-scoped for normal users; superusers see every org (mirrors the
|
|
392
440
|
// web tier's userOrgs).
|
|
393
|
-
orgs:
|
|
441
|
+
orgs: z7.array(meOrgSchema)
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
// ../packages/api-schemas/src/orgs.ts
|
|
445
|
+
import { z as z8 } from "zod";
|
|
446
|
+
var createOrgRequestSchema = z8.object({
|
|
447
|
+
/** Workspace display name; the slug is derived server-side. */
|
|
448
|
+
name: z8.string().trim().min(1).max(200),
|
|
449
|
+
/** Optional company site (logo source; stamped onto the org). */
|
|
450
|
+
website: z8.string().trim().max(300).optional()
|
|
451
|
+
});
|
|
452
|
+
var createOrgResponseSchema = z8.object({
|
|
453
|
+
slug: z8.string(),
|
|
454
|
+
name: z8.string(),
|
|
455
|
+
// LOCAL orgs never have a Gauge publicId.
|
|
456
|
+
publicId: z8.string().nullable()
|
|
394
457
|
});
|
|
395
458
|
|
|
396
459
|
// ../packages/api-schemas/src/prompts.ts
|
|
397
|
-
import { z as
|
|
460
|
+
import { z as z13 } from "zod";
|
|
398
461
|
|
|
399
462
|
// ../packages/api-schemas/src/schedules.ts
|
|
400
|
-
import { z as
|
|
463
|
+
import { z as z9 } from "zod";
|
|
401
464
|
var AGENTS = ["CLAUDE_CODE", "CODEX_CLI", "CURSOR"];
|
|
402
|
-
var agentSchema =
|
|
465
|
+
var agentSchema = z9.enum(AGENTS);
|
|
403
466
|
var CADENCES = [
|
|
404
467
|
"NONE",
|
|
405
468
|
"DAILY",
|
|
@@ -407,184 +470,283 @@ var CADENCES = [
|
|
|
407
470
|
"MONTHLY",
|
|
408
471
|
"DAYS_PER_WEEK"
|
|
409
472
|
];
|
|
410
|
-
var cadenceSchema =
|
|
411
|
-
var daysPerWeekSchema =
|
|
412
|
-
var
|
|
413
|
-
|
|
414
|
-
promptId: z7.string(),
|
|
415
|
-
/** Base repo to run against; null = the default scaffold. */
|
|
416
|
-
repoUrl: z7.string().nullable(),
|
|
473
|
+
var cadenceSchema = z9.enum(CADENCES);
|
|
474
|
+
var daysPerWeekSchema = z9.number().int().min(1).max(7);
|
|
475
|
+
var scheduleRepoSchema = z9.object({
|
|
476
|
+
repoUrl: z9.string(),
|
|
417
477
|
/** Branch/ref; null = the repo's default branch. */
|
|
418
|
-
repoRef:
|
|
478
|
+
repoRef: z9.string().nullable()
|
|
479
|
+
});
|
|
480
|
+
var scheduleSchema = z9.object({
|
|
481
|
+
id: z9.string(),
|
|
482
|
+
name: z9.string(),
|
|
419
483
|
cadence: cadenceSchema,
|
|
420
484
|
/** Only set when cadence is DAYS_PER_WEEK (1–7). */
|
|
421
|
-
daysPerWeek:
|
|
422
|
-
samplesPerCycle:
|
|
423
|
-
agents:
|
|
485
|
+
daysPerWeek: z9.number().int().nullable(),
|
|
486
|
+
samplesPerCycle: z9.number().int(),
|
|
487
|
+
agents: z9.array(agentSchema),
|
|
424
488
|
/** Pinned model id; null = the agent's default. */
|
|
425
|
-
model:
|
|
426
|
-
/**
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
489
|
+
model: z9.string().nullable(),
|
|
490
|
+
/** Repo targets in stable expansion order; empty = the default scaffold. */
|
|
491
|
+
repos: z9.array(scheduleRepoSchema),
|
|
492
|
+
/** Cohort label for experiment analysis; null outside labeled experiments. */
|
|
493
|
+
experiment: z9.string().nullable(),
|
|
494
|
+
enabled: z9.boolean(),
|
|
495
|
+
lastExpandedAt: z9.string().nullable(),
|
|
496
|
+
/** Member prompt ids, in stable expansion order. */
|
|
497
|
+
promptIds: z9.array(z9.string()),
|
|
498
|
+
promptCount: z9.number().int(),
|
|
499
|
+
createdAt: z9.string(),
|
|
500
|
+
updatedAt: z9.string()
|
|
430
501
|
});
|
|
431
502
|
var scheduleListResponseSchema = listResponseSchema(scheduleSchema);
|
|
432
|
-
var
|
|
433
|
-
repoUrl:
|
|
434
|
-
repoRef:
|
|
503
|
+
var scheduleRepoInputSchema = z9.object({
|
|
504
|
+
repoUrl: z9.string().min(1),
|
|
505
|
+
repoRef: z9.string().min(1).nullish()
|
|
506
|
+
});
|
|
507
|
+
var createScheduleBodySchema = z9.object({
|
|
508
|
+
name: z9.string().min(1, "name is required"),
|
|
435
509
|
cadence: cadenceSchema.default("NONE"),
|
|
436
510
|
daysPerWeek: daysPerWeekSchema.optional(),
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
511
|
+
samplesPerCycle: z9.number().int().min(1).default(1),
|
|
512
|
+
agents: z9.array(agentSchema).min(1, "Select at least one agent"),
|
|
513
|
+
model: z9.string().min(1).nullish(),
|
|
514
|
+
/** Repo targets; empty = the default scaffold (greenfield). */
|
|
515
|
+
repos: z9.array(scheduleRepoInputSchema).default([]),
|
|
516
|
+
/** Member prompt ids (resolved by the caller — tag→prompt resolution is a
|
|
517
|
+
* UI-side authoring convenience, never stored). */
|
|
518
|
+
promptIds: z9.array(z9.string().min(1)).default([]),
|
|
519
|
+
enabled: z9.boolean().default(true)
|
|
520
|
+
});
|
|
521
|
+
var updateScheduleBodySchema = z9.object({
|
|
522
|
+
name: z9.string().min(1).optional(),
|
|
442
523
|
cadence: cadenceSchema.optional(),
|
|
443
524
|
daysPerWeek: daysPerWeekSchema.optional(),
|
|
444
|
-
|
|
525
|
+
samplesPerCycle: z9.number().int().min(1).optional(),
|
|
526
|
+
agents: z9.array(agentSchema).min(1, "Select at least one agent").optional(),
|
|
527
|
+
model: z9.string().min(1).nullish(),
|
|
528
|
+
repos: z9.array(scheduleRepoInputSchema).optional(),
|
|
529
|
+
promptIds: z9.array(z9.string().min(1)).optional(),
|
|
530
|
+
enabled: z9.boolean().optional()
|
|
531
|
+
});
|
|
532
|
+
var runScheduleResponseSchema = z9.object({
|
|
533
|
+
batchIds: z9.array(z9.string()),
|
|
534
|
+
runIds: z9.array(z9.string()),
|
|
535
|
+
blocked: z9.enum(["insufficient_credits", "needs_provider_key"]).optional(),
|
|
536
|
+
notReady: z9.array(
|
|
537
|
+
z9.object({
|
|
538
|
+
repoUrl: z9.string(),
|
|
539
|
+
status: z9.enum(["building", "failed", "none"])
|
|
540
|
+
})
|
|
541
|
+
).optional()
|
|
445
542
|
});
|
|
446
543
|
|
|
447
544
|
// ../packages/api-schemas/src/tags.ts
|
|
448
|
-
import { z as
|
|
449
|
-
var tagSchema =
|
|
450
|
-
id:
|
|
451
|
-
name:
|
|
545
|
+
import { z as z10 } from "zod";
|
|
546
|
+
var tagSchema = z10.object({
|
|
547
|
+
id: z10.string(),
|
|
548
|
+
name: z10.string(),
|
|
452
549
|
/** A Mantine palette name (e.g. "blue", "grape"); unknown values are
|
|
453
550
|
* normalized server-side to the default ("gray"). */
|
|
454
|
-
color:
|
|
551
|
+
color: z10.string()
|
|
455
552
|
});
|
|
456
|
-
var createTagBodySchema =
|
|
457
|
-
name:
|
|
458
|
-
color:
|
|
553
|
+
var createTagBodySchema = z10.object({
|
|
554
|
+
name: z10.string().min(1),
|
|
555
|
+
color: z10.string().optional()
|
|
459
556
|
});
|
|
460
|
-
var updateTagBodySchema =
|
|
461
|
-
name:
|
|
462
|
-
color:
|
|
557
|
+
var updateTagBodySchema = z10.object({
|
|
558
|
+
name: z10.string().min(1).optional(),
|
|
559
|
+
color: z10.string().optional()
|
|
463
560
|
});
|
|
464
561
|
var tagListResponseSchema = listResponseSchema(tagSchema);
|
|
465
562
|
|
|
466
563
|
// ../packages/api-schemas/src/topics.ts
|
|
467
|
-
import { z as
|
|
468
|
-
var topicSchema =
|
|
469
|
-
id:
|
|
470
|
-
name:
|
|
564
|
+
import { z as z11 } from "zod";
|
|
565
|
+
var topicSchema = z11.object({
|
|
566
|
+
id: z11.string(),
|
|
567
|
+
name: z11.string()
|
|
471
568
|
});
|
|
472
|
-
var createTopicBodySchema =
|
|
473
|
-
name:
|
|
569
|
+
var createTopicBodySchema = z11.object({
|
|
570
|
+
name: z11.string().min(1, "name is required")
|
|
474
571
|
});
|
|
475
572
|
var topicListResponseSchema = listResponseSchema(topicSchema);
|
|
476
573
|
|
|
574
|
+
// ../packages/api-schemas/src/web-fixtures.ts
|
|
575
|
+
var web_fixtures_exports = {};
|
|
576
|
+
__export(web_fixtures_exports, {
|
|
577
|
+
MAX_WEB_FIXTURE_BYTES: () => MAX_WEB_FIXTURE_BYTES,
|
|
578
|
+
webFixtureSchema: () => webFixtureSchema
|
|
579
|
+
});
|
|
580
|
+
import { z as z12 } from "zod";
|
|
581
|
+
var MAX_WEB_FIXTURE_BYTES = 1e6;
|
|
582
|
+
function withoutFragment(raw) {
|
|
583
|
+
const fragment = raw.indexOf("#");
|
|
584
|
+
return fragment === -1 ? raw : raw.slice(0, fragment);
|
|
585
|
+
}
|
|
586
|
+
var searchResultSchema = z12.object({
|
|
587
|
+
title: z12.string().min(1),
|
|
588
|
+
url: z12.url().transform(withoutFragment),
|
|
589
|
+
snippet: z12.string()
|
|
590
|
+
});
|
|
591
|
+
var searchFixtureSchema = z12.object({
|
|
592
|
+
query: z12.string().trim().min(1),
|
|
593
|
+
results: z12.array(searchResultSchema)
|
|
594
|
+
});
|
|
595
|
+
var pageFixtureSchema = z12.object({
|
|
596
|
+
url: z12.url().transform(withoutFragment),
|
|
597
|
+
status: z12.int().min(100).max(599).default(200),
|
|
598
|
+
contentType: z12.string().trim().min(1).default("text/html"),
|
|
599
|
+
body: z12.string()
|
|
600
|
+
});
|
|
601
|
+
var webFixtureSchema = z12.object({
|
|
602
|
+
version: z12.literal(1),
|
|
603
|
+
searches: z12.array(searchFixtureSchema).default([]),
|
|
604
|
+
pages: z12.array(pageFixtureSchema).default([])
|
|
605
|
+
}).superRefine((fixture, ctx) => {
|
|
606
|
+
const queries = /* @__PURE__ */ new Set();
|
|
607
|
+
fixture.searches.forEach((entry, index) => {
|
|
608
|
+
if (queries.has(entry.query)) {
|
|
609
|
+
ctx.addIssue({
|
|
610
|
+
code: "custom",
|
|
611
|
+
path: ["searches", index, "query"],
|
|
612
|
+
message: `duplicate normalized query: ${entry.query}`
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
queries.add(entry.query);
|
|
616
|
+
});
|
|
617
|
+
const urls = /* @__PURE__ */ new Set();
|
|
618
|
+
fixture.pages.forEach((entry, index) => {
|
|
619
|
+
if (urls.has(entry.url)) {
|
|
620
|
+
ctx.addIssue({
|
|
621
|
+
code: "custom",
|
|
622
|
+
path: ["pages", index, "url"],
|
|
623
|
+
message: `duplicate normalized URL: ${entry.url}`
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
urls.add(entry.url);
|
|
627
|
+
});
|
|
628
|
+
const bytes = new TextEncoder().encode(JSON.stringify(fixture)).byteLength;
|
|
629
|
+
if (bytes > MAX_WEB_FIXTURE_BYTES) {
|
|
630
|
+
ctx.addIssue({
|
|
631
|
+
code: "custom",
|
|
632
|
+
message: `serialized fixture is ${bytes} bytes; maximum is ${MAX_WEB_FIXTURE_BYTES}`
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
|
|
477
637
|
// ../packages/api-schemas/src/prompts.ts
|
|
478
638
|
var SCENARIOS = ["GREENFIELD", "MIGRATION"];
|
|
479
|
-
var scenarioSchema =
|
|
480
|
-
var promptSummarySchema =
|
|
481
|
-
id:
|
|
482
|
-
text:
|
|
639
|
+
var scenarioSchema = z13.enum(SCENARIOS);
|
|
640
|
+
var promptSummarySchema = z13.object({
|
|
641
|
+
id: z13.string(),
|
|
642
|
+
text: z13.string(),
|
|
483
643
|
scenario: scenarioSchema,
|
|
484
|
-
isBranded:
|
|
644
|
+
isBranded: z13.boolean(),
|
|
485
645
|
/** Battery-spec identity (idempotent applies); null for UI/CLI-created prompts. */
|
|
486
|
-
externalKey:
|
|
646
|
+
externalKey: z13.string().nullable(),
|
|
487
647
|
topic: topicSchema.nullable(),
|
|
488
|
-
tags:
|
|
489
|
-
scheduleCount:
|
|
490
|
-
createdAt:
|
|
648
|
+
tags: z13.array(tagSchema),
|
|
649
|
+
scheduleCount: z13.number().int(),
|
|
650
|
+
createdAt: z13.string()
|
|
651
|
+
});
|
|
652
|
+
var promptScheduleRefSchema = z13.object({
|
|
653
|
+
id: z13.string(),
|
|
654
|
+
name: z13.string(),
|
|
655
|
+
cadence: cadenceSchema,
|
|
656
|
+
daysPerWeek: z13.number().int().nullable(),
|
|
657
|
+
enabled: z13.boolean()
|
|
491
658
|
});
|
|
492
659
|
var promptDetailSchema = promptSummarySchema.extend({
|
|
493
|
-
schedules:
|
|
660
|
+
schedules: z13.array(promptScheduleRefSchema)
|
|
494
661
|
});
|
|
495
662
|
var promptListResponseSchema = listResponseSchema(promptSummarySchema);
|
|
496
663
|
var listPromptsQuerySchema = listQuerySchema.extend({
|
|
497
|
-
topic:
|
|
498
|
-
tag:
|
|
499
|
-
q:
|
|
664
|
+
topic: z13.string().min(1).optional(),
|
|
665
|
+
tag: z13.string().min(1).optional(),
|
|
666
|
+
q: z13.string().min(1).optional()
|
|
500
667
|
});
|
|
501
|
-
var createPromptBodySchema =
|
|
502
|
-
text:
|
|
668
|
+
var createPromptBodySchema = z13.object({
|
|
669
|
+
text: z13.string().min(1, "text is required"),
|
|
503
670
|
scenario: scenarioSchema.default("GREENFIELD"),
|
|
504
|
-
isBranded:
|
|
505
|
-
topic:
|
|
506
|
-
tags:
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
runIds: z10.array(z10.string()),
|
|
525
|
-
/** Present when SOME schedules hit a billing gate but at least one run was
|
|
526
|
-
* enqueued (mirrors the battery apply response; an all-blocked run is a
|
|
527
|
-
* 402 error instead). */
|
|
528
|
-
blocked: z10.enum(["insufficient_credits", "needs_provider_key"]).optional()
|
|
671
|
+
isBranded: z13.boolean().default(false),
|
|
672
|
+
topic: z13.string().min(1).optional(),
|
|
673
|
+
tags: z13.array(z13.string().min(1)).default([])
|
|
674
|
+
});
|
|
675
|
+
var updatePromptBodySchema = z13.object({
|
|
676
|
+
text: z13.string().min(1).optional(),
|
|
677
|
+
isBranded: z13.boolean().optional(),
|
|
678
|
+
topicId: z13.string().min(1).nullish(),
|
|
679
|
+
tags: z13.array(z13.string().min(1)).optional()
|
|
680
|
+
});
|
|
681
|
+
var runPromptBodySchema = z13.object({
|
|
682
|
+
agents: z13.array(agentSchema).min(1, "Select at least one agent").default(["CLAUDE_CODE", "CODEX_CLI"]),
|
|
683
|
+
repoUrl: z13.string().min(1).nullish(),
|
|
684
|
+
repoRef: z13.string().min(1).nullish(),
|
|
685
|
+
samplesPerCycle: z13.number().int().min(1).max(10).default(1),
|
|
686
|
+
webFixture: webFixtureSchema.optional()
|
|
687
|
+
});
|
|
688
|
+
var runPromptResponseSchema = z13.object({
|
|
689
|
+
batchIds: z13.array(z13.string()),
|
|
690
|
+
runIds: z13.array(z13.string())
|
|
529
691
|
});
|
|
530
692
|
|
|
531
693
|
// ../packages/api-schemas/src/query.ts
|
|
532
|
-
import { z as
|
|
694
|
+
import { z as z15 } from "zod";
|
|
533
695
|
|
|
534
696
|
// ../packages/api-schemas/src/stats.ts
|
|
535
|
-
import { z as
|
|
697
|
+
import { z as z14 } from "zod";
|
|
536
698
|
var BRAND_KINDS2 = ["OWNED", "COMPETITOR", "OTHER"];
|
|
537
|
-
var brandKindSchema2 =
|
|
538
|
-
var brandRankingSchema =
|
|
539
|
-
rank:
|
|
540
|
-
brandId:
|
|
541
|
-
brandName:
|
|
699
|
+
var brandKindSchema2 = z14.enum(BRAND_KINDS2);
|
|
700
|
+
var brandRankingSchema = z14.object({
|
|
701
|
+
rank: z14.number().int(),
|
|
702
|
+
brandId: z14.string(),
|
|
703
|
+
brandName: z14.string(),
|
|
542
704
|
kind: brandKindSchema2,
|
|
543
|
-
installs:
|
|
544
|
-
installRate:
|
|
545
|
-
mentionRate:
|
|
705
|
+
installs: z14.number().int(),
|
|
706
|
+
installRate: z14.number(),
|
|
707
|
+
mentionRate: z14.number(),
|
|
546
708
|
/** Movement between the two most recent batch windows; null if not ranked in both. */
|
|
547
|
-
deltaRank:
|
|
709
|
+
deltaRank: z14.number().int().nullable()
|
|
548
710
|
});
|
|
549
|
-
var packageRateSchema =
|
|
550
|
-
ecosystem:
|
|
551
|
-
name:
|
|
552
|
-
brandName:
|
|
711
|
+
var packageRateSchema = z14.object({
|
|
712
|
+
ecosystem: z14.string(),
|
|
713
|
+
name: z14.string(),
|
|
714
|
+
brandName: z14.string().optional(),
|
|
553
715
|
kind: brandKindSchema2.optional(),
|
|
554
|
-
installs:
|
|
555
|
-
rate:
|
|
716
|
+
installs: z14.number().int(),
|
|
717
|
+
rate: z14.number()
|
|
556
718
|
});
|
|
557
|
-
var brandRateSchema =
|
|
558
|
-
brandId:
|
|
559
|
-
brandName:
|
|
719
|
+
var brandRateSchema = z14.object({
|
|
720
|
+
brandId: z14.string(),
|
|
721
|
+
brandName: z14.string(),
|
|
560
722
|
kind: brandKindSchema2,
|
|
561
|
-
installs:
|
|
562
|
-
rate:
|
|
723
|
+
installs: z14.number().int(),
|
|
724
|
+
rate: z14.number()
|
|
563
725
|
});
|
|
564
|
-
var brandFunnelRowSchema =
|
|
565
|
-
brandId:
|
|
566
|
-
brandName:
|
|
726
|
+
var brandFunnelRowSchema = z14.object({
|
|
727
|
+
brandId: z14.string(),
|
|
728
|
+
brandName: z14.string(),
|
|
567
729
|
kind: brandKindSchema2,
|
|
568
|
-
mentionRate:
|
|
569
|
-
installRate:
|
|
570
|
-
});
|
|
571
|
-
var domainRateSchema =
|
|
572
|
-
domain:
|
|
573
|
-
runs:
|
|
574
|
-
rate:
|
|
575
|
-
requests:
|
|
576
|
-
brandName:
|
|
577
|
-
owned:
|
|
578
|
-
});
|
|
579
|
-
var statsFreshnessSchema =
|
|
730
|
+
mentionRate: z14.number(),
|
|
731
|
+
installRate: z14.number()
|
|
732
|
+
});
|
|
733
|
+
var domainRateSchema = z14.object({
|
|
734
|
+
domain: z14.string(),
|
|
735
|
+
runs: z14.number().int(),
|
|
736
|
+
rate: z14.number(),
|
|
737
|
+
requests: z14.number().int(),
|
|
738
|
+
brandName: z14.string().optional(),
|
|
739
|
+
owned: z14.boolean().optional()
|
|
740
|
+
});
|
|
741
|
+
var statsFreshnessSchema = z14.object({
|
|
580
742
|
/** Newest run-ingest time across the org (ISO), or null if nothing ingested. */
|
|
581
|
-
watermark:
|
|
743
|
+
watermark: z14.string().nullable(),
|
|
582
744
|
/** Runs that succeeded recently but haven't landed in the warehouse yet. */
|
|
583
|
-
pending:
|
|
745
|
+
pending: z14.number().int(),
|
|
584
746
|
/** False when the freshness read itself failed (distinguish from genuine zero). */
|
|
585
|
-
available:
|
|
747
|
+
available: z14.boolean()
|
|
586
748
|
});
|
|
587
|
-
var statsResponseSchema = (item) =>
|
|
749
|
+
var statsResponseSchema = (item) => z14.object({ items: z14.array(item), freshness: statsFreshnessSchema });
|
|
588
750
|
var rankingsResponseSchema = statsResponseSchema(brandRankingSchema);
|
|
589
751
|
var installsResponseSchema = statsResponseSchema(packageRateSchema);
|
|
590
752
|
var brandsResponseSchema = statsResponseSchema(brandRateSchema);
|
|
@@ -601,7 +763,7 @@ var DATASETS = [
|
|
|
601
763
|
"files",
|
|
602
764
|
"tokens"
|
|
603
765
|
];
|
|
604
|
-
var datasetSchema =
|
|
766
|
+
var datasetSchema = z15.enum(DATASETS);
|
|
605
767
|
var WHERE_OPS = [
|
|
606
768
|
"eq",
|
|
607
769
|
"neq",
|
|
@@ -613,150 +775,150 @@ var WHERE_OPS = [
|
|
|
613
775
|
"lt",
|
|
614
776
|
"lte"
|
|
615
777
|
];
|
|
616
|
-
var whereOpSchema =
|
|
778
|
+
var whereOpSchema = z15.enum(WHERE_OPS);
|
|
617
779
|
var GRANULARITIES = ["day", "week", "month"];
|
|
618
|
-
var granularitySchema =
|
|
780
|
+
var granularitySchema = z15.enum(GRANULARITIES);
|
|
619
781
|
var DEFAULT_QUERY_LIMIT = 50;
|
|
620
782
|
var MAX_QUERY_LIMIT = 1e3;
|
|
621
|
-
var scalar =
|
|
622
|
-
var whereClauseSchema =
|
|
623
|
-
dimension:
|
|
783
|
+
var scalar = z15.union([z15.string(), z15.number(), z15.boolean()]);
|
|
784
|
+
var whereClauseSchema = z15.object({
|
|
785
|
+
dimension: z15.string().min(1),
|
|
624
786
|
op: whereOpSchema,
|
|
625
|
-
value:
|
|
626
|
-
});
|
|
627
|
-
var queryFiltersSchema =
|
|
628
|
-
prompt:
|
|
629
|
-
topic:
|
|
630
|
-
tag:
|
|
631
|
-
repo:
|
|
632
|
-
language:
|
|
633
|
-
framework:
|
|
634
|
-
size:
|
|
635
|
-
agent:
|
|
636
|
-
model:
|
|
637
|
-
scenario:
|
|
638
|
-
experiment:
|
|
639
|
-
branded:
|
|
787
|
+
value: z15.union([scalar, z15.array(scalar)])
|
|
788
|
+
});
|
|
789
|
+
var queryFiltersSchema = z15.object({
|
|
790
|
+
prompt: z15.string(),
|
|
791
|
+
topic: z15.array(z15.string()),
|
|
792
|
+
tag: z15.array(z15.string()),
|
|
793
|
+
repo: z15.array(z15.string()),
|
|
794
|
+
language: z15.array(z15.string()),
|
|
795
|
+
framework: z15.array(z15.string()),
|
|
796
|
+
size: z15.array(z15.string()),
|
|
797
|
+
agent: z15.array(z15.string()),
|
|
798
|
+
model: z15.array(z15.string()),
|
|
799
|
+
scenario: z15.array(z15.string()),
|
|
800
|
+
experiment: z15.array(z15.string()),
|
|
801
|
+
branded: z15.boolean()
|
|
640
802
|
}).partial();
|
|
641
|
-
var dateRangeSchema =
|
|
642
|
-
since:
|
|
643
|
-
until:
|
|
644
|
-
lastDays:
|
|
803
|
+
var dateRangeSchema = z15.object({
|
|
804
|
+
since: z15.string(),
|
|
805
|
+
until: z15.string(),
|
|
806
|
+
lastDays: z15.number().int().positive()
|
|
645
807
|
}).partial();
|
|
646
|
-
var orderBySchema =
|
|
808
|
+
var orderBySchema = z15.object({
|
|
647
809
|
/** A selected dimension or metric name. */
|
|
648
|
-
key:
|
|
649
|
-
dir:
|
|
810
|
+
key: z15.string().min(1),
|
|
811
|
+
dir: z15.enum(["asc", "desc"]).default("desc")
|
|
650
812
|
});
|
|
651
|
-
var querySpecSchema =
|
|
813
|
+
var querySpecSchema = z15.object({
|
|
652
814
|
dataset: datasetSchema.default("runs"),
|
|
653
|
-
dimensions:
|
|
654
|
-
metrics:
|
|
815
|
+
dimensions: z15.array(z15.string()).default([]),
|
|
816
|
+
metrics: z15.array(z15.string()).min(1, "at least one metric is required"),
|
|
655
817
|
filters: queryFiltersSchema.default({}),
|
|
656
|
-
where:
|
|
818
|
+
where: z15.array(whereClauseSchema).default([]),
|
|
657
819
|
dateRange: dateRangeSchema.optional(),
|
|
658
|
-
orderBy:
|
|
659
|
-
limit:
|
|
820
|
+
orderBy: z15.array(orderBySchema).default([]),
|
|
821
|
+
limit: z15.number().int().min(1).max(MAX_QUERY_LIMIT).default(DEFAULT_QUERY_LIMIT),
|
|
660
822
|
granularity: granularitySchema.default("day"),
|
|
661
823
|
/** When true, the response echoes the compiled SQL (params bound, not inlined). */
|
|
662
|
-
explain:
|
|
824
|
+
explain: z15.boolean().default(false)
|
|
663
825
|
});
|
|
664
|
-
var columnKindSchema =
|
|
665
|
-
var queryColumnSchema =
|
|
666
|
-
key:
|
|
826
|
+
var columnKindSchema = z15.enum(["dimension", "metric"]);
|
|
827
|
+
var queryColumnSchema = z15.object({
|
|
828
|
+
key: z15.string(),
|
|
667
829
|
kind: columnKindSchema
|
|
668
830
|
});
|
|
669
|
-
var queryRowSchema =
|
|
670
|
-
|
|
671
|
-
|
|
831
|
+
var queryRowSchema = z15.record(
|
|
832
|
+
z15.string(),
|
|
833
|
+
z15.union([z15.string(), z15.number(), z15.boolean(), z15.null()])
|
|
672
834
|
);
|
|
673
|
-
var queryResponseSchema =
|
|
674
|
-
columns:
|
|
675
|
-
rows:
|
|
835
|
+
var queryResponseSchema = z15.object({
|
|
836
|
+
columns: z15.array(queryColumnSchema),
|
|
837
|
+
rows: z15.array(queryRowSchema),
|
|
676
838
|
/** Present only when the request set explain=true. */
|
|
677
|
-
sql:
|
|
839
|
+
sql: z15.string().optional(),
|
|
678
840
|
freshness: statsFreshnessSchema
|
|
679
841
|
});
|
|
680
|
-
var fieldTypeSchema =
|
|
842
|
+
var fieldTypeSchema = z15.enum([
|
|
681
843
|
"string",
|
|
682
844
|
"number",
|
|
683
845
|
"rate",
|
|
684
846
|
"date",
|
|
685
847
|
"boolean"
|
|
686
848
|
]);
|
|
687
|
-
var fieldSchema =
|
|
688
|
-
name:
|
|
849
|
+
var fieldSchema = z15.object({
|
|
850
|
+
name: z15.string(),
|
|
689
851
|
type: fieldTypeSchema,
|
|
690
852
|
/** One-line human/agent hint. */
|
|
691
|
-
description:
|
|
853
|
+
description: z15.string().optional()
|
|
692
854
|
});
|
|
693
|
-
var datasetMetaSchema =
|
|
855
|
+
var datasetMetaSchema = z15.object({
|
|
694
856
|
name: datasetSchema,
|
|
695
|
-
grain:
|
|
696
|
-
dimensions:
|
|
697
|
-
metrics:
|
|
857
|
+
grain: z15.string(),
|
|
858
|
+
dimensions: z15.array(fieldSchema),
|
|
859
|
+
metrics: z15.array(fieldSchema)
|
|
698
860
|
});
|
|
699
|
-
var metadataResponseSchema =
|
|
700
|
-
datasets:
|
|
861
|
+
var metadataResponseSchema = z15.object({
|
|
862
|
+
datasets: z15.array(datasetMetaSchema)
|
|
701
863
|
});
|
|
702
864
|
|
|
703
865
|
// ../packages/api-schemas/src/repos.ts
|
|
704
|
-
import { z as
|
|
866
|
+
import { z as z16 } from "zod";
|
|
705
867
|
var REPO_SIZE_BUCKETS = [
|
|
706
868
|
"small",
|
|
707
869
|
"medium",
|
|
708
870
|
"large",
|
|
709
871
|
"xlarge"
|
|
710
872
|
];
|
|
711
|
-
var repoSizeBucketSchema =
|
|
712
|
-
var repoSchema =
|
|
713
|
-
url:
|
|
714
|
-
name:
|
|
715
|
-
isSystem:
|
|
716
|
-
languages:
|
|
717
|
-
frameworks:
|
|
873
|
+
var repoSizeBucketSchema = z16.enum(REPO_SIZE_BUCKETS);
|
|
874
|
+
var repoSchema = z16.object({
|
|
875
|
+
url: z16.string(),
|
|
876
|
+
name: z16.string(),
|
|
877
|
+
isSystem: z16.boolean(),
|
|
878
|
+
languages: z16.array(z16.string()),
|
|
879
|
+
frameworks: z16.array(z16.string()),
|
|
718
880
|
/** Faceted labels (complexity:L2, buildable:yes, stack:nextjs, …). */
|
|
719
|
-
tags:
|
|
720
|
-
primaryLanguage:
|
|
721
|
-
sizeKb:
|
|
881
|
+
tags: z16.array(z16.string()),
|
|
882
|
+
primaryLanguage: z16.string(),
|
|
883
|
+
sizeKb: z16.number(),
|
|
722
884
|
sizeBucket: repoSizeBucketSchema.nullable(),
|
|
723
|
-
stars:
|
|
885
|
+
stars: z16.number()
|
|
724
886
|
});
|
|
725
887
|
var repoListResponseSchema = listResponseSchema(repoSchema);
|
|
726
|
-
var addRepoBodySchema =
|
|
727
|
-
url:
|
|
888
|
+
var addRepoBodySchema = z16.object({
|
|
889
|
+
url: z16.string().min(1, "url is required"),
|
|
728
890
|
/**
|
|
729
891
|
* Reserved (accepted, not yet persisted): the catalog keys repos by URL only
|
|
730
892
|
* — `fact_repo` has no ref column and metadata sync always reads the default
|
|
731
893
|
* branch. Kept in the wire format so `gauge repos add --ref` is stable once
|
|
732
894
|
* the catalog learns refs.
|
|
733
895
|
*/
|
|
734
|
-
ref:
|
|
896
|
+
ref: z16.string().min(1).optional(),
|
|
735
897
|
/** Display name; defaults to the `owner/repo` label of the URL. */
|
|
736
|
-
name:
|
|
898
|
+
name: z16.string().min(1).optional(),
|
|
737
899
|
/** Manual override; defaults to frameworks detected from the repo's manifests. */
|
|
738
|
-
frameworks:
|
|
739
|
-
tags:
|
|
900
|
+
frameworks: z16.array(z16.string()).optional(),
|
|
901
|
+
tags: z16.array(z16.string()).optional()
|
|
740
902
|
});
|
|
741
|
-
var updateRepoBodySchema =
|
|
742
|
-
url:
|
|
743
|
-
name:
|
|
744
|
-
frameworks:
|
|
745
|
-
tags:
|
|
903
|
+
var updateRepoBodySchema = z16.object({
|
|
904
|
+
url: z16.string().min(1, "url is required"),
|
|
905
|
+
name: z16.string().min(1).optional(),
|
|
906
|
+
frameworks: z16.array(z16.string()).optional(),
|
|
907
|
+
tags: z16.array(z16.string()).optional()
|
|
746
908
|
});
|
|
747
|
-
var resyncRepoBodySchema =
|
|
748
|
-
url:
|
|
909
|
+
var resyncRepoBodySchema = z16.object({
|
|
910
|
+
url: z16.string().min(1, "url is required")
|
|
749
911
|
});
|
|
750
|
-
var deleteRepoQuerySchema =
|
|
751
|
-
url:
|
|
912
|
+
var deleteRepoQuerySchema = z16.object({
|
|
913
|
+
url: z16.string().min(1, "url is required")
|
|
752
914
|
});
|
|
753
|
-
var repoSyncResultSchema =
|
|
915
|
+
var repoSyncResultSchema = z16.object({
|
|
754
916
|
repo: repoSchema,
|
|
755
|
-
synced:
|
|
917
|
+
synced: z16.boolean()
|
|
756
918
|
});
|
|
757
919
|
|
|
758
920
|
// ../packages/api-schemas/src/runs.ts
|
|
759
|
-
import { z as
|
|
921
|
+
import { z as z17 } from "zod";
|
|
760
922
|
var RUN_STATUSES = [
|
|
761
923
|
"QUEUED",
|
|
762
924
|
"CLAIMED",
|
|
@@ -767,102 +929,143 @@ var RUN_STATUSES = [
|
|
|
767
929
|
"TIMED_OUT",
|
|
768
930
|
"CANCELED"
|
|
769
931
|
];
|
|
770
|
-
var runStatusSchema =
|
|
932
|
+
var runStatusSchema = z17.enum(RUN_STATUSES);
|
|
771
933
|
var AGENTS2 = ["CLAUDE_CODE", "CODEX_CLI", "CURSOR"];
|
|
772
|
-
var agentSchema2 =
|
|
773
|
-
var runStatusFilterSchema =
|
|
934
|
+
var agentSchema2 = z17.enum(AGENTS2);
|
|
935
|
+
var runStatusFilterSchema = z17.string().transform(
|
|
774
936
|
(raw) => raw.split(",").map((s) => s.trim().toUpperCase()).filter(Boolean)
|
|
775
|
-
).pipe(
|
|
937
|
+
).pipe(z17.array(runStatusSchema).min(1));
|
|
776
938
|
var runListQuerySchema = listQuerySchema.extend({
|
|
777
939
|
status: runStatusFilterSchema.optional(),
|
|
778
|
-
batch:
|
|
779
|
-
prompt:
|
|
780
|
-
experiment:
|
|
781
|
-
since:
|
|
940
|
+
batch: z17.string().optional(),
|
|
941
|
+
prompt: z17.string().optional(),
|
|
942
|
+
experiment: z17.string().optional(),
|
|
943
|
+
since: z17.string().optional()
|
|
782
944
|
});
|
|
783
|
-
var runListItemSchema =
|
|
784
|
-
id:
|
|
945
|
+
var runListItemSchema = z17.object({
|
|
946
|
+
id: z17.string(),
|
|
785
947
|
status: runStatusSchema,
|
|
786
948
|
agent: agentSchema2,
|
|
787
|
-
model:
|
|
788
|
-
promptId:
|
|
949
|
+
model: z17.string(),
|
|
950
|
+
promptId: z17.string(),
|
|
789
951
|
/** First ~80 chars of the batch's prompt snapshot, whitespace-collapsed. */
|
|
790
|
-
promptSnippet:
|
|
791
|
-
batchId:
|
|
792
|
-
experiment:
|
|
793
|
-
turns:
|
|
794
|
-
usdCost:
|
|
795
|
-
durationMs:
|
|
796
|
-
exitReason:
|
|
797
|
-
createdAt:
|
|
798
|
-
startedAt:
|
|
799
|
-
finishedAt:
|
|
952
|
+
promptSnippet: z17.string(),
|
|
953
|
+
batchId: z17.string(),
|
|
954
|
+
experiment: z17.string().nullable(),
|
|
955
|
+
turns: z17.number().int().nullable(),
|
|
956
|
+
usdCost: z17.number().nullable(),
|
|
957
|
+
durationMs: z17.number().int().nullable(),
|
|
958
|
+
exitReason: z17.string().nullable(),
|
|
959
|
+
createdAt: z17.string(),
|
|
960
|
+
startedAt: z17.string().nullable(),
|
|
961
|
+
finishedAt: z17.string().nullable()
|
|
800
962
|
});
|
|
801
963
|
var runListResponseSchema = listResponseSchema(runListItemSchema);
|
|
802
964
|
var runDetailSchema = runListItemSchema.omit({ promptSnippet: true }).extend({
|
|
803
|
-
promptText:
|
|
804
|
-
attempt:
|
|
805
|
-
cancelRequested:
|
|
806
|
-
failureReason:
|
|
807
|
-
repoUrl:
|
|
808
|
-
repoRef:
|
|
809
|
-
scenario:
|
|
810
|
-
funding:
|
|
965
|
+
promptText: z17.string(),
|
|
966
|
+
attempt: z17.number().int(),
|
|
967
|
+
cancelRequested: z17.boolean(),
|
|
968
|
+
failureReason: z17.string().nullable(),
|
|
969
|
+
repoUrl: z17.string().nullable(),
|
|
970
|
+
repoRef: z17.string().nullable(),
|
|
971
|
+
scenario: z17.string(),
|
|
972
|
+
funding: z17.string(),
|
|
811
973
|
/** Raw harness usage write-back (token counts etc.); shape may evolve. */
|
|
812
|
-
usage:
|
|
974
|
+
usage: z17.unknown().nullable(),
|
|
813
975
|
/** Artifact pointer: a working-tree diff exists at GET /runs/{id}/diff. */
|
|
814
|
-
hasDiff:
|
|
815
|
-
claimedAt:
|
|
976
|
+
hasDiff: z17.boolean(),
|
|
977
|
+
claimedAt: z17.string().nullable()
|
|
816
978
|
});
|
|
817
|
-
var cancelRunResponseSchema =
|
|
818
|
-
id:
|
|
979
|
+
var cancelRunResponseSchema = z17.object({
|
|
980
|
+
id: z17.string(),
|
|
819
981
|
status: runStatusSchema,
|
|
820
|
-
cancelRequested:
|
|
821
|
-
note:
|
|
822
|
-
});
|
|
823
|
-
var forkRunBodySchema =
|
|
824
|
-
prompt:
|
|
825
|
-
turn:
|
|
826
|
-
});
|
|
827
|
-
var forkRunResponseSchema =
|
|
828
|
-
runId:
|
|
829
|
-
batchId:
|
|
830
|
-
parentRunId:
|
|
831
|
-
checkpointId:
|
|
832
|
-
turn:
|
|
833
|
-
});
|
|
834
|
-
var
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
982
|
+
cancelRequested: z17.boolean(),
|
|
983
|
+
note: z17.string().optional()
|
|
984
|
+
});
|
|
985
|
+
var forkRunBodySchema = z17.object({
|
|
986
|
+
prompt: z17.string().trim().min(1).max(2e4),
|
|
987
|
+
turn: z17.number().int().min(0).optional()
|
|
988
|
+
});
|
|
989
|
+
var forkRunResponseSchema = z17.object({
|
|
990
|
+
runId: z17.string(),
|
|
991
|
+
batchId: z17.string(),
|
|
992
|
+
parentRunId: z17.string(),
|
|
993
|
+
checkpointId: z17.string(),
|
|
994
|
+
turn: z17.number().int().min(0)
|
|
995
|
+
});
|
|
996
|
+
var RUN_INSIGHT_STATUSES = [
|
|
997
|
+
"PENDING",
|
|
998
|
+
"RUNNING",
|
|
999
|
+
"COMPLETE",
|
|
1000
|
+
"FAILED",
|
|
1001
|
+
"SKIPPED"
|
|
1002
|
+
];
|
|
1003
|
+
var runInsightStatusSchema = z17.enum(RUN_INSIGHT_STATUSES);
|
|
1004
|
+
var insightPassSchema = z17.object({
|
|
1005
|
+
status: runInsightStatusSchema,
|
|
1006
|
+
model: z17.string().nullable(),
|
|
1007
|
+
inputTokens: z17.number().int().nullable(),
|
|
1008
|
+
outputTokens: z17.number().int().nullable(),
|
|
1009
|
+
usdCost: z17.number().nullable(),
|
|
1010
|
+
error: z17.string().nullable()
|
|
1011
|
+
});
|
|
1012
|
+
var runDecisionSchema = z17.object({
|
|
1013
|
+
index: z17.number().int(),
|
|
1014
|
+
category: z17.string(),
|
|
1015
|
+
categoryRaw: z17.string().nullable(),
|
|
1016
|
+
chosenName: z17.string(),
|
|
1017
|
+
chosenEcosystem: z17.string().nullable(),
|
|
1018
|
+
chosenPackage: z17.string().nullable(),
|
|
1019
|
+
reversed: z17.boolean(),
|
|
1020
|
+
detail: z17.unknown()
|
|
1021
|
+
});
|
|
1022
|
+
var runImplementationSchema = z17.object({
|
|
1023
|
+
brandName: z17.string(),
|
|
1024
|
+
ecosystem: z17.string().nullable(),
|
|
1025
|
+
package: z17.string().nullable(),
|
|
1026
|
+
verdict: z17.string(),
|
|
1027
|
+
docConsulted: z17.boolean(),
|
|
1028
|
+
detail: z17.unknown()
|
|
1029
|
+
});
|
|
1030
|
+
var runInsightResponseSchema = z17.object({
|
|
1031
|
+
runId: z17.string(),
|
|
1032
|
+
decision: insightPassSchema,
|
|
1033
|
+
implementation: insightPassSchema,
|
|
1034
|
+
decisions: z17.array(runDecisionSchema),
|
|
1035
|
+
implementations: z17.array(runImplementationSchema)
|
|
1036
|
+
});
|
|
1037
|
+
var runEventSchema = z17.looseObject({
|
|
1038
|
+
run_id: z17.string(),
|
|
1039
|
+
seq: z17.number(),
|
|
1040
|
+
turn: z17.number(),
|
|
1041
|
+
ts: z17.string(),
|
|
1042
|
+
type: z17.string()
|
|
840
1043
|
});
|
|
841
1044
|
|
|
842
1045
|
// ../packages/api-schemas/src/tokens.ts
|
|
843
|
-
import { z as
|
|
844
|
-
var apiTokenSchema =
|
|
845
|
-
id:
|
|
846
|
-
name:
|
|
1046
|
+
import { z as z18 } from "zod";
|
|
1047
|
+
var apiTokenSchema = z18.object({
|
|
1048
|
+
id: z18.string(),
|
|
1049
|
+
name: z18.string(),
|
|
847
1050
|
/** Last 4 chars of the plaintext, for recognizability (non-secret). */
|
|
848
|
-
last4:
|
|
849
|
-
expiresAt:
|
|
850
|
-
lastUsedAt:
|
|
851
|
-
createdAt:
|
|
852
|
-
revokedAt:
|
|
853
|
-
});
|
|
854
|
-
var createTokenRequestSchema =
|
|
855
|
-
name:
|
|
1051
|
+
last4: z18.string(),
|
|
1052
|
+
expiresAt: z18.iso.datetime().nullable(),
|
|
1053
|
+
lastUsedAt: z18.iso.datetime().nullable(),
|
|
1054
|
+
createdAt: z18.iso.datetime(),
|
|
1055
|
+
revokedAt: z18.iso.datetime().nullable()
|
|
1056
|
+
});
|
|
1057
|
+
var createTokenRequestSchema = z18.object({
|
|
1058
|
+
name: z18.string().min(1).max(100),
|
|
856
1059
|
/** ISO-8601 datetime; omit for no expiry. */
|
|
857
|
-
expiresAt:
|
|
1060
|
+
expiresAt: z18.iso.datetime({ offset: true }).optional()
|
|
858
1061
|
});
|
|
859
1062
|
var createTokenResponseSchema = apiTokenSchema.extend({
|
|
860
|
-
token:
|
|
1063
|
+
token: z18.string()
|
|
861
1064
|
});
|
|
862
1065
|
var listTokensResponseSchema = listResponseSchema(apiTokenSchema);
|
|
863
1066
|
|
|
864
1067
|
// src/commands/apply.ts
|
|
865
|
-
import { z as
|
|
1068
|
+
import { z as z19 } from "zod";
|
|
866
1069
|
|
|
867
1070
|
// src/version.ts
|
|
868
1071
|
import { createRequire } from "module";
|
|
@@ -1312,7 +1515,7 @@ function register(program2) {
|
|
|
1312
1515
|
).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(
|
|
1313
1516
|
async (opts, command) => {
|
|
1314
1517
|
if (opts.schema) {
|
|
1315
|
-
printJson(
|
|
1518
|
+
printJson(z19.toJSONSchema(batteries_exports.batterySpecSchema));
|
|
1316
1519
|
return;
|
|
1317
1520
|
}
|
|
1318
1521
|
if (opts.example) {
|
|
@@ -1349,12 +1552,14 @@ function register(program2) {
|
|
|
1349
1552
|
// src/commands/auth.ts
|
|
1350
1553
|
var auth_exports = {};
|
|
1351
1554
|
__export(auth_exports, {
|
|
1555
|
+
deviceLogin: () => deviceLogin,
|
|
1352
1556
|
register: () => register2
|
|
1353
1557
|
});
|
|
1354
1558
|
import { spawn } from "child_process";
|
|
1355
1559
|
import { randomBytes } from "crypto";
|
|
1356
1560
|
import { createServer } from "http";
|
|
1357
1561
|
import { hostname } from "os";
|
|
1562
|
+
import { setTimeout as sleep } from "timers/promises";
|
|
1358
1563
|
|
|
1359
1564
|
// src/lib/paginate.ts
|
|
1360
1565
|
async function fetchAllPages(client, path, query = {}) {
|
|
@@ -1511,6 +1716,125 @@ async function browserLogin() {
|
|
|
1511
1716
|
server.closeAllConnections();
|
|
1512
1717
|
}
|
|
1513
1718
|
}
|
|
1719
|
+
var DEVICE_ENDPOINT = "/api/v1/device";
|
|
1720
|
+
async function devicePost(path, body) {
|
|
1721
|
+
const base = resolveBaseUrl().replace(/\/+$/, "");
|
|
1722
|
+
let res;
|
|
1723
|
+
try {
|
|
1724
|
+
res = await fetch(`${base}${path}`, {
|
|
1725
|
+
method: "POST",
|
|
1726
|
+
headers: {
|
|
1727
|
+
"Content-Type": "application/json",
|
|
1728
|
+
Accept: "application/json",
|
|
1729
|
+
"User-Agent": USER_AGENT
|
|
1730
|
+
},
|
|
1731
|
+
body: JSON.stringify(body)
|
|
1732
|
+
});
|
|
1733
|
+
} catch (e) {
|
|
1734
|
+
throw new CliError(
|
|
1735
|
+
"network",
|
|
1736
|
+
`Request to ${base} failed: ${e instanceof Error ? e.message : String(e)}`
|
|
1737
|
+
);
|
|
1738
|
+
}
|
|
1739
|
+
const text = await res.text();
|
|
1740
|
+
if (!res.ok) {
|
|
1741
|
+
try {
|
|
1742
|
+
const parsed = errorEnvelopeSchema.safeParse(JSON.parse(text));
|
|
1743
|
+
if (parsed.success) {
|
|
1744
|
+
throw new CliError(parsed.data.error.code, parsed.data.error.message);
|
|
1745
|
+
}
|
|
1746
|
+
} catch (e) {
|
|
1747
|
+
if (e instanceof CliError) throw e;
|
|
1748
|
+
}
|
|
1749
|
+
throw new CliError(
|
|
1750
|
+
"internal",
|
|
1751
|
+
`Device request failed: HTTP ${res.status} ${res.statusText}`.trim()
|
|
1752
|
+
);
|
|
1753
|
+
}
|
|
1754
|
+
return JSON.parse(text);
|
|
1755
|
+
}
|
|
1756
|
+
async function deviceLogin(opts) {
|
|
1757
|
+
const start = await devicePost(
|
|
1758
|
+
`${DEVICE_ENDPOINT}/authorize`,
|
|
1759
|
+
{ deviceName: hostname() || "this device", email: opts.email }
|
|
1760
|
+
);
|
|
1761
|
+
console.log("To sign in, open this URL in a browser:\n");
|
|
1762
|
+
console.log(` ${start.verificationUriComplete}
|
|
1763
|
+
`);
|
|
1764
|
+
console.log(`and confirm this code: ${start.userCode}
|
|
1765
|
+
`);
|
|
1766
|
+
if (start.emailSent && opts.email) {
|
|
1767
|
+
console.log(`We also emailed a sign-in link to ${opts.email}.`);
|
|
1768
|
+
}
|
|
1769
|
+
console.log("Waiting for you to approve in the browser\u2026");
|
|
1770
|
+
openBrowser(start.verificationUriComplete);
|
|
1771
|
+
const deadline = Date.now() + start.expiresIn * 1e3;
|
|
1772
|
+
const MAX_TRANSIENT = 5;
|
|
1773
|
+
let interval = start.interval;
|
|
1774
|
+
let transient = 0;
|
|
1775
|
+
while (Date.now() < deadline) {
|
|
1776
|
+
await sleep(interval * 1e3);
|
|
1777
|
+
let raw;
|
|
1778
|
+
try {
|
|
1779
|
+
raw = await devicePost(`${DEVICE_ENDPOINT}/token`, {
|
|
1780
|
+
deviceCode: start.deviceCode
|
|
1781
|
+
});
|
|
1782
|
+
} catch (e) {
|
|
1783
|
+
if (e instanceof CliError && (e.code === "network" || e.code === "internal") && ++transient <= MAX_TRANSIENT) {
|
|
1784
|
+
continue;
|
|
1785
|
+
}
|
|
1786
|
+
throw e;
|
|
1787
|
+
}
|
|
1788
|
+
transient = 0;
|
|
1789
|
+
const parsed = deviceTokenResultSchema.safeParse(raw);
|
|
1790
|
+
if (!parsed.success) {
|
|
1791
|
+
throw new CliError(
|
|
1792
|
+
"internal",
|
|
1793
|
+
"Unexpected response from the device token endpoint."
|
|
1794
|
+
);
|
|
1795
|
+
}
|
|
1796
|
+
const result = parsed.data;
|
|
1797
|
+
switch (result.status) {
|
|
1798
|
+
case "pending":
|
|
1799
|
+
continue;
|
|
1800
|
+
case "slow_down":
|
|
1801
|
+
interval = result.interval;
|
|
1802
|
+
continue;
|
|
1803
|
+
case "denied":
|
|
1804
|
+
throw new CliError(
|
|
1805
|
+
"unauthorized",
|
|
1806
|
+
"Authorization was denied in the browser."
|
|
1807
|
+
);
|
|
1808
|
+
case "expired":
|
|
1809
|
+
throw new CliError(
|
|
1810
|
+
"unauthorized",
|
|
1811
|
+
"The sign-in request expired before it was approved. Re-run it to try again."
|
|
1812
|
+
);
|
|
1813
|
+
case "approved": {
|
|
1814
|
+
const token = result.accessToken;
|
|
1815
|
+
saveToken(token);
|
|
1816
|
+
try {
|
|
1817
|
+
const me = await fetchMe(new ApiClient({ token }));
|
|
1818
|
+
return { token, me };
|
|
1819
|
+
} catch (e) {
|
|
1820
|
+
throw new CliError(
|
|
1821
|
+
"network",
|
|
1822
|
+
`Signed in and token saved to ${credentialsPath()}, but couldn't load your profile (${e instanceof Error ? e.message : String(e)}). Run \`gauge whoami\` to retry.`
|
|
1823
|
+
);
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
default:
|
|
1827
|
+
throw new CliError(
|
|
1828
|
+
"internal",
|
|
1829
|
+
`Unexpected device authorization status: ${result.status}`
|
|
1830
|
+
);
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
throw new CliError(
|
|
1834
|
+
"network",
|
|
1835
|
+
"Timed out waiting for browser approval. Re-run to try again."
|
|
1836
|
+
);
|
|
1837
|
+
}
|
|
1514
1838
|
async function readStdin() {
|
|
1515
1839
|
let data = "";
|
|
1516
1840
|
for await (const chunk of process.stdin) data += chunk;
|
|
@@ -1578,10 +1902,26 @@ async function whoami(output) {
|
|
|
1578
1902
|
}
|
|
1579
1903
|
function register2(program2) {
|
|
1580
1904
|
const auth = program2.command("auth").description("Authenticate the CLI (personal access tokens)");
|
|
1581
|
-
auth.command("login").description("Log in via the browser (localhost callback flow)").option("--with-token", "read a token from stdin (headless machines)").
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1905
|
+
auth.command("login").description("Log in via the browser (localhost callback flow)").option("--with-token", "read a token from stdin (headless machines)").option(
|
|
1906
|
+
"--device",
|
|
1907
|
+
"device-authorization flow: print a URL + code to approve elsewhere (no loopback listener; agent/remote-friendly)"
|
|
1908
|
+
).option(
|
|
1909
|
+
"--email <email>",
|
|
1910
|
+
"with --device: also email a sign-in link to this address"
|
|
1911
|
+
).action(
|
|
1912
|
+
async (opts) => {
|
|
1913
|
+
if (opts.device) {
|
|
1914
|
+
const { token, me } = await deviceLogin({ email: opts.email });
|
|
1915
|
+
saveToken(token);
|
|
1916
|
+
console.log(`Token saved to ${credentialsPath()}`);
|
|
1917
|
+
printIdentity(me);
|
|
1918
|
+
} else if (opts.withToken) {
|
|
1919
|
+
await withTokenLogin();
|
|
1920
|
+
} else {
|
|
1921
|
+
await browserLogin();
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
);
|
|
1585
1925
|
auth.command("logout").description("Remove the stored token").action(() => {
|
|
1586
1926
|
clearToken();
|
|
1587
1927
|
console.log(`Removed ${credentialsPath()}`);
|
|
@@ -2057,15 +2397,95 @@ function register7(program2) {
|
|
|
2057
2397
|
});
|
|
2058
2398
|
}
|
|
2059
2399
|
|
|
2060
|
-
// src/commands/
|
|
2061
|
-
var
|
|
2062
|
-
__export(
|
|
2400
|
+
// src/commands/onboard.ts
|
|
2401
|
+
var onboard_exports = {};
|
|
2402
|
+
__export(onboard_exports, {
|
|
2063
2403
|
register: () => register8
|
|
2064
2404
|
});
|
|
2405
|
+
function orgNameFromEmail(email) {
|
|
2406
|
+
const domain = email?.split("@")[1] ?? "";
|
|
2407
|
+
const base = domain.split(".")[0] ?? "";
|
|
2408
|
+
if (!base) return "My Workspace";
|
|
2409
|
+
return base.charAt(0).toUpperCase() + base.slice(1);
|
|
2410
|
+
}
|
|
2411
|
+
function register8(program2) {
|
|
2412
|
+
program2.command("onboard").description(
|
|
2413
|
+
"Self-serve onboarding: sign in (device flow) and create your first workspace"
|
|
2414
|
+
).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(
|
|
2415
|
+
async (opts, command) => {
|
|
2416
|
+
const output = resolveOutput(command);
|
|
2417
|
+
let client;
|
|
2418
|
+
let me;
|
|
2419
|
+
if (resolveToken()) {
|
|
2420
|
+
client = new ApiClient();
|
|
2421
|
+
me = await client.get("/api/v1/me");
|
|
2422
|
+
if (output !== "json") {
|
|
2423
|
+
console.log(`Already signed in as ${me.user.email ?? me.user.id}.`);
|
|
2424
|
+
}
|
|
2425
|
+
} else {
|
|
2426
|
+
const login = await deviceLogin({ email: opts.email });
|
|
2427
|
+
saveToken(login.token);
|
|
2428
|
+
me = login.me;
|
|
2429
|
+
client = new ApiClient({ token: login.token });
|
|
2430
|
+
if (output !== "json") {
|
|
2431
|
+
console.log(
|
|
2432
|
+
`
|
|
2433
|
+
Signed in as ${me.user.email ?? me.user.id} \u2014 token saved to ${credentialsPath()}.`
|
|
2434
|
+
);
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
const wantNewOrg = opts.new === true || opts.orgName !== void 0 || me.orgs.length === 0;
|
|
2438
|
+
let orgSlug;
|
|
2439
|
+
let createdOrg = null;
|
|
2440
|
+
if (wantNewOrg) {
|
|
2441
|
+
const name = opts.orgName?.trim() || orgNameFromEmail(me.user.email);
|
|
2442
|
+
createdOrg = await client.post("/api/v1/orgs", {
|
|
2443
|
+
name,
|
|
2444
|
+
website: opts.website
|
|
2445
|
+
});
|
|
2446
|
+
orgSlug = createdOrg.slug;
|
|
2447
|
+
} else {
|
|
2448
|
+
orgSlug = readConfig().defaultOrg ?? me.orgs[0]?.slug ?? "";
|
|
2449
|
+
if (!orgSlug) {
|
|
2450
|
+
throw new CliError(
|
|
2451
|
+
"internal",
|
|
2452
|
+
"No workspace available; re-run with --org-name to create one."
|
|
2453
|
+
);
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
updateConfig({ defaultOrg: orgSlug });
|
|
2457
|
+
if (output === "json") {
|
|
2458
|
+
printJson({
|
|
2459
|
+
user: me.user,
|
|
2460
|
+
org: createdOrg ?? { slug: orgSlug },
|
|
2461
|
+
defaultOrg: orgSlug
|
|
2462
|
+
});
|
|
2463
|
+
return;
|
|
2464
|
+
}
|
|
2465
|
+
console.log(
|
|
2466
|
+
createdOrg ? `
|
|
2467
|
+
Created workspace ${createdOrg.name} (${orgSlug}).` : `
|
|
2468
|
+
Using workspace ${orgSlug}.`
|
|
2469
|
+
);
|
|
2470
|
+
console.log(`Default org set to ${orgSlug}. You're ready:`);
|
|
2471
|
+
console.log(
|
|
2472
|
+
" gauge apply --example > battery.json # scaffold a run"
|
|
2473
|
+
);
|
|
2474
|
+
console.log(" gauge apply -f battery.json # launch it");
|
|
2475
|
+
console.log(" gauge runs list # watch results");
|
|
2476
|
+
}
|
|
2477
|
+
);
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
// src/commands/orgs.ts
|
|
2481
|
+
var orgs_exports2 = {};
|
|
2482
|
+
__export(orgs_exports2, {
|
|
2483
|
+
register: () => register9
|
|
2484
|
+
});
|
|
2065
2485
|
function isDefault(org, defaultOrg) {
|
|
2066
2486
|
return defaultOrg !== void 0 && (org.slug === defaultOrg || org.publicId === defaultOrg);
|
|
2067
2487
|
}
|
|
2068
|
-
function
|
|
2488
|
+
function register9(program2) {
|
|
2069
2489
|
const orgs = program2.command("orgs").description("Organizations");
|
|
2070
2490
|
orgs.command("list").description("List orgs you belong to").action(async (_opts, command) => {
|
|
2071
2491
|
const output = resolveOutput(command);
|
|
@@ -2090,6 +2510,23 @@ function register8(program2) {
|
|
|
2090
2510
|
"table"
|
|
2091
2511
|
);
|
|
2092
2512
|
});
|
|
2513
|
+
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(
|
|
2514
|
+
async (name, opts, command) => {
|
|
2515
|
+
const created = await createClient().post(
|
|
2516
|
+
"/api/v1/orgs",
|
|
2517
|
+
{ name, website: opts.website }
|
|
2518
|
+
);
|
|
2519
|
+
if (opts.use !== false) updateConfig({ defaultOrg: created.slug });
|
|
2520
|
+
if (resolveOutput(command) === "json") {
|
|
2521
|
+
printJson(created);
|
|
2522
|
+
return;
|
|
2523
|
+
}
|
|
2524
|
+
console.log(`Created workspace ${created.name} (${created.slug})`);
|
|
2525
|
+
if (opts.use !== false) {
|
|
2526
|
+
console.log(`Default org set to ${created.slug}`);
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
);
|
|
2093
2530
|
orgs.command("use <org>").description("Set the default org (slug or public id) in local config").action(async (org, _opts, command) => {
|
|
2094
2531
|
const me = await createClient().get("/api/v1/me");
|
|
2095
2532
|
const match = me.orgs.find((o) => o.slug === org || o.publicId === org);
|
|
@@ -2120,9 +2557,11 @@ function register8(program2) {
|
|
|
2120
2557
|
var prompts_exports2 = {};
|
|
2121
2558
|
__export(prompts_exports2, {
|
|
2122
2559
|
parseAgents: () => parseAgents,
|
|
2560
|
+
parseSamples: () => parseSamples,
|
|
2123
2561
|
promptsPath: () => promptsPath,
|
|
2124
2562
|
readPromptText: () => readPromptText,
|
|
2125
|
-
|
|
2563
|
+
readWebFixture: () => readWebFixture,
|
|
2564
|
+
register: () => register10,
|
|
2126
2565
|
resolveOrCreateTopicId: () => resolveOrCreateTopicId
|
|
2127
2566
|
});
|
|
2128
2567
|
import { readFileSync as readFileSync4 } from "fs";
|
|
@@ -2167,6 +2606,38 @@ function readPromptText(opts) {
|
|
|
2167
2606
|
if (!text) throw new CliError("usage", "prompt file is empty");
|
|
2168
2607
|
return text;
|
|
2169
2608
|
}
|
|
2609
|
+
function readWebFixture(path) {
|
|
2610
|
+
let raw;
|
|
2611
|
+
try {
|
|
2612
|
+
raw = readFileSync4(path, "utf8");
|
|
2613
|
+
} catch (error) {
|
|
2614
|
+
throw new CliError(
|
|
2615
|
+
"usage",
|
|
2616
|
+
"cannot read web fixture " + path + ": " + (error instanceof Error ? error.message : String(error))
|
|
2617
|
+
);
|
|
2618
|
+
}
|
|
2619
|
+
let parsed;
|
|
2620
|
+
try {
|
|
2621
|
+
parsed = JSON.parse(raw);
|
|
2622
|
+
} catch (error) {
|
|
2623
|
+
throw new CliError(
|
|
2624
|
+
"invalid_request",
|
|
2625
|
+
"web fixture is not valid JSON: " + (error instanceof Error ? error.message : String(error))
|
|
2626
|
+
);
|
|
2627
|
+
}
|
|
2628
|
+
const result = web_fixtures_exports.webFixtureSchema.safeParse(parsed);
|
|
2629
|
+
if (!result.success) {
|
|
2630
|
+
const details = result.error.issues.map(
|
|
2631
|
+
(issue) => ` ${issue.path.join(".") || "(fixture)"}: ${issue.message}`
|
|
2632
|
+
).join("\n");
|
|
2633
|
+
throw new CliError(
|
|
2634
|
+
"invalid_request",
|
|
2635
|
+
`not a valid web fixture:
|
|
2636
|
+
${details}`
|
|
2637
|
+
);
|
|
2638
|
+
}
|
|
2639
|
+
return result.data;
|
|
2640
|
+
}
|
|
2170
2641
|
async function resolveOrCreateTopicId(client, org, name) {
|
|
2171
2642
|
const path = `/api/v1/orgs/${encodeURIComponent(org)}/topics`;
|
|
2172
2643
|
let cursor;
|
|
@@ -2201,15 +2672,17 @@ function toRow2(p) {
|
|
|
2201
2672
|
scenario: p.scenario
|
|
2202
2673
|
};
|
|
2203
2674
|
}
|
|
2204
|
-
var
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2675
|
+
var DEFAULT_RUN_AGENTS = ["CLAUDE_CODE", "CODEX_CLI"];
|
|
2676
|
+
function parseSamples(raw, max) {
|
|
2677
|
+
const n = Number(raw);
|
|
2678
|
+
if (!Number.isInteger(n) || n < 1 || max !== void 0 && n > max)
|
|
2679
|
+
throw new CliError(
|
|
2680
|
+
"usage",
|
|
2681
|
+
max === void 0 ? "--samples must be an integer >= 1" : `--samples must be an integer 1-${max}`
|
|
2682
|
+
);
|
|
2683
|
+
return n;
|
|
2684
|
+
}
|
|
2685
|
+
function register10(program2) {
|
|
2213
2686
|
const group = program2.command("prompts").description("Manage prompts");
|
|
2214
2687
|
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(
|
|
2215
2688
|
async (opts, cmd) => {
|
|
@@ -2223,7 +2696,7 @@ function register9(program2) {
|
|
|
2223
2696
|
else printItems(items.map(toRow2), "table");
|
|
2224
2697
|
}
|
|
2225
2698
|
);
|
|
2226
|
-
group.command("get <id>").description("Show a prompt (
|
|
2699
|
+
group.command("get <id>").description("Show a prompt (scheduled-via, topic, tags)").action(async (id, _opts, cmd) => {
|
|
2227
2700
|
const org = resolveOrg(cmd);
|
|
2228
2701
|
const prompt = await createClient().get(
|
|
2229
2702
|
`${promptsPath(org)}/${encodeURIComponent(id)}`
|
|
@@ -2242,20 +2715,19 @@ function register9(program2) {
|
|
|
2242
2715
|
console.log(`created: ${prompt.createdAt}`);
|
|
2243
2716
|
console.log(`text: ${prompt.text}`);
|
|
2244
2717
|
if (prompt.schedules.length) {
|
|
2245
|
-
console.log("
|
|
2718
|
+
console.log("scheduled via:");
|
|
2246
2719
|
printItems(
|
|
2247
2720
|
prompt.schedules.map((s) => ({
|
|
2248
2721
|
id: s.id,
|
|
2249
|
-
|
|
2250
|
-
ref: s.repoRef ?? "",
|
|
2722
|
+
name: s.name,
|
|
2251
2723
|
cadence: s.cadence,
|
|
2252
2724
|
days: s.daysPerWeek ?? "",
|
|
2253
|
-
|
|
2725
|
+
enabled: s.enabled ? "yes" : "no"
|
|
2254
2726
|
})),
|
|
2255
2727
|
"table"
|
|
2256
2728
|
);
|
|
2257
2729
|
} else {
|
|
2258
|
-
console.log("
|
|
2730
|
+
console.log("scheduled via: (none)");
|
|
2259
2731
|
}
|
|
2260
2732
|
});
|
|
2261
2733
|
group.command("create").description("Create a prompt").option("--text <text>", "prompt text").option("--file <path>", 'read prompt text from a file ("-" for stdin)').option("--scenario <scenario>", "greenfield | migration", "greenfield").option("--branded", "mark as a branded prompt").option("--topic <name>", "topic (created if new)").option(
|
|
@@ -2287,11 +2759,9 @@ function register9(program2) {
|
|
|
2287
2759
|
else {
|
|
2288
2760
|
console.log(`Created prompt ${created.id}`);
|
|
2289
2761
|
console.log(
|
|
2290
|
-
`
|
|
2762
|
+
`Run it now with \`gauge prompts run ${created.id}\`, or add it to a schedule set with \`gauge schedules create --name <name> --prompt ${created.id} --agent claude-code\``
|
|
2291
2763
|
);
|
|
2292
2764
|
}
|
|
2293
|
-
if (created.firstRunBlocked)
|
|
2294
|
-
console.error(BLOCK_WARNINGS[created.firstRunBlocked]);
|
|
2295
2765
|
}
|
|
2296
2766
|
);
|
|
2297
2767
|
group.command("edit <id>").description("Update a prompt").option("--text <text>", "new prompt text").option("--file <path>", 'read new text from a file ("-" for stdin)').option("--branded <bool>", "true | false").option("--topic <name>", "set the topic (created if new)").option("--clear-topic", "clear the topic").option(
|
|
@@ -2337,19 +2807,27 @@ function register9(program2) {
|
|
|
2337
2807
|
);
|
|
2338
2808
|
if (resolveOutput(cmd) !== "json") console.log(`Deleted prompt ${id}`);
|
|
2339
2809
|
});
|
|
2340
|
-
group.command("run <id>").description(
|
|
2810
|
+
group.command("run <id>").description(
|
|
2811
|
+
"Run a prompt now \u2014 an ad-hoc agents x repo x samples spec (ORG funding, credit-gated)"
|
|
2812
|
+
).option(
|
|
2341
2813
|
"--agent <agents>",
|
|
2342
|
-
"comma-separated agents, e.g. claude-code,codex"
|
|
2343
|
-
).option("--
|
|
2814
|
+
"comma-separated agents, e.g. claude-code,codex (default: claude-code,codex)"
|
|
2815
|
+
).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(
|
|
2816
|
+
"--web-fixture <path>",
|
|
2817
|
+
"web fixture JSON; pages are injected transparently into native WebFetch (misses pass through live)"
|
|
2818
|
+
).action(
|
|
2344
2819
|
async (id, opts, cmd) => {
|
|
2345
2820
|
const org = resolveOrg(cmd);
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2821
|
+
if (opts.ref !== void 0 && opts.repo === void 0)
|
|
2822
|
+
throw new CliError("usage", "--ref requires --repo");
|
|
2823
|
+
const body = {
|
|
2824
|
+
agents: opts.agent !== void 0 ? parseAgents(opts.agent) : DEFAULT_RUN_AGENTS,
|
|
2825
|
+
samplesPerCycle: opts.samples !== void 0 ? parseSamples(opts.samples, 10) : 1
|
|
2826
|
+
};
|
|
2827
|
+
if (opts.repo !== void 0) body.repoUrl = opts.repo;
|
|
2828
|
+
if (opts.ref !== void 0) body.repoRef = opts.ref;
|
|
2829
|
+
if (opts.webFixture !== void 0) {
|
|
2830
|
+
body.webFixture = readWebFixture(opts.webFixture);
|
|
2353
2831
|
}
|
|
2354
2832
|
const result = await createClient().post(
|
|
2355
2833
|
`${promptsPath(org)}/${encodeURIComponent(id)}/run`,
|
|
@@ -2360,16 +2838,13 @@ function register9(program2) {
|
|
|
2360
2838
|
return;
|
|
2361
2839
|
}
|
|
2362
2840
|
if (result.runIds.length === 0) {
|
|
2363
|
-
console.log(
|
|
2364
|
-
"No runs enqueued (the prompt has no matching schedules)"
|
|
2365
|
-
);
|
|
2841
|
+
console.log("No runs enqueued");
|
|
2366
2842
|
return;
|
|
2367
2843
|
}
|
|
2368
2844
|
console.log(
|
|
2369
2845
|
`Enqueued ${result.runIds.length} run(s) in ${result.batchIds.length} batch(es)`
|
|
2370
2846
|
);
|
|
2371
2847
|
for (const runId of result.runIds) console.log(runId);
|
|
2372
|
-
if (result.blocked) console.error(RUN_BLOCK_WARNINGS[result.blocked]);
|
|
2373
2848
|
console.error("Tip: `gauge runs watch <id>` streams a run live");
|
|
2374
2849
|
}
|
|
2375
2850
|
);
|
|
@@ -2378,7 +2853,7 @@ function register9(program2) {
|
|
|
2378
2853
|
// src/commands/query.ts
|
|
2379
2854
|
var query_exports2 = {};
|
|
2380
2855
|
__export(query_exports2, {
|
|
2381
|
-
register: () =>
|
|
2856
|
+
register: () => register11
|
|
2382
2857
|
});
|
|
2383
2858
|
var collect3 = (value, prev = []) => [
|
|
2384
2859
|
...prev,
|
|
@@ -2571,7 +3046,7 @@ async function showMetadata(command, mode, dataset) {
|
|
|
2571
3046
|
console.error(`dataset: ${ds.name} \u2014 ${ds.grain}`);
|
|
2572
3047
|
printItems(rows, "table");
|
|
2573
3048
|
}
|
|
2574
|
-
function
|
|
3049
|
+
function register11(program2) {
|
|
2575
3050
|
const group = program2.command("query").description(
|
|
2576
3051
|
"Flexible reports over your event warehouse (run a report, or discover the catalog)"
|
|
2577
3052
|
);
|
|
@@ -2607,7 +3082,7 @@ function register10(program2) {
|
|
|
2607
3082
|
// src/commands/repos.ts
|
|
2608
3083
|
var repos_exports2 = {};
|
|
2609
3084
|
__export(repos_exports2, {
|
|
2610
|
-
register: () =>
|
|
3085
|
+
register: () => register12
|
|
2611
3086
|
});
|
|
2612
3087
|
function reposPath(org) {
|
|
2613
3088
|
return `/api/v1/orgs/${encodeURIComponent(org)}/repos`;
|
|
@@ -2630,7 +3105,7 @@ function toRow3(repo) {
|
|
|
2630
3105
|
function syncWarning(repo) {
|
|
2631
3106
|
return `warning: GitHub metadata sync failed; retry with \`gauge repos resync ${repo.url}\``;
|
|
2632
3107
|
}
|
|
2633
|
-
function
|
|
3108
|
+
function register12(program2) {
|
|
2634
3109
|
const repos = program2.command("repos").description("Manage repositories");
|
|
2635
3110
|
repos.command("list").description("List repositories (yours + read-only Gauge-provided ones)").action(async (_opts, command) => {
|
|
2636
3111
|
const org = resolveOrg(command);
|
|
@@ -2694,7 +3169,7 @@ function register11(program2) {
|
|
|
2694
3169
|
// src/commands/runs.ts
|
|
2695
3170
|
var runs_exports2 = {};
|
|
2696
3171
|
__export(runs_exports2, {
|
|
2697
|
-
register: () =>
|
|
3172
|
+
register: () => register13
|
|
2698
3173
|
});
|
|
2699
3174
|
function runPath(id) {
|
|
2700
3175
|
return `/api/v1/runs/${encodeURIComponent(id)}`;
|
|
@@ -2757,6 +3232,64 @@ function detailLines(run) {
|
|
|
2757
3232
|
["Finished", run.finishedAt ?? "\u2014"]
|
|
2758
3233
|
];
|
|
2759
3234
|
}
|
|
3235
|
+
function passLine(label, pass) {
|
|
3236
|
+
const bits = [pass.status];
|
|
3237
|
+
if (pass.model) bits.push(pass.model);
|
|
3238
|
+
const cost = fmtUsd(pass.usdCost);
|
|
3239
|
+
if (cost) bits.push(cost);
|
|
3240
|
+
if (pass.error) bits.push(`error: ${compact(pass.error, 60)}`);
|
|
3241
|
+
return `${label.padEnd(20)} ${bits.join(" ")}`;
|
|
3242
|
+
}
|
|
3243
|
+
function influencesVia(detail) {
|
|
3244
|
+
const raw = detail?.influences;
|
|
3245
|
+
if (!Array.isArray(raw)) return "";
|
|
3246
|
+
const types = [];
|
|
3247
|
+
for (const inf of raw) {
|
|
3248
|
+
const type = inf?.type;
|
|
3249
|
+
if (typeof type === "string" && !types.includes(type)) types.push(type);
|
|
3250
|
+
}
|
|
3251
|
+
return types.join(", ");
|
|
3252
|
+
}
|
|
3253
|
+
function printInsight(insight) {
|
|
3254
|
+
console.log(passLine("Decision pass", insight.decision));
|
|
3255
|
+
console.log(passLine("Implementation pass", insight.implementation));
|
|
3256
|
+
console.log(`
|
|
3257
|
+
Decisions (${insight.decisions.length})`);
|
|
3258
|
+
if (insight.decisions.length === 0) {
|
|
3259
|
+
console.log(insight.decision.status === "SKIPPED" ? "(skipped)" : "(none)");
|
|
3260
|
+
} else {
|
|
3261
|
+
printItems(
|
|
3262
|
+
insight.decisions.map((d) => ({
|
|
3263
|
+
"#": d.index,
|
|
3264
|
+
arena: d.category === "other" && d.categoryRaw ? d.categoryRaw : d.category,
|
|
3265
|
+
chosen: d.chosenPackage ?? d.chosenName,
|
|
3266
|
+
reversed: d.reversed ? "yes" : "",
|
|
3267
|
+
via: influencesVia(d.detail)
|
|
3268
|
+
})),
|
|
3269
|
+
"table"
|
|
3270
|
+
);
|
|
3271
|
+
}
|
|
3272
|
+
console.log(`
|
|
3273
|
+
Implementation quality (${insight.implementations.length})`);
|
|
3274
|
+
if (insight.implementations.length === 0) {
|
|
3275
|
+
console.log(
|
|
3276
|
+
insight.implementation.status === "SKIPPED" ? "(skipped)" : "(none)"
|
|
3277
|
+
);
|
|
3278
|
+
} else {
|
|
3279
|
+
printItems(
|
|
3280
|
+
insight.implementations.map((it) => ({
|
|
3281
|
+
verdict: it.verdict,
|
|
3282
|
+
brand: it.brandName,
|
|
3283
|
+
package: it.package ?? "",
|
|
3284
|
+
docs: it.docConsulted ? "docs consulted" : ""
|
|
3285
|
+
})),
|
|
3286
|
+
"table"
|
|
3287
|
+
);
|
|
3288
|
+
}
|
|
3289
|
+
if (insight.decisions.length > 0 || insight.implementations.length > 0) {
|
|
3290
|
+
console.error("\n(full detail: rerun with -o json)");
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
2760
3293
|
function parseEvent(data) {
|
|
2761
3294
|
try {
|
|
2762
3295
|
const parsed = runEventSchema.safeParse(JSON.parse(data));
|
|
@@ -2872,7 +3405,7 @@ async function streamRun(id, json, opts) {
|
|
|
2872
3405
|
if (drainTimer) clearTimeout(drainTimer);
|
|
2873
3406
|
}
|
|
2874
3407
|
}
|
|
2875
|
-
function
|
|
3408
|
+
function register13(program2) {
|
|
2876
3409
|
const runs = program2.command("runs").description("Inspect and manage runs");
|
|
2877
3410
|
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(
|
|
2878
3411
|
async (opts, command) => {
|
|
@@ -2914,6 +3447,18 @@ function register12(program2) {
|
|
|
2914
3447
|
console.log(`${label.padEnd(width)} ${value}`);
|
|
2915
3448
|
}
|
|
2916
3449
|
});
|
|
3450
|
+
runs.command("insight <id>").description(
|
|
3451
|
+
"Show the run's LLM analysis (decisions + implementation quality)"
|
|
3452
|
+
).action(async (id, _opts, command) => {
|
|
3453
|
+
const insight = await createClient().get(
|
|
3454
|
+
`${runPath(id)}/insight`
|
|
3455
|
+
);
|
|
3456
|
+
if (resolveOutput(command) === "json") {
|
|
3457
|
+
printJson(insight);
|
|
3458
|
+
return;
|
|
3459
|
+
}
|
|
3460
|
+
printInsight(insight);
|
|
3461
|
+
});
|
|
2917
3462
|
runs.command("watch <id>").description(
|
|
2918
3463
|
"Stream normalized trace events live (SSE; exits when the run finishes)"
|
|
2919
3464
|
).action(async (id, _opts, command) => {
|
|
@@ -2932,6 +3477,10 @@ function register12(program2) {
|
|
|
2932
3477
|
});
|
|
2933
3478
|
runs.command("diff <id>").description("Print the run's working-tree diff to stdout").action(async (id) => {
|
|
2934
3479
|
const diff = await createClient().get(`${runPath(id)}/diff`);
|
|
3480
|
+
if (!diff) {
|
|
3481
|
+
console.error("(no diff)");
|
|
3482
|
+
return;
|
|
3483
|
+
}
|
|
2935
3484
|
process.stdout.write(diff);
|
|
2936
3485
|
});
|
|
2937
3486
|
runs.command("fork <id>").description("Fork a finished run from its latest conversation checkpoint").requiredOption("--prompt <text>", "continuation prompt for the child run").action(async (id, opts, command) => {
|
|
@@ -2966,7 +3515,7 @@ function register12(program2) {
|
|
|
2966
3515
|
// src/commands/schedules.ts
|
|
2967
3516
|
var schedules_exports2 = {};
|
|
2968
3517
|
__export(schedules_exports2, {
|
|
2969
|
-
register: () =>
|
|
3518
|
+
register: () => register14
|
|
2970
3519
|
});
|
|
2971
3520
|
var CADENCE_CHOICES = [
|
|
2972
3521
|
"none",
|
|
@@ -2991,67 +3540,138 @@ function parseDays(raw) {
|
|
|
2991
3540
|
throw new CliError("usage", "--days-per-week must be an integer 1-7");
|
|
2992
3541
|
return n;
|
|
2993
3542
|
}
|
|
3543
|
+
function collect4(value, previous) {
|
|
3544
|
+
return [...previous, value];
|
|
3545
|
+
}
|
|
3546
|
+
function reposLabel(repos) {
|
|
3547
|
+
if (repos.length === 0) return "(default scaffold)";
|
|
3548
|
+
if (repos.length === 1) {
|
|
3549
|
+
const r = repos[0];
|
|
3550
|
+
return r.repoRef ? `${r.repoUrl}@${r.repoRef}` : r.repoUrl;
|
|
3551
|
+
}
|
|
3552
|
+
return `${repos.length} repos`;
|
|
3553
|
+
}
|
|
3554
|
+
function reposFromOpts(repo, ref) {
|
|
3555
|
+
return [{ repoUrl: repo, repoRef: ref ?? null }];
|
|
3556
|
+
}
|
|
2994
3557
|
function toRow5(s) {
|
|
2995
3558
|
return {
|
|
2996
3559
|
id: s.id,
|
|
2997
|
-
|
|
2998
|
-
ref: s.repoRef ?? "",
|
|
3560
|
+
name: s.name,
|
|
2999
3561
|
cadence: s.cadence,
|
|
3000
3562
|
days: s.daysPerWeek ?? "",
|
|
3001
3563
|
agents: s.agents.join(", "),
|
|
3564
|
+
repos: reposLabel(s.repos),
|
|
3565
|
+
prompts: s.promptCount,
|
|
3566
|
+
enabled: s.enabled ? "yes" : "no",
|
|
3002
3567
|
experiment: s.experiment ?? ""
|
|
3003
3568
|
};
|
|
3004
3569
|
}
|
|
3005
|
-
function
|
|
3006
|
-
|
|
3007
|
-
|
|
3570
|
+
function toRefRow(s) {
|
|
3571
|
+
return {
|
|
3572
|
+
id: s.id,
|
|
3573
|
+
name: s.name,
|
|
3574
|
+
cadence: s.cadence,
|
|
3575
|
+
days: s.daysPerWeek ?? "",
|
|
3576
|
+
enabled: s.enabled ? "yes" : "no"
|
|
3577
|
+
};
|
|
3578
|
+
}
|
|
3579
|
+
var RUN_BLOCK_WARNINGS = {
|
|
3580
|
+
insufficient_credits: "warning: some targets were skipped or truncated: out of credits",
|
|
3581
|
+
needs_provider_key: "warning: some targets were skipped: no provider key for the selected agents"
|
|
3582
|
+
};
|
|
3583
|
+
function register14(program2) {
|
|
3584
|
+
const group = program2.command("schedules").description("Manage org schedules (named prompt sets on a cadence)");
|
|
3585
|
+
group.command("list").description(
|
|
3586
|
+
"List schedules for the org, or (with --prompt) the schedules a prompt is in"
|
|
3587
|
+
).option("--prompt <id>", "only schedules that contain this prompt").action(async (opts, cmd) => {
|
|
3008
3588
|
const org = resolveOrg(cmd);
|
|
3009
|
-
const
|
|
3010
|
-
|
|
3589
|
+
const client = createClient();
|
|
3590
|
+
const json = resolveOutput(cmd) === "json";
|
|
3591
|
+
if (opts.prompt !== void 0) {
|
|
3592
|
+
const res2 = await client.get(
|
|
3593
|
+
`${promptsPath(org)}/${encodeURIComponent(opts.prompt)}/schedules`
|
|
3594
|
+
);
|
|
3595
|
+
if (json) printJson(res2.items);
|
|
3596
|
+
else printItems(res2.items.map(toRefRow), "table");
|
|
3597
|
+
return;
|
|
3598
|
+
}
|
|
3599
|
+
const res = await client.get(
|
|
3600
|
+
`/api/v1/orgs/${encodeURIComponent(org)}/schedules`
|
|
3011
3601
|
);
|
|
3012
|
-
if (
|
|
3602
|
+
if (json) printJson(res.items);
|
|
3013
3603
|
else printItems(res.items.map(toRow5), "table");
|
|
3014
3604
|
});
|
|
3015
|
-
group.command("
|
|
3016
|
-
"
|
|
3017
|
-
).requiredOption("--
|
|
3605
|
+
group.command("create").description(
|
|
3606
|
+
"Create an org schedule: a named prompt set + agents + cadence + repo"
|
|
3607
|
+
).requiredOption("--name <name>", "schedule name").requiredOption(
|
|
3018
3608
|
"--agent <agents>",
|
|
3019
3609
|
"comma-separated agents, e.g. claude-code,codex"
|
|
3020
|
-
).option(
|
|
3610
|
+
).option(
|
|
3611
|
+
"--prompt <id>",
|
|
3612
|
+
"member prompt id (repeatable)",
|
|
3613
|
+
collect4,
|
|
3614
|
+
[]
|
|
3615
|
+
).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(
|
|
3021
3616
|
async (opts, cmd) => {
|
|
3022
3617
|
const org = resolveOrg(cmd);
|
|
3618
|
+
if (opts.ref !== void 0 && opts.repo === void 0)
|
|
3619
|
+
throw new CliError("usage", "--ref requires --repo");
|
|
3023
3620
|
const body = {
|
|
3621
|
+
name: opts.name,
|
|
3024
3622
|
agents: parseAgents(opts.agent),
|
|
3025
3623
|
cadence: parseCadence(opts.cadence),
|
|
3026
|
-
|
|
3027
|
-
|
|
3624
|
+
samplesPerCycle: opts.samples !== void 0 ? parseSamples(opts.samples) : 1,
|
|
3625
|
+
repos: opts.repo !== void 0 ? reposFromOpts(opts.repo, opts.ref) : [],
|
|
3626
|
+
promptIds: opts.prompt,
|
|
3627
|
+
enabled: !opts.disabled
|
|
3028
3628
|
};
|
|
3029
3629
|
if (opts.daysPerWeek !== void 0)
|
|
3030
3630
|
body.daysPerWeek = parseDays(opts.daysPerWeek);
|
|
3631
|
+
if (opts.model !== void 0) body.model = opts.model;
|
|
3031
3632
|
const schedule = await createClient().post(
|
|
3032
|
-
|
|
3633
|
+
`/api/v1/orgs/${encodeURIComponent(org)}/schedules`,
|
|
3033
3634
|
body
|
|
3034
3635
|
);
|
|
3035
3636
|
if (resolveOutput(cmd) === "json") printJson(schedule);
|
|
3036
|
-
else console.log(`
|
|
3637
|
+
else console.log(`Created schedule ${schedule.id}`);
|
|
3037
3638
|
}
|
|
3038
3639
|
);
|
|
3039
|
-
group.command("edit <id>").description("Update a schedule
|
|
3640
|
+
group.command("edit <id>").description("Update a schedule (repos and prompts are full replacements)").option("--name <name>", "rename the schedule").option("--agent <agents>", "comma-separated agents").option(
|
|
3641
|
+
"--prompt <id>",
|
|
3642
|
+
"member prompt id \u2014 replaces the whole set (repeatable)",
|
|
3643
|
+
collect4,
|
|
3644
|
+
[]
|
|
3645
|
+
).option("--clear-prompts", "remove all member prompts").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(
|
|
3040
3646
|
async (id, opts, cmd) => {
|
|
3041
3647
|
const body = {};
|
|
3648
|
+
if (opts.name !== void 0) body.name = opts.name;
|
|
3042
3649
|
if (opts.agent !== void 0) body.agents = parseAgents(opts.agent);
|
|
3043
|
-
if (opts.repo !== void 0 && opts.clearRepo)
|
|
3044
|
-
throw new CliError("usage", "--repo and --clear-repo conflict");
|
|
3045
|
-
if (opts.clearRepo) body.repoUrl = null;
|
|
3046
|
-
else if (opts.repo !== void 0) body.repoUrl = opts.repo;
|
|
3047
|
-
if (opts.ref !== void 0 && opts.clearRef)
|
|
3048
|
-
throw new CliError("usage", "--ref and --clear-ref conflict");
|
|
3049
|
-
if (opts.clearRef) body.repoRef = null;
|
|
3050
|
-
else if (opts.ref !== void 0) body.repoRef = opts.ref;
|
|
3051
3650
|
if (opts.cadence !== void 0)
|
|
3052
3651
|
body.cadence = parseCadence(opts.cadence);
|
|
3053
3652
|
if (opts.daysPerWeek !== void 0)
|
|
3054
3653
|
body.daysPerWeek = parseDays(opts.daysPerWeek);
|
|
3654
|
+
if (opts.samples !== void 0)
|
|
3655
|
+
body.samplesPerCycle = parseSamples(opts.samples);
|
|
3656
|
+
if (opts.model !== void 0 && opts.clearModel)
|
|
3657
|
+
throw new CliError("usage", "--model and --clear-model conflict");
|
|
3658
|
+
if (opts.clearModel) body.model = null;
|
|
3659
|
+
else if (opts.model !== void 0) body.model = opts.model;
|
|
3660
|
+
if (opts.ref !== void 0 && opts.repo === void 0)
|
|
3661
|
+
throw new CliError("usage", "--ref requires --repo");
|
|
3662
|
+
if (opts.repo !== void 0 && opts.clearRepos)
|
|
3663
|
+
throw new CliError("usage", "--repo and --clear-repos conflict");
|
|
3664
|
+
if (opts.clearRepos) body.repos = [];
|
|
3665
|
+
else if (opts.repo !== void 0)
|
|
3666
|
+
body.repos = reposFromOpts(opts.repo, opts.ref);
|
|
3667
|
+
if (opts.prompt.length > 0 && opts.clearPrompts)
|
|
3668
|
+
throw new CliError("usage", "--prompt and --clear-prompts conflict");
|
|
3669
|
+
if (opts.clearPrompts) body.promptIds = [];
|
|
3670
|
+
else if (opts.prompt.length > 0) body.promptIds = opts.prompt;
|
|
3671
|
+
if (opts.enable && opts.disable)
|
|
3672
|
+
throw new CliError("usage", "--enable and --disable conflict");
|
|
3673
|
+
if (opts.enable) body.enabled = true;
|
|
3674
|
+
else if (opts.disable) body.enabled = false;
|
|
3055
3675
|
if (Object.keys(body).length === 0)
|
|
3056
3676
|
throw new CliError("usage", "nothing to change");
|
|
3057
3677
|
const schedule = await createClient().patch(
|
|
@@ -3062,6 +3682,32 @@ function register13(program2) {
|
|
|
3062
3682
|
else console.log(`Updated schedule ${schedule.id}`);
|
|
3063
3683
|
}
|
|
3064
3684
|
);
|
|
3685
|
+
group.command("run <id>").description(
|
|
3686
|
+
"Run a schedule now \u2014 forced expansion of its whole member set (ORG funding, credit-gated)"
|
|
3687
|
+
).action(async (id, _opts, cmd) => {
|
|
3688
|
+
const result = await createClient().post(
|
|
3689
|
+
`/api/v1/schedules/${encodeURIComponent(id)}/run`,
|
|
3690
|
+
{}
|
|
3691
|
+
);
|
|
3692
|
+
if (resolveOutput(cmd) === "json") {
|
|
3693
|
+
printJson(result);
|
|
3694
|
+
return;
|
|
3695
|
+
}
|
|
3696
|
+
if (result.runIds.length === 0) {
|
|
3697
|
+
console.log("No runs enqueued (the schedule has no member prompts)");
|
|
3698
|
+
return;
|
|
3699
|
+
}
|
|
3700
|
+
console.log(
|
|
3701
|
+
`Enqueued ${result.runIds.length} run(s) in ${result.batchIds.length} batch(es)`
|
|
3702
|
+
);
|
|
3703
|
+
for (const runId of result.runIds) console.log(runId);
|
|
3704
|
+
if (result.blocked) console.error(RUN_BLOCK_WARNINGS[result.blocked]);
|
|
3705
|
+
for (const nr of result.notReady ?? [])
|
|
3706
|
+
console.error(
|
|
3707
|
+
`warning: skipped ${nr.repoUrl} \u2014 baseline snapshot ${nr.status}`
|
|
3708
|
+
);
|
|
3709
|
+
console.error("Tip: `gauge runs watch <id>` streams a run live");
|
|
3710
|
+
});
|
|
3065
3711
|
group.command("rm <id>").description("Delete a schedule").action(async (id, _opts, cmd) => {
|
|
3066
3712
|
await createClient().delete(
|
|
3067
3713
|
`/api/v1/schedules/${encodeURIComponent(id)}`
|
|
@@ -3073,7 +3719,7 @@ function register13(program2) {
|
|
|
3073
3719
|
// src/commands/stats.ts
|
|
3074
3720
|
var stats_exports2 = {};
|
|
3075
3721
|
__export(stats_exports2, {
|
|
3076
|
-
register: () =>
|
|
3722
|
+
register: () => register15
|
|
3077
3723
|
});
|
|
3078
3724
|
function addFilterOptions(cmd) {
|
|
3079
3725
|
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)");
|
|
@@ -3157,7 +3803,7 @@ var domainRow = (r) => ({
|
|
|
3157
3803
|
rate: pct2(r.rate),
|
|
3158
3804
|
requests: r.requests
|
|
3159
3805
|
});
|
|
3160
|
-
function
|
|
3806
|
+
function register15(program2) {
|
|
3161
3807
|
const group = program2.command("stats").description("Read-only analytics over your runs");
|
|
3162
3808
|
addFilterOptions(
|
|
3163
3809
|
group.command("rankings").description("Brands ranked by install rate")
|
|
@@ -3189,12 +3835,12 @@ function register14(program2) {
|
|
|
3189
3835
|
// src/commands/tags.ts
|
|
3190
3836
|
var tags_exports2 = {};
|
|
3191
3837
|
__export(tags_exports2, {
|
|
3192
|
-
register: () =>
|
|
3838
|
+
register: () => register16
|
|
3193
3839
|
});
|
|
3194
3840
|
function tagsPath(org) {
|
|
3195
3841
|
return `/api/v1/orgs/${encodeURIComponent(org)}/tags`;
|
|
3196
3842
|
}
|
|
3197
|
-
function
|
|
3843
|
+
function register16(program2) {
|
|
3198
3844
|
const group = program2.command("tags").description("Manage org tags");
|
|
3199
3845
|
group.command("list").description("List tags").action(async (_opts, cmd) => {
|
|
3200
3846
|
const org = resolveOrg(cmd);
|
|
@@ -3237,12 +3883,12 @@ function register15(program2) {
|
|
|
3237
3883
|
// src/commands/topics.ts
|
|
3238
3884
|
var topics_exports2 = {};
|
|
3239
3885
|
__export(topics_exports2, {
|
|
3240
|
-
register: () =>
|
|
3886
|
+
register: () => register17
|
|
3241
3887
|
});
|
|
3242
3888
|
function topicsPath(org) {
|
|
3243
3889
|
return `/api/v1/orgs/${encodeURIComponent(org)}/topics`;
|
|
3244
3890
|
}
|
|
3245
|
-
function
|
|
3891
|
+
function register17(program2) {
|
|
3246
3892
|
const group = program2.command("topics").description("Manage org topics");
|
|
3247
3893
|
group.command("list").description("List topics").action(async (_opts, cmd) => {
|
|
3248
3894
|
const org = resolveOrg(cmd);
|
|
@@ -3263,9 +3909,9 @@ function register16(program2) {
|
|
|
3263
3909
|
// src/commands/usage.ts
|
|
3264
3910
|
var usage_exports = {};
|
|
3265
3911
|
__export(usage_exports, {
|
|
3266
|
-
register: () =>
|
|
3912
|
+
register: () => register18
|
|
3267
3913
|
});
|
|
3268
|
-
function
|
|
3914
|
+
function register18(program2) {
|
|
3269
3915
|
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(
|
|
3270
3916
|
async (opts, cmd) => {
|
|
3271
3917
|
const org = resolveOrg(cmd);
|
|
@@ -3321,7 +3967,8 @@ program.name("gauge").description(
|
|
|
3321
3967
|
);
|
|
3322
3968
|
for (const group of [
|
|
3323
3969
|
auth_exports,
|
|
3324
|
-
|
|
3970
|
+
onboard_exports,
|
|
3971
|
+
orgs_exports2,
|
|
3325
3972
|
prompts_exports2,
|
|
3326
3973
|
schedules_exports2,
|
|
3327
3974
|
repos_exports2,
|