@vm0/cli 9.244.6 → 9.244.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/{agent-AOWGKKI7.js → agent-QLXX4WY7.js} +5 -5
  2. package/{banking-2ZRGXQJB.js → banking-WY3J5BTJ.js} +3 -3
  3. package/{chat-XT3ZFO2U.js → chat-L3EFI2XJ.js} +4 -4
  4. package/{chunk-2GMLVBYY.js → chunk-43PGP5OI.js} +4 -4
  5. package/{chunk-MBYTQ3JJ.js → chunk-65MTNZ44.js} +93 -34
  6. package/chunk-65MTNZ44.js.map +1 -0
  7. package/{chunk-GGJ3V5JF.js → chunk-JVIFZRZ7.js} +3 -3
  8. package/{chunk-J7NZ4R4R.js → chunk-KMLBXZVR.js} +2 -2
  9. package/{chunk-RPQMDXP2.js → chunk-LHR5Z775.js} +2 -2
  10. package/{chunk-MWXV2NJK.js → chunk-MA37R4QS.js} +4 -32
  11. package/chunk-MA37R4QS.js.map +1 -0
  12. package/{chunk-MZUWWKCF.js → chunk-MPSVIFKZ.js} +4 -4
  13. package/{chunk-OPYEYUSY.js → chunk-MX32FFQR.js} +29 -55
  14. package/chunk-MX32FFQR.js.map +1 -0
  15. package/{chunk-V33YE2AE.js → chunk-TTP663DN.js} +2 -2
  16. package/{chunk-LX7FTB2W.js → chunk-WCRXAO2G.js} +2 -2
  17. package/{chunk-PB66MQ5U.js → chunk-ZUSDQG2O.js} +2 -7
  18. package/{chunk-PB66MQ5U.js.map → chunk-ZUSDQG2O.js.map} +1 -1
  19. package/{computer-use-IP4SF35H.js → computer-use-7FYLJXZS.js} +3 -3
  20. package/{connector-XK7EPZWH.js → connector-BSBQIFMQ.js} +6 -6
  21. package/{credit-VPTX7ZTC.js → credit-JBFJY5US.js} +4 -4
  22. package/{developer-support-3ED5W5G3.js → developer-support-RUWSZBFP.js} +3 -3
  23. package/{doctor-JZG5ZNW2.js → doctor-YLD526OE.js} +3 -3
  24. package/{generate-PAMRL3B5.js → generate-5EMJ3PE6.js} +4 -4
  25. package/{github-OUIYACCV.js → github-36XCAIUP.js} +3 -3
  26. package/{goal-PXTE4BCJ.js → goal-FRXLYRUG.js} +3 -3
  27. package/{host-3KVI5HIB.js → host-X2KS3WTS.js} +4 -4
  28. package/index.js +11 -730
  29. package/index.js.map +1 -1
  30. package/{logs-LEPXLZOA.js → logs-WHQES7BY.js} +5 -5
  31. package/{mail-22YJ3HFW.js → mail-LOXCIZZN.js} +5 -5
  32. package/{maps-GTBQWQOV.js → maps-KQWCQLHW.js} +3 -3
  33. package/{model-RWQNBS3N.js → model-2BBROTMX.js} +4 -4
  34. package/{model-provider-6B54DC7X.js → model-provider-BOMTZ6JA.js} +4 -4
  35. package/{org-JEJIR4XQ.js → org-SO7ELOV6.js} +3 -3
  36. package/package.json +1 -1
  37. package/{phone-CI77EG37.js → phone-IYUG3RGY.js} +3 -3
  38. package/{preference-546TA23L.js → preference-TGBWXIP7.js} +3 -3
  39. package/{chunk-HEAUPGDO.js → resource-EA5OUVG4.js} +133 -3
  40. package/resource-EA5OUVG4.js.map +1 -0
  41. package/{scrape-VZJ67GNU.js → scrape-2S3B33RA.js} +3 -3
  42. package/{search-L5ICIORF.js → search-LCGK3BJI.js} +5 -5
  43. package/{secret-FKMH53Y4.js → secret-M5C54VAT.js} +3 -3
  44. package/{slack-BQ4KIZPV.js → slack-FJV2NEOT.js} +3 -3
  45. package/{teams-YZSKKRY4.js → teams-XBLEN2XV.js} +3 -3
  46. package/{telegram-HHGB5PE3.js → telegram-RE6IO7ZT.js} +3 -3
  47. package/{variable-4CIAHKLM.js → variable-5MVUR6U4.js} +3 -3
  48. package/{video-54PFQIQD.js → video-DIVG6CMM.js} +2 -2
  49. package/{web-BOBLQ27H.js → web-KVZL6WM4.js} +3 -3
  50. package/{web-search-27452WDH.js → web-search-XNJH2FXZ.js} +3 -3
  51. package/{whoami-5SIOEBZY.js → whoami-NQYYRWEE.js} +5 -5
  52. package/{workflow-62JWPXNK.js → workflow-5CGPRRAY.js} +3 -3
  53. package/zero.js +35 -35
  54. package/chunk-HEAUPGDO.js.map +0 -1
  55. package/chunk-MBYTQ3JJ.js.map +0 -1
  56. package/chunk-MWXV2NJK.js.map +0 -1
  57. package/chunk-OPYEYUSY.js.map +0 -1
  58. package/resource-HRVLBG7N.js +0 -143
  59. package/resource-HRVLBG7N.js.map +0 -1
  60. /package/{agent-AOWGKKI7.js.map → agent-QLXX4WY7.js.map} +0 -0
  61. /package/{banking-2ZRGXQJB.js.map → banking-WY3J5BTJ.js.map} +0 -0
  62. /package/{chat-XT3ZFO2U.js.map → chat-L3EFI2XJ.js.map} +0 -0
  63. /package/{chunk-2GMLVBYY.js.map → chunk-43PGP5OI.js.map} +0 -0
  64. /package/{chunk-GGJ3V5JF.js.map → chunk-JVIFZRZ7.js.map} +0 -0
  65. /package/{chunk-J7NZ4R4R.js.map → chunk-KMLBXZVR.js.map} +0 -0
  66. /package/{chunk-RPQMDXP2.js.map → chunk-LHR5Z775.js.map} +0 -0
  67. /package/{chunk-MZUWWKCF.js.map → chunk-MPSVIFKZ.js.map} +0 -0
  68. /package/{chunk-V33YE2AE.js.map → chunk-TTP663DN.js.map} +0 -0
  69. /package/{chunk-LX7FTB2W.js.map → chunk-WCRXAO2G.js.map} +0 -0
  70. /package/{computer-use-IP4SF35H.js.map → computer-use-7FYLJXZS.js.map} +0 -0
  71. /package/{connector-XK7EPZWH.js.map → connector-BSBQIFMQ.js.map} +0 -0
  72. /package/{credit-VPTX7ZTC.js.map → credit-JBFJY5US.js.map} +0 -0
  73. /package/{developer-support-3ED5W5G3.js.map → developer-support-RUWSZBFP.js.map} +0 -0
  74. /package/{doctor-JZG5ZNW2.js.map → doctor-YLD526OE.js.map} +0 -0
  75. /package/{generate-PAMRL3B5.js.map → generate-5EMJ3PE6.js.map} +0 -0
  76. /package/{github-OUIYACCV.js.map → github-36XCAIUP.js.map} +0 -0
  77. /package/{goal-PXTE4BCJ.js.map → goal-FRXLYRUG.js.map} +0 -0
  78. /package/{host-3KVI5HIB.js.map → host-X2KS3WTS.js.map} +0 -0
  79. /package/{logs-LEPXLZOA.js.map → logs-WHQES7BY.js.map} +0 -0
  80. /package/{mail-22YJ3HFW.js.map → mail-LOXCIZZN.js.map} +0 -0
  81. /package/{maps-GTBQWQOV.js.map → maps-KQWCQLHW.js.map} +0 -0
  82. /package/{model-RWQNBS3N.js.map → model-2BBROTMX.js.map} +0 -0
  83. /package/{model-provider-6B54DC7X.js.map → model-provider-BOMTZ6JA.js.map} +0 -0
  84. /package/{org-JEJIR4XQ.js.map → org-SO7ELOV6.js.map} +0 -0
  85. /package/{phone-CI77EG37.js.map → phone-IYUG3RGY.js.map} +0 -0
  86. /package/{preference-546TA23L.js.map → preference-TGBWXIP7.js.map} +0 -0
  87. /package/{scrape-VZJ67GNU.js.map → scrape-2S3B33RA.js.map} +0 -0
  88. /package/{search-L5ICIORF.js.map → search-LCGK3BJI.js.map} +0 -0
  89. /package/{secret-FKMH53Y4.js.map → secret-M5C54VAT.js.map} +0 -0
  90. /package/{slack-BQ4KIZPV.js.map → slack-FJV2NEOT.js.map} +0 -0
  91. /package/{teams-YZSKKRY4.js.map → teams-XBLEN2XV.js.map} +0 -0
  92. /package/{telegram-HHGB5PE3.js.map → telegram-RE6IO7ZT.js.map} +0 -0
  93. /package/{variable-4CIAHKLM.js.map → variable-5MVUR6U4.js.map} +0 -0
  94. /package/{video-54PFQIQD.js.map → video-DIVG6CMM.js.map} +0 -0
  95. /package/{web-BOBLQ27H.js.map → web-KVZL6WM4.js.map} +0 -0
  96. /package/{web-search-27452WDH.js.map → web-search-XNJH2FXZ.js.map} +0 -0
  97. /package/{whoami-5SIOEBZY.js.map → whoami-NQYYRWEE.js.map} +0 -0
  98. /package/{workflow-62JWPXNK.js.map → workflow-5CGPRRAY.js.map} +0 -0
