@polka-codes/core 0.6.7 → 0.6.8
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 +82 -50
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2921,8 +2921,19 @@ class AiServiceBase {
|
|
|
2921
2921
|
}
|
|
2922
2922
|
|
|
2923
2923
|
// src/AiService/ModelInfo.ts
|
|
2924
|
-
var anthropicDefaultModelId = "claude-3-
|
|
2924
|
+
var anthropicDefaultModelId = "claude-3-7-sonnet-20250219";
|
|
2925
2925
|
var anthropicModels = {
|
|
2926
|
+
"claude-3-7-sonnet-20250219": {
|
|
2927
|
+
maxTokens: 8192,
|
|
2928
|
+
contextWindow: 200000,
|
|
2929
|
+
supportsImages: true,
|
|
2930
|
+
supportsComputerUse: true,
|
|
2931
|
+
supportsPromptCache: true,
|
|
2932
|
+
inputPrice: 3,
|
|
2933
|
+
outputPrice: 15,
|
|
2934
|
+
cacheWritesPrice: 3.75,
|
|
2935
|
+
cacheReadsPrice: 0.3
|
|
2936
|
+
},
|
|
2926
2937
|
"claude-3-5-sonnet-20241022": {
|
|
2927
2938
|
maxTokens: 8192,
|
|
2928
2939
|
contextWindow: 200000,
|
|
@@ -3020,6 +3031,7 @@ class AnthropicService extends AiServiceBase {
|
|
|
3020
3031
|
const modelId = this.model.id;
|
|
3021
3032
|
const cacheControl = this.#options.enableCache ? { type: "ephemeral" } : undefined;
|
|
3022
3033
|
switch (modelId) {
|
|
3034
|
+
case "claude-3-7-sonnet-20250219":
|
|
3023
3035
|
case "claude-3-5-sonnet-20241022":
|
|
3024
3036
|
case "claude-3-5-haiku-20241022":
|
|
3025
3037
|
case "claude-3-opus-20240229":
|
|
@@ -7988,6 +8000,11 @@ class OpenRouterService extends AiServiceBase {
|
|
|
7988
8000
|
];
|
|
7989
8001
|
const cacheControl = this.#options.enableCache ? { type: "ephemeral" } : undefined;
|
|
7990
8002
|
switch (this.model.id) {
|
|
8003
|
+
case "anthropic/claude-3.7-sonnet:thinking":
|
|
8004
|
+
case "anthropic/claude-3.7-sonnet":
|
|
8005
|
+
case "anthropic/claude-3.7-sonnet:beta":
|
|
8006
|
+
case "anthropic/claude-3-7-sonnet":
|
|
8007
|
+
case "anthropic/claude-3-7-sonnet:beta":
|
|
7991
8008
|
case "anthropic/claude-3.5-sonnet":
|
|
7992
8009
|
case "anthropic/claude-3.5-sonnet:beta":
|
|
7993
8010
|
case "anthropic/claude-3.5-sonnet-20240620":
|
|
@@ -8031,6 +8048,11 @@ class OpenRouterService extends AiServiceBase {
|
|
|
8031
8048
|
}
|
|
8032
8049
|
let maxTokens;
|
|
8033
8050
|
switch (this.model.id) {
|
|
8051
|
+
case "anthropic/claude-3.7-sonnet:thinking":
|
|
8052
|
+
case "anthropic/claude-3.7-sonnet":
|
|
8053
|
+
case "anthropic/claude-3.7-sonnet:beta":
|
|
8054
|
+
case "anthropic/claude-3-7-sonnet":
|
|
8055
|
+
case "anthropic/claude-3-7-sonnet:beta":
|
|
8034
8056
|
case "anthropic/claude-3.5-sonnet":
|
|
8035
8057
|
case "anthropic/claude-3.5-sonnet:beta":
|
|
8036
8058
|
case "anthropic/claude-3.5-sonnet-20240620":
|
|
@@ -8169,10 +8191,10 @@ var AiServiceProvider;
|
|
|
8169
8191
|
AiServiceProvider2["OpenRouter"] = "openrouter";
|
|
8170
8192
|
})(AiServiceProvider ||= {});
|
|
8171
8193
|
var defaultModels = {
|
|
8172
|
-
["anthropic" /* Anthropic */]: "claude-3-
|
|
8194
|
+
["anthropic" /* Anthropic */]: "claude-3-7-sonnet-20250219",
|
|
8173
8195
|
["ollama" /* Ollama */]: "maryasov/qwen2.5-coder-cline:7b",
|
|
8174
8196
|
["deepseek" /* DeepSeek */]: "deepseek-chat",
|
|
8175
|
-
["openrouter" /* OpenRouter */]: "anthropic/claude-3.
|
|
8197
|
+
["openrouter" /* OpenRouter */]: "anthropic/claude-3.7-sonnet"
|
|
8176
8198
|
};
|
|
8177
8199
|
var createService = (provider, options) => {
|
|
8178
8200
|
switch (provider) {
|
|
@@ -9250,9 +9272,16 @@ var renameFile_default = {
|
|
|
9250
9272
|
isAvailable: isAvailable13
|
|
9251
9273
|
};
|
|
9252
9274
|
// src/getAvailableTools.ts
|
|
9253
|
-
var getAvailableTools = (
|
|
9275
|
+
var getAvailableTools = ({
|
|
9276
|
+
provider: provider2,
|
|
9277
|
+
allTools: allTools2,
|
|
9278
|
+
hasAgent,
|
|
9279
|
+
permissionLevel,
|
|
9280
|
+
interactive
|
|
9281
|
+
}) => {
|
|
9282
|
+
const filteredTools = interactive ? allTools2 : allTools2.filter((tool) => tool.name !== askFollowupQuestion_default.name);
|
|
9254
9283
|
const tools = [];
|
|
9255
|
-
for (const tool of
|
|
9284
|
+
for (const tool of filteredTools) {
|
|
9256
9285
|
if (!hasAgent) {
|
|
9257
9286
|
switch (tool.name) {
|
|
9258
9287
|
case handOver_default.name:
|
|
@@ -9384,6 +9413,8 @@ For example:
|
|
|
9384
9413
|
|
|
9385
9414
|
Always adhere to this format for the tool use to ensure proper parsing and execution.
|
|
9386
9415
|
|
|
9416
|
+
NEVER surround tool use with triple backticks (\`\`\`).
|
|
9417
|
+
|
|
9387
9418
|
# Tools
|
|
9388
9419
|
${tools.map((tool) => toolInfoPrompt(tool, toolNamePrefix, parameterPrefix)).join(`
|
|
9389
9420
|
`)}
|
|
@@ -9424,7 +9455,7 @@ var agentsPrompt = (agents, name) => `
|
|
|
9424
9455
|
|
|
9425
9456
|
AVAILABLE AGENTS
|
|
9426
9457
|
|
|
9427
|
-
The following agents are available for task handover:
|
|
9458
|
+
The following agents are available for task handover/delegate:
|
|
9428
9459
|
${agents.map((agent) => `
|
|
9429
9460
|
- **${agent.name}**
|
|
9430
9461
|
- Responsibilities:
|
|
@@ -9433,7 +9464,7 @@ ${agent.responsibilities.map((resp) => ` - ${resp}`).join(`
|
|
|
9433
9464
|
`)}
|
|
9434
9465
|
|
|
9435
9466
|
- **Current Agent Role**
|
|
9436
|
-
You are currently acting as **${name}**. If you identify the task is beyond your current scope, use the handover tool to transition to the other agent. Include sufficient context so the new agent can seamlessly continue the work.
|
|
9467
|
+
You are currently acting as **${name}**. If you identify the task is beyond your current scope, use the handover or delegate tool to transition to the other agent. Include sufficient context so the new agent can seamlessly continue the work.
|
|
9437
9468
|
`;
|
|
9438
9469
|
var capabilities = (toolNamePrefix) => `
|
|
9439
9470
|
====
|
|
@@ -9448,24 +9479,6 @@ var systemInformation = (info) => `
|
|
|
9448
9479
|
SYSTEM INFORMATION
|
|
9449
9480
|
|
|
9450
9481
|
Operating System: ${info.os}`;
|
|
9451
|
-
var interactiveMode = (interactive) => {
|
|
9452
|
-
if (interactive) {
|
|
9453
|
-
return `
|
|
9454
|
-
====
|
|
9455
|
-
|
|
9456
|
-
INTERACTIVE MODE
|
|
9457
|
-
|
|
9458
|
-
You are in interactive mode. This means you may ask user questions to gather additional information to complete the task.
|
|
9459
|
-
`;
|
|
9460
|
-
}
|
|
9461
|
-
return `
|
|
9462
|
-
====
|
|
9463
|
-
|
|
9464
|
-
NON-INTERACTIVE MODE
|
|
9465
|
-
|
|
9466
|
-
You are in non-interactive mode. This means you will not be able to ask user questions to gather additional information to complete the task. You should try to use available tools to accomplish the task. If unable to precede further, you may try to end the task and provide a reason.
|
|
9467
|
-
`;
|
|
9468
|
-
};
|
|
9469
9482
|
var customInstructions = (customInstructions2) => {
|
|
9470
9483
|
const joined = customInstructions2.join(`
|
|
9471
9484
|
`);
|
|
@@ -9744,7 +9757,7 @@ ${agents}`;
|
|
|
9744
9757
|
}
|
|
9745
9758
|
|
|
9746
9759
|
// src/Agent/AnalyzerAgent/prompts.ts
|
|
9747
|
-
var fullSystemPrompt = (info, tools, toolNamePrefix, instructions, scripts
|
|
9760
|
+
var fullSystemPrompt = (info, tools, toolNamePrefix, instructions, scripts) => `
|
|
9748
9761
|
# Analyzer Agent
|
|
9749
9762
|
|
|
9750
9763
|
## Role
|
|
@@ -9770,18 +9783,23 @@ ${capabilities(toolNamePrefix)}
|
|
|
9770
9783
|
${systemInformation(info)}
|
|
9771
9784
|
${customInstructions(instructions)}
|
|
9772
9785
|
${customScripts(scripts)}
|
|
9773
|
-
${interactiveMode(interactive)}
|
|
9774
9786
|
`;
|
|
9775
9787
|
|
|
9776
9788
|
// src/Agent/AnalyzerAgent/index.ts
|
|
9777
9789
|
class AnalyzerAgent extends AgentBase {
|
|
9778
9790
|
constructor(options) {
|
|
9779
9791
|
const combinedTools = [...options.additionalTools ?? [], ...Object.values(exports_allTools)];
|
|
9780
|
-
const tools = getAvailableTools(
|
|
9792
|
+
const tools = getAvailableTools({
|
|
9793
|
+
provider: options.provider,
|
|
9794
|
+
allTools: combinedTools,
|
|
9795
|
+
hasAgent: (options.agents?.length ?? 0) > 0,
|
|
9796
|
+
permissionLevel: 1 /* Read */,
|
|
9797
|
+
interactive: true
|
|
9798
|
+
});
|
|
9781
9799
|
const toolNamePrefix = "tool_";
|
|
9782
9800
|
const systemPrompt = fullSystemPrompt({
|
|
9783
9801
|
os: options.os
|
|
9784
|
-
}, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}
|
|
9802
|
+
}, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {});
|
|
9785
9803
|
super(analyzerAgentInfo.name, options.ai, {
|
|
9786
9804
|
systemPrompt,
|
|
9787
9805
|
tools,
|
|
@@ -9809,7 +9827,7 @@ var analyzerAgentInfo = {
|
|
|
9809
9827
|
};
|
|
9810
9828
|
|
|
9811
9829
|
// src/Agent/ArchitectAgent/prompts.ts
|
|
9812
|
-
var fullSystemPrompt2 = (info, tools, toolNamePrefix, instructions, scripts
|
|
9830
|
+
var fullSystemPrompt2 = (info, tools, toolNamePrefix, instructions, scripts) => `
|
|
9813
9831
|
# Architect Agent
|
|
9814
9832
|
|
|
9815
9833
|
## Role
|
|
@@ -9847,31 +9865,37 @@ You are the **Architect** agent, responsible for:
|
|
|
9847
9865
|
4. **Create Implementation Plan**
|
|
9848
9866
|
- Outline tasks, define milestones, and detail resources or dependencies.
|
|
9849
9867
|
- Provide clear, concise instructions for each step.
|
|
9868
|
+
- Each step should be appropriate sized and self-contained.
|
|
9850
9869
|
|
|
9851
|
-
5. **
|
|
9852
|
-
-
|
|
9853
|
-
-
|
|
9854
|
-
|
|
9855
|
-
6. **Handover/Delegate**
|
|
9870
|
+
5. **Handover/Delegate**
|
|
9871
|
+
- Evaluate the number of steps required.
|
|
9872
|
+
- Handleover to the **Coder** agent if only one step is required.
|
|
9873
|
+
- If multiple steps are required, delegate each step to the **Coder** agent.
|
|
9856
9874
|
- Deliver the final implementation plan, context, and relevant files to the **Coder** agent.
|
|
9857
9875
|
- Provide any additional instructions or clarifications needed for successful implementation.
|
|
9876
|
+
|
|
9858
9877
|
${toolUsePrompt(tools, toolNamePrefix)}
|
|
9859
9878
|
${capabilities(toolNamePrefix)}
|
|
9860
9879
|
${systemInformation(info)}
|
|
9861
9880
|
${customInstructions(instructions)}
|
|
9862
9881
|
${customScripts(scripts)}
|
|
9863
|
-
${interactiveMode(interactive)}
|
|
9864
9882
|
`;
|
|
9865
9883
|
|
|
9866
9884
|
// src/Agent/ArchitectAgent/index.ts
|
|
9867
9885
|
class ArchitectAgent extends AgentBase {
|
|
9868
9886
|
constructor(options) {
|
|
9869
9887
|
const combinedTools = [...options.additionalTools ?? [], ...Object.values(exports_allTools)];
|
|
9870
|
-
const tools = getAvailableTools(
|
|
9888
|
+
const tools = getAvailableTools({
|
|
9889
|
+
provider: options.provider,
|
|
9890
|
+
allTools: combinedTools,
|
|
9891
|
+
hasAgent: (options.agents?.length ?? 0) > 0,
|
|
9892
|
+
permissionLevel: 1 /* Read */,
|
|
9893
|
+
interactive: true
|
|
9894
|
+
});
|
|
9871
9895
|
const toolNamePrefix = "tool_";
|
|
9872
9896
|
const systemPrompt = fullSystemPrompt2({
|
|
9873
9897
|
os: options.os
|
|
9874
|
-
}, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}
|
|
9898
|
+
}, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {});
|
|
9875
9899
|
super(architectAgentInfo.name, options.ai, {
|
|
9876
9900
|
systemPrompt,
|
|
9877
9901
|
tools,
|
|
@@ -9971,8 +9995,7 @@ ${retryGuidelines}
|
|
|
9971
9995
|
${capabilities(toolNamePrefix)}
|
|
9972
9996
|
${systemInformation(info)}
|
|
9973
9997
|
${customInstructions(instructions)}
|
|
9974
|
-
${customScripts(scripts)}
|
|
9975
|
-
${interactiveMode(interactive)}`;
|
|
9998
|
+
${customScripts(scripts)}`;
|
|
9976
9999
|
|
|
9977
10000
|
// src/Agent/CodeFixerAgent/index.ts
|
|
9978
10001
|
class CodeFixerAgent extends AgentBase {
|
|
@@ -9980,7 +10003,13 @@ class CodeFixerAgent extends AgentBase {
|
|
|
9980
10003
|
#retryCount = 0;
|
|
9981
10004
|
constructor(options) {
|
|
9982
10005
|
const combinedTools = [...options.additionalTools ?? [], ...Object.values(exports_allTools)];
|
|
9983
|
-
const tools = getAvailableTools(
|
|
10006
|
+
const tools = getAvailableTools({
|
|
10007
|
+
provider: options.provider,
|
|
10008
|
+
allTools: combinedTools,
|
|
10009
|
+
hasAgent: (options.agents?.length ?? 0) > 0,
|
|
10010
|
+
permissionLevel: 3 /* Arbitrary */,
|
|
10011
|
+
interactive: true
|
|
10012
|
+
});
|
|
9984
10013
|
const toolNamePrefix = "tool_";
|
|
9985
10014
|
const systemPrompt = fullSystemPrompt3({
|
|
9986
10015
|
os: options.os
|
|
@@ -10138,7 +10167,9 @@ RULES
|
|
|
10138
10167
|
- When presented with images, utilize your vision capabilities to thoroughly examine them and extract meaningful information. Incorporate these insights into your thought process as you accomplish the user's task.
|
|
10139
10168
|
- When using the ${toolNamePrefix}replace_in_file tool, you must include complete lines in your SEARCH blocks, not partial lines. The system requires exact line matches and cannot match partial lines. For example, if you want to match a line containing "const x = 5;", your SEARCH block must include the entire line, not just "x = 5" or other fragments.
|
|
10140
10169
|
- When using the ${toolNamePrefix}replace_in_file tool, if you use multiple SEARCH/REPLACE blocks, list them in the order they appear in the file. For example if you need to make changes to both line 10 and line 50, first include the SEARCH/REPLACE block for line 10, followed by the SEARCH/REPLACE block for line 50.
|
|
10141
|
-
- It is critical you wait for the user's response after each tool use, in order to confirm the success of the tool use. For example, if asked to make a todo app, you would create a file, wait for the user's response it was created successfully, then create another file if needed, wait for the user's response it was created successfully, etc
|
|
10170
|
+
- It is critical you wait for the user's response after each tool use, in order to confirm the success of the tool use. For example, if asked to make a todo app, you would create a file, wait for the user's response it was created successfully, then create another file if needed, wait for the user's response it was created successfully, etc.
|
|
10171
|
+
- Keep the inline docs up to date if needed.
|
|
10172
|
+
`;
|
|
10142
10173
|
var objectives = (toolNamePrefix) => `
|
|
10143
10174
|
====
|
|
10144
10175
|
|
|
@@ -10151,7 +10182,7 @@ You accomplish a given task iteratively, breaking it down into clear steps and w
|
|
|
10151
10182
|
3. Remember, you have extensive capabilities with access to a wide range of tools that can be used in powerful and clever ways as necessary to accomplish each goal. Before calling a tool, do some analysis within <thinking></thinking> tags. First, analyze the file structure provided in environment_details to gain context and insights for proceeding effectively. Then, think about which of the provided tools is the most relevant tool to accomplish the user's task. Next, go through each of the required parameters of the relevant tool and determine if the user has directly provided or given enough information to infer a value. When deciding if the parameter can be inferred, carefully consider all the context to see if it supports a specific value. If all of the required parameters are present or can be reasonably inferred, close the thinking tag and proceed with the tool use.
|
|
10152
10183
|
4. Once you've completed the user's task, you must use the ${toolNamePrefix}attempt_completion tool to present the result of the task to the user.
|
|
10153
10184
|
5. The user may provide feedback, which you can use to make improvements and try again. But DO NOT continue in pointless back and forth conversations, i.e. don't end your responses with questions or offers for further assistance.`;
|
|
10154
|
-
var fullSystemPrompt4 = (info, tools, toolNamePrefix, instructions, scripts
|
|
10185
|
+
var fullSystemPrompt4 = (info, tools, toolNamePrefix, instructions, scripts) => `
|
|
10155
10186
|
${basePrompt2}
|
|
10156
10187
|
${toolUsePrompt(tools, toolNamePrefix)}
|
|
10157
10188
|
${editingFilesPrompt(toolNamePrefix)}
|
|
@@ -10161,18 +10192,23 @@ ${objectives(toolNamePrefix)}
|
|
|
10161
10192
|
${systemInformation(info)}
|
|
10162
10193
|
${customInstructions(instructions)}
|
|
10163
10194
|
${customScripts(scripts)}
|
|
10164
|
-
${interactiveMode(interactive)}
|
|
10165
10195
|
`;
|
|
10166
10196
|
|
|
10167
10197
|
// src/Agent/CoderAgent/index.ts
|
|
10168
10198
|
class CoderAgent extends AgentBase {
|
|
10169
10199
|
constructor(options) {
|
|
10170
10200
|
const combinedTools = [...options.additionalTools ?? [], ...Object.values(exports_allTools)];
|
|
10171
|
-
const tools = getAvailableTools(
|
|
10201
|
+
const tools = getAvailableTools({
|
|
10202
|
+
provider: options.provider,
|
|
10203
|
+
allTools: combinedTools,
|
|
10204
|
+
hasAgent: (options.agents?.length ?? 0) > 0,
|
|
10205
|
+
permissionLevel: 3 /* Arbitrary */,
|
|
10206
|
+
interactive: true
|
|
10207
|
+
});
|
|
10172
10208
|
const toolNamePrefix = "tool_";
|
|
10173
10209
|
const systemPrompt = fullSystemPrompt4({
|
|
10174
10210
|
os: options.os
|
|
10175
|
-
}, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}
|
|
10211
|
+
}, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {});
|
|
10176
10212
|
super(coderAgentInfo.name, options.ai, {
|
|
10177
10213
|
systemPrompt,
|
|
10178
10214
|
tools,
|
|
@@ -10390,7 +10426,6 @@ You will produce a single commit message enclosed within <tool_output> tags. The
|
|
|
10390
10426
|
|
|
10391
10427
|
Here’s an example of the input and the expected output format:
|
|
10392
10428
|
|
|
10393
|
-
\`\`\`
|
|
10394
10429
|
<tool_input>
|
|
10395
10430
|
--- a/example_file.py
|
|
10396
10431
|
+++ b/example_file.py
|
|
@@ -10401,15 +10436,12 @@ Here’s an example of the input and the expected output format:
|
|
|
10401
10436
|
<tool_input_context>
|
|
10402
10437
|
Changing print statement to update the user-facing message.
|
|
10403
10438
|
</tool_input_context>
|
|
10404
|
-
\`\`\`
|
|
10405
10439
|
|
|
10406
10440
|
Example Output:
|
|
10407
10441
|
|
|
10408
|
-
\`\`\`
|
|
10409
10442
|
<tool_output>
|
|
10410
10443
|
Update print statement for revised user-facing message
|
|
10411
10444
|
</tool_output>
|
|
10412
|
-
\`\`\`
|
|
10413
10445
|
|
|
10414
10446
|
Follow the same structure for any new input. Never repeat questions; focus on generating a concise commit message that captures the essence of the changes.
|
|
10415
10447
|
`;
|