@vm0/cli 9.161.6 → 9.161.7

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 CHANGED
@@ -68,7 +68,7 @@ import {
68
68
  source_default,
69
69
  volumeConfigSchema,
70
70
  withErrorHandler
71
- } from "./chunk-DYDX54LP.js";
71
+ } from "./chunk-P3SAJ3Q2.js";
72
72
  import {
73
73
  __toESM,
74
74
  init_esm_shims
@@ -387,7 +387,7 @@ function getConfigPath() {
387
387
  return join(os.homedir(), ".vm0", "config.json");
388
388
  }
389
389
  var infoCommand = new Command().name("info").description("Display environment and debug information").action(async () => {
390
- console.log(source_default.bold(`VM0 CLI v${"9.161.6"}`));
390
+ console.log(source_default.bold(`VM0 CLI v${"9.161.7"}`));
391
391
  console.log();
392
392
  const config = await loadConfig();
393
393
  const hasEnvToken = !!process.env.VM0_TOKEN;
@@ -4280,7 +4280,7 @@ var composeCommand = new Command().name("compose").description("Create or update
4280
4280
  options.autoUpdate = false;
4281
4281
  }
4282
4282
  if (options.autoUpdate !== false) {
4283
- await startSilentUpgrade("9.161.6");
4283
+ await startSilentUpgrade("9.161.7");
4284
4284
  }
4285
4285
  try {
4286
4286
  let result;
@@ -4372,7 +4372,7 @@ var mainRunCommand = new Command().name("run").description("Run an agent").argum
4372
4372
  withErrorHandler(
4373
4373
  async (identifier, prompt, options) => {
4374
4374
  if (options.autoUpdate !== false) {
4375
- await startSilentUpgrade("9.161.6");
4375
+ await startSilentUpgrade("9.161.7");
4376
4376
  }
4377
4377
  const { name, version } = parseIdentifier(identifier);
4378
4378
  let composeId;
@@ -6165,13 +6165,13 @@ var upgradeCommand = new Command().name("upgrade").description("Upgrade vm0 CLI
6165
6165
  if (latestVersion === null) {
6166
6166
  throw new Error("Could not check for updates. Please try again later.");
6167
6167
  }
6168
- if (latestVersion === "9.161.6") {
6169
- console.log(source_default.green(`\u2713 Already up to date (${"9.161.6"})`));
6168
+ if (latestVersion === "9.161.7") {
6169
+ console.log(source_default.green(`\u2713 Already up to date (${"9.161.7"})`));
6170
6170
  return;
6171
6171
  }
6172
6172
  console.log(
6173
6173
  source_default.yellow(
6174
- `Current version: ${"9.161.6"} -> Latest version: ${latestVersion}`
6174
+ `Current version: ${"9.161.7"} -> Latest version: ${latestVersion}`
6175
6175
  )
6176
6176
  );
6177
6177
  console.log();
@@ -6198,7 +6198,7 @@ var upgradeCommand = new Command().name("upgrade").description("Upgrade vm0 CLI
6198
6198
  const success = await performUpgrade(packageManager);
6199
6199
  if (success) {
6200
6200
  console.log(
6201
- source_default.green(`\u2713 Upgraded from ${"9.161.6"} to ${latestVersion}`)
6201
+ source_default.green(`\u2713 Upgraded from ${"9.161.7"} to ${latestVersion}`)
6202
6202
  );
6203
6203
  return;
6204
6204
  }
@@ -6265,7 +6265,7 @@ var whoamiCommand = new Command().name("whoami").description("Show current ident
6265
6265
 
6266
6266
  // src/index.ts
6267
6267
  var program = new Command();
6268
- program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.161.6");
6268
+ program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.161.7");
6269
6269
  program.addCommand(authCommand);
6270
6270
  program.addCommand(infoCommand);
6271
6271
  program.addCommand(composeCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm0/cli",
3
- "version": "9.161.6",
3
+ "version": "9.161.7",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",
package/zero.js CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  createLocalBrowserWriteCommand,
26
26
  createSkill,
27
27
  createZeroAgent,
28
+ createZeroCreditCheckout,
28
29
  createZeroRun,
29
30
  decodeCliTokenPayload,
30
31
  decodeZeroTokenPayload,
@@ -73,6 +74,7 @@ import {
73
74
  getZeroAgent,
74
75
  getZeroAgentInstructions,
75
76
  getZeroAgentUserConnectors,
77
+ getZeroBillingStatus,
76
78
  getZeroConnector,
77
79
  getZeroOrg,
78
80
  getZeroOrgMembers,
@@ -148,7 +150,7 @@ import {
148
150
  zeroAgentCustomSkillNameSchema,
149
151
  zeroLocalAgentCommand,
150
152
  zeroTokenAllowsFeatureSwitch
151
- } from "./chunk-DYDX54LP.js";
153
+ } from "./chunk-P3SAJ3Q2.js";
152
154
  import {
153
155
  __commonJS,
154
156
  __require,
@@ -29828,6 +29830,62 @@ var statusCommand2 = new Command().name("status").description("Show detailed sta
29828
29830
  // src/commands/zero/connector/index.ts
29829
29831
  var zeroConnectorCommand = new Command().name("connector").description("Check third-party service connections (GitHub, Slack, etc.)").addCommand(listCommand6).addCommand(searchCommand).addCommand(statusCommand2);
29830
29832
 
29833
+ // src/commands/zero/credit.ts
29834
+ init_esm_shims();
29835
+ function parseCredits(value) {
29836
+ const credits = Number(value.replaceAll(",", ""));
29837
+ if (!Number.isInteger(credits) || credits <= 0) {
29838
+ throw new Error("credits must be a positive integer");
29839
+ }
29840
+ return credits;
29841
+ }
29842
+ var zeroCreditCommand = new Command().name("credit").description("Create a Stripe checkout link to buy credits").argument("<credits>", "Number of credits to buy", parseCredits).addOption(
29843
+ new Option("--auto-recharge", "Enable auto-recharge after checkout")
29844
+ ).option(
29845
+ "--auto-recharge-threshold <credits>",
29846
+ "Recharge when balance is at or below this number of credits",
29847
+ parseCredits
29848
+ ).option(
29849
+ "--auto-recharge-amount <credits>",
29850
+ "Credits to buy for each auto-recharge",
29851
+ parseCredits
29852
+ ).action(
29853
+ withErrorHandler(
29854
+ async (credits, options) => {
29855
+ const members = await getZeroOrgMembers();
29856
+ if (members.role !== "admin") {
29857
+ console.log(
29858
+ source_default.yellow(
29859
+ "Only organization admins can buy credits. Run `zero doctor credit` to see the current credit status and org admins."
29860
+ )
29861
+ );
29862
+ return;
29863
+ }
29864
+ const origin = await getPlatformOrigin();
29865
+ const successUrl = `${origin}/?settings=usage&credit=success`;
29866
+ const cancelUrl = `${origin}/?settings=usage&credit=canceled`;
29867
+ const autoRecharge = options.autoRecharge === void 0 && options.autoRechargeThreshold === void 0 && options.autoRechargeAmount === void 0 ? void 0 : {
29868
+ enabled: options.autoRecharge === true,
29869
+ threshold: options.autoRechargeThreshold,
29870
+ amount: options.autoRechargeAmount
29871
+ };
29872
+ if (autoRecharge?.enabled === true && (autoRecharge.threshold === void 0 || autoRecharge.amount === void 0)) {
29873
+ throw new Error(
29874
+ "--auto-recharge requires --auto-recharge-threshold and --auto-recharge-amount"
29875
+ );
29876
+ }
29877
+ const result = await createZeroCreditCheckout({
29878
+ credits,
29879
+ successUrl,
29880
+ cancelUrl,
29881
+ ...autoRecharge ? { autoRecharge } : {}
29882
+ });
29883
+ console.log(source_default.bold("Credit checkout link:"));
29884
+ console.log(result.url);
29885
+ }
29886
+ )
29887
+ );
29888
+
29831
29889
  // src/commands/zero/doctor/index.ts
29832
29890
  init_esm_shims();
29833
29891
 
@@ -30905,8 +30963,67 @@ Notes:
30905
30963
  )
30906
30964
  );
30907
30965
 
30966
+ // src/commands/zero/doctor/credit.ts
30967
+ init_esm_shims();
30968
+ function memberName(member) {
30969
+ const name = [member.firstName, member.lastName].filter(Boolean).join(" ");
30970
+ return name ? `${name} <${member.email}>` : member.email;
30971
+ }
30972
+ var creditCommand = new Command().name("credit").description("Diagnose current organization credit and purchase access").action(
30973
+ withErrorHandler(async () => {
30974
+ const [org, billing, members] = await Promise.all([
30975
+ getZeroOrg(),
30976
+ getZeroBillingStatus(),
30977
+ getZeroOrgMembers()
30978
+ ]);
30979
+ const admins = members.members.filter((member) => {
30980
+ return member.role === "admin";
30981
+ });
30982
+ const isAdmin = members.role === "admin";
30983
+ const canPurchaseCredits = isAdmin;
30984
+ console.log(source_default.bold("Credit diagnostics:"));
30985
+ console.log(` Org: ${source_default.green(org.slug)}`);
30986
+ console.log(` Tier: ${source_default.cyan(billing.tier)}`);
30987
+ console.log(
30988
+ ` Available credits: ${source_default.cyan(billing.credits.toLocaleString())}`
30989
+ );
30990
+ console.log(` Current user role: ${source_default.cyan(members.role)}`);
30991
+ console.log(
30992
+ ` Can purchase credits: ${canPurchaseCredits ? source_default.green("yes") : source_default.yellow("no")}`
30993
+ );
30994
+ console.log(
30995
+ ` Auto-recharge: ${billing.autoRecharge.enabled ? source_default.green("enabled") : "disabled"}`
30996
+ );
30997
+ if (billing.autoRecharge.enabled) {
30998
+ console.log(
30999
+ ` Threshold: ${billing.autoRecharge.threshold?.toLocaleString() ?? "not set"}`
31000
+ );
31001
+ console.log(
31002
+ ` Amount: ${billing.autoRecharge.amount?.toLocaleString() ?? "not set"}`
31003
+ );
31004
+ }
31005
+ if (!isAdmin) {
31006
+ console.log(source_default.bold("\nOrganization admins:"));
31007
+ for (const admin of admins) {
31008
+ console.log(` - ${memberName(admin)}`);
31009
+ }
31010
+ console.log(
31011
+ source_default.yellow(
31012
+ "\nAsk an organization admin to buy credits or upgrade the plan."
31013
+ )
31014
+ );
31015
+ } else if (billing.tier === "free") {
31016
+ console.log(
31017
+ "\nFree-tier admins can upgrade to Pro from billing or buy credits with `zero credit <credits>`."
31018
+ );
31019
+ } else {
31020
+ console.log("\nUse `zero credit <credits>` to buy more credits.");
31021
+ }
31022
+ })
31023
+ );
31024
+
30908
31025
  // src/commands/zero/doctor/index.ts
30909
- var zeroDoctorCommand = new Command().name("doctor").description("Diagnose runtime issues (connector health, permission denials)").addCommand(checkConnectorCommand).addCommand(generateCommand).addCommand(permissionDenyCommand).addCommand(permissionChangeCommand).addHelpText(
31026
+ var zeroDoctorCommand = new Command().name("doctor").description("Diagnose runtime issues (connector health, permission denials)").addCommand(checkConnectorCommand).addCommand(generateCommand).addCommand(creditCommand).addCommand(permissionDenyCommand).addCommand(permissionChangeCommand).addHelpText(
30910
31027
  "after",
30911
31028
  `
30912
31029
  Examples:
@@ -30914,11 +31031,13 @@ Examples:
30914
31031
  Check a URL? zero doctor check-connector --url https://api.github.com/repos/owner/repo
30915
31032
  Generate with image? zero doctor generate image
30916
31033
  Generate with video? zero doctor generate video
31034
+ Check credits? zero doctor credit
30917
31035
  Check with permission? zero doctor check-connector --env-name SLACK_TOKEN --check-permission chat:write
30918
31036
  Permission denied? zero doctor permission-deny github --method GET --path /repos/owner/repo
30919
31037
  Change a permission? zero doctor permission-change github --permission contents:read --enable
30920
31038
 
30921
31039
  Notes:
31040
+ - Use zero doctor credit when a run or generation fails because the org has insufficient credits, when a user asks how to recharge, or before trying to buy credits
30922
31041
  - Use this when your task fails due to a missing environment variable or permission denial
30923
31042
  - The doctor will identify the issue and give the user a link to resolve it`
30924
31043
  );
@@ -36947,6 +37066,7 @@ var COMMAND_CAPABILITY_MAP = {
36947
37066
  run: "agent-run:write",
36948
37067
  schedule: "schedule:read",
36949
37068
  doctor: null,
37069
+ credit: null,
36950
37070
  model: null,
36951
37071
  "model-provider": null,
36952
37072
  logs: "agent-run:read",
@@ -36972,6 +37092,7 @@ var DEFAULT_COMMANDS = [
36972
37092
  zeroModelProviderCommand,
36973
37093
  zeroAgentCommand,
36974
37094
  zeroConnectorCommand,
37095
+ zeroCreditCommand,
36975
37096
  zeroDoctorCommand,
36976
37097
  zeroPreferenceCommand,
36977
37098
  zeroRunCommand,
@@ -37014,6 +37135,8 @@ function shouldHideCommand(name, payload) {
37014
37135
  function buildZeroHelpText(payload = decodeZeroTokenPayload()) {
37015
37136
  const examples = [
37016
37137
  " Check a connector? zero doctor check-connector --env-name <ENV_NAME>",
37138
+ " Check credits? zero doctor credit",
37139
+ " Buy credits? zero credit 20000",
37017
37140
  " Send a Slack message? zero slack message send --help",
37018
37141
  " Upload GitHub? zero github upload-file --help",
37019
37142
  " Download GitHub? zero github download-file --help",
@@ -37054,7 +37177,7 @@ function registerZeroCommands(prog, commands) {
37054
37177
  var program = new Command();
37055
37178
  program.name("zero").description(
37056
37179
  "Zero CLI \u2014 interact with the zero platform from inside the sandbox"
37057
- ).version("9.161.6").addHelpText("after", () => {
37180
+ ).version("9.161.7").addHelpText("after", () => {
37058
37181
  return buildZeroHelpText();
37059
37182
  });
37060
37183
  if (process.argv[1]?.endsWith("zero.js") || process.argv[1]?.endsWith("zero.ts") || process.argv[1]?.endsWith("zero")) {