cascade-ai 0.12.8 → 0.12.9

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
@@ -35,7 +35,7 @@ import cron from 'node-cron';
35
35
 
36
36
 
37
37
  // src/constants.ts
38
- var CASCADE_VERSION = "0.12.8";
38
+ var CASCADE_VERSION = "0.12.9";
39
39
  var CASCADE_CONFIG_DIR = ".cascade";
40
40
  var CASCADE_MD_FILE = "CASCADE.md";
41
41
  var CASCADE_IGNORE_FILE = ".cascadeignore";
@@ -435,6 +435,12 @@ var BaseProvider = class {
435
435
  };
436
436
 
437
437
  // src/providers/anthropic.ts
438
+ function anthropicThinkingParam(modelId, maxTokens) {
439
+ if (!/claude-(opus|sonnet)-4/i.test(modelId)) return {};
440
+ const budget = Math.min(8e3, maxTokens - 1024);
441
+ if (budget < 1024) return {};
442
+ return { thinking: { type: "enabled", budget_tokens: budget } };
443
+ }
438
444
  var AnthropicProvider = class extends BaseProvider {
439
445
  client;
440
446
  constructor(config, model) {
@@ -464,13 +470,18 @@ var AnthropicProvider = class extends BaseProvider {
464
470
  let fullContent = "";
465
471
  let inputTokens = 0;
466
472
  let outputTokens = 0;
473
+ const maxTokens = options.maxTokens ?? this.model.maxOutputTokens;
474
+ const thinkParam = anthropicThinkingParam(this.model.id, maxTokens);
475
+ const useThinking = !!thinkParam.thinking;
467
476
  const stream = this.client.messages.stream({
468
477
  model: this.model.id,
469
- max_tokens: options.maxTokens ?? this.model.maxOutputTokens,
470
- temperature: options.temperature ?? 0.7,
478
+ max_tokens: maxTokens,
479
+ // Extended thinking requires temperature = 1; otherwise honor the request.
480
+ temperature: useThinking ? 1 : options.temperature ?? 0.7,
471
481
  system: options.systemPrompt,
472
482
  messages,
473
- tools: tools?.length ? tools : void 0
483
+ tools: tools?.length ? tools : void 0,
484
+ ...thinkParam
474
485
  }, { signal: options.signal });
475
486
  let isThinking = false;
476
487
  for await (const event of stream) {