@polka-codes/core 0.9.79 → 0.9.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,3 @@
1
- import { $strip } from 'zod/v4/core';
2
1
  import type { FilePart } from 'ai';
3
2
  import type { ImagePart } from 'ai';
4
3
  import type { JSONValue } from '@ai-sdk/provider';
@@ -15,11 +14,6 @@ import type { ToolModelMessage } from '@ai-sdk/provider-utils';
15
14
  import type { ToolResultPart } from '@ai-sdk/provider-utils';
16
15
  import { ToolSet } from 'ai';
17
16
  import { z } from 'zod';
18
- import { ZodEnum } from 'zod';
19
- import { ZodNullable } from 'zod';
20
- import { ZodObject } from 'zod';
21
- import { ZodOptional } from 'zod';
22
- import { ZodString } from 'zod';
23
17
 
24
18
  declare type AgentToolRegistry = {
25
19
  generateText: {
@@ -66,6 +60,13 @@ export { AgentWorkflowInput }
66
60
  export { AgentWorkflowInput as AgentWorkflowInput_alias_1 }
67
61
  export { AgentWorkflowInput as AgentWorkflowInput_alias_2 }
68
62
 
63
+ /**
64
+ * Instructions about code field format constraints.
65
+ */
66
+ declare const CODE_FIELD_CONSTRAINTS = "REMEMBER: The \"code\" field must be ONLY the function body statements.\n- DO NOT wrap code in arrow functions: `(ctx) => { ... }`\n- DO NOT wrap code in async functions: `async (ctx) => { ... }`\n- DO NOT include outer curly braces\n- DO include a return statement if the step should produce output\n- Each \"code\" field should be a string containing multiple statements separated by newlines";
67
+ export { CODE_FIELD_CONSTRAINTS }
68
+ export { CODE_FIELD_CONSTRAINTS as CODE_FIELD_CONSTRAINTS_alias_1 }
69
+
69
70
  declare type CommandProvider = {
70
71
  executeCommand?: (command: string, needApprove: boolean) => Promise<{
71
72
  stdout: string;
@@ -78,6 +79,20 @@ export { CommandProvider }
78
79
  export { CommandProvider as CommandProvider_alias_1 }
79
80
  export { CommandProvider as CommandProvider_alias_2 }
80
81
 
82
+ /**
83
+ * Complete example demonstrating all quality guidelines in a single step.
84
+ */
85
+ declare const COMPLETE_STEP_EXAMPLE = "## Complete Example: High-Quality Step Implementation\n\nThis example demonstrates all quality guidelines in a single step:\n\n```ts\n// Step: processUserData\n// Task: Read, validate, and process user data from a file\n\n// Input validation\nif (!ctx.input.dataFile) {\n throw new Error('Missing required input: dataFile')\n}\n\nctx.logger.info(`Starting user data processing for: ${ctx.input.dataFile}`)\n\n// Read file with error handling\nlet rawData\ntry {\n ctx.logger.debug(`Reading file: ${ctx.input.dataFile}`)\n rawData = await ctx.agentTools.readFile({ path: ctx.input.dataFile })\n\n if (!rawData) {\n throw new Error(`File not found or empty: ${ctx.input.dataFile}`)\n }\n} catch (error) {\n const err = error instanceof Error ? error : new Error(String(error))\n ctx.logger.error(`Failed to read file: ${err.message}`)\n throw err // Preserve original stack trace\n}\n\n// Parse and validate data\nlet users\ntry {\n ctx.logger.debug('Parsing JSON data')\n const parsed = JSON.parse(rawData)\n\n if (!parsed?.users || !Array.isArray(parsed.users)) {\n throw new Error('Invalid data format: expected {users: [...]}')\n }\n\n users = parsed.users\n ctx.logger.info(`Found ${users.length} users to process`)\n} catch (error) {\n const err = error instanceof Error ? error : new Error(String(error))\n ctx.logger.error(`Data parsing failed: ${err.message}`)\n throw err // Preserve original stack trace\n}\n\n// Process each user with progress reporting\nconst results = []\nfor (let i = 0; i < users.length; i++) {\n const user = users[i]\n\n // Validate each user object\n if (!user?.id || !user?.email) {\n ctx.logger.warn(`Skipping invalid user at index ${i}: missing id or email`)\n continue\n }\n\n // Process user\n const processed = {\n id: user.id,\n email: user.email.toLowerCase().trim(),\n name: user.name?.trim() || 'Unknown',\n processedAt: new Date().toISOString(),\n status: 'active'\n }\n\n results.push(processed)\n\n // Progress feedback every 10 items\n if ((i + 1) % 10 === 0) {\n ctx.logger.info(`Processed ${i + 1}/${users.length} users`)\n }\n}\n\nctx.logger.info(`Successfully processed ${results.length}/${users.length} users`)\n\n// Return structured result with metadata\nreturn {\n users: results,\n metadata: {\n totalInput: users.length,\n totalProcessed: results.length,\n skipped: users.length - results.length,\n processedAt: new Date().toISOString()\n }\n}\n```\n\nKey features demonstrated:\n- Input validation at start\n- Comprehensive error handling with try-catch that preserves stack traces\n- Logging at info, debug, warn, and error levels\n- Progress reporting for long operations (every 10 items)\n- Data validation throughout (null checks, type checks, array validation)\n- Structured return value with metadata for observability\n- Descriptive error messages with context\n- Meaningful variable names (rawData, users, processed)\n- Clean async/await usage\n- Template literals for readable string interpolation\n- Proper error type guards (error instanceof Error)";
86
+ export { COMPLETE_STEP_EXAMPLE }
87
+ export { COMPLETE_STEP_EXAMPLE as COMPLETE_STEP_EXAMPLE_alias_1 }
88
+
89
+ /**
90
+ * Compose the full implementation guidelines from individual components.
91
+ */
92
+ declare function composeImplementationGuidelines(): string;
93
+ export { composeImplementationGuidelines }
94
+ export { composeImplementationGuidelines as composeImplementationGuidelines_alias_1 }
95
+
81
96
  /**
82
97
  * Utility to compute exponential backoff delays for rate-limit handling. generated by polka.codes
83
98
  *
@@ -128,6 +143,17 @@ declare const configSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
128
143
  model: z.ZodOptional<z.ZodString>;
129
144
  parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
130
145
  budget: z.ZodOptional<z.ZodNumber>;
146
+ rules: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
147
+ path: z.ZodString;
148
+ }, z.core.$strict>, z.ZodObject<{
149
+ url: z.ZodString;
150
+ }, z.core.$strict>, z.ZodObject<{
151
+ repo: z.ZodString;
152
+ path: z.ZodString;
153
+ tag: z.ZodOptional<z.ZodString>;
154
+ commit: z.ZodOptional<z.ZodString>;
155
+ branch: z.ZodOptional<z.ZodString>;
156
+ }, z.core.$strict>]>>>, z.ZodString]>>;
131
157
  }, z.core.$strip>>>;
132
158
  tools: z.ZodOptional<z.ZodObject<{
133
159
  search: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
@@ -135,6 +161,17 @@ declare const configSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
135
161
  model: z.ZodOptional<z.ZodString>;
136
162
  parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
137
163
  budget: z.ZodOptional<z.ZodNumber>;
164
+ rules: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
165
+ path: z.ZodString;
166
+ }, z.core.$strict>, z.ZodObject<{
167
+ url: z.ZodString;
168
+ }, z.core.$strict>, z.ZodObject<{
169
+ repo: z.ZodString;
170
+ path: z.ZodString;
171
+ tag: z.ZodOptional<z.ZodString>;
172
+ commit: z.ZodOptional<z.ZodString>;
173
+ branch: z.ZodOptional<z.ZodString>;
174
+ }, z.core.$strict>]>>>, z.ZodString]>>;
138
175
  }, z.core.$strip>, z.ZodBoolean]>>;
139
176
  }, z.core.$strip>>;
140
177
  rules: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
@@ -153,6 +190,13 @@ declare const configSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
153
190
  export { configSchema }
154
191
  export { configSchema as configSchema_alias_1 }
155
192
 
193
+ /**
194
+ * Guidelines for accessing context and returning values.
195
+ */
196
+ declare const CONTEXT_USAGE_GUIDELINES = "## Guidelines\n- Use `await` for all async operations.\n- Return the output value for the step (this becomes the step output).\n- Access inputs via `ctx.input.<inputId>`.\n- Access previous step outputs via `ctx.state.<stepOutputKey>` (defaults to the step `output` or `id`).";
197
+ export { CONTEXT_USAGE_GUIDELINES }
198
+ export { CONTEXT_USAGE_GUIDELINES as CONTEXT_USAGE_GUIDELINES_alias_1 }
199
+
156
200
  declare function createContext<TTools extends ToolRegistry>(tools: WorkflowTools<TTools>, stepFn?: StepFn, logger?: Logger): WorkflowContext<TTools>;
157
201
  export { createContext }
158
202
  export { createContext as createContext_alias_1 }
@@ -161,6 +205,7 @@ export { createContext as createContext_alias_2 }
161
205
  declare function createDynamicWorkflow<TTools extends ToolRegistry = DynamicWorkflowRegistry>(definition: WorkflowFile | string, options?: DynamicWorkflowRunnerOptions): (workflowId: string, input: Record<string, any>, context: WorkflowContext<TTools>) => Promise<any>;
162
206
  export { createDynamicWorkflow }
163
207
  export { createDynamicWorkflow as createDynamicWorkflow_alias_1 }
208
+ export { createDynamicWorkflow as createDynamicWorkflow_alias_2 }
164
209
 
165
210
  declare const _default: {
166
211
  handler: ToolHandler<{
@@ -187,82 +232,6 @@ export { _default as askFollowupQuestion_alias_1 }
187
232
  export { _default as default_alias }
188
233
 
189
234
  declare const _default_10: {
190
- handler: ToolHandler<{
191
- readonly name: "readMemory";
192
- readonly description: "Reads content from a memory topic. Use this to retrieve information stored in previous steps. If no topic is specified, reads from the default topic.";
193
- readonly parameters: z.ZodObject<{
194
- topic: z.ZodOptional<z.ZodNullable<z.ZodString>>;
195
- }, z.core.$strip>;
196
- }, MemoryProvider>;
197
- name: "readMemory";
198
- description: "Reads content from a memory topic. Use this to retrieve information stored in previous steps. If no topic is specified, reads from the default topic.";
199
- parameters: z.ZodObject<{
200
- topic: z.ZodOptional<z.ZodNullable<z.ZodString>>;
201
- }, z.core.$strip>;
202
- };
203
- export { _default_10 as default_alias_9 }
204
- export { _default_10 as readMemory }
205
- export { _default_10 as readMemory_alias_1 }
206
-
207
- declare const _default_11: {
208
- handler: ToolHandler<{
209
- readonly name: "removeFile";
210
- readonly description: "Request to remove a file at the specified path.";
211
- readonly parameters: z.ZodObject<{
212
- path: z.ZodString;
213
- }, z.core.$strip>;
214
- }, FilesystemProvider>;
215
- name: "removeFile";
216
- description: "Request to remove a file at the specified path.";
217
- parameters: z.ZodObject<{
218
- path: z.ZodString;
219
- }, z.core.$strip>;
220
- };
221
- export { _default_11 as default_alias_10 }
222
- export { _default_11 as removeFile }
223
- export { _default_11 as removeFile_alias_1 }
224
-
225
- declare const _default_12: {
226
- handler: ToolHandler<{
227
- readonly name: "renameFile";
228
- readonly description: "Request to rename a file from source path to target path.";
229
- readonly parameters: z.ZodObject<{
230
- source_path: z.ZodString;
231
- target_path: z.ZodString;
232
- }, z.core.$strip>;
233
- }, FilesystemProvider>;
234
- name: "renameFile";
235
- description: "Request to rename a file from source path to target path.";
236
- parameters: z.ZodObject<{
237
- source_path: z.ZodString;
238
- target_path: z.ZodString;
239
- }, z.core.$strip>;
240
- };
241
- export { _default_12 as default_alias_11 }
242
- export { _default_12 as renameFile }
243
- export { _default_12 as renameFile_alias_1 }
244
-
245
- declare const _default_13: {
246
- handler: ToolHandler<{
247
- readonly name: "replaceInFile";
248
- readonly 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.";
249
- readonly parameters: z.ZodObject<{
250
- path: z.ZodString;
251
- diff: z.ZodString;
252
- }, z.core.$strip>;
253
- }, FilesystemProvider>;
254
- name: "replaceInFile";
255
- 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.";
256
- parameters: z.ZodObject<{
257
- path: z.ZodString;
258
- diff: z.ZodString;
259
- }, z.core.$strip>;
260
- };
261
- export { _default_13 as default_alias_12 }
262
- export { _default_13 as replaceInFile }
263
- export { _default_13 as replaceInFile_alias_1 }
264
-
265
- declare const _default_14: {
266
235
  handler: ToolHandler<{
267
236
  readonly name: "search";
268
237
  readonly 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.";
@@ -276,11 +245,11 @@ declare const _default_14: {
276
245
  query: z.ZodString;
277
246
  }, z.core.$strip>;
278
247
  };
279
- export { _default_14 as default_alias_13 }
280
- export { _default_14 as search }
281
- export { _default_14 as search_alias_1 }
248
+ export { _default_10 as default_alias_9 }
249
+ export { _default_10 as search }
250
+ export { _default_10 as search_alias_1 }
282
251
 
283
- declare const _default_15: {
252
+ declare const _default_11: {
284
253
  handler: ToolHandler<{
285
254
  readonly name: "searchFiles";
286
255
  readonly 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.";
@@ -298,83 +267,11 @@ declare const _default_15: {
298
267
  filePattern: z.ZodOptional<z.ZodString>;
299
268
  }, z.core.$strip>;
300
269
  };
301
- export { _default_15 as default_alias_14 }
302
- export { _default_15 as searchFiles }
303
- export { _default_15 as searchFiles_alias_1 }
304
-
305
- declare const _default_16: {
306
- handler: ToolHandler<{
307
- readonly name: "updateMemory";
308
- readonly description: "Appends, replaces, or removes content from a memory topic. Use \"append\" to add to existing content, \"replace\" to overwrite entirely, or \"remove\" to delete a topic. Memory persists across tool calls within a workflow.";
309
- readonly parameters: z.ZodObject<{
310
- operation: z.ZodEnum<{
311
- append: "append";
312
- replace: "replace";
313
- remove: "remove";
314
- }>;
315
- topic: z.ZodOptional<z.ZodNullable<z.ZodString>>;
316
- content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
317
- }, z.core.$strip>;
318
- }, MemoryProvider>;
319
- name: "updateMemory";
320
- description: "Appends, replaces, or removes content from a memory topic. Use \"append\" to add to existing content, \"replace\" to overwrite entirely, or \"remove\" to delete a topic. Memory persists across tool calls within a workflow.";
321
- parameters: z.ZodObject<{
322
- operation: z.ZodEnum<{
323
- append: "append";
324
- replace: "replace";
325
- remove: "remove";
326
- }>;
327
- topic: z.ZodOptional<z.ZodNullable<z.ZodString>>;
328
- content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
329
- }, z.core.$strip>;
330
- };
331
- export { _default_16 as default_alias_15 }
332
- export { _default_16 as updateMemory }
333
- export { _default_16 as updateMemory_alias_1 }
334
-
335
- declare const _default_17: {
336
- handler: ToolHandler<{
337
- readonly name: "updateTodoItem";
338
- readonly description: "Add or update a to-do item.";
339
- readonly parameters: ZodObject< {
340
- operation: ZodEnum< {
341
- add: "add";
342
- update: "update";
343
- }>;
344
- id: ZodOptional<ZodNullable<ZodString>>;
345
- parentId: ZodOptional<ZodNullable<ZodString>>;
346
- title: ZodOptional<ZodNullable<ZodString>>;
347
- description: ZodOptional<ZodNullable<ZodString>>;
348
- status: ZodOptional<ZodNullable<ZodEnum< {
349
- open: "open";
350
- completed: "completed";
351
- closed: "closed";
352
- }>>>;
353
- }, $strip>;
354
- }, TodoProvider>;
355
- name: "updateTodoItem";
356
- description: "Add or update a to-do item.";
357
- parameters: ZodObject< {
358
- operation: ZodEnum< {
359
- add: "add";
360
- update: "update";
361
- }>;
362
- id: ZodOptional<ZodNullable<ZodString>>;
363
- parentId: ZodOptional<ZodNullable<ZodString>>;
364
- title: ZodOptional<ZodNullable<ZodString>>;
365
- description: ZodOptional<ZodNullable<ZodString>>;
366
- status: ZodOptional<ZodNullable<ZodEnum< {
367
- open: "open";
368
- completed: "completed";
369
- closed: "closed";
370
- }>>>;
371
- }, $strip>;
372
- };
373
- export { _default_17 as default_alias_16 }
374
- export { _default_17 as updateTodoItem }
375
- export { _default_17 as updateTodoItem_alias_1 }
270
+ export { _default_11 as default_alias_10 }
271
+ export { _default_11 as searchFiles }
272
+ export { _default_11 as searchFiles_alias_1 }
376
273
 
377
- declare const _default_18: {
274
+ declare const _default_12: {
378
275
  handler: ToolHandler<{
379
276
  readonly name: "writeToFile";
380
277
  readonly 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.";
@@ -390,9 +287,9 @@ declare const _default_18: {
390
287
  content: z.ZodString;
391
288
  }, z.core.$strip>;
392
289
  };
393
- export { _default_18 as default_alias_17 }
394
- export { _default_18 as writeToFile }
395
- export { _default_18 as writeToFile_alias_1 }
290
+ export { _default_12 as default_alias_11 }
291
+ export { _default_12 as writeToFile }
292
+ export { _default_12 as writeToFile_alias_1 }
396
293
 
397
294
  declare const _default_2: {
398
295
  handler: ToolHandler<{
@@ -433,24 +330,6 @@ export { _default_3 as fetchUrl }
433
330
  export { _default_3 as fetchUrl_alias_1 }
434
331
 
435
332
  declare const _default_4: {
436
- handler: ToolHandler<{
437
- readonly name: "getTodoItem";
438
- readonly description: "Get a to-do item by its ID.";
439
- readonly parameters: z.ZodObject<{
440
- id: z.ZodString;
441
- }, z.core.$strip>;
442
- }, TodoProvider>;
443
- name: "getTodoItem";
444
- description: "Get a to-do item by its ID.";
445
- parameters: z.ZodObject<{
446
- id: z.ZodString;
447
- }, z.core.$strip>;
448
- };
449
- export { _default_4 as default_alias_3 }
450
- export { _default_4 as getTodoItem }
451
- export { _default_4 as getTodoItem_alias_1 }
452
-
453
- declare const _default_5: {
454
333
  handler: ToolHandler<{
455
334
  readonly name: "listFiles";
456
335
  readonly 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.";
@@ -470,89 +349,105 @@ declare const _default_5: {
470
349
  includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
471
350
  }, z.core.$strip>;
472
351
  };
352
+ export { _default_4 as default_alias_3 }
353
+ export { _default_4 as listFiles }
354
+ export { _default_4 as listFiles_alias_1 }
355
+
356
+ declare const _default_5: {
357
+ handler: ToolHandler<{
358
+ readonly name: "readBinaryFile";
359
+ readonly 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.";
360
+ readonly parameters: z.ZodObject<{
361
+ url: z.ZodString;
362
+ }, z.core.$strip>;
363
+ }, FilesystemProvider>;
364
+ name: "readBinaryFile";
365
+ 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.";
366
+ parameters: z.ZodObject<{
367
+ url: z.ZodString;
368
+ }, z.core.$strip>;
369
+ };
473
370
  export { _default_5 as default_alias_4 }
474
- export { _default_5 as listFiles }
475
- export { _default_5 as listFiles_alias_1 }
371
+ export { _default_5 as readBinaryFile }
372
+ export { _default_5 as readBinaryFile_alias_1 }
476
373
 
477
374
  declare const _default_6: {
478
375
  handler: ToolHandler<{
479
- readonly name: "listMemoryTopics";
480
- readonly description: "Lists all topics in memory. Use this to see what information has been stored and which topics are available to read from.";
481
- readonly parameters: z.ZodObject<{}, z.core.$strip>;
482
- }, MemoryProvider>;
483
- name: "listMemoryTopics";
484
- description: "Lists all topics in memory. Use this to see what information has been stored and which topics are available to read from.";
485
- parameters: z.ZodObject<{}, z.core.$strip>;
376
+ readonly name: "readFile";
377
+ readonly description: "Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string. Try to list all the potential files are relevent to the task, and then use this tool to read all the relevant files.";
378
+ readonly parameters: z.ZodObject<{
379
+ path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
380
+ includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>>;
381
+ }, z.core.$strip>;
382
+ }, FilesystemProvider>;
383
+ name: "readFile";
384
+ 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.";
385
+ parameters: z.ZodObject<{
386
+ path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
387
+ includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>>;
388
+ }, z.core.$strip>;
486
389
  };
487
390
  export { _default_6 as default_alias_5 }
488
- export { _default_6 as listMemoryTopics }
489
- export { _default_6 as listMemoryTopics_alias_1 }
391
+ export { _default_6 as readFile }
392
+ export { _default_6 as readFile_alias_1 }
490
393
 
491
394
  declare const _default_7: {
492
395
  handler: ToolHandler<{
493
- readonly name: "listTodoItems";
494
- readonly description: "List all to-do items, sorted by id. If an id is provided, it lists all sub-items for that id. Can be filtered by status.";
396
+ readonly name: "removeFile";
397
+ readonly description: "Request to remove a file at the specified path.";
495
398
  readonly parameters: z.ZodObject<{
496
- id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
497
- status: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
498
- open: "open";
499
- completed: "completed";
500
- closed: "closed";
501
- }>>>;
399
+ path: z.ZodString;
502
400
  }, z.core.$strip>;
503
- }, TodoProvider>;
504
- name: "listTodoItems";
505
- description: "List all to-do items, sorted by id. If an id is provided, it lists all sub-items for that id. Can be filtered by status.";
401
+ }, FilesystemProvider>;
402
+ name: "removeFile";
403
+ description: "Request to remove a file at the specified path.";
506
404
  parameters: z.ZodObject<{
507
- id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
508
- status: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
509
- open: "open";
510
- completed: "completed";
511
- closed: "closed";
512
- }>>>;
405
+ path: z.ZodString;
513
406
  }, z.core.$strip>;
514
407
  };
515
408
  export { _default_7 as default_alias_6 }
516
- export { _default_7 as listTodoItems }
517
- export { _default_7 as listTodoItems_alias_1 }
409
+ export { _default_7 as removeFile }
410
+ export { _default_7 as removeFile_alias_1 }
518
411
 
519
412
  declare const _default_8: {
520
413
  handler: ToolHandler<{
521
- readonly name: "readBinaryFile";
522
- readonly 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.";
414
+ readonly name: "renameFile";
415
+ readonly description: "Request to rename a file from source path to target path.";
523
416
  readonly parameters: z.ZodObject<{
524
- url: z.ZodString;
417
+ source_path: z.ZodString;
418
+ target_path: z.ZodString;
525
419
  }, z.core.$strip>;
526
420
  }, FilesystemProvider>;
527
- name: "readBinaryFile";
528
- 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.";
421
+ name: "renameFile";
422
+ description: "Request to rename a file from source path to target path.";
529
423
  parameters: z.ZodObject<{
530
- url: z.ZodString;
424
+ source_path: z.ZodString;
425
+ target_path: z.ZodString;
531
426
  }, z.core.$strip>;
532
427
  };
533
428
  export { _default_8 as default_alias_7 }
534
- export { _default_8 as readBinaryFile }
535
- export { _default_8 as readBinaryFile_alias_1 }
429
+ export { _default_8 as renameFile }
430
+ export { _default_8 as renameFile_alias_1 }
536
431
 
537
432
  declare const _default_9: {
538
433
  handler: ToolHandler<{
539
- readonly name: "readFile";
540
- readonly description: "Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string. Try to list all the potential files are relevent to the task, and then use this tool to read all the relevant files.";
434
+ readonly name: "replaceInFile";
435
+ readonly 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.";
541
436
  readonly parameters: z.ZodObject<{
542
- path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
543
- includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>>;
437
+ path: z.ZodString;
438
+ diff: z.ZodString;
544
439
  }, z.core.$strip>;
545
440
  }, FilesystemProvider>;
546
- name: "readFile";
547
- 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.";
441
+ name: "replaceInFile";
442
+ 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.";
548
443
  parameters: z.ZodObject<{
549
- path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
550
- includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>>;
444
+ path: z.ZodString;
445
+ diff: z.ZodString;
551
446
  }, z.core.$strip>;
552
447
  };
553
448
  export { _default_9 as default_alias_8 }
554
- export { _default_9 as readFile }
555
- export { _default_9 as readFile_alias_1 }
449
+ export { _default_9 as replaceInFile }
450
+ export { _default_9 as replaceInFile_alias_1 }
556
451
 
557
452
  /**
558
453
  * Returns the directory portion of a path string.
@@ -570,9 +465,11 @@ declare type DynamicStepRuntimeContext<TTools extends ToolRegistry> = {
570
465
  step: StepFn;
571
466
  runWorkflow: (workflowId: string, input?: Record<string, any>) => Promise<any>;
572
467
  toolInfo: Readonly<FullToolInfo[]> | undefined;
468
+ agentTools: Record<string, (input: any) => Promise<any>>;
573
469
  };
574
470
  export { DynamicStepRuntimeContext }
575
471
  export { DynamicStepRuntimeContext as DynamicStepRuntimeContext_alias_1 }
472
+ export { DynamicStepRuntimeContext as DynamicStepRuntimeContext_alias_2 }
576
473
 
577
474
  declare type DynamicWorkflowParseResult = {
578
475
  success: true;
@@ -583,12 +480,14 @@ declare type DynamicWorkflowParseResult = {
583
480
  };
584
481
  export { DynamicWorkflowParseResult }
585
482
  export { DynamicWorkflowParseResult as DynamicWorkflowParseResult_alias_1 }
483
+ export { DynamicWorkflowParseResult as DynamicWorkflowParseResult_alias_2 }
586
484
 
587
485
  declare type DynamicWorkflowRegistry = ToolRegistry & {
588
486
  runWorkflow: RunWorkflowTool;
589
487
  };
590
488
  export { DynamicWorkflowRegistry }
591
489
  export { DynamicWorkflowRegistry as DynamicWorkflowRegistry_alias_1 }
490
+ export { DynamicWorkflowRegistry as DynamicWorkflowRegistry_alias_2 }
592
491
 
593
492
  declare type DynamicWorkflowRunnerOptions = {
594
493
  /**
@@ -618,9 +517,15 @@ declare type DynamicWorkflowRunnerOptions = {
618
517
  input: any;
619
518
  state: any;
620
519
  }) => string;
520
+ /**
521
+ * Whether to wrap plain text agent responses in an object { result: ... }.
522
+ * Defaults to false.
523
+ */
524
+ wrapAgentResultInObject?: boolean;
621
525
  };
622
526
  export { DynamicWorkflowRunnerOptions }
623
527
  export { DynamicWorkflowRunnerOptions as DynamicWorkflowRunnerOptions_alias_1 }
528
+ export { DynamicWorkflowRunnerOptions as DynamicWorkflowRunnerOptions_alias_2 }
624
529
 
625
530
  declare type ExitReason = {
626
531
  type: 'UsageExceeded';
@@ -672,6 +577,7 @@ export { FullToolInfo as FullToolInfo_alias_1 }
672
577
  declare type GenerateWorkflowCodeInput = z.infer<typeof GenerateWorkflowCodeInputSchema>;
673
578
  export { GenerateWorkflowCodeInput }
674
579
  export { GenerateWorkflowCodeInput as GenerateWorkflowCodeInput_alias_1 }
580
+ export { GenerateWorkflowCodeInput as GenerateWorkflowCodeInput_alias_2 }
675
581
 
676
582
  declare const GenerateWorkflowCodeInputSchema: z.ZodObject<{
677
583
  workflow: z.ZodObject<{
@@ -690,35 +596,42 @@ declare const GenerateWorkflowCodeInputSchema: z.ZodObject<{
690
596
  expected_outcome: z.ZodOptional<z.ZodNullable<z.ZodString>>;
691
597
  code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
692
598
  outputSchema: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
599
+ timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
693
600
  }, z.core.$strip>>;
694
601
  output: z.ZodOptional<z.ZodNullable<z.ZodString>>;
695
602
  }, z.core.$strip>>;
696
603
  }, z.core.$strip>;
604
+ skipReview: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
697
605
  }, z.core.$strip>;
698
606
  export { GenerateWorkflowCodeInputSchema }
699
607
  export { GenerateWorkflowCodeInputSchema as GenerateWorkflowCodeInputSchema_alias_1 }
608
+ export { GenerateWorkflowCodeInputSchema as GenerateWorkflowCodeInputSchema_alias_2 }
700
609
 
701
610
  declare const generateWorkflowCodeWorkflow: WorkflowFn<GenerateWorkflowCodeInput, WorkflowFile, AgentToolRegistry>;
702
611
  export { generateWorkflowCodeWorkflow }
703
612
  export { generateWorkflowCodeWorkflow as generateWorkflowCodeWorkflow_alias_1 }
613
+ export { generateWorkflowCodeWorkflow as generateWorkflowCodeWorkflow_alias_2 }
704
614
 
705
615
  declare type GenerateWorkflowDefinitionInput = z.infer<typeof GenerateWorkflowDefinitionInputSchema>;
706
616
  export { GenerateWorkflowDefinitionInput }
707
617
  export { GenerateWorkflowDefinitionInput as GenerateWorkflowDefinitionInput_alias_1 }
618
+ export { GenerateWorkflowDefinitionInput as GenerateWorkflowDefinitionInput_alias_2 }
708
619
 
709
620
  declare const GenerateWorkflowDefinitionInputSchema: z.ZodObject<{
710
621
  prompt: z.ZodString;
711
- availableTools: z.ZodOptional<z.ZodArray<z.ZodObject<{
622
+ availableTools: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
712
623
  name: z.ZodString;
713
624
  description: z.ZodString;
714
- }, z.core.$strip>>>;
625
+ }, z.core.$strip>>>>;
715
626
  }, z.core.$strip>;
716
627
  export { GenerateWorkflowDefinitionInputSchema }
717
628
  export { GenerateWorkflowDefinitionInputSchema as GenerateWorkflowDefinitionInputSchema_alias_1 }
629
+ export { GenerateWorkflowDefinitionInputSchema as GenerateWorkflowDefinitionInputSchema_alias_2 }
718
630
 
719
631
  declare const generateWorkflowDefinitionWorkflow: WorkflowFn<GenerateWorkflowDefinitionInput, WorkflowFile, AgentToolRegistry>;
720
632
  export { generateWorkflowDefinitionWorkflow }
721
633
  export { generateWorkflowDefinitionWorkflow as generateWorkflowDefinitionWorkflow_alias_1 }
634
+ export { generateWorkflowDefinitionWorkflow as generateWorkflowDefinitionWorkflow_alias_2 }
722
635
 
723
636
  declare type GetTodoItemOutput = TodoItem & {
724
637
  subItems: {
@@ -738,33 +651,21 @@ export declare const handler_alias_10: ToolHandler<typeof toolInfo_alias_10, Fil
738
651
 
739
652
  export declare const handler_alias_11: ToolHandler<typeof toolInfo_alias_11, FilesystemProvider>;
740
653
 
741
- export declare const handler_alias_12: ToolHandler<typeof toolInfo_alias_12, FilesystemProvider>;
742
-
743
- export declare const handler_alias_13: ToolHandler<typeof toolInfo_alias_13, WebProvider>;
744
-
745
- export declare const handler_alias_14: ToolHandler<typeof toolInfo_alias_14, FilesystemProvider>;
746
-
747
- export declare const handler_alias_15: ToolHandler<typeof toolInfo_alias_15, MemoryProvider>;
748
-
749
- export declare const handler_alias_16: ToolHandler<typeof toolInfo_alias_16, TodoProvider>;
750
-
751
- export declare const handler_alias_17: ToolHandler<typeof toolInfo_alias_17, FilesystemProvider>;
752
-
753
654
  export declare const handler_alias_2: ToolHandler<typeof toolInfo_alias_2, WebProvider>;
754
655
 
755
- export declare const handler_alias_3: ToolHandler<typeof toolInfo_alias_3, TodoProvider>;
656
+ export declare const handler_alias_3: ToolHandler<typeof toolInfo_alias_3, FilesystemProvider>;
756
657
 
757
658
  export declare const handler_alias_4: ToolHandler<typeof toolInfo_alias_4, FilesystemProvider>;
758
659
 
759
- export declare const handler_alias_5: ToolHandler<typeof toolInfo_alias_5, MemoryProvider>;
660
+ export declare const handler_alias_5: ToolHandler<typeof toolInfo_alias_5, FilesystemProvider>;
760
661
 
761
- export declare const handler_alias_6: ToolHandler<typeof toolInfo_alias_6, TodoProvider>;
662
+ export declare const handler_alias_6: ToolHandler<typeof toolInfo_alias_6, FilesystemProvider>;
762
663
 
763
664
  export declare const handler_alias_7: ToolHandler<typeof toolInfo_alias_7, FilesystemProvider>;
764
665
 
765
666
  export declare const handler_alias_8: ToolHandler<typeof toolInfo_alias_8, FilesystemProvider>;
766
667
 
767
- export declare const handler_alias_9: ToolHandler<typeof toolInfo_alias_9, MemoryProvider>;
668
+ export declare const handler_alias_9: ToolHandler<typeof toolInfo_alias_9, WebProvider>;
768
669
 
769
670
  declare type InteractionProvider = {
770
671
  askFollowupQuestion?: (question: string, options: string[]) => Promise<string>;
@@ -997,6 +898,7 @@ export { ModelInfo as ModelInfo_alias_1 }
997
898
  declare function parseDynamicWorkflowDefinition(source: string): DynamicWorkflowParseResult;
998
899
  export { parseDynamicWorkflowDefinition }
999
900
  export { parseDynamicWorkflowDefinition as parseDynamicWorkflowDefinition_alias_1 }
901
+ export { parseDynamicWorkflowDefinition as parseDynamicWorkflowDefinition_alias_2 }
1000
902
 
1001
903
  declare const parseJsonFromMarkdown: (markdown: string) => ParseOutputResult<any>;
1002
904
  export { parseJsonFromMarkdown }
@@ -1019,10 +921,28 @@ declare const providerModelSchema: z.ZodObject<{
1019
921
  model: z.ZodOptional<z.ZodString>;
1020
922
  parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1021
923
  budget: z.ZodOptional<z.ZodNumber>;
924
+ rules: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
925
+ path: z.ZodString;
926
+ }, z.core.$strict>, z.ZodObject<{
927
+ url: z.ZodString;
928
+ }, z.core.$strict>, z.ZodObject<{
929
+ repo: z.ZodString;
930
+ path: z.ZodString;
931
+ tag: z.ZodOptional<z.ZodString>;
932
+ commit: z.ZodOptional<z.ZodString>;
933
+ branch: z.ZodOptional<z.ZodString>;
934
+ }, z.core.$strict>]>>>, z.ZodString]>>;
1022
935
  }, z.core.$strip>;
1023
936
  export { providerModelSchema }
1024
937
  export { providerModelSchema as providerModelSchema_alias_1 }
1025
938
 
939
+ /**
940
+ * Quality guidelines for error handling, logging, validation, and best practices.
941
+ */
942
+ declare const QUALITY_GUIDELINES = "## Quality Guidelines for Code Implementation\n\n### Error Handling\n- ALWAYS validate inputs at the start of steps\n- Use try-catch for operations that might fail (file I/O, parsing, API calls)\n- Preserve stack traces: re-throw original errors rather than creating new ones\n- Use error type guards: `const err = error instanceof Error ? error : new Error(String(error))`\n- Check for null/undefined before using values\n- Handle edge cases (empty arrays, missing files, invalid data)\n\n### Logging\n- Use `ctx.logger.info()` for important progress updates\n- Use `ctx.logger.debug()` for detailed information\n- Use `ctx.logger.warn()` for recoverable issues\n- Use `ctx.logger.error()` before throwing errors\n- Log when starting and completing significant operations\n- Use template literals for readability: `ctx.logger.info(\\`Processing ${items.length} items...\\`)`\n\n### User Experience\n- Provide progress feedback for long operations\n- Return structured data (objects/arrays), not strings when possible\n- Include helpful metadata in results (counts, timestamps, status)\n- For batch operations, report progress: `Processed 5/10 items`\n\n### Data Validation\n- Validate required fields exist before accessing\n- Check data types match expectations\n- Validate array lengths before iteration\n- Example: `if (!data?.users || !Array.isArray(data.users)) throw new Error('Invalid data format')`\n\n### Best Practices\n- Use meaningful variable names\n- Avoid nested callbacks - use async/await\n- Clean up resources (close files, clear timeouts)\n- Return consistent data structures across similar steps\n- For iteration, consider batching or rate limiting\n\n### When to Simplify\n- Simple transformation steps (e.g., formatting strings) need only basic error handling\n- Internal sub-workflow steps with validated inputs from parent can skip redundant validation\n- Minimal logging is fine for fast steps (<100ms) that don't perform I/O or external calls\n- Use judgment: match error handling complexity to the step's failure risk and impact";
943
+ export { QUALITY_GUIDELINES }
944
+ export { QUALITY_GUIDELINES as QUALITY_GUIDELINES_alias_1 }
945
+
1026
946
  declare const replaceInFile_2: (fileContent: string, diff: string) => ReplaceResult;
1027
947
  export { replaceInFile_2 as replaceInFileHelper }
1028
948
  export { replaceInFile_2 as replaceInFile_alias_2 }
@@ -1062,6 +982,13 @@ declare const ruleSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1062
982
  export { ruleSchema }
1063
983
  export { ruleSchema as ruleSchema_alias_1 }
1064
984
 
985
+ /**
986
+ * TypeScript type definitions for the runtime context available in dynamic workflow steps.
987
+ */
988
+ declare const RUNTIME_CONTEXT_TYPES = "## Runtime context (ctx)\n```ts\n// Runtime types (for reference)\ntype Logger = {\n debug: (...args: any[]) => void\n info: (...args: any[]) => void\n warn: (...args: any[]) => void\n error: (...args: any[]) => void\n}\n\ntype StepFn = {\n <T>(name: string, fn: () => Promise<T>): Promise<T>\n <T>(name: string, options: { retry?: number }, fn: () => Promise<T>): Promise<T>\n}\n\ntype JsonModelMessage = { role: 'system' | 'user' | 'assistant' | 'tool'; content: any }\ntype JsonResponseMessage = { role: 'assistant' | 'tool'; content: any }\ntype ToolSet = Record<string, any>\n\ntype ToolResponseResult =\n | { type: 'text'; value: string }\n | { type: 'json'; value: any }\n | { type: 'error-text'; value: string }\n | { type: 'error-json'; value: any }\n | { type: 'content'; value: any[] }\n\ntype ToolResponse =\n | { type: 'Reply'; message: ToolResponseResult }\n | { type: 'Exit'; message: string; object?: any }\n | { type: 'Error'; message: ToolResponseResult }\n\ntype ExitReason =\n | { type: 'UsageExceeded' }\n | { type: 'Exit'; message: string; object?: any }\n | { type: 'Error'; error: { message: string; stack?: string } }\n\ntype FullToolInfo = { name: string; description: string; parameters: any; handler: any }\n\ntype AgentTools = {\n readFile: (input: { path: string }) => Promise<string | null>\n writeToFile: (input: { path: string; content: string }) => Promise<void>\n executeCommand: (input: { command: string; pipe?: boolean; requiresApproval?: boolean } & ({ args: string[]; shell?: false } | { shell: true })) => Promise<{\n exitCode: number\n stdout: string\n stderr: string\n }>\n searchFiles: (input: { path: string; regex: string; filePattern?: string }) => Promise<string>\n listFiles: (input: { path: string; recursive?: boolean; maxCount?: number; includeIgnored?: boolean }) => Promise<string>\n fetchUrl: (input: { url: string[] }) => Promise<string>\n askFollowupQuestion: (input: { questions: { prompt: string; options?: string[] }[] }) => Promise<any>\n // ... and other tools available in the environment\n}\n\n// Tools available on ctx.tools in dynamic steps\ntype DynamicWorkflowTools = {\n // LLM + agent helpers\n runAgent: (input: {\n tools: Readonly<FullToolInfo[]>\n maxToolRoundTrips?: number\n userMessage: readonly JsonModelMessage[]\n } & ({ messages: JsonModelMessage[] } | { systemPrompt: string })) => Promise<ExitReason>\n\n // CLI UX helpers\n confirm: (input: { message: string }) => Promise<boolean>\n input: (input: { message: string; default?: string }) => Promise<string>\n select: (input: { message: string; choices: { name: string; value: string }[] }) => Promise<string>\n}\n\ntype DynamicStepRuntimeContext = {\n workflowId: string\n stepId: string\n input: Record<string, any>\n state: Record<string, any>\n tools: DynamicWorkflowTools\n agentTools: AgentTools\n logger: Logger\n step: StepFn\n runWorkflow: (workflowId: string, input?: Record<string, any>) => Promise<any>\n toolInfo?: ReadonlyArray<FullToolInfo>\n}\n```\n\n- `ctx.input`: workflow inputs (read-only).\n- `ctx.state`: shared state between steps (previous step outputs are stored here).\n- `ctx.agentTools`: standard tools (readFile, executeCommand, etc.). Call as `await ctx.agentTools.someTool({ ... })`.\n- `ctx.tools`: workflow helpers (runAgent, confirm, input, select).\n- `ctx.runWorkflow`: run a sub-workflow by id.";
989
+ export { RUNTIME_CONTEXT_TYPES }
990
+ export { RUNTIME_CONTEXT_TYPES as RUNTIME_CONTEXT_TYPES_alias_1 }
991
+
1065
992
  declare type RunWorkflowTool = {
1066
993
  input: {
1067
994
  workflowId: string;
@@ -1071,6 +998,7 @@ declare type RunWorkflowTool = {
1071
998
  };
1072
999
  export { RunWorkflowTool }
1073
1000
  export { RunWorkflowTool as RunWorkflowTool_alias_1 }
1001
+ export { RunWorkflowTool as RunWorkflowTool_alias_2 }
1074
1002
 
1075
1003
  declare interface StepFn {
1076
1004
  <T>(name: string, fn: () => Promise<T>): Promise<T>;
@@ -1187,7 +1115,7 @@ export { TaskEventText as TaskEventText_alias_2 }
1187
1115
  declare interface TaskEventToolError extends TaskEventBase {
1188
1116
  kind: TaskEventKind.ToolError;
1189
1117
  tool: string;
1190
- error: ToolResponseError | ToolResponseResult;
1118
+ error: ToolResponseResult;
1191
1119
  }
1192
1120
  export { TaskEventToolError }
1193
1121
  export { TaskEventToolError as TaskEventToolError_alias_1 }
@@ -1266,6 +1194,22 @@ export { toJsonModelMessage }
1266
1194
  export { toJsonModelMessage as toJsonModelMessage_alias_1 }
1267
1195
  export { toJsonModelMessage as toJsonModelMessage_alias_2 }
1268
1196
 
1197
+ declare const TOOL_CALLING_EXAMPLES = "## Tool calling examples\n\n### Standard tools (ctx.agentTools)\n```ts\n// readFile\nconst readme = await ctx.agentTools.readFile({ path: 'README.md' })\nif (readme == null) throw new Error('README.md not found')\n\n// writeToFile\nawait ctx.agentTools.writeToFile({ path: 'notes.txt', content: 'hello\\n' })\n\n// executeCommand (args form)\nconst rg = await ctx.agentTools.executeCommand({ command: 'rg', args: ['-n', 'TODO', '.'] })\nif (rg.exitCode !== 0) throw new Error(rg.stderr)\n\n// executeCommand (shell form)\nawait ctx.agentTools.executeCommand({ command: 'ls -la', shell: true, pipe: true })\n```\n\n### Workflow helpers (ctx.tools)\n```ts\n// runAgent (nested agent; use ctx.toolInfo as the tool list)\nconst agentRes = await ctx.tools.runAgent({\n systemPrompt: 'You are a helpful assistant.',\n userMessage: [{ role: 'user', content: 'Summarize README.md in 3 bullets.' }],\n tools: (ctx.toolInfo ?? []) as any,\n})\nif (agentRes.type !== 'Exit') throw new Error('runAgent failed')\n\n// confirm / input / select (interactive)\nconst ok = await ctx.tools.confirm({ message: 'Proceed?' })\nconst name = await ctx.tools.input({ message: 'Name?', default: 'main' })\nconst flavor = await ctx.tools.select({\n message: 'Pick one',\n choices: [\n { name: 'A', value: 'a' },\n { name: 'B', value: 'b' },\n ],\n})\n```\n\n### Sub-workflow example (ctx.runWorkflow)\n```ts\nconst results: any[] = []\nfor (const pr of ctx.state.prs ?? []) {\n results.push(await ctx.runWorkflow('reviewPR', { prId: pr.id }))\n}\nreturn results\n```";
1198
+ export { TOOL_CALLING_EXAMPLES }
1199
+ export { TOOL_CALLING_EXAMPLES as TOOL_CALLING_EXAMPLES_alias_1 }
1200
+
1201
+ /**
1202
+ * Tool groups that can be used in step.tools arrays.
1203
+ * - "readonly": File reading operations only
1204
+ * - "readwrite": Full file system access
1205
+ * - "internet": Network operations (fetch, search)
1206
+ * - "all": All available tools (special keyword, not in this map)
1207
+ */
1208
+ declare const TOOL_GROUPS: Record<string, string[]>;
1209
+ export { TOOL_GROUPS }
1210
+ export { TOOL_GROUPS as TOOL_GROUPS_alias_1 }
1211
+ export { TOOL_GROUPS as TOOL_GROUPS_alias_2 }
1212
+
1269
1213
  declare type ToolHandler<_T, P> = (provider: P, args: Partial<Record<string, ToolParameterValue>>) => Promise<ToolResponse>;
1270
1214
  export { ToolHandler }
1271
1215
  export { ToolHandler as ToolHandler_alias_1 }
@@ -1299,40 +1243,6 @@ export declare const toolInfo_alias_1: {
1299
1243
  };
1300
1244
 
1301
1245
  export declare const toolInfo_alias_10: {
1302
- readonly name: "removeFile";
1303
- readonly description: "Request to remove a file at the specified path.";
1304
- readonly parameters: z.ZodObject<{
1305
- path: z.ZodString;
1306
- }, z.core.$strip>;
1307
- };
1308
-
1309
- export declare const toolInfo_alias_11: {
1310
- readonly name: "renameFile";
1311
- readonly description: "Request to rename a file from source path to target path.";
1312
- readonly parameters: z.ZodObject<{
1313
- source_path: z.ZodString;
1314
- target_path: z.ZodString;
1315
- }, z.core.$strip>;
1316
- };
1317
-
1318
- export declare const toolInfo_alias_12: {
1319
- readonly name: "replaceInFile";
1320
- readonly 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.";
1321
- readonly parameters: z.ZodObject<{
1322
- path: z.ZodString;
1323
- diff: z.ZodString;
1324
- }, z.core.$strip>;
1325
- };
1326
-
1327
- export declare const toolInfo_alias_13: {
1328
- readonly name: "search";
1329
- readonly 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.";
1330
- readonly parameters: z.ZodObject<{
1331
- query: z.ZodString;
1332
- }, z.core.$strip>;
1333
- };
1334
-
1335
- export declare const toolInfo_alias_14: {
1336
1246
  readonly name: "searchFiles";
1337
1247
  readonly 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.";
1338
1248
  readonly parameters: z.ZodObject<{
@@ -1342,41 +1252,7 @@ export declare const toolInfo_alias_14: {
1342
1252
  }, z.core.$strip>;
1343
1253
  };
1344
1254
 
1345
- export declare const toolInfo_alias_15: {
1346
- readonly name: "updateMemory";
1347
- readonly description: "Appends, replaces, or removes content from a memory topic. Use \"append\" to add to existing content, \"replace\" to overwrite entirely, or \"remove\" to delete a topic. Memory persists across tool calls within a workflow.";
1348
- readonly parameters: z.ZodObject<{
1349
- operation: z.ZodEnum<{
1350
- append: "append";
1351
- replace: "replace";
1352
- remove: "remove";
1353
- }>;
1354
- topic: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1355
- content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1356
- }, z.core.$strip>;
1357
- };
1358
-
1359
- export declare const toolInfo_alias_16: {
1360
- readonly name: "updateTodoItem";
1361
- readonly description: "Add or update a to-do item.";
1362
- readonly parameters: ZodObject< {
1363
- operation: ZodEnum< {
1364
- add: "add";
1365
- update: "update";
1366
- }>;
1367
- id: ZodOptional<ZodNullable<ZodString>>;
1368
- parentId: ZodOptional<ZodNullable<ZodString>>;
1369
- title: ZodOptional<ZodNullable<ZodString>>;
1370
- description: ZodOptional<ZodNullable<ZodString>>;
1371
- status: ZodOptional<ZodNullable<ZodEnum< {
1372
- open: "open";
1373
- completed: "completed";
1374
- closed: "closed";
1375
- }>>>;
1376
- }, $strip>;
1377
- };
1378
-
1379
- export declare const toolInfo_alias_17: {
1255
+ export declare const toolInfo_alias_11: {
1380
1256
  readonly name: "writeToFile";
1381
1257
  readonly 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.";
1382
1258
  readonly parameters: z.ZodObject<{
@@ -1394,14 +1270,6 @@ export declare const toolInfo_alias_2: {
1394
1270
  };
1395
1271
 
1396
1272
  export declare const toolInfo_alias_3: {
1397
- readonly name: "getTodoItem";
1398
- readonly description: "Get a to-do item by its ID.";
1399
- readonly parameters: z.ZodObject<{
1400
- id: z.ZodString;
1401
- }, z.core.$strip>;
1402
- };
1403
-
1404
- export declare const toolInfo_alias_4: {
1405
1273
  readonly name: "listFiles";
1406
1274
  readonly 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.";
1407
1275
  readonly parameters: z.ZodObject<{
@@ -1412,47 +1280,54 @@ export declare const toolInfo_alias_4: {
1412
1280
  }, z.core.$strip>;
1413
1281
  };
1414
1282
 
1283
+ export declare const toolInfo_alias_4: {
1284
+ readonly name: "readBinaryFile";
1285
+ readonly 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.";
1286
+ readonly parameters: z.ZodObject<{
1287
+ url: z.ZodString;
1288
+ }, z.core.$strip>;
1289
+ };
1290
+
1415
1291
  export declare const toolInfo_alias_5: {
1416
- readonly name: "listMemoryTopics";
1417
- readonly description: "Lists all topics in memory. Use this to see what information has been stored and which topics are available to read from.";
1418
- readonly parameters: z.ZodObject<{}, z.core.$strip>;
1292
+ readonly name: "readFile";
1293
+ readonly description: "Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string. Try to list all the potential files are relevent to the task, and then use this tool to read all the relevant files.";
1294
+ readonly parameters: z.ZodObject<{
1295
+ path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
1296
+ includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>>;
1297
+ }, z.core.$strip>;
1419
1298
  };
1420
1299
 
1421
1300
  export declare const toolInfo_alias_6: {
1422
- readonly name: "listTodoItems";
1423
- readonly description: "List all to-do items, sorted by id. If an id is provided, it lists all sub-items for that id. Can be filtered by status.";
1301
+ readonly name: "removeFile";
1302
+ readonly description: "Request to remove a file at the specified path.";
1424
1303
  readonly parameters: z.ZodObject<{
1425
- id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1426
- status: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
1427
- open: "open";
1428
- completed: "completed";
1429
- closed: "closed";
1430
- }>>>;
1304
+ path: z.ZodString;
1431
1305
  }, z.core.$strip>;
1432
1306
  };
1433
1307
 
1434
1308
  export declare const toolInfo_alias_7: {
1435
- readonly name: "readBinaryFile";
1436
- readonly 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.";
1309
+ readonly name: "renameFile";
1310
+ readonly description: "Request to rename a file from source path to target path.";
1437
1311
  readonly parameters: z.ZodObject<{
1438
- url: z.ZodString;
1312
+ source_path: z.ZodString;
1313
+ target_path: z.ZodString;
1439
1314
  }, z.core.$strip>;
1440
1315
  };
1441
1316
 
1442
1317
  export declare const toolInfo_alias_8: {
1443
- readonly name: "readFile";
1444
- readonly description: "Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string. Try to list all the potential files are relevent to the task, and then use this tool to read all the relevant files.";
1318
+ readonly name: "replaceInFile";
1319
+ readonly 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.";
1445
1320
  readonly parameters: z.ZodObject<{
1446
- path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
1447
- includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>>;
1321
+ path: z.ZodString;
1322
+ diff: z.ZodString;
1448
1323
  }, z.core.$strip>;
1449
1324
  };
1450
1325
 
1451
1326
  export declare const toolInfo_alias_9: {
1452
- readonly name: "readMemory";
1453
- readonly description: "Reads content from a memory topic. Use this to retrieve information stored in previous steps. If no topic is specified, reads from the default topic.";
1327
+ readonly name: "search";
1328
+ readonly 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.";
1454
1329
  readonly parameters: z.ZodObject<{
1455
- topic: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1330
+ query: z.ZodString;
1456
1331
  }, z.core.$strip>;
1457
1332
  };
1458
1333
 
@@ -1483,31 +1358,12 @@ export { ToolRegistry }
1483
1358
  export { ToolRegistry as ToolRegistry_alias_1 }
1484
1359
  export { ToolRegistry as ToolRegistry_alias_2 }
1485
1360
 
1486
- declare type ToolResponse = ToolResponseReply | ToolResponseExit | ToolResponseError;
1487
- export { ToolResponse }
1488
- export { ToolResponse as ToolResponse_alias_1 }
1489
-
1490
- declare type ToolResponseError = {
1491
- type: ToolResponseType.Error;
1361
+ declare type ToolResponse = {
1362
+ success: boolean;
1492
1363
  message: ToolResponseResult;
1493
1364
  };
1494
- export { ToolResponseError }
1495
- export { ToolResponseError as ToolResponseError_alias_1 }
1496
-
1497
- declare type ToolResponseExit = {
1498
- type: ToolResponseType.Exit;
1499
- message: string;
1500
- object?: any;
1501
- };
1502
- export { ToolResponseExit }
1503
- export { ToolResponseExit as ToolResponseExit_alias_1 }
1504
-
1505
- declare type ToolResponseReply = {
1506
- type: ToolResponseType.Reply;
1507
- message: ToolResponseResult;
1508
- };
1509
- export { ToolResponseReply }
1510
- export { ToolResponseReply as ToolResponseReply_alias_1 }
1365
+ export { ToolResponse }
1366
+ export { ToolResponse as ToolResponse_alias_1 }
1511
1367
 
1512
1368
  declare type ToolResponseResult = {
1513
1369
  type: 'text';
@@ -1540,14 +1396,6 @@ declare type ToolResponseResultMedia = {
1540
1396
  export { ToolResponseResultMedia }
1541
1397
  export { ToolResponseResultMedia as ToolResponseResultMedia_alias_1 }
1542
1398
 
1543
- declare enum ToolResponseType {
1544
- Reply = "Reply",
1545
- Exit = "Exit",
1546
- Error = "Error"
1547
- }
1548
- export { ToolResponseType }
1549
- export { ToolResponseType as ToolResponseType_alias_1 }
1550
-
1551
1399
  declare type ToolSignature<I, O> = {
1552
1400
  input: I;
1553
1401
  output: O;
@@ -1654,6 +1502,22 @@ declare class UsageMeter {
1654
1502
  export { UsageMeter }
1655
1503
  export { UsageMeter as UsageMeter_alias_1 }
1656
1504
 
1505
+ /**
1506
+ * Validates the code syntax for all steps in a workflow.
1507
+ */
1508
+ declare function validateWorkflowCodeSyntax(workflow: WorkflowFile): WorkflowValidationResult;
1509
+ export { validateWorkflowCodeSyntax }
1510
+ export { validateWorkflowCodeSyntax as validateWorkflowCodeSyntax_alias_1 }
1511
+ export { validateWorkflowCodeSyntax as validateWorkflowCodeSyntax_alias_2 }
1512
+
1513
+ /**
1514
+ * Validates a workflow definition for structural correctness.
1515
+ */
1516
+ declare function validateWorkflowDefinition(workflow: WorkflowFile): WorkflowValidationResult;
1517
+ export { validateWorkflowDefinition }
1518
+ export { validateWorkflowDefinition as validateWorkflowDefinition_alias_1 }
1519
+ export { validateWorkflowDefinition as validateWorkflowDefinition_alias_2 }
1520
+
1657
1521
  declare type WebProvider = {
1658
1522
  fetchUrl?: (url: string) => Promise<string>;
1659
1523
  search?: (query: string) => Promise<string>;
@@ -1674,6 +1538,7 @@ export { WorkflowContext as WorkflowContext_alias_2 }
1674
1538
  declare type WorkflowDefinition = z.infer<typeof WorkflowDefinitionSchema>;
1675
1539
  export { WorkflowDefinition }
1676
1540
  export { WorkflowDefinition as WorkflowDefinition_alias_1 }
1541
+ export { WorkflowDefinition as WorkflowDefinition_alias_2 }
1677
1542
 
1678
1543
  declare const WorkflowDefinitionSchema: z.ZodObject<{
1679
1544
  task: z.ZodString;
@@ -1690,15 +1555,18 @@ declare const WorkflowDefinitionSchema: z.ZodObject<{
1690
1555
  expected_outcome: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1691
1556
  code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1692
1557
  outputSchema: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
1558
+ timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
1693
1559
  }, z.core.$strip>>;
1694
1560
  output: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1695
1561
  }, z.core.$strip>;
1696
1562
  export { WorkflowDefinitionSchema }
1697
1563
  export { WorkflowDefinitionSchema as WorkflowDefinitionSchema_alias_1 }
1564
+ export { WorkflowDefinitionSchema as WorkflowDefinitionSchema_alias_2 }
1698
1565
 
1699
1566
  declare type WorkflowFile = z.infer<typeof WorkflowFileSchema>;
1700
1567
  export { WorkflowFile }
1701
1568
  export { WorkflowFile as WorkflowFile_alias_1 }
1569
+ export { WorkflowFile as WorkflowFile_alias_2 }
1702
1570
 
1703
1571
  declare const WorkflowFileSchema: z.ZodObject<{
1704
1572
  workflows: z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -1716,12 +1584,14 @@ declare const WorkflowFileSchema: z.ZodObject<{
1716
1584
  expected_outcome: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1717
1585
  code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1718
1586
  outputSchema: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
1587
+ timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
1719
1588
  }, z.core.$strip>>;
1720
1589
  output: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1721
1590
  }, z.core.$strip>>;
1722
1591
  }, z.core.$strip>;
1723
1592
  export { WorkflowFileSchema }
1724
1593
  export { WorkflowFileSchema as WorkflowFileSchema_alias_1 }
1594
+ export { WorkflowFileSchema as WorkflowFileSchema_alias_2 }
1725
1595
 
1726
1596
  declare type WorkflowFn<TInput, TOutput, TTools extends ToolRegistry> = (input: TInput, context: WorkflowContext<TTools>) => Promise<TOutput>;
1727
1597
  export { WorkflowFn }
@@ -1731,6 +1601,7 @@ export { WorkflowFn as WorkflowFn_alias_2 }
1731
1601
  declare type WorkflowInputDefinition = z.infer<typeof WorkflowInputDefinitionSchema>;
1732
1602
  export { WorkflowInputDefinition }
1733
1603
  export { WorkflowInputDefinition as WorkflowInputDefinition_alias_1 }
1604
+ export { WorkflowInputDefinition as WorkflowInputDefinition_alias_2 }
1734
1605
 
1735
1606
  declare const WorkflowInputDefinitionSchema: z.ZodObject<{
1736
1607
  id: z.ZodString;
@@ -1739,10 +1610,12 @@ declare const WorkflowInputDefinitionSchema: z.ZodObject<{
1739
1610
  }, z.core.$strip>;
1740
1611
  export { WorkflowInputDefinitionSchema }
1741
1612
  export { WorkflowInputDefinitionSchema as WorkflowInputDefinitionSchema_alias_1 }
1613
+ export { WorkflowInputDefinitionSchema as WorkflowInputDefinitionSchema_alias_2 }
1742
1614
 
1743
1615
  declare type WorkflowStepDefinition = z.infer<typeof WorkflowStepDefinitionSchema>;
1744
1616
  export { WorkflowStepDefinition }
1745
1617
  export { WorkflowStepDefinition as WorkflowStepDefinition_alias_1 }
1618
+ export { WorkflowStepDefinition as WorkflowStepDefinition_alias_2 }
1746
1619
 
1747
1620
  declare const WorkflowStepDefinitionSchema: z.ZodObject<{
1748
1621
  id: z.ZodString;
@@ -1752,9 +1625,11 @@ declare const WorkflowStepDefinitionSchema: z.ZodObject<{
1752
1625
  expected_outcome: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1753
1626
  code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1754
1627
  outputSchema: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
1628
+ timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
1755
1629
  }, z.core.$strip>;
1756
1630
  export { WorkflowStepDefinitionSchema }
1757
1631
  export { WorkflowStepDefinitionSchema as WorkflowStepDefinitionSchema_alias_1 }
1632
+ export { WorkflowStepDefinitionSchema as WorkflowStepDefinitionSchema_alias_2 }
1758
1633
 
1759
1634
  declare type WorkflowTools<TTools extends ToolRegistry> = {
1760
1635
  [K in keyof TTools]: (input: TTools[K]['input']) => Promise<TTools[K]['output']>;
@@ -1763,4 +1638,12 @@ export { WorkflowTools }
1763
1638
  export { WorkflowTools as WorkflowTools_alias_1 }
1764
1639
  export { WorkflowTools as WorkflowTools_alias_2 }
1765
1640
 
1641
+ declare type WorkflowValidationResult = {
1642
+ valid: boolean;
1643
+ errors: string[];
1644
+ };
1645
+ export { WorkflowValidationResult }
1646
+ export { WorkflowValidationResult as WorkflowValidationResult_alias_1 }
1647
+ export { WorkflowValidationResult as WorkflowValidationResult_alias_2 }
1648
+
1766
1649
  export { }