@polka-codes/core 0.9.47 → 0.9.49
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 +368 -165
- package/dist/index.d.ts +14 -3
- package/dist/index.js +339 -164
- 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,6 +451,40 @@ var handler4 = async (provider, args) => {
|
|
|
477
451
|
};
|
|
478
452
|
};
|
|
479
453
|
var fetchUrl_default = {
|
|
454
|
+
...toolInfo3,
|
|
455
|
+
handler: handler3
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
// src/tools/getTodoItem.ts
|
|
459
|
+
import { z as z5 } from "zod";
|
|
460
|
+
var toolInfo4 = {
|
|
461
|
+
name: "getTodoItem",
|
|
462
|
+
description: "Get a to-do item by its ID.",
|
|
463
|
+
parameters: z5.object({
|
|
464
|
+
id: z5.string().describe("The ID of the to-do item.")
|
|
465
|
+
})
|
|
466
|
+
};
|
|
467
|
+
var handler4 = async (provider, args) => {
|
|
468
|
+
if (!provider.getTodoItem) {
|
|
469
|
+
return {
|
|
470
|
+
type: "Error" /* Error */,
|
|
471
|
+
message: {
|
|
472
|
+
type: "error-text",
|
|
473
|
+
value: "Not possible to get a to-do item."
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
const { id } = toolInfo4.parameters.parse(args);
|
|
478
|
+
const item = await provider.getTodoItem(id);
|
|
479
|
+
return {
|
|
480
|
+
type: "Reply" /* Reply */,
|
|
481
|
+
message: {
|
|
482
|
+
type: "json",
|
|
483
|
+
value: item ?? null
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
var getTodoItem_default = {
|
|
480
488
|
...toolInfo4,
|
|
481
489
|
handler: handler4
|
|
482
490
|
};
|
|
@@ -550,7 +558,7 @@ var listFiles_default = {
|
|
|
550
558
|
import { z as z7 } from "zod";
|
|
551
559
|
var toolInfo6 = {
|
|
552
560
|
name: "listMemoryTopics",
|
|
553
|
-
description: "Lists all topics in memory.",
|
|
561
|
+
description: "Lists all topics in memory. Use this to see what information has been stored and which topics are available to read from.",
|
|
554
562
|
parameters: z7.object({})
|
|
555
563
|
};
|
|
556
564
|
var handler6 = async (provider, _args) => {
|
|
@@ -572,8 +580,108 @@ var listMemoryTopics_default = {
|
|
|
572
580
|
handler: handler6
|
|
573
581
|
};
|
|
574
582
|
|
|
583
|
+
// src/tools/listTodoItems.ts
|
|
584
|
+
import { z as z9 } from "zod";
|
|
585
|
+
|
|
586
|
+
// src/tools/todo.ts
|
|
587
|
+
import { z as z8 } from "zod";
|
|
588
|
+
var TodoStatus = z8.enum(["open", "completed", "closed"]);
|
|
589
|
+
var TodoItemSchema = z8.object({
|
|
590
|
+
id: z8.string(),
|
|
591
|
+
title: z8.string(),
|
|
592
|
+
description: z8.string(),
|
|
593
|
+
relevantFileList: z8.array(z8.string()),
|
|
594
|
+
status: TodoStatus
|
|
595
|
+
});
|
|
596
|
+
var UpdateTodoItemInputSchema = z8.object({
|
|
597
|
+
operation: z8.enum(["add", "update"]),
|
|
598
|
+
id: z8.string().nullish(),
|
|
599
|
+
parentId: z8.string().nullish(),
|
|
600
|
+
title: z8.string().nullish(),
|
|
601
|
+
description: z8.string().nullish(),
|
|
602
|
+
relevantFileList: z8.array(z8.string()).nullish(),
|
|
603
|
+
status: TodoStatus.nullish()
|
|
604
|
+
}).superRefine((data, ctx) => {
|
|
605
|
+
if (data.operation === "add") {
|
|
606
|
+
if (!data.title) {
|
|
607
|
+
ctx.addIssue({
|
|
608
|
+
code: "custom",
|
|
609
|
+
message: 'Title is required for "add" operation',
|
|
610
|
+
path: ["title"]
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
} else if (data.operation === "update") {
|
|
614
|
+
if (!data.id) {
|
|
615
|
+
ctx.addIssue({
|
|
616
|
+
code: "custom",
|
|
617
|
+
message: 'ID is required for "update" operation',
|
|
618
|
+
path: ["id"]
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
var UpdateTodoItemOutputSchema = z8.object({
|
|
624
|
+
id: z8.string()
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
// src/tools/listTodoItems.ts
|
|
628
|
+
var toolInfo7 = {
|
|
629
|
+
name: "listTodoItems",
|
|
630
|
+
description: "List all to-do items, sorted by id. If an id is provided, it lists all sub-items for that id. Can be filtered by status.",
|
|
631
|
+
parameters: z9.object({
|
|
632
|
+
id: z9.string().nullish(),
|
|
633
|
+
status: TodoStatus.nullish()
|
|
634
|
+
})
|
|
635
|
+
};
|
|
636
|
+
var handler7 = async (provider, args) => {
|
|
637
|
+
if (!provider.listTodoItems) {
|
|
638
|
+
return {
|
|
639
|
+
type: "Error" /* Error */,
|
|
640
|
+
message: {
|
|
641
|
+
type: "error-text",
|
|
642
|
+
value: "Not possible to list to-do items."
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
const { id, status } = toolInfo7.parameters.parse(args);
|
|
647
|
+
const items = await provider.listTodoItems(id, status);
|
|
648
|
+
return {
|
|
649
|
+
type: "Reply" /* Reply */,
|
|
650
|
+
message: {
|
|
651
|
+
type: "json",
|
|
652
|
+
value: items
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
};
|
|
656
|
+
var listTodoItems_default = {
|
|
657
|
+
...toolInfo7,
|
|
658
|
+
handler: handler7
|
|
659
|
+
};
|
|
660
|
+
|
|
575
661
|
// src/tools/provider.ts
|
|
576
662
|
var MockProvider = class {
|
|
663
|
+
async listTodoItems(id, _status) {
|
|
664
|
+
if (id) {
|
|
665
|
+
return [{ id: `${id}-1`, title: "mock sub item", status: "open", description: "", relevantFileList: [] }];
|
|
666
|
+
}
|
|
667
|
+
return [{ id: "1", title: "mock item", status: "open", description: "", relevantFileList: [] }];
|
|
668
|
+
}
|
|
669
|
+
async getTodoItem(id) {
|
|
670
|
+
return {
|
|
671
|
+
id,
|
|
672
|
+
title: "mock item",
|
|
673
|
+
description: "mock desc",
|
|
674
|
+
relevantFileList: [],
|
|
675
|
+
status: "open",
|
|
676
|
+
subItems: []
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
async updateTodoItem(input) {
|
|
680
|
+
if (input.operation === "add") {
|
|
681
|
+
return { id: "2" };
|
|
682
|
+
}
|
|
683
|
+
return { id: input.id };
|
|
684
|
+
}
|
|
577
685
|
async readFile(_path, _includeIgnored) {
|
|
578
686
|
return "mock content";
|
|
579
687
|
}
|
|
@@ -598,18 +706,27 @@ var MockProvider = class {
|
|
|
598
706
|
async askFollowupQuestion(_question, _options) {
|
|
599
707
|
return "mock answer";
|
|
600
708
|
}
|
|
709
|
+
async listMemoryTopics() {
|
|
710
|
+
return ["default"];
|
|
711
|
+
}
|
|
712
|
+
async readMemory(_topic) {
|
|
713
|
+
return "mock memory content";
|
|
714
|
+
}
|
|
715
|
+
async updateMemory(_operation, _topic, _content) {
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
601
718
|
};
|
|
602
719
|
|
|
603
720
|
// src/tools/readBinaryFile.ts
|
|
604
|
-
import { z as
|
|
605
|
-
var
|
|
721
|
+
import { z as z10 } from "zod";
|
|
722
|
+
var toolInfo8 = {
|
|
606
723
|
name: "readBinaryFile",
|
|
607
724
|
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:
|
|
725
|
+
parameters: z10.object({
|
|
726
|
+
url: z10.string().describe("The URL or local path of the file to read.")
|
|
610
727
|
})
|
|
611
728
|
};
|
|
612
|
-
var
|
|
729
|
+
var handler8 = async (provider, args) => {
|
|
613
730
|
if (!provider.readBinaryFile) {
|
|
614
731
|
return {
|
|
615
732
|
type: "Error" /* Error */,
|
|
@@ -619,7 +736,7 @@ var handler7 = async (provider, args) => {
|
|
|
619
736
|
}
|
|
620
737
|
};
|
|
621
738
|
}
|
|
622
|
-
const { url } =
|
|
739
|
+
const { url } = toolInfo8.parameters.parse(args);
|
|
623
740
|
try {
|
|
624
741
|
const filePart = await provider.readBinaryFile(url);
|
|
625
742
|
return {
|
|
@@ -648,29 +765,29 @@ var handler7 = async (provider, args) => {
|
|
|
648
765
|
}
|
|
649
766
|
};
|
|
650
767
|
var readBinaryFile_default = {
|
|
651
|
-
...
|
|
652
|
-
handler:
|
|
768
|
+
...toolInfo8,
|
|
769
|
+
handler: handler8
|
|
653
770
|
};
|
|
654
771
|
|
|
655
772
|
// src/tools/readFile.ts
|
|
656
|
-
import { z as
|
|
657
|
-
var
|
|
773
|
+
import { z as z11 } from "zod";
|
|
774
|
+
var toolInfo9 = {
|
|
658
775
|
name: "readFile",
|
|
659
776
|
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:
|
|
777
|
+
parameters: z11.object({
|
|
778
|
+
path: z11.preprocess((val) => {
|
|
662
779
|
if (!val) return [];
|
|
663
780
|
const values = Array.isArray(val) ? val : [val];
|
|
664
781
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
665
|
-
},
|
|
666
|
-
includeIgnored:
|
|
782
|
+
}, z11.array(z11.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" }),
|
|
783
|
+
includeIgnored: z11.preprocess((val) => {
|
|
667
784
|
if (typeof val === "string") {
|
|
668
785
|
const lower = val.toLowerCase();
|
|
669
786
|
if (lower === "false") return false;
|
|
670
787
|
if (lower === "true") return true;
|
|
671
788
|
}
|
|
672
789
|
return val;
|
|
673
|
-
},
|
|
790
|
+
}, z11.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
791
|
}).meta({
|
|
675
792
|
examples: [
|
|
676
793
|
{
|
|
@@ -688,7 +805,7 @@ var toolInfo8 = {
|
|
|
688
805
|
]
|
|
689
806
|
})
|
|
690
807
|
};
|
|
691
|
-
var
|
|
808
|
+
var handler9 = async (provider, args) => {
|
|
692
809
|
if (!provider.readFile) {
|
|
693
810
|
return {
|
|
694
811
|
type: "Error" /* Error */,
|
|
@@ -698,7 +815,7 @@ var handler8 = async (provider, args) => {
|
|
|
698
815
|
}
|
|
699
816
|
};
|
|
700
817
|
}
|
|
701
|
-
const { path: paths, includeIgnored } =
|
|
818
|
+
const { path: paths, includeIgnored } = toolInfo9.parameters.parse(args);
|
|
702
819
|
const resp = [];
|
|
703
820
|
for (const path of paths) {
|
|
704
821
|
const fileContent = await provider.readFile(path, includeIgnored);
|
|
@@ -722,21 +839,21 @@ var handler8 = async (provider, args) => {
|
|
|
722
839
|
};
|
|
723
840
|
};
|
|
724
841
|
var readFile_default = {
|
|
725
|
-
...
|
|
726
|
-
handler:
|
|
842
|
+
...toolInfo9,
|
|
843
|
+
handler: handler9
|
|
727
844
|
};
|
|
728
845
|
|
|
729
846
|
// src/tools/readMemory.ts
|
|
730
|
-
import { z as
|
|
731
|
-
var
|
|
847
|
+
import { z as z12 } from "zod";
|
|
848
|
+
var toolInfo10 = {
|
|
732
849
|
name: "readMemory",
|
|
733
|
-
description: "Reads content from a memory topic.",
|
|
734
|
-
parameters:
|
|
735
|
-
topic:
|
|
850
|
+
description: "Reads content from a memory topic. Use this to retrieve information stored in previous steps. If no topic is specified, reads from the default topic.",
|
|
851
|
+
parameters: z12.object({
|
|
852
|
+
topic: z12.string().optional().describe('The topic to read from memory. Defaults to ":default:".')
|
|
736
853
|
})
|
|
737
854
|
};
|
|
738
|
-
var
|
|
739
|
-
const { topic } =
|
|
855
|
+
var handler10 = async (provider, args) => {
|
|
856
|
+
const { topic } = toolInfo10.parameters.parse(args);
|
|
740
857
|
const content = await provider.readMemory(topic);
|
|
741
858
|
if (content) {
|
|
742
859
|
return {
|
|
@@ -758,17 +875,17 @@ ${content}
|
|
|
758
875
|
};
|
|
759
876
|
};
|
|
760
877
|
var readMemory_default = {
|
|
761
|
-
...
|
|
762
|
-
handler:
|
|
878
|
+
...toolInfo10,
|
|
879
|
+
handler: handler10
|
|
763
880
|
};
|
|
764
881
|
|
|
765
882
|
// src/tools/removeFile.ts
|
|
766
|
-
import { z as
|
|
767
|
-
var
|
|
883
|
+
import { z as z13 } from "zod";
|
|
884
|
+
var toolInfo11 = {
|
|
768
885
|
name: "removeFile",
|
|
769
886
|
description: "Request to remove a file at the specified path.",
|
|
770
|
-
parameters:
|
|
771
|
-
path:
|
|
887
|
+
parameters: z13.object({
|
|
888
|
+
path: z13.string().describe("The path of the file to remove").meta({ usageValue: "File path here" })
|
|
772
889
|
}).meta({
|
|
773
890
|
examples: [
|
|
774
891
|
{
|
|
@@ -780,7 +897,7 @@ var toolInfo10 = {
|
|
|
780
897
|
]
|
|
781
898
|
})
|
|
782
899
|
};
|
|
783
|
-
var
|
|
900
|
+
var handler11 = async (provider, args) => {
|
|
784
901
|
if (!provider.removeFile) {
|
|
785
902
|
return {
|
|
786
903
|
type: "Error" /* Error */,
|
|
@@ -790,7 +907,7 @@ var handler10 = async (provider, args) => {
|
|
|
790
907
|
}
|
|
791
908
|
};
|
|
792
909
|
}
|
|
793
|
-
const parsed =
|
|
910
|
+
const parsed = toolInfo11.parameters.safeParse(args);
|
|
794
911
|
if (!parsed.success) {
|
|
795
912
|
return {
|
|
796
913
|
type: "Error" /* Error */,
|
|
@@ -811,43 +928,18 @@ var handler10 = async (provider, args) => {
|
|
|
811
928
|
};
|
|
812
929
|
};
|
|
813
930
|
var removeFile_default = {
|
|
814
|
-
...toolInfo10,
|
|
815
|
-
handler: handler10
|
|
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
931
|
...toolInfo11,
|
|
840
932
|
handler: handler11
|
|
841
933
|
};
|
|
842
934
|
|
|
843
935
|
// src/tools/renameFile.ts
|
|
844
|
-
import { z as
|
|
936
|
+
import { z as z14 } from "zod";
|
|
845
937
|
var toolInfo12 = {
|
|
846
938
|
name: "renameFile",
|
|
847
939
|
description: "Request to rename a file from source path to target path.",
|
|
848
|
-
parameters:
|
|
849
|
-
source_path:
|
|
850
|
-
target_path:
|
|
940
|
+
parameters: z14.object({
|
|
941
|
+
source_path: z14.string().describe("The current path of the file").meta({ usageValue: "Source file path here" }),
|
|
942
|
+
target_path: z14.string().describe("The new path for the file").meta({ usageValue: "Target file path here" })
|
|
851
943
|
}).meta({
|
|
852
944
|
examples: [
|
|
853
945
|
{
|
|
@@ -886,11 +978,11 @@ var renameFile_default = {
|
|
|
886
978
|
};
|
|
887
979
|
|
|
888
980
|
// src/tools/replaceInFile.ts
|
|
889
|
-
import { z as
|
|
981
|
+
import { z as z15 } from "zod";
|
|
890
982
|
|
|
891
983
|
// src/tools/utils/replaceInFile.ts
|
|
892
984
|
var replaceInFile = (fileContent, diff) => {
|
|
893
|
-
const blockPattern =
|
|
985
|
+
const blockPattern = /^\s*<<<<<+\s*SEARCH>?\s*\r?\n([\s\S]*?)\r?\n=======[ \t]*\r?\n([\s\S]*?)\r?\n?>>>>>+\s*REPLACE\s*$/gm;
|
|
894
986
|
const blocks = [];
|
|
895
987
|
for (let match = blockPattern.exec(diff); match !== null; match = blockPattern.exec(diff)) {
|
|
896
988
|
blocks.push({ search: match[1], replace: match[2] });
|
|
@@ -966,9 +1058,9 @@ var replaceInFile = (fileContent, diff) => {
|
|
|
966
1058
|
var toolInfo13 = {
|
|
967
1059
|
name: "replaceInFile",
|
|
968
1060
|
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:
|
|
1061
|
+
parameters: z15.object({
|
|
1062
|
+
path: z15.string().describe("The path of the file to modify").meta({ usageValue: "File path here" }),
|
|
1063
|
+
diff: z15.string().describe(
|
|
972
1064
|
`One or more SEARCH/REPLACE blocks following this exact format:
|
|
973
1065
|
\`\`\`
|
|
974
1066
|
<<<<<<< SEARCH
|
|
@@ -1153,35 +1245,9 @@ var replaceInFile_default = {
|
|
|
1153
1245
|
handler: handler13
|
|
1154
1246
|
};
|
|
1155
1247
|
|
|
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
|
|
1180
|
-
};
|
|
1181
|
-
|
|
1182
1248
|
// src/tools/searchFiles.ts
|
|
1183
1249
|
import { z as z16 } from "zod";
|
|
1184
|
-
var
|
|
1250
|
+
var toolInfo14 = {
|
|
1185
1251
|
name: "searchFiles",
|
|
1186
1252
|
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
1253
|
parameters: z16.object({
|
|
@@ -1209,7 +1275,7 @@ var toolInfo15 = {
|
|
|
1209
1275
|
]
|
|
1210
1276
|
})
|
|
1211
1277
|
};
|
|
1212
|
-
var
|
|
1278
|
+
var handler14 = async (provider, args) => {
|
|
1213
1279
|
if (!provider.searchFiles) {
|
|
1214
1280
|
return {
|
|
1215
1281
|
type: "Error" /* Error */,
|
|
@@ -1219,7 +1285,7 @@ var handler15 = async (provider, args) => {
|
|
|
1219
1285
|
}
|
|
1220
1286
|
};
|
|
1221
1287
|
}
|
|
1222
|
-
const parsed =
|
|
1288
|
+
const parsed = toolInfo14.parameters.safeParse(args);
|
|
1223
1289
|
if (!parsed.success) {
|
|
1224
1290
|
return {
|
|
1225
1291
|
type: "Error" /* Error */,
|
|
@@ -1256,18 +1322,122 @@ ${files.join("\n")}
|
|
|
1256
1322
|
}
|
|
1257
1323
|
};
|
|
1258
1324
|
var searchFiles_default = {
|
|
1325
|
+
...toolInfo14,
|
|
1326
|
+
handler: handler14
|
|
1327
|
+
};
|
|
1328
|
+
|
|
1329
|
+
// src/tools/updateMemory.ts
|
|
1330
|
+
import { z as z17 } from "zod";
|
|
1331
|
+
var toolInfo15 = {
|
|
1332
|
+
name: "updateMemory",
|
|
1333
|
+
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.',
|
|
1334
|
+
parameters: z17.object({
|
|
1335
|
+
operation: z17.enum(["append", "replace", "remove"]).describe("The operation to perform."),
|
|
1336
|
+
topic: z17.string().nullish().describe('The topic to update in memory. Defaults to ":default:".'),
|
|
1337
|
+
content: z17.string().optional().describe("The content for append or replace operations. Must be omitted for remove operation.")
|
|
1338
|
+
}).superRefine((data, ctx) => {
|
|
1339
|
+
if (data.operation === "append" || data.operation === "replace") {
|
|
1340
|
+
if (data.content === void 0) {
|
|
1341
|
+
ctx.addIssue({
|
|
1342
|
+
code: "custom",
|
|
1343
|
+
message: 'Content is required for "append" and "replace" operations.',
|
|
1344
|
+
path: ["content"]
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
} else if (data.operation === "remove") {
|
|
1348
|
+
if (data.content !== void 0) {
|
|
1349
|
+
ctx.addIssue({
|
|
1350
|
+
code: "custom",
|
|
1351
|
+
message: 'Content must not be provided for "remove" operation.',
|
|
1352
|
+
path: ["content"]
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
})
|
|
1357
|
+
};
|
|
1358
|
+
var handler15 = async (provider, args) => {
|
|
1359
|
+
if (!provider.updateMemory) {
|
|
1360
|
+
return {
|
|
1361
|
+
type: "Error" /* Error */,
|
|
1362
|
+
message: {
|
|
1363
|
+
type: "error-text",
|
|
1364
|
+
value: "Memory operations are not supported by the current provider."
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
}
|
|
1368
|
+
const params = toolInfo15.parameters.parse(args);
|
|
1369
|
+
await provider.updateMemory(params.operation, params.topic ?? void 0, "content" in params ? params.content : void 0);
|
|
1370
|
+
switch (params.operation) {
|
|
1371
|
+
case "append":
|
|
1372
|
+
return {
|
|
1373
|
+
type: "Reply" /* Reply */,
|
|
1374
|
+
message: {
|
|
1375
|
+
type: "text",
|
|
1376
|
+
value: `Content appended to memory topic '${params.topic || ":default:"}'.`
|
|
1377
|
+
}
|
|
1378
|
+
};
|
|
1379
|
+
case "replace":
|
|
1380
|
+
return {
|
|
1381
|
+
type: "Reply" /* Reply */,
|
|
1382
|
+
message: {
|
|
1383
|
+
type: "text",
|
|
1384
|
+
value: `Memory topic '${params.topic || ":default:"}' replaced.`
|
|
1385
|
+
}
|
|
1386
|
+
};
|
|
1387
|
+
case "remove":
|
|
1388
|
+
return {
|
|
1389
|
+
type: "Reply" /* Reply */,
|
|
1390
|
+
message: {
|
|
1391
|
+
type: "text",
|
|
1392
|
+
value: `Memory topic '${params.topic || ":default:"}' removed.`
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
};
|
|
1397
|
+
var updateMemory_default = {
|
|
1259
1398
|
...toolInfo15,
|
|
1260
1399
|
handler: handler15
|
|
1261
1400
|
};
|
|
1262
1401
|
|
|
1263
|
-
// src/tools/
|
|
1264
|
-
import { z as z17 } from "zod";
|
|
1402
|
+
// src/tools/updateTodoItem.ts
|
|
1265
1403
|
var toolInfo16 = {
|
|
1404
|
+
name: "updateTodoItem",
|
|
1405
|
+
description: "Add or update a to-do item.",
|
|
1406
|
+
parameters: UpdateTodoItemInputSchema
|
|
1407
|
+
};
|
|
1408
|
+
var handler16 = async (provider, args) => {
|
|
1409
|
+
if (!provider.updateTodoItem) {
|
|
1410
|
+
return {
|
|
1411
|
+
type: "Error" /* Error */,
|
|
1412
|
+
message: {
|
|
1413
|
+
type: "error-text",
|
|
1414
|
+
value: "Not possible to update a to-do item."
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
const input = toolInfo16.parameters.parse(args);
|
|
1419
|
+
const result = await provider.updateTodoItem(input);
|
|
1420
|
+
return {
|
|
1421
|
+
type: "Reply" /* Reply */,
|
|
1422
|
+
message: {
|
|
1423
|
+
type: "json",
|
|
1424
|
+
value: result
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
};
|
|
1428
|
+
var updateTodoItem_default = {
|
|
1429
|
+
...toolInfo16,
|
|
1430
|
+
handler: handler16
|
|
1431
|
+
};
|
|
1432
|
+
|
|
1433
|
+
// src/tools/writeToFile.ts
|
|
1434
|
+
import { z as z18 } from "zod";
|
|
1435
|
+
var toolInfo17 = {
|
|
1266
1436
|
name: "writeToFile",
|
|
1267
1437
|
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:
|
|
1438
|
+
parameters: z18.object({
|
|
1439
|
+
path: z18.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
|
|
1440
|
+
content: z18.string().describe(
|
|
1271
1441
|
"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
1442
|
).meta({ usageValue: "Your file content here" })
|
|
1273
1443
|
}).meta({
|
|
@@ -1293,7 +1463,7 @@ export default App;
|
|
|
1293
1463
|
]
|
|
1294
1464
|
})
|
|
1295
1465
|
};
|
|
1296
|
-
var
|
|
1466
|
+
var handler17 = async (provider, args) => {
|
|
1297
1467
|
if (!provider.writeFile) {
|
|
1298
1468
|
return {
|
|
1299
1469
|
type: "Error" /* Error */,
|
|
@@ -1303,7 +1473,7 @@ var handler16 = async (provider, args) => {
|
|
|
1303
1473
|
}
|
|
1304
1474
|
};
|
|
1305
1475
|
}
|
|
1306
|
-
const parsed =
|
|
1476
|
+
const parsed = toolInfo17.parameters.safeParse(args);
|
|
1307
1477
|
if (!parsed.success) {
|
|
1308
1478
|
return {
|
|
1309
1479
|
type: "Error" /* Error */,
|
|
@@ -1326,8 +1496,8 @@ var handler16 = async (provider, args) => {
|
|
|
1326
1496
|
};
|
|
1327
1497
|
};
|
|
1328
1498
|
var writeToFile_default = {
|
|
1329
|
-
...
|
|
1330
|
-
handler:
|
|
1499
|
+
...toolInfo17,
|
|
1500
|
+
handler: handler17
|
|
1331
1501
|
};
|
|
1332
1502
|
|
|
1333
1503
|
// src/UsageMeter.ts
|
|
@@ -1479,27 +1649,32 @@ var UsageMeter = class {
|
|
|
1479
1649
|
};
|
|
1480
1650
|
export {
|
|
1481
1651
|
MockProvider,
|
|
1652
|
+
TodoItemSchema,
|
|
1653
|
+
TodoStatus,
|
|
1482
1654
|
ToolResponseType,
|
|
1655
|
+
UpdateTodoItemInputSchema,
|
|
1656
|
+
UpdateTodoItemOutputSchema,
|
|
1483
1657
|
UsageMeter,
|
|
1484
|
-
appendMemory_default as appendMemory,
|
|
1485
1658
|
askFollowupQuestion_default as askFollowupQuestion,
|
|
1486
1659
|
computeRateLimitBackoffSeconds,
|
|
1487
1660
|
configSchema,
|
|
1488
1661
|
executeCommand_default as executeCommand,
|
|
1489
1662
|
fetchUrl_default as fetchUrl,
|
|
1663
|
+
getTodoItem_default as getTodoItem,
|
|
1490
1664
|
listFiles_default as listFiles,
|
|
1491
1665
|
listMemoryTopics_default as listMemoryTopics,
|
|
1666
|
+
listTodoItems_default as listTodoItems,
|
|
1492
1667
|
parseJsonFromMarkdown,
|
|
1493
1668
|
readBinaryFile_default as readBinaryFile,
|
|
1494
1669
|
readFile_default as readFile,
|
|
1495
1670
|
readMemory_default as readMemory,
|
|
1496
1671
|
removeFile_default as removeFile,
|
|
1497
|
-
removeMemory_default as removeMemory,
|
|
1498
1672
|
renameFile_default as renameFile,
|
|
1499
1673
|
replaceInFile_default as replaceInFile,
|
|
1500
1674
|
replaceInFile as replaceInFileHelper,
|
|
1501
|
-
replaceMemory_default as replaceMemory,
|
|
1502
1675
|
responsePrompts,
|
|
1503
1676
|
searchFiles_default as searchFiles,
|
|
1677
|
+
updateMemory_default as updateMemory,
|
|
1678
|
+
updateTodoItem_default as updateTodoItem,
|
|
1504
1679
|
writeToFile_default as writeToFile
|
|
1505
1680
|
};
|