@vm0/cli 9.209.3 → 9.210.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.209.3",
3
+ "version": "9.210.0",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",
package/zero.js CHANGED
@@ -69,6 +69,7 @@ import {
69
69
  findTool,
70
70
  findVideoTemplate,
71
71
  formatBytes,
72
+ formatIsoTimestamp,
72
73
  generateWebImage,
73
74
  generateWebVideo,
74
75
  generateWebVoice,
@@ -107,6 +108,7 @@ import {
107
108
  initTelegramFileUpload,
108
109
  inviteZeroOrgMember,
109
110
  isInteractive,
111
+ isSupportedFramework,
110
112
  isUUID,
111
113
  leaveZeroOrg,
112
114
  listAutomations,
@@ -130,8 +132,9 @@ import {
130
132
  listZeroUserPermissionGrants,
131
133
  listZeroVariables,
132
134
  matchFirewallBaseUrl,
133
- parseEvent,
135
+ parseBoundedLogCount,
134
136
  parsePositiveLogCount,
137
+ parseSearchQuery,
135
138
  parseTime,
136
139
  pauseGoal,
137
140
  prepareHostedSite,
@@ -146,7 +149,6 @@ import {
146
149
  resumeGoal,
147
150
  runAutomation,
148
151
  runWorkflow,
149
- runWorkflowTrigger,
150
152
  saveConfig,
151
153
  searchZeroChat,
152
154
  searchZeroConnectors,
@@ -178,7 +180,7 @@ import {
178
180
  uploadWebFile,
179
181
  upsertZeroOrgModelProvider,
180
182
  withErrorHandler
181
- } from "./chunk-O6UJMPWI.js";
183
+ } from "./chunk-6EGWCGWC.js";
182
184
  import {
183
185
  CONNECTOR_TYPES,
184
186
  CONNECTOR_TYPE_KEYS,
@@ -6169,7 +6171,7 @@ var GENERATED_RUNTIME_FIREWALL_LOADERS = {
6169
6171
  return (await import("./fal.generated-TQ7AQFJJ.js")).falFirewall;
6170
6172
  },
6171
6173
  "figma": async () => {
6172
- return (await import("./figma.generated-7FWIRN56.js")).figmaFirewall;
6174
+ return (await import("./figma.generated-EJXHASDR.js")).figmaFirewall;
6173
6175
  },
6174
6176
  "firecrawl": async () => {
6175
6177
  return (await import("./firecrawl.generated-JJ5JQJTV.js")).firecrawlFirewall;
@@ -10688,16 +10690,7 @@ var disableCommand2 = new Command().name("disable").description("Disable a workf
10688
10690
  console.log(source_default.green(`\u2713 Trigger ${trigger.id} disabled`));
10689
10691
  })
10690
10692
  );
10691
- var runCommand3 = new Command().name("run").description("Fire a workflow trigger test run").argument("<trigger>", "Workflow trigger ID").action(
10692
- withErrorHandler(async (id) => {
10693
- const result = await runWorkflowTrigger(id);
10694
- console.log(source_default.green(`\u2713 Workflow trigger ${id} run started`));
10695
- console.log(` Run ID: ${result.runId}`);
10696
- console.log();
10697
- console.log(`Stream logs: zero logs ${result.runId}`);
10698
- })
10699
- );
10700
- var triggerCommand = new Command().name("trigger").description("Manage a workflow's triggers").addCommand(addCommand).addCommand(updateCommand3).addCommand(listCommand14).addCommand(showCommand2).addCommand(rmCommand).addCommand(enableCommand2).addCommand(disableCommand2).addCommand(runCommand3).addHelpText(
10693
+ var triggerCommand = new Command().name("trigger").description("Manage a workflow's triggers").addCommand(addCommand).addCommand(updateCommand3).addCommand(listCommand14).addCommand(showCommand2).addCommand(rmCommand).addCommand(enableCommand2).addCommand(disableCommand2).addHelpText(
10701
10694
  "after",
10702
10695
  `
10703
10696
  Examples:
@@ -10705,7 +10698,6 @@ Examples:
10705
10698
  Update a schedule: zero workflow trigger update <trigger-id> --every 10m
10706
10699
  List triggers: zero workflow trigger list <workflow>
10707
10700
  Inspect a trigger: zero workflow trigger show <trigger-id>
10708
- Test run: zero workflow trigger run <trigger-id>
10709
10701
  Pause one trigger: zero workflow trigger disable <trigger-id>`
10710
10702
  );
10711
10703
 
@@ -10799,7 +10791,7 @@ function formatStatus(status) {
10799
10791
  }
10800
10792
  }
10801
10793
  function formatTime(iso) {
10802
- return new Date(iso).toISOString().replace(/\.\d{3}Z$/, "Z");
10794
+ return formatIsoTimestamp(iso);
10803
10795
  }
10804
10796
  var listCommand15 = new Command().name("list").alias("ls").description("List agent run logs").option("--agent <id>", "Filter by Zero agent ID").option(
10805
10797
  "--status <status>",
@@ -10819,8 +10811,19 @@ Examples:
10819
10811
  ).action(
10820
10812
  withErrorHandler(
10821
10813
  async (options) => {
10822
- const limit = options.limit ? parseInt(options.limit, 10) : void 0;
10823
- const since = options.since ? parseTime(options.since) : void 0;
10814
+ const limit = options.limit !== void 0 ? parseBoundedLogCount(options.limit, "--limit", 1, 100) : void 0;
10815
+ const since = options.since !== void 0 ? parseTime(options.since) : void 0;
10816
+ if (options.agent !== void 0 && !isUUID(options.agent)) {
10817
+ console.error(
10818
+ source_default.red(
10819
+ `\u2717 Invalid agent ID "${options.agent}" \u2014 expected a UUID`
10820
+ )
10821
+ );
10822
+ console.error(
10823
+ source_default.dim(" Run: zero logs list to find agent IDs")
10824
+ );
10825
+ process.exit(1);
10826
+ }
10824
10827
  const result = await listZeroLogs({
10825
10828
  agentId: options.agent,
10826
10829
  status: options.status,
@@ -10876,37 +10879,39 @@ Examples:
10876
10879
  // src/commands/zero/logs/search.ts
10877
10880
  init_esm_shims();
10878
10881
  var SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1e3;
10879
- function renderEvent(event, renderer) {
10880
- const eventData = event.eventData;
10881
- const parsed = parseEvent(eventData);
10882
- if (parsed) {
10883
- parsed.timestamp = new Date(event.createdAt);
10882
+ function supportedSearchFramework(framework) {
10883
+ const normalized = framework ?? void 0;
10884
+ return isSupportedFramework(normalized) ? normalized : void 0;
10885
+ }
10886
+ function renderSearchEvent(event, framework, renderer, normalizer) {
10887
+ const parsedEvents = normalizer.process(
10888
+ event.eventData,
10889
+ supportedSearchFramework(framework),
10890
+ new Date(event.createdAt)
10891
+ );
10892
+ for (const parsed of parsedEvents) {
10893
+ renderer.render(parsed);
10894
+ }
10895
+ }
10896
+ function flushSearchRenderer(renderer, normalizer) {
10897
+ for (const parsed of normalizer.flush()) {
10884
10898
  renderer.render(parsed);
10885
10899
  }
10900
+ renderer.flush();
10886
10901
  }
10887
10902
  function formatRunHeader(runId, agentName, timestamp) {
10888
- const time = new Date(timestamp).toISOString().replace(/\.\d{3}Z$/, "Z");
10903
+ const time = formatIsoTimestamp(timestamp);
10889
10904
  return `\u2500\u2500 Run ${runId} (${agentName}, ${time}) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`;
10890
10905
  }
10891
10906
  function parseContextOptions(options) {
10892
- const contextN = options.context ? parseInt(options.context, 10) : 0;
10893
- const before = options.beforeContext ? parseInt(options.beforeContext, 10) : contextN;
10894
- const after = options.afterContext ? parseInt(options.afterContext, 10) : contextN;
10895
- if (isNaN(before) || before < 0 || before > 10) {
10896
- throw new Error("--before-context must be between 0 and 10");
10897
- }
10898
- if (isNaN(after) || after < 0 || after > 10) {
10899
- throw new Error("--after-context must be between 0 and 10");
10900
- }
10907
+ const contextN = options.context !== void 0 ? parseBoundedLogCount(options.context, "--context", 0, 10) : 0;
10908
+ const before = options.beforeContext !== void 0 ? parseBoundedLogCount(options.beforeContext, "--before-context", 0, 10) : contextN;
10909
+ const after = options.afterContext !== void 0 ? parseBoundedLogCount(options.afterContext, "--after-context", 0, 10) : contextN;
10901
10910
  return { before, after };
10902
10911
  }
10903
10912
  function parseLimit2(value) {
10904
- if (!value) return void 0;
10905
- const limit = parseInt(value, 10);
10906
- if (isNaN(limit) || limit < 1 || limit > 50) {
10907
- throw new Error("--limit must be between 1 and 50");
10908
- }
10909
- return limit;
10913
+ if (value === void 0) return void 0;
10914
+ return parseBoundedLogCount(value, "--limit", 1, 50);
10910
10915
  }
10911
10916
  function renderResults(response) {
10912
10917
  const grouped = /* @__PURE__ */ new Map();
@@ -10934,16 +10939,22 @@ function renderResults(response) {
10934
10939
  for (const result of group.results) {
10935
10940
  const renderer = new EventRenderer({
10936
10941
  showTimestamp: true,
10937
- verbose: false,
10938
- buffered: false
10942
+ verbose: false
10939
10943
  });
10944
+ const normalizer = new EventStreamNormalizer();
10940
10945
  for (const event of result.contextBefore) {
10941
- renderEvent(event, renderer);
10946
+ renderSearchEvent(event, result.framework, renderer, normalizer);
10942
10947
  }
10943
- renderEvent(result.matchedEvent, renderer);
10948
+ renderSearchEvent(
10949
+ result.matchedEvent,
10950
+ result.framework,
10951
+ renderer,
10952
+ normalizer
10953
+ );
10944
10954
  for (const event of result.contextAfter) {
10945
- renderEvent(event, renderer);
10955
+ renderSearchEvent(event, result.framework, renderer, normalizer);
10946
10956
  }
10957
+ flushSearchRenderer(renderer, normalizer);
10947
10958
  }
10948
10959
  }
10949
10960
  if (response.hasMore) {
@@ -10956,18 +10967,26 @@ function renderResults(response) {
10956
10967
  }
10957
10968
  }
10958
10969
  async function runLogsSearch(keyword, options) {
10970
+ const searchKeyword = parseSearchQuery(keyword, "Keyword");
10959
10971
  const { before, after } = parseContextOptions(options);
10960
- if (options.run && !isUUID(options.run)) {
10972
+ if (options.agentId !== void 0 && !isUUID(options.agentId)) {
10973
+ console.error(
10974
+ source_default.red(`\u2717 Invalid agent ID "${options.agentId}" \u2014 expected a UUID`)
10975
+ );
10976
+ console.error(source_default.dim(" Run: zero logs list to find agent IDs"));
10977
+ process.exit(1);
10978
+ }
10979
+ if (options.run !== void 0 && !isUUID(options.run)) {
10961
10980
  console.error(
10962
10981
  source_default.red(`\u2717 Invalid run ID "${options.run}" \u2014 expected a UUID`)
10963
10982
  );
10964
10983
  console.error(source_default.dim(" Run: zero logs list to find run IDs"));
10965
10984
  process.exit(1);
10966
10985
  }
10967
- const since = options.since ? parseTime(options.since) : Date.now() - SEVEN_DAYS_MS;
10986
+ const since = options.since !== void 0 ? parseTime(options.since) : Date.now() - SEVEN_DAYS_MS;
10968
10987
  const limit = parseLimit2(options.limit);
10969
10988
  const response = await searchZeroLogs({
10970
- keyword,
10989
+ keyword: searchKeyword,
10971
10990
  agentId: options.agentId,
10972
10991
  runId: options.run,
10973
10992
  since,
@@ -11004,6 +11023,12 @@ Examples:
11004
11023
 
11005
11024
  // src/commands/zero/logs/index.ts
11006
11025
  var PAGE_LIMIT = 100;
11026
+ function supportedLogFramework(framework) {
11027
+ return isSupportedFramework(framework) ? framework : void 0;
11028
+ }
11029
+ function hasLogFramework(framework) {
11030
+ return framework !== void 0 && framework !== null;
11031
+ }
11007
11032
  function renderAgentEvent(event, renderer, normalizer, framework) {
11008
11033
  const parsedEvents = normalizer.process(
11009
11034
  event.eventData,
@@ -11015,13 +11040,21 @@ function renderAgentEvent(event, renderer, normalizer, framework) {
11015
11040
  }
11016
11041
  }
11017
11042
  async function showAgentEvents(runId, options) {
11018
- let framework = "claude-code";
11019
11043
  const events = await collectLogItems({
11020
11044
  fetchPage: async (request) => {
11021
11045
  const response = await getZeroRunAgentEvents(runId, request);
11022
- framework = response.framework;
11046
+ const responseFramework = response.framework;
11023
11047
  return {
11024
- items: response.events,
11048
+ items: response.events.map((event) => {
11049
+ const framework2 = supportedLogFramework(
11050
+ responseFramework ?? void 0
11051
+ );
11052
+ return {
11053
+ event,
11054
+ ...framework2 ? { framework: framework2 } : {},
11055
+ useDefaultFramework: !hasLogFramework(responseFramework)
11056
+ };
11057
+ }),
11025
11058
  hasMore: response.hasMore,
11026
11059
  nextCursor: response.nextCursor
11027
11060
  };
@@ -11039,13 +11072,22 @@ async function showAgentEvents(runId, options) {
11039
11072
  showTimestamp: true,
11040
11073
  verbose: true
11041
11074
  });
11075
+ const framework = events.find((item) => {
11076
+ return item.framework !== void 0;
11077
+ })?.framework;
11042
11078
  const normalizer = new EventStreamNormalizer();
11043
- for (const event of events) {
11044
- renderAgentEvent(event, renderer, normalizer, framework);
11079
+ for (const item of events) {
11080
+ renderAgentEvent(
11081
+ item.event,
11082
+ renderer,
11083
+ normalizer,
11084
+ item.framework ?? (item.useDefaultFramework ? framework : void 0)
11085
+ );
11045
11086
  }
11046
11087
  for (const parsed of normalizer.flush()) {
11047
11088
  renderer.render(parsed);
11048
11089
  }
11090
+ renderer.flush();
11049
11091
  }
11050
11092
  var zeroLogsCommand = new Command().name("logs").description("View and search agent run logs").argument("[runId]", "Run ID to view agent events for").addCommand(listCommand15).addCommand(searchCommand2).option(
11051
11093
  "--since <time>",
@@ -11084,7 +11126,7 @@ Examples:
11084
11126
  );
11085
11127
  }
11086
11128
  let since;
11087
- if (options.since) {
11129
+ if (options.since !== void 0) {
11088
11130
  since = parseTime(options.since);
11089
11131
  }
11090
11132
  const isAll = options.all === true;
@@ -11142,24 +11184,14 @@ function collectSource(value, previous) {
11142
11184
  return [...previous, value];
11143
11185
  }
11144
11186
  function parseContextOptions2(options) {
11145
- const contextN = options.context ? parseInt(options.context, 10) : 0;
11146
- const before = options.beforeContext ? parseInt(options.beforeContext, 10) : contextN;
11147
- const after = options.afterContext ? parseInt(options.afterContext, 10) : contextN;
11148
- if (isNaN(before) || before < 0 || before > 10) {
11149
- throw new Error("--before-context must be between 0 and 10");
11150
- }
11151
- if (isNaN(after) || after < 0 || after > 10) {
11152
- throw new Error("--after-context must be between 0 and 10");
11153
- }
11187
+ const contextN = options.context !== void 0 ? parseBoundedLogCount(options.context, "--context", 0, 10) : 0;
11188
+ const before = options.beforeContext !== void 0 ? parseBoundedLogCount(options.beforeContext, "--before-context", 0, 10) : contextN;
11189
+ const after = options.afterContext !== void 0 ? parseBoundedLogCount(options.afterContext, "--after-context", 0, 10) : contextN;
11154
11190
  return { before, after };
11155
11191
  }
11156
11192
  function parseLimit3(value) {
11157
- if (!value) return void 0;
11158
- const limit = parseInt(value, 10);
11159
- if (isNaN(limit) || limit < 1 || limit > 50) {
11160
- throw new Error("--limit must be between 1 and 50");
11161
- }
11162
- return limit;
11193
+ if (value === void 0) return void 0;
11194
+ return parseBoundedLogCount(value, "--limit", 1, 50);
11163
11195
  }
11164
11196
  async function runLogsSource(query, options) {
11165
11197
  const logsOptions = {
@@ -11174,7 +11206,7 @@ async function runLogsSource(query, options) {
11174
11206
  await runLogsSearch(query, logsOptions);
11175
11207
  }
11176
11208
  function formatTimestamp(iso) {
11177
- return new Date(iso).toISOString().replace(/\.\d{3}Z$/, "Z");
11209
+ return formatIsoTimestamp(iso);
11178
11210
  }
11179
11211
  function renderChatMessage(msg, isMatch) {
11180
11212
  const marker = isMatch ? source_default.yellow("\u25B8") : source_default.dim("\xB7");
@@ -11210,12 +11242,19 @@ function renderChatResults(response) {
11210
11242
  }
11211
11243
  }
11212
11244
  async function runChatSource(query, options) {
11213
- if (options.run) {
11245
+ if (options.run !== void 0) {
11214
11246
  throw new Error("--run is not supported with --source chat");
11215
11247
  }
11248
+ if (options.agent !== void 0 && !isUUID(options.agent)) {
11249
+ console.error(
11250
+ source_default.red(`\u2717 Invalid agent ID "${options.agent}" \u2014 expected a UUID`)
11251
+ );
11252
+ console.error(source_default.dim(" Run: zero logs list to find agent IDs"));
11253
+ process.exit(1);
11254
+ }
11216
11255
  const { before, after } = parseContextOptions2(options);
11217
11256
  const limit = parseLimit3(options.limit);
11218
- const since = options.since ? parseTime(options.since) : Date.now() - SEVEN_DAYS_MS2;
11257
+ const since = options.since !== void 0 ? parseTime(options.since) : Date.now() - SEVEN_DAYS_MS2;
11219
11258
  const response = await searchZeroChat({
11220
11259
  keyword: query,
11221
11260
  agentId: options.agent,
@@ -11245,6 +11284,7 @@ var zeroSearchCommand = new Command().name("search").description("Search logs, c
11245
11284
  []
11246
11285
  ).option("--agent <id>", "Filter by Zero agent ID").option("--run <id>", "Filter by run ID").option("--since <time>", "Time window (e.g., 7d, 2h)").option("--limit <n>", "Maximum number of matches").option("-A, --after-context <n>", "Show n items after each match").option("-B, --before-context <n>", "Show n items before each match").option("-C, --context <n>", "Show n items before and after each match").addHelpText("after", SEARCH_EXPLAINER).action(
11247
11286
  withErrorHandler(async (query, options) => {
11287
+ const searchQuery = parseSearchQuery(query, "Query");
11248
11288
  const sources = options.source;
11249
11289
  if (sources.length === 0) {
11250
11290
  console.log(SEARCH_EXPLAINER);
@@ -11261,13 +11301,13 @@ var zeroSearchCommand = new Command().name("search").description("Search logs, c
11261
11301
  }
11262
11302
  switch (source) {
11263
11303
  case "logs":
11264
- await runLogsSource(query, options);
11304
+ await runLogsSource(searchQuery, options);
11265
11305
  return;
11266
11306
  case "chat":
11267
- await runChatSource(query, options);
11307
+ await runChatSource(searchQuery, options);
11268
11308
  return;
11269
11309
  case "slack":
11270
- await runSlackSource(query, options);
11310
+ await runSlackSource(searchQuery, options);
11271
11311
  return;
11272
11312
  }
11273
11313
  })
@@ -16143,7 +16183,7 @@ function registerZeroCommands(prog, commands) {
16143
16183
  var program = new Command();
16144
16184
  program.name("zero").description(
16145
16185
  "Zero CLI \u2014 interact with the zero platform from inside the sandbox"
16146
- ).version("9.209.3").addHelpText("after", () => {
16186
+ ).version("9.210.0").addHelpText("after", () => {
16147
16187
  return buildZeroHelpText();
16148
16188
  });
16149
16189
  if (process.argv[1]?.endsWith("zero.js") || process.argv[1]?.endsWith("zero.ts") || process.argv[1]?.endsWith("zero")) {