cascade-ai 0.19.0 → 0.20.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.d.cts CHANGED
@@ -499,6 +499,16 @@ interface ToolsConfig {
499
499
  * 'auto' (default) = isolate when available else worker.
500
500
  */
501
501
  dynamicToolSandbox?: 'isolate' | 'worker' | 'auto';
502
+ /**
503
+ * When set, ONLY these tool names are registered — every other built-in tool
504
+ * (including shell/file/git, which have no other off-switch) is omitted
505
+ * entirely rather than merely approval-gated. Built for embedding Cascade in
506
+ * an untrusted/multi-tenant context (e.g. a hosted chat server) where the
507
+ * full tool surface must never exist for a run, not just require a click to
508
+ * use. `undefined`/omitted registers the full default set (unchanged
509
+ * behavior). An empty array registers no tools at all.
510
+ */
511
+ enabledTools?: string[];
502
512
  }
503
513
  interface HooksConfig {
504
514
  preToolUse?: HookDefinition[];
package/dist/index.d.ts CHANGED
@@ -499,6 +499,16 @@ interface ToolsConfig {
499
499
  * 'auto' (default) = isolate when available else worker.
500
500
  */
501
501
  dynamicToolSandbox?: 'isolate' | 'worker' | 'auto';
502
+ /**
503
+ * When set, ONLY these tool names are registered — every other built-in tool
504
+ * (including shell/file/git, which have no other off-switch) is omitted
505
+ * entirely rather than merely approval-gated. Built for embedding Cascade in
506
+ * an untrusted/multi-tenant context (e.g. a hosted chat server) where the
507
+ * full tool surface must never exist for a run, not just require a click to
508
+ * use. `undefined`/omitted registers the full default set (unchanged
509
+ * behavior). An empty array registers no tools at all.
510
+ */
511
+ enabledTools?: string[];
502
512
  }
503
513
  interface HooksConfig {
504
514
  preToolUse?: HookDefinition[];
package/dist/index.js CHANGED
@@ -190,7 +190,7 @@ var init_audit_logger = __esm({
190
190
  });
191
191
 
192
192
  // src/constants.ts
193
- var CASCADE_VERSION = "0.19.0";
193
+ var CASCADE_VERSION = "0.20.0";
194
194
  var CASCADE_CONFIG_DIR = ".cascade";
195
195
  var CASCADE_MD_FILE = "CASCADE.md";
196
196
  var CASCADE_IGNORE_FILE = ".cascadeignore";
@@ -1034,14 +1034,27 @@ var AzureOpenAIProvider = class extends OpenAIProvider {
1034
1034
  return [fromDeployment ?? this.model];
1035
1035
  }
1036
1036
  async isAvailable() {
1037
+ const params = {
1038
+ model: this.model.id,
1039
+ messages: [{ role: "user", content: "ping" }],
1040
+ max_tokens: 1
1041
+ };
1037
1042
  try {
1038
- await this.client.chat.completions.create({
1039
- model: this.model.id,
1040
- messages: [{ role: "user", content: "ping" }],
1041
- max_tokens: 1
1042
- });
1043
+ await this.client.chat.completions.create(params);
1043
1044
  return true;
1044
- } catch {
1045
+ } catch (err) {
1046
+ if (err?.message && String(err.message).includes("max_completion_tokens")) {
1047
+ try {
1048
+ await this.client.chat.completions.create({
1049
+ model: this.model.id,
1050
+ messages: [{ role: "user", content: "ping" }],
1051
+ max_completion_tokens: 1
1052
+ });
1053
+ return true;
1054
+ } catch {
1055
+ return false;
1056
+ }
1057
+ }
1045
1058
  return false;
1046
1059
  }
1047
1060
  }
@@ -1783,6 +1796,10 @@ var ModelSelector = class {
1783
1796
  actualId = parts.slice(1).join(":");
1784
1797
  }
1785
1798
  }
1799
+ const registered = this.availableModels.get(actualId);
1800
+ if (registered && (!providerStr || registered.provider === providerStr)) {
1801
+ return registered;
1802
+ }
1786
1803
  if (!providerStr) {
1787
1804
  const lower = actualId.toLowerCase();
1788
1805
  if (lower.includes("claude")) providerStr = "anthropic";
@@ -8028,29 +8045,32 @@ var ToolRegistry = class extends EventEmitter {
8028
8045
  return tool.execute(input, options);
8029
8046
  }
8030
8047
  registerDefaults() {
8031
- const tools = [
8032
- new ShellTool(this.config.shellAllowlist, this.config.shellBlocklist),
8033
- new FileReadTool(),
8034
- new FileWriteTool(),
8035
- new FileEditTool(),
8036
- new FileDeleteTool(),
8037
- new FileListTool(),
8038
- new GitTool(),
8039
- new GitHubTool(),
8040
- new ImageAnalyzeTool(),
8041
- new PDFCreateTool(),
8042
- new CodeInterpreterTool(),
8043
- new PeerCommunicationTool(),
8044
- new WebSearchTool(this.config.webSearch),
8045
- new GlobTool(),
8046
- new GrepTool(),
8047
- new WebFetchTool()
8048
+ const allowlist = this.config.enabledTools;
8049
+ const enabled = (name) => !allowlist || allowlist.includes(name);
8050
+ const candidates = [
8051
+ enabled("shell") && new ShellTool(this.config.shellAllowlist, this.config.shellBlocklist),
8052
+ enabled("file_read") && new FileReadTool(),
8053
+ enabled("file_write") && new FileWriteTool(),
8054
+ enabled("file_edit") && new FileEditTool(),
8055
+ enabled("file_delete") && new FileDeleteTool(),
8056
+ enabled("file_list") && new FileListTool(),
8057
+ enabled("git") && new GitTool(),
8058
+ enabled("github") && new GitHubTool(),
8059
+ enabled("image_analyze") && new ImageAnalyzeTool(),
8060
+ enabled("pdf_create") && new PDFCreateTool(),
8061
+ enabled("run_code") && new CodeInterpreterTool(),
8062
+ enabled("peer_message") && new PeerCommunicationTool(),
8063
+ enabled("web_search") && new WebSearchTool(this.config.webSearch),
8064
+ enabled("glob") && new GlobTool(),
8065
+ enabled("grep") && new GrepTool(),
8066
+ enabled("web_fetch") && new WebFetchTool()
8048
8067
  ];
8068
+ const tools = candidates.filter((t) => t !== false);
8049
8069
  for (const tool of tools) {
8050
8070
  tool.setWorkspaceRoot(this.workspaceRoot);
8051
8071
  this.register(tool);
8052
8072
  }
8053
- if (this.config.browserEnabled) {
8073
+ if (this.config.browserEnabled && enabled("browser")) {
8054
8074
  const browser = new BrowserTool();
8055
8075
  browser.setWorkspaceRoot(this.workspaceRoot);
8056
8076
  this.register(browser);
@@ -8400,7 +8420,13 @@ var ToolsConfigSchema = z.object({
8400
8420
  * - 'worker': node:worker_threads (resource/kill limits, but not capability-confined).
8401
8421
  * - 'auto' (default): use the isolate when `isolated-vm` loads, else fall back to worker.
8402
8422
  */
8403
- dynamicToolSandbox: z.enum(["isolate", "worker", "auto"]).default("auto")
8423
+ dynamicToolSandbox: z.enum(["isolate", "worker", "auto"]).default("auto"),
8424
+ /**
8425
+ * When set, ONLY these tool names are registered — the sole way to omit a
8426
+ * built-in tool (shell/file/git/…) from existing at all, rather than just
8427
+ * gating it behind approval. Omitted = full default set (unchanged).
8428
+ */
8429
+ enabledTools: z.array(z.string()).optional()
8404
8430
  });
8405
8431
  var HookDefinitionSchema = z.object({
8406
8432
  name: z.string().optional(),