cascade-ai 0.54.0 → 0.56.0

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.js CHANGED
@@ -1851,7 +1851,7 @@ function reconcilePrice(model, live) {
1851
1851
  }
1852
1852
 
1853
1853
  // src/constants.ts
1854
- var CASCADE_VERSION = "0.54.0";
1854
+ var CASCADE_VERSION = "0.56.0";
1855
1855
  var CASCADE_CONFIG_DIR = ".cascade";
1856
1856
  var CASCADE_MD_FILE = "CASCADE.md";
1857
1857
  var CASCADE_IGNORE_FILE = ".cascadeignore";
@@ -4789,6 +4789,23 @@ var CascadeRouter = class _CascadeRouter extends EventEmitter {
4789
4789
  */
4790
4790
  budgetState = "ok";
4791
4791
  budgetExceededReason;
4792
+ /**
4793
+ * Whether the run/session budget is permanently tripped, and why.
4794
+ *
4795
+ * A tier or worker that catches `BudgetExceededError` internally (T3Worker
4796
+ * does, so one dead-end subtask doesn't crash the whole run) absorbs the
4797
+ * exception into a normal FAILED/PARTIAL result — the tier returns as if
4798
+ * nothing unusual happened. That silently skips `Cascade.run()`'s dedicated
4799
+ * budget-exceeded handling (the `run:budget-exceeded` event and
4800
+ * `lastInterruptedRun` for `/continue`). This lets a caller check the
4801
+ * router's own state directly after a tier returns, regardless of how that
4802
+ * tier chose to report the error internally.
4803
+ */
4804
+ budgetExceededInfo() {
4805
+ if (this.runBudgetExceeded) return { reason: this.runBudgetExceededReason ?? "Per-task budget exceeded." };
4806
+ if (this.budgetState === "exceeded") return { reason: this.budgetExceededReason ?? "Session budget exceeded." };
4807
+ return null;
4808
+ }
4792
4809
  tpmLimiter;
4793
4810
  localQueue;
4794
4811
  taskAnalyzer;
@@ -6446,6 +6463,13 @@ Now execute your subtask using this context where relevant.`
6446
6463
  this.peerBus?.publish(this.id, assignment.subtaskId, finalOutput2, "FAILED");
6447
6464
  return this.buildResult("ESCALATED", finalOutput2, { checksRun, passed, failed }, issues, correctionAttempts);
6448
6465
  }
6466
+ if (err instanceof Error && err.name === "BudgetExceededError") {
6467
+ issues.push(errMsg);
6468
+ const stopped = output || errMsg;
6469
+ this.setStatus("FAILED", stopped);
6470
+ this.peerBus?.publish(this.id, assignment.subtaskId, stopped, "FAILED");
6471
+ return this.buildResult("FAILED", stopped, { checksRun, passed, failed }, issues, correctionAttempts);
6472
+ }
6449
6473
  issues.push(`Execution error: ${errMsg}`);
6450
6474
  const finalOutput = output || errMsg;
6451
6475
  this.setStatus("FAILED", finalOutput);
@@ -7467,6 +7491,26 @@ var RedactionLayer = class {
7467
7491
  }
7468
7492
  };
7469
7493
 
7494
+ // src/core/tiers/escalation-policy.ts
7495
+ function sectionNeedsDecision(results) {
7496
+ return results.some((r) => r.status === "ESCALATED");
7497
+ }
7498
+ function settledEscalationStatus(results) {
7499
+ const hasWork = results.some((r) => r.status === "COMPLETED" || !!r.output);
7500
+ return hasWork ? "PARTIAL" : "FAILED";
7501
+ }
7502
+ function composeRootSectionOutput(t2Result, completedOutputs) {
7503
+ let output = `${t2Result.sectionSummary}
7504
+
7505
+ ${completedOutputs.join("\n\n")}`;
7506
+ if (t2Result.status === "FAILED" && t2Result.issues?.length) {
7507
+ output += `
7508
+
7509
+ _(incomplete: ${t2Result.issues.join("; ")})_`;
7510
+ }
7511
+ return output;
7512
+ }
7513
+
7470
7514
  // src/core/tiers/t2-manager.ts
7471
7515
  function buildT2SystemPrompt(hasPeerMessage) {
7472
7516
  return [
@@ -7492,6 +7536,19 @@ var T2Manager = class extends BaseTier {
7492
7536
  t2PeerBus;
7493
7537
  permissionEscalator;
7494
7538
  toolCreator;
7539
+ /**
7540
+ * Asked when a section ends ESCALATED — i.e. a worker hit something it could
7541
+ * not decide alone. Without this the escalation was a dead end: the status
7542
+ * said "needs a decision" and no decision was ever requested, so an MCP run
7543
+ * that legitimately needed input just stopped there.
7544
+ */
7545
+ escalationCallback;
7546
+ /**
7547
+ * The one allowed retry has been spent. Retrying is bounded because an
7548
+ * escalation loop that can re-ask forever burns a budget on a question that
7549
+ * is not resolving; a second escalation is terminal instead.
7550
+ */
7551
+ escalationRetryUsed = false;
7495
7552
  /** Optional boardroom gate (Moderate / root-T2 runs) — pauses after decomposition. */
7496
7553
  planApprovalCallback;
7497
7554
  /** AbortController for the current T3 wave — aborted on cancel-and-respawn */
@@ -7540,6 +7597,10 @@ var T2Manager = class extends BaseTier {
7540
7597
  setToolCreator(creator) {
7541
7598
  this.toolCreator = creator;
7542
7599
  }
7600
+ /** Ask the user what to do when a section escalates. */
7601
+ setEscalationCallback(cb) {
7602
+ this.escalationCallback = cb;
7603
+ }
7543
7604
  /** Boardroom gate for Moderate (root-T2) runs: pause after decomposition. */
7544
7605
  setPlanApprovalCallback(cb) {
7545
7606
  this.planApprovalCallback = cb;
@@ -7644,9 +7705,57 @@ Guidance (must be followed): ${decision.note}`
7644
7705
  currentAction: "Aggregating T3 results",
7645
7706
  status: "IN_PROGRESS"
7646
7707
  });
7647
- const summary = await this.aggregateResults(assignment, t3Results);
7708
+ let summary = await this.aggregateResults(assignment, t3Results);
7648
7709
  const issues = t3Results.filter((r) => r.status !== "COMPLETED").flatMap((r) => r.issues);
7649
- const overallStatus = this.determineStatus(t3Results);
7710
+ let overallStatus = this.determineStatus(t3Results);
7711
+ let userSkipped = false;
7712
+ const hasEscalated = sectionNeedsDecision(t3Results);
7713
+ const settleEscalated = async (reason) => {
7714
+ if (reason) issues.push(reason);
7715
+ summary = await this.aggregateResults(assignment, t3Results, { includeEscalated: true });
7716
+ overallStatus = settledEscalationStatus(t3Results);
7717
+ };
7718
+ if (hasEscalated && this.escalationCallback && this.escalationRetryUsed) {
7719
+ await settleEscalated("Escalated again after the retry \u2014 no further attempts were made.");
7720
+ } else if (hasEscalated && !this.escalationCallback) {
7721
+ await settleEscalated();
7722
+ } else if (hasEscalated && this.escalationCallback) {
7723
+ this.sendStatusUpdate({
7724
+ progressPct: 95,
7725
+ currentAction: "Escalated \u2014 waiting for your decision",
7726
+ status: "ESCALATING"
7727
+ });
7728
+ const decision = await this.escalationCallback({
7729
+ sectionId: assignment.sectionId,
7730
+ sectionTitle: assignment.sectionTitle,
7731
+ issues,
7732
+ summary
7733
+ });
7734
+ this.log(`Escalation decision for "${assignment.sectionTitle}": ${decision.action}`);
7735
+ if (decision.action === "skip") {
7736
+ summary = await this.aggregateResults(assignment, t3Results, { includeEscalated: true });
7737
+ overallStatus = settledEscalationStatus(t3Results);
7738
+ userSkipped = decision.automatic !== true;
7739
+ } else if (decision.action === "retry" || decision.action === "guidance") {
7740
+ this.escalationRetryUsed = true;
7741
+ const guided = decision.action === "guidance" && decision.note?.trim() ? {
7742
+ ...assignment,
7743
+ description: `${assignment.description}
7744
+
7745
+ Guidance (must be followed): ${decision.note.trim()}`,
7746
+ // Drop T1's preplanned subtasks so the retry re-decomposes with
7747
+ // the guidance in hand. The workers execute from their subtask
7748
+ // slices, not from this description — leaving the slices in
7749
+ // place gave "Retry with guidance" byte-identical worker
7750
+ // prompts to "Retry as-is", making the note do nothing at all.
7751
+ t3Subtasks: []
7752
+ } : assignment;
7753
+ return await this.execute(guided, taskId, signal);
7754
+ } else {
7755
+ issues.push("Escalated, but no decision was received in time.");
7756
+ overallStatus = "FAILED";
7757
+ }
7758
+ }
7650
7759
  const isOk = overallStatus === "COMPLETED" || overallStatus === "PARTIAL";
7651
7760
  this.setStatus(isOk ? "COMPLETED" : "FAILED", summary);
7652
7761
  const sectionAction = overallStatus === "COMPLETED" ? "Section complete" : overallStatus === "PARTIAL" ? "Section partially complete \u2014 some subtasks failed" : overallStatus === "ESCALATED" ? "Section escalated \u2014 needs a decision" : "Section failed \u2014 no subtask completed";
