@vm0/cli 9.99.0 → 9.100.1
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/{chunk-52LSZTSN.js → chunk-CENK4RLS.js} +7025 -7022
- package/{chunk-52LSZTSN.js.map → chunk-CENK4RLS.js.map} +1 -1
- package/index.js +10 -10
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/zero.js +116 -42
- package/zero.js.map +1 -1
package/package.json
CHANGED
package/zero.js
CHANGED
|
@@ -109,7 +109,7 @@ import {
|
|
|
109
109
|
updateZeroUserPreferences,
|
|
110
110
|
upsertZeroOrgModelProvider,
|
|
111
111
|
withErrorHandler
|
|
112
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-CENK4RLS.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
|
|
1295
|
-
if (!
|
|
1296
|
-
if (
|
|
1297
|
-
|
|
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 formatDetailIdentity(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
|
+
return 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
|
|
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
|
-
|
|
1352
|
+
connectorTypes
|
|
1319
1353
|
);
|
|
1320
|
-
const connectorInfos =
|
|
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(
|
|
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) {
|
|
@@ -1332,24 +1368,17 @@ Examples:
|
|
|
1332
1368
|
if (agent.sound) console.log(`Sound: ${agent.sound}`);
|
|
1333
1369
|
if (options.permissions && connectorInfos.length > 0) {
|
|
1334
1370
|
console.log();
|
|
1371
|
+
console.log(chalk23.bold("Connectors:"));
|
|
1335
1372
|
for (const info of connectorInfos) {
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
continue;
|
|
1340
|
-
}
|
|
1373
|
+
const identity = formatDetailIdentity(identityMap.get(info.type));
|
|
1374
|
+
console.log(` ${info.type.padEnd(14)}${identity}`);
|
|
1375
|
+
if (!info.hasFirewall) continue;
|
|
1341
1376
|
if (!info.policies) {
|
|
1342
|
-
console.log(chalk23.dim(`\u2500\u2500 ${info.type} (full access) \u2500\u2500`));
|
|
1343
1377
|
console.log(
|
|
1344
|
-
"
|
|
1378
|
+
chalk23.dim(" full access \u2014 no permission rules configured")
|
|
1345
1379
|
);
|
|
1346
1380
|
continue;
|
|
1347
1381
|
}
|
|
1348
|
-
console.log(
|
|
1349
|
-
chalk23.dim(
|
|
1350
|
-
`\u2500\u2500 ${info.type} (${info.allowed}/${info.total} allowed) \u2500\u2500`
|
|
1351
|
-
)
|
|
1352
|
-
);
|
|
1353
1382
|
const nameWidth = Math.max(
|
|
1354
1383
|
...info.permissions.map((p) => {
|
|
1355
1384
|
return p.name.length;
|
|
@@ -1359,7 +1388,9 @@ Examples:
|
|
|
1359
1388
|
const policy = info.policies[perm.name] ?? "deny";
|
|
1360
1389
|
const icon = policy === "allow" ? chalk23.green("\u2713") : policy === "ask" ? chalk23.yellow("?") : chalk23.dim("\u2717");
|
|
1361
1390
|
const desc = perm.description ?? "";
|
|
1362
|
-
console.log(
|
|
1391
|
+
console.log(
|
|
1392
|
+
` ${icon} ${perm.name.padEnd(nameWidth)} ${desc}`
|
|
1393
|
+
);
|
|
1363
1394
|
}
|
|
1364
1395
|
}
|
|
1365
1396
|
}
|
|
@@ -3801,6 +3832,44 @@ import chalk47 from "chalk";
|
|
|
3801
3832
|
function isInsideSandbox() {
|
|
3802
3833
|
return !!process.env.ZERO_AGENT_ID;
|
|
3803
3834
|
}
|
|
3835
|
+
function formatConnectorIdentity2(connector) {
|
|
3836
|
+
let identity = "";
|
|
3837
|
+
if (connector.externalUsername && connector.externalEmail) {
|
|
3838
|
+
identity = `@${connector.externalUsername} (${connector.externalEmail})`;
|
|
3839
|
+
} else if (connector.externalUsername) {
|
|
3840
|
+
identity = `@${connector.externalUsername}`;
|
|
3841
|
+
} else if (connector.externalEmail) {
|
|
3842
|
+
identity = connector.externalEmail;
|
|
3843
|
+
}
|
|
3844
|
+
if (connector.needsReconnect) {
|
|
3845
|
+
identity += ` ${chalk47.yellow("(needs reconnect)")}`;
|
|
3846
|
+
}
|
|
3847
|
+
return identity;
|
|
3848
|
+
}
|
|
3849
|
+
function printConnectorPermissions(type, resolvedPolicies) {
|
|
3850
|
+
if (!isFirewallConnectorType(type)) return;
|
|
3851
|
+
const policies = resolvedPolicies?.[type] ?? null;
|
|
3852
|
+
if (!policies) {
|
|
3853
|
+
console.log(chalk47.dim(" full access \u2014 no permission rules configured"));
|
|
3854
|
+
return;
|
|
3855
|
+
}
|
|
3856
|
+
const config = getConnectorFirewall(type);
|
|
3857
|
+
const permissions = config.apis.flatMap((a) => {
|
|
3858
|
+
return a.permissions ?? [];
|
|
3859
|
+
});
|
|
3860
|
+
if (permissions.length === 0) return;
|
|
3861
|
+
const nameWidth = Math.max(
|
|
3862
|
+
...permissions.map((p) => {
|
|
3863
|
+
return p.name.length;
|
|
3864
|
+
})
|
|
3865
|
+
);
|
|
3866
|
+
for (const perm of permissions) {
|
|
3867
|
+
const policy = policies[perm.name] ?? "deny";
|
|
3868
|
+
const icon = policy === "allow" ? chalk47.green("\u2713") : policy === "ask" ? chalk47.yellow("?") : chalk47.dim("\u2717");
|
|
3869
|
+
const desc = perm.description ?? "";
|
|
3870
|
+
console.log(` ${icon} ${perm.name.padEnd(nameWidth)} ${desc}`);
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3804
3873
|
async function showSandboxInfo() {
|
|
3805
3874
|
const agentId = process.env.ZERO_AGENT_ID;
|
|
3806
3875
|
const payload = decodeZeroTokenPayload();
|
|
@@ -3813,26 +3882,31 @@ async function showSandboxInfo() {
|
|
|
3813
3882
|
console.log(` ${payload.capabilities.join(", ")}`);
|
|
3814
3883
|
}
|
|
3815
3884
|
try {
|
|
3816
|
-
const
|
|
3817
|
-
|
|
3885
|
+
const [connectorsResult, agentResult, enabledResult] = await Promise.allSettled([
|
|
3886
|
+
listZeroConnectors(),
|
|
3887
|
+
getZeroAgent(agentId),
|
|
3888
|
+
getZeroAgentUserConnectors(agentId)
|
|
3889
|
+
]);
|
|
3890
|
+
if (connectorsResult.status === "rejected") return;
|
|
3891
|
+
const identities = connectorsResult.value.connectors.filter((c) => {
|
|
3818
3892
|
return c.externalUsername !== null || c.externalEmail !== null;
|
|
3819
3893
|
});
|
|
3820
|
-
if (identities.length
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3894
|
+
if (identities.length === 0) return;
|
|
3895
|
+
let resolvedPolicies = null;
|
|
3896
|
+
const permissionDataAvailable = agentResult.status === "fulfilled" && enabledResult.status === "fulfilled";
|
|
3897
|
+
if (permissionDataAvailable) {
|
|
3898
|
+
resolvedPolicies = resolveFirewallPolicies(
|
|
3899
|
+
agentResult.value.firewallPolicies,
|
|
3900
|
+
enabledResult.value
|
|
3901
|
+
);
|
|
3902
|
+
}
|
|
3903
|
+
console.log();
|
|
3904
|
+
console.log(chalk47.bold("Connectors:"));
|
|
3905
|
+
for (const connector of identities) {
|
|
3906
|
+
const identity = formatConnectorIdentity2(connector);
|
|
3907
|
+
console.log(` ${connector.type.padEnd(14)}${identity}`);
|
|
3908
|
+
if (permissionDataAvailable) {
|
|
3909
|
+
printConnectorPermissions(connector.type, resolvedPolicies);
|
|
3836
3910
|
}
|
|
3837
3911
|
}
|
|
3838
3912
|
} catch {
|
|
@@ -4596,7 +4670,7 @@ function registerZeroCommands(prog, commands) {
|
|
|
4596
4670
|
var program = new Command73();
|
|
4597
4671
|
program.name("zero").description(
|
|
4598
4672
|
"Zero CLI \u2014 interact with the zero platform from inside the sandbox"
|
|
4599
|
-
).version("9.
|
|
4673
|
+
).version("9.100.1").addHelpText(
|
|
4600
4674
|
"after",
|
|
4601
4675
|
`
|
|
4602
4676
|
Examples:
|