@polka-codes/runner 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 +52 -65
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -32748,7 +32748,7 @@ var {
32748
32748
  Help
32749
32749
  } = import__.default;
32750
32750
  // package.json
32751
- var version = "0.8.15";
32751
+ var version = "0.8.16";
32752
32752
 
32753
32753
  // src/runner.ts
32754
32754
  import { execSync } from "node:child_process";
@@ -36155,8 +36155,32 @@ Anthropic.Beta = Beta;
36155
36155
  // ../core/src/AiService/ModelInfo.ts
36156
36156
  var anthropicDefaultModelId = "claude-3-7-sonnet-20250219";
36157
36157
  var anthropicModels = {
36158
+ "claude-opus-4-20250514": {
36159
+ maxTokens: 32000,
36160
+ contextWindow: 200000,
36161
+ supportsImages: true,
36162
+ supportsComputerUse: true,
36163
+ supportsPromptCache: true,
36164
+ inputPrice: 15,
36165
+ outputPrice: 75,
36166
+ cacheWritesPrice: 18.75,
36167
+ cacheReadsPrice: 1.5,
36168
+ reasoning: true
36169
+ },
36170
+ "claude-sonnet-4-20250514": {
36171
+ maxTokens: 64000,
36172
+ contextWindow: 200000,
36173
+ supportsImages: true,
36174
+ supportsComputerUse: true,
36175
+ supportsPromptCache: true,
36176
+ inputPrice: 3,
36177
+ outputPrice: 15,
36178
+ cacheWritesPrice: 3.75,
36179
+ cacheReadsPrice: 0.3,
36180
+ reasoning: true
36181
+ },
36158
36182
  "claude-3-7-sonnet-20250219": {
36159
- maxTokens: 8192,
36183
+ maxTokens: 64000,
36160
36184
  contextWindow: 200000,
36161
36185
  supportsImages: true,
36162
36186
  supportsComputerUse: true,
@@ -36277,6 +36301,7 @@ class AnthropicService extends AiServiceBase {
36277
36301
  temperature = undefined;
36278
36302
  }
36279
36303
  switch (modelId) {
36304
+ case "claude-sonnet-4-20250514":
36280
36305
  case "claude-3-7-sonnet-20250219":
36281
36306
  case "claude-3-5-sonnet-20241022":
36282
36307
  case "claude-3-5-haiku-20241022":
@@ -41809,70 +41834,31 @@ class OpenRouterService extends AiServiceBase {
41809
41834
  ...convertToOpenAiMessages(messages)
41810
41835
  ];
41811
41836
  const cacheControl = this.#options.enableCache ? { type: "ephemeral" } : undefined;
41812
- switch (this.model.id) {
41813
- case "anthropic/claude-3.7-sonnet:thinking":
41814
- case "anthropic/claude-3.7-sonnet":
41815
- case "anthropic/claude-3.7-sonnet:beta":
41816
- case "anthropic/claude-3-7-sonnet":
41817
- case "anthropic/claude-3-7-sonnet:beta":
41818
- case "anthropic/claude-3.5-sonnet":
41819
- case "anthropic/claude-3.5-sonnet:beta":
41820
- case "anthropic/claude-3.5-sonnet-20240620":
41821
- case "anthropic/claude-3.5-sonnet-20240620:beta":
41822
- case "anthropic/claude-3-5-haiku":
41823
- case "anthropic/claude-3-5-haiku:beta":
41824
- case "anthropic/claude-3-5-haiku-20241022":
41825
- case "anthropic/claude-3-5-haiku-20241022:beta":
41826
- case "anthropic/claude-3-haiku":
41827
- case "anthropic/claude-3-haiku:beta":
41828
- case "anthropic/claude-3-opus":
41829
- case "anthropic/claude-3-opus:beta": {
41830
- openAiMessages[0] = {
41831
- role: "system",
41832
- content: [
41833
- {
41834
- type: "text",
41835
- text: systemPrompt,
41836
- cache_control: cacheControl
41837
- }
41838
- ]
41839
- };
41840
- const lastTwoUserMessages = openAiMessages.filter((msg) => msg.role === "user").slice(-2);
41841
- for (const msg of lastTwoUserMessages) {
41842
- if (typeof msg.content === "string") {
41843
- msg.content = [{ type: "text", text: msg.content }];
41844
- }
41845
- if (Array.isArray(msg.content)) {
41846
- let lastTextPart = msg.content.filter((part) => part.type === "text").pop();
41847
- if (!lastTextPart) {
41848
- lastTextPart = { type: "text", text: "..." };
41849
- msg.content.push(lastTextPart);
41850
- }
41851
- lastTextPart.cache_control = cacheControl;
41837
+ if (this.model.id.startsWith("anthropic/claude")) {
41838
+ openAiMessages[0] = {
41839
+ role: "system",
41840
+ content: [
41841
+ {
41842
+ type: "text",
41843
+ text: systemPrompt,
41844
+ cache_control: cacheControl
41845
+ }
41846
+ ]
41847
+ };
41848
+ const lastTwoUserMessages = openAiMessages.filter((msg) => msg.role === "user").slice(-2);
41849
+ for (const msg of lastTwoUserMessages) {
41850
+ if (typeof msg.content === "string") {
41851
+ msg.content = [{ type: "text", text: msg.content }];
41852
+ }
41853
+ if (Array.isArray(msg.content)) {
41854
+ let lastTextPart = msg.content.filter((part) => part.type === "text").pop();
41855
+ if (!lastTextPart) {
41856
+ lastTextPart = { type: "text", text: "..." };
41857
+ msg.content.push(lastTextPart);
41852
41858
  }
41859
+ lastTextPart.cache_control = cacheControl;
41853
41860
  }
41854
- break;
41855
41861
  }
41856
- default:
41857
- break;
41858
- }
41859
- let maxTokens;
41860
- switch (this.model.id) {
41861
- case "anthropic/claude-3.7-sonnet:thinking":
41862
- case "anthropic/claude-3.7-sonnet":
41863
- case "anthropic/claude-3.7-sonnet:beta":
41864
- case "anthropic/claude-3-7-sonnet":
41865
- case "anthropic/claude-3-7-sonnet:beta":
41866
- case "anthropic/claude-3.5-sonnet":
41867
- case "anthropic/claude-3.5-sonnet:beta":
41868
- case "anthropic/claude-3.5-sonnet-20240620":
41869
- case "anthropic/claude-3.5-sonnet-20240620:beta":
41870
- case "anthropic/claude-3-5-haiku":
41871
- case "anthropic/claude-3-5-haiku:beta":
41872
- case "anthropic/claude-3-5-haiku-20241022":
41873
- case "anthropic/claude-3-5-haiku-20241022:beta":
41874
- maxTokens = 8192;
41875
- break;
41876
41862
  }
41877
41863
  let reasoning = {};
41878
41864
  switch (this.model.id) {
@@ -41880,7 +41866,9 @@ class OpenRouterService extends AiServiceBase {
41880
41866
  case "anthropic/claude-3.7-sonnet:beta":
41881
41867
  case "anthropic/claude-3.7-sonnet:thinking":
41882
41868
  case "anthropic/claude-3-7-sonnet":
41883
- case "anthropic/claude-3-7-sonnet:beta": {
41869
+ case "anthropic/claude-3-7-sonnet:beta":
41870
+ case "anthropic/claude-opus-4":
41871
+ case "anthropic/claude-sonnet-4": {
41884
41872
  const budget_tokens = this.#options.parameters.thinkingBudgetTokens || 0;
41885
41873
  if (budget_tokens > 0) {
41886
41874
  reasoning = { max_tokens: budget_tokens };
@@ -41894,7 +41882,6 @@ class OpenRouterService extends AiServiceBase {
41894
41882
  }
41895
41883
  const stream = await this.#client.chat.completions.create({
41896
41884
  model: this.model.id,
41897
- max_completion_tokens: maxTokens,
41898
41885
  messages: openAiMessages,
41899
41886
  temperature: 0,
41900
41887
  stream: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/runner",
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",