@polka-codes/runner 0.8.15 → 0.8.17
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 +87 -100
- 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.
|
|
32751
|
+
var version = "0.8.17";
|
|
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:
|
|
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
|
-
|
|
41813
|
-
|
|
41814
|
-
|
|
41815
|
-
|
|
41816
|
-
|
|
41817
|
-
|
|
41818
|
-
|
|
41819
|
-
|
|
41820
|
-
|
|
41821
|
-
|
|
41822
|
-
|
|
41823
|
-
|
|
41824
|
-
|
|
41825
|
-
|
|
41826
|
-
|
|
41827
|
-
|
|
41828
|
-
|
|
41829
|
-
|
|
41830
|
-
|
|
41831
|
-
|
|
41832
|
-
|
|
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,
|
|
@@ -42078,41 +42065,41 @@ var editFile = async (fileContent, operations) => {
|
|
|
42078
42065
|
return updatedContent;
|
|
42079
42066
|
};
|
|
42080
42067
|
async function applyEditOperation(fileContent, operation, originalLines) {
|
|
42081
|
-
const {
|
|
42082
|
-
if (
|
|
42068
|
+
const { start_anchor, end_anchor, new_text, start_anchor_line_start, end_anchor_line_start } = operation;
|
|
42069
|
+
if (start_anchor === START_OF_FILE && end_anchor === END_OF_FILE) {
|
|
42083
42070
|
return new_text;
|
|
42084
42071
|
}
|
|
42085
|
-
if (
|
|
42086
|
-
if (!
|
|
42072
|
+
if (start_anchor === START_OF_FILE) {
|
|
42073
|
+
if (!end_anchor) {
|
|
42087
42074
|
return new_text + fileContent;
|
|
42088
42075
|
}
|
|
42089
|
-
const afterIndex = findTextWithHint(fileContent,
|
|
42076
|
+
const afterIndex = findTextWithHint(fileContent, end_anchor, end_anchor_line_start, originalLines);
|
|
42090
42077
|
return new_text + fileContent.slice(afterIndex);
|
|
42091
42078
|
}
|
|
42092
|
-
if (
|
|
42093
|
-
if (!
|
|
42079
|
+
if (end_anchor === END_OF_FILE) {
|
|
42080
|
+
if (!start_anchor) {
|
|
42094
42081
|
return fileContent + new_text;
|
|
42095
42082
|
}
|
|
42096
|
-
const beforeIndex = findTextWithHint(fileContent,
|
|
42097
|
-
const beforeEndIndex = beforeIndex +
|
|
42083
|
+
const beforeIndex = findTextWithHint(fileContent, start_anchor, start_anchor_line_start, originalLines);
|
|
42084
|
+
const beforeEndIndex = beforeIndex + start_anchor.length;
|
|
42098
42085
|
return fileContent.slice(0, beforeEndIndex) + new_text;
|
|
42099
42086
|
}
|
|
42100
|
-
if (
|
|
42101
|
-
const beforeIndex = findTextWithHint(fileContent,
|
|
42102
|
-
const beforeEndIndex = beforeIndex +
|
|
42103
|
-
const afterIndex = findTextWithHint(fileContent,
|
|
42087
|
+
if (start_anchor && end_anchor) {
|
|
42088
|
+
const beforeIndex = findTextWithHint(fileContent, start_anchor, start_anchor_line_start, originalLines);
|
|
42089
|
+
const beforeEndIndex = beforeIndex + start_anchor.length;
|
|
42090
|
+
const afterIndex = findTextWithHint(fileContent, end_anchor, end_anchor_line_start, originalLines, beforeEndIndex);
|
|
42104
42091
|
return fileContent.slice(0, beforeEndIndex) + new_text + fileContent.slice(afterIndex);
|
|
42105
42092
|
}
|
|
42106
|
-
if (
|
|
42107
|
-
const beforeIndex = findTextWithHint(fileContent,
|
|
42108
|
-
const beforeEndIndex = beforeIndex +
|
|
42093
|
+
if (start_anchor) {
|
|
42094
|
+
const beforeIndex = findTextWithHint(fileContent, start_anchor, start_anchor_line_start, originalLines);
|
|
42095
|
+
const beforeEndIndex = beforeIndex + start_anchor.length;
|
|
42109
42096
|
return fileContent.slice(0, beforeEndIndex) + new_text + fileContent.slice(beforeEndIndex);
|
|
42110
42097
|
}
|
|
42111
|
-
if (
|
|
42112
|
-
const afterIndex = findTextWithHint(fileContent,
|
|
42098
|
+
if (end_anchor) {
|
|
42099
|
+
const afterIndex = findTextWithHint(fileContent, end_anchor, end_anchor_line_start, originalLines);
|
|
42113
42100
|
return fileContent.slice(0, afterIndex) + new_text + fileContent.slice(afterIndex);
|
|
42114
42101
|
}
|
|
42115
|
-
throw new Error("Either
|
|
42102
|
+
throw new Error("Either start_anchor or end_anchor must be specified");
|
|
42116
42103
|
}
|
|
42117
42104
|
function findTextWithHint(content, searchText, lineHint, originalLines, startIndex = 0) {
|
|
42118
42105
|
if (lineHint && lineHint > 0 && lineHint <= originalLines.length) {
|
|
@@ -43333,37 +43320,37 @@ var toolInfo13 = {
|
|
|
43333
43320
|
},
|
|
43334
43321
|
{
|
|
43335
43322
|
name: "operations",
|
|
43336
|
-
description: "Edit operation with
|
|
43323
|
+
description: "Edit operation with start_anchor, end_anchor, new_text, and optional line range hints",
|
|
43337
43324
|
required: true,
|
|
43338
43325
|
allowMultiple: true,
|
|
43339
43326
|
children: [
|
|
43340
43327
|
{
|
|
43341
|
-
name: "
|
|
43328
|
+
name: "start_anchor",
|
|
43342
43329
|
description: `Text to find as the start anchor (use ${START_OF_FILE} for file start)`,
|
|
43343
43330
|
required: false,
|
|
43344
43331
|
usageValue: "Text before the edit location"
|
|
43345
43332
|
},
|
|
43346
43333
|
{
|
|
43347
|
-
name: "
|
|
43334
|
+
name: "end_anchor",
|
|
43348
43335
|
description: `Text to find as the end anchor (use ${END_OF_FILE} for file end)`,
|
|
43349
43336
|
required: false,
|
|
43350
43337
|
usageValue: "Text after the edit location"
|
|
43351
43338
|
},
|
|
43352
43339
|
{
|
|
43353
43340
|
name: "new_text",
|
|
43354
|
-
description: "Text to replace the content between
|
|
43341
|
+
description: "Text to replace the content between start_anchor and end_anchor",
|
|
43355
43342
|
required: true,
|
|
43356
43343
|
usageValue: "New text content"
|
|
43357
43344
|
},
|
|
43358
43345
|
{
|
|
43359
|
-
name: "
|
|
43360
|
-
description: "Optional line number hint for
|
|
43346
|
+
name: "start_anchor_line_start",
|
|
43347
|
+
description: "Optional line number hint for start_anchor location (1-based)",
|
|
43361
43348
|
required: false,
|
|
43362
43349
|
usageValue: "10"
|
|
43363
43350
|
},
|
|
43364
43351
|
{
|
|
43365
|
-
name: "
|
|
43366
|
-
description: "Optional line number hint for
|
|
43352
|
+
name: "end_anchor_line_start",
|
|
43353
|
+
description: "Optional line number hint for end_anchor location (1-based)",
|
|
43367
43354
|
required: false,
|
|
43368
43355
|
usageValue: "20"
|
|
43369
43356
|
}
|
|
@@ -43382,8 +43369,8 @@ var toolInfo13 = {
|
|
|
43382
43369
|
{
|
|
43383
43370
|
name: "operations",
|
|
43384
43371
|
value: {
|
|
43385
|
-
|
|
43386
|
-
|
|
43372
|
+
start_anchor: "function oldFunction() {",
|
|
43373
|
+
end_anchor: "}",
|
|
43387
43374
|
new_text: `
|
|
43388
43375
|
return "new implementation";
|
|
43389
43376
|
`
|
|
@@ -43401,8 +43388,8 @@ var toolInfo13 = {
|
|
|
43401
43388
|
{
|
|
43402
43389
|
name: "operations",
|
|
43403
43390
|
value: {
|
|
43404
|
-
|
|
43405
|
-
|
|
43391
|
+
start_anchor: START_OF_FILE,
|
|
43392
|
+
end_anchor: "export",
|
|
43406
43393
|
new_text: `// File header comment
|
|
43407
43394
|
`
|
|
43408
43395
|
}
|
|
@@ -43420,13 +43407,13 @@ var toolInfo13 = {
|
|
|
43420
43407
|
name: "operations",
|
|
43421
43408
|
value: [
|
|
43422
43409
|
{
|
|
43423
|
-
|
|
43424
|
-
|
|
43410
|
+
start_anchor: "import React",
|
|
43411
|
+
end_anchor: 'from "react"',
|
|
43425
43412
|
new_text: ", { useState }"
|
|
43426
43413
|
},
|
|
43427
43414
|
{
|
|
43428
|
-
|
|
43429
|
-
|
|
43415
|
+
start_anchor: "function Component() {",
|
|
43416
|
+
end_anchor: "return (",
|
|
43430
43417
|
new_text: `
|
|
43431
43418
|
const [state, setState] = useState(false);
|
|
43432
43419
|
`
|