@polka-codes/cli-shared 0.9.79 → 0.9.81
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 +502 -365
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47675,12 +47675,6 @@ function date4(params) {
|
|
|
47675
47675
|
// ../../node_modules/zod/v4/classic/external.js
|
|
47676
47676
|
config(en_default());
|
|
47677
47677
|
// ../core/src/config.ts
|
|
47678
|
-
var providerModelSchema = exports_external.object({
|
|
47679
|
-
provider: exports_external.string().optional(),
|
|
47680
|
-
model: exports_external.string().optional(),
|
|
47681
|
-
parameters: exports_external.record(exports_external.string(), exports_external.any()).optional(),
|
|
47682
|
-
budget: exports_external.number().positive().optional()
|
|
47683
|
-
});
|
|
47684
47678
|
var ruleSchema = exports_external.union([
|
|
47685
47679
|
exports_external.string(),
|
|
47686
47680
|
exports_external.object({ path: exports_external.string() }).strict(),
|
|
@@ -47693,6 +47687,13 @@ var ruleSchema = exports_external.union([
|
|
|
47693
47687
|
branch: exports_external.string().optional()
|
|
47694
47688
|
}).strict()
|
|
47695
47689
|
]);
|
|
47690
|
+
var providerModelSchema = exports_external.object({
|
|
47691
|
+
provider: exports_external.string().optional(),
|
|
47692
|
+
model: exports_external.string().optional(),
|
|
47693
|
+
parameters: exports_external.record(exports_external.string(), exports_external.any()).optional(),
|
|
47694
|
+
budget: exports_external.number().positive().optional(),
|
|
47695
|
+
rules: exports_external.array(ruleSchema).optional().or(exports_external.string()).optional()
|
|
47696
|
+
});
|
|
47696
47697
|
var configSchema = exports_external.object({
|
|
47697
47698
|
prices: exports_external.record(exports_external.string(), exports_external.record(exports_external.string(), exports_external.object({
|
|
47698
47699
|
inputPrice: exports_external.number().optional(),
|
|
@@ -47785,7 +47786,7 @@ var toolInfo = {
|
|
|
47785
47786
|
var handler = async (provider, args) => {
|
|
47786
47787
|
if (!provider.askFollowupQuestion) {
|
|
47787
47788
|
return {
|
|
47788
|
-
|
|
47789
|
+
success: false,
|
|
47789
47790
|
message: {
|
|
47790
47791
|
type: "error-text",
|
|
47791
47792
|
value: "Not possible to ask followup question."
|
|
@@ -47795,7 +47796,7 @@ var handler = async (provider, args) => {
|
|
|
47795
47796
|
const { questions } = toolInfo.parameters.parse(args);
|
|
47796
47797
|
if (questions.length === 0) {
|
|
47797
47798
|
return {
|
|
47798
|
-
|
|
47799
|
+
success: false,
|
|
47799
47800
|
message: {
|
|
47800
47801
|
type: "error-text",
|
|
47801
47802
|
value: "No questions provided"
|
|
@@ -47811,7 +47812,7 @@ ${answer}
|
|
|
47811
47812
|
</ask_followup_question_answer>`);
|
|
47812
47813
|
}
|
|
47813
47814
|
return {
|
|
47814
|
-
|
|
47815
|
+
success: true,
|
|
47815
47816
|
message: {
|
|
47816
47817
|
type: "text",
|
|
47817
47818
|
value: answers.join(`
|
|
@@ -47854,7 +47855,7 @@ var toolInfo2 = {
|
|
|
47854
47855
|
var handler2 = async (provider, args) => {
|
|
47855
47856
|
if (!provider.executeCommand) {
|
|
47856
47857
|
return {
|
|
47857
|
-
|
|
47858
|
+
success: false,
|
|
47858
47859
|
message: {
|
|
47859
47860
|
type: "error-text",
|
|
47860
47861
|
value: "Not possible to execute command. Abort."
|
|
@@ -47883,7 +47884,7 @@ ${result.stderr}
|
|
|
47883
47884
|
}
|
|
47884
47885
|
if (result.exitCode === 0) {
|
|
47885
47886
|
return {
|
|
47886
|
-
|
|
47887
|
+
success: true,
|
|
47887
47888
|
message: {
|
|
47888
47889
|
type: "text",
|
|
47889
47890
|
value: message
|
|
@@ -47891,7 +47892,7 @@ ${result.stderr}
|
|
|
47891
47892
|
};
|
|
47892
47893
|
}
|
|
47893
47894
|
return {
|
|
47894
|
-
|
|
47895
|
+
success: false,
|
|
47895
47896
|
message: {
|
|
47896
47897
|
type: "error-text",
|
|
47897
47898
|
value: message
|
|
@@ -47899,7 +47900,7 @@ ${result.stderr}
|
|
|
47899
47900
|
};
|
|
47900
47901
|
} catch (error46) {
|
|
47901
47902
|
return {
|
|
47902
|
-
|
|
47903
|
+
success: false,
|
|
47903
47904
|
message: {
|
|
47904
47905
|
type: "error-text",
|
|
47905
47906
|
value: error46 instanceof Error ? error46.message : String(error46)
|
|
@@ -47948,7 +47949,7 @@ var toolInfo3 = {
|
|
|
47948
47949
|
var handler3 = async (provider, args) => {
|
|
47949
47950
|
if (!provider.fetchUrl) {
|
|
47950
47951
|
return {
|
|
47951
|
-
|
|
47952
|
+
success: false,
|
|
47952
47953
|
message: {
|
|
47953
47954
|
type: "error-text",
|
|
47954
47955
|
value: "Not possible to fetch url."
|
|
@@ -47958,7 +47959,7 @@ var handler3 = async (provider, args) => {
|
|
|
47958
47959
|
const { url: urls } = toolInfo3.parameters.parse(args);
|
|
47959
47960
|
if (urls.length === 0) {
|
|
47960
47961
|
return {
|
|
47961
|
-
|
|
47962
|
+
success: false,
|
|
47962
47963
|
message: {
|
|
47963
47964
|
type: "error-text",
|
|
47964
47965
|
value: "No URLs provided. Please provide at least one URL to fetch."
|
|
@@ -47977,7 +47978,7 @@ var handler3 = async (provider, args) => {
|
|
|
47977
47978
|
}
|
|
47978
47979
|
const resolvedResults = await Promise.all(results);
|
|
47979
47980
|
return {
|
|
47980
|
-
|
|
47981
|
+
success: true,
|
|
47981
47982
|
message: {
|
|
47982
47983
|
type: "text",
|
|
47983
47984
|
value: resolvedResults.join(`
|
|
@@ -47989,40 +47990,8 @@ var fetchUrl_default = {
|
|
|
47989
47990
|
...toolInfo3,
|
|
47990
47991
|
handler: handler3
|
|
47991
47992
|
};
|
|
47992
|
-
// ../core/src/tools/getTodoItem.ts
|
|
47993
|
-
var toolInfo4 = {
|
|
47994
|
-
name: "getTodoItem",
|
|
47995
|
-
description: "Get a to-do item by its ID.",
|
|
47996
|
-
parameters: exports_external.object({
|
|
47997
|
-
id: exports_external.string().describe("The ID of the to-do item.")
|
|
47998
|
-
})
|
|
47999
|
-
};
|
|
48000
|
-
var handler4 = async (provider, args) => {
|
|
48001
|
-
if (!provider.getTodoItem) {
|
|
48002
|
-
return {
|
|
48003
|
-
type: "Error" /* Error */,
|
|
48004
|
-
message: {
|
|
48005
|
-
type: "error-text",
|
|
48006
|
-
value: "Not possible to get a to-do item."
|
|
48007
|
-
}
|
|
48008
|
-
};
|
|
48009
|
-
}
|
|
48010
|
-
const { id } = toolInfo4.parameters.parse(args);
|
|
48011
|
-
const item = await provider.getTodoItem(id);
|
|
48012
|
-
return {
|
|
48013
|
-
type: "Reply" /* Reply */,
|
|
48014
|
-
message: {
|
|
48015
|
-
type: "json",
|
|
48016
|
-
value: item ?? null
|
|
48017
|
-
}
|
|
48018
|
-
};
|
|
48019
|
-
};
|
|
48020
|
-
var getTodoItem_default = {
|
|
48021
|
-
...toolInfo4,
|
|
48022
|
-
handler: handler4
|
|
48023
|
-
};
|
|
48024
47993
|
// ../core/src/tools/listFiles.ts
|
|
48025
|
-
var
|
|
47994
|
+
var toolInfo4 = {
|
|
48026
47995
|
name: "listFiles",
|
|
48027
47996
|
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.",
|
|
48028
47997
|
parameters: exports_external.object({
|
|
@@ -48060,20 +48029,20 @@ var toolInfo5 = {
|
|
|
48060
48029
|
]
|
|
48061
48030
|
})
|
|
48062
48031
|
};
|
|
48063
|
-
var
|
|
48032
|
+
var handler4 = async (provider, args) => {
|
|
48064
48033
|
if (!provider.listFiles) {
|
|
48065
48034
|
return {
|
|
48066
|
-
|
|
48035
|
+
success: false,
|
|
48067
48036
|
message: {
|
|
48068
48037
|
type: "error-text",
|
|
48069
48038
|
value: "Not possible to list files."
|
|
48070
48039
|
}
|
|
48071
48040
|
};
|
|
48072
48041
|
}
|
|
48073
|
-
const { path, maxCount, recursive, includeIgnored } =
|
|
48042
|
+
const { path, maxCount, recursive, includeIgnored } = toolInfo4.parameters.parse(args);
|
|
48074
48043
|
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
|
|
48075
48044
|
return {
|
|
48076
|
-
|
|
48045
|
+
success: true,
|
|
48077
48046
|
message: {
|
|
48078
48047
|
type: "text",
|
|
48079
48048
|
value: `<list_files_path>${path}</list_files_path>
|
|
@@ -48086,128 +48055,32 @@ ${files.join(`
|
|
|
48086
48055
|
};
|
|
48087
48056
|
};
|
|
48088
48057
|
var listFiles_default = {
|
|
48089
|
-
...
|
|
48090
|
-
handler:
|
|
48091
|
-
};
|
|
48092
|
-
// ../core/src/tools/listMemoryTopics.ts
|
|
48093
|
-
var toolInfo6 = {
|
|
48094
|
-
name: "listMemoryTopics",
|
|
48095
|
-
description: "Lists all topics in memory. Use this to see what information has been stored and which topics are available to read from.",
|
|
48096
|
-
parameters: exports_external.object({})
|
|
48097
|
-
};
|
|
48098
|
-
var handler6 = async (provider, _args) => {
|
|
48099
|
-
const topics = await provider.listMemoryTopics();
|
|
48100
|
-
if (!topics.length) {
|
|
48101
|
-
return { type: "Reply" /* Reply */, message: { type: "text", value: "No topics found." } };
|
|
48102
|
-
}
|
|
48103
|
-
return {
|
|
48104
|
-
type: "Reply" /* Reply */,
|
|
48105
|
-
message: {
|
|
48106
|
-
type: "text",
|
|
48107
|
-
value: `Memory topics:
|
|
48108
|
-
${topics.join(`
|
|
48109
|
-
`)}`
|
|
48110
|
-
}
|
|
48111
|
-
};
|
|
48112
|
-
};
|
|
48113
|
-
var listMemoryTopics_default = {
|
|
48114
|
-
...toolInfo6,
|
|
48115
|
-
handler: handler6
|
|
48116
|
-
};
|
|
48117
|
-
// ../core/src/tools/todo.ts
|
|
48118
|
-
var TodoStatus = exports_external.enum(["open", "completed", "closed"]);
|
|
48119
|
-
var TodoItemSchema = exports_external.object({
|
|
48120
|
-
id: exports_external.string(),
|
|
48121
|
-
title: exports_external.string(),
|
|
48122
|
-
description: exports_external.string(),
|
|
48123
|
-
status: TodoStatus
|
|
48124
|
-
});
|
|
48125
|
-
var UpdateTodoItemInputSchema = exports_external.object({
|
|
48126
|
-
operation: exports_external.enum(["add", "update"]),
|
|
48127
|
-
id: exports_external.string().nullish(),
|
|
48128
|
-
parentId: exports_external.string().nullish(),
|
|
48129
|
-
title: exports_external.string().nullish(),
|
|
48130
|
-
description: exports_external.string().nullish(),
|
|
48131
|
-
status: TodoStatus.nullish()
|
|
48132
|
-
}).superRefine((data, ctx) => {
|
|
48133
|
-
if (data.operation === "add") {
|
|
48134
|
-
if (!data.title) {
|
|
48135
|
-
ctx.addIssue({
|
|
48136
|
-
code: "custom",
|
|
48137
|
-
message: 'Title is required for "add" operation',
|
|
48138
|
-
path: ["title"]
|
|
48139
|
-
});
|
|
48140
|
-
}
|
|
48141
|
-
} else if (data.operation === "update") {
|
|
48142
|
-
if (!data.id) {
|
|
48143
|
-
ctx.addIssue({
|
|
48144
|
-
code: "custom",
|
|
48145
|
-
message: 'ID is required for "update" operation',
|
|
48146
|
-
path: ["id"]
|
|
48147
|
-
});
|
|
48148
|
-
}
|
|
48149
|
-
}
|
|
48150
|
-
});
|
|
48151
|
-
var UpdateTodoItemOutputSchema = exports_external.object({
|
|
48152
|
-
id: exports_external.string()
|
|
48153
|
-
});
|
|
48154
|
-
|
|
48155
|
-
// ../core/src/tools/listTodoItems.ts
|
|
48156
|
-
var toolInfo7 = {
|
|
48157
|
-
name: "listTodoItems",
|
|
48158
|
-
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.",
|
|
48159
|
-
parameters: exports_external.object({
|
|
48160
|
-
id: exports_external.string().nullish(),
|
|
48161
|
-
status: TodoStatus.nullish()
|
|
48162
|
-
})
|
|
48163
|
-
};
|
|
48164
|
-
var handler7 = async (provider, args) => {
|
|
48165
|
-
if (!provider.listTodoItems) {
|
|
48166
|
-
return {
|
|
48167
|
-
type: "Error" /* Error */,
|
|
48168
|
-
message: {
|
|
48169
|
-
type: "error-text",
|
|
48170
|
-
value: "Not possible to list to-do items."
|
|
48171
|
-
}
|
|
48172
|
-
};
|
|
48173
|
-
}
|
|
48174
|
-
const { id, status } = toolInfo7.parameters.parse(args);
|
|
48175
|
-
const items = await provider.listTodoItems(id, status);
|
|
48176
|
-
return {
|
|
48177
|
-
type: "Reply" /* Reply */,
|
|
48178
|
-
message: {
|
|
48179
|
-
type: "json",
|
|
48180
|
-
value: items
|
|
48181
|
-
}
|
|
48182
|
-
};
|
|
48183
|
-
};
|
|
48184
|
-
var listTodoItems_default = {
|
|
48185
|
-
...toolInfo7,
|
|
48186
|
-
handler: handler7
|
|
48058
|
+
...toolInfo4,
|
|
48059
|
+
handler: handler4
|
|
48187
48060
|
};
|
|
48188
48061
|
// ../core/src/tools/readBinaryFile.ts
|
|
48189
|
-
var
|
|
48062
|
+
var toolInfo5 = {
|
|
48190
48063
|
name: "readBinaryFile",
|
|
48191
48064
|
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.",
|
|
48192
48065
|
parameters: exports_external.object({
|
|
48193
48066
|
url: exports_external.string().describe("The URL or local path of the file to read.")
|
|
48194
48067
|
})
|
|
48195
48068
|
};
|
|
48196
|
-
var
|
|
48069
|
+
var handler5 = async (provider, args) => {
|
|
48197
48070
|
if (!provider.readBinaryFile) {
|
|
48198
48071
|
return {
|
|
48199
|
-
|
|
48072
|
+
success: false,
|
|
48200
48073
|
message: {
|
|
48201
48074
|
type: "error-text",
|
|
48202
48075
|
value: "Not possible to fetch files. Abort."
|
|
48203
48076
|
}
|
|
48204
48077
|
};
|
|
48205
48078
|
}
|
|
48206
|
-
const { url: url2 } =
|
|
48079
|
+
const { url: url2 } = toolInfo5.parameters.parse(args);
|
|
48207
48080
|
try {
|
|
48208
48081
|
const filePart = await provider.readBinaryFile(url2);
|
|
48209
48082
|
return {
|
|
48210
|
-
|
|
48083
|
+
success: true,
|
|
48211
48084
|
message: {
|
|
48212
48085
|
type: "content",
|
|
48213
48086
|
value: [
|
|
@@ -48223,7 +48096,7 @@ var handler8 = async (provider, args) => {
|
|
|
48223
48096
|
} catch (error46) {
|
|
48224
48097
|
const errorMessage = error46 instanceof Error ? error46.message : "Unknown error";
|
|
48225
48098
|
return {
|
|
48226
|
-
|
|
48099
|
+
success: false,
|
|
48227
48100
|
message: {
|
|
48228
48101
|
type: "error-text",
|
|
48229
48102
|
value: `Error fetching file from ${url2}: ${errorMessage}`
|
|
@@ -48232,11 +48105,11 @@ var handler8 = async (provider, args) => {
|
|
|
48232
48105
|
}
|
|
48233
48106
|
};
|
|
48234
48107
|
var readBinaryFile_default = {
|
|
48235
|
-
...
|
|
48236
|
-
handler:
|
|
48108
|
+
...toolInfo5,
|
|
48109
|
+
handler: handler5
|
|
48237
48110
|
};
|
|
48238
48111
|
// ../core/src/tools/readFile.ts
|
|
48239
|
-
var
|
|
48112
|
+
var toolInfo6 = {
|
|
48240
48113
|
name: "readFile",
|
|
48241
48114
|
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.",
|
|
48242
48115
|
parameters: exports_external.object({
|
|
@@ -48273,17 +48146,17 @@ var toolInfo9 = {
|
|
|
48273
48146
|
]
|
|
48274
48147
|
})
|
|
48275
48148
|
};
|
|
48276
|
-
var
|
|
48149
|
+
var handler6 = async (provider, args) => {
|
|
48277
48150
|
if (!provider.readFile) {
|
|
48278
48151
|
return {
|
|
48279
|
-
|
|
48152
|
+
success: false,
|
|
48280
48153
|
message: {
|
|
48281
48154
|
type: "error-text",
|
|
48282
48155
|
value: "Not possible to read file."
|
|
48283
48156
|
}
|
|
48284
48157
|
};
|
|
48285
48158
|
}
|
|
48286
|
-
const { path: paths, includeIgnored } =
|
|
48159
|
+
const { path: paths, includeIgnored } = toolInfo6.parameters.parse(args);
|
|
48287
48160
|
const resp = [];
|
|
48288
48161
|
for (const path of paths) {
|
|
48289
48162
|
const fileContent = await provider.readFile(path, includeIgnored ?? false);
|
|
@@ -48299,7 +48172,7 @@ var handler9 = async (provider, args) => {
|
|
|
48299
48172
|
}
|
|
48300
48173
|
}
|
|
48301
48174
|
return {
|
|
48302
|
-
|
|
48175
|
+
success: true,
|
|
48303
48176
|
message: {
|
|
48304
48177
|
type: "text",
|
|
48305
48178
|
value: resp.join(`
|
|
@@ -48308,45 +48181,11 @@ var handler9 = async (provider, args) => {
|
|
|
48308
48181
|
};
|
|
48309
48182
|
};
|
|
48310
48183
|
var readFile_default = {
|
|
48311
|
-
...
|
|
48312
|
-
handler:
|
|
48313
|
-
};
|
|
48314
|
-
// ../core/src/tools/readMemory.ts
|
|
48315
|
-
var toolInfo10 = {
|
|
48316
|
-
name: "readMemory",
|
|
48317
|
-
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.",
|
|
48318
|
-
parameters: exports_external.object({
|
|
48319
|
-
topic: exports_external.string().nullish().describe('The topic to read from memory. Defaults to ":default:".')
|
|
48320
|
-
})
|
|
48321
|
-
};
|
|
48322
|
-
var handler10 = async (provider, args) => {
|
|
48323
|
-
const { topic } = toolInfo10.parameters.parse(args);
|
|
48324
|
-
const content = await provider.readMemory(topic ?? undefined);
|
|
48325
|
-
if (content) {
|
|
48326
|
-
return {
|
|
48327
|
-
type: "Reply" /* Reply */,
|
|
48328
|
-
message: {
|
|
48329
|
-
type: "text",
|
|
48330
|
-
value: `<memory${topic ? ` topic="${topic}"` : ""}>
|
|
48331
|
-
${content}
|
|
48332
|
-
</memory>`
|
|
48333
|
-
}
|
|
48334
|
-
};
|
|
48335
|
-
}
|
|
48336
|
-
return {
|
|
48337
|
-
type: "Reply" /* Reply */,
|
|
48338
|
-
message: {
|
|
48339
|
-
type: "text",
|
|
48340
|
-
value: `<memory ${topic ? `topic="${topic}"` : ""} isEmpty="true" />`
|
|
48341
|
-
}
|
|
48342
|
-
};
|
|
48343
|
-
};
|
|
48344
|
-
var readMemory_default = {
|
|
48345
|
-
...toolInfo10,
|
|
48346
|
-
handler: handler10
|
|
48184
|
+
...toolInfo6,
|
|
48185
|
+
handler: handler6
|
|
48347
48186
|
};
|
|
48348
48187
|
// ../core/src/tools/removeFile.ts
|
|
48349
|
-
var
|
|
48188
|
+
var toolInfo7 = {
|
|
48350
48189
|
name: "removeFile",
|
|
48351
48190
|
description: "Request to remove a file at the specified path.",
|
|
48352
48191
|
parameters: exports_external.object({
|
|
@@ -48362,20 +48201,20 @@ var toolInfo11 = {
|
|
|
48362
48201
|
]
|
|
48363
48202
|
})
|
|
48364
48203
|
};
|
|
48365
|
-
var
|
|
48204
|
+
var handler7 = async (provider, args) => {
|
|
48366
48205
|
if (!provider.removeFile) {
|
|
48367
48206
|
return {
|
|
48368
|
-
|
|
48207
|
+
success: false,
|
|
48369
48208
|
message: {
|
|
48370
48209
|
type: "error-text",
|
|
48371
48210
|
value: "Not possible to remove file."
|
|
48372
48211
|
}
|
|
48373
48212
|
};
|
|
48374
48213
|
}
|
|
48375
|
-
const parsed =
|
|
48214
|
+
const parsed = toolInfo7.parameters.safeParse(args);
|
|
48376
48215
|
if (!parsed.success) {
|
|
48377
48216
|
return {
|
|
48378
|
-
|
|
48217
|
+
success: false,
|
|
48379
48218
|
message: {
|
|
48380
48219
|
type: "error-text",
|
|
48381
48220
|
value: `Invalid arguments for removeFile: ${parsed.error.message}`
|
|
@@ -48385,7 +48224,7 @@ var handler11 = async (provider, args) => {
|
|
|
48385
48224
|
const { path } = parsed.data;
|
|
48386
48225
|
await provider.removeFile(path);
|
|
48387
48226
|
return {
|
|
48388
|
-
|
|
48227
|
+
success: true,
|
|
48389
48228
|
message: {
|
|
48390
48229
|
type: "text",
|
|
48391
48230
|
value: `<remove_file_path>${path}</remove_file_path><status>Success</status>`
|
|
@@ -48393,11 +48232,11 @@ var handler11 = async (provider, args) => {
|
|
|
48393
48232
|
};
|
|
48394
48233
|
};
|
|
48395
48234
|
var removeFile_default = {
|
|
48396
|
-
...
|
|
48397
|
-
handler:
|
|
48235
|
+
...toolInfo7,
|
|
48236
|
+
handler: handler7
|
|
48398
48237
|
};
|
|
48399
48238
|
// ../core/src/tools/renameFile.ts
|
|
48400
|
-
var
|
|
48239
|
+
var toolInfo8 = {
|
|
48401
48240
|
name: "renameFile",
|
|
48402
48241
|
description: "Request to rename a file from source path to target path.",
|
|
48403
48242
|
parameters: exports_external.object({
|
|
@@ -48415,20 +48254,20 @@ var toolInfo12 = {
|
|
|
48415
48254
|
]
|
|
48416
48255
|
})
|
|
48417
48256
|
};
|
|
48418
|
-
var
|
|
48257
|
+
var handler8 = async (provider, args) => {
|
|
48419
48258
|
if (!provider.renameFile) {
|
|
48420
48259
|
return {
|
|
48421
|
-
|
|
48260
|
+
success: false,
|
|
48422
48261
|
message: {
|
|
48423
48262
|
type: "error-text",
|
|
48424
48263
|
value: "Not possible to rename file."
|
|
48425
48264
|
}
|
|
48426
48265
|
};
|
|
48427
48266
|
}
|
|
48428
|
-
const { source_path, target_path } =
|
|
48267
|
+
const { source_path, target_path } = toolInfo8.parameters.parse(args);
|
|
48429
48268
|
await provider.renameFile(source_path, target_path);
|
|
48430
48269
|
return {
|
|
48431
|
-
|
|
48270
|
+
success: true,
|
|
48432
48271
|
message: {
|
|
48433
48272
|
type: "text",
|
|
48434
48273
|
value: `<rename_file_path>${target_path}</rename_file_path><status>Success</status>`
|
|
@@ -48436,8 +48275,8 @@ var handler12 = async (provider, args) => {
|
|
|
48436
48275
|
};
|
|
48437
48276
|
};
|
|
48438
48277
|
var renameFile_default = {
|
|
48439
|
-
...
|
|
48440
|
-
handler:
|
|
48278
|
+
...toolInfo8,
|
|
48279
|
+
handler: handler8
|
|
48441
48280
|
};
|
|
48442
48281
|
// ../core/src/tools/utils/replaceInFile.ts
|
|
48443
48282
|
var replaceInFile = (fileContent, diff) => {
|
|
@@ -48514,7 +48353,7 @@ var replaceInFile = (fileContent, diff) => {
|
|
|
48514
48353
|
};
|
|
48515
48354
|
|
|
48516
48355
|
// ../core/src/tools/replaceInFile.ts
|
|
48517
|
-
var
|
|
48356
|
+
var toolInfo9 = {
|
|
48518
48357
|
name: "replaceInFile",
|
|
48519
48358
|
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.",
|
|
48520
48359
|
parameters: exports_external.object({
|
|
@@ -48624,20 +48463,20 @@ function oldFeature() {
|
|
|
48624
48463
|
]
|
|
48625
48464
|
})
|
|
48626
48465
|
};
|
|
48627
|
-
var
|
|
48466
|
+
var handler9 = async (provider, args) => {
|
|
48628
48467
|
if (!provider.readFile || !provider.writeFile) {
|
|
48629
48468
|
return {
|
|
48630
|
-
|
|
48469
|
+
success: false,
|
|
48631
48470
|
message: {
|
|
48632
48471
|
type: "error-text",
|
|
48633
48472
|
value: "Not possible to replace in file."
|
|
48634
48473
|
}
|
|
48635
48474
|
};
|
|
48636
48475
|
}
|
|
48637
|
-
const parsed =
|
|
48476
|
+
const parsed = toolInfo9.parameters.safeParse(args);
|
|
48638
48477
|
if (!parsed.success) {
|
|
48639
48478
|
return {
|
|
48640
|
-
|
|
48479
|
+
success: false,
|
|
48641
48480
|
message: {
|
|
48642
48481
|
type: "error-text",
|
|
48643
48482
|
value: `Invalid arguments for replaceInFile: ${parsed.error.message}`
|
|
@@ -48649,7 +48488,7 @@ var handler13 = async (provider, args) => {
|
|
|
48649
48488
|
const fileContent = await provider.readFile(path, false);
|
|
48650
48489
|
if (fileContent == null) {
|
|
48651
48490
|
return {
|
|
48652
|
-
|
|
48491
|
+
success: false,
|
|
48653
48492
|
message: {
|
|
48654
48493
|
type: "error-text",
|
|
48655
48494
|
value: `<replace_in_file_result path="${path}" status="failed" message="File not found" />`
|
|
@@ -48659,7 +48498,7 @@ var handler13 = async (provider, args) => {
|
|
|
48659
48498
|
const result = replaceInFile(fileContent, diff);
|
|
48660
48499
|
if (result.status === "no_diff_applied") {
|
|
48661
48500
|
return {
|
|
48662
|
-
|
|
48501
|
+
success: false,
|
|
48663
48502
|
message: {
|
|
48664
48503
|
type: "error-text",
|
|
48665
48504
|
value: `<replace_in_file_result path="${path}" status="failed" message="Unable to apply changes">
|
|
@@ -48671,7 +48510,7 @@ var handler13 = async (provider, args) => {
|
|
|
48671
48510
|
await provider.writeFile(path, result.content);
|
|
48672
48511
|
if (result.status === "some_diff_applied") {
|
|
48673
48512
|
return {
|
|
48674
|
-
|
|
48513
|
+
success: true,
|
|
48675
48514
|
message: {
|
|
48676
48515
|
type: "text",
|
|
48677
48516
|
value: `<replace_in_file_result path="${path}" status="some_diff_applied" applied_count="${result.appliedCount}" total_count="${result.totalCount}">
|
|
@@ -48681,7 +48520,7 @@ var handler13 = async (provider, args) => {
|
|
|
48681
48520
|
};
|
|
48682
48521
|
}
|
|
48683
48522
|
return {
|
|
48684
|
-
|
|
48523
|
+
success: true,
|
|
48685
48524
|
message: {
|
|
48686
48525
|
type: "text",
|
|
48687
48526
|
value: `<replace_in_file_result path="${path}" status="all_diff_applied" />`
|
|
@@ -48689,7 +48528,7 @@ var handler13 = async (provider, args) => {
|
|
|
48689
48528
|
};
|
|
48690
48529
|
} catch (error46) {
|
|
48691
48530
|
return {
|
|
48692
|
-
|
|
48531
|
+
success: false,
|
|
48693
48532
|
message: {
|
|
48694
48533
|
type: "error-text",
|
|
48695
48534
|
value: `Invalid arguments for replaceInFile: ${error46}`
|
|
@@ -48698,11 +48537,11 @@ var handler13 = async (provider, args) => {
|
|
|
48698
48537
|
}
|
|
48699
48538
|
};
|
|
48700
48539
|
var replaceInFile_default = {
|
|
48701
|
-
...
|
|
48702
|
-
handler:
|
|
48540
|
+
...toolInfo9,
|
|
48541
|
+
handler: handler9
|
|
48703
48542
|
};
|
|
48704
48543
|
// ../core/src/tools/search.ts
|
|
48705
|
-
var
|
|
48544
|
+
var toolInfo10 = {
|
|
48706
48545
|
name: "search",
|
|
48707
48546
|
description: "Search the web for information using Google Search. Use this tool to find current information, facts, news, documentation, or research that is not available in your training data. Returns comprehensive search results with relevant content extracted from the web.",
|
|
48708
48547
|
parameters: exports_external.object({
|
|
@@ -48730,11 +48569,11 @@ var toolInfo14 = {
|
|
|
48730
48569
|
]
|
|
48731
48570
|
})
|
|
48732
48571
|
};
|
|
48733
|
-
var
|
|
48734
|
-
const { query } =
|
|
48572
|
+
var handler10 = async (provider, args) => {
|
|
48573
|
+
const { query } = toolInfo10.parameters.parse(args);
|
|
48735
48574
|
if (!provider.search) {
|
|
48736
48575
|
return {
|
|
48737
|
-
|
|
48576
|
+
success: false,
|
|
48738
48577
|
message: {
|
|
48739
48578
|
type: "text",
|
|
48740
48579
|
value: "This tool requires a web provider to be installed."
|
|
@@ -48743,7 +48582,7 @@ var handler14 = async (provider, args) => {
|
|
|
48743
48582
|
}
|
|
48744
48583
|
const result = await provider.search(query);
|
|
48745
48584
|
return {
|
|
48746
|
-
|
|
48585
|
+
success: true,
|
|
48747
48586
|
message: {
|
|
48748
48587
|
type: "text",
|
|
48749
48588
|
value: result
|
|
@@ -48751,11 +48590,11 @@ var handler14 = async (provider, args) => {
|
|
|
48751
48590
|
};
|
|
48752
48591
|
};
|
|
48753
48592
|
var search_default = {
|
|
48754
|
-
...
|
|
48755
|
-
handler:
|
|
48593
|
+
...toolInfo10,
|
|
48594
|
+
handler: handler10
|
|
48756
48595
|
};
|
|
48757
48596
|
// ../core/src/tools/searchFiles.ts
|
|
48758
|
-
var
|
|
48597
|
+
var toolInfo11 = {
|
|
48759
48598
|
name: "searchFiles",
|
|
48760
48599
|
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.",
|
|
48761
48600
|
parameters: exports_external.object({
|
|
@@ -48779,20 +48618,20 @@ var toolInfo15 = {
|
|
|
48779
48618
|
]
|
|
48780
48619
|
})
|
|
48781
48620
|
};
|
|
48782
|
-
var
|
|
48621
|
+
var handler11 = async (provider, args) => {
|
|
48783
48622
|
if (!provider.searchFiles) {
|
|
48784
48623
|
return {
|
|
48785
|
-
|
|
48624
|
+
success: false,
|
|
48786
48625
|
message: {
|
|
48787
48626
|
type: "error-text",
|
|
48788
48627
|
value: "Not possible to search files."
|
|
48789
48628
|
}
|
|
48790
48629
|
};
|
|
48791
48630
|
}
|
|
48792
|
-
const parsed =
|
|
48631
|
+
const parsed = toolInfo11.parameters.safeParse(args);
|
|
48793
48632
|
if (!parsed.success) {
|
|
48794
48633
|
return {
|
|
48795
|
-
|
|
48634
|
+
success: false,
|
|
48796
48635
|
message: {
|
|
48797
48636
|
type: "error-text",
|
|
48798
48637
|
value: `Invalid arguments for searchFiles: ${parsed.error.message}`
|
|
@@ -48803,7 +48642,7 @@ var handler15 = async (provider, args) => {
|
|
|
48803
48642
|
try {
|
|
48804
48643
|
const files = await provider.searchFiles(path, regex, filePattern ?? "*");
|
|
48805
48644
|
return {
|
|
48806
|
-
|
|
48645
|
+
success: true,
|
|
48807
48646
|
message: {
|
|
48808
48647
|
type: "text",
|
|
48809
48648
|
value: `<search_files_path>${path}</search_files_path>
|
|
@@ -48818,7 +48657,7 @@ ${files.join(`
|
|
|
48818
48657
|
};
|
|
48819
48658
|
} catch (error46) {
|
|
48820
48659
|
return {
|
|
48821
|
-
|
|
48660
|
+
success: false,
|
|
48822
48661
|
message: {
|
|
48823
48662
|
type: "error-text",
|
|
48824
48663
|
value: `Error searching files: ${error46}`
|
|
@@ -48827,112 +48666,48 @@ ${files.join(`
|
|
|
48827
48666
|
}
|
|
48828
48667
|
};
|
|
48829
48668
|
var searchFiles_default = {
|
|
48830
|
-
...
|
|
48831
|
-
handler:
|
|
48669
|
+
...toolInfo11,
|
|
48670
|
+
handler: handler11
|
|
48832
48671
|
};
|
|
48833
|
-
// ../core/src/tools/
|
|
48834
|
-
var
|
|
48835
|
-
|
|
48836
|
-
|
|
48837
|
-
|
|
48838
|
-
|
|
48839
|
-
|
|
48840
|
-
|
|
48841
|
-
|
|
48842
|
-
|
|
48843
|
-
|
|
48844
|
-
|
|
48845
|
-
|
|
48846
|
-
|
|
48847
|
-
|
|
48848
|
-
|
|
48849
|
-
|
|
48850
|
-
|
|
48851
|
-
|
|
48852
|
-
|
|
48853
|
-
|
|
48854
|
-
|
|
48855
|
-
|
|
48856
|
-
});
|
|
48857
|
-
}
|
|
48672
|
+
// ../core/src/tools/todo.ts
|
|
48673
|
+
var TodoStatus = exports_external.enum(["open", "completed", "closed"]);
|
|
48674
|
+
var TodoItemSchema = exports_external.object({
|
|
48675
|
+
id: exports_external.string(),
|
|
48676
|
+
title: exports_external.string(),
|
|
48677
|
+
description: exports_external.string(),
|
|
48678
|
+
status: TodoStatus
|
|
48679
|
+
});
|
|
48680
|
+
var UpdateTodoItemInputSchema = exports_external.object({
|
|
48681
|
+
operation: exports_external.enum(["add", "update"]),
|
|
48682
|
+
id: exports_external.string().nullish(),
|
|
48683
|
+
parentId: exports_external.string().nullish(),
|
|
48684
|
+
title: exports_external.string().nullish(),
|
|
48685
|
+
description: exports_external.string().nullish(),
|
|
48686
|
+
status: TodoStatus.nullish()
|
|
48687
|
+
}).superRefine((data, ctx) => {
|
|
48688
|
+
if (data.operation === "add") {
|
|
48689
|
+
if (!data.title) {
|
|
48690
|
+
ctx.addIssue({
|
|
48691
|
+
code: "custom",
|
|
48692
|
+
message: 'Title is required for "add" operation',
|
|
48693
|
+
path: ["title"]
|
|
48694
|
+
});
|
|
48858
48695
|
}
|
|
48859
|
-
})
|
|
48860
|
-
|
|
48861
|
-
|
|
48862
|
-
|
|
48863
|
-
|
|
48864
|
-
|
|
48865
|
-
|
|
48866
|
-
type: "error-text",
|
|
48867
|
-
value: "Memory operations are not supported by the current provider."
|
|
48868
|
-
}
|
|
48869
|
-
};
|
|
48870
|
-
}
|
|
48871
|
-
const params = toolInfo16.parameters.parse(args);
|
|
48872
|
-
await provider.updateMemory(params.operation, params.topic ?? undefined, params.content ?? undefined);
|
|
48873
|
-
switch (params.operation) {
|
|
48874
|
-
case "append":
|
|
48875
|
-
return {
|
|
48876
|
-
type: "Reply" /* Reply */,
|
|
48877
|
-
message: {
|
|
48878
|
-
type: "text",
|
|
48879
|
-
value: `Content appended to memory topic '${params.topic || ":default:"}'.`
|
|
48880
|
-
}
|
|
48881
|
-
};
|
|
48882
|
-
case "replace":
|
|
48883
|
-
return {
|
|
48884
|
-
type: "Reply" /* Reply */,
|
|
48885
|
-
message: {
|
|
48886
|
-
type: "text",
|
|
48887
|
-
value: `Memory topic '${params.topic || ":default:"}' replaced.`
|
|
48888
|
-
}
|
|
48889
|
-
};
|
|
48890
|
-
case "remove":
|
|
48891
|
-
return {
|
|
48892
|
-
type: "Reply" /* Reply */,
|
|
48893
|
-
message: {
|
|
48894
|
-
type: "text",
|
|
48895
|
-
value: `Memory topic '${params.topic || ":default:"}' removed.`
|
|
48896
|
-
}
|
|
48897
|
-
};
|
|
48898
|
-
}
|
|
48899
|
-
};
|
|
48900
|
-
var updateMemory_default = {
|
|
48901
|
-
...toolInfo16,
|
|
48902
|
-
handler: handler16
|
|
48903
|
-
};
|
|
48904
|
-
// ../core/src/tools/updateTodoItem.ts
|
|
48905
|
-
var toolInfo17 = {
|
|
48906
|
-
name: "updateTodoItem",
|
|
48907
|
-
description: "Add or update a to-do item.",
|
|
48908
|
-
parameters: UpdateTodoItemInputSchema
|
|
48909
|
-
};
|
|
48910
|
-
var handler17 = async (provider, args) => {
|
|
48911
|
-
if (!provider.updateTodoItem) {
|
|
48912
|
-
return {
|
|
48913
|
-
type: "Error" /* Error */,
|
|
48914
|
-
message: {
|
|
48915
|
-
type: "error-text",
|
|
48916
|
-
value: "Not possible to update a to-do item."
|
|
48917
|
-
}
|
|
48918
|
-
};
|
|
48919
|
-
}
|
|
48920
|
-
const input = toolInfo17.parameters.parse(args);
|
|
48921
|
-
const result = await provider.updateTodoItem(input);
|
|
48922
|
-
return {
|
|
48923
|
-
type: "Reply" /* Reply */,
|
|
48924
|
-
message: {
|
|
48925
|
-
type: "json",
|
|
48926
|
-
value: result
|
|
48696
|
+
} else if (data.operation === "update") {
|
|
48697
|
+
if (!data.id) {
|
|
48698
|
+
ctx.addIssue({
|
|
48699
|
+
code: "custom",
|
|
48700
|
+
message: 'ID is required for "update" operation',
|
|
48701
|
+
path: ["id"]
|
|
48702
|
+
});
|
|
48927
48703
|
}
|
|
48928
|
-
}
|
|
48929
|
-
};
|
|
48930
|
-
var
|
|
48931
|
-
|
|
48932
|
-
|
|
48933
|
-
};
|
|
48704
|
+
}
|
|
48705
|
+
});
|
|
48706
|
+
var UpdateTodoItemOutputSchema = exports_external.object({
|
|
48707
|
+
id: exports_external.string()
|
|
48708
|
+
});
|
|
48934
48709
|
// ../core/src/tools/writeToFile.ts
|
|
48935
|
-
var
|
|
48710
|
+
var toolInfo12 = {
|
|
48936
48711
|
name: "writeToFile",
|
|
48937
48712
|
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.",
|
|
48938
48713
|
parameters: exports_external.object({
|
|
@@ -48961,20 +48736,20 @@ export default App;
|
|
|
48961
48736
|
]
|
|
48962
48737
|
})
|
|
48963
48738
|
};
|
|
48964
|
-
var
|
|
48739
|
+
var handler12 = async (provider, args) => {
|
|
48965
48740
|
if (!provider.writeFile) {
|
|
48966
48741
|
return {
|
|
48967
|
-
|
|
48742
|
+
success: false,
|
|
48968
48743
|
message: {
|
|
48969
48744
|
type: "error-text",
|
|
48970
48745
|
value: "Not possible to write file."
|
|
48971
48746
|
}
|
|
48972
48747
|
};
|
|
48973
48748
|
}
|
|
48974
|
-
const parsed =
|
|
48749
|
+
const parsed = toolInfo12.parameters.safeParse(args);
|
|
48975
48750
|
if (!parsed.success) {
|
|
48976
48751
|
return {
|
|
48977
|
-
|
|
48752
|
+
success: false,
|
|
48978
48753
|
message: {
|
|
48979
48754
|
type: "error-text",
|
|
48980
48755
|
value: `Invalid arguments for writeToFile: ${parsed.error.message}`
|
|
@@ -48987,7 +48762,7 @@ var handler18 = async (provider, args) => {
|
|
|
48987
48762
|
content = trimmedContent.slice(9, -3);
|
|
48988
48763
|
await provider.writeFile(path, content);
|
|
48989
48764
|
return {
|
|
48990
|
-
|
|
48765
|
+
success: true,
|
|
48991
48766
|
message: {
|
|
48992
48767
|
type: "text",
|
|
48993
48768
|
value: `<write_to_file_path>${path}</write_to_file_path><status>Success</status>`
|
|
@@ -48995,8 +48770,8 @@ var handler18 = async (provider, args) => {
|
|
|
48995
48770
|
};
|
|
48996
48771
|
};
|
|
48997
48772
|
var writeToFile_default = {
|
|
48998
|
-
...
|
|
48999
|
-
handler:
|
|
48773
|
+
...toolInfo12,
|
|
48774
|
+
handler: handler12
|
|
49000
48775
|
};
|
|
49001
48776
|
// ../core/src/UsageMeter.ts
|
|
49002
48777
|
class UsageMeter {
|
|
@@ -58816,7 +58591,8 @@ var WorkflowStepDefinitionSchema = exports_external.object({
|
|
|
58816
58591
|
output: exports_external.string().nullish(),
|
|
58817
58592
|
expected_outcome: exports_external.string().nullish(),
|
|
58818
58593
|
code: exports_external.string().nullish(),
|
|
58819
|
-
outputSchema: exports_external.any().nullish()
|
|
58594
|
+
outputSchema: exports_external.any().nullish(),
|
|
58595
|
+
timeout: exports_external.number().positive().nullish()
|
|
58820
58596
|
});
|
|
58821
58597
|
var WorkflowDefinitionSchema = exports_external.object({
|
|
58822
58598
|
task: exports_external.string(),
|
|
@@ -58830,17 +58606,383 @@ var WorkflowFileSchema = exports_external.object({
|
|
|
58830
58606
|
|
|
58831
58607
|
// ../core/src/workflow/dynamic.ts
|
|
58832
58608
|
var AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;
|
|
58609
|
+
// ../core/src/workflow/prompts/dynamic-generator-prompts.ts
|
|
58610
|
+
var RUNTIME_CONTEXT_TYPES = `## Runtime context (ctx)
|
|
58611
|
+
\`\`\`ts
|
|
58612
|
+
// Runtime types (for reference)
|
|
58613
|
+
type Logger = {
|
|
58614
|
+
debug: (...args: any[]) => void
|
|
58615
|
+
info: (...args: any[]) => void
|
|
58616
|
+
warn: (...args: any[]) => void
|
|
58617
|
+
error: (...args: any[]) => void
|
|
58618
|
+
}
|
|
58619
|
+
|
|
58620
|
+
type StepFn = {
|
|
58621
|
+
<T>(name: string, fn: () => Promise<T>): Promise<T>
|
|
58622
|
+
<T>(name: string, options: { retry?: number }, fn: () => Promise<T>): Promise<T>
|
|
58623
|
+
}
|
|
58624
|
+
|
|
58625
|
+
type JsonModelMessage = { role: 'system' | 'user' | 'assistant' | 'tool'; content: any }
|
|
58626
|
+
type JsonResponseMessage = { role: 'assistant' | 'tool'; content: any }
|
|
58627
|
+
type ToolSet = Record<string, any>
|
|
58628
|
+
|
|
58629
|
+
type ToolResponseResult =
|
|
58630
|
+
| { type: 'text'; value: string }
|
|
58631
|
+
| { type: 'json'; value: any }
|
|
58632
|
+
| { type: 'error-text'; value: string }
|
|
58633
|
+
| { type: 'error-json'; value: any }
|
|
58634
|
+
| { type: 'content'; value: any[] }
|
|
58635
|
+
|
|
58636
|
+
type ToolResponse =
|
|
58637
|
+
| { type: 'Reply'; message: ToolResponseResult }
|
|
58638
|
+
| { type: 'Exit'; message: string; object?: any }
|
|
58639
|
+
| { type: 'Error'; message: ToolResponseResult }
|
|
58640
|
+
|
|
58641
|
+
type ExitReason =
|
|
58642
|
+
| { type: 'UsageExceeded' }
|
|
58643
|
+
| { type: 'Exit'; message: string; object?: any }
|
|
58644
|
+
| { type: 'Error'; error: { message: string; stack?: string } }
|
|
58645
|
+
|
|
58646
|
+
type FullToolInfo = { name: string; description: string; parameters: any; handler: any }
|
|
58647
|
+
|
|
58648
|
+
type AgentTools = {
|
|
58649
|
+
readFile: (input: { path: string }) => Promise<string | null>
|
|
58650
|
+
writeToFile: (input: { path: string; content: string }) => Promise<void>
|
|
58651
|
+
executeCommand: (input: { command: string; pipe?: boolean; requiresApproval?: boolean } & ({ args: string[]; shell?: false } | { shell: true })) => Promise<{
|
|
58652
|
+
exitCode: number
|
|
58653
|
+
stdout: string
|
|
58654
|
+
stderr: string
|
|
58655
|
+
}>
|
|
58656
|
+
searchFiles: (input: { path: string; regex: string; filePattern?: string }) => Promise<string>
|
|
58657
|
+
listFiles: (input: { path: string; recursive?: boolean; maxCount?: number; includeIgnored?: boolean }) => Promise<string>
|
|
58658
|
+
fetchUrl: (input: { url: string[] }) => Promise<string>
|
|
58659
|
+
askFollowupQuestion: (input: { questions: { prompt: string; options?: string[] }[] }) => Promise<any>
|
|
58660
|
+
// ... and other tools available in the environment
|
|
58661
|
+
}
|
|
58662
|
+
|
|
58663
|
+
// Tools available on ctx.tools in dynamic steps
|
|
58664
|
+
type DynamicWorkflowTools = {
|
|
58665
|
+
// LLM + agent helpers
|
|
58666
|
+
runAgent: (input: {
|
|
58667
|
+
tools: Readonly<FullToolInfo[]>
|
|
58668
|
+
maxToolRoundTrips?: number
|
|
58669
|
+
userMessage: readonly JsonModelMessage[]
|
|
58670
|
+
} & ({ messages: JsonModelMessage[] } | { systemPrompt: string })) => Promise<ExitReason>
|
|
58671
|
+
|
|
58672
|
+
// CLI UX helpers
|
|
58673
|
+
confirm: (input: { message: string }) => Promise<boolean>
|
|
58674
|
+
input: (input: { message: string; default?: string }) => Promise<string>
|
|
58675
|
+
select: (input: { message: string; choices: { name: string; value: string }[] }) => Promise<string>
|
|
58676
|
+
}
|
|
58677
|
+
|
|
58678
|
+
type DynamicStepRuntimeContext = {
|
|
58679
|
+
workflowId: string
|
|
58680
|
+
stepId: string
|
|
58681
|
+
input: Record<string, any>
|
|
58682
|
+
state: Record<string, any>
|
|
58683
|
+
tools: DynamicWorkflowTools
|
|
58684
|
+
agentTools: AgentTools
|
|
58685
|
+
logger: Logger
|
|
58686
|
+
step: StepFn
|
|
58687
|
+
runWorkflow: (workflowId: string, input?: Record<string, any>) => Promise<any>
|
|
58688
|
+
toolInfo?: ReadonlyArray<FullToolInfo>
|
|
58689
|
+
}
|
|
58690
|
+
\`\`\`
|
|
58691
|
+
|
|
58692
|
+
- \`ctx.input\`: workflow inputs (read-only).
|
|
58693
|
+
- \`ctx.state\`: shared state between steps (previous step outputs are stored here).
|
|
58694
|
+
- \`ctx.agentTools\`: standard tools (readFile, executeCommand, etc.). Call as \`await ctx.agentTools.someTool({ ... })\`.
|
|
58695
|
+
- \`ctx.tools\`: workflow helpers (runAgent, confirm, input, select).
|
|
58696
|
+
- \`ctx.runWorkflow\`: run a sub-workflow by id.`;
|
|
58697
|
+
var CONTEXT_USAGE_GUIDELINES = `## Guidelines
|
|
58698
|
+
- Use \`await\` for all async operations.
|
|
58699
|
+
- Return the output value for the step (this becomes the step output).
|
|
58700
|
+
- Access inputs via \`ctx.input.<inputId>\`.
|
|
58701
|
+
- Access previous step outputs via \`ctx.state.<stepOutputKey>\` (defaults to the step \`output\` or \`id\`).`;
|
|
58702
|
+
var QUALITY_GUIDELINES = `## Quality Guidelines for Code Implementation
|
|
58703
|
+
|
|
58704
|
+
### Error Handling
|
|
58705
|
+
- ALWAYS validate inputs at the start of steps
|
|
58706
|
+
- Use try-catch for operations that might fail (file I/O, parsing, API calls)
|
|
58707
|
+
- Preserve stack traces: re-throw original errors rather than creating new ones
|
|
58708
|
+
- Use error type guards: \`const err = error instanceof Error ? error : new Error(String(error))\`
|
|
58709
|
+
- Check for null/undefined before using values
|
|
58710
|
+
- Handle edge cases (empty arrays, missing files, invalid data)
|
|
58711
|
+
|
|
58712
|
+
### Logging
|
|
58713
|
+
- Use \`ctx.logger.info()\` for important progress updates
|
|
58714
|
+
- Use \`ctx.logger.debug()\` for detailed information
|
|
58715
|
+
- Use \`ctx.logger.warn()\` for recoverable issues
|
|
58716
|
+
- Use \`ctx.logger.error()\` before throwing errors
|
|
58717
|
+
- Log when starting and completing significant operations
|
|
58718
|
+
- Use template literals for readability: \`ctx.logger.info(\\\`Processing \${items.length} items...\\\`)\`
|
|
58719
|
+
|
|
58720
|
+
### User Experience
|
|
58721
|
+
- Provide progress feedback for long operations
|
|
58722
|
+
- Return structured data (objects/arrays), not strings when possible
|
|
58723
|
+
- Include helpful metadata in results (counts, timestamps, status)
|
|
58724
|
+
- For batch operations, report progress: \`Processed 5/10 items\`
|
|
58725
|
+
|
|
58726
|
+
### Data Validation
|
|
58727
|
+
- Validate required fields exist before accessing
|
|
58728
|
+
- Check data types match expectations
|
|
58729
|
+
- Validate array lengths before iteration
|
|
58730
|
+
- Example: \`if (!data?.users || !Array.isArray(data.users)) throw new Error('Invalid data format')\`
|
|
58731
|
+
|
|
58732
|
+
### Best Practices
|
|
58733
|
+
- Use meaningful variable names
|
|
58734
|
+
- Avoid nested callbacks - use async/await
|
|
58735
|
+
- Clean up resources (close files, clear timeouts)
|
|
58736
|
+
- Return consistent data structures across similar steps
|
|
58737
|
+
- For iteration, consider batching or rate limiting
|
|
58738
|
+
|
|
58739
|
+
### When to Simplify
|
|
58740
|
+
- Simple transformation steps (e.g., formatting strings) need only basic error handling
|
|
58741
|
+
- Internal sub-workflow steps with validated inputs from parent can skip redundant validation
|
|
58742
|
+
- Minimal logging is fine for fast steps (<100ms) that don't perform I/O or external calls
|
|
58743
|
+
- Use judgment: match error handling complexity to the step's failure risk and impact`;
|
|
58744
|
+
var TOOL_CALLING_EXAMPLES = `## Tool calling examples
|
|
58745
|
+
|
|
58746
|
+
### Standard tools (ctx.agentTools)
|
|
58747
|
+
\`\`\`ts
|
|
58748
|
+
// readFile
|
|
58749
|
+
const readme = await ctx.agentTools.readFile({ path: 'README.md' })
|
|
58750
|
+
if (readme == null) throw new Error('README.md not found')
|
|
58751
|
+
|
|
58752
|
+
// writeToFile
|
|
58753
|
+
await ctx.agentTools.writeToFile({ path: 'notes.txt', content: 'hello\\n' })
|
|
58754
|
+
|
|
58755
|
+
// executeCommand (args form)
|
|
58756
|
+
const rg = await ctx.agentTools.executeCommand({ command: 'rg', args: ['-n', 'TODO', '.'] })
|
|
58757
|
+
if (rg.exitCode !== 0) throw new Error(rg.stderr)
|
|
58758
|
+
|
|
58759
|
+
// executeCommand (shell form)
|
|
58760
|
+
await ctx.agentTools.executeCommand({ command: 'ls -la', shell: true, pipe: true })
|
|
58761
|
+
\`\`\`
|
|
58762
|
+
|
|
58763
|
+
### Workflow helpers (ctx.tools)
|
|
58764
|
+
\`\`\`ts
|
|
58765
|
+
// runAgent (nested agent; use ctx.toolInfo as the tool list)
|
|
58766
|
+
const agentRes = await ctx.tools.runAgent({
|
|
58767
|
+
systemPrompt: 'You are a helpful assistant.',
|
|
58768
|
+
userMessage: [{ role: 'user', content: 'Summarize README.md in 3 bullets.' }],
|
|
58769
|
+
tools: (ctx.toolInfo ?? []) as any,
|
|
58770
|
+
})
|
|
58771
|
+
if (agentRes.type !== 'Exit') throw new Error('runAgent failed')
|
|
58772
|
+
|
|
58773
|
+
// confirm / input / select (interactive)
|
|
58774
|
+
const ok = await ctx.tools.confirm({ message: 'Proceed?' })
|
|
58775
|
+
const name = await ctx.tools.input({ message: 'Name?', default: 'main' })
|
|
58776
|
+
const flavor = await ctx.tools.select({
|
|
58777
|
+
message: 'Pick one',
|
|
58778
|
+
choices: [
|
|
58779
|
+
{ name: 'A', value: 'a' },
|
|
58780
|
+
{ name: 'B', value: 'b' },
|
|
58781
|
+
],
|
|
58782
|
+
})
|
|
58783
|
+
\`\`\`
|
|
58784
|
+
|
|
58785
|
+
### Sub-workflow example (ctx.runWorkflow)
|
|
58786
|
+
\`\`\`ts
|
|
58787
|
+
const results: any[] = []
|
|
58788
|
+
for (const pr of ctx.state.prs ?? []) {
|
|
58789
|
+
results.push(await ctx.runWorkflow('reviewPR', { prId: pr.id }))
|
|
58790
|
+
}
|
|
58791
|
+
return results
|
|
58792
|
+
\`\`\``;
|
|
58793
|
+
var COMPLETE_STEP_EXAMPLE = `## Complete Example: High-Quality Step Implementation
|
|
58794
|
+
|
|
58795
|
+
This example demonstrates all quality guidelines in a single step:
|
|
58796
|
+
|
|
58797
|
+
\`\`\`ts
|
|
58798
|
+
// Step: processUserData
|
|
58799
|
+
// Task: Read, validate, and process user data from a file
|
|
58800
|
+
|
|
58801
|
+
// Input validation
|
|
58802
|
+
if (!ctx.input.dataFile) {
|
|
58803
|
+
throw new Error('Missing required input: dataFile')
|
|
58804
|
+
}
|
|
58805
|
+
|
|
58806
|
+
ctx.logger.info(\`Starting user data processing for: \${ctx.input.dataFile}\`)
|
|
58807
|
+
|
|
58808
|
+
// Read file with error handling
|
|
58809
|
+
let rawData
|
|
58810
|
+
try {
|
|
58811
|
+
ctx.logger.debug(\`Reading file: \${ctx.input.dataFile}\`)
|
|
58812
|
+
rawData = await ctx.agentTools.readFile({ path: ctx.input.dataFile })
|
|
58813
|
+
|
|
58814
|
+
if (!rawData) {
|
|
58815
|
+
throw new Error(\`File not found or empty: \${ctx.input.dataFile}\`)
|
|
58816
|
+
}
|
|
58817
|
+
} catch (error) {
|
|
58818
|
+
const err = error instanceof Error ? error : new Error(String(error))
|
|
58819
|
+
ctx.logger.error(\`Failed to read file: \${err.message}\`)
|
|
58820
|
+
throw err // Preserve original stack trace
|
|
58821
|
+
}
|
|
58822
|
+
|
|
58823
|
+
// Parse and validate data
|
|
58824
|
+
let users
|
|
58825
|
+
try {
|
|
58826
|
+
ctx.logger.debug('Parsing JSON data')
|
|
58827
|
+
const parsed = JSON.parse(rawData)
|
|
58828
|
+
|
|
58829
|
+
if (!parsed?.users || !Array.isArray(parsed.users)) {
|
|
58830
|
+
throw new Error('Invalid data format: expected {users: [...]}')
|
|
58831
|
+
}
|
|
58832
|
+
|
|
58833
|
+
users = parsed.users
|
|
58834
|
+
ctx.logger.info(\`Found \${users.length} users to process\`)
|
|
58835
|
+
} catch (error) {
|
|
58836
|
+
const err = error instanceof Error ? error : new Error(String(error))
|
|
58837
|
+
ctx.logger.error(\`Data parsing failed: \${err.message}\`)
|
|
58838
|
+
throw err // Preserve original stack trace
|
|
58839
|
+
}
|
|
58840
|
+
|
|
58841
|
+
// Process each user with progress reporting
|
|
58842
|
+
const results = []
|
|
58843
|
+
for (let i = 0; i < users.length; i++) {
|
|
58844
|
+
const user = users[i]
|
|
58845
|
+
|
|
58846
|
+
// Validate each user object
|
|
58847
|
+
if (!user?.id || !user?.email) {
|
|
58848
|
+
ctx.logger.warn(\`Skipping invalid user at index \${i}: missing id or email\`)
|
|
58849
|
+
continue
|
|
58850
|
+
}
|
|
58851
|
+
|
|
58852
|
+
// Process user
|
|
58853
|
+
const processed = {
|
|
58854
|
+
id: user.id,
|
|
58855
|
+
email: user.email.toLowerCase().trim(),
|
|
58856
|
+
name: user.name?.trim() || 'Unknown',
|
|
58857
|
+
processedAt: new Date().toISOString(),
|
|
58858
|
+
status: 'active'
|
|
58859
|
+
}
|
|
58860
|
+
|
|
58861
|
+
results.push(processed)
|
|
58862
|
+
|
|
58863
|
+
// Progress feedback every 10 items
|
|
58864
|
+
if ((i + 1) % 10 === 0) {
|
|
58865
|
+
ctx.logger.info(\`Processed \${i + 1}/\${users.length} users\`)
|
|
58866
|
+
}
|
|
58867
|
+
}
|
|
58868
|
+
|
|
58869
|
+
ctx.logger.info(\`Successfully processed \${results.length}/\${users.length} users\`)
|
|
58870
|
+
|
|
58871
|
+
// Return structured result with metadata
|
|
58872
|
+
return {
|
|
58873
|
+
users: results,
|
|
58874
|
+
metadata: {
|
|
58875
|
+
totalInput: users.length,
|
|
58876
|
+
totalProcessed: results.length,
|
|
58877
|
+
skipped: users.length - results.length,
|
|
58878
|
+
processedAt: new Date().toISOString()
|
|
58879
|
+
}
|
|
58880
|
+
}
|
|
58881
|
+
\`\`\`
|
|
58882
|
+
|
|
58883
|
+
Key features demonstrated:
|
|
58884
|
+
- Input validation at start
|
|
58885
|
+
- Comprehensive error handling with try-catch that preserves stack traces
|
|
58886
|
+
- Logging at info, debug, warn, and error levels
|
|
58887
|
+
- Progress reporting for long operations (every 10 items)
|
|
58888
|
+
- Data validation throughout (null checks, type checks, array validation)
|
|
58889
|
+
- Structured return value with metadata for observability
|
|
58890
|
+
- Descriptive error messages with context
|
|
58891
|
+
- Meaningful variable names (rawData, users, processed)
|
|
58892
|
+
- Clean async/await usage
|
|
58893
|
+
- Template literals for readable string interpolation
|
|
58894
|
+
- Proper error type guards (error instanceof Error)`;
|
|
58895
|
+
var CODE_FIELD_CONSTRAINTS = `REMEMBER: The "code" field must be ONLY the function body statements.
|
|
58896
|
+
- DO NOT wrap code in arrow functions: \`(ctx) => { ... }\`
|
|
58897
|
+
- DO NOT wrap code in async functions: \`async (ctx) => { ... }\`
|
|
58898
|
+
- DO NOT include outer curly braces
|
|
58899
|
+
- DO include a return statement if the step should produce output
|
|
58900
|
+
- Each "code" field should be a string containing multiple statements separated by newlines`;
|
|
58901
|
+
function composeImplementationGuidelines() {
|
|
58902
|
+
return [
|
|
58903
|
+
RUNTIME_CONTEXT_TYPES,
|
|
58904
|
+
"",
|
|
58905
|
+
CONTEXT_USAGE_GUIDELINES,
|
|
58906
|
+
"",
|
|
58907
|
+
QUALITY_GUIDELINES,
|
|
58908
|
+
"",
|
|
58909
|
+
TOOL_CALLING_EXAMPLES,
|
|
58910
|
+
"",
|
|
58911
|
+
COMPLETE_STEP_EXAMPLE
|
|
58912
|
+
].join(`
|
|
58913
|
+
`);
|
|
58914
|
+
}
|
|
58915
|
+
|
|
58833
58916
|
// ../core/src/workflow/dynamic-generator.workflow.ts
|
|
58834
58917
|
var GenerateWorkflowDefinitionInputSchema = exports_external.object({
|
|
58835
58918
|
prompt: exports_external.string(),
|
|
58836
58919
|
availableTools: exports_external.array(exports_external.object({
|
|
58837
58920
|
name: exports_external.string(),
|
|
58838
58921
|
description: exports_external.string()
|
|
58839
|
-
})).
|
|
58922
|
+
})).nullish()
|
|
58840
58923
|
});
|
|
58841
58924
|
var GenerateWorkflowCodeInputSchema = exports_external.object({
|
|
58842
|
-
workflow: WorkflowFileSchema
|
|
58925
|
+
workflow: WorkflowFileSchema,
|
|
58926
|
+
skipReview: exports_external.boolean().nullish()
|
|
58843
58927
|
});
|
|
58928
|
+
var AsyncFunction2 = Object.getPrototypeOf(async () => {}).constructor;
|
|
58929
|
+
var WORKFLOW_IMPLEMENTATION_GUIDELINES = composeImplementationGuidelines();
|
|
58930
|
+
var WORKFLOW_CODE_SYSTEM_PROMPT = `You are an expert TypeScript developer.
|
|
58931
|
+
Your task is to implement the TypeScript code for the steps in the provided workflow definition.
|
|
58932
|
+
|
|
58933
|
+
You will receive a JSON workflow definition where the "code" field is null.
|
|
58934
|
+
You must fill in the "code" field for each step with valid TypeScript code.
|
|
58935
|
+
|
|
58936
|
+
CRITICAL: Each step "code" field must contain ONLY the function body statements (the code inside the curly braces).
|
|
58937
|
+
DO NOT include function declaration, arrow function syntax, async keyword, parameter list, or outer curly braces.
|
|
58938
|
+
|
|
58939
|
+
Prefer using \`ctx.tools.runAgent\` for complex tasks or when multiple steps/tools are needed. Use \`ctx.agentTools\` for direct tool usage (e.g. \`ctx.agentTools.readFile\`).
|
|
58940
|
+
|
|
58941
|
+
The code will be wrapped automatically in: \`async (ctx) => { YOUR_CODE_HERE }\`
|
|
58942
|
+
|
|
58943
|
+
Example of CORRECT code field:
|
|
58944
|
+
\`\`\`ts
|
|
58945
|
+
const result = await ctx.agentTools.readFile({ path: 'README.md' })
|
|
58946
|
+
if (!result) throw new Error('File not found')
|
|
58947
|
+
return result
|
|
58948
|
+
\`\`\`
|
|
58949
|
+
|
|
58950
|
+
Example of INCORRECT code field (DO NOT DO THIS):
|
|
58951
|
+
\`\`\`ts
|
|
58952
|
+
async (ctx) => {
|
|
58953
|
+
const result = await ctx.agentTools.readFile({ path: 'README.md' })
|
|
58954
|
+
return result
|
|
58955
|
+
}
|
|
58956
|
+
\`\`\`
|
|
58957
|
+
|
|
58958
|
+
${WORKFLOW_IMPLEMENTATION_GUIDELINES}
|
|
58959
|
+
|
|
58960
|
+
## Final Instructions
|
|
58961
|
+
|
|
58962
|
+
${CODE_FIELD_CONSTRAINTS}
|
|
58963
|
+
|
|
58964
|
+
Return the complete workflow JSON with the "code" fields populated.
|
|
58965
|
+
`;
|
|
58966
|
+
var WORKFLOW_REVIEW_SYSTEM_PROMPT = `You are an expert TypeScript Code Reviewer.
|
|
58967
|
+
Your task is to review the provided workflow definition and its implemented code, and improve it to meet the highest quality standards.
|
|
58968
|
+
|
|
58969
|
+
You will receive a JSON workflow definition where the "code" fields are already populated.
|
|
58970
|
+
You must review each step's code and improve it if necessary.
|
|
58971
|
+
|
|
58972
|
+
Check for:
|
|
58973
|
+
- Correct usage of \`ctx.agentTools\` (for standard tools) and \`ctx.tools\` (for workflow helpers).
|
|
58974
|
+
- Proper error handling (try-catch, input validation).
|
|
58975
|
+
- Meaningful logging.
|
|
58976
|
+
- Adherence to the Quality Guidelines.
|
|
58977
|
+
- Correct syntax (no outer function wrappers).
|
|
58978
|
+
|
|
58979
|
+
${QUALITY_GUIDELINES}
|
|
58980
|
+
|
|
58981
|
+
## Final Instructions
|
|
58982
|
+
|
|
58983
|
+
Return the complete workflow JSON with the "code" fields improved where necessary.
|
|
58984
|
+
Ensure the "code" field still contains ONLY the function body statements.
|
|
58985
|
+
`;
|
|
58844
58986
|
// ../../node_modules/lodash-es/_freeGlobal.js
|
|
58845
58987
|
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
58846
58988
|
var _freeGlobal_default = freeGlobal;
|
|
@@ -62109,15 +62251,15 @@ function useKeypress(userHandler) {
|
|
|
62109
62251
|
signal.current = userHandler;
|
|
62110
62252
|
useEffect((rl) => {
|
|
62111
62253
|
let ignore = false;
|
|
62112
|
-
const
|
|
62254
|
+
const handler13 = withUpdates((_input, event) => {
|
|
62113
62255
|
if (ignore)
|
|
62114
62256
|
return;
|
|
62115
62257
|
signal.current(event, rl);
|
|
62116
62258
|
});
|
|
62117
|
-
rl.input.on("keypress",
|
|
62259
|
+
rl.input.on("keypress", handler13);
|
|
62118
62260
|
return () => {
|
|
62119
62261
|
ignore = true;
|
|
62120
|
-
rl.input.removeListener("keypress",
|
|
62262
|
+
rl.input.removeListener("keypress", handler13);
|
|
62121
62263
|
};
|
|
62122
62264
|
}, []);
|
|
62123
62265
|
}
|
|
@@ -62708,16 +62850,16 @@ class Emitter {
|
|
|
62708
62850
|
|
|
62709
62851
|
class SignalExitBase {
|
|
62710
62852
|
}
|
|
62711
|
-
var signalExitWrap = (
|
|
62853
|
+
var signalExitWrap = (handler13) => {
|
|
62712
62854
|
return {
|
|
62713
62855
|
onExit(cb, opts) {
|
|
62714
|
-
return
|
|
62856
|
+
return handler13.onExit(cb, opts);
|
|
62715
62857
|
},
|
|
62716
62858
|
load() {
|
|
62717
|
-
return
|
|
62859
|
+
return handler13.load();
|
|
62718
62860
|
},
|
|
62719
62861
|
unload() {
|
|
62720
|
-
return
|
|
62862
|
+
return handler13.unload();
|
|
62721
62863
|
}
|
|
62722
62864
|
};
|
|
62723
62865
|
};
|
|
@@ -64567,11 +64709,6 @@ Tool error:`, event.tool));
|
|
|
64567
64709
|
}
|
|
64568
64710
|
break;
|
|
64569
64711
|
}
|
|
64570
|
-
case "Exit" /* Exit */:
|
|
64571
|
-
if (verbose > 0) {
|
|
64572
|
-
customConsole.log("Exit Message:", event.exitReason.message);
|
|
64573
|
-
}
|
|
64574
|
-
break;
|
|
64575
64712
|
}
|
|
64576
64713
|
for (const [tool3, taskStats] of taskToolCallStats.entries()) {
|
|
64577
64714
|
const globalStats = globalToolCallStats.get(tool3) ?? { calls: 0, success: 0, errors: 0 };
|