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/README.md CHANGED
@@ -45,3 +45,5 @@ await t.listen(0); // t.url → http://127.0.0.1:<port>/
45
45
  ```
46
46
 
47
47
  MIT · source: https://github.com/shreyassaw5394/agent-theatre
48
+
49
+ Community: https://discord.gg/PPGeQWd7r
package/dist/cli.js CHANGED
@@ -1281,7 +1281,15 @@ var Theatre = class {
1281
1281
  this.broadcast({ type: "beats", beats: out, events });
1282
1282
  return out;
1283
1283
  }
1284
+ /** In-process subscribers (the VS Code extension relays these to its webview). */
1285
+ listeners = /* @__PURE__ */ new Set();
1284
1286
  broadcast(msg) {
1287
+ for (const l of this.listeners) {
1288
+ try {
1289
+ l(msg);
1290
+ } catch {
1291
+ }
1292
+ }
1285
1293
  const data = JSON.stringify(msg);
1286
1294
  for (const ws of this.wss?.clients ?? []) if (ws.readyState === 1) ws.send(data);
1287
1295
  }
@@ -1324,6 +1332,10 @@ var Theatre = class {
1324
1332
  this.wss?.close();
1325
1333
  await new Promise((res) => this.server ? this.server.close(() => res()) : res());
1326
1334
  }
1335
+ /** The live scene as /api/scene returns it. */
1336
+ scene() {
1337
+ return { mode: "live", repoId: this.opts.repoId, world: this.live.world, events: this.live.events, beats: this.live.beats, signal: this.signal };
1338
+ }
1327
1339
  get url() {
1328
1340
  return `http://127.0.0.1:${this.port}/`;
1329
1341
  }