agent-theatre 1.3.1 → 1.3.3
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/cli.js +24 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +24 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/web/assets/browserAll-DMruipHl.js +2 -0
- package/web/assets/{browserAll-jpKtMttp.js.map → browserAll-DMruipHl.js.map} +1 -1
- package/web/assets/{index-DoUA_XxG.js → index-CSVCrpUG.js} +12 -12
- package/web/assets/index-CSVCrpUG.js.map +1 -0
- package/web/assets/webworkerAll-DVbAiE6j.js +2 -0
- package/web/assets/{webworkerAll-eBrHhNNp.js.map → webworkerAll-DVbAiE6j.js.map} +1 -1
- package/web/index.html +1 -1
- package/web/assets/browserAll-jpKtMttp.js +0 -2
- package/web/assets/index-DoUA_XxG.js.map +0 -1
- package/web/assets/webworkerAll-eBrHhNNp.js +0 -2
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ declare class Theatre {
|
|
|
28
28
|
private signal;
|
|
29
29
|
/** The most recent Claude Code session that spoke to this stage; what a prompt from the stage resumes. */
|
|
30
30
|
private lastSessionId;
|
|
31
|
+
/** The most recent cwd of a Claude Code session that is NOT this repo (so an empty stage can point the person there). */
|
|
32
|
+
private elsewhere;
|
|
31
33
|
private timer;
|
|
32
34
|
port: number;
|
|
33
35
|
constructor(opts: TheatreOptions);
|
package/dist/index.js
CHANGED
|
@@ -54,7 +54,8 @@ var INSTALL = /\b(npm\s+(i|install|ci)|pnpm\s+(i|install|add)|yarn(\s+add|\s+ins
|
|
|
54
54
|
var SEARCH = /\b(grep|rg|ag|ack|find|fd|locate)\b/;
|
|
55
55
|
var READ = /^\s*(cat|head|tail|less|more|bat|wc|stat|jq)\b/;
|
|
56
56
|
function argv0Of(command) {
|
|
57
|
-
const
|
|
57
|
+
const segments = command.split(/\s*(?:&&|\|\||;|\|)\s*/);
|
|
58
|
+
const first = (segments.find((s) => !/^\s*(\[|test\b|!)/.test(s)) ?? segments[0] ?? "").replace(/^\s*!\s*/, "");
|
|
58
59
|
const toks = first.trim().split(/\s+/).map((t) => t.replace(/^[({]+/, "")).filter(Boolean);
|
|
59
60
|
let i = 0;
|
|
60
61
|
while (i < toks.length && /^[A-Za-z_][A-Za-z0-9_]*=/.test(toks[i])) i++;
|
|
@@ -359,9 +360,17 @@ function hookPayloadToEvents(payload, opts = {}) {
|
|
|
359
360
|
}
|
|
360
361
|
function noteOf(text) {
|
|
361
362
|
if (!text) return {};
|
|
362
|
-
const
|
|
363
|
-
if (!
|
|
364
|
-
|
|
363
|
+
const clean = text.replace(/```[\s\S]*?```/g, " ").replace(/`([^`]*)`/g, "$1").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/\*+|#+|>+/g, "").replace(/(^|\s)_+|_+(?=\s|$)/g, "$1").replace(/^\s*[-•\d.)]+\s+/gm, "").replace(/\s+/g, " ").trim();
|
|
364
|
+
if (!clean) return {};
|
|
365
|
+
const sentences = clean.match(/[^.!?]+[.!?]+(?=\s|$)|[^.!?]+$/g)?.map((x) => x.trim()).filter(Boolean) ?? [clean];
|
|
366
|
+
const questions = sentences.filter((x) => x.endsWith("?"));
|
|
367
|
+
let note = questions.length ? questions[questions.length - 1] : sentences[0];
|
|
368
|
+
if (!questions.length) for (const next of sentences.slice(1)) {
|
|
369
|
+
if (!/[.!?]$/.test(next) || note.length + next.length + 1 > 160) break;
|
|
370
|
+
note = `${note} ${next}`;
|
|
371
|
+
}
|
|
372
|
+
if (note.length > 200) note = note.slice(0, 197).replace(/\s+\S*$/, "") + "\u2026";
|
|
373
|
+
return { note };
|
|
365
374
|
}
|
|
366
375
|
var ROW_TYPES = /* @__PURE__ */ new Set(["user", "assistant", "system"]);
|
|
367
376
|
var obj3 = (x) => x && typeof x === "object" ? x : {};
|
|
@@ -1195,6 +1204,8 @@ var Theatre = class {
|
|
|
1195
1204
|
signal = "ok";
|
|
1196
1205
|
/** The most recent Claude Code session that spoke to this stage; what a prompt from the stage resumes. */
|
|
1197
1206
|
lastSessionId = null;
|
|
1207
|
+
/** The most recent cwd of a Claude Code session that is NOT this repo (so an empty stage can point the person there). */
|
|
1208
|
+
elsewhere = null;
|
|
1198
1209
|
timer = null;
|
|
1199
1210
|
port = 0;
|
|
1200
1211
|
routes() {
|
|
@@ -1207,7 +1218,13 @@ var Theatre = class {
|
|
|
1207
1218
|
return c.body(null, 204);
|
|
1208
1219
|
}
|
|
1209
1220
|
const cwd = typeof payload?.cwd === "string" ? payload.cwd : "";
|
|
1210
|
-
if (cwd && !isWithin(cwd, this.opts.cwd))
|
|
1221
|
+
if (cwd && !isWithin(cwd, this.opts.cwd)) {
|
|
1222
|
+
if (this.elsewhere !== cwd) {
|
|
1223
|
+
this.elsewhere = cwd;
|
|
1224
|
+
this.broadcast({ type: "elsewhere", cwd });
|
|
1225
|
+
}
|
|
1226
|
+
return c.body(null, 204);
|
|
1227
|
+
}
|
|
1211
1228
|
const sid = payload.session_id;
|
|
1212
1229
|
if (typeof sid === "string" && sid) this.lastSessionId = sid;
|
|
1213
1230
|
const { events } = hookPayloadToEvents(payload, { home: homedir2() });
|
|
@@ -1220,7 +1237,7 @@ var Theatre = class {
|
|
|
1220
1237
|
for (const [k, v] of Object.entries(cors)) c.res.headers.set(k, v);
|
|
1221
1238
|
});
|
|
1222
1239
|
a.options("/api/*", (c) => c.body(null, 204, cors));
|
|
1223
|
-
a.get("/api/scene", (c) => c.json(
|
|
1240
|
+
a.get("/api/scene", (c) => c.json(this.scene()));
|
|
1224
1241
|
a.get("/api/sessions", (c) => c.json(listSessions(this.opts.cwd).map((s) => ({ id: s.id, title: s.title, mtime: s.mtime, bytes: s.bytes }))));
|
|
1225
1242
|
a.get("/api/replay/:id", (c) => {
|
|
1226
1243
|
const id = c.req.param("id");
|
|
@@ -1354,7 +1371,7 @@ var Theatre = class {
|
|
|
1354
1371
|
}
|
|
1355
1372
|
/** The live scene as /api/scene returns it. */
|
|
1356
1373
|
scene() {
|
|
1357
|
-
return { mode: "live", repoId: this.opts.repoId, world: this.live.world, events: this.live.events, beats: this.live.beats, signal: this.signal };
|
|
1374
|
+
return { mode: "live", repoId: this.opts.repoId, cwd: this.opts.cwd, elsewhere: this.elsewhere, world: this.live.world, events: this.live.events, beats: this.live.beats, signal: this.signal };
|
|
1358
1375
|
}
|
|
1359
1376
|
get url() {
|
|
1360
1377
|
return `http://127.0.0.1:${this.port}/`;
|