@erdoai/cli 0.249.0 → 0.253.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/dist/index.js +22 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1620,13 +1620,29 @@ var ErdoClient = class {
|
|
|
1620
1620
|
// after the HTTP call returns, so without this the first poll on a reused thread
|
|
1621
1621
|
// would return that prior (already-terminal) run and print a stale answer. We
|
|
1622
1622
|
// skip it and wait for a genuinely new run to appear.
|
|
1623
|
+
//
|
|
1624
|
+
// invocationID names the run the send started. Watchers post their own runs on
|
|
1625
|
+
// the thread after the answer, so the newest run is not necessarily ours; an
|
|
1626
|
+
// older backend that returns no invocation id falls back to locking onto the
|
|
1627
|
+
// first new run.
|
|
1623
1628
|
async waitForThreadRun(threadID, opts = {}) {
|
|
1624
1629
|
const intervalMs = opts.intervalMs ?? 3e3;
|
|
1625
1630
|
const deadline = Date.now() + (opts.timeoutMs ?? 15 * 60 * 1e3);
|
|
1631
|
+
let lockedRunID;
|
|
1626
1632
|
while (Date.now() < deadline) {
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1633
|
+
let run;
|
|
1634
|
+
if (opts.invocationID) {
|
|
1635
|
+
const { runs } = await this.listAgentRuns({ thread: threadID, invocation: opts.invocationID, limit: 1 });
|
|
1636
|
+
run = runs[0];
|
|
1637
|
+
} else if (lockedRunID) {
|
|
1638
|
+
run = (await this.getAgentRun(lockedRunID)).run;
|
|
1639
|
+
} else {
|
|
1640
|
+
const { runs } = await this.listAgentRuns({ thread: threadID, limit: 1 });
|
|
1641
|
+
const candidate = runs[0];
|
|
1642
|
+
if (candidate && candidate.id !== opts.ignoreRunID) lockedRunID = candidate.id;
|
|
1643
|
+
run = candidate && candidate.id !== opts.ignoreRunID ? candidate : void 0;
|
|
1644
|
+
}
|
|
1645
|
+
if (run) {
|
|
1630
1646
|
opts.onTick?.(run.status);
|
|
1631
1647
|
if (POLL_STOP_STATUSES.has(run.status)) return run;
|
|
1632
1648
|
}
|
|
@@ -5229,6 +5245,7 @@ thread: ${res.thread_id}`);
|
|
|
5229
5245
|
process.stderr.write(`thread: ${res.thread_id}
|
|
5230
5246
|
running\u2026`);
|
|
5231
5247
|
const run = await client.waitForThreadRun(res.thread_id, {
|
|
5248
|
+
invocationID: res.invocation_id,
|
|
5232
5249
|
onTick: () => process.stderr.write(".")
|
|
5233
5250
|
});
|
|
5234
5251
|
process.stderr.write("\n");
|
|
@@ -5274,6 +5291,7 @@ agentCmd.command("send <threadId> <message>").description("Send a message to a t
|
|
|
5274
5291
|
process.stderr.write("running\u2026");
|
|
5275
5292
|
const run = await client.waitForThreadRun(threadId, {
|
|
5276
5293
|
ignoreRunID: baselineRunID,
|
|
5294
|
+
invocationID: res.invocation_id,
|
|
5277
5295
|
onTick: () => process.stderr.write(".")
|
|
5278
5296
|
});
|
|
5279
5297
|
process.stderr.write("\n");
|
|
@@ -5365,7 +5383,7 @@ thread: ${response.thread_id}`);
|
|
|
5365
5383
|
}
|
|
5366
5384
|
process.stderr.write(`thread: ${response.thread_id}
|
|
5367
5385
|
running\u2026`);
|
|
5368
|
-
const run = await client.waitForThreadRun(response.thread_id, { onTick: () => process.stderr.write(".") });
|
|
5386
|
+
const run = await client.waitForThreadRun(response.thread_id, { invocationID: response.invocation_id, onTick: () => process.stderr.write(".") });
|
|
5369
5387
|
process.stderr.write("\n");
|
|
5370
5388
|
if (!run) throw new Error(timedOutMessage(response.thread_id));
|
|
5371
5389
|
if (run.status === "awaiting_approval") throw new Error(awaitingApprovalMessage(response.thread_id));
|