@vm0/cli 9.72.1 → 9.74.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/index.js +753 -547
- 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.
|
|
50
|
+
release: "9.74.0",
|
|
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.
|
|
69
|
+
version: "9.74.0",
|
|
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.72.1"}`));
|
|
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";
|
|
@@ -1556,8 +1269,11 @@ var runsMainContract = c5.router({
|
|
|
1556
1269
|
201: createRunResponseSchema,
|
|
1557
1270
|
400: apiErrorSchema,
|
|
1558
1271
|
401: apiErrorSchema,
|
|
1272
|
+
402: apiErrorSchema,
|
|
1559
1273
|
403: apiErrorSchema,
|
|
1560
|
-
404: apiErrorSchema
|
|
1274
|
+
404: apiErrorSchema,
|
|
1275
|
+
422: apiErrorSchema,
|
|
1276
|
+
503: apiErrorSchema
|
|
1561
1277
|
},
|
|
1562
1278
|
summary: "Create and execute agent run"
|
|
1563
1279
|
}
|
|
@@ -1658,6 +1374,7 @@ var agentEventsResponseSchema = z8.object({
|
|
|
1658
1374
|
});
|
|
1659
1375
|
var networkLogEntrySchema = z8.object({
|
|
1660
1376
|
timestamp: z8.string(),
|
|
1377
|
+
type: z8.enum(["http", "tcp"]).optional(),
|
|
1661
1378
|
action: z8.enum(["ALLOW", "DENY"]).optional(),
|
|
1662
1379
|
host: z8.string().optional(),
|
|
1663
1380
|
port: z8.number().optional(),
|
|
@@ -1673,7 +1390,8 @@ var networkLogEntrySchema = z8.object({
|
|
|
1673
1390
|
firewall_permission: z8.string().optional(),
|
|
1674
1391
|
firewall_rule_match: z8.string().optional(),
|
|
1675
1392
|
firewall_params: z8.record(z8.string(), z8.string()).optional(),
|
|
1676
|
-
firewall_error: z8.string().optional()
|
|
1393
|
+
firewall_error: z8.string().optional(),
|
|
1394
|
+
error: z8.string().optional()
|
|
1677
1395
|
});
|
|
1678
1396
|
var networkLogsResponseSchema = z8.object({
|
|
1679
1397
|
networkLogs: z8.array(networkLogEntrySchema),
|
|
@@ -2326,17 +2044,24 @@ var sandboxOperationSchema = z10.object({
|
|
|
2326
2044
|
});
|
|
2327
2045
|
var networkLogSchema = z10.object({
|
|
2328
2046
|
timestamp: z10.string(),
|
|
2329
|
-
|
|
2047
|
+
type: z10.enum(["http", "tcp"]).optional(),
|
|
2330
2048
|
action: z10.enum(["ALLOW", "DENY"]).optional(),
|
|
2331
2049
|
host: z10.string().optional(),
|
|
2332
2050
|
port: z10.number().optional(),
|
|
2333
|
-
rule_matched: z10.string().nullable().optional(),
|
|
2334
2051
|
method: z10.string().optional(),
|
|
2335
2052
|
url: z10.string().optional(),
|
|
2336
2053
|
status: z10.number().optional(),
|
|
2337
2054
|
latency_ms: z10.number().optional(),
|
|
2338
2055
|
request_size: z10.number().optional(),
|
|
2339
|
-
response_size: z10.number().optional()
|
|
2056
|
+
response_size: z10.number().optional(),
|
|
2057
|
+
firewall_base: z10.string().optional(),
|
|
2058
|
+
firewall_name: z10.string().optional(),
|
|
2059
|
+
firewall_ref: z10.string().optional(),
|
|
2060
|
+
firewall_permission: z10.string().optional(),
|
|
2061
|
+
firewall_rule_match: z10.string().optional(),
|
|
2062
|
+
firewall_params: z10.record(z10.string(), z10.string()).optional(),
|
|
2063
|
+
firewall_error: z10.string().optional(),
|
|
2064
|
+
error: z10.string().optional()
|
|
2340
2065
|
});
|
|
2341
2066
|
var webhookTelemetryContract = c7.router({
|
|
2342
2067
|
/**
|
|
@@ -3836,17 +3561,23 @@ var schedulesEnableContract = c16.router({
|
|
|
3836
3561
|
pathParams: z20.object({
|
|
3837
3562
|
name: z20.string().min(1, "Schedule name required")
|
|
3838
3563
|
}),
|
|
3564
|
+
query: z20.object({
|
|
3565
|
+
org: z20.string().optional()
|
|
3566
|
+
}),
|
|
3839
3567
|
body: z20.object({
|
|
3840
3568
|
composeId: z20.string().uuid("Compose ID required")
|
|
3841
3569
|
}),
|
|
3842
3570
|
responses: {
|
|
3843
3571
|
200: scheduleResponseSchema,
|
|
3572
|
+
400: apiErrorSchema,
|
|
3844
3573
|
401: apiErrorSchema,
|
|
3845
3574
|
403: apiErrorSchema,
|
|
3846
3575
|
404: apiErrorSchema
|
|
3847
3576
|
},
|
|
3848
3577
|
summary: "Enable schedule"
|
|
3849
|
-
}
|
|
3578
|
+
}
|
|
3579
|
+
});
|
|
3580
|
+
var schedulesDisableContract = c16.router({
|
|
3850
3581
|
/**
|
|
3851
3582
|
* POST /api/agent/schedules/:name/disable
|
|
3852
3583
|
* Disable an enabled schedule
|
|
@@ -3858,11 +3589,15 @@ var schedulesEnableContract = c16.router({
|
|
|
3858
3589
|
pathParams: z20.object({
|
|
3859
3590
|
name: z20.string().min(1, "Schedule name required")
|
|
3860
3591
|
}),
|
|
3592
|
+
query: z20.object({
|
|
3593
|
+
org: z20.string().optional()
|
|
3594
|
+
}),
|
|
3861
3595
|
body: z20.object({
|
|
3862
3596
|
composeId: z20.string().uuid("Compose ID required")
|
|
3863
3597
|
}),
|
|
3864
3598
|
responses: {
|
|
3865
3599
|
200: scheduleResponseSchema,
|
|
3600
|
+
400: apiErrorSchema,
|
|
3866
3601
|
401: apiErrorSchema,
|
|
3867
3602
|
403: apiErrorSchema,
|
|
3868
3603
|
404: apiErrorSchema
|
|
@@ -3895,6 +3630,32 @@ var scheduleRunsContract = c16.router({
|
|
|
3895
3630
|
summary: "List recent runs for a schedule"
|
|
3896
3631
|
}
|
|
3897
3632
|
});
|
|
3633
|
+
var agentMissingSecretsSchema = z20.object({
|
|
3634
|
+
composeId: z20.string(),
|
|
3635
|
+
agentName: z20.string(),
|
|
3636
|
+
requiredSecrets: z20.array(z20.string()),
|
|
3637
|
+
missingSecrets: z20.array(z20.string())
|
|
3638
|
+
});
|
|
3639
|
+
var schedulesMissingSecretsContract = c16.router({
|
|
3640
|
+
/**
|
|
3641
|
+
* GET /api/agent/schedules/missing-secrets
|
|
3642
|
+
* Check agents for missing secrets
|
|
3643
|
+
*/
|
|
3644
|
+
getMissingSecrets: {
|
|
3645
|
+
method: "GET",
|
|
3646
|
+
path: "/api/agent/schedules/missing-secrets",
|
|
3647
|
+
headers: authHeadersSchema,
|
|
3648
|
+
query: z20.object({
|
|
3649
|
+
org: z20.string().optional()
|
|
3650
|
+
}),
|
|
3651
|
+
responses: {
|
|
3652
|
+
200: z20.object({ agents: z20.array(agentMissingSecretsSchema) }),
|
|
3653
|
+
401: apiErrorSchema,
|
|
3654
|
+
403: apiErrorSchema
|
|
3655
|
+
},
|
|
3656
|
+
summary: "Check agents for missing secrets"
|
|
3657
|
+
}
|
|
3658
|
+
});
|
|
3898
3659
|
|
|
3899
3660
|
// ../../packages/core/src/contracts/realtime.ts
|
|
3900
3661
|
import { z as z21 } from "zod";
|
|
@@ -8017,31 +7778,57 @@ var orgVariablesByNameContract = c25.router({
|
|
|
8017
7778
|
}
|
|
8018
7779
|
});
|
|
8019
7780
|
|
|
7781
|
+
// ../../packages/core/src/contracts/required-env.ts
|
|
7782
|
+
import { z as z30 } from "zod";
|
|
7783
|
+
var c26 = initContract();
|
|
7784
|
+
var agentRequiredEnvSchema = z30.object({
|
|
7785
|
+
composeId: z30.string(),
|
|
7786
|
+
agentName: z30.string(),
|
|
7787
|
+
requiredSecrets: z30.array(z30.string()),
|
|
7788
|
+
requiredVariables: z30.array(z30.string())
|
|
7789
|
+
});
|
|
7790
|
+
var requiredEnvContract = c26.router({
|
|
7791
|
+
/**
|
|
7792
|
+
* GET /api/agent/required-env
|
|
7793
|
+
* Get required environment variables for user agents
|
|
7794
|
+
*/
|
|
7795
|
+
getRequiredEnv: {
|
|
7796
|
+
method: "GET",
|
|
7797
|
+
path: "/api/agent/required-env",
|
|
7798
|
+
headers: authHeadersSchema,
|
|
7799
|
+
responses: {
|
|
7800
|
+
200: z30.object({ agents: z30.array(agentRequiredEnvSchema) }),
|
|
7801
|
+
401: apiErrorSchema
|
|
7802
|
+
},
|
|
7803
|
+
summary: "Get required environment variables for user agents"
|
|
7804
|
+
}
|
|
7805
|
+
});
|
|
7806
|
+
|
|
8020
7807
|
// ../../packages/core/src/contracts/zero-agents.ts
|
|
8021
|
-
import { z as
|
|
8022
|
-
var
|
|
8023
|
-
var zeroAgentResponseSchema =
|
|
8024
|
-
name:
|
|
8025
|
-
agentComposeId:
|
|
8026
|
-
description:
|
|
8027
|
-
displayName:
|
|
8028
|
-
sound:
|
|
8029
|
-
connectors:
|
|
7808
|
+
import { z as z31 } from "zod";
|
|
7809
|
+
var c27 = initContract();
|
|
7810
|
+
var zeroAgentResponseSchema = z31.object({
|
|
7811
|
+
name: z31.string(),
|
|
7812
|
+
agentComposeId: z31.string(),
|
|
7813
|
+
description: z31.string().nullable(),
|
|
7814
|
+
displayName: z31.string().nullable(),
|
|
7815
|
+
sound: z31.string().nullable(),
|
|
7816
|
+
connectors: z31.array(z31.string())
|
|
8030
7817
|
});
|
|
8031
|
-
var zeroAgentRequestSchema =
|
|
8032
|
-
description:
|
|
8033
|
-
displayName:
|
|
8034
|
-
sound:
|
|
8035
|
-
connectors:
|
|
7818
|
+
var zeroAgentRequestSchema = z31.object({
|
|
7819
|
+
description: z31.string().optional(),
|
|
7820
|
+
displayName: z31.string().optional(),
|
|
7821
|
+
sound: z31.string().optional(),
|
|
7822
|
+
connectors: z31.array(z31.string())
|
|
8036
7823
|
});
|
|
8037
|
-
var zeroAgentInstructionsResponseSchema =
|
|
8038
|
-
content:
|
|
8039
|
-
filename:
|
|
7824
|
+
var zeroAgentInstructionsResponseSchema = z31.object({
|
|
7825
|
+
content: z31.string().nullable(),
|
|
7826
|
+
filename: z31.string().nullable()
|
|
8040
7827
|
});
|
|
8041
|
-
var zeroAgentInstructionsRequestSchema =
|
|
8042
|
-
content:
|
|
7828
|
+
var zeroAgentInstructionsRequestSchema = z31.object({
|
|
7829
|
+
content: z31.string()
|
|
8043
7830
|
});
|
|
8044
|
-
var zeroAgentsMainContract =
|
|
7831
|
+
var zeroAgentsMainContract = c27.router({
|
|
8045
7832
|
create: {
|
|
8046
7833
|
method: "POST",
|
|
8047
7834
|
path: "/api/zero/agents",
|
|
@@ -8056,12 +7843,12 @@ var zeroAgentsMainContract = c26.router({
|
|
|
8056
7843
|
summary: "Create zero agent"
|
|
8057
7844
|
}
|
|
8058
7845
|
});
|
|
8059
|
-
var zeroAgentsByNameContract =
|
|
7846
|
+
var zeroAgentsByNameContract = c27.router({
|
|
8060
7847
|
get: {
|
|
8061
7848
|
method: "GET",
|
|
8062
7849
|
path: "/api/zero/agents/:name",
|
|
8063
7850
|
headers: authHeadersSchema,
|
|
8064
|
-
pathParams:
|
|
7851
|
+
pathParams: z31.object({ name: z31.string() }),
|
|
8065
7852
|
responses: {
|
|
8066
7853
|
200: zeroAgentResponseSchema,
|
|
8067
7854
|
401: apiErrorSchema,
|
|
@@ -8073,7 +7860,7 @@ var zeroAgentsByNameContract = c26.router({
|
|
|
8073
7860
|
method: "PUT",
|
|
8074
7861
|
path: "/api/zero/agents/:name",
|
|
8075
7862
|
headers: authHeadersSchema,
|
|
8076
|
-
pathParams:
|
|
7863
|
+
pathParams: z31.object({ name: z31.string() }),
|
|
8077
7864
|
body: zeroAgentRequestSchema,
|
|
8078
7865
|
responses: {
|
|
8079
7866
|
200: zeroAgentResponseSchema,
|
|
@@ -8085,12 +7872,12 @@ var zeroAgentsByNameContract = c26.router({
|
|
|
8085
7872
|
summary: "Update zero agent"
|
|
8086
7873
|
}
|
|
8087
7874
|
});
|
|
8088
|
-
var zeroAgentInstructionsContract =
|
|
7875
|
+
var zeroAgentInstructionsContract = c27.router({
|
|
8089
7876
|
get: {
|
|
8090
7877
|
method: "GET",
|
|
8091
7878
|
path: "/api/zero/agents/:name/instructions",
|
|
8092
7879
|
headers: authHeadersSchema,
|
|
8093
|
-
pathParams:
|
|
7880
|
+
pathParams: z31.object({ name: z31.string() }),
|
|
8094
7881
|
responses: {
|
|
8095
7882
|
200: zeroAgentInstructionsResponseSchema,
|
|
8096
7883
|
401: apiErrorSchema,
|
|
@@ -8102,7 +7889,7 @@ var zeroAgentInstructionsContract = c26.router({
|
|
|
8102
7889
|
method: "PUT",
|
|
8103
7890
|
path: "/api/zero/agents/:name/instructions",
|
|
8104
7891
|
headers: authHeadersSchema,
|
|
8105
|
-
pathParams:
|
|
7892
|
+
pathParams: z31.object({ name: z31.string() }),
|
|
8106
7893
|
body: zeroAgentInstructionsRequestSchema,
|
|
8107
7894
|
responses: {
|
|
8108
7895
|
200: zeroAgentResponseSchema,
|
|
@@ -8115,9 +7902,9 @@ var zeroAgentInstructionsContract = c26.router({
|
|
|
8115
7902
|
});
|
|
8116
7903
|
|
|
8117
7904
|
// ../../packages/core/src/contracts/zero-connectors.ts
|
|
8118
|
-
import { z as
|
|
8119
|
-
var
|
|
8120
|
-
var zeroConnectorsMainContract =
|
|
7905
|
+
import { z as z32 } from "zod";
|
|
7906
|
+
var c28 = initContract();
|
|
7907
|
+
var zeroConnectorsMainContract = c28.router({
|
|
8121
7908
|
list: {
|
|
8122
7909
|
method: "GET",
|
|
8123
7910
|
path: "/api/zero/connectors",
|
|
@@ -8130,26 +7917,26 @@ var zeroConnectorsMainContract = c27.router({
|
|
|
8130
7917
|
summary: "List all connectors (zero proxy)"
|
|
8131
7918
|
}
|
|
8132
7919
|
});
|
|
8133
|
-
var zeroConnectorsByTypeContract =
|
|
7920
|
+
var zeroConnectorsByTypeContract = c28.router({
|
|
8134
7921
|
delete: {
|
|
8135
7922
|
method: "DELETE",
|
|
8136
7923
|
path: "/api/zero/connectors/:type",
|
|
8137
7924
|
headers: authHeadersSchema,
|
|
8138
|
-
pathParams:
|
|
7925
|
+
pathParams: z32.object({ type: connectorTypeSchema }),
|
|
8139
7926
|
responses: {
|
|
8140
|
-
204:
|
|
7927
|
+
204: c28.noBody(),
|
|
8141
7928
|
401: apiErrorSchema,
|
|
8142
7929
|
404: apiErrorSchema
|
|
8143
7930
|
},
|
|
8144
7931
|
summary: "Disconnect a connector (zero proxy)"
|
|
8145
7932
|
}
|
|
8146
7933
|
});
|
|
8147
|
-
var zeroConnectorScopeDiffContract =
|
|
7934
|
+
var zeroConnectorScopeDiffContract = c28.router({
|
|
8148
7935
|
getScopeDiff: {
|
|
8149
7936
|
method: "GET",
|
|
8150
7937
|
path: "/api/zero/connectors/:type/scope-diff",
|
|
8151
7938
|
headers: authHeadersSchema,
|
|
8152
|
-
pathParams:
|
|
7939
|
+
pathParams: z32.object({ type: connectorTypeSchema }),
|
|
8153
7940
|
responses: {
|
|
8154
7941
|
200: scopeDiffResponseSchema,
|
|
8155
7942
|
401: apiErrorSchema,
|
|
@@ -8160,8 +7947,8 @@ var zeroConnectorScopeDiffContract = c27.router({
|
|
|
8160
7947
|
});
|
|
8161
7948
|
|
|
8162
7949
|
// ../../packages/core/src/contracts/zero-org.ts
|
|
8163
|
-
var
|
|
8164
|
-
var zeroOrgContract =
|
|
7950
|
+
var c29 = initContract();
|
|
7951
|
+
var zeroOrgContract = c29.router({
|
|
8165
7952
|
get: {
|
|
8166
7953
|
method: "GET",
|
|
8167
7954
|
path: "/api/zero/org",
|
|
@@ -8176,16 +7963,16 @@ var zeroOrgContract = c28.router({
|
|
|
8176
7963
|
});
|
|
8177
7964
|
|
|
8178
7965
|
// ../../packages/core/src/contracts/zero-composes.ts
|
|
8179
|
-
import { z as
|
|
8180
|
-
var
|
|
8181
|
-
var zeroComposesMainContract =
|
|
7966
|
+
import { z as z33 } from "zod";
|
|
7967
|
+
var c30 = initContract();
|
|
7968
|
+
var zeroComposesMainContract = c30.router({
|
|
8182
7969
|
getByName: {
|
|
8183
7970
|
method: "GET",
|
|
8184
7971
|
path: "/api/zero/composes",
|
|
8185
7972
|
headers: authHeadersSchema,
|
|
8186
|
-
query:
|
|
8187
|
-
name:
|
|
8188
|
-
org:
|
|
7973
|
+
query: z33.object({
|
|
7974
|
+
name: z33.string().min(1, "Missing name query parameter"),
|
|
7975
|
+
org: z33.string().optional()
|
|
8189
7976
|
}),
|
|
8190
7977
|
responses: {
|
|
8191
7978
|
200: composeResponseSchema,
|
|
@@ -8196,13 +7983,13 @@ var zeroComposesMainContract = c29.router({
|
|
|
8196
7983
|
summary: "Get agent compose by name (zero proxy)"
|
|
8197
7984
|
}
|
|
8198
7985
|
});
|
|
8199
|
-
var zeroComposesByIdContract =
|
|
7986
|
+
var zeroComposesByIdContract = c30.router({
|
|
8200
7987
|
getById: {
|
|
8201
7988
|
method: "GET",
|
|
8202
7989
|
path: "/api/zero/composes/:id",
|
|
8203
7990
|
headers: authHeadersSchema,
|
|
8204
|
-
pathParams:
|
|
8205
|
-
id:
|
|
7991
|
+
pathParams: z33.object({
|
|
7992
|
+
id: z33.string().min(1, "Compose ID is required")
|
|
8206
7993
|
}),
|
|
8207
7994
|
responses: {
|
|
8208
7995
|
200: composeResponseSchema,
|
|
@@ -8216,12 +8003,12 @@ var zeroComposesByIdContract = c29.router({
|
|
|
8216
8003
|
method: "DELETE",
|
|
8217
8004
|
path: "/api/zero/composes/:id",
|
|
8218
8005
|
headers: authHeadersSchema,
|
|
8219
|
-
pathParams:
|
|
8220
|
-
id:
|
|
8006
|
+
pathParams: z33.object({
|
|
8007
|
+
id: z33.string().uuid("Compose ID is required")
|
|
8221
8008
|
}),
|
|
8222
|
-
body:
|
|
8009
|
+
body: c30.noBody(),
|
|
8223
8010
|
responses: {
|
|
8224
|
-
204:
|
|
8011
|
+
204: c30.noBody(),
|
|
8225
8012
|
401: apiErrorSchema,
|
|
8226
8013
|
403: apiErrorSchema,
|
|
8227
8014
|
404: apiErrorSchema,
|
|
@@ -8230,17 +8017,17 @@ var zeroComposesByIdContract = c29.router({
|
|
|
8230
8017
|
summary: "Delete agent compose (zero proxy)"
|
|
8231
8018
|
}
|
|
8232
8019
|
});
|
|
8233
|
-
var zeroComposesListContract =
|
|
8020
|
+
var zeroComposesListContract = c30.router({
|
|
8234
8021
|
list: {
|
|
8235
8022
|
method: "GET",
|
|
8236
8023
|
path: "/api/zero/composes/list",
|
|
8237
8024
|
headers: authHeadersSchema,
|
|
8238
|
-
query:
|
|
8239
|
-
org:
|
|
8025
|
+
query: z33.object({
|
|
8026
|
+
org: z33.string().optional()
|
|
8240
8027
|
}),
|
|
8241
8028
|
responses: {
|
|
8242
|
-
200:
|
|
8243
|
-
composes:
|
|
8029
|
+
200: z33.object({
|
|
8030
|
+
composes: z33.array(composeListItemSchema)
|
|
8244
8031
|
}),
|
|
8245
8032
|
400: apiErrorSchema,
|
|
8246
8033
|
401: apiErrorSchema,
|
|
@@ -8251,12 +8038,12 @@ var zeroComposesListContract = c29.router({
|
|
|
8251
8038
|
});
|
|
8252
8039
|
|
|
8253
8040
|
// ../../packages/core/src/contracts/zero-runs.ts
|
|
8254
|
-
import { z as
|
|
8041
|
+
import { z as z34 } from "zod";
|
|
8255
8042
|
var zeroRunRequestSchema = unifiedRunRequestSchema.omit({
|
|
8256
8043
|
triggerSource: true
|
|
8257
8044
|
});
|
|
8258
|
-
var
|
|
8259
|
-
var zeroRunsMainContract =
|
|
8045
|
+
var c31 = initContract();
|
|
8046
|
+
var zeroRunsMainContract = c31.router({
|
|
8260
8047
|
create: {
|
|
8261
8048
|
method: "POST",
|
|
8262
8049
|
path: "/api/zero/runs",
|
|
@@ -8272,13 +8059,13 @@ var zeroRunsMainContract = c30.router({
|
|
|
8272
8059
|
summary: "Create and execute agent run (zero proxy)"
|
|
8273
8060
|
}
|
|
8274
8061
|
});
|
|
8275
|
-
var zeroRunsByIdContract =
|
|
8062
|
+
var zeroRunsByIdContract = c31.router({
|
|
8276
8063
|
getById: {
|
|
8277
8064
|
method: "GET",
|
|
8278
8065
|
path: "/api/zero/runs/:id",
|
|
8279
8066
|
headers: authHeadersSchema,
|
|
8280
|
-
pathParams:
|
|
8281
|
-
id:
|
|
8067
|
+
pathParams: z34.object({
|
|
8068
|
+
id: z34.string().min(1, "Run ID is required")
|
|
8282
8069
|
}),
|
|
8283
8070
|
responses: {
|
|
8284
8071
|
200: getRunResponseSchema,
|
|
@@ -8289,15 +8076,15 @@ var zeroRunsByIdContract = c30.router({
|
|
|
8289
8076
|
summary: "Get agent run by ID (zero proxy)"
|
|
8290
8077
|
}
|
|
8291
8078
|
});
|
|
8292
|
-
var zeroRunsCancelContract =
|
|
8079
|
+
var zeroRunsCancelContract = c31.router({
|
|
8293
8080
|
cancel: {
|
|
8294
8081
|
method: "POST",
|
|
8295
8082
|
path: "/api/zero/runs/:id/cancel",
|
|
8296
8083
|
headers: authHeadersSchema,
|
|
8297
|
-
pathParams:
|
|
8298
|
-
id:
|
|
8084
|
+
pathParams: z34.object({
|
|
8085
|
+
id: z34.string().min(1, "Run ID is required")
|
|
8299
8086
|
}),
|
|
8300
|
-
body:
|
|
8087
|
+
body: z34.undefined(),
|
|
8301
8088
|
responses: {
|
|
8302
8089
|
200: cancelRunResponseSchema,
|
|
8303
8090
|
400: apiErrorSchema,
|
|
@@ -8308,7 +8095,7 @@ var zeroRunsCancelContract = c30.router({
|
|
|
8308
8095
|
summary: "Cancel a pending or running run (zero proxy)"
|
|
8309
8096
|
}
|
|
8310
8097
|
});
|
|
8311
|
-
var zeroRunsQueueContract =
|
|
8098
|
+
var zeroRunsQueueContract = c31.router({
|
|
8312
8099
|
getQueue: {
|
|
8313
8100
|
method: "GET",
|
|
8314
8101
|
path: "/api/zero/runs/queue",
|
|
@@ -8321,18 +8108,18 @@ var zeroRunsQueueContract = c30.router({
|
|
|
8321
8108
|
summary: "Get org run queue status (zero proxy)"
|
|
8322
8109
|
}
|
|
8323
8110
|
});
|
|
8324
|
-
var zeroRunAgentEventsContract =
|
|
8111
|
+
var zeroRunAgentEventsContract = c31.router({
|
|
8325
8112
|
getAgentEvents: {
|
|
8326
8113
|
method: "GET",
|
|
8327
8114
|
path: "/api/zero/runs/:id/telemetry/agent",
|
|
8328
8115
|
headers: authHeadersSchema,
|
|
8329
|
-
pathParams:
|
|
8330
|
-
id:
|
|
8116
|
+
pathParams: z34.object({
|
|
8117
|
+
id: z34.string().min(1, "Run ID is required")
|
|
8331
8118
|
}),
|
|
8332
|
-
query:
|
|
8333
|
-
since:
|
|
8334
|
-
limit:
|
|
8335
|
-
order:
|
|
8119
|
+
query: z34.object({
|
|
8120
|
+
since: z34.coerce.number().optional(),
|
|
8121
|
+
limit: z34.coerce.number().min(1).max(100).default(5),
|
|
8122
|
+
order: z34.enum(["asc", "desc"]).default("desc")
|
|
8336
8123
|
}),
|
|
8337
8124
|
responses: {
|
|
8338
8125
|
200: agentEventsResponseSchema,
|
|
@@ -8344,9 +8131,9 @@ var zeroRunAgentEventsContract = c30.router({
|
|
|
8344
8131
|
});
|
|
8345
8132
|
|
|
8346
8133
|
// ../../packages/core/src/contracts/zero-schedules.ts
|
|
8347
|
-
import { z as
|
|
8348
|
-
var
|
|
8349
|
-
var zeroSchedulesMainContract =
|
|
8134
|
+
import { z as z35 } from "zod";
|
|
8135
|
+
var c32 = initContract();
|
|
8136
|
+
var zeroSchedulesMainContract = c32.router({
|
|
8350
8137
|
deploy: {
|
|
8351
8138
|
method: "POST",
|
|
8352
8139
|
path: "/api/zero/schedules",
|
|
@@ -8374,19 +8161,19 @@ var zeroSchedulesMainContract = c31.router({
|
|
|
8374
8161
|
summary: "List all schedules (zero proxy)"
|
|
8375
8162
|
}
|
|
8376
8163
|
});
|
|
8377
|
-
var zeroSchedulesByNameContract =
|
|
8164
|
+
var zeroSchedulesByNameContract = c32.router({
|
|
8378
8165
|
delete: {
|
|
8379
8166
|
method: "DELETE",
|
|
8380
8167
|
path: "/api/zero/schedules/:name",
|
|
8381
8168
|
headers: authHeadersSchema,
|
|
8382
|
-
pathParams:
|
|
8383
|
-
name:
|
|
8169
|
+
pathParams: z35.object({
|
|
8170
|
+
name: z35.string().min(1, "Schedule name required")
|
|
8384
8171
|
}),
|
|
8385
|
-
query:
|
|
8386
|
-
composeId:
|
|
8172
|
+
query: z35.object({
|
|
8173
|
+
composeId: z35.string().uuid("Compose ID required")
|
|
8387
8174
|
}),
|
|
8388
8175
|
responses: {
|
|
8389
|
-
204:
|
|
8176
|
+
204: c32.noBody(),
|
|
8390
8177
|
401: apiErrorSchema,
|
|
8391
8178
|
403: apiErrorSchema,
|
|
8392
8179
|
404: apiErrorSchema
|
|
@@ -8394,16 +8181,16 @@ var zeroSchedulesByNameContract = c31.router({
|
|
|
8394
8181
|
summary: "Delete schedule (zero proxy)"
|
|
8395
8182
|
}
|
|
8396
8183
|
});
|
|
8397
|
-
var zeroSchedulesEnableContract =
|
|
8184
|
+
var zeroSchedulesEnableContract = c32.router({
|
|
8398
8185
|
enable: {
|
|
8399
8186
|
method: "POST",
|
|
8400
8187
|
path: "/api/zero/schedules/:name/enable",
|
|
8401
8188
|
headers: authHeadersSchema,
|
|
8402
|
-
pathParams:
|
|
8403
|
-
name:
|
|
8189
|
+
pathParams: z35.object({
|
|
8190
|
+
name: z35.string().min(1, "Schedule name required")
|
|
8404
8191
|
}),
|
|
8405
|
-
body:
|
|
8406
|
-
composeId:
|
|
8192
|
+
body: z35.object({
|
|
8193
|
+
composeId: z35.string().uuid("Compose ID required")
|
|
8407
8194
|
}),
|
|
8408
8195
|
responses: {
|
|
8409
8196
|
200: scheduleResponseSchema,
|
|
@@ -8418,11 +8205,11 @@ var zeroSchedulesEnableContract = c31.router({
|
|
|
8418
8205
|
method: "POST",
|
|
8419
8206
|
path: "/api/zero/schedules/:name/disable",
|
|
8420
8207
|
headers: authHeadersSchema,
|
|
8421
|
-
pathParams:
|
|
8422
|
-
name:
|
|
8208
|
+
pathParams: z35.object({
|
|
8209
|
+
name: z35.string().min(1, "Schedule name required")
|
|
8423
8210
|
}),
|
|
8424
|
-
body:
|
|
8425
|
-
composeId:
|
|
8211
|
+
body: z35.object({
|
|
8212
|
+
composeId: z35.string().uuid("Compose ID required")
|
|
8426
8213
|
}),
|
|
8427
8214
|
responses: {
|
|
8428
8215
|
200: scheduleResponseSchema,
|
|
@@ -8436,9 +8223,9 @@ var zeroSchedulesEnableContract = c31.router({
|
|
|
8436
8223
|
});
|
|
8437
8224
|
|
|
8438
8225
|
// ../../packages/core/src/contracts/zero-model-providers.ts
|
|
8439
|
-
import { z as
|
|
8440
|
-
var
|
|
8441
|
-
var zeroModelProvidersMainContract =
|
|
8226
|
+
import { z as z36 } from "zod";
|
|
8227
|
+
var c33 = initContract();
|
|
8228
|
+
var zeroModelProvidersMainContract = c33.router({
|
|
8442
8229
|
list: {
|
|
8443
8230
|
method: "GET",
|
|
8444
8231
|
path: "/api/zero/model-providers",
|
|
@@ -8466,16 +8253,16 @@ var zeroModelProvidersMainContract = c32.router({
|
|
|
8466
8253
|
summary: "Create or update an org-level model provider (admin only)"
|
|
8467
8254
|
}
|
|
8468
8255
|
});
|
|
8469
|
-
var zeroModelProvidersByTypeContract =
|
|
8256
|
+
var zeroModelProvidersByTypeContract = c33.router({
|
|
8470
8257
|
delete: {
|
|
8471
8258
|
method: "DELETE",
|
|
8472
8259
|
path: "/api/zero/model-providers/:type",
|
|
8473
8260
|
headers: authHeadersSchema,
|
|
8474
|
-
pathParams:
|
|
8261
|
+
pathParams: z36.object({
|
|
8475
8262
|
type: modelProviderTypeSchema
|
|
8476
8263
|
}),
|
|
8477
8264
|
responses: {
|
|
8478
|
-
204:
|
|
8265
|
+
204: c33.noBody(),
|
|
8479
8266
|
401: apiErrorSchema,
|
|
8480
8267
|
403: apiErrorSchema,
|
|
8481
8268
|
404: apiErrorSchema,
|
|
@@ -8484,15 +8271,15 @@ var zeroModelProvidersByTypeContract = c32.router({
|
|
|
8484
8271
|
summary: "Delete an org-level model provider (admin only)"
|
|
8485
8272
|
}
|
|
8486
8273
|
});
|
|
8487
|
-
var zeroModelProvidersDefaultContract =
|
|
8274
|
+
var zeroModelProvidersDefaultContract = c33.router({
|
|
8488
8275
|
setDefault: {
|
|
8489
8276
|
method: "POST",
|
|
8490
8277
|
path: "/api/zero/model-providers/:type/default",
|
|
8491
8278
|
headers: authHeadersSchema,
|
|
8492
|
-
pathParams:
|
|
8279
|
+
pathParams: z36.object({
|
|
8493
8280
|
type: modelProviderTypeSchema
|
|
8494
8281
|
}),
|
|
8495
|
-
body:
|
|
8282
|
+
body: z36.undefined(),
|
|
8496
8283
|
responses: {
|
|
8497
8284
|
200: modelProviderResponseSchema,
|
|
8498
8285
|
401: apiErrorSchema,
|
|
@@ -8505,8 +8292,8 @@ var zeroModelProvidersDefaultContract = c32.router({
|
|
|
8505
8292
|
});
|
|
8506
8293
|
|
|
8507
8294
|
// ../../packages/core/src/contracts/zero-user-preferences.ts
|
|
8508
|
-
var
|
|
8509
|
-
var zeroUserPreferencesContract =
|
|
8295
|
+
var c34 = initContract();
|
|
8296
|
+
var zeroUserPreferencesContract = c34.router({
|
|
8510
8297
|
get: {
|
|
8511
8298
|
method: "GET",
|
|
8512
8299
|
path: "/api/zero/user-preferences",
|
|
@@ -8534,8 +8321,8 @@ var zeroUserPreferencesContract = c33.router({
|
|
|
8534
8321
|
});
|
|
8535
8322
|
|
|
8536
8323
|
// ../../packages/core/src/contracts/zero-secrets.ts
|
|
8537
|
-
var
|
|
8538
|
-
var zeroSecretsContract =
|
|
8324
|
+
var c35 = initContract();
|
|
8325
|
+
var zeroSecretsContract = c35.router({
|
|
8539
8326
|
set: {
|
|
8540
8327
|
method: "POST",
|
|
8541
8328
|
path: "/api/zero/secrets",
|
|
@@ -8551,7 +8338,7 @@ var zeroSecretsContract = c34.router({
|
|
|
8551
8338
|
summary: "Create or update a secret"
|
|
8552
8339
|
}
|
|
8553
8340
|
});
|
|
8554
|
-
var zeroVariablesContract =
|
|
8341
|
+
var zeroVariablesContract = c35.router({
|
|
8555
8342
|
set: {
|
|
8556
8343
|
method: "POST",
|
|
8557
8344
|
path: "/api/zero/variables",
|
|
@@ -8569,15 +8356,15 @@ var zeroVariablesContract = c34.router({
|
|
|
8569
8356
|
});
|
|
8570
8357
|
|
|
8571
8358
|
// ../../packages/core/src/contracts/zero-sessions.ts
|
|
8572
|
-
import { z as
|
|
8573
|
-
var
|
|
8574
|
-
var zeroSessionsByIdContract =
|
|
8359
|
+
import { z as z37 } from "zod";
|
|
8360
|
+
var c36 = initContract();
|
|
8361
|
+
var zeroSessionsByIdContract = c36.router({
|
|
8575
8362
|
getById: {
|
|
8576
8363
|
method: "GET",
|
|
8577
8364
|
path: "/api/zero/sessions/:id",
|
|
8578
8365
|
headers: authHeadersSchema,
|
|
8579
|
-
pathParams:
|
|
8580
|
-
id:
|
|
8366
|
+
pathParams: z37.object({
|
|
8367
|
+
id: z37.string().min(1, "Session ID is required")
|
|
8581
8368
|
}),
|
|
8582
8369
|
responses: {
|
|
8583
8370
|
200: sessionResponseSchema,
|
|
@@ -8589,6 +8376,35 @@ var zeroSessionsByIdContract = c35.router({
|
|
|
8589
8376
|
}
|
|
8590
8377
|
});
|
|
8591
8378
|
|
|
8379
|
+
// ../../packages/core/src/contracts/integrations.ts
|
|
8380
|
+
import { z as z38 } from "zod";
|
|
8381
|
+
var c37 = initContract();
|
|
8382
|
+
var integrationsSlackMessageContract = c37.router({
|
|
8383
|
+
sendMessage: {
|
|
8384
|
+
method: "POST",
|
|
8385
|
+
path: "/api/agent/integrations/slack/message",
|
|
8386
|
+
headers: authHeadersSchema,
|
|
8387
|
+
body: z38.object({
|
|
8388
|
+
channel: z38.string().min(1, "Channel ID is required"),
|
|
8389
|
+
text: z38.string().optional(),
|
|
8390
|
+
threadTs: z38.string().optional(),
|
|
8391
|
+
blocks: z38.array(z38.object({ type: z38.string() }).passthrough()).optional()
|
|
8392
|
+
}),
|
|
8393
|
+
responses: {
|
|
8394
|
+
200: z38.object({
|
|
8395
|
+
ok: z38.literal(true),
|
|
8396
|
+
ts: z38.string().optional(),
|
|
8397
|
+
channel: z38.string().optional()
|
|
8398
|
+
}),
|
|
8399
|
+
400: apiErrorSchema,
|
|
8400
|
+
401: apiErrorSchema,
|
|
8401
|
+
403: apiErrorSchema,
|
|
8402
|
+
404: apiErrorSchema
|
|
8403
|
+
},
|
|
8404
|
+
summary: "Send a Slack message via org bot token"
|
|
8405
|
+
}
|
|
8406
|
+
});
|
|
8407
|
+
|
|
8592
8408
|
// ../../packages/core/src/storage-names.ts
|
|
8593
8409
|
function getInstructionsStorageName(agentName) {
|
|
8594
8410
|
return `agent-instructions@${agentName}`;
|
|
@@ -8848,46 +8664,422 @@ var FEATURE_SWITCHES = {
|
|
|
8848
8664
|
enabled: false,
|
|
8849
8665
|
enabledUserHashes: STAFF_USER_HASHES
|
|
8850
8666
|
}
|
|
8851
|
-
};
|
|
8852
|
-
async function isFeatureEnabled(key, userId, email) {
|
|
8853
|
-
const featureSwitch = FEATURE_SWITCHES[key];
|
|
8854
|
-
if (featureSwitch.enabled) {
|
|
8855
|
-
return true;
|
|
8667
|
+
};
|
|
8668
|
+
async function isFeatureEnabled(key, userId, email) {
|
|
8669
|
+
const featureSwitch = FEATURE_SWITCHES[key];
|
|
8670
|
+
if (featureSwitch.enabled) {
|
|
8671
|
+
return true;
|
|
8672
|
+
}
|
|
8673
|
+
if (userId && featureSwitch.enabledUserHashes?.length) {
|
|
8674
|
+
const hash = await sha1(userId);
|
|
8675
|
+
if (featureSwitch.enabledUserHashes.includes(hash)) return true;
|
|
8676
|
+
}
|
|
8677
|
+
if (email && featureSwitch.enabledEmailHashes?.length) {
|
|
8678
|
+
const hash = await sha1(email.toLowerCase());
|
|
8679
|
+
if (featureSwitch.enabledEmailHashes.includes(hash)) return true;
|
|
8680
|
+
}
|
|
8681
|
+
return false;
|
|
8682
|
+
}
|
|
8683
|
+
|
|
8684
|
+
// ../../packages/core/src/skill-frontmatter.ts
|
|
8685
|
+
import { parse as parseYaml2 } from "yaml";
|
|
8686
|
+
function parseSkillFrontmatter(content) {
|
|
8687
|
+
const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
8688
|
+
if (!frontmatterMatch) {
|
|
8689
|
+
return {};
|
|
8690
|
+
}
|
|
8691
|
+
const yamlContent = frontmatterMatch[1];
|
|
8692
|
+
if (!yamlContent) {
|
|
8693
|
+
return {};
|
|
8694
|
+
}
|
|
8695
|
+
const parsed = parseYaml2(yamlContent);
|
|
8696
|
+
if (!parsed || typeof parsed !== "object") {
|
|
8697
|
+
return {};
|
|
8698
|
+
}
|
|
8699
|
+
const data = parsed;
|
|
8700
|
+
return {
|
|
8701
|
+
name: typeof data.name === "string" ? data.name : void 0,
|
|
8702
|
+
description: typeof data.description === "string" ? data.description : void 0,
|
|
8703
|
+
vm0_secrets: Array.isArray(data.vm0_secrets) ? data.vm0_secrets.filter((s) => typeof s === "string") : void 0,
|
|
8704
|
+
vm0_vars: Array.isArray(data.vm0_vars) ? data.vm0_vars.filter((s) => typeof s === "string") : void 0
|
|
8705
|
+
};
|
|
8706
|
+
}
|
|
8707
|
+
|
|
8708
|
+
// src/lib/api/core/client-factory.ts
|
|
8709
|
+
import { tsRestFetchApi } from "@ts-rest/core";
|
|
8710
|
+
var ApiRequestError = class extends Error {
|
|
8711
|
+
constructor(message, code, status) {
|
|
8712
|
+
super(message);
|
|
8713
|
+
this.code = code;
|
|
8714
|
+
this.status = status;
|
|
8715
|
+
this.name = "ApiRequestError";
|
|
8716
|
+
}
|
|
8717
|
+
};
|
|
8718
|
+
async function getHeaders() {
|
|
8719
|
+
const token = await getActiveToken();
|
|
8720
|
+
if (!token) {
|
|
8721
|
+
throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
|
|
8722
|
+
}
|
|
8723
|
+
const headers = {
|
|
8724
|
+
Authorization: `Bearer ${token}`
|
|
8725
|
+
};
|
|
8726
|
+
const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
|
|
8727
|
+
if (bypassSecret) {
|
|
8728
|
+
headers["x-vercel-protection-bypass"] = bypassSecret;
|
|
8729
|
+
}
|
|
8730
|
+
return headers;
|
|
8731
|
+
}
|
|
8732
|
+
async function getBaseUrl() {
|
|
8733
|
+
const apiUrl = await getApiUrl();
|
|
8734
|
+
if (!apiUrl) {
|
|
8735
|
+
throw new Error("API URL not configured");
|
|
8736
|
+
}
|
|
8737
|
+
return apiUrl;
|
|
8738
|
+
}
|
|
8739
|
+
async function getClientConfig() {
|
|
8740
|
+
const baseUrl = await getBaseUrl();
|
|
8741
|
+
const baseHeaders = await getHeaders();
|
|
8742
|
+
const activeOrg = await getActiveOrg();
|
|
8743
|
+
if (!activeOrg) {
|
|
8744
|
+
throw new Error(
|
|
8745
|
+
"No active organization configured. Run: vm0 org use <slug>"
|
|
8746
|
+
);
|
|
8747
|
+
}
|
|
8748
|
+
return {
|
|
8749
|
+
baseUrl,
|
|
8750
|
+
baseHeaders,
|
|
8751
|
+
jsonQuery: false,
|
|
8752
|
+
api: async (args) => {
|
|
8753
|
+
const separator = args.path.includes("?") ? "&" : "?";
|
|
8754
|
+
if (!args.path.includes("org=")) {
|
|
8755
|
+
args.path = `${args.path}${separator}org=${encodeURIComponent(activeOrg)}`;
|
|
8756
|
+
}
|
|
8757
|
+
return tsRestFetchApi(args);
|
|
8758
|
+
}
|
|
8759
|
+
};
|
|
8760
|
+
}
|
|
8761
|
+
function handleError(result, defaultMessage) {
|
|
8762
|
+
const errorBody = result.body;
|
|
8763
|
+
const message = errorBody.error?.message || defaultMessage;
|
|
8764
|
+
const code = errorBody.error?.code || "UNKNOWN";
|
|
8765
|
+
throw new ApiRequestError(message, code, result.status);
|
|
8766
|
+
}
|
|
8767
|
+
|
|
8768
|
+
// src/lib/command/with-error-handler.ts
|
|
8769
|
+
function withErrorHandler(fn) {
|
|
8770
|
+
return async (...args) => {
|
|
8771
|
+
try {
|
|
8772
|
+
await fn(...args);
|
|
8773
|
+
} catch (error) {
|
|
8774
|
+
if (error instanceof ApiRequestError) {
|
|
8775
|
+
if (error.code === "UNAUTHORIZED") {
|
|
8776
|
+
console.error(chalk2.red("\u2717 Not authenticated"));
|
|
8777
|
+
console.error(chalk2.dim(" Run: vm0 auth login"));
|
|
8778
|
+
} else {
|
|
8779
|
+
const guidance = RUN_ERROR_GUIDANCE[error.code];
|
|
8780
|
+
if (guidance) {
|
|
8781
|
+
console.error(chalk2.red(`\u2717 ${guidance.title}`));
|
|
8782
|
+
console.error(chalk2.dim(` ${guidance.guidance}`));
|
|
8783
|
+
if (guidance.cliHint) {
|
|
8784
|
+
console.error(chalk2.dim(` Run: ${guidance.cliHint}`));
|
|
8785
|
+
}
|
|
8786
|
+
} else {
|
|
8787
|
+
console.error(chalk2.red(`\u2717 ${error.status}: ${error.message}`));
|
|
8788
|
+
}
|
|
8789
|
+
}
|
|
8790
|
+
} else if (error instanceof Error) {
|
|
8791
|
+
console.error(chalk2.red(`\u2717 ${error.message}`));
|
|
8792
|
+
} else {
|
|
8793
|
+
console.error(chalk2.red("\u2717 An unexpected error occurred"));
|
|
8794
|
+
}
|
|
8795
|
+
if (error instanceof Error && error.cause instanceof Error) {
|
|
8796
|
+
console.error(chalk2.dim(` Cause: ${error.cause.message}`));
|
|
8797
|
+
}
|
|
8798
|
+
process.exit(1);
|
|
8799
|
+
}
|
|
8800
|
+
};
|
|
8801
|
+
}
|
|
8802
|
+
|
|
8803
|
+
// src/commands/auth/login.ts
|
|
8804
|
+
var loginCommand = new Command().name("login").description("Log in to VM0 (use VM0_API_URL env var to set API URL)").action(
|
|
8805
|
+
withErrorHandler(async () => {
|
|
8806
|
+
await authenticate();
|
|
8807
|
+
})
|
|
8808
|
+
);
|
|
8809
|
+
|
|
8810
|
+
// src/commands/auth/logout.ts
|
|
8811
|
+
import { Command as Command2 } from "commander";
|
|
8812
|
+
var logoutCommand = new Command2().name("logout").description("Log out of VM0").action(
|
|
8813
|
+
withErrorHandler(async () => {
|
|
8814
|
+
await logout();
|
|
8815
|
+
})
|
|
8816
|
+
);
|
|
8817
|
+
|
|
8818
|
+
// src/commands/auth/status.ts
|
|
8819
|
+
import { Command as Command3 } from "commander";
|
|
8820
|
+
var statusCommand = new Command3().name("status").description("Show current authentication status").action(
|
|
8821
|
+
withErrorHandler(async () => {
|
|
8822
|
+
await checkAuthStatus();
|
|
8823
|
+
})
|
|
8824
|
+
);
|
|
8825
|
+
|
|
8826
|
+
// src/commands/auth/setup-token.ts
|
|
8827
|
+
import { Command as Command4 } from "commander";
|
|
8828
|
+
var setupTokenCommand = new Command4().name("setup-token").description("Output auth token for CI/CD environments").action(
|
|
8829
|
+
withErrorHandler(async () => {
|
|
8830
|
+
await setupToken();
|
|
8831
|
+
})
|
|
8832
|
+
);
|
|
8833
|
+
|
|
8834
|
+
// src/commands/auth/index.ts
|
|
8835
|
+
var authCommand = new Command5().name("auth").description("Authenticate vm0").addCommand(loginCommand).addCommand(logoutCommand).addCommand(statusCommand).addCommand(setupTokenCommand);
|
|
8836
|
+
|
|
8837
|
+
// src/commands/info/index.ts
|
|
8838
|
+
import { Command as Command6 } from "commander";
|
|
8839
|
+
import chalk4 from "chalk";
|
|
8840
|
+
import { existsSync as existsSync2 } from "fs";
|
|
8841
|
+
import { homedir as homedir2, release as release2, type } from "os";
|
|
8842
|
+
import { join as join2 } from "path";
|
|
8843
|
+
|
|
8844
|
+
// src/lib/utils/update-checker.ts
|
|
8845
|
+
import chalk3 from "chalk";
|
|
8846
|
+
|
|
8847
|
+
// src/lib/utils/spawn.ts
|
|
8848
|
+
import { spawn } from "child_process";
|
|
8849
|
+
function safeSpawn(command, args, options) {
|
|
8850
|
+
const isWindows = process.platform === "win32";
|
|
8851
|
+
const resolvedCommand = isWindows ? `${command}.cmd` : command;
|
|
8852
|
+
return spawn(resolvedCommand, args, {
|
|
8853
|
+
...options,
|
|
8854
|
+
shell: isWindows
|
|
8855
|
+
});
|
|
8856
|
+
}
|
|
8857
|
+
|
|
8858
|
+
// src/lib/utils/update-checker.ts
|
|
8859
|
+
var PACKAGE_NAME = "@vm0/cli";
|
|
8860
|
+
var NPM_REGISTRY_URL = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME)}/latest`;
|
|
8861
|
+
var TIMEOUT_MS = 5e3;
|
|
8862
|
+
var pendingUpgrade = null;
|
|
8863
|
+
function detectPackageManager() {
|
|
8864
|
+
const execPath = process.argv[1] ?? "";
|
|
8865
|
+
if (execPath.includes("pnpm")) {
|
|
8866
|
+
return "pnpm";
|
|
8867
|
+
}
|
|
8868
|
+
if (execPath.includes("/.bun/") || execPath.includes("/bun/")) {
|
|
8869
|
+
return "bun";
|
|
8856
8870
|
}
|
|
8857
|
-
if (
|
|
8858
|
-
|
|
8859
|
-
if (featureSwitch.enabledUserHashes.includes(hash)) return true;
|
|
8871
|
+
if (execPath.includes("/.yarn/") || execPath.includes("/yarn/")) {
|
|
8872
|
+
return "yarn";
|
|
8860
8873
|
}
|
|
8861
|
-
if (
|
|
8862
|
-
|
|
8863
|
-
|
|
8874
|
+
if (execPath.includes("/usr/local/") || // Homebrew on Intel Mac
|
|
8875
|
+
execPath.includes("/opt/homebrew/") || // Homebrew on arm64 Mac
|
|
8876
|
+
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
|
|
8877
|
+
execPath.includes("\\nodejs\\")) {
|
|
8878
|
+
return "npm";
|
|
8864
8879
|
}
|
|
8865
|
-
return
|
|
8880
|
+
return "unknown";
|
|
8866
8881
|
}
|
|
8867
|
-
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
function
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8882
|
+
function isAutoUpgradeSupported(pm) {
|
|
8883
|
+
return pm === "npm" || pm === "pnpm";
|
|
8884
|
+
}
|
|
8885
|
+
function getManualUpgradeCommand(pm) {
|
|
8886
|
+
switch (pm) {
|
|
8887
|
+
case "bun":
|
|
8888
|
+
return `bun add -g ${PACKAGE_NAME}@latest`;
|
|
8889
|
+
case "yarn":
|
|
8890
|
+
return `yarn global add ${PACKAGE_NAME}@latest`;
|
|
8891
|
+
case "pnpm":
|
|
8892
|
+
return `pnpm add -g ${PACKAGE_NAME}@latest`;
|
|
8893
|
+
case "npm":
|
|
8894
|
+
return `npm install -g ${PACKAGE_NAME}@latest`;
|
|
8895
|
+
case "unknown":
|
|
8896
|
+
return `npm install -g ${PACKAGE_NAME}@latest`;
|
|
8874
8897
|
}
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8898
|
+
}
|
|
8899
|
+
function escapeForShell(str) {
|
|
8900
|
+
return `'${str.replace(/'/g, "'\\''")}'`;
|
|
8901
|
+
}
|
|
8902
|
+
function buildRerunCommand(prompt) {
|
|
8903
|
+
if (prompt) {
|
|
8904
|
+
return `vm0 cook ${escapeForShell(prompt)}`;
|
|
8878
8905
|
}
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8906
|
+
return "vm0 cook";
|
|
8907
|
+
}
|
|
8908
|
+
async function getLatestVersion() {
|
|
8909
|
+
try {
|
|
8910
|
+
const controller = new AbortController();
|
|
8911
|
+
const timeoutId = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
8912
|
+
const response = await fetch(NPM_REGISTRY_URL, {
|
|
8913
|
+
signal: controller.signal
|
|
8914
|
+
});
|
|
8915
|
+
clearTimeout(timeoutId);
|
|
8916
|
+
if (!response.ok) {
|
|
8917
|
+
return null;
|
|
8918
|
+
}
|
|
8919
|
+
const json = await response.json();
|
|
8920
|
+
return json.version ?? null;
|
|
8921
|
+
} catch {
|
|
8922
|
+
return null;
|
|
8882
8923
|
}
|
|
8883
|
-
const data = parsed;
|
|
8884
|
-
return {
|
|
8885
|
-
name: typeof data.name === "string" ? data.name : void 0,
|
|
8886
|
-
description: typeof data.description === "string" ? data.description : void 0,
|
|
8887
|
-
vm0_secrets: Array.isArray(data.vm0_secrets) ? data.vm0_secrets.filter((s) => typeof s === "string") : void 0,
|
|
8888
|
-
vm0_vars: Array.isArray(data.vm0_vars) ? data.vm0_vars.filter((s) => typeof s === "string") : void 0
|
|
8889
|
-
};
|
|
8890
8924
|
}
|
|
8925
|
+
function performUpgrade(packageManager) {
|
|
8926
|
+
return new Promise((resolve2) => {
|
|
8927
|
+
const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
|
|
8928
|
+
const child = safeSpawn(packageManager, args, {
|
|
8929
|
+
stdio: "inherit"
|
|
8930
|
+
});
|
|
8931
|
+
child.on("close", (code) => {
|
|
8932
|
+
resolve2(code === 0);
|
|
8933
|
+
});
|
|
8934
|
+
child.on("error", () => {
|
|
8935
|
+
resolve2(false);
|
|
8936
|
+
});
|
|
8937
|
+
});
|
|
8938
|
+
}
|
|
8939
|
+
async function checkAndUpgrade(currentVersion, prompt) {
|
|
8940
|
+
const latestVersion = await getLatestVersion();
|
|
8941
|
+
if (latestVersion === null) {
|
|
8942
|
+
console.log(chalk3.yellow("\u26A0 Could not check for updates"));
|
|
8943
|
+
console.log();
|
|
8944
|
+
return false;
|
|
8945
|
+
}
|
|
8946
|
+
if (latestVersion === currentVersion) {
|
|
8947
|
+
return false;
|
|
8948
|
+
}
|
|
8949
|
+
console.log(chalk3.yellow("vm0 is currently in beta."));
|
|
8950
|
+
console.log(
|
|
8951
|
+
chalk3.yellow(
|
|
8952
|
+
`Current version: ${currentVersion} -> Latest version: ${latestVersion}`
|
|
8953
|
+
)
|
|
8954
|
+
);
|
|
8955
|
+
console.log(
|
|
8956
|
+
chalk3.yellow(
|
|
8957
|
+
"Please always use the latest version for best compatibility."
|
|
8958
|
+
)
|
|
8959
|
+
);
|
|
8960
|
+
console.log();
|
|
8961
|
+
const packageManager = detectPackageManager();
|
|
8962
|
+
if (!isAutoUpgradeSupported(packageManager)) {
|
|
8963
|
+
if (packageManager === "unknown") {
|
|
8964
|
+
console.log(
|
|
8965
|
+
chalk3.yellow("Could not detect your package manager for auto-upgrade.")
|
|
8966
|
+
);
|
|
8967
|
+
} else {
|
|
8968
|
+
console.log(
|
|
8969
|
+
chalk3.yellow(`Auto-upgrade is not supported for ${packageManager}.`)
|
|
8970
|
+
);
|
|
8971
|
+
}
|
|
8972
|
+
console.log(chalk3.yellow("Please upgrade manually:"));
|
|
8973
|
+
console.log(chalk3.cyan(` ${getManualUpgradeCommand(packageManager)}`));
|
|
8974
|
+
console.log();
|
|
8975
|
+
return false;
|
|
8976
|
+
}
|
|
8977
|
+
console.log(`Upgrading via ${packageManager}...`);
|
|
8978
|
+
const success = await performUpgrade(packageManager);
|
|
8979
|
+
if (success) {
|
|
8980
|
+
console.log(chalk3.green(`Upgraded to ${latestVersion}`));
|
|
8981
|
+
console.log();
|
|
8982
|
+
console.log("To continue, run:");
|
|
8983
|
+
console.log(chalk3.cyan(` ${buildRerunCommand(prompt)}`));
|
|
8984
|
+
return true;
|
|
8985
|
+
}
|
|
8986
|
+
console.error();
|
|
8987
|
+
console.error(chalk3.red("\u2717 Upgrade failed. Please run manually:"));
|
|
8988
|
+
console.error(chalk3.cyan(` ${getManualUpgradeCommand(packageManager)}`));
|
|
8989
|
+
console.error();
|
|
8990
|
+
console.error("Then re-run:");
|
|
8991
|
+
console.error(chalk3.cyan(` ${buildRerunCommand(prompt)}`));
|
|
8992
|
+
return true;
|
|
8993
|
+
}
|
|
8994
|
+
async function startSilentUpgrade(currentVersion) {
|
|
8995
|
+
pendingUpgrade = null;
|
|
8996
|
+
const latestVersion = await getLatestVersion();
|
|
8997
|
+
if (latestVersion === null || latestVersion === currentVersion) {
|
|
8998
|
+
return;
|
|
8999
|
+
}
|
|
9000
|
+
const packageManager = detectPackageManager();
|
|
9001
|
+
if (!isAutoUpgradeSupported(packageManager)) {
|
|
9002
|
+
return;
|
|
9003
|
+
}
|
|
9004
|
+
const isWindows = process.platform === "win32";
|
|
9005
|
+
const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
|
|
9006
|
+
const child = safeSpawn(packageManager, args, {
|
|
9007
|
+
stdio: "pipe",
|
|
9008
|
+
detached: !isWindows,
|
|
9009
|
+
windowsHide: true
|
|
9010
|
+
});
|
|
9011
|
+
const promise = new Promise((resolve2) => {
|
|
9012
|
+
child.on("close", (code) => resolve2(code === 0));
|
|
9013
|
+
child.on("error", () => resolve2(false));
|
|
9014
|
+
});
|
|
9015
|
+
pendingUpgrade = { promise, child, packageManager };
|
|
9016
|
+
}
|
|
9017
|
+
async function waitForSilentUpgrade(timeout = TIMEOUT_MS) {
|
|
9018
|
+
if (!pendingUpgrade) {
|
|
9019
|
+
return;
|
|
9020
|
+
}
|
|
9021
|
+
const { promise, child, packageManager } = pendingUpgrade;
|
|
9022
|
+
pendingUpgrade = null;
|
|
9023
|
+
const result = await Promise.race([
|
|
9024
|
+
promise,
|
|
9025
|
+
new Promise((resolve2) => {
|
|
9026
|
+
setTimeout(() => {
|
|
9027
|
+
child.kill();
|
|
9028
|
+
resolve2(false);
|
|
9029
|
+
}, timeout);
|
|
9030
|
+
})
|
|
9031
|
+
]);
|
|
9032
|
+
if (!result) {
|
|
9033
|
+
console.log(
|
|
9034
|
+
chalk3.yellow(
|
|
9035
|
+
`
|
|
9036
|
+
\u26A0 vm0 auto upgrade failed. Please run: ${getManualUpgradeCommand(packageManager)}`
|
|
9037
|
+
)
|
|
9038
|
+
);
|
|
9039
|
+
}
|
|
9040
|
+
}
|
|
9041
|
+
|
|
9042
|
+
// src/commands/info/index.ts
|
|
9043
|
+
function getConfigPath() {
|
|
9044
|
+
return join2(homedir2(), ".vm0", "config.json");
|
|
9045
|
+
}
|
|
9046
|
+
var infoCommand = new Command6().name("info").description("Display environment and debug information").action(async () => {
|
|
9047
|
+
console.log(chalk4.bold(`VM0 CLI v${"9.74.0"}`));
|
|
9048
|
+
console.log();
|
|
9049
|
+
const config = await loadConfig();
|
|
9050
|
+
const hasEnvToken = !!process.env.VM0_TOKEN;
|
|
9051
|
+
const hasConfigToken = !!config.token;
|
|
9052
|
+
const isAuthenticated2 = hasEnvToken || hasConfigToken;
|
|
9053
|
+
console.log(chalk4.bold("Authentication:"));
|
|
9054
|
+
if (isAuthenticated2) {
|
|
9055
|
+
const tokenSource = hasEnvToken ? "VM0_TOKEN env var" : "config file";
|
|
9056
|
+
console.log(` ${chalk4.green("\u2713")} Logged in (via ${tokenSource})`);
|
|
9057
|
+
} else {
|
|
9058
|
+
console.log(` ${chalk4.red("\u2717")} Not authenticated`);
|
|
9059
|
+
}
|
|
9060
|
+
const configExists = existsSync2(getConfigPath());
|
|
9061
|
+
const configDisplay = configExists ? `~/.vm0/config.json` : `~/.vm0/config.json (not found)`;
|
|
9062
|
+
console.log(` Config: ${configDisplay}`);
|
|
9063
|
+
console.log();
|
|
9064
|
+
const apiUrl = await getApiUrl();
|
|
9065
|
+
console.log(chalk4.bold("API:"));
|
|
9066
|
+
console.log(` Host: ${apiUrl}`);
|
|
9067
|
+
console.log();
|
|
9068
|
+
console.log(chalk4.bold("System:"));
|
|
9069
|
+
console.log(` Node: ${process.version}`);
|
|
9070
|
+
console.log(` Platform: ${process.platform} (${process.arch})`);
|
|
9071
|
+
console.log(` OS: ${type()} ${release2()}`);
|
|
9072
|
+
console.log(` Shell: ${process.env.SHELL ?? "unknown"}`);
|
|
9073
|
+
console.log(` Package Manager: ${detectPackageManager()}`);
|
|
9074
|
+
});
|
|
9075
|
+
|
|
9076
|
+
// src/commands/compose/index.ts
|
|
9077
|
+
import { Command as Command7, Option } from "commander";
|
|
9078
|
+
import chalk6 from "chalk";
|
|
9079
|
+
import { readFile as readFile4, rm as rm3 } from "fs/promises";
|
|
9080
|
+
import { existsSync as existsSync5 } from "fs";
|
|
9081
|
+
import { dirname as dirname2, join as join8 } from "path";
|
|
9082
|
+
import { parse as parseYaml3 } from "yaml";
|
|
8891
9083
|
|
|
8892
9084
|
// src/lib/api/core/http.ts
|
|
8893
9085
|
async function appendOrgParam(path18) {
|
|
@@ -9286,7 +9478,7 @@ async function enableSchedule(params) {
|
|
|
9286
9478
|
}
|
|
9287
9479
|
async function disableSchedule(params) {
|
|
9288
9480
|
const config = await getClientConfig();
|
|
9289
|
-
const client = initClient6(
|
|
9481
|
+
const client = initClient6(schedulesDisableContract, config);
|
|
9290
9482
|
const result = await client.disable({
|
|
9291
9483
|
params: { name: params.name },
|
|
9292
9484
|
body: { composeId: params.composeId }
|
|
@@ -9641,8 +9833,8 @@ async function resolveSkills(skillUrls) {
|
|
|
9641
9833
|
}
|
|
9642
9834
|
|
|
9643
9835
|
// src/lib/domain/yaml-validator.ts
|
|
9644
|
-
import { z as
|
|
9645
|
-
var cliAgentNameSchema =
|
|
9836
|
+
import { z as z39 } from "zod";
|
|
9837
|
+
var cliAgentNameSchema = z39.string().min(3, "Agent name must be at least 3 characters").max(64, "Agent name must be 64 characters or less").regex(
|
|
9646
9838
|
/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,62}[a-zA-Z0-9])?$/,
|
|
9647
9839
|
"Agent name must start and end with letter or number, and contain only letters, numbers, and hyphens"
|
|
9648
9840
|
);
|
|
@@ -9656,7 +9848,7 @@ var cliAgentDefinitionSchema = agentDefinitionSchema.superRefine(
|
|
|
9656
9848
|
resolveSkillRef(skillRef);
|
|
9657
9849
|
} catch (error) {
|
|
9658
9850
|
ctx.addIssue({
|
|
9659
|
-
code:
|
|
9851
|
+
code: z39.ZodIssueCode.custom,
|
|
9660
9852
|
message: error instanceof Error ? error.message : `Invalid skill reference: ${skillRef}`,
|
|
9661
9853
|
path: ["skills", i]
|
|
9662
9854
|
});
|
|
@@ -9666,15 +9858,15 @@ var cliAgentDefinitionSchema = agentDefinitionSchema.superRefine(
|
|
|
9666
9858
|
}
|
|
9667
9859
|
}
|
|
9668
9860
|
);
|
|
9669
|
-
var cliComposeSchema =
|
|
9670
|
-
version:
|
|
9671
|
-
agents:
|
|
9672
|
-
volumes:
|
|
9861
|
+
var cliComposeSchema = z39.object({
|
|
9862
|
+
version: z39.string().min(1, "Missing config.version"),
|
|
9863
|
+
agents: z39.record(cliAgentNameSchema, cliAgentDefinitionSchema),
|
|
9864
|
+
volumes: z39.record(z39.string(), volumeConfigSchema).optional()
|
|
9673
9865
|
}).superRefine((config, ctx) => {
|
|
9674
9866
|
const agentKeys = Object.keys(config.agents);
|
|
9675
9867
|
if (agentKeys.length === 0) {
|
|
9676
9868
|
ctx.addIssue({
|
|
9677
|
-
code:
|
|
9869
|
+
code: z39.ZodIssueCode.custom,
|
|
9678
9870
|
message: "agents must have at least one agent defined",
|
|
9679
9871
|
path: ["agents"]
|
|
9680
9872
|
});
|
|
@@ -9682,7 +9874,7 @@ var cliComposeSchema = z37.object({
|
|
|
9682
9874
|
}
|
|
9683
9875
|
if (agentKeys.length > 1) {
|
|
9684
9876
|
ctx.addIssue({
|
|
9685
|
-
code:
|
|
9877
|
+
code: z39.ZodIssueCode.custom,
|
|
9686
9878
|
message: "Multiple agents not supported yet. Only one agent allowed.",
|
|
9687
9879
|
path: ["agents"]
|
|
9688
9880
|
});
|
|
@@ -9694,7 +9886,7 @@ var cliComposeSchema = z37.object({
|
|
|
9694
9886
|
if (agentVolumes && agentVolumes.length > 0) {
|
|
9695
9887
|
if (!config.volumes) {
|
|
9696
9888
|
ctx.addIssue({
|
|
9697
|
-
code:
|
|
9889
|
+
code: z39.ZodIssueCode.custom,
|
|
9698
9890
|
message: "Agent references volumes but no volumes section defined. Each volume must have explicit name and version.",
|
|
9699
9891
|
path: ["volumes"]
|
|
9700
9892
|
});
|
|
@@ -9704,7 +9896,7 @@ var cliComposeSchema = z37.object({
|
|
|
9704
9896
|
const parts = volDeclaration.split(":");
|
|
9705
9897
|
if (parts.length !== 2) {
|
|
9706
9898
|
ctx.addIssue({
|
|
9707
|
-
code:
|
|
9899
|
+
code: z39.ZodIssueCode.custom,
|
|
9708
9900
|
message: `Invalid volume declaration: ${volDeclaration}. Expected format: volume-key:/mount/path`,
|
|
9709
9901
|
path: ["agents", agentName, "volumes"]
|
|
9710
9902
|
});
|
|
@@ -9713,7 +9905,7 @@ var cliComposeSchema = z37.object({
|
|
|
9713
9905
|
const volumeKey = parts[0].trim();
|
|
9714
9906
|
if (!config.volumes[volumeKey]) {
|
|
9715
9907
|
ctx.addIssue({
|
|
9716
|
-
code:
|
|
9908
|
+
code: z39.ZodIssueCode.custom,
|
|
9717
9909
|
message: `Volume "${volumeKey}" is not defined in volumes section. Each volume must have explicit name and version.`,
|
|
9718
9910
|
path: ["volumes", volumeKey]
|
|
9719
9911
|
});
|
|
@@ -10912,7 +11104,7 @@ var composeCommand = new Command7().name("compose").description("Create or updat
|
|
|
10912
11104
|
options.autoUpdate = false;
|
|
10913
11105
|
}
|
|
10914
11106
|
if (options.autoUpdate !== false) {
|
|
10915
|
-
await startSilentUpgrade("9.
|
|
11107
|
+
await startSilentUpgrade("9.74.0");
|
|
10916
11108
|
}
|
|
10917
11109
|
try {
|
|
10918
11110
|
let result;
|
|
@@ -11668,6 +11860,10 @@ async function pollEvents(runId, options) {
|
|
|
11668
11860
|
chalk9.dim(` (use "vm0 logs ${runId} --system" to view system logs)`)
|
|
11669
11861
|
);
|
|
11670
11862
|
result = { succeeded: false, runId };
|
|
11863
|
+
} else if (runStatus === "cancelled") {
|
|
11864
|
+
complete = true;
|
|
11865
|
+
console.error(chalk9.yellow("\n\u2717 Run cancelled"));
|
|
11866
|
+
result = { succeeded: false, runId };
|
|
11671
11867
|
}
|
|
11672
11868
|
if (!complete) {
|
|
11673
11869
|
await new Promise((resolve2) => setTimeout(resolve2, pollIntervalMs));
|
|
@@ -11743,7 +11939,7 @@ var mainRunCommand = new Command8().name("run").description("Run an agent").argu
|
|
|
11743
11939
|
withErrorHandler(
|
|
11744
11940
|
async (identifier, prompt, options) => {
|
|
11745
11941
|
if (options.autoUpdate !== false) {
|
|
11746
|
-
await startSilentUpgrade("9.
|
|
11942
|
+
await startSilentUpgrade("9.74.0");
|
|
11747
11943
|
}
|
|
11748
11944
|
const { org, name, version } = parseIdentifier(identifier);
|
|
11749
11945
|
let composeId;
|
|
@@ -13499,7 +13695,7 @@ var cookAction = new Command35().name("cook").description("Quick start: prepare,
|
|
|
13499
13695
|
withErrorHandler(
|
|
13500
13696
|
async (prompt, options) => {
|
|
13501
13697
|
if (options.autoUpdate !== false) {
|
|
13502
|
-
const shouldExit = await checkAndUpgrade("9.
|
|
13698
|
+
const shouldExit = await checkAndUpgrade("9.74.0", prompt);
|
|
13503
13699
|
if (shouldExit) {
|
|
13504
13700
|
process.exit(0);
|
|
13505
13701
|
}
|
|
@@ -14170,7 +14366,7 @@ var ApiClient = class {
|
|
|
14170
14366
|
async disableSchedule(params) {
|
|
14171
14367
|
const baseUrl = await this.getBaseUrl();
|
|
14172
14368
|
const headers = await this.getHeaders();
|
|
14173
|
-
const client = initClient14(
|
|
14369
|
+
const client = initClient14(schedulesDisableContract, {
|
|
14174
14370
|
baseUrl,
|
|
14175
14371
|
baseHeaders: headers,
|
|
14176
14372
|
jsonQuery: false
|
|
@@ -14512,7 +14708,17 @@ function formatNetworkRequest(entry) {
|
|
|
14512
14708
|
const error = entry.firewall_error ? ` ${chalk36.red(entry.firewall_error)}` : "";
|
|
14513
14709
|
return `[${entry.timestamp}] ${method.padEnd(6)} ${statusColor(status)} ${latencyColor(latencyMs + "ms")} ${formatBytes(requestSize)}/${formatBytes(responseSize)} ${chalk36.dim(url)}${firewall}${error}`;
|
|
14514
14710
|
}
|
|
14711
|
+
function formatNetworkTcp(entry) {
|
|
14712
|
+
const host = entry.host || "unknown";
|
|
14713
|
+
const port = entry.port || 0;
|
|
14714
|
+
const requestSize = entry.request_size || 0;
|
|
14715
|
+
const responseSize = entry.response_size || 0;
|
|
14716
|
+
const latencyMs = entry.latency_ms || 0;
|
|
14717
|
+
const error = entry.error ? ` ${chalk36.red(entry.error)}` : "";
|
|
14718
|
+
return `[${entry.timestamp}] ${chalk36.blue("TCP")} ${latencyMs}ms ${formatBytes(requestSize)}/${formatBytes(responseSize)} ${chalk36.dim(`${host}:${port}`)}${error}`;
|
|
14719
|
+
}
|
|
14515
14720
|
function formatNetworkLog(entry) {
|
|
14721
|
+
if (entry.type === "tcp") return formatNetworkTcp(entry);
|
|
14516
14722
|
if (entry.action === "DENY") return formatNetworkDeny(entry);
|
|
14517
14723
|
return formatNetworkRequest(entry);
|
|
14518
14724
|
}
|
|
@@ -15863,7 +16069,7 @@ var listCommand9 = new Command65().name("list").alias("ls").description("List al
|
|
|
15863
16069
|
);
|
|
15864
16070
|
return;
|
|
15865
16071
|
}
|
|
15866
|
-
const nameWidth = Math.max(4, ...data.composes.map((
|
|
16072
|
+
const nameWidth = Math.max(4, ...data.composes.map((c38) => c38.name.length));
|
|
15867
16073
|
const header = ["NAME".padEnd(nameWidth), "VERSION", "UPDATED"].join(
|
|
15868
16074
|
" "
|
|
15869
16075
|
);
|
|
@@ -16464,7 +16670,7 @@ async function gatherFrequency(optionFrequency, existingFrequency) {
|
|
|
16464
16670
|
if (!isInteractive()) {
|
|
16465
16671
|
throw new Error("--frequency is required (daily|weekly|monthly|once|loop)");
|
|
16466
16672
|
}
|
|
16467
|
-
const defaultIndex = existingFrequency ? FREQUENCY_CHOICES.findIndex((
|
|
16673
|
+
const defaultIndex = existingFrequency ? FREQUENCY_CHOICES.findIndex((c38) => c38.value === existingFrequency) : 0;
|
|
16468
16674
|
frequency = await promptSelect(
|
|
16469
16675
|
"Schedule frequency",
|
|
16470
16676
|
FREQUENCY_CHOICES,
|
|
@@ -16489,7 +16695,7 @@ async function gatherDay(frequency, optionDay, existingDay) {
|
|
|
16489
16695
|
throw new Error("--day is required for weekly/monthly");
|
|
16490
16696
|
}
|
|
16491
16697
|
if (frequency === "weekly") {
|
|
16492
|
-
const defaultDayIndex = existingDay !== void 0 ? DAY_OF_WEEK_CHOICES.findIndex((
|
|
16698
|
+
const defaultDayIndex = existingDay !== void 0 ? DAY_OF_WEEK_CHOICES.findIndex((c38) => c38.value === existingDay) : 0;
|
|
16493
16699
|
const day2 = await promptSelect(
|
|
16494
16700
|
"Day of week",
|
|
16495
16701
|
DAY_OF_WEEK_CHOICES,
|
|
@@ -17939,7 +18145,7 @@ import chalk76 from "chalk";
|
|
|
17939
18145
|
var listCommand13 = new Command86().name("list").alias("ls").description("List all connectors and their status").action(
|
|
17940
18146
|
withErrorHandler(async () => {
|
|
17941
18147
|
const result = await listConnectors();
|
|
17942
|
-
const connectedMap = new Map(result.connectors.map((
|
|
18148
|
+
const connectedMap = new Map(result.connectors.map((c38) => [c38.type, c38]));
|
|
17943
18149
|
const allTypesRaw = Object.keys(CONNECTOR_TYPES);
|
|
17944
18150
|
const allTypes = [];
|
|
17945
18151
|
for (const type2 of allTypesRaw) {
|
|
@@ -18500,16 +18706,16 @@ async function handleModelProvider(ctx) {
|
|
|
18500
18706
|
const providerType = await step.prompt(
|
|
18501
18707
|
() => promptSelect(
|
|
18502
18708
|
"Select provider type:",
|
|
18503
|
-
choices.map((
|
|
18504
|
-
title:
|
|
18505
|
-
value:
|
|
18709
|
+
choices.map((c38) => ({
|
|
18710
|
+
title: c38.label,
|
|
18711
|
+
value: c38.type
|
|
18506
18712
|
}))
|
|
18507
18713
|
)
|
|
18508
18714
|
);
|
|
18509
18715
|
if (!providerType) {
|
|
18510
18716
|
process.exit(0);
|
|
18511
18717
|
}
|
|
18512
|
-
const selectedChoice = choices.find((
|
|
18718
|
+
const selectedChoice = choices.find((c38) => c38.type === providerType);
|
|
18513
18719
|
if (selectedChoice?.helpText) {
|
|
18514
18720
|
for (const line of selectedChoice.helpText.split("\n")) {
|
|
18515
18721
|
step.detail(chalk82.dim(line));
|
|
@@ -18863,13 +19069,13 @@ var upgradeCommand = new Command94().name("upgrade").description("Upgrade vm0 CL
|
|
|
18863
19069
|
if (latestVersion === null) {
|
|
18864
19070
|
throw new Error("Could not check for updates. Please try again later.");
|
|
18865
19071
|
}
|
|
18866
|
-
if (latestVersion === "9.
|
|
18867
|
-
console.log(chalk86.green(`\u2713 Already up to date (${"9.
|
|
19072
|
+
if (latestVersion === "9.74.0") {
|
|
19073
|
+
console.log(chalk86.green(`\u2713 Already up to date (${"9.74.0"})`));
|
|
18868
19074
|
return;
|
|
18869
19075
|
}
|
|
18870
19076
|
console.log(
|
|
18871
19077
|
chalk86.yellow(
|
|
18872
|
-
`Current version: ${"9.
|
|
19078
|
+
`Current version: ${"9.74.0"} -> Latest version: ${latestVersion}`
|
|
18873
19079
|
)
|
|
18874
19080
|
);
|
|
18875
19081
|
console.log();
|
|
@@ -18896,7 +19102,7 @@ var upgradeCommand = new Command94().name("upgrade").description("Upgrade vm0 CL
|
|
|
18896
19102
|
const success = await performUpgrade(packageManager);
|
|
18897
19103
|
if (success) {
|
|
18898
19104
|
console.log(
|
|
18899
|
-
chalk86.green(`\u2713 Upgraded from ${"9.
|
|
19105
|
+
chalk86.green(`\u2713 Upgraded from ${"9.74.0"} to ${latestVersion}`)
|
|
18900
19106
|
);
|
|
18901
19107
|
return;
|
|
18902
19108
|
}
|
|
@@ -18970,7 +19176,7 @@ var whoamiCommand = new Command95().name("whoami").description("Show current ide
|
|
|
18970
19176
|
|
|
18971
19177
|
// src/index.ts
|
|
18972
19178
|
var program = new Command96();
|
|
18973
|
-
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.
|
|
19179
|
+
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.74.0");
|
|
18974
19180
|
program.addCommand(authCommand);
|
|
18975
19181
|
program.addCommand(infoCommand);
|
|
18976
19182
|
program.addCommand(composeCommand);
|