cascade-ai 0.12.4 → 0.12.6

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
@@ -87,50 +87,21 @@ var parser__default = /*#__PURE__*/_interopDefault(parser);
87
87
  var jwt__default = /*#__PURE__*/_interopDefault(jwt);
88
88
 
89
89
  // Cascade AI — Multi-tier AI Orchestration System
90
- var __create = Object.create;
91
90
  var __defProp = Object.defineProperty;
92
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
93
91
  var __getOwnPropNames = Object.getOwnPropertyNames;
94
- var __getProtoOf = Object.getPrototypeOf;
95
- var __hasOwnProp = Object.prototype.hasOwnProperty;
96
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
97
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
98
- }) : x)(function(x) {
99
- if (typeof require !== "undefined") return require.apply(this, arguments);
100
- throw Error('Dynamic require of "' + x + '" is not supported');
101
- });
102
92
  var __esm = (fn, res) => function __init() {
103
93
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
104
94
  };
105
- var __commonJS = (cb, mod) => function __require2() {
106
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
107
- };
108
95
  var __export = (target, all) => {
109
96
  for (var name in all)
110
97
  __defProp(target, name, { get: all[name], enumerable: true });
111
98
  };
112
- var __copyProps = (to, from, except, desc) => {
113
- if (from && typeof from === "object" || typeof from === "function") {
114
- for (let key of __getOwnPropNames(from))
115
- if (!__hasOwnProp.call(to, key) && key !== except)
116
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
117
- }
118
- return to;
119
- };
120
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
121
- // If the importer is in node compatibility mode or this is not an ESM
122
- // file that has been converted to a CommonJS file using a Babel-
123
- // compatible transform (i.e. "__esModule" has not been set), then set
124
- // "default" to the CommonJS "module.exports" for node compatibility.
125
- __defProp(target, "default", { value: mod, enumerable: true }) ,
126
- mod
127
- ));
128
99
 
129
100
  // src/constants.ts
130
101
  var CASCADE_VERSION, CASCADE_CONFIG_FILE, CASCADE_DB_FILE, CASCADE_DASHBOARD_SECRET_FILE, GLOBAL_CONFIG_DIR, GLOBAL_DB_FILE, GLOBAL_KEYSTORE_FILE, GLOBAL_RUNTIME_DB_FILE, DEFAULT_DASHBOARD_PORT, DEFAULT_CONTEXT_LIMIT, DEFAULT_AUTO_SUMMARIZE_AT, MODELS, T1_MODEL_PRIORITY, T2_MODEL_PRIORITY, T3_MODEL_PRIORITY, VISION_MODEL_PRIORITY, COMPLEXITY_T2_COUNT, THEME_NAMES, DEFAULT_THEME, OLLAMA_BASE_URL, LM_STUDIO_BASE_URL, AZURE_BASE_URL_TEMPLATE, TOOL_NAMES, DEFAULT_APPROVAL_REQUIRED;
