@polka-codes/core 0.9.61 → 0.9.62
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 +52 -22
- package/dist/index.d.ts +1 -0
- package/dist/index.js +81 -39
- package/package.json +1 -1
|
@@ -237,6 +237,24 @@ export { _default_13 as replaceInFile }
|
|
|
237
237
|
export { _default_13 as replaceInFile_alias_1 }
|
|
238
238
|
|
|
239
239
|
declare const _default_14: {
|
|
240
|
+
handler: ToolHandler<{
|
|
241
|
+
readonly name: "search";
|
|
242
|
+
readonly description: "Search the web for information.";
|
|
243
|
+
readonly parameters: z.ZodObject<{
|
|
244
|
+
query: z.ZodString;
|
|
245
|
+
}, z.core.$strip>;
|
|
246
|
+
}, WebProvider>;
|
|
247
|
+
name: "search";
|
|
248
|
+
description: "Search the web for information.";
|
|
249
|
+
parameters: z.ZodObject<{
|
|
250
|
+
query: z.ZodString;
|
|
251
|
+
}, z.core.$strip>;
|
|
252
|
+
};
|
|
253
|
+
export { _default_14 as default_alias_13 }
|
|
254
|
+
export { _default_14 as search }
|
|
255
|
+
export { _default_14 as search_alias_1 }
|
|
256
|
+
|
|
257
|
+
declare const _default_15: {
|
|
240
258
|
handler: ToolHandler<{
|
|
241
259
|
readonly name: "searchFiles";
|
|
242
260
|
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 +272,11 @@ declare const _default_14: {
|
|
|
254
272
|
filePattern: z.ZodOptional<z.ZodString>;
|
|
255
273
|
}, z.core.$strip>;
|
|
256
274
|
};
|
|
257
|
-
export {
|
|
258
|
-
export {
|
|
259
|
-
export {
|
|
275
|
+
export { _default_15 as default_alias_14 }
|
|
276
|
+
export { _default_15 as searchFiles }
|
|
277
|
+
export { _default_15 as searchFiles_alias_1 }
|
|
260
278
|
|
|
261
|
-
declare const
|
|
279
|
+
declare const _default_16: {
|
|
262
280
|
handler: ToolHandler<{
|
|
263
281
|
readonly name: "updateMemory";
|
|
264
282
|
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 +302,11 @@ declare const _default_15: {
|
|
|
284
302
|
content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
285
303
|
}, z.core.$strip>;
|
|
286
304
|
};
|
|
287
|
-
export {
|
|
288
|
-
export {
|
|
289
|
-
export {
|
|
305
|
+
export { _default_16 as default_alias_15 }
|
|
306
|
+
export { _default_16 as updateMemory }
|
|
307
|
+
export { _default_16 as updateMemory_alias_1 }
|
|
290
308
|
|
|
291
|
-
declare const
|
|
309
|
+
declare const _default_17: {
|
|
292
310
|
handler: ToolHandler<{
|
|
293
311
|
readonly name: "updateTodoItem";
|
|
294
312
|
readonly description: "Add or update a to-do item.";
|
|
@@ -326,11 +344,11 @@ declare const _default_16: {
|
|
|
326
344
|
}>>>;
|
|
327
345
|
}, $strip>;
|
|
328
346
|
};
|
|
329
|
-
export {
|
|
330
|
-
export {
|
|
331
|
-
export {
|
|
347
|
+
export { _default_17 as default_alias_16 }
|
|
348
|
+
export { _default_17 as updateTodoItem }
|
|
349
|
+
export { _default_17 as updateTodoItem_alias_1 }
|
|
332
350
|
|
|
333
|
-
declare const
|
|
351
|
+
declare const _default_18: {
|
|
334
352
|
handler: ToolHandler<{
|
|
335
353
|
readonly name: "writeToFile";
|
|
336
354
|
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 +364,9 @@ declare const _default_17: {
|
|
|
346
364
|
content: z.ZodString;
|
|
347
365
|
}, z.core.$strip>;
|
|
348
366
|
};
|
|
349
|
-
export {
|
|
350
|
-
export {
|
|
351
|
-
export {
|
|
367
|
+
export { _default_18 as default_alias_17 }
|
|
368
|
+
export { _default_18 as writeToFile }
|
|
369
|
+
export { _default_18 as writeToFile_alias_1 }
|
|
352
370
|
|
|
353
371
|
declare const _default_2: {
|
|
354
372
|
handler: ToolHandler<{
|
|
@@ -583,13 +601,15 @@ export declare const handler_alias_11: ToolHandler<typeof toolInfo_alias_11, Fil
|
|
|
583
601
|
|
|
584
602
|
export declare const handler_alias_12: ToolHandler<typeof toolInfo_alias_12, FilesystemProvider>;
|
|
585
603
|
|
|
586
|
-
export declare const handler_alias_13: ToolHandler<typeof toolInfo_alias_13,
|
|
604
|
+
export declare const handler_alias_13: ToolHandler<typeof toolInfo_alias_13, WebProvider>;
|
|
605
|
+
|
|
606
|
+
export declare const handler_alias_14: ToolHandler<typeof toolInfo_alias_14, FilesystemProvider>;
|
|
587
607
|
|
|
588
|
-
export declare const
|
|
608
|
+
export declare const handler_alias_15: ToolHandler<typeof toolInfo_alias_15, MemoryProvider>;
|
|
589
609
|
|
|
590
|
-
export declare const
|
|
610
|
+
export declare const handler_alias_16: ToolHandler<typeof toolInfo_alias_16, TodoProvider>;
|
|
591
611
|
|
|
592
|
-
export declare const
|
|
612
|
+
export declare const handler_alias_17: ToolHandler<typeof toolInfo_alias_17, FilesystemProvider>;
|
|
593
613
|
|
|
594
614
|
export declare const handler_alias_2: ToolHandler<typeof toolInfo_alias_2, WebProvider>;
|
|
595
615
|
|
|
@@ -817,6 +837,7 @@ declare class MockProvider implements ToolProvider {
|
|
|
817
837
|
summary?: string;
|
|
818
838
|
}>;
|
|
819
839
|
askFollowupQuestion(_question: string, _options?: string[]): Promise<string>;
|
|
840
|
+
search(_query: string): Promise<string>;
|
|
820
841
|
listMemoryTopics(): Promise<string[]>;
|
|
821
842
|
readMemory(_topic?: string): Promise<string | undefined>;
|
|
822
843
|
updateMemory(_operation: 'append' | 'replace' | 'remove', _topic?: string, _content?: string): Promise<void>;
|
|
@@ -1113,6 +1134,14 @@ export declare const toolInfo_alias_12: {
|
|
|
1113
1134
|
};
|
|
1114
1135
|
|
|
1115
1136
|
export declare const toolInfo_alias_13: {
|
|
1137
|
+
readonly name: "search";
|
|
1138
|
+
readonly description: "Search the web for information.";
|
|
1139
|
+
readonly parameters: z.ZodObject<{
|
|
1140
|
+
query: z.ZodString;
|
|
1141
|
+
}, z.core.$strip>;
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
export declare const toolInfo_alias_14: {
|
|
1116
1145
|
readonly name: "searchFiles";
|
|
1117
1146
|
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
1147
|
readonly parameters: z.ZodObject<{
|
|
@@ -1122,7 +1151,7 @@ export declare const toolInfo_alias_13: {
|
|
|
1122
1151
|
}, z.core.$strip>;
|
|
1123
1152
|
};
|
|
1124
1153
|
|
|
1125
|
-
export declare const
|
|
1154
|
+
export declare const toolInfo_alias_15: {
|
|
1126
1155
|
readonly name: "updateMemory";
|
|
1127
1156
|
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
1157
|
readonly parameters: z.ZodObject<{
|
|
@@ -1136,7 +1165,7 @@ export declare const toolInfo_alias_14: {
|
|
|
1136
1165
|
}, z.core.$strip>;
|
|
1137
1166
|
};
|
|
1138
1167
|
|
|
1139
|
-
export declare const
|
|
1168
|
+
export declare const toolInfo_alias_16: {
|
|
1140
1169
|
readonly name: "updateTodoItem";
|
|
1141
1170
|
readonly description: "Add or update a to-do item.";
|
|
1142
1171
|
readonly parameters: ZodObject< {
|
|
@@ -1156,7 +1185,7 @@ export declare const toolInfo_alias_15: {
|
|
|
1156
1185
|
}, $strip>;
|
|
1157
1186
|
};
|
|
1158
1187
|
|
|
1159
|
-
export declare const
|
|
1188
|
+
export declare const toolInfo_alias_17: {
|
|
1160
1189
|
readonly name: "writeToFile";
|
|
1161
1190
|
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
1191
|
readonly parameters: z.ZodObject<{
|
|
@@ -1436,6 +1465,7 @@ export { UsageMeter as UsageMeter_alias_1 }
|
|
|
1436
1465
|
|
|
1437
1466
|
declare type WebProvider = {
|
|
1438
1467
|
fetchUrl?: (url: string) => Promise<string>;
|
|
1468
|
+
search?: (query: string) => Promise<string>;
|
|
1439
1469
|
};
|
|
1440
1470
|
export { WebProvider }
|
|
1441
1471
|
export { WebProvider as WebProvider_alias_1 }
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export { readMemory } from './_tsup-dts-rollup.js';
|
|
|
30
30
|
export { removeFile } from './_tsup-dts-rollup.js';
|
|
31
31
|
export { renameFile } from './_tsup-dts-rollup.js';
|
|
32
32
|
export { replaceInFile } from './_tsup-dts-rollup.js';
|
|
33
|
+
export { search } from './_tsup-dts-rollup.js';
|
|
33
34
|
export { searchFiles } from './_tsup-dts-rollup.js';
|
|
34
35
|
export { updateMemory } from './_tsup-dts-rollup.js';
|
|
35
36
|
export { updateTodoItem } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -702,6 +702,9 @@ var MockProvider = class {
|
|
|
702
702
|
async askFollowupQuestion(_question, _options) {
|
|
703
703
|
return "mock answer";
|
|
704
704
|
}
|
|
705
|
+
async search(_query) {
|
|
706
|
+
return "mock search result";
|
|
707
|
+
}
|
|
705
708
|
async listMemoryTopics() {
|
|
706
709
|
return ["default"];
|
|
707
710
|
}
|
|
@@ -1241,19 +1244,53 @@ var replaceInFile_default = {
|
|
|
1241
1244
|
handler: handler13
|
|
1242
1245
|
};
|
|
1243
1246
|
|
|
1244
|
-
// src/tools/
|
|
1247
|
+
// src/tools/search.ts
|
|
1245
1248
|
import { z as z16 } from "zod";
|
|
1246
1249
|
var toolInfo14 = {
|
|
1250
|
+
name: "search",
|
|
1251
|
+
description: "Search the web for information.",
|
|
1252
|
+
parameters: z16.object({
|
|
1253
|
+
query: z16.string().describe("The query to search for")
|
|
1254
|
+
})
|
|
1255
|
+
};
|
|
1256
|
+
var handler14 = async (provider, args) => {
|
|
1257
|
+
const { query } = toolInfo14.parameters.parse(args);
|
|
1258
|
+
if (!provider.search) {
|
|
1259
|
+
return {
|
|
1260
|
+
type: "Error" /* Error */,
|
|
1261
|
+
message: {
|
|
1262
|
+
type: "text",
|
|
1263
|
+
value: "This tool requires a web provider to be installed."
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
const result = await provider.search(query);
|
|
1268
|
+
return {
|
|
1269
|
+
type: "Reply" /* Reply */,
|
|
1270
|
+
message: {
|
|
1271
|
+
type: "text",
|
|
1272
|
+
value: result
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1275
|
+
};
|
|
1276
|
+
var search_default = {
|
|
1277
|
+
...toolInfo14,
|
|
1278
|
+
handler: handler14
|
|
1279
|
+
};
|
|
1280
|
+
|
|
1281
|
+
// src/tools/searchFiles.ts
|
|
1282
|
+
import { z as z17 } from "zod";
|
|
1283
|
+
var toolInfo15 = {
|
|
1247
1284
|
name: "searchFiles",
|
|
1248
1285
|
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:
|
|
1286
|
+
parameters: z17.object({
|
|
1287
|
+
path: z17.string().describe(
|
|
1251
1288
|
"The path of the directory to search in (relative to the current working directory). This directory will be recursively searched."
|
|
1252
1289
|
).meta({ usageValue: "Directory path here" }),
|
|
1253
|
-
regex:
|
|
1290
|
+
regex: z17.string().describe("The regular expression pattern to search for. Uses Rust regex syntax.").meta({
|
|
1254
1291
|
usageValue: "Your regex pattern here"
|
|
1255
1292
|
}),
|
|
1256
|
-
filePattern:
|
|
1293
|
+
filePattern: z17.string().optional().describe(
|
|
1257
1294
|
'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
1295
|
).meta({
|
|
1259
1296
|
usageValue: "file pattern here (optional)"
|
|
@@ -1271,7 +1308,7 @@ var toolInfo14 = {
|
|
|
1271
1308
|
]
|
|
1272
1309
|
})
|
|
1273
1310
|
};
|
|
1274
|
-
var
|
|
1311
|
+
var handler15 = async (provider, args) => {
|
|
1275
1312
|
if (!provider.searchFiles) {
|
|
1276
1313
|
return {
|
|
1277
1314
|
type: "Error" /* Error */,
|
|
@@ -1281,7 +1318,7 @@ var handler14 = async (provider, args) => {
|
|
|
1281
1318
|
}
|
|
1282
1319
|
};
|
|
1283
1320
|
}
|
|
1284
|
-
const parsed =
|
|
1321
|
+
const parsed = toolInfo15.parameters.safeParse(args);
|
|
1285
1322
|
if (!parsed.success) {
|
|
1286
1323
|
return {
|
|
1287
1324
|
type: "Error" /* Error */,
|
|
@@ -1318,19 +1355,19 @@ ${files.join("\n")}
|
|
|
1318
1355
|
}
|
|
1319
1356
|
};
|
|
1320
1357
|
var searchFiles_default = {
|
|
1321
|
-
...
|
|
1322
|
-
handler:
|
|
1358
|
+
...toolInfo15,
|
|
1359
|
+
handler: handler15
|
|
1323
1360
|
};
|
|
1324
1361
|
|
|
1325
1362
|
// src/tools/updateMemory.ts
|
|
1326
|
-
import { z as
|
|
1327
|
-
var
|
|
1363
|
+
import { z as z18 } from "zod";
|
|
1364
|
+
var toolInfo16 = {
|
|
1328
1365
|
name: "updateMemory",
|
|
1329
1366
|
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:
|
|
1367
|
+
parameters: z18.object({
|
|
1368
|
+
operation: z18.enum(["append", "replace", "remove"]).describe("The operation to perform."),
|
|
1369
|
+
topic: z18.string().nullish().describe('The topic to update in memory. Defaults to ":default:".'),
|
|
1370
|
+
content: z18.string().nullish().describe("The content for append or replace operations. Must be omitted for remove operation.")
|
|
1334
1371
|
}).superRefine((data, ctx) => {
|
|
1335
1372
|
if (data.operation === "append" || data.operation === "replace") {
|
|
1336
1373
|
if (data.content === void 0) {
|
|
@@ -1351,7 +1388,7 @@ var toolInfo15 = {
|
|
|
1351
1388
|
}
|
|
1352
1389
|
})
|
|
1353
1390
|
};
|
|
1354
|
-
var
|
|
1391
|
+
var handler16 = async (provider, args) => {
|
|
1355
1392
|
if (!provider.updateMemory) {
|
|
1356
1393
|
return {
|
|
1357
1394
|
type: "Error" /* Error */,
|
|
@@ -1361,7 +1398,7 @@ var handler15 = async (provider, args) => {
|
|
|
1361
1398
|
}
|
|
1362
1399
|
};
|
|
1363
1400
|
}
|
|
1364
|
-
const params =
|
|
1401
|
+
const params = toolInfo16.parameters.parse(args);
|
|
1365
1402
|
await provider.updateMemory(params.operation, params.topic ?? void 0, params.content ?? void 0);
|
|
1366
1403
|
switch (params.operation) {
|
|
1367
1404
|
case "append":
|
|
@@ -1391,17 +1428,17 @@ var handler15 = async (provider, args) => {
|
|
|
1391
1428
|
}
|
|
1392
1429
|
};
|
|
1393
1430
|
var updateMemory_default = {
|
|
1394
|
-
...
|
|
1395
|
-
handler:
|
|
1431
|
+
...toolInfo16,
|
|
1432
|
+
handler: handler16
|
|
1396
1433
|
};
|
|
1397
1434
|
|
|
1398
1435
|
// src/tools/updateTodoItem.ts
|
|
1399
|
-
var
|
|
1436
|
+
var toolInfo17 = {
|
|
1400
1437
|
name: "updateTodoItem",
|
|
1401
1438
|
description: "Add or update a to-do item.",
|
|
1402
1439
|
parameters: UpdateTodoItemInputSchema
|
|
1403
1440
|
};
|
|
1404
|
-
var
|
|
1441
|
+
var handler17 = async (provider, args) => {
|
|
1405
1442
|
if (!provider.updateTodoItem) {
|
|
1406
1443
|
return {
|
|
1407
1444
|
type: "Error" /* Error */,
|
|
@@ -1411,7 +1448,7 @@ var handler16 = async (provider, args) => {
|
|
|
1411
1448
|
}
|
|
1412
1449
|
};
|
|
1413
1450
|
}
|
|
1414
|
-
const input =
|
|
1451
|
+
const input = toolInfo17.parameters.parse(args);
|
|
1415
1452
|
const result = await provider.updateTodoItem(input);
|
|
1416
1453
|
return {
|
|
1417
1454
|
type: "Reply" /* Reply */,
|
|
@@ -1422,18 +1459,18 @@ var handler16 = async (provider, args) => {
|
|
|
1422
1459
|
};
|
|
1423
1460
|
};
|
|
1424
1461
|
var updateTodoItem_default = {
|
|
1425
|
-
...
|
|
1426
|
-
handler:
|
|
1462
|
+
...toolInfo17,
|
|
1463
|
+
handler: handler17
|
|
1427
1464
|
};
|
|
1428
1465
|
|
|
1429
1466
|
// src/tools/writeToFile.ts
|
|
1430
|
-
import { z as
|
|
1431
|
-
var
|
|
1467
|
+
import { z as z19 } from "zod";
|
|
1468
|
+
var toolInfo18 = {
|
|
1432
1469
|
name: "writeToFile",
|
|
1433
1470
|
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:
|
|
1471
|
+
parameters: z19.object({
|
|
1472
|
+
path: z19.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
|
|
1473
|
+
content: z19.string().describe(
|
|
1437
1474
|
"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
1475
|
).meta({ usageValue: "Your file content here" })
|
|
1439
1476
|
}).meta({
|
|
@@ -1459,7 +1496,7 @@ export default App;
|
|
|
1459
1496
|
]
|
|
1460
1497
|
})
|
|
1461
1498
|
};
|
|
1462
|
-
var
|
|
1499
|
+
var handler18 = async (provider, args) => {
|
|
1463
1500
|
if (!provider.writeFile) {
|
|
1464
1501
|
return {
|
|
1465
1502
|
type: "Error" /* Error */,
|
|
@@ -1469,7 +1506,7 @@ var handler17 = async (provider, args) => {
|
|
|
1469
1506
|
}
|
|
1470
1507
|
};
|
|
1471
1508
|
}
|
|
1472
|
-
const parsed =
|
|
1509
|
+
const parsed = toolInfo18.parameters.safeParse(args);
|
|
1473
1510
|
if (!parsed.success) {
|
|
1474
1511
|
return {
|
|
1475
1512
|
type: "Error" /* Error */,
|
|
@@ -1492,8 +1529,8 @@ var handler17 = async (provider, args) => {
|
|
|
1492
1529
|
};
|
|
1493
1530
|
};
|
|
1494
1531
|
var writeToFile_default = {
|
|
1495
|
-
...
|
|
1496
|
-
handler:
|
|
1532
|
+
...toolInfo18,
|
|
1533
|
+
handler: handler18
|
|
1497
1534
|
};
|
|
1498
1535
|
|
|
1499
1536
|
// src/UsageMeter.ts
|
|
@@ -1646,7 +1683,7 @@ var UsageMeter = class {
|
|
|
1646
1683
|
|
|
1647
1684
|
// src/workflow/agent.workflow.ts
|
|
1648
1685
|
import { jsonSchema } from "ai";
|
|
1649
|
-
import { toJSONSchema, z as
|
|
1686
|
+
import { toJSONSchema, z as z20 } from "zod";
|
|
1650
1687
|
|
|
1651
1688
|
// src/workflow/types.ts
|
|
1652
1689
|
var TaskEventKind = /* @__PURE__ */ ((TaskEventKind2) => {
|
|
@@ -1664,13 +1701,13 @@ var TaskEventKind = /* @__PURE__ */ ((TaskEventKind2) => {
|
|
|
1664
1701
|
})(TaskEventKind || {});
|
|
1665
1702
|
|
|
1666
1703
|
// src/workflow/agent.workflow.ts
|
|
1667
|
-
var agentWorkflow = async (input, { step, tools }) => {
|
|
1704
|
+
var agentWorkflow = async (input, { step, tools, logger }) => {
|
|
1668
1705
|
const event = (name, event2) => step(name, () => tools.taskEvent(event2));
|
|
1669
|
-
const { tools:
|
|
1706
|
+
const { tools: toolInfo19, maxToolRoundTrips = 200 } = input;
|
|
1670
1707
|
const messages = "systemPrompt" in input ? [{ role: "system", content: input.systemPrompt }] : input.messages;
|
|
1671
1708
|
await event("start-task", { kind: "StartTask" /* StartTask */, systemPrompt: "systemPrompt" in input ? input.systemPrompt : "" });
|
|
1672
1709
|
const toolSet = {};
|
|
1673
|
-
for (const tool of
|
|
1710
|
+
for (const tool of toolInfo19) {
|
|
1674
1711
|
toolSet[tool.name] = {
|
|
1675
1712
|
description: tool.description,
|
|
1676
1713
|
inputSchema: jsonSchema(toJSONSchema(tool.parameters))
|
|
@@ -1696,7 +1733,11 @@ var agentWorkflow = async (input, { step, tools }) => {
|
|
|
1696
1733
|
if (msg.content) {
|
|
1697
1734
|
for (const part of msg.content) {
|
|
1698
1735
|
if (part.type === "tool-call") {
|
|
1699
|
-
|
|
1736
|
+
if (toolSet[part.toolName]) {
|
|
1737
|
+
toolCalls.push(part);
|
|
1738
|
+
} else {
|
|
1739
|
+
logger.warn("Tool not found. Skipping.", part);
|
|
1740
|
+
}
|
|
1700
1741
|
}
|
|
1701
1742
|
}
|
|
1702
1743
|
}
|
|
@@ -1730,7 +1771,7 @@ var agentWorkflow = async (input, { step, tools }) => {
|
|
|
1730
1771
|
}
|
|
1731
1772
|
const validated = input.outputSchema.safeParse(parsed.data);
|
|
1732
1773
|
if (!validated.success) {
|
|
1733
|
-
const errorMessage = `Output validation failed. Error: ${
|
|
1774
|
+
const errorMessage = `Output validation failed. Error: ${z20.prettifyError(validated.error)}. Please correct the output.`;
|
|
1734
1775
|
nextMessage = [{ role: "user", content: errorMessage }];
|
|
1735
1776
|
continue;
|
|
1736
1777
|
}
|
|
@@ -2018,6 +2059,7 @@ export {
|
|
|
2018
2059
|
replaceInFile_default as replaceInFile,
|
|
2019
2060
|
replaceInFile as replaceInFileHelper,
|
|
2020
2061
|
responsePrompts,
|
|
2062
|
+
search_default as search,
|
|
2021
2063
|
searchFiles_default as searchFiles,
|
|
2022
2064
|
toJsonModelMessage,
|
|
2023
2065
|
updateMemory_default as updateMemory,
|