@vm0/cli 9.59.1 → 9.59.2

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 +198 -195
  2. package/package.json +1 -1
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.59.1",
48
+ release: "9.59.2",
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.59.1",
67
+ version: "9.59.2",
68
68
  command: process.argv.slice(2).join(" ")
69
69
  });
70
70
  Sentry.setContext("runtime", {
@@ -673,7 +673,7 @@ function getConfigPath() {
673
673
  return join2(homedir2(), ".vm0", "config.json");
674
674
  }
675
675
  var infoCommand = new Command6().name("info").description("Display environment and debug information").action(async () => {
676
- console.log(chalk4.bold(`VM0 CLI v${"9.59.1"}`));
676
+ console.log(chalk4.bold(`VM0 CLI v${"9.59.2"}`));
677
677
  console.log();
678
678
  const config = await loadConfig();
679
679
  const hasEnvToken = !!process.env.VM0_TOKEN;
@@ -1227,7 +1227,8 @@ var ALL_RUN_STATUSES = [
1227
1227
  "running",
1228
1228
  "completed",
1229
1229
  "failed",
1230
- "timeout"
1230
+ "timeout",
1231
+ "cancelled"
1231
1232
  ];
1232
1233
  var runStatusSchema = z5.enum(ALL_RUN_STATUSES);
1233
1234
  var unifiedRunRequestSchema = z5.object({
@@ -7005,6 +7006,191 @@ function getServiceConfig(type2) {
7005
7006
  return { ...config, name: type2 };
7006
7007
  }
7007
7008
 
7009
+ // ../../packages/core/src/contracts/service-expander.ts
7010
+ var VALID_RULE_METHODS = /* @__PURE__ */ new Set([
7011
+ "GET",
7012
+ "POST",
7013
+ "PUT",
7014
+ "PATCH",
7015
+ "DELETE",
7016
+ "HEAD",
7017
+ "OPTIONS",
7018
+ "ANY"
7019
+ ]);
7020
+ function validateRule(rule, permName, serviceName) {
7021
+ const parts = rule.split(" ", 2);
7022
+ if (parts.length !== 2 || !parts[1]) {
7023
+ throw new Error(
7024
+ `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": must be "METHOD /path"`
7025
+ );
7026
+ }
7027
+ const [method, path18] = parts;
7028
+ if (!VALID_RULE_METHODS.has(method)) {
7029
+ throw new Error(
7030
+ `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": unknown method "${method}" (must be uppercase)`
7031
+ );
7032
+ }
7033
+ if (!path18.startsWith("/")) {
7034
+ throw new Error(
7035
+ `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": path must start with "/"`
7036
+ );
7037
+ }
7038
+ if (path18.includes("?") || path18.includes("#")) {
7039
+ throw new Error(
7040
+ `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": path must not contain query string or fragment`
7041
+ );
7042
+ }
7043
+ const segments = path18.split("/").filter(Boolean);
7044
+ const paramNames = /* @__PURE__ */ new Set();
7045
+ for (let i = 0; i < segments.length; i++) {
7046
+ const seg = segments[i];
7047
+ if (seg.startsWith("{") && seg.endsWith("}")) {
7048
+ const name = seg.slice(1, -1);
7049
+ const baseName = name.endsWith("+") ? name.slice(0, -1) : name;
7050
+ if (!baseName) {
7051
+ throw new Error(
7052
+ `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": empty parameter name`
7053
+ );
7054
+ }
7055
+ if (paramNames.has(baseName)) {
7056
+ throw new Error(
7057
+ `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": duplicate parameter name "{${baseName}}"`
7058
+ );
7059
+ }
7060
+ paramNames.add(baseName);
7061
+ if (name.endsWith("+") && i !== segments.length - 1) {
7062
+ throw new Error(
7063
+ `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": {${name}} must be the last segment`
7064
+ );
7065
+ }
7066
+ }
7067
+ }
7068
+ }
7069
+ function validateBaseUrl(base, serviceName) {
7070
+ let url;
7071
+ try {
7072
+ url = new URL(base);
7073
+ } catch {
7074
+ throw new Error(
7075
+ `Invalid base URL "${base}" in service "${serviceName}": not a valid URL`
7076
+ );
7077
+ }
7078
+ if (url.search) {
7079
+ throw new Error(
7080
+ `Invalid base URL "${base}" in service "${serviceName}": must not contain query string`
7081
+ );
7082
+ }
7083
+ if (url.hash) {
7084
+ throw new Error(
7085
+ `Invalid base URL "${base}" in service "${serviceName}": must not contain fragment`
7086
+ );
7087
+ }
7088
+ }
7089
+ function resolveServiceConfig(ref) {
7090
+ const parsed = connectorTypeSchema.safeParse(ref);
7091
+ if (!parsed.success) {
7092
+ throw new Error(
7093
+ `Cannot resolve service ref "${ref}": no built-in service with this name`
7094
+ );
7095
+ }
7096
+ const serviceConfig = getServiceConfig(parsed.data);
7097
+ if (!serviceConfig) {
7098
+ throw new Error(
7099
+ `Service ref "${ref}" resolved to "${parsed.data}" but it does not support proxy-side token replacement`
7100
+ );
7101
+ }
7102
+ return serviceConfig;
7103
+ }
7104
+ function collectAndValidatePermissions(ref, serviceConfig) {
7105
+ if (serviceConfig.apis.length === 0) {
7106
+ throw new Error(
7107
+ `Service "${serviceConfig.name}" (ref "${ref}") has no api entries`
7108
+ );
7109
+ }
7110
+ const available = /* @__PURE__ */ new Set();
7111
+ for (const api2 of serviceConfig.apis) {
7112
+ validateBaseUrl(api2.base, serviceConfig.name);
7113
+ if (!api2.permissions || api2.permissions.length === 0) {
7114
+ throw new Error(
7115
+ `API entry "${api2.base}" in service "${serviceConfig.name}" (ref "${ref}") has no permissions`
7116
+ );
7117
+ }
7118
+ const seen = /* @__PURE__ */ new Set();
7119
+ for (const perm of api2.permissions) {
7120
+ if (!perm.name) {
7121
+ throw new Error(
7122
+ `Service "${serviceConfig.name}" (ref "${ref}") has a permission with empty name`
7123
+ );
7124
+ }
7125
+ if (perm.name === "all") {
7126
+ throw new Error(
7127
+ `Service "${serviceConfig.name}" (ref "${ref}") has a permission named "all", which is a reserved keyword`
7128
+ );
7129
+ }
7130
+ if (seen.has(perm.name)) {
7131
+ throw new Error(
7132
+ `Duplicate permission name "${perm.name}" in API entry "${api2.base}" of service "${serviceConfig.name}" (ref "${ref}")`
7133
+ );
7134
+ }
7135
+ if (perm.rules.length === 0) {
7136
+ throw new Error(
7137
+ `Permission "${perm.name}" in service "${serviceConfig.name}" (ref "${ref}") has no rules`
7138
+ );
7139
+ }
7140
+ for (const rule of perm.rules) {
7141
+ validateRule(rule, perm.name, serviceConfig.name);
7142
+ }
7143
+ seen.add(perm.name);
7144
+ available.add(perm.name);
7145
+ }
7146
+ }
7147
+ return available;
7148
+ }
7149
+ function expandServiceConfigs(config) {
7150
+ const compose = config;
7151
+ if (!compose?.agents) return;
7152
+ for (const agent of Object.values(compose.agents)) {
7153
+ const services = agent.experimental_services;
7154
+ if (!services) continue;
7155
+ if (Array.isArray(services)) continue;
7156
+ const expanded = [];
7157
+ for (const [ref, selection] of Object.entries(services)) {
7158
+ const serviceConfig = resolveServiceConfig(ref);
7159
+ const availablePermissions = collectAndValidatePermissions(
7160
+ ref,
7161
+ serviceConfig
7162
+ );
7163
+ if (selection.permissions !== "all") {
7164
+ for (const name of selection.permissions) {
7165
+ if (!availablePermissions.has(name)) {
7166
+ const available = [...availablePermissions].join(", ");
7167
+ throw new Error(
7168
+ `Permission "${name}" does not exist in service "${serviceConfig.name}" (ref "${ref}"). Available: ${available}`
7169
+ );
7170
+ }
7171
+ }
7172
+ }
7173
+ const selectedSet = selection.permissions === "all" ? null : new Set(selection.permissions);
7174
+ const filteredApis = serviceConfig.apis.map((api2) => ({
7175
+ ...api2,
7176
+ permissions: selectedSet ? (api2.permissions ?? []).filter((p) => selectedSet.has(p.name)) : api2.permissions
7177
+ })).filter((api2) => (api2.permissions ?? []).length > 0);
7178
+ if (filteredApis.length === 0) continue;
7179
+ const entry = {
7180
+ name: serviceConfig.name,
7181
+ ref,
7182
+ apis: filteredApis
7183
+ };
7184
+ if (serviceConfig.description !== void 0)
7185
+ entry.description = serviceConfig.description;
7186
+ if (serviceConfig.placeholders !== void 0)
7187
+ entry.placeholders = serviceConfig.placeholders;
7188
+ expanded.push(entry);
7189
+ }
7190
+ agent.experimental_services = expanded;
7191
+ }
7192
+ }
7193
+
7008
7194
  // ../../packages/core/src/contracts/user-preferences.ts
7009
7195
  import { z as z21 } from "zod";
7010
7196
  var c19 = initContract();
@@ -9498,189 +9684,6 @@ function mergeSkillVariables(agent, variables) {
9498
9684
  agent.environment = environment;
9499
9685
  }
9500
9686
  }
9501
- function resolveServiceConfig(ref) {
9502
- const parsed = connectorTypeSchema.safeParse(ref);
9503
- if (!parsed.success) {
9504
- throw new Error(
9505
- `Cannot resolve service ref "${ref}": no built-in service with this name`
9506
- );
9507
- }
9508
- const serviceConfig = getServiceConfig(parsed.data);
9509
- if (!serviceConfig) {
9510
- throw new Error(
9511
- `Service ref "${ref}" resolved to "${parsed.data}" but it does not support proxy-side token replacement`
9512
- );
9513
- }
9514
- return serviceConfig;
9515
- }
9516
- var VALID_RULE_METHODS = /* @__PURE__ */ new Set([
9517
- "GET",
9518
- "POST",
9519
- "PUT",
9520
- "PATCH",
9521
- "DELETE",
9522
- "HEAD",
9523
- "OPTIONS",
9524
- "ANY"
9525
- ]);
9526
- function validateRule(rule, permName, serviceName) {
9527
- const parts = rule.split(" ", 2);
9528
- if (parts.length !== 2 || !parts[1]) {
9529
- throw new Error(
9530
- `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": must be "METHOD /path"`
9531
- );
9532
- }
9533
- const [method, path18] = parts;
9534
- if (!VALID_RULE_METHODS.has(method)) {
9535
- throw new Error(
9536
- `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": unknown method "${method}" (must be uppercase)`
9537
- );
9538
- }
9539
- if (!path18.startsWith("/")) {
9540
- throw new Error(
9541
- `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": path must start with "/"`
9542
- );
9543
- }
9544
- if (path18.includes("?") || path18.includes("#")) {
9545
- throw new Error(
9546
- `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": path must not contain query string or fragment`
9547
- );
9548
- }
9549
- const segments = path18.split("/").filter(Boolean);
9550
- const paramNames = /* @__PURE__ */ new Set();
9551
- for (let i = 0; i < segments.length; i++) {
9552
- const seg = segments[i];
9553
- if (seg.startsWith("{") && seg.endsWith("}")) {
9554
- const name = seg.slice(1, -1);
9555
- const baseName = name.endsWith("+") ? name.slice(0, -1) : name;
9556
- if (!baseName) {
9557
- throw new Error(
9558
- `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": empty parameter name`
9559
- );
9560
- }
9561
- if (paramNames.has(baseName)) {
9562
- throw new Error(
9563
- `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": duplicate parameter name "{${baseName}}"`
9564
- );
9565
- }
9566
- paramNames.add(baseName);
9567
- if (name.endsWith("+") && i !== segments.length - 1) {
9568
- throw new Error(
9569
- `Invalid rule "${rule}" in permission "${permName}" of service "${serviceName}": {${name}} must be the last segment`
9570
- );
9571
- }
9572
- }
9573
- }
9574
- }
9575
- function validateBaseUrl(base, serviceName) {
9576
- let url;
9577
- try {
9578
- url = new URL(base);
9579
- } catch {
9580
- throw new Error(
9581
- `Invalid base URL "${base}" in service "${serviceName}": not a valid URL`
9582
- );
9583
- }
9584
- if (url.search) {
9585
- throw new Error(
9586
- `Invalid base URL "${base}" in service "${serviceName}": must not contain query string`
9587
- );
9588
- }
9589
- if (url.hash) {
9590
- throw new Error(
9591
- `Invalid base URL "${base}" in service "${serviceName}": must not contain fragment`
9592
- );
9593
- }
9594
- }
9595
- function collectAndValidatePermissions(ref, serviceConfig) {
9596
- if (serviceConfig.apis.length === 0) {
9597
- throw new Error(
9598
- `Service "${serviceConfig.name}" (ref "${ref}") has no api entries`
9599
- );
9600
- }
9601
- const available = /* @__PURE__ */ new Set();
9602
- for (const api2 of serviceConfig.apis) {
9603
- validateBaseUrl(api2.base, serviceConfig.name);
9604
- if (!api2.permissions || api2.permissions.length === 0) {
9605
- throw new Error(
9606
- `API entry "${api2.base}" in service "${serviceConfig.name}" (ref "${ref}") has no permissions`
9607
- );
9608
- }
9609
- const seen = /* @__PURE__ */ new Set();
9610
- for (const perm of api2.permissions) {
9611
- if (!perm.name) {
9612
- throw new Error(
9613
- `Service "${serviceConfig.name}" (ref "${ref}") has a permission with empty name`
9614
- );
9615
- }
9616
- if (perm.name === "all") {
9617
- throw new Error(
9618
- `Service "${serviceConfig.name}" (ref "${ref}") has a permission named "all", which is a reserved keyword`
9619
- );
9620
- }
9621
- if (seen.has(perm.name)) {
9622
- throw new Error(
9623
- `Duplicate permission name "${perm.name}" in API entry "${api2.base}" of service "${serviceConfig.name}" (ref "${ref}")`
9624
- );
9625
- }
9626
- if (perm.rules.length === 0) {
9627
- throw new Error(
9628
- `Permission "${perm.name}" in service "${serviceConfig.name}" (ref "${ref}") has no rules`
9629
- );
9630
- }
9631
- for (const rule of perm.rules) {
9632
- validateRule(rule, perm.name, serviceConfig.name);
9633
- }
9634
- seen.add(perm.name);
9635
- available.add(perm.name);
9636
- }
9637
- }
9638
- return available;
9639
- }
9640
- function expandServiceConfigs(config) {
9641
- const compose = config;
9642
- if (!compose?.agents) return;
9643
- for (const agent of Object.values(compose.agents)) {
9644
- const services = agent.experimental_services;
9645
- if (!services) continue;
9646
- if (Array.isArray(services)) continue;
9647
- const expanded = [];
9648
- for (const [ref, selection] of Object.entries(services)) {
9649
- const serviceConfig = resolveServiceConfig(ref);
9650
- const availablePermissions = collectAndValidatePermissions(
9651
- ref,
9652
- serviceConfig
9653
- );
9654
- if (selection.permissions !== "all") {
9655
- for (const name of selection.permissions) {
9656
- if (!availablePermissions.has(name)) {
9657
- const available = [...availablePermissions].join(", ");
9658
- throw new Error(
9659
- `Permission "${name}" does not exist in service "${serviceConfig.name}" (ref "${ref}"). Available: ${available}`
9660
- );
9661
- }
9662
- }
9663
- }
9664
- const selectedSet = selection.permissions === "all" ? null : new Set(selection.permissions);
9665
- const filteredApis = serviceConfig.apis.map((api2) => ({
9666
- ...api2,
9667
- permissions: selectedSet ? (api2.permissions ?? []).filter((p) => selectedSet.has(p.name)) : api2.permissions
9668
- })).filter((api2) => (api2.permissions ?? []).length > 0);
9669
- if (filteredApis.length === 0) continue;
9670
- const entry = {
9671
- name: serviceConfig.name,
9672
- ref,
9673
- apis: filteredApis
9674
- };
9675
- if (serviceConfig.description !== void 0)
9676
- entry.description = serviceConfig.description;
9677
- if (serviceConfig.placeholders !== void 0)
9678
- entry.placeholders = serviceConfig.placeholders;
9679
- expanded.push(entry);
9680
- }
9681
- agent.experimental_services = expanded;
9682
- }
9683
- }
9684
9687
  function getPlatformUrl(apiUrl) {
9685
9688
  const url = new URL(apiUrl);
9686
9689
  url.hostname = url.hostname.replace("www", "platform");
@@ -9883,7 +9886,7 @@ var composeCommand = new Command7().name("compose").description("Create or updat
9883
9886
  options.autoUpdate = false;
9884
9887
  }
9885
9888
  if (options.autoUpdate !== false) {
9886
- await startSilentUpgrade("9.59.1");
9889
+ await startSilentUpgrade("9.59.2");
9887
9890
  }
9888
9891
  try {
9889
9892
  let result;
@@ -11057,7 +11060,7 @@ var mainRunCommand = new Command8().name("run").description("Run an agent").argu
11057
11060
  withErrorHandler(
11058
11061
  async (identifier, prompt, options) => {
11059
11062
  if (options.autoUpdate !== false) {
11060
- await startSilentUpgrade("9.59.1");
11063
+ await startSilentUpgrade("9.59.2");
11061
11064
  }
11062
11065
  const { org, name, version } = parseIdentifier(identifier);
11063
11066
  if (org && !options.experimentalSharedAgent) {
@@ -12744,7 +12747,7 @@ var cookAction = new Command34().name("cook").description("Quick start: prepare,
12744
12747
  withErrorHandler(
12745
12748
  async (prompt, options) => {
12746
12749
  if (options.autoUpdate !== false) {
12747
- const shouldExit = await checkAndUpgrade("9.59.1", prompt);
12750
+ const shouldExit = await checkAndUpgrade("9.59.2", prompt);
12748
12751
  if (shouldExit) {
12749
12752
  process.exit(0);
12750
12753
  }
@@ -18095,13 +18098,13 @@ var upgradeCommand = new Command90().name("upgrade").description("Upgrade vm0 CL
18095
18098
  if (latestVersion === null) {
18096
18099
  throw new Error("Could not check for updates. Please try again later.");
18097
18100
  }
18098
- if (latestVersion === "9.59.1") {
18099
- console.log(chalk84.green(`\u2713 Already up to date (${"9.59.1"})`));
18101
+ if (latestVersion === "9.59.2") {
18102
+ console.log(chalk84.green(`\u2713 Already up to date (${"9.59.2"})`));
18100
18103
  return;
18101
18104
  }
18102
18105
  console.log(
18103
18106
  chalk84.yellow(
18104
- `Current version: ${"9.59.1"} -> Latest version: ${latestVersion}`
18107
+ `Current version: ${"9.59.2"} -> Latest version: ${latestVersion}`
18105
18108
  )
18106
18109
  );
18107
18110
  console.log();
@@ -18128,7 +18131,7 @@ var upgradeCommand = new Command90().name("upgrade").description("Upgrade vm0 CL
18128
18131
  const success = await performUpgrade(packageManager);
18129
18132
  if (success) {
18130
18133
  console.log(
18131
- chalk84.green(`\u2713 Upgraded from ${"9.59.1"} to ${latestVersion}`)
18134
+ chalk84.green(`\u2713 Upgraded from ${"9.59.2"} to ${latestVersion}`)
18132
18135
  );
18133
18136
  return;
18134
18137
  }
@@ -18142,7 +18145,7 @@ var upgradeCommand = new Command90().name("upgrade").description("Upgrade vm0 CL
18142
18145
 
18143
18146
  // src/index.ts
18144
18147
  var program = new Command91();
18145
- program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.59.1");
18148
+ program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.59.2");
18146
18149
  program.addCommand(authCommand);
18147
18150
  program.addCommand(infoCommand);
18148
18151
  program.addCommand(composeCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm0/cli",
3
- "version": "9.59.1",
3
+ "version": "9.59.2",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",