@polka-codes/core 0.9.61 → 0.9.63
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 +98 -23
- package/dist/index.d.ts +4 -0
- package/dist/index.js +120 -40
- package/package.json +2 -2
|
@@ -92,6 +92,10 @@ declare type Config = z.infer<typeof configSchema>;
|
|
|
92
92
|
export { Config }
|
|
93
93
|
export { Config as Config_alias_1 }
|
|
94
94
|
|
|
95
|
+
declare type ConfigRule = z.infer<typeof ruleSchema>;
|
|
96
|
+
export { ConfigRule }
|
|
97
|
+
export { ConfigRule as ConfigRule_alias_1 }
|
|
98
|
+
|
|
95
99
|
declare const configSchema: z.ZodObject<{
|
|
96
100
|
prices: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
97
101
|
inputPrice: z.ZodOptional<z.ZodNumber>;
|
|
@@ -125,7 +129,25 @@ declare const configSchema: z.ZodObject<{
|
|
|
125
129
|
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
126
130
|
budget: z.ZodOptional<z.ZodNumber>;
|
|
127
131
|
}, z.core.$strip>>>;
|
|
128
|
-
|
|
132
|
+
tools: z.ZodOptional<z.ZodObject<{
|
|
133
|
+
search: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
134
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
135
|
+
model: z.ZodOptional<z.ZodString>;
|
|
136
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
137
|
+
budget: z.ZodOptional<z.ZodNumber>;
|
|
138
|
+
}, z.core.$strip>, z.ZodBoolean]>>;
|
|
139
|
+
}, z.core.$strip>>;
|
|
140
|
+
rules: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
141
|
+
path: z.ZodString;
|
|
142
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
143
|
+
url: z.ZodString;
|
|
144
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
145
|
+
repo: z.ZodString;
|
|
146
|
+
path: z.ZodString;
|
|
147
|
+
tag: z.ZodOptional<z.ZodString>;
|
|
148
|
+
commit: z.ZodOptional<z.ZodString>;
|
|
149
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
150
|
+
}, z.core.$strict>]>>>, z.ZodString]>>;
|
|
129
151
|
excludeFiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
130
152
|
}, z.core.$strict>;
|
|
131
153
|
export { configSchema }
|
|
@@ -237,6 +259,24 @@ export { _default_13 as replaceInFile }
|
|
|
237
259
|
export { _default_13 as replaceInFile_alias_1 }
|
|
238
260
|
|
|
239
261
|
declare const _default_14: {
|
|
262
|
+
handler: ToolHandler<{
|
|
263
|
+
readonly name: "search";
|
|
264
|
+
readonly description: "Search the web for information using Google Search. Use this tool to find current information, facts, news, documentation, or research that is not available in your training data. Returns comprehensive search results with relevant content extracted from the web.";
|
|
265
|
+
readonly parameters: z.ZodObject<{
|
|
266
|
+
query: z.ZodString;
|
|
267
|
+
}, z.core.$strip>;
|
|
268
|
+
}, WebProvider>;
|
|
269
|
+
name: "search";
|
|
270
|
+
description: "Search the web for information using Google Search. Use this tool to find current information, facts, news, documentation, or research that is not available in your training data. Returns comprehensive search results with relevant content extracted from the web.";
|
|
271
|
+
parameters: z.ZodObject<{
|
|
272
|
+
query: z.ZodString;
|
|
273
|
+
}, z.core.$strip>;
|
|
274
|
+
};
|
|
275
|
+
export { _default_14 as default_alias_13 }
|
|
276
|
+
export { _default_14 as search }
|
|
277
|
+
export { _default_14 as search_alias_1 }
|
|
278
|
+
|
|
279
|
+
declare const _default_15: {
|
|
240
280
|
handler: ToolHandler<{
|
|
241
281
|
readonly name: "searchFiles";
|
|
242
282
|
readonly description: "Request to perform a regex search across files in a specified directory, outputting context-rich results that include surrounding lines. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.";
|
|
@@ -254,11 +294,11 @@ declare const _default_14: {
|
|
|
254
294
|
filePattern: z.ZodOptional<z.ZodString>;
|
|
255
295
|
}, z.core.$strip>;
|
|
256
296
|
};
|
|
257
|
-
export {
|
|
258
|
-
export {
|
|
259
|
-
export {
|
|
297
|
+
export { _default_15 as default_alias_14 }
|
|
298
|
+
export { _default_15 as searchFiles }
|
|
299
|
+
export { _default_15 as searchFiles_alias_1 }
|
|
260
300
|
|
|
261
|
-
declare const
|
|
301
|
+
declare const _default_16: {
|
|
262
302
|
handler: ToolHandler<{
|
|
263
303
|
readonly name: "updateMemory";
|
|
264
304
|
readonly description: "Appends, replaces, or removes content from a memory topic. Use \"append\" to add to existing content, \"replace\" to overwrite entirely, or \"remove\" to delete a topic. Memory persists across tool calls within a workflow.";
|
|
@@ -284,11 +324,11 @@ declare const _default_15: {
|
|
|
284
324
|
content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
285
325
|
}, z.core.$strip>;
|
|
286
326
|
};
|
|
287
|
-
export {
|
|
288
|
-
export {
|
|
289
|
-
export {
|
|
327
|
+
export { _default_16 as default_alias_15 }
|
|
328
|
+
export { _default_16 as updateMemory }
|
|
329
|
+
export { _default_16 as updateMemory_alias_1 }
|
|
290
330
|
|
|
291
|
-
declare const
|
|
331
|
+
declare const _default_17: {
|
|
292
332
|
handler: ToolHandler<{
|
|
293
333
|
readonly name: "updateTodoItem";
|
|
294
334
|
readonly description: "Add or update a to-do item.";
|
|
@@ -326,11 +366,11 @@ declare const _default_16: {
|
|
|
326
366
|
}>>>;
|
|
327
367
|
}, $strip>;
|
|
328
368
|
};
|
|
329
|
-
export {
|
|
330
|
-
export {
|
|
331
|
-
export {
|
|
369
|
+
export { _default_17 as default_alias_16 }
|
|
370
|
+
export { _default_17 as updateTodoItem }
|
|
371
|
+
export { _default_17 as updateTodoItem_alias_1 }
|
|
332
372
|
|
|
333
|
-
declare const
|
|
373
|
+
declare const _default_18: {
|
|
334
374
|
handler: ToolHandler<{
|
|
335
375
|
readonly name: "writeToFile";
|
|
336
376
|
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.";
|
|
@@ -346,9 +386,9 @@ declare const _default_17: {
|
|
|
346
386
|
content: z.ZodString;
|
|
347
387
|
}, z.core.$strip>;
|
|
348
388
|
};
|
|
349
|
-
export {
|
|
350
|
-
export {
|
|
351
|
-
export {
|
|
389
|
+
export { _default_18 as default_alias_17 }
|
|
390
|
+
export { _default_18 as writeToFile }
|
|
391
|
+
export { _default_18 as writeToFile_alias_1 }
|
|
352
392
|
|
|
353
393
|
declare const _default_2: {
|
|
354
394
|
handler: ToolHandler<{
|
|
@@ -583,13 +623,15 @@ export declare const handler_alias_11: ToolHandler<typeof toolInfo_alias_11, Fil
|
|
|
583
623
|
|
|
584
624
|
export declare const handler_alias_12: ToolHandler<typeof toolInfo_alias_12, FilesystemProvider>;
|
|
585
625
|
|
|
586
|
-
export declare const handler_alias_13: ToolHandler<typeof toolInfo_alias_13,
|
|
626
|
+
export declare const handler_alias_13: ToolHandler<typeof toolInfo_alias_13, WebProvider>;
|
|
587
627
|
|
|
588
|
-
export declare const handler_alias_14: ToolHandler<typeof toolInfo_alias_14,
|
|
628
|
+
export declare const handler_alias_14: ToolHandler<typeof toolInfo_alias_14, FilesystemProvider>;
|
|
589
629
|
|
|
590
|
-
export declare const handler_alias_15: ToolHandler<typeof toolInfo_alias_15,
|
|
630
|
+
export declare const handler_alias_15: ToolHandler<typeof toolInfo_alias_15, MemoryProvider>;
|
|
591
631
|
|
|
592
|
-
export declare const handler_alias_16: ToolHandler<typeof toolInfo_alias_16,
|
|
632
|
+
export declare const handler_alias_16: ToolHandler<typeof toolInfo_alias_16, TodoProvider>;
|
|
633
|
+
|
|
634
|
+
export declare const handler_alias_17: ToolHandler<typeof toolInfo_alias_17, FilesystemProvider>;
|
|
593
635
|
|
|
594
636
|
export declare const handler_alias_2: ToolHandler<typeof toolInfo_alias_2, WebProvider>;
|
|
595
637
|
|
|
@@ -817,6 +859,7 @@ declare class MockProvider implements ToolProvider {
|
|
|
817
859
|
summary?: string;
|
|
818
860
|
}>;
|
|
819
861
|
askFollowupQuestion(_question: string, _options?: string[]): Promise<string>;
|
|
862
|
+
search(_query: string): Promise<string>;
|
|
820
863
|
listMemoryTopics(): Promise<string[]>;
|
|
821
864
|
readMemory(_topic?: string): Promise<string | undefined>;
|
|
822
865
|
updateMemory(_operation: 'append' | 'replace' | 'remove', _topic?: string, _content?: string): Promise<void>;
|
|
@@ -850,6 +893,15 @@ export { ParseOutputResult }
|
|
|
850
893
|
export { ParseOutputResult as ParseOutputResult_alias_1 }
|
|
851
894
|
export { ParseOutputResult as ParseOutputResult_alias_2 }
|
|
852
895
|
|
|
896
|
+
declare const providerModelSchema: z.ZodObject<{
|
|
897
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
898
|
+
model: z.ZodOptional<z.ZodString>;
|
|
899
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
900
|
+
budget: z.ZodOptional<z.ZodNumber>;
|
|
901
|
+
}, z.core.$strip>;
|
|
902
|
+
export { providerModelSchema }
|
|
903
|
+
export { providerModelSchema as providerModelSchema_alias_1 }
|
|
904
|
+
|
|
853
905
|
declare const replaceInFile_2: (fileContent: string, diff: string) => ReplaceResult;
|
|
854
906
|
export { replaceInFile_2 as replaceInFileHelper }
|
|
855
907
|
export { replaceInFile_2 as replaceInFile_alias_2 }
|
|
@@ -875,6 +927,20 @@ export { responsePrompts }
|
|
|
875
927
|
export { responsePrompts as responsePrompts_alias_1 }
|
|
876
928
|
export { responsePrompts as responsePrompts_alias_2 }
|
|
877
929
|
|
|
930
|
+
declare const ruleSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
931
|
+
path: z.ZodString;
|
|
932
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
933
|
+
url: z.ZodString;
|
|
934
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
935
|
+
repo: z.ZodString;
|
|
936
|
+
path: z.ZodString;
|
|
937
|
+
tag: z.ZodOptional<z.ZodString>;
|
|
938
|
+
commit: z.ZodOptional<z.ZodString>;
|
|
939
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
940
|
+
}, z.core.$strict>]>;
|
|
941
|
+
export { ruleSchema }
|
|
942
|
+
export { ruleSchema as ruleSchema_alias_1 }
|
|
943
|
+
|
|
878
944
|
/**
|
|
879
945
|
* Union type of all possible task events
|
|
880
946
|
*/
|
|
@@ -1113,6 +1179,14 @@ export declare const toolInfo_alias_12: {
|
|
|
1113
1179
|
};
|
|
1114
1180
|
|
|
1115
1181
|
export declare const toolInfo_alias_13: {
|
|
1182
|
+
readonly name: "search";
|
|
1183
|
+
readonly description: "Search the web for information using Google Search. Use this tool to find current information, facts, news, documentation, or research that is not available in your training data. Returns comprehensive search results with relevant content extracted from the web.";
|
|
1184
|
+
readonly parameters: z.ZodObject<{
|
|
1185
|
+
query: z.ZodString;
|
|
1186
|
+
}, z.core.$strip>;
|
|
1187
|
+
};
|
|
1188
|
+
|
|
1189
|
+
export declare const toolInfo_alias_14: {
|
|
1116
1190
|
readonly name: "searchFiles";
|
|
1117
1191
|
readonly description: "Request to perform a regex search across files in a specified directory, outputting context-rich results that include surrounding lines. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.";
|
|
1118
1192
|
readonly parameters: z.ZodObject<{
|
|
@@ -1122,7 +1196,7 @@ export declare const toolInfo_alias_13: {
|
|
|
1122
1196
|
}, z.core.$strip>;
|
|
1123
1197
|
};
|
|
1124
1198
|
|
|
1125
|
-
export declare const
|
|
1199
|
+
export declare const toolInfo_alias_15: {
|
|
1126
1200
|
readonly name: "updateMemory";
|
|
1127
1201
|
readonly description: "Appends, replaces, or removes content from a memory topic. Use \"append\" to add to existing content, \"replace\" to overwrite entirely, or \"remove\" to delete a topic. Memory persists across tool calls within a workflow.";
|
|
1128
1202
|
readonly parameters: z.ZodObject<{
|
|
@@ -1136,7 +1210,7 @@ export declare const toolInfo_alias_14: {
|
|
|
1136
1210
|
}, z.core.$strip>;
|
|
1137
1211
|
};
|
|
1138
1212
|
|
|
1139
|
-
export declare const
|
|
1213
|
+
export declare const toolInfo_alias_16: {
|
|
1140
1214
|
readonly name: "updateTodoItem";
|
|
1141
1215
|
readonly description: "Add or update a to-do item.";
|
|
1142
1216
|
readonly parameters: ZodObject< {
|
|
@@ -1156,7 +1230,7 @@ export declare const toolInfo_alias_15: {
|
|
|
1156
1230
|
}, $strip>;
|
|
1157
1231
|
};
|
|
1158
1232
|
|
|
1159
|
-
export declare const
|
|
1233
|
+
export declare const toolInfo_alias_17: {
|
|
1160
1234
|
readonly name: "writeToFile";
|
|
1161
1235
|
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.";
|
|
1162
1236
|
readonly parameters: z.ZodObject<{
|
|
@@ -1436,6 +1510,7 @@ export { UsageMeter as UsageMeter_alias_1 }
|
|
|
1436
1510
|
|
|
1437
1511
|
declare type WebProvider = {
|
|
1438
1512
|
fetchUrl?: (url: string) => Promise<string>;
|
|
1513
|
+
search?: (query: string) => Promise<string>;
|
|
1439
1514
|
};
|
|
1440
1515
|
export { WebProvider }
|
|
1441
1516
|
export { WebProvider as WebProvider_alias_1 }
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export { ParseOutputResult } from './_tsup-dts-rollup.js';
|
|
|
3
3
|
export { parseJsonFromMarkdown } from './_tsup-dts-rollup.js';
|
|
4
4
|
export { responsePrompts } from './_tsup-dts-rollup.js';
|
|
5
5
|
export { computeRateLimitBackoffSeconds } from './_tsup-dts-rollup.js';
|
|
6
|
+
export { providerModelSchema_alias_1 as providerModelSchema } from './_tsup-dts-rollup.js';
|
|
7
|
+
export { ruleSchema_alias_1 as ruleSchema } from './_tsup-dts-rollup.js';
|
|
8
|
+
export { ConfigRule_alias_1 as ConfigRule } from './_tsup-dts-rollup.js';
|
|
6
9
|
export { configSchema_alias_1 as configSchema } from './_tsup-dts-rollup.js';
|
|
7
10
|
export { Config_alias_1 as Config } from './_tsup-dts-rollup.js';
|
|
8
11
|
export { ToolParameterValue } from './_tsup-dts-rollup.js';
|
|
@@ -30,6 +33,7 @@ export { readMemory } from './_tsup-dts-rollup.js';
|
|
|
30
33
|
export { removeFile } from './_tsup-dts-rollup.js';
|
|
31
34
|
export { renameFile } from './_tsup-dts-rollup.js';
|
|
32
35
|
export { replaceInFile } from './_tsup-dts-rollup.js';
|
|
36
|
+
export { search } from './_tsup-dts-rollup.js';
|
|
33
37
|
export { searchFiles } from './_tsup-dts-rollup.js';
|
|
34
38
|
export { updateMemory } from './_tsup-dts-rollup.js';
|
|
35
39
|
export { updateTodoItem } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -133,6 +133,18 @@ var providerModelSchema = z.object({
|
|
|
133
133
|
parameters: z.record(z.string(), z.any()).optional(),
|
|
134
134
|
budget: z.number().positive().optional()
|
|
135
135
|
});
|
|
136
|
+
var ruleSchema = z.union([
|
|
137
|
+
z.string(),
|
|
138
|
+
z.object({ path: z.string() }).strict(),
|
|
139
|
+
z.object({ url: z.string() }).strict(),
|
|
140
|
+
z.object({
|
|
141
|
+
repo: z.string(),
|
|
142
|
+
path: z.string(),
|
|
143
|
+
tag: z.string().optional(),
|
|
144
|
+
commit: z.string().optional(),
|
|
145
|
+
branch: z.string().optional()
|
|
146
|
+
}).strict()
|
|
147
|
+
]);
|
|
136
148
|
var configSchema = z.object({
|
|
137
149
|
prices: z.record(
|
|
138
150
|
z.string(),
|
|
@@ -177,7 +189,10 @@ var configSchema = z.object({
|
|
|
177
189
|
)
|
|
178
190
|
).optional(),
|
|
179
191
|
commands: z.record(z.string(), providerModelSchema).optional(),
|
|
180
|
-
|
|
192
|
+
tools: z.object({
|
|
193
|
+
search: providerModelSchema.or(z.boolean()).optional()
|
|
194
|
+
}).optional(),
|
|
195
|
+
rules: z.array(ruleSchema).optional().or(z.string()).optional(),
|
|
181
196
|
excludeFiles: z.array(z.string()).optional()
|
|
182
197
|
}).strict();
|
|
183
198
|
|
|
@@ -702,6 +717,9 @@ var MockProvider = class {
|
|
|
702
717
|
async askFollowupQuestion(_question, _options) {
|
|
703
718
|
return "mock answer";
|
|
704
719
|
}
|
|
720
|
+
async search(_query) {
|
|
721
|
+
return "mock search result";
|
|
722
|
+
}
|
|
705
723
|
async listMemoryTopics() {
|
|
706
724
|
return ["default"];
|
|
707
725
|
}
|
|
@@ -1241,19 +1259,74 @@ var replaceInFile_default = {
|
|
|
1241
1259
|
handler: handler13
|
|
1242
1260
|
};
|
|
1243
1261
|
|
|
1244
|
-
// src/tools/
|
|
1262
|
+
// src/tools/search.ts
|
|
1245
1263
|
import { z as z16 } from "zod";
|
|
1246
1264
|
var toolInfo14 = {
|
|
1265
|
+
name: "search",
|
|
1266
|
+
description: "Search the web for information using Google Search. Use this tool to find current information, facts, news, documentation, or research that is not available in your training data. Returns comprehensive search results with relevant content extracted from the web.",
|
|
1267
|
+
parameters: z16.object({
|
|
1268
|
+
query: z16.string().describe("The query to search for").meta({ usageValue: "Your search query here" })
|
|
1269
|
+
}).meta({
|
|
1270
|
+
examples: [
|
|
1271
|
+
{
|
|
1272
|
+
description: "Search for current events or news",
|
|
1273
|
+
input: {
|
|
1274
|
+
query: "latest developments in AI language models 2024"
|
|
1275
|
+
}
|
|
1276
|
+
},
|
|
1277
|
+
{
|
|
1278
|
+
description: "Look up technical documentation",
|
|
1279
|
+
input: {
|
|
1280
|
+
query: "TypeScript advanced type system features"
|
|
1281
|
+
}
|
|
1282
|
+
},
|
|
1283
|
+
{
|
|
1284
|
+
description: "Research specific information",
|
|
1285
|
+
input: {
|
|
1286
|
+
query: "Node.js performance optimization best practices"
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
]
|
|
1290
|
+
})
|
|
1291
|
+
};
|
|
1292
|
+
var handler14 = async (provider, args) => {
|
|
1293
|
+
const { query } = toolInfo14.parameters.parse(args);
|
|
1294
|
+
if (!provider.search) {
|
|
1295
|
+
return {
|
|
1296
|
+
type: "Error" /* Error */,
|
|
1297
|
+
message: {
|
|
1298
|
+
type: "text",
|
|
1299
|
+
value: "This tool requires a web provider to be installed."
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
const result = await provider.search(query);
|
|
1304
|
+
return {
|
|
1305
|
+
type: "Reply" /* Reply */,
|
|
1306
|
+
message: {
|
|
1307
|
+
type: "text",
|
|
1308
|
+
value: result
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
};
|
|
1312
|
+
var search_default = {
|
|
1313
|
+
...toolInfo14,
|
|
1314
|
+
handler: handler14
|
|
1315
|
+
};
|
|
1316
|
+
|
|
1317
|
+
// src/tools/searchFiles.ts
|
|
1318
|
+
import { z as z17 } from "zod";
|
|
1319
|
+
var toolInfo15 = {
|
|
1247
1320
|
name: "searchFiles",
|
|
1248
1321
|
description: "Request to perform a regex search across files in a specified directory, outputting context-rich results that include surrounding lines. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.",
|
|
1249
|
-
parameters:
|
|
1250
|
-
path:
|
|
1322
|
+
parameters: z17.object({
|
|
1323
|
+
path: z17.string().describe(
|
|
1251
1324
|
"The path of the directory to search in (relative to the current working directory). This directory will be recursively searched."
|
|
1252
1325
|
).meta({ usageValue: "Directory path here" }),
|
|
1253
|
-
regex:
|
|
1326
|
+
regex: z17.string().describe("The regular expression pattern to search for. Uses Rust regex syntax.").meta({
|
|
1254
1327
|
usageValue: "Your regex pattern here"
|
|
1255
1328
|
}),
|
|
1256
|
-
filePattern:
|
|
1329
|
+
filePattern: z17.string().optional().describe(
|
|
1257
1330
|
'Comma-separated glob pattern to filter files (e.g., "*.ts" for TypeScript files or "*.ts,*.js" for both TypeScript and JavaScript files). If not provided, it will search all files (*).'
|
|
1258
1331
|
).meta({
|
|
1259
1332
|
usageValue: "file pattern here (optional)"
|
|
@@ -1271,7 +1344,7 @@ var toolInfo14 = {
|
|
|
1271
1344
|
]
|
|
1272
1345
|
})
|
|
1273
1346
|
};
|
|
1274
|
-
var
|
|
1347
|
+
var handler15 = async (provider, args) => {
|
|
1275
1348
|
if (!provider.searchFiles) {
|
|
1276
1349
|
return {
|
|
1277
1350
|
type: "Error" /* Error */,
|
|
@@ -1281,7 +1354,7 @@ var handler14 = async (provider, args) => {
|
|
|
1281
1354
|
}
|
|
1282
1355
|
};
|
|
1283
1356
|
}
|
|
1284
|
-
const parsed =
|
|
1357
|
+
const parsed = toolInfo15.parameters.safeParse(args);
|
|
1285
1358
|
if (!parsed.success) {
|
|
1286
1359
|
return {
|
|
1287
1360
|
type: "Error" /* Error */,
|
|
@@ -1318,19 +1391,19 @@ ${files.join("\n")}
|
|
|
1318
1391
|
}
|
|
1319
1392
|
};
|
|
1320
1393
|
var searchFiles_default = {
|
|
1321
|
-
...
|
|
1322
|
-
handler:
|
|
1394
|
+
...toolInfo15,
|
|
1395
|
+
handler: handler15
|
|
1323
1396
|
};
|
|
1324
1397
|
|
|
1325
1398
|
// src/tools/updateMemory.ts
|
|
1326
|
-
import { z as
|
|
1327
|
-
var
|
|
1399
|
+
import { z as z18 } from "zod";
|
|
1400
|
+
var toolInfo16 = {
|
|
1328
1401
|
name: "updateMemory",
|
|
1329
1402
|
description: 'Appends, replaces, or removes content from a memory topic. Use "append" to add to existing content, "replace" to overwrite entirely, or "remove" to delete a topic. Memory persists across tool calls within a workflow.',
|
|
1330
|
-
parameters:
|
|
1331
|
-
operation:
|
|
1332
|
-
topic:
|
|
1333
|
-
content:
|
|
1403
|
+
parameters: z18.object({
|
|
1404
|
+
operation: z18.enum(["append", "replace", "remove"]).describe("The operation to perform."),
|
|
1405
|
+
topic: z18.string().nullish().describe('The topic to update in memory. Defaults to ":default:".'),
|
|
1406
|
+
content: z18.string().nullish().describe("The content for append or replace operations. Must be omitted for remove operation.")
|
|
1334
1407
|
}).superRefine((data, ctx) => {
|
|
1335
1408
|
if (data.operation === "append" || data.operation === "replace") {
|
|
1336
1409
|
if (data.content === void 0) {
|
|
@@ -1351,7 +1424,7 @@ var toolInfo15 = {
|
|
|
1351
1424
|
}
|
|
1352
1425
|
})
|
|
1353
1426
|
};
|
|
1354
|
-
var
|
|
1427
|
+
var handler16 = async (provider, args) => {
|
|
1355
1428
|
if (!provider.updateMemory) {
|
|
1356
1429
|
return {
|
|
1357
1430
|
type: "Error" /* Error */,
|
|
@@ -1361,7 +1434,7 @@ var handler15 = async (provider, args) => {
|
|
|
1361
1434
|
}
|
|
1362
1435
|
};
|
|
1363
1436
|
}
|
|
1364
|
-
const params =
|
|
1437
|
+
const params = toolInfo16.parameters.parse(args);
|
|
1365
1438
|
await provider.updateMemory(params.operation, params.topic ?? void 0, params.content ?? void 0);
|
|
1366
1439
|
switch (params.operation) {
|
|
1367
1440
|
case "append":
|
|
@@ -1391,17 +1464,17 @@ var handler15 = async (provider, args) => {
|
|
|
1391
1464
|
}
|
|
1392
1465
|
};
|
|
1393
1466
|
var updateMemory_default = {
|
|
1394
|
-
...
|
|
1395
|
-
handler:
|
|
1467
|
+
...toolInfo16,
|
|
1468
|
+
handler: handler16
|
|
1396
1469
|
};
|
|
1397
1470
|
|
|
1398
1471
|
// src/tools/updateTodoItem.ts
|
|
1399
|
-
var
|
|
1472
|
+
var toolInfo17 = {
|
|
1400
1473
|
name: "updateTodoItem",
|
|
1401
1474
|
description: "Add or update a to-do item.",
|
|
1402
1475
|
parameters: UpdateTodoItemInputSchema
|
|
1403
1476
|
};
|
|
1404
|
-
var
|
|
1477
|
+
var handler17 = async (provider, args) => {
|
|
1405
1478
|
if (!provider.updateTodoItem) {
|
|
1406
1479
|
return {
|
|
1407
1480
|
type: "Error" /* Error */,
|
|
@@ -1411,7 +1484,7 @@ var handler16 = async (provider, args) => {
|
|
|
1411
1484
|
}
|
|
1412
1485
|
};
|
|
1413
1486
|
}
|
|
1414
|
-
const input =
|
|
1487
|
+
const input = toolInfo17.parameters.parse(args);
|
|
1415
1488
|
const result = await provider.updateTodoItem(input);
|
|
1416
1489
|
return {
|
|
1417
1490
|
type: "Reply" /* Reply */,
|
|
@@ -1422,18 +1495,18 @@ var handler16 = async (provider, args) => {
|
|
|
1422
1495
|
};
|
|
1423
1496
|
};
|
|
1424
1497
|
var updateTodoItem_default = {
|
|
1425
|
-
...
|
|
1426
|
-
handler:
|
|
1498
|
+
...toolInfo17,
|
|
1499
|
+
handler: handler17
|
|
1427
1500
|
};
|
|
1428
1501
|
|
|
1429
1502
|
// src/tools/writeToFile.ts
|
|
1430
|
-
import { z as
|
|
1431
|
-
var
|
|
1503
|
+
import { z as z19 } from "zod";
|
|
1504
|
+
var toolInfo18 = {
|
|
1432
1505
|
name: "writeToFile",
|
|
1433
1506
|
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.",
|
|
1434
|
-
parameters:
|
|
1435
|
-
path:
|
|
1436
|
-
content:
|
|
1507
|
+
parameters: z19.object({
|
|
1508
|
+
path: z19.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
|
|
1509
|
+
content: z19.string().describe(
|
|
1437
1510
|
"The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified."
|
|
1438
1511
|
).meta({ usageValue: "Your file content here" })
|
|
1439
1512
|
}).meta({
|
|
@@ -1459,7 +1532,7 @@ export default App;
|
|
|
1459
1532
|
]
|
|
1460
1533
|
})
|
|
1461
1534
|
};
|
|
1462
|
-
var
|
|
1535
|
+
var handler18 = async (provider, args) => {
|
|
1463
1536
|
if (!provider.writeFile) {
|
|
1464
1537
|
return {
|
|
1465
1538
|
type: "Error" /* Error */,
|
|
@@ -1469,7 +1542,7 @@ var handler17 = async (provider, args) => {
|
|
|
1469
1542
|
}
|
|
1470
1543
|
};
|
|
1471
1544
|
}
|
|
1472
|
-
const parsed =
|
|
1545
|
+
const parsed = toolInfo18.parameters.safeParse(args);
|
|
1473
1546
|
if (!parsed.success) {
|
|
1474
1547
|
return {
|
|
1475
1548
|
type: "Error" /* Error */,
|
|
@@ -1492,8 +1565,8 @@ var handler17 = async (provider, args) => {
|
|
|
1492
1565
|
};
|
|
1493
1566
|
};
|
|
1494
1567
|
var writeToFile_default = {
|
|
1495
|
-
...
|
|
1496
|
-
handler:
|
|
1568
|
+
...toolInfo18,
|
|
1569
|
+
handler: handler18
|
|
1497
1570
|
};
|
|
1498
1571
|
|
|
1499
1572
|
// src/UsageMeter.ts
|
|
@@ -1646,7 +1719,7 @@ var UsageMeter = class {
|
|
|
1646
1719
|
|
|
1647
1720
|
// src/workflow/agent.workflow.ts
|
|
1648
1721
|
import { jsonSchema } from "ai";
|
|
1649
|
-
import { toJSONSchema, z as
|
|
1722
|
+
import { toJSONSchema, z as z20 } from "zod";
|
|
1650
1723
|
|
|
1651
1724
|
// src/workflow/types.ts
|
|
1652
1725
|
var TaskEventKind = /* @__PURE__ */ ((TaskEventKind2) => {
|
|
@@ -1664,13 +1737,13 @@ var TaskEventKind = /* @__PURE__ */ ((TaskEventKind2) => {
|
|
|
1664
1737
|
})(TaskEventKind || {});
|
|
1665
1738
|
|
|
1666
1739
|
// src/workflow/agent.workflow.ts
|
|
1667
|
-
var agentWorkflow = async (input, { step, tools }) => {
|
|
1740
|
+
var agentWorkflow = async (input, { step, tools, logger }) => {
|
|
1668
1741
|
const event = (name, event2) => step(name, () => tools.taskEvent(event2));
|
|
1669
|
-
const { tools:
|
|
1742
|
+
const { tools: toolInfo19, maxToolRoundTrips = 200 } = input;
|
|
1670
1743
|
const messages = "systemPrompt" in input ? [{ role: "system", content: input.systemPrompt }] : input.messages;
|
|
1671
1744
|
await event("start-task", { kind: "StartTask" /* StartTask */, systemPrompt: "systemPrompt" in input ? input.systemPrompt : "" });
|
|
1672
1745
|
const toolSet = {};
|
|
1673
|
-
for (const tool of
|
|
1746
|
+
for (const tool of toolInfo19) {
|
|
1674
1747
|
toolSet[tool.name] = {
|
|
1675
1748
|
description: tool.description,
|
|
1676
1749
|
inputSchema: jsonSchema(toJSONSchema(tool.parameters))
|
|
@@ -1696,7 +1769,11 @@ var agentWorkflow = async (input, { step, tools }) => {
|
|
|
1696
1769
|
if (msg.content) {
|
|
1697
1770
|
for (const part of msg.content) {
|
|
1698
1771
|
if (part.type === "tool-call") {
|
|
1699
|
-
|
|
1772
|
+
if (toolSet[part.toolName]) {
|
|
1773
|
+
toolCalls.push(part);
|
|
1774
|
+
} else {
|
|
1775
|
+
logger.warn("Tool not found. Skipping.", part);
|
|
1776
|
+
}
|
|
1700
1777
|
}
|
|
1701
1778
|
}
|
|
1702
1779
|
}
|
|
@@ -1730,7 +1807,7 @@ var agentWorkflow = async (input, { step, tools }) => {
|
|
|
1730
1807
|
}
|
|
1731
1808
|
const validated = input.outputSchema.safeParse(parsed.data);
|
|
1732
1809
|
if (!validated.success) {
|
|
1733
|
-
const errorMessage = `Output validation failed. Error: ${
|
|
1810
|
+
const errorMessage = `Output validation failed. Error: ${z20.prettifyError(validated.error)}. Please correct the output.`;
|
|
1734
1811
|
nextMessage = [{ role: "user", content: errorMessage }];
|
|
1735
1812
|
continue;
|
|
1736
1813
|
}
|
|
@@ -2010,6 +2087,7 @@ export {
|
|
|
2010
2087
|
listTodoItems_default as listTodoItems,
|
|
2011
2088
|
makeStepFn,
|
|
2012
2089
|
parseJsonFromMarkdown,
|
|
2090
|
+
providerModelSchema,
|
|
2013
2091
|
readBinaryFile_default as readBinaryFile,
|
|
2014
2092
|
readFile_default as readFile,
|
|
2015
2093
|
readMemory_default as readMemory,
|
|
@@ -2018,6 +2096,8 @@ export {
|
|
|
2018
2096
|
replaceInFile_default as replaceInFile,
|
|
2019
2097
|
replaceInFile as replaceInFileHelper,
|
|
2020
2098
|
responsePrompts,
|
|
2099
|
+
ruleSchema,
|
|
2100
|
+
search_default as search,
|
|
2021
2101
|
searchFiles_default as searchFiles,
|
|
2022
2102
|
toJsonModelMessage,
|
|
2023
2103
|
updateMemory_default as updateMemory,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polka-codes/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.63",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"author": "github@polka.codes",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@ai-sdk/provider": "^2.0.0",
|
|
21
21
|
"@ai-sdk/provider-utils": "^3.0.15",
|
|
22
|
-
"ai": "^5.0.
|
|
22
|
+
"ai": "^5.0.97",
|
|
23
23
|
"yaml": "^2.8.1",
|
|
24
24
|
"zod": "^4.1.12"
|
|
25
25
|
}
|