@polka-codes/cli-shared 0.9.48 → 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/index.js +381 -74
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30922,8 +30922,40 @@ var fetchUrl_default = {
|
|
|
30922
30922
|
...toolInfo3,
|
|
30923
30923
|
handler: handler3
|
|
30924
30924
|
};
|
|
30925
|
-
// ../core/src/tools/
|
|
30925
|
+
// ../core/src/tools/getTodoItem.ts
|
|
30926
30926
|
var toolInfo4 = {
|
|
30927
|
+
name: "getTodoItem",
|
|
30928
|
+
description: "Get a to-do item by its ID.",
|
|
30929
|
+
parameters: exports_external.object({
|
|
30930
|
+
id: exports_external.string().describe("The ID of the to-do item.")
|
|
30931
|
+
})
|
|
30932
|
+
};
|
|
30933
|
+
var handler4 = async (provider, args) => {
|
|
30934
|
+
if (!provider.getTodoItem) {
|
|
30935
|
+
return {
|
|
30936
|
+
type: "Error" /* Error */,
|
|
30937
|
+
message: {
|
|
30938
|
+
type: "error-text",
|
|
30939
|
+
value: "Not possible to get a to-do item."
|
|
30940
|
+
}
|
|
30941
|
+
};
|
|
30942
|
+
}
|
|
30943
|
+
const { id } = toolInfo4.parameters.parse(args);
|
|
30944
|
+
const item = await provider.getTodoItem(id);
|
|
30945
|
+
return {
|
|
30946
|
+
type: "Reply" /* Reply */,
|
|
30947
|
+
message: {
|
|
30948
|
+
type: "json",
|
|
30949
|
+
value: item ?? null
|
|
30950
|
+
}
|
|
30951
|
+
};
|
|
30952
|
+
};
|
|
30953
|
+
var getTodoItem_default = {
|
|
30954
|
+
...toolInfo4,
|
|
30955
|
+
handler: handler4
|
|
30956
|
+
};
|
|
30957
|
+
// ../core/src/tools/listFiles.ts
|
|
30958
|
+
var toolInfo5 = {
|
|
30927
30959
|
name: "listFiles",
|
|
30928
30960
|
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.",
|
|
30929
30961
|
parameters: exports_external.object({
|
|
@@ -30961,7 +30993,7 @@ var toolInfo4 = {
|
|
|
30961
30993
|
]
|
|
30962
30994
|
})
|
|
30963
30995
|
};
|
|
30964
|
-
var
|
|
30996
|
+
var handler5 = async (provider, args) => {
|
|
30965
30997
|
if (!provider.listFiles) {
|
|
30966
30998
|
return {
|
|
30967
30999
|
type: "Error" /* Error */,
|
|
@@ -30971,7 +31003,7 @@ var handler4 = async (provider, args) => {
|
|
|
30971
31003
|
}
|
|
30972
31004
|
};
|
|
30973
31005
|
}
|
|
30974
|
-
const { path, maxCount, recursive, includeIgnored } =
|
|
31006
|
+
const { path, maxCount, recursive, includeIgnored } = toolInfo5.parameters.parse(args);
|
|
30975
31007
|
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
|
|
30976
31008
|
return {
|
|
30977
31009
|
type: "Reply" /* Reply */,
|
|
@@ -30987,16 +31019,16 @@ ${files.join(`
|
|
|
30987
31019
|
};
|
|
30988
31020
|
};
|
|
30989
31021
|
var listFiles_default = {
|
|
30990
|
-
...
|
|
30991
|
-
handler:
|
|
31022
|
+
...toolInfo5,
|
|
31023
|
+
handler: handler5
|
|
30992
31024
|
};
|
|
30993
31025
|
// ../core/src/tools/listMemoryTopics.ts
|
|
30994
|
-
var
|
|
31026
|
+
var toolInfo6 = {
|
|
30995
31027
|
name: "listMemoryTopics",
|
|
30996
|
-
description: "Lists all topics in memory.",
|
|
31028
|
+
description: "Lists all topics in memory. Use this to see what information has been stored and which topics are available to read from.",
|
|
30997
31029
|
parameters: exports_external.object({})
|
|
30998
31030
|
};
|
|
30999
|
-
var
|
|
31031
|
+
var handler6 = async (provider, _args) => {
|
|
31000
31032
|
const topics = await provider.listMemoryTopics();
|
|
31001
31033
|
if (!topics.length) {
|
|
31002
31034
|
return { type: "Reply" /* Reply */, message: { type: "text", value: "No topics found." } };
|
|
@@ -31012,18 +31044,91 @@ ${topics.join(`
|
|
|
31012
31044
|
};
|
|
31013
31045
|
};
|
|
31014
31046
|
var listMemoryTopics_default = {
|
|
31015
|
-
...
|
|
31016
|
-
handler:
|
|
31047
|
+
...toolInfo6,
|
|
31048
|
+
handler: handler6
|
|
31049
|
+
};
|
|
31050
|
+
// ../core/src/tools/todo.ts
|
|
31051
|
+
var TodoStatus = exports_external.enum(["open", "completed", "closed"]);
|
|
31052
|
+
var TodoItemSchema = exports_external.object({
|
|
31053
|
+
id: exports_external.string(),
|
|
31054
|
+
title: exports_external.string(),
|
|
31055
|
+
description: exports_external.string(),
|
|
31056
|
+
relevantFileList: exports_external.array(exports_external.string()),
|
|
31057
|
+
status: TodoStatus
|
|
31058
|
+
});
|
|
31059
|
+
var UpdateTodoItemInputSchema = exports_external.object({
|
|
31060
|
+
operation: exports_external.enum(["add", "update"]),
|
|
31061
|
+
id: exports_external.string().nullish(),
|
|
31062
|
+
parentId: exports_external.string().nullish(),
|
|
31063
|
+
title: exports_external.string().nullish(),
|
|
31064
|
+
description: exports_external.string().nullish(),
|
|
31065
|
+
relevantFileList: exports_external.array(exports_external.string()).nullish(),
|
|
31066
|
+
status: TodoStatus.nullish()
|
|
31067
|
+
}).superRefine((data, ctx) => {
|
|
31068
|
+
if (data.operation === "add") {
|
|
31069
|
+
if (!data.title) {
|
|
31070
|
+
ctx.addIssue({
|
|
31071
|
+
code: "custom",
|
|
31072
|
+
message: 'Title is required for "add" operation',
|
|
31073
|
+
path: ["title"]
|
|
31074
|
+
});
|
|
31075
|
+
}
|
|
31076
|
+
} else if (data.operation === "update") {
|
|
31077
|
+
if (!data.id) {
|
|
31078
|
+
ctx.addIssue({
|
|
31079
|
+
code: "custom",
|
|
31080
|
+
message: 'ID is required for "update" operation',
|
|
31081
|
+
path: ["id"]
|
|
31082
|
+
});
|
|
31083
|
+
}
|
|
31084
|
+
}
|
|
31085
|
+
});
|
|
31086
|
+
var UpdateTodoItemOutputSchema = exports_external.object({
|
|
31087
|
+
id: exports_external.string()
|
|
31088
|
+
});
|
|
31089
|
+
|
|
31090
|
+
// ../core/src/tools/listTodoItems.ts
|
|
31091
|
+
var toolInfo7 = {
|
|
31092
|
+
name: "listTodoItems",
|
|
31093
|
+
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.",
|
|
31094
|
+
parameters: exports_external.object({
|
|
31095
|
+
id: exports_external.string().nullish(),
|
|
31096
|
+
status: TodoStatus.nullish()
|
|
31097
|
+
})
|
|
31098
|
+
};
|
|
31099
|
+
var handler7 = async (provider, args) => {
|
|
31100
|
+
if (!provider.listTodoItems) {
|
|
31101
|
+
return {
|
|
31102
|
+
type: "Error" /* Error */,
|
|
31103
|
+
message: {
|
|
31104
|
+
type: "error-text",
|
|
31105
|
+
value: "Not possible to list to-do items."
|
|
31106
|
+
}
|
|
31107
|
+
};
|
|
31108
|
+
}
|
|
31109
|
+
const { id, status } = toolInfo7.parameters.parse(args);
|
|
31110
|
+
const items = await provider.listTodoItems(id, status);
|
|
31111
|
+
return {
|
|
31112
|
+
type: "Reply" /* Reply */,
|
|
31113
|
+
message: {
|
|
31114
|
+
type: "json",
|
|
31115
|
+
value: items
|
|
31116
|
+
}
|
|
31117
|
+
};
|
|
31118
|
+
};
|
|
31119
|
+
var listTodoItems_default = {
|
|
31120
|
+
...toolInfo7,
|
|
31121
|
+
handler: handler7
|
|
31017
31122
|
};
|
|
31018
31123
|
// ../core/src/tools/readBinaryFile.ts
|
|
31019
|
-
var
|
|
31124
|
+
var toolInfo8 = {
|
|
31020
31125
|
name: "readBinaryFile",
|
|
31021
31126
|
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.",
|
|
31022
31127
|
parameters: exports_external.object({
|
|
31023
31128
|
url: exports_external.string().describe("The URL or local path of the file to read.")
|
|
31024
31129
|
})
|
|
31025
31130
|
};
|
|
31026
|
-
var
|
|
31131
|
+
var handler8 = async (provider, args) => {
|
|
31027
31132
|
if (!provider.readBinaryFile) {
|
|
31028
31133
|
return {
|
|
31029
31134
|
type: "Error" /* Error */,
|
|
@@ -31033,7 +31138,7 @@ var handler6 = async (provider, args) => {
|
|
|
31033
31138
|
}
|
|
31034
31139
|
};
|
|
31035
31140
|
}
|
|
31036
|
-
const { url: url2 } =
|
|
31141
|
+
const { url: url2 } = toolInfo8.parameters.parse(args);
|
|
31037
31142
|
try {
|
|
31038
31143
|
const filePart = await provider.readBinaryFile(url2);
|
|
31039
31144
|
return {
|
|
@@ -31062,11 +31167,11 @@ var handler6 = async (provider, args) => {
|
|
|
31062
31167
|
}
|
|
31063
31168
|
};
|
|
31064
31169
|
var readBinaryFile_default = {
|
|
31065
|
-
...
|
|
31066
|
-
handler:
|
|
31170
|
+
...toolInfo8,
|
|
31171
|
+
handler: handler8
|
|
31067
31172
|
};
|
|
31068
31173
|
// ../core/src/tools/readFile.ts
|
|
31069
|
-
var
|
|
31174
|
+
var toolInfo9 = {
|
|
31070
31175
|
name: "readFile",
|
|
31071
31176
|
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.",
|
|
31072
31177
|
parameters: exports_external.object({
|
|
@@ -31103,7 +31208,7 @@ var toolInfo7 = {
|
|
|
31103
31208
|
]
|
|
31104
31209
|
})
|
|
31105
31210
|
};
|
|
31106
|
-
var
|
|
31211
|
+
var handler9 = async (provider, args) => {
|
|
31107
31212
|
if (!provider.readFile) {
|
|
31108
31213
|
return {
|
|
31109
31214
|
type: "Error" /* Error */,
|
|
@@ -31113,7 +31218,7 @@ var handler7 = async (provider, args) => {
|
|
|
31113
31218
|
}
|
|
31114
31219
|
};
|
|
31115
31220
|
}
|
|
31116
|
-
const { path: paths, includeIgnored } =
|
|
31221
|
+
const { path: paths, includeIgnored } = toolInfo9.parameters.parse(args);
|
|
31117
31222
|
const resp = [];
|
|
31118
31223
|
for (const path of paths) {
|
|
31119
31224
|
const fileContent = await provider.readFile(path, includeIgnored);
|
|
@@ -31138,19 +31243,19 @@ var handler7 = async (provider, args) => {
|
|
|
31138
31243
|
};
|
|
31139
31244
|
};
|
|
31140
31245
|
var readFile_default = {
|
|
31141
|
-
...
|
|
31142
|
-
handler:
|
|
31246
|
+
...toolInfo9,
|
|
31247
|
+
handler: handler9
|
|
31143
31248
|
};
|
|
31144
31249
|
// ../core/src/tools/readMemory.ts
|
|
31145
|
-
var
|
|
31250
|
+
var toolInfo10 = {
|
|
31146
31251
|
name: "readMemory",
|
|
31147
|
-
description: "Reads content from a memory topic.",
|
|
31252
|
+
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.",
|
|
31148
31253
|
parameters: exports_external.object({
|
|
31149
31254
|
topic: exports_external.string().optional().describe('The topic to read from memory. Defaults to ":default:".')
|
|
31150
31255
|
})
|
|
31151
31256
|
};
|
|
31152
|
-
var
|
|
31153
|
-
const { topic } =
|
|
31257
|
+
var handler10 = async (provider, args) => {
|
|
31258
|
+
const { topic } = toolInfo10.parameters.parse(args);
|
|
31154
31259
|
const content = await provider.readMemory(topic);
|
|
31155
31260
|
if (content) {
|
|
31156
31261
|
return {
|
|
@@ -31172,11 +31277,11 @@ ${content}
|
|
|
31172
31277
|
};
|
|
31173
31278
|
};
|
|
31174
31279
|
var readMemory_default = {
|
|
31175
|
-
...
|
|
31176
|
-
handler:
|
|
31280
|
+
...toolInfo10,
|
|
31281
|
+
handler: handler10
|
|
31177
31282
|
};
|
|
31178
31283
|
// ../core/src/tools/removeFile.ts
|
|
31179
|
-
var
|
|
31284
|
+
var toolInfo11 = {
|
|
31180
31285
|
name: "removeFile",
|
|
31181
31286
|
description: "Request to remove a file at the specified path.",
|
|
31182
31287
|
parameters: exports_external.object({
|
|
@@ -31192,7 +31297,7 @@ var toolInfo9 = {
|
|
|
31192
31297
|
]
|
|
31193
31298
|
})
|
|
31194
31299
|
};
|
|
31195
|
-
var
|
|
31300
|
+
var handler11 = async (provider, args) => {
|
|
31196
31301
|
if (!provider.removeFile) {
|
|
31197
31302
|
return {
|
|
31198
31303
|
type: "Error" /* Error */,
|
|
@@ -31202,7 +31307,7 @@ var handler9 = async (provider, args) => {
|
|
|
31202
31307
|
}
|
|
31203
31308
|
};
|
|
31204
31309
|
}
|
|
31205
|
-
const parsed =
|
|
31310
|
+
const parsed = toolInfo11.parameters.safeParse(args);
|
|
31206
31311
|
if (!parsed.success) {
|
|
31207
31312
|
return {
|
|
31208
31313
|
type: "Error" /* Error */,
|
|
@@ -31223,11 +31328,11 @@ var handler9 = async (provider, args) => {
|
|
|
31223
31328
|
};
|
|
31224
31329
|
};
|
|
31225
31330
|
var removeFile_default = {
|
|
31226
|
-
...
|
|
31227
|
-
handler:
|
|
31331
|
+
...toolInfo11,
|
|
31332
|
+
handler: handler11
|
|
31228
31333
|
};
|
|
31229
31334
|
// ../core/src/tools/renameFile.ts
|
|
31230
|
-
var
|
|
31335
|
+
var toolInfo12 = {
|
|
31231
31336
|
name: "renameFile",
|
|
31232
31337
|
description: "Request to rename a file from source path to target path.",
|
|
31233
31338
|
parameters: exports_external.object({
|
|
@@ -31245,7 +31350,7 @@ var toolInfo10 = {
|
|
|
31245
31350
|
]
|
|
31246
31351
|
})
|
|
31247
31352
|
};
|
|
31248
|
-
var
|
|
31353
|
+
var handler12 = async (provider, args) => {
|
|
31249
31354
|
if (!provider.renameFile) {
|
|
31250
31355
|
return {
|
|
31251
31356
|
type: "Error" /* Error */,
|
|
@@ -31255,7 +31360,7 @@ var handler10 = async (provider, args) => {
|
|
|
31255
31360
|
}
|
|
31256
31361
|
};
|
|
31257
31362
|
}
|
|
31258
|
-
const { source_path, target_path } =
|
|
31363
|
+
const { source_path, target_path } = toolInfo12.parameters.parse(args);
|
|
31259
31364
|
await provider.renameFile(source_path, target_path);
|
|
31260
31365
|
return {
|
|
31261
31366
|
type: "Reply" /* Reply */,
|
|
@@ -31266,12 +31371,12 @@ var handler10 = async (provider, args) => {
|
|
|
31266
31371
|
};
|
|
31267
31372
|
};
|
|
31268
31373
|
var renameFile_default = {
|
|
31269
|
-
...
|
|
31270
|
-
handler:
|
|
31374
|
+
...toolInfo12,
|
|
31375
|
+
handler: handler12
|
|
31271
31376
|
};
|
|
31272
31377
|
// ../core/src/tools/utils/replaceInFile.ts
|
|
31273
31378
|
var replaceInFile = (fileContent, diff) => {
|
|
31274
|
-
const blockPattern =
|
|
31379
|
+
const blockPattern = /^\s*<<<<<+\s*SEARCH>?\s*\r?\n([\s\S]*?)\r?\n=======[ \t]*\r?\n([\s\S]*?)\r?\n?>>>>>+\s*REPLACE\s*$/gm;
|
|
31275
31380
|
const blocks = [];
|
|
31276
31381
|
for (let match = blockPattern.exec(diff);match !== null; match = blockPattern.exec(diff)) {
|
|
31277
31382
|
blocks.push({ search: match[1], replace: match[2] });
|
|
@@ -31344,7 +31449,7 @@ var replaceInFile = (fileContent, diff) => {
|
|
|
31344
31449
|
};
|
|
31345
31450
|
|
|
31346
31451
|
// ../core/src/tools/replaceInFile.ts
|
|
31347
|
-
var
|
|
31452
|
+
var toolInfo13 = {
|
|
31348
31453
|
name: "replaceInFile",
|
|
31349
31454
|
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.",
|
|
31350
31455
|
parameters: exports_external.object({
|
|
@@ -31454,7 +31559,7 @@ function oldFeature() {
|
|
|
31454
31559
|
]
|
|
31455
31560
|
})
|
|
31456
31561
|
};
|
|
31457
|
-
var
|
|
31562
|
+
var handler13 = async (provider, args) => {
|
|
31458
31563
|
if (!provider.readFile || !provider.writeFile) {
|
|
31459
31564
|
return {
|
|
31460
31565
|
type: "Error" /* Error */,
|
|
@@ -31464,7 +31569,7 @@ var handler11 = async (provider, args) => {
|
|
|
31464
31569
|
}
|
|
31465
31570
|
};
|
|
31466
31571
|
}
|
|
31467
|
-
const parsed =
|
|
31572
|
+
const parsed = toolInfo13.parameters.safeParse(args);
|
|
31468
31573
|
if (!parsed.success) {
|
|
31469
31574
|
return {
|
|
31470
31575
|
type: "Error" /* Error */,
|
|
@@ -31528,11 +31633,11 @@ var handler11 = async (provider, args) => {
|
|
|
31528
31633
|
}
|
|
31529
31634
|
};
|
|
31530
31635
|
var replaceInFile_default = {
|
|
31531
|
-
...
|
|
31532
|
-
handler:
|
|
31636
|
+
...toolInfo13,
|
|
31637
|
+
handler: handler13
|
|
31533
31638
|
};
|
|
31534
31639
|
// ../core/src/tools/searchFiles.ts
|
|
31535
|
-
var
|
|
31640
|
+
var toolInfo14 = {
|
|
31536
31641
|
name: "searchFiles",
|
|
31537
31642
|
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.",
|
|
31538
31643
|
parameters: exports_external.object({
|
|
@@ -31556,7 +31661,7 @@ var toolInfo12 = {
|
|
|
31556
31661
|
]
|
|
31557
31662
|
})
|
|
31558
31663
|
};
|
|
31559
|
-
var
|
|
31664
|
+
var handler14 = async (provider, args) => {
|
|
31560
31665
|
if (!provider.searchFiles) {
|
|
31561
31666
|
return {
|
|
31562
31667
|
type: "Error" /* Error */,
|
|
@@ -31566,7 +31671,7 @@ var handler12 = async (provider, args) => {
|
|
|
31566
31671
|
}
|
|
31567
31672
|
};
|
|
31568
31673
|
}
|
|
31569
|
-
const parsed =
|
|
31674
|
+
const parsed = toolInfo14.parameters.safeParse(args);
|
|
31570
31675
|
if (!parsed.success) {
|
|
31571
31676
|
return {
|
|
31572
31677
|
type: "Error" /* Error */,
|
|
@@ -31604,13 +31709,13 @@ ${files.join(`
|
|
|
31604
31709
|
}
|
|
31605
31710
|
};
|
|
31606
31711
|
var searchFiles_default = {
|
|
31607
|
-
...
|
|
31608
|
-
handler:
|
|
31712
|
+
...toolInfo14,
|
|
31713
|
+
handler: handler14
|
|
31609
31714
|
};
|
|
31610
31715
|
// ../core/src/tools/updateMemory.ts
|
|
31611
|
-
var
|
|
31716
|
+
var toolInfo15 = {
|
|
31612
31717
|
name: "updateMemory",
|
|
31613
|
-
description:
|
|
31718
|
+
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.',
|
|
31614
31719
|
parameters: exports_external.object({
|
|
31615
31720
|
operation: exports_external.enum(["append", "replace", "remove"]).describe("The operation to perform."),
|
|
31616
31721
|
topic: exports_external.string().nullish().describe('The topic to update in memory. Defaults to ":default:".'),
|
|
@@ -31635,7 +31740,7 @@ var toolInfo13 = {
|
|
|
31635
31740
|
}
|
|
31636
31741
|
})
|
|
31637
31742
|
};
|
|
31638
|
-
var
|
|
31743
|
+
var handler15 = async (provider, args) => {
|
|
31639
31744
|
if (!provider.updateMemory) {
|
|
31640
31745
|
return {
|
|
31641
31746
|
type: "Error" /* Error */,
|
|
@@ -31645,7 +31750,7 @@ var handler13 = async (provider, args) => {
|
|
|
31645
31750
|
}
|
|
31646
31751
|
};
|
|
31647
31752
|
}
|
|
31648
|
-
const params =
|
|
31753
|
+
const params = toolInfo15.parameters.parse(args);
|
|
31649
31754
|
await provider.updateMemory(params.operation, params.topic ?? undefined, "content" in params ? params.content : undefined);
|
|
31650
31755
|
switch (params.operation) {
|
|
31651
31756
|
case "append":
|
|
@@ -31675,11 +31780,41 @@ var handler13 = async (provider, args) => {
|
|
|
31675
31780
|
}
|
|
31676
31781
|
};
|
|
31677
31782
|
var updateMemory_default = {
|
|
31678
|
-
...
|
|
31679
|
-
handler:
|
|
31783
|
+
...toolInfo15,
|
|
31784
|
+
handler: handler15
|
|
31785
|
+
};
|
|
31786
|
+
// ../core/src/tools/updateTodoItem.ts
|
|
31787
|
+
var toolInfo16 = {
|
|
31788
|
+
name: "updateTodoItem",
|
|
31789
|
+
description: "Add or update a to-do item.",
|
|
31790
|
+
parameters: UpdateTodoItemInputSchema
|
|
31791
|
+
};
|
|
31792
|
+
var handler16 = async (provider, args) => {
|
|
31793
|
+
if (!provider.updateTodoItem) {
|
|
31794
|
+
return {
|
|
31795
|
+
type: "Error" /* Error */,
|
|
31796
|
+
message: {
|
|
31797
|
+
type: "error-text",
|
|
31798
|
+
value: "Not possible to update a to-do item."
|
|
31799
|
+
}
|
|
31800
|
+
};
|
|
31801
|
+
}
|
|
31802
|
+
const input = toolInfo16.parameters.parse(args);
|
|
31803
|
+
const result = await provider.updateTodoItem(input);
|
|
31804
|
+
return {
|
|
31805
|
+
type: "Reply" /* Reply */,
|
|
31806
|
+
message: {
|
|
31807
|
+
type: "json",
|
|
31808
|
+
value: result
|
|
31809
|
+
}
|
|
31810
|
+
};
|
|
31811
|
+
};
|
|
31812
|
+
var updateTodoItem_default = {
|
|
31813
|
+
...toolInfo16,
|
|
31814
|
+
handler: handler16
|
|
31680
31815
|
};
|
|
31681
31816
|
// ../core/src/tools/writeToFile.ts
|
|
31682
|
-
var
|
|
31817
|
+
var toolInfo17 = {
|
|
31683
31818
|
name: "writeToFile",
|
|
31684
31819
|
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.",
|
|
31685
31820
|
parameters: exports_external.object({
|
|
@@ -31708,7 +31843,7 @@ export default App;
|
|
|
31708
31843
|
]
|
|
31709
31844
|
})
|
|
31710
31845
|
};
|
|
31711
|
-
var
|
|
31846
|
+
var handler17 = async (provider, args) => {
|
|
31712
31847
|
if (!provider.writeFile) {
|
|
31713
31848
|
return {
|
|
31714
31849
|
type: "Error" /* Error */,
|
|
@@ -31718,7 +31853,7 @@ var handler14 = async (provider, args) => {
|
|
|
31718
31853
|
}
|
|
31719
31854
|
};
|
|
31720
31855
|
}
|
|
31721
|
-
const parsed =
|
|
31856
|
+
const parsed = toolInfo17.parameters.safeParse(args);
|
|
31722
31857
|
if (!parsed.success) {
|
|
31723
31858
|
return {
|
|
31724
31859
|
type: "Error" /* Error */,
|
|
@@ -31742,8 +31877,8 @@ var handler14 = async (provider, args) => {
|
|
|
31742
31877
|
};
|
|
31743
31878
|
};
|
|
31744
31879
|
var writeToFile_default = {
|
|
31745
|
-
...
|
|
31746
|
-
handler:
|
|
31880
|
+
...toolInfo17,
|
|
31881
|
+
handler: handler17
|
|
31747
31882
|
};
|
|
31748
31883
|
// ../core/src/UsageMeter.ts
|
|
31749
31884
|
class UsageMeter {
|
|
@@ -33633,15 +33768,15 @@ function useKeypress(userHandler) {
|
|
|
33633
33768
|
signal.current = userHandler;
|
|
33634
33769
|
useEffect((rl) => {
|
|
33635
33770
|
let ignore = false;
|
|
33636
|
-
const
|
|
33771
|
+
const handler18 = withUpdates((_input, event) => {
|
|
33637
33772
|
if (ignore)
|
|
33638
33773
|
return;
|
|
33639
33774
|
signal.current(event, rl);
|
|
33640
33775
|
});
|
|
33641
|
-
rl.input.on("keypress",
|
|
33776
|
+
rl.input.on("keypress", handler18);
|
|
33642
33777
|
return () => {
|
|
33643
33778
|
ignore = true;
|
|
33644
|
-
rl.input.removeListener("keypress",
|
|
33779
|
+
rl.input.removeListener("keypress", handler18);
|
|
33645
33780
|
};
|
|
33646
33781
|
}, []);
|
|
33647
33782
|
}
|
|
@@ -33800,16 +33935,16 @@ class Emitter {
|
|
|
33800
33935
|
|
|
33801
33936
|
class SignalExitBase {
|
|
33802
33937
|
}
|
|
33803
|
-
var signalExitWrap = (
|
|
33938
|
+
var signalExitWrap = (handler18) => {
|
|
33804
33939
|
return {
|
|
33805
33940
|
onExit(cb, opts) {
|
|
33806
|
-
return
|
|
33941
|
+
return handler18.onExit(cb, opts);
|
|
33807
33942
|
},
|
|
33808
33943
|
load() {
|
|
33809
|
-
return
|
|
33944
|
+
return handler18.load();
|
|
33810
33945
|
},
|
|
33811
33946
|
unload() {
|
|
33812
|
-
return
|
|
33947
|
+
return handler18.unload();
|
|
33813
33948
|
}
|
|
33814
33949
|
};
|
|
33815
33950
|
};
|
|
@@ -34610,8 +34745,96 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
|
34610
34745
|
var getProvider = (options = {}) => {
|
|
34611
34746
|
const ig = import_ignore2.default().add(options.excludeFiles ?? []);
|
|
34612
34747
|
const memoryStore = {};
|
|
34748
|
+
const todoItems = [];
|
|
34613
34749
|
const defaultMemoryTopic = ":default:";
|
|
34614
34750
|
const provider2 = {
|
|
34751
|
+
listTodoItems: async (id, status) => {
|
|
34752
|
+
let items;
|
|
34753
|
+
if (!id) {
|
|
34754
|
+
items = todoItems.filter((i) => !i.id.includes("."));
|
|
34755
|
+
} else {
|
|
34756
|
+
const parent = todoItems.find((i) => i.id === id);
|
|
34757
|
+
if (!parent) {
|
|
34758
|
+
throw new Error(`To-do item with id ${id} not found`);
|
|
34759
|
+
}
|
|
34760
|
+
items = todoItems.filter((i) => i.id.startsWith(`${id}.`) && i.id.split(".").length === id.split(".").length + 1);
|
|
34761
|
+
}
|
|
34762
|
+
if (status) {
|
|
34763
|
+
items = items.filter((item) => item.status === status);
|
|
34764
|
+
}
|
|
34765
|
+
items.sort((a, b) => {
|
|
34766
|
+
const aParts = a.id.split(".");
|
|
34767
|
+
const bParts = b.id.split(".");
|
|
34768
|
+
const len = Math.min(aParts.length, bParts.length);
|
|
34769
|
+
for (let i = 0;i < len; i++) {
|
|
34770
|
+
const comparison = aParts[i].localeCompare(bParts[i], undefined, { numeric: true });
|
|
34771
|
+
if (comparison !== 0) {
|
|
34772
|
+
return comparison;
|
|
34773
|
+
}
|
|
34774
|
+
}
|
|
34775
|
+
return aParts.length - bParts.length;
|
|
34776
|
+
});
|
|
34777
|
+
return items;
|
|
34778
|
+
},
|
|
34779
|
+
getTodoItem: async (id) => {
|
|
34780
|
+
const item = todoItems.find((i) => i.id === id);
|
|
34781
|
+
if (!item) {
|
|
34782
|
+
throw new Error(`To-do item with id ${id} not found`);
|
|
34783
|
+
}
|
|
34784
|
+
const subItems = todoItems.filter((i) => i.id.startsWith(`${id}.`) && i.id.split(".").length === id.split(".").length + 1).map(({ id: id2, title }) => ({ id: id2, title }));
|
|
34785
|
+
return { ...item, subItems };
|
|
34786
|
+
},
|
|
34787
|
+
updateTodoItem: async (input) => {
|
|
34788
|
+
if (input.operation === "add") {
|
|
34789
|
+
const { parentId, title, description, relevantFileList } = input;
|
|
34790
|
+
if (!title) {
|
|
34791
|
+
throw new Error("Title is required for add operation");
|
|
34792
|
+
}
|
|
34793
|
+
let newId;
|
|
34794
|
+
if (parentId) {
|
|
34795
|
+
const parent = todoItems.find((i) => i.id === parentId);
|
|
34796
|
+
if (!parent) {
|
|
34797
|
+
throw new Error(`Parent to-do item with id ${parentId} not found`);
|
|
34798
|
+
}
|
|
34799
|
+
const childItems = todoItems.filter((i) => i.id.startsWith(`${parentId}.`) && i.id.split(".").length === parentId.split(".").length + 1);
|
|
34800
|
+
newId = `${parentId}.${childItems.length + 1}`;
|
|
34801
|
+
} else {
|
|
34802
|
+
const rootItems = todoItems.filter((i) => !i.id.includes("."));
|
|
34803
|
+
newId = `${rootItems.length + 1}`;
|
|
34804
|
+
}
|
|
34805
|
+
const newItem = {
|
|
34806
|
+
id: newId,
|
|
34807
|
+
title,
|
|
34808
|
+
description: description ?? "",
|
|
34809
|
+
relevantFileList: relevantFileList ?? [],
|
|
34810
|
+
status: "open"
|
|
34811
|
+
};
|
|
34812
|
+
todoItems.push(newItem);
|
|
34813
|
+
return { id: newId };
|
|
34814
|
+
} else {
|
|
34815
|
+
const { id } = input;
|
|
34816
|
+
if (!id) {
|
|
34817
|
+
throw new Error("ID is required for update operation");
|
|
34818
|
+
}
|
|
34819
|
+
const item = todoItems.find((i) => i.id === id);
|
|
34820
|
+
if (!item) {
|
|
34821
|
+
throw new Error(`To-do item with id ${id} not found`);
|
|
34822
|
+
}
|
|
34823
|
+
if (input.title != null) {
|
|
34824
|
+
item.title = input.title;
|
|
34825
|
+
}
|
|
34826
|
+
if (input.description != null) {
|
|
34827
|
+
item.description = input.description ?? "";
|
|
34828
|
+
}
|
|
34829
|
+
if (input.relevantFileList != null) {
|
|
34830
|
+
item.relevantFileList = input.relevantFileList;
|
|
34831
|
+
}
|
|
34832
|
+
if (input.status != null) {
|
|
34833
|
+
item.status = input.status;
|
|
34834
|
+
}
|
|
34835
|
+
return { id };
|
|
34836
|
+
}
|
|
34837
|
+
},
|
|
34615
34838
|
listMemoryTopics: async () => {
|
|
34616
34839
|
return Object.keys(memoryStore);
|
|
34617
34840
|
},
|
|
@@ -35275,6 +35498,53 @@ var chalk = createChalk();
|
|
|
35275
35498
|
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
35276
35499
|
var source_default = chalk;
|
|
35277
35500
|
|
|
35501
|
+
// src/utils/parameterSimplifier.ts
|
|
35502
|
+
function replaceInFileSimplifier(params) {
|
|
35503
|
+
return { path: params.path };
|
|
35504
|
+
}
|
|
35505
|
+
function writeToFileSimplifier(params) {
|
|
35506
|
+
return { path: params.path };
|
|
35507
|
+
}
|
|
35508
|
+
function readFileSimplifier(params) {
|
|
35509
|
+
return { path: params.path, includeIgnored: params.includeIgnored };
|
|
35510
|
+
}
|
|
35511
|
+
function listFilesSimplifier(params) {
|
|
35512
|
+
const maxCount = params.maxCount;
|
|
35513
|
+
return {
|
|
35514
|
+
path: params.path,
|
|
35515
|
+
recursive: params.recursive,
|
|
35516
|
+
...maxCount !== 2000 && { maxCount }
|
|
35517
|
+
};
|
|
35518
|
+
}
|
|
35519
|
+
function searchFilesSimplifier(params) {
|
|
35520
|
+
return { ...params };
|
|
35521
|
+
}
|
|
35522
|
+
function executeCommandSimplifier(params) {
|
|
35523
|
+
return { command: params.command, requiresApproval: params.requiresApproval };
|
|
35524
|
+
}
|
|
35525
|
+
function updateMemorySimplifier(params) {
|
|
35526
|
+
return { operation: params.operation, topic: params.topic };
|
|
35527
|
+
}
|
|
35528
|
+
var SIMPLIFIERS = {
|
|
35529
|
+
replaceInFile: replaceInFileSimplifier,
|
|
35530
|
+
writeToFile: writeToFileSimplifier,
|
|
35531
|
+
readFile: readFileSimplifier,
|
|
35532
|
+
listFiles: listFilesSimplifier,
|
|
35533
|
+
searchFiles: searchFilesSimplifier,
|
|
35534
|
+
executeCommand: executeCommandSimplifier,
|
|
35535
|
+
updateMemory: updateMemorySimplifier
|
|
35536
|
+
};
|
|
35537
|
+
function simplifyToolParameters(toolName, params) {
|
|
35538
|
+
if (params === undefined || params === null) {
|
|
35539
|
+
return {};
|
|
35540
|
+
}
|
|
35541
|
+
const simplifier = SIMPLIFIERS[toolName];
|
|
35542
|
+
if (simplifier) {
|
|
35543
|
+
return simplifier(params);
|
|
35544
|
+
}
|
|
35545
|
+
return { ...params };
|
|
35546
|
+
}
|
|
35547
|
+
|
|
35278
35548
|
// src/utils/eventHandler.ts
|
|
35279
35549
|
var taskToolCallStats = new Map;
|
|
35280
35550
|
var globalToolCallStats = new Map;
|
|
@@ -35299,8 +35569,26 @@ function logToolCallStats(stream, statsMap, title) {
|
|
|
35299
35569
|
customConsole.log("No tools were called.");
|
|
35300
35570
|
}
|
|
35301
35571
|
}
|
|
35572
|
+
var mergeToolCallStats = (a, b) => {
|
|
35573
|
+
const merged = new Map;
|
|
35574
|
+
for (const [tool2, stat] of a) {
|
|
35575
|
+
merged.set(tool2, { ...stat });
|
|
35576
|
+
}
|
|
35577
|
+
for (const [tool2, stat] of b) {
|
|
35578
|
+
const existing = merged.get(tool2);
|
|
35579
|
+
if (existing) {
|
|
35580
|
+
existing.calls += stat.calls;
|
|
35581
|
+
existing.success += stat.success;
|
|
35582
|
+
existing.errors += stat.errors;
|
|
35583
|
+
} else {
|
|
35584
|
+
merged.set(tool2, { ...stat });
|
|
35585
|
+
}
|
|
35586
|
+
}
|
|
35587
|
+
return merged;
|
|
35588
|
+
};
|
|
35302
35589
|
function logGlobalToolCallStats(stream) {
|
|
35303
|
-
|
|
35590
|
+
const merged = mergeToolCallStats(globalToolCallStats, taskToolCallStats);
|
|
35591
|
+
logToolCallStats(stream, merged, "Global Tool Call Stats");
|
|
35304
35592
|
}
|
|
35305
35593
|
var printEvent = (verbose, usageMeter, stream = process.stdout) => {
|
|
35306
35594
|
if (verbose < 0) {
|
|
@@ -35308,6 +35596,7 @@ var printEvent = (verbose, usageMeter, stream = process.stdout) => {
|
|
|
35308
35596
|
}
|
|
35309
35597
|
const customConsole = new Console(stream, stream);
|
|
35310
35598
|
let hadReasoning = false;
|
|
35599
|
+
let hasText = false;
|
|
35311
35600
|
const write = stream.write.bind(stream);
|
|
35312
35601
|
return (event) => {
|
|
35313
35602
|
switch (event.kind) {
|
|
@@ -35324,6 +35613,7 @@ ${event.systemPrompt}`);
|
|
|
35324
35613
|
}
|
|
35325
35614
|
break;
|
|
35326
35615
|
case "StartRequest" /* StartRequest */:
|
|
35616
|
+
hasText = false;
|
|
35327
35617
|
if (verbose > 0) {
|
|
35328
35618
|
customConsole.log(`
|
|
35329
35619
|
|
|
@@ -35377,6 +35667,11 @@ ${event.systemPrompt}`);
|
|
|
35377
35667
|
customConsole.log(`
|
|
35378
35668
|
|
|
35379
35669
|
======== Request Ended ========
|
|
35670
|
+
`);
|
|
35671
|
+
}
|
|
35672
|
+
if (verbose === 0 && hasText) {
|
|
35673
|
+
write(`
|
|
35674
|
+
|
|
35380
35675
|
`);
|
|
35381
35676
|
}
|
|
35382
35677
|
if (verbose > 1) {
|
|
@@ -35390,6 +35685,9 @@ ${event.systemPrompt}`);
|
|
|
35390
35685
|
`);
|
|
35391
35686
|
hadReasoning = false;
|
|
35392
35687
|
}
|
|
35688
|
+
if (event.newText.trim().length > 0) {
|
|
35689
|
+
hasText = true;
|
|
35690
|
+
}
|
|
35393
35691
|
write(event.newText);
|
|
35394
35692
|
break;
|
|
35395
35693
|
}
|
|
@@ -35404,7 +35702,7 @@ ${event.systemPrompt}`);
|
|
|
35404
35702
|
if (verbose > 0) {
|
|
35405
35703
|
customConsole.log(source_default.yellow(`
|
|
35406
35704
|
|
|
35407
|
-
Tool use:`, event.tool), event.params);
|
|
35705
|
+
Tool use:`, event.tool), simplifyToolParameters(event.tool, event.params));
|
|
35408
35706
|
}
|
|
35409
35707
|
const stats = taskToolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
35410
35708
|
stats.calls++;
|
|
@@ -35440,18 +35738,26 @@ Tool error:`, event.tool));
|
|
|
35440
35738
|
`);
|
|
35441
35739
|
customConsole.log("Reason:", event.exitReason.type);
|
|
35442
35740
|
switch (event.exitReason.type) {
|
|
35741
|
+
case "Error": {
|
|
35742
|
+
const { error: error46 } = event.exitReason;
|
|
35743
|
+
customConsole.error(source_default.red(`Workflow failed: ${error46.message}`));
|
|
35744
|
+
if (verbose > 0 && error46.stack) {
|
|
35745
|
+
customConsole.error(source_default.red(error46.stack));
|
|
35746
|
+
}
|
|
35747
|
+
break;
|
|
35748
|
+
}
|
|
35443
35749
|
case "Exit" /* Exit */:
|
|
35444
35750
|
customConsole.log("Exit Message:", event.exitReason.message);
|
|
35445
35751
|
break;
|
|
35446
35752
|
}
|
|
35753
|
+
for (const [tool2, taskStats] of taskToolCallStats.entries()) {
|
|
35754
|
+
const globalStats = globalToolCallStats.get(tool2) ?? { calls: 0, success: 0, errors: 0 };
|
|
35755
|
+
globalStats.calls += taskStats.calls;
|
|
35756
|
+
globalStats.success += taskStats.success;
|
|
35757
|
+
globalStats.errors += taskStats.errors;
|
|
35758
|
+
globalToolCallStats.set(tool2, globalStats);
|
|
35759
|
+
}
|
|
35447
35760
|
if (verbose > 0) {
|
|
35448
|
-
for (const [tool2, taskStats] of taskToolCallStats.entries()) {
|
|
35449
|
-
const globalStats = globalToolCallStats.get(tool2) ?? { calls: 0, success: 0, errors: 0 };
|
|
35450
|
-
globalStats.calls += taskStats.calls;
|
|
35451
|
-
globalStats.success += taskStats.success;
|
|
35452
|
-
globalStats.errors += taskStats.errors;
|
|
35453
|
-
globalToolCallStats.set(tool2, globalStats);
|
|
35454
|
-
}
|
|
35455
35761
|
logToolCallStats(stream, taskToolCallStats, "Task Tool Call Stats");
|
|
35456
35762
|
}
|
|
35457
35763
|
break;
|
|
@@ -35479,6 +35785,7 @@ function readMultiline(prompt = "Enter text (Ctrl+D to finish):") {
|
|
|
35479
35785
|
});
|
|
35480
35786
|
}
|
|
35481
35787
|
export {
|
|
35788
|
+
simplifyToolParameters,
|
|
35482
35789
|
searchFiles,
|
|
35483
35790
|
readMultiline,
|
|
35484
35791
|
readLocalConfig,
|