@polka-codes/core 0.9.47 → 0.9.48
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 +156 -199
- package/dist/index.d.ts +1 -3
- package/dist/index.js +204 -201
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -190,43 +190,17 @@ var ToolResponseType = /* @__PURE__ */ ((ToolResponseType2) => {
|
|
|
190
190
|
return ToolResponseType2;
|
|
191
191
|
})(ToolResponseType || {});
|
|
192
192
|
|
|
193
|
-
// src/tools/appendMemory.ts
|
|
194
|
-
import { z as z2 } from "zod";
|
|
195
|
-
var toolInfo = {
|
|
196
|
-
name: "appendMemory",
|
|
197
|
-
description: "Appends content to a memory topic.",
|
|
198
|
-
parameters: z2.object({
|
|
199
|
-
topic: z2.string().nullish().describe('The topic to append to in memory. Defaults to ":default:".'),
|
|
200
|
-
content: z2.string().describe("The content to append.")
|
|
201
|
-
})
|
|
202
|
-
};
|
|
203
|
-
var handler = async (provider, args) => {
|
|
204
|
-
const { topic, content } = toolInfo.parameters.parse(args);
|
|
205
|
-
await provider.appendMemory(topic ?? void 0, content);
|
|
206
|
-
return {
|
|
207
|
-
type: "Reply" /* Reply */,
|
|
208
|
-
message: {
|
|
209
|
-
type: "text",
|
|
210
|
-
value: `Content appended to memory topic '${topic || ""}'.`
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
};
|
|
214
|
-
var appendMemory_default = {
|
|
215
|
-
...toolInfo,
|
|
216
|
-
handler
|
|
217
|
-
};
|
|
218
|
-
|
|
219
193
|
// src/tools/askFollowupQuestion.ts
|
|
220
|
-
import { z as
|
|
221
|
-
var questionObject =
|
|
222
|
-
prompt:
|
|
223
|
-
options:
|
|
194
|
+
import { z as z2 } from "zod";
|
|
195
|
+
var questionObject = z2.object({
|
|
196
|
+
prompt: z2.string().describe("The text of the question.").meta({ usageValue: "question text here" }),
|
|
197
|
+
options: z2.array(z2.string()).default([]).describe("Ordered list of suggested answers (omit if none).").meta({ usageValue: "suggested answer here" })
|
|
224
198
|
});
|
|
225
|
-
var
|
|
199
|
+
var toolInfo = {
|
|
226
200
|
name: "askFollowupQuestion",
|
|
227
201
|
description: "Call this when vital details are missing. Pose each follow-up as one direct, unambiguous question. If it speeds the reply, add up to five short, mutually-exclusive answer options. Group any related questions in the same call to avoid a back-and-forth chain.",
|
|
228
|
-
parameters:
|
|
229
|
-
questions:
|
|
202
|
+
parameters: z2.object({
|
|
203
|
+
questions: z2.array(questionObject).describe("One or more follow-up questions you need answered before you can continue.").meta({ usageValue: "questions here" })
|
|
230
204
|
}).meta({
|
|
231
205
|
examples: [
|
|
232
206
|
{
|
|
@@ -272,7 +246,7 @@ var toolInfo2 = {
|
|
|
272
246
|
]
|
|
273
247
|
})
|
|
274
248
|
};
|
|
275
|
-
var
|
|
249
|
+
var handler = async (provider, args) => {
|
|
276
250
|
if (!provider.askFollowupQuestion) {
|
|
277
251
|
return {
|
|
278
252
|
type: "Error" /* Error */,
|
|
@@ -282,7 +256,7 @@ var handler2 = async (provider, args) => {
|
|
|
282
256
|
}
|
|
283
257
|
};
|
|
284
258
|
}
|
|
285
|
-
const { questions } =
|
|
259
|
+
const { questions } = toolInfo.parameters.parse(args);
|
|
286
260
|
if (questions.length === 0) {
|
|
287
261
|
return {
|
|
288
262
|
type: "Error" /* Error */,
|
|
@@ -309,25 +283,25 @@ ${answer}
|
|
|
309
283
|
};
|
|
310
284
|
};
|
|
311
285
|
var askFollowupQuestion_default = {
|
|
312
|
-
...
|
|
313
|
-
handler
|
|
286
|
+
...toolInfo,
|
|
287
|
+
handler
|
|
314
288
|
};
|
|
315
289
|
|
|
316
290
|
// src/tools/executeCommand.ts
|
|
317
|
-
import { z as
|
|
318
|
-
var
|
|
291
|
+
import { z as z3 } from "zod";
|
|
292
|
+
var toolInfo2 = {
|
|
319
293
|
name: "executeCommand",
|
|
320
294
|
description: "Run a single CLI command. The command is always executed in the project-root working directory (regardless of earlier commands). Prefer one-off shell commands over wrapper scripts for flexibility. **IMPORTANT**: After an `execute_command` call, you MUST stop and NOT allowed to make further tool calls in the same message.",
|
|
321
|
-
parameters:
|
|
322
|
-
command:
|
|
323
|
-
requiresApproval:
|
|
295
|
+
parameters: z3.object({
|
|
296
|
+
command: z3.string().describe("The exact command to run (valid for the current OS). It must be correctly formatted and free of harmful instructions.").meta({ usageValue: "your-command-here" }),
|
|
297
|
+
requiresApproval: z3.preprocess((val) => {
|
|
324
298
|
if (typeof val === "string") {
|
|
325
299
|
const lower = val.toLowerCase();
|
|
326
300
|
if (lower === "false") return false;
|
|
327
301
|
if (lower === "true") return true;
|
|
328
302
|
}
|
|
329
303
|
return val;
|
|
330
|
-
},
|
|
304
|
+
}, z3.boolean().optional().default(false)).describe(
|
|
331
305
|
"Set to `true` for commands that install/uninstall software, modify or delete files, change system settings, perform network operations, or have other side effects. Use `false` for safe, read-only, or purely local development actions (e.g., listing files, make a build, running tests)."
|
|
332
306
|
).meta({ usageValue: "true | false" })
|
|
333
307
|
}).meta({
|
|
@@ -342,7 +316,7 @@ var toolInfo3 = {
|
|
|
342
316
|
]
|
|
343
317
|
})
|
|
344
318
|
};
|
|
345
|
-
var
|
|
319
|
+
var handler2 = async (provider, args) => {
|
|
346
320
|
if (!provider.executeCommand) {
|
|
347
321
|
return {
|
|
348
322
|
type: "Error" /* Error */,
|
|
@@ -352,7 +326,7 @@ var handler3 = async (provider, args) => {
|
|
|
352
326
|
}
|
|
353
327
|
};
|
|
354
328
|
}
|
|
355
|
-
const { command, requiresApproval } =
|
|
329
|
+
const { command, requiresApproval } = toolInfo2.parameters.parse(args);
|
|
356
330
|
try {
|
|
357
331
|
const result = await provider.executeCommand(command, requiresApproval);
|
|
358
332
|
let message = `<command>${command}</command>
|
|
@@ -399,21 +373,21 @@ ${result.stderr}
|
|
|
399
373
|
}
|
|
400
374
|
};
|
|
401
375
|
var executeCommand_default = {
|
|
402
|
-
...
|
|
403
|
-
handler:
|
|
376
|
+
...toolInfo2,
|
|
377
|
+
handler: handler2
|
|
404
378
|
};
|
|
405
379
|
|
|
406
380
|
// src/tools/fetchUrl.ts
|
|
407
|
-
import { z as
|
|
408
|
-
var
|
|
381
|
+
import { z as z4 } from "zod";
|
|
382
|
+
var toolInfo3 = {
|
|
409
383
|
name: "fetchUrl",
|
|
410
384
|
description: "Fetch the content located at one or more HTTP(S) URLs and return it in Markdown format. This works for standard web pages as well as raw files (e.g. README.md, source code) hosted on platforms like GitHub.",
|
|
411
|
-
parameters:
|
|
412
|
-
url:
|
|
385
|
+
parameters: z4.object({
|
|
386
|
+
url: z4.preprocess((val) => {
|
|
413
387
|
if (!val) return [];
|
|
414
388
|
const values = Array.isArray(val) ? val : [val];
|
|
415
389
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
416
|
-
},
|
|
390
|
+
}, z4.array(z4.string())).describe("One or more URLs to fetch, separated by commas if multiple.").meta({ usageValue: "url" })
|
|
417
391
|
}).meta({
|
|
418
392
|
examples: [
|
|
419
393
|
{
|
|
@@ -437,7 +411,7 @@ var toolInfo4 = {
|
|
|
437
411
|
]
|
|
438
412
|
})
|
|
439
413
|
};
|
|
440
|
-
var
|
|
414
|
+
var handler3 = async (provider, args) => {
|
|
441
415
|
if (!provider.fetchUrl) {
|
|
442
416
|
return {
|
|
443
417
|
type: "Error" /* Error */,
|
|
@@ -447,7 +421,7 @@ var handler4 = async (provider, args) => {
|
|
|
447
421
|
}
|
|
448
422
|
};
|
|
449
423
|
}
|
|
450
|
-
const { url: urls } =
|
|
424
|
+
const { url: urls } = toolInfo3.parameters.parse(args);
|
|
451
425
|
if (urls.length === 0) {
|
|
452
426
|
return {
|
|
453
427
|
type: "Error" /* Error */,
|
|
@@ -477,34 +451,34 @@ var handler4 = async (provider, args) => {
|
|
|
477
451
|
};
|
|
478
452
|
};
|
|
479
453
|
var fetchUrl_default = {
|
|
480
|
-
...
|
|
481
|
-
handler:
|
|
454
|
+
...toolInfo3,
|
|
455
|
+
handler: handler3
|
|
482
456
|
};
|
|
483
457
|
|
|
484
458
|
// src/tools/listFiles.ts
|
|
485
|
-
import { z as
|
|
486
|
-
var
|
|
459
|
+
import { z as z5 } from "zod";
|
|
460
|
+
var toolInfo4 = {
|
|
487
461
|
name: "listFiles",
|
|
488
462
|
description: "Request to list files and directories within the specified directory. If recursive is true, it will list all files and directories recursively. If recursive is false or not provided, it will only list the top-level contents. Do not use this tool to confirm the existence of files you may have created, as the user will let you know if the files were created successfully or not.",
|
|
489
|
-
parameters:
|
|
490
|
-
path:
|
|
491
|
-
maxCount:
|
|
492
|
-
recursive:
|
|
463
|
+
parameters: z5.object({
|
|
464
|
+
path: z5.string().describe("The path of the directory to list contents for (relative to the current working directory)").meta({ usageValue: "Directory path here" }),
|
|
465
|
+
maxCount: z5.coerce.number().optional().default(2e3).describe("The maximum number of files to list. Default to 2000").meta({ usageValue: "Maximum number of files to list (optional)" }),
|
|
466
|
+
recursive: z5.preprocess((val) => {
|
|
493
467
|
if (typeof val === "string") {
|
|
494
468
|
const lower = val.toLowerCase();
|
|
495
469
|
if (lower === "false") return false;
|
|
496
470
|
if (lower === "true") return true;
|
|
497
471
|
}
|
|
498
472
|
return val;
|
|
499
|
-
},
|
|
500
|
-
includeIgnored:
|
|
473
|
+
}, z5.boolean().optional().default(true)).describe("Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.").meta({ usageValue: "true or false (optional)" }),
|
|
474
|
+
includeIgnored: z5.preprocess((val) => {
|
|
501
475
|
if (typeof val === "string") {
|
|
502
476
|
const lower = val.toLowerCase();
|
|
503
477
|
if (lower === "false") return false;
|
|
504
478
|
if (lower === "true") return true;
|
|
505
479
|
}
|
|
506
480
|
return val;
|
|
507
|
-
},
|
|
481
|
+
}, z5.boolean().optional().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
|
|
508
482
|
}).meta({
|
|
509
483
|
examples: [
|
|
510
484
|
{
|
|
@@ -517,7 +491,7 @@ var toolInfo5 = {
|
|
|
517
491
|
]
|
|
518
492
|
})
|
|
519
493
|
};
|
|
520
|
-
var
|
|
494
|
+
var handler4 = async (provider, args) => {
|
|
521
495
|
if (!provider.listFiles) {
|
|
522
496
|
return {
|
|
523
497
|
type: "Error" /* Error */,
|
|
@@ -527,7 +501,7 @@ var handler5 = async (provider, args) => {
|
|
|
527
501
|
}
|
|
528
502
|
};
|
|
529
503
|
}
|
|
530
|
-
const { path, maxCount, recursive, includeIgnored } =
|
|
504
|
+
const { path, maxCount, recursive, includeIgnored } = toolInfo4.parameters.parse(args);
|
|
531
505
|
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
|
|
532
506
|
return {
|
|
533
507
|
type: "Reply" /* Reply */,
|
|
@@ -542,18 +516,18 @@ ${files.join("\n")}
|
|
|
542
516
|
};
|
|
543
517
|
};
|
|
544
518
|
var listFiles_default = {
|
|
545
|
-
...
|
|
546
|
-
handler:
|
|
519
|
+
...toolInfo4,
|
|
520
|
+
handler: handler4
|
|
547
521
|
};
|
|
548
522
|
|
|
549
523
|
// src/tools/listMemoryTopics.ts
|
|
550
|
-
import { z as
|
|
551
|
-
var
|
|
524
|
+
import { z as z6 } from "zod";
|
|
525
|
+
var toolInfo5 = {
|
|
552
526
|
name: "listMemoryTopics",
|
|
553
527
|
description: "Lists all topics in memory.",
|
|
554
|
-
parameters:
|
|
528
|
+
parameters: z6.object({})
|
|
555
529
|
};
|
|
556
|
-
var
|
|
530
|
+
var handler5 = async (provider, _args) => {
|
|
557
531
|
const topics = await provider.listMemoryTopics();
|
|
558
532
|
if (!topics.length) {
|
|
559
533
|
return { type: "Reply" /* Reply */, message: { type: "text", value: "No topics found." } };
|
|
@@ -568,8 +542,8 @@ ${topics.join("\n")}`
|
|
|
568
542
|
};
|
|
569
543
|
};
|
|
570
544
|
var listMemoryTopics_default = {
|
|
571
|
-
...
|
|
572
|
-
handler:
|
|
545
|
+
...toolInfo5,
|
|
546
|
+
handler: handler5
|
|
573
547
|
};
|
|
574
548
|
|
|
575
549
|
// src/tools/provider.ts
|
|
@@ -598,18 +572,27 @@ var MockProvider = class {
|
|
|
598
572
|
async askFollowupQuestion(_question, _options) {
|
|
599
573
|
return "mock answer";
|
|
600
574
|
}
|
|
575
|
+
async listMemoryTopics() {
|
|
576
|
+
return ["default"];
|
|
577
|
+
}
|
|
578
|
+
async readMemory(_topic) {
|
|
579
|
+
return "mock memory content";
|
|
580
|
+
}
|
|
581
|
+
async updateMemory(_operation, _topic, _content) {
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
601
584
|
};
|
|
602
585
|
|
|
603
586
|
// src/tools/readBinaryFile.ts
|
|
604
|
-
import { z as
|
|
605
|
-
var
|
|
587
|
+
import { z as z7 } from "zod";
|
|
588
|
+
var toolInfo6 = {
|
|
606
589
|
name: "readBinaryFile",
|
|
607
590
|
description: "Read a binary file from a URL or local path. Use file:// prefix to access local files. This can be used to access non-text files such as PDFs or images.",
|
|
608
|
-
parameters:
|
|
609
|
-
url:
|
|
591
|
+
parameters: z7.object({
|
|
592
|
+
url: z7.string().describe("The URL or local path of the file to read.")
|
|
610
593
|
})
|
|
611
594
|
};
|
|
612
|
-
var
|
|
595
|
+
var handler6 = async (provider, args) => {
|
|
613
596
|
if (!provider.readBinaryFile) {
|
|
614
597
|
return {
|
|
615
598
|
type: "Error" /* Error */,
|
|
@@ -619,7 +602,7 @@ var handler7 = async (provider, args) => {
|
|
|
619
602
|
}
|
|
620
603
|
};
|
|
621
604
|
}
|
|
622
|
-
const { url } =
|
|
605
|
+
const { url } = toolInfo6.parameters.parse(args);
|
|
623
606
|
try {
|
|
624
607
|
const filePart = await provider.readBinaryFile(url);
|
|
625
608
|
return {
|
|
@@ -648,29 +631,29 @@ var handler7 = async (provider, args) => {
|
|
|
648
631
|
}
|
|
649
632
|
};
|
|
650
633
|
var readBinaryFile_default = {
|
|
651
|
-
...
|
|
652
|
-
handler:
|
|
634
|
+
...toolInfo6,
|
|
635
|
+
handler: handler6
|
|
653
636
|
};
|
|
654
637
|
|
|
655
638
|
// src/tools/readFile.ts
|
|
656
|
-
import { z as
|
|
657
|
-
var
|
|
639
|
+
import { z as z8 } from "zod";
|
|
640
|
+
var toolInfo7 = {
|
|
658
641
|
name: "readFile",
|
|
659
642
|
description: "Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string. Try to list all the potential files are relevent to the task, and then use this tool to read all the relevant files.",
|
|
660
|
-
parameters:
|
|
661
|
-
path:
|
|
643
|
+
parameters: z8.object({
|
|
644
|
+
path: z8.preprocess((val) => {
|
|
662
645
|
if (!val) return [];
|
|
663
646
|
const values = Array.isArray(val) ? val : [val];
|
|
664
647
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
665
|
-
},
|
|
666
|
-
includeIgnored:
|
|
648
|
+
}, z8.array(z8.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" }),
|
|
649
|
+
includeIgnored: z8.preprocess((val) => {
|
|
667
650
|
if (typeof val === "string") {
|
|
668
651
|
const lower = val.toLowerCase();
|
|
669
652
|
if (lower === "false") return false;
|
|
670
653
|
if (lower === "true") return true;
|
|
671
654
|
}
|
|
672
655
|
return val;
|
|
673
|
-
},
|
|
656
|
+
}, z8.boolean().optional().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
|
|
674
657
|
}).meta({
|
|
675
658
|
examples: [
|
|
676
659
|
{
|
|
@@ -688,7 +671,7 @@ var toolInfo8 = {
|
|
|
688
671
|
]
|
|
689
672
|
})
|
|
690
673
|
};
|
|
691
|
-
var
|
|
674
|
+
var handler7 = async (provider, args) => {
|
|
692
675
|
if (!provider.readFile) {
|
|
693
676
|
return {
|
|
694
677
|
type: "Error" /* Error */,
|
|
@@ -698,7 +681,7 @@ var handler8 = async (provider, args) => {
|
|
|
698
681
|
}
|
|
699
682
|
};
|
|
700
683
|
}
|
|
701
|
-
const { path: paths, includeIgnored } =
|
|
684
|
+
const { path: paths, includeIgnored } = toolInfo7.parameters.parse(args);
|
|
702
685
|
const resp = [];
|
|
703
686
|
for (const path of paths) {
|
|
704
687
|
const fileContent = await provider.readFile(path, includeIgnored);
|
|
@@ -722,21 +705,21 @@ var handler8 = async (provider, args) => {
|
|
|
722
705
|
};
|
|
723
706
|
};
|
|
724
707
|
var readFile_default = {
|
|
725
|
-
...
|
|
726
|
-
handler:
|
|
708
|
+
...toolInfo7,
|
|
709
|
+
handler: handler7
|
|
727
710
|
};
|
|
728
711
|
|
|
729
712
|
// src/tools/readMemory.ts
|
|
730
|
-
import { z as
|
|
731
|
-
var
|
|
713
|
+
import { z as z9 } from "zod";
|
|
714
|
+
var toolInfo8 = {
|
|
732
715
|
name: "readMemory",
|
|
733
716
|
description: "Reads content from a memory topic.",
|
|
734
|
-
parameters:
|
|
735
|
-
topic:
|
|
717
|
+
parameters: z9.object({
|
|
718
|
+
topic: z9.string().optional().describe('The topic to read from memory. Defaults to ":default:".')
|
|
736
719
|
})
|
|
737
720
|
};
|
|
738
|
-
var
|
|
739
|
-
const { topic } =
|
|
721
|
+
var handler8 = async (provider, args) => {
|
|
722
|
+
const { topic } = toolInfo8.parameters.parse(args);
|
|
740
723
|
const content = await provider.readMemory(topic);
|
|
741
724
|
if (content) {
|
|
742
725
|
return {
|
|
@@ -758,17 +741,17 @@ ${content}
|
|
|
758
741
|
};
|
|
759
742
|
};
|
|
760
743
|
var readMemory_default = {
|
|
761
|
-
...
|
|
762
|
-
handler:
|
|
744
|
+
...toolInfo8,
|
|
745
|
+
handler: handler8
|
|
763
746
|
};
|
|
764
747
|
|
|
765
748
|
// src/tools/removeFile.ts
|
|
766
|
-
import { z as
|
|
767
|
-
var
|
|
749
|
+
import { z as z10 } from "zod";
|
|
750
|
+
var toolInfo9 = {
|
|
768
751
|
name: "removeFile",
|
|
769
752
|
description: "Request to remove a file at the specified path.",
|
|
770
|
-
parameters:
|
|
771
|
-
path:
|
|
753
|
+
parameters: z10.object({
|
|
754
|
+
path: z10.string().describe("The path of the file to remove").meta({ usageValue: "File path here" })
|
|
772
755
|
}).meta({
|
|
773
756
|
examples: [
|
|
774
757
|
{
|
|
@@ -780,7 +763,7 @@ var toolInfo10 = {
|
|
|
780
763
|
]
|
|
781
764
|
})
|
|
782
765
|
};
|
|
783
|
-
var
|
|
766
|
+
var handler9 = async (provider, args) => {
|
|
784
767
|
if (!provider.removeFile) {
|
|
785
768
|
return {
|
|
786
769
|
type: "Error" /* Error */,
|
|
@@ -790,7 +773,7 @@ var handler10 = async (provider, args) => {
|
|
|
790
773
|
}
|
|
791
774
|
};
|
|
792
775
|
}
|
|
793
|
-
const parsed =
|
|
776
|
+
const parsed = toolInfo9.parameters.safeParse(args);
|
|
794
777
|
if (!parsed.success) {
|
|
795
778
|
return {
|
|
796
779
|
type: "Error" /* Error */,
|
|
@@ -811,43 +794,18 @@ var handler10 = async (provider, args) => {
|
|
|
811
794
|
};
|
|
812
795
|
};
|
|
813
796
|
var removeFile_default = {
|
|
814
|
-
...
|
|
815
|
-
handler:
|
|
816
|
-
};
|
|
817
|
-
|
|
818
|
-
// src/tools/removeMemory.ts
|
|
819
|
-
import { z as z12 } from "zod";
|
|
820
|
-
var toolInfo11 = {
|
|
821
|
-
name: "removeMemory",
|
|
822
|
-
description: "Removes a topic from memory.",
|
|
823
|
-
parameters: z12.object({
|
|
824
|
-
topic: z12.string().optional().describe('The topic to remove from memory. Defaults to ":default:".')
|
|
825
|
-
})
|
|
826
|
-
};
|
|
827
|
-
var handler11 = async (provider, args) => {
|
|
828
|
-
const { topic } = toolInfo11.parameters.parse(args);
|
|
829
|
-
await provider.removeMemory(topic);
|
|
830
|
-
return {
|
|
831
|
-
type: "Reply" /* Reply */,
|
|
832
|
-
message: {
|
|
833
|
-
type: "text",
|
|
834
|
-
value: `Memory topic '${topic || ""}' removed.`
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
|
-
};
|
|
838
|
-
var removeMemory_default = {
|
|
839
|
-
...toolInfo11,
|
|
840
|
-
handler: handler11
|
|
797
|
+
...toolInfo9,
|
|
798
|
+
handler: handler9
|
|
841
799
|
};
|
|
842
800
|
|
|
843
801
|
// src/tools/renameFile.ts
|
|
844
|
-
import { z as
|
|
845
|
-
var
|
|
802
|
+
import { z as z11 } from "zod";
|
|
803
|
+
var toolInfo10 = {
|
|
846
804
|
name: "renameFile",
|
|
847
805
|
description: "Request to rename a file from source path to target path.",
|
|
848
|
-
parameters:
|
|
849
|
-
source_path:
|
|
850
|
-
target_path:
|
|
806
|
+
parameters: z11.object({
|
|
807
|
+
source_path: z11.string().describe("The current path of the file").meta({ usageValue: "Source file path here" }),
|
|
808
|
+
target_path: z11.string().describe("The new path for the file").meta({ usageValue: "Target file path here" })
|
|
851
809
|
}).meta({
|
|
852
810
|
examples: [
|
|
853
811
|
{
|
|
@@ -860,7 +818,7 @@ var toolInfo12 = {
|
|
|
860
818
|
]
|
|
861
819
|
})
|
|
862
820
|
};
|
|
863
|
-
var
|
|
821
|
+
var handler10 = async (provider, args) => {
|
|
864
822
|
if (!provider.renameFile) {
|
|
865
823
|
return {
|
|
866
824
|
type: "Error" /* Error */,
|
|
@@ -870,7 +828,7 @@ var handler12 = async (provider, args) => {
|
|
|
870
828
|
}
|
|
871
829
|
};
|
|
872
830
|
}
|
|
873
|
-
const { source_path, target_path } =
|
|
831
|
+
const { source_path, target_path } = toolInfo10.parameters.parse(args);
|
|
874
832
|
await provider.renameFile(source_path, target_path);
|
|
875
833
|
return {
|
|
876
834
|
type: "Reply" /* Reply */,
|
|
@@ -881,12 +839,12 @@ var handler12 = async (provider, args) => {
|
|
|
881
839
|
};
|
|
882
840
|
};
|
|
883
841
|
var renameFile_default = {
|
|
884
|
-
...
|
|
885
|
-
handler:
|
|
842
|
+
...toolInfo10,
|
|
843
|
+
handler: handler10
|
|
886
844
|
};
|
|
887
845
|
|
|
888
846
|
// src/tools/replaceInFile.ts
|
|
889
|
-
import { z as
|
|
847
|
+
import { z as z12 } from "zod";
|
|
890
848
|
|
|
891
849
|
// src/tools/utils/replaceInFile.ts
|
|
892
850
|
var replaceInFile = (fileContent, diff) => {
|
|
@@ -963,12 +921,12 @@ var replaceInFile = (fileContent, diff) => {
|
|
|
963
921
|
};
|
|
964
922
|
|
|
965
923
|
// src/tools/replaceInFile.ts
|
|
966
|
-
var
|
|
924
|
+
var toolInfo11 = {
|
|
967
925
|
name: "replaceInFile",
|
|
968
926
|
description: "Request to replace sections of content in an existing file using SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file.",
|
|
969
|
-
parameters:
|
|
970
|
-
path:
|
|
971
|
-
diff:
|
|
927
|
+
parameters: z12.object({
|
|
928
|
+
path: z12.string().describe("The path of the file to modify").meta({ usageValue: "File path here" }),
|
|
929
|
+
diff: z12.string().describe(
|
|
972
930
|
`One or more SEARCH/REPLACE blocks following this exact format:
|
|
973
931
|
\`\`\`
|
|
974
932
|
<<<<<<< SEARCH
|
|
@@ -1075,7 +1033,7 @@ function oldFeature() {
|
|
|
1075
1033
|
]
|
|
1076
1034
|
})
|
|
1077
1035
|
};
|
|
1078
|
-
var
|
|
1036
|
+
var handler11 = async (provider, args) => {
|
|
1079
1037
|
if (!provider.readFile || !provider.writeFile) {
|
|
1080
1038
|
return {
|
|
1081
1039
|
type: "Error" /* Error */,
|
|
@@ -1085,7 +1043,7 @@ var handler13 = async (provider, args) => {
|
|
|
1085
1043
|
}
|
|
1086
1044
|
};
|
|
1087
1045
|
}
|
|
1088
|
-
const parsed =
|
|
1046
|
+
const parsed = toolInfo11.parameters.safeParse(args);
|
|
1089
1047
|
if (!parsed.success) {
|
|
1090
1048
|
return {
|
|
1091
1049
|
type: "Error" /* Error */,
|
|
@@ -1149,49 +1107,23 @@ var handler13 = async (provider, args) => {
|
|
|
1149
1107
|
}
|
|
1150
1108
|
};
|
|
1151
1109
|
var replaceInFile_default = {
|
|
1152
|
-
...
|
|
1153
|
-
handler:
|
|
1154
|
-
};
|
|
1155
|
-
|
|
1156
|
-
// src/tools/replaceMemory.ts
|
|
1157
|
-
import { z as z15 } from "zod";
|
|
1158
|
-
var toolInfo14 = {
|
|
1159
|
-
name: "replaceMemory",
|
|
1160
|
-
description: "Replaces content of a memory topic.",
|
|
1161
|
-
parameters: z15.object({
|
|
1162
|
-
topic: z15.string().optional().describe('The topic to replace in memory. Defaults to ":default:".'),
|
|
1163
|
-
content: z15.string().describe("The new content.")
|
|
1164
|
-
})
|
|
1165
|
-
};
|
|
1166
|
-
var handler14 = async (provider, args) => {
|
|
1167
|
-
const { topic, content } = toolInfo14.parameters.parse(args);
|
|
1168
|
-
await provider.replaceMemory(topic, content);
|
|
1169
|
-
return {
|
|
1170
|
-
type: "Reply" /* Reply */,
|
|
1171
|
-
message: {
|
|
1172
|
-
type: "text",
|
|
1173
|
-
value: `Memory topic '${topic || ""}' replaced.`
|
|
1174
|
-
}
|
|
1175
|
-
};
|
|
1176
|
-
};
|
|
1177
|
-
var replaceMemory_default = {
|
|
1178
|
-
...toolInfo14,
|
|
1179
|
-
handler: handler14
|
|
1110
|
+
...toolInfo11,
|
|
1111
|
+
handler: handler11
|
|
1180
1112
|
};
|
|
1181
1113
|
|
|
1182
1114
|
// src/tools/searchFiles.ts
|
|
1183
|
-
import { z as
|
|
1184
|
-
var
|
|
1115
|
+
import { z as z13 } from "zod";
|
|
1116
|
+
var toolInfo12 = {
|
|
1185
1117
|
name: "searchFiles",
|
|
1186
1118
|
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.",
|
|
1187
|
-
parameters:
|
|
1188
|
-
path:
|
|
1119
|
+
parameters: z13.object({
|
|
1120
|
+
path: z13.string().describe(
|
|
1189
1121
|
"The path of the directory to search in (relative to the current working directory). This directory will be recursively searched."
|
|
1190
1122
|
).meta({ usageValue: "Directory path here" }),
|
|
1191
|
-
regex:
|
|
1123
|
+
regex: z13.string().describe("The regular expression pattern to search for. Uses Rust regex syntax.").meta({
|
|
1192
1124
|
usageValue: "Your regex pattern here"
|
|
1193
1125
|
}),
|
|
1194
|
-
filePattern:
|
|
1126
|
+
filePattern: z13.string().optional().describe(
|
|
1195
1127
|
'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 (*).'
|
|
1196
1128
|
).meta({
|
|
1197
1129
|
usageValue: "file pattern here (optional)"
|
|
@@ -1209,7 +1141,7 @@ var toolInfo15 = {
|
|
|
1209
1141
|
]
|
|
1210
1142
|
})
|
|
1211
1143
|
};
|
|
1212
|
-
var
|
|
1144
|
+
var handler12 = async (provider, args) => {
|
|
1213
1145
|
if (!provider.searchFiles) {
|
|
1214
1146
|
return {
|
|
1215
1147
|
type: "Error" /* Error */,
|
|
@@ -1219,7 +1151,7 @@ var handler15 = async (provider, args) => {
|
|
|
1219
1151
|
}
|
|
1220
1152
|
};
|
|
1221
1153
|
}
|
|
1222
|
-
const parsed =
|
|
1154
|
+
const parsed = toolInfo12.parameters.safeParse(args);
|
|
1223
1155
|
if (!parsed.success) {
|
|
1224
1156
|
return {
|
|
1225
1157
|
type: "Error" /* Error */,
|
|
@@ -1256,18 +1188,91 @@ ${files.join("\n")}
|
|
|
1256
1188
|
}
|
|
1257
1189
|
};
|
|
1258
1190
|
var searchFiles_default = {
|
|
1259
|
-
...
|
|
1260
|
-
handler:
|
|
1191
|
+
...toolInfo12,
|
|
1192
|
+
handler: handler12
|
|
1193
|
+
};
|
|
1194
|
+
|
|
1195
|
+
// src/tools/updateMemory.ts
|
|
1196
|
+
import { z as z14 } from "zod";
|
|
1197
|
+
var toolInfo13 = {
|
|
1198
|
+
name: "updateMemory",
|
|
1199
|
+
description: "Appends, replaces, or removes content from a memory topic.",
|
|
1200
|
+
parameters: z14.object({
|
|
1201
|
+
operation: z14.enum(["append", "replace", "remove"]).describe("The operation to perform."),
|
|
1202
|
+
topic: z14.string().nullish().describe('The topic to update in memory. Defaults to ":default:".'),
|
|
1203
|
+
content: z14.string().optional().describe("The content for append or replace operations. Must be omitted for remove operation.")
|
|
1204
|
+
}).superRefine((data, ctx) => {
|
|
1205
|
+
if (data.operation === "append" || data.operation === "replace") {
|
|
1206
|
+
if (data.content === void 0) {
|
|
1207
|
+
ctx.addIssue({
|
|
1208
|
+
code: "custom",
|
|
1209
|
+
message: 'Content is required for "append" and "replace" operations.',
|
|
1210
|
+
path: ["content"]
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
} else if (data.operation === "remove") {
|
|
1214
|
+
if (data.content !== void 0) {
|
|
1215
|
+
ctx.addIssue({
|
|
1216
|
+
code: "custom",
|
|
1217
|
+
message: 'Content must not be provided for "remove" operation.',
|
|
1218
|
+
path: ["content"]
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
})
|
|
1223
|
+
};
|
|
1224
|
+
var handler13 = async (provider, args) => {
|
|
1225
|
+
if (!provider.updateMemory) {
|
|
1226
|
+
return {
|
|
1227
|
+
type: "Error" /* Error */,
|
|
1228
|
+
message: {
|
|
1229
|
+
type: "error-text",
|
|
1230
|
+
value: "Memory operations are not supported by the current provider."
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
const params = toolInfo13.parameters.parse(args);
|
|
1235
|
+
await provider.updateMemory(params.operation, params.topic ?? void 0, "content" in params ? params.content : void 0);
|
|
1236
|
+
switch (params.operation) {
|
|
1237
|
+
case "append":
|
|
1238
|
+
return {
|
|
1239
|
+
type: "Reply" /* Reply */,
|
|
1240
|
+
message: {
|
|
1241
|
+
type: "text",
|
|
1242
|
+
value: `Content appended to memory topic '${params.topic || ":default:"}'.`
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1245
|
+
case "replace":
|
|
1246
|
+
return {
|
|
1247
|
+
type: "Reply" /* Reply */,
|
|
1248
|
+
message: {
|
|
1249
|
+
type: "text",
|
|
1250
|
+
value: `Memory topic '${params.topic || ":default:"}' replaced.`
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
case "remove":
|
|
1254
|
+
return {
|
|
1255
|
+
type: "Reply" /* Reply */,
|
|
1256
|
+
message: {
|
|
1257
|
+
type: "text",
|
|
1258
|
+
value: `Memory topic '${params.topic || ":default:"}' removed.`
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
var updateMemory_default = {
|
|
1264
|
+
...toolInfo13,
|
|
1265
|
+
handler: handler13
|
|
1261
1266
|
};
|
|
1262
1267
|
|
|
1263
1268
|
// src/tools/writeToFile.ts
|
|
1264
|
-
import { z as
|
|
1265
|
-
var
|
|
1269
|
+
import { z as z15 } from "zod";
|
|
1270
|
+
var toolInfo14 = {
|
|
1266
1271
|
name: "writeToFile",
|
|
1267
1272
|
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.",
|
|
1268
|
-
parameters:
|
|
1269
|
-
path:
|
|
1270
|
-
content:
|
|
1273
|
+
parameters: z15.object({
|
|
1274
|
+
path: z15.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
|
|
1275
|
+
content: z15.string().describe(
|
|
1271
1276
|
"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."
|
|
1272
1277
|
).meta({ usageValue: "Your file content here" })
|
|
1273
1278
|
}).meta({
|
|
@@ -1293,7 +1298,7 @@ export default App;
|
|
|
1293
1298
|
]
|
|
1294
1299
|
})
|
|
1295
1300
|
};
|
|
1296
|
-
var
|
|
1301
|
+
var handler14 = async (provider, args) => {
|
|
1297
1302
|
if (!provider.writeFile) {
|
|
1298
1303
|
return {
|
|
1299
1304
|
type: "Error" /* Error */,
|
|
@@ -1303,7 +1308,7 @@ var handler16 = async (provider, args) => {
|
|
|
1303
1308
|
}
|
|
1304
1309
|
};
|
|
1305
1310
|
}
|
|
1306
|
-
const parsed =
|
|
1311
|
+
const parsed = toolInfo14.parameters.safeParse(args);
|
|
1307
1312
|
if (!parsed.success) {
|
|
1308
1313
|
return {
|
|
1309
1314
|
type: "Error" /* Error */,
|
|
@@ -1326,8 +1331,8 @@ var handler16 = async (provider, args) => {
|
|
|
1326
1331
|
};
|
|
1327
1332
|
};
|
|
1328
1333
|
var writeToFile_default = {
|
|
1329
|
-
...
|
|
1330
|
-
handler:
|
|
1334
|
+
...toolInfo14,
|
|
1335
|
+
handler: handler14
|
|
1331
1336
|
};
|
|
1332
1337
|
|
|
1333
1338
|
// src/UsageMeter.ts
|
|
@@ -1481,7 +1486,6 @@ export {
|
|
|
1481
1486
|
MockProvider,
|
|
1482
1487
|
ToolResponseType,
|
|
1483
1488
|
UsageMeter,
|
|
1484
|
-
appendMemory_default as appendMemory,
|
|
1485
1489
|
askFollowupQuestion_default as askFollowupQuestion,
|
|
1486
1490
|
computeRateLimitBackoffSeconds,
|
|
1487
1491
|
configSchema,
|
|
@@ -1494,12 +1498,11 @@ export {
|
|
|
1494
1498
|
readFile_default as readFile,
|
|
1495
1499
|
readMemory_default as readMemory,
|
|
1496
1500
|
removeFile_default as removeFile,
|
|
1497
|
-
removeMemory_default as removeMemory,
|
|
1498
1501
|
renameFile_default as renameFile,
|
|
1499
1502
|
replaceInFile_default as replaceInFile,
|
|
1500
1503
|
replaceInFile as replaceInFileHelper,
|
|
1501
|
-
replaceMemory_default as replaceMemory,
|
|
1502
1504
|
responsePrompts,
|
|
1503
1505
|
searchFiles_default as searchFiles,
|
|
1506
|
+
updateMemory_default as updateMemory,
|
|
1504
1507
|
writeToFile_default as writeToFile
|
|
1505
1508
|
};
|