131
102
  var init_constants = __esm({
132
103
  "src/constants.ts"() {
133
- CASCADE_VERSION = "0.9.6";
104
+ CASCADE_VERSION = "0.12.6";
134
105
  CASCADE_CONFIG_FILE = ".cascade/config.json";
135
106
  CASCADE_DB_FILE = ".cascade/memory.db";
136
107
  CASCADE_DASHBOARD_SECRET_FILE = ".cascade/dashboard-secret";
@@ -191,6 +162,30 @@ var init_constants = __esm({
191
162
  supportsStreaming: true,
192
163
  isLocal: false
193
164
  },
165
+ "claude-opus-4-8": {
166
+ id: "claude-opus-4-8",
167
+ name: "Claude Opus 4.8",
168
+ provider: "anthropic",
169
+ contextWindow: 2e5,
170
+ isVisionCapable: true,
171
+ inputCostPer1kTokens: 0.015,
172
+ outputCostPer1kTokens: 0.075,
173
+ maxOutputTokens: 32e3,
174
+ supportsStreaming: true,
175
+ isLocal: false
176
+ },
177
+ "claude-sonnet-4-6": {
178
+ id: "claude-sonnet-4-6",
179
+ name: "Claude Sonnet 4.6",
180
+ provider: "anthropic",
181
+ contextWindow: 2e5,
182
+ isVisionCapable: true,
183
+ inputCostPer1kTokens: 3e-3,
184
+ outputCostPer1kTokens: 0.015,
185
+ maxOutputTokens: 16e3,
186
+ supportsStreaming: true,
187
+ isLocal: false
188
+ },
194
189
  // OpenAI
195
190
  "gpt-4o": {
196
191
  id: "gpt-4o",
@@ -446,60 +441,26 @@ var init_constants = __esm({
446
441
  }
447
442
  });
448
443
 
449
- // node_modules/keytar/build/Release/keytar.node
450
- var keytar_default;
451
- var init_keytar = __esm({
452
- "node_modules/keytar/build/Release/keytar.node"() {
453
- keytar_default = "./keytar-VMICNFEJ.node";
454
- }
455
- });
456
-
457
- // node-file:/home/runner/work/Cascade-AI/Cascade-AI/node_modules/keytar/build/Release/keytar.node
458
- var require_keytar = __commonJS({
459
- "node-file:/home/runner/work/Cascade-AI/Cascade-AI/node_modules/keytar/build/Release/keytar.node"(exports, module) {
460
- init_keytar();
461
- try {
462
- module.exports = __require(keytar_default);
463
- } catch {
444
+ // src/utils/cost.ts
445
+ function resolveModelPricing(model) {
446
+ let input = model.inputCostPer1kTokens;
447
+ let output = model.outputCostPer1kTokens;
448
+ if (input === 0 && output === 0 && model.id && !model.isLocal) {
449
+ const known = Object.values(MODELS).find((m) => m.id === model.id && !m.isLocal);
450
+ if (known) {
451
+ input = known.inputCostPer1kTokens;
452
+ output = known.outputCostPer1kTokens;
464
453
  }
465
454
  }
466
- });
467
-
468
- // node_modules/keytar/lib/keytar.js
469
- var require_keytar2 = __commonJS({
470
- "node_modules/keytar/lib/keytar.js"(exports, module) {
471
- var keytar = require_keytar();
472
- function checkRequired(val, name) {
473
- if (!val || val.length <= 0) {
474
- throw new Error(name + " is required.");
475
- }
476
- }
477
- module.exports = {
478
- getPassword: function(service, account) {
479
- checkRequired(service, "Service");
480
- checkRequired(account, "Account");
481
- return keytar.getPassword(service, account);
482
- },
483
- setPassword: function(service, account, password) {
484
- checkRequired(service, "Service");
485
- checkRequired(account, "Account");
486
- checkRequired(password, "Password");
487
- return keytar.setPassword(service, account, password);
488
- },
489
- deletePassword: function(service, account) {
490
- checkRequired(service, "Service");
491
- checkRequired(account, "Account");
492
- return keytar.deletePassword(service, account);
493
- },
494
- findPassword: function(service) {
495
- checkRequired(service, "Service");
496
- return keytar.findPassword(service);
497
- },
498
- findCredentials: function(service) {
499
- checkRequired(service, "Service");
500
- return keytar.findCredentials(service);
501
- }
502
- };
455
+ return { input, output };
456
+ }
457
+ function calculateCost(inputTokens, outputTokens, model) {
458
+ const { input, output } = resolveModelPricing(model);
459
+ return inputTokens / 1e3 * input + outputTokens / 1e3 * output;
460
+ }
461
+ var init_cost = __esm({
462
+ "src/utils/cost.ts"() {
463
+ init_constants();
503
464
  }
504
465
  });
505
466
 
@@ -507,6 +468,7 @@ var require_keytar2 = __commonJS({
507
468
  var BaseProvider;
508
469
  var init_base = __esm({
509
470
  "src/providers/base.ts"() {
471
+ init_cost();
510
472
  BaseProvider = class {
511
473
  config;
512
474
  model;
@@ -521,7 +483,7 @@ var init_base = __esm({
521
483
  return this.model.isVisionCapable;
522
484
  }
523
485
  estimateCost(inputTokens, outputTokens) {
524
- return inputTokens / 1e3 * this.model.inputCostPer1kTokens + outputTokens / 1e3 * this.model.outputCostPer1kTokens;
486
+ return calculateCost(inputTokens, outputTokens, this.model);
525
487
  }
526
488
  makeUsage(inputTokens, outputTokens) {
527
489
  return {
@@ -1512,7 +1474,7 @@ var PBKDF2_ITERATIONS = 1e5;
1512
1474
  var KEYTAR_SERVICE = "cascade-ai";
1513
1475
  async function loadKeytar() {
1514
1476
  try {
1515
- const mod = await Promise.resolve().then(() => __toESM(require_keytar2(), 1));
1477
+ const mod = await import('keytar');
1516
1478
  const candidate = mod.default ?? mod;
1517
1479
  if (typeof candidate.getPassword !== "function") return null;
1518
1480
  return candidate;
@@ -3646,11 +3608,7 @@ var LocalRequestQueue = class {
3646
3608
 
3647
3609
  // src/core/router/index.ts
3648
3610
  init_constants();
3649
-
3650
- // src/utils/cost.ts
3651
- function calculateCost(inputTokens, outputTokens, model) {
3652
- return inputTokens / 1e3 * model.inputCostPer1kTokens + outputTokens / 1e3 * model.outputCostPer1kTokens;
3653
- }
3611
+ init_cost();
3654
3612
 
3655
3613
  // src/utils/retry.ts
3656
3614
  var CascadeCancelledError = class extends Error {
@@ -3768,6 +3726,7 @@ var ModelProfiler = class {
3768
3726
  };
3769
3727
 
3770
3728
  // src/core/router/savings.ts
3729
+ init_cost();
3771
3730
  var NO_SAVINGS = { savedUsd: 0, savedPct: 0, counterfactualUsd: 0 };
3772
3731
  function computeDelegationSavings(stats, t1Model) {
3773
3732
  if (!t1Model) return NO_SAVINGS;
@@ -5221,8 +5180,9 @@ var T3Worker = class extends BaseTier {
5221
5180
  const depOutputs = [];
5222
5181
  for (const depId of assignment.dependsOn) {
5223
5182
  try {
5224
- const dep = await this.peerBus.waitFor(depId);
5183
+ const dep = await this.peerBus.waitFor(depId, 6e4);
5225
5184
  if (dep.status === "FAILED" || dep.status === "ESCALATED") {
5185
+ this.peerBus.publish(this.id, assignment.subtaskId, `Blocked by failed dependency: ${depId}`, "FAILED");
5226
5186
  return this.buildResult(
5227
5187
  "ESCALATED",
5228
5188
  `Dependency ${depId} failed \u2014 cannot proceed`,
@@ -5234,6 +5194,7 @@ var T3Worker = class extends BaseTier {
5234
5194
  depOutputs.push(`[From ${dep.fromId} - ${dep.subtaskId}]:
5235
5195
  ${dep.output}`);
5236
5196
  } catch (err) {
5197
+ this.peerBus.publish(this.id, assignment.subtaskId, `Dependency timeout: ${depId}`, "FAILED");
5237
5198
  return this.buildResult(
5238
5199
  "ESCALATED",
5239
5200
  `Dependency timeout: ${depId}`,
@@ -6935,6 +6896,16 @@ function parseFirstJsonObject(input) {
6935
6896
  }
6936
6897
 
6937
6898
  // src/core/tiers/t1-administrator.ts
6899
+ function sharedKeywords(a = [], b = []) {
6900
+ const setB = new Set(b.map((k) => k.toLowerCase().trim()).filter(Boolean));
6901
+ return [...new Set(a.map((k) => k.toLowerCase().trim()).filter(Boolean))].filter((k) => setB.has(k));
6902
+ }
6903
+ function isStrongKeywordOverlap(a = [], b = []) {
6904
+ if (!a.length || !b.length) return false;
6905
+ const shared = sharedKeywords(a, b);
6906
+ const ratio = shared.length / Math.min(a.length, b.length);
6907
+ return shared.length >= 3 && ratio >= 0.6;
6908
+ }
6938
6909
  var T1_SYSTEM_PROMPT = `You are T1, the Administrator in the Cascade AI orchestration system.
6939
6910
 
6940
6911
  Your responsibilities:
@@ -7359,17 +7330,27 @@ Leave dependsOn empty for sections that can run immediately in parallel.`;
7359
7330
  siblingKeywords.set(payload.sectionId, [...new Set(existing)]);
7360
7331
  }
7361
7332
  }
7362
- const overlapSections = /* @__PURE__ */ new Set();
7363
- for (let i = 0; i < announcements.length; i++) {
7364
- for (let j = i + 1; j < announcements.length; j++) {
7365
- const a = announcements[i].payload;
7366
- const b = announcements[j].payload;
7367
- if (!a.keywords || !b.keywords || !a.sectionId || !b.sectionId) continue;
7368
- const shared = a.keywords.filter((k) => b.keywords.includes(k));
7369
- if (shared.length > 0) {
7370
- overlapSections.add(a.sectionId);
7371
- overlapSections.add(b.sectionId);
7372
- this.log(`T2 overlap detected between sections: ${a.sectionId} \u2194 ${b.sectionId} (shared: ${shared.join(", ")})`);
7333
+ const payloads = announcements.map((ann) => ann.payload).filter((p) => p?.type === "T2_PLAN_ANNOUNCEMENT" && !!p.sectionId);
7334
+ const softOverlap = /* @__PURE__ */ new Set();
7335
+ const orderOf = new Map(sections.map((s, i) => [s.sectionId, i]));
7336
+ for (let i = 0; i < payloads.length; i++) {
7337
+ for (let j = i + 1; j < payloads.length; j++) {
7338
+ const a = payloads[i];
7339
+ const b = payloads[j];
7340
+ const shared = sharedKeywords(a.keywords ?? [], b.keywords ?? []);
7341
+ if (shared.length === 0) continue;
7342
+ softOverlap.add(a.sectionId);
7343
+ softOverlap.add(b.sectionId);
7344
+ if (isStrongKeywordOverlap(a.keywords ?? [], b.keywords ?? [])) {
7345
+ const ai = orderOf.get(a.sectionId) ?? 0;
7346
+ const bi = orderOf.get(b.sectionId) ?? 0;
7347
+ const earlier = ai <= bi ? a.sectionId : b.sectionId;
7348
+ const later = ai <= bi ? b.sectionId : a.sectionId;
7349
+ const laterSection = sections.find((s) => s.sectionId === later);
7350
+ if (laterSection && earlier !== later && !(laterSection.dependsOn ?? []).includes(earlier)) {
7351
+ laterSection.dependsOn = [...laterSection.dependsOn || [], earlier];
7352
+ this.log(`Strong overlap ${earlier} \u2194 ${later} (shared: ${shared.slice(0, 5).join(", ")}) \u2014 serializing ${later} after ${earlier}`);
7353
+ }
7373
7354
  }
7374
7355
  }
7375
7356
  }
@@ -7381,20 +7362,10 @@ Leave dependsOn empty for sections that can run immediately in parallel.`;
7381
7362
  `You are T2 Manager for section: "${section.sectionTitle}".`,
7382
7363
  `Sibling sections being worked on in parallel: ${otherTitles.join(", ") || "none"}.`,
7383
7364
  myKeywords.length > 0 ? `Watch for overlap with: ${[...new Set(myKeywords)].slice(0, 10).join(", ")}.` : "",
7384
- overlapSections.has(section.sectionId) ? "NOTE: Potential overlap detected with a sibling section \u2014 be careful not to duplicate work." : ""
7365
+ softOverlap.has(section.sectionId) ? "NOTE: Potential overlap detected with a sibling section \u2014 be careful not to duplicate work." : ""
7385
7366
  ].filter(Boolean).join(" ");
7386
7367
  m.setHierarchyContext(context);
7387
7368
  });
7388
- if (overlapSections.size > 0) {
7389
- this.log("Overlap detected \u2014 adding sequential dependencies for conflicting sections to prevent race conditions");
7390
- const overlapArray = Array.from(overlapSections);
7391
- for (let i = 1; i < overlapArray.length; i++) {
7392
- const section = sections.find((s) => s.sectionId === overlapArray[i]);
7393
- if (section) {
7394
- section.dependsOn = [...section.dependsOn || [], overlapArray[i - 1]];
7395
- }
7396
- }
7397
- }
7398
7369
  const t2Results = [];
7399
7370
  try {
7400
7371
  t2Results.push(...await this.runT2sWithDependencies(sections, managers, this.taskId));
@@ -7589,6 +7560,9 @@ Reply with exactly one word: YES, NO, or UNSURE.
7589
7560
  }
7590
7561
  };
7591
7562
 
7563
+ // src/core/cascade.ts
7564
+ init_cost();
7565
+
7592
7566
  // src/tools/registry.ts
7593
7567
  init_constants();
7594
7568
 
@@ -14348,7 +14322,7 @@ async function doctorCommand() {
14348
14322
  });
14349
14323
  let keystoreBackend = "file (AES-256-GCM)";
14350
14324
  try {
14351
- await Promise.resolve().then(() => __toESM(require_keytar2(), 1));
14325
+ await import('keytar');
14352
14326
  keystoreBackend = "keytar (OS keychain)";
14353
14327
  } catch {
14354
14328
  }