agent-theatre 1.3.7 → 1.3.9
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/README.md +5 -0
- package/dist/cli.js +1 -58
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.js +1 -59
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/web/assets/browserAll-DQZ9DKi_.js +2 -0
- package/web/assets/{browserAll-B0tuAxkH.js.map → browserAll-DQZ9DKi_.js.map} +1 -1
- package/web/assets/{index-DcaDqrwu.js → index-7R3Kwh2s.js} +38 -38
- package/web/assets/index-7R3Kwh2s.js.map +1 -0
- package/web/assets/{index-CWrWoYA0.css → index-d1I3dd03.css} +1 -1
- package/web/assets/webworkerAll-CxPyBP1l.js +2 -0
- package/web/assets/{webworkerAll-K1SffoNh.js.map → webworkerAll-CxPyBP1l.js.map} +1 -1
- package/web/index.html +2 -2
- package/web/assets/browserAll-B0tuAxkH.js +0 -2
- package/web/assets/index-DcaDqrwu.js.map +0 -1
- package/web/assets/webworkerAll-K1SffoNh.js +0 -2
package/dist/index.d.ts
CHANGED
|
@@ -26,8 +26,6 @@ declare class Theatre {
|
|
|
26
26
|
private wss;
|
|
27
27
|
private live;
|
|
28
28
|
private signal;
|
|
29
|
-
/** The most recent Claude Code session that spoke to this stage; what a prompt from the stage resumes. */
|
|
30
|
-
private lastSessionId;
|
|
31
29
|
/** The most recent cwd of a Claude Code session that is NOT this repo (so an empty stage can point the person there). */
|
|
32
30
|
private elsewhere;
|
|
33
31
|
private readonly openSessions;
|
|
@@ -47,8 +45,6 @@ declare class Theatre {
|
|
|
47
45
|
get url(): string;
|
|
48
46
|
get name(): string;
|
|
49
47
|
}
|
|
50
|
-
/** Claude Code 2.x on PATH, or the binary the VS Code extension ships; null if neither. Overridable with AGENT_THEATRE_CLAUDE. */
|
|
51
|
-
declare function claudeBinary(): string | null;
|
|
52
48
|
|
|
53
49
|
/** The repo's file tree as FileNodes. Counts lines only; never keeps contents. Bounded for huge repos. */
|
|
54
50
|
declare function scanRepo(root: string, opts?: {
|
|
@@ -92,4 +88,4 @@ declare function hooksStatus(paths?: InstallPaths): {
|
|
|
92
88
|
settings: string;
|
|
93
89
|
};
|
|
94
90
|
|
|
95
|
-
export { type InstallPaths, type SessionInfo, Theatre, type TheatreOptions,
|
|
91
|
+
export { type InstallPaths, type SessionInfo, Theatre, type TheatreOptions, hooksStatus, installHooks, installPaths, listSessions, repoIdFor, scanRepo, sessionTitle, uninstallHooks };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createServer } from "http";
|
|
|
3
3
|
import { existsSync, mkdirSync, readFileSync as readFileSync2, readdirSync as readdirSync2, rmSync, writeFileSync, realpathSync } from "fs";
|
|
4
4
|
import { homedir as homedir2 } from "os";
|
|
5
5
|
import { join as join2, basename as basename2, resolve, sep } from "path";
|
|
6
|
-
import {
|
|
6
|
+
import { spawnSync } from "child_process";
|
|
7
7
|
import { Hono } from "hono";
|
|
8
8
|
import { getRequestListener } from "@hono/node-server";
|
|
9
9
|
import { WebSocketServer } from "ws";
|
|
@@ -1209,8 +1209,6 @@ var Theatre = class {
|
|
|
1209
1209
|
wss = null;
|
|
1210
1210
|
live;
|
|
1211
1211
|
signal = "ok";
|
|
1212
|
-
/** The most recent Claude Code session that spoke to this stage; what a prompt from the stage resumes. */
|
|
1213
|
-
lastSessionId = null;
|
|
1214
1212
|
/** The most recent cwd of a Claude Code session that is NOT this repo (so an empty stage can point the person there). */
|
|
1215
1213
|
elsewhere = null;
|
|
1216
1214
|
openSessions = /* @__PURE__ */ new Set();
|
|
@@ -1234,7 +1232,6 @@ var Theatre = class {
|
|
|
1234
1232
|
return c.body(null, 204);
|
|
1235
1233
|
}
|
|
1236
1234
|
const sid = payload.session_id;
|
|
1237
|
-
if (typeof sid === "string" && sid) this.lastSessionId = sid;
|
|
1238
1235
|
const hookName = payload.hook_event_name;
|
|
1239
1236
|
if (typeof sid === "string" && sid) {
|
|
1240
1237
|
if (hookName === "SessionEnd") this.openSessions.delete(sid);
|
|
@@ -1265,43 +1262,6 @@ var Theatre = class {
|
|
|
1265
1262
|
const beats = direct(events, world);
|
|
1266
1263
|
return c.json({ mode: "replay", repoId: this.opts.repoId, title: s.title, world, events, beats, warnings: warnings.length });
|
|
1267
1264
|
});
|
|
1268
|
-
a.get("/api/prompt", (c) => c.json({ available: !!claudeBinary() && !!this.lastSessionId, session: this.lastSessionId }));
|
|
1269
|
-
a.post("/api/prompt", async (c) => {
|
|
1270
|
-
const body = await c.req.json().catch(() => ({}));
|
|
1271
|
-
const text = typeof body.text === "string" ? body.text.trim() : "";
|
|
1272
|
-
const bin = claudeBinary();
|
|
1273
|
-
if (!text) return c.json({ ok: false, error: "empty prompt" }, 400);
|
|
1274
|
-
if (!bin) return c.json({ ok: false, error: "Claude Code 2.x not found on PATH" }, 503);
|
|
1275
|
-
if (!this.lastSessionId) return c.json({ ok: false, error: "no session to resume yet" }, 409);
|
|
1276
|
-
const logPath = join2(this.opts.home ?? join2(homedir2(), ".agent-theatre"), "prompt.log");
|
|
1277
|
-
const child = spawn(bin, ["-p", "--resume", this.lastSessionId, text], { cwd: this.opts.cwd, stdio: ["ignore", "pipe", "pipe"], detached: true, env: process.env });
|
|
1278
|
-
let err = "";
|
|
1279
|
-
child.stdout?.on("data", (d) => {
|
|
1280
|
-
try {
|
|
1281
|
-
writeFileSync(logPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] out: ${String(d).slice(0, 2e3)}
|
|
1282
|
-
`, { flag: "a" });
|
|
1283
|
-
} catch {
|
|
1284
|
-
}
|
|
1285
|
-
});
|
|
1286
|
-
child.stderr?.on("data", (d) => {
|
|
1287
|
-
err += String(d);
|
|
1288
|
-
try {
|
|
1289
|
-
writeFileSync(logPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] err: ${String(d).slice(0, 2e3)}
|
|
1290
|
-
`, { flag: "a" });
|
|
1291
|
-
} catch {
|
|
1292
|
-
}
|
|
1293
|
-
});
|
|
1294
|
-
child.unref();
|
|
1295
|
-
const early = await new Promise((res) => {
|
|
1296
|
-
const t = setTimeout(() => res(null), 2500);
|
|
1297
|
-
child.once("exit", (code) => {
|
|
1298
|
-
clearTimeout(t);
|
|
1299
|
-
res(code ?? 1);
|
|
1300
|
-
});
|
|
1301
|
-
});
|
|
1302
|
-
if (early !== null && early !== 0) return c.json({ ok: false, error: `Claude Code exited ${early}: ${err.trim().split("\n").pop() ?? "see ~/.agent-theatre/prompt.log"}` }, 502);
|
|
1303
|
-
return c.json({ ok: true, session: this.lastSessionId });
|
|
1304
|
-
});
|
|
1305
1265
|
a.get("/healthz", (c) => c.json({ ok: true, port: this.port, events: this.live.events.length }));
|
|
1306
1266
|
if (this.opts.webDir) {
|
|
1307
1267
|
const dir = this.opts.webDir;
|
|
@@ -1430,23 +1390,6 @@ function isWithin(dir, root) {
|
|
|
1430
1390
|
const d = norm3(dir), r = norm3(root);
|
|
1431
1391
|
return d === r || d.startsWith(r.endsWith(sep) ? r : r + sep);
|
|
1432
1392
|
}
|
|
1433
|
-
function claudeBinary() {
|
|
1434
|
-
const cands = [process.env.AGENT_THEATRE_CLAUDE, "claude"].filter((x) => !!x);
|
|
1435
|
-
try {
|
|
1436
|
-
const ext = join2(homedir2(), ".vscode", "extensions");
|
|
1437
|
-
for (const d of (existsSync(ext) ? readdirSync2(ext) : []).filter((n) => n.startsWith("anthropic.claude-code-")).sort().reverse()) cands.push(join2(ext, d, "resources", "native-binary", "claude"));
|
|
1438
|
-
} catch {
|
|
1439
|
-
}
|
|
1440
|
-
for (const c of cands) {
|
|
1441
|
-
try {
|
|
1442
|
-
const r = spawnSync(c, ["--version"], { encoding: "utf8", timeout: 4e3 });
|
|
1443
|
-
const m = /^(\d+)\./.exec(r.stdout.trim());
|
|
1444
|
-
if (r.status === 0 && m && Number(m[1]) >= 2) return c;
|
|
1445
|
-
} catch {
|
|
1446
|
-
}
|
|
1447
|
-
}
|
|
1448
|
-
return null;
|
|
1449
|
-
}
|
|
1450
1393
|
function portAlive(port) {
|
|
1451
1394
|
const r = spawnSync("lsof", ["-nP", `-iTCP:${port}`, "-sTCP:LISTEN", "-t"], { encoding: "utf8", timeout: 2e3 });
|
|
1452
1395
|
if (r.status === 0 && r.stdout.trim()) return true;
|
|
@@ -1648,7 +1591,6 @@ function hooksStatus(paths = installPaths()) {
|
|
|
1648
1591
|
}
|
|
1649
1592
|
export {
|
|
1650
1593
|
Theatre,
|
|
1651
|
-
claudeBinary,
|
|
1652
1594
|
hooksStatus,
|
|
1653
1595
|
installHooks,
|
|
1654
1596
|
installPaths,
|