package/index.js CHANGED
@@ -2,19 +2,15 @@
2
2
  import { createRequire as __createRequire } from "node:module";
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
- excludeVm0Filter,
6
5
  formatRelativeTime
7
- } from "./chunk-PB66MQ5U.js";
6
+ } from "./chunk-ZUSDQG2O.js";
8
7
  import {
9
8
  collectArtifacts,
10
9
  collectKeyValue,
11
10
  collectMounts,
12
11
  collectVolumeVersions,
13
- extractAndGroupVariables,
14
12
  extractSecretNames,
15
13
  extractVarNames,
16
- getInstructionsFilename,
17
- getInstructionsStorageName,
18
14
  isUUID,
19
15
  loadValues,
20
16
  parseIdentifier,
@@ -22,19 +18,12 @@ import {
22
18
  parseTime,
23
19
  pollEvents,
24
20
  renderRunCreated,
25
- require_dist,
26
21
  showNextSteps
27
- } from "./chunk-MBYTQ3JJ.js";
28
- import {
29
- Qn
30
- } from "./chunk-HEAUPGDO.js";
22
+ } from "./chunk-65MTNZ44.js";
31
23
  import "./chunk-DWWE7STW.js";
32
24
  import {
33
25
  ALL_RUN_STATUSES,
34
- agentDefinitionSchema,
35
26
  cancelRun,
36
- commitStorage,
37
- createOrUpdateCompose,
38
27
  createRun,
39
28
  directRunModelProviderTypeSchema,
40
29
  getCheckpoint,
@@ -43,18 +32,11 @@ import {
43
32
  getComposeVersion,
44
33
  getRunQueue,
45
34
  getSession,
46
- guaranteedConnectorProvidedBindingNames,
47
- listRuns,
48
- listZeroConnectors,
49
- listZeroSecrets,
50
- listZeroVariables,
51
- prepareStorage,
52
- volumeConfigSchema
53
- } from "./chunk-OPYEYUSY.js";
35
+ listRuns
36
+ } from "./chunk-MX32FFQR.js";
54
37
  import "./chunk-LTDQISD7.js";
