@polka-codes/core 0.9.85 → 0.9.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_tsup-dts-rollup.d.ts +161 -2
- package/dist/index.d.ts +5 -0
- package/dist/index.js +104 -13
- package/package.json +1 -1
|
@@ -122,6 +122,7 @@ declare const configSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
|
122
122
|
project: z.ZodOptional<z.ZodString>;
|
|
123
123
|
keyFile: z.ZodOptional<z.ZodString>;
|
|
124
124
|
baseUrl: z.ZodOptional<z.ZodString>;
|
|
125
|
+
name: z.ZodOptional<z.ZodString>;
|
|
125
126
|
}, z.core.$strip>>>;
|
|
126
127
|
defaultProvider: z.ZodOptional<z.ZodString>;
|
|
127
128
|
defaultModel: z.ZodOptional<z.ZodString>;
|
|
@@ -211,6 +212,59 @@ declare const configSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
|
211
212
|
branch: z.ZodOptional<z.ZodString>;
|
|
212
213
|
}, z.core.$strict>]>>>, z.ZodString]>>;
|
|
213
214
|
excludeFiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
215
|
+
agent: z.ZodOptional<z.ZodObject<{
|
|
216
|
+
preset: z.ZodOptional<z.ZodString>;
|
|
217
|
+
strategy: z.ZodOptional<z.ZodEnum<{
|
|
218
|
+
"goal-directed": "goal-directed";
|
|
219
|
+
"continuous-improvement": "continuous-improvement";
|
|
220
|
+
}>>;
|
|
221
|
+
continueOnCompletion: z.ZodOptional<z.ZodBoolean>;
|
|
222
|
+
maxIterations: z.ZodOptional<z.ZodNumber>;
|
|
223
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
224
|
+
requireApprovalFor: z.ZodOptional<z.ZodEnum<{
|
|
225
|
+
none: "none";
|
|
226
|
+
destructive: "destructive";
|
|
227
|
+
commits: "commits";
|
|
228
|
+
all: "all";
|
|
229
|
+
}>>;
|
|
230
|
+
autoApproveSafeTasks: z.ZodOptional<z.ZodBoolean>;
|
|
231
|
+
maxAutoApprovalCost: z.ZodOptional<z.ZodNumber>;
|
|
232
|
+
pauseOnError: z.ZodOptional<z.ZodBoolean>;
|
|
233
|
+
workingBranch: z.ZodOptional<z.ZodString>;
|
|
234
|
+
destructiveOperations: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
235
|
+
maxConcurrency: z.ZodOptional<z.ZodNumber>;
|
|
236
|
+
autoSaveInterval: z.ZodOptional<z.ZodNumber>;
|
|
237
|
+
workingDir: z.ZodOptional<z.ZodString>;
|
|
238
|
+
continuousImprovement: z.ZodOptional<z.ZodObject<{
|
|
239
|
+
sleepTimeOnNoTasks: z.ZodOptional<z.ZodNumber>;
|
|
240
|
+
sleepTimeBetweenTasks: z.ZodOptional<z.ZodNumber>;
|
|
241
|
+
maxCycles: z.ZodOptional<z.ZodNumber>;
|
|
242
|
+
}, z.core.$strict>>;
|
|
243
|
+
discovery: z.ZodOptional<z.ZodObject<{
|
|
244
|
+
enabledStrategies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
245
|
+
cacheTime: z.ZodOptional<z.ZodNumber>;
|
|
246
|
+
checkChanges: z.ZodOptional<z.ZodBoolean>;
|
|
247
|
+
}, z.core.$strict>>;
|
|
248
|
+
safety: z.ZodOptional<z.ZodObject<{
|
|
249
|
+
enabledChecks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
250
|
+
blockDestructive: z.ZodOptional<z.ZodBoolean>;
|
|
251
|
+
maxFileSize: z.ZodOptional<z.ZodNumber>;
|
|
252
|
+
}, z.core.$strict>>;
|
|
253
|
+
healthCheck: z.ZodOptional<z.ZodObject<{
|
|
254
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
255
|
+
interval: z.ZodOptional<z.ZodNumber>;
|
|
256
|
+
}, z.core.$strict>>;
|
|
257
|
+
approval: z.ZodOptional<z.ZodObject<{
|
|
258
|
+
level: z.ZodOptional<z.ZodEnum<{
|
|
259
|
+
none: "none";
|
|
260
|
+
destructive: "destructive";
|
|
261
|
+
commits: "commits";
|
|
262
|
+
all: "all";
|
|
263
|
+
}>>;
|
|
264
|
+
autoApproveSafeTasks: z.ZodOptional<z.ZodBoolean>;
|
|
265
|
+
maxAutoApprovalCost: z.ZodOptional<z.ZodNumber>;
|
|
266
|
+
}, z.core.$strict>>;
|
|
267
|
+
}, z.core.$strict>>;
|
|
214
268
|
}, z.core.$strict>>>;
|
|
215
269
|
export { configSchema }
|
|
216
270
|
export { configSchema as configSchema_alias_1 }
|
|
@@ -232,6 +286,18 @@ export { ContinueStepSchema }
|
|
|
232
286
|
export { ContinueStepSchema as ContinueStepSchema_alias_1 }
|
|
233
287
|
export { ContinueStepSchema as ContinueStepSchema_alias_2 }
|
|
234
288
|
|
|
289
|
+
/**
|
|
290
|
+
* Convert a JSON Schema to a Zod schema
|
|
291
|
+
* Supports a subset of JSON SchemaDraft 7
|
|
292
|
+
*
|
|
293
|
+
* This is exported to allow reuse in other parts of the codebase that need to
|
|
294
|
+
* convert JSON schemas to Zod schemas (e.g., MCP server tool schema conversion).
|
|
295
|
+
*/
|
|
296
|
+
declare function convertJsonSchemaToZod(schema: JsonSchema): z.ZodTypeAny;
|
|
297
|
+
export { convertJsonSchemaToZod }
|
|
298
|
+
export { convertJsonSchemaToZod as convertJsonSchemaToZod_alias_1 }
|
|
299
|
+
export { convertJsonSchemaToZod as convertJsonSchemaToZod_alias_2 }
|
|
300
|
+
|
|
235
301
|
declare function createContext<TTools extends ToolRegistry>(tools: WorkflowTools<TTools>, stepFn?: StepFn, logger?: Logger): WorkflowContext<TTools>;
|
|
236
302
|
export { createContext }
|
|
237
303
|
export { createContext as createContext_alias_1 }
|
|
@@ -242,15 +308,86 @@ export { createDynamicWorkflow }
|
|
|
242
308
|
export { createDynamicWorkflow as createDynamicWorkflow_alias_1 }
|
|
243
309
|
export { createDynamicWorkflow as createDynamicWorkflow_alias_2 }
|
|
244
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Create an error tool response
|
|
313
|
+
*
|
|
314
|
+
* @param message - The error message
|
|
315
|
+
* @returns An error tool response object
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```ts
|
|
319
|
+
* return createErrorResponse('Failed to read file')
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
declare function createErrorResponse(message: string): ToolResponse;
|
|
323
|
+
export { createErrorResponse }
|
|
324
|
+
export { createErrorResponse as createErrorResponse_alias_1 }
|
|
325
|
+
export { createErrorResponse as createErrorResponse_alias_2 }
|
|
326
|
+
|
|
245
327
|
/**
|
|
246
328
|
* Create a file content XML element
|
|
247
329
|
*/
|
|
248
330
|
export declare function createFileElement(tagName: string, path: string, content?: string, attrs?: Record<string, string>): string;
|
|
249
331
|
|
|
250
332
|
/**
|
|
251
|
-
* Create a
|
|
333
|
+
* Create a provider capability error response
|
|
334
|
+
* Use this when a required provider capability is not available
|
|
335
|
+
*
|
|
336
|
+
* @param capability - The capability that's missing (e.g., "read file", "write file")
|
|
337
|
+
* @returns An error response indicating the missing capability
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```ts
|
|
341
|
+
* if (!provider.readFile) {
|
|
342
|
+
* return createProviderErrorResponse('read file')
|
|
343
|
+
* }
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
declare function createProviderErrorResponse(capability: string): ToolResponse;
|
|
347
|
+
export { createProviderErrorResponse as createProviderError }
|
|
348
|
+
export { createProviderErrorResponse }
|
|
349
|
+
export { createProviderErrorResponse as createProviderErrorResponse_alias_1 }
|
|
350
|
+
export { createProviderErrorResponse as createProviderErrorResponse_alias_2 }
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Create a successful tool response
|
|
354
|
+
*
|
|
355
|
+
* @param value - The response value (string or JSON string)
|
|
356
|
+
* @param type - Response type ('text' or 'json')
|
|
357
|
+
* @returns A successful tool response object
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```ts
|
|
361
|
+
* return createSuccessResponse('File content loaded')
|
|
362
|
+
* return createSuccessResponse(JSON.stringify(data), 'json')
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
declare function createSuccessResponse(value: string, type?: 'text' | 'json'): ToolResponse;
|
|
366
|
+
export { createSuccessResponse }
|
|
367
|
+
export { createSuccessResponse as createSuccessResponse_alias_1 }
|
|
368
|
+
export { createSuccessResponse as createSuccessResponse_alias_2 }
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Create a validation error response
|
|
372
|
+
* Use this when input validation fails
|
|
373
|
+
*
|
|
374
|
+
* @param errors - The validation error details
|
|
375
|
+
* @returns An error response with validation details
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```ts
|
|
379
|
+
* const result = schema.safeParse(input)
|
|
380
|
+
* if (!result.success) {
|
|
381
|
+
* return createValidationErrorResponse(result.error)
|
|
382
|
+
* }
|
|
383
|
+
* ```
|
|
252
384
|
*/
|
|
253
|
-
|
|
385
|
+
declare function createValidationErrorResponse(errors: {
|
|
386
|
+
message: string;
|
|
387
|
+
}): ToolResponse;
|
|
388
|
+
export { createValidationErrorResponse }
|
|
389
|
+
export { createValidationErrorResponse as createValidationErrorResponse_alias_1 }
|
|
390
|
+
export { createValidationErrorResponse as createValidationErrorResponse_alias_2 }
|
|
254
391
|
|
|
255
392
|
declare const _default: {
|
|
256
393
|
handler: ToolHandler<{
|
|
@@ -884,6 +1021,27 @@ export { JsonResponseMessage }
|
|
|
884
1021
|
export { JsonResponseMessage as JsonResponseMessage_alias_1 }
|
|
885
1022
|
export { JsonResponseMessage as JsonResponseMessage_alias_2 }
|
|
886
1023
|
|
|
1024
|
+
declare interface JsonSchema {
|
|
1025
|
+
type?: JsonSchemaType | JsonSchemaType[];
|
|
1026
|
+
enum?: JsonSchemaEnum;
|
|
1027
|
+
properties?: Record<string, JsonSchema>;
|
|
1028
|
+
required?: string[];
|
|
1029
|
+
items?: JsonSchema;
|
|
1030
|
+
additionalProperties?: boolean | JsonSchema;
|
|
1031
|
+
description?: string;
|
|
1032
|
+
[key: string]: unknown;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* JSON Schema enum values - can be string, number, or boolean
|
|
1037
|
+
*/
|
|
1038
|
+
declare type JsonSchemaEnum = (string | number | boolean)[];
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* JSON Schema type to Zod type mapping
|
|
1042
|
+
*/
|
|
1043
|
+
declare type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
1044
|
+
|
|
887
1045
|
declare interface JsonToolCallPart {
|
|
888
1046
|
type: 'tool-call';
|
|
889
1047
|
/**
|
|
@@ -1231,6 +1389,7 @@ declare const providerConfigSchema: z.ZodObject<{
|
|
|
1231
1389
|
project: z.ZodOptional<z.ZodString>;
|
|
1232
1390
|
keyFile: z.ZodOptional<z.ZodString>;
|
|
1233
1391
|
baseUrl: z.ZodOptional<z.ZodString>;
|
|
1392
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1234
1393
|
}, z.core.$strip>;
|
|
1235
1394
|
export { providerConfigSchema }
|
|
1236
1395
|
export { providerConfigSchema as providerConfigSchema_alias_1 }
|
package/dist/index.d.ts
CHANGED
|
@@ -72,6 +72,10 @@ export { readFile } from './_tsup-dts-rollup.js';
|
|
|
72
72
|
export { removeFile } from './_tsup-dts-rollup.js';
|
|
73
73
|
export { renameFile } from './_tsup-dts-rollup.js';
|
|
74
74
|
export { replaceInFile } from './_tsup-dts-rollup.js';
|
|
75
|
+
export { createErrorResponse } from './_tsup-dts-rollup.js';
|
|
76
|
+
export { createProviderErrorResponse } from './_tsup-dts-rollup.js';
|
|
77
|
+
export { createSuccessResponse } from './_tsup-dts-rollup.js';
|
|
78
|
+
export { createValidationErrorResponse } from './_tsup-dts-rollup.js';
|
|
75
79
|
export { search } from './_tsup-dts-rollup.js';
|
|
76
80
|
export { searchFiles } from './_tsup-dts-rollup.js';
|
|
77
81
|
export { writeToFile } from './_tsup-dts-rollup.js';
|
|
@@ -97,6 +101,7 @@ export { UsageMeter_alias_1 as UsageMeter } from './_tsup-dts-rollup.js';
|
|
|
97
101
|
export { AgentWorkflowInput } from './_tsup-dts-rollup.js';
|
|
98
102
|
export { AgentToolRegistry } from './_tsup-dts-rollup.js';
|
|
99
103
|
export { agentWorkflow } from './_tsup-dts-rollup.js';
|
|
104
|
+
export { convertJsonSchemaToZod } from './_tsup-dts-rollup.js';
|
|
100
105
|
export { validateWorkflowFile } from './_tsup-dts-rollup.js';
|
|
101
106
|
export { parseDynamicWorkflowDefinition } from './_tsup-dts-rollup.js';
|
|
102
107
|
export { createDynamicWorkflow } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -146,7 +146,9 @@ var providerConfigSchema = z.object({
|
|
|
146
146
|
location: z.string().optional(),
|
|
147
147
|
project: z.string().optional(),
|
|
148
148
|
keyFile: z.string().optional(),
|
|
149
|
-
baseUrl: z.string().optional()
|
|
149
|
+
baseUrl: z.string().optional(),
|
|
150
|
+
name: z.string().optional()
|
|
151
|
+
// For OpenAI-compatible providers
|
|
150
152
|
});
|
|
151
153
|
var providerModelSchema = z.object({
|
|
152
154
|
provider: z.string().optional(),
|
|
@@ -202,6 +204,51 @@ var mcpServerConfigSchema = z.object({
|
|
|
202
204
|
)
|
|
203
205
|
).optional()
|
|
204
206
|
}).strict();
|
|
207
|
+
var agentContinuousImprovementSchema = z.object({
|
|
208
|
+
sleepTimeOnNoTasks: z.number().int().optional(),
|
|
209
|
+
sleepTimeBetweenTasks: z.number().int().optional(),
|
|
210
|
+
maxCycles: z.number().int().optional()
|
|
211
|
+
}).strict().optional();
|
|
212
|
+
var agentDiscoverySchema = z.object({
|
|
213
|
+
enabledStrategies: z.array(z.string()).optional(),
|
|
214
|
+
cacheTime: z.number().int().optional(),
|
|
215
|
+
checkChanges: z.boolean().optional()
|
|
216
|
+
}).strict().optional();
|
|
217
|
+
var agentSafetySchema = z.object({
|
|
218
|
+
enabledChecks: z.array(z.string()).optional(),
|
|
219
|
+
blockDestructive: z.boolean().optional(),
|
|
220
|
+
maxFileSize: z.number().int().optional()
|
|
221
|
+
}).strict().optional();
|
|
222
|
+
var agentHealthCheckSchema = z.object({
|
|
223
|
+
enabled: z.boolean().optional(),
|
|
224
|
+
interval: z.number().int().optional()
|
|
225
|
+
}).strict().optional();
|
|
226
|
+
var agentApprovalSchema = z.object({
|
|
227
|
+
level: z.enum(["none", "destructive", "commits", "all"]).optional(),
|
|
228
|
+
autoApproveSafeTasks: z.boolean().optional(),
|
|
229
|
+
maxAutoApprovalCost: z.number().optional()
|
|
230
|
+
}).strict().optional();
|
|
231
|
+
var agentSchema = z.object({
|
|
232
|
+
preset: z.string().optional(),
|
|
233
|
+
strategy: z.enum(["goal-directed", "continuous-improvement"]).optional(),
|
|
234
|
+
continueOnCompletion: z.boolean().optional(),
|
|
235
|
+
maxIterations: z.number().int().optional(),
|
|
236
|
+
timeout: z.number().int().optional(),
|
|
237
|
+
requireApprovalFor: z.enum(["none", "destructive", "commits", "all"]).optional(),
|
|
238
|
+
autoApproveSafeTasks: z.boolean().optional(),
|
|
239
|
+
maxAutoApprovalCost: z.number().optional(),
|
|
240
|
+
pauseOnError: z.boolean().optional(),
|
|
241
|
+
workingBranch: z.string().optional(),
|
|
242
|
+
destructiveOperations: z.array(z.string()).optional(),
|
|
243
|
+
maxConcurrency: z.number().int().optional(),
|
|
244
|
+
autoSaveInterval: z.number().int().optional(),
|
|
245
|
+
workingDir: z.string().optional(),
|
|
246
|
+
continuousImprovement: agentContinuousImprovementSchema,
|
|
247
|
+
discovery: agentDiscoverySchema,
|
|
248
|
+
safety: agentSafetySchema,
|
|
249
|
+
healthCheck: agentHealthCheckSchema,
|
|
250
|
+
approval: agentApprovalSchema
|
|
251
|
+
}).strict().optional();
|
|
205
252
|
var configSchema = z.object({
|
|
206
253
|
prices: z.record(
|
|
207
254
|
z.string(),
|
|
@@ -233,7 +280,8 @@ var configSchema = z.object({
|
|
|
233
280
|
}).optional(),
|
|
234
281
|
mcpServers: z.record(z.string(), mcpServerConfigSchema).optional(),
|
|
235
282
|
rules: z.array(ruleSchema).optional().or(z.string()).optional(),
|
|
236
|
-
excludeFiles: z.array(z.string()).optional()
|
|
283
|
+
excludeFiles: z.array(z.string()).optional(),
|
|
284
|
+
agent: agentSchema
|
|
237
285
|
}).strict().nullish();
|
|
238
286
|
|
|
239
287
|
// src/fs/node-provider.ts
|
|
@@ -999,16 +1047,39 @@ var askFollowupQuestion_default = {
|
|
|
999
1047
|
// src/tools/executeCommand.ts
|
|
1000
1048
|
import { z as z7 } from "zod";
|
|
1001
1049
|
|
|
1002
|
-
// src/tools/
|
|
1003
|
-
function
|
|
1050
|
+
// src/tools/response-builders.ts
|
|
1051
|
+
function createSuccessResponse(value, type = "text") {
|
|
1052
|
+
return {
|
|
1053
|
+
success: true,
|
|
1054
|
+
message: { type, value }
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
function createErrorResponse(message) {
|
|
1058
|
+
return {
|
|
1059
|
+
success: false,
|
|
1060
|
+
message: { type: "error-text", value: message }
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
function createProviderErrorResponse(capability) {
|
|
1004
1064
|
return {
|
|
1005
1065
|
success: false,
|
|
1006
1066
|
message: {
|
|
1007
1067
|
type: "error-text",
|
|
1008
|
-
value: `Not possible to ${
|
|
1068
|
+
value: `Not possible to ${capability}.`
|
|
1009
1069
|
}
|
|
1010
1070
|
};
|
|
1011
1071
|
}
|
|
1072
|
+
function createValidationErrorResponse(errors) {
|
|
1073
|
+
return {
|
|
1074
|
+
success: false,
|
|
1075
|
+
message: {
|
|
1076
|
+
type: "error-text",
|
|
1077
|
+
value: `Validation failed: ${errors.message}`
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
// src/tools/utils.ts
|
|
1012
1083
|
function preprocessBoolean(val) {
|
|
1013
1084
|
return typeof val === "string" ? val.toLowerCase() === "true" : val;
|
|
1014
1085
|
}
|
|
@@ -1048,7 +1119,7 @@ var toolInfo2 = {
|
|
|
1048
1119
|
};
|
|
1049
1120
|
var handler2 = async (provider, args) => {
|
|
1050
1121
|
if (!provider.executeCommand) {
|
|
1051
|
-
return
|
|
1122
|
+
return createProviderErrorResponse("execute command. Abort");
|
|
1052
1123
|
}
|
|
1053
1124
|
const { command, requiresApproval } = toolInfo2.parameters.parse(args);
|
|
1054
1125
|
try {
|
|
@@ -1203,7 +1274,7 @@ var toolInfo4 = {
|
|
|
1203
1274
|
};
|
|
1204
1275
|
var handler4 = async (provider, args) => {
|
|
1205
1276
|
if (!provider.listFiles) {
|
|
1206
|
-
return
|
|
1277
|
+
return createProviderErrorResponse("list files");
|
|
1207
1278
|
}
|
|
1208
1279
|
const { path, maxCount, recursive, includeIgnored } = toolInfo4.parameters.parse(args);
|
|
1209
1280
|
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
|
|
@@ -1368,7 +1439,7 @@ var toolInfo6 = {
|
|
|
1368
1439
|
};
|
|
1369
1440
|
var handler6 = async (provider, args) => {
|
|
1370
1441
|
if (!provider.readFile) {
|
|
1371
|
-
return
|
|
1442
|
+
return createProviderErrorResponse("read file");
|
|
1372
1443
|
}
|
|
1373
1444
|
const { path: paths, includeIgnored } = toolInfo6.parameters.parse(args);
|
|
1374
1445
|
const resp = [];
|
|
@@ -1413,7 +1484,7 @@ var toolInfo7 = {
|
|
|
1413
1484
|
};
|
|
1414
1485
|
var handler7 = async (provider, args) => {
|
|
1415
1486
|
if (!provider.removeFile) {
|
|
1416
|
-
return
|
|
1487
|
+
return createProviderErrorResponse("remove file");
|
|
1417
1488
|
}
|
|
1418
1489
|
const parsed = toolInfo7.parameters.safeParse(args);
|
|
1419
1490
|
if (!parsed.success) {
|
|
@@ -1980,7 +2051,7 @@ export default App;
|
|
|
1980
2051
|
};
|
|
1981
2052
|
var handler12 = async (provider, args) => {
|
|
1982
2053
|
if (!provider.writeFile) {
|
|
1983
|
-
return
|
|
2054
|
+
return createProviderErrorResponse("write file");
|
|
1984
2055
|
}
|
|
1985
2056
|
const parsed = toolInfo12.parameters.safeParse(args);
|
|
1986
2057
|
if (!parsed.success) {
|
|
@@ -2403,8 +2474,18 @@ var WorkflowFileSchema = z20.object({
|
|
|
2403
2474
|
var MAX_WHILE_LOOP_ITERATIONS = 1e3;
|
|
2404
2475
|
function convertJsonSchemaToZod(schema) {
|
|
2405
2476
|
if (schema.enum) {
|
|
2406
|
-
const enumValues = schema.enum
|
|
2407
|
-
|
|
2477
|
+
const enumValues = schema.enum;
|
|
2478
|
+
if (enumValues.length === 0) {
|
|
2479
|
+
return z21.never();
|
|
2480
|
+
}
|
|
2481
|
+
if (enumValues.every((v) => typeof v === "string")) {
|
|
2482
|
+
return z21.enum(enumValues);
|
|
2483
|
+
}
|
|
2484
|
+
const literals = enumValues.map((v) => z21.literal(v));
|
|
2485
|
+
if (literals.length === 1) {
|
|
2486
|
+
return literals[0];
|
|
2487
|
+
}
|
|
2488
|
+
return z21.union([literals[0], literals[1], ...literals.slice(2)]);
|
|
2408
2489
|
}
|
|
2409
2490
|
if (Array.isArray(schema.type)) {
|
|
2410
2491
|
const types = schema.type;
|
|
@@ -2573,8 +2654,13 @@ ${errors.map((e) => ` - ${e}`).join("\n")}`);
|
|
|
2573
2654
|
}
|
|
2574
2655
|
return validatedInput;
|
|
2575
2656
|
}
|
|
2576
|
-
function evaluateCondition(condition, input, state, allowUnsafeCodeExecution = false) {
|
|
2657
|
+
function evaluateCondition(condition, input, state, allowUnsafeCodeExecution = false, logger) {
|
|
2577
2658
|
if (allowUnsafeCodeExecution) {
|
|
2659
|
+
if (logger) {
|
|
2660
|
+
logger.warn(
|
|
2661
|
+
`[SECURITY] Executing unsafe code evaluation for condition: ${condition}. This allows arbitrary JavaScript execution and should only be used for trusted workflows.`
|
|
2662
|
+
);
|
|
2663
|
+
}
|
|
2578
2664
|
const functionBody = `
|
|
2579
2665
|
try {
|
|
2580
2666
|
return ${condition};
|
|
@@ -3466,8 +3552,13 @@ export {
|
|
|
3466
3552
|
askFollowupQuestion_default as askFollowupQuestion,
|
|
3467
3553
|
computeRateLimitBackoffSeconds,
|
|
3468
3554
|
configSchema,
|
|
3555
|
+
convertJsonSchemaToZod,
|
|
3469
3556
|
createContext,
|
|
3470
3557
|
createDynamicWorkflow,
|
|
3558
|
+
createErrorResponse,
|
|
3559
|
+
createProviderErrorResponse,
|
|
3560
|
+
createSuccessResponse,
|
|
3561
|
+
createValidationErrorResponse,
|
|
3471
3562
|
executeCommand_default as executeCommand,
|
|
3472
3563
|
fetchUrl_default as fetchUrl,
|
|
3473
3564
|
fromJsonModelMessage,
|