agent-theatre 1.3.1 → 1.3.2

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.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 first = command.split(/\s*(?:&&|\|\||;|\|)\s*/)[0] ?? "";
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++;
@@ -1195,6 +1196,8 @@ var Theatre = class {
1195
1196
  signal = "ok";
1196
1197
  /** The most recent Claude Code session that spoke to this stage; what a prompt from the stage resumes. */
1197
1198
  lastSessionId = null;
1199
+ /** The most recent cwd of a Claude Code session that is NOT this repo (so an empty stage can point the person there). */
1200
+ elsewhere = null;
1198
1201
  timer = null;
1199
1202
  port = 0;
1200
1203
  routes() {
@@ -1207,7 +1210,13 @@ var Theatre = class {
1207
1210
  return c.body(null, 204);
1208
1211
  }
1209
1212
  const cwd = typeof payload?.cwd === "string" ? payload.cwd : "";
1210
- if (cwd && !isWithin(cwd, this.opts.cwd)) return c.body(null, 204);
1213
+ if (cwd && !isWithin(cwd, this.opts.cwd)) {
1214
+ if (this.elsewhere !== cwd) {
1215
+ this.elsewhere = cwd;
1216
+ this.broadcast({ type: "elsewhere", cwd });
1217
+ }
1218
+ return c.body(null, 204);
1219
+ }
1211
1220
  const sid = payload.session_id;
1212
1221
  if (typeof sid === "string" && sid) this.lastSessionId = sid;
1213
1222
  const { events } = hookPayloadToEvents(payload, { home: homedir2() });
@@ -1220,7 +1229,7 @@ var Theatre = class {
1220
1229
  for (const [k, v] of Object.entries(cors)) c.res.headers.set(k, v);
1221
1230
  });
1222
1231
  a.options("/api/*", (c) => c.body(null, 204, cors));
1223
- a.get("/api/scene", (c) => c.json({ mode: "live", repoId: this.opts.repoId, world: this.live.world, events: this.live.events, beats: this.live.beats, signal: this.signal }));
1232
+ a.get("/api/scene", (c) => c.json(this.scene()));
1224
1233
  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
1234
  a.get("/api/replay/:id", (c) => {
1226
1235
  const id = c.req.param("id");
@@ -1354,7 +1363,7 @@ var Theatre = class {
1354
1363
  }
1355
1364
  /** The live scene as /api/scene returns it. */
1356
1365
  scene() {
1357
- return { mode: "live", repoId: this.opts.repoId, world: this.live.world, events: this.live.events, beats: this.live.beats, signal: this.signal };
1366
+ 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
1367
  }
1359
1368
  get url() {
1360
1369
  return `http://127.0.0.1:${this.port}/`;