@vm0/cli 9.99.0 → 9.100.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm0/cli",
3
- "version": "9.99.0",
3
+ "version": "9.100.0",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",
package/zero.js CHANGED
@@ -109,7 +109,7 @@ import {
109
109
  updateZeroUserPreferences,
110
110
  upsertZeroOrgModelProvider,
111
111
  withErrorHandler
112
- } from "./chunk-52LSZTSN.js";
112
+ } from "./chunk-2KKNOZ4M.js";
113
113
 
114
114
  // src/zero.ts
115
115
  import { Command as Command73 } from "commander";
@@ -1291,10 +1291,34 @@ function getConnectorPermissionInfo(type, resolvedPolicies) {
1291
1291
  }).length : 0;
1292
1292
  return { type, hasFirewall: true, permissions, policies, allowed, total };
1293
1293
  }
1294
- function formatConnectorSummary(info) {
1295
- if (!info.hasFirewall) return info.type;
1296
- if (!info.policies) return `${info.type} (full access)`;
1297
- return `${info.type} (${info.allowed}/${info.total} allowed)`;
1294
+ function formatConnectorIdentity(connector) {
1295
+ if (!connector) return "";
1296
+ if (connector.externalUsername) return `@${connector.externalUsername}`;
1297
+ if (connector.externalEmail) return connector.externalEmail;
1298
+ return "";
1299
+ }
1300
+ function formatConnectorSummary(info, identity) {
1301
+ const id = formatConnectorIdentity(identity);
1302
+ const idStr = id ? ` ${id}` : "";
1303
+ if (!info.hasFirewall) return `${info.type}${idStr}`;
1304
+ if (!info.policies) return `${info.type}${idStr} (full access)`;
1305
+ return `${info.type}${idStr} (${info.allowed}/${info.total} allowed)`;
1306
+ }
1307
+ function printAccountLine(connector) {
1308
+ if (!connector) return;
1309
+ let identity = "";
1310
+ if (connector.externalUsername && connector.externalEmail) {
1311
+ identity = `@${connector.externalUsername} (${connector.externalEmail})`;
1312
+ } else if (connector.externalUsername) {
1313
+ identity = `@${connector.externalUsername}`;
1314
+ } else if (connector.externalEmail) {
1315
+ identity = connector.externalEmail;
1316
+ }
1317
+ if (!identity) return;
1318
+ if (connector.needsReconnect) {
1319
+ identity += ` ${chalk23.yellow("(needs reconnect)")}`;
1320
+ }
1321
+ console.log(` Account: ${identity}`);
1298
1322
  }
1299
1323
  var viewCommand = new Command26().name("view").description("View a zero agent").argument("<agent-id>", "Agent ID").option("--instructions", "Also show instructions content").option("--permissions", "Show full permission details for each connector").addHelpText(
1300
1324
  "after",
@@ -1307,21 +1331,33 @@ Examples:
1307
1331
  ).action(
1308
1332
  withErrorHandler(
1309
1333
  async (agentId, options) => {
1310
- const agent = await getZeroAgent(agentId);
1334
+ const [agent, connectorTypes, connectorIdentities] = await Promise.all([
1335
+ getZeroAgent(agentId),
1336
+ getZeroAgentUserConnectors(agentId),
1337
+ listZeroConnectors().catch(() => {
1338
+ return { connectors: [] };
1339
+ })
1340
+ ]);
1341
+ const identityMap = new Map(
1342
+ connectorIdentities.connectors.map((c) => {
1343
+ return [c.type, c];
1344
+ })
1345
+ );
1311
1346
  console.log(chalk23.bold(agent.agentId));
1312
1347
  if (agent.displayName) console.log(chalk23.dim(agent.displayName));
1313
1348
  console.log();
1314
1349
  console.log(`Agent ID: ${agent.agentId}`);
1315
- const connectors = await getZeroAgentUserConnectors(agentId);
1316
1350
  const resolvedPolicies = resolveFirewallPolicies(
1317
1351
  agent.firewallPolicies,
1318
- connectors
1352
+ connectorTypes
1319
1353
  );
1320
- const connectorInfos = connectors.map((type) => {
1354
+ const connectorInfos = connectorTypes.map((type) => {
1321
1355
  return getConnectorPermissionInfo(type, resolvedPolicies);
1322
1356
  });
1323
1357
  if (connectorInfos.length > 0) {
1324
- const summaries = connectorInfos.map(formatConnectorSummary);
1358
+ const summaries = connectorInfos.map((info) => {
1359
+ return formatConnectorSummary(info, identityMap.get(info.type));
1360
+ });
1325
1361
  console.log(`Connectors: ${summaries.join(", ")}`);
1326
1362
  }
1327
1363
  if (agent.customSkills?.length > 0) {
@@ -1335,11 +1371,13 @@ Examples:
1335
1371
  for (const info of connectorInfos) {
1336
1372
  if (!info.hasFirewall) {
1337
1373
  console.log(chalk23.dim(`\u2500\u2500 ${info.type} \u2500\u2500`));
1374
+ printAccountLine(identityMap.get(info.type));
1338
1375
  console.log(" No firewall configured.");
1339
1376
  continue;
1340
1377
  }
1341
1378
  if (!info.policies) {
1342
1379
  console.log(chalk23.dim(`\u2500\u2500 ${info.type} (full access) \u2500\u2500`));
1380
+ printAccountLine(identityMap.get(info.type));
1343
1381
  console.log(
1344
1382
  " No permission rules configured \u2014 all API calls allowed."
1345
1383
  );
@@ -1350,6 +1388,7 @@ Examples:
1350
1388
  `\u2500\u2500 ${info.type} (${info.allowed}/${info.total} allowed) \u2500\u2500`
1351
1389
  )
1352
1390
  );
1391
+ printAccountLine(identityMap.get(info.type));
1353
1392
  const nameWidth = Math.max(
1354
1393
  ...info.permissions.map((p) => {
1355
1394
  return p.name.length;
@@ -3801,6 +3840,44 @@ import chalk47 from "chalk";
3801
3840
  function isInsideSandbox() {
3802
3841
  return !!process.env.ZERO_AGENT_ID;
3803
3842
  }
3843
+ function formatConnectorIdentity2(connector) {
3844
+ let identity = "";
3845
+ if (connector.externalUsername && connector.externalEmail) {
3846
+ identity = `@${connector.externalUsername} (${connector.externalEmail})`;
3847
+ } else if (connector.externalUsername) {
3848
+ identity = `@${connector.externalUsername}`;
3849
+ } else if (connector.externalEmail) {
3850
+ identity = connector.externalEmail;
3851
+ }
3852
+ if (connector.needsReconnect) {
3853
+ identity += ` ${chalk47.yellow("(needs reconnect)")}`;
3854
+ }
3855
+ return identity;
3856
+ }
3857
+ function printConnectorPermissions(type, resolvedPolicies) {
3858
+ if (!isFirewallConnectorType(type)) return;
3859
+ const policies = resolvedPolicies?.[type] ?? null;
3860
+ if (!policies) {
3861
+ console.log(chalk47.dim(" full access \u2014 no permission rules configured"));
3862
+ return;
3863
+ }
3864
+ const config = getConnectorFirewall(type);
3865
+ const permissions = config.apis.flatMap((a) => {
3866
+ return a.permissions ?? [];
3867
+ });
3868
+ if (permissions.length === 0) return;
3869
+ const nameWidth = Math.max(
3870
+ ...permissions.map((p) => {
3871
+ return p.name.length;
3872
+ })
3873
+ );
3874
+ for (const perm of permissions) {
3875
+ const policy = policies[perm.name] ?? "deny";
3876
+ const icon = policy === "allow" ? chalk47.green("\u2713") : policy === "ask" ? chalk47.yellow("?") : chalk47.dim("\u2717");
3877
+ const desc = perm.description ?? "";
3878
+ console.log(` ${icon} ${perm.name.padEnd(nameWidth)} ${desc}`);
3879
+ }
3880
+ }
3804
3881
  async function showSandboxInfo() {
3805
3882
  const agentId = process.env.ZERO_AGENT_ID;
3806
3883
  const payload = decodeZeroTokenPayload();
@@ -3813,26 +3890,31 @@ async function showSandboxInfo() {
3813
3890
  console.log(` ${payload.capabilities.join(", ")}`);
3814
3891
  }
3815
3892
  try {
3816
- const result = await listZeroConnectors();
3817
- const identities = result.connectors.filter((c) => {
3893
+ const [connectorsResult, agentResult, enabledResult] = await Promise.allSettled([
3894
+ listZeroConnectors(),
3895
+ getZeroAgent(agentId),
3896
+ getZeroAgentUserConnectors(agentId)
3897
+ ]);
3898
+ if (connectorsResult.status === "rejected") return;
3899
+ const identities = connectorsResult.value.connectors.filter((c) => {
3818
3900
  return c.externalUsername !== null || c.externalEmail !== null;
3819
3901
  });
3820
- if (identities.length > 0) {
3821
- console.log();
3822
- console.log(chalk47.bold("Connected Services:"));
3823
- for (const connector of identities) {
3824
- let identity = "";
3825
- if (connector.externalUsername && connector.externalEmail) {
3826
- identity = `@${connector.externalUsername} (${connector.externalEmail})`;
3827
- } else if (connector.externalUsername) {
3828
- identity = `@${connector.externalUsername}`;
3829
- } else if (connector.externalEmail) {
3830
- identity = connector.externalEmail;
3831
- }
3832
- if (connector.needsReconnect) {
3833
- identity += ` ${chalk47.yellow("(needs reconnect)")}`;
3834
- }
3835
- console.log(` ${connector.type.padEnd(14)}${identity}`);
3902
+ if (identities.length === 0) return;
3903
+ let resolvedPolicies = null;
3904
+ const permissionDataAvailable = agentResult.status === "fulfilled" && enabledResult.status === "fulfilled";
3905
+ if (permissionDataAvailable) {
3906
+ resolvedPolicies = resolveFirewallPolicies(
3907
+ agentResult.value.firewallPolicies,
3908
+ enabledResult.value
3909
+ );
3910
+ }
3911
+ console.log();
3912
+ console.log(chalk47.bold("Connected Services:"));
3913
+ for (const connector of identities) {
3914
+ const identity = formatConnectorIdentity2(connector);
3915
+ console.log(` ${connector.type.padEnd(14)}${identity}`);
3916
+ if (permissionDataAvailable) {
3917
+ printConnectorPermissions(connector.type, resolvedPolicies);
3836
3918
  }
3837
3919
  }
3838
3920
  } catch {
@@ -4596,7 +4678,7 @@ function registerZeroCommands(prog, commands) {
4596
4678
  var program = new Command73();
4597
4679
  program.name("zero").description(
4598
4680
  "Zero CLI \u2014 interact with the zero platform from inside the sandbox"
4599
- ).version("9.99.0").addHelpText(
4681
+ ).version("9.100.0").addHelpText(
4600
4682
  "after",
4601
4683
  `
4602
4684
  Examples: