teapot-coding-agent 0.37.26 → 0.37.27
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/agent/agent.js +23 -4
- package/dist/master.js +45 -6
- package/package.json +1 -1
- package/public/assets/{index-C3BmKnaM.js → index-BaPyc5su.js} +4 -4
- package/public/assets/{index-C3BmKnaM.js.map → index-BaPyc5su.js.map} +1 -1
- package/public/assets/{shiki-C2QzQnp8.js → shiki-BFWqsxms.js} +2 -2
- package/public/assets/{shiki-C2QzQnp8.js.map → shiki-BFWqsxms.js.map} +1 -1
- package/public/index.html +1 -1
package/dist/agent/agent.js
CHANGED
|
@@ -4783,14 +4783,33 @@ export class Agent {
|
|
|
4783
4783
|
/**
|
|
4784
4784
|
* Wait for the round to end, bounded.
|
|
4785
4785
|
*
|
|
4786
|
-
* `settled()` resolves when the run chain drains, which is
|
|
4787
|
-
*
|
|
4788
|
-
*
|
|
4786
|
+
* `settled()` resolves when the run chain drains, which is "the turn finished" — but a
|
|
4787
|
+
* BACKGROUND SHELL is not on that chain. The round deliberately ends while a dev server,
|
|
4788
|
+
* watcher or long build keeps running (`hasRunningBgShells` breaks the loop instead of nagging),
|
|
4789
|
+
* so `settled()` is already resolved and this used to return immediately.
|
|
4790
|
+
*
|
|
4791
|
+
* MEASURED: an update then reached `dispose()`, which calls `killBgShells` — a live update killed
|
|
4792
|
+
* every background job on the machine, with no wait and no notice. A background job is work in
|
|
4793
|
+
* flight, which is the whole reason `isLive()` counts it, so it must be waited for here too.
|
|
4794
|
+
*
|
|
4795
|
+
* The timeout exists only for a wedged agent (an LLM call that never returns, or a job that will
|
|
4796
|
+
* never exit); the caller reports which agents hit it rather than leaving them silently
|
|
4797
|
+
* half-stopped.
|
|
4789
4798
|
*/
|
|
4790
4799
|
let timer;
|
|
4800
|
+
const done = async () => {
|
|
4801
|
+
await this.settled();
|
|
4802
|
+
// wait out any background job this agent owns, polling the same owner-scoped question
|
|
4803
|
+
// `isLive()` uses — a sibling's job in the shared workspace is not this agent's work
|
|
4804
|
+
while (hasRunningBgShellsFor(this.toolCtx.cwd, this.opts.id)) {
|
|
4805
|
+
if (this.stopRequested)
|
|
4806
|
+
break;
|
|
4807
|
+
await this.sleepInterruptible(500);
|
|
4808
|
+
}
|
|
4809
|
+
};
|
|
4791
4810
|
try {
|
|
4792
4811
|
await Promise.race([
|
|
4793
|
-
|
|
4812
|
+
done(),
|
|
4794
4813
|
new Promise((_, reject) => {
|
|
4795
4814
|
timer = setTimeout(() => reject(new Error(`did not reach a turn boundary within ${timeoutMs}ms`)), timeoutMs);
|
|
4796
4815
|
}),
|
package/dist/master.js
CHANGED
|
@@ -2429,10 +2429,18 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
|
|
|
2429
2429
|
/**
|
|
2430
2430
|
* How long a live update waits for agents to reach a turn boundary.
|
|
2431
2431
|
*
|
|
2432
|
-
*
|
|
2433
|
-
*
|
|
2432
|
+
* It must be comparable to a TOOL's own ceiling, not to a human's patience. MEASURED: a live update
|
|
2433
|
+
* waited 180s while a `bash` call was in flight, gave up, and killed it — the timeline then showed
|
|
2434
|
+
* `✖ fail … not completed — the agent restarted while this tool was running` for work that was
|
|
2435
|
+
* about to return (that call had been running ~300s, well within the 3600s a `bash` call may take).
|
|
2436
|
+
* Waiting too SHORT is what turns a clean update into a truncated turn.
|
|
2437
|
+
*
|
|
2438
|
+
* 15 minutes: three times the longest call seen in the wild (a ~300s `bash`) and still short of a
|
|
2439
|
+
* `bash` call's own 3600s ceiling. Waiting an entire tool ceiling would block the update for an
|
|
2440
|
+
* hour, which defeats the purpose of updating; waiting 180s interrupted work that was about to
|
|
2441
|
+
* finish. The interrupted case is not lost — the resumed session is told exactly what happened.
|
|
2434
2442
|
*/
|
|
2435
|
-
updateWindDownMs =
|
|
2443
|
+
updateWindDownMs = 900_000;
|
|
2436
2444
|
/**
|
|
2437
2445
|
* Ask every agent to stop at its next turn boundary; returns the ids that did not make it.
|
|
2438
2446
|
*
|
|
@@ -2441,9 +2449,22 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
|
|
|
2441
2449
|
* it interrupted.
|
|
2442
2450
|
*/
|
|
2443
2451
|
async windDownAllAgents(timeoutMs = this.updateWindDownMs) {
|
|
2444
|
-
|
|
2445
|
-
|
|
2452
|
+
/**
|
|
2453
|
+
* Only agents with WORK IN FLIGHT need to be waited for.
|
|
2454
|
+
*
|
|
2455
|
+
* This asked every loaded agent, and the log then said "waiting for 440 agent(s)" on a machine
|
|
2456
|
+
* with one working session (MEASURED: 511 configured, 71 archived, 440 loaded). The count was
|
|
2457
|
+
* false in the most alarming direction — it read as 440 interrupted jobs — and the call itself is
|
|
2458
|
+
* not free: each idle agent gets a `windDownRequested` flag set and a `wake()`, which is
|
|
2459
|
+
* pointless state churn on agents that are doing nothing.
|
|
2460
|
+
*/
|
|
2461
|
+
const ids = [...this.agents.entries()]
|
|
2462
|
+
.filter(([, a]) => a.isLive())
|
|
2463
|
+
.map(([id]) => id);
|
|
2464
|
+
if (!ids.length) {
|
|
2465
|
+
console.log("[teapot] live update: nothing is running — no need to wait for a turn boundary");
|
|
2446
2466
|
return [];
|
|
2467
|
+
}
|
|
2447
2468
|
console.log(`[teapot] live update: waiting for ${ids.length} agent(s) to reach a turn boundary...`);
|
|
2448
2469
|
const stuck = await Promise.all(ids.map(async (id) => {
|
|
2449
2470
|
const a = this.agents.get(id);
|
|
@@ -2548,6 +2569,24 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
|
|
|
2548
2569
|
throw new Error("live update needs process.execve (Node 22+); restart the server by hand on this runtime");
|
|
2549
2570
|
}
|
|
2550
2571
|
console.log("[teapot] live update: replacing this process in place (same pid, same terminal)");
|
|
2572
|
+
/**
|
|
2573
|
+
* Give the heap back BEFORE the new image allocates its own.
|
|
2574
|
+
*
|
|
2575
|
+
* `execve` replaces the image in place, so the outgoing heap is still resident while the incoming
|
|
2576
|
+
* one grows. MEASURED on a long-lived server: `VmHWM` reached 1092MB after an update while the
|
|
2577
|
+
* steady state was 323MB, and the boot peak was visible in the status banner as
|
|
2578
|
+
* `602.4MB / 423.3MB`. A sandbox boot of the same 832 sessions measured only 250MB, so the extra
|
|
2579
|
+
* gigabyte is not the data — it is two heaps overlapping.
|
|
2580
|
+
*
|
|
2581
|
+
* `global.gc` exists only with `--expose-gc`; without it this is a cheap no-op and the peak simply
|
|
2582
|
+
* stays as it was, which is the old behaviour.
|
|
2583
|
+
*/
|
|
2584
|
+
const gc = globalThis.gc;
|
|
2585
|
+
if (typeof gc === "function") {
|
|
2586
|
+
// twice: the first pass frees what is unreachable, the second collects what the first freed
|
|
2587
|
+
gc();
|
|
2588
|
+
gc();
|
|
2589
|
+
}
|
|
2551
2590
|
/**
|
|
2552
2591
|
* Build the argv for the replacement image.
|
|
2553
2592
|
*
|
|
@@ -2561,7 +2600,7 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
|
|
|
2561
2600
|
* simply means the new image boots with node's defaults, which is what a live update wants;
|
|
2562
2601
|
* anything else the operator set lives in `env` and the shell.
|
|
2563
2602
|
*/
|
|
2564
|
-
const FORWARDABLE = /^--(experimental-strip-types|experimental-transform-types|no-warnings|enable-source-maps|import|require|conditions)$/;
|
|
2603
|
+
const FORWARDABLE = /^--(experimental-strip-types|experimental-transform-types|no-warnings|enable-source-maps|import|require|conditions|expose-gc)$/;
|
|
2565
2604
|
const forwardable = process.execArgv.filter((a) => FORWARDABLE.test(a.split("=")[0] ?? ""));
|
|
2566
2605
|
/**
|
|
2567
2606
|
* `args[0]` MUST be the program, exactly as a shell would pass it.
|