55
38
  import {
56
39
  clearConfig,
57
- external_exports,
58
40
  getActiveOrg,
59
41
  getApiUrl,
60
42
  getToken,
@@ -63,17 +45,16 @@ import {
63
45
  saveConfig,
64
46
  source_default,
65
47
  withErrorHandler
66
- } from "./chunk-MWXV2NJK.js";
48
+ } from "./chunk-MA37R4QS.js";
67
49
  import {
68
50
  configureGlobalProxyFromEnv
69
- } from "./chunk-GGJ3V5JF.js";
51
+ } from "./chunk-JVIFZRZ7.js";
70
52
  import "./chunk-LRHXR7JT.js";
71
53
  import {
72
54
  Command,
73
55
  Option
74
56
  } from "./chunk-B3W2RUBP.js";
75
57
  import {
76
- __toESM,
77
58
  init_esm_shims
78
59
  } from "./chunk-DIRAZ3YX.js";
79
60
 
@@ -252,485 +233,11 @@ var setupTokenCommand = new Command().name("setup-token").description("Output au
252
233
  // src/commands/auth/index.ts
253
234
  var authCommand = new Command().name("auth").description("Authenticate vm0").addCommand(loginCommand).addCommand(logoutCommand).addCommand(statusCommand).addCommand(setupTokenCommand);
254
235
 
255
- // src/commands/compose/index.ts
256
- init_esm_shims();
257
- var import_yaml = __toESM(require_dist(), 1);
258
- import { readFile as readFile2 } from "fs/promises";
259
- import { existsSync as existsSync2 } from "fs";
260
- import { dirname } from "path";
261
-
262
- // src/lib/domain/yaml-validator.ts
236
+ // src/commands/run/index.ts
263
237
  init_esm_shims();
264
- var cliAgentNameSchema = external_exports.string().min(3, "Agent name must be at least 3 characters").max(64, "Agent name must be 64 characters or less").regex(
265
- /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,62}[a-zA-Z0-9])?$/,
266
- "Agent name must start and end with letter or number, and contain only letters, numbers, and hyphens"
267
- );
268
- var cliComposeSchema = external_exports.object({
269
- version: external_exports.string().min(1, "Missing config.version"),
270
- agents: external_exports.record(cliAgentNameSchema, agentDefinitionSchema),
271
- volumes: external_exports.record(external_exports.string(), volumeConfigSchema).optional()
272
- }).superRefine((config, ctx) => {
273
- const agentKeys = Object.keys(config.agents);
274
- if (agentKeys.length === 0) {
275
- ctx.addIssue({
276
- code: external_exports.ZodIssueCode.custom,
277
- message: "agents must have at least one agent defined",
278
- path: ["agents"]
279
- });
280
- return;
281
- }
282
- if (agentKeys.length > 1) {
283
- ctx.addIssue({
284
- code: external_exports.ZodIssueCode.custom,
285
- message: "Multiple agents not supported yet. Only one agent allowed.",
286
- path: ["agents"]
287
- });
288
- return;
289
- }
290
- const agentName = agentKeys[0];
291
- const agent = config.agents[agentName];
292
- const agentVolumes = agent?.volumes;
293
- if (agentVolumes && agentVolumes.length > 0) {
294
- if (!config.volumes) {
295
- ctx.addIssue({
296
- code: external_exports.ZodIssueCode.custom,
297
- message: "Agent references volumes but no volumes section defined. Each volume must have explicit name and version.",
298
- path: ["volumes"]
299
- });
300
- return;
301
- }
302
- for (const volDeclaration of agentVolumes) {
303
- const parts = volDeclaration.split(":");
304
- if (parts.length !== 2) {
305
- ctx.addIssue({
306
- code: external_exports.ZodIssueCode.custom,
307
- message: `Invalid volume declaration: ${volDeclaration}. Expected format: volume-key:/mount/path`,
308
- path: ["agents", agentName, "volumes"]
309
- });
310
- continue;
311
- }
312
- const volumeKey = parts[0].trim();
313
- if (!config.volumes[volumeKey]) {
314
- ctx.addIssue({
315
- code: external_exports.ZodIssueCode.custom,
316
- message: `Volume "${volumeKey}" is not defined in volumes section. Each volume must have explicit name and version.`,
317
- path: ["volumes", volumeKey]
318
- });
319
- }
320
- }
321
- }
322
- });
323
- function formatInvalidTypeIssue(path3, issue) {
324
- const runtimeReceived = Reflect.get(issue, "received");
325
- const received = typeof runtimeReceived === "string" ? runtimeReceived : void 0;
326
- const isMissing = received === "undefined" || issue.message.includes("received undefined") || issue.message === "Required";
327
- if (path3 === "version" && isMissing) {
328
- return "Missing config.version";
329
- }
330
- if (path3 === "agents" && isMissing) {
331
- return "Missing agents object in config";
332
- }
333
- if (path3.startsWith("volumes.") && path3.endsWith(".name")) {
334
- const volumeKey = path3.split(".")[1];
335
- return `Volume "${volumeKey}" must have a 'name' field (string)`;
336
- }
337
- if (path3.startsWith("volumes.") && path3.endsWith(".version")) {
338
- const volumeKey = path3.split(".")[1];
339
- return `Volume "${volumeKey}" must have a 'version' field (string)`;
340
- }
341
- if (issue.expected === "array") {
342
- const fieldName = path3.replace(/^agents\.[^.]+\./, "agent.");
343
- return `${fieldName} must be an array`;
344
- }
345
- if (issue.expected === "string" && received === "number") {
346
- const fieldName = path3.replace(/^agents\.[^.]+\./, "agent.");
347
- const match = fieldName.match(/^(agent\.[^.]+)\.\d+$/);
348
- if (match) {
349
- return `Each entry in ${match[1]?.replace("agent.", "")} must be a string`;
350
- }
351
- }
352
- return null;
353
- }
354
- function formatZodError(error) {
355
- const issue = error.issues[0];
356
- if (!issue) return "Validation failed";
357
- const path3 = issue.path.join(".");
358
- const message = issue.message;
359
- if (!path3) return message;
360
- if (issue.code === "invalid_type") {
361
- const formatted = formatInvalidTypeIssue(path3, issue);
362
- if (formatted) return formatted;
363
- }
364
- if (issue.code === "invalid_key" && path3.startsWith("agents.")) {
365
- return "Invalid agent name format. Must be 3-64 characters, letters, numbers, and hyphens only. Must start and end with letter or number.";
366
- }
367
- if (message === "Invalid key in record" && path3.startsWith("agents.")) {
368
- return "Invalid agent name format. Must be 3-64 characters, letters, numbers, and hyphens only. Must start and end with letter or number.";
369
- }
370
- if (issue.code === "custom") {
371
- return message;
372
- }
373
- if (path3.startsWith("agents.")) {
374
- const cleanPath = path3.replace(/^agents\.[^.]+\./, "agent.");
375
- if (message.startsWith("Invalid input:")) {
376
- const match = message.match(/expected (\w+), received (\w+)/);
377
- if (match && match[1] === "string" && match[2] === "number") {
378
- const fieldMatch = cleanPath.match(/^(agent\.[^.]+)\.\d+$/);
379
- if (fieldMatch) {
380
- return `Each entry in ${fieldMatch[1]?.replace("agent.", "")} must be a string`;
381
- }
382
- }
383
- }
384
- return `${cleanPath}: ${message}`;
385
- }
386
- return `${path3}: ${message}`;
387
- }
388
- var KNOWN_AGENT_FIELDS = Object.keys(agentDefinitionSchema.shape);
389
- function levenshteinDistance(a, b) {
390
- if (a === b) return 0;
391
- if (a.length === 0) return b.length;
392
- if (b.length === 0) return a.length;
393
- if (a.length > b.length) [a, b] = [b, a];
394
- const row = Array.from({ length: a.length + 1 }, (_, i) => {
395
- return i;
396
- });
397
- for (let j = 1; j <= b.length; j++) {
398
- let prev = j - 1;
399
- row[0] = j;
400
- for (let i = 1; i <= a.length; i++) {
401
- const cost = a[i - 1] === b[j - 1] ? 0 : 1;
402
- const current = Math.min(
403
- row[i] + 1,
404
- // deletion
405
- row[i - 1] + 1,
406
- // insertion
407
- prev + cost
408
- // substitution
409
- );
410
- prev = row[i];
411
- row[i] = current;
412
- }
413
- }
414
- return row[a.length];
415
- }
416
- function findSimilarField(unknown, knownFields) {
417
- let bestMatch = null;
418
- let bestDistance = Infinity;
419
- for (const known of knownFields) {
420
- if (unknown === known) continue;
421
- const distance = levenshteinDistance(unknown, known);
422
- if (distance <= 2 && distance < bestDistance) {
423
- bestDistance = distance;
424
- bestMatch = known;
425
- }
426
- if (unknown.length >= 3 && known.startsWith(unknown) && !bestMatch) {
427
- bestMatch = known;
428
- }
429
- }
430
- return bestMatch;
431
- }
432
- function extractAgentEntries(config) {
433
- if (!config || typeof config !== "object") return null;
434
- const cfg = config;
435
- const agents = cfg.agents;
436
- if (!agents || typeof agents !== "object" || Array.isArray(agents))
437
- return null;
438
- return agents;
439
- }
440
- function checkForFieldTypos(config) {
441
- const agents = extractAgentEntries(config);
442
- if (!agents) return null;
443
- const errors = [];
444
- for (const [agentName, agent] of Object.entries(agents)) {
445
- if (!agent || typeof agent !== "object" || Array.isArray(agent)) continue;
446
- for (const field of Object.keys(agent)) {
447
- if (KNOWN_AGENT_FIELDS.includes(field)) continue;
448
- const suggestion = findSimilarField(field, KNOWN_AGENT_FIELDS);
449
- if (suggestion) {
450
- errors.push(
451
- `Unknown field "${field}" in agent "${agentName}". Did you mean "${suggestion}"?`
452
- );
453
- }
454
- }
455
- }
456
- return errors.length > 0 ? errors.join("\n") : null;
457
- }
458
- function checkForDeprecatedProvider(config) {
459
- const agents = extractAgentEntries(config);
460
- if (!agents) return null;
461
- for (const agent of Object.values(agents)) {
462
- if (agent && typeof agent === "object" && !Array.isArray(agent)) {
463
- if ("provider" in agent && !("framework" in agent)) {
464
- const providerValue = agent.provider;
465
- return `'provider' field is deprecated. Use 'framework' instead.
466
-
467
- Change in your vm0.yaml:
468
- - provider: ${providerValue}
469
- + framework: ${providerValue}`;
470
- }
471
- }
472
- }
473
- return null;
474
- }
475
- function validateAgentCompose(config) {
476
- const deprecationError = checkForDeprecatedProvider(config);
477
- if (deprecationError) {
478
- return { valid: false, error: deprecationError };
479
- }
480
- const typoError = checkForFieldTypos(config);
481
- if (typoError) {
482
- return { valid: false, error: typoError };
483
- }
484
- if (config && typeof config === "object" && Array.isArray(config.agents)) {
485
- return {
486
- valid: false,
487
- error: "agents must be an object, not an array. Use format: agents: { agent-name: { ... } }"
488
- };
489
- }
490
- if (!config || typeof config !== "object") {
491
- return { valid: false, error: "Config must be an object" };
492
- }
493
- const result = cliComposeSchema.safeParse(config);
494
- if (!result.success) {
495
- return { valid: false, error: formatZodError(result.error) };
496
- }
497
- return { valid: true };
498
- }
499
238
 
