@vm0/cli 9.132.9 → 9.132.10
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-MPUU27KS.js → chunk-PUKA5E32.js} +18 -17
- package/{chunk-MPUU27KS.js.map → chunk-PUKA5E32.js.map} +1 -1
- package/index.js +9 -9
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/zero.js +115 -39
- package/zero.js.map +1 -1
package/package.json
CHANGED
package/zero.js
CHANGED
|
@@ -112,7 +112,7 @@ import {
|
|
|
112
112
|
upsertZeroOrgModelProvider,
|
|
113
113
|
withErrorHandler,
|
|
114
114
|
zeroAgentCustomSkillNameSchema
|
|
115
|
-
} from "./chunk-
|
|
115
|
+
} from "./chunk-PUKA5E32.js";
|
|
116
116
|
import {
|
|
117
117
|
__toESM,
|
|
118
118
|
init_esm_shims
|
|
@@ -13875,6 +13875,11 @@ var FEATURE_SWITCHES = {
|
|
|
13875
13875
|
description: "Enable the PostHog analytics connector",
|
|
13876
13876
|
enabled: false
|
|
13877
13877
|
},
|
|
13878
|
+
["pwaOfflineCache" /* PwaOfflineCache */]: {
|
|
13879
|
+
maintainer: "ethan@vm0.ai",
|
|
13880
|
+
description: "Enable PWA offline caching (static asset cache-first, offline fallback page, and service worker updateViaCache: none)",
|
|
13881
|
+
enabled: false
|
|
13882
|
+
},
|
|
13878
13883
|
["mailchimpConnector" /* MailchimpConnector */]: {
|
|
13879
13884
|
maintainer: "ethan@vm0.ai",
|
|
13880
13885
|
description: "Enable the Mailchimp email marketing connector",
|
|
@@ -15271,6 +15276,12 @@ init_esm_shims();
|
|
|
15271
15276
|
|
|
15272
15277
|
// src/commands/zero/run/shared.ts
|
|
15273
15278
|
init_esm_shims();
|
|
15279
|
+
var TERMINAL_RUN_STATUSES = [
|
|
15280
|
+
"completed",
|
|
15281
|
+
"failed",
|
|
15282
|
+
"timeout",
|
|
15283
|
+
"cancelled"
|
|
15284
|
+
];
|
|
15274
15285
|
function toRunResult(result) {
|
|
15275
15286
|
const { checkpointId, agentSessionId, conversationId } = result;
|
|
15276
15287
|
if (!checkpointId || !agentSessionId || !conversationId) {
|
|
@@ -15278,62 +15289,127 @@ function toRunResult(result) {
|
|
|
15278
15289
|
}
|
|
15279
15290
|
return { checkpointId, agentSessionId, conversationId };
|
|
15280
15291
|
}
|
|
15292
|
+
function filterContiguousEvents(events, lastSequence) {
|
|
15293
|
+
const contiguousEvents = [];
|
|
15294
|
+
let expectedSequence = lastSequence + 1;
|
|
15295
|
+
for (const event of events) {
|
|
15296
|
+
if (event.sequenceNumber < expectedSequence) {
|
|
15297
|
+
continue;
|
|
15298
|
+
}
|
|
15299
|
+
if (event.sequenceNumber !== expectedSequence) {
|
|
15300
|
+
break;
|
|
15301
|
+
}
|
|
15302
|
+
contiguousEvents.push(event);
|
|
15303
|
+
expectedSequence++;
|
|
15304
|
+
}
|
|
15305
|
+
return contiguousEvents;
|
|
15306
|
+
}
|
|
15307
|
+
var POLL_INTERVAL_MS = 1e3;
|
|
15308
|
+
var TERMINAL_DRAIN_POLL_INTERVAL_MS = 500;
|
|
15309
|
+
var TERMINAL_DRAIN_IDLE_MS = 1e3;
|
|
15310
|
+
var TERMINAL_DRAIN_MAX_MS = 3e3;
|
|
15311
|
+
function isTerminalRunResponse(runResponse) {
|
|
15312
|
+
return TERMINAL_RUN_STATUSES.includes(
|
|
15313
|
+
runResponse.status
|
|
15314
|
+
);
|
|
15315
|
+
}
|
|
15316
|
+
function shouldDrainNextEventPage(eventsResponse, contiguousEvents) {
|
|
15317
|
+
return eventsResponse.hasMore && contiguousEvents.length > 0 && contiguousEvents.length === eventsResponse.events.length;
|
|
15318
|
+
}
|
|
15319
|
+
function hasSequenceGap(eventsResponse, contiguousEvents) {
|
|
15320
|
+
return eventsResponse.events.length > 0 && contiguousEvents.length < eventsResponse.events.length;
|
|
15321
|
+
}
|
|
15322
|
+
function shouldCompleteTerminalDrain(terminalSeenAt, lastTerminalProgressAt, blockedByGap) {
|
|
15323
|
+
const now = Date.now();
|
|
15324
|
+
const terminalElapsedMs = now - terminalSeenAt;
|
|
15325
|
+
const terminalIdleMs = now - lastTerminalProgressAt;
|
|
15326
|
+
return terminalElapsedMs >= TERMINAL_DRAIN_MAX_MS || !blockedByGap && terminalIdleMs >= TERMINAL_DRAIN_IDLE_MS;
|
|
15327
|
+
}
|
|
15328
|
+
function renderTerminalRunResult(runId, runResponse) {
|
|
15329
|
+
if (runResponse.status === "completed") {
|
|
15330
|
+
EventRenderer.renderRunCompleted(
|
|
15331
|
+
runResponse.result ? toRunResult(runResponse.result) : void 0
|
|
15332
|
+
);
|
|
15333
|
+
return {
|
|
15334
|
+
succeeded: true,
|
|
15335
|
+
runId,
|
|
15336
|
+
sessionId: runResponse.result?.agentSessionId,
|
|
15337
|
+
checkpointId: runResponse.result?.checkpointId
|
|
15338
|
+
};
|
|
15339
|
+
}
|
|
15340
|
+
if (runResponse.status === "failed") {
|
|
15341
|
+
EventRenderer.renderRunFailed(runResponse.error, runId);
|
|
15342
|
+
return { succeeded: false, runId };
|
|
15343
|
+
}
|
|
15344
|
+
if (runResponse.status === "timeout") {
|
|
15345
|
+
console.error(source_default.red("\n\u2717 Run timed out"));
|
|
15346
|
+
return { succeeded: false, runId };
|
|
15347
|
+
}
|
|
15348
|
+
console.error(source_default.yellow("\n\u2717 Run cancelled"));
|
|
15349
|
+
return { succeeded: false, runId };
|
|
15350
|
+
}
|
|
15351
|
+
function sleep(ms) {
|
|
15352
|
+
return new Promise((resolve) => {
|
|
15353
|
+
return setTimeout(resolve, ms);
|
|
15354
|
+
});
|
|
15355
|
+
}
|
|
15281
15356
|
async function pollZeroEvents(runId, options) {
|
|
15282
15357
|
const renderer = new EventRenderer({ verbose: options?.verbose });
|
|
15283
15358
|
let lastSequence = -1;
|
|
15284
15359
|
let complete = false;
|
|
15285
15360
|
let result = { succeeded: true, runId };
|
|
15286
|
-
|
|
15361
|
+
let terminalRunResponse;
|
|
15362
|
+
let terminalSeenAt = 0;
|
|
15363
|
+
let lastTerminalProgressAt = 0;
|
|
15287
15364
|
while (!complete) {
|
|
15288
15365
|
const eventsResponse = await getZeroRunAgentEvents(runId, {
|
|
15289
15366
|
since: lastSequence,
|
|
15290
15367
|
limit: 100,
|
|
15291
15368
|
order: "asc"
|
|
15292
15369
|
});
|
|
15293
|
-
|
|
15370
|
+
const contiguousEvents = filterContiguousEvents(
|
|
15371
|
+
eventsResponse.events,
|
|
15372
|
+
lastSequence
|
|
15373
|
+
);
|
|
15374
|
+
for (const event of contiguousEvents) {
|
|
15294
15375
|
const eventData = event.eventData;
|
|
15295
15376
|
const parsed = parseEvent(eventData);
|
|
15296
15377
|
if (parsed) {
|
|
15297
15378
|
renderer.render(parsed);
|
|
15298
15379
|
}
|
|
15299
15380
|
}
|
|
15300
|
-
if (
|
|
15301
|
-
lastSequence =
|
|
15302
|
-
|
|
15303
|
-
|
|
15304
|
-
|
|
15305
|
-
|
|
15381
|
+
if (contiguousEvents.length > 0) {
|
|
15382
|
+
lastSequence = contiguousEvents[contiguousEvents.length - 1].sequenceNumber;
|
|
15383
|
+
if (terminalRunResponse) {
|
|
15384
|
+
lastTerminalProgressAt = Date.now();
|
|
15385
|
+
}
|
|
15386
|
+
}
|
|
15387
|
+
const blockedByGap = hasSequenceGap(eventsResponse, contiguousEvents);
|
|
15388
|
+
if (shouldDrainNextEventPage(eventsResponse, contiguousEvents)) {
|
|
15389
|
+
continue;
|
|
15306
15390
|
}
|
|
15307
15391
|
const runResponse = await getZeroRun(runId);
|
|
15308
|
-
|
|
15309
|
-
|
|
15310
|
-
|
|
15311
|
-
|
|
15312
|
-
|
|
15313
|
-
|
|
15314
|
-
|
|
15315
|
-
|
|
15316
|
-
|
|
15317
|
-
|
|
15318
|
-
|
|
15319
|
-
|
|
15320
|
-
|
|
15321
|
-
|
|
15322
|
-
|
|
15323
|
-
|
|
15324
|
-
} else if (runStatus === "timeout") {
|
|
15325
|
-
complete = true;
|
|
15326
|
-
console.error(source_default.red("\n\u2717 Run timed out"));
|
|
15327
|
-
result = { succeeded: false, runId };
|
|
15328
|
-
} else if (runStatus === "cancelled") {
|
|
15329
|
-
complete = true;
|
|
15330
|
-
console.error(source_default.yellow("\n\u2717 Run cancelled"));
|
|
15331
|
-
result = { succeeded: false, runId };
|
|
15392
|
+
if (isTerminalRunResponse(runResponse)) {
|
|
15393
|
+
if (!terminalRunResponse) {
|
|
15394
|
+
terminalSeenAt = Date.now();
|
|
15395
|
+
lastTerminalProgressAt = terminalSeenAt;
|
|
15396
|
+
}
|
|
15397
|
+
terminalRunResponse = runResponse;
|
|
15398
|
+
}
|
|
15399
|
+
if (terminalRunResponse) {
|
|
15400
|
+
if (shouldCompleteTerminalDrain(
|
|
15401
|
+
terminalSeenAt,
|
|
15402
|
+
lastTerminalProgressAt,
|
|
15403
|
+
blockedByGap
|
|
15404
|
+
)) {
|
|
15405
|
+
result = renderTerminalRunResult(runId, terminalRunResponse);
|
|
15406
|
+
complete = true;
|
|
15407
|
+
}
|
|
15332
15408
|
}
|
|
15333
15409
|
if (!complete) {
|
|
15334
|
-
await
|
|
15335
|
-
|
|
15336
|
-
|
|
15410
|
+
await sleep(
|
|
15411
|
+
terminalRunResponse ? TERMINAL_DRAIN_POLL_INTERVAL_MS : POLL_INTERVAL_MS
|
|
15412
|
+
);
|
|
15337
15413
|
}
|
|
15338
15414
|
}
|
|
15339
15415
|
return result;
|
|
@@ -17788,7 +17864,7 @@ async function getScreenInfo() {
|
|
|
17788
17864
|
init_esm_shims();
|
|
17789
17865
|
import { execFile as execFile2 } from "child_process";
|
|
17790
17866
|
import { promisify as promisify2 } from "util";
|
|
17791
|
-
import { setTimeout as
|
|
17867
|
+
import { setTimeout as sleep2 } from "timers/promises";
|
|
17792
17868
|
var execFileAsync2 = promisify2(execFile2);
|
|
17793
17869
|
async function leftClickDrag(startX, startY, endX, endY) {
|
|
17794
17870
|
await execFileAsync2("cliclick", [
|
|
@@ -17921,7 +17997,7 @@ async function holdKey(keys, durationMs) {
|
|
|
17921
17997
|
return `ku:${k}`;
|
|
17922
17998
|
});
|
|
17923
17999
|
await execFileAsync2("cliclick", downArgs);
|
|
17924
|
-
await
|
|
18000
|
+
await sleep2(durationMs);
|
|
17925
18001
|
await execFileAsync2("cliclick", upArgs);
|
|
17926
18002
|
}
|
|
17927
18003
|
async function typeText(text) {
|
|
@@ -18820,7 +18896,7 @@ function registerZeroCommands(prog, commands) {
|
|
|
18820
18896
|
var program = new Command();
|
|
18821
18897
|
program.name("zero").description(
|
|
18822
18898
|
"Zero CLI \u2014 interact with the zero platform from inside the sandbox"
|
|
18823
|
-
).version("9.132.
|
|
18899
|
+
).version("9.132.10").addHelpText(
|
|
18824
18900
|
"after",
|
|
18825
18901
|
`
|
|
18826
18902
|
Examples:
|