feat(backend): resume + venv PATH + end-to-end F1 smoke (fake-pi-rpc)
- Add PiProcessManager.resume(sessionId, tht): reads provider/model/thinking from tht.sessionShow() and calls spawnFor with those values - Add POST /sessions/:id/resume route: calls mgr.resume then re-wires bridge.onClientEvent → hub.publish - Confirm venv PATH already present in real spawn (no change needed) - Add e2e test: POST /sessions → SSE receives ui_request via pendingWidget re-emit → POST /sessions/s1/response → 204 (all over real HTTP against fake-pi-rpc) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { join } from "node:path";
|
||||
import type { AppConfig } from "../config.js";
|
||||
import { RpcClient } from "../rpc/rpc-client.js";
|
||||
import { SessionBridge } from "../bridge/session-bridge.js";
|
||||
import type { ThtRunner } from "../tht/tht-runner.js";
|
||||
|
||||
export interface SessionRuntime {
|
||||
rpc: RpcClient;
|
||||
@@ -74,6 +75,15 @@ export class PiProcessManager {
|
||||
return rt;
|
||||
}
|
||||
|
||||
async resume(sessionId: string, tht: ThtRunner): Promise<SessionRuntime> {
|
||||
const manifest = await tht.sessionShow(sessionId) as { provider?: string; model?: string; thinking?: string } | null;
|
||||
return this.spawnFor(sessionId, {
|
||||
provider: manifest?.provider,
|
||||
model: manifest?.model,
|
||||
thinking: manifest?.thinking,
|
||||
});
|
||||
}
|
||||
|
||||
teardown(id: string): void {
|
||||
const rt = this.runtimes.get(id);
|
||||
if (rt) {
|
||||
|
||||
@@ -31,6 +31,12 @@ export function sessionRoutes(app: FastifyInstance, d: { mgr: PiProcessManager;
|
||||
rt.bridge.steer((req.body as any).text);
|
||||
return reply.code(204).send();
|
||||
});
|
||||
app.post("/sessions/:id/resume", async (req, reply) => {
|
||||
const id = (req.params as any).id;
|
||||
const rt = await d.mgr.resume(id, d.tht);
|
||||
rt.bridge.onClientEvent((e) => d.hub.publish(id, e.type, e));
|
||||
return reply.code(200).send({ id });
|
||||
});
|
||||
app.post("/sessions/:id/close", async (req) => {
|
||||
d.mgr.teardown((req.params as any).id);
|
||||
return { closed: true };
|
||||
|
||||
Reference in New Issue
Block a user