@vm0/cli 9.73.0 → 9.74.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +878 -565
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -22,6 +22,8 @@ var OPERATIONAL_ERROR_PATTERNS = [
22
22
  // Rate limiting (expected operational condition)
23
23
  /rate limit/i,
24
24
  /concurrent run limit/i,
25
+ /insufficient.*credit/i,
26
+ /no model provider/i,
25
27
  // Network issues (transient, not bugs)
26
28
  /network error/i,
27
29
  /network issue/i,
@@ -45,7 +47,7 @@ if (DSN) {
45
47
  Sentry.init({
46
48
  dsn: DSN,
47
49
  environment: process.env.SENTRY_ENVIRONMENT ?? "production",
48
- release: "9.73.0",
50
+ release: "9.74.1",
49
51
  sendDefaultPii: false,
50
52
  tracesSampleRate: 0,
51
53
  shutdownTimeout: 500,
@@ -64,7 +66,7 @@ if (DSN) {
64
66
  }
65
67
  });
66
68
  Sentry.setContext("cli", {
67
- version: "9.73.0",
69
+ version: "9.74.1",
68
70
  command: process.argv.slice(2).join(" ")
69
71
  });
70
72
  Sentry.setContext("runtime", {
@@ -345,373 +347,6 @@ async function setupToken() {
345
347
  // src/lib/command/with-error-handler.ts
346
348
  import chalk2 from "chalk";
347
349
 
348
- // src/lib/api/core/client-factory.ts
349
- import { tsRestFetchApi } from "@ts-rest/core";
350
- var ApiRequestError = class extends Error {
351
- constructor(message, code, status) {
352
- super(message);
353
- this.code = code;
354
- this.status = status;
355
- this.name = "ApiRequestError";
356
- }
357
- };
358
- async function getHeaders() {
359
- const token = await getActiveToken();
360
- if (!token) {
361
- throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
362
- }
363
- const headers = {
364
- Authorization: `Bearer ${token}`
365
- };
366
- const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
367
- if (bypassSecret) {
368
- headers["x-vercel-protection-bypass"] = bypassSecret;
369
- }
370
- return headers;
371
- }
372
- async function getBaseUrl() {
373
- const apiUrl = await getApiUrl();
374
- if (!apiUrl) {
375
- throw new Error("API URL not configured");
376
- }
377
- return apiUrl;
378
- }
379
- async function getClientConfig() {
380
- const baseUrl = await getBaseUrl();
381
- const baseHeaders = await getHeaders();
382
- const activeOrg = await getActiveOrg();
383
- if (!activeOrg) {
384
- throw new Error(
385
- "No active organization configured. Run: vm0 org use <slug>"
386
- );
387
- }
388
- return {
389
- baseUrl,
390
- baseHeaders,
391
- jsonQuery: false,
392
- api: async (args) => {
393
- const separator = args.path.includes("?") ? "&" : "?";
394
- if (!args.path.includes("org=")) {
395
- args.path = `${args.path}${separator}org=${encodeURIComponent(activeOrg)}`;
396
- }
397
- return tsRestFetchApi(args);
398
- }
399
- };
400
- }
401
- function handleError(result, defaultMessage) {
402
- const errorBody = result.body;
403
- const message = errorBody.error?.message || defaultMessage;
404
- const code = errorBody.error?.code || "UNKNOWN";
405
- throw new ApiRequestError(message, code, result.status);
406
- }
407
-
408
- // src/lib/command/with-error-handler.ts
409
- function withErrorHandler(fn) {
410
- return async (...args) => {
411
- try {
412
- await fn(...args);
413
- } catch (error) {
414
- if (error instanceof ApiRequestError) {
415
- if (error.code === "UNAUTHORIZED") {
416
- console.error(chalk2.red("\u2717 Not authenticated"));
417
- console.error(chalk2.dim(" Run: vm0 auth login"));
418
- } else {
419
- console.error(chalk2.red(`\u2717 ${error.status}: ${error.message}`));
420
- }
421
- } else if (error instanceof Error) {
422
- console.error(chalk2.red(`\u2717 ${error.message}`));
423
- } else {
424
- console.error(chalk2.red("\u2717 An unexpected error occurred"));
425
- }
426
- if (error instanceof Error && error.cause instanceof Error) {
427
- console.error(chalk2.dim(` Cause: ${error.cause.message}`));
428
- }
429
- process.exit(1);
430
- }
431
- };
432
- }
433
-
434
- // src/commands/auth/login.ts
435
- var loginCommand = new Command().name("login").description("Log in to VM0 (use VM0_API_URL env var to set API URL)").action(
436
- withErrorHandler(async () => {
437
- await authenticate();
438
- })
439
- );
440
-
441
- // src/commands/auth/logout.ts
442
- import { Command as Command2 } from "commander";
443
- var logoutCommand = new Command2().name("logout").description("Log out of VM0").action(
444
- withErrorHandler(async () => {
445
- await logout();
446
- })
447
- );
448
-
449
- // src/commands/auth/status.ts
450
- import { Command as Command3 } from "commander";
451
- var statusCommand = new Command3().name("status").description("Show current authentication status").action(
452
- withErrorHandler(async () => {
453
- await checkAuthStatus();
454
- })
455
- );
456
-
457
- // src/commands/auth/setup-token.ts
458
- import { Command as Command4 } from "commander";
459
- var setupTokenCommand = new Command4().name("setup-token").description("Output auth token for CI/CD environments").action(
460
- withErrorHandler(async () => {
461
- await setupToken();
462
- })
463
- );
464
-
465
- // src/commands/auth/index.ts
466
- var authCommand = new Command5().name("auth").description("Authenticate vm0").addCommand(loginCommand).addCommand(logoutCommand).addCommand(statusCommand).addCommand(setupTokenCommand);
467
-
468
- // src/commands/info/index.ts
469
- import { Command as Command6 } from "commander";
470
- import chalk4 from "chalk";
471
- import { existsSync as existsSync2 } from "fs";
472
- import { homedir as homedir2, release as release2, type } from "os";
473
- import { join as join2 } from "path";
474
-
475
- // src/lib/utils/update-checker.ts
476
- import chalk3 from "chalk";
477
-
478
- // src/lib/utils/spawn.ts
479
- import { spawn } from "child_process";
480
- function safeSpawn(command, args, options) {
481
- const isWindows = process.platform === "win32";
482
- const resolvedCommand = isWindows ? `${command}.cmd` : command;
483
- return spawn(resolvedCommand, args, {
484
- ...options,
485
- shell: isWindows
486
- });
487
- }
488
-
489
- // src/lib/utils/update-checker.ts
490
- var PACKAGE_NAME = "@vm0/cli";
491
- var NPM_REGISTRY_URL = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME)}/latest`;
492
- var TIMEOUT_MS = 5e3;
493
- var pendingUpgrade = null;
494
- function detectPackageManager() {
495
- const execPath = process.argv[1] ?? "";
496
- if (execPath.includes("pnpm")) {
497
- return "pnpm";
498
- }
499
- if (execPath.includes("/.bun/") || execPath.includes("/bun/")) {
500
- return "bun";
501
- }
502
- if (execPath.includes("/.yarn/") || execPath.includes("/yarn/")) {
503
- return "yarn";
504
- }
505
- if (execPath.includes("/usr/local/") || // Homebrew on Intel Mac
506
- execPath.includes("/opt/homebrew/") || // Homebrew on arm64 Mac
507
- execPath.includes("/.nvm/") || execPath.includes("/.fnm/") || execPath.includes("/.volta/") || execPath.includes("/.nodenv/") || execPath.includes("/.n/") || execPath.includes("/node_modules/") || execPath.includes("\\npm\\") || // Windows: AppData\Roaming\npm
508
- execPath.includes("\\nodejs\\")) {
509
- return "npm";
510
- }
511
- return "unknown";
512
- }
513
- function isAutoUpgradeSupported(pm) {
514
- return pm === "npm" || pm === "pnpm";
515
- }
516
- function getManualUpgradeCommand(pm) {
517
- switch (pm) {
518
- case "bun":
519
- return `bun add -g ${PACKAGE_NAME}@latest`;
520
- case "yarn":
521
- return `yarn global add ${PACKAGE_NAME}@latest`;
522
- case "pnpm":
523
- return `pnpm add -g ${PACKAGE_NAME}@latest`;
524
- case "npm":
525
- return `npm install -g ${PACKAGE_NAME}@latest`;
526
- case "unknown":
527
- return `npm install -g ${PACKAGE_NAME}@latest`;
528
- }
529
- }
530
- function escapeForShell(str) {
531
- return `'${str.replace(/'/g, "'\\''")}'`;
532
- }
533
- function buildRerunCommand(prompt) {
534
- if (prompt) {
535
- return `vm0 cook ${escapeForShell(prompt)}`;
536
- }
537
- return "vm0 cook";
538
- }
539
- async function getLatestVersion() {
540
- try {
541
- const controller = new AbortController();
542
- const timeoutId = setTimeout(() => controller.abort(), TIMEOUT_MS);
543
- const response = await fetch(NPM_REGISTRY_URL, {
544
- signal: controller.signal
545
- });
546
- clearTimeout(timeoutId);
547
- if (!response.ok) {
548
- return null;
549
- }
550
- const json = await response.json();
551
- return json.version ?? null;
552
- } catch {
553
- return null;
554
- }
555
- }
556
- function performUpgrade(packageManager) {
557
- return new Promise((resolve2) => {
558
- const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
559
- const child = safeSpawn(packageManager, args, {
560
- stdio: "inherit"
561
- });
562
- child.on("close", (code) => {
563
- resolve2(code === 0);
564
- });
565
- child.on("error", () => {
566
- resolve2(false);
567
- });
568
- });
569
- }
570
- async function checkAndUpgrade(currentVersion, prompt) {
571
- const latestVersion = await getLatestVersion();
572
- if (latestVersion === null) {
573
- console.log(chalk3.yellow("\u26A0 Could not check for updates"));
574
- console.log();
575
- return false;
576
- }
577
- if (latestVersion === currentVersion) {
578
- return false;
579
- }
580
- console.log(chalk3.yellow("vm0 is currently in beta."));
581
- console.log(
582
- chalk3.yellow(
583
- `Current version: ${currentVersion} -> Latest version: ${latestVersion}`
584
- )
585
- );
586
- console.log(
587
- chalk3.yellow(
588
- "Please always use the latest version for best compatibility."
589
- )
590
- );
591
- console.log();
592
- const packageManager = detectPackageManager();
593
- if (!isAutoUpgradeSupported(packageManager)) {
594
- if (packageManager === "unknown") {
595
- console.log(
596
- chalk3.yellow("Could not detect your package manager for auto-upgrade.")
597
- );
598
- } else {
599
- console.log(
600
- chalk3.yellow(`Auto-upgrade is not supported for ${packageManager}.`)
601
- );
602
- }
603
- console.log(chalk3.yellow("Please upgrade manually:"));
604
- console.log(chalk3.cyan(` ${getManualUpgradeCommand(packageManager)}`));
605
- console.log();
606
- return false;
607
- }
608
- console.log(`Upgrading via ${packageManager}...`);
609
- const success = await performUpgrade(packageManager);
610
- if (success) {
611
- console.log(chalk3.green(`Upgraded to ${latestVersion}`));
612
- console.log();
613
- console.log("To continue, run:");
614
- console.log(chalk3.cyan(` ${buildRerunCommand(prompt)}`));
615
- return true;
616
- }
617
- console.error();
618
- console.error(chalk3.red("\u2717 Upgrade failed. Please run manually:"));
619
- console.error(chalk3.cyan(` ${getManualUpgradeCommand(packageManager)}`));
620
- console.error();
621
- console.error("Then re-run:");
622
- console.error(chalk3.cyan(` ${buildRerunCommand(prompt)}`));
623
- return true;
624
- }
625
- async function startSilentUpgrade(currentVersion) {
626
- pendingUpgrade = null;
627
- const latestVersion = await getLatestVersion();
628
- if (latestVersion === null || latestVersion === currentVersion) {
629
- return;
630
- }
631
- const packageManager = detectPackageManager();
632
- if (!isAutoUpgradeSupported(packageManager)) {
633
- return;
634
- }
635
- const isWindows = process.platform === "win32";
636
- const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
637
- const child = safeSpawn(packageManager, args, {
638
- stdio: "pipe",
639
- detached: !isWindows,
640
- windowsHide: true
641
- });
642
- const promise = new Promise((resolve2) => {
643
- child.on("close", (code) => resolve2(code === 0));
644
- child.on("error", () => resolve2(false));
645
- });
646
- pendingUpgrade = { promise, child, packageManager };
647
- }
648
- async function waitForSilentUpgrade(timeout = TIMEOUT_MS) {
649
- if (!pendingUpgrade) {
650
- return;
651
- }
652
- const { promise, child, packageManager } = pendingUpgrade;
653
- pendingUpgrade = null;
654
- const result = await Promise.race([
655
- promise,
656
- new Promise((resolve2) => {
657
- setTimeout(() => {
658
- child.kill();
659
- resolve2(false);
660
- }, timeout);
661
- })
662
- ]);
663
- if (!result) {
664
- console.log(
665
- chalk3.yellow(
666
- `
667
- \u26A0 vm0 auto upgrade failed. Please run: ${getManualUpgradeCommand(packageManager)}`
668
- )
669
- );
670
- }
671
- }
672
-
673
- // src/commands/info/index.ts
674
- function getConfigPath() {
675
- return join2(homedir2(), ".vm0", "config.json");
676
- }
677
- var infoCommand = new Command6().name("info").description("Display environment and debug information").action(async () => {
678
- console.log(chalk4.bold(`VM0 CLI v${"9.73.0"}`));
679
- console.log();
680
- const config = await loadConfig();
681
- const hasEnvToken = !!process.env.VM0_TOKEN;
682
- const hasConfigToken = !!config.token;
683
- const isAuthenticated2 = hasEnvToken || hasConfigToken;
684
- console.log(chalk4.bold("Authentication:"));
685
- if (isAuthenticated2) {
686
- const tokenSource = hasEnvToken ? "VM0_TOKEN env var" : "config file";
687
- console.log(` ${chalk4.green("\u2713")} Logged in (via ${tokenSource})`);
688
- } else {
689
- console.log(` ${chalk4.red("\u2717")} Not authenticated`);
690
- }
691
- const configExists = existsSync2(getConfigPath());
692
- const configDisplay = configExists ? `~/.vm0/config.json` : `~/.vm0/config.json (not found)`;
693
- console.log(` Config: ${configDisplay}`);
694
- console.log();
695
- const apiUrl = await getApiUrl();
696
- console.log(chalk4.bold("API:"));
697
- console.log(` Host: ${apiUrl}`);
698
- console.log();
699
- console.log(chalk4.bold("System:"));
700
- console.log(` Node: ${process.version}`);
701
- console.log(` Platform: ${process.platform} (${process.arch})`);
702
- console.log(` OS: ${type()} ${release2()}`);
703
- console.log(` Shell: ${process.env.SHELL ?? "unknown"}`);
704
- console.log(` Package Manager: ${detectPackageManager()}`);
705
- });
706
-
707
- // src/commands/compose/index.ts
708
- import { Command as Command7, Option } from "commander";
709
- import chalk6 from "chalk";
710
- import { readFile as readFile4, rm as rm3 } from "fs/promises";
711
- import { existsSync as existsSync5 } from "fs";
712
- import { dirname as dirname2, join as join8 } from "path";
713
- import { parse as parseYaml3 } from "yaml";
714
-
715
350
  // ../../packages/core/src/variable-expander.ts
