@polka-codes/core 0.8.23 → 0.8.24
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/_tsup-dts-rollup.d.ts +20 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +32 -12
- package/package.json +1 -1
|
@@ -11,16 +11,16 @@ declare abstract class AgentBase {
|
|
|
11
11
|
get parameters(): Readonly<any>;
|
|
12
12
|
get messages(): Readonly<MessageParam[]>;
|
|
13
13
|
setMessages(messages: Readonly<MessageParam[]>): void;
|
|
14
|
-
start(prompt:
|
|
15
|
-
step(prompt:
|
|
14
|
+
start(prompt: UserContent): Promise<ExitReason>;
|
|
15
|
+
step(prompt: UserContent): Promise<AssistantMessageContent[]>;
|
|
16
16
|
handleStepResponse(response: AssistantMessageContent[]): Promise<{
|
|
17
17
|
type: "reply";
|
|
18
|
-
message:
|
|
18
|
+
message: UserContent;
|
|
19
19
|
} | {
|
|
20
20
|
type: "exit";
|
|
21
21
|
reason: ExitReason;
|
|
22
22
|
}>;
|
|
23
|
-
continueTask(userMessage:
|
|
23
|
+
continueTask(userMessage: UserContent): Promise<ExitReason>;
|
|
24
24
|
protected abstract onBeforeInvokeTool(name: string, args: Record<string, string>): Promise<ToolResponse | undefined>;
|
|
25
25
|
get model(): {
|
|
26
26
|
provider: string;
|
|
@@ -1061,7 +1061,7 @@ export { _default_10 as updateKnowledge_alias_2 }
|
|
|
1061
1061
|
declare const _default_11: {
|
|
1062
1062
|
handler: ToolHandler<{
|
|
1063
1063
|
readonly name: "write_to_file";
|
|
1064
|
-
readonly description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `<
|
|
1064
|
+
readonly description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `<`, `>`, or `&`. Also ensure there is no unwanted CDATA tags in the content.";
|
|
1065
1065
|
readonly parameters: [{
|
|
1066
1066
|
readonly name: "path";
|
|
1067
1067
|
readonly description: "The path of the file to write to";
|
|
@@ -1087,7 +1087,7 @@ declare const _default_11: {
|
|
|
1087
1087
|
}, FilesystemProvider>;
|
|
1088
1088
|
isAvailable: (provider: FilesystemProvider) => boolean;
|
|
1089
1089
|
name: "write_to_file";
|
|
1090
|
-
description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `<
|
|
1090
|
+
description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `<`, `>`, or `&`. Also ensure there is no unwanted CDATA tags in the content.";
|
|
1091
1091
|
parameters: [{
|
|
1092
1092
|
readonly name: "path";
|
|
1093
1093
|
readonly description: "The path of the file to write to";
|
|
@@ -2111,6 +2111,8 @@ export declare const handler_alias_8: ToolHandler<typeof toolInfo_alias_8, Files
|
|
|
2111
2111
|
|
|
2112
2112
|
export declare const handler_alias_9: ToolHandler<typeof toolInfo_alias_9, FilesystemProvider>;
|
|
2113
2113
|
|
|
2114
|
+
export declare type ImageBlockParam = Anthropic.Messages.ImageBlockParam;
|
|
2115
|
+
|
|
2114
2116
|
declare type Input = {
|
|
2115
2117
|
commitMessages: string;
|
|
2116
2118
|
commitDiff: string;
|
|
@@ -2613,7 +2615,7 @@ export { replaceInFile_2 as replaceInFile_alias_4 }
|
|
|
2613
2615
|
declare const responsePrompts: {
|
|
2614
2616
|
readonly errorInvokeTool: (tool: string, error: unknown) => string;
|
|
2615
2617
|
readonly requireUseTool: "Error: No tool use detected. You MUST use a tool before proceeding.\ne.g. <tool_tool_name>tool_name</tool_tool_name>\n\nEnsure the opening and closing tags are correctly nested and closed, and that you are using the correct tool name.\nAvoid unnecessary text or symbols before or after the tool use.\nAvoid unnecessary escape characters or special characters.\n";
|
|
2616
|
-
readonly toolResults: (tool: string, result:
|
|
2618
|
+
readonly toolResults: (tool: string, result: UserContent) => (TextBlockParam | ImageBlockParam)[];
|
|
2617
2619
|
readonly commandResult: (command: string, exitCode: number, stdout: string, stderr: string) => string;
|
|
2618
2620
|
};
|
|
2619
2621
|
export { responsePrompts }
|
|
@@ -2726,7 +2728,7 @@ export { TaskEventKind as TaskEventKind_alias_2 }
|
|
|
2726
2728
|
*/
|
|
2727
2729
|
declare interface TaskEventStartRequest extends TaskEventBase {
|
|
2728
2730
|
kind: TaskEventKind.StartRequest;
|
|
2729
|
-
userMessage:
|
|
2731
|
+
userMessage: UserContent;
|
|
2730
2732
|
}
|
|
2731
2733
|
export { TaskEventStartRequest }
|
|
2732
2734
|
export { TaskEventStartRequest as TaskEventStartRequest_alias_1 }
|
|
@@ -2809,6 +2811,8 @@ export { TaskEventUsageExceeded }
|
|
|
2809
2811
|
export { TaskEventUsageExceeded as TaskEventUsageExceeded_alias_1 }
|
|
2810
2812
|
export { TaskEventUsageExceeded as TaskEventUsageExceeded_alias_2 }
|
|
2811
2813
|
|
|
2814
|
+
export declare type TextBlockParam = Anthropic.Messages.TextBlockParam;
|
|
2815
|
+
|
|
2812
2816
|
declare interface TextContent {
|
|
2813
2817
|
type: 'text';
|
|
2814
2818
|
content: string;
|
|
@@ -3077,7 +3081,7 @@ export declare const toolInfo_alias_12: {
|
|
|
3077
3081
|
|
|
3078
3082
|
export declare const toolInfo_alias_13: {
|
|
3079
3083
|
readonly name: "write_to_file";
|
|
3080
|
-
readonly description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `<
|
|
3084
|
+
readonly description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `<`, `>`, or `&`. Also ensure there is no unwanted CDATA tags in the content.";
|
|
3081
3085
|
readonly parameters: [{
|
|
3082
3086
|
readonly name: "path";
|
|
3083
3087
|
readonly description: "The path of the file to write to";
|
|
@@ -3427,7 +3431,7 @@ export { ToolResponseInvalid as ToolResponseInvalid_alias_1 }
|
|
|
3427
3431
|
declare type ToolResponseOrToolPause = {
|
|
3428
3432
|
type: 'response';
|
|
3429
3433
|
tool: string;
|
|
3430
|
-
response:
|
|
3434
|
+
response: UserContent;
|
|
3431
3435
|
} | {
|
|
3432
3436
|
type: 'pause';
|
|
3433
3437
|
tool: string;
|
|
@@ -3446,7 +3450,7 @@ export { ToolResponsePause as ToolResponsePause_alias_1 }
|
|
|
3446
3450
|
|
|
3447
3451
|
declare type ToolResponseReply = {
|
|
3448
3452
|
type: ToolResponseType.Reply;
|
|
3449
|
-
message:
|
|
3453
|
+
message: UserContent;
|
|
3450
3454
|
};
|
|
3451
3455
|
export { ToolResponseReply }
|
|
3452
3456
|
export { ToolResponseReply as ToolResponseReply_alias_1 }
|
|
@@ -3530,6 +3534,11 @@ export { UsageMeter }
|
|
|
3530
3534
|
export { UsageMeter as UsageMeter_alias_1 }
|
|
3531
3535
|
export { UsageMeter as UsageMeter_alias_2 }
|
|
3532
3536
|
|
|
3537
|
+
declare type UserContent = string | (TextBlockParam | ImageBlockParam)[];
|
|
3538
|
+
export { UserContent }
|
|
3539
|
+
export { UserContent as UserContent_alias_1 }
|
|
3540
|
+
export { UserContent as UserContent_alias_2 }
|
|
3541
|
+
|
|
3533
3542
|
declare type WebProvider = {
|
|
3534
3543
|
fetchUrl?: (url: string) => Promise<string>;
|
|
3535
3544
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { defaultModels } from './_tsup-dts-rollup.js';
|
|
|
4
4
|
export { createService } from './_tsup-dts-rollup.js';
|
|
5
5
|
export { UsageMeter } from './_tsup-dts-rollup.js';
|
|
6
6
|
export { AiServiceBase } from './_tsup-dts-rollup.js';
|
|
7
|
+
export { UserContent } from './_tsup-dts-rollup.js';
|
|
7
8
|
export { MessageParam } from './_tsup-dts-rollup.js';
|
|
8
9
|
export { AiServiceOptions } from './_tsup-dts-rollup.js';
|
|
9
10
|
export { ModelInfo } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -2166,7 +2166,7 @@ var updateKnowledge_default = {
|
|
|
2166
2166
|
// src/tools/writeToFile.ts
|
|
2167
2167
|
var toolInfo11 = {
|
|
2168
2168
|
name: "write_to_file",
|
|
2169
|
-
description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `<
|
|
2169
|
+
description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `<`, `>`, or `&`. Also ensure there is no unwanted CDATA tags in the content.",
|
|
2170
2170
|
parameters: [
|
|
2171
2171
|
{
|
|
2172
2172
|
name: "path",
|
|
@@ -2217,7 +2217,9 @@ var handler11 = async (provider, args) => {
|
|
|
2217
2217
|
};
|
|
2218
2218
|
}
|
|
2219
2219
|
const path = getString(args, "path");
|
|
2220
|
-
|
|
2220
|
+
let content = getString(args, "content");
|
|
2221
|
+
const trimmedContent = content.trim();
|
|
2222
|
+
if (trimmedContent.startsWith("<![CDATA[") && content.endsWith("]]>")) content = trimmedContent.slice(9, -3);
|
|
2221
2223
|
await provider.writeFile(path, content);
|
|
2222
2224
|
return {
|
|
2223
2225
|
type: "Reply" /* Reply */,
|
|
@@ -2773,12 +2775,27 @@ Ensure the opening and closing tags are correctly nested and closed, and that yo
|
|
|
2773
2775
|
Avoid unnecessary text or symbols before or after the tool use.
|
|
2774
2776
|
Avoid unnecessary escape characters or special characters.
|
|
2775
2777
|
`,
|
|
2776
|
-
toolResults: (tool, result) =>
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
</tool_response
|
|
2778
|
+
toolResults: (tool, result) => {
|
|
2779
|
+
if (typeof result === "string") {
|
|
2780
|
+
return [
|
|
2781
|
+
{
|
|
2782
|
+
type: "text",
|
|
2783
|
+
text: `<tool_response name=${tool}>${result}</tool_response>`
|
|
2784
|
+
}
|
|
2785
|
+
];
|
|
2786
|
+
}
|
|
2787
|
+
return [
|
|
2788
|
+
{
|
|
2789
|
+
type: "text",
|
|
2790
|
+
text: `<tool_response name=${tool}>`
|
|
2791
|
+
},
|
|
2792
|
+
...result,
|
|
2793
|
+
{
|
|
2794
|
+
type: "text",
|
|
2795
|
+
text: "</tool_response>"
|
|
2796
|
+
}
|
|
2797
|
+
];
|
|
2798
|
+
},
|
|
2782
2799
|
commandResult: (command, exitCode, stdout, stderr) => `<command>${command}</command>
|
|
2783
2800
|
<command_exit_code>${exitCode}</command_exit_code>
|
|
2784
2801
|
<command_stdout>
|
|
@@ -2960,23 +2977,26 @@ ${instance.prompt}`;
|
|
|
2960
2977
|
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name });
|
|
2961
2978
|
const toolResp = await this.#invokeTool(content.name, content.params);
|
|
2962
2979
|
switch (toolResp.type) {
|
|
2963
|
-
case "Reply" /* Reply */:
|
|
2980
|
+
case "Reply" /* Reply */: {
|
|
2964
2981
|
await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name });
|
|
2965
2982
|
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
2966
2983
|
break;
|
|
2984
|
+
}
|
|
2967
2985
|
case "Exit" /* Exit */:
|
|
2968
2986
|
if (toolResponses.length > 0) {
|
|
2969
2987
|
break outer;
|
|
2970
2988
|
}
|
|
2971
2989
|
return { type: "exit", reason: toolResp };
|
|
2972
|
-
case "Invalid" /* Invalid */:
|
|
2990
|
+
case "Invalid" /* Invalid */: {
|
|
2973
2991
|
await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
|
|
2974
2992
|
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
2975
2993
|
break outer;
|
|
2976
|
-
|
|
2994
|
+
}
|
|
2995
|
+
case "Error" /* Error */: {
|
|
2977
2996
|
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name });
|
|
2978
2997
|
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
2979
2998
|
break outer;
|
|
2999
|
+
}
|
|
2980
3000
|
case "Interrupted" /* Interrupted */:
|
|
2981
3001
|
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
|
|
2982
3002
|
return { type: "exit", reason: toolResp };
|
|
@@ -3026,7 +3046,7 @@ ${instance.prompt}`;
|
|
|
3026
3046
|
if (toolResponses.length === 0) {
|
|
3027
3047
|
return { type: "reply", message: responsePrompts.requireUseTool };
|
|
3028
3048
|
}
|
|
3029
|
-
const finalResp = toolResponses.filter((resp) => resp.type === "response").
|
|
3049
|
+
const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2));
|
|
3030
3050
|
return { type: "reply", message: finalResp };
|
|
3031
3051
|
}
|
|
3032
3052
|
async #invokeTool(name, args) {
|