@@ -7657,7 +7766,8 @@ Guidance (must be followed): ${decision.note}`
7657
7766
  status: overallStatus,
7658
7767
  t3Results,
7659
7768
  sectionSummary: summary,
7660
- issues
7769
+ issues,
7770
+ ...userSkipped ? { userSkipped: true } : {}
7661
7771
  };
7662
7772
  this.publishSectionOutput(result);
7663
7773
  return result;
@@ -7716,7 +7826,7 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : ""),
7716
7826
  const jsonMatch = /\[[\s\S]*\]/.exec(result.content);
7717
7827
  if (!jsonMatch) throw new Error("No JSON array found");
7718
7828
  const parsed = JSON.parse(jsonMatch[0]);
7719
- return parsed.map((a) => ({ ...a, sectionTitle: assignment.sectionTitle }));
7829
+ return parsed.map((a) => ({ ...a, sectionTitle: assignment.sectionTitle, constraints: a.constraints ?? [] }));
7720
7830
  } catch {
7721
7831
  return [{
7722
7832
  subtaskId: randomUUID(),
@@ -8091,8 +8201,10 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : ""),
8091
8201
  result.status === "COMPLETED" ? "COMPLETED" : "FAILED"
8092
8202
  );
8093
8203
  }
8094
- async aggregateResults(assignment, results) {
8095
- const completed = results.filter((r) => r.status === "COMPLETED");
8204
+ async aggregateResults(assignment, results, opts = {}) {
8205
+ const completed = results.filter(
8206
+ (r) => r.status === "COMPLETED" || opts.includeEscalated && r.status === "ESCALATED" && r.output
8207
+ );
8096
8208
  if (!completed.length) return `Section ${assignment.sectionTitle} failed \u2014 no T3 workers completed.`;
8097
8209
  const peerOutputs = this.peerSyncBuffer.filter((p) => p.content?.type === "T2_SECTION_OUTPUT").map((p) => `[Peer ${p.fromId} Output]: ${p.content.output}`).join("\n\n");
8098
8210
  const peerContext = peerOutputs ? `
@@ -8298,6 +8410,7 @@ var T1Administrator = class extends BaseTier {
8298
8410
  escalations = [];
8299
8411
  store;
8300
8412
  runBreaker;
8413
+ escalationCallback;
8301
8414
  t2PeerBus = new PeerBus();
8302
8415
  permissionEscalator;
8303
8416
  toolCreator;
@@ -8312,6 +8425,10 @@ var T1Administrator = class extends BaseTier {
8312
8425
  this.toolRegistry = toolRegistry;
8313
8426
  this.config = config;
8314
8427
  }
8428
+ /** Ask the user what to do when any section escalates. */
8429
+ setEscalationCallback(cb) {
8430
+ this.escalationCallback = cb;
8431
+ }
8315
8432
  /** Share the run-wide circuit breaker with every section manager. */
8316
8433
  setRunBreaker(breaker) {
8317
8434
  this.runBreaker = breaker;
@@ -8471,8 +8588,11 @@ Create a CORRECTION PLAN that contains only the new sections needed to fix the i
8471
8588
  reason: `Some T2 managers failed entirely: ${failedSections.map((s) => s.sectionTitle).join(", ")}. Errors: ${failedSections.flatMap((s) => s.issues).join("; ")}`
8472
8589
  };
8473
8590
  }
8474
- const sectionsText = t2Results.map((r) => `**${r.sectionTitle}**
8475
- ${r.sectionSummary}`).join("\n\n");
8591
+ const sectionsText = t2Results.map((r) => {
8592
+ const skipNote = r.userSkipped ? "\n[The user was asked to retry or skip this section and explicitly chose to SKIP it. This is an intentional decision, not a failure \u2014 do not cite it as a reason to reject.]" : "";
8593
+ return `**${r.sectionTitle}**
8594
+ ${r.sectionSummary}${skipNote}`;
8595
+ }).join("\n\n");
8476
8596
  const prompt = `You are a strict QA Reviewer for the Cascade AI system.
8477
8597
  Review the following execution outputs against the original user prompt.
8478
8598
 
@@ -8482,6 +8602,7 @@ T2 Manager Summaries:
8482
8602
  ${sectionsText}
8483
8603
 
8484
8604
  Does the current state of the workspace and the outputs fully satisfy the user's request?
8605
+ A section marked as user-skipped above is accepted as-is by the user's own choice \u2014 treat it as satisfied, not as a gap.
8485
8606
  If yes, reply with exactly: "APPROVED".
8486
8607
  If no, reply with "REJECTED: [Detailed reason explaining exactly what is missing or incorrect]".`;
