agent-theatre 1.2.0 → 1.2.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
@@ -34,9 +34,13 @@ declare class Theatre {
34
34
  private routes;
35
35
  /** Append events to the live session, direct them, and broadcast. */
36
36
  ingest(events: AgentEvent[]): Beat[];
37
+ /** In-process subscribers (the VS Code extension relays these to its webview). */
38
+ readonly listeners: Set<(msg: unknown) => void>;
37
39
  private broadcast;
38
40
  listen(port?: number): Promise<number>;
39
41
  close(): Promise<void>;
42
+ /** The live scene as /api/scene returns it. */
43
+ scene(): unknown;
40
44
  get url(): string;
41
45
  get name(): string;
42
46
  }
package/dist/index.js CHANGED
@@ -1272,7 +1272,15 @@ var Theatre = class {
1272
1272
  this.broadcast({ type: "beats", beats: out, events });
1273
1273
  return out;
1274
1274
  }
1275
+ /** In-process subscribers (the VS Code extension relays these to its webview). */
1276
+ listeners = /* @__PURE__ */ new Set();
1275
1277
  broadcast(msg) {
1278
+ for (const l of this.listeners) {
1279
+ try {
1280
+ l(msg);
1281
+ } catch {
1282
+ }
1283
+ }
1276
1284
  const data = JSON.stringify(msg);
1277
1285
  for (const ws of this.wss?.clients ?? []) if (ws.readyState === 1) ws.send(data);
1278
1286
  }
@@ -1315,6 +1323,10 @@ var Theatre = class {
1315
1323
  this.wss?.close();
1316
1324
  await new Promise((res) => this.server ? this.server.close(() => res()) : res());
1317
1325
  }
1326
+ /** The live scene as /api/scene returns it. */
1327
+ scene() {
1328
+ return { mode: "live", repoId: this.opts.repoId, world: this.live.world, events: this.live.events, beats: this.live.beats, signal: this.signal };
1329
+ }
1318
1330
  get url() {
1319
1331
  return `http://127.0.0.1:${this.port}/`;
1320
1332
  }