@vm0/cli 9.57.1 → 9.58.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +144 -43
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -45,7 +45,7 @@ if (DSN) {
45
45
  Sentry.init({
46
46
  dsn: DSN,
47
47
  environment: process.env.SENTRY_ENVIRONMENT ?? "production",
48
- release: "9.57.1",
48
+ release: "9.58.1",
49
49
  sendDefaultPii: false,
50
50
  tracesSampleRate: 0,
51
51
  shutdownTimeout: 500,
@@ -64,7 +64,7 @@ if (DSN) {
64
64
  }
65
65
  });
66
66
  Sentry.setContext("cli", {
67
- version: "9.57.1",
67
+ version: "9.58.1",
68
68
  command: process.argv.slice(2).join(" ")
69
69
  });
70
70
  Sentry.setContext("runtime", {
@@ -198,6 +198,13 @@ async function getApiUrl() {
198
198
  }
199
199
  return config.apiUrl ?? "https://www.vm0.ai";
200
200
  }
201
+ async function getActiveOrg() {
202
+ if (process.env.VM0_ACTIVE_ORG) {
203
+ return process.env.VM0_ACTIVE_ORG;
204
+ }
205
+ const config = await loadConfig();
206
+ return config.activeOrg;
207
+ }
201
208
  async function clearConfig() {
202
209
  const configFile = getConfigFile();
203
210
  if (existsSync(configFile)) {
@@ -271,7 +278,8 @@ The code expires in ${Math.floor(deviceAuth.expires_in / 60)} minutes.`
271
278
  if (tokenResult.access_token) {
272
279
  await saveConfig({
273
280
  token: tokenResult.access_token,
274
- apiUrl: targetApiUrl
281
+ apiUrl: targetApiUrl,
282
+ ...tokenResult.org_slug && { activeOrg: tokenResult.org_slug }
275
283
  });
276
284
  console.log(chalk.green("\nAuthentication successful!"));
277
285
  console.log("Your credentials have been saved");
@@ -371,8 +379,7 @@ async function getBaseUrl() {
371
379
  async function getClientConfig() {
372
380
  const baseUrl = await getBaseUrl();
373
381
  const baseHeaders = await getHeaders();
374
- const config = await loadConfig();
375
- const activeOrg = config.activeOrg;
382
+ const activeOrg = await getActiveOrg();
376
383
  if (activeOrg) {
377
384
  return {
378
385
  baseUrl,
@@ -666,7 +673,7 @@ function getConfigPath() {
666
673
  return join2(homedir2(), ".vm0", "config.json");
667
674
  }
668
675
  var infoCommand = new Command6().name("info").description("Display environment and debug information").action(async () => {
669
- console.log(chalk4.bold(`VM0 CLI v${"9.57.1"}`));
676
+ console.log(chalk4.bold(`VM0 CLI v${"9.58.1"}`));
670
677
  console.log();
671
678
  const config = await loadConfig();
672
679
  const hasEnvToken = !!process.env.VM0_TOKEN;
@@ -2209,7 +2216,8 @@ var cliAuthTokenContract = c6.router({
2209
2216
  200: z8.object({
2210
2217
  access_token: z8.string(),
2211
2218
  token_type: z8.literal("Bearer"),
2212
- expires_in: z8.number()
2219
+ expires_in: z8.number(),
2220
+ org_slug: z8.string().optional()
2213
2221
  }),
2214
2222
  // Authorization pending
2215
2223
  202: oauthErrorSchema,
@@ -6832,29 +6840,13 @@ var SERVICE_CONFIGS = {
6832
6840
  apis: [api("https://plausible.io/api", bearerAuth("PLAUSIBLE_TOKEN"))]
6833
6841
  },
6834
6842
  mailchimp: {
6835
- apis: [
6836
- api("https://us1.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6837
- api("https://us2.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6838
- api("https://us3.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6839
- api("https://us4.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6840
- api("https://us5.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6841
- api("https://us6.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6842
- api("https://us7.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6843
- api("https://us8.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6844
- api("https://us9.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6845
- api("https://us10.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6846
- api("https://us11.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6847
- api("https://us12.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6848
- api("https://us13.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6849
- api("https://us14.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6850
- api("https://us15.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6851
- api("https://us16.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6852
- api("https://us17.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6853
- api("https://us18.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6854
- api("https://us19.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6855
- api("https://us20.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN")),
6856
- api("https://us21.api.mailchimp.com/3.0", bearerAuth("MAILCHIMP_TOKEN"))
6857
- ]
6843
+ apis: Array.from(
6844
+ { length: 21 },
6845
+ (_, i) => api(
6846
+ `https://us${i + 1}.api.mailchimp.com/3.0`,
6847
+ bearerAuth("MAILCHIMP_TOKEN")
6848
+ )
6849
+ )
6858
6850
  },
6859
6851
  chatwoot: {
6860
6852
  apis: [api("https://app.chatwoot.com", bearerAuth("CHATWOOT_TOKEN"))]
@@ -7705,8 +7697,7 @@ ${block}
7705
7697
 
7706
7698
  // src/lib/api/core/http.ts
7707
7699
  async function appendOrgParam(path18) {
7708
- const config = await loadConfig();
7709
- const activeOrg = config.activeOrg;
7700
+ const activeOrg = await getActiveOrg();
7710
7701
  if (!activeOrg) {
7711
7702
  return path18;
7712
7703
  }
@@ -9428,15 +9419,125 @@ function resolveServiceConfig(ref) {
9428
9419
  }
9429
9420
  return serviceConfig;
9430
9421
  }
9422
+ var VALID_RULE_METHODS = /* @__PURE__ */ new Set([
9423
+ "GET",
9424
+ "POST",
9425
+ "PUT",
9426
+ "PATCH",
9427
+ "DELETE",
9428
+ "HEAD",
9429
+ "OPTIONS",
9430
+ "ANY"
9431
+ ]);
9432
+ function validateRule(rule, permName, serviceName) {
9433
+ const parts = rule.split(" ", 2);
9434
+ if (parts.length !== 2 || !parts[1]) {
9435
+ throw new Error(
9436
+ `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": must be "METHOD /path"`
9437
+ );
9438
+ }
9439
+ const [method, path18] = parts;
9440
+ if (!VALID_RULE_METHODS.has(method)) {
9441
+ throw new Error(
9442
+ `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": unknown method "${method}" (must be uppercase)`
9443
+ );
9444
+ }
9445
+ if (!path18.startsWith("/")) {
9446
+ throw new Error(
9447
+ `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": path must start with "/"`
9448
+ );
9449
+ }
9450
+ if (path18.includes("?") || path18.includes("#")) {
9451
+ throw new Error(
9452
+ `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": path must not contain query string or fragment`
9453
+ );
9454
+ }
9455
+ const segments = path18.split("/").filter(Boolean);
9456
+ const paramNames = /* @__PURE__ */ new Set();
9457
+ for (let i = 0; i < segments.length; i++) {
9458
+ const seg = segments[i];
9459
+ if (seg.startsWith("{") && seg.endsWith("}")) {
9460
+ const name = seg.slice(1, -1);
9461
+ const baseName = name.endsWith("+") ? name.slice(0, -1) : name;
9462
+ if (!baseName) {
9463
+ throw new Error(
9464
+ `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": empty parameter name`
9465
+ );
9466
+ }
9467
+ if (paramNames.has(baseName)) {
9468
+ throw new Error(
9469
+ `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": duplicate parameter name "{${baseName}}"`
9470
+ );
9471
+ }
9472
+ paramNames.add(baseName);
9473
+ if (name.endsWith("+") && i !== segments.length - 1) {
9474
+ throw new Error(
9475
+ `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": {${name}} must be the last segment`
9476
+ );
9477
+ }
9478
+ }
9479
+ }
9480
+ }
9481
+ function validateBaseUrl(base, serviceName) {
9482
+ let url;
9483
+ try {
9484
+ url = new URL(base);
9485
+ } catch {
9486
+ throw new Error(
9487
+ `Invalid base URL "${base}" in service "${serviceName}": not a valid URL`
9488
+ );
9489
+ }
9490
+ if (url.search) {
9491
+ throw new Error(
9492
+ `Invalid base URL "${base}" in service "${serviceName}": must not contain query string`
9493
+ );
9494
+ }
9495
+ if (url.hash) {
9496
+ throw new Error(
9497
+ `Invalid base URL "${base}" in service "${serviceName}": must not contain fragment`
9498
+ );
9499
+ }
9500
+ }
9431
9501
  function collectAndValidatePermissions(ref, serviceConfig) {
9502
+ if (serviceConfig.apis.length === 0) {
9503
+ throw new Error(
9504
+ `Service "${serviceConfig.name}" (ref "${ref}") has no api entries`
9505
+ );
9506
+ }
9432
9507
  const available = /* @__PURE__ */ new Set();
9433
9508
  for (const api2 of serviceConfig.apis) {
9434
- for (const perm of api2.permissions ?? []) {
9509
+ validateBaseUrl(api2.base, serviceConfig.name);
9510
+ if (!api2.permissions || api2.permissions.length === 0) {
9511
+ throw new Error(
9512
+ `API entry "${api2.base}" in service "${serviceConfig.name}" (ref "${ref}") has no permissions`
9513
+ );
9514
+ }
9515
+ const seen = /* @__PURE__ */ new Set();
9516
+ for (const perm of api2.permissions) {
9517
+ if (!perm.name) {
9518
+ throw new Error(
9519
+ `Service "${serviceConfig.name}" (ref "${ref}") has a permission with empty name`
9520
+ );
9521
+ }
9435
9522
  if (perm.name === "all") {
9436
9523
  throw new Error(
9437
9524
  `Service "${serviceConfig.name}" (ref "${ref}") has a permission named "all", which is a reserved keyword`
9438
9525
  );
9439
9526
  }
9527
+ if (seen.has(perm.name)) {
9528
+ throw new Error(
9529
+ `Duplicate permission name "${perm.name}" in API entry "${api2.base}" of service "${serviceConfig.name}" (ref "${ref}")`
9530
+ );
9531
+ }
9532
+ if (perm.rules.length === 0) {
9533
+ throw new Error(
9534
+ `Permission "${perm.name}" in service "${serviceConfig.name}" (ref "${ref}") has no rules`
9535
+ );
9536
+ }
9537
+ for (const rule of perm.rules) {
9538
+ validateRule(rule, perm.name, serviceConfig.name);
9539
+ }
9540
+ seen.add(perm.name);
9440
9541
  available.add(perm.name);
9441
9542
  }
9442
9543
  }
@@ -9686,7 +9787,7 @@ var composeCommand = new Command7().name("compose").description("Create or updat
9686
9787
  options.autoUpdate = false;
9687
9788
  }
9688
9789
  if (options.autoUpdate !== false) {
9689
- await startSilentUpgrade("9.57.1");
9790
+ await startSilentUpgrade("9.58.1");
9690
9791
  }
9691
9792
  try {
9692
9793
  let result;
@@ -10859,7 +10960,7 @@ var mainRunCommand = new Command8().name("run").description("Run an agent").argu
10859
10960
  withErrorHandler(
10860
10961
  async (identifier, prompt, options) => {
10861
10962
  if (options.autoUpdate !== false) {
10862
- await startSilentUpgrade("9.57.1");
10963
+ await startSilentUpgrade("9.58.1");
10863
10964
  }
10864
10965
  const { org, name, version } = parseIdentifier(identifier);
10865
10966
  if (org && !options.experimentalSharedAgent) {
@@ -12546,7 +12647,7 @@ var cookAction = new Command34().name("cook").description("Quick start: prepare,
12546
12647
  withErrorHandler(
12547
12648
  async (prompt, options) => {
12548
12649
  if (options.autoUpdate !== false) {
12549
- const shouldExit = await checkAndUpgrade("9.57.1", prompt);
12650
+ const shouldExit = await checkAndUpgrade("9.58.1", prompt);
12550
12651
  if (shouldExit) {
12551
12652
  process.exit(0);
12552
12653
  }
@@ -13863,6 +13964,7 @@ var setCommand = new Command41().name("set").description("Rename your organizati
13863
13964
  );
13864
13965
  }
13865
13966
  const org = await updateOrg({ slug, force: true });
13967
+ await saveConfig({ activeOrg: org.slug });
13866
13968
  console.log(chalk37.green(`\u2713 Organization updated to ${org.slug}`));
13867
13969
  console.log();
13868
13970
  console.log("Your agents will now be namespaced as:");
@@ -13884,8 +13986,7 @@ import chalk38 from "chalk";
13884
13986
  var listCommand5 = new Command42().name("list").description("List all accessible organizations").action(
13885
13987
  withErrorHandler(async () => {
13886
13988
  const result = await listOrgs();
13887
- const config = await loadConfig();
13888
- const activeOrg = config.activeOrg;
13989
+ const activeOrg = await getActiveOrg();
13889
13990
  console.log(chalk38.bold("Available organizations:"));
13890
13991
  for (const org of result.orgs) {
13891
13992
  const isCurrent = org.slug === activeOrg;
@@ -17897,13 +17998,13 @@ var upgradeCommand = new Command90().name("upgrade").description("Upgrade vm0 CL
17897
17998
  if (latestVersion === null) {
17898
17999
  throw new Error("Could not check for updates. Please try again later.");
17899
18000
  }
17900
- if (latestVersion === "9.57.1") {
17901
- console.log(chalk83.green(`\u2713 Already up to date (${"9.57.1"})`));
18001
+ if (latestVersion === "9.58.1") {
18002
+ console.log(chalk83.green(`\u2713 Already up to date (${"9.58.1"})`));
17902
18003
  return;
17903
18004
  }
17904
18005
  console.log(
17905
18006
  chalk83.yellow(
17906
- `Current version: ${"9.57.1"} -> Latest version: ${latestVersion}`
18007
+ `Current version: ${"9.58.1"} -> Latest version: ${latestVersion}`
17907
18008
  )
17908
18009
  );
17909
18010
  console.log();
@@ -17930,7 +18031,7 @@ var upgradeCommand = new Command90().name("upgrade").description("Upgrade vm0 CL
17930
18031
  const success = await performUpgrade(packageManager);
17931
18032
  if (success) {
17932
18033
  console.log(
17933
- chalk83.green(`\u2713 Upgraded from ${"9.57.1"} to ${latestVersion}`)
18034
+ chalk83.green(`\u2713 Upgraded from ${"9.58.1"} to ${latestVersion}`)
17934
18035
  );
17935
18036
  return;
17936
18037
  }
@@ -17944,7 +18045,7 @@ var upgradeCommand = new Command90().name("upgrade").description("Upgrade vm0 CL
17944
18045
 
17945
18046
  // src/index.ts
17946
18047
  var program = new Command91();
17947
- program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.57.1");
18048
+ program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.58.1");
17948
18049
  program.addCommand(authCommand);
17949
18050
  program.addCommand(infoCommand);
17950
18051
  program.addCommand(composeCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm0/cli",
3
- "version": "9.57.1",
3
+ "version": "9.58.1",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "dotenv": "^17.2.1",
24
24
  "prompts": "^2.4.2",
25
25
  "tar": "^7.5.7",
26
- "undici": "^6.23.0",
26
+ "undici": "^6.24.0",
27
27
  "yaml": "^2.3.4",
28
28
  "zod": "^4.3.6"
29
29
  }