500
- // src/lib/storage/system-storage.ts
239
+ // src/commands/run/run.ts
501
240
  init_esm_shims();
502
- import * as fs2 from "fs/promises";
503
- import * as path2 from "path";
504
- import * as os2 from "os";
505
-
506
- // src/lib/storage/direct-upload.ts
507
- init_esm_shims();
508
- import { createHash } from "crypto";
509
- import * as fs from "fs";
510
- import * as path from "path";
511
- import * as os from "os";
512
- async function hashFileStream(filePath) {
513
- return new Promise((resolve, reject) => {
514
- const hash = createHash("sha256");
515
- const stream = fs.createReadStream(filePath);
516
- stream.on("data", (chunk) => {
517
- return hash.update(chunk);
518
- });
519
- stream.on("end", () => {
520
- return resolve(hash.digest("hex"));
521
- });
522
- stream.on("error", reject);
523
- });
524
- }
525
- async function getAllFiles(dirPath, baseDir = dirPath) {
526
- const files = [];
527
- const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });
528
- for (const entry of entries) {
529
- const fullPath = path.join(dirPath, entry.name);
530
- const relativePath = path.relative(baseDir, fullPath);
531
- if (relativePath.startsWith(".vm0")) {
532
- continue;
533
- }
534
- if (entry.isDirectory()) {
535
- const subFiles = await getAllFiles(fullPath, baseDir);
536
- files.push(...subFiles);
537
- } else {
538
- files.push(fullPath);
539
- }
540
- }
541
- return files;
542
- }
543
- async function collectFileMetadata(cwd, files, onProgress) {
544
- const fileEntries = [];
545
- for (let i = 0; i < files.length; i++) {
546
- const file = files[i];
547
- const relativePath = path.relative(cwd, file);
548
- const [hash, stats] = await Promise.all([
549
- hashFileStream(file),
550
- fs.promises.stat(file)
551
- ]);
552
- fileEntries.push({
553
- path: relativePath,
554
- hash,
555
- size: stats.size
556
- });
557
- if (onProgress && (i + 1) % 100 === 0) {
558
- onProgress(`Hashing files... ${i + 1}/${files.length}`);
559
- }
560
- }
561
- return fileEntries;
562
- }
563
- async function createArchive(cwd, files) {
564
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "vm0-"));
565
- const tarPath = path.join(tmpDir, "archive.tar.gz");
566
- try {
567
- const relativePaths = files.map((file) => {
568
- return path.relative(cwd, file);
569
- });
570
- if (relativePaths.length > 0) {
571
- await Qn(
572
- {
573
- gzip: true,
574
- file: tarPath,
575
- cwd
576
- },
577
- relativePaths
578
- );
579
- } else {
580
- await Qn(
581
- {
582
- gzip: true,
583
- file: tarPath,
584
- cwd,
585
- filter: excludeVm0Filter
586
- },
587
- ["."]
588
- );
589
- }
590
- const tarBuffer = await fs.promises.readFile(tarPath);
591
- return tarBuffer;
592
- } finally {
593
- if (fs.existsSync(tarPath)) {
594
- await fs.promises.unlink(tarPath);
595
- }
596
- await fs.promises.rmdir(tmpDir);
597
- }
598
- }
599
- function createManifest(files) {
600
- const manifest = {
601
- version: 1,
602
- files,
603
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
604
- };
605
- return Buffer.from(JSON.stringify(manifest, null, 2));
606
- }
607
- function sleep(ms) {
608
- return new Promise((resolve) => {
609
- return setTimeout(resolve, ms);
610
- });
611
- }
612
- async function uploadToPresignedUrl(presignedUrl, data, contentType, maxRetries = 3) {
613
- let lastError = null;
614
- for (let attempt = 1; attempt <= maxRetries; attempt++) {
615
- try {
616
- const response = await fetch(presignedUrl, {
617
- method: "PUT",
618
- body: data,
619
- headers: {
620
- "Content-Type": contentType
621
- }
622
- });
623
- if (response.ok) {
624
- return;
625
- }
626
- if (response.status >= 400 && response.status < 500) {
627
- const text2 = await response.text();
628
- throw new Error(`S3 upload failed: ${response.status} - ${text2}`);
629
- }
630
- const text = await response.text();
631
- lastError = new Error(`S3 upload failed: ${response.status} - ${text}`);
632
- } catch (error) {
633
- lastError = error instanceof Error ? error : new Error("Unknown upload error");
634
- if (lastError.message.includes("400") || lastError.message.includes("403")) {
635
- throw lastError;
636
- }
637
- }
638
- if (attempt < maxRetries) {
639
- const backoffMs = Math.pow(2, attempt - 1) * 1e3;
640
- await sleep(backoffMs);
641
- }
642
- }
643
- throw lastError || new Error("S3 upload failed after retries");
644
- }
645
- async function directUpload(storageName, storageType, cwd, options) {
646
- const { onProgress, force } = options || {};
647
- onProgress?.("Collecting files...");
648
- const files = await getAllFiles(cwd);
649
- onProgress?.("Computing file hashes...");
650
- const fileEntries = await collectFileMetadata(cwd, files, onProgress);
651
- onProgress?.("Preparing upload...");
652
- const prepareResult = await prepareStorage({
653
- storageName,
654
- storageType,
655
- files: fileEntries,
656
- force
657
- });
658
- if (prepareResult.existing) {
659
- onProgress?.("Version exists, updating HEAD...");
660
- const commitResult2 = await commitStorage({
661
- storageName,
662
- storageType,
663
- versionId: prepareResult.versionId,
664
- files: fileEntries
665
- });
666
- return {
667
- versionId: commitResult2.versionId,
668
- size: commitResult2.size,
669
- fileCount: commitResult2.fileCount,
670
- deduplicated: true,
671
- empty: commitResult2.fileCount === 0
672
- };
673
- }
674
- if (files.length > 0) {
675
- onProgress?.("Compressing files...");
676
- const archiveBuffer = await createArchive(cwd, files);
677
- onProgress?.("Uploading archive to S3...");
678
- if (!prepareResult.uploads) {
679
- throw new Error("No upload URLs received from prepare endpoint");
680
- }
681
- await uploadToPresignedUrl(
682
- prepareResult.uploads.archive.presignedUrl,
683
- archiveBuffer,
684
- "application/gzip"
685
- );
686
- }
687
- onProgress?.("Uploading manifest...");
688
- if (!prepareResult.uploads) {
689
- throw new Error("No upload URLs received from prepare endpoint");
690
- }
691
- const manifestBuffer = createManifest(fileEntries);
692
- await uploadToPresignedUrl(
693
- prepareResult.uploads.manifest.presignedUrl,
694
- manifestBuffer,
695
- "application/json"
696
- );
697
- onProgress?.("Committing...");
698
- const commitResult = await commitStorage({
699
- storageName,
700
- storageType,
701
- versionId: prepareResult.versionId,
702
- files: fileEntries
703
- });
704
- return {
705
- versionId: commitResult.versionId,
706
- size: commitResult.size,
707
- fileCount: commitResult.fileCount,
708
- deduplicated: commitResult.deduplicated || false,
709
- empty: commitResult.fileCount === 0
710
- };
711
- }
712
-
713
- // src/lib/storage/system-storage.ts
714
- async function uploadInstructions(agentName, instructionsFilePath, basePath, framework) {
715
- const storageName = getInstructionsStorageName(agentName.toLowerCase());
716
- const absolutePath = path2.isAbsolute(instructionsFilePath) ? instructionsFilePath : path2.join(basePath, instructionsFilePath);
717
- const content = await fs2.readFile(absolutePath, "utf8");
718
- const tmpDir = await fs2.mkdtemp(path2.join(os2.tmpdir(), "vm0-instructions-"));
719
- const instructionsDir = path2.join(tmpDir, "instructions");
720
- await fs2.mkdir(instructionsDir);
721
- const filename = getInstructionsFilename(framework);
722
- await fs2.writeFile(path2.join(instructionsDir, filename), content);
723
- try {
724
- const result = await directUpload(storageName, "volume", instructionsDir);
725
- return {
726
- name: storageName,
727
- versionId: result.versionId,
728
- action: result.deduplicated ? "deduplicated" : "created"
729
- };
730
- } finally {
731
- await fs2.rm(tmpDir, { recursive: true, force: true });
732
- }
733
- }
734
241
 
