cascade-ai 0.12.0 → 0.12.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.cjs +49 -0
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +49 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +49 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -14540,6 +14540,18 @@ var DashboardSocket = class {
|
|
|
14540
14540
|
});
|
|
14541
14541
|
});
|
|
14542
14542
|
}
|
|
14543
|
+
emitToSocket(socketId, event, data) {
|
|
14544
|
+
this.io.sockets.sockets.get(socketId)?.emit(event, data);
|
|
14545
|
+
}
|
|
14546
|
+
onCascadeRun(callback) {
|
|
14547
|
+
this.io.on("connection", (socket) => {
|
|
14548
|
+
socket.on("cascade:run", (payload) => {
|
|
14549
|
+
if (typeof payload?.prompt === "string" && payload.prompt.trim()) {
|
|
14550
|
+
callback(payload.prompt.trim(), payload.model ?? "auto", socket.id);
|
|
14551
|
+
}
|
|
14552
|
+
});
|
|
14553
|
+
});
|
|
14554
|
+
}
|
|
14543
14555
|
close() {
|
|
14544
14556
|
this.io.close();
|
|
14545
14557
|
}
|
|
@@ -14601,6 +14613,43 @@ var DashboardServer = class {
|
|
|
14601
14613
|
}
|
|
14602
14614
|
}
|
|
14603
14615
|
});
|
|
14616
|
+
this.socket.onCascadeRun(async (prompt, model, socketId) => {
|
|
14617
|
+
const sessionId = randomUUID();
|
|
14618
|
+
const cfg = model !== "auto" ? { ...this.config, models: { ...this.config.models, t1: model } } : this.config;
|
|
14619
|
+
const cascade = new Cascade(cfg, this.workspacePath, this.store);
|
|
14620
|
+
this.activeSessions.set(sessionId, cascade);
|
|
14621
|
+
cascade.on("stream:token", (e) => {
|
|
14622
|
+
this.socket.emitToSocket(socketId, "stream:token", { sessionId, tierId: e.tierId, text: e.text });
|
|
14623
|
+
this.socket.broadcast("stream:token", { sessionId, tierId: e.tierId, text: e.text });
|
|
14624
|
+
});
|
|
14625
|
+
cascade.on("tier:status", (e) => {
|
|
14626
|
+
this.socket.emitToSocket(socketId, "tier:status", { sessionId, ...e });
|
|
14627
|
+
this.socket.broadcast("tier:status", { sessionId, ...e });
|
|
14628
|
+
});
|
|
14629
|
+
cascade.on("permission:user-required", (e) => {
|
|
14630
|
+
this.socket.emitToSocket(socketId, "permission:user-required", { sessionId, ...e });
|
|
14631
|
+
});
|
|
14632
|
+
cascade.on("peer:message", (e) => {
|
|
14633
|
+
this.socket.emitPeerMessage(e);
|
|
14634
|
+
});
|
|
14635
|
+
try {
|
|
14636
|
+
const result = await cascade.run({ prompt });
|
|
14637
|
+
this.socket.emitToSocket(socketId, "session:complete", { sessionId, result });
|
|
14638
|
+
this.socket.broadcast("cost:update", {
|
|
14639
|
+
sessionId,
|
|
14640
|
+
totalTokens: result.usage.totalTokens,
|
|
14641
|
+
totalCostUsd: result.usage.estimatedCostUsd
|
|
14642
|
+
});
|
|
14643
|
+
this.throttledBroadcast("workspace");
|
|
14644
|
+
} catch (err) {
|
|
14645
|
+
this.socket.emitToSocket(socketId, "session:error", {
|
|
14646
|
+
sessionId,
|
|
14647
|
+
error: err instanceof Error ? err.message : String(err)
|
|
14648
|
+
});
|
|
14649
|
+
} finally {
|
|
14650
|
+
this.activeSessions.delete(sessionId);
|
|
14651
|
+
}
|
|
14652
|
+
});
|
|
14604
14653
|
}
|
|
14605
14654
|
async start() {
|
|
14606
14655
|
const isLoopback = this.host === "127.0.0.1" || this.host === "::1" || this.host === "localhost";
|