cascade-ai 0.12.15 → 0.12.16

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
@@ -103,7 +103,7 @@ var __export = (target, all) => {
103
103
  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;
104
104
  var init_constants = __esm({
105
105
  "src/constants.ts"() {
106
- CASCADE_VERSION = "0.12.15";
106
+ CASCADE_VERSION = "0.12.16";
107
107
  CASCADE_CONFIG_FILE = ".cascade/config.json";
108
108
  CASCADE_DB_FILE = ".cascade/memory.db";
109
109
  CASCADE_DASHBOARD_SECRET_FILE = ".cascade/dashboard-secret";
@@ -1459,29 +1459,52 @@ var init_openai_compatible = __esm({
1459
1459
  baseURL: preferIpv4Host(config.baseUrl)
1460
1460
  });
1461
1461
  }
1462
+ modelsUrl() {
1463
+ const base = (preferIpv4Host(this.config.baseUrl) ?? "").replace(/\/+$/, "");
1464
+ return base + "/models";
1465
+ }
1466
+ authHeaders() {
1467
+ const h = { Accept: "application/json" };
1468
+ if (this.config.apiKey) h["Authorization"] = `Bearer ${this.config.apiKey}`;
1469
+ return h;
1470
+ }
1471
+ // Discover models with a tolerant direct GET instead of the OpenAI SDK's typed
1472
+ // `models.list()`. Local servers (llama.cpp / LM Studio / vLLM) return
1473
+ // non-standard `/v1/models` payloads — an extra `models` array, filesystem
1474
+ // path ids (`C:\…\model.gguf`) — that can make the SDK's typed pagination
1475
+ // throw, which previously surfaced as a misleading "endpoint unreachable".
1476
+ // A plain fetch + lenient parse is robust and reports the real HTTP error.
1462
1477
  async listModels() {
1463
- try {
1464
- const response = await this.client.models.list();
1465
- return response.data.map((m) => ({
1466
- id: m.id,
1467
- name: m.id,
1468
- provider: "openai-compatible",
1469
- contextWindow: 32e3,
1470
- isVisionCapable: false,
1471
- inputCostPer1kTokens: 0,
1472
- outputCostPer1kTokens: 0,
1473
- maxOutputTokens: 4e3,
1474
- supportsStreaming: true,
1475
- isLocal: false
1476
- }));
1477
- } catch {
1478
- return [this.model];
1479
- }
1478
+ const res = await fetch(this.modelsUrl(), { headers: this.authHeaders() });
1479
+ if (!res.ok) throw new Error(`models endpoint ${this.modelsUrl()} returned HTTP ${res.status}`);
1480
+ const body = await res.json();
1481
+ const raw = Array.isArray(body?.data) ? body.data : Array.isArray(body?.models) ? body.models : [];
1482
+ const ids = raw.map((m) => {
1483
+ if (m && typeof m === "object") {
1484
+ const o = m;
1485
+ const v = o["id"] ?? o["name"] ?? o["model"];
1486
+ return typeof v === "string" ? v : void 0;
1487
+ }
1488
+ return typeof m === "string" ? m : void 0;
1489
+ }).filter((x) => typeof x === "string" && x.length > 0);
1490
+ if (ids.length === 0) return [this.model];
1491
+ return ids.map((id) => ({
1492
+ id,
1493
+ name: id,
1494
+ provider: "openai-compatible",
1495
+ contextWindow: 32e3,
1496
+ isVisionCapable: false,
1497
+ inputCostPer1kTokens: 0,
1498
+ outputCostPer1kTokens: 0,
1499
+ maxOutputTokens: 4e3,
1500
+ supportsStreaming: true,
1501
+ isLocal: false
1502
+ }));
1480
1503
  }
1481
1504
  async isAvailable() {
1482
1505
  try {
1483
- await this.client.models.list();
1484
- return true;
1506
+ const res = await fetch(this.modelsUrl(), { headers: this.authHeaders() });
1507
+ return res.ok;
1485
1508
  } catch {
1486
1509
  return false;
1487
1510
  }
@@ -4572,7 +4595,8 @@ var CascadeRouter = class _CascadeRouter extends EventEmitter__default.default {
4572
4595
  for (const m of models) {
4573
4596
  this.selector.addDynamicModel(m);
4574
4597
  }
4575
- } catch {
4598
+ } catch (err) {
4599
+ console.warn("[router] OpenAI-compatible model discovery failed:", err instanceof Error ? err.message : err);
4576
4600
  }
4577
4601
  }
4578
4602
  ensureProvider(model, configs) {