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/cli.js CHANGED
@@ -63,7 +63,8 @@ var INSTALL = /\b(npm\s+(i|install|ci)|pnpm\s+(i|install|add)|yarn(\s+add|\s+ins
63
63
  var SEARCH = /\b(grep|rg|ag|ack|find|fd|locate)\b/;
64
64
  var READ = /^\s*(cat|head|tail|less|more|bat|wc|stat|jq)\b/;
65
65
  function argv0Of(command) {
66
- const first = command.split(/\s*(?:&&|\|\||;|\|)\s*/)[0] ?? "";
66
+ const segments = command.split(/\s*(?:&&|\|\||;|\|)\s*/);
67
+ const first = (segments.find((s) => !/^\s*(\[|test\b|!)/.test(s)) ?? segments[0] ?? "").replace(/^\s*!\s*/, "");
67
68
  const toks = first.trim().split(/\s+/).map((t) => t.replace(/^[({]+/, "")).filter(Boolean);
68
69
  let i = 0;
69
70
  while (i < toks.length && /^[A-Za-z_][A-Za-z0-9_]*=/.test(toks[i])) i++;
@@ -1204,6 +1205,8 @@ var Theatre = class {
1204
1205
  signal = "ok";
1205
1206
  /** The most recent Claude Code session that spoke to this stage; what a prompt from the stage resumes. */
1206
1207
  lastSessionId = null;
1208
+ /** The most recent cwd of a Claude Code session that is NOT this repo (so an empty stage can point the person there). */
1209
+ elsewhere = null;
1207
1210
  timer = null;
1208
1211
  port = 0;
1209
1212
  routes() {
@@ -1216,7 +1219,13 @@ var Theatre = class {
1216
1219
  return c.body(null, 204);
1217
1220
  }
1218
1221
  const cwd = typeof payload?.cwd === "string" ? payload.cwd : "";
1219
- if (cwd && !isWithin(cwd, this.opts.cwd)) return c.body(null, 204);
1222
+ if (cwd && !isWithin(cwd, this.opts.cwd)) {
1223
+ if (this.elsewhere !== cwd) {
1224
+ this.elsewhere = cwd;
1225
+ this.broadcast({ type: "elsewhere", cwd });
1226
+ }
1227
+ return c.body(null, 204);
1228
+ }
1220
1229
  const sid = payload.session_id;
1221
1230
  if (typeof sid === "string" && sid) this.lastSessionId = sid;
1222
1231
  const { events } = hookPayloadToEvents(payload, { home: homedir2() });
@@ -1229,7 +1238,7 @@ var Theatre = class {
1229
1238
  for (const [k, v] of Object.entries(cors)) c.res.headers.set(k, v);
1230
1239
  });
1231
1240
  a.options("/api/*", (c) => c.body(null, 204, cors));
1232
- 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 }));
1241
+ a.get("/api/scene", (c) => c.json(this.scene()));
1233
1242
  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 }))));
1234
1243
  a.get("/api/replay/:id", (c) => {
1235
1244
  const id = c.req.param("id");
@@ -1363,7 +1372,7 @@ var Theatre = class {
1363
1372
  }
1364
1373
  /** The live scene as /api/scene returns it. */
1365
1374
  scene() {
1366
- return { mode: "live", repoId: this.opts.repoId, world: this.live.world, events: this.live.events, beats: this.live.beats, signal: this.signal };
1375
+ 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 };
1367
1376
  }
1368
1377
  get url() {
1369
1378
  return `http://127.0.0.1:${this.port}/`;