@polka-codes/cli 0.8.15 → 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
@@ -38447,7 +38447,7 @@ var {
38447
38447
  Help
38448
38448
  } = import__.default;
38449
38449
  // package.json
38450
- var version = "0.8.15";
38450
+ var version = "0.8.16";
38451
38451
 
38452
38452
  // ../core/src/AiService/AiServiceBase.ts
38453
38453
  class AiServiceBase {
@@ -41845,8 +41845,32 @@ Anthropic.Beta = Beta;
41845
41845
  // ../core/src/AiService/ModelInfo.ts
41846
41846
  var anthropicDefaultModelId = "claude-3-7-sonnet-20250219";
41847
41847
  var anthropicModels = {
41848
+ "claude-opus-4-20250514": {
41849
+ maxTokens: 32000,
41850
+ contextWindow: 200000,
41851
+ supportsImages: true,
41852
+ supportsComputerUse: true,
41853
+ supportsPromptCache: true,
41854
+ inputPrice: 15,
41855
+ outputPrice: 75,
41856
+ cacheWritesPrice: 18.75,
41857
+ cacheReadsPrice: 1.5,
41858
+ reasoning: true
41859
+ },
41860
+ "claude-sonnet-4-20250514": {
41861
+ maxTokens: 64000,
41862
+ contextWindow: 200000,
41863
+ supportsImages: true,
41864
+ supportsComputerUse: true,
41865
+ supportsPromptCache: true,
41866
+ inputPrice: 3,
41867
+ outputPrice: 15,
41868
+ cacheWritesPrice: 3.75,
41869
+ cacheReadsPrice: 0.3,
41870
+ reasoning: true
41871
+ },
41848
41872
  "claude-3-7-sonnet-20250219": {
41849
- maxTokens: 8192,
41873
+ maxTokens: 64000,
41850
41874
  contextWindow: 200000,
41851
41875
  supportsImages: true,
41852
41876
  supportsComputerUse: true,
@@ -41967,6 +41991,7 @@ class AnthropicService extends AiServiceBase {
41967
41991
  temperature = undefined;
41968
41992
  }
41969
41993
  switch (modelId) {
41994
+ case "claude-sonnet-4-20250514":
41970
41995
  case "claude-3-7-sonnet-20250219":
41971
41996
  case "claude-3-5-sonnet-20241022":
41972
41997
  case "claude-3-5-haiku-20241022":
@@ -47499,70 +47524,31 @@ class OpenRouterService extends AiServiceBase {
47499
47524
  ...convertToOpenAiMessages(messages)
47500
47525
  ];
47501
47526
  const cacheControl = this.#options.enableCache ? { type: "ephemeral" } : undefined;
47502
- switch (this.model.id) {
47503
- case "anthropic/claude-3.7-sonnet:thinking":
47504
- case "anthropic/claude-3.7-sonnet":
47505
- case "anthropic/claude-3.7-sonnet:beta":
47506
- case "anthropic/claude-3-7-sonnet":
47507
- case "anthropic/claude-3-7-sonnet:beta":
47508
- case "anthropic/claude-3.5-sonnet":
47509
- case "anthropic/claude-3.5-sonnet:beta":
47510
- case "anthropic/claude-3.5-sonnet-20240620":
47511
- case "anthropic/claude-3.5-sonnet-20240620:beta":
47512
- case "anthropic/claude-3-5-haiku":
47513
- case "anthropic/claude-3-5-haiku:beta":
47514
- case "anthropic/claude-3-5-haiku-20241022":
47515
- case "anthropic/claude-3-5-haiku-20241022:beta":
47516
- case "anthropic/claude-3-haiku":
47517
- case "anthropic/claude-3-haiku:beta":
47518
- case "anthropic/claude-3-opus":
47519
- case "anthropic/claude-3-opus:beta": {
47520
- openAiMessages[0] = {
47521
- role: "system",
47522
- content: [
47523
- {
47524
- type: "text",
47525
- text: systemPrompt,
47526
- cache_control: cacheControl
47527
- }
47528
- ]
47529
- };
47530
- const lastTwoUserMessages = openAiMessages.filter((msg) => msg.role === "user").slice(-2);
47531
- for (const msg of lastTwoUserMessages) {
47532
- if (typeof msg.content === "string") {
47533
- msg.content = [{ type: "text", text: msg.content }];
47527
+ if (this.model.id.startsWith("anthropic/claude")) {
47528
+ openAiMessages[0] = {
47529
+ role: "system",
47530
+ content: [
47531
+ {
47532
+ type: "text",
47533
+ text: systemPrompt,
47534
+ cache_control: cacheControl
47534
47535
  }
47535
- if (Array.isArray(msg.content)) {
47536
- let lastTextPart = msg.content.filter((part) => part.type === "text").pop();
47537
- if (!lastTextPart) {
47538
- lastTextPart = { type: "text", text: "..." };
47539
- msg.content.push(lastTextPart);
47540
- }
47541
- lastTextPart.cache_control = cacheControl;
47536
+ ]
47537
+ };
47538
+ const lastTwoUserMessages = openAiMessages.filter((msg) => msg.role === "user").slice(-2);
47539
+ for (const msg of lastTwoUserMessages) {
47540
+ if (typeof msg.content === "string") {
47541
+ msg.content = [{ type: "text", text: msg.content }];
47542
+ }
47543
+ if (Array.isArray(msg.content)) {
47544
+ let lastTextPart = msg.content.filter((part) => part.type === "text").pop();
47545
+ if (!lastTextPart) {
47546
+ lastTextPart = { type: "text", text: "..." };
47547
+ msg.content.push(lastTextPart);
47542
47548
  }
47549
+ lastTextPart.cache_control = cacheControl;
47543
47550
  }
47544
- break;
47545
47551
  }
47546
- default:
47547
- break;
47548
- }
47549
- let maxTokens;
47550
- switch (this.model.id) {
47551
- case "anthropic/claude-3.7-sonnet:thinking":
47552
- case "anthropic/claude-3.7-sonnet":
47553
- case "anthropic/claude-3.7-sonnet:beta":
47554
- case "anthropic/claude-3-7-sonnet":
47555
- case "anthropic/claude-3-7-sonnet:beta":
47556
- case "anthropic/claude-3.5-sonnet":
47557
- case "anthropic/claude-3.5-sonnet:beta":
47558
- case "anthropic/claude-3.5-sonnet-20240620":
47559
- case "anthropic/claude-3.5-sonnet-20240620:beta":
47560
- case "anthropic/claude-3-5-haiku":
47561
- case "anthropic/claude-3-5-haiku:beta":
47562
- case "anthropic/claude-3-5-haiku-20241022":
47563
- case "anthropic/claude-3-5-haiku-20241022:beta":
47564
- maxTokens = 8192;
47565
- break;
47566
47552
  }
47567
47553
  let reasoning = {};
47568
47554
  switch (this.model.id) {
@@ -47570,7 +47556,9 @@ class OpenRouterService extends AiServiceBase {
47570
47556
  case "anthropic/claude-3.7-sonnet:beta":
47571
47557
  case "anthropic/claude-3.7-sonnet:thinking":
47572
47558
  case "anthropic/claude-3-7-sonnet":
47573
- case "anthropic/claude-3-7-sonnet:beta": {
47559
+ case "anthropic/claude-3-7-sonnet:beta":
47560
+ case "anthropic/claude-opus-4":
47561
+ case "anthropic/claude-sonnet-4": {
47574
47562
  const budget_tokens = this.#options.parameters.thinkingBudgetTokens || 0;
47575
47563
  if (budget_tokens > 0) {
47576
47564
  reasoning = { max_tokens: budget_tokens };
@@ -47584,7 +47572,6 @@ class OpenRouterService extends AiServiceBase {
47584
47572
  }
47585
47573
  const stream = await this.#client.chat.completions.create({
47586
47574
  model: this.model.id,
47587
- max_completion_tokens: maxTokens,
47588
47575
  messages: openAiMessages,
47589
47576
  temperature: 0,
47590
47577
  stream: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.8.15",
3
+ "version": "0.8.16",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",