735
242
  // src/lib/utils/update-checker.ts
736
243
  init_esm_shims();
@@ -859,228 +366,7 @@ async function waitForSilentUpgrade(timeout = TIMEOUT_MS) {
859
366
  }
860
367
  }
861
368
 
862
- // src/commands/compose/index.ts
863
- var DEFAULT_CONFIG_FILE = "vm0.yaml";
864
- function getSecretsFromComposeContent(content) {
865
- const grouped = extractAndGroupVariables(content);
866
- return new Set(
867
- grouped.secrets.map((r) => {
868
- return r.name;
869
- })
870
- );
871
- }
872
- function getVarsFromComposeContent(content) {
873
- const grouped = extractAndGroupVariables(content);
874
- return new Set(
875
- grouped.vars.map((r) => {
876
- return r.name;
877
- })
878
- );
879
- }
880
- async function loadAndValidateConfig(configFile) {
881
- if (!existsSync2(configFile)) {
882
- throw new Error(`Config file not found: ${configFile}`);
883
- }
884
- const content = await readFile2(configFile, "utf8");
885
- let config;
886
- try {
887
- config = (0, import_yaml.parse)(content);
888
- } catch (error) {
889
- const message = error instanceof Error ? error.message : "Unknown error";
890
- throw new Error(`Invalid YAML format: ${message}`);
891
- }
892
- const validation = validateAgentCompose(config);
893
- if (!validation.valid) {
894
- throw new Error(validation.error);
895
- }
896
- const cfg = config;
897
- const agentsConfig = cfg.agents;
898
- const agentName = Object.keys(agentsConfig)[0];
899
- const agent = agentsConfig[agentName];
900
- const basePath = dirname(configFile);
901
- return { config, agentName, agent, basePath };
902
- }
903
- async function uploadInstructionsIfPresent(agentName, agent, basePath, jsonMode) {
904
- if (!agent.instructions) return;
905
- if (!jsonMode) {
906
- console.log(`Uploading instructions: ${agent.instructions}`);
907
- }
908
- const result = await uploadInstructions(
909
- agentName,
910
- agent.instructions,
911
- basePath,
912
- agent.framework
913
- );
914
- if (!jsonMode) {
915
- console.log(
916
- source_default.green(
917
- `\u2713 Instructions ${result.action === "deduplicated" ? "(unchanged)" : "uploaded"}: ${result.versionId.slice(0, 8)}`
918
- )
919
- );
920
- }
921
- }
922
- function stripSkillsFromAgents(config) {
923
- if (!config || typeof config !== "object") return config;
924
- const cfg = structuredClone(config);
925
- const agents = cfg.agents;
926
- if (agents && typeof agents === "object" && !Array.isArray(agents)) {
927
- for (const agent of Object.values(agents)) {
928
- if (agent && typeof agent === "object" && !Array.isArray(agent)) {
929
- delete agent.skills;
930
- }
931
- }
932
- }
933
- return cfg;
934
- }
935
- async function checkAndPromptMissingItems(config, options) {
936
- const requiredSecrets = getSecretsFromComposeContent(config);
937
- const requiredVars = getVarsFromComposeContent(config);
938
- if (requiredSecrets.size === 0 && requiredVars.size === 0) {
939
- return { missingSecrets: [], missingVars: [] };
940
- }
941
- const [secretsResponse, variablesResponse, connectorsResponse] = await Promise.all([
942
- requiredSecrets.size > 0 ? listZeroSecrets() : { secrets: [] },
943
- requiredVars.size > 0 ? listZeroVariables() : { variables: [] },
944
- listZeroConnectors()
945
- ]);
946
- const existingSecretNames = new Set(
947
- secretsResponse.secrets.map((s) => {
948
- return s.name;
949
- })
950
- );
951
- const existingVarNames = new Set(
952
- variablesResponse.variables.map((v) => {
953
- return v.name;
954
- })
955
- );
956
- const guaranteedConnectorProvidedSecretNames = guaranteedConnectorProvidedBindingNames({
957
- bindings: connectorsResponse.connectorProvidedBindings,
958
- namespace: "secrets"
959
- });
960
- const guaranteedConnectorProvidedVarNames = guaranteedConnectorProvidedBindingNames({
961
- bindings: connectorsResponse.connectorProvidedBindings,
962
- namespace: "vars"
963
- });
964
- const missingSecrets = [...requiredSecrets].filter((name) => {
965
- return !existingSecretNames.has(name) && !guaranteedConnectorProvidedSecretNames.has(name);
966
- });
967
- const missingVars = [...requiredVars].filter((name) => {
968
- return !existingVarNames.has(name) && !guaranteedConnectorProvidedVarNames.has(name);
969
- });
970
- if (missingSecrets.length === 0 && missingVars.length === 0) {
971
- return { missingSecrets: [], missingVars: [] };
972
- }
973
- if (!options.json) {
974
- console.log();
975
- console.log(source_default.yellow("\u26A0 Missing secrets/variables detected:"));
976
- if (missingSecrets.length > 0) {
977
- console.log(source_default.yellow(` Secrets: ${missingSecrets.join(", ")}`));
978
- }
979
- if (missingVars.length > 0) {
980
- console.log(source_default.yellow(` Variables: ${missingVars.join(", ")}`));
981
- }
982
- console.log();
983
- }
984
- return { missingSecrets, missingVars };
985
- }
986
- async function finalizeCompose(config, agent, options) {
987
- if (!options.json) {
988
- console.log("Uploading compose...");
989
- }
990
- const contentToPost = stripSkillsFromAgents(config);
991
- const response = await createOrUpdateCompose({ content: contentToPost });
992
- const shortVersionId = response.versionId.slice(0, 8);
993
- const displayName = response.name;
994
- const result = {
995
- composeId: response.composeId,
996
- composeName: response.name,
997
- versionId: response.versionId,
998
- action: response.action,
999
- displayName
1000
- };
1001
- if (!options.json) {
1002
- const missingItems = await checkAndPromptMissingItems(config, options);
1003
- if (missingItems.missingSecrets.length > 0 || missingItems.missingVars.length > 0) {
1004
- result.missingSecrets = missingItems.missingSecrets;
1005
- result.missingVars = missingItems.missingVars;
1006
- }
1007
- }
1008
- if (!options.json) {
1009
- if (response.action === "created") {
1010
- console.log(source_default.green(`\u2713 Compose created: ${displayName}`));
1011
- } else {
1012
- console.log(source_default.green(`\u2713 Compose version exists: ${displayName}`));
1013
- }
1014
- console.log(source_default.dim(` Version: ${shortVersionId}`));
1015
- console.log();
1016
- console.log(" Run your agent:");
1017
- console.log(
1018
- source_default.cyan(
1019
- ` vm0 run ${displayName}:${shortVersionId} --artifact <artifact> "your prompt"`
1020
- )
1021
- );
1022
- }
1023
- if (options.autoUpdate !== false) {
1024
- await waitForSilentUpgrade();
1025
- }
1026
- return result;
1027
- }
1028
- var composeCommand = new Command().name("compose").description("Create or update agent compose (e.g., vm0.yaml)").argument(
1029
- "[agent-yaml]",
1030
- `Path to agent YAML file (default: ${DEFAULT_CONFIG_FILE})`
1031
- ).option("-y, --yes", "Skip confirmation prompts").option(
1032
- "--experimental-shared-compose",
1033
- "[deprecated] No longer required, kept for backward compatibility"
1034
- ).option("--json", "Output JSON for scripts (suppresses interactive output)").option(
1035
- "--porcelain",
1036
- "[deprecated: use --json] Output JSON for scripts",
1037
- false
1038
- ).addOption(new Option("--no-auto-update").hideHelp()).action(
1039
- withErrorHandler(
1040
- async (configFile, options) => {
1041
- const resolvedConfigFile = configFile ?? DEFAULT_CONFIG_FILE;
1042
- if (options.porcelain && !options.json) {
1043
- console.error(
1044
- source_default.yellow("\u26A0 --porcelain is deprecated, use --json instead")
1045
- );
1046
- options.json = true;
1047
- }
1048
- if (options.json) {
1049
- options.yes = true;
1050
- options.autoUpdate = false;
1051
- }
1052
- if (options.autoUpdate !== false) {
1053
- await startSilentUpgrade("9.244.6");
1054
- }
1055
- try {
1056
- const { config, agentName, agent, basePath } = await loadAndValidateConfig(resolvedConfigFile);
1057
- await uploadInstructionsIfPresent(
1058
- agentName,
1059
- agent,
1060
- basePath,
1061
- options.json
1062
- );
1063
- const result = await finalizeCompose(config, agent, options);
1064
- if (options.json) {
1065
- console.log(JSON.stringify(result));
1066
- }
1067
- } catch (error) {
1068
- if (options.json) {
1069
- const message = error instanceof Error ? error.message : "An unexpected error occurred";
1070
- console.log(JSON.stringify({ error: message }));
1071
- process.exit(1);
1072
- }
1073
- throw error;
1074
- }
1075
- }
1076
- )
1077
- );
1078
-
1079
- // src/commands/run/index.ts
1080
- init_esm_shims();
1081
-
1082
369
  // src/commands/run/run.ts
