cascade-ai 0.12.3 → 0.12.5

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.cjs CHANGED
@@ -74,100 +74,10 @@ var jwt__default = /*#__PURE__*/_interopDefault(jwt);
74
74
  var cron__default = /*#__PURE__*/_interopDefault(cron);
75
75
 
76
76
  // Cascade AI — Multi-tier AI Orchestration System
77
- var __create = Object.create;
78
- var __defProp = Object.defineProperty;
79
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
80
- var __getOwnPropNames = Object.getOwnPropertyNames;
81
- var __getProtoOf = Object.getPrototypeOf;
82
- var __hasOwnProp = Object.prototype.hasOwnProperty;
83
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
84
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
85
- }) : x)(function(x) {
86
- if (typeof require !== "undefined") return require.apply(this, arguments);
87
- throw Error('Dynamic require of "' + x + '" is not supported');
88
- });
89
- var __esm = (fn, res) => function __init() {
90
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
91
- };
92
- var __commonJS = (cb, mod) => function __require2() {
93
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
94
- };
95
- var __copyProps = (to, from, except, desc) => {
96
- if (from && typeof from === "object" || typeof from === "function") {
97
- for (let key of __getOwnPropNames(from))
98
- if (!__hasOwnProp.call(to, key) && key !== except)
99
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
100
- }
101
- return to;
102
- };
103
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
104
- // If the importer is in node compatibility mode or this is not an ESM
105
- // file that has been converted to a CommonJS file using a Babel-
106
- // compatible transform (i.e. "__esModule" has not been set), then set
107
- // "default" to the CommonJS "module.exports" for node compatibility.
108
- __defProp(target, "default", { value: mod, enumerable: true }) ,
109
- mod
110
- ));
111
-
112
- // node_modules/keytar/build/Release/keytar.node
113
- var keytar_default;
114
- var init_keytar = __esm({
115
- "node_modules/keytar/build/Release/keytar.node"() {
116
- keytar_default = "./keytar-VMICNFEJ.node";
117
- }
118
- });
119
-
120
- // node-file:/home/runner/work/Cascade-AI/Cascade-AI/node_modules/keytar/build/Release/keytar.node
121
- var require_keytar = __commonJS({
122
- "node-file:/home/runner/work/Cascade-AI/Cascade-AI/node_modules/keytar/build/Release/keytar.node"(exports, module) {
123
- init_keytar();
124
- try {
125
- module.exports = __require(keytar_default);
126
- } catch {
127
- }
128
- }
129
- });
130
77
 
131
- // node_modules/keytar/lib/keytar.js
132
- var require_keytar2 = __commonJS({
133
- "node_modules/keytar/lib/keytar.js"(exports, module) {
134
- var keytar = require_keytar();
135
- function checkRequired(val, name) {
136
- if (!val || val.length <= 0) {
137
- throw new Error(name + " is required.");
138
- }
139
- }
140
- module.exports = {
141
- getPassword: function(service, account) {
142
- checkRequired(service, "Service");
143
- checkRequired(account, "Account");
144
- return keytar.getPassword(service, account);
145
- },
146
- setPassword: function(service, account, password) {
147
- checkRequired(service, "Service");
148
- checkRequired(account, "Account");
149
- checkRequired(password, "Password");
150
- return keytar.setPassword(service, account, password);
151
- },
152
- deletePassword: function(service, account) {
153
- checkRequired(service, "Service");
154
- checkRequired(account, "Account");
155
- return keytar.deletePassword(service, account);
156
- },
157
- findPassword: function(service) {
158
- checkRequired(service, "Service");
159
- return keytar.findPassword(service);
160
- },
161
- findCredentials: function(service) {
162
- checkRequired(service, "Service");
163
- return keytar.findCredentials(service);
164
- }
165
- };
166
- }
167
- });
168
78
 
169
79
  // src/constants.ts
170
- var CASCADE_VERSION = "0.9.6";
80
+ var CASCADE_VERSION = "0.12.5";
171
81
  var CASCADE_CONFIG_DIR = ".cascade";
172
82
  var CASCADE_MD_FILE = "CASCADE.md";
173
83
  var CASCADE_IGNORE_FILE = ".cascadeignore";
@@ -2258,7 +2168,7 @@ var CascadeRouter = class _CascadeRouter extends EventEmitter__default.default {
2258
2168
  }
