@vm0/cli 9.177.9 → 9.177.11

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.177.9",
3
+ "version": "9.177.11",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",
package/zero.js CHANGED
@@ -48,6 +48,7 @@ import {
48
48
  downloadWebFile,
49
49
  enableZeroSchedule,
50
50
  extractSecretNamesFromApis,
51
+ fetchComputerUseScreenshot,
51
52
  findMatchingPermissions,
52
53
  generateWebImage,
53
54
  generateWebVideo,
@@ -59,7 +60,7 @@ import {
59
60
  getConfiguredConnectorAuthMethods,
60
61
  getConnectorAuthMethod,
61
62
  getConnectorAuthMethodScopeDiff,
62
- getConnectorEnvBindings,
63
+ getConnectorEnvBindingEntries,
63
64
  getConnectorEnvNamesForSecret,
64
65
  getConnectorFirewall,
65
66
  getConnectorGenerationTypes,
@@ -146,7 +147,7 @@ import {
146
147
  upsertZeroOrgModelProvider,
147
148
  withErrorHandler,
148
149
  zeroAgentCustomSkillNameSchema
149
- } from "./chunk-HA7ZZ2L6.js";
150
+ } from "./chunk-26CIENVP.js";
150
151
  import {
151
152
  __toESM,
152
153
  init_esm_shims
@@ -1965,11 +1966,20 @@ function listSecretNames(config) {
1965
1966
  }
1966
1967
  return names;
1967
1968
  }
1969
+ function listEnvNames(type) {
1970
+ return [
1971
+ ...new Set(
1972
+ getConnectorEnvBindingEntries(type).map(({ envName }) => {
1973
+ return envName;
1974
+ })
1975
+ )
1976
+ ];
1977
+ }
1968
1978
  function findExactMatch(keywordLower, type, config) {
1969
1979
  if (type.toLowerCase() === keywordLower) {
1970
1980
  return { score: 100, matchedField: "type" };
1971
1981
  }
1972
- for (const envName of Object.keys(getConnectorEnvBindings(type))) {
1982
+ for (const envName of listEnvNames(type)) {
1973
1983
  if (envName.toLowerCase() === keywordLower) {
1974
1984
  return { score: 90, matchedField: `env:${envName}` };
1975
1985
  }
@@ -1992,7 +2002,7 @@ function findSubstringMatch(keywordLower, type, config) {
1992
2002
  if (config.label.toLowerCase().includes(keywordLower)) {
1993
2003
  return { score: 50, matchedField: "label" };
1994
2004
  }
1995
- for (const envName of Object.keys(getConnectorEnvBindings(type))) {
2005
+ for (const envName of listEnvNames(type)) {
1996
2006
  if (envName.toLowerCase().includes(keywordLower)) {
1997
2007
  return { score: 40, matchedField: `env:${envName}` };
1998
2008
  }
@@ -2015,7 +2025,7 @@ function collectCandidateTokens(type, config) {
2015
2025
  const sources = [
2016
2026
  type,
2017
2027
  config.label,
2018
- ...Object.keys(getConnectorEnvBindings(type)),
2028
+ ...listEnvNames(type),
2019
2029
  ...listSecretNames(config),
2020
2030
  ...config.tags ?? []
2021
2031
  ];
@@ -2561,10 +2571,10 @@ function resolveConnectorFromUrl(url) {
2561
2571
  }
2562
2572
  }
2563
2573
  if (!bestMatch) return null;
2564
- const envBindings = getConnectorEnvBindings(
2574
+ const envBindingEntries = getConnectorEnvBindingEntries(
2565
2575
  bestMatch.connectorType
2566
2576
  );
2567
- const envName = Object.keys(envBindings)[0];
2577
+ const envName = envBindingEntries[0]?.envName;
2568
2578
  if (!envName) return null;
2569
2579
  const relativePath = normalized === bestMatch.base ? "/" : normalized.slice(bestMatch.base.length);
2570
2580
  return {
@@ -6780,6 +6790,24 @@ async function writeScreenshotDataUrl(result, dataUrl) {
6780
6790
  await writeFile(outputPath, Buffer.from(base64Data, "base64"));
6781
6791
  return outputPath;
6782
6792
  }
6793
+ function screenshotPointerType(value) {
6794
+ if (typeof value !== "object" || value === null) {
6795
+ return null;
6796
+ }
6797
+ const type = value.type;
6798
+ return type === "s3" || type === "expired" ? type : null;
6799
+ }
6800
+ async function writeScreenshotBytes(result, buffer, mimeType) {
6801
+ const appName = sanitizeFilenamePart(result.app, "app");
6802
+ const snapshotId = sanitizeFilenamePart(result.snapshotId, "snapshot");
6803
+ const outputPath = join6(
6804
+ COMPUTER_USE_OUTPUT_DIR,
6805
+ `${appName}-${snapshotId}.${extensionForMimeType(mimeType)}`
6806
+ );
6807
+ await mkdir(COMPUTER_USE_OUTPUT_DIR, { recursive: true });
6808
+ await writeFile(outputPath, buffer);
6809
+ return outputPath;
6810
+ }
6783
6811
  async function writeAppStateText(result, appState) {
6784
6812
  const appName = sanitizeFilenamePart(result.app, "app");
6785
6813
  const snapshotId = sanitizeFilenamePart(result.snapshotId, "snapshot");
@@ -6800,7 +6828,7 @@ function compactActionResult(action) {
6800
6828
  }
6801
6829
  return compact;
6802
6830
  }
6803
- async function formatComputerUseResultForConsole(result) {
6831
+ async function formatComputerUseResultForConsole(result, commandId) {
6804
6832
  const printable = { status: "succeeded" };
6805
6833
  const apps = result.apps;
6806
6834
  if (Array.isArray(apps)) {
@@ -6814,10 +6842,22 @@ async function formatComputerUseResultForConsole(result) {
6814
6842
  if (appState) {
6815
6843
  printable.appState = await writeAppStateText(result, appState);
6816
6844
  }
6817
- const screenshot = stringField(result, "screenshot");
6818
- if (screenshot) {
6845
+ const screenshot = result.screenshot;
6846
+ if (typeof screenshot === "string") {
6819
6847
  const screenshotPath = await writeScreenshotDataUrl(result, screenshot);
6820
6848
  printable.screenshot = screenshotPath ?? screenshot;
6849
+ } else {
6850
+ const pointerType = screenshotPointerType(screenshot);
6851
+ if (pointerType === "s3") {
6852
+ const { buffer, mimeType } = await fetchComputerUseScreenshot(commandId);
6853
+ printable.screenshot = await writeScreenshotBytes(
6854
+ result,
6855
+ buffer,
6856
+ mimeType
6857
+ );
6858
+ } else if (pointerType === "expired") {
6859
+ printable.screenshot = "[screenshot expired]";
6860
+ }
6821
6861
  }
6822
6862
  const action = result.action;
6823
6863
  if (isRecord(action)) {
@@ -6829,7 +6869,7 @@ async function commandOutputText(command) {
6829
6869
  if (!command.result) {
6830
6870
  return "";
6831
6871
  }
6832
- return await formatComputerUseResultForConsole(command.result);
6872
+ return await formatComputerUseResultForConsole(command.result, command.id);
6833
6873
  }
6834
6874
  async function waitForCommand(commandId, timeoutSeconds) {
6835
6875
  const deadline = Date.now() + timeoutSeconds * 1e3;
@@ -13189,7 +13229,7 @@ function registerZeroCommands(prog, commands) {
13189
13229
  var program = new Command();
13190
13230
  program.name("zero").description(
13191
13231
  "Zero CLI \u2014 interact with the zero platform from inside the sandbox"
13192
- ).version("9.177.9").addHelpText("after", () => {
13232
+ ).version("9.177.11").addHelpText("after", () => {
13193
13233
  return buildZeroHelpText();
13194
13234
  });
13195
13235
  if (process.argv[1]?.endsWith("zero.js") || process.argv[1]?.endsWith("zero.ts") || process.argv[1]?.endsWith("zero")) {