@polka-codes/core 0.9.86 → 0.9.89

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 CHANGED
@@ -126,114 +126,184 @@ function computeRateLimitBackoffSeconds(count, baseSeconds = 2, capSeconds = 60)
126
126
  }
127
127
 
128
128
  // src/config.ts
129
+ import { z as z2 } from "zod";
130
+
131
+ // src/config/memory.ts
129
132
  import { z } from "zod";
130
- var ruleSchema = z.union([
131
- z.string(),
132
- z.object({ path: z.string() }).strict(),
133
- z.object({ url: z.string() }).strict(),
134
- z.object({
135
- repo: z.string(),
136
- path: z.string(),
137
- tag: z.string().optional(),
138
- commit: z.string().optional(),
139
- branch: z.string().optional()
133
+ var memoryConfigSchema = z.object({
134
+ enabled: z.boolean().optional().default(true),
135
+ type: z.enum(["sqlite", "memory"]).optional().default("sqlite"),
136
+ path: z.string().optional().default("~/.config/polka-codes/memory.sqlite")
137
+ }).strict().optional();
138
+ var DEFAULT_MEMORY_CONFIG = {
139
+ enabled: true,
140
+ type: "sqlite",
141
+ path: "~/.config/polka-codes/memory.sqlite"
142
+ };
143
+ function resolveHomePath(path) {
144
+ if (path.startsWith("~")) {
145
+ return `${process.env.HOME}${path.slice(1)}`;
146
+ }
147
+ return path;
148
+ }
149
+
150
+ // src/config.ts
151
+ var ruleSchema = z2.union([
152
+ z2.string(),
153
+ z2.object({ path: z2.string() }).strict(),
154
+ z2.object({ url: z2.string() }).strict(),
155
+ z2.object({
156
+ repo: z2.string(),
157
+ path: z2.string(),
158
+ tag: z2.string().optional(),
159
+ commit: z2.string().optional(),
160
+ branch: z2.string().optional()
140
161
  }).strict()
141
162
  ]);
142
- var providerConfigSchema = z.object({
143
- apiKey: z.string().optional(),
144
- defaultModel: z.string().optional(),
145
- defaultParameters: z.record(z.string(), z.any()).optional(),
146
- location: z.string().optional(),
147
- project: z.string().optional(),
148
- keyFile: z.string().optional(),
149
- baseUrl: z.string().optional()
163
+ var providerConfigSchema = z2.object({
164
+ apiKey: z2.string().optional(),
165
+ defaultModel: z2.string().optional(),
166
+ defaultParameters: z2.record(z2.string(), z2.any()).optional(),
167
+ location: z2.string().optional(),
168
+ project: z2.string().optional(),
169
+ keyFile: z2.string().optional(),
170
+ baseUrl: z2.string().optional(),
171
+ name: z2.string().optional()
172
+ // For OpenAI-compatible providers
150
173
  });
151
- var providerModelSchema = z.object({
152
- provider: z.string().optional(),
153
- model: z.string().optional(),
154
- parameters: z.record(z.string(), z.any()).optional(),
155
- budget: z.number().positive().optional(),
156
- rules: z.array(ruleSchema).optional().or(z.string()).optional()
174
+ var providerModelSchema = z2.object({
175
+ provider: z2.string().optional(),
176
+ model: z2.string().optional(),
177
+ parameters: z2.record(z2.string(), z2.any()).optional(),
178
+ budget: z2.number().positive().optional(),
179
+ rules: z2.array(ruleSchema).optional().or(z2.string()).optional()
157
180
  });
158
- var scriptSchema = z.union([
181
+ var scriptSchema = z2.union([
159
182
  // Type 1: Simple shell command (backward compatible)
160
- z.string(),
183
+ z2.string(),
161
184
  // Type 2: Object with command and description (backward compatible)
162
- z.object({
163
- command: z.string(),
164
- description: z.string()
185
+ z2.object({
186
+ command: z2.string(),
187
+ description: z2.string()
165
188
  }).strict(),
166
189
  // Type 3: Reference to dynamic workflow YAML
167
- z.object({
168
- workflow: z.string(),
190
+ z2.object({
191
+ workflow: z2.string(),
169
192
  // Path to .yml workflow file
170
- description: z.string().optional(),
171
- input: z.record(z.string(), z.any()).optional()
193
+ description: z2.string().optional(),
194
+ input: z2.record(z2.string(), z2.any()).optional()
172
195
  // Default workflow input
173
196
  }).strict(),
174
197
  // Type 4: TypeScript script file (NEW)
175
- z.object({
176
- script: z.string(),
198
+ z2.object({
199
+ script: z2.string(),
177
200
  // Path to .ts file
178
- description: z.string().optional(),
179
- permissions: z.object({
180
- fs: z.enum(["read", "write", "none"]).optional(),
181
- network: z.boolean().optional(),
182
- subprocess: z.boolean().optional()
201
+ description: z2.string().optional(),
202
+ permissions: z2.object({
203
+ fs: z2.enum(["read", "write", "none"]).optional(),
204
+ network: z2.boolean().optional(),
205
+ subprocess: z2.boolean().optional()
183
206
  }).optional(),
184
- timeout: z.number().int().positive().max(36e5).optional(),
207
+ timeout: z2.number().int().positive().max(36e5).optional(),
185
208
  // Max 1 hour in milliseconds
186
- memory: z.number().int().positive().min(64).max(8192).optional()
209
+ memory: z2.number().int().positive().min(64).max(8192).optional()
187
210
  // 64MB-8GB in MB
188
211
  }).strict()
189
212
  ]);
190
- var mcpServerConfigSchema = z.object({
191
- command: z.string(),
192
- args: z.array(z.string()).optional(),
193
- env: z.record(z.string(), z.string()).optional(),
194
- tools: z.record(
195
- z.string(),
196
- z.boolean().or(
197
- z.object({
198
- provider: z.string().optional(),
199
- model: z.string().optional(),
200
- parameters: z.record(z.string(), z.unknown()).optional()
213
+ var mcpServerConfigSchema = z2.object({
214
+ command: z2.string(),
215
+ args: z2.array(z2.string()).optional(),
216
+ env: z2.record(z2.string(), z2.string()).optional(),
217
+ tools: z2.record(
218
+ z2.string(),
219
+ z2.boolean().or(
220
+ z2.object({
221
+ provider: z2.string().optional(),
222
+ model: z2.string().optional(),
223
+ parameters: z2.record(z2.string(), z2.unknown()).optional()
201
224
  }).strict()
202
225
  )
203
226
  ).optional()
204
227
  }).strict();
205
- var configSchema = z.object({
206
- prices: z.record(
207
- z.string(),
228
+ var agentContinuousImprovementSchema = z2.object({
229
+ sleepTimeOnNoTasks: z2.number().int().optional(),
230
+ sleepTimeBetweenTasks: z2.number().int().optional(),
231
+ maxCycles: z2.number().int().optional()
232
+ }).strict().optional();
233
+ var agentDiscoverySchema = z2.object({
234
+ enabledStrategies: z2.array(z2.string()).optional(),
235
+ cacheTime: z2.number().int().optional(),
236
+ checkChanges: z2.boolean().optional()
237
+ }).strict().optional();
238
+ var agentSafetySchema = z2.object({
239
+ enabledChecks: z2.array(z2.string()).optional(),
240
+ blockDestructive: z2.boolean().optional(),
241
+ maxFileSize: z2.number().int().optional()
242
+ }).strict().optional();
243
+ var agentHealthCheckSchema = z2.object({
244
+ enabled: z2.boolean().optional(),
245
+ interval: z2.number().int().optional()
246
+ }).strict().optional();
247
+ var agentApprovalSchema = z2.object({
248
+ level: z2.enum(["none", "destructive", "commits", "all"]).optional(),
249
+ autoApproveSafeTasks: z2.boolean().optional(),
250
+ maxAutoApprovalCost: z2.number().optional()
251
+ }).strict().optional();
252
+ var agentSchema = z2.object({
253
+ preset: z2.string().optional(),
254
+ strategy: z2.enum(["goal-directed", "continuous-improvement"]).optional(),
255
+ continueOnCompletion: z2.boolean().optional(),
256
+ maxIterations: z2.number().int().optional(),
257
+ timeout: z2.number().int().optional(),
258
+ requireApprovalFor: z2.enum(["none", "destructive", "commits", "all"]).optional(),
259
+ autoApproveSafeTasks: z2.boolean().optional(),
260
+ maxAutoApprovalCost: z2.number().optional(),
261
+ pauseOnError: z2.boolean().optional(),
262
+ workingBranch: z2.string().optional(),
263
+ destructiveOperations: z2.array(z2.string()).optional(),
264
+ maxConcurrency: z2.number().int().optional(),
265
+ autoSaveInterval: z2.number().int().optional(),
266
+ workingDir: z2.string().optional(),
267
+ continuousImprovement: agentContinuousImprovementSchema,
268
+ discovery: agentDiscoverySchema,
269
+ safety: agentSafetySchema,
270
+ healthCheck: agentHealthCheckSchema,
271
+ approval: agentApprovalSchema
272
+ }).strict().optional();
273
+ var configSchema = z2.object({
274
+ prices: z2.record(
275
+ z2.string(),
208
276
  // provider
209
- z.record(
210
- z.string(),
277
+ z2.record(
278
+ z2.string(),
211
279
  // model
212
- z.object({
213
- inputPrice: z.number().optional(),
214
- outputPrice: z.number().optional(),
215
- cacheWritesPrice: z.number().optional(),
216
- cacheReadsPrice: z.number().optional()
280
+ z2.object({
281
+ inputPrice: z2.number().optional(),
282
+ outputPrice: z2.number().optional(),
283
+ cacheWritesPrice: z2.number().optional(),
284
+ cacheReadsPrice: z2.number().optional()
217
285
  })
218
286
  )
219
287
  ).optional(),
220
- providers: z.record(z.string(), providerConfigSchema).optional(),
221
- defaultProvider: z.string().optional(),
222
- defaultModel: z.string().optional(),
223
- defaultParameters: z.record(z.string(), z.any()).optional(),
224
- maxMessageCount: z.number().int().positive().optional(),
225
- budget: z.number().positive().optional(),
226
- retryCount: z.number().int().min(0).optional(),
227
- requestTimeoutSeconds: z.number().int().positive().optional(),
228
- summaryThreshold: z.number().int().positive().optional(),
229
- scripts: z.record(z.string(), scriptSchema).optional(),
230
- commands: z.record(z.string(), providerModelSchema).optional(),
231
- tools: z.object({
232
- search: providerModelSchema.or(z.boolean()).optional()
288
+ providers: z2.record(z2.string(), providerConfigSchema).optional(),
289
+ defaultProvider: z2.string().optional(),
290
+ defaultModel: z2.string().optional(),
291
+ defaultParameters: z2.record(z2.string(), z2.any()).optional(),
292
+ maxMessageCount: z2.number().int().positive().optional(),
293
+ budget: z2.number().positive().optional(),
294
+ retryCount: z2.number().int().min(0).optional(),
295
+ requestTimeoutSeconds: z2.number().int().positive().optional(),
296
+ summaryThreshold: z2.number().int().positive().optional(),
297
+ scripts: z2.record(z2.string(), scriptSchema).optional(),
298
+ commands: z2.record(z2.string(), providerModelSchema).optional(),
299
+ tools: z2.object({
300
+ search: providerModelSchema.or(z2.boolean()).optional()
233
301
  }).optional(),
234
- mcpServers: z.record(z.string(), mcpServerConfigSchema).optional(),
235
- rules: z.array(ruleSchema).optional().or(z.string()).optional(),
236
- excludeFiles: z.array(z.string()).optional()
302
+ mcpServers: z2.record(z2.string(), mcpServerConfigSchema).optional(),
303
+ rules: z2.array(ruleSchema).optional().or(z2.string()).optional(),
304
+ excludeFiles: z2.array(z2.string()).optional(),
305
+ agent: agentSchema,
306
+ memory: memoryConfigSchema
237
307
  }).strict().nullish();
238
308
 
239
309
  // src/fs/node-provider.ts
@@ -336,11 +406,11 @@ import { parse } from "yaml";
336
406
  import { ZodError } from "zod";
337
407
 
338
408
  // src/skills/types.ts
339
- import { z as z2 } from "zod";
340
- var skillMetadataSchema = z2.object({
341
- name: z2.string().regex(/^[a-z0-9-]+$/, "Skill name must be lowercase letters, numbers, and hyphens").max(64, "Skill name must be at most 64 characters"),
342
- description: z2.string().max(1024, "Description must be at most 1024 characters"),
343
- allowedTools: z2.array(z2.string()).optional()
409
+ import { z as z3 } from "zod";
410
+ var skillMetadataSchema = z3.object({
411
+ name: z3.string().regex(/^[a-z0-9-]+$/, "Skill name must be lowercase letters, numbers, and hyphens").max(64, "Skill name must be at most 64 characters"),
412
+ description: z3.string().max(1024, "Description must be at most 1024 characters"),
413
+ allowedTools: z3.array(z3.string()).optional()
344
414
  });
345
415
  var SkillDiscoveryError = class extends Error {
346
416
  constructor(message, path) {
@@ -754,19 +824,19 @@ function getSkillStats(skill) {
754
824
  }
755
825
 
756
826
  // src/skills/tools/listSkills.ts
757
- import { z as z3 } from "zod";
758
- var ListSkillsInputSchema = z3.object({
759
- filter: z3.string().optional().describe("Optional filter string to match against skill names and descriptions")
827
+ import { z as z4 } from "zod";
828
+ var ListSkillsInputSchema = z4.object({
829
+ filter: z4.string().optional().describe("Optional filter string to match against skill names and descriptions")
760
830
  });
761
- var ListSkillsOutputSchema = z3.object({
762
- skills: z3.array(
763
- z3.object({
764
- name: z3.string(),
765
- description: z3.string(),
766
- source: z3.enum(["personal", "project", "plugin"])
831
+ var ListSkillsOutputSchema = z4.object({
832
+ skills: z4.array(
833
+ z4.object({
834
+ name: z4.string(),
835
+ description: z4.string(),
836
+ source: z4.enum(["personal", "project", "plugin"])
767
837
  })
768
838
  ),
769
- total: z3.number()
839
+ total: z4.number()
770
840
  });
771
841
  async function listSkills(input, context) {
772
842
  const { filter } = input;
@@ -792,20 +862,20 @@ var listSkillsToolInfo = {
792
862
  };
793
863
 
794
864
  // src/skills/tools/loadSkill.ts
795
- import { z as z4 } from "zod";
796
- var LoadSkillInputSchema = z4.object({
797
- skillName: z4.string().describe("The name of the skill to load")
865
+ import { z as z5 } from "zod";
866
+ var LoadSkillInputSchema = z5.object({
867
+ skillName: z5.string().describe("The name of the skill to load")
798
868
  });
799
- var LoadSkillOutputSchema = z4.object({
800
- success: z4.boolean(),
801
- skill: z4.object({
802
- name: z4.string(),
803
- description: z4.string(),
804
- content: z4.string(),
805
- availableFiles: z4.array(z4.string())
869
+ var LoadSkillOutputSchema = z5.object({
870
+ success: z5.boolean(),
871
+ skill: z5.object({
872
+ name: z5.string(),
873
+ description: z5.string(),
874
+ content: z5.string(),
875
+ availableFiles: z5.array(z5.string())
806
876
  }).optional(),
807
- error: z4.string().optional(),
808
- warnings: z4.array(z4.string()).optional()
877
+ error: z5.string().optional(),
878
+ warnings: z5.array(z5.string()).optional()
809
879
  });
810
880
  async function loadSkill(input, context) {
811
881
  const { skillName } = input;
@@ -854,15 +924,15 @@ var loadSkillToolInfo = {
854
924
  };
855
925
 
856
926
  // src/skills/tools/readSkillFile.ts
857
- import { z as z5 } from "zod";
858
- var ReadSkillFileInputSchema = z5.object({
859
- skillName: z5.string().describe("The name of the skill"),
860
- filename: z5.string().describe('The name of the file to read (e.g., "reference.md", "scripts/helper.py")')
927
+ import { z as z6 } from "zod";
928
+ var ReadSkillFileInputSchema = z6.object({
929
+ skillName: z6.string().describe("The name of the skill"),
930
+ filename: z6.string().describe('The name of the file to read (e.g., "reference.md", "scripts/helper.py")')
861
931
  });
862
- var ReadSkillFileOutputSchema = z5.object({
863
- success: z5.boolean(),
864
- content: z5.string().optional(),
865
- error: z5.string().optional()
932
+ var ReadSkillFileOutputSchema = z6.object({
933
+ success: z6.boolean(),
934
+ content: z6.string().optional(),
935
+ error: z6.string().optional()
866
936
  });
867
937
  async function readSkillFile(input, context) {
868
938
  const { skillName, filename } = input;
@@ -900,16 +970,16 @@ var readSkillFileToolInfo = {
900
970
  };
901
971
 
902
972
  // src/tools/askFollowupQuestion.ts
903
- import { z as z6 } from "zod";
904
- var questionObject = z6.object({
905
- prompt: z6.string().describe("The text of the question.").meta({ usageValue: "question text here" }),
906
- options: z6.array(z6.string()).default([]).describe("Ordered list of suggested answers (omit if none).").meta({ usageValue: "suggested answer here" })
973
+ import { z as z7 } from "zod";
974
+ var questionObject = z7.object({
975
+ prompt: z7.string().describe("The text of the question.").meta({ usageValue: "question text here" }),
976
+ options: z7.array(z7.string()).default([]).describe("Ordered list of suggested answers (omit if none).").meta({ usageValue: "suggested answer here" })
907
977
  });
908
978
  var toolInfo = {
909
979
  name: "askFollowupQuestion",
910
980
  description: "Call this when vital details are missing. Pose each follow-up as one direct, unambiguous question. If it speeds the reply, add up to five short, mutually-exclusive answer options. Group any related questions in the same call to avoid a back-and-forth chain.",
911
- parameters: z6.object({
912
- questions: z6.array(questionObject).describe("One or more follow-up questions you need answered before you can continue.").meta({ usageValue: "questions here" })
981
+ parameters: z7.object({
982
+ questions: z7.array(questionObject).describe("One or more follow-up questions you need answered before you can continue.").meta({ usageValue: "questions here" })
913
983
  }).meta({
914
984
  examples: [
915
985
  {
@@ -997,18 +1067,41 @@ var askFollowupQuestion_default = {
997
1067
  };
998
1068
 
999
1069
  // src/tools/executeCommand.ts
1000
- import { z as z7 } from "zod";
1070
+ import { z as z8 } from "zod";
1001
1071
 
1002
- // src/tools/utils.ts
1003
- function createProviderError(action) {
1072
+ // src/tools/response-builders.ts
1073
+ function createSuccessResponse(value, type = "text") {
1074
+ return {
1075
+ success: true,
1076
+ message: { type, value }
1077
+ };
1078
+ }
1079
+ function createErrorResponse(message) {
1080
+ return {
1081
+ success: false,
1082
+ message: { type: "error-text", value: message }
1083
+ };
1084
+ }
1085
+ function createProviderErrorResponse(capability) {
1004
1086
  return {
1005
1087
  success: false,
1006
1088
  message: {
1007
1089
  type: "error-text",
1008
- value: `Not possible to ${action}.`
1090
+ value: `Not possible to ${capability}.`
1009
1091
  }
1010
1092
  };
1011
1093
  }
1094
+ function createValidationErrorResponse(errors) {
1095
+ return {
1096
+ success: false,
1097
+ message: {
1098
+ type: "error-text",
1099
+ value: `Validation failed: ${errors.message}`
1100
+ }
1101
+ };
1102
+ }
1103
+
1104
+ // src/tools/utils.ts
1012
1105
  function preprocessBoolean(val) {
1013
1106
  return typeof val === "string" ? val.toLowerCase() === "true" : val;
1014
1107
  }
@@ -1029,9 +1122,9 @@ function createFileElement(tagName, path, content, attrs) {
1029
1122
  var toolInfo2 = {
1030
1123
  name: "executeCommand",
1031
1124
  description: "Run a single CLI command. The command is always executed in the project-root working directory (regardless of earlier commands). Prefer one-off shell commands over wrapper scripts for flexibility. **IMPORTANT**: After an `execute_command` call, you MUST stop and NOT allowed to make further tool calls in the same message.",
1032
- parameters: z7.object({
1033
- command: z7.string().describe("The exact command to run (valid for the current OS). It must be correctly formatted and free of harmful instructions.").meta({ usageValue: "your-command-here" }),
1034
- requiresApproval: z7.preprocess(preprocessBoolean, z7.boolean().optional().default(false)).describe(
1125
+ parameters: z8.object({
1126
+ command: z8.string().describe("The exact command to run (valid for the current OS). It must be correctly formatted and free of harmful instructions.").meta({ usageValue: "your-command-here" }),
1127
+ requiresApproval: z8.preprocess(preprocessBoolean, z8.boolean().optional().default(false)).describe(
1035
1128
  "Set to `true` for commands that install/uninstall software, modify or delete files, change system settings, perform network operations, or have other side effects. Use `false` for safe, read-only, or purely local development actions (e.g., listing files, make a build, running tests)."
1036
1129
  ).meta({ usageValue: "true | false" })
1037
1130
  }).meta({
@@ -1048,7 +1141,7 @@ var toolInfo2 = {
1048
1141
  };
1049
1142
  var handler2 = async (provider, args) => {
1050
1143
  if (!provider.executeCommand) {
1051
- return createProviderError("execute command. Abort");
1144
+ return createProviderErrorResponse("execute command. Abort");
1052
1145
  }
1053
1146
  const { command, requiresApproval } = toolInfo2.parameters.parse(args);
1054
1147
  try {
@@ -1102,16 +1195,16 @@ var executeCommand_default = {
1102
1195
  };
1103
1196
 
1104
1197
  // src/tools/fetchUrl.ts
1105
- import { z as z8 } from "zod";
1198
+ import { z as z9 } from "zod";
1106
1199
  var toolInfo3 = {
1107
1200
  name: "fetchUrl",
1108
1201
  description: "Fetch the content located at one or more HTTP(S) URLs and return it in Markdown format. This works for standard web pages as well as raw files (e.g. README.md, source code) hosted on platforms like GitHub.",
1109
- parameters: z8.object({
1110
- url: z8.preprocess((val) => {
1202
+ parameters: z9.object({
1203
+ url: z9.preprocess((val) => {
1111
1204
  if (!val) return [];
1112
1205
  const values = Array.isArray(val) ? val : [val];
1113
1206
  return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
1114
- }, z8.array(z8.string())).describe("One or more URLs to fetch, separated by commas if multiple.").meta({ usageValue: "url" })
1207
+ }, z9.array(z9.string())).describe("One or more URLs to fetch, separated by commas if multiple.").meta({ usageValue: "url" })
1115
1208
  }).meta({
1116
1209
  examples: [
1117
1210
  {
@@ -1180,15 +1273,15 @@ var fetchUrl_default = {
1180
1273
  };
1181
1274
 
1182
1275
  // src/tools/listFiles.ts
1183
- import { z as z9 } from "zod";
1276
+ import { z as z10 } from "zod";
1184
1277
  var toolInfo4 = {
1185
1278
  name: "listFiles",
1186
1279
  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.",
1187
- parameters: z9.object({
1188
- path: z9.string().describe("The path of the directory to list contents for (relative to the current working directory)").meta({ usageValue: "Directory path here" }),
1189
- maxCount: z9.coerce.number().optional().default(2e3).describe("The maximum number of files to list. Default to 2000").meta({ usageValue: "Maximum number of files to list (optional)" }),
1190
- recursive: z9.preprocess(preprocessBoolean, z9.boolean().optional().default(true)).describe("Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.").meta({ usageValue: "true or false (optional)" }),
1191
- includeIgnored: z9.preprocess(preprocessBoolean, z9.boolean().optional().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
1280
+ parameters: z10.object({
1281
+ path: z10.string().describe("The path of the directory to list contents for (relative to the current working directory)").meta({ usageValue: "Directory path here" }),
1282
+ maxCount: z10.coerce.number().optional().default(2e3).describe("The maximum number of files to list. Default to 2000").meta({ usageValue: "Maximum number of files to list (optional)" }),
1283
+ recursive: z10.preprocess(preprocessBoolean, z10.boolean().optional().default(true)).describe("Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.").meta({ usageValue: "true or false (optional)" }),
1284
+ includeIgnored: z10.preprocess(preprocessBoolean, z10.boolean().optional().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
1192
1285
  }).meta({
1193
1286
  examples: [
1194
1287
  {
@@ -1203,7 +1296,7 @@ var toolInfo4 = {
1203
1296
  };
1204
1297
  var handler4 = async (provider, args) => {
1205
1298
  if (!provider.listFiles) {
1206
- return createProviderError("list files");
1299
+ return createProviderErrorResponse("list files");
1207
1300
  }
1208
1301
  const { path, maxCount, recursive, includeIgnored } = toolInfo4.parameters.parse(args);
1209
1302
  const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
@@ -1286,12 +1379,12 @@ var MockProvider = class {
1286
1379
  };
1287
1380
 
1288
1381
  // src/tools/readBinaryFile.ts
1289
- import { z as z10 } from "zod";
1382
+ import { z as z11 } from "zod";
1290
1383
  var toolInfo5 = {
1291
1384
  name: "readBinaryFile",
1292
1385
  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.",
1293
- parameters: z10.object({
1294
- url: z10.string().describe("The URL or local path of the file to read.")
1386
+ parameters: z11.object({
1387
+ url: z11.string().describe("The URL or local path of the file to read.")
1295
1388
  })
1296
1389
  };
1297
1390
  var handler5 = async (provider, args) => {
@@ -1338,17 +1431,43 @@ var readBinaryFile_default = {
1338
1431
  };
1339
1432
 
1340
1433
  // src/tools/readFile.ts
1341
- import { z as z11 } from "zod";
1434
+ import { z as z12 } from "zod";
1342
1435
  var toolInfo6 = {
1343
1436
  name: "readFile",
1344
- 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.",
1345
- parameters: z11.object({
1346
- path: z11.preprocess((val) => {
1437
+ description: `Request to read the contents of one or multiple files at the specified paths.
1438
+
1439
+ When to use:
1440
+ - Examining file contents you don't know
1441
+ - Analyzing code, reviewing text files, extracting configuration info
1442
+ - Reading multiple files at once (use comma-separated paths)
1443
+ - Understanding file structure before editing
1444
+
1445
+ When NOT to use:
1446
+ - For file existence checks: Use listFiles instead
1447
+ - For searching within files: Use grep instead
1448
+ - For file name searches: Use searchFiles instead
1449
+ - Prefer this tool over executeCommand with cat/head/tail
1450
+
1451
+ Features:
1452
+ - Supports comma-separated paths for multiple files
1453
+ - Line numbers included for easy reference
1454
+ - Optional offset/limit for partial file reading
1455
+ - Automatically handles different file types
1456
+
1457
+ IMPORTANT:
1458
+ - Line numbers are included for easy reference
1459
+ - Use offset/limit for large files to read specific sections`,
1460
+ parameters: z12.object({
1461
+ path: z12.preprocess((val) => {
1347
1462
  if (!val) return [];
1348
- const values = Array.isArray(val) ? val : [val];
1349
- return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
1350
- }, z11.array(z11.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" }),
1351
- includeIgnored: z11.preprocess(preprocessBoolean, z11.boolean().nullish().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
1463
+ if (Array.isArray(val)) {
1464
+ return val.filter((s) => typeof s === "string" && s.length > 0);
1465
+ }
1466
+ return val.split(",").filter((s) => s.length > 0);
1467
+ }, z12.array(z12.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" }),
1468
+ offset: z12.number().optional().describe("Skip first N lines (for partial file reading)").meta({ usageValue: "100" }),
1469
+ limit: z12.number().optional().describe("Read at most N lines (for partial file reading)").meta({ usageValue: "50" }),
1470
+ includeIgnored: z12.preprocess(preprocessBoolean, z12.boolean().nullish().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
1352
1471
  }).meta({
1353
1472
  examples: [
1354
1473
  {
@@ -1362,23 +1481,53 @@ var toolInfo6 = {
1362
1481
  input: {
1363
1482
  path: "src/main.js,src/index.js"
1364
1483
  }
1484
+ },
1485
+ {
1486
+ description: "Read partial file (lines 100-150)",
1487
+ input: {
1488
+ path: "src/large-file.ts",
1489
+ offset: 100,
1490
+ limit: 50
1491
+ }
1365
1492
  }
1366
1493
  ]
1367
1494
  })
1368
1495
  };
1369
1496
  var handler6 = async (provider, args) => {
1370
1497
  if (!provider.readFile) {
1371
- return createProviderError("read file");
1498
+ return createProviderErrorResponse("read file");
1499
+ }
1500
+ const parsed = toolInfo6.parameters.safeParse(args);
1501
+ if (!parsed.success) {
1502
+ return {
1503
+ success: false,
1504
+ message: {
1505
+ type: "error-text",
1506
+ value: `Invalid arguments for readFile: ${parsed.error.message}`
1507
+ }
1508
+ };
1372
1509
  }
1373
- const { path: paths, includeIgnored } = toolInfo6.parameters.parse(args);
1510
+ const { path: paths, offset, limit, includeIgnored } = parsed.data;
1374
1511
  const resp = [];
1375
1512
  for (const path of paths) {
1376
1513
  const fileContent = await provider.readFile(path, includeIgnored ?? false);
1377
1514
  if (!fileContent) {
1378
1515
  resp.push(createFileElement("read_file_file_content", path, void 0, { file_not_found: "true" }));
1379
- } else {
1380
- resp.push(createFileElement("read_file_file_content", path, fileContent));
1516
+ continue;
1381
1517
  }
1518
+ let lines = fileContent.split("\n");
1519
+ const start = offset ?? 0;
1520
+ const end = limit ? start + limit : lines.length;
1521
+ if (offset !== void 0 || limit !== void 0) {
1522
+ lines = lines.slice(start, end);
1523
+ }
1524
+ const lineOffset = offset ?? 0;
1525
+ const numberedContent = lines.map((line, i) => {
1526
+ const lineNumber = lineOffset + i + 1;
1527
+ const paddedNumber = String(lineNumber).padStart(6, " ");
1528
+ return `${paddedNumber}\u2192${line}`;
1529
+ }).join("\n");
1530
+ resp.push(createFileElement("read_file_file_content", path, numberedContent));
1382
1531
  }
1383
1532
  return {
1384
1533
  success: true,
@@ -1394,12 +1543,12 @@ var readFile_default = {
1394
1543
  };
1395
1544
 
1396
1545
  // src/tools/removeFile.ts
1397
- import { z as z12 } from "zod";
1546
+ import { z as z13 } from "zod";
1398
1547
  var toolInfo7 = {
1399
1548
  name: "removeFile",
1400
1549
  description: "Request to remove a file at the specified path.",
1401
- parameters: z12.object({
1402
- path: z12.string().describe("The path of the file to remove").meta({ usageValue: "File path here" })
1550
+ parameters: z13.object({
1551
+ path: z13.string().describe("The path of the file to remove").meta({ usageValue: "File path here" })
1403
1552
  }).meta({
1404
1553
  examples: [
1405
1554
  {
@@ -1413,7 +1562,7 @@ var toolInfo7 = {
1413
1562
  };
1414
1563
  var handler7 = async (provider, args) => {
1415
1564
  if (!provider.removeFile) {
1416
- return createProviderError("remove file");
1565
+ return createProviderErrorResponse("remove file");
1417
1566
  }
1418
1567
  const parsed = toolInfo7.parameters.safeParse(args);
1419
1568
  if (!parsed.success) {
@@ -1441,13 +1590,13 @@ var removeFile_default = {
1441
1590
  };
1442
1591
 
1443
1592
  // src/tools/renameFile.ts
1444
- import { z as z13 } from "zod";
1593
+ import { z as z14 } from "zod";
1445
1594
  var toolInfo8 = {
1446
1595
  name: "renameFile",
1447
1596
  description: "Request to rename a file from source path to target path.",
1448
- parameters: z13.object({
1449
- source_path: z13.string().describe("The current path of the file").meta({ usageValue: "Source file path here" }),
1450
- target_path: z13.string().describe("The new path for the file").meta({ usageValue: "Target file path here" })
1597
+ parameters: z14.object({
1598
+ source_path: z14.string().describe("The current path of the file").meta({ usageValue: "Source file path here" }),
1599
+ target_path: z14.string().describe("The new path for the file").meta({ usageValue: "Target file path here" })
1451
1600
  }).meta({
1452
1601
  examples: [
1453
1602
  {
@@ -1486,7 +1635,7 @@ var renameFile_default = {
1486
1635
  };
1487
1636
 
1488
1637
  // src/tools/replaceInFile.ts
1489
- import { z as z14 } from "zod";
1638
+ import { z as z15 } from "zod";
1490
1639
 
1491
1640
  // src/tools/utils/replaceInFile.ts
1492
1641
  var replaceInFile = (fileContent, diff) => {
@@ -1582,10 +1731,46 @@ var replaceInFile = (fileContent, diff) => {
1582
1731
  // src/tools/replaceInFile.ts
1583
1732
  var toolInfo9 = {
1584
1733
  name: "replaceInFile",
1585
- 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.",
1586
- parameters: z14.object({
1587
- path: z14.string().describe("The path of the file to modify").meta({ usageValue: "File path here" }),
1588
- diff: z14.string().describe(
1734
+ description: `Request to replace sections of content in an existing file using
1735
+ SEARCH/REPLACE blocks.
1736
+
1737
+ When to use:
1738
+ - Making targeted changes to specific parts of a file
1739
+ - Replacing variable names, function signatures, imports
1740
+ - Fixing bugs in existing code
1741
+ - When you know the exact content to replace
1742
+
1743
+ When NOT to use:
1744
+ - For creating new files: Use writeToFile instead
1745
+ - For completely replacing file contents: Use writeToFile instead
1746
+ - When you don't know the exact content: Read file first
1747
+
1748
+ SEARCH/REPLACE FORMAT:
1749
+ <<<<<<< SEARCH
1750
+ [exact content to find]
1751
+ =======
1752
+ [new content to replace with]
1753
+ >>>>>>> REPLACE
1754
+
1755
+ Critical rules:
1756
+ 1. SEARCH content must match EXACTLY (character-for-character including whitespace)
1757
+ 2. Each block replaces only first occurrence
1758
+ 3. Include just enough lines for uniqueness (not too many, not too few)
1759
+ 4. Keep blocks concise (don't include long unchanged sections)
1760
+ 5. List blocks in order they appear in file
1761
+ 6. Use multiple blocks for multiple independent changes
1762
+
1763
+ Special operations:
1764
+ - Move code: Two blocks (delete from original + insert at new location)
1765
+ - Delete code: Empty REPLACE section
1766
+
1767
+ IMPORTANT CONSTRAINTS:
1768
+ - SEARCH text must match file content exactly
1769
+ - Each block is independent (doesn't affect other blocks)
1770
+ - Cannot use for appending or inserting without SEARCH context`,
1771
+ parameters: z15.object({
1772
+ path: z15.string().describe("The path of the file to modify").meta({ usageValue: "File path here" }),
1773
+ diff: z15.string().describe(
1589
1774
  `One or more SEARCH/REPLACE blocks following this exact format:
1590
1775
  \`\`\`
1591
1776
  <<<<<<< SEARCH
@@ -1609,7 +1794,7 @@ Critical rules:
1609
1794
  * Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
1610
1795
  4. Special operations:
1611
1796
  * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
1612
- * To delete code: Use empty REPLACE section`
1797
+ * To delete code: Empty REPLACE section`
1613
1798
  ).meta({ usageValue: "Search and replace blocks here" })
1614
1799
  }).meta({
1615
1800
  examples: [
@@ -1771,12 +1956,12 @@ var replaceInFile_default = {
1771
1956
  };
1772
1957
 
1773
1958
  // src/tools/search.ts
1774
- import { z as z15 } from "zod";
1959
+ import { z as z16 } from "zod";
1775
1960
  var toolInfo10 = {
1776
1961
  name: "search",
1777
1962
  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.",
1778
- parameters: z15.object({
1779
- query: z15.string().describe("The query to search for").meta({ usageValue: "Your search query here" })
1963
+ parameters: z16.object({
1964
+ query: z16.string().describe("The query to search for").meta({ usageValue: "Your search query here" })
1780
1965
  }).meta({
1781
1966
  examples: [
1782
1967
  {
@@ -1826,18 +2011,18 @@ var search_default = {
1826
2011
  };
1827
2012
 
1828
2013
  // src/tools/searchFiles.ts
1829
- import { z as z16 } from "zod";
2014
+ import { z as z17 } from "zod";
1830
2015
  var toolInfo11 = {
1831
2016
  name: "searchFiles",
1832
2017
  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.",
1833
- parameters: z16.object({
1834
- path: z16.string().describe(
2018
+ parameters: z17.object({
2019
+ path: z17.string().describe(
1835
2020
  "The path of the directory to search in (relative to the current working directory). This directory will be recursively searched."
1836
2021
  ).meta({ usageValue: "Directory path here" }),
1837
- regex: z16.string().describe("The regular expression pattern to search for. Uses Rust regex syntax.").meta({
2022
+ regex: z17.string().describe("The regular expression pattern to search for. Uses Rust regex syntax.").meta({
1838
2023
  usageValue: "Your regex pattern here"
1839
2024
  }),
1840
- filePattern: z16.string().optional().describe(
2025
+ filePattern: z17.string().optional().describe(
1841
2026
  'Comma-separated glob pattern to filter files (e.g., "*.ts" for TypeScript files or "*.ts,*.js" for both TypeScript and JavaScript files). If not provided, it will search all files (*).'
1842
2027
  ).meta({
1843
2028
  usageValue: "file pattern here (optional)"
@@ -1907,20 +2092,20 @@ var searchFiles_default = {
1907
2092
  };
1908
2093
 
1909
2094
  // src/tools/todo.ts
1910
- import { z as z17 } from "zod";
1911
- var TodoStatus = z17.enum(["open", "completed", "closed"]);
1912
- var TodoItemSchema = z17.object({
1913
- id: z17.string(),
1914
- title: z17.string(),
1915
- description: z17.string(),
2095
+ import { z as z18 } from "zod";
2096
+ var TodoStatus = z18.enum(["open", "completed", "closed"]);
2097
+ var TodoItemSchema = z18.object({
2098
+ id: z18.string(),
2099
+ title: z18.string(),
2100
+ description: z18.string(),
1916
2101
  status: TodoStatus
1917
2102
  });
1918
- var UpdateTodoItemInputSchema = z17.object({
1919
- operation: z17.enum(["add", "update"]),
1920
- id: z17.string().nullish(),
1921
- parentId: z17.string().nullish(),
1922
- title: z17.string().nullish(),
1923
- description: z17.string().nullish(),
2103
+ var UpdateTodoItemInputSchema = z18.object({
2104
+ operation: z18.enum(["add", "update"]),
2105
+ id: z18.string().nullish(),
2106
+ parentId: z18.string().nullish(),
2107
+ title: z18.string().nullish(),
2108
+ description: z18.string().nullish(),
1924
2109
  status: TodoStatus.nullish()
1925
2110
  }).superRefine((data, ctx) => {
1926
2111
  if (data.operation === "add") {
@@ -1941,18 +2126,38 @@ var UpdateTodoItemInputSchema = z17.object({
1941
2126
  }
1942
2127
  }
1943
2128
  });
1944
- var UpdateTodoItemOutputSchema = z17.object({
1945
- id: z17.string()
2129
+ var UpdateTodoItemOutputSchema = z18.object({
2130
+ id: z18.string()
1946
2131
  });
1947
2132
 
1948
2133
  // src/tools/writeToFile.ts
1949
- import { z as z18 } from "zod";
2134
+ import { z as z19 } from "zod";
1950
2135
  var toolInfo12 = {
1951
2136
  name: "writeToFile",
1952
- 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 `&lt;`, `&gt;`, or `&amp;`. Also ensure there is no unwanted CDATA tags in the content.",
1953
- parameters: z18.object({
1954
- path: z18.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
1955
- content: z18.string().describe(
2137
+ description: `Request to write content to a file at the specified path.
2138
+
2139
+ When to use:
2140
+ - Creating new files
2141
+ - Completely replacing file contents
2142
+ - When you have the complete intended content
2143
+
2144
+ When NOT to use:
2145
+ - For modifying existing files: Use replaceInFile instead
2146
+ - For appending content: Use executeCommand with echo >> instead
2147
+ - For targeted edits: Use replaceInFile instead
2148
+
2149
+ Features:
2150
+ - Automatically creates any directories needed
2151
+ - Overwrites existing files completely
2152
+ - Must provide complete file content (no truncation)
2153
+
2154
+ IMPORTANT CONSTRAINT:
2155
+ - Always provide COMPLETE intended content (no omissions)
2156
+ - Ensure no incorrect escape sequences (&lt;, &gt;, &amp;)
2157
+ - Ensure no unwanted CDATA tags in content`,
2158
+ parameters: z19.object({
2159
+ path: z19.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
2160
+ content: z19.string().describe(
1956
2161
  "The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified."
1957
2162
  ).meta({ usageValue: "Your file content here" })
1958
2163
  }).meta({
@@ -1980,7 +2185,7 @@ export default App;
1980
2185
  };
1981
2186
  var handler12 = async (provider, args) => {
1982
2187
  if (!provider.writeFile) {
1983
- return createProviderError("write file");
2188
+ return createProviderErrorResponse("write file");
1984
2189
  }
1985
2190
  const parsed = toolInfo12.parameters.safeParse(args);
1986
2191
  if (!parsed.success) {
@@ -1992,9 +2197,7 @@ var handler12 = async (provider, args) => {
1992
2197
  }
1993
2198
  };
1994
2199
  }
1995
- let { path, content } = parsed.data;
1996
- const trimmedContent = content.trim();
1997
- if (trimmedContent.startsWith("<![CDATA[") && trimmedContent.endsWith("]]>")) content = trimmedContent.slice(9, -3);
2200
+ const { path, content } = parsed.data;
1998
2201
  await provider.writeFile(path, content);
1999
2202
  return {
2000
2203
  success: true,
@@ -2159,7 +2362,7 @@ var UsageMeter = class {
2159
2362
 
2160
2363
  // src/workflow/agent.workflow.ts
2161
2364
  import { jsonSchema } from "ai";
2162
- import { toJSONSchema, z as z19 } from "zod";
2365
+ import { toJSONSchema, z as z20 } from "zod";
2163
2366
 
2164
2367
  // src/workflow/types.ts
2165
2368
  var TaskEventKind = /* @__PURE__ */ ((TaskEventKind2) => {
@@ -2243,7 +2446,7 @@ var agentWorkflow = async (input, { step, tools, logger }) => {
2243
2446
  }
2244
2447
  const validated = input.outputSchema.safeParse(parsed.data);
2245
2448
  if (!validated.success) {
2246
- const errorMessage = `Output validation failed. Error: ${z19.prettifyError(validated.error)}. Please correct the output.`;
2449
+ const errorMessage = `Output validation failed. Error: ${z20.prettifyError(validated.error)}. Please correct the output.`;
2247
2450
  nextMessage = [{ role: "user", content: errorMessage }];
2248
2451
  continue;
2249
2452
  }
@@ -2325,63 +2528,63 @@ var agentWorkflow = async (input, { step, tools, logger }) => {
2325
2528
 
2326
2529
  // src/workflow/dynamic.ts
2327
2530
  import { parse as parse2 } from "yaml";
2328
- import { z as z21 } from "zod";
2531
+ import { z as z22 } from "zod";
2329
2532
 
2330
2533
  // src/workflow/dynamic-types.ts
2331
- import { z as z20 } from "zod";
2332
- var WorkflowInputDefinitionSchema = z20.object({
2333
- id: z20.string(),
2334
- description: z20.string().nullish(),
2335
- default: z20.any().nullish()
2534
+ import { z as z21 } from "zod";
2535
+ var WorkflowInputDefinitionSchema = z21.object({
2536
+ id: z21.string(),
2537
+ description: z21.string().nullish(),
2538
+ default: z21.any().nullish()
2336
2539
  });
2337
- var WorkflowStepDefinitionSchema = z20.object({
2338
- id: z20.string(),
2339
- tools: z20.array(z20.string()).nullish(),
2340
- task: z20.string(),
2341
- output: z20.string().nullish(),
2342
- expected_outcome: z20.string().nullish(),
2540
+ var WorkflowStepDefinitionSchema = z21.object({
2541
+ id: z21.string(),
2542
+ tools: z21.array(z21.string()).nullish(),
2543
+ task: z21.string(),
2544
+ output: z21.string().nullish(),
2545
+ expected_outcome: z21.string().nullish(),
2343
2546
  /**
2344
2547
  * Optional JSON schema or other metadata for future structured outputs.
2345
2548
  * Not interpreted by core today.
2346
2549
  */
2347
- outputSchema: z20.any().nullish(),
2550
+ outputSchema: z21.any().nullish(),
2348
2551
  /**
2349
2552
  * Optional timeout in milliseconds. Step execution will be aborted if it exceeds this duration.
2350
2553
  */
2351
- timeout: z20.number().positive().nullish()
2554
+ timeout: z21.number().positive().nullish()
2352
2555
  });
2353
- var WhileLoopStepSchema = z20.object({
2354
- id: z20.string(),
2355
- while: z20.object({
2356
- condition: z20.string().describe("JavaScript expression that evaluates to true/false"),
2357
- steps: z20.array(z20.lazy(() => WorkflowControlFlowStepSchema))
2556
+ var WhileLoopStepSchema = z21.object({
2557
+ id: z21.string(),
2558
+ while: z21.object({
2559
+ condition: z21.string().describe("JavaScript expression that evaluates to true/false"),
2560
+ steps: z21.array(z21.lazy(() => WorkflowControlFlowStepSchema))
2358
2561
  }),
2359
- output: z20.string().nullish()
2562
+ output: z21.string().nullish()
2360
2563
  });
2361
- var IfElseStepSchema = z20.object({
2362
- id: z20.string(),
2363
- if: z20.object({
2364
- condition: z20.string().describe("JavaScript expression that evaluates to true/false"),
2365
- thenBranch: z20.array(z20.lazy(() => WorkflowControlFlowStepSchema)),
2366
- elseBranch: z20.array(z20.lazy(() => WorkflowControlFlowStepSchema)).optional()
2564
+ var IfElseStepSchema = z21.object({
2565
+ id: z21.string(),
2566
+ if: z21.object({
2567
+ condition: z21.string().describe("JavaScript expression that evaluates to true/false"),
2568
+ thenBranch: z21.array(z21.lazy(() => WorkflowControlFlowStepSchema)),
2569
+ elseBranch: z21.array(z21.lazy(() => WorkflowControlFlowStepSchema)).optional()
2367
2570
  }),
2368
- output: z20.string().nullish()
2571
+ output: z21.string().nullish()
2369
2572
  });
2370
- var BreakStepSchema = z20.object({
2371
- break: z20.literal(true)
2573
+ var BreakStepSchema = z21.object({
2574
+ break: z21.literal(true)
2372
2575
  });
2373
- var ContinueStepSchema = z20.object({
2374
- continue: z20.literal(true)
2576
+ var ContinueStepSchema = z21.object({
2577
+ continue: z21.literal(true)
2375
2578
  });
2376
- var TryCatchStepSchema = z20.object({
2377
- id: z20.string(),
2378
- try: z20.object({
2379
- trySteps: z20.array(z20.lazy(() => WorkflowControlFlowStepSchema)),
2380
- catchSteps: z20.array(z20.lazy(() => WorkflowControlFlowStepSchema))
2579
+ var TryCatchStepSchema = z21.object({
2580
+ id: z21.string(),
2581
+ try: z21.object({
2582
+ trySteps: z21.array(z21.lazy(() => WorkflowControlFlowStepSchema)),
2583
+ catchSteps: z21.array(z21.lazy(() => WorkflowControlFlowStepSchema))
2381
2584
  }),
2382
- output: z20.string().nullish()
2585
+ output: z21.string().nullish()
2383
2586
  });
2384
- var WorkflowControlFlowStepSchema = z20.union([
2587
+ var WorkflowControlFlowStepSchema = z21.union([
2385
2588
  WorkflowStepDefinitionSchema,
2386
2589
  WhileLoopStepSchema,
2387
2590
  IfElseStepSchema,
@@ -2389,14 +2592,14 @@ var WorkflowControlFlowStepSchema = z20.union([
2389
2592
  ContinueStepSchema,
2390
2593
  TryCatchStepSchema
2391
2594
  ]);
2392
- var WorkflowDefinitionSchema = z20.object({
2393
- task: z20.string(),
2394
- inputs: z20.array(WorkflowInputDefinitionSchema).nullish(),
2395
- steps: z20.array(WorkflowControlFlowStepSchema),
2396
- output: z20.string().nullish()
2595
+ var WorkflowDefinitionSchema = z21.object({
2596
+ task: z21.string(),
2597
+ inputs: z21.array(WorkflowInputDefinitionSchema).nullish(),
2598
+ steps: z21.array(WorkflowControlFlowStepSchema),
2599
+ output: z21.string().nullish()
2397
2600
  });
2398
- var WorkflowFileSchema = z20.object({
2399
- workflows: z20.record(z20.string(), WorkflowDefinitionSchema)
2601
+ var WorkflowFileSchema = z21.object({
2602
+ workflows: z21.record(z21.string(), WorkflowDefinitionSchema)
2400
2603
  });
2401
2604
 
2402
2605
  // src/workflow/dynamic.ts
@@ -2405,26 +2608,26 @@ function convertJsonSchemaToZod(schema) {
2405
2608
  if (schema.enum) {
2406
2609
  const enumValues = schema.enum;
2407
2610
  if (enumValues.length === 0) {
2408
- return z21.never();
2611
+ return z22.never();
2409
2612
  }
2410
2613
  if (enumValues.every((v) => typeof v === "string")) {
2411
- return z21.enum(enumValues);
2614
+ return z22.enum(enumValues);
2412
2615
  }
2413
- const literals = enumValues.map((v) => z21.literal(v));
2616
+ const literals = enumValues.map((v) => z22.literal(v));
2414
2617
  if (literals.length === 1) {
2415
2618
  return literals[0];
2416
2619
  }
2417
- return z21.union([literals[0], literals[1], ...literals.slice(2)]);
2620
+ return z22.union([literals[0], literals[1], ...literals.slice(2)]);
2418
2621
  }
2419
2622
  if (Array.isArray(schema.type)) {
2420
2623
  const types = schema.type;
2421
2624
  if (types.includes("null") && types.length === 2) {
2422
2625
  const nonNullType = types.find((t) => t !== "null");
2423
- if (nonNullType === "string") return z21.string().nullable();
2424
- if (nonNullType === "number") return z21.number().nullable();
2626
+ if (nonNullType === "string") return z22.string().nullable();
2627
+ if (nonNullType === "number") return z22.number().nullable();
2425
2628
  if (nonNullType === "integer")
2426
- return z21.number().refine((val) => Number.isInteger(val)).nullable();
2427
- if (nonNullType === "boolean") return z21.boolean().nullable();
2629
+ return z22.number().refine((val) => Number.isInteger(val)).nullable();
2630
+ if (nonNullType === "boolean") return z22.boolean().nullable();
2428
2631
  if (nonNullType === "object") {
2429
2632
  const shape = {};
2430
2633
  if (schema.properties) {
@@ -2434,24 +2637,24 @@ function convertJsonSchemaToZod(schema) {
2434
2637
  shape[propName] = isRequired ? propZod : propZod.optional();
2435
2638
  }
2436
2639
  }
2437
- return z21.object(shape).nullable();
2640
+ return z22.object(shape).nullable();
2438
2641
  }
2439
- if (nonNullType === "array") return z21.array(z21.any()).nullable();
2642
+ if (nonNullType === "array") return z22.array(z22.any()).nullable();
2440
2643
  }
2441
- return z21.any();
2644
+ return z22.any();
2442
2645
  }
2443
2646
  const type = schema.type;
2444
2647
  switch (type) {
2445
2648
  case "string":
2446
- return z21.string();
2649
+ return z22.string();
2447
2650
  case "number":
2448
- return z21.number();
2651
+ return z22.number();
2449
2652
  case "integer":
2450
- return z21.number().refine((val) => Number.isInteger(val), { message: "Expected an integer" });
2653
+ return z22.number().refine((val) => Number.isInteger(val), { message: "Expected an integer" });
2451
2654
  case "boolean":
2452
- return z21.boolean();
2655
+ return z22.boolean();
2453
2656
  case "null":
2454
- return z21.null();
2657
+ return z22.null();
2455
2658
  case "object": {
2456
2659
  const shape = {};
2457
2660
  if (schema.properties) {
@@ -2462,23 +2665,23 @@ function convertJsonSchemaToZod(schema) {
2462
2665
  }
2463
2666
  }
2464
2667
  if (schema.additionalProperties === true) {
2465
- return z21.object(shape).passthrough();
2668
+ return z22.object(shape).passthrough();
2466
2669
  }
2467
2670
  if (typeof schema.additionalProperties === "object") {
2468
2671
  const additionalSchema = convertJsonSchemaToZod(schema.additionalProperties);
2469
- return z21.intersection(z21.object(shape), z21.record(z21.string(), additionalSchema));
2672
+ return z22.intersection(z22.object(shape), z22.record(z22.string(), additionalSchema));
2470
2673
  }
2471
- return z21.object(shape);
2674
+ return z22.object(shape);
2472
2675
  }
2473
2676
  case "array": {
2474
2677
  if (!schema.items) {
2475
- return z21.array(z21.any());
2678
+ return z22.array(z22.any());
2476
2679
  }
2477
2680
  const itemSchema = convertJsonSchemaToZod(schema.items);
2478
- return z21.array(itemSchema);
2681
+ return z22.array(itemSchema);
2479
2682
  }
2480
2683
  default:
2481
- return z21.any();
2684
+ return z22.any();
2482
2685
  }
2483
2686
  }
2484
2687
  var TOOL_GROUPS = {
@@ -2549,7 +2752,7 @@ function parseDynamicWorkflowDefinition(source) {
2549
2752
  const raw = parse2(source);
2550
2753
  const validated = WorkflowFileSchema.safeParse(raw);
2551
2754
  if (!validated.success) {
2552
- return { success: false, error: z21.prettifyError(validated.error) };
2755
+ return { success: false, error: z22.prettifyError(validated.error) };
2553
2756
  }
2554
2757
  const validation = validateWorkflowFile(validated.data);
2555
2758
  if (!validation.success) {
@@ -2842,9 +3045,9 @@ async function executeStepWithAgent(stepDef, workflowId, input, state, context,
2842
3045
  toolsForAgent.push({
2843
3046
  name: "runWorkflow",
2844
3047
  description: "Run a named sub-workflow defined in the current workflow file.",
2845
- parameters: z21.object({
2846
- workflowId: z21.string().describe("Sub-workflow id to run"),
2847
- input: z21.any().nullish().describe("Optional input object for the sub-workflow")
3048
+ parameters: z22.object({
3049
+ workflowId: z22.string().describe("Sub-workflow id to run"),
3050
+ input: z22.any().nullish().describe("Optional input object for the sub-workflow")
2848
3051
  }),
2849
3052
  handler: async () => {
2850
3053
  return { success: false, message: { type: "error-text", value: "runWorkflow is virtual." } };
@@ -3446,6 +3649,7 @@ var makeStepFn = () => {
3446
3649
  export {
3447
3650
  BreakStepSchema,
3448
3651
  ContinueStepSchema,
3652
+ DEFAULT_MEMORY_CONFIG,
3449
3653
  IGNORED_DIRECTORIES,
3450
3654
  IfElseStepSchema,
3451
3655
  ListSkillsInputSchema,
@@ -3484,6 +3688,10 @@ export {
3484
3688
  convertJsonSchemaToZod,
3485
3689
  createContext,
3486
3690
  createDynamicWorkflow,
3691
+ createErrorResponse,
3692
+ createProviderErrorResponse,
3693
+ createSuccessResponse,
3694
+ createValidationErrorResponse,
3487
3695
  executeCommand_default as executeCommand,
3488
3696
  fetchUrl_default as fetchUrl,
3489
3697
  fromJsonModelMessage,
@@ -3495,6 +3703,7 @@ export {
3495
3703
  loadSkillToolInfo,
3496
3704
  makeStepFn,
3497
3705
  mcpServerConfigSchema,
3706
+ memoryConfigSchema,
3498
3707
  parseDynamicWorkflowDefinition,
3499
3708
  parseJsonFromMarkdown,
3500
3709
  providerConfigSchema,
@@ -3507,6 +3716,7 @@ export {
3507
3716
  renameFile_default as renameFile,
3508
3717
  replaceInFile_default as replaceInFile,
3509
3718
  replaceInFile as replaceInFileHelper,
3719
+ resolveHomePath,
3510
3720
  responsePrompts,
3511
3721
  ruleSchema,
3512
3722
  scriptSchema,