@polka-codes/core 0.9.4 → 0.9.5
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 +10 -4
- package/dist/index.js +34 -9
- package/package.json +1 -1
|
@@ -628,6 +628,7 @@ declare const _default_7: {
|
|
|
628
628
|
path: z.ZodString;
|
|
629
629
|
maxCount: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
630
630
|
recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
631
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
631
632
|
}, z.core.$strip>;
|
|
632
633
|
readonly permissionLevel: PermissionLevel.Read;
|
|
633
634
|
}, FilesystemProvider>;
|
|
@@ -638,6 +639,7 @@ declare const _default_7: {
|
|
|
638
639
|
path: z.ZodString;
|
|
639
640
|
maxCount: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
640
641
|
recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
642
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
641
643
|
}, z.core.$strip>;
|
|
642
644
|
permissionLevel: PermissionLevel.Read;
|
|
643
645
|
};
|
|
@@ -652,6 +654,7 @@ declare const _default_8: {
|
|
|
652
654
|
readonly 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.";
|
|
653
655
|
readonly parameters: z.ZodObject<{
|
|
654
656
|
path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
|
|
657
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
655
658
|
}, z.core.$strip>;
|
|
656
659
|
readonly permissionLevel: PermissionLevel.Read;
|
|
657
660
|
}, FilesystemProvider>;
|
|
@@ -660,6 +663,7 @@ declare const _default_8: {
|
|
|
660
663
|
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.";
|
|
661
664
|
parameters: z.ZodObject<{
|
|
662
665
|
path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
|
|
666
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
663
667
|
}, z.core.$strip>;
|
|
664
668
|
permissionLevel: PermissionLevel.Read;
|
|
665
669
|
};
|
|
@@ -807,11 +811,11 @@ export { ExitReason as ExitReason_alias_1 }
|
|
|
807
811
|
export { ExitReason as ExitReason_alias_2 }
|
|
808
812
|
|
|
809
813
|
declare type FilesystemProvider = {
|
|
810
|
-
readFile?: (path: string) => Promise<string | undefined>;
|
|
814
|
+
readFile?: (path: string, includeIgnored: boolean) => Promise<string | undefined>;
|
|
811
815
|
writeFile?: (path: string, content: string) => Promise<void>;
|
|
812
816
|
removeFile?: (path: string) => Promise<void>;
|
|
813
817
|
renameFile?: (sourcePath: string, targetPath: string) => Promise<void>;
|
|
814
|
-
listFiles?: (path: string, recursive: boolean, maxCount: number) => Promise<[string[], boolean]>;
|
|
818
|
+
listFiles?: (path: string, recursive: boolean, maxCount: number, includeIgnored: boolean) => Promise<[string[], boolean]>;
|
|
815
819
|
searchFiles?: (path: string, regex: string, filePattern: string) => Promise<string[]>;
|
|
816
820
|
};
|
|
817
821
|
export { FilesystemProvider }
|
|
@@ -1023,11 +1027,11 @@ export { makeTool }
|
|
|
1023
1027
|
export { makeTool as makeTool_alias_1 }
|
|
1024
1028
|
|
|
1025
1029
|
declare class MockProvider implements ToolProvider {
|
|
1026
|
-
readFile(_path: string): Promise<string>;
|
|
1030
|
+
readFile(_path: string, _includeIgnored?: boolean): Promise<string>;
|
|
1027
1031
|
writeFile(_path: string, _content: string): Promise<void>;
|
|
1028
1032
|
removeFile(_path: string): Promise<void>;
|
|
1029
1033
|
renameFile(_sourcePath: string, _targetPath: string): Promise<void>;
|
|
1030
|
-
listFiles(_path: string, _recursive: boolean, _maxCount: number): Promise<[string[], boolean]>;
|
|
1034
|
+
listFiles(_path: string, _recursive: boolean, _maxCount: number, _includeIgnored?: boolean): Promise<[string[], boolean]>;
|
|
1031
1035
|
searchFiles(_path: string, _regex: string, _filePattern: string): Promise<string[]>;
|
|
1032
1036
|
executeCommand(_command: string, _needApprove: boolean): Promise<{
|
|
1033
1037
|
stdout: string;
|
|
@@ -1571,6 +1575,7 @@ export declare const toolInfo_alias_7: {
|
|
|
1571
1575
|
path: z.ZodString;
|
|
1572
1576
|
maxCount: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
1573
1577
|
recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
1578
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
1574
1579
|
}, z.core.$strip>;
|
|
1575
1580
|
readonly permissionLevel: PermissionLevel.Read;
|
|
1576
1581
|
};
|
|
@@ -1580,6 +1585,7 @@ export declare const toolInfo_alias_8: {
|
|
|
1580
1585
|
readonly 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.";
|
|
1581
1586
|
readonly parameters: z.ZodObject<{
|
|
1582
1587
|
path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
|
|
1588
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
1583
1589
|
}, z.core.$strip>;
|
|
1584
1590
|
readonly permissionLevel: PermissionLevel.Read;
|
|
1585
1591
|
};
|
package/dist/index.js
CHANGED
|
@@ -458,7 +458,15 @@ var toolInfo7 = {
|
|
|
458
458
|
if (lower === "true") return true;
|
|
459
459
|
}
|
|
460
460
|
return val;
|
|
461
|
-
}, z7.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)" })
|
|
461
|
+
}, z7.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)" }),
|
|
462
|
+
includeIgnored: z7.preprocess((val) => {
|
|
463
|
+
if (typeof val === "string") {
|
|
464
|
+
const lower = val.toLowerCase();
|
|
465
|
+
if (lower === "false") return false;
|
|
466
|
+
if (lower === "true") return true;
|
|
467
|
+
}
|
|
468
|
+
return val;
|
|
469
|
+
}, z7.boolean().optional().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
|
|
462
470
|
}).meta({
|
|
463
471
|
examples: [
|
|
464
472
|
{
|
|
@@ -479,8 +487,8 @@ var handler7 = async (provider, args) => {
|
|
|
479
487
|
message: "Not possible to list files. Abort."
|
|
480
488
|
};
|
|
481
489
|
}
|
|
482
|
-
const { path, maxCount, recursive } = toolInfo7.parameters.parse(args);
|
|
483
|
-
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount);
|
|
490
|
+
const { path, maxCount, recursive, includeIgnored } = toolInfo7.parameters.parse(args);
|
|
491
|
+
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
|
|
484
492
|
return {
|
|
485
493
|
type: "Reply" /* Reply */,
|
|
486
494
|
message: `<list_files_path>${path}</list_files_path>
|
|
@@ -509,7 +517,15 @@ var toolInfo8 = {
|
|
|
509
517
|
if (!val) return [];
|
|
510
518
|
const values = Array.isArray(val) ? val : [val];
|
|
511
519
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
512
|
-
}, z8.array(z8.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" })
|
|
520
|
+
}, z8.array(z8.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" }),
|
|
521
|
+
includeIgnored: z8.preprocess((val) => {
|
|
522
|
+
if (typeof val === "string") {
|
|
523
|
+
const lower = val.toLowerCase();
|
|
524
|
+
if (lower === "false") return false;
|
|
525
|
+
if (lower === "true") return true;
|
|
526
|
+
}
|
|
527
|
+
return val;
|
|
528
|
+
}, 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)" })
|
|
513
529
|
}).meta({
|
|
514
530
|
examples: [
|
|
515
531
|
{
|
|
@@ -535,10 +551,10 @@ var handler8 = async (provider, args) => {
|
|
|
535
551
|
message: "Not possible to read file. Abort."
|
|
536
552
|
};
|
|
537
553
|
}
|
|
538
|
-
const { path: paths } = toolInfo8.parameters.parse(args);
|
|
554
|
+
const { path: paths, includeIgnored } = toolInfo8.parameters.parse(args);
|
|
539
555
|
const resp = [];
|
|
540
556
|
for (const path of paths) {
|
|
541
|
-
const fileContent = await provider.readFile(path);
|
|
557
|
+
const fileContent = await provider.readFile(path, includeIgnored);
|
|
542
558
|
if (!fileContent) {
|
|
543
559
|
resp.push(`<read_file_file_content path="${path}" file_not_found="true" />`);
|
|
544
560
|
} else {
|
|
@@ -857,7 +873,7 @@ var handler11 = async (provider, args) => {
|
|
|
857
873
|
}
|
|
858
874
|
try {
|
|
859
875
|
const { path, diff } = toolInfo11.parameters.parse(args);
|
|
860
|
-
const fileContent = await provider.readFile(path);
|
|
876
|
+
const fileContent = await provider.readFile(path, false);
|
|
861
877
|
if (fileContent == null) {
|
|
862
878
|
return {
|
|
863
879
|
type: "Error" /* Error */,
|
|
@@ -1037,7 +1053,7 @@ var writeToFile_default = {
|
|
|
1037
1053
|
|
|
1038
1054
|
// src/tools/provider.ts
|
|
1039
1055
|
var MockProvider = class {
|
|
1040
|
-
async readFile(_path) {
|
|
1056
|
+
async readFile(_path, _includeIgnored) {
|
|
1041
1057
|
return "mock content";
|
|
1042
1058
|
}
|
|
1043
1059
|
async writeFile(_path, _content) {
|
|
@@ -1049,7 +1065,7 @@ var MockProvider = class {
|
|
|
1049
1065
|
async renameFile(_sourcePath, _targetPath) {
|
|
1050
1066
|
return;
|
|
1051
1067
|
}
|
|
1052
|
-
async listFiles(_path, _recursive, _maxCount) {
|
|
1068
|
+
async listFiles(_path, _recursive, _maxCount, _includeIgnored) {
|
|
1053
1069
|
return [["mock-file.txt"], false];
|
|
1054
1070
|
}
|
|
1055
1071
|
async searchFiles(_path, _regex, _filePattern) {
|
|
@@ -1836,6 +1852,7 @@ ${instance.prompt}`;
|
|
|
1836
1852
|
resetTimeout();
|
|
1837
1853
|
const streamTextOptions = {
|
|
1838
1854
|
model: this.ai,
|
|
1855
|
+
temperature: 0,
|
|
1839
1856
|
messages,
|
|
1840
1857
|
providerOptions: this.config.parameters?.providerOptions,
|
|
1841
1858
|
onChunk: async ({ chunk }) => {
|
|
@@ -1904,6 +1921,13 @@ ${instance.prompt}`;
|
|
|
1904
1921
|
}
|
|
1905
1922
|
this.#messages.push(...respMessages);
|
|
1906
1923
|
if (this.config.toolFormat === "native") {
|
|
1924
|
+
const assistantText = respMessages.map((msg) => {
|
|
1925
|
+
if (typeof msg.content === "string") {
|
|
1926
|
+
return msg.content;
|
|
1927
|
+
}
|
|
1928
|
+
return msg.content.map((part) => part.type === "text" || part.type === "reasoning" ? part.text : "").join("");
|
|
1929
|
+
}).join("\n");
|
|
1930
|
+
await this.#callback({ kind: "EndRequest" /* EndRequest */, agent: this, message: assistantText });
|
|
1907
1931
|
return respMessages.flatMap((msg) => {
|
|
1908
1932
|
if (msg.role === "assistant") {
|
|
1909
1933
|
const content = msg.content;
|
|
@@ -3494,6 +3518,7 @@ ${output}`,
|
|
|
3494
3518
|
var executeTool = async (definition, ai, params, usageMeter) => {
|
|
3495
3519
|
const resp = await generateText({
|
|
3496
3520
|
model: ai,
|
|
3521
|
+
temperature: 0,
|
|
3497
3522
|
system: definition.prompt,
|
|
3498
3523
|
messages: [
|
|
3499
3524
|
{
|