8487
8608
  try {
@@ -8663,6 +8784,12 @@ SPEC RULES \u2014 each subtask is a self-contained spec slice (workers execute f
8663
8784
  if (!plan.sections || !Array.isArray(plan.sections) || plan.sections.length === 0) {
8664
8785
  throw new Error("Invalid plan: no sections");
8665
8786
  }
8787
+ for (const section of plan.sections) {
8788
+ section.constraints ??= [];
8789
+ for (const subtask of section.t3Subtasks ?? []) {
8790
+ subtask.constraints ??= [];
8791
+ }
8792
+ }
8666
8793
  const [min, max] = COMPLEXITY_T2_COUNT[plan.complexity] ?? [1, 8];
8667
8794
  if (plan.sections.length < min) ;
8668
8795
  }
@@ -8679,6 +8806,7 @@ SPEC RULES \u2014 each subtask is a self-contained spec slice (workers execute f
8679
8806
  const managers = sections.map((section) => {
8680
8807
  const manager = new T2Manager(this.router, this.toolRegistry, this.id);
8681
8808
  if (this.runBreaker) manager.setRunBreaker(this.runBreaker);
8809
+ if (this.escalationCallback) manager.setEscalationCallback(this.escalationCallback);
8682
8810
  manager.setHierarchyContext(`You are a T2 Manager for the section "${section.sectionTitle}". You are part of a COMPLEX task overseen by T1 Administrator.`);
8683
8811
  if (this.store) {
8684
8812
  manager.setStore(this.store);
@@ -8888,7 +9016,10 @@ SPEC RULES \u2014 each subtask is a self-contained spec slice (workers execute f
8888
9016
  async compileFinalOutput(originalPrompt, plan, t2Results) {
8889
9017
  const completedSections = t2Results.filter((r) => r.status !== "FAILED");
8890
9018
  if (!completedSections.length) {
8891
- const allIssues = t2Results.flatMap((r) => r.t3Results.flatMap((t) => t.issues));
9019
+ const allIssues = [
9020
+ ...t2Results.flatMap((r) => r.issues ?? []),
9021
+ ...t2Results.flatMap((r) => r.t3Results.flatMap((t) => t.issues))
9022
+ ].filter(Boolean);
8892
9023
  const critical = allIssues.find((i) => i.includes("[CRITICAL_TOOL_ERROR]"));
8893
9024
  const stalled = allIssues.find((i) => /^Stalled:/.test(i));
8894
9025
  const topReason = critical ?? stalled ?? allIssues[0] ?? "no specific reason recorded";
@@ -9697,6 +9828,102 @@ var RunBreaker = class {
9697
9828
  return out;
9698
9829
  }
9699
9830
  };
9831
+ var MCP_TOOL_PREFIX = "mcp__";
9832
+ var MAX_SEGMENT_LENGTH = 24;
9833
+ var SEGMENT_HASH_LENGTH = 8;
9834
+ function boundedSegment(raw) {
9835
+ const clean = sanitizeToolNameSegment(raw);
9836
+ if (clean.length <= MAX_SEGMENT_LENGTH) return clean;
9837
+ const hash = createHash("sha256").update(raw, "utf8").digest("hex").slice(0, SEGMENT_HASH_LENGTH);
9838
+ return `${clean.slice(0, MAX_SEGMENT_LENGTH - SEGMENT_HASH_LENGTH - 1)}_${hash}`;
9839
+ }
9840
+ function isStableSegment(raw) {
9841
+ return sanitizeToolNameSegment(raw) === raw && raw.length <= MAX_SEGMENT_LENGTH;
9842
+ }
9843
+ function sanitizeToolNameSegment(segment) {
9844
+ const cleaned = segment.replace(/[^a-zA-Z0-9-]+/g, "_");
9845
+ let start = 0;
9846
+ let end = cleaned.length;
9847
+ while (start < end && cleaned[start] === "_") start++;
9848
+ while (end > start && cleaned[end - 1] === "_") end--;
9849
+ return cleaned.slice(start, end) || "_";
9850
+ }
9851
+ function mcpToolName(serverName, toolName) {
9852
+ return `${MCP_TOOL_PREFIX}${boundedSegment(serverName)}__${boundedSegment(toolName)}`;
9853
+ }
9854
+ function isMcpToolName(name) {
9855
+ return name.startsWith(MCP_TOOL_PREFIX);
9856
+ }
9857
+ function uniqueMcpServerName(desired, existingNames) {
9858
+ const taken = new Set(existingNames.map(mcpServerPrefix));
9859
+ if (!taken.has(mcpServerPrefix(desired))) return desired;
9860
+ for (let n = 2; n < 1e3; n++) {
9861
+ const candidate = `${desired} (${n})`;
9862
+ if (!taken.has(mcpServerPrefix(candidate))) return candidate;
9863
+ }
9864
+ return `${desired} (${randomUUID().slice(0, 8)})`;
9865
+ }
9866
+ function disambiguateMcpServerNames(servers) {
9867
+ const seenNames = [];
9868
+ const renames = [];
9869
+ const result = servers.map((s) => {
9870
+ const name = uniqueMcpServerName(s.name, seenNames);
9871
+ seenNames.push(name);
9872
+ if (name === s.name) return s;
9873
+ renames.push({ from: s.name, to: name });
9874
+ return { ...s, name };
9875
+ });
9876
+ return { servers: renames.length ? result : servers, renames };
9877
+ }
9878
+ function assignMcpToolNames(tools) {
9879
+ const names = new Array(tools.length);
9880
+ const bases = tools.map((t) => mcpToolName(t.server, t.tool));
9881
+ const groups = /* @__PURE__ */ new Map();
9882
+ bases.forEach((base, i) => {
9883
+ const g = groups.get(base);
9884
+ if (g) g.push(i);
9885
+ else groups.set(base, [i]);
9886
+ });
9887
+ const used = new Set(bases);
9888
+ for (const [base, idx] of groups) {
9889
+ if (idx.length === 1) {
9890
+ names[idx[0]] = base;
9891
+ continue;
9892
+ }
9893
+ const raw = (i) => `${tools[i].server}::${tools[i].tool}`;
9894
+ const isClean = (i) => isStableSegment(tools[i].server) && isStableSegment(tools[i].tool);
9895
+ const ordered = [...idx].sort((a, b) => {
9896
+ const la = isClean(a) ? 0 : 1;
9897
+ const lb = isClean(b) ? 0 : 1;
9898
+ if (la !== lb) return la - lb;
9899
+ const ra = raw(a);
9900
+ const rb = raw(b);
9901
+ return ra < rb ? -1 : ra > rb ? 1 : 0;
9902
+ });
9903
+ names[ordered[0]] = base;
9904
+ let n = 2;
9905
+ for (let rank3 = 1; rank3 < ordered.length; rank3++) {
9906
+ let candidate = `${base}_${n}`;
9907
+ while (used.has(candidate)) {
9908
+ n++;
9909
+ candidate = `${base}_${n}`;
9910
+ }
9911
+ names[ordered[rank3]] = candidate;
9912
+ used.add(candidate);
9913
+ n++;
9914
+ }
9915
+ }
9916
+ return names;
9917
+ }
9918
+ function mcpServerPrefix(serverName) {
9919
+ return `${MCP_TOOL_PREFIX}${boundedSegment(serverName)}__`;
9920
+ }
9921
+ function removeMcpServerDenials(disabledTools, serverName) {
9922
+ if (!disabledTools?.length) return disabledTools;
9923
+ const prefix = mcpServerPrefix(serverName);
9924
+ const kept = disabledTools.filter((t) => !t.startsWith(prefix));
9925
+ return kept.length === disabledTools.length ? disabledTools : kept;
9926
+ }
9700
9927
  var execAsync = promisify(exec);
9701
9928
  var ShellTool = class extends BaseTool {
9702
9929
  name = "shell";
@@ -11112,20 +11339,6 @@ ${text}`;
11112
11339
  }
11113
11340
  };
11114
11341
 
11115
- // src/tools/tool-name.ts
11116
- var MCP_TOOL_PREFIX = "mcp__";
11117
- function sanitizeToolNameSegment(segment) {
11118
- const cleaned = segment.replace(/[^a-zA-Z0-9-]+/g, "_");
11119
- let start = 0;
11120
- let end = cleaned.length;
11121
- while (start < end && cleaned[start] === "_") start++;
11122
- while (end > start && cleaned[end - 1] === "_") end--;
11123
- return cleaned.slice(start, end) || "_";
11124
- }
11125
- function mcpToolName(serverName, toolName) {
11126
- return `${MCP_TOOL_PREFIX}${sanitizeToolNameSegment(serverName)}__${sanitizeToolNameSegment(toolName)}`;
11127
- }
11128
-
11129
11342
  // src/tools/mcp.ts
11130
11343
  var McpToolWrapper = class extends BaseTool {
11131
11344
  name;
@@ -11134,12 +11347,12 @@ var McpToolWrapper = class extends BaseTool {
11134
11347
  mcpClient;
11135
11348
  serverName;
11136
11349
  toolName;
11137
- constructor(mcpClient, serverName, toolName, description, inputSchema) {
11350
+ constructor(mcpClient, serverName, toolName, description, inputSchema, registeredName) {
11138
11351
  super();
11139
11352
  this.mcpClient = mcpClient;
11140
11353
  this.serverName = serverName;
11141
11354
  this.toolName = toolName;
11142
- this.name = mcpToolName(serverName, toolName);
11355
+ this.name = registeredName ?? mcpToolName(serverName, toolName);
11143
11356
  this.description = `[MCP:${serverName}] ${description}`;
11144
11357
  this.inputSchema = inputSchema;
11145
11358
  }
@@ -11210,22 +11423,35 @@ var ToolRegistry = class extends EventEmitter {
11210
11423
  getRegisteredPlugins() {
11211
11424
  return Array.from(this.plugins.keys());
11212
11425
  }
11213
- /** Registers all tools from an MCP client */
11214
- registerMcpTools(mcpClient) {
11215
- const definitions = mcpClient.getToolDefinitions();
11216
- for (const def of definitions) {
11217
- const [, serverName, toolName] = def.name.split("::");
11218
- if (!serverName || !toolName) continue;
11426
+ /**
11427
+ * Registers all tools from an MCP client.
11428
+ *
11429
+ * `isAllowed` receives the FINAL registered name (`mcp__server__tool`) — the
11430
+ * same string the user sees and the same one that reaches the provider — so
11431
+ * a per-tool opt-out in Settings can be expressed as a plain name list.
11432
+ * Filtering here rather than at call time means a deselected tool is genuinely
11433
+ * absent from the definitions handed to the model, so it is never proposed,
11434
+ * never counted against the tool budget, and never has to be refused.
11435
+ */
11436
+ registerMcpTools(mcpClient, isAllowed) {
11437
+ const parsed = mcpClient.getToolDefinitions().flatMap((def) => {
11438
+ const [, server, tool] = def.name.split("::");
11439
+ return server && tool ? [{ def, server, tool }] : [];
11440
+ });
11441
+ const names = assignMcpToolNames(parsed);
11442
+ parsed.forEach(({ def, server, tool }, i) => {
11219
11443
  const wrapper = new McpToolWrapper(
11220
11444
  mcpClient,
11221
- serverName,
11222
- toolName,
11223
- def.description.replace(`[MCP:${serverName}] `, ""),
11224
- def.inputSchema
11445
+ server,
11446
+ tool,
11447
+ def.description.replace(`[MCP:${server}] `, ""),
11448
+ def.inputSchema,
11449
+ names[i]
11225
11450
  );
11451
+ if (isAllowed && !isAllowed(wrapper.name)) return;
11226
11452
  wrapper.setWorkspaceRoot(this.workspaceRoot);
11227
11453
  this.register(wrapper);
11228
- }
11454
+ });
11229
11455
  }
11230
11456
  setIgnoredPaths(patterns) {
11231
11457
  this.ignoreMatcher = ignore().add(patterns);
@@ -11562,6 +11788,17 @@ function fileOAuthProvider(storePath) {
11562
11788
  }
11563
11789
  });
11564
11790
  }
11791
+ var oauthStoreLocks = /* @__PURE__ */ new Map();
11792
+ function withOAuthStoreLock(storePath, fn) {
11793
+ const prev = oauthStoreLocks.get(storePath) ?? Promise.resolve();
11794
+ const run = prev.then(fn, fn);
11795
+ const tail = run.then(() => void 0, () => void 0);
11796
+ oauthStoreLocks.set(storePath, tail);
11797
+ void tail.then(() => {
11798
+ if (oauthStoreLocks.get(storePath) === tail) oauthStoreLocks.delete(storePath);
11799
+ });
11800
+ return run;
11801
+ }
11565
11802
  function beginMcpOAuth(provider, serverUrl) {
11566
11803
  return auth(provider, { serverUrl });
11567
11804
  }
@@ -14500,7 +14737,50 @@ var GuidanceQueue = class {
14500
14737
  }
14501
14738
  };
14502
14739
 
14740
+ // src/tools/current-page.ts
14741
+ var MAX_PAGE_TEXT_CHARS = 4e4;
14742
+ var CurrentPageTool = class extends BaseTool {
14743
+ name = "read_current_page";
14744
+ description = 'Read the web page the user currently has open in the built-in browser \u2014 its URL, title, and visible text. Use this whenever the user refers to "this page", "what I am looking at", or asks about something on screen. Prefer it over web_fetch for the open page: it sees content behind a login and content rendered by JavaScript, which web_fetch cannot.';
14745
+ inputSchema = {
14746
+ type: "object",
14747
+ properties: {},
14748
+ required: []
14749
+ };
14750
+ provider;
14751
+ constructor(provider) {
14752
+ super();
14753
+ this.provider = provider;
14754
+ }
14755
+ // Reading what is already on the user's screen changes nothing and reaches
14756
+ // nothing they have not already opened themselves.
14757
+ isDangerous() {
14758
+ return false;
14759
+ }
14760
+ async execute(_input, _options) {
14761
+ let page2;
14762
+ try {
14763
+ page2 = await this.provider();
14764
+ } catch (err) {
14765
+ return `Error: could not read the open page \u2014 ${err instanceof Error ? err.message : String(err)}`;
14766
+ }
14767
+ if (!page2) {
14768
+ return "No page is open in the built-in browser. Ask the user to open one, or use web_fetch for a public URL.";
14769
+ }
14770
+ const text = page2.text.length > MAX_PAGE_TEXT_CHARS ? `${page2.text.slice(0, MAX_PAGE_TEXT_CHARS)}
14771
+
14772
+ [truncated \u2014 the page is longer than ${MAX_PAGE_TEXT_CHARS} characters]` : page2.text;
14773
+ return [
14774
+ `URL: ${page2.url}`,
14775
+ `Title: ${page2.title}`,
14776
+ "",
14777
+ text.trim() || "[the page rendered no readable text]"
14778
+ ].join("\n");
14779
+ }
14780
+ };
14781
+
14503
14782
  // src/core/cascade.ts
14783
+ var ESCALATION_DECISION_TIMEOUT_MS = 5 * 6e4;
14504
14784
  function buildContextualPrompt(prompt, history = []) {
14505
14785
  const recent = history.slice(-6);
14506
14786
  if (recent.length === 0) return prompt;
@@ -14723,6 +15003,94 @@ var Cascade = class _Cascade extends EventEmitter {
14723
15003
  });
14724
15004
  });
14725
15005
  }
15006
+ // ── Escalation decisions ────────────────────────────────────────────
15007
+ //
15008
+ // A section that ends ESCALATED used to be a dead end: the Cockpit showed
15009
+ // "Section escalated — needs a decision" and no decision was ever requested,
15010
+ // so the run stopped there having spent a full orchestration. This is the
15011
+ // same round-trip shape as plan approval, with one deliberate difference —
15012
+ // an unanswered escalation FAILS the section instead of proceeding.
15013
+ //
15014
+ // That direction is the safe one here. Plan approval defaults to "yes" on
15015
+ // timeout because the plan is already the model's considered proposal;
15016
+ // an escalation exists precisely BECAUSE the worker was not confident, so
15017
+ // acting unattended is the option most likely to be wrong. And in cloud a
15018
+ // waiting run holds server resources, so hanging is not free either.
15019
+ // Keyed by request id, NOT a single slot. A Complex run dispatches each wave
15020
+ // of ready sections with `Promise.all` (t1-administrator.ts), so two sections
15021
+ // can be waiting on a decision at the same moment. A single field made that
15022
+ // case fail hard rather than merely confusingly: the second escalation
15023
+ // overwrote the first's resolver, the user's answer resolved only the second,
15024
+ // and then the FIRST section's timer found the slot already empty and
15025
+ // returned without resolving anything — parking the run forever, past its own
15026
+ // timeout. Same class of bug as the twelve-failover dead-model race: a wave
15027
+ // is concurrent, so per-run singletons are never safe inside it.
15028
+ pendingEscalations = /* @__PURE__ */ new Map();
15029
+ async requestEscalationDecision(ctx, taskId, signal) {
15030
+ if (this.config.autonomy === "auto") return { action: "skip", automatic: true };
15031
+ if (this.listenerCount("escalation:decision-required") === 0) return { action: "skip", automatic: true };
15032
+ if (signal?.aborted) return { action: "skip", automatic: true };
15033
+ const requestId = randomUUID();
15034
+ return await new Promise((resolve2) => {
15035
+ let timeout;
15036
+ const settle = (decision) => {
15037
+ if (!this.pendingEscalations.delete(requestId)) return;
15038
+ if (timeout) clearTimeout(timeout);
15039
+ signal?.removeEventListener("abort", onAbort);
15040
+ resolve2(decision);
15041
+ };
15042
+ const onAbort = () => settle({ action: "skip", automatic: true });
15043
+ signal?.addEventListener("abort", onAbort, { once: true });
15044
+ timeout = setTimeout(() => {
15045
+ this.emit("escalation:timeout", { taskId, requestId, sectionId: ctx.sectionId });
15046
+ settle({ action: "timeout" });
15047
+ }, ESCALATION_DECISION_TIMEOUT_MS);
15048
+ this.pendingEscalations.set(requestId, settle);
15049
+ this.emit("escalation:decision-required", {
15050
+ taskId,
15051
+ requestId,
15052
+ sectionId: ctx.sectionId,
15053
+ sectionTitle: ctx.sectionTitle,
15054
+ issues: ctx.issues,
15055
+ summary: ctx.summary,
15056
+ timeoutMs: ESCALATION_DECISION_TIMEOUT_MS
15057
+ });
15058
+ });
15059
+ }
15060
+ /**
15061
+ * Resolve a pending escalation from a REPL / dashboard / cloud listener.
15062
+ *
15063
+ * `requestId` comes back from the `escalation:decision-required` event and is
15064
+ * what makes an answer land on the section that asked. It is optional so a
15065
+ * host with only one escalation in flight (and any caller that predates the
15066
+ * id) still works: without it the oldest outstanding request is answered,
15067
+ * which is correct whenever there is exactly one.
15068
+ *
15069
+ * `automatic` defaults to false — a call into this method is normally a real
15070
+ * person answering the prompt. Pass `true` from a host that is itself
15071
+ * settling the gate on nobody's behalf (a REST caller who never had a
15072
+ * chance to connect, a session halt with no per-section review behind it),
15073
+ * so T2 doesn't set `userSkipped` for a decision no one actually reviewed —
15074
+ * see EscalationDecision.automatic.
15075
+ */
15076
+ resolveEscalation(action, note, requestId, automatic) {
15077
+ const decision = { action, ...note ? { note } : {}, ...automatic ? { automatic: true } : {} };
15078
+ if (requestId) {
15079
+ this.pendingEscalations.get(requestId)?.(decision);
15080
+ return;
15081
+ }
15082
+ const oldest = this.pendingEscalations.keys().next();
15083
+ if (!oldest.done) this.pendingEscalations.get(oldest.value)?.(decision);
15084
+ }
15085
+ /**
15086
+ * Release every parked escalation — run teardown, so none outlive the run.
15087
+ * `automatic: true`: teardown resolving a section nobody answered is the
15088
+ * same system-decided case as the early-return skips above, not a person
15089
+ * reviewing and accepting that section's output.
15090
+ */
15091
+ releasePendingEscalations(action = "skip") {
15092
+ for (const settle of Array.from(this.pendingEscalations.values())) settle({ action, automatic: true });
15093
+ }
14726
15094
  /**
14727
15095
  * Resolve a pending boardroom plan approval from a REPL / dashboard listener.
14728
15096
  * An optional `note` re-plans and re-asks; an optional `editedPlan` is applied
@@ -14856,6 +15224,20 @@ ${input}` }],
14856
15224
  this.mediaSink = sink;
14857
15225
  this.registerMediaTools(this.workspacePath);
14858
15226
  }
15227
+ /**
15228
+ * Let the agent read the page the user has open in the host's browser.
15229
+ *
15230
+ * Host-supplied because only a host WITH a browser can answer it — so the
15231
+ * tool is simply absent in the CLI and in hosted runs, rather than present
15232
+ * and always failing. Registered outside `enabledTools` for the same reason
15233
+ * media tools are: that allowlist is a blast-radius control for tools that
15234
+ * touch the machine, and reading a page the user already opened touches
15235
+ * nothing. `disabledTools` still removes it.
15236
+ */
15237
+ setCurrentPageProvider(provider) {
15238
+ if ((this.config.tools?.disabledTools ?? []).includes("read_current_page")) return;
15239
+ this.toolRegistry.register(new CurrentPageTool(provider));
15240
+ }
14859
15241
  registerMediaTools(workspacePath) {
14860
15242
  const denied = new Set(this.config.tools?.disabledTools ?? []);
14861
15243
  const permitted = (name) => !denied.has(name);
@@ -14988,8 +15370,12 @@ ${last.partialOutput}` : "");
14988
15370
  for (const server of this.config.tools.mcpServers) {
14989
15371
  try {
14990
15372
  const authProvider = server.oauthStore ? fileOAuthProvider(server.oauthStore) : void 0;
14991
- await this.mcpClient.connect(server, authProvider ? { authProvider } : {});
14992
- this.toolRegistry.registerMcpTools(this.mcpClient);
15373
+ const connect = () => this.mcpClient.connect(server, authProvider ? { authProvider } : {});
15374
+ await (server.oauthStore ? withOAuthStoreLock(server.oauthStore, connect) : connect());
15375
+ this.toolRegistry.registerMcpTools(
15376
+ this.mcpClient,
15377
+ (name) => !(this.config.tools?.disabledTools ?? []).includes(name)
15378
+ );
14993
15379
  } catch (err) {
14994
15380
  console.error(`Failed to connect to MCP server "${server.name}":`, err);
14995
15381
  }
@@ -15454,6 +15840,7 @@ ${prompt}` : prompt;
15454
15840
  } else if (complexity === "Moderate") {
15455
15841
  const t2 = new T2Manager(this.router, this.toolRegistry, "root");
15456
15842
  t2.setRunBreaker(runBreaker);
15843
+ t2.setEscalationCallback((ctx) => this.requestEscalationDecision(ctx, taskId, options.signal));
15457
15844
  t2.setPresenter(true);
15458
15845
  t2.setHierarchyContext("You are the ROOT Manager for this task. There is no T1 Administrator involved in this run. You are responsible for decomposing the task and managing T3 workers directly.");
15459
15846
  if (identityPrompt) {
@@ -15498,11 +15885,17 @@ ${prompt}` : prompt;
15498
15885
  t2Results = [t2Result];
15499
15886
  const completed = t2Result.t3Results.filter((r) => r.status === "COMPLETED");
15500
15887
  if (completed.length > 0) {
15501
- finalOutput = t2Result.sectionSummary + "\n\n" + completed.map((r) => r.output).join("\n\n");
15888
+ finalOutput = composeRootSectionOutput(
15889
+ t2Result,
15890
+ completed.map((r) => typeof r.output === "string" ? r.output : JSON.stringify(r.output))
15891
+ );
15502
15892
  } else {
15503
15893
  const partial = t2Result.t3Results.map((r) => typeof r.output === "string" ? r.output : "").filter((o) => o.trim()).sort((a, b) => b.length - a.length)[0];
15504
15894
  const reasons = Array.from(
15505
- new Set(t2Result.t3Results.flatMap((r) => r.issues ?? []).filter(Boolean))
15895
+ new Set([
15896
+ ...t2Result.issues ?? [],
15897
+ ...t2Result.t3Results.flatMap((r) => r.issues ?? [])
15898
+ ].filter(Boolean))
15506
15899
  );
15507
15900
  if (partial) {
15508
15901
  finalOutput = reasons.length ? `${partial}
@@ -15515,6 +15908,7 @@ _(incomplete: ${reasons.join("; ")})_` : partial;
15515
15908
  } else {
15516
15909
  const t1 = new T1Administrator(this.router, this.toolRegistry, this.config);
15517
15910
  t1.setRunBreaker(runBreaker);
15911
+ t1.setEscalationCallback((ctx) => this.requestEscalationDecision(ctx, taskId, options.signal));
15518
15912
  t1.setPresenter(true);
15519
15913
  t1.setHierarchyContext("You are the top-level Administrator. You are responsible for the overall plan and supervising multiple T2 Managers.");
15520
15914
  if (identityPrompt) {
@@ -15539,6 +15933,8 @@ _(incomplete: ${reasons.join("; ")})_` : partial;
15539
15933
  finalOutput = result.output;
15540
15934
  t2Results = result.t2Results;
15541
15935
  }
15936
+ const budgetInfo = this.router.budgetExceededInfo();
15937
+ if (budgetInfo) throw new CascadeRouter.BudgetExceededError(budgetInfo.reason);
15542
15938
  const trip = runBreaker.reason();
15543
15939
  if (trip) {
15544
15940
  finalOutput = [
@@ -15579,6 +15975,10 @@ ${finalOutput}` : ""
15579
15975
  escalator.cancelAllPending();
15580
15976
  } catch {
15581
15977
  }
15978
+ try {
15979
+ this.releasePendingEscalations();
15980
+ } catch {
15981
+ }
15582
15982
  this.router.restoreTierModels();
15583
15983
  this.router.setRunSignal(void 0);
15584
15984
  if (this.taskAnalyzer) {
@@ -16895,6 +17295,13 @@ var ConfigManager = class {
16895
17295
  }
16896
17296
  async load() {
16897
17297
  this.config = await this.loadConfig();
17298
+ const servers = this.config.tools?.mcpServers;
17299
+ const { servers: disambiguated, renames } = servers?.length ? disambiguateMcpServerNames(servers) : { servers, renames: [] };
17300
+ const mcpNamesChanged = renames.length > 0;
17301
+ if (mcpNamesChanged && this.config.tools) {
17302
+ this.config.tools.mcpServers = disambiguated;
17303
+ this.renameMcpServerReferences(renames);
17304
+ }
16898
17305
  this.ignore = new CascadeIgnore();
16899
17306
  await this.ignore.load(this.workspacePath);
16900
17307
  this.cascadeMd = await loadCascadeMd(this.workspacePath);
@@ -16903,6 +17310,7 @@ var ConfigManager = class {
16903
17310
  await this.injectEnvKeys();
16904
17311
  this.config.providers = mergeGlobalCredentials(this.config.providers, loadGlobalCredentials(this.globalDir));
16905
17312
  await this.ensureDefaultIdentity();
17313
+ if (mcpNamesChanged) await this.save();
16906
17314
  }
16907
17315
  getConfig() {
16908
17316
  return this.config;
@@ -16986,6 +17394,66 @@ var ConfigManager = class {
16986
17394
  this.config.providers.push({ type: "ollama" });
16987
17395
  }
16988
17396
  }
17397
+ /**
17398
+ * Follow a disambiguation rename into `tools.mcpTrusted`.
17399
+ *
17400
+ * `mcpTrusted` is matched by EXACT name (`McpClient.connect()`). Two shapes
17401
+ * of rename reach here, and they need OPPOSITE treatment:
17402
+ *
17403
+ * - Distinct raw names that only collide via sanitizing (`foo bar` /
17404
+ * `foo@bar`): each had its OWN trust entry, and the old string now belongs
17405
+ * to nothing — the server that used it moved away, so the entry has to
17406
+ * move with it. A plain rewrite is correct here.
17407
+ * - Literally identical names (a hand-edited or duplicated config: two rows
17408
+ * both named `foo`): there is only ONE trust entry for both, since
17409
+ * `mcpTrusted` itself is deduplicated. `this.config.tools.mcpServers` has
17410
+ * already been updated to the disambiguated list by the time this runs
17411
+ * (see `load()`), so the untouched survivor is STILL named `foo` — a plain
17412
+ * rewrite would move the one entry entirely onto the renamed row and
17413
+ * leave the survivor untrusted. The entry must be kept for the survivor
17414
+ * AND granted to the renamed identity, not moved.
17415
+ *
17416
+ * Renames are grouped by `from` before either treatment is applied, and
17417
+ * each group is settled in one step. Two DIFFERENT rows can start out with
17418
+ * the exact same raw name and BOTH get renamed away (e.g. three servers
17419
+ * named `foo bar`, `foo@bar`, `foo@bar` — the two `foo@bar` rows collide
17420
+ * with `foo bar` and with each other, so both are renamed to distinct
17421
+ * identities while `foo bar` survives untouched). Processing renames one at
17422
+ * a time in that shape drops coverage: the first rename's REPLACE branch
17423
+ * would erase `from` from `trusted` entirely, so the guard on the second
17424
+ * rename with the same `from` sees it already gone and silently skips —
17425
+ * granting trust to only one of the two renamed identities. Grouping first
17426
+ * means every renamed identity that shares a `from` is added or substituted
17427
+ * together, in the one pass that still sees the original entry.
17428
+ *
17429
+ * `tools.disabledTools` deliberately gets no equivalent treatment. It's
17430
+ * matched by sanitized PREFIX, and a prefix collision is exactly what made
17431
+ * an existing entry ambiguous between the two servers in the first place —
17432
+ * there is no way to tell, from the stored string alone, which of the two
17433
+ * a denial was meant for. Leaving those entries untouched resolves that
17434
+ * ambiguity for free: the survivor keeps the original (now unique) prefix,
17435
+ * so an old entry keeps applying to it, while the renamed server starts
17436
+ * clean under its new prefix. Rewriting the entry to follow the rename
17437
+ * would do the opposite — move a denial that already worked for the
17438
+ * survivor onto a server it may never have meant to cover.
17439
+ */
17440
+ renameMcpServerReferences(renames) {
17441
+ const tools = this.config.tools;
17442
+ if (!tools?.mcpTrusted?.length || !renames.length) return;
17443
+ const currentNames = new Set((tools.mcpServers ?? []).map((s) => s.name));
17444
+ const byFrom = /* @__PURE__ */ new Map();
17445
+ for (const { from, to } of renames) {
17446
+ const tos = byFrom.get(from);
17447
+ if (tos) tos.push(to);
17448
+ else byFrom.set(from, [to]);
17449
+ }
17450
+ let trusted = tools.mcpTrusted;
17451
+ for (const [from, tos] of byFrom) {
17452
+ if (!trusted.includes(from)) continue;
17453
+ trusted = currentNames.has(from) ? [...trusted, ...tos] : [...trusted.filter((n) => n !== from), ...tos];
17454
+ }
17455
+ tools.mcpTrusted = Array.from(new Set(trusted));
17456
+ }
16989
17457
  async ensureDefaultIdentity() {
16990
17458
  const existing = this.store.getDefaultIdentity();
16991
17459
  if (existing) return;
@@ -17108,6 +17576,14 @@ var DashboardSocket = class {
17108
17576
  this.secret = options.secret;
17109
17577
  this.setupHandlers();
17110
17578
  }
17579
+ /** How many sockets are currently in a room — 0 means nobody can answer. */
17580
+ roomSize(room) {
17581
+ return this.io.sockets.adapter.rooms.get(room)?.size ?? 0;
17582
+ }
17583
+ /** Is this exact connection still live? A reconnect issues a NEW socket id. */
17584
+ hasSocket(socketId) {
17585
+ return this.io.sockets.sockets.has(socketId);
17586
+ }
17111
17587
  broadcastToRoom(room, event, data) {
17112
17588
  this.io.to(room).emit(event, data);
17113
17589
  }
@@ -17179,6 +17655,22 @@ var DashboardSocket = class {
17179
17655
  });
17180
17656
  });
17181
17657
  }
17658
+ /**
17659
+ * A client subscribed to a session's room.
17660
+ *
17661
+ * The host uses this to replay a gate the run is already parked on. Socket.IO
17662
+ * does not buffer room emissions, so a prompt broadcast while the renderer was
17663
+ * reconnecting is simply gone; without a replay the section waits out its full
17664
+ * timeout with the user sitting in front of a screen that never asked.
17665
+ */
17666
+ onJoinSession(callback) {
17667
+ this.io.on("connection", (socket) => {
17668
+ socket.on("join:session", (payload) => {
17669
+ const { sessionId } = normalizeSessionSubscriptionPayload(payload);
17670
+ if (sessionId) callback(sessionId, socket.id);
17671
+ });
17672
+ });
17673
+ }
17182
17674
  onSessionRate(callback) {
17183
17675
  this.io.on("connection", (socket) => {
17184
17676
  socket.on("session:rate", (payload) => {
@@ -17216,6 +17708,31 @@ var DashboardSocket = class {
17216
17708
  });
17217
17709
  });
17218
17710
  }
17711
+ /**
17712
+ * A section escalated and the run is parked waiting for an answer. The
17713
+ * desktop shows the escalation modal on `escalation:decision-required` and
17714
+ * answers here.
17715
+ *
17716
+ * Unlike a plan decision, silence is NOT taken as consent — the SDK fails
17717
+ * the section on timeout — so this handler only ever forwards a real choice.
17718
+ */
17719
+ onEscalationDecision(callback) {
17720
+ this.io.on("connection", (socket) => {
17721
+ socket.on("escalation:decide", (payload) => {
17722
+ const action = payload?.action;
17723
+ if (typeof payload?.sessionId !== "string") return;
17724
+ if (action !== "retry" && action !== "skip" && action !== "guidance") return;
17725
+ callback({
17726
+ sessionId: payload.sessionId,
17727
+ // Identifies WHICH parked section this answers — sections in a wave
17728
+ // run concurrently, so more than one can be waiting.
17729
+ requestId: typeof payload.requestId === "string" ? payload.requestId : void 0,
17730
+ action,
17731
+ note: typeof payload.note === "string" && payload.note.trim() ? payload.note.trim() : void 0
17732
+ });
17733
+ });
17734
+ });
17735
+ }
17219
17736
  onSessionSteer(callback) {
17220
17737
  this.io.on("connection", (socket) => {
17221
17738
  socket.on("session:steer", (payload) => {
@@ -17374,6 +17891,7 @@ function aggregateCostStats(sessions, opts = {}) {
17374
17891
 
17375
17892
  // src/dashboard/server.ts
17376
17893
  var __dirname$1 = path24.dirname(fileURLToPath(import.meta.url));
17894
+ var ORPHANED_ESCALATION_GRACE_MS = 3e4;
17377
17895
  var DashboardServer = class {
17378
17896
  app;
17379
17897
  httpServer;
@@ -17384,6 +17902,13 @@ var DashboardServer = class {
17384
17902
  globalStore = null;
17385
17903
  broadcastTimer = null;
17386
17904
  activeSessions = /* @__PURE__ */ new Map();
17905
+ /**
17906
+ * Supplied by the desktop shell so a run can read the page the user has
17907
+ * open in the built-in browser. Absent in the CLI, where there is no
17908
+ * browser — so the tool is simply not registered rather than present and
17909
+ * always failing.
17910
+ */
17911
+ currentPageProvider;
17387
17912
  activeControllers = /* @__PURE__ */ new Map();
17388
17913
  /**
17389
17914
  * Run taskIds per chat session — file snapshots are keyed by the run's
@@ -17398,6 +17923,17 @@ var DashboardServer = class {
17398
17923
  * map is how that answer reaches the run that's blocked on it.
17399
17924
  */
17400
17925
  pendingApprovals = /* @__PURE__ */ new Map();
17926
+ /**
17927
+ * The escalation prompt a session is currently parked on, kept so it can be
17928
+ * delivered to a client that was not reachable when it was raised.
17929
+ *
17930
+ * Socket.IO buffers nothing: a prompt emitted while the renderer is mid
17931
+ * reconnect is gone, and the section then waits out its full five minutes
17932
+ * with the user in front of a screen that never asked them anything. Holding
17933
+ * the payload lets `join:session` replay it, and lets a run with no reachable
17934
+ * client be settled instead of parked (see ORPHANED_ESCALATION_GRACE_MS).
17935
+ */
17936
+ pendingEscalations = /* @__PURE__ */ new Map();
17401
17937
  /**
17402
17938
  * The orchestration decision trail ("why") of each session's most recent
17403
17939
  * run — captured when the run ends so the desktop's Why panel can show it
@@ -17475,20 +18011,29 @@ var DashboardServer = class {
17475
18011
  if (forceTier) cfg = { ...cfg, routing: { ...cfg.routing, forceTier } };
17476
18012
  const cascade = new Cascade(cfg, this.workspacePath, this.store);
17477
18013
  this.activeSessions.set(sessionId, cascade);
18014
+ if (this.currentPageProvider) cascade.setCurrentPageProvider(this.currentPageProvider);
17478
18015
  cascade.on("stream:token", (e) => {
17479
- this.socket.emitToSocket(socketId, "stream:token", { sessionId, tierId: e.tierId, text: e.text, primary: e.primary });
18016
+ this.emitToSessionClients(socketId, sessionId, "stream:token", { sessionId, tierId: e.tierId, text: e.text, primary: e.primary });
17480
18017
  });
17481
18018
  cascade.on("tier:status", (e) => {
17482
- this.socket.emitToSocket(socketId, "tier:status", { sessionId, ...e });
18019
+ this.emitToSessionClients(socketId, sessionId, "tier:status", { sessionId, ...e });
17483
18020
  });
17484
18021
  cascade.on("permission:user-required", (e) => {
17485
- this.socket.emitToSocket(socketId, "permission:user-required", { sessionId, ...e });
18022
+ this.emitToSessionClients(socketId, sessionId, "permission:user-required", { sessionId, ...e });
17486
18023
  });
17487
18024
  cascade.on("peer:message", (e) => {
17488
18025
  this.socket.emitPeerMessage(e);
17489
18026
  });
17490
18027
  cascade.on("plan:approval-required", (e) => {
17491
- this.socket.emitToSocket(socketId, "plan:approval-required", { sessionId, ...e });
18028
+ this.emitToSessionClients(socketId, sessionId, "plan:approval-required", { sessionId, ...e });
18029
+ });
18030
+ cascade.on("escalation:decision-required", (e) => {
18031
+ this.raiseEscalation(sessionId, socketId, e);
18032
+ });
18033
+ cascade.on("escalation:timeout", (e) => {
18034
+ const ev = e;
18035
+ if (ev.requestId) this.clearPendingEscalation(ev.requestId);
18036
+ this.emitToSessionClients(socketId, sessionId, "escalation:timeout", { sessionId, ...e });
17492
18037
  });
17493
18038
  try {
17494
18039
  const result = await cascade.run({
@@ -17499,7 +18044,7 @@ var DashboardServer = class {
17499
18044
  this.recordSessionTask(sessionId, result.taskId);
17500
18045
  this.persistRunEnd(sessionId, title, prompt, result.output, "COMPLETED", result);
17501
18046
  this.captureWhy(sessionId, cascade, result);
17502
- this.socket.emitToSocket(socketId, "session:complete", { sessionId, result });
18047
+ this.emitToSessionClients(socketId, sessionId, "session:complete", { sessionId, result });
17503
18048
  this.socket.broadcast("cost:update", {
17504
18049
  sessionId,
17505
18050
  totalTokens: result.usage.totalTokens,
@@ -17512,7 +18057,7 @@ var DashboardServer = class {
17512
18057
  } catch (err) {
17513
18058
  this.persistRunEnd(sessionId, title, prompt, void 0, "FAILED");
17514
18059
  this.captureWhy(sessionId, cascade);
17515
- this.socket.emitToSocket(socketId, "session:error", {
18060
+ this.emitToSessionClients(socketId, sessionId, "session:error", {
17516
18061
  sessionId,
17517
18062
  error: err instanceof Error ? err.message : String(err)
17518
18063
  });
@@ -17520,6 +18065,7 @@ var DashboardServer = class {
17520
18065
  this.activeSessions.delete(sessionId);
17521
18066
  this.activeControllers.delete(sessionId);
17522
18067
  this.denyPendingApprovals(sessionId);
18068
+ this.clearSessionEscalations(sessionId);
17523
18069
  }
17524
18070
  });
17525
18071
  this.socket.onPlanDecision(({ sessionId, approved, note, editedPlan }) => {
@@ -17529,10 +18075,20 @@ var DashboardServer = class {
17529
18075
  editedPlan
17530
18076
  );
17531
18077
  });
18078
+ this.socket.onEscalationDecision(({ sessionId, requestId, action, note }) => {
18079
+ if (requestId) this.clearPendingEscalation(requestId);
18080
+ else this.clearOldestSessionEscalation(sessionId);
18081
+ this.activeSessions.get(sessionId)?.resolveEscalation(action, note, requestId);
18082
+ });
18083
+ this.socket.onJoinSession((sessionId, socketId) => {
18084
+ this.replayEscalations(sessionId, socketId);
18085
+ });
17532
18086
  this.socket.onSessionHalt((sessionId) => {
17533
18087
  this.activeControllers.get(sessionId)?.abort();
17534
18088
  this.denyPendingApprovals(sessionId);
17535
18089
  this.activeSessions.get(sessionId)?.resolvePlanApproval(false);
18090
+ this.clearSessionEscalations(sessionId);
18091
+ this.activeSessions.get(sessionId)?.resolveEscalation("skip", void 0, void 0, true);
17536
18092
  });
17537
18093
  this.socket.onApprovalResponse(({ requestId, approved, always }) => {
17538
18094
  const pending = this.pendingApprovals.get(requestId);
@@ -17547,6 +18103,10 @@ var DashboardServer = class {
17547
18103
  }
17548
18104
  });
17549
18105
  }
18106
+ /** Wire the host's browser view in (desktop only). */
18107
+ setCurrentPageProvider(provider) {
18108
+ this.currentPageProvider = provider;
18109
+ }
17550
18110
  async start() {
17551
18111
  const isLoopback = this.host === "127.0.0.1" || this.host === "::1" || this.host === "localhost";
17552
18112
  if (!isLoopback) {
@@ -17835,6 +18395,116 @@ var DashboardServer = class {
17835
18395
  this.activeSessions.delete(sessionId);
17836
18396
  }
17837
18397
  }
18398
+ /**
18399
+ * Is anyone able to answer for this session right now?
18400
+ *
18401
+ * The originating socket first — that connection is definitely watching this
18402
+ * run — then the session room, which is where a client lands after a
18403
+ * reconnect issues it a new socket id.
18404
+ */
18405
+ hasResponder(sessionId, socketId) {
18406
+ if (socketId && this.socket.hasSocket(socketId)) return true;
18407
+ return this.socket.roomSize(`session:${sessionId}`) > 0;
18408
+ }
18409
+ /**
18410
+ * Send a run event to whoever is watching this session.
18411
+ *
18412
+ * A captured socket id goes stale the moment Socket.IO reconnects — the
18413
+ * client is back, but under a new id, and `emitToSocket` on the old one is a
18414
+ * silent no-op. Falling back to the session room keeps the run addressable
18415
+ * across a reconnect; emitting to one OR the other (never both) keeps a
18416
+ * client that is both the originator and a room member from seeing every
18417
+ * token twice.
18418
+ */
18419
+ emitToSessionClients(socketId, sessionId, event, data) {
18420
+ if (socketId && this.socket.hasSocket(socketId)) this.socket.emitToSocket(socketId, event, data);
18421
+ else this.socket.broadcastToRoom(`session:${sessionId}`, event, data);
18422
+ }
18423
+ /**
18424
+ * Raise an escalation prompt, and make sure it can still be answered.
18425
+ *
18426
+ * Held in `pendingEscalations` — keyed by requestId, because a Complex wave
18427
+ * dispatches sections concurrently and two can be parked at once — so a
18428
+ * client that joins late (or rejoins after a reconnect) gets every waiting
18429
+ * prompt replayed. Keying by session would drop the first of a pair: its
18430
+ * grace timer would be cleared by the second, leaving it parked for the full
18431
+ * timeout with nobody able to answer it. If nobody is reachable at all, the gate is
18432
+ * settled as `skip` after a short grace period rather than parked for the
18433
+ * full timeout: that matches the SDK's policy when no listener exists, and
18434
+ * five minutes of a held run is a real cost for a REST caller who has already
18435
+ * hung up. The grace period exists so an ordinary two-second reconnect is not
18436
+ * mistaken for an absent user.
18437
+ */
18438
+ raiseEscalation(sessionId, socketId, event) {
18439
+ const requestId = typeof event.requestId === "string" && event.requestId ? event.requestId : randomUUID();
18440
+ const payload = { sessionId, ...event };
18441
+ const entry = { payload, sessionId, requestId, raisedAt: Date.now() };
18442
+ this.pendingEscalations.set(requestId, entry);
18443
+ if (this.hasResponder(sessionId, socketId)) {
18444
+ this.emitToSessionClients(socketId, sessionId, "escalation:decision-required", payload);
18445
+ return;
18446
+ }
18447
+ entry.graceTimer = setTimeout(() => {
18448
+ if (this.pendingEscalations.get(requestId) !== entry) return;
18449
+ if (this.hasResponder(sessionId, socketId)) return;
18450
+ this.pendingEscalations.delete(requestId);
18451
+ this.activeSessions.get(sessionId)?.resolveEscalation("skip", "No client was connected to answer.", requestId, true);
18452
+ }, ORPHANED_ESCALATION_GRACE_MS);
18453
+ }
18454
+ /**
18455
+ * Replay EVERY parked prompt to a client that just subscribed to the session.
18456
+ *
18457
+ * Plural because a Complex run dispatches sections concurrently, so a wave can
18458
+ * leave more than one waiting at the same time — the same reason the SDK keys
18459
+ * its gates and the clients queue theirs.
18460
+ *
18461
+ * `timeoutMs` is recomputed as the time actually LEFT, because the SDK's timer
18462
+ * has been running since the prompt was raised. Sent verbatim, a client
18463
+ * reconnecting four minutes in would show a fresh five-minute countdown and
18464
+ * then watch the section fail with four of those minutes still on the clock.
18465
+ * A remaining duration is used rather than an absolute deadline so the two
18466
+ * sides never have to agree on a wall clock.
18467
+ */
18468
+ replayEscalations(sessionId, socketId) {
18469
+ for (const entry of this.pendingEscalations.values()) {
18470
+ if (entry.sessionId !== sessionId) continue;
18471
+ if (entry.graceTimer) {
18472
+ clearTimeout(entry.graceTimer);
18473
+ entry.graceTimer = void 0;
18474
+ }
18475
+ const originalTimeout = typeof entry.payload.timeoutMs === "number" ? entry.payload.timeoutMs : 0;
18476
+ const remaining = Math.max(0, originalTimeout - (Date.now() - entry.raisedAt));
18477
+ this.socket.emitToSocket(socketId, "escalation:decision-required", { ...entry.payload, timeoutMs: remaining });
18478
+ }
18479
+ }
18480
+ /** Forget ONE parked prompt — the one that was answered or timed out. */
18481
+ clearPendingEscalation(requestId) {
18482
+ const entry = this.pendingEscalations.get(requestId);
18483
+ if (!entry) return;
18484
+ if (entry.graceTimer) clearTimeout(entry.graceTimer);
18485
+ this.pendingEscalations.delete(requestId);
18486
+ }
18487
+ /**
18488
+ * Forget the session's OLDEST prompt — for a client that answered without a
18489
+ * requestId, which is exactly the gate `resolveEscalation` will settle.
18490
+ * Insertion order makes `values()` oldest-first.
18491
+ */
18492
+ clearOldestSessionEscalation(sessionId) {
18493
+ for (const [id, entry] of this.pendingEscalations) {
18494
+ if (entry.sessionId !== sessionId) continue;
18495
+ if (entry.graceTimer) clearTimeout(entry.graceTimer);
18496
+ this.pendingEscalations.delete(id);
18497
+ return;
18498
+ }
18499
+ }
18500
+ /** Forget every prompt a session was parked on (run ended, or halted). */
18501
+ clearSessionEscalations(sessionId) {
18502
+ for (const [id, entry] of this.pendingEscalations) {
18503
+ if (entry.sessionId !== sessionId) continue;
18504
+ if (entry.graceTimer) clearTimeout(entry.graceTimer);
18505
+ this.pendingEscalations.delete(id);
18506
+ }
18507
+ }
17838
18508
  /** Deny + clear any approvals still pending for a session (run end / abort). */
17839
18509
  denyPendingApprovals(sessionId) {
17840
18510
  for (const [id, pending] of this.pendingApprovals) {
@@ -18335,6 +19005,7 @@ ${prompt}`;
18335
19005
  void (async () => {
18336
19006
  const cascade = new Cascade(this.config, this.workspacePath, this.store);
18337
19007
  this.activeSessions.set(sessionId, cascade);
19008
+ if (this.currentPageProvider) cascade.setCurrentPageProvider(this.currentPageProvider);
18338
19009
  cascade.on("stream:token", (e) => {
18339
19010
  this.socket.broadcastToRoom(`session:${sessionId}`, "stream:token", { sessionId, tierId: e.tierId, text: e.text, primary: e.primary });
18340
19011
  });
@@ -18350,6 +19021,14 @@ ${prompt}`;
18350
19021
  cascade.on("plan:approval-required", (e) => {
18351
19022
  this.socket.broadcastToRoom(`session:${sessionId}`, "plan:approval-required", { sessionId, ...e });
18352
19023
  });
19024
+ cascade.on("escalation:decision-required", (e) => {
19025
+ this.raiseEscalation(sessionId, void 0, e);
19026
+ });
19027
+ cascade.on("escalation:timeout", (e) => {
19028
+ const ev = e;
19029
+ if (ev.requestId) this.clearPendingEscalation(ev.requestId);
19030
+ this.socket.broadcastToRoom(`session:${sessionId}`, "escalation:timeout", { sessionId, ...e });
19031
+ });
18353
19032
  try {
18354
19033
  const result = await cascade.run({
18355
19034
  prompt: runPrompt,
@@ -18377,6 +19056,7 @@ ${prompt}`;
18377
19056
  } finally {
18378
19057
  this.activeSessions.delete(sessionId);
18379
19058
  this.denyPendingApprovals(sessionId);
19059
+ this.clearSessionEscalations(sessionId);
18380
19060
  }
18381
19061
  })();
18382
19062
  });
@@ -18709,6 +19389,41 @@ var HooksRunner = class {
18709
19389
  }
18710
19390
  };
18711
19391
 
19392
+ // src/mcp/discover.ts
19393
+ async function discoverMcpTools(servers) {
19394
+ const results = [];
19395
+ for (const server of servers) {
19396
+ const client = new McpClient({ trustedServers: [server.name] });
19397
+ try {
19398
+ const authProvider = server.oauthStore ? fileOAuthProvider(server.oauthStore) : void 0;
19399
+ const connect = () => client.connect(server, authProvider ? { authProvider } : {});
19400
+ await (server.oauthStore ? withOAuthStoreLock(server.oauthStore, connect) : connect());
19401
+ const parsed = client.getToolDefinitions().flatMap((def) => {
19402
+ const [, serverName, toolName] = def.name.split("::");
19403
+ return serverName && toolName ? [{ def, server: serverName, tool: toolName }] : [];
19404
+ });
19405
+ const names = assignMcpToolNames(parsed);
19406
+ const tools = parsed.map(({ def, server: s, tool }, i) => ({
19407
+ server: s,
19408
+ tool,
19409
+ name: names[i],
19410
+ description: def.description.replace(`[MCP:${s}] `, "")
19411
+ }));
19412
+ results.push({ server: server.name, tools });
19413
+ } catch (err) {
19414
+ results.push({
19415
+ server: server.name,
19416
+ tools: [],
19417
+ error: err instanceof Error ? err.message : String(err)
19418
+ });
19419
+ } finally {
19420
+ await client.disconnectAll().catch(() => {
19421
+ });
19422
+ }
19423
+ }
19424
+ return results;
19425
+ }
19426
+
18712
19427
  // src/retrieval/chunk.ts
18713
19428
  var DEFAULTS2 = { targetChars: 2e3, overlapChars: 200, minChars: 80 };
18714
19429
  function splitLongBlock(block, max) {
@@ -19247,11 +19962,55 @@ function mergeByKey(local, incoming, key) {
19247
19962
  for (const i of incoming) map.set(key(i), i);
19248
19963
  return [...map.values()];
19249
19964
  }
19965
+ function uniqueServerName(desired, takenPrefixes) {
19966
+ if (!takenPrefixes.has(mcpServerPrefix(desired))) return desired;
19967
+ let n = 2;
19968
+ while (takenPrefixes.has(mcpServerPrefix(`${desired} ${n}`))) n++;
19969
+ return `${desired} ${n}`;
19970
+ }
19971
+ function mergeMcpServers(local, incoming) {
19972
+ const rewrite = /* @__PURE__ */ new Map();
19973
+ if (!incoming?.length) return { servers: local, synced: [], rewrite };
19974
+ const byName = /* @__PURE__ */ new Map();
19975
+ for (const l of local ?? []) byName.set(l.name, l);
19976
+ const prefixes = new Set([...byName.values()].map((m) => mcpServerPrefix(m.name)));
19977
+ const synced = [];
19978
+ for (const inc of incoming) {
19979
+ if (byName.has(inc.name)) {
19980
+ byName.set(inc.name, inc);
19981
+ synced.push(inc);
19982
+ continue;
19983
+ }
19984
+ const name = uniqueServerName(inc.name, prefixes);
19985
+ if (name !== inc.name) rewrite.set(mcpServerPrefix(inc.name), mcpServerPrefix(name));
19986
+ const server = name === inc.name ? inc : { ...inc, name };
19987
+ byName.set(name, server);
19988
+ synced.push(server);
19989
+ prefixes.add(mcpServerPrefix(name));
19990
+ }
19991
+ return { servers: [...byName.values()], synced, rewrite };
19992
+ }
19993
+ function rewriteDisabledTools(tools, rewrite) {
19994
+ if (!tools?.length || rewrite.size === 0) return tools;
19995
+ return tools.map((t) => {
19996
+ for (const [from, to] of rewrite) if (t.startsWith(from)) return to + t.slice(from.length);
19997
+ return t;
19998
+ });
19999
+ }
20000
+ function mergeDisabledTools(local, incoming, syncedServers) {
20001
+ const prefixes = (syncedServers ?? []).map((m) => mcpServerPrefix(m.name));
20002
+ const covered = (tool) => prefixes.some((p) => tool.startsWith(p));
20003
+ const kept = (local ?? []).filter((t) => !covered(t));
20004
+ const merged = [.../* @__PURE__ */ new Set([...kept, ...incoming ?? []])];
20005
+ return merged.length ? merged : void 0;
20006
+ }
19250
20007
  function gatherSyncBundle(config) {
19251
- const bundle = { v: 1 };
20008
+ const bundle = { v: 2 };
19252
20009
  if (config.providers?.length) bundle.providers = config.providers;
19253
20010
  if (config.tools?.webSearch) bundle.webSearch = config.tools.webSearch;
19254
20011
  if (config.tools?.mcpServers?.length) bundle.mcpServers = config.tools.mcpServers;
20012
+ const syncedDisabledTools = config.tools?.disabledTools?.filter(isMcpToolName);
20013
+ if (syncedDisabledTools?.length) bundle.disabledTools = syncedDisabledTools;
19255
20014
  if (config.models) bundle.models = config.models;
19256
20015
  if (config.budget) bundle.budget = config.budget;
19257
20016
  const prefs = {};
@@ -19266,7 +20025,16 @@ function applySyncBundle(bundle, config) {
19266
20025
  const next = { ...config, tools: { ...config.tools } };
19267
20026
  if (bundle.providers) next.providers = mergeByKey(config.providers, bundle.providers, providerSig) ?? [];
19268
20027
  if (bundle.webSearch) next.tools.webSearch = { ...config.tools?.webSearch, ...bundle.webSearch };
19269
- if (bundle.mcpServers) next.tools.mcpServers = mergeByKey(config.tools?.mcpServers, bundle.mcpServers, (m) => m.name);
20028
+ const mcp = mergeMcpServers(config.tools?.mcpServers, bundle.mcpServers);
20029
+ if (bundle.mcpServers) next.tools.mcpServers = mcp.servers;
20030
+ const carriesSelections = bundle.v >= 2 || bundle.disabledTools !== void 0;
20031
+ if (carriesSelections && (bundle.mcpServers || bundle.disabledTools)) {
20032
+ next.tools.disabledTools = mergeDisabledTools(
20033
+ config.tools?.disabledTools,
20034
+ rewriteDisabledTools(bundle.disabledTools, mcp.rewrite),
20035
+ bundle.mcpServers ? mcp.synced : void 0
20036
+ );
20037
+ }
19270
20038
  if (bundle.models) next.models = { ...config.models, ...bundle.models };
19271
20039
  if (bundle.budget) next.budget = { ...config.budget, ...bundle.budget };
19272
20040
  if (bundle.prefs) {
@@ -19279,6 +20047,6 @@ function applySyncBundle(bundle, config) {
19279
20047
  return next;
19280
20048
  }
19281
20049
 
19282
- export { AZURE_BASE_MODELS, AZURE_BASE_URL_TEMPLATE, AuditLogger, CASCADE_AUDIT_FILE, CASCADE_CONFIG_DIR, CASCADE_CONFIG_FILE, CASCADE_DASHBOARD_SECRET_FILE, CASCADE_DB_FILE, CASCADE_IGNORE_FILE, CASCADE_KEYSTORE_FILE, CASCADE_MD_FILE, CASCADE_VERSION, CHARS_PER_TOKEN, COMPLEXITY_T2_COUNT, Cascade, CascadeCancelledError, CascadeIgnore, CascadeRouter, CascadeToolError, CloudClient, CodeSearchTool, ConfigManager, DEFAULT_API_PORT, DEFAULT_APPROVAL_REQUIRED, DEFAULT_AUTO_SUMMARIZE_AT, DEFAULT_CLOUD_URL, DEFAULT_CONTEXT_LIMIT, DEFAULT_DASHBOARD_PORT, DEFAULT_MAX_SESSION_MESSAGES, DEFAULT_RETENTION_DAYS, DEFAULT_THEME, DashboardServer, FileMcpOAuthStore, GLOBAL_CONFIG_DIR, GLOBAL_CREDENTIALS_FILE, GLOBAL_DB_FILE, GLOBAL_KEYSTORE_FILE, GLOBAL_RUNTIME_DB_FILE, GraphRetriever, GraphSearchTool, HooksRunner, Keystore, LLMReranker, LM_STUDIO_BASE_URL, MODELS, McpClient, McpOAuthProvider, MemoryStore, OLLAMA_BASE_URL, OpenAICompatibleEmbedder, PROVIDER_DISPLAY_NAMES, Retriever, SqliteVectorStore, T1Administrator, T1_MODEL_PRIORITY, T2Manager, T2_MODEL_PRIORITY, T3Worker, T3_MODEL_PRIORITY, THEME_NAMES, TOOL_NAMES, TaskScheduler, Telemetry, ToolRegistry, VISION_MODEL_PRIORITY, WorkspaceIndex, applySyncBundle, azureModelForDeployment, beginMcpOAuth, buildManifest, buildSessionTranscript, cagCharBudget, chatCompleterFromProviders, chunkCode, chunkText2 as chunkText, completeMcpOAuth, connectMcpWithLoopbackOAuth, createCascade, decryptJSON as decryptSyncBlob, diffManifest, discoverMcpAuthServer, distillSessionFacts, embedderFromProviders, encryptJSON as encryptSyncBlob, fileOAuthProvider, gatherSyncBundle, hashContent, heuristicCodeChunker, inferAzureBaseModel, nodeHttpFetch, parseRankOrder, planRetrieval, preferIpv4Host, reciprocalRankFusion, refreshMcpToken, runCascade, sessionWorthRemembering, streamCascade };
20050
+ export { AZURE_BASE_MODELS, AZURE_BASE_URL_TEMPLATE, AuditLogger, CASCADE_AUDIT_FILE, CASCADE_CONFIG_DIR, CASCADE_CONFIG_FILE, CASCADE_DASHBOARD_SECRET_FILE, CASCADE_DB_FILE, CASCADE_IGNORE_FILE, CASCADE_KEYSTORE_FILE, CASCADE_MD_FILE, CASCADE_VERSION, CHARS_PER_TOKEN, COMPLEXITY_T2_COUNT, Cascade, CascadeCancelledError, CascadeIgnore, CascadeRouter, CascadeToolError, CloudClient, CodeSearchTool, ConfigManager, CurrentPageTool, DEFAULT_API_PORT, DEFAULT_APPROVAL_REQUIRED, DEFAULT_AUTO_SUMMARIZE_AT, DEFAULT_CLOUD_URL, DEFAULT_CONTEXT_LIMIT, DEFAULT_DASHBOARD_PORT, DEFAULT_MAX_SESSION_MESSAGES, DEFAULT_RETENTION_DAYS, DEFAULT_THEME, DashboardServer, FileMcpOAuthStore, GLOBAL_CONFIG_DIR, GLOBAL_CREDENTIALS_FILE, GLOBAL_DB_FILE, GLOBAL_KEYSTORE_FILE, GLOBAL_RUNTIME_DB_FILE, GraphRetriever, GraphSearchTool, HooksRunner, Keystore, LLMReranker, LM_STUDIO_BASE_URL, MAX_PAGE_TEXT_CHARS, MCP_TOOL_PREFIX, MODELS, McpClient, McpOAuthProvider, MemoryStore, OLLAMA_BASE_URL, OpenAICompatibleEmbedder, PROVIDER_DISPLAY_NAMES, Retriever, SqliteVectorStore, T1Administrator, T1_MODEL_PRIORITY, T2Manager, T2_MODEL_PRIORITY, T3Worker, T3_MODEL_PRIORITY, THEME_NAMES, TOOL_NAMES, TaskScheduler, Telemetry, ToolRegistry, VISION_MODEL_PRIORITY, WorkspaceIndex, applySyncBundle, azureModelForDeployment, beginMcpOAuth, buildManifest, buildSessionTranscript, cagCharBudget, chatCompleterFromProviders, chunkCode, chunkText2 as chunkText, completeMcpOAuth, connectMcpWithLoopbackOAuth, createCascade, decryptJSON as decryptSyncBlob, diffManifest, disambiguateMcpServerNames, discoverMcpAuthServer, discoverMcpTools, distillSessionFacts, embedderFromProviders, encryptJSON as encryptSyncBlob, fileOAuthProvider, gatherSyncBundle, hashContent, heuristicCodeChunker, inferAzureBaseModel, isMcpToolName, mcpServerPrefix, mcpToolName, nodeHttpFetch, parseRankOrder, planRetrieval, preferIpv4Host, reciprocalRankFusion, refreshMcpToken, removeMcpServerDenials, runCascade, sessionWorthRemembering, streamCascade, uniqueMcpServerName };
19283
20051
  //# sourceMappingURL=index.js.map
19284
20052
  //# sourceMappingURL=index.js.map