@codemation/core-nodes 0.2.0 → 0.4.0
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/CHANGELOG.md +23 -1
- package/dist/index.cjs +10 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -30
- package/dist/index.d.ts +42 -30
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/nodes/AIAgentNode.ts +1 -1
- package/src/nodes/NodeBackedToolRuntime.ts +4 -4
- package/src/workflowAuthoring/WorkflowBranchBuilder.types.ts +19 -14
- package/src/workflowAuthoring/WorkflowChain.types.ts +39 -25
package/dist/index.d.cts
CHANGED
|
@@ -21,9 +21,9 @@ type PortsEmission = Readonly<{
|
|
|
21
21
|
readonly ports: Readonly<Partial<Record<OutputPortKey, Items | ReadonlyArray<JsonNonArray>>>>;
|
|
22
22
|
}>;
|
|
23
23
|
//#endregion
|
|
24
|
-
//#region ../core/src/contracts/
|
|
25
|
-
declare const
|
|
26
|
-
type
|
|
24
|
+
//#region ../core/src/contracts/itemExpr.d.ts
|
|
25
|
+
declare const ITEM_EXPR_BRAND: unique symbol;
|
|
26
|
+
type ItemExprResolvedContext = Readonly<{
|
|
27
27
|
runId: RunId;
|
|
28
28
|
workflowId: WorkflowId;
|
|
29
29
|
nodeId: NodeId;
|
|
@@ -33,19 +33,23 @@ type ItemValueResolvedContext = Readonly<{
|
|
|
33
33
|
/**
|
|
34
34
|
* Context aligned with former {@link ItemInputMapperContext} — use **`data`** to read any completed upstream node.
|
|
35
35
|
*/
|
|
36
|
-
type
|
|
37
|
-
type
|
|
36
|
+
type ItemExprContext = ItemExprResolvedContext;
|
|
37
|
+
type ItemExprArgs<TItemJson = unknown> = Readonly<{
|
|
38
38
|
item: Item<TItemJson>;
|
|
39
39
|
itemIndex: number;
|
|
40
40
|
items: Items<TItemJson>;
|
|
41
|
-
ctx:
|
|
41
|
+
ctx: ItemExprContext;
|
|
42
42
|
}>;
|
|
43
|
-
type
|
|
44
|
-
type
|
|
45
|
-
readonly [
|
|
46
|
-
readonly fn:
|
|
43
|
+
type ItemExprCallback<T, TItemJson = unknown> = (args: ItemExprArgs<TItemJson>) => T | Promise<T>;
|
|
44
|
+
type ItemExpr<T, TItemJson = unknown> = Readonly<{
|
|
45
|
+
readonly [ITEM_EXPR_BRAND]: true;
|
|
46
|
+
readonly fn: ItemExprCallback<T, TItemJson>;
|
|
47
47
|
}>;
|
|
48
48
|
//#endregion
|
|
49
|
+
//#region ../core/src/contracts/params.d.ts
|
|
50
|
+
type Expr<T, TItemJson = unknown> = ItemExpr<T, TItemJson>;
|
|
51
|
+
type ParamDeep<T, TItemJson = unknown> = Expr<T, TItemJson> | (T extends readonly (infer U)[] ? ReadonlyArray<ParamDeep<U, TItemJson>> : never) | (T extends object ? { [K in keyof T]: ParamDeep<T[K], TItemJson> } : T);
|
|
52
|
+
//#endregion
|
|
49
53
|
//#region ../core/src/contracts/retryPolicySpec.types.d.ts
|
|
50
54
|
/**
|
|
51
55
|
* In-process retry policy for runnable nodes. Serialized configs use the same
|
|
@@ -362,6 +366,9 @@ type ExecutableTriggerNode<TConfig extends TriggerNodeConfig<any, any> = Trigger
|
|
|
362
366
|
//#region ../core/src/contracts/workflowTypes.d.ts
|
|
363
367
|
type WorkflowId = string;
|
|
364
368
|
type NodeId = string;
|
|
369
|
+
type NodeIdRef<TJson = unknown> = NodeId & Readonly<{
|
|
370
|
+
__codemationNodeJson?: TJson;
|
|
371
|
+
}>;
|
|
365
372
|
type OutputPortKey = string;
|
|
366
373
|
type InputPortKey = string;
|
|
367
374
|
type NodeKind = "trigger" | "node";
|
|
@@ -531,8 +538,8 @@ interface ParentExecutionRef {
|
|
|
531
538
|
}
|
|
532
539
|
interface RunDataSnapshot {
|
|
533
540
|
getOutputs(nodeId: NodeId): NodeOutputs | undefined;
|
|
534
|
-
getOutputItems(nodeId: NodeId
|
|
535
|
-
getOutputItem(nodeId: NodeId
|
|
541
|
+
getOutputItems<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, output?: OutputPortKey): Items<TJson>;
|
|
542
|
+
getOutputItem<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, itemIndex: number, output?: OutputPortKey): Item<TJson> | undefined;
|
|
536
543
|
}
|
|
537
544
|
type UpstreamRefPlaceholder = `$${number}`;
|
|
538
545
|
/** Whether to persist run execution data after the workflow finishes. */
|
|
@@ -738,12 +745,13 @@ type DefinedNodeCredentialBinding = ResolvableCredentialType | Readonly<{
|
|
|
738
745
|
readonly helpUrl?: string;
|
|
739
746
|
}>;
|
|
740
747
|
type DefinedNodeCredentialBindings = Readonly<Record<string, DefinedNodeCredentialBinding>>;
|
|
748
|
+
type DefinedNodeConfigInput<TConfigResolved extends CredentialJsonRecord, TItemJson> = ParamDeep<TConfigResolved, TItemJson>;
|
|
741
749
|
interface DefinedNode<TKey$1 extends string, TConfig extends CredentialJsonRecord, TInputJson$1, TOutputJson$1, _TBindings extends DefinedNodeCredentialBindings | undefined = undefined> {
|
|
742
750
|
readonly kind: "defined-node";
|
|
743
751
|
readonly key: TKey$1;
|
|
744
752
|
readonly title: string;
|
|
745
753
|
readonly description?: string;
|
|
746
|
-
create(config: TConfig, name?: string, id?: string): RunnableNodeConfig<TInputJson$1, TOutputJson$1>;
|
|
754
|
+
create<TConfigItemJson = TInputJson$1>(config: DefinedNodeConfigInput<TConfig, TConfigItemJson>, name?: string, id?: string): RunnableNodeConfig<TInputJson$1, TOutputJson$1>;
|
|
747
755
|
register(context: {
|
|
748
756
|
registerNode<TValue>(token: TypeToken<TValue>, implementation?: TypeToken<TValue>): void;
|
|
749
757
|
}): void;
|
|
@@ -814,7 +822,7 @@ type AgentMessageLine<TInputJson$1 = unknown> = AgentMessageDto | AgentMessageTe
|
|
|
814
822
|
* Message list for an agent. Prefer a **plain array** of `{ role, content }` (optionally with function `content` for templates).
|
|
815
823
|
* Use the object form only when you need `buildMessages` to append messages after optional `prompt` lines.
|
|
816
824
|
*/
|
|
817
|
-
type AgentMessageConfig<TInputJson$1 = unknown> =
|
|
825
|
+
type AgentMessageConfig<TInputJson$1 = unknown> = Expr<ReadonlyArray<AgentMessageLine<TInputJson$1>>, TInputJson$1> | ReadonlyArray<AgentMessageLine<TInputJson$1>> | {
|
|
818
826
|
readonly prompt?: ReadonlyArray<AgentMessageLine<TInputJson$1>>;
|
|
819
827
|
readonly buildMessages?: (args: AgentMessageBuildArgs<TInputJson$1>) => ReadonlyArray<AgentMessageDto>;
|
|
820
828
|
};
|
|
@@ -894,11 +902,11 @@ interface AgentNodeConfig<TInputJson$1 = unknown, TOutputJson$1 = unknown> exten
|
|
|
894
902
|
readonly outputSchema?: ZodType<TOutputJson$1>;
|
|
895
903
|
}
|
|
896
904
|
//#endregion
|
|
897
|
-
//#region ../core/src/execution/
|
|
905
|
+
//#region ../core/src/execution/ItemExprResolver.d.ts
|
|
898
906
|
/**
|
|
899
|
-
* Resolves {@link import("../contracts/
|
|
907
|
+
* Resolves {@link import("../contracts/itemExpr").ItemExpr} leaves on runnable config before {@link RunnableNode.execute}.
|
|
900
908
|
*/
|
|
901
|
-
declare class
|
|
909
|
+
declare class ItemExprResolver {
|
|
902
910
|
resolveConfigForItem<TConfig extends RunnableNodeConfig<any, any>>(ctx: NodeExecutionContext<TConfig>, item: Item, itemIndex: number, items: ReadonlyArray<Item>): Promise<NodeExecutionContext<TConfig>>;
|
|
903
911
|
}
|
|
904
912
|
//#endregion
|
|
@@ -1155,10 +1163,10 @@ declare class AIAgent<TInputJson$1 = unknown, TOutputJson$1 = unknown> implement
|
|
|
1155
1163
|
//#region src/nodes/NodeBackedToolRuntime.d.ts
|
|
1156
1164
|
declare class NodeBackedToolRuntime {
|
|
1157
1165
|
private readonly nodeResolver;
|
|
1158
|
-
private readonly
|
|
1166
|
+
private readonly itemExprResolver;
|
|
1159
1167
|
private readonly outputNormalizer;
|
|
1160
1168
|
private readonly outputBehaviorResolver;
|
|
1161
|
-
constructor(nodeResolver: NodeResolver,
|
|
1169
|
+
constructor(nodeResolver: NodeResolver, itemExprResolver: ItemExprResolver, outputNormalizer: NodeOutputNormalizer, outputBehaviorResolver: RunnableOutputBehaviorResolver);
|
|
1162
1170
|
execute(config: NodeBackedToolConfig<any, ZodSchemaAny, ZodSchemaAny>, args: ToolExecuteArgs): Promise<unknown>;
|
|
1163
1171
|
private executeResolvedNode;
|
|
1164
1172
|
private isRunnableNode;
|
|
@@ -1175,7 +1183,7 @@ declare class AIAgentNode implements RunnableNode<AIAgent<any, any>> {
|
|
|
1175
1183
|
outputPorts: readonly ["main"];
|
|
1176
1184
|
/**
|
|
1177
1185
|
* Engine validates {@link RunnableNodeConfig.inputSchema} (Zod) on {@code item.json} before enqueue, then resolves
|
|
1178
|
-
* per-item **`
|
|
1186
|
+
* per-item **`itemExpr`** leaves on config before {@link #execute}. Prefer modeling prompts as
|
|
1179
1187
|
* {@code { messages: [{ role, content }, ...] }} (on input or config) so persisted inputs are visible in the UI.
|
|
1180
1188
|
*/
|
|
1181
1189
|
readonly inputSchema: z.ZodUnknown;
|
|
@@ -1695,12 +1703,13 @@ interface WorkflowAgentOptions<TCurrentJson, TOutputSchema extends z.ZodTypeAny
|
|
|
1695
1703
|
}
|
|
1696
1704
|
//#endregion
|
|
1697
1705
|
//#region src/workflowAuthoring/WorkflowBranchBuilder.types.d.ts
|
|
1706
|
+
type WorkflowMapCallback$1<TCurrentJson, TNextJson$1> = (item: Item<TCurrentJson>, ctx: NodeExecutionContext<MapData<TCurrentJson, TNextJson$1>>) => TNextJson$1;
|
|
1698
1707
|
declare class WorkflowBranchBuilder<TCurrentJson> {
|
|
1699
1708
|
private readonly steps;
|
|
1700
1709
|
constructor(steps?: ReadonlyArray<AnyRunnableNodeConfig>);
|
|
1701
1710
|
then<TOutputJson$1, TConfig extends RunnableNodeConfig<TCurrentJson, TOutputJson$1>>(config: TConfig): WorkflowBranchBuilder<RunnableNodeOutputJson<TConfig>>;
|
|
1702
|
-
map<TNextJson$1>(mapper:
|
|
1703
|
-
map<TNextJson$1>(name: string, mapper:
|
|
1711
|
+
map<TNextJson$1>(mapper: WorkflowMapCallback$1<TCurrentJson, TNextJson$1>): WorkflowBranchBuilder<TNextJson$1>;
|
|
1712
|
+
map<TNextJson$1>(name: string, mapper: WorkflowMapCallback$1<TCurrentJson, TNextJson$1>, options?: MapDataOptions): WorkflowBranchBuilder<TNextJson$1>;
|
|
1704
1713
|
wait(duration: number | string): WorkflowBranchBuilder<TCurrentJson>;
|
|
1705
1714
|
wait(name: string, duration: number | string, id?: string): WorkflowBranchBuilder<TCurrentJson>;
|
|
1706
1715
|
split<TElem>(getElements: (item: Item<TCurrentJson>, ctx: NodeExecutionContext<Split<TCurrentJson, TElem>>) => readonly TElem[]): WorkflowBranchBuilder<TElem>;
|
|
@@ -1712,19 +1721,22 @@ declare class WorkflowBranchBuilder<TCurrentJson> {
|
|
|
1712
1721
|
agent<TOutputSchema extends z.ZodTypeAny>(options: WorkflowAgentOptions<TCurrentJson, TOutputSchema>): WorkflowBranchBuilder<z.output<TOutputSchema>>;
|
|
1713
1722
|
agent(options: WorkflowAgentOptions<TCurrentJson, undefined>): WorkflowBranchBuilder<Record<string, unknown>>;
|
|
1714
1723
|
agent<TOutputSchema extends z.ZodTypeAny>(name: string, options: WorkflowAgentOptions<TCurrentJson, TOutputSchema | undefined>): WorkflowBranchBuilder<TOutputSchema extends z.ZodTypeAny ? z.output<TOutputSchema> : Record<string, unknown>>;
|
|
1715
|
-
node<TConfig extends
|
|
1724
|
+
node<TConfig extends CredentialJsonRecord, TInputJson$1, TOutputJson$1>(definitionOrKey: DefinedNode<string, TConfig, TInputJson$1, TOutputJson$1> | string, config: DefinedNodeConfigInput<TConfig, TCurrentJson>, name?: string, id?: string): TCurrentJson extends TInputJson$1 ? WorkflowBranchBuilder<TOutputJson$1> : never;
|
|
1716
1725
|
getSteps(): ReadonlyArray<AnyRunnableNodeConfig>;
|
|
1717
1726
|
}
|
|
1718
1727
|
//#endregion
|
|
1719
1728
|
//#region src/workflowAuthoring/WorkflowChain.types.d.ts
|
|
1720
1729
|
type BranchCallback<TCurrentJson, TNextJson$1> = (branch: WorkflowBranchBuilder<TCurrentJson>) => WorkflowBranchBuilder<TNextJson$1>;
|
|
1721
1730
|
type RouteBranchCallback<TCurrentJson, TNextJson$1> = (branch: WorkflowChain<TCurrentJson>) => WorkflowChain<TNextJson$1>;
|
|
1731
|
+
type WorkflowMapCallback<TCurrentJson, TNextJson$1> = (item: Item<TCurrentJson>, ctx: NodeExecutionContext<MapData<TCurrentJson, TNextJson$1>>) => TNextJson$1;
|
|
1732
|
+
type WorkflowIfPredicate<TCurrentJson> = (item: Item<TCurrentJson>, ctx: NodeExecutionContext<If<TCurrentJson>>) => boolean;
|
|
1733
|
+
type WorkflowSwitchCaseKeyResolver<TCurrentJson> = (item: Item<TCurrentJson>, ctx: NodeExecutionContext<Switch<TCurrentJson>>) => string | Promise<string>;
|
|
1722
1734
|
declare class WorkflowChain<TCurrentJson> {
|
|
1723
1735
|
private readonly chain;
|
|
1724
1736
|
constructor(chain: ChainCursor<TCurrentJson>);
|
|
1725
1737
|
then<TOutputJson$1, TConfig extends RunnableNodeConfig<TCurrentJson, TOutputJson$1>>(config: TConfig): WorkflowChain<RunnableNodeOutputJson<TConfig>>;
|
|
1726
|
-
map<TNextJson$1>(mapper:
|
|
1727
|
-
map<TNextJson$1>(name: string, mapper:
|
|
1738
|
+
map<TNextJson$1>(mapper: WorkflowMapCallback<TCurrentJson, TNextJson$1>): WorkflowChain<TNextJson$1>;
|
|
1739
|
+
map<TNextJson$1>(name: string, mapper: WorkflowMapCallback<TCurrentJson, TNextJson$1>, options?: MapDataOptions): WorkflowChain<TNextJson$1>;
|
|
1728
1740
|
wait(duration: number | string): WorkflowChain<TCurrentJson>;
|
|
1729
1741
|
wait(name: string, duration: number | string, id?: string): WorkflowChain<TCurrentJson>;
|
|
1730
1742
|
split<TElem>(getElements: (item: Item<TCurrentJson>, ctx: NodeExecutionContext<Split<TCurrentJson, TElem>>) => readonly TElem[]): WorkflowChain<TElem>;
|
|
@@ -1742,11 +1754,11 @@ declare class WorkflowChain<TCurrentJson> {
|
|
|
1742
1754
|
mode: MergeMode;
|
|
1743
1755
|
prefer?: ReadonlyArray<string>;
|
|
1744
1756
|
}>, id?: string): WorkflowChain<TCurrentJson>;
|
|
1745
|
-
if<TBranchJson>(predicate:
|
|
1757
|
+
if<TBranchJson>(predicate: WorkflowIfPredicate<TCurrentJson>, branches: Readonly<{
|
|
1746
1758
|
true?: BranchCallback<TCurrentJson, TBranchJson>;
|
|
1747
1759
|
false?: BranchCallback<TCurrentJson, TBranchJson>;
|
|
1748
1760
|
}>): WorkflowChain<TBranchJson>;
|
|
1749
|
-
if<TBranchJson>(name: string, predicate:
|
|
1761
|
+
if<TBranchJson>(name: string, predicate: WorkflowIfPredicate<TCurrentJson>, branches: Readonly<{
|
|
1750
1762
|
true?: BranchCallback<TCurrentJson, TBranchJson>;
|
|
1751
1763
|
false?: BranchCallback<TCurrentJson, TBranchJson>;
|
|
1752
1764
|
}>): WorkflowChain<TBranchJson>;
|
|
@@ -1754,19 +1766,19 @@ declare class WorkflowChain<TCurrentJson> {
|
|
|
1754
1766
|
switch<TBranchJson>(cfg: Readonly<{
|
|
1755
1767
|
cases: readonly string[];
|
|
1756
1768
|
defaultCase: string;
|
|
1757
|
-
resolveCaseKey:
|
|
1769
|
+
resolveCaseKey: WorkflowSwitchCaseKeyResolver<TCurrentJson>;
|
|
1758
1770
|
branches: Readonly<Record<string, RouteBranchCallback<TCurrentJson, TBranchJson> | undefined>>;
|
|
1759
1771
|
}>): WorkflowChain<TBranchJson>;
|
|
1760
1772
|
switch<TBranchJson>(name: string, cfg: Readonly<{
|
|
1761
1773
|
cases: readonly string[];
|
|
1762
1774
|
defaultCase: string;
|
|
1763
|
-
resolveCaseKey:
|
|
1775
|
+
resolveCaseKey: WorkflowSwitchCaseKeyResolver<TCurrentJson>;
|
|
1764
1776
|
branches: Readonly<Record<string, RouteBranchCallback<TCurrentJson, TBranchJson> | undefined>>;
|
|
1765
1777
|
}>, id?: string): WorkflowChain<TBranchJson>;
|
|
1766
1778
|
agent<TOutputSchema extends z.ZodTypeAny>(options: WorkflowAgentOptions<TCurrentJson, TOutputSchema>): WorkflowChain<z.output<TOutputSchema>>;
|
|
1767
1779
|
agent(options: WorkflowAgentOptions<TCurrentJson, undefined>): WorkflowChain<Record<string, unknown>>;
|
|
1768
1780
|
agent<TOutputSchema extends z.ZodTypeAny>(name: string, options: WorkflowAgentOptions<TCurrentJson, TOutputSchema | undefined>): WorkflowChain<TOutputSchema extends z.ZodTypeAny ? z.output<TOutputSchema> : Record<string, unknown>>;
|
|
1769
|
-
node<TConfig extends
|
|
1781
|
+
node<TConfig extends CredentialJsonRecord, TInputJson$1, TOutputJson$1>(definitionOrKey: DefinedNode<string, TConfig, TInputJson$1, TOutputJson$1> | string, config: DefinedNodeConfigInput<TConfig, TCurrentJson>, name?: string, id?: string): TCurrentJson extends TInputJson$1 ? WorkflowChain<TOutputJson$1> : never;
|
|
1770
1782
|
build(): WorkflowDefinition;
|
|
1771
1783
|
}
|
|
1772
1784
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -21,9 +21,9 @@ type PortsEmission = Readonly<{
|
|
|
21
21
|
readonly ports: Readonly<Partial<Record<OutputPortKey, Items | ReadonlyArray<JsonNonArray>>>>;
|
|
22
22
|
}>;
|
|
23
23
|
//#endregion
|
|
24
|
-
//#region ../core/src/contracts/
|
|
25
|
-
declare const
|
|
26
|
-
type
|
|
24
|
+
//#region ../core/src/contracts/itemExpr.d.ts
|
|
25
|
+
declare const ITEM_EXPR_BRAND: unique symbol;
|
|
26
|
+
type ItemExprResolvedContext = Readonly<{
|
|
27
27
|
runId: RunId;
|
|
28
28
|
workflowId: WorkflowId;
|
|
29
29
|
nodeId: NodeId;
|
|
@@ -33,19 +33,23 @@ type ItemValueResolvedContext = Readonly<{
|
|
|
33
33
|
/**
|
|
34
34
|
* Context aligned with former {@link ItemInputMapperContext} — use **`data`** to read any completed upstream node.
|
|
35
35
|
*/
|
|
36
|
-
type
|
|
37
|
-
type
|
|
36
|
+
type ItemExprContext = ItemExprResolvedContext;
|
|
37
|
+
type ItemExprArgs<TItemJson = unknown> = Readonly<{
|
|
38
38
|
item: Item<TItemJson>;
|
|
39
39
|
itemIndex: number;
|
|
40
40
|
items: Items<TItemJson>;
|
|
41
|
-
ctx:
|
|
41
|
+
ctx: ItemExprContext;
|
|
42
42
|
}>;
|
|
43
|
-
type
|
|
44
|
-
type
|
|
45
|
-
readonly [
|
|
46
|
-
readonly fn:
|
|
43
|
+
type ItemExprCallback<T, TItemJson = unknown> = (args: ItemExprArgs<TItemJson>) => T | Promise<T>;
|
|
44
|
+
type ItemExpr<T, TItemJson = unknown> = Readonly<{
|
|
45
|
+
readonly [ITEM_EXPR_BRAND]: true;
|
|
46
|
+
readonly fn: ItemExprCallback<T, TItemJson>;
|
|
47
47
|
}>;
|
|
48
48
|
//#endregion
|
|
49
|
+
//#region ../core/src/contracts/params.d.ts
|
|
50
|
+
type Expr<T, TItemJson = unknown> = ItemExpr<T, TItemJson>;
|
|
51
|
+
type ParamDeep<T, TItemJson = unknown> = Expr<T, TItemJson> | (T extends readonly (infer U)[] ? ReadonlyArray<ParamDeep<U, TItemJson>> : never) | (T extends object ? { [K in keyof T]: ParamDeep<T[K], TItemJson> } : T);
|
|
52
|
+
//#endregion
|
|
49
53
|
//#region ../core/src/contracts/retryPolicySpec.types.d.ts
|
|
50
54
|
/**
|
|
51
55
|
* In-process retry policy for runnable nodes. Serialized configs use the same
|
|
@@ -362,6 +366,9 @@ type ExecutableTriggerNode<TConfig extends TriggerNodeConfig<any, any> = Trigger
|
|
|
362
366
|
//#region ../core/src/contracts/workflowTypes.d.ts
|
|
363
367
|
type WorkflowId = string;
|
|
364
368
|
type NodeId = string;
|
|
369
|
+
type NodeIdRef<TJson = unknown> = NodeId & Readonly<{
|
|
370
|
+
__codemationNodeJson?: TJson;
|
|
371
|
+
}>;
|
|
365
372
|
type OutputPortKey = string;
|
|
366
373
|
type InputPortKey = string;
|
|
367
374
|
type NodeKind = "trigger" | "node";
|
|
@@ -531,8 +538,8 @@ interface ParentExecutionRef {
|
|
|
531
538
|
}
|
|
532
539
|
interface RunDataSnapshot {
|
|
533
540
|
getOutputs(nodeId: NodeId): NodeOutputs | undefined;
|
|
534
|
-
getOutputItems(nodeId: NodeId
|
|
535
|
-
getOutputItem(nodeId: NodeId
|
|
541
|
+
getOutputItems<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, output?: OutputPortKey): Items<TJson>;
|
|
542
|
+
getOutputItem<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, itemIndex: number, output?: OutputPortKey): Item<TJson> | undefined;
|
|
536
543
|
}
|
|
537
544
|
type UpstreamRefPlaceholder = `$${number}`;
|
|
538
545
|
/** Whether to persist run execution data after the workflow finishes. */
|
|
@@ -738,12 +745,13 @@ type DefinedNodeCredentialBinding = ResolvableCredentialType | Readonly<{
|
|
|
738
745
|
readonly helpUrl?: string;
|
|
739
746
|
}>;
|
|
740
747
|
type DefinedNodeCredentialBindings = Readonly<Record<string, DefinedNodeCredentialBinding>>;
|
|
748
|
+
type DefinedNodeConfigInput<TConfigResolved extends CredentialJsonRecord, TItemJson> = ParamDeep<TConfigResolved, TItemJson>;
|
|
741
749
|
interface DefinedNode<TKey$1 extends string, TConfig extends CredentialJsonRecord, TInputJson$1, TOutputJson$1, _TBindings extends DefinedNodeCredentialBindings | undefined = undefined> {
|
|
742
750
|
readonly kind: "defined-node";
|
|
743
751
|
readonly key: TKey$1;
|
|
744
752
|
readonly title: string;
|
|
745
753
|
readonly description?: string;
|
|
746
|
-
create(config: TConfig, name?: string, id?: string): RunnableNodeConfig<TInputJson$1, TOutputJson$1>;
|
|
754
|
+
create<TConfigItemJson = TInputJson$1>(config: DefinedNodeConfigInput<TConfig, TConfigItemJson>, name?: string, id?: string): RunnableNodeConfig<TInputJson$1, TOutputJson$1>;
|
|
747
755
|
register(context: {
|
|
748
756
|
registerNode<TValue>(token: TypeToken<TValue>, implementation?: TypeToken<TValue>): void;
|
|
749
757
|
}): void;
|
|
@@ -814,7 +822,7 @@ type AgentMessageLine<TInputJson$1 = unknown> = AgentMessageDto | AgentMessageTe
|
|
|
814
822
|
* Message list for an agent. Prefer a **plain array** of `{ role, content }` (optionally with function `content` for templates).
|
|
815
823
|
* Use the object form only when you need `buildMessages` to append messages after optional `prompt` lines.
|
|
816
824
|
*/
|
|
817
|
-
type AgentMessageConfig<TInputJson$1 = unknown> =
|
|
825
|
+
type AgentMessageConfig<TInputJson$1 = unknown> = Expr<ReadonlyArray<AgentMessageLine<TInputJson$1>>, TInputJson$1> | ReadonlyArray<AgentMessageLine<TInputJson$1>> | {
|
|
818
826
|
readonly prompt?: ReadonlyArray<AgentMessageLine<TInputJson$1>>;
|
|
819
827
|
readonly buildMessages?: (args: AgentMessageBuildArgs<TInputJson$1>) => ReadonlyArray<AgentMessageDto>;
|
|
820
828
|
};
|
|
@@ -894,11 +902,11 @@ interface AgentNodeConfig<TInputJson$1 = unknown, TOutputJson$1 = unknown> exten
|
|
|
894
902
|
readonly outputSchema?: ZodType<TOutputJson$1>;
|
|
895
903
|
}
|
|
896
904
|
//#endregion
|
|
897
|
-
//#region ../core/src/execution/
|
|
905
|
+
//#region ../core/src/execution/ItemExprResolver.d.ts
|
|
898
906
|
/**
|
|
899
|
-
* Resolves {@link import("../contracts/
|
|
907
|
+
* Resolves {@link import("../contracts/itemExpr").ItemExpr} leaves on runnable config before {@link RunnableNode.execute}.
|
|
900
908
|
*/
|
|
901
|
-
declare class
|
|
909
|
+
declare class ItemExprResolver {
|
|
902
910
|
resolveConfigForItem<TConfig extends RunnableNodeConfig<any, any>>(ctx: NodeExecutionContext<TConfig>, item: Item, itemIndex: number, items: ReadonlyArray<Item>): Promise<NodeExecutionContext<TConfig>>;
|
|
903
911
|
}
|
|
904
912
|
//#endregion
|
|
@@ -1155,10 +1163,10 @@ declare class AIAgent<TInputJson$1 = unknown, TOutputJson$1 = unknown> implement
|
|
|
1155
1163
|
//#region src/nodes/NodeBackedToolRuntime.d.ts
|
|
1156
1164
|
declare class NodeBackedToolRuntime {
|
|
1157
1165
|
private readonly nodeResolver;
|
|
1158
|
-
private readonly
|
|
1166
|
+
private readonly itemExprResolver;
|
|
1159
1167
|
private readonly outputNormalizer;
|
|
1160
1168
|
private readonly outputBehaviorResolver;
|
|
1161
|
-
constructor(nodeResolver: NodeResolver,
|
|
1169
|
+
constructor(nodeResolver: NodeResolver, itemExprResolver: ItemExprResolver, outputNormalizer: NodeOutputNormalizer, outputBehaviorResolver: RunnableOutputBehaviorResolver);
|
|
1162
1170
|
execute(config: NodeBackedToolConfig<any, ZodSchemaAny, ZodSchemaAny>, args: ToolExecuteArgs): Promise<unknown>;
|
|
1163
1171
|
private executeResolvedNode;
|
|
1164
1172
|
private isRunnableNode;
|
|
@@ -1175,7 +1183,7 @@ declare class AIAgentNode implements RunnableNode<AIAgent<any, any>> {
|
|
|
1175
1183
|
outputPorts: readonly ["main"];
|
|
1176
1184
|
/**
|
|
1177
1185
|
* Engine validates {@link RunnableNodeConfig.inputSchema} (Zod) on {@code item.json} before enqueue, then resolves
|
|
1178
|
-
* per-item **`
|
|
1186
|
+
* per-item **`itemExpr`** leaves on config before {@link #execute}. Prefer modeling prompts as
|
|
1179
1187
|
* {@code { messages: [{ role, content }, ...] }} (on input or config) so persisted inputs are visible in the UI.
|
|
1180
1188
|
*/
|
|
1181
1189
|
readonly inputSchema: z.ZodUnknown;
|
|
@@ -1695,12 +1703,13 @@ interface WorkflowAgentOptions<TCurrentJson, TOutputSchema extends z.ZodTypeAny
|
|
|
1695
1703
|
}
|
|
1696
1704
|
//#endregion
|
|
1697
1705
|
//#region src/workflowAuthoring/WorkflowBranchBuilder.types.d.ts
|
|
1706
|
+
type WorkflowMapCallback$1<TCurrentJson, TNextJson$1> = (item: Item<TCurrentJson>, ctx: NodeExecutionContext<MapData<TCurrentJson, TNextJson$1>>) => TNextJson$1;
|
|
1698
1707
|
declare class WorkflowBranchBuilder<TCurrentJson> {
|
|
1699
1708
|
private readonly steps;
|
|
1700
1709
|
constructor(steps?: ReadonlyArray<AnyRunnableNodeConfig>);
|
|
1701
1710
|
then<TOutputJson$1, TConfig extends RunnableNodeConfig<TCurrentJson, TOutputJson$1>>(config: TConfig): WorkflowBranchBuilder<RunnableNodeOutputJson<TConfig>>;
|
|
1702
|
-
map<TNextJson$1>(mapper:
|
|
1703
|
-
map<TNextJson$1>(name: string, mapper:
|
|
1711
|
+
map<TNextJson$1>(mapper: WorkflowMapCallback$1<TCurrentJson, TNextJson$1>): WorkflowBranchBuilder<TNextJson$1>;
|
|
1712
|
+
map<TNextJson$1>(name: string, mapper: WorkflowMapCallback$1<TCurrentJson, TNextJson$1>, options?: MapDataOptions): WorkflowBranchBuilder<TNextJson$1>;
|
|
1704
1713
|
wait(duration: number | string): WorkflowBranchBuilder<TCurrentJson>;
|
|
1705
1714
|
wait(name: string, duration: number | string, id?: string): WorkflowBranchBuilder<TCurrentJson>;
|
|
1706
1715
|
split<TElem>(getElements: (item: Item<TCurrentJson>, ctx: NodeExecutionContext<Split<TCurrentJson, TElem>>) => readonly TElem[]): WorkflowBranchBuilder<TElem>;
|
|
@@ -1712,19 +1721,22 @@ declare class WorkflowBranchBuilder<TCurrentJson> {
|
|
|
1712
1721
|
agent<TOutputSchema extends z.ZodTypeAny>(options: WorkflowAgentOptions<TCurrentJson, TOutputSchema>): WorkflowBranchBuilder<z.output<TOutputSchema>>;
|
|
1713
1722
|
agent(options: WorkflowAgentOptions<TCurrentJson, undefined>): WorkflowBranchBuilder<Record<string, unknown>>;
|
|
1714
1723
|
agent<TOutputSchema extends z.ZodTypeAny>(name: string, options: WorkflowAgentOptions<TCurrentJson, TOutputSchema | undefined>): WorkflowBranchBuilder<TOutputSchema extends z.ZodTypeAny ? z.output<TOutputSchema> : Record<string, unknown>>;
|
|
1715
|
-
node<TConfig extends
|
|
1724
|
+
node<TConfig extends CredentialJsonRecord, TInputJson$1, TOutputJson$1>(definitionOrKey: DefinedNode<string, TConfig, TInputJson$1, TOutputJson$1> | string, config: DefinedNodeConfigInput<TConfig, TCurrentJson>, name?: string, id?: string): TCurrentJson extends TInputJson$1 ? WorkflowBranchBuilder<TOutputJson$1> : never;
|
|
1716
1725
|
getSteps(): ReadonlyArray<AnyRunnableNodeConfig>;
|
|
1717
1726
|
}
|
|
1718
1727
|
//#endregion
|
|
1719
1728
|
//#region src/workflowAuthoring/WorkflowChain.types.d.ts
|
|
1720
1729
|
type BranchCallback<TCurrentJson, TNextJson$1> = (branch: WorkflowBranchBuilder<TCurrentJson>) => WorkflowBranchBuilder<TNextJson$1>;
|
|
1721
1730
|
type RouteBranchCallback<TCurrentJson, TNextJson$1> = (branch: WorkflowChain<TCurrentJson>) => WorkflowChain<TNextJson$1>;
|
|
1731
|
+
type WorkflowMapCallback<TCurrentJson, TNextJson$1> = (item: Item<TCurrentJson>, ctx: NodeExecutionContext<MapData<TCurrentJson, TNextJson$1>>) => TNextJson$1;
|
|
1732
|
+
type WorkflowIfPredicate<TCurrentJson> = (item: Item<TCurrentJson>, ctx: NodeExecutionContext<If<TCurrentJson>>) => boolean;
|
|
1733
|
+
type WorkflowSwitchCaseKeyResolver<TCurrentJson> = (item: Item<TCurrentJson>, ctx: NodeExecutionContext<Switch<TCurrentJson>>) => string | Promise<string>;
|
|
1722
1734
|
declare class WorkflowChain<TCurrentJson> {
|
|
1723
1735
|
private readonly chain;
|
|
1724
1736
|
constructor(chain: ChainCursor<TCurrentJson>);
|
|
1725
1737
|
then<TOutputJson$1, TConfig extends RunnableNodeConfig<TCurrentJson, TOutputJson$1>>(config: TConfig): WorkflowChain<RunnableNodeOutputJson<TConfig>>;
|
|
1726
|
-
map<TNextJson$1>(mapper:
|
|
1727
|
-
map<TNextJson$1>(name: string, mapper:
|
|
1738
|
+
map<TNextJson$1>(mapper: WorkflowMapCallback<TCurrentJson, TNextJson$1>): WorkflowChain<TNextJson$1>;
|
|
1739
|
+
map<TNextJson$1>(name: string, mapper: WorkflowMapCallback<TCurrentJson, TNextJson$1>, options?: MapDataOptions): WorkflowChain<TNextJson$1>;
|
|
1728
1740
|
wait(duration: number | string): WorkflowChain<TCurrentJson>;
|
|
1729
1741
|
wait(name: string, duration: number | string, id?: string): WorkflowChain<TCurrentJson>;
|
|
1730
1742
|
split<TElem>(getElements: (item: Item<TCurrentJson>, ctx: NodeExecutionContext<Split<TCurrentJson, TElem>>) => readonly TElem[]): WorkflowChain<TElem>;
|
|
@@ -1742,11 +1754,11 @@ declare class WorkflowChain<TCurrentJson> {
|
|
|
1742
1754
|
mode: MergeMode;
|
|
1743
1755
|
prefer?: ReadonlyArray<string>;
|
|
1744
1756
|
}>, id?: string): WorkflowChain<TCurrentJson>;
|
|
1745
|
-
if<TBranchJson>(predicate:
|
|
1757
|
+
if<TBranchJson>(predicate: WorkflowIfPredicate<TCurrentJson>, branches: Readonly<{
|
|
1746
1758
|
true?: BranchCallback<TCurrentJson, TBranchJson>;
|
|
1747
1759
|
false?: BranchCallback<TCurrentJson, TBranchJson>;
|
|
1748
1760
|
}>): WorkflowChain<TBranchJson>;
|
|
1749
|
-
if<TBranchJson>(name: string, predicate:
|
|
1761
|
+
if<TBranchJson>(name: string, predicate: WorkflowIfPredicate<TCurrentJson>, branches: Readonly<{
|
|
1750
1762
|
true?: BranchCallback<TCurrentJson, TBranchJson>;
|
|
1751
1763
|
false?: BranchCallback<TCurrentJson, TBranchJson>;
|
|
1752
1764
|
}>): WorkflowChain<TBranchJson>;
|
|
@@ -1754,19 +1766,19 @@ declare class WorkflowChain<TCurrentJson> {
|
|
|
1754
1766
|
switch<TBranchJson>(cfg: Readonly<{
|
|
1755
1767
|
cases: readonly string[];
|
|
1756
1768
|
defaultCase: string;
|
|
1757
|
-
resolveCaseKey:
|
|
1769
|
+
resolveCaseKey: WorkflowSwitchCaseKeyResolver<TCurrentJson>;
|
|
1758
1770
|
branches: Readonly<Record<string, RouteBranchCallback<TCurrentJson, TBranchJson> | undefined>>;
|
|
1759
1771
|
}>): WorkflowChain<TBranchJson>;
|
|
1760
1772
|
switch<TBranchJson>(name: string, cfg: Readonly<{
|
|
1761
1773
|
cases: readonly string[];
|
|
1762
1774
|
defaultCase: string;
|
|
1763
|
-
resolveCaseKey:
|
|
1775
|
+
resolveCaseKey: WorkflowSwitchCaseKeyResolver<TCurrentJson>;
|
|
1764
1776
|
branches: Readonly<Record<string, RouteBranchCallback<TCurrentJson, TBranchJson> | undefined>>;
|
|
1765
1777
|
}>, id?: string): WorkflowChain<TBranchJson>;
|
|
1766
1778
|
agent<TOutputSchema extends z.ZodTypeAny>(options: WorkflowAgentOptions<TCurrentJson, TOutputSchema>): WorkflowChain<z.output<TOutputSchema>>;
|
|
1767
1779
|
agent(options: WorkflowAgentOptions<TCurrentJson, undefined>): WorkflowChain<Record<string, unknown>>;
|
|
1768
1780
|
agent<TOutputSchema extends z.ZodTypeAny>(name: string, options: WorkflowAgentOptions<TCurrentJson, TOutputSchema | undefined>): WorkflowChain<TOutputSchema extends z.ZodTypeAny ? z.output<TOutputSchema> : Record<string, unknown>>;
|
|
1769
|
-
node<TConfig extends
|
|
1781
|
+
node<TConfig extends CredentialJsonRecord, TInputJson$1, TOutputJson$1>(definitionOrKey: DefinedNode<string, TConfig, TInputJson$1, TOutputJson$1> | string, config: DefinedNodeConfigInput<TConfig, TCurrentJson>, name?: string, id?: string): TCurrentJson extends TInputJson$1 ? WorkflowChain<TOutputJson$1> : never;
|
|
1770
1782
|
build(): WorkflowDefinition;
|
|
1771
1783
|
}
|
|
1772
1784
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentConfigInspector, AgentConnectionNodeCollector, AgentGuardrailDefaults, AgentMessageConfigNormalizer, CallableToolConfig, ConnectionInvocationIdFactory, ConnectionNodeIdFactory, CoreTokens, DefinedNodeRegistry,
|
|
1
|
+
import { AgentConfigInspector, AgentConnectionNodeCollector, AgentGuardrailDefaults, AgentMessageConfigNormalizer, CallableToolConfig, ConnectionInvocationIdFactory, ConnectionNodeIdFactory, CoreTokens, DefinedNodeRegistry, ItemExprResolver, ItemsInputNormalizer, NodeBackedToolConfig, NodeOutputNormalizer, RetryPolicy, RunnableOutputBehaviorResolver, WorkflowBuilder, chatModel, emitPorts, getOriginIndexFromItem, inject, injectable, isPortsEmission, node } from "@codemation/core";
|
|
2
2
|
import { ChatOpenAI } from "@langchain/openai";
|
|
3
3
|
import { AIMessage, HumanMessage, SystemMessage, ToolMessage } from "@langchain/core/messages";
|
|
4
4
|
import { isInteropZodSchema } from "@langchain/core/utils/types";
|
|
@@ -2690,9 +2690,9 @@ var AgentToolCallPortMap = class {
|
|
|
2690
2690
|
//#region src/nodes/NodeBackedToolRuntime.ts
|
|
2691
2691
|
var _ref$1, _ref2$1, _ref3$1;
|
|
2692
2692
|
let NodeBackedToolRuntime = class NodeBackedToolRuntime$1 {
|
|
2693
|
-
constructor(nodeResolver,
|
|
2693
|
+
constructor(nodeResolver, itemExprResolver, outputNormalizer, outputBehaviorResolver) {
|
|
2694
2694
|
this.nodeResolver = nodeResolver;
|
|
2695
|
-
this.
|
|
2695
|
+
this.itemExprResolver = itemExprResolver;
|
|
2696
2696
|
this.outputNormalizer = outputNormalizer;
|
|
2697
2697
|
this.outputBehaviorResolver = outputBehaviorResolver;
|
|
2698
2698
|
}
|
|
@@ -2734,7 +2734,7 @@ let NodeBackedToolRuntime = class NodeBackedToolRuntime$1 {
|
|
|
2734
2734
|
item: nodeInput,
|
|
2735
2735
|
itemIndex: 0,
|
|
2736
2736
|
items,
|
|
2737
|
-
ctx: await this.
|
|
2737
|
+
ctx: await this.itemExprResolver.resolveConfigForItem(ctx, nodeInput, 0, items)
|
|
2738
2738
|
};
|
|
2739
2739
|
const raw = await Promise.resolve(runnable.execute(execArgs));
|
|
2740
2740
|
return this.outputNormalizer.normalizeExecuteResult({
|
|
@@ -2755,12 +2755,12 @@ let NodeBackedToolRuntime = class NodeBackedToolRuntime$1 {
|
|
|
2755
2755
|
NodeBackedToolRuntime = __decorate([
|
|
2756
2756
|
injectable(),
|
|
2757
2757
|
__decorateParam(0, inject(CoreTokens.NodeResolver)),
|
|
2758
|
-
__decorateParam(1, inject(
|
|
2758
|
+
__decorateParam(1, inject(ItemExprResolver)),
|
|
2759
2759
|
__decorateParam(2, inject(NodeOutputNormalizer)),
|
|
2760
2760
|
__decorateParam(3, inject(RunnableOutputBehaviorResolver)),
|
|
2761
2761
|
__decorateMetadata("design:paramtypes", [
|
|
2762
2762
|
Object,
|
|
2763
|
-
typeof (_ref$1 = typeof
|
|
2763
|
+
typeof (_ref$1 = typeof ItemExprResolver !== "undefined" && ItemExprResolver) === "function" ? _ref$1 : Object,
|
|
2764
2764
|
typeof (_ref2$1 = typeof NodeOutputNormalizer !== "undefined" && NodeOutputNormalizer) === "function" ? _ref2$1 : Object,
|
|
2765
2765
|
typeof (_ref3$1 = typeof RunnableOutputBehaviorResolver !== "undefined" && RunnableOutputBehaviorResolver) === "function" ? _ref3$1 : Object
|
|
2766
2766
|
])
|
|
@@ -2782,7 +2782,7 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
2782
2782
|
outputPorts = ["main"];
|
|
2783
2783
|
/**
|
|
2784
2784
|
* Engine validates {@link RunnableNodeConfig.inputSchema} (Zod) on {@code item.json} before enqueue, then resolves
|
|
2785
|
-
* per-item **`
|
|
2785
|
+
* per-item **`itemExpr`** leaves on config before {@link #execute}. Prefer modeling prompts as
|
|
2786
2786
|
* {@code { messages: [{ role, content }, ...] }} (on input or config) so persisted inputs are visible in the UI.
|
|
2787
2787
|
*/
|
|
2788
2788
|
inputSchema = unknown();
|
|
@@ -4028,7 +4028,7 @@ var WorkflowBranchBuilder = class WorkflowBranchBuilder {
|
|
|
4028
4028
|
map(nameOrMapper, mapperOrUndefined, options) {
|
|
4029
4029
|
const name = typeof nameOrMapper === "string" ? nameOrMapper : "Map data";
|
|
4030
4030
|
const mapper = typeof nameOrMapper === "string" ? mapperOrUndefined : nameOrMapper;
|
|
4031
|
-
return this.then(new MapData(name,
|
|
4031
|
+
return this.then(new MapData(name, mapper, options));
|
|
4032
4032
|
}
|
|
4033
4033
|
wait(nameOrDuration, durationOrUndefined, id) {
|
|
4034
4034
|
const name = typeof nameOrDuration === "string" && durationOrUndefined !== void 0 ? nameOrDuration : "Wait";
|
|
@@ -4074,7 +4074,7 @@ var WorkflowChain = class WorkflowChain {
|
|
|
4074
4074
|
map(nameOrMapper, mapperOrUndefined, options) {
|
|
4075
4075
|
const name = typeof nameOrMapper === "string" ? nameOrMapper : "Map data";
|
|
4076
4076
|
const mapper = typeof nameOrMapper === "string" ? mapperOrUndefined : nameOrMapper;
|
|
4077
|
-
return this.then(new MapData(name,
|
|
4077
|
+
return this.then(new MapData(name, mapper, options));
|
|
4078
4078
|
}
|
|
4079
4079
|
wait(nameOrDuration, durationOrUndefined, id) {
|
|
4080
4080
|
const name = typeof nameOrDuration === "string" && durationOrUndefined !== void 0 ? nameOrDuration : "Wait";
|
|
@@ -4106,7 +4106,7 @@ var WorkflowChain = class WorkflowChain {
|
|
|
4106
4106
|
const name = typeof nameOrPredicate === "string" ? nameOrPredicate : "If";
|
|
4107
4107
|
const predicate = typeof nameOrPredicate === "string" ? predicateOrBranches : nameOrPredicate;
|
|
4108
4108
|
const branches = typeof nameOrPredicate === "string" ? branchesOrUndefined : predicateOrBranches;
|
|
4109
|
-
const cursor = this.chain.then(new If(name, (item) => predicate(item
|
|
4109
|
+
const cursor = this.chain.then(new If(name, (item, _index, _items, ctx) => predicate(item, ctx)));
|
|
4110
4110
|
const trueSteps = branches.true?.(new WorkflowBranchBuilder()).getSteps();
|
|
4111
4111
|
const falseSteps = branches.false?.(new WorkflowBranchBuilder()).getSteps();
|
|
4112
4112
|
return new WorkflowChain(cursor.when({
|
|
@@ -4124,7 +4124,7 @@ var WorkflowChain = class WorkflowChain {
|
|
|
4124
4124
|
return this.then(new Switch(name, {
|
|
4125
4125
|
cases: cfg.cases,
|
|
4126
4126
|
defaultCase: cfg.defaultCase,
|
|
4127
|
-
resolveCaseKey: (item) => cfg.resolveCaseKey(item
|
|
4127
|
+
resolveCaseKey: (item, _index, _items, ctx) => cfg.resolveCaseKey(item, ctx)
|
|
4128
4128
|
}, id)).route(cfg.branches);
|
|
4129
4129
|
}
|
|
4130
4130
|
agent(nameOrOptions, optionsOrUndefined) {
|