1083
- init_esm_shims();
1084
370
  function parseModelProviderType(value) {
1085
371
  if (value === void 0) {
1086
372
  return void 0;
@@ -1147,7 +433,7 @@ var mainRunCommand = new Command().name("run").description("Run an agent").argum
1147
433
  withErrorHandler(
1148
434
  async (identifier, prompt, options) => {
1149
435
  if (options.autoUpdate !== false) {
1150
- await startSilentUpgrade("9.244.6");
436
+ await startSilentUpgrade("9.244.8");
1151
437
  }
1152
438
  const { name, version } = parseIdentifier(identifier);
1153
439
  let composeId;
@@ -1159,11 +445,7 @@ var mainRunCommand = new Command().name("run").description("Run an agent").argum
1159
445
  } else {
1160
446
  const compose = await getComposeByName(name);
1161
447
  if (!compose) {
1162
- throw new Error(`Agent not found: ${identifier}`, {
1163
- cause: new Error(
1164
- "Make sure you've composed the agent with: vm0 compose"
1165
- )
1166
- });
448
+ throw new Error(`Agent not found: ${identifier}`);
1167
449
  }
1168
450
  composeId = compose.id;
1169
451
  composeContent = compose.content;
@@ -1682,9 +964,8 @@ var whoamiCommand = new Command().name("whoami").description("Show current ident
1682
964
 
1683
965
  // src/index.ts
1684
966
  var program = new Command();
1685
- program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.244.6");
967
+ program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.244.8");
1686
968
  program.addCommand(authCommand);
1687
- program.addCommand(composeCommand);
1688
969
  program.addCommand(runCommand);
1689
970
  program.addCommand(whoamiCommand);
1690
971
  if (process.argv[1]?.endsWith("index.js") || process.argv[1]?.endsWith("index.ts") || process.argv[1]?.endsWith("vm0")) {