@vm0/cli 9.82.0 → 9.82.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm0/cli",
3
- "version": "9.82.0",
3
+ "version": "9.82.2",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",
package/zero.js CHANGED
@@ -80,7 +80,7 @@ import {
80
80
  updateZeroUserPreferences,
81
81
  upsertZeroOrgModelProvider,
82
82
  withErrorHandler
83
- } from "./chunk-RGS2GO4Q.js";
83
+ } from "./chunk-2RXB3R33.js";
84
84
 
85
85
  // src/zero.ts
86
86
  import { Command as Command55 } from "commander";
@@ -296,7 +296,8 @@ var setCommand2 = new Command11().name("set").description("Create or update an o
296
296
  } else if (isInteractive()) {
297
297
  const prompted = await promptPassword("Enter secret value:");
298
298
  if (prompted === void 0) {
299
- process.exit(0);
299
+ console.log(chalk11.dim("Cancelled"));
300
+ return;
300
301
  }
301
302
  value = prompted;
302
303
  } else {
@@ -783,6 +784,11 @@ async function handleInteractiveMode() {
783
784
  )
784
785
  });
785
786
  }
787
+ let cancelled = false;
788
+ const onCancel = () => {
789
+ cancelled = true;
790
+ return false;
791
+ };
786
792
  const { modelProviders: configuredProviders } = await listZeroOrgModelProviders();
787
793
  const configuredTypes = new Set(configuredProviders.map((p) => p.type));
788
794
  const annotatedChoices = getSelectableProviderTypes().map((type2) => {
@@ -808,8 +814,12 @@ async function handleInteractiveMode() {
808
814
  message: "Select provider type:",
809
815
  choices: annotatedChoices
810
816
  },
811
- { onCancel: () => process.exit(0) }
817
+ { onCancel }
812
818
  );
819
+ if (cancelled) {
820
+ console.log(chalk18.dim("Cancelled"));
821
+ return null;
822
+ }
813
823
  const type = typeResponse.type;
814
824
  const existingProvider = configuredProviders.find((p) => p.type === type);
815
825
  if (existingProvider) {
@@ -826,8 +836,12 @@ async function handleInteractiveMode() {
826
836
  { title: "Update secret", value: "update" }
827
837
  ]
828
838
  },
829
- { onCancel: () => process.exit(0) }
839
+ { onCancel }
830
840
  );
841
+ if (cancelled) {
842
+ console.log(chalk18.dim("Cancelled"));
843
+ return null;
844
+ }
831
845
  if (actionResponse.action === "keep") {
832
846
  const selectedModel2 = await promptForModelSelection(type);
833
847
  return {
@@ -864,14 +878,19 @@ async function handleInteractiveMode() {
864
878
  message: `Enter your ${secretLabel}:`,
865
879
  validate: (value) => value.length > 0 || `${secretLabel} is required`
866
880
  },
867
- { onCancel: () => process.exit(0) }
881
+ { onCancel }
868
882
  );
883
+ if (cancelled) {
884
+ console.log(chalk18.dim("Cancelled"));
885
+ return null;
886
+ }
869
887
  const secret = secretResponse.secret;
870
888
  const selectedModel = await promptForModelSelection(type);
871
889
  return { type, secret, selectedModel, isInteractiveMode: true };
872
890
  }
873
891
  async function promptSetAsDefault(type, framework, isDefault) {
874
892
  if (isDefault) return;
893
+ let cancelled = false;
875
894
  const response = await prompts2(
876
895
  {
877
896
  type: "confirm",
@@ -879,8 +898,17 @@ async function promptSetAsDefault(type, framework, isDefault) {
879
898
  message: "Set this provider as default?",
880
899
  initial: false
881
900
  },
882
- { onCancel: () => process.exit(0) }
901
+ {
902
+ onCancel: () => {
903
+ cancelled = true;
904
+ return false;
905
+ }
906
+ }
883
907
  );
908
+ if (cancelled) {
909
+ console.log(chalk18.dim("Cancelled"));
910
+ return;
911
+ }
884
912
  if (response.setDefault) {
885
913
  await setZeroOrgModelProviderDefault(type);
886
914
  console.log(chalk18.green(`\u2713 Default for ${framework} set to "${type}"`));
@@ -1179,7 +1207,7 @@ var deleteCommand2 = new Command28().name("delete").alias("rm").description("Del
1179
1207
  );
1180
1208
 
1181
1209
  // src/commands/zero/agent/index.ts
1182
- var agentCommand = new Command29("agent").description("Manage zero agents").addCommand(createCommand).addCommand(editCommand).addCommand(viewCommand).addCommand(listCommand5).addCommand(deleteCommand2);
1210
+ var zeroAgentCommand = new Command29("agent").description("Manage zero agents").addCommand(createCommand).addCommand(editCommand).addCommand(viewCommand).addCommand(listCommand5).addCommand(deleteCommand2);
1183
1211
 
1184
1212
  // src/commands/zero/connector/index.ts
1185
1213
  import { Command as Command34 } from "commander";
@@ -1399,7 +1427,8 @@ async function connectViaApiToken(connectorType, tokenValue) {
1399
1427
  `${secretConfig.label}${secretConfig.placeholder ? chalk27.dim(` (${secretConfig.placeholder})`) : ""}:`
1400
1428
  );
1401
1429
  if (!value) {
1402
- throw new Error("Cancelled");
1430
+ console.log(chalk27.dim("Cancelled"));
1431
+ return;
1403
1432
  }
1404
1433
  inputSecrets[secretName] = value;
1405
1434
  }
@@ -1451,7 +1480,8 @@ async function resolveAuthMethod(connectorType, tokenFlag) {
1451
1480
  ]
1452
1481
  );
1453
1482
  if (!selected) {
1454
- throw new Error("Cancelled");
1483
+ console.log(chalk27.dim("Cancelled"));
1484
+ return null;
1455
1485
  }
1456
1486
  return selected;
1457
1487
  }
