@vm0/cli 9.81.0 → 9.82.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/{chunk-3EOIDO3I.js → chunk-RGS2GO4Q.js} +350 -64
- package/chunk-RGS2GO4Q.js.map +1 -0
- package/index.js +10 -10
- package/package.json +1 -1
- package/zero.js +146 -99
- package/zero.js.map +1 -1
- package/chunk-3EOIDO3I.js.map +0 -1
package/index.js
CHANGED
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
storagesPrepareContract,
|
|
66
66
|
volumeConfigSchema,
|
|
67
67
|
withErrorHandler
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-RGS2GO4Q.js";
|
|
69
69
|
|
|
70
70
|
// src/index.ts
|
|
71
71
|
import { Command as Command44 } from "commander";
|
|
@@ -451,7 +451,7 @@ function getConfigPath() {
|
|
|
451
451
|
return join(homedir(), ".vm0", "config.json");
|
|
452
452
|
}
|
|
453
453
|
var infoCommand = new Command6().name("info").description("Display environment and debug information").action(async () => {
|
|
454
|
-
console.log(chalk3.bold(`VM0 CLI v${"9.
|
|
454
|
+
console.log(chalk3.bold(`VM0 CLI v${"9.82.0"}`));
|
|
455
455
|
console.log();
|
|
456
456
|
const config = await loadConfig();
|
|
457
457
|
const hasEnvToken = !!process.env.VM0_TOKEN;
|
|
@@ -1677,7 +1677,7 @@ var composeCommand = new Command7().name("compose").description("Create or updat
|
|
|
1677
1677
|
options.autoUpdate = false;
|
|
1678
1678
|
}
|
|
1679
1679
|
if (options.autoUpdate !== false) {
|
|
1680
|
-
await startSilentUpgrade("9.
|
|
1680
|
+
await startSilentUpgrade("9.82.0");
|
|
1681
1681
|
}
|
|
1682
1682
|
try {
|
|
1683
1683
|
let result;
|
|
@@ -2512,7 +2512,7 @@ var mainRunCommand = new Command8().name("run").description("Run an agent").argu
|
|
|
2512
2512
|
withErrorHandler(
|
|
2513
2513
|
async (identifier, prompt, options) => {
|
|
2514
2514
|
if (options.autoUpdate !== false) {
|
|
2515
|
-
await startSilentUpgrade("9.
|
|
2515
|
+
await startSilentUpgrade("9.82.0");
|
|
2516
2516
|
}
|
|
2517
2517
|
const { org, name, version } = parseIdentifier(identifier);
|
|
2518
2518
|
let composeId;
|
|
@@ -4268,7 +4268,7 @@ var cookAction = new Command35().name("cook").description("Quick start: prepare,
|
|
|
4268
4268
|
withErrorHandler(
|
|
4269
4269
|
async (prompt, options) => {
|
|
4270
4270
|
if (options.autoUpdate !== false) {
|
|
4271
|
-
const shouldExit = await checkAndUpgrade("9.
|
|
4271
|
+
const shouldExit = await checkAndUpgrade("9.82.0", prompt);
|
|
4272
4272
|
if (shouldExit) {
|
|
4273
4273
|
process.exit(0);
|
|
4274
4274
|
}
|
|
@@ -5434,13 +5434,13 @@ var upgradeCommand = new Command42().name("upgrade").description("Upgrade vm0 CL
|
|
|
5434
5434
|
if (latestVersion === null) {
|
|
5435
5435
|
throw new Error("Could not check for updates. Please try again later.");
|
|
5436
5436
|
}
|
|
5437
|
-
if (latestVersion === "9.
|
|
5438
|
-
console.log(chalk36.green(`\u2713 Already up to date (${"9.
|
|
5437
|
+
if (latestVersion === "9.82.0") {
|
|
5438
|
+
console.log(chalk36.green(`\u2713 Already up to date (${"9.82.0"})`));
|
|
5439
5439
|
return;
|
|
5440
5440
|
}
|
|
5441
5441
|
console.log(
|
|
5442
5442
|
chalk36.yellow(
|
|
5443
|
-
`Current version: ${"9.
|
|
5443
|
+
`Current version: ${"9.82.0"} -> Latest version: ${latestVersion}`
|
|
5444
5444
|
)
|
|
5445
5445
|
);
|
|
5446
5446
|
console.log();
|
|
@@ -5467,7 +5467,7 @@ var upgradeCommand = new Command42().name("upgrade").description("Upgrade vm0 CL
|
|
|
5467
5467
|
const success = await performUpgrade(packageManager);
|
|
5468
5468
|
if (success) {
|
|
5469
5469
|
console.log(
|
|
5470
|
-
chalk36.green(`\u2713 Upgraded from ${"9.
|
|
5470
|
+
chalk36.green(`\u2713 Upgraded from ${"9.82.0"} to ${latestVersion}`)
|
|
5471
5471
|
);
|
|
5472
5472
|
return;
|
|
5473
5473
|
}
|
|
@@ -5535,7 +5535,7 @@ var whoamiCommand = new Command43().name("whoami").description("Show current ide
|
|
|
5535
5535
|
|
|
5536
5536
|
// src/index.ts
|
|
5537
5537
|
var program = new Command44();
|
|
5538
|
-
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.
|
|
5538
|
+
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.82.0");
|
|
5539
5539
|
program.addCommand(authCommand);
|
|
5540
5540
|
program.addCommand(infoCommand);
|
|
5541
5541
|
program.addCommand(composeCommand);
|
package/package.json
CHANGED
package/zero.js
CHANGED
|
@@ -67,6 +67,7 @@ import {
|
|
|
67
67
|
removeZeroOrgMember,
|
|
68
68
|
resolveZeroScheduleByAgent,
|
|
69
69
|
saveConfig,
|
|
70
|
+
sendSlackMessage,
|
|
70
71
|
setZeroOrgModelProviderDefault,
|
|
71
72
|
setZeroOrgSecret,
|
|
72
73
|
setZeroOrgVariable,
|
|
@@ -79,10 +80,10 @@ import {
|
|
|
79
80
|
updateZeroUserPreferences,
|
|
80
81
|
upsertZeroOrgModelProvider,
|
|
81
82
|
withErrorHandler
|
|
82
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-RGS2GO4Q.js";
|
|
83
84
|
|
|
84
85
|
// src/zero.ts
|
|
85
|
-
import { Command as
|
|
86
|
+
import { Command as Command55 } from "commander";
|
|
86
87
|
|
|
87
88
|
// src/commands/zero/org/index.ts
|
|
88
89
|
import { Command as Command23 } from "commander";
|
|
@@ -1427,7 +1428,8 @@ async function connectComputer() {
|
|
|
1427
1428
|
async function resolveAuthMethod(connectorType, tokenFlag) {
|
|
1428
1429
|
const config = CONNECTOR_TYPES[connectorType];
|
|
1429
1430
|
const oauthFlag = CONNECTOR_TYPES[connectorType].featureFlag;
|
|
1430
|
-
const
|
|
1431
|
+
const orgId = await getActiveOrg();
|
|
1432
|
+
const oauthAvailable = "oauth" in config.authMethods && (!oauthFlag || await isFeatureEnabled(oauthFlag, { orgId }));
|
|
1431
1433
|
const apiTokenAvailable = "api-token" in config.authMethods;
|
|
1432
1434
|
if (tokenFlag) {
|
|
1433
1435
|
if (!apiTokenAvailable) {
|
|
@@ -1533,12 +1535,13 @@ var listCommand6 = new Command31().name("list").alias("ls").description("List al
|
|
|
1533
1535
|
withErrorHandler(async () => {
|
|
1534
1536
|
const result = await listZeroConnectors();
|
|
1535
1537
|
const connectedMap = new Map(result.connectors.map((c) => [c.type, c]));
|
|
1538
|
+
const orgId = await getActiveOrg();
|
|
1536
1539
|
const allTypesRaw = Object.keys(CONNECTOR_TYPES);
|
|
1537
1540
|
const allTypes = [];
|
|
1538
1541
|
for (const type of allTypesRaw) {
|
|
1539
1542
|
const flag = CONNECTOR_TYPES[type].featureFlag;
|
|
1540
1543
|
const hasApiToken = "api-token" in CONNECTOR_TYPES[type].authMethods;
|
|
1541
|
-
if (flag && !await isFeatureEnabled(flag) && !hasApiToken) {
|
|
1544
|
+
if (flag && !await isFeatureEnabled(flag, { orgId }) && !hasApiToken) {
|
|
1542
1545
|
continue;
|
|
1543
1546
|
}
|
|
1544
1547
|
allTypes.push(type);
|
|
@@ -1785,49 +1788,22 @@ function isValidTimezone(timezone) {
|
|
|
1785
1788
|
return false;
|
|
1786
1789
|
}
|
|
1787
1790
|
}
|
|
1788
|
-
function parseOnOff(flag, value) {
|
|
1789
|
-
const lower = value.toLowerCase();
|
|
1790
|
-
if (lower === "on" || lower === "true" || lower === "1") return true;
|
|
1791
|
-
if (lower === "off" || lower === "false" || lower === "0") return false;
|
|
1792
|
-
throw new Error(
|
|
1793
|
-
`Invalid value for --${flag}: "${value}". Use "on" or "off".`
|
|
1794
|
-
);
|
|
1795
|
-
}
|
|
1796
1791
|
function displayPreferences(prefs) {
|
|
1797
1792
|
console.log(chalk31.bold("Current preferences:"));
|
|
1798
1793
|
console.log(
|
|
1799
1794
|
` Timezone: ${prefs.timezone ? chalk31.cyan(prefs.timezone) : chalk31.dim("not set")}`
|
|
1800
1795
|
);
|
|
1801
|
-
console.log(
|
|
1802
|
-
` Email notify: ${prefs.notifyEmail ? chalk31.green("on") : chalk31.dim("off")}`
|
|
1803
|
-
);
|
|
1804
|
-
console.log(
|
|
1805
|
-
` Slack notify: ${prefs.notifySlack ? chalk31.green("on") : chalk31.dim("off")}`
|
|
1806
|
-
);
|
|
1807
1796
|
}
|
|
1808
1797
|
function buildUpdates(opts) {
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
throw new Error(`Invalid timezone: ${opts.timezone}`, {
|
|
1817
|
-
cause: new Error(
|
|
1818
|
-
"Use an IANA timezone identifier (e.g., America/New_York, Asia/Shanghai)"
|
|
1819
|
-
)
|
|
1820
|
-
});
|
|
1821
|
-
}
|
|
1822
|
-
updates.timezone = opts.timezone;
|
|
1823
|
-
}
|
|
1824
|
-
if (hasNotifyEmail) {
|
|
1825
|
-
updates.notifyEmail = parseOnOff("notify-email", opts.notifyEmail);
|
|
1826
|
-
}
|
|
1827
|
-
if (hasNotifySlack) {
|
|
1828
|
-
updates.notifySlack = parseOnOff("notify-slack", opts.notifySlack);
|
|
1798
|
+
if (opts.timezone === void 0) return null;
|
|
1799
|
+
if (!isValidTimezone(opts.timezone)) {
|
|
1800
|
+
throw new Error(`Invalid timezone: ${opts.timezone}`, {
|
|
1801
|
+
cause: new Error(
|
|
1802
|
+
"Use an IANA timezone identifier (e.g., America/New_York, Asia/Shanghai)"
|
|
1803
|
+
)
|
|
1804
|
+
});
|
|
1829
1805
|
}
|
|
1830
|
-
return
|
|
1806
|
+
return { timezone: opts.timezone };
|
|
1831
1807
|
}
|
|
1832
1808
|
function printUpdateResult(updates, result) {
|
|
1833
1809
|
if (updates.timezone !== void 0) {
|
|
@@ -1837,20 +1813,6 @@ function printUpdateResult(updates, result) {
|
|
|
1837
1813
|
)
|
|
1838
1814
|
);
|
|
1839
1815
|
}
|
|
1840
|
-
if (updates.notifyEmail !== void 0) {
|
|
1841
|
-
console.log(
|
|
1842
|
-
chalk31.green(
|
|
1843
|
-
`Email notifications ${result.notifyEmail ? "enabled" : "disabled"}`
|
|
1844
|
-
)
|
|
1845
|
-
);
|
|
1846
|
-
}
|
|
1847
|
-
if (updates.notifySlack !== void 0) {
|
|
1848
|
-
console.log(
|
|
1849
|
-
chalk31.green(
|
|
1850
|
-
`Slack notifications ${result.notifySlack ? "enabled" : "disabled"}`
|
|
1851
|
-
)
|
|
1852
|
-
);
|
|
1853
|
-
}
|
|
1854
1816
|
}
|
|
1855
1817
|
async function interactiveSetup(prefs) {
|
|
1856
1818
|
if (!prefs.timezone) {
|
|
@@ -1869,18 +1831,8 @@ System timezone detected: ${detectedTz}`));
|
|
|
1869
1831
|
console.log(chalk31.green(`Timezone set to ${chalk31.cyan(tz.trim())}`));
|
|
1870
1832
|
}
|
|
1871
1833
|
}
|
|
1872
|
-
if (!prefs.notifyEmail) {
|
|
1873
|
-
const enable = await promptConfirm(
|
|
1874
|
-
"\nEnable email notifications for scheduled runs?",
|
|
1875
|
-
false
|
|
1876
|
-
);
|
|
1877
|
-
if (enable) {
|
|
1878
|
-
await updateZeroUserPreferences({ notifyEmail: true });
|
|
1879
|
-
console.log(chalk31.green("Email notifications enabled"));
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
1834
|
}
|
|
1883
|
-
var zeroPreferenceCommand = new Command35().name("preference").description("View or update your preferences").option("--timezone <timezone>", "IANA timezone (e.g., America/New_York)").
|
|
1835
|
+
var zeroPreferenceCommand = new Command35().name("preference").description("View or update your preferences").option("--timezone <timezone>", "IANA timezone (e.g., America/New_York)").action(
|
|
1884
1836
|
withErrorHandler(async (opts) => {
|
|
1885
1837
|
const updates = buildUpdates(opts);
|
|
1886
1838
|
if (updates) {
|
|
@@ -2769,49 +2721,104 @@ var deleteCommand4 = new Command45().name("delete").description("Delete a secret
|
|
|
2769
2721
|
// src/commands/zero/secret/index.ts
|
|
2770
2722
|
var zeroSecretCommand = new Command46().name("secret").description("Manage secrets").addCommand(listCommand8).addCommand(setCommand4).addCommand(deleteCommand4);
|
|
2771
2723
|
|
|
2772
|
-
// src/commands/zero/
|
|
2773
|
-
import { Command as
|
|
2724
|
+
// src/commands/zero/slack/index.ts
|
|
2725
|
+
import { Command as Command49 } from "commander";
|
|
2774
2726
|
|
|
2775
|
-
// src/commands/zero/
|
|
2727
|
+
// src/commands/zero/slack/message/index.ts
|
|
2728
|
+
import { Command as Command48 } from "commander";
|
|
2729
|
+
|
|
2730
|
+
// src/commands/zero/slack/message/send.ts
|
|
2731
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
2776
2732
|
import { Command as Command47 } from "commander";
|
|
2777
2733
|
import chalk41 from "chalk";
|
|
2734
|
+
var sendCommand = new Command47().name("send").description("Send a message to a Slack channel").requiredOption("-c, --channel <id>", "Channel ID").option("-t, --text <message>", "Message text").option("--thread <ts>", "Thread timestamp for replies").option("--blocks <json>", "Block Kit JSON string").action(
|
|
2735
|
+
withErrorHandler(
|
|
2736
|
+
async (options) => {
|
|
2737
|
+
let text = options.text;
|
|
2738
|
+
const { channel, thread, blocks: blocksStr } = options;
|
|
2739
|
+
if (!text && process.stdin.isTTY === false) {
|
|
2740
|
+
text = readFileSync3("/dev/stdin", "utf8").trim();
|
|
2741
|
+
}
|
|
2742
|
+
let blocks;
|
|
2743
|
+
if (blocksStr) {
|
|
2744
|
+
try {
|
|
2745
|
+
blocks = JSON.parse(blocksStr);
|
|
2746
|
+
} catch {
|
|
2747
|
+
throw new Error("Invalid JSON for --blocks flag", {
|
|
2748
|
+
cause: new Error(
|
|
2749
|
+
"Provide a valid JSON array of Block Kit blocks"
|
|
2750
|
+
)
|
|
2751
|
+
});
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
if (!text && !blocks) {
|
|
2755
|
+
throw new Error("Either --text or --blocks must be provided", {
|
|
2756
|
+
cause: new Error(
|
|
2757
|
+
'Usage: zero slack message send -c CHANNEL_ID -t "your message"'
|
|
2758
|
+
)
|
|
2759
|
+
});
|
|
2760
|
+
}
|
|
2761
|
+
const result = await sendSlackMessage({
|
|
2762
|
+
channel,
|
|
2763
|
+
text: text || void 0,
|
|
2764
|
+
threadTs: thread,
|
|
2765
|
+
blocks
|
|
2766
|
+
});
|
|
2767
|
+
const tsInfo = result.ts ? ` (ts: ${result.ts})` : "";
|
|
2768
|
+
console.log(chalk41.green(`\u2713 Message sent${tsInfo}`));
|
|
2769
|
+
}
|
|
2770
|
+
)
|
|
2771
|
+
);
|
|
2772
|
+
|
|
2773
|
+
// src/commands/zero/slack/message/index.ts
|
|
2774
|
+
var zeroSlackMessageCommand = new Command48().name("message").description("Manage Slack messages").addCommand(sendCommand);
|
|
2775
|
+
|
|
2776
|
+
// src/commands/zero/slack/index.ts
|
|
2777
|
+
var zeroSlackCommand = new Command49().name("slack").description("Manage Slack integrations").addCommand(zeroSlackMessageCommand);
|
|
2778
|
+
|
|
2779
|
+
// src/commands/zero/variable/index.ts
|
|
2780
|
+
import { Command as Command53 } from "commander";
|
|
2781
|
+
|
|
2782
|
+
// src/commands/zero/variable/list.ts
|
|
2783
|
+
import { Command as Command50 } from "commander";
|
|
2784
|
+
import chalk42 from "chalk";
|
|
2778
2785
|
function truncateValue2(value, maxLength = 60) {
|
|
2779
2786
|
if (value.length <= maxLength) {
|
|
2780
2787
|
return value;
|
|
2781
2788
|
}
|
|
2782
2789
|
return value.slice(0, maxLength - 15) + "... [truncated]";
|
|
2783
2790
|
}
|
|
2784
|
-
var listCommand9 = new
|
|
2791
|
+
var listCommand9 = new Command50().name("list").alias("ls").description("List all variables").action(
|
|
2785
2792
|
withErrorHandler(async () => {
|
|
2786
2793
|
const result = await listZeroVariables();
|
|
2787
2794
|
if (result.variables.length === 0) {
|
|
2788
|
-
console.log(
|
|
2795
|
+
console.log(chalk42.dim("No variables found"));
|
|
2789
2796
|
console.log();
|
|
2790
2797
|
console.log("To add a variable:");
|
|
2791
|
-
console.log(
|
|
2798
|
+
console.log(chalk42.cyan(" zero variable set MY_VAR <value>"));
|
|
2792
2799
|
return;
|
|
2793
2800
|
}
|
|
2794
|
-
console.log(
|
|
2801
|
+
console.log(chalk42.bold("Variables:"));
|
|
2795
2802
|
console.log();
|
|
2796
2803
|
for (const variable of result.variables) {
|
|
2797
2804
|
const displayValue = truncateValue2(variable.value);
|
|
2798
|
-
console.log(` ${
|
|
2805
|
+
console.log(` ${chalk42.cyan(variable.name)} = ${displayValue}`);
|
|
2799
2806
|
if (variable.description) {
|
|
2800
|
-
console.log(` ${
|
|
2807
|
+
console.log(` ${chalk42.dim(variable.description)}`);
|
|
2801
2808
|
}
|
|
2802
2809
|
console.log(
|
|
2803
|
-
` ${
|
|
2810
|
+
` ${chalk42.dim(`Updated: ${new Date(variable.updatedAt).toLocaleString()}`)}`
|
|
2804
2811
|
);
|
|
2805
2812
|
console.log();
|
|
2806
2813
|
}
|
|
2807
|
-
console.log(
|
|
2814
|
+
console.log(chalk42.dim(`Total: ${result.variables.length} variable(s)`));
|
|
2808
2815
|
})
|
|
2809
2816
|
);
|
|
2810
2817
|
|
|
2811
2818
|
// src/commands/zero/variable/set.ts
|
|
2812
|
-
import { Command as
|
|
2813
|
-
import
|
|
2814
|
-
var setCommand5 = new
|
|
2819
|
+
import { Command as Command51 } from "commander";
|
|
2820
|
+
import chalk43 from "chalk";
|
|
2821
|
+
var setCommand5 = new Command51().name("set").description("Create or update a variable").argument("<name>", "Variable name (uppercase, e.g., MY_VAR)").argument("<value>", "Variable value").option("-d, --description <description>", "Optional description").action(
|
|
2815
2822
|
withErrorHandler(
|
|
2816
2823
|
async (name, value, options) => {
|
|
2817
2824
|
let variable;
|
|
@@ -2831,15 +2838,15 @@ var setCommand5 = new Command48().name("set").description("Create or update a va
|
|
|
2831
2838
|
}
|
|
2832
2839
|
throw error;
|
|
2833
2840
|
}
|
|
2834
|
-
console.log(
|
|
2841
|
+
console.log(chalk43.green(`\u2713 Variable "${variable.name}" saved`));
|
|
2835
2842
|
}
|
|
2836
2843
|
)
|
|
2837
2844
|
);
|
|
2838
2845
|
|
|
2839
2846
|
// src/commands/zero/variable/delete.ts
|
|
2840
|
-
import { Command as
|
|
2841
|
-
import
|
|
2842
|
-
var deleteCommand5 = new
|
|
2847
|
+
import { Command as Command52 } from "commander";
|
|
2848
|
+
import chalk44 from "chalk";
|
|
2849
|
+
var deleteCommand5 = new Command52().name("delete").description("Delete a variable").argument("<name>", "Variable name to delete").option("-y, --yes", "Skip confirmation prompt").action(
|
|
2843
2850
|
withErrorHandler(async (name, options) => {
|
|
2844
2851
|
if (!options.yes) {
|
|
2845
2852
|
if (!isInteractive()) {
|
|
@@ -2850,36 +2857,36 @@ var deleteCommand5 = new Command49().name("delete").description("Delete a variab
|
|
|
2850
2857
|
false
|
|
2851
2858
|
);
|
|
2852
2859
|
if (!confirmed) {
|
|
2853
|
-
console.log(
|
|
2860
|
+
console.log(chalk44.dim("Cancelled"));
|
|
2854
2861
|
return;
|
|
2855
2862
|
}
|
|
2856
2863
|
}
|
|
2857
2864
|
await deleteZeroVariable(name);
|
|
2858
|
-
console.log(
|
|
2865
|
+
console.log(chalk44.green(`\u2713 Variable "${name}" deleted`));
|
|
2859
2866
|
})
|
|
2860
2867
|
);
|
|
2861
2868
|
|
|
2862
2869
|
// src/commands/zero/variable/index.ts
|
|
2863
|
-
var zeroVariableCommand = new
|
|
2870
|
+
var zeroVariableCommand = new Command53().name("variable").description("Manage variables").addCommand(listCommand9).addCommand(setCommand5).addCommand(deleteCommand5);
|
|
2864
2871
|
|
|
2865
2872
|
// src/commands/zero/whoami.ts
|
|
2866
|
-
import { Command as
|
|
2867
|
-
import
|
|
2873
|
+
import { Command as Command54 } from "commander";
|
|
2874
|
+
import chalk45 from "chalk";
|
|
2868
2875
|
function isInsideSandbox() {
|
|
2869
2876
|
return !!process.env.ZERO_AGENT_ID;
|
|
2870
2877
|
}
|
|
2871
2878
|
async function showSandboxInfo() {
|
|
2872
2879
|
const agentId = process.env.ZERO_AGENT_ID;
|
|
2873
2880
|
const payload = decodeZeroTokenPayload();
|
|
2874
|
-
console.log(
|
|
2881
|
+
console.log(chalk45.bold("Agent:"));
|
|
2875
2882
|
console.log(` ID: ${agentId}`);
|
|
2876
2883
|
console.log();
|
|
2877
|
-
console.log(
|
|
2878
|
-
console.log(` ID: ${payload?.runId ??
|
|
2879
|
-
console.log(` Org: ${payload?.orgId ??
|
|
2884
|
+
console.log(chalk45.bold("Run:"));
|
|
2885
|
+
console.log(` ID: ${payload?.runId ?? chalk45.dim("unavailable")}`);
|
|
2886
|
+
console.log(` Org: ${payload?.orgId ?? chalk45.dim("unavailable")}`);
|
|
2880
2887
|
if (payload?.capabilities?.length) {
|
|
2881
2888
|
console.log();
|
|
2882
|
-
console.log(
|
|
2889
|
+
console.log(chalk45.bold("Capabilities:"));
|
|
2883
2890
|
console.log(` ${payload.capabilities.join(", ")}`);
|
|
2884
2891
|
}
|
|
2885
2892
|
}
|
|
@@ -2887,23 +2894,23 @@ async function showLocalInfo() {
|
|
|
2887
2894
|
const token = await getToken();
|
|
2888
2895
|
const apiUrl = await getApiUrl();
|
|
2889
2896
|
const activeOrg = await getActiveOrg();
|
|
2890
|
-
console.log(
|
|
2897
|
+
console.log(chalk45.bold("Auth:"));
|
|
2891
2898
|
if (token) {
|
|
2892
2899
|
const tokenSource = process.env.ZERO_TOKEN ? "ZERO_TOKEN env var" : process.env.VM0_TOKEN ? "VM0_TOKEN env var" : "config file";
|
|
2893
2900
|
console.log(
|
|
2894
|
-
` Status: ${
|
|
2901
|
+
` Status: ${chalk45.green("Authenticated")} (via ${tokenSource})`
|
|
2895
2902
|
);
|
|
2896
2903
|
} else {
|
|
2897
|
-
console.log(` Status: ${
|
|
2904
|
+
console.log(` Status: ${chalk45.dim("Not authenticated")}`);
|
|
2898
2905
|
}
|
|
2899
2906
|
console.log(` API: ${apiUrl}`);
|
|
2900
2907
|
console.log();
|
|
2901
2908
|
if (activeOrg) {
|
|
2902
|
-
console.log(
|
|
2909
|
+
console.log(chalk45.bold("Org:"));
|
|
2903
2910
|
console.log(` Active: ${activeOrg}`);
|
|
2904
2911
|
}
|
|
2905
2912
|
}
|
|
2906
|
-
var zeroWhoamiCommand = new
|
|
2913
|
+
var zeroWhoamiCommand = new Command54().name("whoami").description("Show current identity and environment information").action(
|
|
2907
2914
|
withErrorHandler(async () => {
|
|
2908
2915
|
if (isInsideSandbox()) {
|
|
2909
2916
|
await showSandboxInfo();
|
|
@@ -2914,14 +2921,51 @@ var zeroWhoamiCommand = new Command51().name("whoami").description("Show current
|
|
|
2914
2921
|
);
|
|
2915
2922
|
|
|
2916
2923
|
// src/zero.ts
|
|
2917
|
-
var
|
|
2918
|
-
|
|
2924
|
+
var COMMAND_CAPABILITY_MAP = {
|
|
2925
|
+
agent: "agent:read",
|
|
2926
|
+
schedule: "schedule:read",
|
|
2927
|
+
whoami: null
|
|
2928
|
+
};
|
|
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
|
+
function applyCapabilityVisibility(prog) {
|
|
2947
|
+
const token = process.env.ZERO_TOKEN;
|
|
2948
|
+
if (!token) return;
|
|
2949
|
+
const capabilities = decodeCapabilitiesFromZeroToken(token);
|
|
2950
|
+
if (!capabilities) return;
|
|
2951
|
+
for (const cmd of prog.commands) {
|
|
2952
|
+
const requiredCap = COMMAND_CAPABILITY_MAP[cmd.name()];
|
|
2953
|
+
if (requiredCap === void 0) {
|
|
2954
|
+
cmd._hidden = true;
|
|
2955
|
+
} else if (requiredCap !== null && !capabilities.includes(requiredCap)) {
|
|
2956
|
+
cmd._hidden = true;
|
|
2957
|
+
}
|
|
2958
|
+
}
|
|
2959
|
+
}
|
|
2960
|
+
var program = new Command55();
|
|
2961
|
+
program.name("zero").description("Zero CLI - Manage your zero platform").version("9.82.0");
|
|
2919
2962
|
program.addCommand(zeroOrgCommand);
|
|
2920
2963
|
program.addCommand(agentCommand);
|
|
2921
2964
|
program.addCommand(zeroConnectorCommand);
|
|
2922
2965
|
program.addCommand(zeroPreferenceCommand);
|
|
2923
2966
|
program.addCommand(zeroScheduleCommand);
|
|
2924
2967
|
program.addCommand(zeroSecretCommand);
|
|
2968
|
+
program.addCommand(zeroSlackCommand);
|
|
2925
2969
|
program.addCommand(zeroVariableCommand);
|
|
2926
2970
|
program.addCommand(zeroWhoamiCommand);
|
|
2927
2971
|
if (process.argv[1]?.endsWith("zero.js") || process.argv[1]?.endsWith("zero.ts") || process.argv[1]?.endsWith("zero")) {
|
|
@@ -2934,9 +2978,12 @@ if (process.argv[1]?.endsWith("zero.js") || process.argv[1]?.endsWith("zero.ts")
|
|
|
2934
2978
|
throw err;
|
|
2935
2979
|
});
|
|
2936
2980
|
configureGlobalProxyFromEnv();
|
|
2981
|
+
applyCapabilityVisibility(program);
|
|
2937
2982
|
program.parse();
|
|
2938
2983
|
}
|
|
2939
2984
|
export {
|
|
2985
|
+
applyCapabilityVisibility,
|
|
2986
|
+
decodeCapabilitiesFromZeroToken,
|
|
2940
2987
|
program
|
|
2941
2988
|
};
|
|
2942
2989
|
//# sourceMappingURL=zero.js.map
|