@polka-codes/core 0.9.84 → 0.9.85
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 +52 -23
- package/dist/index.d.ts +6 -6
- package/dist/index.js +11 -8
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ declare type AgentToolRegistry = {
|
|
|
31
31
|
invokeTool: {
|
|
32
32
|
input: {
|
|
33
33
|
toolName: string;
|
|
34
|
-
input:
|
|
34
|
+
input: unknown;
|
|
35
35
|
};
|
|
36
36
|
output: ToolResponse;
|
|
37
37
|
};
|
|
@@ -60,7 +60,9 @@ export { AgentWorkflowInput }
|
|
|
60
60
|
export { AgentWorkflowInput as AgentWorkflowInput_alias_1 }
|
|
61
61
|
export { AgentWorkflowInput as AgentWorkflowInput_alias_2 }
|
|
62
62
|
|
|
63
|
-
declare
|
|
63
|
+
declare interface BreakStep {
|
|
64
|
+
break: true;
|
|
65
|
+
}
|
|
64
66
|
export { BreakStep }
|
|
65
67
|
export { BreakStep as BreakStep_alias_1 }
|
|
66
68
|
export { BreakStep as BreakStep_alias_2 }
|
|
@@ -213,7 +215,9 @@ declare const configSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
|
213
215
|
export { configSchema }
|
|
214
216
|
export { configSchema as configSchema_alias_1 }
|
|
215
217
|
|
|
216
|
-
declare
|
|
218
|
+
declare interface ContinueStep {
|
|
219
|
+
continue: true;
|
|
220
|
+
}
|
|
217
221
|
export { ContinueStep }
|
|
218
222
|
export { ContinueStep as ContinueStep_alias_1 }
|
|
219
223
|
export { ContinueStep as ContinueStep_alias_2 }
|
|
@@ -233,7 +237,7 @@ export { createContext }
|
|
|
233
237
|
export { createContext as createContext_alias_1 }
|
|
234
238
|
export { createContext as createContext_alias_2 }
|
|
235
239
|
|
|
236
|
-
declare function createDynamicWorkflow<TTools extends ToolRegistry = DynamicWorkflowRegistry>(definition: WorkflowFile | string, options?: DynamicWorkflowRunnerOptions): (workflowId: string, input: Record<string,
|
|
240
|
+
declare function createDynamicWorkflow<TTools extends ToolRegistry = DynamicWorkflowRegistry>(definition: WorkflowFile | string, options?: DynamicWorkflowRunnerOptions): (workflowId: string, input: Record<string, unknown>, context: WorkflowContext<TTools>) => Promise<unknown>;
|
|
237
241
|
export { createDynamicWorkflow }
|
|
238
242
|
export { createDynamicWorkflow as createDynamicWorkflow_alias_1 }
|
|
239
243
|
export { createDynamicWorkflow as createDynamicWorkflow_alias_2 }
|
|
@@ -511,14 +515,14 @@ export declare function dirname(path: string): string;
|
|
|
511
515
|
declare type DynamicStepRuntimeContext<TTools extends ToolRegistry> = {
|
|
512
516
|
workflowId: string;
|
|
513
517
|
stepId: string;
|
|
514
|
-
input: Record<string,
|
|
515
|
-
state: Record<string,
|
|
518
|
+
input: Record<string, unknown>;
|
|
519
|
+
state: Record<string, unknown>;
|
|
516
520
|
tools: WorkflowTools<TTools>;
|
|
517
521
|
logger: Logger;
|
|
518
522
|
step: StepFn;
|
|
519
|
-
runWorkflow: (workflowId: string, input?: Record<string,
|
|
523
|
+
runWorkflow: (workflowId: string, input?: Record<string, unknown>) => Promise<unknown>;
|
|
520
524
|
toolInfo: Readonly<FullToolInfo[]> | undefined;
|
|
521
|
-
agentTools: Record<string, (input:
|
|
525
|
+
agentTools: Record<string, (input: unknown) => Promise<unknown>>;
|
|
522
526
|
};
|
|
523
527
|
export { DynamicStepRuntimeContext }
|
|
524
528
|
export { DynamicStepRuntimeContext as DynamicStepRuntimeContext_alias_1 }
|
|
@@ -562,8 +566,8 @@ declare type DynamicWorkflowRunnerOptions = {
|
|
|
562
566
|
stepSystemPrompt?: (args: {
|
|
563
567
|
workflowId: string;
|
|
564
568
|
step: WorkflowStepDefinition;
|
|
565
|
-
input:
|
|
566
|
-
state:
|
|
569
|
+
input: Record<string, unknown>;
|
|
570
|
+
state: Record<string, unknown>;
|
|
567
571
|
}) => string;
|
|
568
572
|
/**
|
|
569
573
|
* Whether to wrap plain text agent responses in an object { result: ... }.
|
|
@@ -748,7 +752,15 @@ export declare const handler_alias_8: ToolHandler<typeof toolInfo_alias_8, Files
|
|
|
748
752
|
|
|
749
753
|
export declare const handler_alias_9: ToolHandler<typeof toolInfo_alias_9, WebProvider>;
|
|
750
754
|
|
|
751
|
-
declare
|
|
755
|
+
declare interface IfElseStep {
|
|
756
|
+
id: string;
|
|
757
|
+
if: {
|
|
758
|
+
condition: string;
|
|
759
|
+
thenBranch: WorkflowControlFlowStep[];
|
|
760
|
+
elseBranch?: WorkflowControlFlowStep[];
|
|
761
|
+
};
|
|
762
|
+
output?: string | null;
|
|
763
|
+
}
|
|
752
764
|
export { IfElseStep }
|
|
753
765
|
export { IfElseStep as IfElseStep_alias_1 }
|
|
754
766
|
export { IfElseStep as IfElseStep_alias_2 }
|
|
@@ -756,7 +768,7 @@ export { IfElseStep as IfElseStep_alias_2 }
|
|
|
756
768
|
/**
|
|
757
769
|
* If/else branch - conditionally executes steps
|
|
758
770
|
*/
|
|
759
|
-
declare const IfElseStepSchema:
|
|
771
|
+
declare const IfElseStepSchema: z.ZodType<IfElseStep>;
|
|
760
772
|
export { IfElseStepSchema }
|
|
761
773
|
export { IfElseStepSchema as IfElseStepSchema_alias_1 }
|
|
762
774
|
export { IfElseStepSchema as IfElseStepSchema_alias_2 }
|
|
@@ -1347,12 +1359,15 @@ declare const ruleSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
|
1347
1359
|
export { ruleSchema }
|
|
1348
1360
|
export { ruleSchema as ruleSchema_alias_1 }
|
|
1349
1361
|
|
|
1362
|
+
/**
|
|
1363
|
+
* Type for the runWorkflow tool that allows workflows to call other workflows
|
|
1364
|
+
*/
|
|
1350
1365
|
declare type RunWorkflowTool = {
|
|
1351
1366
|
input: {
|
|
1352
1367
|
workflowId: string;
|
|
1353
|
-
input?:
|
|
1368
|
+
input?: Record<string, unknown>;
|
|
1354
1369
|
};
|
|
1355
|
-
output:
|
|
1370
|
+
output: unknown;
|
|
1356
1371
|
};
|
|
1357
1372
|
export { RunWorkflowTool }
|
|
1358
1373
|
export { RunWorkflowTool as RunWorkflowTool_alias_1 }
|
|
@@ -2008,7 +2023,14 @@ declare type Totals = {
|
|
|
2008
2023
|
messageCount: number;
|
|
2009
2024
|
};
|
|
2010
2025
|
|
|
2011
|
-
declare
|
|
2026
|
+
declare interface TryCatchStep {
|
|
2027
|
+
id: string;
|
|
2028
|
+
try: {
|
|
2029
|
+
trySteps: WorkflowControlFlowStep[];
|
|
2030
|
+
catchSteps: WorkflowControlFlowStep[];
|
|
2031
|
+
};
|
|
2032
|
+
output?: string | null;
|
|
2033
|
+
}
|
|
2012
2034
|
export { TryCatchStep }
|
|
2013
2035
|
export { TryCatchStep as TryCatchStep_alias_1 }
|
|
2014
2036
|
export { TryCatchStep as TryCatchStep_alias_2 }
|
|
@@ -2019,8 +2041,8 @@ export { TryCatchStep as TryCatchStep_alias_2 }
|
|
|
2019
2041
|
declare const TryCatchStepSchema: z.ZodObject<{
|
|
2020
2042
|
id: z.ZodString;
|
|
2021
2043
|
try: z.ZodObject<{
|
|
2022
|
-
trySteps: z.ZodArray<z.ZodLazy<
|
|
2023
|
-
catchSteps: z.ZodArray<z.ZodLazy<
|
|
2044
|
+
trySteps: z.ZodArray<z.ZodLazy<z.ZodType<WorkflowControlFlowStep, unknown, z.core.$ZodTypeInternals<WorkflowControlFlowStep, unknown>>>>;
|
|
2045
|
+
catchSteps: z.ZodArray<z.ZodLazy<z.ZodType<WorkflowControlFlowStep, unknown, z.core.$ZodTypeInternals<WorkflowControlFlowStep, unknown>>>>;
|
|
2024
2046
|
}, z.core.$strip>;
|
|
2025
2047
|
output: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2026
2048
|
}, z.core.$strip>;
|
|
@@ -2174,7 +2196,14 @@ export { WebProvider }
|
|
|
2174
2196
|
export { WebProvider as WebProvider_alias_1 }
|
|
2175
2197
|
export { WebProvider as WebProvider_alias_2 }
|
|
2176
2198
|
|
|
2177
|
-
declare
|
|
2199
|
+
declare interface WhileLoopStep {
|
|
2200
|
+
id: string;
|
|
2201
|
+
while: {
|
|
2202
|
+
condition: string;
|
|
2203
|
+
steps: WorkflowControlFlowStep[];
|
|
2204
|
+
};
|
|
2205
|
+
output?: string | null;
|
|
2206
|
+
}
|
|
2178
2207
|
export { WhileLoopStep }
|
|
2179
2208
|
export { WhileLoopStep as WhileLoopStep_alias_1 }
|
|
2180
2209
|
export { WhileLoopStep as WhileLoopStep_alias_2 }
|
|
@@ -2182,7 +2211,7 @@ export { WhileLoopStep as WhileLoopStep_alias_2 }
|
|
|
2182
2211
|
/**
|
|
2183
2212
|
* While loop - repeats steps while condition is true
|
|
2184
2213
|
*/
|
|
2185
|
-
declare const WhileLoopStepSchema:
|
|
2214
|
+
declare const WhileLoopStepSchema: z.ZodType<WhileLoopStep>;
|
|
2186
2215
|
export { WhileLoopStepSchema }
|
|
2187
2216
|
export { WhileLoopStepSchema as WhileLoopStepSchema_alias_1 }
|
|
2188
2217
|
export { WhileLoopStepSchema as WhileLoopStepSchema_alias_2 }
|
|
@@ -2196,7 +2225,7 @@ export { WorkflowContext }
|
|
|
2196
2225
|
export { WorkflowContext as WorkflowContext_alias_1 }
|
|
2197
2226
|
export { WorkflowContext as WorkflowContext_alias_2 }
|
|
2198
2227
|
|
|
2199
|
-
declare type WorkflowControlFlowStep = z.infer<typeof
|
|
2228
|
+
declare type WorkflowControlFlowStep = z.infer<typeof WorkflowStepDefinitionSchema> | WhileLoopStep | IfElseStep | BreakStep | ContinueStep | TryCatchStep;
|
|
2200
2229
|
export { WorkflowControlFlowStep }
|
|
2201
2230
|
export { WorkflowControlFlowStep as WorkflowControlFlowStep_alias_1 }
|
|
2202
2231
|
export { WorkflowControlFlowStep as WorkflowControlFlowStep_alias_2 }
|
|
@@ -2205,7 +2234,7 @@ export { WorkflowControlFlowStep as WorkflowControlFlowStep_alias_2 }
|
|
|
2205
2234
|
* Any step that can appear in a workflow's steps array
|
|
2206
2235
|
* Can be a basic step, control flow, or jump statement
|
|
2207
2236
|
*/
|
|
2208
|
-
declare const WorkflowControlFlowStepSchema:
|
|
2237
|
+
declare const WorkflowControlFlowStepSchema: z.ZodType<WorkflowControlFlowStep>;
|
|
2209
2238
|
export { WorkflowControlFlowStepSchema }
|
|
2210
2239
|
export { WorkflowControlFlowStepSchema as WorkflowControlFlowStepSchema_alias_1 }
|
|
2211
2240
|
export { WorkflowControlFlowStepSchema as WorkflowControlFlowStepSchema_alias_2 }
|
|
@@ -2225,7 +2254,7 @@ declare const WorkflowDefinitionSchema: z.ZodObject<{
|
|
|
2225
2254
|
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2226
2255
|
default: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
|
|
2227
2256
|
}, z.core.$strip>>>>;
|
|
2228
|
-
steps: z.ZodArray<
|
|
2257
|
+
steps: z.ZodArray<z.ZodType<WorkflowControlFlowStep, unknown, z.core.$ZodTypeInternals<WorkflowControlFlowStep, unknown>>>;
|
|
2229
2258
|
output: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2230
2259
|
}, z.core.$strip>;
|
|
2231
2260
|
export { WorkflowDefinitionSchema }
|
|
@@ -2245,7 +2274,7 @@ declare const WorkflowFileSchema: z.ZodObject<{
|
|
|
2245
2274
|
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2246
2275
|
default: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
|
|
2247
2276
|
}, z.core.$strip>>>>;
|
|
2248
|
-
steps: z.ZodArray<
|
|
2277
|
+
steps: z.ZodArray<z.ZodType<WorkflowControlFlowStep, unknown, z.core.$ZodTypeInternals<WorkflowControlFlowStep, unknown>>>;
|
|
2249
2278
|
output: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2250
2279
|
}, z.core.$strip>>;
|
|
2251
2280
|
}, z.core.$strip>;
|
package/dist/index.d.ts
CHANGED
|
@@ -107,6 +107,12 @@ export { DynamicWorkflowParseResult } from './_tsup-dts-rollup.js';
|
|
|
107
107
|
export { DynamicStepRuntimeContext } from './_tsup-dts-rollup.js';
|
|
108
108
|
export { DynamicWorkflowRunnerOptions } from './_tsup-dts-rollup.js';
|
|
109
109
|
export { ValidationResult } from './_tsup-dts-rollup.js';
|
|
110
|
+
export { WhileLoopStep } from './_tsup-dts-rollup.js';
|
|
111
|
+
export { IfElseStep } from './_tsup-dts-rollup.js';
|
|
112
|
+
export { BreakStep } from './_tsup-dts-rollup.js';
|
|
113
|
+
export { ContinueStep } from './_tsup-dts-rollup.js';
|
|
114
|
+
export { TryCatchStep } from './_tsup-dts-rollup.js';
|
|
115
|
+
export { WorkflowControlFlowStep } from './_tsup-dts-rollup.js';
|
|
110
116
|
export { WorkflowInputDefinitionSchema } from './_tsup-dts-rollup.js';
|
|
111
117
|
export { WorkflowStepDefinitionSchema } from './_tsup-dts-rollup.js';
|
|
112
118
|
export { WhileLoopStepSchema } from './_tsup-dts-rollup.js';
|
|
@@ -119,12 +125,6 @@ export { WorkflowDefinitionSchema } from './_tsup-dts-rollup.js';
|
|
|
119
125
|
export { WorkflowFileSchema } from './_tsup-dts-rollup.js';
|
|
120
126
|
export { WorkflowInputDefinition } from './_tsup-dts-rollup.js';
|
|
121
127
|
export { WorkflowStepDefinition } from './_tsup-dts-rollup.js';
|
|
122
|
-
export { WhileLoopStep } from './_tsup-dts-rollup.js';
|
|
123
|
-
export { IfElseStep } from './_tsup-dts-rollup.js';
|
|
124
|
-
export { BreakStep } from './_tsup-dts-rollup.js';
|
|
125
|
-
export { ContinueStep } from './_tsup-dts-rollup.js';
|
|
126
|
-
export { TryCatchStep } from './_tsup-dts-rollup.js';
|
|
127
|
-
export { WorkflowControlFlowStep } from './_tsup-dts-rollup.js';
|
|
128
128
|
export { WorkflowDefinition } from './_tsup-dts-rollup.js';
|
|
129
129
|
export { WorkflowFile } from './_tsup-dts-rollup.js';
|
|
130
130
|
export { JsonImagePart } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -2403,7 +2403,8 @@ var WorkflowFileSchema = z20.object({
|
|
|
2403
2403
|
var MAX_WHILE_LOOP_ITERATIONS = 1e3;
|
|
2404
2404
|
function convertJsonSchemaToZod(schema) {
|
|
2405
2405
|
if (schema.enum) {
|
|
2406
|
-
|
|
2406
|
+
const enumValues = schema.enum.map((v) => String(v));
|
|
2407
|
+
return z21.enum(enumValues);
|
|
2407
2408
|
}
|
|
2408
2409
|
if (Array.isArray(schema.type)) {
|
|
2409
2410
|
const types = schema.type;
|
|
@@ -2450,14 +2451,14 @@ function convertJsonSchemaToZod(schema) {
|
|
|
2450
2451
|
shape[propName] = isRequired ? propZod : propZod.optional();
|
|
2451
2452
|
}
|
|
2452
2453
|
}
|
|
2453
|
-
let objectSchema = z21.object(shape);
|
|
2454
2454
|
if (schema.additionalProperties === true) {
|
|
2455
|
-
|
|
2456
|
-
}
|
|
2455
|
+
return z21.object(shape).passthrough();
|
|
2456
|
+
}
|
|
2457
|
+
if (typeof schema.additionalProperties === "object") {
|
|
2457
2458
|
const additionalSchema = convertJsonSchemaToZod(schema.additionalProperties);
|
|
2458
|
-
|
|
2459
|
+
return z21.intersection(z21.object(shape), z21.record(z21.string(), additionalSchema));
|
|
2459
2460
|
}
|
|
2460
|
-
return
|
|
2461
|
+
return z21.object(shape);
|
|
2461
2462
|
}
|
|
2462
2463
|
case "array": {
|
|
2463
2464
|
if (!schema.items) {
|
|
@@ -2751,6 +2752,7 @@ function getNestedProperty(obj, path) {
|
|
|
2751
2752
|
let current = obj;
|
|
2752
2753
|
for (const part of parts) {
|
|
2753
2754
|
if (current == null) return void 0;
|
|
2755
|
+
if (typeof current !== "object") return void 0;
|
|
2754
2756
|
current = current[part];
|
|
2755
2757
|
}
|
|
2756
2758
|
return current;
|
|
@@ -2865,8 +2867,9 @@ async function executeStepWithAgent(stepDef, workflowId, input, state, context,
|
|
|
2865
2867
|
};
|
|
2866
2868
|
}
|
|
2867
2869
|
if (toolName === "runWorkflow") {
|
|
2868
|
-
const
|
|
2869
|
-
const
|
|
2870
|
+
const runWorkflowInput = toolInput;
|
|
2871
|
+
const subWorkflowId = runWorkflowInput?.workflowId;
|
|
2872
|
+
const subInput = runWorkflowInput?.input;
|
|
2870
2873
|
if (typeof subWorkflowId !== "string") {
|
|
2871
2874
|
return {
|
|
2872
2875
|
success: false,
|