716
351
  var VARIABLE_PATTERN = /\$\{\{\s*(env|vars|secrets)\.([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g;
717
352
  function extractVariableReferencesFromString(value) {
@@ -780,6 +415,30 @@ var apiErrorSchema = z2.object({
780
415
  code: z2.string()
781
416
  })
782
417
  });
418
+ var RUN_ERROR_GUIDANCE = {
419
+ NO_MODEL_PROVIDER: {
420
+ title: "No model provider configured",
421
+ guidance: "Configure a model provider to start running agents.",
422
+ cliHint: "vm0 org model-provider setup"
423
+ },
424
+ INSUFFICIENT_CREDITS: {
425
+ title: "Credits depleted",
426
+ guidance: "Add credits or configure your own API key to continue.",
427
+ cliHint: "vm0 org billing"
428
+ },
429
+ PROVIDER_INCOMPATIBLE: {
430
+ title: "Provider not compatible",
431
+ guidance: "This session was created with a different provider type."
432
+ },
433
+ PROVIDER_UNAVAILABLE: {
434
+ title: "Provider temporarily unavailable",
435
+ guidance: "The model provider is temporarily unavailable. Please try again later."
436
+ },
437
+ TOO_MANY_REQUESTS: {
438
+ title: "Concurrent run limit reached",
439
+ guidance: "Wait for your current run to complete before starting a new one."
440
+ }
441
+ };
783
442
 
784
443
  // ../../packages/core/src/contracts/composes.ts
785
444
  import { z as z4 } from "zod";
@@ -826,7 +485,8 @@ var VALID_CAPABILITIES = [
826
485
  "agent-run:read",
827
486
  "agent-run:write",
828
487
  "schedule:read",
829
- "schedule:write"
488
+ "schedule:write",
489
+ "integration-slack:write"
830
490
  ];
831
491
  var agentNameSchema = z4.string().min(3, "Agent name must be at least 3 characters").max(64, "Agent name must be 64 characters or less").regex(
832
492
  AGENT_NAME_REGEX,
@@ -1087,6 +747,59 @@ var composesListContract = c.router({
1087
747
  summary: "List all agent composes for an org"
1088
748
  }
1089
749
  });
750
+ var metadataUpdateSchema = z4.object({
751
+ displayName: z4.string().optional(),
752
+ description: z4.string().optional(),
753
+ sound: z4.string().optional()
754
+ });
755
+ var composesMetadataContract = c.router({
756
+ /**
757
+ * PATCH /api/agent/composes/:id/metadata
758
+ * Update agent compose metadata (displayName, description, sound)
759
+ */
760
+ updateMetadata: {
761
+ method: "PATCH",
762
+ path: "/api/agent/composes/:id/metadata",
763
+ headers: authHeadersSchema,
764
+ pathParams: z4.object({
765
+ id: z4.string().min(1, "Compose ID is required")
766
+ }),
767
+ body: metadataUpdateSchema,
768
+ responses: {
769
+ 200: z4.object({ ok: z4.literal(true) }),
770
+ 400: apiErrorSchema,
771
+ 401: apiErrorSchema,
772
+ 403: apiErrorSchema,
773
+ 404: apiErrorSchema
774
+ },
775
+ summary: "Update agent compose metadata"
776
+ }
777
+ });
778
+ var composeInstructionsResponseSchema = z4.object({
779
+ content: z4.string().nullable(),
780
+ filename: z4.string().nullable()
781
+ });
782
+ var composesInstructionsContract = c.router({
783
+ /**
784
+ * GET /api/agent/composes/:id/instructions
785
+ * Get the instructions content for an agent compose
786
+ */
787
+ getInstructions: {
788
+ method: "GET",
789
+ path: "/api/agent/composes/:id/instructions",
790
+ headers: authHeadersSchema,
791
+ pathParams: z4.object({
792
+ id: z4.string().min(1, "Compose ID is required")
793
+ }),
794
+ responses: {
795
+ 200: composeInstructionsResponseSchema,
796
+ 401: apiErrorSchema,
797
+ 403: apiErrorSchema,
798
+ 404: apiErrorSchema
799
+ },
800
+ summary: "Get agent compose instructions content"
801
+ }
802
+ });
1090
803
 
1091
804
  // ../../packages/core/src/contracts/runs.ts
1092
805
  import { z as z8 } from "zod";
@@ -1193,26 +906,6 @@ var logsByIdContract = c2.router({
1193
906
  summary: "Get agent run log details by ID"
1194
907
  }
1195
908
  });
1196
- var artifactDownloadResponseSchema = z5.object({
1197
- url: z5.url(),
1198
- expiresAt: z5.string()
1199
- });
1200
- var artifactDownloadContract = c2.router({
1201
- getDownloadUrl: {
1202
- method: "GET",
1203
- path: "/api/app/artifacts/download",
1204
- query: z5.object({
1205
- name: z5.string().min(1, "Artifact name is required"),
1206
- version: z5.string().optional()
1207
- }),
1208
- responses: {
1209
- 200: artifactDownloadResponseSchema,
1210
- 401: apiErrorSchema,
1211
- 404: apiErrorSchema
1212
- },
1213
- summary: "Get presigned URL for artifact download"
1214
- }
1215
- });
1216
909
 
1217
910
  // ../../packages/core/src/contracts/orgs.ts
1218
911
  import { z as z7 } from "zod";
@@ -1224,13 +917,22 @@ var orgRoleSchema = z6.enum(["admin", "member"]);
1224
917
  var orgMemberSchema = z6.object({
1225
918
  userId: z6.string(),
1226
919
  email: z6.string(),
920
+ firstName: z6.string().nullable(),
921
+ lastName: z6.string().nullable(),
922
+ imageUrl: z6.string(),
1227
923
  role: orgRoleSchema,
1228
924
  joinedAt: z6.string()
1229
925
  });
926
+ var orgPendingInvitationSchema = z6.object({
927
+ email: z6.string(),
928
+ role: orgRoleSchema,
929
+ createdAt: z6.string()
930
+ });
1230
931
  var orgMembersResponseSchema = z6.object({
1231
932
  slug: z6.string(),
1232
933
  role: orgRoleSchema,
1233
934
  members: z6.array(orgMemberSchema),
935
+ pendingInvitations: z6.array(orgPendingInvitationSchema).optional(),
1234
936
  createdAt: z6.string()
1235
937
  });
1236
938
  var inviteOrgMemberRequestSchema = z6.object({
@@ -1239,6 +941,10 @@ var inviteOrgMemberRequestSchema = z6.object({
1239
941
  var removeOrgMemberRequestSchema = z6.object({
1240
942
  email: z6.string().email()
1241
943
  });
944
+ var updateOrgMemberRoleRequestSchema = z6.object({
945
+ email: z6.string().email(),
946
+ role: orgRoleSchema
947
+ });
1242
948
  var orgMessageResponseSchema = z6.object({
1243
949
  message: z6.string()
1244
950
  });
@@ -1326,11 +1032,13 @@ var orgSlugSchema = z7.string().min(3, "Org slug must be at least 3 characters")
1326
1032
  var orgResponseSchema = z7.object({
1327
1033
  id: z7.string(),
1328
1034
  slug: z7.string(),
1035
+ name: z7.string(),
1329
1036
  tier: z7.string().optional(),
1330
1037
  role: orgRoleSchema.optional()
1331
1038
  });
1332
1039
  var updateOrgRequestSchema = z7.object({
1333
- slug: orgSlugSchema,
1040
+ slug: orgSlugSchema.optional(),
1041
+ name: z7.string().min(1).max(128).optional(),
1334
1042
  force: z7.boolean().optional().default(false)
1335
1043
  });
1336
1044
  var orgContract = c4.router({
@@ -1556,8 +1264,11 @@ var runsMainContract = c5.router({
1556
1264
  201: createRunResponseSchema,
1557
1265
  400: apiErrorSchema,
1558
1266
  401: apiErrorSchema,
1267
+ 402: apiErrorSchema,
1559
1268
  403: apiErrorSchema,
1560
- 404: apiErrorSchema
1269
+ 404: apiErrorSchema,
1270
+ 422: apiErrorSchema,
1271
+ 503: apiErrorSchema
1561
1272
  },
1562
1273
  summary: "Create and execute agent run"
1563
1274
  }
@@ -3390,6 +3101,7 @@ var storedChatMessageSchema2 = z18.object({
3390
3101
  content: z18.string(),
3391
3102
  runId: z18.string().optional(),
3392
3103
  error: z18.string().optional(),
3104
+ summaries: z18.array(z18.string()).optional(),
3393
3105
  createdAt: z18.string()
3394
3106
  });
3395
3107
  var unsavedRunSchema = z18.object({
@@ -3845,17 +3557,23 @@ var schedulesEnableContract = c16.router({
3845
3557
  pathParams: z20.object({
3846
3558
  name: z20.string().min(1, "Schedule name required")
3847
3559
  }),
3560
+ query: z20.object({
3561
+ org: z20.string().optional()
3562
+ }),
3848
3563
  body: z20.object({
3849
3564
  composeId: z20.string().uuid("Compose ID required")
3850
3565
  }),
3851
3566
  responses: {
3852
3567
  200: scheduleResponseSchema,
3568
+ 400: apiErrorSchema,
3853
3569
  401: apiErrorSchema,
3854
3570
  403: apiErrorSchema,
3855
3571
  404: apiErrorSchema
3856
3572
  },
3857
3573
  summary: "Enable schedule"
3858
- },
3574
+ }
3575
+ });
3576
+ var schedulesDisableContract = c16.router({
3859
3577
  /**
3860
3578
  * POST /api/agent/schedules/:name/disable
3861
3579
  * Disable an enabled schedule
@@ -3867,11 +3585,15 @@ var schedulesEnableContract = c16.router({
3867
3585
  pathParams: z20.object({
3868
3586
  name: z20.string().min(1, "Schedule name required")
3869
3587
  }),
3588
+ query: z20.object({
3589
+ org: z20.string().optional()
3590
+ }),
3870
3591
  body: z20.object({
3871
3592
  composeId: z20.string().uuid("Compose ID required")
3872
3593
  }),
3873
3594
  responses: {
3874
3595
  200: scheduleResponseSchema,
3596
+ 400: apiErrorSchema,
3875
3597
  401: apiErrorSchema,
3876
3598
  403: apiErrorSchema,
3877
3599
  404: apiErrorSchema
@@ -3904,6 +3626,32 @@ var scheduleRunsContract = c16.router({
3904
3626
  summary: "List recent runs for a schedule"
3905
3627
  }
3906
3628
  });
3629
+ var agentMissingSecretsSchema = z20.object({
3630
+ composeId: z20.string(),
3631
+ agentName: z20.string(),
3632
+ requiredSecrets: z20.array(z20.string()),
3633
+ missingSecrets: z20.array(z20.string())
3634
+ });
3635
+ var schedulesMissingSecretsContract = c16.router({
3636
+ /**
3637
+ * GET /api/agent/schedules/missing-secrets
3638
+ * Check agents for missing secrets
3639
+ */
3640
+ getMissingSecrets: {
3641
+ method: "GET",
3642
+ path: "/api/agent/schedules/missing-secrets",
3643
+ headers: authHeadersSchema,
3644
+ query: z20.object({
3645
+ org: z20.string().optional()
3646
+ }),
3647
+ responses: {
3648
+ 200: z20.object({ agents: z20.array(agentMissingSecretsSchema) }),
3649
+ 401: apiErrorSchema,
3650
+ 403: apiErrorSchema
3651
+ },
3652
+ summary: "Check agents for missing secrets"
3653
+ }
3654
+ });
3907
3655
 
3908
3656
  // ../../packages/core/src/contracts/realtime.ts
3909
3657
  import { z as z21 } from "zod";
@@ -8026,31 +7774,57 @@ var orgVariablesByNameContract = c25.router({
8026
7774
  }
8027
7775
  });
8028
7776
 
8029
- // ../../packages/core/src/contracts/zero-agents.ts
7777
+ // ../../packages/core/src/contracts/required-env.ts
8030
7778
  import { z as z30 } from "zod";
8031
7779
  var c26 = initContract();
8032
- var zeroAgentResponseSchema = z30.object({
8033
- name: z30.string(),
8034
- agentComposeId: z30.string(),
8035
- description: z30.string().nullable(),
8036
- displayName: z30.string().nullable(),
8037
- sound: z30.string().nullable(),
8038
- connectors: z30.array(z30.string())
7780
+ var agentRequiredEnvSchema = z30.object({
7781
+ composeId: z30.string(),
7782
+ agentName: z30.string(),
7783
+ requiredSecrets: z30.array(z30.string()),
7784
+ requiredVariables: z30.array(z30.string())
7785
+ });
7786
+ var requiredEnvContract = c26.router({
7787
+ /**
7788
+ * GET /api/agent/required-env
7789
+ * Get required environment variables for user agents
7790
+ */
7791
+ getRequiredEnv: {
7792
+ method: "GET",
7793
+ path: "/api/agent/required-env",
7794
+ headers: authHeadersSchema,
7795
+ responses: {
7796
+ 200: z30.object({ agents: z30.array(agentRequiredEnvSchema) }),
7797
+ 401: apiErrorSchema
7798
+ },
7799
+ summary: "Get required environment variables for user agents"
7800
+ }
7801
+ });
7802
+
7803
+ // ../../packages/core/src/contracts/zero-agents.ts
7804
+ import { z as z31 } from "zod";
7805
+ var c27 = initContract();
7806
+ var zeroAgentResponseSchema = z31.object({
7807
+ name: z31.string(),
7808
+ agentComposeId: z31.string(),
7809
+ description: z31.string().nullable(),
7810
+ displayName: z31.string().nullable(),
7811
+ sound: z31.string().nullable(),
7812
+ connectors: z31.array(z31.string())
8039
7813
  });
8040
- var zeroAgentRequestSchema = z30.object({
8041
- description: z30.string().optional(),
8042
- displayName: z30.string().optional(),
8043
- sound: z30.string().optional(),
8044
- connectors: z30.array(z30.string())
7814
+ var zeroAgentRequestSchema = z31.object({
7815
+ description: z31.string().optional(),
7816
+ displayName: z31.string().optional(),
7817
+ sound: z31.string().optional(),
7818
+ connectors: z31.array(z31.string())
8045
7819
  });
8046
- var zeroAgentInstructionsResponseSchema = z30.object({
8047
- content: z30.string().nullable(),
8048
- filename: z30.string().nullable()
7820
+ var zeroAgentInstructionsResponseSchema = z31.object({
7821
+ content: z31.string().nullable(),
7822
+ filename: z31.string().nullable()
8049
7823
  });
8050
- var zeroAgentInstructionsRequestSchema = z30.object({
8051
- content: z30.string()
7824
+ var zeroAgentInstructionsRequestSchema = z31.object({
7825
+ content: z31.string()
8052
7826
  });
8053
- var zeroAgentsMainContract = c26.router({
7827
+ var zeroAgentsMainContract = c27.router({
8054
7828
  create: {
8055
7829
  method: "POST",
8056
7830
  path: "/api/zero/agents",
@@ -8065,12 +7839,12 @@ var zeroAgentsMainContract = c26.router({
8065
7839
  summary: "Create zero agent"
8066
7840
  }
8067
7841
  });
8068
- var zeroAgentsByNameContract = c26.router({
7842
+ var zeroAgentsByNameContract = c27.router({
8069
7843
  get: {
8070
7844
  method: "GET",
8071
7845
  path: "/api/zero/agents/:name",
8072
7846
  headers: authHeadersSchema,
8073
- pathParams: z30.object({ name: z30.string() }),
7847
+ pathParams: z31.object({ name: z31.string() }),
8074
7848
  responses: {
8075
7849
  200: zeroAgentResponseSchema,
8076
7850
  401: apiErrorSchema,
@@ -8082,7 +7856,7 @@ var zeroAgentsByNameContract = c26.router({
8082
7856
  method: "PUT",
8083
7857
  path: "/api/zero/agents/:name",
8084
7858
  headers: authHeadersSchema,
8085
- pathParams: z30.object({ name: z30.string() }),
7859
+ pathParams: z31.object({ name: z31.string() }),
8086
7860
  body: zeroAgentRequestSchema,
8087
7861
  responses: {
8088
7862
  200: zeroAgentResponseSchema,
@@ -8094,12 +7868,12 @@ var zeroAgentsByNameContract = c26.router({
8094
7868
  summary: "Update zero agent"
8095
7869
  }
8096
7870
  });
8097
- var zeroAgentInstructionsContract = c26.router({
7871
+ var zeroAgentInstructionsContract = c27.router({
8098
7872
  get: {
8099
7873
  method: "GET",
8100
7874
  path: "/api/zero/agents/:name/instructions",
8101
7875
  headers: authHeadersSchema,
8102
- pathParams: z30.object({ name: z30.string() }),
7876
+ pathParams: z31.object({ name: z31.string() }),
8103
7877
  responses: {
8104
7878
  200: zeroAgentInstructionsResponseSchema,
8105
7879
  401: apiErrorSchema,
@@ -8111,7 +7885,7 @@ var zeroAgentInstructionsContract = c26.router({
8111
7885
  method: "PUT",
8112
7886
  path: "/api/zero/agents/:name/instructions",
8113
7887
  headers: authHeadersSchema,
8114
- pathParams: z30.object({ name: z30.string() }),
7888
+ pathParams: z31.object({ name: z31.string() }),
8115
7889
  body: zeroAgentInstructionsRequestSchema,
8116
7890
  responses: {
8117
7891
  200: zeroAgentResponseSchema,
@@ -8124,9 +7898,9 @@ var zeroAgentInstructionsContract = c26.router({
8124
7898
  });
8125
7899
 
8126
7900
  // ../../packages/core/src/contracts/zero-connectors.ts
8127
- import { z as z31 } from "zod";
8128
- var c27 = initContract();
8129
- var zeroConnectorsMainContract = c27.router({
7901
+ import { z as z32 } from "zod";
7902
+ var c28 = initContract();
7903
+ var zeroConnectorsMainContract = c28.router({
8130
7904
  list: {
8131
7905
  method: "GET",
8132
7906
  path: "/api/zero/connectors",
@@ -8139,26 +7913,26 @@ var zeroConnectorsMainContract = c27.router({
8139
7913
  summary: "List all connectors (zero proxy)"
8140
7914
  }
8141
7915
  });
8142
- var zeroConnectorsByTypeContract = c27.router({
7916
+ var zeroConnectorsByTypeContract = c28.router({
8143
7917
  delete: {
8144
7918
  method: "DELETE",
8145
7919
  path: "/api/zero/connectors/:type",
8146
7920
  headers: authHeadersSchema,
8147
- pathParams: z31.object({ type: connectorTypeSchema }),
7921
+ pathParams: z32.object({ type: connectorTypeSchema }),
8148
7922
  responses: {
8149
- 204: c27.noBody(),
7923
+ 204: c28.noBody(),
8150
7924
  401: apiErrorSchema,
8151
7925
  404: apiErrorSchema
8152
7926
  },
8153
7927
  summary: "Disconnect a connector (zero proxy)"
8154
7928
  }
8155
7929
  });
8156
- var zeroConnectorScopeDiffContract = c27.router({
7930
+ var zeroConnectorScopeDiffContract = c28.router({
8157
7931
  getScopeDiff: {
8158
7932
  method: "GET",
8159
7933
  path: "/api/zero/connectors/:type/scope-diff",
8160
7934
  headers: authHeadersSchema,
8161
- pathParams: z31.object({ type: connectorTypeSchema }),
7935
+ pathParams: z32.object({ type: connectorTypeSchema }),
8162
7936
  responses: {
8163
7937
  200: scopeDiffResponseSchema,
8164
7938
  401: apiErrorSchema,
@@ -8169,8 +7943,9 @@ var zeroConnectorScopeDiffContract = c27.router({
8169
7943
  });
8170
7944
 
8171
7945
  // ../../packages/core/src/contracts/zero-org.ts
8172
- var c28 = initContract();
8173
- var zeroOrgContract = c28.router({
7946
+ import { z as z33 } from "zod";
7947
+ var c29 = initContract();
7948
+ var zeroOrgContract = c29.router({
8174
7949
  get: {
8175
7950
  method: "GET",
8176
7951
  path: "/api/zero/org",
@@ -8178,23 +7953,133 @@ var zeroOrgContract = c28.router({
8178
7953
  responses: {
8179
7954
  200: orgResponseSchema,
8180
7955
  401: apiErrorSchema,
8181
- 404: apiErrorSchema
7956
+ 404: apiErrorSchema
7957
+ },
7958
+ summary: "Get current org (zero proxy)"
7959
+ },
7960
+ update: {
7961
+ method: "PUT",
7962
+ path: "/api/zero/org",
7963
+ headers: authHeadersSchema,
7964
+ body: updateOrgRequestSchema,
7965
+ responses: {
7966
+ 200: orgResponseSchema,
7967
+ 400: apiErrorSchema,
7968
+ 401: apiErrorSchema,
7969
+ 403: apiErrorSchema,
7970
+ 404: apiErrorSchema,
7971
+ 409: apiErrorSchema,
7972
+ 500: apiErrorSchema
7973
+ },
7974
+ summary: "Update org slug (zero proxy)"
7975
+ }
7976
+ });
7977
+ var zeroOrgLeaveContract = c29.router({
7978
+ leave: {
7979
+ method: "POST",
7980
+ path: "/api/zero/org/leave",
7981
+ headers: authHeadersSchema,
7982
+ body: z33.object({}),
7983
+ responses: {
7984
+ 200: orgMessageResponseSchema,
7985
+ 401: apiErrorSchema,
7986
+ 403: apiErrorSchema,
7987
+ 500: apiErrorSchema
7988
+ },
7989
+ summary: "Leave the current org (zero proxy)"
7990
+ }
7991
+ });
7992
+ var zeroOrgDeleteContract = c29.router({
7993
+ delete: {
7994
+ method: "POST",
7995
+ path: "/api/zero/org/delete",
7996
+ headers: authHeadersSchema,
7997
+ body: z33.object({ slug: z33.string() }),
7998
+ responses: {
7999
+ 200: orgMessageResponseSchema,
8000
+ 400: apiErrorSchema,
8001
+ 401: apiErrorSchema,
8002
+ 403: apiErrorSchema,
8003
+ 500: apiErrorSchema
8004
+ },
8005
+ summary: "Delete the current org (zero proxy)"
8006
+ }
8007
+ });
8008
+
8009
+ // ../../packages/core/src/contracts/zero-org-members.ts
8010
+ var c30 = initContract();
8011
+ var zeroOrgMembersContract = c30.router({
8012
+ members: {
8013
+ method: "GET",
8014
+ path: "/api/zero/org/members",
8015
+ headers: authHeadersSchema,
8016
+ responses: {
8017
+ 200: orgMembersResponseSchema,
8018
+ 400: apiErrorSchema,
8019
+ 401: apiErrorSchema,
8020
+ 403: apiErrorSchema,
8021
+ 404: apiErrorSchema,
8022
+ 500: apiErrorSchema
8023
+ },
8024
+ summary: "Get org members (zero proxy)"
8025
+ },
8026
+ updateRole: {
8027
+ method: "PATCH",
8028
+ path: "/api/zero/org/members",
8029
+ headers: authHeadersSchema,
8030
+ body: updateOrgMemberRoleRequestSchema,
8031
+ responses: {
8032
+ 200: orgMessageResponseSchema,
8033
+ 400: apiErrorSchema,
8034
+ 401: apiErrorSchema,
8035
+ 403: apiErrorSchema,
8036
+ 500: apiErrorSchema
8037
+ },
8038
+ summary: "Update a member's role (zero proxy)"
8039
+ },
8040
+ removeMember: {
8041
+ method: "DELETE",
8042
+ path: "/api/zero/org/members",
8043
+ headers: authHeadersSchema,
8044
+ body: removeOrgMemberRequestSchema,
8045
+ responses: {
8046
+ 200: orgMessageResponseSchema,
8047
+ 400: apiErrorSchema,
8048
+ 401: apiErrorSchema,
8049
+ 403: apiErrorSchema,
8050
+ 500: apiErrorSchema
8051
+ },
8052
+ summary: "Remove a member from the org (zero proxy)"
8053
+ }
8054
+ });
8055
+ var zeroOrgInviteContract = c30.router({
8056
+ invite: {
8057
+ method: "POST",
8058
+ path: "/api/zero/org/invite",
8059
+ headers: authHeadersSchema,
8060
+ body: inviteOrgMemberRequestSchema,
8061
+ responses: {
8062
+ 200: orgMessageResponseSchema,
8063
+ 400: apiErrorSchema,
8064
+ 401: apiErrorSchema,
8065
+ 403: apiErrorSchema,
8066
+ 500: apiErrorSchema
8182
8067
  },
8183
- summary: "Get current org (zero proxy)"
8068
+ summary: "Invite a member to the org (zero proxy)"
8184
8069
  }
8185
8070
  });
8186
8071
 
8187
8072
  // ../../packages/core/src/contracts/zero-composes.ts
8188
- import { z as z32 } from "zod";
8189
- var c29 = initContract();
8190
- var zeroComposesMainContract = c29.router({
8073
+ import { z as z34 } from "zod";
8074
+ var c31 = initContract();
8075
+ var zeroComposesMainContract = c31.router({
8191
8076
  getByName: {
8192
8077
  method: "GET",
8193
8078
  path: "/api/zero/composes",
8194
8079
  headers: authHeadersSchema,
8195
- query: z32.object({
8196
- name: z32.string().min(1, "Missing name query parameter"),
8197
- org: z32.string().optional()
8080
+ query: z34.object({
8081
+ name: z34.string().min(1, "Missing name query parameter"),
8082
+ org: z34.string().optional()
8198
8083
  }),
8199
8084
  responses: {
8200
8085
  200: composeResponseSchema,
@@ -8205,13 +8090,13 @@ var zeroComposesMainContract = c29.router({
8205
8090
  summary: "Get agent compose by name (zero proxy)"
8206
8091
  }
8207
8092
  });
8208
- var zeroComposesByIdContract = c29.router({
8093
+ var zeroComposesByIdContract = c31.router({
8209
8094
  getById: {
8210
8095
  method: "GET",
8211
8096
  path: "/api/zero/composes/:id",
8212
8097
  headers: authHeadersSchema,
8213
- pathParams: z32.object({
8214
- id: z32.string().min(1, "Compose ID is required")
8098
+ pathParams: z34.object({
8099
+ id: z34.string().min(1, "Compose ID is required")
8215
8100
  }),
8216
8101
  responses: {
8217
8102
  200: composeResponseSchema,
@@ -8225,12 +8110,12 @@ var zeroComposesByIdContract = c29.router({
8225
8110
  method: "DELETE",
8226
8111
  path: "/api/zero/composes/:id",
8227
8112
  headers: authHeadersSchema,
8228
- pathParams: z32.object({
8229
- id: z32.string().uuid("Compose ID is required")
8113
+ pathParams: z34.object({
8114
+ id: z34.string().uuid("Compose ID is required")
8230
8115
  }),
8231
- body: c29.noBody(),
8116
+ body: c31.noBody(),
8232
8117
  responses: {
8233
- 204: c29.noBody(),
8118
+ 204: c31.noBody(),
8234
8119
  401: apiErrorSchema,
8235
8120
  403: apiErrorSchema,
8236
8121
  404: apiErrorSchema,
@@ -8239,17 +8124,17 @@ var zeroComposesByIdContract = c29.router({
8239
8124
  summary: "Delete agent compose (zero proxy)"
8240
8125
  }
8241
8126
  });
8242
- var zeroComposesListContract = c29.router({
8127
+ var zeroComposesListContract = c31.router({
8243
8128
  list: {
8244
8129
  method: "GET",
8245
8130
  path: "/api/zero/composes/list",
8246
8131
  headers: authHeadersSchema,
8247
- query: z32.object({
8248
- org: z32.string().optional()
8132
+ query: z34.object({
8133
+ org: z34.string().optional()
8249
8134
  }),
8250
8135
  responses: {
8251
- 200: z32.object({
8252
- composes: z32.array(composeListItemSchema)
8136
+ 200: z34.object({
8137
+ composes: z34.array(composeListItemSchema)
8253
8138
  }),
8254
8139
  400: apiErrorSchema,
8255
8140
  401: apiErrorSchema,
@@ -8260,12 +8145,12 @@ var zeroComposesListContract = c29.router({
8260
8145
  });
8261
8146
 
8262
8147
  // ../../packages/core/src/contracts/zero-runs.ts
8263
- import { z as z33 } from "zod";
8148
+ import { z as z35 } from "zod";
8264
8149
  var zeroRunRequestSchema = unifiedRunRequestSchema.omit({
8265
8150
  triggerSource: true
8266
8151
  });
8267
- var c30 = initContract();
8268
- var zeroRunsMainContract = c30.router({
8152
+ var c32 = initContract();
8153
+ var zeroRunsMainContract = c32.router({
8269
8154
  create: {
8270
8155
  method: "POST",
8271
8156
  path: "/api/zero/runs",
@@ -8281,13 +8166,13 @@ var zeroRunsMainContract = c30.router({
8281
8166
  summary: "Create and execute agent run (zero proxy)"
8282
8167
  }
8283
8168
  });
8284
- var zeroRunsByIdContract = c30.router({
8169
+ var zeroRunsByIdContract = c32.router({
8285
8170
  getById: {
8286
8171
  method: "GET",
8287
8172
  path: "/api/zero/runs/:id",
8288
8173
  headers: authHeadersSchema,
8289
- pathParams: z33.object({
8290
- id: z33.string().min(1, "Run ID is required")
8174
+ pathParams: z35.object({
8175
+ id: z35.string().min(1, "Run ID is required")
8291
8176
  }),
8292
8177
  responses: {
8293
8178
  200: getRunResponseSchema,
@@ -8298,15 +8183,15 @@ var zeroRunsByIdContract = c30.router({
8298
8183
  summary: "Get agent run by ID (zero proxy)"
8299
8184
  }
8300
8185
  });
8301
- var zeroRunsCancelContract = c30.router({
8186
+ var zeroRunsCancelContract = c32.router({
8302
8187
  cancel: {
8303
8188
  method: "POST",
8304
8189
  path: "/api/zero/runs/:id/cancel",
8305
8190
  headers: authHeadersSchema,
8306
- pathParams: z33.object({
8307
- id: z33.string().min(1, "Run ID is required")
8191
+ pathParams: z35.object({
8192
+ id: z35.string().min(1, "Run ID is required")
8308
8193
  }),
8309
- body: z33.undefined(),
8194
+ body: z35.undefined(),
8310
8195
  responses: {
8311
8196
  200: cancelRunResponseSchema,
8312
8197
  400: apiErrorSchema,
@@ -8317,7 +8202,7 @@ var zeroRunsCancelContract = c30.router({
8317
8202
  summary: "Cancel a pending or running run (zero proxy)"
8318
8203
  }
8319
8204
  });
8320
- var zeroRunsQueueContract = c30.router({
8205
+ var zeroRunsQueueContract = c32.router({
8321
8206
  getQueue: {
8322
8207
  method: "GET",
8323
8208
  path: "/api/zero/runs/queue",
@@ -8330,18 +8215,18 @@ var zeroRunsQueueContract = c30.router({
8330
8215
  summary: "Get org run queue status (zero proxy)"
8331
8216
  }
8332
8217
  });
8333
- var zeroRunAgentEventsContract = c30.router({
8218
+ var zeroRunAgentEventsContract = c32.router({
8334
8219
  getAgentEvents: {
8335
8220
  method: "GET",
8336
8221
  path: "/api/zero/runs/:id/telemetry/agent",
8337
8222
  headers: authHeadersSchema,
8338
- pathParams: z33.object({
8339
- id: z33.string().min(1, "Run ID is required")
8223
+ pathParams: z35.object({
8224
+ id: z35.string().min(1, "Run ID is required")
8340
8225
  }),
8341
- query: z33.object({
8342
- since: z33.coerce.number().optional(),
8343
- limit: z33.coerce.number().min(1).max(100).default(5),
8344
- order: z33.enum(["asc", "desc"]).default("desc")
8226
+ query: z35.object({
8227
+ since: z35.coerce.number().optional(),
8228
+ limit: z35.coerce.number().min(1).max(100).default(5),
8229
+ order: z35.enum(["asc", "desc"]).default("desc")
8345
8230
  }),
8346
8231
  responses: {
8347
8232
  200: agentEventsResponseSchema,
@@ -8353,9 +8238,9 @@ var zeroRunAgentEventsContract = c30.router({
8353
8238
  });
8354
8239
 
8355
8240
  // ../../packages/core/src/contracts/zero-schedules.ts
8356
- import { z as z34 } from "zod";
8357
- var c31 = initContract();
8358
- var zeroSchedulesMainContract = c31.router({
8241
+ import { z as z36 } from "zod";
8242
+ var c33 = initContract();
8243
+ var zeroSchedulesMainContract = c33.router({
8359
8244
  deploy: {
8360
8245
  method: "POST",
8361
8246
  path: "/api/zero/schedules",
@@ -8383,19 +8268,19 @@ var zeroSchedulesMainContract = c31.router({
8383
8268
  summary: "List all schedules (zero proxy)"
8384
8269
  }
8385
8270
  });
8386
- var zeroSchedulesByNameContract = c31.router({
8271
+ var zeroSchedulesByNameContract = c33.router({
8387
8272
  delete: {
8388
8273
  method: "DELETE",
8389
8274
  path: "/api/zero/schedules/:name",
8390
8275
  headers: authHeadersSchema,
8391
- pathParams: z34.object({
8392
- name: z34.string().min(1, "Schedule name required")
8276
+ pathParams: z36.object({
8277
+ name: z36.string().min(1, "Schedule name required")
8393
8278
  }),
8394
- query: z34.object({
8395
- composeId: z34.string().uuid("Compose ID required")
8279
+ query: z36.object({
8280
+ composeId: z36.string().uuid("Compose ID required")
8396
8281
  }),
8397
8282
  responses: {
8398
- 204: c31.noBody(),
8283
+ 204: c33.noBody(),
8399
8284
  401: apiErrorSchema,
8400
8285
  403: apiErrorSchema,
8401
8286
  404: apiErrorSchema
@@ -8403,16 +8288,16 @@ var zeroSchedulesByNameContract = c31.router({
8403
8288
  summary: "Delete schedule (zero proxy)"
8404
8289
  }
8405
8290
  });
8406
- var zeroSchedulesEnableContract = c31.router({
8291
+ var zeroSchedulesEnableContract = c33.router({
8407
8292
  enable: {
8408
8293
  method: "POST",
8409
8294
  path: "/api/zero/schedules/:name/enable",
8410
8295
  headers: authHeadersSchema,
8411
- pathParams: z34.object({
8412
- name: z34.string().min(1, "Schedule name required")
8296
+ pathParams: z36.object({
8297
+ name: z36.string().min(1, "Schedule name required")
8413
8298
  }),
8414
- body: z34.object({
8415
- composeId: z34.string().uuid("Compose ID required")
8299
+ body: z36.object({
8300
+ composeId: z36.string().uuid("Compose ID required")
8416
8301
  }),
8417
8302
  responses: {
8418
8303
  200: scheduleResponseSchema,
@@ -8427,11 +8312,11 @@ var zeroSchedulesEnableContract = c31.router({
8427
8312
  method: "POST",
8428
8313
  path: "/api/zero/schedules/:name/disable",
8429
8314
  headers: authHeadersSchema,
8430
- pathParams: z34.object({
8431
- name: z34.string().min(1, "Schedule name required")
8315
+ pathParams: z36.object({
8316
+ name: z36.string().min(1, "Schedule name required")
8432
8317
  }),
8433
- body: z34.object({
8434
- composeId: z34.string().uuid("Compose ID required")
8318
+ body: z36.object({
8319
+ composeId: z36.string().uuid("Compose ID required")
8435
8320
  }),
8436
8321
  responses: {
8437
8322
  200: scheduleResponseSchema,
@@ -8445,9 +8330,9 @@ var zeroSchedulesEnableContract = c31.router({
8445
8330
  });
8446
8331
 
8447
8332
  // ../../packages/core/src/contracts/zero-model-providers.ts
8448
- import { z as z35 } from "zod";
8449
- var c32 = initContract();
8450
- var zeroModelProvidersMainContract = c32.router({
8333
+ import { z as z37 } from "zod";
8334
+ var c34 = initContract();
8335
+ var zeroModelProvidersMainContract = c34.router({
8451
8336
  list: {
8452
8337
  method: "GET",
8453
8338
  path: "/api/zero/model-providers",
@@ -8475,16 +8360,16 @@ var zeroModelProvidersMainContract = c32.router({
8475
8360
  summary: "Create or update an org-level model provider (admin only)"
8476
8361
  }
8477
8362
  });
8478
- var zeroModelProvidersByTypeContract = c32.router({
8363
+ var zeroModelProvidersByTypeContract = c34.router({
8479
8364
  delete: {
8480
8365
  method: "DELETE",
8481
8366
  path: "/api/zero/model-providers/:type",
8482
8367
  headers: authHeadersSchema,
8483
- pathParams: z35.object({
8368
+ pathParams: z37.object({
8484
8369
  type: modelProviderTypeSchema
8485
8370
  }),
8486
8371
  responses: {
8487
- 204: c32.noBody(),
8372
+ 204: c34.noBody(),
8488
8373
  401: apiErrorSchema,
8489
8374
  403: apiErrorSchema,
8490
8375
  404: apiErrorSchema,
@@ -8493,15 +8378,15 @@ var zeroModelProvidersByTypeContract = c32.router({
8493
8378
  summary: "Delete an org-level model provider (admin only)"
8494
8379
  }
8495
8380
  });
8496
- var zeroModelProvidersDefaultContract = c32.router({
8381
+ var zeroModelProvidersDefaultContract = c34.router({
8497
8382
  setDefault: {
8498
8383
  method: "POST",
8499
8384
  path: "/api/zero/model-providers/:type/default",
8500
8385
  headers: authHeadersSchema,
8501
- pathParams: z35.object({
8386
+ pathParams: z37.object({
8502
8387
  type: modelProviderTypeSchema
8503
8388
  }),
8504
- body: z35.undefined(),
8389
+ body: z37.undefined(),
8505
8390
  responses: {
8506
8391
  200: modelProviderResponseSchema,
8507
8392
  401: apiErrorSchema,
@@ -8512,10 +8397,29 @@ var zeroModelProvidersDefaultContract = c32.router({
8512
8397
  summary: "Set org-level model provider as default (admin only)"
8513
8398
  }
8514
8399
  });
8400
+ var zeroModelProvidersUpdateModelContract = c34.router({
8401
+ updateModel: {
8402
+ method: "PATCH",
8403
+ path: "/api/zero/model-providers/:type/model",
8404
+ headers: authHeadersSchema,
8405
+ pathParams: z37.object({
8406
+ type: modelProviderTypeSchema
8407
+ }),
8408
+ body: updateModelRequestSchema,
8409
+ responses: {
8410
+ 200: modelProviderResponseSchema,
8411
+ 401: apiErrorSchema,
8412
+ 403: apiErrorSchema,
8413
+ 404: apiErrorSchema,
8414
+ 500: apiErrorSchema
8415
+ },
8416
+ summary: "Update model selection for org-level provider (admin only)"
8417
+ }
8418
+ });
8515
8419
 
8516
8420
  // ../../packages/core/src/contracts/zero-user-preferences.ts
8517
- var c33 = initContract();
8518
- var zeroUserPreferencesContract = c33.router({
8421
+ var c35 = initContract();
8422
+ var zeroUserPreferencesContract = c35.router({
8519
8423
  get: {
8520
8424
  method: "GET",
8521
8425
  path: "/api/zero/user-preferences",
@@ -8543,8 +8447,8 @@ var zeroUserPreferencesContract = c33.router({
8543
8447
  });
8544
8448
 
8545
8449
  // ../../packages/core/src/contracts/zero-secrets.ts
8546
- var c34 = initContract();
8547
- var zeroSecretsContract = c34.router({
8450
+ var c36 = initContract();
8451
+ var zeroSecretsContract = c36.router({
8548
8452
  set: {
8549
8453
  method: "POST",
8550
8454
  path: "/api/zero/secrets",
@@ -8560,7 +8464,7 @@ var zeroSecretsContract = c34.router({
8560
8464
  summary: "Create or update a secret"
8561
8465
  }
8562
8466
  });
8563
- var zeroVariablesContract = c34.router({
8467
+ var zeroVariablesContract = c36.router({
8564
8468
  set: {
8565
8469
  method: "POST",
8566
8470
  path: "/api/zero/variables",
@@ -8578,15 +8482,15 @@ var zeroVariablesContract = c34.router({
8578
8482
  });
8579
8483
 
8580
8484
  // ../../packages/core/src/contracts/zero-sessions.ts
8581
- import { z as z36 } from "zod";
8582
- var c35 = initContract();
8583
- var zeroSessionsByIdContract = c35.router({
8485
+ import { z as z38 } from "zod";
8486
+ var c37 = initContract();
8487
+ var zeroSessionsByIdContract = c37.router({
8584
8488
  getById: {
8585
8489
  method: "GET",
8586
8490
  path: "/api/zero/sessions/:id",
8587
8491
  headers: authHeadersSchema,
8588
- pathParams: z36.object({
8589
- id: z36.string().min(1, "Session ID is required")
8492
+ pathParams: z38.object({
8493
+ id: z38.string().min(1, "Session ID is required")
8590
8494
  }),
8591
8495
  responses: {
8592
8496
  200: sessionResponseSchema,
@@ -8598,6 +8502,35 @@ var zeroSessionsByIdContract = c35.router({
8598
8502
  }
8599
8503
  });
8600
8504
 
8505
+ // ../../packages/core/src/contracts/integrations.ts
8506
+ import { z as z39 } from "zod";
8507
+ var c38 = initContract();
8508
+ var integrationsSlackMessageContract = c38.router({
8509
+ sendMessage: {
8510
+ method: "POST",
8511
+ path: "/api/agent/integrations/slack/message",
8512
+ headers: authHeadersSchema,
8513
+ body: z39.object({
8514
+ channel: z39.string().min(1, "Channel ID is required"),
8515
+ text: z39.string().optional(),
8516
+ threadTs: z39.string().optional(),
8517
+ blocks: z39.array(z39.object({ type: z39.string() }).passthrough()).optional()
8518
+ }),
8519
+ responses: {
8520
+ 200: z39.object({
8521
+ ok: z39.literal(true),
8522
+ ts: z39.string().optional(),
8523
+ channel: z39.string().optional()
8524
+ }),
8525
+ 400: apiErrorSchema,
8526
+ 401: apiErrorSchema,
8527
+ 403: apiErrorSchema,
8528
+ 404: apiErrorSchema
8529
+ },
8530
+ summary: "Send a Slack message via org bot token"
8531
+ }
8532
+ });
8533
+
8601
8534
  // ../../packages/core/src/storage-names.ts
8602
8535
  function getInstructionsStorageName(agentName) {
8603
8536
  return `agent-instructions@${agentName}`;
@@ -8857,46 +8790,422 @@ var FEATURE_SWITCHES = {
8857
8790
  enabled: false,
8858
8791
  enabledUserHashes: STAFF_USER_HASHES
8859
8792
  }
8860
- };
8861
- async function isFeatureEnabled(key, userId, email) {
8862
- const featureSwitch = FEATURE_SWITCHES[key];
8863
- if (featureSwitch.enabled) {
8864
- return true;
8793
+ };
8794
+ async function isFeatureEnabled(key, userId, email) {
8795
+ const featureSwitch = FEATURE_SWITCHES[key];
8796
+ if (featureSwitch.enabled) {
8797
+ return true;
8798
+ }
8799
+ if (userId && featureSwitch.enabledUserHashes?.length) {
8800
+ const hash = await sha1(userId);
8801
+ if (featureSwitch.enabledUserHashes.includes(hash)) return true;
8802
+ }
8803
+ if (email && featureSwitch.enabledEmailHashes?.length) {
8804
+ const hash = await sha1(email.toLowerCase());
8805
+ if (featureSwitch.enabledEmailHashes.includes(hash)) return true;
8806
+ }
8807
+ return false;
8808
+ }
8809
+
8810
+ // ../../packages/core/src/skill-frontmatter.ts
8811
+ import { parse as parseYaml2 } from "yaml";
8812
+ function parseSkillFrontmatter(content) {
8813
+ const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
8814
+ if (!frontmatterMatch) {
8815
+ return {};
8816
+ }
8817
+ const yamlContent = frontmatterMatch[1];
8818
+ if (!yamlContent) {
8819
+ return {};
8820
+ }
8821
+ const parsed = parseYaml2(yamlContent);
8822
+ if (!parsed || typeof parsed !== "object") {
8823
+ return {};
8824
+ }
8825
+ const data = parsed;
8826
+ return {
8827
+ name: typeof data.name === "string" ? data.name : void 0,
8828
+ description: typeof data.description === "string" ? data.description : void 0,
8829
+ vm0_secrets: Array.isArray(data.vm0_secrets) ? data.vm0_secrets.filter((s) => typeof s === "string") : void 0,
8830
+ vm0_vars: Array.isArray(data.vm0_vars) ? data.vm0_vars.filter((s) => typeof s === "string") : void 0
8831
+ };
8832
+ }
8833
+
8834
+ // src/lib/api/core/client-factory.ts
8835
+ import { tsRestFetchApi } from "@ts-rest/core";
8836
+ var ApiRequestError = class extends Error {
8837
+ constructor(message, code, status) {
8838
+ super(message);
8839
+ this.code = code;
8840
+ this.status = status;
8841
+ this.name = "ApiRequestError";
8842
+ }
8843
+ };
8844
+ async function getHeaders() {
8845
+ const token = await getActiveToken();
8846
+ if (!token) {
8847
+ throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
8848
+ }
8849
+ const headers = {
8850
+ Authorization: `Bearer ${token}`
8851
+ };
8852
+ const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
8853
+ if (bypassSecret) {
8854
+ headers["x-vercel-protection-bypass"] = bypassSecret;
8855
+ }
8856
+ return headers;
8857
+ }
8858
+ async function getBaseUrl() {
8859
+ const apiUrl = await getApiUrl();
8860
+ if (!apiUrl) {
8861
+ throw new Error("API URL not configured");
8862
+ }
8863
+ return apiUrl;
8864
+ }
8865
+ async function getClientConfig() {
8866
+ const baseUrl = await getBaseUrl();
8867
+ const baseHeaders = await getHeaders();
8868
+ const activeOrg = await getActiveOrg();
8869
+ if (!activeOrg) {
8870
+ throw new Error(
8871
+ "No active organization configured. Run: vm0 org use <slug>"
8872
+ );
8873
+ }
8874
+ return {
8875
+ baseUrl,
8876
+ baseHeaders,
8877
+ jsonQuery: false,
8878
+ api: async (args) => {
8879
+ const separator = args.path.includes("?") ? "&" : "?";
8880
+ if (!args.path.includes("org=")) {
8881
+ args.path = `${args.path}${separator}org=${encodeURIComponent(activeOrg)}`;
8882
+ }
8883
+ return tsRestFetchApi(args);
8884
+ }
8885
+ };
8886
+ }
8887
+ function handleError(result, defaultMessage) {
8888
+ const errorBody = result.body;
8889
+ const message = errorBody.error?.message || defaultMessage;
8890
+ const code = errorBody.error?.code || "UNKNOWN";
8891
+ throw new ApiRequestError(message, code, result.status);
8892
+ }
8893
+
8894
+ // src/lib/command/with-error-handler.ts
8895
+ function withErrorHandler(fn) {
8896
+ return async (...args) => {
8897
+ try {
8898
+ await fn(...args);
8899
+ } catch (error) {
8900
+ if (error instanceof ApiRequestError) {
8901
+ if (error.code === "UNAUTHORIZED") {
8902
+ console.error(chalk2.red("\u2717 Not authenticated"));
8903
+ console.error(chalk2.dim(" Run: vm0 auth login"));
8904
+ } else {
8905
+ const guidance = RUN_ERROR_GUIDANCE[error.code];
8906
+ if (guidance) {
8907
+ console.error(chalk2.red(`\u2717 ${guidance.title}`));
8908
+ console.error(chalk2.dim(` ${guidance.guidance}`));
8909
+ if (guidance.cliHint) {
8910
+ console.error(chalk2.dim(` Run: ${guidance.cliHint}`));
8911
+ }
8912
+ } else {
8913
+ console.error(chalk2.red(`\u2717 ${error.status}: ${error.message}`));
8914
+ }
8915
+ }
8916
+ } else if (error instanceof Error) {
8917
+ console.error(chalk2.red(`\u2717 ${error.message}`));
8918
+ } else {
8919
+ console.error(chalk2.red("\u2717 An unexpected error occurred"));
8920
+ }
8921
+ if (error instanceof Error && error.cause instanceof Error) {
8922
+ console.error(chalk2.dim(` Cause: ${error.cause.message}`));
8923
+ }
8924
+ process.exit(1);
8925
+ }
8926
+ };
8927
+ }
8928
+
8929
+ // src/commands/auth/login.ts
8930
+ var loginCommand = new Command().name("login").description("Log in to VM0 (use VM0_API_URL env var to set API URL)").action(
8931
+ withErrorHandler(async () => {
8932
+ await authenticate();
8933
+ })
8934
+ );
8935
+
8936
+ // src/commands/auth/logout.ts
8937
+ import { Command as Command2 } from "commander";
8938
+ var logoutCommand = new Command2().name("logout").description("Log out of VM0").action(
8939
+ withErrorHandler(async () => {
8940
+ await logout();
8941
+ })
8942
+ );
8943
+
8944
+ // src/commands/auth/status.ts
8945
+ import { Command as Command3 } from "commander";
8946
+ var statusCommand = new Command3().name("status").description("Show current authentication status").action(
8947
+ withErrorHandler(async () => {
8948
+ await checkAuthStatus();
8949
+ })
8950
+ );
8951
+
8952
+ // src/commands/auth/setup-token.ts
8953
+ import { Command as Command4 } from "commander";
8954
+ var setupTokenCommand = new Command4().name("setup-token").description("Output auth token for CI/CD environments").action(
8955
+ withErrorHandler(async () => {
8956
+ await setupToken();
8957
+ })
8958
+ );
8959
+
8960
+ // src/commands/auth/index.ts
8961
+ var authCommand = new Command5().name("auth").description("Authenticate vm0").addCommand(loginCommand).addCommand(logoutCommand).addCommand(statusCommand).addCommand(setupTokenCommand);
8962
+
8963
+ // src/commands/info/index.ts
8964
+ import { Command as Command6 } from "commander";
8965
+ import chalk4 from "chalk";
8966
+ import { existsSync as existsSync2 } from "fs";
8967
+ import { homedir as homedir2, release as release2, type } from "os";
8968
+ import { join as join2 } from "path";
8969
+
8970
+ // src/lib/utils/update-checker.ts
8971
+ import chalk3 from "chalk";
8972
+
8973
+ // src/lib/utils/spawn.ts
8974
+ import { spawn } from "child_process";
8975
+ function safeSpawn(command, args, options) {
8976
+ const isWindows = process.platform === "win32";
8977
+ const resolvedCommand = isWindows ? `${command}.cmd` : command;
8978
+ return spawn(resolvedCommand, args, {
8979
+ ...options,
8980
+ shell: isWindows
8981
+ });
8982
+ }
8983
+
8984
+ // src/lib/utils/update-checker.ts
8985
+ var PACKAGE_NAME = "@vm0/cli";
8986
+ var NPM_REGISTRY_URL = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME)}/latest`;
8987
+ var TIMEOUT_MS = 5e3;
8988
+ var pendingUpgrade = null;
8989
+ function detectPackageManager() {
8990
+ const execPath = process.argv[1] ?? "";
8991
+ if (execPath.includes("pnpm")) {
8992
+ return "pnpm";
8993
+ }
8994
+ if (execPath.includes("/.bun/") || execPath.includes("/bun/")) {
8995
+ return "bun";
8865
8996
  }
8866
- if (userId && featureSwitch.enabledUserHashes?.length) {
8867
- const hash = await sha1(userId);
8868
- if (featureSwitch.enabledUserHashes.includes(hash)) return true;
8997
+ if (execPath.includes("/.yarn/") || execPath.includes("/yarn/")) {
8998
+ return "yarn";
8869
8999
  }
8870
- if (email && featureSwitch.enabledEmailHashes?.length) {
8871
- const hash = await sha1(email.toLowerCase());
8872
- if (featureSwitch.enabledEmailHashes.includes(hash)) return true;
9000
+ if (execPath.includes("/usr/local/") || // Homebrew on Intel Mac
9001
+ execPath.includes("/opt/homebrew/") || // Homebrew on arm64 Mac
9002
+ execPath.includes("/.nvm/") || execPath.includes("/.fnm/") || execPath.includes("/.volta/") || execPath.includes("/.nodenv/") || execPath.includes("/.n/") || execPath.includes("/node_modules/") || execPath.includes("\\npm\\") || // Windows: AppData\Roaming\npm
9003
+ execPath.includes("\\nodejs\\")) {
9004
+ return "npm";
8873
9005
  }
8874
- return false;
9006
+ return "unknown";
8875
9007
  }
8876
-
8877
- // ../../packages/core/src/skill-frontmatter.ts
8878
- import { parse as parseYaml2 } from "yaml";
8879
- function parseSkillFrontmatter(content) {
8880
- const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
8881
- if (!frontmatterMatch) {
8882
- return {};
9008
+ function isAutoUpgradeSupported(pm) {
9009
+ return pm === "npm" || pm === "pnpm";
9010
+ }
9011
+ function getManualUpgradeCommand(pm) {
9012
+ switch (pm) {
9013
+ case "bun":
9014
+ return `bun add -g ${PACKAGE_NAME}@latest`;
9015
+ case "yarn":
9016
+ return `yarn global add ${PACKAGE_NAME}@latest`;
9017
+ case "pnpm":
9018
+ return `pnpm add -g ${PACKAGE_NAME}@latest`;
9019
+ case "npm":
9020
+ return `npm install -g ${PACKAGE_NAME}@latest`;
9021
+ case "unknown":
9022
+ return `npm install -g ${PACKAGE_NAME}@latest`;
8883
9023
  }
8884
- const yamlContent = frontmatterMatch[1];
8885
- if (!yamlContent) {
8886
- return {};
9024
+ }
9025
+ function escapeForShell(str) {
9026
+ return `'${str.replace(/'/g, "'\\''")}'`;
9027
+ }
9028
+ function buildRerunCommand(prompt) {
9029
+ if (prompt) {
9030
+ return `vm0 cook ${escapeForShell(prompt)}`;
8887
9031
  }
8888
- const parsed = parseYaml2(yamlContent);
8889
- if (!parsed || typeof parsed !== "object") {
8890
- return {};
9032
+ return "vm0 cook";
9033
+ }
9034
+ async function getLatestVersion() {
9035
+ try {
9036
+ const controller = new AbortController();
9037
+ const timeoutId = setTimeout(() => controller.abort(), TIMEOUT_MS);
9038
+ const response = await fetch(NPM_REGISTRY_URL, {
9039
+ signal: controller.signal
9040
+ });
9041
+ clearTimeout(timeoutId);
9042
+ if (!response.ok) {
9043
+ return null;
9044
+ }
9045
+ const json = await response.json();
9046
+ return json.version ?? null;
9047
+ } catch {
9048
+ return null;
8891
9049
  }
8892
- const data = parsed;
8893
- return {
8894
- name: typeof data.name === "string" ? data.name : void 0,
8895
- description: typeof data.description === "string" ? data.description : void 0,
8896
- vm0_secrets: Array.isArray(data.vm0_secrets) ? data.vm0_secrets.filter((s) => typeof s === "string") : void 0,
8897
- vm0_vars: Array.isArray(data.vm0_vars) ? data.vm0_vars.filter((s) => typeof s === "string") : void 0
8898
- };
8899
9050
  }
9051
+ function performUpgrade(packageManager) {
9052
+ return new Promise((resolve2) => {
9053
+ const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
9054
+ const child = safeSpawn(packageManager, args, {
9055
+ stdio: "inherit"
9056
+ });
9057
+ child.on("close", (code) => {
9058
+ resolve2(code === 0);
9059
+ });
9060
+ child.on("error", () => {
9061
+ resolve2(false);
9062
+ });
9063
+ });
9064
+ }
9065
+ async function checkAndUpgrade(currentVersion, prompt) {
9066
+ const latestVersion = await getLatestVersion();
9067
+ if (latestVersion === null) {
9068
+ console.log(chalk3.yellow("\u26A0 Could not check for updates"));
9069
+ console.log();
9070
+ return false;
9071
+ }
9072
+ if (latestVersion === currentVersion) {
9073
+ return false;
9074
+ }
9075
+ console.log(chalk3.yellow("vm0 is currently in beta."));
9076
+ console.log(
9077
+ chalk3.yellow(
9078
+ `Current version: ${currentVersion} -> Latest version: ${latestVersion}`
9079
+ )
9080
+ );
9081
+ console.log(
9082
+ chalk3.yellow(
9083
+ "Please always use the latest version for best compatibility."
9084
+ )
9085
+ );
9086
+ console.log();
9087
+ const packageManager = detectPackageManager();
9088
+ if (!isAutoUpgradeSupported(packageManager)) {
9089
+ if (packageManager === "unknown") {
9090
+ console.log(
9091
+ chalk3.yellow("Could not detect your package manager for auto-upgrade.")
9092
+ );
9093
+ } else {
9094
+ console.log(
9095
+ chalk3.yellow(`Auto-upgrade is not supported for ${packageManager}.`)
9096
+ );
9097
+ }
9098
+ console.log(chalk3.yellow("Please upgrade manually:"));
9099
+ console.log(chalk3.cyan(` ${getManualUpgradeCommand(packageManager)}`));
9100
+ console.log();
9101
+ return false;
9102
+ }
9103
+ console.log(`Upgrading via ${packageManager}...`);
9104
+ const success = await performUpgrade(packageManager);
9105
+ if (success) {
9106
+ console.log(chalk3.green(`Upgraded to ${latestVersion}`));
9107
+ console.log();
9108
+ console.log("To continue, run:");
9109
+ console.log(chalk3.cyan(` ${buildRerunCommand(prompt)}`));
9110
+ return true;
9111
+ }
9112
+ console.error();
9113
+ console.error(chalk3.red("\u2717 Upgrade failed. Please run manually:"));
9114
+ console.error(chalk3.cyan(` ${getManualUpgradeCommand(packageManager)}`));
9115
+ console.error();
9116
+ console.error("Then re-run:");
9117
+ console.error(chalk3.cyan(` ${buildRerunCommand(prompt)}`));
9118
+ return true;
9119
+ }
9120
+ async function startSilentUpgrade(currentVersion) {
9121
+ pendingUpgrade = null;
9122
+ const latestVersion = await getLatestVersion();
9123
+ if (latestVersion === null || latestVersion === currentVersion) {
9124
+ return;
9125
+ }
9126
+ const packageManager = detectPackageManager();
9127
+ if (!isAutoUpgradeSupported(packageManager)) {
9128
+ return;
9129
+ }
9130
+ const isWindows = process.platform === "win32";
9131
+ const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
9132
+ const child = safeSpawn(packageManager, args, {
9133
+ stdio: "pipe",
9134
+ detached: !isWindows,
9135
+ windowsHide: true
9136
+ });
9137
+ const promise = new Promise((resolve2) => {
9138
+ child.on("close", (code) => resolve2(code === 0));
9139
+ child.on("error", () => resolve2(false));
9140
+ });
9141
+ pendingUpgrade = { promise, child, packageManager };
9142
+ }
9143
+ async function waitForSilentUpgrade(timeout = TIMEOUT_MS) {
9144
+ if (!pendingUpgrade) {
9145
+ return;
9146
+ }
9147
+ const { promise, child, packageManager } = pendingUpgrade;
9148
+ pendingUpgrade = null;
9149
+ const result = await Promise.race([
9150
+ promise,
9151
+ new Promise((resolve2) => {
9152
+ setTimeout(() => {
9153
+ child.kill();
9154
+ resolve2(false);
9155
+ }, timeout);
9156
+ })
9157
+ ]);
9158
+ if (!result) {
9159
+ console.log(
9160
+ chalk3.yellow(
9161
+ `
9162
+ \u26A0 vm0 auto upgrade failed. Please run: ${getManualUpgradeCommand(packageManager)}`
9163
+ )
9164
+ );
9165
+ }
9166
+ }
9167
+
9168
+ // src/commands/info/index.ts
9169
+ function getConfigPath() {
9170
+ return join2(homedir2(), ".vm0", "config.json");
9171
+ }
9172
+ var infoCommand = new Command6().name("info").description("Display environment and debug information").action(async () => {
9173
+ console.log(chalk4.bold(`VM0 CLI v${"9.74.1"}`));
9174
+ console.log();
9175
+ const config = await loadConfig();
9176
+ const hasEnvToken = !!process.env.VM0_TOKEN;
9177
+ const hasConfigToken = !!config.token;
9178
+ const isAuthenticated2 = hasEnvToken || hasConfigToken;
9179
+ console.log(chalk4.bold("Authentication:"));
9180
+ if (isAuthenticated2) {
9181
+ const tokenSource = hasEnvToken ? "VM0_TOKEN env var" : "config file";
9182
+ console.log(` ${chalk4.green("\u2713")} Logged in (via ${tokenSource})`);
9183
+ } else {
9184
+ console.log(` ${chalk4.red("\u2717")} Not authenticated`);
9185
+ }
9186
+ const configExists = existsSync2(getConfigPath());
9187
+ const configDisplay = configExists ? `~/.vm0/config.json` : `~/.vm0/config.json (not found)`;
9188
+ console.log(` Config: ${configDisplay}`);
9189
+ console.log();
9190
+ const apiUrl = await getApiUrl();
9191
+ console.log(chalk4.bold("API:"));
9192
+ console.log(` Host: ${apiUrl}`);
9193
+ console.log();
9194
+ console.log(chalk4.bold("System:"));
9195
+ console.log(` Node: ${process.version}`);
9196
+ console.log(` Platform: ${process.platform} (${process.arch})`);
9197
+ console.log(` OS: ${type()} ${release2()}`);
9198
+ console.log(` Shell: ${process.env.SHELL ?? "unknown"}`);
9199
+ console.log(` Package Manager: ${detectPackageManager()}`);
9200
+ });
9201
+
9202
+ // src/commands/compose/index.ts
9203
+ import { Command as Command7, Option } from "commander";
9204
+ import chalk6 from "chalk";
9205
+ import { readFile as readFile4, rm as rm3 } from "fs/promises";
9206
+ import { existsSync as existsSync5 } from "fs";
9207
+ import { dirname as dirname2, join as join8 } from "path";
9208
+ import { parse as parseYaml3 } from "yaml";
8900
9209
 
8901
9210
  // src/lib/api/core/http.ts
8902
9211
  async function appendOrgParam(path18) {
@@ -9295,7 +9604,7 @@ async function enableSchedule(params) {
9295
9604
  }
9296
9605
  async function disableSchedule(params) {
9297
9606
  const config = await getClientConfig();
9298
- const client = initClient6(schedulesEnableContract, config);
9607
+ const client = initClient6(schedulesDisableContract, config);
9299
9608
  const result = await client.disable({
9300
9609
  params: { name: params.name },
9301
9610
  body: { composeId: params.composeId }
@@ -9650,8 +9959,8 @@ async function resolveSkills(skillUrls) {
9650
9959
  }
9651
9960
 
9652
9961
  // src/lib/domain/yaml-validator.ts
9653
- import { z as z37 } from "zod";
9654
- var cliAgentNameSchema = z37.string().min(3, "Agent name must be at least 3 characters").max(64, "Agent name must be 64 characters or less").regex(
9962
+ import { z as z40 } from "zod";
9963
+ var cliAgentNameSchema = z40.string().min(3, "Agent name must be at least 3 characters").max(64, "Agent name must be 64 characters or less").regex(
9655
9964
  /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,62}[a-zA-Z0-9])?$/,
9656
9965
  "Agent name must start and end with letter or number, and contain only letters, numbers, and hyphens"
9657
9966
  );
@@ -9665,7 +9974,7 @@ var cliAgentDefinitionSchema = agentDefinitionSchema.superRefine(
9665
9974
  resolveSkillRef(skillRef);
9666
9975
  } catch (error) {
9667
9976
  ctx.addIssue({
9668
- code: z37.ZodIssueCode.custom,
9977
+ code: z40.ZodIssueCode.custom,
9669
9978
  message: error instanceof Error ? error.message : `Invalid skill reference: ${skillRef}`,
9670
9979
  path: ["skills", i]
9671
9980
  });
@@ -9675,15 +9984,15 @@ var cliAgentDefinitionSchema = agentDefinitionSchema.superRefine(
9675
9984
  }
9676
9985
  }
9677
9986
  );
9678
- var cliComposeSchema = z37.object({
9679
- version: z37.string().min(1, "Missing config.version"),
9680
- agents: z37.record(cliAgentNameSchema, cliAgentDefinitionSchema),
9681
- volumes: z37.record(z37.string(), volumeConfigSchema).optional()
9987
+ var cliComposeSchema = z40.object({
9988
+ version: z40.string().min(1, "Missing config.version"),
9989
+ agents: z40.record(cliAgentNameSchema, cliAgentDefinitionSchema),
9990
+ volumes: z40.record(z40.string(), volumeConfigSchema).optional()
9682
9991
  }).superRefine((config, ctx) => {
9683
9992
  const agentKeys = Object.keys(config.agents);
9684
9993
  if (agentKeys.length === 0) {
9685
9994
  ctx.addIssue({
9686
- code: z37.ZodIssueCode.custom,
9995
+ code: z40.ZodIssueCode.custom,
9687
9996
  message: "agents must have at least one agent defined",
9688
9997
  path: ["agents"]
9689
9998
  });
@@ -9691,7 +10000,7 @@ var cliComposeSchema = z37.object({
9691
10000
  }
9692
10001
  if (agentKeys.length > 1) {
9693
10002
  ctx.addIssue({
9694
- code: z37.ZodIssueCode.custom,
10003
+ code: z40.ZodIssueCode.custom,
9695
10004
  message: "Multiple agents not supported yet. Only one agent allowed.",
9696
10005
  path: ["agents"]
9697
10006
  });
@@ -9703,7 +10012,7 @@ var cliComposeSchema = z37.object({
9703
10012
  if (agentVolumes && agentVolumes.length > 0) {
9704
10013
  if (!config.volumes) {
9705
10014
  ctx.addIssue({
9706
- code: z37.ZodIssueCode.custom,
10015
+ code: z40.ZodIssueCode.custom,
9707
10016
  message: "Agent references volumes but no volumes section defined. Each volume must have explicit name and version.",
9708
10017
  path: ["volumes"]
9709
10018
  });
@@ -9713,7 +10022,7 @@ var cliComposeSchema = z37.object({
9713
10022
  const parts = volDeclaration.split(":");
9714
10023
  if (parts.length !== 2) {
9715
10024
  ctx.addIssue({
9716
- code: z37.ZodIssueCode.custom,
10025
+ code: z40.ZodIssueCode.custom,
9717
10026
  message: `Invalid volume declaration: ${volDeclaration}. Expected format: volume-key:/mount/path`,
9718
10027
  path: ["agents", agentName, "volumes"]
9719
10028
  });
@@ -9722,7 +10031,7 @@ var cliComposeSchema = z37.object({
9722
10031
  const volumeKey = parts[0].trim();
9723
10032
  if (!config.volumes[volumeKey]) {
9724
10033
  ctx.addIssue({
9725
- code: z37.ZodIssueCode.custom,
10034
+ code: z40.ZodIssueCode.custom,
9726
10035
  message: `Volume "${volumeKey}" is not defined in volumes section. Each volume must have explicit name and version.`,
9727
10036
  path: ["volumes", volumeKey]
9728
10037
  });
@@ -10921,7 +11230,7 @@ var composeCommand = new Command7().name("compose").description("Create or updat
10921
11230
  options.autoUpdate = false;
10922
11231
  }
10923
11232
  if (options.autoUpdate !== false) {
10924
- await startSilentUpgrade("9.73.0");
11233
+ await startSilentUpgrade("9.74.1");
10925
11234
  }
10926
11235
  try {
10927
11236
  let result;
@@ -11677,6 +11986,10 @@ async function pollEvents(runId, options) {
11677
11986
  chalk9.dim(` (use "vm0 logs ${runId} --system" to view system logs)`)
11678
11987
  );
11679
11988
  result = { succeeded: false, runId };
11989
+ } else if (runStatus === "cancelled") {
11990
+ complete = true;
11991
+ console.error(chalk9.yellow("\n\u2717 Run cancelled"));
11992
+ result = { succeeded: false, runId };
11680
11993
  }
11681
11994
  if (!complete) {
11682
11995
  await new Promise((resolve2) => setTimeout(resolve2, pollIntervalMs));
@@ -11752,7 +12065,7 @@ var mainRunCommand = new Command8().name("run").description("Run an agent").argu
11752
12065
  withErrorHandler(
11753
12066
  async (identifier, prompt, options) => {
11754
12067
  if (options.autoUpdate !== false) {
11755
- await startSilentUpgrade("9.73.0");
12068
+ await startSilentUpgrade("9.74.1");
11756
12069
  }
11757
12070
  const { org, name, version } = parseIdentifier(identifier);
11758
12071
  let composeId;
@@ -13508,7 +13821,7 @@ var cookAction = new Command35().name("cook").description("Quick start: prepare,
13508
13821
  withErrorHandler(
13509
13822
  async (prompt, options) => {
13510
13823
  if (options.autoUpdate !== false) {
13511
- const shouldExit = await checkAndUpgrade("9.73.0", prompt);
13824
+ const shouldExit = await checkAndUpgrade("9.74.1", prompt);
13512
13825
  if (shouldExit) {
13513
13826
  process.exit(0);
13514
13827
  }
@@ -14179,7 +14492,7 @@ var ApiClient = class {
14179
14492
  async disableSchedule(params) {
14180
14493
  const baseUrl = await this.getBaseUrl();
14181
14494
  const headers = await this.getHeaders();
14182
- const client = initClient14(schedulesEnableContract, {
14495
+ const client = initClient14(schedulesDisableContract, {
14183
14496
  baseUrl,
14184
14497
  baseHeaders: headers,
14185
14498
  jsonQuery: false
@@ -15882,7 +16195,7 @@ var listCommand9 = new Command65().name("list").alias("ls").description("List al
15882
16195
  );
15883
16196
  return;
15884
16197
  }
15885
- const nameWidth = Math.max(4, ...data.composes.map((c36) => c36.name.length));
16198
+ const nameWidth = Math.max(4, ...data.composes.map((c39) => c39.name.length));
15886
16199
  const header = ["NAME".padEnd(nameWidth), "VERSION", "UPDATED"].join(
15887
16200
  " "
15888
16201
  );
@@ -16483,7 +16796,7 @@ async function gatherFrequency(optionFrequency, existingFrequency) {
16483
16796
  if (!isInteractive()) {
16484
16797
  throw new Error("--frequency is required (daily|weekly|monthly|once|loop)");
16485
16798
  }
16486
- const defaultIndex = existingFrequency ? FREQUENCY_CHOICES.findIndex((c36) => c36.value === existingFrequency) : 0;
16799
+ const defaultIndex = existingFrequency ? FREQUENCY_CHOICES.findIndex((c39) => c39.value === existingFrequency) : 0;
16487
16800
  frequency = await promptSelect(
16488
16801
  "Schedule frequency",
16489
16802
  FREQUENCY_CHOICES,
@@ -16508,7 +16821,7 @@ async function gatherDay(frequency, optionDay, existingDay) {
16508
16821
  throw new Error("--day is required for weekly/monthly");
16509
16822
  }
16510
16823
  if (frequency === "weekly") {
16511
- const defaultDayIndex = existingDay !== void 0 ? DAY_OF_WEEK_CHOICES.findIndex((c36) => c36.value === existingDay) : 0;
16824
+ const defaultDayIndex = existingDay !== void 0 ? DAY_OF_WEEK_CHOICES.findIndex((c39) => c39.value === existingDay) : 0;
16512
16825
  const day2 = await promptSelect(
16513
16826
  "Day of week",
16514
16827
  DAY_OF_WEEK_CHOICES,
@@ -17958,7 +18271,7 @@ import chalk76 from "chalk";
17958
18271
  var listCommand13 = new Command86().name("list").alias("ls").description("List all connectors and their status").action(
17959
18272
  withErrorHandler(async () => {
17960
18273
  const result = await listConnectors();
17961
- const connectedMap = new Map(result.connectors.map((c36) => [c36.type, c36]));
18274
+ const connectedMap = new Map(result.connectors.map((c39) => [c39.type, c39]));
17962
18275
  const allTypesRaw = Object.keys(CONNECTOR_TYPES);
17963
18276
  const allTypes = [];
17964
18277
  for (const type2 of allTypesRaw) {
@@ -18519,16 +18832,16 @@ async function handleModelProvider(ctx) {
18519
18832
  const providerType = await step.prompt(
18520
18833
  () => promptSelect(
18521
18834
  "Select provider type:",
18522
- choices.map((c36) => ({
18523
- title: c36.label,
18524
- value: c36.type
18835
+ choices.map((c39) => ({
18836
+ title: c39.label,
18837
+ value: c39.type
18525
18838
  }))
18526
18839
  )
18527
18840
  );
18528
18841
  if (!providerType) {
18529
18842
  process.exit(0);
18530
18843
  }
18531
- const selectedChoice = choices.find((c36) => c36.type === providerType);
18844
+ const selectedChoice = choices.find((c39) => c39.type === providerType);
18532
18845
  if (selectedChoice?.helpText) {
18533
18846
  for (const line of selectedChoice.helpText.split("\n")) {
18534
18847
  step.detail(chalk82.dim(line));
@@ -18882,13 +19195,13 @@ var upgradeCommand = new Command94().name("upgrade").description("Upgrade vm0 CL
18882
19195
  if (latestVersion === null) {
18883
19196
  throw new Error("Could not check for updates. Please try again later.");
18884
19197
  }
18885
- if (latestVersion === "9.73.0") {
18886
- console.log(chalk86.green(`\u2713 Already up to date (${"9.73.0"})`));
19198
+ if (latestVersion === "9.74.1") {
19199
+ console.log(chalk86.green(`\u2713 Already up to date (${"9.74.1"})`));
18887
19200
  return;
18888
19201
  }
18889
19202
  console.log(
18890
19203
  chalk86.yellow(
18891
- `Current version: ${"9.73.0"} -> Latest version: ${latestVersion}`
19204
+ `Current version: ${"9.74.1"} -> Latest version: ${latestVersion}`
18892
19205
  )
18893
19206
  );
18894
19207
  console.log();
@@ -18915,7 +19228,7 @@ var upgradeCommand = new Command94().name("upgrade").description("Upgrade vm0 CL
18915
19228
  const success = await performUpgrade(packageManager);
18916
19229
  if (success) {
18917
19230
  console.log(
18918
- chalk86.green(`\u2713 Upgraded from ${"9.73.0"} to ${latestVersion}`)
19231
+ chalk86.green(`\u2713 Upgraded from ${"9.74.1"} to ${latestVersion}`)
18919
19232
  );
18920
19233
  return;
18921
19234
  }
@@ -18989,7 +19302,7 @@ var whoamiCommand = new Command95().name("whoami").description("Show current ide
18989
19302
 
18990
19303
  // src/index.ts
18991
19304
  var program = new Command96();
18992
- program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.73.0");
19305
+ program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.74.1");
18993
19306
  program.addCommand(authCommand);
18994
19307
  program.addCommand(infoCommand);
18995
19308
  program.addCommand(composeCommand);