@vm0/cli 4.8.0 → 4.9.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 +183 -161
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var __export = (target, all) => {
|
|
|
7
7
|
|
|
8
8
|
// src/index.ts
|
|
9
9
|
import { Command as Command17 } from "commander";
|
|
10
|
-
import
|
|
10
|
+
import chalk17 from "chalk";
|
|
11
11
|
|
|
12
12
|
// src/lib/auth.ts
|
|
13
13
|
import chalk from "chalk";
|
|
@@ -15303,11 +15303,25 @@ var pushCommand = new Command4().name("push").description("Push local files to c
|
|
|
15303
15303
|
|
|
15304
15304
|
// src/commands/volume/pull.ts
|
|
15305
15305
|
import { Command as Command5 } from "commander";
|
|
15306
|
-
import
|
|
15306
|
+
import chalk8 from "chalk";
|
|
15307
15307
|
import path8 from "path";
|
|
15308
15308
|
import * as fs6 from "fs";
|
|
15309
15309
|
import * as os4 from "os";
|
|
15310
15310
|
import * as tar4 from "tar";
|
|
15311
|
+
|
|
15312
|
+
// src/lib/pull-utils.ts
|
|
15313
|
+
import chalk7 from "chalk";
|
|
15314
|
+
async function handleEmptyStorageResponse(cwd) {
|
|
15315
|
+
console.log(chalk7.gray("Syncing local files..."));
|
|
15316
|
+
const removedCount = await removeExtraFiles(cwd, /* @__PURE__ */ new Set());
|
|
15317
|
+
if (removedCount > 0) {
|
|
15318
|
+
console.log(chalk7.green(`\u2713 Removed ${removedCount} files not in remote`));
|
|
15319
|
+
}
|
|
15320
|
+
console.log(chalk7.green("\u2713 Synced (0 files)"));
|
|
15321
|
+
return { removedCount };
|
|
15322
|
+
}
|
|
15323
|
+
|
|
15324
|
+
// src/commands/volume/pull.ts
|
|
15311
15325
|
function formatBytes2(bytes) {
|
|
15312
15326
|
if (bytes === 0) return "0 B";
|
|
15313
15327
|
const k = 1024;
|
|
@@ -15320,18 +15334,18 @@ var pullCommand = new Command5().name("pull").description("Pull cloud files to l
|
|
|
15320
15334
|
const cwd = process.cwd();
|
|
15321
15335
|
const config2 = await readStorageConfig(cwd);
|
|
15322
15336
|
if (!config2) {
|
|
15323
|
-
console.error(
|
|
15324
|
-
console.error(
|
|
15337
|
+
console.error(chalk8.red("\u2717 No volume initialized in this directory"));
|
|
15338
|
+
console.error(chalk8.gray(" Run: vm0 volume init"));
|
|
15325
15339
|
process.exit(1);
|
|
15326
15340
|
}
|
|
15327
15341
|
if (versionId) {
|
|
15328
15342
|
console.log(
|
|
15329
|
-
|
|
15343
|
+
chalk8.cyan(`Pulling volume: ${config2.name} (version: ${versionId})`)
|
|
15330
15344
|
);
|
|
15331
15345
|
} else {
|
|
15332
|
-
console.log(
|
|
15346
|
+
console.log(chalk8.cyan(`Pulling volume: ${config2.name}`));
|
|
15333
15347
|
}
|
|
15334
|
-
console.log(
|
|
15348
|
+
console.log(chalk8.gray("Downloading..."));
|
|
15335
15349
|
let url2 = `/api/storages?name=${encodeURIComponent(config2.name)}&type=volume`;
|
|
15336
15350
|
if (versionId) {
|
|
15337
15351
|
url2 += `&version=${encodeURIComponent(versionId)}`;
|
|
@@ -15339,28 +15353,32 @@ var pullCommand = new Command5().name("pull").description("Pull cloud files to l
|
|
|
15339
15353
|
const response = await apiClient.get(url2);
|
|
15340
15354
|
if (!response.ok) {
|
|
15341
15355
|
if (response.status === 404) {
|
|
15342
|
-
console.error(
|
|
15356
|
+
console.error(chalk8.red(`\u2717 Volume "${config2.name}" not found`));
|
|
15343
15357
|
console.error(
|
|
15344
|
-
|
|
15358
|
+
chalk8.gray(
|
|
15345
15359
|
" Make sure the volume name is correct in .vm0/storage.yaml"
|
|
15346
15360
|
)
|
|
15347
15361
|
);
|
|
15348
15362
|
console.error(
|
|
15349
|
-
|
|
15363
|
+
chalk8.gray(" Or push the volume first with: vm0 volume push")
|
|
15350
15364
|
);
|
|
15351
15365
|
} else {
|
|
15352
15366
|
const error43 = await response.json();
|
|
15353
|
-
throw new Error(error43.error || "Download failed");
|
|
15367
|
+
throw new Error(error43.error?.message || "Download failed");
|
|
15354
15368
|
}
|
|
15355
15369
|
process.exit(1);
|
|
15356
15370
|
}
|
|
15371
|
+
if (response.status === 204) {
|
|
15372
|
+
await handleEmptyStorageResponse(cwd);
|
|
15373
|
+
return;
|
|
15374
|
+
}
|
|
15357
15375
|
const arrayBuffer = await response.arrayBuffer();
|
|
15358
15376
|
const tarBuffer = Buffer.from(arrayBuffer);
|
|
15359
|
-
console.log(
|
|
15377
|
+
console.log(chalk8.green(`\u2713 Downloaded ${formatBytes2(tarBuffer.length)}`));
|
|
15360
15378
|
const tmpDir = fs6.mkdtempSync(path8.join(os4.tmpdir(), "vm0-"));
|
|
15361
15379
|
const tarPath = path8.join(tmpDir, "volume.tar.gz");
|
|
15362
15380
|
await fs6.promises.writeFile(tarPath, tarBuffer);
|
|
15363
|
-
console.log(
|
|
15381
|
+
console.log(chalk8.gray("Syncing local files..."));
|
|
15364
15382
|
const remoteFiles = await listTarFiles(tarPath);
|
|
15365
15383
|
const remoteFilesSet = new Set(
|
|
15366
15384
|
remoteFiles.map((f) => f.replace(/\\/g, "/"))
|
|
@@ -15368,10 +15386,10 @@ var pullCommand = new Command5().name("pull").description("Pull cloud files to l
|
|
|
15368
15386
|
const removedCount = await removeExtraFiles(cwd, remoteFilesSet);
|
|
15369
15387
|
if (removedCount > 0) {
|
|
15370
15388
|
console.log(
|
|
15371
|
-
|
|
15389
|
+
chalk8.green(`\u2713 Removed ${removedCount} files not in remote`)
|
|
15372
15390
|
);
|
|
15373
15391
|
}
|
|
15374
|
-
console.log(
|
|
15392
|
+
console.log(chalk8.gray("Extracting files..."));
|
|
15375
15393
|
await tar4.extract({
|
|
15376
15394
|
file: tarPath,
|
|
15377
15395
|
cwd,
|
|
@@ -15379,11 +15397,11 @@ var pullCommand = new Command5().name("pull").description("Pull cloud files to l
|
|
|
15379
15397
|
});
|
|
15380
15398
|
await fs6.promises.unlink(tarPath);
|
|
15381
15399
|
await fs6.promises.rmdir(tmpDir);
|
|
15382
|
-
console.log(
|
|
15400
|
+
console.log(chalk8.green(`\u2713 Extracted ${remoteFiles.length} files`));
|
|
15383
15401
|
} catch (error43) {
|
|
15384
|
-
console.error(
|
|
15402
|
+
console.error(chalk8.red("\u2717 Pull failed"));
|
|
15385
15403
|
if (error43 instanceof Error) {
|
|
15386
|
-
console.error(
|
|
15404
|
+
console.error(chalk8.gray(` ${error43.message}`));
|
|
15387
15405
|
}
|
|
15388
15406
|
process.exit(1);
|
|
15389
15407
|
}
|
|
@@ -15397,7 +15415,7 @@ import { Command as Command10 } from "commander";
|
|
|
15397
15415
|
|
|
15398
15416
|
// src/commands/artifact/init.ts
|
|
15399
15417
|
import { Command as Command7 } from "commander";
|
|
15400
|
-
import
|
|
15418
|
+
import chalk9 from "chalk";
|
|
15401
15419
|
import path9 from "path";
|
|
15402
15420
|
var initCommand2 = new Command7().name("init").description("Initialize an artifact in the current directory").action(async () => {
|
|
15403
15421
|
try {
|
|
@@ -15407,51 +15425,51 @@ var initCommand2 = new Command7().name("init").description("Initialize an artifa
|
|
|
15407
15425
|
if (existingConfig) {
|
|
15408
15426
|
if (existingConfig.type === "artifact") {
|
|
15409
15427
|
console.log(
|
|
15410
|
-
|
|
15428
|
+
chalk9.yellow(
|
|
15411
15429
|
`Artifact already initialized: ${existingConfig.name}`
|
|
15412
15430
|
)
|
|
15413
15431
|
);
|
|
15414
15432
|
} else {
|
|
15415
15433
|
console.log(
|
|
15416
|
-
|
|
15434
|
+
chalk9.yellow(
|
|
15417
15435
|
`Directory already initialized as volume: ${existingConfig.name}`
|
|
15418
15436
|
)
|
|
15419
15437
|
);
|
|
15420
15438
|
console.log(
|
|
15421
|
-
|
|
15439
|
+
chalk9.gray(
|
|
15422
15440
|
" To change type, delete .vm0/storage.yaml and reinitialize"
|
|
15423
15441
|
)
|
|
15424
15442
|
);
|
|
15425
15443
|
}
|
|
15426
15444
|
console.log(
|
|
15427
|
-
|
|
15445
|
+
chalk9.gray(`Config file: ${path9.join(cwd, ".vm0", "storage.yaml")}`)
|
|
15428
15446
|
);
|
|
15429
15447
|
return;
|
|
15430
15448
|
}
|
|
15431
15449
|
const artifactName = dirName;
|
|
15432
15450
|
if (!isValidStorageName(artifactName)) {
|
|
15433
|
-
console.error(
|
|
15451
|
+
console.error(chalk9.red(`\u2717 Invalid artifact name: "${dirName}"`));
|
|
15434
15452
|
console.error(
|
|
15435
|
-
|
|
15453
|
+
chalk9.gray(
|
|
15436
15454
|
" Artifact names must be 3-64 characters, lowercase alphanumeric with hyphens"
|
|
15437
15455
|
)
|
|
15438
15456
|
);
|
|
15439
15457
|
console.error(
|
|
15440
|
-
|
|
15458
|
+
chalk9.gray(" Example: my-project, user-workspace, code-artifact")
|
|
15441
15459
|
);
|
|
15442
15460
|
process.exit(1);
|
|
15443
15461
|
}
|
|
15444
15462
|
await writeStorageConfig(artifactName, cwd, "artifact");
|
|
15445
|
-
console.log(
|
|
15463
|
+
console.log(chalk9.green(`\u2713 Initialized artifact: ${artifactName}`));
|
|
15446
15464
|
console.log(
|
|
15447
|
-
|
|
15465
|
+
chalk9.gray(
|
|
15448
15466
|
`\u2713 Config saved to ${path9.join(cwd, ".vm0", "storage.yaml")}`
|
|
15449
15467
|
)
|
|
15450
15468
|
);
|
|
15451
15469
|
} catch (error43) {
|
|
15452
|
-
console.error(
|
|
15470
|
+
console.error(chalk9.red("\u2717 Failed to initialize artifact"));
|
|
15453
15471
|
if (error43 instanceof Error) {
|
|
15454
|
-
console.error(
|
|
15472
|
+
console.error(chalk9.gray(` ${error43.message}`));
|
|
15455
15473
|
}
|
|
15456
15474
|
process.exit(1);
|
|
15457
15475
|
}
|
|
@@ -15459,7 +15477,7 @@ var initCommand2 = new Command7().name("init").description("Initialize an artifa
|
|
|
15459
15477
|
|
|
15460
15478
|
// src/commands/artifact/push.ts
|
|
15461
15479
|
import { Command as Command8 } from "commander";
|
|
15462
|
-
import
|
|
15480
|
+
import chalk10 from "chalk";
|
|
15463
15481
|
import path10 from "path";
|
|
15464
15482
|
import * as fs7 from "fs";
|
|
15465
15483
|
import * as os5 from "os";
|
|
@@ -15497,21 +15515,21 @@ var pushCommand2 = new Command8().name("push").description("Push local files to
|
|
|
15497
15515
|
const cwd = process.cwd();
|
|
15498
15516
|
const config2 = await readStorageConfig(cwd);
|
|
15499
15517
|
if (!config2) {
|
|
15500
|
-
console.error(
|
|
15501
|
-
console.error(
|
|
15518
|
+
console.error(chalk10.red("\u2717 No artifact initialized in this directory"));
|
|
15519
|
+
console.error(chalk10.gray(" Run: vm0 artifact init"));
|
|
15502
15520
|
process.exit(1);
|
|
15503
15521
|
}
|
|
15504
15522
|
if (config2.type !== "artifact") {
|
|
15505
15523
|
console.error(
|
|
15506
|
-
|
|
15524
|
+
chalk10.red(
|
|
15507
15525
|
`\u2717 This directory is initialized as a volume, not an artifact`
|
|
15508
15526
|
)
|
|
15509
15527
|
);
|
|
15510
|
-
console.error(
|
|
15528
|
+
console.error(chalk10.gray(" Use: vm0 volume push"));
|
|
15511
15529
|
process.exit(1);
|
|
15512
15530
|
}
|
|
15513
|
-
console.log(
|
|
15514
|
-
console.log(
|
|
15531
|
+
console.log(chalk10.cyan(`Pushing artifact: ${config2.name}`));
|
|
15532
|
+
console.log(chalk10.gray("Collecting files..."));
|
|
15515
15533
|
const files = await getAllFiles2(cwd);
|
|
15516
15534
|
let totalSize = 0;
|
|
15517
15535
|
for (const file2 of files) {
|
|
@@ -15519,13 +15537,13 @@ var pushCommand2 = new Command8().name("push").description("Push local files to
|
|
|
15519
15537
|
totalSize += stats.size;
|
|
15520
15538
|
}
|
|
15521
15539
|
if (files.length === 0) {
|
|
15522
|
-
console.log(
|
|
15540
|
+
console.log(chalk10.gray("No files found (empty artifact)"));
|
|
15523
15541
|
} else {
|
|
15524
15542
|
console.log(
|
|
15525
|
-
|
|
15543
|
+
chalk10.gray(`Found ${files.length} files (${formatBytes3(totalSize)})`)
|
|
15526
15544
|
);
|
|
15527
15545
|
}
|
|
15528
|
-
console.log(
|
|
15546
|
+
console.log(chalk10.gray("Compressing files..."));
|
|
15529
15547
|
const tmpDir = fs7.mkdtempSync(path10.join(os5.tmpdir(), "vm0-"));
|
|
15530
15548
|
const tarPath = path10.join(tmpDir, "artifact.tar.gz");
|
|
15531
15549
|
const relativePaths = files.map((file2) => path10.relative(cwd, file2));
|
|
@@ -15553,9 +15571,9 @@ var pushCommand2 = new Command8().name("push").description("Push local files to
|
|
|
15553
15571
|
await fs7.promises.unlink(tarPath);
|
|
15554
15572
|
await fs7.promises.rmdir(tmpDir);
|
|
15555
15573
|
console.log(
|
|
15556
|
-
|
|
15574
|
+
chalk10.green(`\u2713 Compressed to ${formatBytes3(tarBuffer.length)}`)
|
|
15557
15575
|
);
|
|
15558
|
-
console.log(
|
|
15576
|
+
console.log(chalk10.gray("Uploading..."));
|
|
15559
15577
|
const formData = new FormData();
|
|
15560
15578
|
formData.append("name", config2.name);
|
|
15561
15579
|
formData.append("type", "artifact");
|
|
@@ -15577,17 +15595,17 @@ var pushCommand2 = new Command8().name("push").description("Push local files to
|
|
|
15577
15595
|
const result = await response.json();
|
|
15578
15596
|
const shortVersion = result.versionId.slice(0, 8);
|
|
15579
15597
|
if (result.deduplicated) {
|
|
15580
|
-
console.log(
|
|
15598
|
+
console.log(chalk10.green("\u2713 Content unchanged (deduplicated)"));
|
|
15581
15599
|
} else {
|
|
15582
|
-
console.log(
|
|
15600
|
+
console.log(chalk10.green("\u2713 Upload complete"));
|
|
15583
15601
|
}
|
|
15584
|
-
console.log(
|
|
15585
|
-
console.log(
|
|
15586
|
-
console.log(
|
|
15602
|
+
console.log(chalk10.gray(` Version: ${shortVersion}`));
|
|
15603
|
+
console.log(chalk10.gray(` Files: ${result.fileCount.toLocaleString()}`));
|
|
15604
|
+
console.log(chalk10.gray(` Size: ${formatBytes3(result.size)}`));
|
|
15587
15605
|
} catch (error43) {
|
|
15588
|
-
console.error(
|
|
15606
|
+
console.error(chalk10.red("\u2717 Push failed"));
|
|
15589
15607
|
if (error43 instanceof Error) {
|
|
15590
|
-
console.error(
|
|
15608
|
+
console.error(chalk10.gray(` ${error43.message}`));
|
|
15591
15609
|
}
|
|
15592
15610
|
process.exit(1);
|
|
15593
15611
|
}
|
|
@@ -15595,7 +15613,7 @@ var pushCommand2 = new Command8().name("push").description("Push local files to
|
|
|
15595
15613
|
|
|
15596
15614
|
// src/commands/artifact/pull.ts
|
|
15597
15615
|
import { Command as Command9 } from "commander";
|
|
15598
|
-
import
|
|
15616
|
+
import chalk11 from "chalk";
|
|
15599
15617
|
import path11 from "path";
|
|
15600
15618
|
import * as fs8 from "fs";
|
|
15601
15619
|
import * as os6 from "os";
|
|
@@ -15612,29 +15630,29 @@ var pullCommand2 = new Command9().name("pull").description("Pull cloud artifact
|
|
|
15612
15630
|
const cwd = process.cwd();
|
|
15613
15631
|
const config2 = await readStorageConfig(cwd);
|
|
15614
15632
|
if (!config2) {
|
|
15615
|
-
console.error(
|
|
15616
|
-
console.error(
|
|
15633
|
+
console.error(chalk11.red("\u2717 No artifact initialized in this directory"));
|
|
15634
|
+
console.error(chalk11.gray(" Run: vm0 artifact init"));
|
|
15617
15635
|
process.exit(1);
|
|
15618
15636
|
}
|
|
15619
15637
|
if (config2.type !== "artifact") {
|
|
15620
15638
|
console.error(
|
|
15621
|
-
|
|
15639
|
+
chalk11.red(
|
|
15622
15640
|
`\u2717 This directory is initialized as a volume, not an artifact`
|
|
15623
15641
|
)
|
|
15624
15642
|
);
|
|
15625
|
-
console.error(
|
|
15643
|
+
console.error(chalk11.gray(" Use: vm0 volume pull"));
|
|
15626
15644
|
process.exit(1);
|
|
15627
15645
|
}
|
|
15628
15646
|
if (versionId) {
|
|
15629
15647
|
console.log(
|
|
15630
|
-
|
|
15648
|
+
chalk11.cyan(
|
|
15631
15649
|
`Pulling artifact: ${config2.name} (version: ${versionId})`
|
|
15632
15650
|
)
|
|
15633
15651
|
);
|
|
15634
15652
|
} else {
|
|
15635
|
-
console.log(
|
|
15653
|
+
console.log(chalk11.cyan(`Pulling artifact: ${config2.name}`));
|
|
15636
15654
|
}
|
|
15637
|
-
console.log(
|
|
15655
|
+
console.log(chalk11.gray("Downloading..."));
|
|
15638
15656
|
let url2 = `/api/storages?name=${encodeURIComponent(config2.name)}&type=artifact`;
|
|
15639
15657
|
if (versionId) {
|
|
15640
15658
|
url2 += `&version=${encodeURIComponent(versionId)}`;
|
|
@@ -15642,28 +15660,32 @@ var pullCommand2 = new Command9().name("pull").description("Pull cloud artifact
|
|
|
15642
15660
|
const response = await apiClient.get(url2);
|
|
15643
15661
|
if (!response.ok) {
|
|
15644
15662
|
if (response.status === 404) {
|
|
15645
|
-
console.error(
|
|
15663
|
+
console.error(chalk11.red(`\u2717 Artifact "${config2.name}" not found`));
|
|
15646
15664
|
console.error(
|
|
15647
|
-
|
|
15665
|
+
chalk11.gray(
|
|
15648
15666
|
" Make sure the artifact name is correct in .vm0/storage.yaml"
|
|
15649
15667
|
)
|
|
15650
15668
|
);
|
|
15651
15669
|
console.error(
|
|
15652
|
-
|
|
15670
|
+
chalk11.gray(" Or push the artifact first with: vm0 artifact push")
|
|
15653
15671
|
);
|
|
15654
15672
|
} else {
|
|
15655
15673
|
const error43 = await response.json();
|
|
15656
|
-
throw new Error(error43.error || "Download failed");
|
|
15674
|
+
throw new Error(error43.error?.message || "Download failed");
|
|
15657
15675
|
}
|
|
15658
15676
|
process.exit(1);
|
|
15659
15677
|
}
|
|
15678
|
+
if (response.status === 204) {
|
|
15679
|
+
await handleEmptyStorageResponse(cwd);
|
|
15680
|
+
return;
|
|
15681
|
+
}
|
|
15660
15682
|
const arrayBuffer = await response.arrayBuffer();
|
|
15661
15683
|
const tarBuffer = Buffer.from(arrayBuffer);
|
|
15662
|
-
console.log(
|
|
15684
|
+
console.log(chalk11.green(`\u2713 Downloaded ${formatBytes4(tarBuffer.length)}`));
|
|
15663
15685
|
const tmpDir = fs8.mkdtempSync(path11.join(os6.tmpdir(), "vm0-"));
|
|
15664
15686
|
const tarPath = path11.join(tmpDir, "artifact.tar.gz");
|
|
15665
15687
|
await fs8.promises.writeFile(tarPath, tarBuffer);
|
|
15666
|
-
console.log(
|
|
15688
|
+
console.log(chalk11.gray("Syncing local files..."));
|
|
15667
15689
|
const remoteFiles = await listTarFiles(tarPath);
|
|
15668
15690
|
const remoteFilesSet = new Set(
|
|
15669
15691
|
remoteFiles.map((f) => f.replace(/\\/g, "/"))
|
|
@@ -15671,10 +15693,10 @@ var pullCommand2 = new Command9().name("pull").description("Pull cloud artifact
|
|
|
15671
15693
|
const removedCount = await removeExtraFiles(cwd, remoteFilesSet);
|
|
15672
15694
|
if (removedCount > 0) {
|
|
15673
15695
|
console.log(
|
|
15674
|
-
|
|
15696
|
+
chalk11.green(`\u2713 Removed ${removedCount} files not in remote`)
|
|
15675
15697
|
);
|
|
15676
15698
|
}
|
|
15677
|
-
console.log(
|
|
15699
|
+
console.log(chalk11.gray("Extracting files..."));
|
|
15678
15700
|
await tar6.extract({
|
|
15679
15701
|
file: tarPath,
|
|
15680
15702
|
cwd,
|
|
@@ -15682,11 +15704,11 @@ var pullCommand2 = new Command9().name("pull").description("Pull cloud artifact
|
|
|
15682
15704
|
});
|
|
15683
15705
|
await fs8.promises.unlink(tarPath);
|
|
15684
15706
|
await fs8.promises.rmdir(tmpDir);
|
|
15685
|
-
console.log(
|
|
15707
|
+
console.log(chalk11.green(`\u2713 Extracted ${remoteFiles.length} files`));
|
|
15686
15708
|
} catch (error43) {
|
|
15687
|
-
console.error(
|
|
15709
|
+
console.error(chalk11.red("\u2717 Pull failed"));
|
|
15688
15710
|
if (error43 instanceof Error) {
|
|
15689
|
-
console.error(
|
|
15711
|
+
console.error(chalk11.gray(` ${error43.message}`));
|
|
15690
15712
|
}
|
|
15691
15713
|
process.exit(1);
|
|
15692
15714
|
}
|
|
@@ -15697,7 +15719,7 @@ var artifactCommand = new Command10().name("artifact").description("Manage cloud
|
|
|
15697
15719
|
|
|
15698
15720
|
// src/commands/cook.ts
|
|
15699
15721
|
import { Command as Command11 } from "commander";
|
|
15700
|
-
import
|
|
15722
|
+
import chalk12 from "chalk";
|
|
15701
15723
|
import { readFile as readFile5, mkdir as mkdir5 } from "fs/promises";
|
|
15702
15724
|
import { existsSync as existsSync5 } from "fs";
|
|
15703
15725
|
import path12 from "path";
|
|
@@ -15782,9 +15804,9 @@ function escapeRegExp(str) {
|
|
|
15782
15804
|
}
|
|
15783
15805
|
var cookCommand = new Command11().name("cook").description("One-click agent preparation and execution from vm0.yaml").argument("[prompt]", "Prompt for the agent").action(async (prompt) => {
|
|
15784
15806
|
const cwd = process.cwd();
|
|
15785
|
-
console.log(
|
|
15807
|
+
console.log(chalk12.blue(`Reading config: ${CONFIG_FILE3}`));
|
|
15786
15808
|
if (!existsSync5(CONFIG_FILE3)) {
|
|
15787
|
-
console.error(
|
|
15809
|
+
console.error(chalk12.red(`\u2717 Config file not found: ${CONFIG_FILE3}`));
|
|
15788
15810
|
process.exit(1);
|
|
15789
15811
|
}
|
|
15790
15812
|
let config2;
|
|
@@ -15792,32 +15814,32 @@ var cookCommand = new Command11().name("cook").description("One-click agent prep
|
|
|
15792
15814
|
const content = await readFile5(CONFIG_FILE3, "utf8");
|
|
15793
15815
|
config2 = parseYaml3(content);
|
|
15794
15816
|
} catch (error43) {
|
|
15795
|
-
console.error(
|
|
15817
|
+
console.error(chalk12.red("\u2717 Invalid YAML format"));
|
|
15796
15818
|
if (error43 instanceof Error) {
|
|
15797
|
-
console.error(
|
|
15819
|
+
console.error(chalk12.gray(` ${error43.message}`));
|
|
15798
15820
|
}
|
|
15799
15821
|
process.exit(1);
|
|
15800
15822
|
}
|
|
15801
15823
|
const validation = validateAgentCompose(config2);
|
|
15802
15824
|
if (!validation.valid) {
|
|
15803
|
-
console.error(
|
|
15825
|
+
console.error(chalk12.red(`\u2717 ${validation.error}`));
|
|
15804
15826
|
process.exit(1);
|
|
15805
15827
|
}
|
|
15806
15828
|
const agentNames = Object.keys(config2.agents);
|
|
15807
15829
|
const agentName = agentNames[0];
|
|
15808
15830
|
const volumeCount = config2.volumes ? Object.keys(config2.volumes).length : 0;
|
|
15809
15831
|
console.log(
|
|
15810
|
-
|
|
15832
|
+
chalk12.green(`\u2713 Config validated: 1 agent, ${volumeCount} volume(s)`)
|
|
15811
15833
|
);
|
|
15812
15834
|
if (config2.volumes && Object.keys(config2.volumes).length > 0) {
|
|
15813
15835
|
console.log();
|
|
15814
|
-
console.log(
|
|
15836
|
+
console.log(chalk12.blue("Processing volumes..."));
|
|
15815
15837
|
for (const volumeConfig of Object.values(config2.volumes)) {
|
|
15816
15838
|
const volumeDir = path12.join(cwd, volumeConfig.name);
|
|
15817
|
-
console.log(
|
|
15839
|
+
console.log(chalk12.gray(` ${volumeConfig.name}/`));
|
|
15818
15840
|
if (!existsSync5(volumeDir)) {
|
|
15819
15841
|
console.error(
|
|
15820
|
-
|
|
15842
|
+
chalk12.red(
|
|
15821
15843
|
` \u2717 Directory not found. Create the directory and add files first.`
|
|
15822
15844
|
)
|
|
15823
15845
|
);
|
|
@@ -15830,30 +15852,30 @@ var cookCommand = new Command11().name("cook").description("One-click agent prep
|
|
|
15830
15852
|
cwd: volumeDir,
|
|
15831
15853
|
silent: true
|
|
15832
15854
|
});
|
|
15833
|
-
console.log(
|
|
15855
|
+
console.log(chalk12.green(` \u2713 Initialized`));
|
|
15834
15856
|
}
|
|
15835
15857
|
await execVm0Command(["volume", "push"], {
|
|
15836
15858
|
cwd: volumeDir,
|
|
15837
15859
|
silent: true
|
|
15838
15860
|
});
|
|
15839
|
-
console.log(
|
|
15861
|
+
console.log(chalk12.green(` \u2713 Pushed`));
|
|
15840
15862
|
} catch (error43) {
|
|
15841
|
-
console.error(
|
|
15863
|
+
console.error(chalk12.red(` \u2717 Failed`));
|
|
15842
15864
|
if (error43 instanceof Error) {
|
|
15843
|
-
console.error(
|
|
15865
|
+
console.error(chalk12.gray(` ${error43.message}`));
|
|
15844
15866
|
}
|
|
15845
15867
|
process.exit(1);
|
|
15846
15868
|
}
|
|
15847
15869
|
}
|
|
15848
15870
|
}
|
|
15849
15871
|
console.log();
|
|
15850
|
-
console.log(
|
|
15872
|
+
console.log(chalk12.blue("Processing artifact..."));
|
|
15851
15873
|
const artifactDir = path12.join(cwd, ARTIFACT_DIR);
|
|
15852
|
-
console.log(
|
|
15874
|
+
console.log(chalk12.gray(` ${ARTIFACT_DIR}/`));
|
|
15853
15875
|
try {
|
|
15854
15876
|
if (!existsSync5(artifactDir)) {
|
|
15855
15877
|
await mkdir5(artifactDir, { recursive: true });
|
|
15856
|
-
console.log(
|
|
15878
|
+
console.log(chalk12.green(` \u2713 Created directory`));
|
|
15857
15879
|
}
|
|
15858
15880
|
const existingConfig = await readStorageConfig(artifactDir);
|
|
15859
15881
|
if (!existingConfig) {
|
|
@@ -15861,38 +15883,38 @@ var cookCommand = new Command11().name("cook").description("One-click agent prep
|
|
|
15861
15883
|
cwd: artifactDir,
|
|
15862
15884
|
silent: true
|
|
15863
15885
|
});
|
|
15864
|
-
console.log(
|
|
15886
|
+
console.log(chalk12.green(` \u2713 Initialized`));
|
|
15865
15887
|
}
|
|
15866
15888
|
await execVm0Command(["artifact", "push"], {
|
|
15867
15889
|
cwd: artifactDir,
|
|
15868
15890
|
silent: true
|
|
15869
15891
|
});
|
|
15870
|
-
console.log(
|
|
15892
|
+
console.log(chalk12.green(` \u2713 Pushed`));
|
|
15871
15893
|
} catch (error43) {
|
|
15872
|
-
console.error(
|
|
15894
|
+
console.error(chalk12.red(` \u2717 Failed`));
|
|
15873
15895
|
if (error43 instanceof Error) {
|
|
15874
|
-
console.error(
|
|
15896
|
+
console.error(chalk12.gray(` ${error43.message}`));
|
|
15875
15897
|
}
|
|
15876
15898
|
process.exit(1);
|
|
15877
15899
|
}
|
|
15878
15900
|
console.log();
|
|
15879
|
-
console.log(
|
|
15901
|
+
console.log(chalk12.blue("Uploading compose..."));
|
|
15880
15902
|
try {
|
|
15881
15903
|
await execVm0Command(["compose", CONFIG_FILE3], {
|
|
15882
15904
|
cwd,
|
|
15883
15905
|
silent: true
|
|
15884
15906
|
});
|
|
15885
|
-
console.log(
|
|
15907
|
+
console.log(chalk12.green(`\u2713 Compose uploaded: ${agentName}`));
|
|
15886
15908
|
} catch (error43) {
|
|
15887
|
-
console.error(
|
|
15909
|
+
console.error(chalk12.red(`\u2717 Compose failed`));
|
|
15888
15910
|
if (error43 instanceof Error) {
|
|
15889
|
-
console.error(
|
|
15911
|
+
console.error(chalk12.gray(` ${error43.message}`));
|
|
15890
15912
|
}
|
|
15891
15913
|
process.exit(1);
|
|
15892
15914
|
}
|
|
15893
15915
|
if (prompt) {
|
|
15894
15916
|
console.log();
|
|
15895
|
-
console.log(
|
|
15917
|
+
console.log(chalk12.blue(`Running agent: ${agentName}`));
|
|
15896
15918
|
console.log();
|
|
15897
15919
|
let runOutput;
|
|
15898
15920
|
try {
|
|
@@ -15913,17 +15935,17 @@ var cookCommand = new Command11().name("cook").description("One-click agent prep
|
|
|
15913
15935
|
);
|
|
15914
15936
|
if (serverVersion) {
|
|
15915
15937
|
console.log();
|
|
15916
|
-
console.log(
|
|
15938
|
+
console.log(chalk12.blue("Pulling updated artifact..."));
|
|
15917
15939
|
try {
|
|
15918
15940
|
await execVm0Command(["artifact", "pull"], {
|
|
15919
15941
|
cwd: artifactDir,
|
|
15920
15942
|
silent: true
|
|
15921
15943
|
});
|
|
15922
|
-
console.log(
|
|
15944
|
+
console.log(chalk12.green(`\u2713 Artifact pulled (${serverVersion})`));
|
|
15923
15945
|
} catch (error43) {
|
|
15924
|
-
console.error(
|
|
15946
|
+
console.error(chalk12.red(`\u2717 Artifact pull failed`));
|
|
15925
15947
|
if (error43 instanceof Error) {
|
|
15926
|
-
console.error(
|
|
15948
|
+
console.error(chalk12.gray(` ${error43.message}`));
|
|
15927
15949
|
}
|
|
15928
15950
|
}
|
|
15929
15951
|
}
|
|
@@ -15931,7 +15953,7 @@ var cookCommand = new Command11().name("cook").description("One-click agent prep
|
|
|
15931
15953
|
console.log();
|
|
15932
15954
|
console.log(" Run your agent:");
|
|
15933
15955
|
console.log(
|
|
15934
|
-
|
|
15956
|
+
chalk12.cyan(
|
|
15935
15957
|
` vm0 run ${agentName} --artifact-name ${ARTIFACT_DIR} "your prompt"`
|
|
15936
15958
|
)
|
|
15937
15959
|
);
|
|
@@ -15943,7 +15965,7 @@ import { Command as Command15 } from "commander";
|
|
|
15943
15965
|
|
|
15944
15966
|
// src/commands/image/build.ts
|
|
15945
15967
|
import { Command as Command12 } from "commander";
|
|
15946
|
-
import
|
|
15968
|
+
import chalk13 from "chalk";
|
|
15947
15969
|
import { readFile as readFile6 } from "fs/promises";
|
|
15948
15970
|
import { existsSync as existsSync6 } from "fs";
|
|
15949
15971
|
var sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
@@ -15951,13 +15973,13 @@ var buildCommand = new Command12().name("build").description("Build a custom ima
|
|
|
15951
15973
|
async (options) => {
|
|
15952
15974
|
const { file: file2, name, deleteExisting } = options;
|
|
15953
15975
|
if (!existsSync6(file2)) {
|
|
15954
|
-
console.error(
|
|
15976
|
+
console.error(chalk13.red(`\u2717 Dockerfile not found: ${file2}`));
|
|
15955
15977
|
process.exit(1);
|
|
15956
15978
|
}
|
|
15957
15979
|
const nameRegex = /^[a-zA-Z0-9][a-zA-Z0-9-]{1,62}[a-zA-Z0-9]$/;
|
|
15958
15980
|
if (!nameRegex.test(name)) {
|
|
15959
15981
|
console.error(
|
|
15960
|
-
|
|
15982
|
+
chalk13.red(
|
|
15961
15983
|
"\u2717 Invalid name format. Must be 3-64 characters, letters, numbers, and hyphens only."
|
|
15962
15984
|
)
|
|
15963
15985
|
);
|
|
@@ -15965,7 +15987,7 @@ var buildCommand = new Command12().name("build").description("Build a custom ima
|
|
|
15965
15987
|
}
|
|
15966
15988
|
if (name.startsWith("vm0-")) {
|
|
15967
15989
|
console.error(
|
|
15968
|
-
|
|
15990
|
+
chalk13.red(
|
|
15969
15991
|
'\u2717 Invalid name. Cannot start with "vm0-" (reserved prefix).'
|
|
15970
15992
|
)
|
|
15971
15993
|
);
|
|
@@ -15973,8 +15995,8 @@ var buildCommand = new Command12().name("build").description("Build a custom ima
|
|
|
15973
15995
|
}
|
|
15974
15996
|
try {
|
|
15975
15997
|
const dockerfile = await readFile6(file2, "utf8");
|
|
15976
|
-
console.log(
|
|
15977
|
-
console.log(
|
|
15998
|
+
console.log(chalk13.blue(`Building image: ${name}`));
|
|
15999
|
+
console.log(chalk13.gray(` Dockerfile: ${file2}`));
|
|
15978
16000
|
console.log();
|
|
15979
16001
|
const buildInfo = await apiClient.createImage({
|
|
15980
16002
|
dockerfile,
|
|
@@ -15982,7 +16004,7 @@ var buildCommand = new Command12().name("build").description("Build a custom ima
|
|
|
15982
16004
|
deleteExisting
|
|
15983
16005
|
});
|
|
15984
16006
|
const { imageId, buildId } = buildInfo;
|
|
15985
|
-
console.log(
|
|
16007
|
+
console.log(chalk13.gray(` Build ID: ${buildId}`));
|
|
15986
16008
|
console.log();
|
|
15987
16009
|
let logsOffset = 0;
|
|
15988
16010
|
let status = "building";
|
|
@@ -15998,7 +16020,7 @@ var buildCommand = new Command12().name("build").description("Build a custom ima
|
|
|
15998
16020
|
}
|
|
15999
16021
|
const statusData = await statusResponse.json();
|
|
16000
16022
|
for (const log of statusData.logs) {
|
|
16001
|
-
console.log(
|
|
16023
|
+
console.log(chalk13.gray(` ${log}`));
|
|
16002
16024
|
}
|
|
16003
16025
|
logsOffset = statusData.logsOffset;
|
|
16004
16026
|
status = statusData.status;
|
|
@@ -16008,27 +16030,27 @@ var buildCommand = new Command12().name("build").description("Build a custom ima
|
|
|
16008
16030
|
}
|
|
16009
16031
|
console.log();
|
|
16010
16032
|
if (status === "ready") {
|
|
16011
|
-
console.log(
|
|
16033
|
+
console.log(chalk13.green(`\u2713 Image built: ${name}`));
|
|
16012
16034
|
console.log();
|
|
16013
16035
|
console.log("Use in vm0.yaml:");
|
|
16014
|
-
console.log(
|
|
16015
|
-
console.log(
|
|
16016
|
-
console.log(
|
|
16036
|
+
console.log(chalk13.cyan(` agents:`));
|
|
16037
|
+
console.log(chalk13.cyan(` your-agent:`));
|
|
16038
|
+
console.log(chalk13.cyan(` image: "${name}"`));
|
|
16017
16039
|
} else {
|
|
16018
|
-
console.error(
|
|
16040
|
+
console.error(chalk13.red(`\u2717 Build failed`));
|
|
16019
16041
|
process.exit(1);
|
|
16020
16042
|
}
|
|
16021
16043
|
} catch (error43) {
|
|
16022
16044
|
if (error43 instanceof Error) {
|
|
16023
16045
|
if (error43.message.includes("Not authenticated")) {
|
|
16024
16046
|
console.error(
|
|
16025
|
-
|
|
16047
|
+
chalk13.red("\u2717 Not authenticated. Run: vm0 auth login")
|
|
16026
16048
|
);
|
|
16027
16049
|
} else {
|
|
16028
|
-
console.error(
|
|
16050
|
+
console.error(chalk13.red(`\u2717 ${error43.message}`));
|
|
16029
16051
|
}
|
|
16030
16052
|
} else {
|
|
16031
|
-
console.error(
|
|
16053
|
+
console.error(chalk13.red("\u2717 An unexpected error occurred"));
|
|
16032
16054
|
}
|
|
16033
16055
|
process.exit(1);
|
|
16034
16056
|
}
|
|
@@ -16037,7 +16059,7 @@ var buildCommand = new Command12().name("build").description("Build a custom ima
|
|
|
16037
16059
|
|
|
16038
16060
|
// src/commands/image/list.ts
|
|
16039
16061
|
import { Command as Command13 } from "commander";
|
|
16040
|
-
import
|
|
16062
|
+
import chalk14 from "chalk";
|
|
16041
16063
|
var listCommand = new Command13().name("list").alias("ls").description("List your custom images").action(async () => {
|
|
16042
16064
|
try {
|
|
16043
16065
|
const response = await apiClient.get("/api/images");
|
|
@@ -16050,43 +16072,43 @@ var listCommand = new Command13().name("list").alias("ls").description("List you
|
|
|
16050
16072
|
const data = await response.json();
|
|
16051
16073
|
const { images } = data;
|
|
16052
16074
|
if (images.length === 0) {
|
|
16053
|
-
console.log(
|
|
16075
|
+
console.log(chalk14.gray("No images found."));
|
|
16054
16076
|
console.log();
|
|
16055
16077
|
console.log("Build your first image:");
|
|
16056
16078
|
console.log(
|
|
16057
|
-
|
|
16079
|
+
chalk14.cyan(" vm0 image build --file Dockerfile --name my-image")
|
|
16058
16080
|
);
|
|
16059
16081
|
return;
|
|
16060
16082
|
}
|
|
16061
|
-
console.log(
|
|
16083
|
+
console.log(chalk14.bold("Your images:"));
|
|
16062
16084
|
console.log();
|
|
16063
16085
|
console.log(
|
|
16064
|
-
|
|
16086
|
+
chalk14.gray(
|
|
16065
16087
|
`${"NAME".padEnd(30)} ${"STATUS".padEnd(12)} ${"CREATED".padEnd(20)}`
|
|
16066
16088
|
)
|
|
16067
16089
|
);
|
|
16068
|
-
console.log(
|
|
16090
|
+
console.log(chalk14.gray("-".repeat(62)));
|
|
16069
16091
|
for (const image of images) {
|
|
16070
|
-
const statusColor = image.status === "ready" ?
|
|
16092
|
+
const statusColor = image.status === "ready" ? chalk14.green : image.status === "building" ? chalk14.yellow : chalk14.red;
|
|
16071
16093
|
const createdAt = new Date(image.createdAt).toLocaleString();
|
|
16072
16094
|
console.log(
|
|
16073
16095
|
`${image.alias.padEnd(30)} ${statusColor(image.status.padEnd(12))} ${createdAt.padEnd(20)}`
|
|
16074
16096
|
);
|
|
16075
16097
|
if (image.status === "error" && image.errorMessage) {
|
|
16076
|
-
console.log(
|
|
16098
|
+
console.log(chalk14.red(` Error: ${image.errorMessage}`));
|
|
16077
16099
|
}
|
|
16078
16100
|
}
|
|
16079
16101
|
console.log();
|
|
16080
|
-
console.log(
|
|
16102
|
+
console.log(chalk14.gray(`Total: ${images.length} image(s)`));
|
|
16081
16103
|
} catch (error43) {
|
|
16082
16104
|
if (error43 instanceof Error) {
|
|
16083
16105
|
if (error43.message.includes("Not authenticated")) {
|
|
16084
|
-
console.error(
|
|
16106
|
+
console.error(chalk14.red("Not authenticated. Run: vm0 auth login"));
|
|
16085
16107
|
} else {
|
|
16086
|
-
console.error(
|
|
16108
|
+
console.error(chalk14.red(`Error: ${error43.message}`));
|
|
16087
16109
|
}
|
|
16088
16110
|
} else {
|
|
16089
|
-
console.error(
|
|
16111
|
+
console.error(chalk14.red("An unexpected error occurred"));
|
|
16090
16112
|
}
|
|
16091
16113
|
process.exit(1);
|
|
16092
16114
|
}
|
|
@@ -16094,7 +16116,7 @@ var listCommand = new Command13().name("list").alias("ls").description("List you
|
|
|
16094
16116
|
|
|
16095
16117
|
// src/commands/image/delete.ts
|
|
16096
16118
|
import { Command as Command14 } from "commander";
|
|
16097
|
-
import
|
|
16119
|
+
import chalk15 from "chalk";
|
|
16098
16120
|
import * as readline from "readline";
|
|
16099
16121
|
var deleteCommand = new Command14().name("delete").alias("rm").description("Delete a custom image").argument("<name>", "Name of the image to delete").option("-f, --force", "Skip confirmation prompt").action(async (name, options) => {
|
|
16100
16122
|
try {
|
|
@@ -16108,7 +16130,7 @@ var deleteCommand = new Command14().name("delete").alias("rm").description("Dele
|
|
|
16108
16130
|
const data = await listResponse.json();
|
|
16109
16131
|
const image = data.images.find((img) => img.alias === name);
|
|
16110
16132
|
if (!image) {
|
|
16111
|
-
console.error(
|
|
16133
|
+
console.error(chalk15.red(`Image not found: ${name}`));
|
|
16112
16134
|
process.exit(1);
|
|
16113
16135
|
}
|
|
16114
16136
|
if (!options.force) {
|
|
@@ -16118,7 +16140,7 @@ var deleteCommand = new Command14().name("delete").alias("rm").description("Dele
|
|
|
16118
16140
|
});
|
|
16119
16141
|
const answer = await new Promise((resolve2) => {
|
|
16120
16142
|
rl.question(
|
|
16121
|
-
|
|
16143
|
+
chalk15.yellow(`Delete image "${name}"? [y/N] `),
|
|
16122
16144
|
(answer2) => {
|
|
16123
16145
|
rl.close();
|
|
16124
16146
|
resolve2(answer2);
|
|
@@ -16126,7 +16148,7 @@ var deleteCommand = new Command14().name("delete").alias("rm").description("Dele
|
|
|
16126
16148
|
);
|
|
16127
16149
|
});
|
|
16128
16150
|
if (answer.toLowerCase() !== "y" && answer.toLowerCase() !== "yes") {
|
|
16129
|
-
console.log(
|
|
16151
|
+
console.log(chalk15.gray("Cancelled."));
|
|
16130
16152
|
return;
|
|
16131
16153
|
}
|
|
16132
16154
|
}
|
|
@@ -16137,16 +16159,16 @@ var deleteCommand = new Command14().name("delete").alias("rm").description("Dele
|
|
|
16137
16159
|
error43.error?.message || "Failed to delete image"
|
|
16138
16160
|
);
|
|
16139
16161
|
}
|
|
16140
|
-
console.log(
|
|
16162
|
+
console.log(chalk15.green(`Deleted image: ${name}`));
|
|
16141
16163
|
} catch (error43) {
|
|
16142
16164
|
if (error43 instanceof Error) {
|
|
16143
16165
|
if (error43.message.includes("Not authenticated")) {
|
|
16144
|
-
console.error(
|
|
16166
|
+
console.error(chalk15.red("Not authenticated. Run: vm0 auth login"));
|
|
16145
16167
|
} else {
|
|
16146
|
-
console.error(
|
|
16168
|
+
console.error(chalk15.red(`Error: ${error43.message}`));
|
|
16147
16169
|
}
|
|
16148
16170
|
} else {
|
|
16149
|
-
console.error(
|
|
16171
|
+
console.error(chalk15.red("An unexpected error occurred"));
|
|
16150
16172
|
}
|
|
16151
16173
|
process.exit(1);
|
|
16152
16174
|
}
|
|
@@ -16157,7 +16179,7 @@ var imageCommand = new Command15().name("image").description("Manage custom imag
|
|
|
16157
16179
|
|
|
16158
16180
|
// src/commands/logs/index.ts
|
|
16159
16181
|
import { Command as Command16 } from "commander";
|
|
16160
|
-
import
|
|
16182
|
+
import chalk16 from "chalk";
|
|
16161
16183
|
|
|
16162
16184
|
// src/lib/time-parser.ts
|
|
16163
16185
|
function parseTime(timeStr) {
|
|
@@ -16219,23 +16241,23 @@ function formatMetric(metric) {
|
|
|
16219
16241
|
function formatNetworkLog(entry) {
|
|
16220
16242
|
let statusColor;
|
|
16221
16243
|
if (entry.status >= 200 && entry.status < 300) {
|
|
16222
|
-
statusColor =
|
|
16244
|
+
statusColor = chalk16.green;
|
|
16223
16245
|
} else if (entry.status >= 300 && entry.status < 400) {
|
|
16224
|
-
statusColor =
|
|
16246
|
+
statusColor = chalk16.yellow;
|
|
16225
16247
|
} else if (entry.status >= 400) {
|
|
16226
|
-
statusColor =
|
|
16248
|
+
statusColor = chalk16.red;
|
|
16227
16249
|
} else {
|
|
16228
|
-
statusColor =
|
|
16250
|
+
statusColor = chalk16.gray;
|
|
16229
16251
|
}
|
|
16230
16252
|
let latencyColor;
|
|
16231
16253
|
if (entry.latency_ms < 500) {
|
|
16232
|
-
latencyColor =
|
|
16254
|
+
latencyColor = chalk16.green;
|
|
16233
16255
|
} else if (entry.latency_ms < 2e3) {
|
|
16234
|
-
latencyColor =
|
|
16256
|
+
latencyColor = chalk16.yellow;
|
|
16235
16257
|
} else {
|
|
16236
|
-
latencyColor =
|
|
16258
|
+
latencyColor = chalk16.red;
|
|
16237
16259
|
}
|
|
16238
|
-
return `[${entry.timestamp}] ${
|
|
16260
|
+
return `[${entry.timestamp}] ${chalk16.cyan(entry.method.padEnd(6))} ${statusColor(entry.status)} ${latencyColor(entry.latency_ms + "ms")} ${formatBytes5(entry.request_size)}/${formatBytes5(entry.response_size)} ${chalk16.gray(entry.url)}`;
|
|
16239
16261
|
}
|
|
16240
16262
|
function renderAgentEvent(event) {
|
|
16241
16263
|
const parsed = ClaudeEventParser.parse(
|
|
@@ -16255,7 +16277,7 @@ function getLogType(options) {
|
|
|
16255
16277
|
].filter(Boolean).length;
|
|
16256
16278
|
if (selected > 1) {
|
|
16257
16279
|
console.error(
|
|
16258
|
-
|
|
16280
|
+
chalk16.red(
|
|
16259
16281
|
"Options --agent, --system, --metrics, and --network are mutually exclusive"
|
|
16260
16282
|
)
|
|
16261
16283
|
);
|
|
@@ -16308,7 +16330,7 @@ var logsCommand = new Command16().name("logs").description("View logs for an age
|
|
|
16308
16330
|
async function showAgentEvents(runId, options) {
|
|
16309
16331
|
const response = await apiClient.getAgentEvents(runId, options);
|
|
16310
16332
|
if (response.events.length === 0) {
|
|
16311
|
-
console.log(
|
|
16333
|
+
console.log(chalk16.yellow("No agent events found for this run."));
|
|
16312
16334
|
return;
|
|
16313
16335
|
}
|
|
16314
16336
|
for (const event of response.events) {
|
|
@@ -16317,7 +16339,7 @@ async function showAgentEvents(runId, options) {
|
|
|
16317
16339
|
if (response.hasMore) {
|
|
16318
16340
|
console.log();
|
|
16319
16341
|
console.log(
|
|
16320
|
-
|
|
16342
|
+
chalk16.gray(
|
|
16321
16343
|
`Showing ${response.events.length} events. Use --limit to see more.`
|
|
16322
16344
|
)
|
|
16323
16345
|
);
|
|
@@ -16326,21 +16348,21 @@ async function showAgentEvents(runId, options) {
|
|
|
16326
16348
|
async function showSystemLog(runId, options) {
|
|
16327
16349
|
const response = await apiClient.getSystemLog(runId, options);
|
|
16328
16350
|
if (!response.systemLog) {
|
|
16329
|
-
console.log(
|
|
16351
|
+
console.log(chalk16.yellow("No system log found for this run."));
|
|
16330
16352
|
return;
|
|
16331
16353
|
}
|
|
16332
16354
|
console.log(response.systemLog);
|
|
16333
16355
|
if (response.hasMore) {
|
|
16334
16356
|
console.log();
|
|
16335
16357
|
console.log(
|
|
16336
|
-
|
|
16358
|
+
chalk16.gray("More log entries available. Use --limit to see more.")
|
|
16337
16359
|
);
|
|
16338
16360
|
}
|
|
16339
16361
|
}
|
|
16340
16362
|
async function showMetrics(runId, options) {
|
|
16341
16363
|
const response = await apiClient.getMetrics(runId, options);
|
|
16342
16364
|
if (response.metrics.length === 0) {
|
|
16343
|
-
console.log(
|
|
16365
|
+
console.log(chalk16.yellow("No metrics found for this run."));
|
|
16344
16366
|
return;
|
|
16345
16367
|
}
|
|
16346
16368
|
for (const metric of response.metrics) {
|
|
@@ -16349,7 +16371,7 @@ async function showMetrics(runId, options) {
|
|
|
16349
16371
|
if (response.hasMore) {
|
|
16350
16372
|
console.log();
|
|
16351
16373
|
console.log(
|
|
16352
|
-
|
|
16374
|
+
chalk16.gray(
|
|
16353
16375
|
`Showing ${response.metrics.length} metrics. Use --limit to see more.`
|
|
16354
16376
|
)
|
|
16355
16377
|
);
|
|
@@ -16359,7 +16381,7 @@ async function showNetworkLogs(runId, options) {
|
|
|
16359
16381
|
const response = await apiClient.getNetworkLogs(runId, options);
|
|
16360
16382
|
if (response.networkLogs.length === 0) {
|
|
16361
16383
|
console.log(
|
|
16362
|
-
|
|
16384
|
+
chalk16.yellow(
|
|
16363
16385
|
"No network logs found for this run. Network logs are only captured when beta_network_security is enabled."
|
|
16364
16386
|
)
|
|
16365
16387
|
);
|
|
@@ -16371,7 +16393,7 @@ async function showNetworkLogs(runId, options) {
|
|
|
16371
16393
|
if (response.hasMore) {
|
|
16372
16394
|
console.log();
|
|
16373
16395
|
console.log(
|
|
16374
|
-
|
|
16396
|
+
chalk16.gray(
|
|
16375
16397
|
`Showing ${response.networkLogs.length} network logs. Use --limit to see more.`
|
|
16376
16398
|
)
|
|
16377
16399
|
);
|
|
@@ -16380,25 +16402,25 @@ async function showNetworkLogs(runId, options) {
|
|
|
16380
16402
|
function handleError(error43, runId) {
|
|
16381
16403
|
if (error43 instanceof Error) {
|
|
16382
16404
|
if (error43.message.includes("Not authenticated")) {
|
|
16383
|
-
console.error(
|
|
16405
|
+
console.error(chalk16.red("Not authenticated. Run: vm0 auth login"));
|
|
16384
16406
|
} else if (error43.message.includes("not found")) {
|
|
16385
|
-
console.error(
|
|
16407
|
+
console.error(chalk16.red(`Run not found: ${runId}`));
|
|
16386
16408
|
} else if (error43.message.includes("Invalid time format")) {
|
|
16387
|
-
console.error(
|
|
16409
|
+
console.error(chalk16.red(error43.message));
|
|
16388
16410
|
} else {
|
|
16389
|
-
console.error(
|
|
16390
|
-
console.error(
|
|
16411
|
+
console.error(chalk16.red("Failed to fetch logs"));
|
|
16412
|
+
console.error(chalk16.gray(` ${error43.message}`));
|
|
16391
16413
|
}
|
|
16392
16414
|
} else {
|
|
16393
|
-
console.error(
|
|
16415
|
+
console.error(chalk16.red("An unexpected error occurred"));
|
|
16394
16416
|
}
|
|
16395
16417
|
}
|
|
16396
16418
|
|
|
16397
16419
|
// src/index.ts
|
|
16398
16420
|
var program = new Command17();
|
|
16399
|
-
program.name("vm0").description("VM0 CLI - A modern build tool").version("4.
|
|
16421
|
+
program.name("vm0").description("VM0 CLI - A modern build tool").version("4.9.0");
|
|
16400
16422
|
program.command("info").description("Display environment information").action(async () => {
|
|
16401
|
-
console.log(
|
|
16423
|
+
console.log(chalk17.cyan("System Information:"));
|
|
16402
16424
|
console.log(`Node Version: ${process.version}`);
|
|
16403
16425
|
console.log(`Platform: ${process.platform}`);
|
|
16404
16426
|
console.log(`Architecture: ${process.arch}`);
|