@polka-codes/cli-shared 0.8.14 → 0.8.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.
Files changed (2) hide show
  1. package/dist/index.js +51 -64
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -30889,8 +30889,32 @@ Anthropic.Beta = Beta;
30889
30889
  // ../core/src/AiService/ModelInfo.ts
30890
30890
  var anthropicDefaultModelId = "claude-3-7-sonnet-20250219";
30891
30891
  var anthropicModels = {
30892
+ "claude-opus-4-20250514": {
30893
+ maxTokens: 32000,
30894
+ contextWindow: 200000,
30895
+ supportsImages: true,
30896
+ supportsComputerUse: true,
30897
+ supportsPromptCache: true,
30898
+ inputPrice: 15,
30899
+ outputPrice: 75,
30900
+ cacheWritesPrice: 18.75,
30901
+ cacheReadsPrice: 1.5,
30902
+ reasoning: true
30903
+ },
30904
+ "claude-sonnet-4-20250514": {
30905
+ maxTokens: 64000,
30906
+ contextWindow: 200000,
30907
+ supportsImages: true,
30908
+ supportsComputerUse: true,
30909
+ supportsPromptCache: true,
30910
+ inputPrice: 3,
30911
+ outputPrice: 15,
30912
+ cacheWritesPrice: 3.75,
30913
+ cacheReadsPrice: 0.3,
30914
+ reasoning: true
30915
+ },
30892
30916
  "claude-3-7-sonnet-20250219": {
30893
- maxTokens: 8192,
30917
+ maxTokens: 64000,
30894
30918
  contextWindow: 200000,
30895
30919
  supportsImages: true,
30896
30920
  supportsComputerUse: true,
@@ -31011,6 +31035,7 @@ class AnthropicService extends AiServiceBase {
31011
31035
  temperature = undefined;
31012
31036
  }
31013
31037
  switch (modelId) {
31038
+ case "claude-sonnet-4-20250514":
31014
31039
  case "claude-3-7-sonnet-20250219":
31015
31040
  case "claude-3-5-sonnet-20241022":
31016
31041
  case "claude-3-5-haiku-20241022":
@@ -36543,70 +36568,31 @@ class OpenRouterService extends AiServiceBase {
36543
36568
  ...convertToOpenAiMessages(messages)
36544
36569
  ];
36545
36570
  const cacheControl = this.#options.enableCache ? { type: "ephemeral" } : undefined;
36546
- switch (this.model.id) {
36547
- case "anthropic/claude-3.7-sonnet:thinking":
36548
- case "anthropic/claude-3.7-sonnet":
36549
- case "anthropic/claude-3.7-sonnet:beta":
36550
- case "anthropic/claude-3-7-sonnet":
36551
- case "anthropic/claude-3-7-sonnet:beta":
36552
- case "anthropic/claude-3.5-sonnet":
36553
- case "anthropic/claude-3.5-sonnet:beta":
36554
- case "anthropic/claude-3.5-sonnet-20240620":
36555
- case "anthropic/claude-3.5-sonnet-20240620:beta":
36556
- case "anthropic/claude-3-5-haiku":
36557
- case "anthropic/claude-3-5-haiku:beta":
36558
- case "anthropic/claude-3-5-haiku-20241022":
36559
- case "anthropic/claude-3-5-haiku-20241022:beta":
36560
- case "anthropic/claude-3-haiku":
36561
- case "anthropic/claude-3-haiku:beta":
36562
- case "anthropic/claude-3-opus":
36563
- case "anthropic/claude-3-opus:beta": {
36564
- openAiMessages[0] = {
36565
- role: "system",
36566
- content: [
36567
- {
36568
- type: "text",
36569
- text: systemPrompt,
36570
- cache_control: cacheControl
36571
- }
36572
- ]
36573
- };
36574
- const lastTwoUserMessages = openAiMessages.filter((msg) => msg.role === "user").slice(-2);
36575
- for (const msg of lastTwoUserMessages) {
36576
- if (typeof msg.content === "string") {
36577
- msg.content = [{ type: "text", text: msg.content }];
36578
- }
36579
- if (Array.isArray(msg.content)) {
36580
- let lastTextPart = msg.content.filter((part) => part.type === "text").pop();
36581
- if (!lastTextPart) {
36582
- lastTextPart = { type: "text", text: "..." };
36583
- msg.content.push(lastTextPart);
36584
- }
36585
- lastTextPart.cache_control = cacheControl;
36571
+ if (this.model.id.startsWith("anthropic/claude")) {
36572
+ openAiMessages[0] = {
36573
+ role: "system",
36574
+ content: [
36575
+ {
36576
+ type: "text",
36577
+ text: systemPrompt,
36578
+ cache_control: cacheControl
36579
+ }
36580
+ ]
36581
+ };
36582
+ const lastTwoUserMessages = openAiMessages.filter((msg) => msg.role === "user").slice(-2);
36583
+ for (const msg of lastTwoUserMessages) {
36584
+ if (typeof msg.content === "string") {
36585
+ msg.content = [{ type: "text", text: msg.content }];
36586
+ }
36587
+ if (Array.isArray(msg.content)) {
36588
+ let lastTextPart = msg.content.filter((part) => part.type === "text").pop();
36589
+ if (!lastTextPart) {
36590
+ lastTextPart = { type: "text", text: "..." };
36591
+ msg.content.push(lastTextPart);
36586
36592
  }
36593
+ lastTextPart.cache_control = cacheControl;
36587
36594
  }
36588
- break;
36589
36595
  }
36590
- default:
36591
- break;
36592
- }
36593
- let maxTokens;
36594
- switch (this.model.id) {
36595
- case "anthropic/claude-3.7-sonnet:thinking":
36596
- case "anthropic/claude-3.7-sonnet":
36597
- case "anthropic/claude-3.7-sonnet:beta":
36598
- case "anthropic/claude-3-7-sonnet":
36599
- case "anthropic/claude-3-7-sonnet:beta":
36600
- case "anthropic/claude-3.5-sonnet":
36601
- case "anthropic/claude-3.5-sonnet:beta":
36602
- case "anthropic/claude-3.5-sonnet-20240620":
36603
- case "anthropic/claude-3.5-sonnet-20240620:beta":
36604
- case "anthropic/claude-3-5-haiku":
36605
- case "anthropic/claude-3-5-haiku:beta":
36606
- case "anthropic/claude-3-5-haiku-20241022":
36607
- case "anthropic/claude-3-5-haiku-20241022:beta":
36608
- maxTokens = 8192;
36609
- break;
36610
36596
  }
36611
36597
  let reasoning = {};
36612
36598
  switch (this.model.id) {
@@ -36614,7 +36600,9 @@ class OpenRouterService extends AiServiceBase {
36614
36600
  case "anthropic/claude-3.7-sonnet:beta":
36615
36601
  case "anthropic/claude-3.7-sonnet:thinking":
36616
36602
  case "anthropic/claude-3-7-sonnet":
36617
- case "anthropic/claude-3-7-sonnet:beta": {
36603
+ case "anthropic/claude-3-7-sonnet:beta":
36604
+ case "anthropic/claude-opus-4":
36605
+ case "anthropic/claude-sonnet-4": {
36618
36606
  const budget_tokens = this.#options.parameters.thinkingBudgetTokens || 0;
36619
36607
  if (budget_tokens > 0) {
36620
36608
  reasoning = { max_tokens: budget_tokens };
@@ -36628,7 +36616,6 @@ class OpenRouterService extends AiServiceBase {
36628
36616
  }
36629
36617
  const stream = await this.#client.chat.completions.create({
36630
36618
  model: this.model.id,
36631
- max_completion_tokens: maxTokens,
36632
36619
  messages: openAiMessages,
36633
36620
  temperature: 0,
36634
36621
  stream: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli-shared",
3
- "version": "0.8.14",
3
+ "version": "0.8.16",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",