@polka-codes/core 0.9.80 → 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,19 +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
-
24
- declare type AgentToolInfo = {
25
- name: string;
26
- description: string;
27
- parameters: z.ZodObject<any>;
28
- };
29
- export { AgentToolInfo }
30
- export { AgentToolInfo as AgentToolInfo_alias_1 }
31
17
 
32
18
  declare type AgentToolRegistry = {
33
19
  generateText: {
@@ -47,24 +33,20 @@ declare type AgentToolRegistry = {
47
33
  toolName: string;
48
34
  input: any;
49
35
  };
50
- output: AgentToolResponse;
36
+ output: ToolResponse;
51
37
  };
52
38
  };
53
39
  export { AgentToolRegistry }
54
40
  export { AgentToolRegistry as AgentToolRegistry_alias_1 }
55
41
  export { AgentToolRegistry as AgentToolRegistry_alias_2 }
56
42
 
57
- declare type AgentToolResponse = ToolResponseReply | ToolResponseExit | ToolResponseError;
58
- export { AgentToolResponse }
59
- export { AgentToolResponse as AgentToolResponse_alias_1 }
60
-
61
43
  declare const agentWorkflow: WorkflowFn<AgentWorkflowInput, ExitReason, AgentToolRegistry>;
62
44
  export { agentWorkflow }
63
45
  export { agentWorkflow as agentWorkflow_alias_1 }
64
46
  export { agentWorkflow as agentWorkflow_alias_2 }
65
47
 