@@ -1520,6 +1550,7 @@ var connectCommand = new Command30().name("connect").description("Connect a thir
1520
1550
  return;
1521
1551
  }
1522
1552
  const authMethod = await resolveAuthMethod(connectorType, options.token);
1553
+ if (!authMethod) return;
1523
1554
  if (authMethod === "api-token") {
1524
1555
  await connectViaApiToken(connectorType, options.token);
1525
1556
  return;
@@ -1772,7 +1803,7 @@ var disconnectCommand = new Command33().name("disconnect").description("Disconne
1772
1803
  );
1773
1804
 
1774
1805
  // src/commands/zero/connector/index.ts
1775
- var zeroConnectorCommand = new Command34().name("connector").description("Manage third-party service connections (zero)").addCommand(listCommand6).addCommand(statusCommand2).addCommand(connectCommand).addCommand(disconnectCommand);
1806
+ var zeroConnectorCommand = new Command34().name("connector").description("Manage third-party service connections").addCommand(listCommand6).addCommand(statusCommand2).addCommand(connectCommand).addCommand(disconnectCommand);
1776
1807
 
1777
1808
  // src/commands/zero/preference/index.ts
1778
1809
  import { Command as Command35 } from "commander";
@@ -2663,7 +2694,8 @@ var setCommand4 = new Command44().name("set").description("Create or update a se
2663
2694
  } else if (isInteractive()) {
2664
2695
  const prompted = await promptPassword("Enter secret value:");
2665
2696
  if (prompted === void 0) {
2666
- process.exit(0);
2697
+ console.log(chalk39.dim("Cancelled"));
2698
+ return;
2667
2699
  }
2668
2700
  value = prompted;
2669
2701
  } else {
@@ -2924,43 +2956,27 @@ var zeroWhoamiCommand = new Command54().name("whoami").description("Show current
2924
2956
  var COMMAND_CAPABILITY_MAP = {
2925
2957
  agent: "agent:read",
2926
2958
  schedule: "schedule:read",
2959
+ slack: "slack:write",
2927
2960
  whoami: null
2928
2961
  };
2929
- function decodeCapabilitiesFromZeroToken(token) {
2930
- const prefix = "vm0_sandbox_";
2931
- if (!token.startsWith(prefix)) return null;
2932
- const jwt = token.slice(prefix.length);
2933
- const parts = jwt.split(".");
2934
- if (parts.length !== 3) return null;
2935
- try {
2936
- const payload = JSON.parse(
2937
- Buffer.from(parts[1], "base64url").toString()
2938
- );
2939
- if (payload.scope === "zero" && Array.isArray(payload.capabilities)) {
2940
- return payload.capabilities;
2941
- }
2942
- } catch {
2943
- }
2944
- return null;
2945
- }
2946
2962
  function applyCapabilityVisibility(prog) {
2947
2963
  const token = process.env.ZERO_TOKEN;
2948
2964
  if (!token) return;
2949
- const capabilities = decodeCapabilitiesFromZeroToken(token);
2950
- if (!capabilities) return;
2965
+ const payload = decodeZeroTokenPayload(token);
2966
+ if (!payload) return;
2951
2967
  for (const cmd of prog.commands) {
2952
2968
  const requiredCap = COMMAND_CAPABILITY_MAP[cmd.name()];
2953
2969
  if (requiredCap === void 0) {
2954
2970
  cmd._hidden = true;
2955
- } else if (requiredCap !== null && !capabilities.includes(requiredCap)) {
2971
+ } else if (requiredCap !== null && !payload.capabilities.includes(requiredCap)) {
2956
2972
  cmd._hidden = true;
2957
2973
  }
2958
2974
  }
2959
2975
  }
2960
2976
  var program = new Command55();
2961
- program.name("zero").description("Zero CLI - Manage your zero platform").version("9.82.0");
2977
+ program.name("zero").description("Zero CLI - Manage your zero platform").version("9.82.2");
2962
2978
  program.addCommand(zeroOrgCommand);
2963
- program.addCommand(agentCommand);
2979
+ program.addCommand(zeroAgentCommand);
2964
2980
  program.addCommand(zeroConnectorCommand);
2965
2981
  program.addCommand(zeroPreferenceCommand);
2966
2982
  program.addCommand(zeroScheduleCommand);
@@ -2969,21 +2985,12 @@ program.addCommand(zeroSlackCommand);
2969
2985
  program.addCommand(zeroVariableCommand);
2970
2986
  program.addCommand(zeroWhoamiCommand);
2971
2987
  if (process.argv[1]?.endsWith("zero.js") || process.argv[1]?.endsWith("zero.ts") || process.argv[1]?.endsWith("zero")) {
2972
- process.stdout.on("error", (err) => {
2973
- if (err.code === "EPIPE") process.exit(0);
2974
- throw err;
2975
- });
2976
- process.stderr.on("error", (err) => {
2977
- if (err.code === "EPIPE") process.exit(0);
2978
- throw err;
2979
- });
2980
2988
  configureGlobalProxyFromEnv();
2981
2989
  applyCapabilityVisibility(program);
2982
2990
  program.parse();
2983
2991
  }
2984
2992
  export {
2985
2993
  applyCapabilityVisibility,
2986
- decodeCapabilitiesFromZeroToken,
2987
2994
  program
2988
2995
  };
2989
2996
  //# sourceMappingURL=zero.js.map