@vm0/cli 9.151.0 → 9.152.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/index.js CHANGED
@@ -68,7 +68,7 @@ import {
68
68
  source_default,
69
69
  volumeConfigSchema,
70
70
  withErrorHandler
71
- } from "./chunk-VUZYX6DE.js";
71
+ } from "./chunk-T32CMT7F.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.151.0"}`));
390
+ console.log(source_default.bold(`VM0 CLI v${"9.152.0"}`));
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.151.0");
4283
+ await startSilentUpgrade("9.152.0");
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.151.0");
4375
+ await startSilentUpgrade("9.152.0");
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.151.0") {
6169
- console.log(source_default.green(`\u2713 Already up to date (${"9.151.0"})`));
6168
+ if (latestVersion === "9.152.0") {
6169
+ console.log(source_default.green(`\u2713 Already up to date (${"9.152.0"})`));
6170
6170
  return;
6171
6171
  }
6172
6172
  console.log(
6173
6173
  source_default.yellow(
6174
- `Current version: ${"9.151.0"} -> Latest version: ${latestVersion}`
6174
+ `Current version: ${"9.152.0"} -> 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.151.0"} to ${latestVersion}`)
6201
+ source_default.green(`\u2713 Upgraded from ${"9.152.0"} 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.151.0");
6268
+ program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.152.0");
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.151.0",
3
+ "version": "9.152.0",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",
package/zero.js CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  configureGlobalProxyFromEnv,
18
18
  connectorTypeSchema,
19
19
  createLocalBrowserReadCommand,
20
+ createLocalBrowserWriteCommand,
20
21
  createSkill,
21
22
  createZeroAgent,
22
23
  createZeroRun,
@@ -134,7 +135,7 @@ import {
134
135
  withErrorHandler,
135
136
  zeroAgentCustomSkillNameSchema,
136
137
  zeroRemoteAgentCommand
137
- } from "./chunk-VUZYX6DE.js";
138
+ } from "./chunk-T32CMT7F.js";
138
139
  import {
139
140
  __toESM,
140
141
  init_esm_shims
@@ -7700,6 +7701,24 @@ function parseTimeoutSeconds(value) {
7700
7701
  }
7701
7702
  return seconds;
7702
7703
  }
7704
+ function parseOptionalNonNegativeInteger(value, label) {
7705
+ if (value === void 0) return void 0;
7706
+ const parsed = Number.parseInt(value, 10);
7707
+ if (!Number.isFinite(parsed) || parsed < 0) {
7708
+ throw new Error(`${label} must be a non-negative integer`);
7709
+ }
7710
+ return parsed;
7711
+ }
7712
+ function parsePositiveInteger2(value, label) {
7713
+ if (value === void 0) {
7714
+ throw new Error(`${label} is required`);
7715
+ }
7716
+ const parsed = Number.parseInt(value, 10);
7717
+ if (!Number.isFinite(parsed) || parsed <= 0) {
7718
+ throw new Error(`${label} must be a positive integer`);
7719
+ }
7720
+ return parsed;
7721
+ }
7703
7722
  function resultText(command) {
7704
7723
  if (!command.result) {
7705
7724
  return "";
@@ -7741,9 +7760,52 @@ async function runReadCommand(kind, options) {
7741
7760
  }
7742
7761
  throw new Error(`Local-browser command timed out: ${created.commandId}`);
7743
7762
  }
7763
+ async function waitForCommand(commandId, timeoutSeconds) {
7764
+ const deadline = Date.now() + timeoutSeconds * 1e3;
7765
+ while (Date.now() <= deadline) {
7766
+ const command = await getLocalBrowserReadCommand(commandId);
7767
+ if (command.status === "pending_approval" || command.status === "queued" || command.status === "running") {
7768
+ if (process.stdout.isTTY) {
7769
+ process.stdout.write(".");
7770
+ }
7771
+ await sleep3(1e3);
7772
+ continue;
7773
+ }
7774
+ if (process.stdout.isTTY) {
7775
+ process.stdout.write("\n");
7776
+ }
7777
+ if (command.status === "failed") {
7778
+ throw new Error(
7779
+ command.error ? `${command.error.code}: ${command.error.message}` : "Local-browser command failed"
7780
+ );
7781
+ }
7782
+ const text = resultText(command);
7783
+ if (text) {
7784
+ console.log(text);
7785
+ }
7786
+ return;
7787
+ }
7788
+ throw new Error(`Local-browser command timed out: ${commandId}`);
7789
+ }
7790
+ async function runWriteCommand(kind, options, payload) {
7791
+ const timeoutSeconds = parseTimeoutSeconds(options.timeout);
7792
+ const created = await createLocalBrowserWriteCommand({
7793
+ kind,
7794
+ timeoutMs: timeoutSeconds * 1e3,
7795
+ ...options.tabId ? { tabId: options.tabId } : {},
7796
+ ...options.host ? { hostName: options.host } : {},
7797
+ ...options.hostId ? { hostId: options.hostId } : {},
7798
+ ...payload
7799
+ });
7800
+ await waitForCommand(created.commandId, timeoutSeconds);
7801
+ }
7744
7802
  function addReadOptions(command) {
7745
7803
  return command.option("--host <name>", "Run on a named local-browser host").option("--host-id <id>", "Run on a specific local-browser host id").option("--tab-id <id>", "Target a specific browser tab").option("--timeout <seconds>", "Maximum time to wait", "30");
7746
7804
  }
7805
+ function addWriteOptions(command, options = {}) {
7806
+ const withHostOptions = command.option("--host <name>", "Run on a named local-browser host").option("--host-id <id>", "Run on a specific local-browser host id").option("--timeout <seconds>", "Maximum time to wait", "30");
7807
+ return options.tabId === false ? withHostOptions : withHostOptions.option("--tab-id <id>", "Target a specific browser tab");
7808
+ }
7747
7809
  function readCommand(name, kind) {
7748
7810
  return addReadOptions(
7749
7811
  new Command().name(name).description(`Run ${kind}`).action(
@@ -7753,16 +7815,93 @@ function readCommand(name, kind) {
7753
7815
  )
7754
7816
  );
7755
7817
  }
7756
- var tabsCommand = new Command().name("tabs").description("Read browser tabs").addCommand(readCommand("list", "tabs.list")).addCommand(readCommand("current", "tabs.current"));
7757
- var pageCommand = new Command().name("page").description("Read the active browser page").addCommand(readCommand("snapshot", "page.snapshot")).addCommand(readCommand("screenshot", "page.screenshot")).addCommand(readCommand("selection", "page.selection")).addCommand(readCommand("metadata", "page.metadata"));
7818
+ var tabsCommand = new Command().name("tabs").description("Read and control browser tabs").addCommand(readCommand("list", "tabs.list")).addCommand(readCommand("current", "tabs.current")).addCommand(
7819
+ addWriteOptions(
7820
+ new Command().name("activate").description("Run tabs.activate").requiredOption("--tab-id <id>", "Tab to activate").action(
7821
+ withErrorHandler(async (options) => {
7822
+ await runWriteCommand("tabs.activate", options, {});
7823
+ })
7824
+ ),
7825
+ { tabId: false }
7826
+ )
7827
+ ).addCommand(
7828
+ addWriteOptions(
7829
+ new Command().name("open").description("Run tabs.open").requiredOption("--url <url>", "URL to open").action(
7830
+ withErrorHandler(async (options) => {
7831
+ await runWriteCommand("tabs.open", options, { url: options.url });
7832
+ })
7833
+ )
7834
+ )
7835
+ ).addCommand(
7836
+ addWriteOptions(
7837
+ new Command().name("close").description("Run tabs.close").requiredOption("--tab-id <id>", "Tab to close").action(
7838
+ withErrorHandler(async (options) => {
7839
+ await runWriteCommand("tabs.close", options, {});
7840
+ })
7841
+ ),
7842
+ { tabId: false }
7843
+ )
7844
+ );
7845
+ var pageCommand = new Command().name("page").description("Read and control the active browser page").addCommand(readCommand("snapshot", "page.snapshot")).addCommand(readCommand("screenshot", "page.screenshot")).addCommand(readCommand("selection", "page.selection")).addCommand(readCommand("metadata", "page.metadata")).addCommand(
7846
+ addWriteOptions(
7847
+ new Command().name("click").description("Run page.click").option("--selector <selector>", "CSS selector to click").option("--x <pixels>", "X coordinate to click").option("--y <pixels>", "Y coordinate to click").action(
7848
+ withErrorHandler(async (options) => {
7849
+ await runWriteCommand("page.click", options, {
7850
+ ...options.selector ? { selector: options.selector } : {},
7851
+ ...options.x !== void 0 ? { x: parseOptionalNonNegativeInteger(options.x, "x") } : {},
7852
+ ...options.y !== void 0 ? { y: parseOptionalNonNegativeInteger(options.y, "y") } : {}
7853
+ });
7854
+ })
7855
+ )
7856
+ )
7857
+ ).addCommand(
7858
+ addWriteOptions(
7859
+ new Command().name("type").description("Run page.type").requiredOption("--selector <selector>", "CSS selector to type into").requiredOption("--text <text>", "Text to type").action(
7860
+ withErrorHandler(async (options) => {
7861
+ await runWriteCommand("page.type", options, {
7862
+ selector: options.selector,
7863
+ text: options.text
7864
+ });
7865
+ })
7866
+ )
7867
+ )
7868
+ ).addCommand(
7869
+ addWriteOptions(
7870
+ new Command().name("scroll").description("Run page.scroll").option(
7871
+ "--direction <direction>",
7872
+ "Scroll direction: up or down",
7873
+ "down"
7874
+ ).option("--amount <pixels>", "Scroll amount in pixels", "600").action(
7875
+ withErrorHandler(async (options) => {
7876
+ if (options.direction !== "up" && options.direction !== "down") {
7877
+ throw new Error("direction must be up or down");
7878
+ }
7879
+ await runWriteCommand("page.scroll", options, {
7880
+ direction: options.direction,
7881
+ amount: parsePositiveInteger2(options.amount, "amount")
7882
+ });
7883
+ })
7884
+ )
7885
+ )
7886
+ ).addCommand(
7887
+ addWriteOptions(
7888
+ new Command().name("navigate").description("Run page.navigate").requiredOption("--url <url>", "URL to navigate to").action(
7889
+ withErrorHandler(async (options) => {
7890
+ await runWriteCommand("page.navigate", options, {
7891
+ url: options.url
7892
+ });
7893
+ })
7894
+ )
7895
+ )
7896
+ );
7758
7897
  var zeroLocalBrowserCommand = new Command().name("local-browser").description("Read authorized browser context").addHelpText(
7759
7898
  "after",
7760
7899
  `
7761
7900
  Examples:
7762
7901
  List tabs? zero local-browser tabs list
7763
7902
  Current tab? zero local-browser tabs current
7764
- Page metadata? zero local-browser page metadata
7765
- Page selection? zero local-browser page selection`
7903
+ Click page? zero local-browser page click --selector button
7904
+ Open tab? zero local-browser tabs open --url https://example.com`
7766
7905
  ).addCommand(tabsCommand).addCommand(pageCommand);
7767
7906
 
7768
7907
  // src/commands/zero/host/index.ts
@@ -8084,7 +8223,7 @@ var COMMAND_CAPABILITY_MAP = {
8084
8223
  web: null,
8085
8224
  host: "host:write",
8086
8225
  "remote-agent": ["remote-agent:read", "remote-agent:write"],
8087
- "local-browser": "local-browser:read"
8226
+ "local-browser": ["local-browser:read", "local-browser:write"]
8088
8227
  };
8089
8228
  var DEFAULT_COMMANDS = [
8090
8229
  zeroOrgCommand,
@@ -8159,7 +8298,7 @@ function registerZeroCommands(prog, commands) {
8159
8298
  var program = new Command();
8160
8299
  program.name("zero").description(
8161
8300
  "Zero CLI \u2014 interact with the zero platform from inside the sandbox"
8162
- ).version("9.151.0").addHelpText("after", () => {
8301
+ ).version("9.152.0").addHelpText("after", () => {
8163
8302
  return buildZeroHelpText();
8164
8303
  });
8165
8304
  if (process.argv[1]?.endsWith("zero.js") || process.argv[1]?.endsWith("zero.ts") || process.argv[1]?.endsWith("zero")) {