cascade-ai 0.11.1 → 0.12.1

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.cjs CHANGED
@@ -14587,6 +14587,18 @@ var DashboardSocket = class {
14587
14587
  });
14588
14588
  });
14589
14589
  }
14590
+ emitToSocket(socketId, event, data) {
14591
+ this.io.sockets.sockets.get(socketId)?.emit(event, data);
14592
+ }
14593
+ onCascadeRun(callback) {
14594
+ this.io.on("connection", (socket) => {
14595
+ socket.on("cascade:run", (payload) => {
14596
+ if (typeof payload?.prompt === "string" && payload.prompt.trim()) {
14597
+ callback(payload.prompt.trim(), payload.model ?? "auto", socket.id);
14598
+ }
14599
+ });
14600
+ });
14601
+ }
14590
14602
  close() {
14591
14603
  this.io.close();
14592
14604
  }
@@ -14648,6 +14660,43 @@ var DashboardServer = class {
14648
14660
  }
14649
14661
  }
14650
14662
  });
14663
+ this.socket.onCascadeRun(async (prompt, model, socketId) => {
14664
+ const sessionId = crypto.randomUUID();
14665
+ const cfg = model !== "auto" ? { ...this.config, models: { ...this.config.models, t1: model } } : this.config;
14666
+ const cascade = new Cascade(cfg, this.workspacePath, this.store);
14667
+ this.activeSessions.set(sessionId, cascade);
14668
+ cascade.on("stream:token", (e) => {
14669
+ this.socket.emitToSocket(socketId, "stream:token", { sessionId, tierId: e.tierId, text: e.text });
14670
+ this.socket.broadcast("stream:token", { sessionId, tierId: e.tierId, text: e.text });
14671
+ });
14672
+ cascade.on("tier:status", (e) => {
14673
+ this.socket.emitToSocket(socketId, "tier:status", { sessionId, ...e });
14674
+ this.socket.broadcast("tier:status", { sessionId, ...e });
14675
+ });
14676
+ cascade.on("permission:user-required", (e) => {
14677
+ this.socket.emitToSocket(socketId, "permission:user-required", { sessionId, ...e });
14678
+ });
14679
+ cascade.on("peer:message", (e) => {
14680
+ this.socket.emitPeerMessage(e);
14681
+ });
14682
+ try {
14683
+ const result = await cascade.run({ prompt });
14684
+ this.socket.emitToSocket(socketId, "session:complete", { sessionId, result });
14685
+ this.socket.broadcast("cost:update", {
14686
+ sessionId,
14687
+ totalTokens: result.usage.totalTokens,
14688
+ totalCostUsd: result.usage.estimatedCostUsd
14689
+ });
14690
+ this.throttledBroadcast("workspace");
14691
+ } catch (err) {
14692
+ this.socket.emitToSocket(socketId, "session:error", {
14693
+ sessionId,
14694
+ error: err instanceof Error ? err.message : String(err)
14695
+ });
14696
+ } finally {
14697
+ this.activeSessions.delete(sessionId);
14698
+ }
14699
+ });
14651
14700
  }
14652
14701
  async start() {
14653
14702
  const isLoopback = this.host === "127.0.0.1" || this.host === "::1" || this.host === "localhost";