teapot-coding-agent 0.37.36 → 0.37.38
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 +27 -0
- package/dist/master.js +44 -3
- package/package.json +1 -1
- package/public/assets/{index-CJRLUcnz.js → index-DZteXB3h.js} +4 -4
- package/public/assets/{index-CJRLUcnz.js.map → index-DZteXB3h.js.map} +1 -1
- package/public/assets/{shiki-By7PBGqR.js → shiki-CCocHZ4i.js} +2 -2
- package/public/assets/{shiki-By7PBGqR.js.map → shiki-CCocHZ4i.js.map} +1 -1
- package/public/index.html +1 -1
package/dist/index.js
CHANGED
|
@@ -191,6 +191,33 @@ async function main() {
|
|
|
191
191
|
* nothing is orphaned and nothing lingers. `execve` only resolves if it FAILED, and that path
|
|
192
192
|
* throws inside `restartServer`, so nothing is left trusting this branch.
|
|
193
193
|
*/
|
|
194
|
+
/**
|
|
195
|
+
* Ctrl-C during a live update must not cancel the handover half-way.
|
|
196
|
+
*
|
|
197
|
+
* `restartServer()` records what to resume and then execs. A SIGINT in that window ran this
|
|
198
|
+
* shutdown path, which DISPOSES every agent and exits — so the operator saw
|
|
199
|
+
*
|
|
200
|
+
* [teapot] live update: waiting for 1 agent(s)…
|
|
201
|
+
* ^C
|
|
202
|
+
* [teapot] shutting down (SIGINT)...
|
|
203
|
+
* [teapot] live update: 0 session(s) will resume
|
|
204
|
+
*
|
|
205
|
+
* and the work that was running never came back. The flag is set by `restartServer()` for the
|
|
206
|
+
* whole duration of the handover, which is exactly the window where the operator's ^C is
|
|
207
|
+
* ambiguous: it can mean "cancel the update" or "stop the server", and treating it as the latter
|
|
208
|
+
* silently discards the resume set that was just written.
|
|
209
|
+
*
|
|
210
|
+
* A second ^C while an update is in flight is the escape hatch — that is why this checks the
|
|
211
|
+
* signal rather than ignoring it outright.
|
|
212
|
+
*/
|
|
213
|
+
const updating = master.updateInFlight === true;
|
|
214
|
+
if (updating && signal === "SIGINT" && !process.env.TEAPOT_FORCE_SHUTDOWN) {
|
|
215
|
+
console.log("\n[teapot] live update is in progress — press ^C again to abort it and stop");
|
|
216
|
+
process.env.TEAPOT_FORCE_SHUTDOWN = "1";
|
|
217
|
+
// do NOT reset `shuttingDown`: the next signal must get through, so clear it
|
|
218
|
+
shuttingDown = false;
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
194
221
|
console.log(`\n[teapot] shutting down${signal ? ` (${signal})` : ""}...`);
|
|
195
222
|
await Promise.allSettled([...master.agents.values()].map((a) => a.dispose()));
|
|
196
223
|
// During a live update the replacement SIGTERMs us to take the port. Linger
|
package/dist/master.js
CHANGED
|
@@ -2499,6 +2499,14 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
|
|
|
2499
2499
|
* finish. The interrupted case is not lost — the resumed session is told exactly what happened.
|
|
2500
2500
|
*/
|
|
2501
2501
|
updateWindDownMs = 900_000;
|
|
2502
|
+
/**
|
|
2503
|
+
* True from the moment a live update starts until the process is replaced.
|
|
2504
|
+
*
|
|
2505
|
+
* A Ctrl-C during the wind-down used to run the ordinary shutdown path — dispose every agent, then
|
|
2506
|
+
* exit — which discarded the resume set that had just been written and left the operator's work
|
|
2507
|
+
* stopped with no explanation.
|
|
2508
|
+
*/
|
|
2509
|
+
updateInFlight = false;
|
|
2502
2510
|
/**
|
|
2503
2511
|
* Ask every agent to stop at its next turn boundary; returns the ids that did not make it.
|
|
2504
2512
|
*
|
|
@@ -2588,6 +2596,25 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
|
|
|
2588
2596
|
}
|
|
2589
2597
|
async restartServer() {
|
|
2590
2598
|
console.log("[teapot] live update: restarting...");
|
|
2599
|
+
/**
|
|
2600
|
+
* A Ctrl-C from here until the exec is ambiguous; signal handlers consult this.
|
|
2601
|
+
*
|
|
2602
|
+
* Every early RETURN below clears it again. `execve` only resolves if it FAILED, and the
|
|
2603
|
+
* `!execve` branch throws — on either path the process keeps running, so leaving the flag set
|
|
2604
|
+
* would make the FIRST ^C refuse forever with a message that promises a second one works. The
|
|
2605
|
+
* flag is therefore a promise about the CURRENT moment, not a one-way switch.
|
|
2606
|
+
*/
|
|
2607
|
+
this.updateInFlight = true;
|
|
2608
|
+
try {
|
|
2609
|
+
await this.handoverToNewImage();
|
|
2610
|
+
}
|
|
2611
|
+
finally {
|
|
2612
|
+
// only reached when the handover did NOT replace the process
|
|
2613
|
+
this.updateInFlight = false;
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
/** wind down, record what to resume, and exec. Never returns on success. */
|
|
2617
|
+
async handoverToNewImage() {
|
|
2591
2618
|
/**
|
|
2592
2619
|
* 1. WIND DOWN — do not abort.
|
|
2593
2620
|
*
|
|
@@ -2596,18 +2623,32 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
|
|
|
2596
2623
|
* and leaves a call whose result never arrives, so the resumed session starts from a state that
|
|
2597
2624
|
* never existed. `windDownForUpdate()` instead lets each agent finish its current round.
|
|
2598
2625
|
*/
|
|
2626
|
+
/**
|
|
2627
|
+
* 2. REMEMBER WHAT TO RESUME — before winding down, not after.
|
|
2628
|
+
*
|
|
2629
|
+
* `takeResumeSet()` asks `isLive()`, and `windDownForUpdate()` SETS `status = "idle"` as its
|
|
2630
|
+
* success condition. Taking the set afterwards therefore collected nothing: MEASURED in a real
|
|
2631
|
+
* update whose log reads
|
|
2632
|
+
*
|
|
2633
|
+
* waiting for 1 agent(s) to reach a turn boundary...
|
|
2634
|
+
* 0 session(s) will resume
|
|
2635
|
+
* resumed 0 session(s)
|
|
2636
|
+
*
|
|
2637
|
+
* — the one agent that was working was recorded as "not working" by the very step that had just
|
|
2638
|
+
* made it stop, so the work never came back.
|
|
2639
|
+
*
|
|
2640
|
+
* Captured first, the set describes what the operator saw when they pressed update.
|
|
2641
|
+
*/
|
|
2642
|
+
this.config.resumeAfterUpdate = this.takeResumeSet();
|
|
2599
2643
|
const interrupted = await this.windDownAllAgents(this.updateWindDownMs);
|
|
2600
2644
|
if (interrupted.length)
|
|
2601
2645
|
console.log(`[teapot] live update: ${interrupted.length} agent(s) did not reach a turn boundary in ` +
|
|
2602
2646
|
`time and were stopped: ${interrupted.join(", ")}`);
|
|
2603
2647
|
/**
|
|
2604
|
-
* 2. REMEMBER WHAT TO RESUME.
|
|
2605
|
-
*
|
|
2606
2648
|
* Written to the config BEFORE the exec, because after it this process no longer exists. Only
|
|
2607
2649
|
* agents that were actually working go in — an idle agent must NOT be started by the new
|
|
2608
2650
|
* process, or a live update would begin doing work the operator never asked for.
|
|
2609
2651
|
*/
|
|
2610
|
-
this.config.resumeAfterUpdate = this.takeResumeSet();
|
|
2611
2652
|
this.saveConfig();
|
|
2612
2653
|
console.log(`[teapot] live update: ${this.config.resumeAfterUpdate.length} session(s) will resume`);
|
|
2613
2654
|
// 3. terminals: closing them is what makes their `detached` spawns safe (see stopAllAgents)
|