66
48
  declare type AgentWorkflowInput = {
67
- tools: Readonly<FullAgentToolInfo[]>;
49
+ tools: Readonly<FullToolInfo[]>;
68
50
  maxToolRoundTrips?: number;
69
51
  userMessage: readonly JsonUserModelMessage[];
70
52
  outputSchema?: z.ZodSchema;
@@ -78,6 +60,13 @@ export { AgentWorkflowInput }
78
60
  export { AgentWorkflowInput as AgentWorkflowInput_alias_1 }
79
61
  export { AgentWorkflowInput as AgentWorkflowInput_alias_2 }
80
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
+
81
70
  declare type CommandProvider = {
82
71
  executeCommand?: (command: string, needApprove: boolean) => Promise<{
83
72
  stdout: string;
@@ -90,6 +79,20 @@ export { CommandProvider }
90
79
  export { CommandProvider as CommandProvider_alias_1 }
91
80
  export { CommandProvider as CommandProvider_alias_2 }
92
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
+
93
96
  /**
94
97
  * Utility to compute exponential backoff delays for rate-limit handling. generated by polka.codes
95
98
  *
@@ -140,6 +143,17 @@ declare const configSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
140
143
  model: z.ZodOptional<z.ZodString>;
141
144
  parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
142
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]>>;
143
157
  }, z.core.$strip>>>;
144
158
  tools: z.ZodOptional<z.ZodObject<{
145
159
  search: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
@@ -147,6 +161,17 @@ declare const configSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
147
161
  model: z.ZodOptional<z.ZodString>;
148
162
  parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
149
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]>>;
150
175
  }, z.core.$strip>, z.ZodBoolean]>>;
151
176
  }, z.core.$strip>>;
152
177
  rules: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
@@ -165,6 +190,13 @@ declare const configSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
165
190
  export { configSchema }
166
191
  export { configSchema as configSchema_alias_1 }
167
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
+
168
200
  declare function createContext<TTools extends ToolRegistry>(tools: WorkflowTools<TTools>, stepFn?: StepFn, logger?: Logger): WorkflowContext<TTools>;
169
201
  export { createContext }
170
202
  export { createContext as createContext_alias_1 }
@@ -173,6 +205,7 @@ export { createContext as createContext_alias_2 }
173
205
  declare function createDynamicWorkflow<TTools extends ToolRegistry = DynamicWorkflowRegistry>(definition: WorkflowFile | string, options?: DynamicWorkflowRunnerOptions): (workflowId: string, input: Record<string, any>, context: WorkflowContext<TTools>) => Promise<any>;
174
206
  export { createDynamicWorkflow }
175
207
  export { createDynamicWorkflow as createDynamicWorkflow_alias_1 }
208
+ export { createDynamicWorkflow as createDynamicWorkflow_alias_2 }
176
209
 
177
210
  declare const _default: {
178
211
  handler: ToolHandler<{
@@ -199,82 +232,6 @@ export { _default as askFollowupQuestion_alias_1 }
199
232
  export { _default as default_alias }
200
233
 
201
234
  declare const _default_10: {
202
- handler: ToolHandler<{
203
- readonly name: "readMemory";
204
- 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.";
205
- readonly parameters: z.ZodObject<{
206
- topic: z.ZodOptional<z.ZodNullable<z.ZodString>>;
207
- }, z.core.$strip>;
208
- }, MemoryProvider>;
209
- name: "readMemory";
210
- 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.";
211
- parameters: z.ZodObject<{
212
- topic: z.ZodOptional<z.ZodNullable<z.ZodString>>;
213
- }, z.core.$strip>;
214
- };
215
- export { _default_10 as default_alias_9 }
216
- export { _default_10 as readMemory }
217
- export { _default_10 as readMemory_alias_1 }
218
-
219
- declare const _default_11: {
220
- handler: ToolHandler<{
221
- readonly name: "removeFile";
222
- readonly description: "Request to remove a file at the specified path.";
223
- readonly parameters: z.ZodObject<{
224
- path: z.ZodString;
225
- }, z.core.$strip>;
226
- }, FilesystemProvider>;
227
- name: "removeFile";
228
- description: "Request to remove a file at the specified path.";
229
- parameters: z.ZodObject<{
230
- path: z.ZodString;
231
- }, z.core.$strip>;
232
- };
233
- export { _default_11 as default_alias_10 }
234
- export { _default_11 as removeFile }
235
- export { _default_11 as removeFile_alias_1 }
236
-
237
- declare const _default_12: {
238
- handler: ToolHandler<{
239
- readonly name: "renameFile";
240
- readonly description: "Request to rename a file from source path to target path.";
241
- readonly parameters: z.ZodObject<{
242
- source_path: z.ZodString;
243
- target_path: z.ZodString;
244
- }, z.core.$strip>;
245
- }, FilesystemProvider>;
246
- name: "renameFile";
247
- description: "Request to rename a file from source path to target path.";
248
- parameters: z.ZodObject<{
249
- source_path: z.ZodString;
250
- target_path: z.ZodString;
251
- }, z.core.$strip>;
252
- };
253
- export { _default_12 as default_alias_11 }
254
- export { _default_12 as renameFile }
255
- export { _default_12 as renameFile_alias_1 }
256
-
257
- declare const _default_13: {
258
- handler: ToolHandler<{
259
- readonly name: "replaceInFile";
260
- 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.";
261
- readonly parameters: z.ZodObject<{
262
- path: z.ZodString;
263
- diff: z.ZodString;
264
- }, z.core.$strip>;
265
- }, FilesystemProvider>;
266
- name: "replaceInFile";
267
- 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.";
268
- parameters: z.ZodObject<{
269
- path: z.ZodString;
270
- diff: z.ZodString;
271
- }, z.core.$strip>;
272
- };
273
- export { _default_13 as default_alias_12 }
274
- export { _default_13 as replaceInFile }
275
- export { _default_13 as replaceInFile_alias_1 }
276
-
277
- declare const _default_14: {
278
235
  handler: ToolHandler<{
279
236
  readonly name: "search";
280
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.";
@@ -288,11 +245,11 @@ declare const _default_14: {
288
245
  query: z.ZodString;
289
246
  }, z.core.$strip>;
290
247
  };
291
- export { _default_14 as default_alias_13 }
292
- export { _default_14 as search }
293
- 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 }
294
251
 
295
- declare const _default_15: {
252
+ declare const _default_11: {
296
253
  handler: ToolHandler<{
297
254
  readonly name: "searchFiles";
298
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.";
@@ -310,83 +267,11 @@ declare const _default_15: {
310
267
  filePattern: z.ZodOptional<z.ZodString>;
311
268
  }, z.core.$strip>;
312
269
  };
313
- export { _default_15 as default_alias_14 }
314
- export { _default_15 as searchFiles }
315
- export { _default_15 as searchFiles_alias_1 }
316
-
317
- declare const _default_16: {
318
- handler: ToolHandler<{
319
- readonly name: "updateMemory";
320
- 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.";
321
- readonly 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
- }, MemoryProvider>;
331
- name: "updateMemory";
332
- 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.";
333
- parameters: z.ZodObject<{
334
- operation: z.ZodEnum<{
335
- append: "append";
336
- replace: "replace";
337
- remove: "remove";
338
- }>;
339
- topic: z.ZodOptional<z.ZodNullable<z.ZodString>>;
340
- content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
341
- }, z.core.$strip>;
342
- };
343
- export { _default_16 as default_alias_15 }
344
- export { _default_16 as updateMemory }
345
- export { _default_16 as updateMemory_alias_1 }
346
-
347
- declare const _default_17: {
348
- handler: ToolHandler<{
349
- readonly name: "updateTodoItem";
350
- readonly description: "Add or update a to-do item.";
351
- readonly parameters: ZodObject< {
352
- operation: ZodEnum< {
353
- add: "add";
354
- update: "update";
355
- }>;
356
- id: ZodOptional<ZodNullable<ZodString>>;
357
- parentId: ZodOptional<ZodNullable<ZodString>>;
358
- title: ZodOptional<ZodNullable<ZodString>>;
359
- description: ZodOptional<ZodNullable<ZodString>>;
360
- status: ZodOptional<ZodNullable<ZodEnum< {
361
- open: "open";
362
- completed: "completed";
363
- closed: "closed";
364
- }>>>;
365
- }, $strip>;
366
- }, TodoProvider>;
367
- name: "updateTodoItem";
368
- description: "Add or update a to-do item.";
369
- parameters: ZodObject< {
370
- operation: ZodEnum< {
371
- add: "add";
372
- update: "update";
373
- }>;
374
- id: ZodOptional<ZodNullable<ZodString>>;
375
- parentId: ZodOptional<ZodNullable<ZodString>>;
376
- title: ZodOptional<ZodNullable<ZodString>>;
377
- description: ZodOptional<ZodNullable<ZodString>>;
378
- status: ZodOptional<ZodNullable<ZodEnum< {
379
- open: "open";
380
- completed: "completed";
381
- closed: "closed";
382
- }>>>;
383
- }, $strip>;
384
- };
385
- export { _default_17 as default_alias_16 }
386
- export { _default_17 as updateTodoItem }
387
- 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 }
388
273
 
389
- declare const _default_18: {
274
+ declare const _default_12: {
390
275
  handler: ToolHandler<{
391
276
  readonly name: "writeToFile";
392
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.";
@@ -402,9 +287,9 @@ declare const _default_18: {
402
287
  content: z.ZodString;
403
288
  }, z.core.$strip>;
404
289
  };
405
- export { _default_18 as default_alias_17 }
406
- export { _default_18 as writeToFile }
407
- 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 }
408
293
 
409
294
  declare const _default_2: {
410
295
  handler: ToolHandler<{
@@ -445,24 +330,6 @@ export { _default_3 as fetchUrl }
445
330
  export { _default_3 as fetchUrl_alias_1 }
446
331
 
447
332
  declare const _default_4: {
448
- handler: ToolHandler<{
449
- readonly name: "getTodoItem";
450
- readonly description: "Get a to-do item by its ID.";
451
- readonly parameters: z.ZodObject<{
452
- id: z.ZodString;
453
- }, z.core.$strip>;
454
- }, TodoProvider>;
455
- name: "getTodoItem";
456
- description: "Get a to-do item by its ID.";
457
- parameters: z.ZodObject<{
458
- id: z.ZodString;
459
- }, z.core.$strip>;
460
- };
461
- export { _default_4 as default_alias_3 }
462
- export { _default_4 as getTodoItem }
463
- export { _default_4 as getTodoItem_alias_1 }
464
-
465
- declare const _default_5: {
466
333
  handler: ToolHandler<{
467
334
  readonly name: "listFiles";
468
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.";
@@ -482,89 +349,105 @@ declare const _default_5: {
482
349
  includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
483
350
  }, z.core.$strip>;
484
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
+ };
485
370
  export { _default_5 as default_alias_4 }
486
- export { _default_5 as listFiles }
487
- export { _default_5 as listFiles_alias_1 }
371
+ export { _default_5 as readBinaryFile }
372
+ export { _default_5 as readBinaryFile_alias_1 }
488
373
 
489
374
  declare const _default_6: {
490
375
  handler: ToolHandler<{
491
- readonly name: "listMemoryTopics";
492
- readonly description: "Lists all topics in memory. Use this to see what information has been stored and which topics are available to read from.";
493
- readonly parameters: z.ZodObject<{}, z.core.$strip>;
494
- }, MemoryProvider>;
495
- name: "listMemoryTopics";
496
- description: "Lists all topics in memory. Use this to see what information has been stored and which topics are available to read from.";
497
- 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>;
498
389
  };
499
390
  export { _default_6 as default_alias_5 }
500
- export { _default_6 as listMemoryTopics }
501
- export { _default_6 as listMemoryTopics_alias_1 }
391
+ export { _default_6 as readFile }
392
+ export { _default_6 as readFile_alias_1 }
502
393
 
503
394
  declare const _default_7: {
504
395
  handler: ToolHandler<{
505
- readonly name: "listTodoItems";
506
- 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.";
507
398
  readonly parameters: z.ZodObject<{
508
- id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
509
- status: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
510
- open: "open";
511
- completed: "completed";
512
- closed: "closed";
513
- }>>>;
399
+ path: z.ZodString;
514
400
  }, z.core.$strip>;
515
- }, TodoProvider>;
516
- name: "listTodoItems";
517
- 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.";
518
404
  parameters: z.ZodObject<{
519
- id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
520
- status: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
521
- open: "open";
522
- completed: "completed";
523
- closed: "closed";
524
- }>>>;
405
+ path: z.ZodString;
525
406
  }, z.core.$strip>;
526
407
  };
527
408
  export { _default_7 as default_alias_6 }
528
- export { _default_7 as listTodoItems }
529
- export { _default_7 as listTodoItems_alias_1 }
409
+ export { _default_7 as removeFile }
410
+ export { _default_7 as removeFile_alias_1 }
530
411
 
531
412
  declare const _default_8: {
532
413
  handler: ToolHandler<{
533
- readonly name: "readBinaryFile";
534
- 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.";
535
416
  readonly parameters: z.ZodObject<{
536
- url: z.ZodString;
417
+ source_path: z.ZodString;
418
+ target_path: z.ZodString;
537
419
  }, z.core.$strip>;
538
420
  }, FilesystemProvider>;
539
- name: "readBinaryFile";
540
- 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.";
541
423
  parameters: z.ZodObject<{
542
- url: z.ZodString;
424
+ source_path: z.ZodString;
425
+ target_path: z.ZodString;
543
426
  }, z.core.$strip>;
544
427
  };
545
428
  export { _default_8 as default_alias_7 }
546
- export { _default_8 as readBinaryFile }
547
- export { _default_8 as readBinaryFile_alias_1 }
429
+ export { _default_8 as renameFile }
430
+ export { _default_8 as renameFile_alias_1 }
548
431
 
549
432
  declare const _default_9: {
550
433
  handler: ToolHandler<{
551
- readonly name: "readFile";
552
- 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.";
553
436
  readonly parameters: z.ZodObject<{
554
- path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
555
- includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>>;
437
+ path: z.ZodString;
438
+ diff: z.ZodString;
556
439
  }, z.core.$strip>;
557
440
  }, FilesystemProvider>;
558
- name: "readFile";
559
- 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.";
560
443
  parameters: z.ZodObject<{
561
- path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
562
- includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>>;
444
+ path: z.ZodString;
445
+ diff: z.ZodString;
563
446
  }, z.core.$strip>;
564
447
  };
565
448
  export { _default_9 as default_alias_8 }
566
- export { _default_9 as readFile }
567
- export { _default_9 as readFile_alias_1 }
449
+ export { _default_9 as replaceInFile }
450
+ export { _default_9 as replaceInFile_alias_1 }
568
451
 
569
452
  /**
570
453
  * Returns the directory portion of a path string.
@@ -581,10 +464,12 @@ declare type DynamicStepRuntimeContext<TTools extends ToolRegistry> = {
581
464
  logger: Logger;
582
465
  step: StepFn;
583
466
  runWorkflow: (workflowId: string, input?: Record<string, any>) => Promise<any>;
584
- toolInfo: Readonly<FullAgentToolInfo[]> | undefined;
467
+ toolInfo: Readonly<FullToolInfo[]> | undefined;
468
+ agentTools: Record<string, (input: any) => Promise<any>>;
585
469
  };
586
470
  export { DynamicStepRuntimeContext }
587
471
  export { DynamicStepRuntimeContext as DynamicStepRuntimeContext_alias_1 }
472
+ export { DynamicStepRuntimeContext as DynamicStepRuntimeContext_alias_2 }
588
473
 
589
474
  declare type DynamicWorkflowParseResult = {
590
475
  success: true;
@@ -595,19 +480,21 @@ declare type DynamicWorkflowParseResult = {
595
480
  };
596
481
  export { DynamicWorkflowParseResult }
597
482
  export { DynamicWorkflowParseResult as DynamicWorkflowParseResult_alias_1 }
483
+ export { DynamicWorkflowParseResult as DynamicWorkflowParseResult_alias_2 }
598
484
 
599
485
  declare type DynamicWorkflowRegistry = ToolRegistry & {
600
486
  runWorkflow: RunWorkflowTool;
601
487
  };
602
488
  export { DynamicWorkflowRegistry }
603
489
  export { DynamicWorkflowRegistry as DynamicWorkflowRegistry_alias_1 }
490
+ export { DynamicWorkflowRegistry as DynamicWorkflowRegistry_alias_2 }
604
491
 
605
492
  declare type DynamicWorkflowRunnerOptions = {
606
493
  /**
607
494
  * Tool definitions used when a step does not have persisted `code`
608
495
  * and needs to be executed via `agentWorkflow`.
609
496
  */
610
- toolInfo?: Readonly<FullAgentToolInfo[]>;
497
+ toolInfo?: Readonly<FullToolInfo[]>;
611
498
  /**
612
499
  * Model id forwarded to `agentWorkflow` for agent-executed steps.
613
500
  */
@@ -638,6 +525,7 @@ declare type DynamicWorkflowRunnerOptions = {
638
525
  };
639
526
  export { DynamicWorkflowRunnerOptions }
640
527
  export { DynamicWorkflowRunnerOptions as DynamicWorkflowRunnerOptions_alias_1 }
528
+ export { DynamicWorkflowRunnerOptions as DynamicWorkflowRunnerOptions_alias_2 }
641
529
 
642
530
  declare type ExitReason = {
643
531
  type: 'UsageExceeded';
@@ -680,15 +568,16 @@ export { fromJsonModelMessage }
680
568
  export { fromJsonModelMessage as fromJsonModelMessage_alias_1 }
681
569
  export { fromJsonModelMessage as fromJsonModelMessage_alias_2 }
682
570
 
683
- declare type FullAgentToolInfo = AgentToolInfo & {
684
- handler: ToolHandler<AgentToolInfo, any>;
571
+ declare type FullToolInfo = ToolInfo & {
572
+ handler: ToolHandler<ToolInfo, any>;
685
573
  };
686
- export { FullAgentToolInfo }
687
- export { FullAgentToolInfo as FullAgentToolInfo_alias_1 }
574
+ export { FullToolInfo }
575
+ export { FullToolInfo as FullToolInfo_alias_1 }
688
576
 
689
577
  declare type GenerateWorkflowCodeInput = z.infer<typeof GenerateWorkflowCodeInputSchema>;
690
578
  export { GenerateWorkflowCodeInput }
691
579
  export { GenerateWorkflowCodeInput as GenerateWorkflowCodeInput_alias_1 }
580
+ export { GenerateWorkflowCodeInput as GenerateWorkflowCodeInput_alias_2 }
692
581
 
693
582
  declare const GenerateWorkflowCodeInputSchema: z.ZodObject<{
694
583
  workflow: z.ZodObject<{
@@ -712,31 +601,37 @@ declare const GenerateWorkflowCodeInputSchema: z.ZodObject<{
712
601
  output: z.ZodOptional<z.ZodNullable<z.ZodString>>;
713
602
  }, z.core.$strip>>;
714
603
  }, z.core.$strip>;
604
+ skipReview: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
715
605
  }, z.core.$strip>;
716
606
  export { GenerateWorkflowCodeInputSchema }
717
607
  export { GenerateWorkflowCodeInputSchema as GenerateWorkflowCodeInputSchema_alias_1 }
608
+ export { GenerateWorkflowCodeInputSchema as GenerateWorkflowCodeInputSchema_alias_2 }
718
609
 
719
610
  declare const generateWorkflowCodeWorkflow: WorkflowFn<GenerateWorkflowCodeInput, WorkflowFile, AgentToolRegistry>;
720
611
  export { generateWorkflowCodeWorkflow }
721
612
  export { generateWorkflowCodeWorkflow as generateWorkflowCodeWorkflow_alias_1 }
613
+ export { generateWorkflowCodeWorkflow as generateWorkflowCodeWorkflow_alias_2 }
722
614
 
723
615
  declare type GenerateWorkflowDefinitionInput = z.infer<typeof GenerateWorkflowDefinitionInputSchema>;
724
616
  export { GenerateWorkflowDefinitionInput }
725
617
  export { GenerateWorkflowDefinitionInput as GenerateWorkflowDefinitionInput_alias_1 }
618
+ export { GenerateWorkflowDefinitionInput as GenerateWorkflowDefinitionInput_alias_2 }
726
619
 
727
620
  declare const GenerateWorkflowDefinitionInputSchema: z.ZodObject<{
728
621
  prompt: z.ZodString;
729
- availableTools: z.ZodOptional<z.ZodArray<z.ZodObject<{
622
+ availableTools: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
730
623
  name: z.ZodString;
731
624
  description: z.ZodString;
732
- }, z.core.$strip>>>;
625
+ }, z.core.$strip>>>>;
733
626
  }, z.core.$strip>;
734
627
  export { GenerateWorkflowDefinitionInputSchema }
735
628
  export { GenerateWorkflowDefinitionInputSchema as GenerateWorkflowDefinitionInputSchema_alias_1 }
629
+ export { GenerateWorkflowDefinitionInputSchema as GenerateWorkflowDefinitionInputSchema_alias_2 }
736
630
 
737
631
  declare const generateWorkflowDefinitionWorkflow: WorkflowFn<GenerateWorkflowDefinitionInput, WorkflowFile, AgentToolRegistry>;
738
632
  export { generateWorkflowDefinitionWorkflow }
739
633
  export { generateWorkflowDefinitionWorkflow as generateWorkflowDefinitionWorkflow_alias_1 }
634
+ export { generateWorkflowDefinitionWorkflow as generateWorkflowDefinitionWorkflow_alias_2 }
740
635
 
741
636
  declare type GetTodoItemOutput = TodoItem & {
742
637
  subItems: {
@@ -756,33 +651,21 @@ export declare const handler_alias_10: ToolHandler<typeof toolInfo_alias_10, Fil
756
651
 
757
652
  export declare const handler_alias_11: ToolHandler<typeof toolInfo_alias_11, FilesystemProvider>;
758
653
 
759
- export declare const handler_alias_12: ToolHandler<typeof toolInfo_alias_12, FilesystemProvider>;
760
-
761
- export declare const handler_alias_13: ToolHandler<typeof toolInfo_alias_13, WebProvider>;
762
-
763
- export declare const handler_alias_14: ToolHandler<typeof toolInfo_alias_14, FilesystemProvider>;
764
-
765
- export declare const handler_alias_15: ToolHandler<typeof toolInfo_alias_15, MemoryProvider>;
766
-
767
- export declare const handler_alias_16: ToolHandler<typeof toolInfo_alias_16, TodoProvider>;
768
-
769
- export declare const handler_alias_17: ToolHandler<typeof toolInfo_alias_17, FilesystemProvider>;
770
-
771
654
  export declare const handler_alias_2: ToolHandler<typeof toolInfo_alias_2, WebProvider>;
772
655
 
773
- 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>;
774
657
 
775
658
  export declare const handler_alias_4: ToolHandler<typeof toolInfo_alias_4, FilesystemProvider>;
776
659
 
777
- 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>;
778
661
 
779
- 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>;
780
663
 
781
664
  export declare const handler_alias_7: ToolHandler<typeof toolInfo_alias_7, FilesystemProvider>;
782
665
 
783
666
  export declare const handler_alias_8: ToolHandler<typeof toolInfo_alias_8, FilesystemProvider>;
784
667
 
785
- 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>;
786
669
 
787
670
  declare type InteractionProvider = {
788
671
  askFollowupQuestion?: (question: string, options: string[]) => Promise<string>;
@@ -1015,6 +898,7 @@ export { ModelInfo as ModelInfo_alias_1 }
1015
898
  declare function parseDynamicWorkflowDefinition(source: string): DynamicWorkflowParseResult;
1016
899
  export { parseDynamicWorkflowDefinition }
1017
900
  export { parseDynamicWorkflowDefinition as parseDynamicWorkflowDefinition_alias_1 }
901
+ export { parseDynamicWorkflowDefinition as parseDynamicWorkflowDefinition_alias_2 }
1018
902
 
1019
903
  declare const parseJsonFromMarkdown: (markdown: string) => ParseOutputResult<any>;
1020
904
  export { parseJsonFromMarkdown }
@@ -1037,10 +921,28 @@ declare const providerModelSchema: z.ZodObject<{
1037
921
  model: z.ZodOptional<z.ZodString>;
1038
922
  parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1039
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]>>;
1040
935
  }, z.core.$strip>;
1041
936
  export { providerModelSchema }
1042
937
  export { providerModelSchema as providerModelSchema_alias_1 }
1043
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
+
1044
946
  declare const replaceInFile_2: (fileContent: string, diff: string) => ReplaceResult;
1045
947
  export { replaceInFile_2 as replaceInFileHelper }
1046
948
  export { replaceInFile_2 as replaceInFile_alias_2 }
@@ -1080,6 +982,13 @@ declare const ruleSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1080
982
  export { ruleSchema }
1081
983
  export { ruleSchema as ruleSchema_alias_1 }
1082
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
+
1083
992
  declare type RunWorkflowTool = {
1084
993
  input: {
1085
994
  workflowId: string;
@@ -1089,6 +998,7 @@ declare type RunWorkflowTool = {
1089
998
  };
1090
999
  export { RunWorkflowTool }
1091
1000
  export { RunWorkflowTool as RunWorkflowTool_alias_1 }
1001
+ export { RunWorkflowTool as RunWorkflowTool_alias_2 }
1092
1002
 
1093
1003
  declare interface StepFn {
1094
1004
  <T>(name: string, fn: () => Promise<T>): Promise<T>;
@@ -1205,7 +1115,7 @@ export { TaskEventText as TaskEventText_alias_2 }
1205
1115
  declare interface TaskEventToolError extends TaskEventBase {
1206
1116
  kind: TaskEventKind.ToolError;
1207
1117
  tool: string;
1208
- error: ToolResponseError | ToolResponseResult;
1118
+ error: ToolResponseResult;
1209
1119
  }
1210
1120
  export { TaskEventToolError }
1211
1121
  export { TaskEventToolError as TaskEventToolError_alias_1 }
@@ -1284,10 +1194,34 @@ export { toJsonModelMessage }
1284
1194
  export { toJsonModelMessage as toJsonModelMessage_alias_1 }
1285
1195
  export { toJsonModelMessage as toJsonModelMessage_alias_2 }
1286
1196
 
1287
- declare type ToolHandler<_T, P> = (provider: P, args: Partial<Record<string, ToolParameterValue>>) => Promise<AgentToolResponse>;
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
+
1213
+ declare type ToolHandler<_T, P> = (provider: P, args: Partial<Record<string, ToolParameterValue>>) => Promise<ToolResponse>;
1288
1214
  export { ToolHandler }
1289
1215
  export { ToolHandler as ToolHandler_alias_1 }
1290
1216
 
1217
+ declare type ToolInfo = {
1218
+ name: string;
1219
+ description: string;
1220
+ parameters: z.ZodObject<any>;
1221
+ };
1222
+ export { ToolInfo }
1223
+ export { ToolInfo as ToolInfo_alias_1 }
1224
+
1291
1225
  export declare const toolInfo: {
1292
1226
  readonly name: "askFollowupQuestion";
1293
1227
  readonly 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.";
@@ -1309,40 +1243,6 @@ export declare const toolInfo_alias_1: {
1309
1243
  };
1310
1244
 
1311
1245
  export declare const toolInfo_alias_10: {
1312
- readonly name: "removeFile";
1313
- readonly description: "Request to remove a file at the specified path.";
1314
- readonly parameters: z.ZodObject<{
1315
- path: z.ZodString;
1316
- }, z.core.$strip>;
1317
- };
1318
-
1319
- export declare const toolInfo_alias_11: {
1320
- readonly name: "renameFile";
1321
- readonly description: "Request to rename a file from source path to target path.";
1322
- readonly parameters: z.ZodObject<{
1323
- source_path: z.ZodString;
1324
- target_path: z.ZodString;
1325
- }, z.core.$strip>;
1326
- };
1327
-
1328
- export declare const toolInfo_alias_12: {
1329
- readonly name: "replaceInFile";
1330
- 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.";
1331
- readonly parameters: z.ZodObject<{
1332
- path: z.ZodString;
1333
- diff: z.ZodString;
1334
- }, z.core.$strip>;
1335
- };
1336
-
1337
- export declare const toolInfo_alias_13: {
1338
- readonly name: "search";
1339
- 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.";
1340
- readonly parameters: z.ZodObject<{
1341
- query: z.ZodString;
1342
- }, z.core.$strip>;
1343
- };
1344
-
1345
- export declare const toolInfo_alias_14: {
1346
1246
  readonly name: "searchFiles";
1347
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.";
1348
1248
  readonly parameters: z.ZodObject<{
@@ -1352,41 +1252,7 @@ export declare const toolInfo_alias_14: {
1352
1252
  }, z.core.$strip>;
1353
1253
  };
1354
1254
 
1355
- export declare const toolInfo_alias_15: {
1356
- readonly name: "updateMemory";
1357
- 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.";
1358
- readonly parameters: z.ZodObject<{
1359
- operation: z.ZodEnum<{
1360
- append: "append";
1361
- replace: "replace";
1362
- remove: "remove";
1363
- }>;
1364
- topic: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1365
- content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1366
- }, z.core.$strip>;
1367
- };
1368
-
1369
- export declare const toolInfo_alias_16: {
1370
- readonly name: "updateTodoItem";
1371
- readonly description: "Add or update a to-do item.";
1372
- readonly parameters: ZodObject< {
1373
- operation: ZodEnum< {
1374
- add: "add";
1375
- update: "update";
1376
- }>;
1377
- id: ZodOptional<ZodNullable<ZodString>>;
1378
- parentId: ZodOptional<ZodNullable<ZodString>>;
1379
- title: ZodOptional<ZodNullable<ZodString>>;
1380
- description: ZodOptional<ZodNullable<ZodString>>;
1381
- status: ZodOptional<ZodNullable<ZodEnum< {
1382
- open: "open";
1383
- completed: "completed";
1384
- closed: "closed";
1385
- }>>>;
1386
- }, $strip>;
1387
- };
1388
-
1389
- export declare const toolInfo_alias_17: {
1255
+ export declare const toolInfo_alias_11: {
1390
1256
  readonly name: "writeToFile";
1391
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.";
1392
1258
  readonly parameters: z.ZodObject<{
@@ -1404,14 +1270,6 @@ export declare const toolInfo_alias_2: {
1404
1270
  };
1405
1271
 
1406
1272
  export declare const toolInfo_alias_3: {
1407
- readonly name: "getTodoItem";
1408
- readonly description: "Get a to-do item by its ID.";
1409
- readonly parameters: z.ZodObject<{
1410
- id: z.ZodString;
1411
- }, z.core.$strip>;
1412
- };
1413
-
1414
- export declare const toolInfo_alias_4: {
1415
1273
  readonly name: "listFiles";
1416
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.";
1417
1275
  readonly parameters: z.ZodObject<{
@@ -1422,47 +1280,54 @@ export declare const toolInfo_alias_4: {
1422
1280
  }, z.core.$strip>;
1423
1281
  };
1424
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
+
1425
1291
  export declare const toolInfo_alias_5: {
1426
- readonly name: "listMemoryTopics";
1427
- readonly description: "Lists all topics in memory. Use this to see what information has been stored and which topics are available to read from.";
1428
- 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>;
1429
1298
  };
1430
1299
 
1431
1300
  export declare const toolInfo_alias_6: {
1432
- readonly name: "listTodoItems";
1433
- 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.";
1434
1303
  readonly parameters: z.ZodObject<{
1435
- id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1436
- status: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
1437
- open: "open";
1438
- completed: "completed";
1439
- closed: "closed";
1440
- }>>>;
1304
+ path: z.ZodString;
1441
1305
  }, z.core.$strip>;
1442
1306
  };
1443
1307
 
1444
1308
  export declare const toolInfo_alias_7: {
1445
- readonly name: "readBinaryFile";
1446
- 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.";
1447
1311
  readonly parameters: z.ZodObject<{
1448
- url: z.ZodString;
1312
+ source_path: z.ZodString;
1313
+ target_path: z.ZodString;
1449
1314
  }, z.core.$strip>;
1450
1315
  };
1451
1316
 
1452
1317
  export declare const toolInfo_alias_8: {
1453
- readonly name: "readFile";
1454
- 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.";
1455
1320
  readonly parameters: z.ZodObject<{
1456
- path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
1457
- includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>>;
1321
+ path: z.ZodString;
1322
+ diff: z.ZodString;
1458
1323
  }, z.core.$strip>;
1459
1324
  };
1460
1325
 
1461
1326
  export declare const toolInfo_alias_9: {
1462
- readonly name: "readMemory";
1463
- 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.";
1464
1329
  readonly parameters: z.ZodObject<{
1465
- topic: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1330
+ query: z.ZodString;
1466
1331
  }, z.core.$strip>;
1467
1332
  };
1468
1333
 
@@ -1493,27 +1358,12 @@ export { ToolRegistry }
1493
1358
  export { ToolRegistry as ToolRegistry_alias_1 }
1494
1359
  export { ToolRegistry as ToolRegistry_alias_2 }
1495
1360
 
1496
- declare type ToolResponseError = {
1497
- type: ToolResponseType.Error;
1498
- message: ToolResponseResult;
1499
- };
1500
- export { ToolResponseError }
1501
- export { ToolResponseError as ToolResponseError_alias_1 }
1502
-
1503
- declare type ToolResponseExit = {
1504
- type: ToolResponseType.Exit;
1505
- message: string;
1506
- object?: any;
1507
- };
1508
- export { ToolResponseExit }
1509
- export { ToolResponseExit as ToolResponseExit_alias_1 }
1510
-
1511
- declare type ToolResponseReply = {
1512
- type: ToolResponseType.Reply;
1361
+ declare type ToolResponse = {
1362
+ success: boolean;
1513
1363
  message: ToolResponseResult;
1514
1364
  };
1515
- export { ToolResponseReply }
1516
- export { ToolResponseReply as ToolResponseReply_alias_1 }
1365
+ export { ToolResponse }
1366
+ export { ToolResponse as ToolResponse_alias_1 }
1517
1367
 
1518
1368
  declare type ToolResponseResult = {
1519
1369
  type: 'text';
@@ -1546,14 +1396,6 @@ declare type ToolResponseResultMedia = {
1546
1396
  export { ToolResponseResultMedia }
1547
1397
  export { ToolResponseResultMedia as ToolResponseResultMedia_alias_1 }
1548
1398
 
1549
- declare enum ToolResponseType {
1550
- Reply = "Reply",
1551
- Exit = "Exit",
1552
- Error = "Error"
1553
- }
1554
- export { ToolResponseType }
1555
- export { ToolResponseType as ToolResponseType_alias_1 }
1556
-
1557
1399
  declare type ToolSignature<I, O> = {
1558
1400
  input: I;
1559
1401
  output: O;
@@ -1660,6 +1502,22 @@ declare class UsageMeter {
1660
1502
  export { UsageMeter }
1661
1503
  export { UsageMeter as UsageMeter_alias_1 }
1662
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
+
1663
1521
  declare type WebProvider = {
1664
1522
  fetchUrl?: (url: string) => Promise<string>;
1665
1523
  search?: (query: string) => Promise<string>;
@@ -1680,6 +1538,7 @@ export { WorkflowContext as WorkflowContext_alias_2 }
1680
1538
  declare type WorkflowDefinition = z.infer<typeof WorkflowDefinitionSchema>;
1681
1539
  export { WorkflowDefinition }
1682
1540
  export { WorkflowDefinition as WorkflowDefinition_alias_1 }
1541
+ export { WorkflowDefinition as WorkflowDefinition_alias_2 }
1683
1542
 
1684
1543
  declare const WorkflowDefinitionSchema: z.ZodObject<{
1685
1544
  task: z.ZodString;
@@ -1702,10 +1561,12 @@ declare const WorkflowDefinitionSchema: z.ZodObject<{
1702
1561
  }, z.core.$strip>;
1703
1562
  export { WorkflowDefinitionSchema }
1704
1563
  export { WorkflowDefinitionSchema as WorkflowDefinitionSchema_alias_1 }
1564
+ export { WorkflowDefinitionSchema as WorkflowDefinitionSchema_alias_2 }
1705
1565
 
1706
1566
  declare type WorkflowFile = z.infer<typeof WorkflowFileSchema>;
1707
1567
  export { WorkflowFile }
1708
1568
  export { WorkflowFile as WorkflowFile_alias_1 }
1569
+ export { WorkflowFile as WorkflowFile_alias_2 }
1709
1570
 
1710
1571
  declare const WorkflowFileSchema: z.ZodObject<{
1711
1572
  workflows: z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -1730,6 +1591,7 @@ declare const WorkflowFileSchema: z.ZodObject<{
1730
1591
  }, z.core.$strip>;
1731
1592
  export { WorkflowFileSchema }
1732
1593
  export { WorkflowFileSchema as WorkflowFileSchema_alias_1 }
1594
+ export { WorkflowFileSchema as WorkflowFileSchema_alias_2 }
1733
1595
 
1734
1596
  declare type WorkflowFn<TInput, TOutput, TTools extends ToolRegistry> = (input: TInput, context: WorkflowContext<TTools>) => Promise<TOutput>;
1735
1597
  export { WorkflowFn }
@@ -1739,6 +1601,7 @@ export { WorkflowFn as WorkflowFn_alias_2 }
1739
1601
  declare type WorkflowInputDefinition = z.infer<typeof WorkflowInputDefinitionSchema>;
1740
1602
  export { WorkflowInputDefinition }
1741
1603
  export { WorkflowInputDefinition as WorkflowInputDefinition_alias_1 }
1604
+ export { WorkflowInputDefinition as WorkflowInputDefinition_alias_2 }
1742
1605
 
1743
1606
  declare const WorkflowInputDefinitionSchema: z.ZodObject<{
1744
1607
  id: z.ZodString;
@@ -1747,10 +1610,12 @@ declare const WorkflowInputDefinitionSchema: z.ZodObject<{
1747
1610
  }, z.core.$strip>;
1748
1611
  export { WorkflowInputDefinitionSchema }
1749
1612
  export { WorkflowInputDefinitionSchema as WorkflowInputDefinitionSchema_alias_1 }
1613
+ export { WorkflowInputDefinitionSchema as WorkflowInputDefinitionSchema_alias_2 }
1750
1614
 
1751
1615
  declare type WorkflowStepDefinition = z.infer<typeof WorkflowStepDefinitionSchema>;
1752
1616
  export { WorkflowStepDefinition }
1753
1617
  export { WorkflowStepDefinition as WorkflowStepDefinition_alias_1 }
1618
+ export { WorkflowStepDefinition as WorkflowStepDefinition_alias_2 }
1754
1619
 
1755
1620
  declare const WorkflowStepDefinitionSchema: z.ZodObject<{
1756
1621
  id: z.ZodString;
@@ -1764,6 +1629,7 @@ declare const WorkflowStepDefinitionSchema: z.ZodObject<{
1764
1629
  }, z.core.$strip>;
1765
1630
  export { WorkflowStepDefinitionSchema }
1766
1631
  export { WorkflowStepDefinitionSchema as WorkflowStepDefinitionSchema_alias_1 }
1632
+ export { WorkflowStepDefinitionSchema as WorkflowStepDefinitionSchema_alias_2 }
1767
1633
 
1768
1634
  declare type WorkflowTools<TTools extends ToolRegistry> = {
1769
1635
  [K in keyof TTools]: (input: TTools[K]['input']) => Promise<TTools[K]['output']>;
@@ -1772,4 +1638,12 @@ export { WorkflowTools }
1772
1638
  export { WorkflowTools as WorkflowTools_alias_1 }
1773
1639
  export { WorkflowTools as WorkflowTools_alias_2 }
1774
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
+
1775
1649
  export { }