@vm0/cli 8.1.0 → 9.0.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 +742 -727
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { Command as Command45 } from "commander";
|
|
5
|
-
import
|
|
5
|
+
import chalk46 from "chalk";
|
|
6
6
|
|
|
7
7
|
// src/lib/api/auth.ts
|
|
8
8
|
import chalk from "chalk";
|
|
@@ -142,16 +142,16 @@ Authentication failed: ${tokenResult.error_description ?? tokenResult.error}`
|
|
|
142
142
|
}
|
|
143
143
|
async function logout() {
|
|
144
144
|
await clearConfig();
|
|
145
|
-
console.log(chalk.green("Successfully logged out"));
|
|
145
|
+
console.log(chalk.green("\u2713 Successfully logged out"));
|
|
146
146
|
console.log("Your credentials have been cleared.");
|
|
147
147
|
}
|
|
148
148
|
async function checkAuthStatus() {
|
|
149
149
|
const config = await loadConfig();
|
|
150
150
|
if (config.token) {
|
|
151
|
-
console.log(chalk.green("Authenticated"));
|
|
151
|
+
console.log(chalk.green("\u2713 Authenticated"));
|
|
152
152
|
console.log("You are logged in to VM0.");
|
|
153
153
|
} else {
|
|
154
|
-
console.log(chalk.
|
|
154
|
+
console.log(chalk.red("\u2717 Not authenticated"));
|
|
155
155
|
console.log("Run 'vm0 auth login' to authenticate.");
|
|
156
156
|
}
|
|
157
157
|
if (process.env.VM0_TOKEN) {
|
|
@@ -161,7 +161,7 @@ async function checkAuthStatus() {
|
|
|
161
161
|
async function setupToken() {
|
|
162
162
|
const token = await getToken();
|
|
163
163
|
if (!token) {
|
|
164
|
-
console.error(chalk.red("
|
|
164
|
+
console.error(chalk.red("\u2717 Not authenticated"));
|
|
165
165
|
console.error("");
|
|
166
166
|
console.error("To get a token for CI/CD:");
|
|
167
167
|
console.error(" 1. Run 'vm0 auth login' to authenticate");
|
|
@@ -189,7 +189,6 @@ import { readFile as readFile4 } from "fs/promises";
|
|
|
189
189
|
import { existsSync as existsSync3 } from "fs";
|
|
190
190
|
import { dirname as dirname2 } from "path";
|
|
191
191
|
import { parse as parseYaml2 } from "yaml";
|
|
192
|
-
import prompts from "prompts";
|
|
193
192
|
|
|
194
193
|
// ../../packages/core/src/variable-expander.ts
|
|
195
194
|
var VARIABLE_PATTERN = /\$\{\{\s*(env|vars|secrets|credentials)\.([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g;
|
|
@@ -2283,6 +2282,9 @@ var realtimeTokenContract = c14.router({
|
|
|
2283
2282
|
}
|
|
2284
2283
|
});
|
|
2285
2284
|
|
|
2285
|
+
// ../../packages/core/src/contracts/platform.ts
|
|
2286
|
+
import { z as z19 } from "zod";
|
|
2287
|
+
|
|
2286
2288
|
// ../../packages/core/src/contracts/public/common.ts
|
|
2287
2289
|
import { z as z18 } from "zod";
|
|
2288
2290
|
var publicApiErrorTypeSchema = z18.enum([
|
|
@@ -2303,12 +2305,12 @@ var publicApiErrorSchema = z18.object({
|
|
|
2303
2305
|
code: z18.string(),
|
|
2304
2306
|
message: z18.string(),
|
|
2305
2307
|
param: z18.string().optional(),
|
|
2306
|
-
|
|
2308
|
+
docUrl: z18.string().url().optional()
|
|
2307
2309
|
})
|
|
2308
2310
|
});
|
|
2309
2311
|
var paginationSchema = z18.object({
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
+
hasMore: z18.boolean(),
|
|
2313
|
+
nextCursor: z18.string().nullable()
|
|
2312
2314
|
});
|
|
2313
2315
|
function createPaginatedResponseSchema(dataSchema) {
|
|
2314
2316
|
return z18.object({
|
|
@@ -2323,29 +2325,92 @@ var listQuerySchema = z18.object({
|
|
|
2323
2325
|
var requestIdSchema = z18.string().uuid();
|
|
2324
2326
|
var timestampSchema = z18.string().datetime();
|
|
2325
2327
|
|
|
2326
|
-
// ../../packages/core/src/contracts/
|
|
2327
|
-
import { z as z19 } from "zod";
|
|
2328
|
+
// ../../packages/core/src/contracts/platform.ts
|
|
2328
2329
|
var c15 = initContract();
|
|
2329
|
-
var
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2330
|
+
var platformLogStatusSchema = z19.enum([
|
|
2331
|
+
"pending",
|
|
2332
|
+
"running",
|
|
2333
|
+
"completed",
|
|
2334
|
+
"failed",
|
|
2335
|
+
"timeout",
|
|
2336
|
+
"cancelled"
|
|
2337
|
+
]);
|
|
2338
|
+
var platformLogEntrySchema = z19.object({
|
|
2339
|
+
id: z19.string().uuid()
|
|
2340
|
+
});
|
|
2341
|
+
var platformLogsListResponseSchema = createPaginatedResponseSchema(
|
|
2342
|
+
platformLogEntrySchema
|
|
2343
|
+
);
|
|
2344
|
+
var artifactSchema = z19.object({
|
|
2345
|
+
name: z19.string().nullable(),
|
|
2346
|
+
version: z19.string().nullable()
|
|
2347
|
+
});
|
|
2348
|
+
var platformLogDetailSchema = z19.object({
|
|
2349
|
+
id: z19.string().uuid(),
|
|
2350
|
+
sessionId: z19.string().nullable(),
|
|
2351
|
+
agentName: z19.string(),
|
|
2352
|
+
provider: z19.string(),
|
|
2353
|
+
status: platformLogStatusSchema,
|
|
2354
|
+
prompt: z19.string(),
|
|
2355
|
+
error: z19.string().nullable(),
|
|
2356
|
+
createdAt: z19.string(),
|
|
2357
|
+
startedAt: z19.string().nullable(),
|
|
2358
|
+
completedAt: z19.string().nullable(),
|
|
2359
|
+
artifact: artifactSchema
|
|
2360
|
+
});
|
|
2361
|
+
var platformLogsListContract = c15.router({
|
|
2362
|
+
list: {
|
|
2363
|
+
method: "GET",
|
|
2364
|
+
path: "/api/platform/logs",
|
|
2365
|
+
query: listQuerySchema.extend({
|
|
2366
|
+
search: z19.string().optional()
|
|
2367
|
+
}),
|
|
2368
|
+
responses: {
|
|
2369
|
+
200: platformLogsListResponseSchema,
|
|
2370
|
+
401: apiErrorSchema
|
|
2371
|
+
},
|
|
2372
|
+
summary: "List agent run logs with pagination"
|
|
2373
|
+
}
|
|
2374
|
+
});
|
|
2375
|
+
var platformLogsByIdContract = c15.router({
|
|
2376
|
+
getById: {
|
|
2377
|
+
method: "GET",
|
|
2378
|
+
path: "/api/platform/logs/:id",
|
|
2379
|
+
pathParams: z19.object({
|
|
2380
|
+
id: z19.string().uuid("Invalid log ID")
|
|
2381
|
+
}),
|
|
2382
|
+
responses: {
|
|
2383
|
+
200: platformLogDetailSchema,
|
|
2384
|
+
401: apiErrorSchema,
|
|
2385
|
+
404: apiErrorSchema
|
|
2386
|
+
},
|
|
2387
|
+
summary: "Get agent run log details by ID"
|
|
2388
|
+
}
|
|
2389
|
+
});
|
|
2390
|
+
|
|
2391
|
+
// ../../packages/core/src/contracts/public/agents.ts
|
|
2392
|
+
import { z as z20 } from "zod";
|
|
2393
|
+
var c16 = initContract();
|
|
2394
|
+
var publicAgentSchema = z20.object({
|
|
2395
|
+
id: z20.string(),
|
|
2396
|
+
name: z20.string(),
|
|
2397
|
+
currentVersionId: z20.string().nullable(),
|
|
2398
|
+
createdAt: timestampSchema,
|
|
2399
|
+
updatedAt: timestampSchema
|
|
2400
|
+
});
|
|
2401
|
+
var agentVersionSchema = z20.object({
|
|
2402
|
+
id: z20.string(),
|
|
2403
|
+
agentId: z20.string(),
|
|
2404
|
+
versionNumber: z20.number(),
|
|
2405
|
+
createdAt: timestampSchema
|
|
2341
2406
|
});
|
|
2342
2407
|
var publicAgentDetailSchema = publicAgentSchema;
|
|
2343
2408
|
var paginatedAgentsSchema = createPaginatedResponseSchema(publicAgentSchema);
|
|
2344
2409
|
var paginatedAgentVersionsSchema = createPaginatedResponseSchema(agentVersionSchema);
|
|
2345
2410
|
var agentListQuerySchema = listQuerySchema.extend({
|
|
2346
|
-
name:
|
|
2411
|
+
name: z20.string().optional()
|
|
2347
2412
|
});
|
|
2348
|
-
var publicAgentsListContract =
|
|
2413
|
+
var publicAgentsListContract = c16.router({
|
|
2349
2414
|
list: {
|
|
2350
2415
|
method: "GET",
|
|
2351
2416
|
path: "/v1/agents",
|
|
@@ -2360,13 +2425,13 @@ var publicAgentsListContract = c15.router({
|
|
|
2360
2425
|
description: "List all agents in the current scope with pagination. Use the `name` query parameter to filter by agent name."
|
|
2361
2426
|
}
|
|
2362
2427
|
});
|
|
2363
|
-
var publicAgentByIdContract =
|
|
2428
|
+
var publicAgentByIdContract = c16.router({
|
|
2364
2429
|
get: {
|
|
2365
2430
|
method: "GET",
|
|
2366
2431
|
path: "/v1/agents/:id",
|
|
2367
2432
|
headers: authHeadersSchema,
|
|
2368
|
-
pathParams:
|
|
2369
|
-
id:
|
|
2433
|
+
pathParams: z20.object({
|
|
2434
|
+
id: z20.string().min(1, "Agent ID is required")
|
|
2370
2435
|
}),
|
|
2371
2436
|
responses: {
|
|
2372
2437
|
200: publicAgentDetailSchema,
|
|
@@ -2378,13 +2443,13 @@ var publicAgentByIdContract = c15.router({
|
|
|
2378
2443
|
description: "Get agent details by ID"
|
|
2379
2444
|
}
|
|
2380
2445
|
});
|
|
2381
|
-
var publicAgentVersionsContract =
|
|
2446
|
+
var publicAgentVersionsContract = c16.router({
|
|
2382
2447
|
list: {
|
|
2383
2448
|
method: "GET",
|
|
2384
2449
|
path: "/v1/agents/:id/versions",
|
|
2385
2450
|
headers: authHeadersSchema,
|
|
2386
|
-
pathParams:
|
|
2387
|
-
id:
|
|
2451
|
+
pathParams: z20.object({
|
|
2452
|
+
id: z20.string().min(1, "Agent ID is required")
|
|
2388
2453
|
}),
|
|
2389
2454
|
query: listQuerySchema,
|
|
2390
2455
|
responses: {
|
|
@@ -2399,9 +2464,9 @@ var publicAgentVersionsContract = c15.router({
|
|
|
2399
2464
|
});
|
|
2400
2465
|
|
|
2401
2466
|
// ../../packages/core/src/contracts/public/runs.ts
|
|
2402
|
-
import { z as
|
|
2403
|
-
var
|
|
2404
|
-
var publicRunStatusSchema =
|
|
2467
|
+
import { z as z21 } from "zod";
|
|
2468
|
+
var c17 = initContract();
|
|
2469
|
+
var publicRunStatusSchema = z21.enum([
|
|
2405
2470
|
"pending",
|
|
2406
2471
|
"running",
|
|
2407
2472
|
"completed",
|
|
@@ -2409,56 +2474,56 @@ var publicRunStatusSchema = z20.enum([
|
|
|
2409
2474
|
"timeout",
|
|
2410
2475
|
"cancelled"
|
|
2411
2476
|
]);
|
|
2412
|
-
var publicRunSchema =
|
|
2413
|
-
id:
|
|
2414
|
-
|
|
2415
|
-
|
|
2477
|
+
var publicRunSchema = z21.object({
|
|
2478
|
+
id: z21.string(),
|
|
2479
|
+
agentId: z21.string(),
|
|
2480
|
+
agentName: z21.string(),
|
|
2416
2481
|
status: publicRunStatusSchema,
|
|
2417
|
-
prompt:
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2482
|
+
prompt: z21.string(),
|
|
2483
|
+
createdAt: timestampSchema,
|
|
2484
|
+
startedAt: timestampSchema.nullable(),
|
|
2485
|
+
completedAt: timestampSchema.nullable()
|
|
2421
2486
|
});
|
|
2422
2487
|
var publicRunDetailSchema = publicRunSchema.extend({
|
|
2423
|
-
error:
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
volumes:
|
|
2488
|
+
error: z21.string().nullable(),
|
|
2489
|
+
executionTimeMs: z21.number().nullable(),
|
|
2490
|
+
checkpointId: z21.string().nullable(),
|
|
2491
|
+
sessionId: z21.string().nullable(),
|
|
2492
|
+
artifactName: z21.string().nullable(),
|
|
2493
|
+
artifactVersion: z21.string().nullable(),
|
|
2494
|
+
volumes: z21.record(z21.string(), z21.string()).optional()
|
|
2430
2495
|
});
|
|
2431
2496
|
var paginatedRunsSchema = createPaginatedResponseSchema(publicRunSchema);
|
|
2432
|
-
var createRunRequestSchema =
|
|
2433
|
-
// Agent identification (one of: agent,
|
|
2434
|
-
agent:
|
|
2497
|
+
var createRunRequestSchema = z21.object({
|
|
2498
|
+
// Agent identification (one of: agent, agentId, sessionId, checkpointId)
|
|
2499
|
+
agent: z21.string().optional(),
|
|
2435
2500
|
// Agent name
|
|
2436
|
-
|
|
2501
|
+
agentId: z21.string().optional(),
|
|
2437
2502
|
// Agent ID
|
|
2438
|
-
|
|
2503
|
+
agentVersion: z21.string().optional(),
|
|
2439
2504
|
// Version specifier (e.g., "latest", "v1", specific ID)
|
|
2440
2505
|
// Continue session
|
|
2441
|
-
|
|
2506
|
+
sessionId: z21.string().optional(),
|
|
2442
2507
|
// Resume from checkpoint
|
|
2443
|
-
|
|
2508
|
+
checkpointId: z21.string().optional(),
|
|
2444
2509
|
// Required
|
|
2445
|
-
prompt:
|
|
2510
|
+
prompt: z21.string().min(1, "Prompt is required"),
|
|
2446
2511
|
// Optional configuration
|
|
2447
|
-
variables:
|
|
2448
|
-
secrets:
|
|
2449
|
-
|
|
2512
|
+
variables: z21.record(z21.string(), z21.string()).optional(),
|
|
2513
|
+
secrets: z21.record(z21.string(), z21.string()).optional(),
|
|
2514
|
+
artifactName: z21.string().optional(),
|
|
2450
2515
|
// Artifact name to mount
|
|
2451
|
-
|
|
2516
|
+
artifactVersion: z21.string().optional(),
|
|
2452
2517
|
// Artifact version (defaults to latest)
|
|
2453
|
-
volumes:
|
|
2518
|
+
volumes: z21.record(z21.string(), z21.string()).optional()
|
|
2454
2519
|
// volume_name -> version
|
|
2455
2520
|
});
|
|
2456
2521
|
var runListQuerySchema = listQuerySchema.extend({
|
|
2457
|
-
|
|
2522
|
+
agentId: z21.string().optional(),
|
|
2458
2523
|
status: publicRunStatusSchema.optional(),
|
|
2459
2524
|
since: timestampSchema.optional()
|
|
2460
2525
|
});
|
|
2461
|
-
var publicRunsListContract =
|
|
2526
|
+
var publicRunsListContract = c17.router({
|
|
2462
2527
|
list: {
|
|
2463
2528
|
method: "GET",
|
|
2464
2529
|
path: "/v1/runs",
|
|
@@ -2489,13 +2554,13 @@ var publicRunsListContract = c16.router({
|
|
|
2489
2554
|
description: "Create and execute a new agent run. Returns 202 Accepted as runs execute asynchronously."
|
|
2490
2555
|
}
|
|
2491
2556
|
});
|
|
2492
|
-
var publicRunByIdContract =
|
|
2557
|
+
var publicRunByIdContract = c17.router({
|
|
2493
2558
|
get: {
|
|
2494
2559
|
method: "GET",
|
|
2495
2560
|
path: "/v1/runs/:id",
|
|
2496
2561
|
headers: authHeadersSchema,
|
|
2497
|
-
pathParams:
|
|
2498
|
-
id:
|
|
2562
|
+
pathParams: z21.object({
|
|
2563
|
+
id: z21.string().min(1, "Run ID is required")
|
|
2499
2564
|
}),
|
|
2500
2565
|
responses: {
|
|
2501
2566
|
200: publicRunDetailSchema,
|
|
@@ -2507,15 +2572,15 @@ var publicRunByIdContract = c16.router({
|
|
|
2507
2572
|
description: "Get run details by ID"
|
|
2508
2573
|
}
|
|
2509
2574
|
});
|
|
2510
|
-
var publicRunCancelContract =
|
|
2575
|
+
var publicRunCancelContract = c17.router({
|
|
2511
2576
|
cancel: {
|
|
2512
2577
|
method: "POST",
|
|
2513
2578
|
path: "/v1/runs/:id/cancel",
|
|
2514
2579
|
headers: authHeadersSchema,
|
|
2515
|
-
pathParams:
|
|
2516
|
-
id:
|
|
2580
|
+
pathParams: z21.object({
|
|
2581
|
+
id: z21.string().min(1, "Run ID is required")
|
|
2517
2582
|
}),
|
|
2518
|
-
body:
|
|
2583
|
+
body: z21.undefined(),
|
|
2519
2584
|
responses: {
|
|
2520
2585
|
200: publicRunDetailSchema,
|
|
2521
2586
|
400: publicApiErrorSchema,
|
|
@@ -2528,27 +2593,27 @@ var publicRunCancelContract = c16.router({
|
|
|
2528
2593
|
description: "Cancel a pending or running execution"
|
|
2529
2594
|
}
|
|
2530
2595
|
});
|
|
2531
|
-
var logEntrySchema =
|
|
2596
|
+
var logEntrySchema = z21.object({
|
|
2532
2597
|
timestamp: timestampSchema,
|
|
2533
|
-
type:
|
|
2534
|
-
level:
|
|
2535
|
-
message:
|
|
2536
|
-
metadata:
|
|
2598
|
+
type: z21.enum(["agent", "system", "network"]),
|
|
2599
|
+
level: z21.enum(["debug", "info", "warn", "error"]),
|
|
2600
|
+
message: z21.string(),
|
|
2601
|
+
metadata: z21.record(z21.string(), z21.unknown()).optional()
|
|
2537
2602
|
});
|
|
2538
2603
|
var paginatedLogsSchema = createPaginatedResponseSchema(logEntrySchema);
|
|
2539
2604
|
var logsQuerySchema = listQuerySchema.extend({
|
|
2540
|
-
type:
|
|
2605
|
+
type: z21.enum(["agent", "system", "network", "all"]).default("all"),
|
|
2541
2606
|
since: timestampSchema.optional(),
|
|
2542
2607
|
until: timestampSchema.optional(),
|
|
2543
|
-
order:
|
|
2608
|
+
order: z21.enum(["asc", "desc"]).default("asc")
|
|
2544
2609
|
});
|
|
2545
|
-
var publicRunLogsContract =
|
|
2610
|
+
var publicRunLogsContract = c17.router({
|
|
2546
2611
|
getLogs: {
|
|
2547
2612
|
method: "GET",
|
|
2548
2613
|
path: "/v1/runs/:id/logs",
|
|
2549
2614
|
headers: authHeadersSchema,
|
|
2550
|
-
pathParams:
|
|
2551
|
-
id:
|
|
2615
|
+
pathParams: z21.object({
|
|
2616
|
+
id: z21.string().min(1, "Run ID is required")
|
|
2552
2617
|
}),
|
|
2553
2618
|
query: logsQuerySchema,
|
|
2554
2619
|
responses: {
|
|
@@ -2561,30 +2626,30 @@ var publicRunLogsContract = c16.router({
|
|
|
2561
2626
|
description: "Get unified logs for a run. Combines agent, system, and network logs."
|
|
2562
2627
|
}
|
|
2563
2628
|
});
|
|
2564
|
-
var metricPointSchema =
|
|
2629
|
+
var metricPointSchema = z21.object({
|
|
2565
2630
|
timestamp: timestampSchema,
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
});
|
|
2572
|
-
var metricsSummarySchema =
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
});
|
|
2577
|
-
var metricsResponseSchema2 =
|
|
2578
|
-
data:
|
|
2631
|
+
cpuPercent: z21.number(),
|
|
2632
|
+
memoryUsedMb: z21.number(),
|
|
2633
|
+
memoryTotalMb: z21.number(),
|
|
2634
|
+
diskUsedMb: z21.number(),
|
|
2635
|
+
diskTotalMb: z21.number()
|
|
2636
|
+
});
|
|
2637
|
+
var metricsSummarySchema = z21.object({
|
|
2638
|
+
avgCpuPercent: z21.number(),
|
|
2639
|
+
maxMemoryUsedMb: z21.number(),
|
|
2640
|
+
totalDurationMs: z21.number().nullable()
|
|
2641
|
+
});
|
|
2642
|
+
var metricsResponseSchema2 = z21.object({
|
|
2643
|
+
data: z21.array(metricPointSchema),
|
|
2579
2644
|
summary: metricsSummarySchema
|
|
2580
2645
|
});
|
|
2581
|
-
var publicRunMetricsContract =
|
|
2646
|
+
var publicRunMetricsContract = c17.router({
|
|
2582
2647
|
getMetrics: {
|
|
2583
2648
|
method: "GET",
|
|
2584
2649
|
path: "/v1/runs/:id/metrics",
|
|
2585
2650
|
headers: authHeadersSchema,
|
|
2586
|
-
pathParams:
|
|
2587
|
-
id:
|
|
2651
|
+
pathParams: z21.object({
|
|
2652
|
+
id: z21.string().min(1, "Run ID is required")
|
|
2588
2653
|
}),
|
|
2589
2654
|
responses: {
|
|
2590
2655
|
200: metricsResponseSchema2,
|
|
@@ -2596,7 +2661,7 @@ var publicRunMetricsContract = c16.router({
|
|
|
2596
2661
|
description: "Get CPU, memory, and disk metrics for a run"
|
|
2597
2662
|
}
|
|
2598
2663
|
});
|
|
2599
|
-
var sseEventTypeSchema =
|
|
2664
|
+
var sseEventTypeSchema = z21.enum([
|
|
2600
2665
|
"status",
|
|
2601
2666
|
// Run status change
|
|
2602
2667
|
"output",
|
|
@@ -2608,26 +2673,26 @@ var sseEventTypeSchema = z20.enum([
|
|
|
2608
2673
|
"heartbeat"
|
|
2609
2674
|
// Keep-alive
|
|
2610
2675
|
]);
|
|
2611
|
-
var sseEventSchema =
|
|
2676
|
+
var sseEventSchema = z21.object({
|
|
2612
2677
|
event: sseEventTypeSchema,
|
|
2613
|
-
data:
|
|
2614
|
-
id:
|
|
2678
|
+
data: z21.unknown(),
|
|
2679
|
+
id: z21.string().optional()
|
|
2615
2680
|
// For Last-Event-ID reconnection
|
|
2616
2681
|
});
|
|
2617
|
-
var publicRunEventsContract =
|
|
2682
|
+
var publicRunEventsContract = c17.router({
|
|
2618
2683
|
streamEvents: {
|
|
2619
2684
|
method: "GET",
|
|
2620
2685
|
path: "/v1/runs/:id/events",
|
|
2621
2686
|
headers: authHeadersSchema,
|
|
2622
|
-
pathParams:
|
|
2623
|
-
id:
|
|
2687
|
+
pathParams: z21.object({
|
|
2688
|
+
id: z21.string().min(1, "Run ID is required")
|
|
2624
2689
|
}),
|
|
2625
|
-
query:
|
|
2626
|
-
|
|
2690
|
+
query: z21.object({
|
|
2691
|
+
lastEventId: z21.string().optional()
|
|
2627
2692
|
// For reconnection
|
|
2628
2693
|
}),
|
|
2629
2694
|
responses: {
|
|
2630
|
-
200:
|
|
2695
|
+
200: z21.any(),
|
|
2631
2696
|
// SSE stream - actual content is text/event-stream
|
|
2632
2697
|
401: publicApiErrorSchema,
|
|
2633
2698
|
404: publicApiErrorSchema,
|
|
@@ -2639,38 +2704,38 @@ var publicRunEventsContract = c16.router({
|
|
|
2639
2704
|
});
|
|
2640
2705
|
|
|
2641
2706
|
// ../../packages/core/src/contracts/public/artifacts.ts
|
|
2642
|
-
import { z as
|
|
2643
|
-
var
|
|
2644
|
-
var publicArtifactSchema =
|
|
2645
|
-
id:
|
|
2646
|
-
name:
|
|
2647
|
-
|
|
2648
|
-
size:
|
|
2707
|
+
import { z as z22 } from "zod";
|
|
2708
|
+
var c18 = initContract();
|
|
2709
|
+
var publicArtifactSchema = z22.object({
|
|
2710
|
+
id: z22.string(),
|
|
2711
|
+
name: z22.string(),
|
|
2712
|
+
currentVersionId: z22.string().nullable(),
|
|
2713
|
+
size: z22.number(),
|
|
2649
2714
|
// Total size in bytes
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2715
|
+
fileCount: z22.number(),
|
|
2716
|
+
createdAt: timestampSchema,
|
|
2717
|
+
updatedAt: timestampSchema
|
|
2653
2718
|
});
|
|
2654
|
-
var artifactVersionSchema =
|
|
2655
|
-
id:
|
|
2719
|
+
var artifactVersionSchema = z22.object({
|
|
2720
|
+
id: z22.string(),
|
|
2656
2721
|
// SHA-256 content hash
|
|
2657
|
-
|
|
2658
|
-
size:
|
|
2722
|
+
artifactId: z22.string(),
|
|
2723
|
+
size: z22.number(),
|
|
2659
2724
|
// Size in bytes
|
|
2660
|
-
|
|
2661
|
-
message:
|
|
2725
|
+
fileCount: z22.number(),
|
|
2726
|
+
message: z22.string().nullable(),
|
|
2662
2727
|
// Optional commit message
|
|
2663
|
-
|
|
2664
|
-
|
|
2728
|
+
createdBy: z22.string(),
|
|
2729
|
+
createdAt: timestampSchema
|
|
2665
2730
|
});
|
|
2666
2731
|
var publicArtifactDetailSchema = publicArtifactSchema.extend({
|
|
2667
|
-
|
|
2732
|
+
currentVersion: artifactVersionSchema.nullable()
|
|
2668
2733
|
});
|
|
2669
2734
|
var paginatedArtifactsSchema = createPaginatedResponseSchema(publicArtifactSchema);
|
|
2670
2735
|
var paginatedArtifactVersionsSchema = createPaginatedResponseSchema(
|
|
2671
2736
|
artifactVersionSchema
|
|
2672
2737
|
);
|
|
2673
|
-
var publicArtifactsListContract =
|
|
2738
|
+
var publicArtifactsListContract = c18.router({
|
|
2674
2739
|
list: {
|
|
2675
2740
|
method: "GET",
|
|
2676
2741
|
path: "/v1/artifacts",
|
|
@@ -2685,13 +2750,13 @@ var publicArtifactsListContract = c17.router({
|
|
|
2685
2750
|
description: "List all artifacts in the current scope with pagination"
|
|
2686
2751
|
}
|
|
2687
2752
|
});
|
|
2688
|
-
var publicArtifactByIdContract =
|
|
2753
|
+
var publicArtifactByIdContract = c18.router({
|
|
2689
2754
|
get: {
|
|
2690
2755
|
method: "GET",
|
|
2691
2756
|
path: "/v1/artifacts/:id",
|
|
2692
2757
|
headers: authHeadersSchema,
|
|
2693
|
-
pathParams:
|
|
2694
|
-
id:
|
|
2758
|
+
pathParams: z22.object({
|
|
2759
|
+
id: z22.string().min(1, "Artifact ID is required")
|
|
2695
2760
|
}),
|
|
2696
2761
|
responses: {
|
|
2697
2762
|
200: publicArtifactDetailSchema,
|
|
@@ -2703,13 +2768,13 @@ var publicArtifactByIdContract = c17.router({
|
|
|
2703
2768
|
description: "Get artifact details by ID"
|
|
2704
2769
|
}
|
|
2705
2770
|
});
|
|
2706
|
-
var publicArtifactVersionsContract =
|
|
2771
|
+
var publicArtifactVersionsContract = c18.router({
|
|
2707
2772
|
list: {
|
|
2708
2773
|
method: "GET",
|
|
2709
2774
|
path: "/v1/artifacts/:id/versions",
|
|
2710
2775
|
headers: authHeadersSchema,
|
|
2711
|
-
pathParams:
|
|
2712
|
-
id:
|
|
2776
|
+
pathParams: z22.object({
|
|
2777
|
+
id: z22.string().min(1, "Artifact ID is required")
|
|
2713
2778
|
}),
|
|
2714
2779
|
query: listQuerySchema,
|
|
2715
2780
|
responses: {
|
|
@@ -2722,20 +2787,20 @@ var publicArtifactVersionsContract = c17.router({
|
|
|
2722
2787
|
description: "List all versions of an artifact with pagination"
|
|
2723
2788
|
}
|
|
2724
2789
|
});
|
|
2725
|
-
var publicArtifactDownloadContract =
|
|
2790
|
+
var publicArtifactDownloadContract = c18.router({
|
|
2726
2791
|
download: {
|
|
2727
2792
|
method: "GET",
|
|
2728
2793
|
path: "/v1/artifacts/:id/download",
|
|
2729
2794
|
headers: authHeadersSchema,
|
|
2730
|
-
pathParams:
|
|
2731
|
-
id:
|
|
2795
|
+
pathParams: z22.object({
|
|
2796
|
+
id: z22.string().min(1, "Artifact ID is required")
|
|
2732
2797
|
}),
|
|
2733
|
-
query:
|
|
2734
|
-
|
|
2798
|
+
query: z22.object({
|
|
2799
|
+
versionId: z22.string().optional()
|
|
2735
2800
|
// Defaults to current version
|
|
2736
2801
|
}),
|
|
2737
2802
|
responses: {
|
|
2738
|
-
302:
|
|
2803
|
+
302: z22.undefined(),
|
|
2739
2804
|
// Redirect to presigned URL
|
|
2740
2805
|
401: publicApiErrorSchema,
|
|
2741
2806
|
404: publicApiErrorSchema,
|
|
@@ -2747,36 +2812,36 @@ var publicArtifactDownloadContract = c17.router({
|
|
|
2747
2812
|
});
|
|
2748
2813
|
|
|
2749
2814
|
// ../../packages/core/src/contracts/public/volumes.ts
|
|
2750
|
-
import { z as
|
|
2751
|
-
var
|
|
2752
|
-
var publicVolumeSchema =
|
|
2753
|
-
id:
|
|
2754
|
-
name:
|
|
2755
|
-
|
|
2756
|
-
size:
|
|
2815
|
+
import { z as z23 } from "zod";
|
|
2816
|
+
var c19 = initContract();
|
|
2817
|
+
var publicVolumeSchema = z23.object({
|
|
2818
|
+
id: z23.string(),
|
|
2819
|
+
name: z23.string(),
|
|
2820
|
+
currentVersionId: z23.string().nullable(),
|
|
2821
|
+
size: z23.number(),
|
|
2757
2822
|
// Total size in bytes
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2823
|
+
fileCount: z23.number(),
|
|
2824
|
+
createdAt: timestampSchema,
|
|
2825
|
+
updatedAt: timestampSchema
|
|
2761
2826
|
});
|
|
2762
|
-
var volumeVersionSchema =
|
|
2763
|
-
id:
|
|
2827
|
+
var volumeVersionSchema = z23.object({
|
|
2828
|
+
id: z23.string(),
|
|
2764
2829
|
// SHA-256 content hash
|
|
2765
|
-
|
|
2766
|
-
size:
|
|
2830
|
+
volumeId: z23.string(),
|
|
2831
|
+
size: z23.number(),
|
|
2767
2832
|
// Size in bytes
|
|
2768
|
-
|
|
2769
|
-
message:
|
|
2833
|
+
fileCount: z23.number(),
|
|
2834
|
+
message: z23.string().nullable(),
|
|
2770
2835
|
// Optional commit message
|
|
2771
|
-
|
|
2772
|
-
|
|
2836
|
+
createdBy: z23.string(),
|
|
2837
|
+
createdAt: timestampSchema
|
|
2773
2838
|
});
|
|
2774
2839
|
var publicVolumeDetailSchema = publicVolumeSchema.extend({
|
|
2775
|
-
|
|
2840
|
+
currentVersion: volumeVersionSchema.nullable()
|
|
2776
2841
|
});
|
|
2777
2842
|
var paginatedVolumesSchema = createPaginatedResponseSchema(publicVolumeSchema);
|
|
2778
2843
|
var paginatedVolumeVersionsSchema = createPaginatedResponseSchema(volumeVersionSchema);
|
|
2779
|
-
var publicVolumesListContract =
|
|
2844
|
+
var publicVolumesListContract = c19.router({
|
|
2780
2845
|
list: {
|
|
2781
2846
|
method: "GET",
|
|
2782
2847
|
path: "/v1/volumes",
|
|
@@ -2791,13 +2856,13 @@ var publicVolumesListContract = c18.router({
|
|
|
2791
2856
|
description: "List all volumes in the current scope with pagination"
|
|
2792
2857
|
}
|
|
2793
2858
|
});
|
|
2794
|
-
var publicVolumeByIdContract =
|
|
2859
|
+
var publicVolumeByIdContract = c19.router({
|
|
2795
2860
|
get: {
|
|
2796
2861
|
method: "GET",
|
|
2797
2862
|
path: "/v1/volumes/:id",
|
|
2798
2863
|
headers: authHeadersSchema,
|
|
2799
|
-
pathParams:
|
|
2800
|
-
id:
|
|
2864
|
+
pathParams: z23.object({
|
|
2865
|
+
id: z23.string().min(1, "Volume ID is required")
|
|
2801
2866
|
}),
|
|
2802
2867
|
responses: {
|
|
2803
2868
|
200: publicVolumeDetailSchema,
|
|
@@ -2809,13 +2874,13 @@ var publicVolumeByIdContract = c18.router({
|
|
|
2809
2874
|
description: "Get volume details by ID"
|
|
2810
2875
|
}
|
|
2811
2876
|
});
|
|
2812
|
-
var publicVolumeVersionsContract =
|
|
2877
|
+
var publicVolumeVersionsContract = c19.router({
|
|
2813
2878
|
list: {
|
|
2814
2879
|
method: "GET",
|
|
2815
2880
|
path: "/v1/volumes/:id/versions",
|
|
2816
2881
|
headers: authHeadersSchema,
|
|
2817
|
-
pathParams:
|
|
2818
|
-
id:
|
|
2882
|
+
pathParams: z23.object({
|
|
2883
|
+
id: z23.string().min(1, "Volume ID is required")
|
|
2819
2884
|
}),
|
|
2820
2885
|
query: listQuerySchema,
|
|
2821
2886
|
responses: {
|
|
@@ -2828,20 +2893,20 @@ var publicVolumeVersionsContract = c18.router({
|
|
|
2828
2893
|
description: "List all versions of a volume with pagination"
|
|
2829
2894
|
}
|
|
2830
2895
|
});
|
|
2831
|
-
var publicVolumeDownloadContract =
|
|
2896
|
+
var publicVolumeDownloadContract = c19.router({
|
|
2832
2897
|
download: {
|
|
2833
2898
|
method: "GET",
|
|
2834
2899
|
path: "/v1/volumes/:id/download",
|
|
2835
2900
|
headers: authHeadersSchema,
|
|
2836
|
-
pathParams:
|
|
2837
|
-
id:
|
|
2901
|
+
pathParams: z23.object({
|
|
2902
|
+
id: z23.string().min(1, "Volume ID is required")
|
|
2838
2903
|
}),
|
|
2839
|
-
query:
|
|
2840
|
-
|
|
2904
|
+
query: z23.object({
|
|
2905
|
+
versionId: z23.string().optional()
|
|
2841
2906
|
// Defaults to current version
|
|
2842
2907
|
}),
|
|
2843
2908
|
responses: {
|
|
2844
|
-
302:
|
|
2909
|
+
302: z23.undefined(),
|
|
2845
2910
|
// Redirect to presigned URL
|
|
2846
2911
|
401: publicApiErrorSchema,
|
|
2847
2912
|
404: publicApiErrorSchema,
|
|
@@ -3429,8 +3494,8 @@ async function getUsage(options) {
|
|
|
3429
3494
|
}
|
|
3430
3495
|
|
|
3431
3496
|
// src/lib/domain/yaml-validator.ts
|
|
3432
|
-
import { z as
|
|
3433
|
-
var cliAgentNameSchema =
|
|
3497
|
+
import { z as z24 } from "zod";
|
|
3498
|
+
var cliAgentNameSchema = z24.string().min(3, "Agent name must be at least 3 characters").max(64, "Agent name must be 64 characters or less").regex(
|
|
3434
3499
|
/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,62}[a-zA-Z0-9])?$/,
|
|
3435
3500
|
"Agent name must start and end with letter or number, and contain only letters, numbers, and hyphens"
|
|
3436
3501
|
);
|
|
@@ -3445,7 +3510,7 @@ var cliAgentDefinitionSchema = agentDefinitionSchema.superRefine(
|
|
|
3445
3510
|
const skillUrl = agent.skills[i];
|
|
3446
3511
|
if (skillUrl && !validateGitHubTreeUrl(skillUrl)) {
|
|
3447
3512
|
ctx.addIssue({
|
|
3448
|
-
code:
|
|
3513
|
+
code: z24.ZodIssueCode.custom,
|
|
3449
3514
|
message: `Invalid skill URL: ${skillUrl}. Expected format: https://github.com/{owner}/{repo}/tree/{branch}/{path}`,
|
|
3450
3515
|
path: ["skills", i]
|
|
3451
3516
|
});
|
|
@@ -3454,15 +3519,15 @@ var cliAgentDefinitionSchema = agentDefinitionSchema.superRefine(
|
|
|
3454
3519
|
}
|
|
3455
3520
|
}
|
|
3456
3521
|
);
|
|
3457
|
-
var cliComposeSchema =
|
|
3458
|
-
version:
|
|
3459
|
-
agents:
|
|
3460
|
-
volumes:
|
|
3522
|
+
var cliComposeSchema = z24.object({
|
|
3523
|
+
version: z24.string().min(1, "Missing config.version"),
|
|
3524
|
+
agents: z24.record(cliAgentNameSchema, cliAgentDefinitionSchema),
|
|
3525
|
+
volumes: z24.record(z24.string(), volumeConfigSchema).optional()
|
|
3461
3526
|
}).superRefine((config, ctx) => {
|
|
3462
3527
|
const agentKeys = Object.keys(config.agents);
|
|
3463
3528
|
if (agentKeys.length === 0) {
|
|
3464
3529
|
ctx.addIssue({
|
|
3465
|
-
code:
|
|
3530
|
+
code: z24.ZodIssueCode.custom,
|
|
3466
3531
|
message: "agents must have at least one agent defined",
|
|
3467
3532
|
path: ["agents"]
|
|
3468
3533
|
});
|
|
@@ -3470,7 +3535,7 @@ var cliComposeSchema = z23.object({
|
|
|
3470
3535
|
}
|
|
3471
3536
|
if (agentKeys.length > 1) {
|
|
3472
3537
|
ctx.addIssue({
|
|
3473
|
-
code:
|
|
3538
|
+
code: z24.ZodIssueCode.custom,
|
|
3474
3539
|
message: "Multiple agents not supported yet. Only one agent allowed.",
|
|
3475
3540
|
path: ["agents"]
|
|
3476
3541
|
});
|
|
@@ -3482,7 +3547,7 @@ var cliComposeSchema = z23.object({
|
|
|
3482
3547
|
if (agentVolumes && agentVolumes.length > 0) {
|
|
3483
3548
|
if (!config.volumes) {
|
|
3484
3549
|
ctx.addIssue({
|
|
3485
|
-
code:
|
|
3550
|
+
code: z24.ZodIssueCode.custom,
|
|
3486
3551
|
message: "Agent references volumes but no volumes section defined. Each volume must have explicit name and version.",
|
|
3487
3552
|
path: ["volumes"]
|
|
3488
3553
|
});
|
|
@@ -3492,7 +3557,7 @@ var cliComposeSchema = z23.object({
|
|
|
3492
3557
|
const parts = volDeclaration.split(":");
|
|
3493
3558
|
if (parts.length !== 2) {
|
|
3494
3559
|
ctx.addIssue({
|
|
3495
|
-
code:
|
|
3560
|
+
code: z24.ZodIssueCode.custom,
|
|
3496
3561
|
message: `Invalid volume declaration: ${volDeclaration}. Expected format: volume-key:/mount/path`,
|
|
3497
3562
|
path: ["agents", agentName, "volumes"]
|
|
3498
3563
|
});
|
|
@@ -3501,7 +3566,7 @@ var cliComposeSchema = z23.object({
|
|
|
3501
3566
|
const volumeKey = parts[0].trim();
|
|
3502
3567
|
if (!config.volumes[volumeKey]) {
|
|
3503
3568
|
ctx.addIssue({
|
|
3504
|
-
code:
|
|
3569
|
+
code: z24.ZodIssueCode.custom,
|
|
3505
3570
|
message: `Volume "${volumeKey}" is not defined in volumes section. Each volume must have explicit name and version.`,
|
|
3506
3571
|
path: ["volumes", volumeKey]
|
|
3507
3572
|
});
|
|
@@ -4051,6 +4116,89 @@ async function uploadSkill(skillUrl) {
|
|
|
4051
4116
|
}
|
|
4052
4117
|
}
|
|
4053
4118
|
|
|
4119
|
+
// src/lib/utils/prompt-utils.ts
|
|
4120
|
+
import prompts from "prompts";
|
|
4121
|
+
function isInteractive() {
|
|
4122
|
+
return process.stdout.isTTY === true;
|
|
4123
|
+
}
|
|
4124
|
+
async function promptText(message, initial, validate) {
|
|
4125
|
+
if (!isInteractive()) {
|
|
4126
|
+
return void 0;
|
|
4127
|
+
}
|
|
4128
|
+
const response = await prompts(
|
|
4129
|
+
{
|
|
4130
|
+
type: "text",
|
|
4131
|
+
name: "value",
|
|
4132
|
+
message,
|
|
4133
|
+
initial,
|
|
4134
|
+
validate
|
|
4135
|
+
},
|
|
4136
|
+
{
|
|
4137
|
+
onCancel: () => {
|
|
4138
|
+
return false;
|
|
4139
|
+
}
|
|
4140
|
+
}
|
|
4141
|
+
);
|
|
4142
|
+
return response.value;
|
|
4143
|
+
}
|
|
4144
|
+
async function promptConfirm(message, initial = true) {
|
|
4145
|
+
if (!isInteractive()) {
|
|
4146
|
+
return void 0;
|
|
4147
|
+
}
|
|
4148
|
+
const response = await prompts(
|
|
4149
|
+
{
|
|
4150
|
+
type: "confirm",
|
|
4151
|
+
name: "value",
|
|
4152
|
+
message,
|
|
4153
|
+
initial
|
|
4154
|
+
},
|
|
4155
|
+
{
|
|
4156
|
+
onCancel: () => {
|
|
4157
|
+
return false;
|
|
4158
|
+
}
|
|
4159
|
+
}
|
|
4160
|
+
);
|
|
4161
|
+
return response.value;
|
|
4162
|
+
}
|
|
4163
|
+
async function promptSelect(message, choices, initial) {
|
|
4164
|
+
if (!isInteractive()) {
|
|
4165
|
+
return void 0;
|
|
4166
|
+
}
|
|
4167
|
+
const response = await prompts(
|
|
4168
|
+
{
|
|
4169
|
+
type: "select",
|
|
4170
|
+
name: "value",
|
|
4171
|
+
message,
|
|
4172
|
+
choices,
|
|
4173
|
+
initial
|
|
4174
|
+
},
|
|
4175
|
+
{
|
|
4176
|
+
onCancel: () => {
|
|
4177
|
+
return false;
|
|
4178
|
+
}
|
|
4179
|
+
}
|
|
4180
|
+
);
|
|
4181
|
+
return response.value;
|
|
4182
|
+
}
|
|
4183
|
+
async function promptPassword(message) {
|
|
4184
|
+
if (!isInteractive()) {
|
|
4185
|
+
return void 0;
|
|
4186
|
+
}
|
|
4187
|
+
const response = await prompts(
|
|
4188
|
+
{
|
|
4189
|
+
type: "password",
|
|
4190
|
+
name: "value",
|
|
4191
|
+
message
|
|
4192
|
+
},
|
|
4193
|
+
{
|
|
4194
|
+
onCancel: () => {
|
|
4195
|
+
return false;
|
|
4196
|
+
}
|
|
4197
|
+
}
|
|
4198
|
+
);
|
|
4199
|
+
return response.value;
|
|
4200
|
+
}
|
|
4201
|
+
|
|
4054
4202
|
// src/commands/compose.ts
|
|
4055
4203
|
function getSecretsFromComposeContent(content) {
|
|
4056
4204
|
const refs = extractVariableReferences(content);
|
|
@@ -4189,7 +4337,7 @@ var composeCommand = new Command().name("compose").description("Create or update
|
|
|
4189
4337
|
console.log();
|
|
4190
4338
|
if (trulyNewSecrets.length > 0) {
|
|
4191
4339
|
if (!options.yes) {
|
|
4192
|
-
if (!
|
|
4340
|
+
if (!isInteractive()) {
|
|
4193
4341
|
console.error(
|
|
4194
4342
|
chalk2.red(
|
|
4195
4343
|
`\u2717 New secrets detected: ${trulyNewSecrets.join(", ")}`
|
|
@@ -4202,14 +4350,12 @@ var composeCommand = new Command().name("compose").description("Create or update
|
|
|
4202
4350
|
);
|
|
4203
4351
|
process.exit(1);
|
|
4204
4352
|
}
|
|
4205
|
-
const
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
if (!response2.value) {
|
|
4212
|
-
console.log(chalk2.yellow("Compose cancelled."));
|
|
4353
|
+
const confirmed = await promptConfirm(
|
|
4354
|
+
`Approve ${trulyNewSecrets.length} new secret(s)?`,
|
|
4355
|
+
true
|
|
4356
|
+
);
|
|
4357
|
+
if (!confirmed) {
|
|
4358
|
+
console.log(chalk2.yellow("Compose cancelled"));
|
|
4213
4359
|
process.exit(0);
|
|
4214
4360
|
}
|
|
4215
4361
|
}
|
|
@@ -4716,9 +4862,9 @@ var CodexEventParser = class {
|
|
|
4716
4862
|
}
|
|
4717
4863
|
}
|
|
4718
4864
|
if (itemType === "file_change" && item.changes && item.changes.length > 0) {
|
|
4719
|
-
const changes = item.changes.map((
|
|
4720
|
-
const action =
|
|
4721
|
-
return `${action}: ${
|
|
4865
|
+
const changes = item.changes.map((c20) => {
|
|
4866
|
+
const action = c20.kind === "add" ? "Created" : c20.kind === "modify" ? "Modified" : "Deleted";
|
|
4867
|
+
return `${action}: ${c20.path}`;
|
|
4722
4868
|
}).join("\n");
|
|
4723
4869
|
return {
|
|
4724
4870
|
type: "text",
|
|
@@ -4872,9 +5018,9 @@ var CodexEventRenderer = class {
|
|
|
4872
5018
|
return;
|
|
4873
5019
|
}
|
|
4874
5020
|
if (itemType === "file_change" && item.changes && item.changes.length > 0) {
|
|
4875
|
-
const summary = item.changes.map((
|
|
4876
|
-
const icon =
|
|
4877
|
-
return `${icon}${
|
|
5021
|
+
const summary = item.changes.map((c20) => {
|
|
5022
|
+
const icon = c20.kind === "add" ? "+" : c20.kind === "delete" ? "-" : "~";
|
|
5023
|
+
return `${icon}${c20.path}`;
|
|
4878
5024
|
}).join(", ");
|
|
4879
5025
|
console.log(chalk4.green("[files]") + ` ${summary}`);
|
|
4880
5026
|
return;
|
|
@@ -6261,9 +6407,7 @@ var mainRunCommand = new Command2().name("run").description("Run an agent").argu
|
|
|
6261
6407
|
);
|
|
6262
6408
|
} else if (error.message.startsWith("Version not found:")) {
|
|
6263
6409
|
console.error(chalk6.red(`\u2717 ${error.message}`));
|
|
6264
|
-
console.error(
|
|
6265
|
-
chalk6.dim(" Make sure the version hash is correct.")
|
|
6266
|
-
);
|
|
6410
|
+
console.error(chalk6.dim(" Make sure the version hash is correct"));
|
|
6267
6411
|
} else if (error.message.startsWith("Environment file not found:")) {
|
|
6268
6412
|
console.error(chalk6.red(`\u2717 ${error.message}`));
|
|
6269
6413
|
} else if (error.message.includes("not found")) {
|
|
@@ -6600,130 +6744,47 @@ async function writeStorageConfig(storageName, basePath = process.cwd(), type =
|
|
|
6600
6744
|
await writeFile4(configPath, yamlContent, "utf8");
|
|
6601
6745
|
}
|
|
6602
6746
|
|
|
6603
|
-
// src/
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
initial,
|
|
6618
|
-
validate
|
|
6619
|
-
},
|
|
6620
|
-
{
|
|
6621
|
-
onCancel: () => {
|
|
6622
|
-
return false;
|
|
6623
|
-
}
|
|
6747
|
+
// src/commands/volume/init.ts
|
|
6748
|
+
var initCommand = new Command5().name("init").description("Initialize a volume in the current directory").option("-n, --name <name>", "Volume name (required in non-interactive mode)").action(async (options) => {
|
|
6749
|
+
try {
|
|
6750
|
+
const cwd = process.cwd();
|
|
6751
|
+
const dirName = path6.basename(cwd);
|
|
6752
|
+
const existingConfig = await readStorageConfig(cwd);
|
|
6753
|
+
if (existingConfig) {
|
|
6754
|
+
console.log(
|
|
6755
|
+
chalk9.yellow(`Volume already initialized: ${existingConfig.name}`)
|
|
6756
|
+
);
|
|
6757
|
+
console.log(
|
|
6758
|
+
chalk9.dim(`Config file: ${path6.join(cwd, ".vm0", "storage.yaml")}`)
|
|
6759
|
+
);
|
|
6760
|
+
return;
|
|
6624
6761
|
}
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
}
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
const response = await prompts2(
|
|
6652
|
-
{
|
|
6653
|
-
type: "select",
|
|
6654
|
-
name: "value",
|
|
6655
|
-
message,
|
|
6656
|
-
choices,
|
|
6657
|
-
initial
|
|
6658
|
-
},
|
|
6659
|
-
{
|
|
6660
|
-
onCancel: () => {
|
|
6661
|
-
return false;
|
|
6662
|
-
}
|
|
6663
|
-
}
|
|
6664
|
-
);
|
|
6665
|
-
return response.value;
|
|
6666
|
-
}
|
|
6667
|
-
async function promptPassword(message) {
|
|
6668
|
-
if (!isInteractive()) {
|
|
6669
|
-
return void 0;
|
|
6670
|
-
}
|
|
6671
|
-
const response = await prompts2(
|
|
6672
|
-
{
|
|
6673
|
-
type: "password",
|
|
6674
|
-
name: "value",
|
|
6675
|
-
message
|
|
6676
|
-
},
|
|
6677
|
-
{
|
|
6678
|
-
onCancel: () => {
|
|
6679
|
-
return false;
|
|
6680
|
-
}
|
|
6681
|
-
}
|
|
6682
|
-
);
|
|
6683
|
-
return response.value;
|
|
6684
|
-
}
|
|
6685
|
-
|
|
6686
|
-
// src/commands/volume/init.ts
|
|
6687
|
-
var initCommand = new Command5().name("init").description("Initialize a volume in the current directory").option("-n, --name <name>", "Volume name (required in non-interactive mode)").action(async (options) => {
|
|
6688
|
-
try {
|
|
6689
|
-
const cwd = process.cwd();
|
|
6690
|
-
const dirName = path6.basename(cwd);
|
|
6691
|
-
const existingConfig = await readStorageConfig(cwd);
|
|
6692
|
-
if (existingConfig) {
|
|
6693
|
-
console.log(
|
|
6694
|
-
chalk9.yellow(`Volume already initialized: ${existingConfig.name}`)
|
|
6695
|
-
);
|
|
6696
|
-
console.log(
|
|
6697
|
-
chalk9.dim(`Config file: ${path6.join(cwd, ".vm0", "storage.yaml")}`)
|
|
6698
|
-
);
|
|
6699
|
-
return;
|
|
6700
|
-
}
|
|
6701
|
-
let volumeName;
|
|
6702
|
-
if (options.name) {
|
|
6703
|
-
volumeName = options.name;
|
|
6704
|
-
} else if (!isInteractive()) {
|
|
6705
|
-
console.error(
|
|
6706
|
-
chalk9.red("\u2717 --name flag is required in non-interactive mode")
|
|
6707
|
-
);
|
|
6708
|
-
console.error(
|
|
6709
|
-
chalk9.dim(" Usage: vm0 volume init --name <volume-name>")
|
|
6710
|
-
);
|
|
6711
|
-
process.exit(1);
|
|
6712
|
-
} else {
|
|
6713
|
-
const defaultName = isValidStorageName(dirName) ? dirName : void 0;
|
|
6714
|
-
const name = await promptText(
|
|
6715
|
-
"Enter volume name",
|
|
6716
|
-
defaultName,
|
|
6717
|
-
(value) => {
|
|
6718
|
-
if (!isValidStorageName(value)) {
|
|
6719
|
-
return "Must be 3-64 characters, lowercase alphanumeric with hyphens";
|
|
6720
|
-
}
|
|
6721
|
-
return true;
|
|
6722
|
-
}
|
|
6723
|
-
);
|
|
6724
|
-
if (name === void 0) {
|
|
6725
|
-
console.log(chalk9.dim("Cancelled"));
|
|
6726
|
-
return;
|
|
6762
|
+
let volumeName;
|
|
6763
|
+
if (options.name) {
|
|
6764
|
+
volumeName = options.name;
|
|
6765
|
+
} else if (!isInteractive()) {
|
|
6766
|
+
console.error(
|
|
6767
|
+
chalk9.red("\u2717 --name flag is required in non-interactive mode")
|
|
6768
|
+
);
|
|
6769
|
+
console.error(
|
|
6770
|
+
chalk9.dim(" Usage: vm0 volume init --name <volume-name>")
|
|
6771
|
+
);
|
|
6772
|
+
process.exit(1);
|
|
6773
|
+
} else {
|
|
6774
|
+
const defaultName = isValidStorageName(dirName) ? dirName : void 0;
|
|
6775
|
+
const name = await promptText(
|
|
6776
|
+
"Enter volume name",
|
|
6777
|
+
defaultName,
|
|
6778
|
+
(value) => {
|
|
6779
|
+
if (!isValidStorageName(value)) {
|
|
6780
|
+
return "Must be 3-64 characters, lowercase alphanumeric with hyphens";
|
|
6781
|
+
}
|
|
6782
|
+
return true;
|
|
6783
|
+
}
|
|
6784
|
+
);
|
|
6785
|
+
if (name === void 0) {
|
|
6786
|
+
console.log(chalk9.dim("Cancelled"));
|
|
6787
|
+
return;
|
|
6727
6788
|
}
|
|
6728
6789
|
volumeName = name;
|
|
6729
6790
|
}
|
|
@@ -6743,7 +6804,7 @@ var initCommand = new Command5().name("init").description("Initialize a volume i
|
|
|
6743
6804
|
console.log(chalk9.green(`\u2713 Initialized volume: ${volumeName}`));
|
|
6744
6805
|
console.log(
|
|
6745
6806
|
chalk9.dim(
|
|
6746
|
-
|
|
6807
|
+
` Config saved to ${path6.join(cwd, ".vm0", "storage.yaml")}`
|
|
6747
6808
|
)
|
|
6748
6809
|
);
|
|
6749
6810
|
} catch (error) {
|
|
@@ -6758,13 +6819,6 @@ var initCommand = new Command5().name("init").description("Initialize a volume i
|
|
|
6758
6819
|
// src/commands/volume/push.ts
|
|
6759
6820
|
import { Command as Command6 } from "commander";
|
|
6760
6821
|
import chalk10 from "chalk";
|
|
6761
|
-
function formatBytes2(bytes) {
|
|
6762
|
-
if (bytes === 0) return "0 B";
|
|
6763
|
-
const k = 1024;
|
|
6764
|
-
const sizes = ["B", "KB", "MB", "GB"];
|
|
6765
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
6766
|
-
return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}`;
|
|
6767
|
-
}
|
|
6768
6822
|
var pushCommand = new Command6().name("push").description("Push local files to cloud volume").option(
|
|
6769
6823
|
"-f, --force",
|
|
6770
6824
|
"Force upload even if content unchanged (recreate archive)"
|
|
@@ -6786,7 +6840,7 @@ var pushCommand = new Command6().name("push").description("Push local files to c
|
|
|
6786
6840
|
});
|
|
6787
6841
|
const shortVersion = result.versionId.slice(0, 8);
|
|
6788
6842
|
if (result.empty) {
|
|
6789
|
-
console.log(chalk10.
|
|
6843
|
+
console.log(chalk10.dim("No files found (empty volume)"));
|
|
6790
6844
|
} else if (result.deduplicated) {
|
|
6791
6845
|
console.log(chalk10.green("\u2713 Content unchanged (deduplicated)"));
|
|
6792
6846
|
} else {
|
|
@@ -6794,7 +6848,7 @@ var pushCommand = new Command6().name("push").description("Push local files to c
|
|
|
6794
6848
|
}
|
|
6795
6849
|
console.log(chalk10.dim(` Version: ${shortVersion}`));
|
|
6796
6850
|
console.log(chalk10.dim(` Files: ${result.fileCount.toLocaleString()}`));
|
|
6797
|
-
console.log(chalk10.dim(` Size: ${
|
|
6851
|
+
console.log(chalk10.dim(` Size: ${formatBytes(result.size)}`));
|
|
6798
6852
|
} catch (error) {
|
|
6799
6853
|
console.error(chalk10.red("\u2717 Push failed"));
|
|
6800
6854
|
if (error instanceof Error) {
|
|
@@ -6829,13 +6883,6 @@ async function handleEmptyStorageResponse(cwd) {
|
|
|
6829
6883
|
}
|
|
6830
6884
|
|
|
6831
6885
|
// src/commands/volume/pull.ts
|
|
6832
|
-
function formatBytes3(bytes) {
|
|
6833
|
-
if (bytes === 0) return "0 B";
|
|
6834
|
-
const k = 1024;
|
|
6835
|
-
const sizes = ["B", "KB", "MB", "GB"];
|
|
6836
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
6837
|
-
return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}`;
|
|
6838
|
-
}
|
|
6839
6886
|
var pullCommand = new Command7().name("pull").description("Pull cloud files to local directory").argument("[versionId]", "Version ID to pull (default: latest)").action(async (versionId) => {
|
|
6840
6887
|
try {
|
|
6841
6888
|
const cwd = process.cwd();
|
|
@@ -6871,7 +6918,7 @@ var pullCommand = new Command7().name("pull").description("Pull cloud files to l
|
|
|
6871
6918
|
}
|
|
6872
6919
|
const arrayBuffer = await s3Response.arrayBuffer();
|
|
6873
6920
|
const tarBuffer = Buffer.from(arrayBuffer);
|
|
6874
|
-
console.log(chalk12.green(`\u2713 Downloaded ${
|
|
6921
|
+
console.log(chalk12.green(`\u2713 Downloaded ${formatBytes(tarBuffer.length)}`));
|
|
6875
6922
|
const tmpDir = fs6.mkdtempSync(path7.join(os4.tmpdir(), "vm0-"));
|
|
6876
6923
|
const tarPath = path7.join(tmpDir, "volume.tar.gz");
|
|
6877
6924
|
await fs6.promises.writeFile(tarPath, tarBuffer);
|
|
@@ -6911,13 +6958,6 @@ var pullCommand = new Command7().name("pull").description("Pull cloud files to l
|
|
|
6911
6958
|
// src/commands/volume/status.ts
|
|
6912
6959
|
import { Command as Command8 } from "commander";
|
|
6913
6960
|
import chalk13 from "chalk";
|
|
6914
|
-
function formatBytes4(bytes) {
|
|
6915
|
-
if (bytes === 0) return "0 B";
|
|
6916
|
-
const k = 1024;
|
|
6917
|
-
const sizes = ["B", "KB", "MB", "GB"];
|
|
6918
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
6919
|
-
return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}`;
|
|
6920
|
-
}
|
|
6921
6961
|
var statusCommand = new Command8().name("status").description("Show status of cloud volume").action(async () => {
|
|
6922
6962
|
try {
|
|
6923
6963
|
const cwd = process.cwd();
|
|
@@ -6949,7 +6989,7 @@ var statusCommand = new Command8().name("status").description("Show status of cl
|
|
|
6949
6989
|
console.log(chalk13.green("\u2713 Found"));
|
|
6950
6990
|
console.log(chalk13.dim(` Version: ${shortVersion}`));
|
|
6951
6991
|
console.log(chalk13.dim(` Files: ${info.fileCount.toLocaleString()}`));
|
|
6952
|
-
console.log(chalk13.dim(` Size: ${
|
|
6992
|
+
console.log(chalk13.dim(` Size: ${formatBytes(info.size)}`));
|
|
6953
6993
|
}
|
|
6954
6994
|
} catch (error) {
|
|
6955
6995
|
if (error instanceof Error && error.message.includes("not found")) {
|
|
@@ -7200,7 +7240,7 @@ var initCommand2 = new Command12().name("init").description("Initialize an artif
|
|
|
7200
7240
|
console.log(chalk17.green(`\u2713 Initialized artifact: ${artifactName}`));
|
|
7201
7241
|
console.log(
|
|
7202
7242
|
chalk17.dim(
|
|
7203
|
-
|
|
7243
|
+
` Config saved to ${path9.join(cwd, ".vm0", "storage.yaml")}`
|
|
7204
7244
|
)
|
|
7205
7245
|
);
|
|
7206
7246
|
} catch (error) {
|
|
@@ -7215,13 +7255,6 @@ var initCommand2 = new Command12().name("init").description("Initialize an artif
|
|
|
7215
7255
|
// src/commands/artifact/push.ts
|
|
7216
7256
|
import { Command as Command13 } from "commander";
|
|
7217
7257
|
import chalk18 from "chalk";
|
|
7218
|
-
function formatBytes5(bytes) {
|
|
7219
|
-
if (bytes === 0) return "0 B";
|
|
7220
|
-
const k = 1024;
|
|
7221
|
-
const sizes = ["B", "KB", "MB", "GB"];
|
|
7222
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
7223
|
-
return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}`;
|
|
7224
|
-
}
|
|
7225
7258
|
var pushCommand2 = new Command13().name("push").description("Push local files to cloud artifact").option(
|
|
7226
7259
|
"-f, --force",
|
|
7227
7260
|
"Force upload even if content unchanged (recreate archive)"
|
|
@@ -7252,7 +7285,7 @@ var pushCommand2 = new Command13().name("push").description("Push local files to
|
|
|
7252
7285
|
});
|
|
7253
7286
|
const shortVersion = result.versionId.slice(0, 8);
|
|
7254
7287
|
if (result.empty) {
|
|
7255
|
-
console.log(chalk18.
|
|
7288
|
+
console.log(chalk18.dim("No files found (empty artifact)"));
|
|
7256
7289
|
} else if (result.deduplicated) {
|
|
7257
7290
|
console.log(chalk18.green("\u2713 Content unchanged (deduplicated)"));
|
|
7258
7291
|
} else {
|
|
@@ -7260,7 +7293,7 @@ var pushCommand2 = new Command13().name("push").description("Push local files to
|
|
|
7260
7293
|
}
|
|
7261
7294
|
console.log(chalk18.dim(` Version: ${shortVersion}`));
|
|
7262
7295
|
console.log(chalk18.dim(` Files: ${result.fileCount.toLocaleString()}`));
|
|
7263
|
-
console.log(chalk18.dim(` Size: ${
|
|
7296
|
+
console.log(chalk18.dim(` Size: ${formatBytes(result.size)}`));
|
|
7264
7297
|
} catch (error) {
|
|
7265
7298
|
console.error(chalk18.red("\u2717 Push failed"));
|
|
7266
7299
|
if (error instanceof Error) {
|
|
@@ -7277,13 +7310,6 @@ import path10 from "path";
|
|
|
7277
7310
|
import * as fs8 from "fs";
|
|
7278
7311
|
import * as os6 from "os";
|
|
7279
7312
|
import * as tar5 from "tar";
|
|
7280
|
-
function formatBytes6(bytes) {
|
|
7281
|
-
if (bytes === 0) return "0 B";
|
|
7282
|
-
const k = 1024;
|
|
7283
|
-
const sizes = ["B", "KB", "MB", "GB"];
|
|
7284
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
7285
|
-
return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}`;
|
|
7286
|
-
}
|
|
7287
7313
|
var pullCommand2 = new Command14().name("pull").description("Pull cloud artifact to local directory").argument("[versionId]", "Version ID to pull (default: latest)").action(async (versionId) => {
|
|
7288
7314
|
try {
|
|
7289
7315
|
const cwd = process.cwd();
|
|
@@ -7328,7 +7354,7 @@ var pullCommand2 = new Command14().name("pull").description("Pull cloud artifact
|
|
|
7328
7354
|
}
|
|
7329
7355
|
const arrayBuffer = await s3Response.arrayBuffer();
|
|
7330
7356
|
const tarBuffer = Buffer.from(arrayBuffer);
|
|
7331
|
-
console.log(chalk19.green(`\u2713 Downloaded ${
|
|
7357
|
+
console.log(chalk19.green(`\u2713 Downloaded ${formatBytes(tarBuffer.length)}`));
|
|
7332
7358
|
const tmpDir = fs8.mkdtempSync(path10.join(os6.tmpdir(), "vm0-"));
|
|
7333
7359
|
const tarPath = path10.join(tmpDir, "artifact.tar.gz");
|
|
7334
7360
|
await fs8.promises.writeFile(tarPath, tarBuffer);
|
|
@@ -7364,13 +7390,6 @@ var pullCommand2 = new Command14().name("pull").description("Pull cloud artifact
|
|
|
7364
7390
|
// src/commands/artifact/status.ts
|
|
7365
7391
|
import { Command as Command15 } from "commander";
|
|
7366
7392
|
import chalk20 from "chalk";
|
|
7367
|
-
function formatBytes7(bytes) {
|
|
7368
|
-
if (bytes === 0) return "0 B";
|
|
7369
|
-
const k = 1024;
|
|
7370
|
-
const sizes = ["B", "KB", "MB", "GB"];
|
|
7371
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
7372
|
-
return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}`;
|
|
7373
|
-
}
|
|
7374
7393
|
var statusCommand2 = new Command15().name("status").description("Show status of cloud artifact").action(async () => {
|
|
7375
7394
|
try {
|
|
7376
7395
|
const cwd = process.cwd();
|
|
@@ -7402,7 +7421,7 @@ var statusCommand2 = new Command15().name("status").description("Show status of
|
|
|
7402
7421
|
console.log(chalk20.green("\u2713 Found"));
|
|
7403
7422
|
console.log(chalk20.dim(` Version: ${shortVersion}`));
|
|
7404
7423
|
console.log(chalk20.dim(` Files: ${info.fileCount.toLocaleString()}`));
|
|
7405
|
-
console.log(chalk20.dim(` Size: ${
|
|
7424
|
+
console.log(chalk20.dim(` Size: ${formatBytes(info.size)}`));
|
|
7406
7425
|
}
|
|
7407
7426
|
} catch (error) {
|
|
7408
7427
|
if (error instanceof Error && error.message.includes("not found")) {
|
|
@@ -7869,7 +7888,7 @@ cookCmd.argument("[prompt]", "Prompt for the agent").option(
|
|
|
7869
7888
|
// eslint-disable-next-line complexity -- TODO: refactor complex function
|
|
7870
7889
|
async (prompt, options) => {
|
|
7871
7890
|
if (!options.noAutoUpdate) {
|
|
7872
|
-
const shouldExit = await checkAndUpgrade("
|
|
7891
|
+
const shouldExit = await checkAndUpgrade("9.0.0", prompt);
|
|
7873
7892
|
if (shouldExit) {
|
|
7874
7893
|
process.exit(0);
|
|
7875
7894
|
}
|
|
@@ -7913,7 +7932,7 @@ cookCmd.argument("[prompt]", "Prompt for the agent").option(
|
|
|
7913
7932
|
console.log();
|
|
7914
7933
|
console.error(chalk24.red("\u2717 Missing required variables:"));
|
|
7915
7934
|
for (const varName of missingVars) {
|
|
7916
|
-
console.error(chalk24.red(`
|
|
7935
|
+
console.error(chalk24.red(` ${varName}`));
|
|
7917
7936
|
}
|
|
7918
7937
|
console.error(
|
|
7919
7938
|
chalk24.dim(
|
|
@@ -7936,9 +7955,10 @@ cookCmd.argument("[prompt]", "Prompt for the agent").option(
|
|
|
7936
7955
|
const volumeDir = path11.join(cwd, volumeConfig.name);
|
|
7937
7956
|
if (!existsSync8(volumeDir)) {
|
|
7938
7957
|
console.error(
|
|
7939
|
-
chalk24.red(
|
|
7940
|
-
|
|
7941
|
-
|
|
7958
|
+
chalk24.red(`\u2717 Directory not found: ${volumeConfig.name}`)
|
|
7959
|
+
);
|
|
7960
|
+
console.error(
|
|
7961
|
+
chalk24.dim(" Create the directory and add files first")
|
|
7942
7962
|
);
|
|
7943
7963
|
process.exit(1);
|
|
7944
7964
|
}
|
|
@@ -8244,17 +8264,10 @@ function parseRelativeTime(value, unit) {
|
|
|
8244
8264
|
}
|
|
8245
8265
|
|
|
8246
8266
|
// src/commands/logs/index.ts
|
|
8247
|
-
function formatBytes8(bytes) {
|
|
8248
|
-
if (bytes === 0) return "0 B";
|
|
8249
|
-
const k = 1024;
|
|
8250
|
-
const sizes = ["B", "KB", "MB", "GB"];
|
|
8251
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
8252
|
-
return `${(bytes / Math.pow(k, i)).toFixed(1)} ${sizes[i]}`;
|
|
8253
|
-
}
|
|
8254
8267
|
function formatMetric(metric) {
|
|
8255
8268
|
const memPercent = (metric.mem_used / metric.mem_total * 100).toFixed(1);
|
|
8256
8269
|
const diskPercent = (metric.disk_used / metric.disk_total * 100).toFixed(1);
|
|
8257
|
-
return `[${metric.ts}] CPU: ${metric.cpu.toFixed(1)}% | Mem: ${
|
|
8270
|
+
return `[${metric.ts}] CPU: ${metric.cpu.toFixed(1)}% | Mem: ${formatBytes(metric.mem_used)}/${formatBytes(metric.mem_total)} (${memPercent}%) | Disk: ${formatBytes(metric.disk_used)}/${formatBytes(metric.disk_total)} (${diskPercent}%)`;
|
|
8258
8271
|
}
|
|
8259
8272
|
function formatNetworkLog(entry) {
|
|
8260
8273
|
if (entry.mode === "sni" || !entry.method) {
|
|
@@ -8287,7 +8300,7 @@ function formatNetworkLog(entry) {
|
|
|
8287
8300
|
const requestSize = entry.request_size || 0;
|
|
8288
8301
|
const responseSize = entry.response_size || 0;
|
|
8289
8302
|
const url = entry.url || entry.host || "unknown";
|
|
8290
|
-
return `[${entry.timestamp}] ${method.padEnd(6)} ${statusColor(status)} ${latencyColor(latencyMs + "ms")} ${
|
|
8303
|
+
return `[${entry.timestamp}] ${method.padEnd(6)} ${statusColor(status)} ${latencyColor(latencyMs + "ms")} ${formatBytes(requestSize)}/${formatBytes(responseSize)} ${chalk25.dim(url)}`;
|
|
8291
8304
|
}
|
|
8292
8305
|
function renderAgentEvent(event, provider) {
|
|
8293
8306
|
const eventData = event.eventData;
|
|
@@ -8367,7 +8380,7 @@ var logsCommand = new Command20().name("logs").description("View logs for an age
|
|
|
8367
8380
|
async function showAgentEvents(runId, options) {
|
|
8368
8381
|
const response = await apiClient.getAgentEvents(runId, options);
|
|
8369
8382
|
if (response.events.length === 0) {
|
|
8370
|
-
console.log(chalk25.yellow("No agent events found for this run
|
|
8383
|
+
console.log(chalk25.yellow("No agent events found for this run"));
|
|
8371
8384
|
return;
|
|
8372
8385
|
}
|
|
8373
8386
|
const events = options.order === "desc" ? [...response.events].reverse() : response.events;
|
|
@@ -8386,7 +8399,7 @@ async function showAgentEvents(runId, options) {
|
|
|
8386
8399
|
async function showSystemLog(runId, options) {
|
|
8387
8400
|
const response = await apiClient.getSystemLog(runId, options);
|
|
8388
8401
|
if (!response.systemLog) {
|
|
8389
|
-
console.log(chalk25.yellow("No system log found for this run
|
|
8402
|
+
console.log(chalk25.yellow("No system log found for this run"));
|
|
8390
8403
|
return;
|
|
8391
8404
|
}
|
|
8392
8405
|
console.log(response.systemLog);
|
|
@@ -8400,7 +8413,7 @@ async function showSystemLog(runId, options) {
|
|
|
8400
8413
|
async function showMetrics(runId, options) {
|
|
8401
8414
|
const response = await apiClient.getMetrics(runId, options);
|
|
8402
8415
|
if (response.metrics.length === 0) {
|
|
8403
|
-
console.log(chalk25.yellow("No metrics found for this run
|
|
8416
|
+
console.log(chalk25.yellow("No metrics found for this run"));
|
|
8404
8417
|
return;
|
|
8405
8418
|
}
|
|
8406
8419
|
const metrics = options.order === "desc" ? [...response.metrics].reverse() : response.metrics;
|
|
@@ -8421,7 +8434,7 @@ async function showNetworkLogs(runId, options) {
|
|
|
8421
8434
|
if (response.networkLogs.length === 0) {
|
|
8422
8435
|
console.log(
|
|
8423
8436
|
chalk25.yellow(
|
|
8424
|
-
"No network logs found for this run. Network logs are only captured when experimental_firewall is enabled on an experimental_runner
|
|
8437
|
+
"No network logs found for this run. Network logs are only captured when experimental_firewall is enabled on an experimental_runner"
|
|
8425
8438
|
)
|
|
8426
8439
|
);
|
|
8427
8440
|
return;
|
|
@@ -8476,7 +8489,7 @@ var statusCommand3 = new Command21().name("status").description("View current sc
|
|
|
8476
8489
|
if (error.message.includes("Not authenticated")) {
|
|
8477
8490
|
console.error(chalk26.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
8478
8491
|
} else if (error.message.includes("No scope configured")) {
|
|
8479
|
-
console.log(chalk26.yellow("No scope configured
|
|
8492
|
+
console.log(chalk26.yellow("No scope configured"));
|
|
8480
8493
|
console.log();
|
|
8481
8494
|
console.log("Set your scope with:");
|
|
8482
8495
|
console.log(chalk26.cyan(" vm0 scope set <slug>"));
|
|
@@ -8584,7 +8597,7 @@ var listCommand3 = new Command24().name("list").alias("ls").description("List al
|
|
|
8584
8597
|
);
|
|
8585
8598
|
return;
|
|
8586
8599
|
}
|
|
8587
|
-
const nameWidth = Math.max(4, ...data.composes.map((
|
|
8600
|
+
const nameWidth = Math.max(4, ...data.composes.map((c20) => c20.name.length));
|
|
8588
8601
|
const header = ["NAME".padEnd(nameWidth), "VERSION", "UPDATED"].join(
|
|
8589
8602
|
" "
|
|
8590
8603
|
);
|
|
@@ -8977,7 +8990,7 @@ import { Command as Command34 } from "commander";
|
|
|
8977
8990
|
|
|
8978
8991
|
// src/commands/schedule/setup.ts
|
|
8979
8992
|
import { Command as Command28 } from "commander";
|
|
8980
|
-
import
|
|
8993
|
+
import chalk32 from "chalk";
|
|
8981
8994
|
|
|
8982
8995
|
// src/lib/domain/schedule-utils.ts
|
|
8983
8996
|
import { parse as parseYaml5 } from "yaml";
|
|
@@ -9118,6 +9131,127 @@ async function resolveScheduleByAgent(agentName) {
|
|
|
9118
9131
|
};
|
|
9119
9132
|
}
|
|
9120
9133
|
|
|
9134
|
+
// src/commands/schedule/gather-configuration.ts
|
|
9135
|
+
import chalk31 from "chalk";
|
|
9136
|
+
var defaultPromptDeps = {
|
|
9137
|
+
isInteractive,
|
|
9138
|
+
promptConfirm,
|
|
9139
|
+
promptPassword,
|
|
9140
|
+
promptText
|
|
9141
|
+
};
|
|
9142
|
+
function parseKeyValuePairs(pairs) {
|
|
9143
|
+
const result = {};
|
|
9144
|
+
for (const pair of pairs) {
|
|
9145
|
+
const eqIndex = pair.indexOf("=");
|
|
9146
|
+
if (eqIndex > 0) {
|
|
9147
|
+
const key = pair.slice(0, eqIndex);
|
|
9148
|
+
const value = pair.slice(eqIndex + 1);
|
|
9149
|
+
result[key] = value;
|
|
9150
|
+
}
|
|
9151
|
+
}
|
|
9152
|
+
return result;
|
|
9153
|
+
}
|
|
9154
|
+
async function handleSecrets(optionSecrets, existingSecretNames, deps) {
|
|
9155
|
+
if (optionSecrets.length > 0) {
|
|
9156
|
+
return {
|
|
9157
|
+
secrets: parseKeyValuePairs(optionSecrets),
|
|
9158
|
+
preserveExistingSecrets: false
|
|
9159
|
+
};
|
|
9160
|
+
}
|
|
9161
|
+
if (existingSecretNames.length > 0 && deps.isInteractive()) {
|
|
9162
|
+
const keepSecrets = await deps.promptConfirm(
|
|
9163
|
+
`Keep existing secrets? (${existingSecretNames.join(", ")})`,
|
|
9164
|
+
true
|
|
9165
|
+
);
|
|
9166
|
+
if (keepSecrets) {
|
|
9167
|
+
return { secrets: {}, preserveExistingSecrets: true };
|
|
9168
|
+
}
|
|
9169
|
+
console.log(chalk31.dim(" Note: You'll need to provide new secret values"));
|
|
9170
|
+
return { secrets: {}, preserveExistingSecrets: false };
|
|
9171
|
+
}
|
|
9172
|
+
return { secrets: {}, preserveExistingSecrets: false };
|
|
9173
|
+
}
|
|
9174
|
+
async function handleVars(optionVars, existingVars, deps) {
|
|
9175
|
+
if (optionVars.length > 0) {
|
|
9176
|
+
return parseKeyValuePairs(optionVars);
|
|
9177
|
+
}
|
|
9178
|
+
if (existingVars && deps.isInteractive()) {
|
|
9179
|
+
const keepVars = await deps.promptConfirm(
|
|
9180
|
+
`Keep existing variables? (${Object.keys(existingVars).join(", ")})`,
|
|
9181
|
+
true
|
|
9182
|
+
);
|
|
9183
|
+
if (keepVars) {
|
|
9184
|
+
return { ...existingVars };
|
|
9185
|
+
}
|
|
9186
|
+
}
|
|
9187
|
+
return {};
|
|
9188
|
+
}
|
|
9189
|
+
function displayMissingRequirements(missingSecrets, missingVars) {
|
|
9190
|
+
console.log(chalk31.yellow("\nAgent requires the following configuration:"));
|
|
9191
|
+
if (missingSecrets.length > 0) {
|
|
9192
|
+
console.log(chalk31.dim(" Secrets:"));
|
|
9193
|
+
for (const name of missingSecrets) {
|
|
9194
|
+
console.log(chalk31.dim(` ${name}`));
|
|
9195
|
+
}
|
|
9196
|
+
}
|
|
9197
|
+
if (missingVars.length > 0) {
|
|
9198
|
+
console.log(chalk31.dim(" Vars:"));
|
|
9199
|
+
for (const name of missingVars) {
|
|
9200
|
+
console.log(chalk31.dim(` ${name}`));
|
|
9201
|
+
}
|
|
9202
|
+
}
|
|
9203
|
+
console.log("");
|
|
9204
|
+
}
|
|
9205
|
+
async function promptForMissingSecrets(missingSecrets, secrets, deps) {
|
|
9206
|
+
for (const name of missingSecrets) {
|
|
9207
|
+
const value = await deps.promptPassword(
|
|
9208
|
+
`Enter value for secret ${chalk31.cyan(name)}`
|
|
9209
|
+
);
|
|
9210
|
+
if (value) {
|
|
9211
|
+
secrets[name] = value;
|
|
9212
|
+
}
|
|
9213
|
+
}
|
|
9214
|
+
}
|
|
9215
|
+
async function promptForMissingVars(missingVars, vars, deps) {
|
|
9216
|
+
for (const name of missingVars) {
|
|
9217
|
+
const value = await deps.promptText(
|
|
9218
|
+
`Enter value for var ${chalk31.cyan(name)}`,
|
|
9219
|
+
""
|
|
9220
|
+
);
|
|
9221
|
+
if (value) {
|
|
9222
|
+
vars[name] = value;
|
|
9223
|
+
}
|
|
9224
|
+
}
|
|
9225
|
+
}
|
|
9226
|
+
async function gatherConfiguration(params, deps = defaultPromptDeps) {
|
|
9227
|
+
const { required, optionSecrets, optionVars, existingSchedule } = params;
|
|
9228
|
+
const existingSecretNames = existingSchedule?.secretNames ?? [];
|
|
9229
|
+
const existingVars = existingSchedule?.vars ?? null;
|
|
9230
|
+
const { secrets, preserveExistingSecrets } = await handleSecrets(
|
|
9231
|
+
optionSecrets,
|
|
9232
|
+
existingSecretNames,
|
|
9233
|
+
deps
|
|
9234
|
+
);
|
|
9235
|
+
const vars = await handleVars(optionVars, existingVars, deps);
|
|
9236
|
+
const effectiveExistingSecrets = preserveExistingSecrets ? existingSecretNames : [];
|
|
9237
|
+
const missingSecrets = required.secrets.filter(
|
|
9238
|
+
(name) => !Object.keys(secrets).includes(name) && !effectiveExistingSecrets.includes(name)
|
|
9239
|
+
);
|
|
9240
|
+
const missingVars = required.vars.filter(
|
|
9241
|
+
(name) => !Object.keys(vars).includes(name)
|
|
9242
|
+
);
|
|
9243
|
+
if (missingSecrets.length === 0 && missingVars.length === 0) {
|
|
9244
|
+
return { secrets, vars, preserveExistingSecrets };
|
|
9245
|
+
}
|
|
9246
|
+
if (!deps.isInteractive()) {
|
|
9247
|
+
return { secrets, vars, preserveExistingSecrets };
|
|
9248
|
+
}
|
|
9249
|
+
displayMissingRequirements(missingSecrets, missingVars);
|
|
9250
|
+
await promptForMissingSecrets(missingSecrets, secrets, deps);
|
|
9251
|
+
await promptForMissingVars(missingVars, vars, deps);
|
|
9252
|
+
return { secrets, vars, preserveExistingSecrets };
|
|
9253
|
+
}
|
|
9254
|
+
|
|
9121
9255
|
// src/commands/schedule/setup.ts
|
|
9122
9256
|
var FREQUENCY_CHOICES = [
|
|
9123
9257
|
{ title: "Daily", value: "daily", description: "Run every day" },
|
|
@@ -9171,7 +9305,7 @@ function expandEnvVars(value) {
|
|
|
9171
9305
|
const envValue = process.env[varName];
|
|
9172
9306
|
if (envValue === void 0) {
|
|
9173
9307
|
console.warn(
|
|
9174
|
-
|
|
9308
|
+
chalk32.yellow(` Warning: Environment variable ${varName} not set`)
|
|
9175
9309
|
);
|
|
9176
9310
|
return match;
|
|
9177
9311
|
}
|
|
@@ -9217,18 +9351,6 @@ function parseFrequencyFromCron(cron) {
|
|
|
9217
9351
|
function collect(value, previous) {
|
|
9218
9352
|
return previous.concat([value]);
|
|
9219
9353
|
}
|
|
9220
|
-
function parseKeyValuePairs(pairs) {
|
|
9221
|
-
const result = {};
|
|
9222
|
-
for (const pair of pairs) {
|
|
9223
|
-
const eqIndex = pair.indexOf("=");
|
|
9224
|
-
if (eqIndex > 0) {
|
|
9225
|
-
const key = pair.slice(0, eqIndex);
|
|
9226
|
-
const value = pair.slice(eqIndex + 1);
|
|
9227
|
-
result[key] = value;
|
|
9228
|
-
}
|
|
9229
|
-
}
|
|
9230
|
-
return result;
|
|
9231
|
-
}
|
|
9232
9354
|
function getExistingDefaults(existingSchedule) {
|
|
9233
9355
|
const defaults = {};
|
|
9234
9356
|
if (existingSchedule?.cronExpression) {
|
|
@@ -9250,11 +9372,11 @@ async function gatherFrequency(optionFrequency, existingFrequency) {
|
|
|
9250
9372
|
}
|
|
9251
9373
|
if (!isInteractive()) {
|
|
9252
9374
|
console.error(
|
|
9253
|
-
|
|
9375
|
+
chalk32.red("\u2717 --frequency is required (daily|weekly|monthly|once)")
|
|
9254
9376
|
);
|
|
9255
9377
|
process.exit(1);
|
|
9256
9378
|
}
|
|
9257
|
-
const defaultIndex = existingFrequency ? FREQUENCY_CHOICES.findIndex((
|
|
9379
|
+
const defaultIndex = existingFrequency ? FREQUENCY_CHOICES.findIndex((c20) => c20.value === existingFrequency) : 0;
|
|
9258
9380
|
frequency = await promptSelect(
|
|
9259
9381
|
"Schedule frequency",
|
|
9260
9382
|
FREQUENCY_CHOICES,
|
|
@@ -9270,7 +9392,7 @@ async function gatherDay(frequency, optionDay, existingDay) {
|
|
|
9270
9392
|
const day2 = parseDayOption(optionDay, frequency);
|
|
9271
9393
|
if (day2 === void 0) {
|
|
9272
9394
|
console.error(
|
|
9273
|
-
|
|
9395
|
+
chalk32.red(
|
|
9274
9396
|
`\u2717 Invalid day: ${optionDay}. Use mon-sun for weekly or 1-31 for monthly.`
|
|
9275
9397
|
)
|
|
9276
9398
|
);
|
|
@@ -9279,11 +9401,11 @@ async function gatherDay(frequency, optionDay, existingDay) {
|
|
|
9279
9401
|
return day2;
|
|
9280
9402
|
}
|
|
9281
9403
|
if (!isInteractive()) {
|
|
9282
|
-
console.error(
|
|
9404
|
+
console.error(chalk32.red("\u2717 --day is required for weekly/monthly"));
|
|
9283
9405
|
process.exit(1);
|
|
9284
9406
|
}
|
|
9285
9407
|
if (frequency === "weekly") {
|
|
9286
|
-
const defaultDayIndex = existingDay !== void 0 ? DAY_OF_WEEK_CHOICES.findIndex((
|
|
9408
|
+
const defaultDayIndex = existingDay !== void 0 ? DAY_OF_WEEK_CHOICES.findIndex((c20) => c20.value === existingDay) : 0;
|
|
9287
9409
|
const day2 = await promptSelect(
|
|
9288
9410
|
"Day of week",
|
|
9289
9411
|
DAY_OF_WEEK_CHOICES,
|
|
@@ -9298,7 +9420,7 @@ async function gatherDay(frequency, optionDay, existingDay) {
|
|
|
9298
9420
|
if (!dayStr) return null;
|
|
9299
9421
|
const day = parseInt(dayStr, 10);
|
|
9300
9422
|
if (isNaN(day) || day < 1 || day > 31) {
|
|
9301
|
-
console.error(
|
|
9423
|
+
console.error(chalk32.red("\u2717 Day must be between 1 and 31"));
|
|
9302
9424
|
process.exit(1);
|
|
9303
9425
|
}
|
|
9304
9426
|
return day;
|
|
@@ -9307,13 +9429,13 @@ async function gatherRecurringTime(optionTime, existingTime) {
|
|
|
9307
9429
|
if (optionTime) {
|
|
9308
9430
|
const validation = validateTimeFormat(optionTime);
|
|
9309
9431
|
if (validation !== true) {
|
|
9310
|
-
console.error(
|
|
9432
|
+
console.error(chalk32.red(`\u2717 Invalid time: ${validation}`));
|
|
9311
9433
|
process.exit(1);
|
|
9312
9434
|
}
|
|
9313
9435
|
return optionTime;
|
|
9314
9436
|
}
|
|
9315
9437
|
if (!isInteractive()) {
|
|
9316
|
-
console.error(
|
|
9438
|
+
console.error(chalk32.red("\u2717 --time is required (HH:MM format)"));
|
|
9317
9439
|
process.exit(1);
|
|
9318
9440
|
}
|
|
9319
9441
|
return await promptText(
|
|
@@ -9326,7 +9448,7 @@ async function gatherOneTimeSchedule(optionDay, optionTime, existingTime) {
|
|
|
9326
9448
|
if (optionDay && optionTime) {
|
|
9327
9449
|
if (!validateDateFormat(optionDay)) {
|
|
9328
9450
|
console.error(
|
|
9329
|
-
|
|
9451
|
+
chalk32.red(
|
|
9330
9452
|
`\u2717 Invalid date format: ${optionDay}. Use YYYY-MM-DD format.`
|
|
9331
9453
|
)
|
|
9332
9454
|
);
|
|
@@ -9334,16 +9456,16 @@ async function gatherOneTimeSchedule(optionDay, optionTime, existingTime) {
|
|
|
9334
9456
|
}
|
|
9335
9457
|
if (!validateTimeFormat(optionTime)) {
|
|
9336
9458
|
console.error(
|
|
9337
|
-
|
|
9459
|
+
chalk32.red(`\u2717 Invalid time format: ${optionTime}. Use HH:MM format.`)
|
|
9338
9460
|
);
|
|
9339
9461
|
process.exit(1);
|
|
9340
9462
|
}
|
|
9341
9463
|
return `${optionDay} ${optionTime}`;
|
|
9342
9464
|
}
|
|
9343
9465
|
if (!isInteractive()) {
|
|
9344
|
-
console.error(
|
|
9466
|
+
console.error(chalk32.red("\u2717 One-time schedules require interactive mode"));
|
|
9345
9467
|
console.error(
|
|
9346
|
-
|
|
9468
|
+
chalk32.dim(" Or provide --day (YYYY-MM-DD) and --time (HH:MM) flags")
|
|
9347
9469
|
);
|
|
9348
9470
|
process.exit(1);
|
|
9349
9471
|
}
|
|
@@ -9374,7 +9496,7 @@ async function gatherTimezone(optionTimezone, existingTimezone) {
|
|
|
9374
9496
|
async function gatherPromptText(optionPrompt, existingPrompt) {
|
|
9375
9497
|
if (optionPrompt) return optionPrompt;
|
|
9376
9498
|
if (!isInteractive()) {
|
|
9377
|
-
console.error(
|
|
9499
|
+
console.error(chalk32.red("\u2717 --prompt is required"));
|
|
9378
9500
|
process.exit(1);
|
|
9379
9501
|
}
|
|
9380
9502
|
return await promptText(
|
|
@@ -9382,96 +9504,11 @@ async function gatherPromptText(optionPrompt, existingPrompt) {
|
|
|
9382
9504
|
existingPrompt || "let's start working."
|
|
9383
9505
|
);
|
|
9384
9506
|
}
|
|
9385
|
-
async function gatherVars(optionVars, existingVars) {
|
|
9386
|
-
if (optionVars.length > 0) {
|
|
9387
|
-
return parseKeyValuePairs(optionVars);
|
|
9388
|
-
}
|
|
9389
|
-
if (isInteractive() && existingVars) {
|
|
9390
|
-
const keepVars = await promptConfirm(
|
|
9391
|
-
`Keep existing variables? (${Object.keys(existingVars).join(", ")})`,
|
|
9392
|
-
true
|
|
9393
|
-
);
|
|
9394
|
-
if (keepVars) {
|
|
9395
|
-
return existingVars;
|
|
9396
|
-
}
|
|
9397
|
-
}
|
|
9398
|
-
return void 0;
|
|
9399
|
-
}
|
|
9400
|
-
async function gatherSecrets(optionSecrets, existingSecretNames) {
|
|
9401
|
-
if (optionSecrets.length > 0) {
|
|
9402
|
-
return parseKeyValuePairs(optionSecrets);
|
|
9403
|
-
}
|
|
9404
|
-
if (isInteractive() && existingSecretNames && existingSecretNames.length > 0) {
|
|
9405
|
-
const keepSecrets = await promptConfirm(
|
|
9406
|
-
`Keep existing secrets? (${existingSecretNames.join(", ")})`,
|
|
9407
|
-
true
|
|
9408
|
-
);
|
|
9409
|
-
if (keepSecrets) {
|
|
9410
|
-
return void 0;
|
|
9411
|
-
}
|
|
9412
|
-
console.log(chalk31.dim(" Note: You'll need to provide new secret values"));
|
|
9413
|
-
return {};
|
|
9414
|
-
}
|
|
9415
|
-
return void 0;
|
|
9416
|
-
}
|
|
9417
|
-
async function gatherMissingConfiguration(required, providedSecrets, providedVars, existingSecretNames) {
|
|
9418
|
-
const secrets = { ...providedSecrets };
|
|
9419
|
-
const vars = { ...providedVars };
|
|
9420
|
-
const providedSecretNames = Object.keys(providedSecrets);
|
|
9421
|
-
const existingNames = existingSecretNames ?? [];
|
|
9422
|
-
const missingSecrets = required.secrets.filter(
|
|
9423
|
-
(name) => !providedSecretNames.includes(name) && !existingNames.includes(name)
|
|
9424
|
-
);
|
|
9425
|
-
const providedVarNames = Object.keys(providedVars);
|
|
9426
|
-
const missingVars = required.vars.filter(
|
|
9427
|
-
(name) => !providedVarNames.includes(name)
|
|
9428
|
-
);
|
|
9429
|
-
if (missingSecrets.length === 0 && missingVars.length === 0) {
|
|
9430
|
-
return { secrets, vars };
|
|
9431
|
-
}
|
|
9432
|
-
if (!isInteractive()) {
|
|
9433
|
-
return { secrets, vars };
|
|
9434
|
-
}
|
|
9435
|
-
if (missingSecrets.length > 0 || missingVars.length > 0) {
|
|
9436
|
-
console.log(chalk31.yellow("\nAgent requires the following configuration:"));
|
|
9437
|
-
if (missingSecrets.length > 0) {
|
|
9438
|
-
console.log(chalk31.dim(" Secrets:"));
|
|
9439
|
-
for (const name of missingSecrets) {
|
|
9440
|
-
console.log(chalk31.dim(` ${name}`));
|
|
9441
|
-
}
|
|
9442
|
-
}
|
|
9443
|
-
if (missingVars.length > 0) {
|
|
9444
|
-
console.log(chalk31.dim(" Vars:"));
|
|
9445
|
-
for (const name of missingVars) {
|
|
9446
|
-
console.log(chalk31.dim(` ${name}`));
|
|
9447
|
-
}
|
|
9448
|
-
}
|
|
9449
|
-
console.log("");
|
|
9450
|
-
}
|
|
9451
|
-
for (const name of missingSecrets) {
|
|
9452
|
-
const value = await promptPassword(
|
|
9453
|
-
`Enter value for secret ${chalk31.cyan(name)}`
|
|
9454
|
-
);
|
|
9455
|
-
if (value) {
|
|
9456
|
-
secrets[name] = value;
|
|
9457
|
-
}
|
|
9458
|
-
}
|
|
9459
|
-
for (const name of missingVars) {
|
|
9460
|
-
const value = await promptText(
|
|
9461
|
-
`Enter value for var ${chalk31.cyan(name)}`,
|
|
9462
|
-
""
|
|
9463
|
-
);
|
|
9464
|
-
if (value) {
|
|
9465
|
-
vars[name] = value;
|
|
9466
|
-
}
|
|
9467
|
-
}
|
|
9468
|
-
return { secrets, vars };
|
|
9469
|
-
}
|
|
9470
9507
|
async function resolveAgent(agentName) {
|
|
9471
9508
|
const compose = await getComposeByName(agentName);
|
|
9472
9509
|
if (!compose) {
|
|
9473
|
-
console.error(
|
|
9474
|
-
console.error(
|
|
9510
|
+
console.error(chalk32.red(`\u2717 Agent not found: ${agentName}`));
|
|
9511
|
+
console.error(chalk32.dim(" Make sure the agent is composed first"));
|
|
9475
9512
|
process.exit(1);
|
|
9476
9513
|
}
|
|
9477
9514
|
return {
|
|
@@ -9518,7 +9555,7 @@ async function buildAndDeploy(params) {
|
|
|
9518
9555
|
const expandedSecrets = expandEnvVarsInObject(params.secrets);
|
|
9519
9556
|
console.log(
|
|
9520
9557
|
`
|
|
9521
|
-
Deploying schedule for agent ${
|
|
9558
|
+
Deploying schedule for agent ${chalk32.cyan(params.agentName)}...`
|
|
9522
9559
|
);
|
|
9523
9560
|
const deployResult = await deploySchedule({
|
|
9524
9561
|
name: params.scheduleName,
|
|
@@ -9534,12 +9571,12 @@ Deploying schedule for agent ${chalk31.cyan(params.agentName)}...`
|
|
|
9534
9571
|
displayDeployResult(params.agentName, deployResult);
|
|
9535
9572
|
}
|
|
9536
9573
|
function handleSetupError(error) {
|
|
9537
|
-
console.error(
|
|
9574
|
+
console.error(chalk32.red("\u2717 Failed to setup schedule"));
|
|
9538
9575
|
if (error instanceof Error) {
|
|
9539
9576
|
if (error.message.includes("Not authenticated")) {
|
|
9540
|
-
console.error(
|
|
9577
|
+
console.error(chalk32.dim(" Run: vm0 auth login"));
|
|
9541
9578
|
} else {
|
|
9542
|
-
console.error(
|
|
9579
|
+
console.error(chalk32.dim(` ${error.message}`));
|
|
9543
9580
|
}
|
|
9544
9581
|
}
|
|
9545
9582
|
process.exit(1);
|
|
@@ -9547,34 +9584,34 @@ function handleSetupError(error) {
|
|
|
9547
9584
|
function displayDeployResult(agentName, deployResult) {
|
|
9548
9585
|
if (deployResult.created) {
|
|
9549
9586
|
console.log(
|
|
9550
|
-
|
|
9587
|
+
chalk32.green(`\u2713 Created schedule for agent ${chalk32.cyan(agentName)}`)
|
|
9551
9588
|
);
|
|
9552
9589
|
} else {
|
|
9553
9590
|
console.log(
|
|
9554
|
-
|
|
9591
|
+
chalk32.green(`\u2713 Updated schedule for agent ${chalk32.cyan(agentName)}`)
|
|
9555
9592
|
);
|
|
9556
9593
|
}
|
|
9557
|
-
console.log(
|
|
9594
|
+
console.log(chalk32.dim(` Timezone: ${deployResult.schedule.timezone}`));
|
|
9558
9595
|
if (deployResult.schedule.cronExpression) {
|
|
9559
|
-
console.log(
|
|
9596
|
+
console.log(chalk32.dim(` Cron: ${deployResult.schedule.cronExpression}`));
|
|
9560
9597
|
if (deployResult.schedule.nextRunAt) {
|
|
9561
9598
|
const nextRun = formatInTimezone(
|
|
9562
9599
|
deployResult.schedule.nextRunAt,
|
|
9563
9600
|
deployResult.schedule.timezone
|
|
9564
9601
|
);
|
|
9565
|
-
console.log(
|
|
9602
|
+
console.log(chalk32.dim(` Next run: ${nextRun}`));
|
|
9566
9603
|
}
|
|
9567
9604
|
} else if (deployResult.schedule.atTime) {
|
|
9568
9605
|
const atTimeFormatted = formatInTimezone(
|
|
9569
9606
|
deployResult.schedule.atTime,
|
|
9570
9607
|
deployResult.schedule.timezone
|
|
9571
9608
|
);
|
|
9572
|
-
console.log(
|
|
9609
|
+
console.log(chalk32.dim(` At: ${atTimeFormatted}`));
|
|
9573
9610
|
}
|
|
9574
9611
|
if (deployResult.created) {
|
|
9575
9612
|
console.log();
|
|
9576
9613
|
console.log(
|
|
9577
|
-
` To activate: ${
|
|
9614
|
+
` To activate: ${chalk32.cyan(`vm0 schedule enable ${agentName}`)}`
|
|
9578
9615
|
);
|
|
9579
9616
|
}
|
|
9580
9617
|
}
|
|
@@ -9584,7 +9621,7 @@ var setupCommand = new Command28().name("setup").description("Create or edit a s
|
|
|
9584
9621
|
const requiredConfig = extractRequiredConfiguration(composeContent);
|
|
9585
9622
|
const existingSchedule = await findExistingSchedule(agentName);
|
|
9586
9623
|
console.log(
|
|
9587
|
-
|
|
9624
|
+
chalk32.dim(
|
|
9588
9625
|
existingSchedule ? `Editing existing schedule for agent ${agentName}` : `Creating new schedule for agent ${agentName}`
|
|
9589
9626
|
)
|
|
9590
9627
|
);
|
|
@@ -9594,12 +9631,12 @@ var setupCommand = new Command28().name("setup").description("Create or edit a s
|
|
|
9594
9631
|
defaults.frequency
|
|
9595
9632
|
);
|
|
9596
9633
|
if (!frequency) {
|
|
9597
|
-
console.log(
|
|
9634
|
+
console.log(chalk32.dim("Cancelled"));
|
|
9598
9635
|
return;
|
|
9599
9636
|
}
|
|
9600
9637
|
const timing = await gatherTiming(frequency, options, defaults);
|
|
9601
9638
|
if (!timing) {
|
|
9602
|
-
console.log(
|
|
9639
|
+
console.log(chalk32.dim("Cancelled"));
|
|
9603
9640
|
return;
|
|
9604
9641
|
}
|
|
9605
9642
|
const { day, time, atTime } = timing;
|
|
@@ -9608,7 +9645,7 @@ var setupCommand = new Command28().name("setup").description("Create or edit a s
|
|
|
9608
9645
|
existingSchedule?.timezone
|
|
9609
9646
|
);
|
|
9610
9647
|
if (!timezone) {
|
|
9611
|
-
console.log(
|
|
9648
|
+
console.log(chalk32.dim("Cancelled"));
|
|
9612
9649
|
return;
|
|
9613
9650
|
}
|
|
9614
9651
|
const promptText_ = await gatherPromptText(
|
|
@@ -9616,24 +9653,15 @@ var setupCommand = new Command28().name("setup").description("Create or edit a s
|
|
|
9616
9653
|
existingSchedule?.prompt
|
|
9617
9654
|
);
|
|
9618
9655
|
if (!promptText_) {
|
|
9619
|
-
console.log(
|
|
9656
|
+
console.log(chalk32.dim("Cancelled"));
|
|
9620
9657
|
return;
|
|
9621
9658
|
}
|
|
9622
|
-
const
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
existingSchedule?.secretNames
|
|
9629
|
-
);
|
|
9630
|
-
const keepExistingSecrets = initialSecrets === void 0;
|
|
9631
|
-
const { secrets, vars } = await gatherMissingConfiguration(
|
|
9632
|
-
requiredConfig,
|
|
9633
|
-
initialSecrets ?? {},
|
|
9634
|
-
initialVars ?? {},
|
|
9635
|
-
existingSchedule?.secretNames
|
|
9636
|
-
);
|
|
9659
|
+
const config = await gatherConfiguration({
|
|
9660
|
+
required: requiredConfig,
|
|
9661
|
+
optionSecrets: options.secret || [],
|
|
9662
|
+
optionVars: options.var || [],
|
|
9663
|
+
existingSchedule
|
|
9664
|
+
});
|
|
9637
9665
|
await buildAndDeploy({
|
|
9638
9666
|
scheduleName,
|
|
9639
9667
|
composeId,
|
|
@@ -9644,8 +9672,8 @@ var setupCommand = new Command28().name("setup").description("Create or edit a s
|
|
|
9644
9672
|
atTime,
|
|
9645
9673
|
timezone,
|
|
9646
9674
|
prompt: promptText_,
|
|
9647
|
-
vars: Object.keys(vars).length > 0 ? vars : void 0,
|
|
9648
|
-
secrets:
|
|
9675
|
+
vars: Object.keys(config.vars).length > 0 ? config.vars : void 0,
|
|
9676
|
+
secrets: config.preserveExistingSecrets ? void 0 : Object.keys(config.secrets).length > 0 ? config.secrets : void 0,
|
|
9649
9677
|
artifactName: options.artifactName
|
|
9650
9678
|
});
|
|
9651
9679
|
} catch (error) {
|
|
@@ -9655,14 +9683,14 @@ var setupCommand = new Command28().name("setup").description("Create or edit a s
|
|
|
9655
9683
|
|
|
9656
9684
|
// src/commands/schedule/list.ts
|
|
9657
9685
|
import { Command as Command29 } from "commander";
|
|
9658
|
-
import
|
|
9686
|
+
import chalk33 from "chalk";
|
|
9659
9687
|
var listCommand4 = new Command29().name("list").alias("ls").description("List all schedules").action(async () => {
|
|
9660
9688
|
try {
|
|
9661
9689
|
const result = await listSchedules();
|
|
9662
9690
|
if (result.schedules.length === 0) {
|
|
9663
|
-
console.log(
|
|
9691
|
+
console.log(chalk33.dim("No schedules found"));
|
|
9664
9692
|
console.log(
|
|
9665
|
-
|
|
9693
|
+
chalk33.dim(" Create one with: vm0 schedule setup <agent-name>")
|
|
9666
9694
|
);
|
|
9667
9695
|
return;
|
|
9668
9696
|
}
|
|
@@ -9682,10 +9710,10 @@ var listCommand4 = new Command29().name("list").alias("ls").description("List al
|
|
|
9682
9710
|
"STATUS".padEnd(8),
|
|
9683
9711
|
"NEXT RUN"
|
|
9684
9712
|
].join(" ");
|
|
9685
|
-
console.log(
|
|
9713
|
+
console.log(chalk33.dim(header));
|
|
9686
9714
|
for (const schedule of result.schedules) {
|
|
9687
9715
|
const trigger = schedule.cronExpression ? `${schedule.cronExpression} (${schedule.timezone})` : schedule.atTime || "-";
|
|
9688
|
-
const status = schedule.enabled ?
|
|
9716
|
+
const status = schedule.enabled ? chalk33.green("enabled") : chalk33.yellow("disabled");
|
|
9689
9717
|
const nextRun = schedule.enabled ? formatRelativeTime2(schedule.nextRunAt) : "-";
|
|
9690
9718
|
const row = [
|
|
9691
9719
|
schedule.composeName.padEnd(agentWidth),
|
|
@@ -9697,12 +9725,12 @@ var listCommand4 = new Command29().name("list").alias("ls").description("List al
|
|
|
9697
9725
|
console.log(row);
|
|
9698
9726
|
}
|
|
9699
9727
|
} catch (error) {
|
|
9700
|
-
console.error(
|
|
9728
|
+
console.error(chalk33.red("\u2717 Failed to list schedules"));
|
|
9701
9729
|
if (error instanceof Error) {
|
|
9702
9730
|
if (error.message.includes("Not authenticated")) {
|
|
9703
|
-
console.error(
|
|
9731
|
+
console.error(chalk33.dim(" Run: vm0 auth login"));
|
|
9704
9732
|
} else {
|
|
9705
|
-
console.error(
|
|
9733
|
+
console.error(chalk33.dim(` ${error.message}`));
|
|
9706
9734
|
}
|
|
9707
9735
|
}
|
|
9708
9736
|
process.exit(1);
|
|
@@ -9711,44 +9739,44 @@ var listCommand4 = new Command29().name("list").alias("ls").description("List al
|
|
|
9711
9739
|
|
|
9712
9740
|
// src/commands/schedule/status.ts
|
|
9713
9741
|
import { Command as Command30 } from "commander";
|
|
9714
|
-
import
|
|
9742
|
+
import chalk34 from "chalk";
|
|
9715
9743
|
function formatDateTimeStyled(dateStr) {
|
|
9716
|
-
if (!dateStr) return
|
|
9744
|
+
if (!dateStr) return chalk34.dim("-");
|
|
9717
9745
|
const formatted = formatDateTime(dateStr);
|
|
9718
|
-
return formatted.replace(/\(([^)]+)\)$/,
|
|
9746
|
+
return formatted.replace(/\(([^)]+)\)$/, chalk34.dim("($1)"));
|
|
9719
9747
|
}
|
|
9720
9748
|
function formatTrigger(schedule) {
|
|
9721
9749
|
if (schedule.cronExpression) {
|
|
9722
9750
|
return schedule.cronExpression;
|
|
9723
9751
|
}
|
|
9724
9752
|
if (schedule.atTime) {
|
|
9725
|
-
return `${schedule.atTime} ${
|
|
9753
|
+
return `${schedule.atTime} ${chalk34.dim("(one-time)")}`;
|
|
9726
9754
|
}
|
|
9727
|
-
return
|
|
9755
|
+
return chalk34.dim("-");
|
|
9728
9756
|
}
|
|
9729
9757
|
function formatRunStatus(status) {
|
|
9730
9758
|
switch (status) {
|
|
9731
9759
|
case "completed":
|
|
9732
|
-
return
|
|
9760
|
+
return chalk34.green(status);
|
|
9733
9761
|
case "failed":
|
|
9734
9762
|
case "timeout":
|
|
9735
|
-
return
|
|
9763
|
+
return chalk34.red(status);
|
|
9736
9764
|
case "running":
|
|
9737
|
-
return
|
|
9765
|
+
return chalk34.blue(status);
|
|
9738
9766
|
case "pending":
|
|
9739
|
-
return
|
|
9767
|
+
return chalk34.yellow(status);
|
|
9740
9768
|
default:
|
|
9741
9769
|
return status;
|
|
9742
9770
|
}
|
|
9743
9771
|
}
|
|
9744
9772
|
function printRunConfiguration(schedule) {
|
|
9745
|
-
const statusText = schedule.enabled ?
|
|
9773
|
+
const statusText = schedule.enabled ? chalk34.green("enabled") : chalk34.yellow("disabled");
|
|
9746
9774
|
console.log(`${"Status:".padEnd(16)}${statusText}`);
|
|
9747
9775
|
console.log(
|
|
9748
|
-
`${"Agent:".padEnd(16)}${schedule.composeName} ${
|
|
9776
|
+
`${"Agent:".padEnd(16)}${schedule.composeName} ${chalk34.dim(`(${schedule.scopeSlug})`)}`
|
|
9749
9777
|
);
|
|
9750
9778
|
const promptPreview = schedule.prompt.length > 60 ? schedule.prompt.slice(0, 57) + "..." : schedule.prompt;
|
|
9751
|
-
console.log(`${"Prompt:".padEnd(16)}${
|
|
9779
|
+
console.log(`${"Prompt:".padEnd(16)}${chalk34.dim(promptPreview)}`);
|
|
9752
9780
|
if (schedule.vars && Object.keys(schedule.vars).length > 0) {
|
|
9753
9781
|
console.log(
|
|
9754
9782
|
`${"Variables:".padEnd(16)}${Object.keys(schedule.vars).join(", ")}`
|
|
@@ -9785,7 +9813,7 @@ async function printRecentRuns(name, composeId, limit) {
|
|
|
9785
9813
|
console.log();
|
|
9786
9814
|
console.log("Recent Runs:");
|
|
9787
9815
|
console.log(
|
|
9788
|
-
|
|
9816
|
+
chalk34.dim("RUN ID STATUS CREATED")
|
|
9789
9817
|
);
|
|
9790
9818
|
for (const run of runs) {
|
|
9791
9819
|
const id = run.id;
|
|
@@ -9796,19 +9824,19 @@ async function printRecentRuns(name, composeId, limit) {
|
|
|
9796
9824
|
}
|
|
9797
9825
|
} catch {
|
|
9798
9826
|
console.log();
|
|
9799
|
-
console.log(
|
|
9827
|
+
console.log(chalk34.dim("Recent Runs: (unable to fetch)"));
|
|
9800
9828
|
}
|
|
9801
9829
|
}
|
|
9802
9830
|
function handleStatusError(error, agentName) {
|
|
9803
|
-
console.error(
|
|
9831
|
+
console.error(chalk34.red("\u2717 Failed to get schedule status"));
|
|
9804
9832
|
if (error instanceof Error) {
|
|
9805
9833
|
if (error.message.includes("Not authenticated")) {
|
|
9806
|
-
console.error(
|
|
9834
|
+
console.error(chalk34.dim(" Run: vm0 auth login"));
|
|
9807
9835
|
} else if (error.message.includes("not found") || error.message.includes("Not found") || error.message.includes("No schedule found")) {
|
|
9808
|
-
console.error(
|
|
9809
|
-
console.error(
|
|
9836
|
+
console.error(chalk34.dim(` No schedule found for agent "${agentName}"`));
|
|
9837
|
+
console.error(chalk34.dim(" Run: vm0 schedule list"));
|
|
9810
9838
|
} else {
|
|
9811
|
-
console.error(
|
|
9839
|
+
console.error(chalk34.dim(` ${error.message}`));
|
|
9812
9840
|
}
|
|
9813
9841
|
}
|
|
9814
9842
|
process.exit(1);
|
|
@@ -9823,8 +9851,8 @@ var statusCommand5 = new Command30().name("status").description("Show detailed s
|
|
|
9823
9851
|
const { name, composeId } = resolved;
|
|
9824
9852
|
const schedule = await getScheduleByName({ name, composeId });
|
|
9825
9853
|
console.log();
|
|
9826
|
-
console.log(`Schedule for agent: ${
|
|
9827
|
-
console.log(
|
|
9854
|
+
console.log(`Schedule for agent: ${chalk34.cyan(agentName)}`);
|
|
9855
|
+
console.log(chalk34.dim("\u2501".repeat(50)));
|
|
9828
9856
|
printRunConfiguration(schedule);
|
|
9829
9857
|
printTimeSchedule(schedule);
|
|
9830
9858
|
const limit = Math.min(
|
|
@@ -9840,29 +9868,23 @@ var statusCommand5 = new Command30().name("status").description("Show detailed s
|
|
|
9840
9868
|
|
|
9841
9869
|
// src/commands/schedule/delete.ts
|
|
9842
9870
|
import { Command as Command31 } from "commander";
|
|
9843
|
-
import
|
|
9844
|
-
import * as readline from "readline";
|
|
9845
|
-
async function confirm(message) {
|
|
9846
|
-
const rl = readline.createInterface({
|
|
9847
|
-
input: process.stdin,
|
|
9848
|
-
output: process.stdout
|
|
9849
|
-
});
|
|
9850
|
-
return new Promise((resolve) => {
|
|
9851
|
-
rl.question(`${message} (y/N) `, (answer) => {
|
|
9852
|
-
rl.close();
|
|
9853
|
-
resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
9854
|
-
});
|
|
9855
|
-
});
|
|
9856
|
-
}
|
|
9871
|
+
import chalk35 from "chalk";
|
|
9857
9872
|
var deleteCommand = new Command31().name("delete").alias("rm").description("Delete a schedule").argument("<agent-name>", "Agent name").option("-f, --force", "Skip confirmation prompt").action(async (agentName, options) => {
|
|
9858
9873
|
try {
|
|
9859
9874
|
const resolved = await resolveScheduleByAgent(agentName);
|
|
9860
9875
|
if (!options.force) {
|
|
9861
|
-
|
|
9862
|
-
|
|
9876
|
+
if (!isInteractive()) {
|
|
9877
|
+
console.error(
|
|
9878
|
+
chalk35.red("\u2717 --force required in non-interactive mode")
|
|
9879
|
+
);
|
|
9880
|
+
process.exit(1);
|
|
9881
|
+
}
|
|
9882
|
+
const confirmed = await promptConfirm(
|
|
9883
|
+
`Delete schedule for agent ${chalk35.cyan(agentName)}?`,
|
|
9884
|
+
false
|
|
9863
9885
|
);
|
|
9864
9886
|
if (!confirmed) {
|
|
9865
|
-
console.log(
|
|
9887
|
+
console.log(chalk35.dim("Cancelled"));
|
|
9866
9888
|
return;
|
|
9867
9889
|
}
|
|
9868
9890
|
}
|
|
@@ -9871,20 +9893,20 @@ var deleteCommand = new Command31().name("delete").alias("rm").description("Dele
|
|
|
9871
9893
|
composeId: resolved.composeId
|
|
9872
9894
|
});
|
|
9873
9895
|
console.log(
|
|
9874
|
-
|
|
9896
|
+
chalk35.green(`\u2713 Deleted schedule for agent ${chalk35.cyan(agentName)}`)
|
|
9875
9897
|
);
|
|
9876
9898
|
} catch (error) {
|
|
9877
|
-
console.error(
|
|
9899
|
+
console.error(chalk35.red("\u2717 Failed to delete schedule"));
|
|
9878
9900
|
if (error instanceof Error) {
|
|
9879
9901
|
if (error.message.includes("Not authenticated")) {
|
|
9880
|
-
console.error(
|
|
9902
|
+
console.error(chalk35.dim(" Run: vm0 auth login"));
|
|
9881
9903
|
} else if (error.message.toLowerCase().includes("not found") || error.message.includes("No schedule found")) {
|
|
9882
9904
|
console.error(
|
|
9883
|
-
|
|
9905
|
+
chalk35.dim(` No schedule found for agent "${agentName}"`)
|
|
9884
9906
|
);
|
|
9885
|
-
console.error(
|
|
9907
|
+
console.error(chalk35.dim(" Run: vm0 schedule list"));
|
|
9886
9908
|
} else {
|
|
9887
|
-
console.error(
|
|
9909
|
+
console.error(chalk35.dim(` ${error.message}`));
|
|
9888
9910
|
}
|
|
9889
9911
|
}
|
|
9890
9912
|
process.exit(1);
|
|
@@ -9893,7 +9915,7 @@ var deleteCommand = new Command31().name("delete").alias("rm").description("Dele
|
|
|
9893
9915
|
|
|
9894
9916
|
// src/commands/schedule/enable.ts
|
|
9895
9917
|
import { Command as Command32 } from "commander";
|
|
9896
|
-
import
|
|
9918
|
+
import chalk36 from "chalk";
|
|
9897
9919
|
var enableCommand = new Command32().name("enable").description("Enable a schedule").argument("<agent-name>", "Agent name").action(async (agentName) => {
|
|
9898
9920
|
try {
|
|
9899
9921
|
const resolved = await resolveScheduleByAgent(agentName);
|
|
@@ -9902,34 +9924,34 @@ var enableCommand = new Command32().name("enable").description("Enable a schedul
|
|
|
9902
9924
|
composeId: resolved.composeId
|
|
9903
9925
|
});
|
|
9904
9926
|
console.log(
|
|
9905
|
-
|
|
9927
|
+
chalk36.green(`\u2713 Enabled schedule for agent ${chalk36.cyan(agentName)}`)
|
|
9906
9928
|
);
|
|
9907
9929
|
} catch (error) {
|
|
9908
|
-
console.error(
|
|
9930
|
+
console.error(chalk36.red("\u2717 Failed to enable schedule"));
|
|
9909
9931
|
if (error instanceof ApiRequestError) {
|
|
9910
9932
|
if (error.code === "SCHEDULE_PAST") {
|
|
9911
|
-
console.error(
|
|
9912
|
-
console.error(
|
|
9933
|
+
console.error(chalk36.dim(" Scheduled time has already passed"));
|
|
9934
|
+
console.error(chalk36.dim(` Run: vm0 schedule setup ${agentName}`));
|
|
9913
9935
|
} else if (error.code === "NOT_FOUND") {
|
|
9914
9936
|
console.error(
|
|
9915
|
-
|
|
9937
|
+
chalk36.dim(` No schedule found for agent "${agentName}"`)
|
|
9916
9938
|
);
|
|
9917
|
-
console.error(
|
|
9939
|
+
console.error(chalk36.dim(" Run: vm0 schedule list"));
|
|
9918
9940
|
} else if (error.code === "UNAUTHORIZED") {
|
|
9919
|
-
console.error(
|
|
9941
|
+
console.error(chalk36.dim(" Run: vm0 auth login"));
|
|
9920
9942
|
} else {
|
|
9921
|
-
console.error(
|
|
9943
|
+
console.error(chalk36.dim(` ${error.message}`));
|
|
9922
9944
|
}
|
|
9923
9945
|
} else if (error instanceof Error) {
|
|
9924
9946
|
if (error.message.includes("Not authenticated")) {
|
|
9925
|
-
console.error(
|
|
9947
|
+
console.error(chalk36.dim(" Run: vm0 auth login"));
|
|
9926
9948
|
} else if (error.message.includes("No schedule found")) {
|
|
9927
9949
|
console.error(
|
|
9928
|
-
|
|
9950
|
+
chalk36.dim(` No schedule found for agent "${agentName}"`)
|
|
9929
9951
|
);
|
|
9930
|
-
console.error(
|
|
9952
|
+
console.error(chalk36.dim(" Run: vm0 schedule list"));
|
|
9931
9953
|
} else {
|
|
9932
|
-
console.error(
|
|
9954
|
+
console.error(chalk36.dim(` ${error.message}`));
|
|
9933
9955
|
}
|
|
9934
9956
|
}
|
|
9935
9957
|
process.exit(1);
|
|
@@ -9938,7 +9960,7 @@ var enableCommand = new Command32().name("enable").description("Enable a schedul
|
|
|
9938
9960
|
|
|
9939
9961
|
// src/commands/schedule/disable.ts
|
|
9940
9962
|
import { Command as Command33 } from "commander";
|
|
9941
|
-
import
|
|
9963
|
+
import chalk37 from "chalk";
|
|
9942
9964
|
var disableCommand = new Command33().name("disable").description("Disable a schedule").argument("<agent-name>", "Agent name").action(async (agentName) => {
|
|
9943
9965
|
try {
|
|
9944
9966
|
const resolved = await resolveScheduleByAgent(agentName);
|
|
@@ -9947,20 +9969,20 @@ var disableCommand = new Command33().name("disable").description("Disable a sche
|
|
|
9947
9969
|
composeId: resolved.composeId
|
|
9948
9970
|
});
|
|
9949
9971
|
console.log(
|
|
9950
|
-
|
|
9972
|
+
chalk37.green(`\u2713 Disabled schedule for agent ${chalk37.cyan(agentName)}`)
|
|
9951
9973
|
);
|
|
9952
9974
|
} catch (error) {
|
|
9953
|
-
console.error(
|
|
9975
|
+
console.error(chalk37.red("\u2717 Failed to disable schedule"));
|
|
9954
9976
|
if (error instanceof Error) {
|
|
9955
9977
|
if (error.message.includes("Not authenticated")) {
|
|
9956
|
-
console.error(
|
|
9978
|
+
console.error(chalk37.dim(" Run: vm0 auth login"));
|
|
9957
9979
|
} else if (error.message.toLowerCase().includes("not found") || error.message.includes("No schedule found")) {
|
|
9958
9980
|
console.error(
|
|
9959
|
-
|
|
9981
|
+
chalk37.dim(` No schedule found for agent "${agentName}"`)
|
|
9960
9982
|
);
|
|
9961
|
-
console.error(
|
|
9983
|
+
console.error(chalk37.dim(" Run: vm0 schedule list"));
|
|
9962
9984
|
} else {
|
|
9963
|
-
console.error(
|
|
9985
|
+
console.error(chalk37.dim(` ${error.message}`));
|
|
9964
9986
|
}
|
|
9965
9987
|
}
|
|
9966
9988
|
process.exit(1);
|
|
@@ -9972,7 +9994,7 @@ var scheduleCommand = new Command34().name("schedule").description("Manage agent
|
|
|
9972
9994
|
|
|
9973
9995
|
// src/commands/usage.ts
|
|
9974
9996
|
import { Command as Command35 } from "commander";
|
|
9975
|
-
import
|
|
9997
|
+
import chalk38 from "chalk";
|
|
9976
9998
|
|
|
9977
9999
|
// src/lib/utils/duration-formatter.ts
|
|
9978
10000
|
function formatDuration(ms) {
|
|
@@ -10059,8 +10081,8 @@ var usageCommand = new Command35().name("usage").description("View usage statist
|
|
|
10059
10081
|
endDate = new Date(untilMs);
|
|
10060
10082
|
} catch {
|
|
10061
10083
|
console.error(
|
|
10062
|
-
|
|
10063
|
-
"
|
|
10084
|
+
chalk38.red(
|
|
10085
|
+
"\u2717 Invalid --until format. Use ISO (2026-01-01) or relative (7d, 30d)"
|
|
10064
10086
|
)
|
|
10065
10087
|
);
|
|
10066
10088
|
process.exit(1);
|
|
@@ -10074,8 +10096,8 @@ var usageCommand = new Command35().name("usage").description("View usage statist
|
|
|
10074
10096
|
startDate = new Date(sinceMs);
|
|
10075
10097
|
} catch {
|
|
10076
10098
|
console.error(
|
|
10077
|
-
|
|
10078
|
-
"
|
|
10099
|
+
chalk38.red(
|
|
10100
|
+
"\u2717 Invalid --since format. Use ISO (2026-01-01) or relative (7d, 30d)"
|
|
10079
10101
|
)
|
|
10080
10102
|
);
|
|
10081
10103
|
process.exit(1);
|
|
@@ -10084,14 +10106,14 @@ var usageCommand = new Command35().name("usage").description("View usage statist
|
|
|
10084
10106
|
startDate = new Date(endDate.getTime() - DEFAULT_RANGE_MS);
|
|
10085
10107
|
}
|
|
10086
10108
|
if (startDate >= endDate) {
|
|
10087
|
-
console.error(
|
|
10109
|
+
console.error(chalk38.red("\u2717 --since must be before --until"));
|
|
10088
10110
|
process.exit(1);
|
|
10089
10111
|
}
|
|
10090
10112
|
const rangeMs = endDate.getTime() - startDate.getTime();
|
|
10091
10113
|
if (rangeMs > MAX_RANGE_MS) {
|
|
10092
10114
|
console.error(
|
|
10093
|
-
|
|
10094
|
-
"
|
|
10115
|
+
chalk38.red(
|
|
10116
|
+
"\u2717 Time range exceeds maximum of 30 days. Use --until to specify an end date"
|
|
10095
10117
|
)
|
|
10096
10118
|
);
|
|
10097
10119
|
process.exit(1);
|
|
@@ -10107,19 +10129,19 @@ var usageCommand = new Command35().name("usage").description("View usage statist
|
|
|
10107
10129
|
);
|
|
10108
10130
|
console.log();
|
|
10109
10131
|
console.log(
|
|
10110
|
-
|
|
10132
|
+
chalk38.bold(
|
|
10111
10133
|
`Usage Summary (${formatDateRange(usage.period.start, usage.period.end)})`
|
|
10112
10134
|
)
|
|
10113
10135
|
);
|
|
10114
10136
|
console.log();
|
|
10115
|
-
console.log(
|
|
10137
|
+
console.log(chalk38.dim("DATE RUNS RUN TIME"));
|
|
10116
10138
|
for (const day of filledDaily) {
|
|
10117
10139
|
const dateDisplay = formatDateDisplay(day.date).padEnd(10);
|
|
10118
10140
|
const runsDisplay = String(day.run_count).padStart(6);
|
|
10119
10141
|
const timeDisplay = formatDuration(day.run_time_ms);
|
|
10120
10142
|
console.log(`${dateDisplay}${runsDisplay} ${timeDisplay}`);
|
|
10121
10143
|
}
|
|
10122
|
-
console.log(
|
|
10144
|
+
console.log(chalk38.dim("\u2500".repeat(29)));
|
|
10123
10145
|
const totalRunsDisplay = String(usage.summary.total_runs).padStart(6);
|
|
10124
10146
|
const totalTimeDisplay = formatDuration(usage.summary.total_run_time_ms);
|
|
10125
10147
|
console.log(
|
|
@@ -10129,14 +10151,13 @@ var usageCommand = new Command35().name("usage").description("View usage statist
|
|
|
10129
10151
|
} catch (error) {
|
|
10130
10152
|
if (error instanceof Error) {
|
|
10131
10153
|
if (error.message.includes("Not authenticated")) {
|
|
10132
|
-
console.error(
|
|
10133
|
-
|
|
10134
|
-
);
|
|
10154
|
+
console.error(chalk38.red("\u2717 Not authenticated"));
|
|
10155
|
+
console.error(chalk38.dim(" Run: vm0 auth login"));
|
|
10135
10156
|
} else {
|
|
10136
|
-
console.error(
|
|
10157
|
+
console.error(chalk38.red(`\u2717 ${error.message}`));
|
|
10137
10158
|
}
|
|
10138
10159
|
} else {
|
|
10139
|
-
console.error(
|
|
10160
|
+
console.error(chalk38.red("\u2717 An unexpected error occurred"));
|
|
10140
10161
|
}
|
|
10141
10162
|
process.exit(1);
|
|
10142
10163
|
}
|
|
@@ -10147,42 +10168,42 @@ import { Command as Command39 } from "commander";
|
|
|
10147
10168
|
|
|
10148
10169
|
// src/commands/credential/list.ts
|
|
10149
10170
|
import { Command as Command36 } from "commander";
|
|
10150
|
-
import
|
|
10171
|
+
import chalk39 from "chalk";
|
|
10151
10172
|
var listCommand5 = new Command36().name("list").alias("ls").description("List all credentials").action(async () => {
|
|
10152
10173
|
try {
|
|
10153
10174
|
const result = await listCredentials();
|
|
10154
10175
|
if (result.credentials.length === 0) {
|
|
10155
|
-
console.log(
|
|
10176
|
+
console.log(chalk39.dim("No credentials found"));
|
|
10156
10177
|
console.log();
|
|
10157
10178
|
console.log("To add a credential:");
|
|
10158
|
-
console.log(
|
|
10179
|
+
console.log(chalk39.cyan(" vm0 credential set MY_API_KEY <value>"));
|
|
10159
10180
|
return;
|
|
10160
10181
|
}
|
|
10161
|
-
console.log(
|
|
10182
|
+
console.log(chalk39.bold("Credentials:"));
|
|
10162
10183
|
console.log();
|
|
10163
10184
|
for (const credential of result.credentials) {
|
|
10164
|
-
const typeIndicator = credential.type === "model-provider" ?
|
|
10165
|
-
console.log(` ${
|
|
10185
|
+
const typeIndicator = credential.type === "model-provider" ? chalk39.dim(" [model-provider]") : "";
|
|
10186
|
+
console.log(` ${chalk39.cyan(credential.name)}${typeIndicator}`);
|
|
10166
10187
|
if (credential.description) {
|
|
10167
|
-
console.log(` ${
|
|
10188
|
+
console.log(` ${chalk39.dim(credential.description)}`);
|
|
10168
10189
|
}
|
|
10169
10190
|
console.log(
|
|
10170
|
-
` ${
|
|
10191
|
+
` ${chalk39.dim(`Updated: ${new Date(credential.updatedAt).toLocaleString()}`)}`
|
|
10171
10192
|
);
|
|
10172
10193
|
console.log();
|
|
10173
10194
|
}
|
|
10174
10195
|
console.log(
|
|
10175
|
-
|
|
10196
|
+
chalk39.dim(`Total: ${result.credentials.length} credential(s)`)
|
|
10176
10197
|
);
|
|
10177
10198
|
} catch (error) {
|
|
10178
10199
|
if (error instanceof Error) {
|
|
10179
10200
|
if (error.message.includes("Not authenticated")) {
|
|
10180
|
-
console.error(
|
|
10201
|
+
console.error(chalk39.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
10181
10202
|
} else {
|
|
10182
|
-
console.error(
|
|
10203
|
+
console.error(chalk39.red(`\u2717 ${error.message}`));
|
|
10183
10204
|
}
|
|
10184
10205
|
} else {
|
|
10185
|
-
console.error(
|
|
10206
|
+
console.error(chalk39.red("\u2717 An unexpected error occurred"));
|
|
10186
10207
|
}
|
|
10187
10208
|
process.exit(1);
|
|
10188
10209
|
}
|
|
@@ -10190,7 +10211,7 @@ var listCommand5 = new Command36().name("list").alias("ls").description("List al
|
|
|
10190
10211
|
|
|
10191
10212
|
// src/commands/credential/set.ts
|
|
10192
10213
|
import { Command as Command37 } from "commander";
|
|
10193
|
-
import
|
|
10214
|
+
import chalk40 from "chalk";
|
|
10194
10215
|
var setCommand2 = new Command37().name("set").description("Create or update a credential").argument("<name>", "Credential name (uppercase, e.g., MY_API_KEY)").argument("<value>", "Credential value").option("-d, --description <description>", "Optional description").action(
|
|
10195
10216
|
async (name, value, options) => {
|
|
10196
10217
|
try {
|
|
@@ -10199,29 +10220,29 @@ var setCommand2 = new Command37().name("set").description("Create or update a cr
|
|
|
10199
10220
|
value,
|
|
10200
10221
|
description: options.description
|
|
10201
10222
|
});
|
|
10202
|
-
console.log(
|
|
10223
|
+
console.log(chalk40.green(`\u2713 Credential "${credential.name}" saved`));
|
|
10203
10224
|
console.log();
|
|
10204
10225
|
console.log("Use in vm0.yaml:");
|
|
10205
|
-
console.log(
|
|
10206
|
-
console.log(
|
|
10226
|
+
console.log(chalk40.cyan(` environment:`));
|
|
10227
|
+
console.log(chalk40.cyan(` ${name}: \${{ credentials.${name} }}`));
|
|
10207
10228
|
} catch (error) {
|
|
10208
10229
|
if (error instanceof Error) {
|
|
10209
10230
|
if (error.message.includes("Not authenticated")) {
|
|
10210
10231
|
console.error(
|
|
10211
|
-
|
|
10232
|
+
chalk40.red("\u2717 Not authenticated. Run: vm0 auth login")
|
|
10212
10233
|
);
|
|
10213
10234
|
} else if (error.message.includes("must contain only uppercase")) {
|
|
10214
|
-
console.error(
|
|
10235
|
+
console.error(chalk40.red(`\u2717 ${error.message}`));
|
|
10215
10236
|
console.log();
|
|
10216
10237
|
console.log("Examples of valid credential names:");
|
|
10217
|
-
console.log(
|
|
10218
|
-
console.log(
|
|
10219
|
-
console.log(
|
|
10238
|
+
console.log(chalk40.dim(" MY_API_KEY"));
|
|
10239
|
+
console.log(chalk40.dim(" GITHUB_TOKEN"));
|
|
10240
|
+
console.log(chalk40.dim(" AWS_ACCESS_KEY_ID"));
|
|
10220
10241
|
} else {
|
|
10221
|
-
console.error(
|
|
10242
|
+
console.error(chalk40.red(`\u2717 ${error.message}`));
|
|
10222
10243
|
}
|
|
10223
10244
|
} else {
|
|
10224
|
-
console.error(
|
|
10245
|
+
console.error(chalk40.red("\u2717 An unexpected error occurred"));
|
|
10225
10246
|
}
|
|
10226
10247
|
process.exit(1);
|
|
10227
10248
|
}
|
|
@@ -10230,48 +10251,42 @@ var setCommand2 = new Command37().name("set").description("Create or update a cr
|
|
|
10230
10251
|
|
|
10231
10252
|
// src/commands/credential/delete.ts
|
|
10232
10253
|
import { Command as Command38 } from "commander";
|
|
10233
|
-
import
|
|
10254
|
+
import chalk41 from "chalk";
|
|
10234
10255
|
var deleteCommand2 = new Command38().name("delete").description("Delete a credential").argument("<name>", "Credential name to delete").option("-y, --yes", "Skip confirmation prompt").action(async (name, options) => {
|
|
10235
10256
|
try {
|
|
10236
10257
|
try {
|
|
10237
10258
|
await getCredential(name);
|
|
10238
10259
|
} catch {
|
|
10239
|
-
console.error(
|
|
10260
|
+
console.error(chalk41.red(`\u2717 Credential "${name}" not found`));
|
|
10240
10261
|
process.exit(1);
|
|
10241
10262
|
}
|
|
10242
10263
|
if (!options.yes) {
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
|
|
10246
|
-
output: process.stdout
|
|
10247
|
-
});
|
|
10248
|
-
const confirmed = await new Promise((resolve) => {
|
|
10249
|
-
rl.question(
|
|
10250
|
-
chalk40.yellow(
|
|
10251
|
-
`Are you sure you want to delete credential "${name}"? (y/N) `
|
|
10252
|
-
),
|
|
10253
|
-
(answer) => {
|
|
10254
|
-
rl.close();
|
|
10255
|
-
resolve(answer.toLowerCase() === "y");
|
|
10256
|
-
}
|
|
10264
|
+
if (!isInteractive()) {
|
|
10265
|
+
console.error(
|
|
10266
|
+
chalk41.red("\u2717 --yes flag is required in non-interactive mode")
|
|
10257
10267
|
);
|
|
10258
|
-
|
|
10268
|
+
process.exit(1);
|
|
10269
|
+
}
|
|
10270
|
+
const confirmed = await promptConfirm(
|
|
10271
|
+
`Are you sure you want to delete credential "${name}"?`,
|
|
10272
|
+
false
|
|
10273
|
+
);
|
|
10259
10274
|
if (!confirmed) {
|
|
10260
|
-
console.log(
|
|
10275
|
+
console.log(chalk41.dim("Cancelled"));
|
|
10261
10276
|
return;
|
|
10262
10277
|
}
|
|
10263
10278
|
}
|
|
10264
10279
|
await deleteCredential(name);
|
|
10265
|
-
console.log(
|
|
10280
|
+
console.log(chalk41.green(`\u2713 Credential "${name}" deleted`));
|
|
10266
10281
|
} catch (error) {
|
|
10267
10282
|
if (error instanceof Error) {
|
|
10268
10283
|
if (error.message.includes("Not authenticated")) {
|
|
10269
|
-
console.error(
|
|
10284
|
+
console.error(chalk41.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
10270
10285
|
} else {
|
|
10271
|
-
console.error(
|
|
10286
|
+
console.error(chalk41.red(`\u2717 ${error.message}`));
|
|
10272
10287
|
}
|
|
10273
10288
|
} else {
|
|
10274
|
-
console.error(
|
|
10289
|
+
console.error(chalk41.red("\u2717 An unexpected error occurred"));
|
|
10275
10290
|
}
|
|
10276
10291
|
process.exit(1);
|
|
10277
10292
|
}
|
|
@@ -10285,15 +10300,15 @@ import { Command as Command44 } from "commander";
|
|
|
10285
10300
|
|
|
10286
10301
|
// src/commands/model-provider/list.ts
|
|
10287
10302
|
import { Command as Command40 } from "commander";
|
|
10288
|
-
import
|
|
10303
|
+
import chalk42 from "chalk";
|
|
10289
10304
|
var listCommand6 = new Command40().name("list").alias("ls").description("List all model providers").action(async () => {
|
|
10290
10305
|
try {
|
|
10291
10306
|
const result = await listModelProviders();
|
|
10292
10307
|
if (result.modelProviders.length === 0) {
|
|
10293
|
-
console.log(
|
|
10308
|
+
console.log(chalk42.dim("No model providers configured"));
|
|
10294
10309
|
console.log();
|
|
10295
10310
|
console.log("To add a model provider:");
|
|
10296
|
-
console.log(
|
|
10311
|
+
console.log(chalk42.cyan(" vm0 model-provider setup"));
|
|
10297
10312
|
return;
|
|
10298
10313
|
}
|
|
10299
10314
|
const byFramework = result.modelProviders.reduce(
|
|
@@ -10307,15 +10322,15 @@ var listCommand6 = new Command40().name("list").alias("ls").description("List al
|
|
|
10307
10322
|
},
|
|
10308
10323
|
{}
|
|
10309
10324
|
);
|
|
10310
|
-
console.log(
|
|
10325
|
+
console.log(chalk42.bold("Model Providers:"));
|
|
10311
10326
|
console.log();
|
|
10312
10327
|
for (const [framework, providers] of Object.entries(byFramework)) {
|
|
10313
|
-
console.log(` ${
|
|
10328
|
+
console.log(` ${chalk42.cyan(framework)}:`);
|
|
10314
10329
|
for (const provider of providers) {
|
|
10315
|
-
const defaultTag = provider.isDefault ?
|
|
10330
|
+
const defaultTag = provider.isDefault ? chalk42.green(" (default)") : "";
|
|
10316
10331
|
console.log(` ${provider.type}${defaultTag}`);
|
|
10317
10332
|
console.log(
|
|
10318
|
-
|
|
10333
|
+
chalk42.dim(
|
|
10319
10334
|
` Updated: ${new Date(provider.updatedAt).toLocaleString()}`
|
|
10320
10335
|
)
|
|
10321
10336
|
);
|
|
@@ -10323,17 +10338,17 @@ var listCommand6 = new Command40().name("list").alias("ls").description("List al
|
|
|
10323
10338
|
console.log();
|
|
10324
10339
|
}
|
|
10325
10340
|
console.log(
|
|
10326
|
-
|
|
10341
|
+
chalk42.dim(`Total: ${result.modelProviders.length} provider(s)`)
|
|
10327
10342
|
);
|
|
10328
10343
|
} catch (error) {
|
|
10329
10344
|
if (error instanceof Error) {
|
|
10330
10345
|
if (error.message.includes("Not authenticated")) {
|
|
10331
|
-
console.error(
|
|
10346
|
+
console.error(chalk42.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
10332
10347
|
} else {
|
|
10333
|
-
console.error(
|
|
10348
|
+
console.error(chalk42.red(`\u2717 ${error.message}`));
|
|
10334
10349
|
}
|
|
10335
10350
|
} else {
|
|
10336
|
-
console.error(
|
|
10351
|
+
console.error(chalk42.red("\u2717 An unexpected error occurred"));
|
|
10337
10352
|
}
|
|
10338
10353
|
process.exit(1);
|
|
10339
10354
|
}
|
|
@@ -10341,8 +10356,8 @@ var listCommand6 = new Command40().name("list").alias("ls").description("List al
|
|
|
10341
10356
|
|
|
10342
10357
|
// src/commands/model-provider/setup.ts
|
|
10343
10358
|
import { Command as Command41 } from "commander";
|
|
10344
|
-
import
|
|
10345
|
-
import
|
|
10359
|
+
import chalk43 from "chalk";
|
|
10360
|
+
import prompts2 from "prompts";
|
|
10346
10361
|
var providerChoices = Object.entries(MODEL_PROVIDER_TYPES).map(
|
|
10347
10362
|
([type, config]) => ({
|
|
10348
10363
|
title: config.label,
|
|
@@ -10360,11 +10375,11 @@ var setupCommand2 = new Command41().name("setup").description("Configure a model
|
|
|
10360
10375
|
const shouldConvert = options.convert ?? false;
|
|
10361
10376
|
if (options.type && options.credential) {
|
|
10362
10377
|
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(options.type)) {
|
|
10363
|
-
console.error(
|
|
10378
|
+
console.error(chalk43.red(`\u2717 Invalid type "${options.type}"`));
|
|
10364
10379
|
console.log();
|
|
10365
10380
|
console.log("Valid types:");
|
|
10366
10381
|
for (const [t, config] of Object.entries(MODEL_PROVIDER_TYPES)) {
|
|
10367
|
-
console.log(` ${
|
|
10382
|
+
console.log(` ${chalk43.cyan(t)} - ${config.label}`);
|
|
10368
10383
|
}
|
|
10369
10384
|
process.exit(1);
|
|
10370
10385
|
}
|
|
@@ -10372,22 +10387,22 @@ var setupCommand2 = new Command41().name("setup").description("Configure a model
|
|
|
10372
10387
|
credential = options.credential;
|
|
10373
10388
|
} else if (options.type || options.credential) {
|
|
10374
10389
|
console.error(
|
|
10375
|
-
|
|
10390
|
+
chalk43.red("\u2717 Both --type and --credential are required")
|
|
10376
10391
|
);
|
|
10377
10392
|
process.exit(1);
|
|
10378
10393
|
} else {
|
|
10379
10394
|
if (!isInteractive()) {
|
|
10380
|
-
console.error(
|
|
10395
|
+
console.error(chalk43.red("\u2717 Interactive mode requires a TTY"));
|
|
10381
10396
|
console.log();
|
|
10382
10397
|
console.log("Use non-interactive mode:");
|
|
10383
10398
|
console.log(
|
|
10384
|
-
|
|
10399
|
+
chalk43.cyan(
|
|
10385
10400
|
' vm0 model-provider setup --type <type> --credential "<value>"'
|
|
10386
10401
|
)
|
|
10387
10402
|
);
|
|
10388
10403
|
process.exit(1);
|
|
10389
10404
|
}
|
|
10390
|
-
const typeResponse = await
|
|
10405
|
+
const typeResponse = await prompts2(
|
|
10391
10406
|
{
|
|
10392
10407
|
type: "select",
|
|
10393
10408
|
name: "type",
|
|
@@ -10399,7 +10414,7 @@ var setupCommand2 = new Command41().name("setup").description("Configure a model
|
|
|
10399
10414
|
type = typeResponse.type;
|
|
10400
10415
|
const checkResult = await checkModelProviderCredential(type);
|
|
10401
10416
|
if (checkResult.exists && checkResult.currentType === "user") {
|
|
10402
|
-
const convertResponse = await
|
|
10417
|
+
const convertResponse = await prompts2(
|
|
10403
10418
|
{
|
|
10404
10419
|
type: "confirm",
|
|
10405
10420
|
name: "convert",
|
|
@@ -10412,21 +10427,21 @@ var setupCommand2 = new Command41().name("setup").description("Configure a model
|
|
|
10412
10427
|
const provider2 = await convertModelProviderCredential(type);
|
|
10413
10428
|
const defaultNote2 = provider2.isDefault ? ` (default for ${provider2.framework})` : "";
|
|
10414
10429
|
console.log(
|
|
10415
|
-
|
|
10416
|
-
|
|
10430
|
+
chalk43.green(
|
|
10431
|
+
`\u2713 Converted "${checkResult.credentialName}" to model provider${defaultNote2}`
|
|
10417
10432
|
)
|
|
10418
10433
|
);
|
|
10419
10434
|
return;
|
|
10420
10435
|
} else {
|
|
10421
|
-
console.log(
|
|
10436
|
+
console.log(chalk43.dim("Aborted"));
|
|
10422
10437
|
process.exit(0);
|
|
10423
10438
|
}
|
|
10424
10439
|
}
|
|
10425
10440
|
const config = MODEL_PROVIDER_TYPES[type];
|
|
10426
10441
|
console.log();
|
|
10427
|
-
console.log(
|
|
10442
|
+
console.log(chalk43.dim(config.helpText));
|
|
10428
10443
|
console.log();
|
|
10429
|
-
const credentialResponse = await
|
|
10444
|
+
const credentialResponse = await prompts2(
|
|
10430
10445
|
{
|
|
10431
10446
|
type: "password",
|
|
10432
10447
|
name: "credential",
|
|
@@ -10445,24 +10460,24 @@ var setupCommand2 = new Command41().name("setup").description("Configure a model
|
|
|
10445
10460
|
const action = created ? "created" : "updated";
|
|
10446
10461
|
const defaultNote = provider.isDefault ? ` (default for ${provider.framework})` : "";
|
|
10447
10462
|
console.log(
|
|
10448
|
-
|
|
10463
|
+
chalk43.green(`\u2713 Model provider "${type}" ${action}${defaultNote}`)
|
|
10449
10464
|
);
|
|
10450
10465
|
} catch (error) {
|
|
10451
10466
|
if (error instanceof Error) {
|
|
10452
10467
|
if (error.message.includes("already exists")) {
|
|
10453
|
-
console.error(
|
|
10468
|
+
console.error(chalk43.red(`\u2717 ${error.message}`));
|
|
10454
10469
|
console.log();
|
|
10455
10470
|
console.log("To convert the existing credential, run:");
|
|
10456
|
-
console.log(
|
|
10471
|
+
console.log(chalk43.cyan(" vm0 model-provider setup --convert"));
|
|
10457
10472
|
} else if (error.message.includes("Not authenticated")) {
|
|
10458
10473
|
console.error(
|
|
10459
|
-
|
|
10474
|
+
chalk43.red("\u2717 Not authenticated. Run: vm0 auth login")
|
|
10460
10475
|
);
|
|
10461
10476
|
} else {
|
|
10462
|
-
console.error(
|
|
10477
|
+
console.error(chalk43.red(`\u2717 ${error.message}`));
|
|
10463
10478
|
}
|
|
10464
10479
|
} else {
|
|
10465
|
-
console.error(
|
|
10480
|
+
console.error(chalk43.red("\u2717 An unexpected error occurred"));
|
|
10466
10481
|
}
|
|
10467
10482
|
process.exit(1);
|
|
10468
10483
|
}
|
|
@@ -10471,31 +10486,31 @@ var setupCommand2 = new Command41().name("setup").description("Configure a model
|
|
|
10471
10486
|
|
|
10472
10487
|
// src/commands/model-provider/delete.ts
|
|
10473
10488
|
import { Command as Command42 } from "commander";
|
|
10474
|
-
import
|
|
10489
|
+
import chalk44 from "chalk";
|
|
10475
10490
|
var deleteCommand3 = new Command42().name("delete").description("Delete a model provider").argument("<type>", "Model provider type to delete").action(async (type) => {
|
|
10476
10491
|
try {
|
|
10477
10492
|
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(type)) {
|
|
10478
|
-
console.error(
|
|
10493
|
+
console.error(chalk44.red(`\u2717 Invalid type "${type}"`));
|
|
10479
10494
|
console.log();
|
|
10480
10495
|
console.log("Valid types:");
|
|
10481
10496
|
for (const [t, config] of Object.entries(MODEL_PROVIDER_TYPES)) {
|
|
10482
|
-
console.log(` ${
|
|
10497
|
+
console.log(` ${chalk44.cyan(t)} - ${config.label}`);
|
|
10483
10498
|
}
|
|
10484
10499
|
process.exit(1);
|
|
10485
10500
|
}
|
|
10486
10501
|
await deleteModelProvider(type);
|
|
10487
|
-
console.log(
|
|
10502
|
+
console.log(chalk44.green(`\u2713 Model provider "${type}" deleted`));
|
|
10488
10503
|
} catch (error) {
|
|
10489
10504
|
if (error instanceof Error) {
|
|
10490
10505
|
if (error.message.includes("not found")) {
|
|
10491
|
-
console.error(
|
|
10506
|
+
console.error(chalk44.red(`\u2717 Model provider "${type}" not found`));
|
|
10492
10507
|
} else if (error.message.includes("Not authenticated")) {
|
|
10493
|
-
console.error(
|
|
10508
|
+
console.error(chalk44.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
10494
10509
|
} else {
|
|
10495
|
-
console.error(
|
|
10510
|
+
console.error(chalk44.red(`\u2717 ${error.message}`));
|
|
10496
10511
|
}
|
|
10497
10512
|
} else {
|
|
10498
|
-
console.error(
|
|
10513
|
+
console.error(chalk44.red("\u2717 An unexpected error occurred"));
|
|
10499
10514
|
}
|
|
10500
10515
|
process.exit(1);
|
|
10501
10516
|
}
|
|
@@ -10503,35 +10518,35 @@ var deleteCommand3 = new Command42().name("delete").description("Delete a model
|
|
|
10503
10518
|
|
|
10504
10519
|
// src/commands/model-provider/set-default.ts
|
|
10505
10520
|
import { Command as Command43 } from "commander";
|
|
10506
|
-
import
|
|
10521
|
+
import chalk45 from "chalk";
|
|
10507
10522
|
var setDefaultCommand = new Command43().name("set-default").description("Set a model provider as default for its framework").argument("<type>", "Model provider type to set as default").action(async (type) => {
|
|
10508
10523
|
try {
|
|
10509
10524
|
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(type)) {
|
|
10510
|
-
console.error(
|
|
10525
|
+
console.error(chalk45.red(`\u2717 Invalid type "${type}"`));
|
|
10511
10526
|
console.log();
|
|
10512
10527
|
console.log("Valid types:");
|
|
10513
10528
|
for (const [t, config] of Object.entries(MODEL_PROVIDER_TYPES)) {
|
|
10514
|
-
console.log(` ${
|
|
10529
|
+
console.log(` ${chalk45.cyan(t)} - ${config.label}`);
|
|
10515
10530
|
}
|
|
10516
10531
|
process.exit(1);
|
|
10517
10532
|
}
|
|
10518
10533
|
const provider = await setModelProviderDefault(type);
|
|
10519
10534
|
console.log(
|
|
10520
|
-
|
|
10521
|
-
|
|
10535
|
+
chalk45.green(
|
|
10536
|
+
`\u2713 Default for ${provider.framework} set to "${provider.type}"`
|
|
10522
10537
|
)
|
|
10523
10538
|
);
|
|
10524
10539
|
} catch (error) {
|
|
10525
10540
|
if (error instanceof Error) {
|
|
10526
10541
|
if (error.message.includes("not found")) {
|
|
10527
|
-
console.error(
|
|
10542
|
+
console.error(chalk45.red(`\u2717 Model provider "${type}" not found`));
|
|
10528
10543
|
} else if (error.message.includes("Not authenticated")) {
|
|
10529
|
-
console.error(
|
|
10544
|
+
console.error(chalk45.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
10530
10545
|
} else {
|
|
10531
|
-
console.error(
|
|
10546
|
+
console.error(chalk45.red(`\u2717 ${error.message}`));
|
|
10532
10547
|
}
|
|
10533
10548
|
} else {
|
|
10534
|
-
console.error(
|
|
10549
|
+
console.error(chalk45.red("\u2717 An unexpected error occurred"));
|
|
10535
10550
|
}
|
|
10536
10551
|
process.exit(1);
|
|
10537
10552
|
}
|
|
@@ -10542,9 +10557,9 @@ var modelProviderCommand = new Command44().name("model-provider").description("M
|
|
|
10542
10557
|
|
|
10543
10558
|
// src/index.ts
|
|
10544
10559
|
var program = new Command45();
|
|
10545
|
-
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("
|
|
10560
|
+
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.0.0");
|
|
10546
10561
|
program.command("info").description("Display environment information").action(async () => {
|
|
10547
|
-
console.log(
|
|
10562
|
+
console.log(chalk46.bold("System Information:"));
|
|
10548
10563
|
console.log(`Node Version: ${process.version}`);
|
|
10549
10564
|
console.log(`Platform: ${process.platform}`);
|
|
10550
10565
|
console.log(`Architecture: ${process.arch}`);
|