@polka-codes/core 0.9.88 → 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,162 +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(),
150
- name: 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()
151
172
  // For OpenAI-compatible providers
152
173
  });
153
- var providerModelSchema = z.object({
154
- provider: z.string().optional(),
155
- model: z.string().optional(),
156
- parameters: z.record(z.string(), z.any()).optional(),
157
- budget: z.number().positive().optional(),
158
- 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()
159
180
  });
160
- var scriptSchema = z.union([
181
+ var scriptSchema = z2.union([
161
182
  // Type 1: Simple shell command (backward compatible)
162
- z.string(),
183
+ z2.string(),
163
184
  // Type 2: Object with command and description (backward compatible)
164
- z.object({
165
- command: z.string(),
166
- description: z.string()
185
+ z2.object({
186
+ command: z2.string(),
187
+ description: z2.string()
167
188
  }).strict(),
168
189
  // Type 3: Reference to dynamic workflow YAML
169
- z.object({
170
- workflow: z.string(),
190
+ z2.object({
191
+ workflow: z2.string(),
171
192
  // Path to .yml workflow file
172
- description: z.string().optional(),
173
- input: z.record(z.string(), z.any()).optional()
193
+ description: z2.string().optional(),
194
+ input: z2.record(z2.string(), z2.any()).optional()
174
195
  // Default workflow input
175
196
  }).strict(),
176
197
  // Type 4: TypeScript script file (NEW)
177
- z.object({
178
- script: z.string(),
198
+ z2.object({
199
+ script: z2.string(),
179
200
  // Path to .ts file
180
- description: z.string().optional(),
181
- permissions: z.object({
182
- fs: z.enum(["read", "write", "none"]).optional(),
183
- network: z.boolean().optional(),
184
- 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()
185
206
  }).optional(),
186
- timeout: z.number().int().positive().max(36e5).optional(),
207
+ timeout: z2.number().int().positive().max(36e5).optional(),
187
208
  // Max 1 hour in milliseconds
188
- memory: z.number().int().positive().min(64).max(8192).optional()
209
+ memory: z2.number().int().positive().min(64).max(8192).optional()
189
210
  // 64MB-8GB in MB
190
211
  }).strict()
191
212
  ]);
192
- var mcpServerConfigSchema = z.object({
193
- command: z.string(),
194
- args: z.array(z.string()).optional(),
195
- env: z.record(z.string(), z.string()).optional(),
196
- tools: z.record(
197
- z.string(),
198
- z.boolean().or(
199
- z.object({
200
- provider: z.string().optional(),
201
- model: z.string().optional(),
202
- 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()
203
224
  }).strict()
204
225
  )
205
226
  ).optional()
206
227
  }).strict();
207
- var agentContinuousImprovementSchema = z.object({
208
- sleepTimeOnNoTasks: z.number().int().optional(),
209
- sleepTimeBetweenTasks: z.number().int().optional(),
210
- maxCycles: z.number().int().optional()
228
+ var agentContinuousImprovementSchema = z2.object({
229
+ sleepTimeOnNoTasks: z2.number().int().optional(),
230
+ sleepTimeBetweenTasks: z2.number().int().optional(),
231
+ maxCycles: z2.number().int().optional()
211
232
  }).strict().optional();
212
- var agentDiscoverySchema = z.object({
213
- enabledStrategies: z.array(z.string()).optional(),
214
- cacheTime: z.number().int().optional(),
215
- checkChanges: z.boolean().optional()
233
+ var agentDiscoverySchema = z2.object({
234
+ enabledStrategies: z2.array(z2.string()).optional(),
235
+ cacheTime: z2.number().int().optional(),
236
+ checkChanges: z2.boolean().optional()
216
237
  }).strict().optional();
217
- var agentSafetySchema = z.object({
218
- enabledChecks: z.array(z.string()).optional(),
219
- blockDestructive: z.boolean().optional(),
220
- maxFileSize: z.number().int().optional()
238
+ var agentSafetySchema = z2.object({
239
+ enabledChecks: z2.array(z2.string()).optional(),
240
+ blockDestructive: z2.boolean().optional(),
241
+ maxFileSize: z2.number().int().optional()
221
242
  }).strict().optional();
222
- var agentHealthCheckSchema = z.object({
223
- enabled: z.boolean().optional(),
224
- interval: z.number().int().optional()
243
+ var agentHealthCheckSchema = z2.object({
244
+ enabled: z2.boolean().optional(),
245
+ interval: z2.number().int().optional()
225
246
  }).strict().optional();
226
- var agentApprovalSchema = z.object({
227
- level: z.enum(["none", "destructive", "commits", "all"]).optional(),
228
- autoApproveSafeTasks: z.boolean().optional(),
229
- maxAutoApprovalCost: z.number().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()
230
251
  }).strict().optional();
231
- var agentSchema = z.object({
232
- preset: z.string().optional(),
233
- strategy: z.enum(["goal-directed", "continuous-improvement"]).optional(),
234
- continueOnCompletion: z.boolean().optional(),
235
- maxIterations: z.number().int().optional(),
236
- timeout: z.number().int().optional(),
237
- requireApprovalFor: z.enum(["none", "destructive", "commits", "all"]).optional(),
238
- autoApproveSafeTasks: z.boolean().optional(),
239
- maxAutoApprovalCost: z.number().optional(),
240
- pauseOnError: z.boolean().optional(),
241
- workingBranch: z.string().optional(),
242
- destructiveOperations: z.array(z.string()).optional(),
243
- maxConcurrency: z.number().int().optional(),
244
- autoSaveInterval: z.number().int().optional(),
245
- workingDir: z.string().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(),
246
267
  continuousImprovement: agentContinuousImprovementSchema,
247
268
  discovery: agentDiscoverySchema,
248
269
  safety: agentSafetySchema,
249
270
  healthCheck: agentHealthCheckSchema,
250
271
  approval: agentApprovalSchema
251
272
  }).strict().optional();
252
- var configSchema = z.object({
253
- prices: z.record(
254
- z.string(),
273
+ var configSchema = z2.object({
274
+ prices: z2.record(
275
+ z2.string(),
255
276
  // provider
256
- z.record(
257
- z.string(),
277
+ z2.record(
278
+ z2.string(),
258
279
  // model
259
- z.object({
260
- inputPrice: z.number().optional(),
261
- outputPrice: z.number().optional(),
262
- cacheWritesPrice: z.number().optional(),
263
- 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()
264
285
  })
265
286
  )
266
287
  ).optional(),
267
- providers: z.record(z.string(), providerConfigSchema).optional(),
268
- defaultProvider: z.string().optional(),
269
- defaultModel: z.string().optional(),
270
- defaultParameters: z.record(z.string(), z.any()).optional(),
271
- maxMessageCount: z.number().int().positive().optional(),
272
- budget: z.number().positive().optional(),
273
- retryCount: z.number().int().min(0).optional(),
274
- requestTimeoutSeconds: z.number().int().positive().optional(),
275
- summaryThreshold: z.number().int().positive().optional(),
276
- scripts: z.record(z.string(), scriptSchema).optional(),
277
- commands: z.record(z.string(), providerModelSchema).optional(),
278
- tools: z.object({
279
- 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()
280
301
  }).optional(),
281
- mcpServers: z.record(z.string(), mcpServerConfigSchema).optional(),
282
- rules: z.array(ruleSchema).optional().or(z.string()).optional(),
283
- excludeFiles: z.array(z.string()).optional(),
284
- agent: agentSchema
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
285
307
  }).strict().nullish();
286
308
 
287
309
  // src/fs/node-provider.ts
@@ -384,11 +406,11 @@ import { parse } from "yaml";
384
406
  import { ZodError } from "zod";
385
407
 
386
408
  // src/skills/types.ts
387
- import { z as z2 } from "zod";
388
- var skillMetadataSchema = z2.object({
389
- 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"),
390
- description: z2.string().max(1024, "Description must be at most 1024 characters"),
391
- 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()
392
414
  });
393
415
  var SkillDiscoveryError = class extends Error {
394
416
  constructor(message, path) {
@@ -802,19 +824,19 @@ function getSkillStats(skill) {
802
824
  }
803
825
 
804
826
  // src/skills/tools/listSkills.ts
805
- import { z as z3 } from "zod";
806
- var ListSkillsInputSchema = z3.object({
807
- 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")
808
830
  });
809
- var ListSkillsOutputSchema = z3.object({
810
- skills: z3.array(
811
- z3.object({
812
- name: z3.string(),
813
- description: z3.string(),
814
- 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"])
815
837
  })
816
838
  ),
817
- total: z3.number()
839
+ total: z4.number()
818
840
  });
819
841
  async function listSkills(input, context) {
820
842
  const { filter } = input;
@@ -840,20 +862,20 @@ var listSkillsToolInfo = {
840
862
  };
841
863
 
842
864
  // src/skills/tools/loadSkill.ts
843
- import { z as z4 } from "zod";
844
- var LoadSkillInputSchema = z4.object({
845
- 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")
846
868
  });
847
- var LoadSkillOutputSchema = z4.object({
848
- success: z4.boolean(),
849
- skill: z4.object({
850
- name: z4.string(),
851
- description: z4.string(),
852
- content: z4.string(),
853
- 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())
854
876
  }).optional(),
855
- error: z4.string().optional(),
856
- warnings: z4.array(z4.string()).optional()
877
+ error: z5.string().optional(),
878
+ warnings: z5.array(z5.string()).optional()
857
879
  });
858
880
  async function loadSkill(input, context) {
859
881
  const { skillName } = input;
@@ -902,15 +924,15 @@ var loadSkillToolInfo = {
902
924
  };
903
925
 
904
926
  // src/skills/tools/readSkillFile.ts
905
- import { z as z5 } from "zod";
906
- var ReadSkillFileInputSchema = z5.object({
907
- skillName: z5.string().describe("The name of the skill"),
908
- 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")')
909
931
  });
910
- var ReadSkillFileOutputSchema = z5.object({
911
- success: z5.boolean(),
912
- content: z5.string().optional(),
913
- error: z5.string().optional()
932
+ var ReadSkillFileOutputSchema = z6.object({
933
+ success: z6.boolean(),
934
+ content: z6.string().optional(),
935
+ error: z6.string().optional()
914
936
  });
915
937
  async function readSkillFile(input, context) {
916
938
  const { skillName, filename } = input;
@@ -948,16 +970,16 @@ var readSkillFileToolInfo = {
948
970
  };
949
971
 
950
972
  // src/tools/askFollowupQuestion.ts
951
- import { z as z6 } from "zod";
952
- var questionObject = z6.object({
953
- prompt: z6.string().describe("The text of the question.").meta({ usageValue: "question text here" }),
954
- 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" })
955
977
  });
956
978
  var toolInfo = {
957
979
  name: "askFollowupQuestion",
958
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.",
959
- parameters: z6.object({
960
- 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" })
961
983
  }).meta({
962
984
  examples: [
963
985
  {
@@ -1045,7 +1067,7 @@ var askFollowupQuestion_default = {
1045
1067
  };
1046
1068
 
1047
1069
  // src/tools/executeCommand.ts
1048
- import { z as z7 } from "zod";
1070
+ import { z as z8 } from "zod";
1049
1071
 
1050
1072
  // src/tools/response-builders.ts
1051
1073
  function createSuccessResponse(value, type = "text") {
@@ -1100,9 +1122,9 @@ function createFileElement(tagName, path, content, attrs) {
1100
1122
  var toolInfo2 = {
1101
1123
  name: "executeCommand",
1102
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.",
1103
- parameters: z7.object({
1104
- 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" }),
1105
- 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(
1106
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)."
1107
1129
  ).meta({ usageValue: "true | false" })
1108
1130
  }).meta({
@@ -1173,16 +1195,16 @@ var executeCommand_default = {
1173
1195
  };
1174
1196
 
1175
1197
  // src/tools/fetchUrl.ts
1176
- import { z as z8 } from "zod";
1198
+ import { z as z9 } from "zod";
1177
1199
  var toolInfo3 = {
1178
1200
  name: "fetchUrl",
1179
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.",
1180
- parameters: z8.object({
1181
- url: z8.preprocess((val) => {
1202
+ parameters: z9.object({
1203
+ url: z9.preprocess((val) => {
1182
1204
  if (!val) return [];
1183
1205
  const values = Array.isArray(val) ? val : [val];
1184
1206
  return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
1185
- }, 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" })
1186
1208
  }).meta({
1187
1209
  examples: [
1188
1210
  {
@@ -1251,15 +1273,15 @@ var fetchUrl_default = {
1251
1273
  };
1252
1274
 
1253
1275
  // src/tools/listFiles.ts
1254
- import { z as z9 } from "zod";
1276
+ import { z as z10 } from "zod";
1255
1277
  var toolInfo4 = {
1256
1278
  name: "listFiles",
1257
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.",
1258
- parameters: z9.object({
1259
- path: z9.string().describe("The path of the directory to list contents for (relative to the current working directory)").meta({ usageValue: "Directory path here" }),
1260
- 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)" }),
1261
- 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)" }),
1262
- 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)" })
1263
1285
  }).meta({
1264
1286
  examples: [
1265
1287
  {
@@ -1357,12 +1379,12 @@ var MockProvider = class {
1357
1379
  };
1358
1380
 
1359
1381
  // src/tools/readBinaryFile.ts
1360
- import { z as z10 } from "zod";
1382
+ import { z as z11 } from "zod";
1361
1383
  var toolInfo5 = {
1362
1384
  name: "readBinaryFile",
1363
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.",
1364
- parameters: z10.object({
1365
- 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.")
1366
1388
  })
1367
1389
  };
1368
1390
  var handler5 = async (provider, args) => {
@@ -1409,17 +1431,43 @@ var readBinaryFile_default = {
1409
1431
  };
1410
1432
 
1411
1433
  // src/tools/readFile.ts
1412
- import { z as z11 } from "zod";
1434
+ import { z as z12 } from "zod";
1413
1435
  var toolInfo6 = {
1414
1436
  name: "readFile",
1415
- 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.",
1416
- parameters: z11.object({
1417
- 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) => {
1418
1462
  if (!val) return [];
1419
- const values = Array.isArray(val) ? val : [val];
1420
- return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
1421
- }, z11.array(z11.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" }),
1422
- 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)" })
1423
1471
  }).meta({
1424
1472
  examples: [
1425
1473
  {
@@ -1433,6 +1481,14 @@ var toolInfo6 = {
1433
1481
  input: {
1434
1482
  path: "src/main.js,src/index.js"
1435
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
+ }
1436
1492
  }
1437
1493
  ]
1438
1494
  })
@@ -1441,15 +1497,37 @@ var handler6 = async (provider, args) => {
1441
1497
  if (!provider.readFile) {
1442
1498
  return createProviderErrorResponse("read file");
1443
1499
  }
1444
- const { path: paths, includeIgnored } = toolInfo6.parameters.parse(args);
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
+ };
1509
+ }
1510
+ const { path: paths, offset, limit, includeIgnored } = parsed.data;
1445
1511
  const resp = [];
1446
1512
  for (const path of paths) {
1447
1513
  const fileContent = await provider.readFile(path, includeIgnored ?? false);
1448
1514
  if (!fileContent) {
1449
1515
  resp.push(createFileElement("read_file_file_content", path, void 0, { file_not_found: "true" }));
1450
- } else {
1451
- resp.push(createFileElement("read_file_file_content", path, fileContent));
1516
+ continue;
1452
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));
1453
1531
  }
1454
1532
  return {
1455
1533
  success: true,
@@ -1465,12 +1543,12 @@ var readFile_default = {
1465
1543
  };
1466
1544
 
1467
1545
  // src/tools/removeFile.ts
1468
- import { z as z12 } from "zod";
1546
+ import { z as z13 } from "zod";
1469
1547
  var toolInfo7 = {
1470
1548
  name: "removeFile",
1471
1549
  description: "Request to remove a file at the specified path.",
1472
- parameters: z12.object({
1473
- 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" })
1474
1552
  }).meta({
1475
1553
  examples: [
1476
1554
  {
@@ -1512,13 +1590,13 @@ var removeFile_default = {
1512
1590
  };
1513
1591
 
1514
1592
  // src/tools/renameFile.ts
1515
- import { z as z13 } from "zod";
1593
+ import { z as z14 } from "zod";
1516
1594
  var toolInfo8 = {
1517
1595
  name: "renameFile",
1518
1596
  description: "Request to rename a file from source path to target path.",
1519
- parameters: z13.object({
1520
- source_path: z13.string().describe("The current path of the file").meta({ usageValue: "Source file path here" }),
1521
- 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" })
1522
1600
  }).meta({
1523
1601
  examples: [
1524
1602
  {
@@ -1557,7 +1635,7 @@ var renameFile_default = {
1557
1635
  };
1558
1636
 
1559
1637
  // src/tools/replaceInFile.ts
1560
- import { z as z14 } from "zod";
1638
+ import { z as z15 } from "zod";
1561
1639
 
1562
1640
  // src/tools/utils/replaceInFile.ts
1563
1641
  var replaceInFile = (fileContent, diff) => {
@@ -1653,10 +1731,46 @@ var replaceInFile = (fileContent, diff) => {
1653
1731
  // src/tools/replaceInFile.ts
1654
1732
  var toolInfo9 = {
1655
1733
  name: "replaceInFile",
1656
- 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.",
1657
- parameters: z14.object({
1658
- path: z14.string().describe("The path of the file to modify").meta({ usageValue: "File path here" }),
1659
- 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(
1660
1774
  `One or more SEARCH/REPLACE blocks following this exact format:
1661
1775
  \`\`\`
1662
1776
  <<<<<<< SEARCH
@@ -1680,7 +1794,7 @@ Critical rules:
1680
1794
  * Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
1681
1795
  4. Special operations:
1682
1796
  * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
1683
- * To delete code: Use empty REPLACE section`
1797
+ * To delete code: Empty REPLACE section`
1684
1798
  ).meta({ usageValue: "Search and replace blocks here" })
1685
1799
  }).meta({
1686
1800
  examples: [
@@ -1842,12 +1956,12 @@ var replaceInFile_default = {
1842
1956
  };
1843
1957
 
1844
1958
  // src/tools/search.ts
1845
- import { z as z15 } from "zod";
1959
+ import { z as z16 } from "zod";
1846
1960
  var toolInfo10 = {
1847
1961
  name: "search",
1848
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.",
1849
- parameters: z15.object({
1850
- 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" })
1851
1965
  }).meta({
1852
1966
  examples: [
1853
1967
  {
@@ -1897,18 +2011,18 @@ var search_default = {
1897
2011
  };
1898
2012
 
1899
2013
  // src/tools/searchFiles.ts
1900
- import { z as z16 } from "zod";
2014
+ import { z as z17 } from "zod";
1901
2015
  var toolInfo11 = {
1902
2016
  name: "searchFiles",
1903
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.",
1904
- parameters: z16.object({
1905
- path: z16.string().describe(
2018
+ parameters: z17.object({
2019
+ path: z17.string().describe(
1906
2020
  "The path of the directory to search in (relative to the current working directory). This directory will be recursively searched."
1907
2021
  ).meta({ usageValue: "Directory path here" }),
1908
- 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({
1909
2023
  usageValue: "Your regex pattern here"
1910
2024
  }),
1911
- filePattern: z16.string().optional().describe(
2025
+ filePattern: z17.string().optional().describe(
1912
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 (*).'
1913
2027
  ).meta({
1914
2028
  usageValue: "file pattern here (optional)"
@@ -1978,20 +2092,20 @@ var searchFiles_default = {
1978
2092
  };
1979
2093
 
1980
2094
  // src/tools/todo.ts
1981
- import { z as z17 } from "zod";
1982
- var TodoStatus = z17.enum(["open", "completed", "closed"]);
1983
- var TodoItemSchema = z17.object({
1984
- id: z17.string(),
1985
- title: z17.string(),
1986
- 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(),
1987
2101
  status: TodoStatus
1988
2102
  });
1989
- var UpdateTodoItemInputSchema = z17.object({
1990
- operation: z17.enum(["add", "update"]),
1991
- id: z17.string().nullish(),
1992
- parentId: z17.string().nullish(),
1993
- title: z17.string().nullish(),
1994
- 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(),
1995
2109
  status: TodoStatus.nullish()
1996
2110
  }).superRefine((data, ctx) => {
1997
2111
  if (data.operation === "add") {
@@ -2012,18 +2126,38 @@ var UpdateTodoItemInputSchema = z17.object({
2012
2126
  }
2013
2127
  }
2014
2128
  });
2015
- var UpdateTodoItemOutputSchema = z17.object({
2016
- id: z17.string()
2129
+ var UpdateTodoItemOutputSchema = z18.object({
2130
+ id: z18.string()
2017
2131
  });
2018
2132
 
2019
2133
  // src/tools/writeToFile.ts
2020
- import { z as z18 } from "zod";
2134
+ import { z as z19 } from "zod";
2021
2135
  var toolInfo12 = {
2022
2136
  name: "writeToFile",
2023
- 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.",
2024
- parameters: z18.object({
2025
- path: z18.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
2026
- 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(
2027
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."
2028
2162
  ).meta({ usageValue: "Your file content here" })
2029
2163
  }).meta({
@@ -2063,9 +2197,7 @@ var handler12 = async (provider, args) => {
2063
2197
  }
2064
2198
  };
2065
2199
  }
2066
- let { path, content } = parsed.data;
2067
- const trimmedContent = content.trim();
2068
- if (trimmedContent.startsWith("<![CDATA[") && trimmedContent.endsWith("]]>")) content = trimmedContent.slice(9, -3);
2200
+ const { path, content } = parsed.data;
2069
2201
  await provider.writeFile(path, content);
2070
2202
  return {
2071
2203
  success: true,
@@ -2230,7 +2362,7 @@ var UsageMeter = class {
2230
2362
 
2231
2363
  // src/workflow/agent.workflow.ts
2232
2364
  import { jsonSchema } from "ai";
2233
- import { toJSONSchema, z as z19 } from "zod";
2365
+ import { toJSONSchema, z as z20 } from "zod";
2234
2366
 
2235
2367
  // src/workflow/types.ts
2236
2368
  var TaskEventKind = /* @__PURE__ */ ((TaskEventKind2) => {
@@ -2314,7 +2446,7 @@ var agentWorkflow = async (input, { step, tools, logger }) => {
2314
2446
  }
2315
2447
  const validated = input.outputSchema.safeParse(parsed.data);
2316
2448
  if (!validated.success) {
2317
- 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.`;
2318
2450
  nextMessage = [{ role: "user", content: errorMessage }];
2319
2451
  continue;
2320
2452
  }
@@ -2396,63 +2528,63 @@ var agentWorkflow = async (input, { step, tools, logger }) => {
2396
2528
 
2397
2529
  // src/workflow/dynamic.ts
2398
2530
  import { parse as parse2 } from "yaml";
2399
- import { z as z21 } from "zod";
2531
+ import { z as z22 } from "zod";
2400
2532
 
2401
2533
  // src/workflow/dynamic-types.ts
2402
- import { z as z20 } from "zod";
2403
- var WorkflowInputDefinitionSchema = z20.object({
2404
- id: z20.string(),
2405
- description: z20.string().nullish(),
2406
- 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()
2407
2539
  });
2408
- var WorkflowStepDefinitionSchema = z20.object({
2409
- id: z20.string(),
2410
- tools: z20.array(z20.string()).nullish(),
2411
- task: z20.string(),
2412
- output: z20.string().nullish(),
2413
- 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(),
2414
2546
  /**
2415
2547
  * Optional JSON schema or other metadata for future structured outputs.
2416
2548
  * Not interpreted by core today.
2417
2549
  */
2418
- outputSchema: z20.any().nullish(),
2550
+ outputSchema: z21.any().nullish(),
2419
2551
  /**
2420
2552
  * Optional timeout in milliseconds. Step execution will be aborted if it exceeds this duration.
2421
2553
  */
2422
- timeout: z20.number().positive().nullish()
2554
+ timeout: z21.number().positive().nullish()
2423
2555
  });
2424
- var WhileLoopStepSchema = z20.object({
2425
- id: z20.string(),
2426
- while: z20.object({
2427
- condition: z20.string().describe("JavaScript expression that evaluates to true/false"),
2428
- 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))
2429
2561
  }),
2430
- output: z20.string().nullish()
2562
+ output: z21.string().nullish()
2431
2563
  });
2432
- var IfElseStepSchema = z20.object({
2433
- id: z20.string(),
2434
- if: z20.object({
2435
- condition: z20.string().describe("JavaScript expression that evaluates to true/false"),
2436
- thenBranch: z20.array(z20.lazy(() => WorkflowControlFlowStepSchema)),
2437
- 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()
2438
2570
  }),
2439
- output: z20.string().nullish()
2571
+ output: z21.string().nullish()
2440
2572
  });
2441
- var BreakStepSchema = z20.object({
2442
- break: z20.literal(true)
2573
+ var BreakStepSchema = z21.object({
2574
+ break: z21.literal(true)
2443
2575
  });
2444
- var ContinueStepSchema = z20.object({
2445
- continue: z20.literal(true)
2576
+ var ContinueStepSchema = z21.object({
2577
+ continue: z21.literal(true)
2446
2578
  });
2447
- var TryCatchStepSchema = z20.object({
2448
- id: z20.string(),
2449
- try: z20.object({
2450
- trySteps: z20.array(z20.lazy(() => WorkflowControlFlowStepSchema)),
2451
- 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))
2452
2584
  }),
2453
- output: z20.string().nullish()
2585
+ output: z21.string().nullish()
2454
2586
  });
2455
- var WorkflowControlFlowStepSchema = z20.union([
2587
+ var WorkflowControlFlowStepSchema = z21.union([
2456
2588
  WorkflowStepDefinitionSchema,
2457
2589
  WhileLoopStepSchema,
2458
2590
  IfElseStepSchema,
@@ -2460,14 +2592,14 @@ var WorkflowControlFlowStepSchema = z20.union([
2460
2592
  ContinueStepSchema,
2461
2593
  TryCatchStepSchema
2462
2594
  ]);
2463
- var WorkflowDefinitionSchema = z20.object({
2464
- task: z20.string(),
2465
- inputs: z20.array(WorkflowInputDefinitionSchema).nullish(),
2466
- steps: z20.array(WorkflowControlFlowStepSchema),
2467
- 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()
2468
2600
  });
2469
- var WorkflowFileSchema = z20.object({
2470
- workflows: z20.record(z20.string(), WorkflowDefinitionSchema)
2601
+ var WorkflowFileSchema = z21.object({
2602
+ workflows: z21.record(z21.string(), WorkflowDefinitionSchema)
2471
2603
  });
2472
2604
 
2473
2605
  // src/workflow/dynamic.ts
@@ -2476,26 +2608,26 @@ function convertJsonSchemaToZod(schema) {
2476
2608
  if (schema.enum) {
2477
2609
  const enumValues = schema.enum;
2478
2610
  if (enumValues.length === 0) {
2479
- return z21.never();
2611
+ return z22.never();
2480
2612
  }
2481
2613
  if (enumValues.every((v) => typeof v === "string")) {
2482
- return z21.enum(enumValues);
2614
+ return z22.enum(enumValues);
2483
2615
  }
2484
- const literals = enumValues.map((v) => z21.literal(v));
2616
+ const literals = enumValues.map((v) => z22.literal(v));
2485
2617
  if (literals.length === 1) {
2486
2618
  return literals[0];
2487
2619
  }
2488
- return z21.union([literals[0], literals[1], ...literals.slice(2)]);
2620
+ return z22.union([literals[0], literals[1], ...literals.slice(2)]);
2489
2621
  }
2490
2622
  if (Array.isArray(schema.type)) {
2491
2623
  const types = schema.type;
2492
2624
  if (types.includes("null") && types.length === 2) {
2493
2625
  const nonNullType = types.find((t) => t !== "null");
2494
- if (nonNullType === "string") return z21.string().nullable();
2495
- if (nonNullType === "number") return z21.number().nullable();
2626
+ if (nonNullType === "string") return z22.string().nullable();
2627
+ if (nonNullType === "number") return z22.number().nullable();
2496
2628
  if (nonNullType === "integer")
2497
- return z21.number().refine((val) => Number.isInteger(val)).nullable();
2498
- 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();
2499
2631
  if (nonNullType === "object") {
2500
2632
  const shape = {};
2501
2633
  if (schema.properties) {
@@ -2505,24 +2637,24 @@ function convertJsonSchemaToZod(schema) {
2505
2637
  shape[propName] = isRequired ? propZod : propZod.optional();
2506
2638
  }
2507
2639
  }
2508
- return z21.object(shape).nullable();
2640
+ return z22.object(shape).nullable();
2509
2641
  }
2510
- if (nonNullType === "array") return z21.array(z21.any()).nullable();
2642
+ if (nonNullType === "array") return z22.array(z22.any()).nullable();
2511
2643
  }
2512
- return z21.any();
2644
+ return z22.any();
2513
2645
  }
2514
2646
  const type = schema.type;
2515
2647
  switch (type) {
2516
2648
  case "string":
2517
- return z21.string();
2649
+ return z22.string();
2518
2650
  case "number":
2519
- return z21.number();
2651
+ return z22.number();
2520
2652
  case "integer":
2521
- 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" });
2522
2654
  case "boolean":
2523
- return z21.boolean();
2655
+ return z22.boolean();
2524
2656
  case "null":
2525
- return z21.null();
2657
+ return z22.null();
2526
2658
  case "object": {
2527
2659
  const shape = {};
2528
2660
  if (schema.properties) {
@@ -2533,23 +2665,23 @@ function convertJsonSchemaToZod(schema) {
2533
2665
  }
2534
2666
  }
2535
2667
  if (schema.additionalProperties === true) {
2536
- return z21.object(shape).passthrough();
2668
+ return z22.object(shape).passthrough();
2537
2669
  }
2538
2670
  if (typeof schema.additionalProperties === "object") {
2539
2671
  const additionalSchema = convertJsonSchemaToZod(schema.additionalProperties);
2540
- return z21.intersection(z21.object(shape), z21.record(z21.string(), additionalSchema));
2672
+ return z22.intersection(z22.object(shape), z22.record(z22.string(), additionalSchema));
2541
2673
  }
2542
- return z21.object(shape);
2674
+ return z22.object(shape);
2543
2675
  }
2544
2676
  case "array": {
2545
2677
  if (!schema.items) {
2546
- return z21.array(z21.any());
2678
+ return z22.array(z22.any());
2547
2679
  }
2548
2680
  const itemSchema = convertJsonSchemaToZod(schema.items);
2549
- return z21.array(itemSchema);
2681
+ return z22.array(itemSchema);
2550
2682
  }
2551
2683
  default:
2552
- return z21.any();
2684
+ return z22.any();
2553
2685
  }
2554
2686
  }
2555
2687
  var TOOL_GROUPS = {
@@ -2620,7 +2752,7 @@ function parseDynamicWorkflowDefinition(source) {
2620
2752
  const raw = parse2(source);
2621
2753
  const validated = WorkflowFileSchema.safeParse(raw);
2622
2754
  if (!validated.success) {
2623
- return { success: false, error: z21.prettifyError(validated.error) };
2755
+ return { success: false, error: z22.prettifyError(validated.error) };
2624
2756
  }
2625
2757
  const validation = validateWorkflowFile(validated.data);
2626
2758
  if (!validation.success) {
@@ -2913,9 +3045,9 @@ async function executeStepWithAgent(stepDef, workflowId, input, state, context,
2913
3045
  toolsForAgent.push({
2914
3046
  name: "runWorkflow",
2915
3047
  description: "Run a named sub-workflow defined in the current workflow file.",
2916
- parameters: z21.object({
2917
- workflowId: z21.string().describe("Sub-workflow id to run"),
2918
- 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")
2919
3051
  }),
2920
3052
  handler: async () => {
2921
3053
  return { success: false, message: { type: "error-text", value: "runWorkflow is virtual." } };
@@ -3517,6 +3649,7 @@ var makeStepFn = () => {
3517
3649
  export {
3518
3650
  BreakStepSchema,
3519
3651
  ContinueStepSchema,
3652
+ DEFAULT_MEMORY_CONFIG,
3520
3653
  IGNORED_DIRECTORIES,
3521
3654
  IfElseStepSchema,
3522
3655
  ListSkillsInputSchema,
@@ -3570,6 +3703,7 @@ export {
3570
3703
  loadSkillToolInfo,
3571
3704
  makeStepFn,
3572
3705
  mcpServerConfigSchema,
3706
+ memoryConfigSchema,
3573
3707
  parseDynamicWorkflowDefinition,
3574
3708
  parseJsonFromMarkdown,
3575
3709
  providerConfigSchema,
@@ -3582,6 +3716,7 @@ export {
3582
3716
  renameFile_default as renameFile,
3583
3717
  replaceInFile_default as replaceInFile,
3584
3718
  replaceInFile as replaceInFileHelper,
3719
+ resolveHomePath,
3585
3720
  responsePrompts,
3586
3721
  ruleSchema,
3587
3722
  scriptSchema,