spacecode 2.12.0 → 2.12.1
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 +2 -2
- package/dist/index.js.map +1 -1
- package/dist/repl.mjs +24 -4
- package/package.json +1 -1
package/dist/repl.mjs
CHANGED
|
@@ -104418,9 +104418,24 @@ async function runCoreTurn(d, prompt) {
|
|
|
104418
104418
|
...body === void 0 ? {} : { body: JSON.stringify(body) },
|
|
104419
104419
|
signal: d.signal
|
|
104420
104420
|
});
|
|
104421
|
-
if (!res.ok) throw new CoreTurnError(`core run request failed (${res.status}) ${method} ${path13.split("?")[0]}
|
|
104421
|
+
if (!res.ok) throw new CoreTurnError(`core run request failed (${res.status}) ${method} ${path13.split("?")[0]}`, res.status);
|
|
104422
104422
|
return res.json();
|
|
104423
104423
|
};
|
|
104424
|
+
const poll = async (path13) => {
|
|
104425
|
+
for (let attempt = 0; ; attempt++) {
|
|
104426
|
+
try {
|
|
104427
|
+
return await call("GET", path13);
|
|
104428
|
+
} catch (err) {
|
|
104429
|
+
const transient = err instanceof CoreTurnError && err.status !== void 0 && err.status >= 500;
|
|
104430
|
+
if (!transient || d.signal.aborted) throw err;
|
|
104431
|
+
if (attempt >= POLL_RETRIES) throw new CoreTurnError(`${err.message} (gave up after ${POLL_RETRIES} retries)`, err.status);
|
|
104432
|
+
d.emit({ type: "text", seq: ++seq, content: `(run service answered ${err.status}; retry ${attempt + 1}/${POLL_RETRIES})
|
|
104433
|
+
|
|
104434
|
+
` });
|
|
104435
|
+
await d.sleep(Math.min(8e3, 1e3 * 2 ** attempt));
|
|
104436
|
+
}
|
|
104437
|
+
}
|
|
104438
|
+
};
|
|
104424
104439
|
let runId = d.getRunId();
|
|
104425
104440
|
if (!runId) {
|
|
104426
104441
|
const created = await call("POST", "", {
|
|
@@ -104442,7 +104457,7 @@ async function runCoreTurn(d, prompt) {
|
|
|
104442
104457
|
let state = null;
|
|
104443
104458
|
for (; ; ) {
|
|
104444
104459
|
if (d.signal.aborted) throw new CoreTurnError("aborted");
|
|
104445
|
-
const events = (await
|
|
104460
|
+
const events = (await poll(`/${runId}/events?after=${cur.after}&limit=200`)).events;
|
|
104446
104461
|
for (const e of events) {
|
|
104447
104462
|
cur.after = Math.max(cur.after, e.seq);
|
|
104448
104463
|
if (!e.applied) continue;
|
|
@@ -104454,7 +104469,7 @@ async function runCoreTurn(d, prompt) {
|
|
|
104454
104469
|
}
|
|
104455
104470
|
if (e.type === "verifier_result" && Array.isArray(p.problems) && p.problems.length > 0) say(`task ${String(p.taskId)}: verifier: ${p.problems.join("; ")}`);
|
|
104456
104471
|
}
|
|
104457
|
-
state = (await
|
|
104472
|
+
state = (await poll(`/${runId}`)).state;
|
|
104458
104473
|
const now = {};
|
|
104459
104474
|
for (const id of state.order) now[id] = state.tasks[id].status;
|
|
104460
104475
|
const changed = state.order.filter((id) => now[id] !== cur.known[id]);
|
|
@@ -104485,7 +104500,7 @@ async function runCoreTurn(d, prompt) {
|
|
|
104485
104500
|
cur.tokensBase = state.tokensUsed;
|
|
104486
104501
|
return { success: (state.status === "done" || state.status === "needs_user") && patchFailures === 0, text: lastText, tokens };
|
|
104487
104502
|
}
|
|
104488
|
-
var newRunCursor, TERMINAL, DEFAULT_BUDGET, DEFAULT_MAX_WAIT_MS, CoreTurnError;
|
|
104503
|
+
var newRunCursor, TERMINAL, DEFAULT_BUDGET, DEFAULT_MAX_WAIT_MS, CoreTurnError, POLL_RETRIES;
|
|
104489
104504
|
var init_core_turn = __esm({
|
|
104490
104505
|
"src/core/core-turn.ts"() {
|
|
104491
104506
|
"use strict";
|
|
@@ -104494,7 +104509,12 @@ var init_core_turn = __esm({
|
|
|
104494
104509
|
DEFAULT_BUDGET = 5e5;
|
|
104495
104510
|
DEFAULT_MAX_WAIT_MS = 30 * 6e4;
|
|
104496
104511
|
CoreTurnError = class extends Error {
|
|
104512
|
+
constructor(message, status) {
|
|
104513
|
+
super(message);
|
|
104514
|
+
this.status = status;
|
|
104515
|
+
}
|
|
104497
104516
|
};
|
|
104517
|
+
POLL_RETRIES = 5;
|
|
104498
104518
|
}
|
|
104499
104519
|
});
|
|
104500
104520
|
|