@vm0/cli 8.0.2 → 8.1.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.
Files changed (2) hide show
  1. package/index.js +90 -74
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1609,13 +1609,11 @@ var scopeResponseSchema = z12.object({
1609
1609
  id: z12.string().uuid(),
1610
1610
  slug: z12.string(),
1611
1611
  type: scopeTypeSchema,
1612
- displayName: z12.string().nullable(),
1613
1612
  createdAt: z12.string(),
1614
1613
  updatedAt: z12.string()
1615
1614
  });
1616
1615
  var createScopeRequestSchema = z12.object({
1617
- slug: scopeSlugSchema,
1618
- displayName: z12.string().max(128).optional()
1616
+ slug: scopeSlugSchema
1619
1617
  });
1620
1618
  var updateScopeRequestSchema = z12.object({
1621
1619
  slug: scopeSlugSchema,
@@ -2976,6 +2974,13 @@ var FEATURE_SWITCHES = {
2976
2974
  };
2977
2975
 
2978
2976
  // src/lib/api/core/client-factory.ts
2977
+ var ApiRequestError = class extends Error {
2978
+ constructor(message, code) {
2979
+ super(message);
2980
+ this.code = code;
2981
+ this.name = "ApiRequestError";
2982
+ }
2983
+ };
2979
2984
  async function getHeaders() {
2980
2985
  const token = await getToken();
2981
2986
  if (!token) {
@@ -3005,7 +3010,8 @@ async function getClientConfig() {
3005
3010
  function handleError(result, defaultMessage) {
3006
3011
  const errorBody = result.body;
3007
3012
  const message = errorBody.error?.message || defaultMessage;
3008
- throw new Error(message);
3013
+ const code = errorBody.error?.code || "UNKNOWN";
3014
+ throw new ApiRequestError(message, code);
3009
3015
  }
3010
3016
 
3011
3017
  // src/lib/api/core/http.ts
@@ -7863,7 +7869,7 @@ cookCmd.argument("[prompt]", "Prompt for the agent").option(
7863
7869
  // eslint-disable-next-line complexity -- TODO: refactor complex function
7864
7870
  async (prompt, options) => {
7865
7871
  if (!options.noAutoUpdate) {
7866
- const shouldExit = await checkAndUpgrade("8.0.2", prompt);
7872
+ const shouldExit = await checkAndUpgrade("8.1.0", prompt);
7867
7873
  if (shouldExit) {
7868
7874
  process.exit(0);
7869
7875
  }
@@ -8462,9 +8468,6 @@ var statusCommand3 = new Command21().name("status").description("View current sc
8462
8468
  console.log(chalk26.bold("Scope Information:"));
8463
8469
  console.log(` Slug: ${chalk26.green(scope.slug)}`);
8464
8470
  console.log(` Type: ${scope.type}`);
8465
- if (scope.displayName) {
8466
- console.log(` Display Name: ${scope.displayName}`);
8467
- }
8468
8471
  console.log(
8469
8472
  ` Created: ${new Date(scope.createdAt).toLocaleDateString()}`
8470
8473
  );
@@ -8493,76 +8496,69 @@ var statusCommand3 = new Command21().name("status").description("View current sc
8493
8496
  // src/commands/scope/set.ts
8494
8497
  import { Command as Command22 } from "commander";
8495
8498
  import chalk27 from "chalk";
8496
- var setCommand = new Command22().name("set").description("Set your scope slug").argument("<slug>", "The scope slug (e.g., your username)").option("--force", "Force change existing scope (may break references)").option("--display-name <name>", "Display name for the scope").action(
8497
- async (slug, options) => {
8499
+ var setCommand = new Command22().name("set").description("Set your scope slug").argument("<slug>", "The scope slug (e.g., your username)").option("--force", "Force change existing scope (may break references)").action(async (slug, options) => {
8500
+ try {
8501
+ let existingScope;
8498
8502
  try {
8499
- let existingScope;
8500
- try {
8501
- existingScope = await getScope();
8502
- } catch (error) {
8503
- if (!(error instanceof Error) || !error.message.includes("No scope configured")) {
8504
- throw error;
8505
- }
8503
+ existingScope = await getScope();
8504
+ } catch (error) {
8505
+ if (!(error instanceof Error) || !error.message.includes("No scope configured")) {
8506
+ throw error;
8506
8507
  }
8507
- let scope;
8508
- if (existingScope) {
8509
- if (!options.force) {
8510
- console.error(
8511
- chalk27.yellow(`You already have a scope: ${existingScope.slug}`)
8512
- );
8513
- console.error();
8514
- console.error("To change your scope, use --force:");
8515
- console.error(chalk27.cyan(` vm0 scope set ${slug} --force`));
8516
- console.error();
8517
- console.error(
8518
- chalk27.yellow(
8519
- "Warning: Changing your scope may break existing agent references."
8520
- )
8521
- );
8522
- process.exit(1);
8523
- }
8524
- scope = await updateScope({ slug, force: true });
8525
- console.log(chalk27.green(`\u2713 Scope updated to ${scope.slug}`));
8526
- } else {
8527
- scope = await createScope({
8528
- slug,
8529
- displayName: options.displayName
8530
- });
8531
- console.log(chalk27.green(`\u2713 Scope created: ${scope.slug}`));
8508
+ }
8509
+ let scope;
8510
+ if (existingScope) {
8511
+ if (!options.force) {
8512
+ console.error(
8513
+ chalk27.yellow(`You already have a scope: ${existingScope.slug}`)
8514
+ );
8515
+ console.error();
8516
+ console.error("To change your scope, use --force:");
8517
+ console.error(chalk27.cyan(` vm0 scope set ${slug} --force`));
8518
+ console.error();
8519
+ console.error(
8520
+ chalk27.yellow(
8521
+ "Warning: Changing your scope may break existing agent references."
8522
+ )
8523
+ );
8524
+ process.exit(1);
8532
8525
  }
8533
- console.log();
8534
- console.log("Your agents will now be namespaced as:");
8535
- console.log(chalk27.cyan(` ${scope.slug}/<agent-name>`));
8536
- } catch (error) {
8537
- if (error instanceof Error) {
8538
- if (error.message.includes("Not authenticated")) {
8539
- console.error(
8540
- chalk27.red("\u2717 Not authenticated. Run: vm0 auth login")
8541
- );
8542
- } else if (error.message.includes("already exists")) {
8543
- console.error(
8544
- chalk27.red(
8545
- `\u2717 Scope "${slug}" is already taken. Please choose a different slug.`
8546
- )
8547
- );
8548
- } else if (error.message.includes("reserved")) {
8549
- console.error(chalk27.red(`\u2717 ${error.message}`));
8550
- } else if (error.message.includes("vm0")) {
8551
- console.error(
8552
- chalk27.red(
8553
- "\u2717 Scope slugs cannot start with 'vm0' (reserved for system use)"
8554
- )
8555
- );
8556
- } else {
8557
- console.error(chalk27.red(`\u2717 ${error.message}`));
8558
- }
8526
+ scope = await updateScope({ slug, force: true });
8527
+ console.log(chalk27.green(`\u2713 Scope updated to ${scope.slug}`));
8528
+ } else {
8529
+ scope = await createScope({ slug });
8530
+ console.log(chalk27.green(`\u2713 Scope created: ${scope.slug}`));
8531
+ }
8532
+ console.log();
8533
+ console.log("Your agents will now be namespaced as:");
8534
+ console.log(chalk27.cyan(` ${scope.slug}/<agent-name>`));
8535
+ } catch (error) {
8536
+ if (error instanceof Error) {
8537
+ if (error.message.includes("Not authenticated")) {
8538
+ console.error(chalk27.red("\u2717 Not authenticated. Run: vm0 auth login"));
8539
+ } else if (error.message.includes("already exists")) {
8540
+ console.error(
8541
+ chalk27.red(
8542
+ `\u2717 Scope "${slug}" is already taken. Please choose a different slug.`
8543
+ )
8544
+ );
8545
+ } else if (error.message.includes("reserved")) {
8546
+ console.error(chalk27.red(`\u2717 ${error.message}`));
8547
+ } else if (error.message.includes("vm0")) {
8548
+ console.error(
8549
+ chalk27.red(
8550
+ "\u2717 Scope slugs cannot start with 'vm0' (reserved for system use)"
8551
+ )
8552
+ );
8559
8553
  } else {
8560
- console.error(chalk27.red("\u2717 An unexpected error occurred"));
8554
+ console.error(chalk27.red(`\u2717 ${error.message}`));
8561
8555
  }
8562
- process.exit(1);
8556
+ } else {
8557
+ console.error(chalk27.red("\u2717 An unexpected error occurred"));
8563
8558
  }
8559
+ process.exit(1);
8564
8560
  }
8565
- );
8561
+ });
8566
8562
 
8567
8563
  // src/commands/scope/index.ts
8568
8564
  var scopeCommand = new Command23().name("scope").description("Manage your scope (namespace for agents)").addCommand(statusCommand3).addCommand(setCommand);
@@ -9575,6 +9571,12 @@ function displayDeployResult(agentName, deployResult) {
9575
9571
  );
9576
9572
  console.log(chalk31.dim(` At: ${atTimeFormatted}`));
9577
9573
  }
9574
+ if (deployResult.created) {
9575
+ console.log();
9576
+ console.log(
9577
+ ` To activate: ${chalk31.cyan(`vm0 schedule enable ${agentName}`)}`
9578
+ );
9579
+ }
9578
9580
  }
9579
9581
  var setupCommand = new Command28().name("setup").description("Create or edit a schedule for an agent").argument("<agent-name>", "Agent name to configure schedule for").option("-f, --frequency <type>", "Frequency: daily|weekly|monthly|once").option("-t, --time <HH:MM>", "Time to run (24-hour format)").option("-d, --day <day>", "Day of week (mon-sun) or day of month (1-31)").option("-z, --timezone <tz>", "IANA timezone").option("-p, --prompt <text>", "Prompt to run").option("--var <name=value>", "Variable (can be repeated)", collect, []).option("--secret <name=value>", "Secret (can be repeated)", collect, []).option("--artifact-name <name>", "Artifact name", "artifact").action(async (agentName, options) => {
9580
9582
  try {
@@ -9904,10 +9906,24 @@ var enableCommand = new Command32().name("enable").description("Enable a schedul
9904
9906
  );
9905
9907
  } catch (error) {
9906
9908
  console.error(chalk35.red("\u2717 Failed to enable schedule"));
9907
- if (error instanceof Error) {
9909
+ if (error instanceof ApiRequestError) {
9910
+ if (error.code === "SCHEDULE_PAST") {
9911
+ console.error(chalk35.dim(" Scheduled time has already passed"));
9912
+ console.error(chalk35.dim(` Run: vm0 schedule setup ${agentName}`));
9913
+ } else if (error.code === "NOT_FOUND") {
9914
+ console.error(
9915
+ chalk35.dim(` No schedule found for agent "${agentName}"`)
9916
+ );
9917
+ console.error(chalk35.dim(" Run: vm0 schedule list"));
9918
+ } else if (error.code === "UNAUTHORIZED") {
9919
+ console.error(chalk35.dim(" Run: vm0 auth login"));
9920
+ } else {
9921
+ console.error(chalk35.dim(` ${error.message}`));
9922
+ }
9923
+ } else if (error instanceof Error) {
9908
9924
  if (error.message.includes("Not authenticated")) {
9909
9925
  console.error(chalk35.dim(" Run: vm0 auth login"));
9910
- } else if (error.message.toLowerCase().includes("not found") || error.message.includes("No schedule found")) {
9926
+ } else if (error.message.includes("No schedule found")) {
9911
9927
  console.error(
9912
9928
  chalk35.dim(` No schedule found for agent "${agentName}"`)
9913
9929
  );
@@ -10526,7 +10542,7 @@ var modelProviderCommand = new Command44().name("model-provider").description("M
10526
10542
 
10527
10543
  // src/index.ts
10528
10544
  var program = new Command45();
10529
- program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("8.0.2");
10545
+ program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("8.1.0");
10530
10546
  program.command("info").description("Display environment information").action(async () => {
10531
10547
  console.log(chalk45.bold("System Information:"));
10532
10548
  console.log(`Node Version: ${process.version}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm0/cli",
3
- "version": "8.0.2",
3
+ "version": "8.1.0",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",