2259
2169
  for (const tier of ["T1", "T2", "T3"]) {
2260
2170
  const override = tier === "T1" ? config.models.t1 : tier === "T2" ? config.models.t2 : config.models.t3;
2261
- if (!override) continue;
2171
+ if (!override || override === "auto") continue;
2262
2172
  const model = this.selector.selectForTier(tier, override);
2263
2173
  if (!model) {
2264
2174
  const knownProviders = ["anthropic", "openai", "gemini", "azure", "openai-compatible", "ollama"];
@@ -9306,7 +9216,7 @@ var PBKDF2_ITERATIONS = 1e5;
9306
9216
  var KEYTAR_SERVICE = "cascade-ai";
9307
9217
  async function loadKeytar() {
9308
9218
  try {
9309
- const mod = await Promise.resolve().then(() => __toESM(require_keytar2(), 1));
9219
+ const mod = await import('keytar');
9310
9220
  const candidate = mod.default ?? mod;
9311
9221
  if (typeof candidate.getPassword !== "function") return null;
9312
9222
  return candidate;
@@ -10608,6 +10518,11 @@ var DashboardSocket = class {
10608
10518
  emitToSocket(socketId, event, data) {
10609
10519
  this.io.sockets.sockets.get(socketId)?.emit(event, data);
10610
10520
  }
10521
+ onConfigGet(callback) {
10522
+ this.io.on("connection", (socket) => {
10523
+ socket.on("config:get", () => callback(socket.id));
10524
+ });
10525
+ }
10611
10526
  onCascadeRun(callback) {
10612
10527
  this.io.on("connection", (socket) => {
10613
10528
  socket.on("cascade:run", (payload) => {
@@ -10654,6 +10569,16 @@ var DashboardServer = class {
10654
10569
  this.socket.onSessionRate((sessionId, rating) => {
10655
10570
  this.activeSessions.get(sessionId)?.rateLastRun(rating);
10656
10571
  });
10572
+ this.socket.onConfigGet((socketId) => {
10573
+ this.socket.emitToSocket(socketId, "config:current", {
10574
+ models: this.config.models ?? {},
10575
+ budget: {
10576
+ maxCostPerRun: this.config.budget?.maxCostPerRunUsd,
10577
+ autoBias: this.config.autoBias
10578
+ },
10579
+ providersWithKey: (this.config.providers ?? []).filter((p) => typeof p.apiKey === "string" && p.apiKey.length > 0).map((p) => p.type)
10580
+ });
10581
+ });
10657
10582
  this.socket.onConfigUpdate((data) => {
10658
10583
  if (data.keys) {
10659
10584
  for (const [type, apiKey] of Object.entries(data.keys)) {
@@ -10664,7 +10589,11 @@ var DashboardServer = class {
10664
10589
  }
10665
10590
  }
10666
10591
  if (data.models) {
10667
- this.config.models = { ...this.config.models, ...data.models };
10592
+ const models = this.config.models;
10593
+ for (const [tier, val] of Object.entries(data.models)) {
10594
+ if (val && val !== "auto") models[tier] = val;
10595
+ else delete models[tier];
10596
+ }
10668
10597
  }
10669
10598
  if (data.budget) {
10670
10599
  if (typeof data.budget.maxCostPerRun === "number") {
@@ -10674,6 +10603,7 @@ var DashboardServer = class {
10674
10603
  this.config.autoBias = data.budget.autoBias;
10675
10604
  }
10676
10605
  }
10606
+ this.persistConfig();
10677
10607
  });
10678
10608
  this.socket.onCascadeRun(async (prompt, model, socketId) => {
10679
10609
  const sessionId = crypto.randomUUID();
@@ -10750,6 +10680,20 @@ var DashboardServer = class {
10750
10680
  getSocket() {
10751
10681
  return this.socket;
10752
10682
  }
10683
+ /**
10684
+ * Write the in-memory config back to the workspace config file so mutations
10685
+ * made over the socket (Settings → Save) persist across restarts. Best-effort:
10686
+ * a write failure is logged but never crashes the running dashboard.
10687
+ */
10688
+ persistConfig() {
10689
+ try {
10690
+ const configPath = path18__default.default.join(this.workspacePath, CASCADE_CONFIG_FILE);
10691
+ fs17__default.default.mkdirSync(path18__default.default.dirname(configPath), { recursive: true });
10692
+ fs17__default.default.writeFileSync(configPath, JSON.stringify(this.config, null, 2), "utf-8");
10693
+ } catch (err) {
10694
+ console.warn(`[dashboard] Failed to persist config: ${err instanceof Error ? err.message : String(err)}`);
10695
+ }
10696
+ }
10753
10697
  /**
10754
10698
  * Produce a stable dashboard JWT signing secret.
10755
10699
  *