@codemation/core 0.2.1 → 0.3.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +2 -0
  3. package/dist/{EngineRuntimeRegistration.types-0sgV2XL2.d.ts → EngineRuntimeRegistration.types-Bjeo7Sfq.d.ts} +2 -2
  4. package/dist/{EngineWorkflowRunnerService-Dx7bJsJR.d.cts → EngineWorkflowRunnerService-Dd4yD31l.d.cts} +2 -2
  5. package/dist/{InMemoryRunDataFactory-qIYQEar7.d.cts → InMemoryRunDataFactory-OUzDmAHt.d.cts} +2 -2
  6. package/dist/{RunIntentService-BCvGdOSY.d.ts → RunIntentService-BAKikN8h.d.ts} +80 -12
  7. package/dist/{RunIntentService-CV8izV8t.d.cts → RunIntentService-Bkg4oYrM.d.cts} +74 -5
  8. package/dist/bootstrap/index.cjs +31 -31
  9. package/dist/bootstrap/index.d.cts +5 -3
  10. package/dist/bootstrap/index.d.ts +3 -3
  11. package/dist/bootstrap/index.js +2 -2
  12. package/dist/bootstrap-BD6CobHl.js +215 -0
  13. package/dist/bootstrap-BD6CobHl.js.map +1 -0
  14. package/dist/bootstrap-DwS5S7s9.cjs +240 -0
  15. package/dist/bootstrap-DwS5S7s9.cjs.map +1 -0
  16. package/dist/{index-CueSzHsf.d.ts → index-uCm9l0nw.d.ts} +64 -15
  17. package/dist/index.cjs +114 -32
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +68 -21
  20. package/dist/index.d.ts +3 -3
  21. package/dist/index.js +83 -2
  22. package/dist/index.js.map +1 -1
  23. package/dist/{RunIntentService-BFA48UpH.js → runtime-Cy-3FTI_.js} +1224 -94
  24. package/dist/runtime-Cy-3FTI_.js.map +1 -0
  25. package/dist/{RunIntentService-DcxXf_AM.cjs → runtime-ZJUpWmPH.cjs} +1251 -132
  26. package/dist/runtime-ZJUpWmPH.cjs.map +1 -0
  27. package/dist/testing.cjs +74 -29
  28. package/dist/testing.cjs.map +1 -1
  29. package/dist/testing.d.cts +55 -3
  30. package/dist/testing.d.ts +55 -3
  31. package/dist/testing.js +46 -3
  32. package/dist/testing.js.map +1 -1
  33. package/dist/workflowActivationPolicy-B8HzTk3o.js.map +1 -1
  34. package/dist/workflowActivationPolicy-BzyzXLa_.cjs.map +1 -1
  35. package/package.json +1 -1
  36. package/src/ai/AgentMessageConfigNormalizerFactory.ts +43 -0
  37. package/src/ai/AgentToolFactory.ts +2 -2
  38. package/src/ai/AiHost.ts +10 -9
  39. package/src/ai/NodeBackedToolConfig.ts +1 -1
  40. package/src/authoring/defineNode.types.ts +153 -10
  41. package/src/authoring/index.ts +3 -1
  42. package/src/contracts/runtimeTypes.ts +26 -0
  43. package/src/contracts/workflowTypes.ts +67 -5
  44. package/src/execution/ActivationEnqueueService.ts +8 -5
  45. package/src/execution/NodeActivationRequestInputPreparer.ts +89 -0
  46. package/src/execution/NodeExecutor.ts +38 -1
  47. package/src/execution/NodeInputContractError.ts +13 -0
  48. package/src/execution/index.ts +2 -0
  49. package/src/orchestration/RunContinuationService.ts +181 -50
  50. package/src/planning/RunQueuePlanner.ts +12 -1
  51. package/src/runtime/EngineFactory.ts +3 -0
  52. package/src/testing/ItemHarnessNode.ts +27 -0
  53. package/src/testing/ItemHarnessNodeConfig.ts +43 -0
  54. package/src/testing/RegistrarEngineTestKitFactory.ts +2 -0
  55. package/src/testing.ts +2 -0
  56. package/src/workflow/dsl/ChainCursorResolver.ts +1 -1
  57. package/src/workflow/dsl/workflowBuilderTypes.ts +8 -5
  58. package/dist/RunIntentService-BFA48UpH.js.map +0 -1
  59. package/dist/RunIntentService-DcxXf_AM.cjs.map +0 -1
  60. package/dist/bootstrap-D67Sf2BF.js +0 -1136
  61. package/dist/bootstrap-D67Sf2BF.js.map +0 -1
  62. package/dist/bootstrap-DoQHAEQJ.cjs +0 -1203
  63. package/dist/bootstrap-DoQHAEQJ.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { $t as RunnableNodeInputJson, An as BinaryStorageWriteResult, At as NodeActivationId, Bn as NodeActivationContinuation, Bt as NodeOutputs, Cr as WorkflowActivationPolicy, Di as RunEventBus, Dn as BinaryStorageReadResult, Ei as RunEvent, En as BinaryStorage, Fi as RetryPolicySpec, Fn as ExecutionContext, Gn as NodeBinaryAttachmentService, Gt as ParentExecutionRef, Hn as NodeActivationRequest, Ht as NodeSchedulerDecision, In as ExecutionContextFactory, Jr as RunPruneCandidate, Jt as RunDataFactory, K as AnyCredentialType, Kn as NodeExecutionContext, Lt as NodeId, Mt as NodeConnectionName, Nt as NodeDefinition, Oi as RunEventSubscription, On as BinaryStorageStatResult, Or as EngineRunCounters, Ot as JsonValue, Pn as ExecutionBinaryService, Qn as NodeResolver, Qt as RunnableNodeConfig, Rr as PersistedRunSchedulingState, St as Item, Tn as BinaryBody, Vr as PersistedWorkflowSnapshotNode, Wn as NodeActivationScheduler, X as CredentialFieldSchema, Xn as NodeExecutionStatePublisher, Xt as RunId, Yn as NodeExecutionScheduler, Yt as RunDataSnapshot, Z as CredentialHealth, _t as BinaryAttachment, an as WorkflowDefinition, at as CredentialRequirement, bt as ExecutionMode, ct as CredentialSessionService, di as TypeToken, dn as WorkflowId, dt as CredentialTypeDefinition, ei as RunSummary, er as PreparedNodeActivationDispatch, ft as CredentialTypeId, hr as HttpMethod, ii as WorkflowExecutionRepository, jn as EngineDeps, jr as NodeExecutionSnapshot, jt as NodeConfigBase, kt as MutableRunData, l as WorkflowSnapshotCodec, lr as WorkflowNodeInstanceFactory, ni as WorkflowExecutionListingRepository, nt as CredentialJsonRecord, qn as NodeExecutionRequest, ri as WorkflowExecutionPruneRepository, st as CredentialSessionFactoryArgs, u as Engine, ur as WorkflowRepository, ut as CredentialType, vr as WebhookInvocationMatch, wi as EngineExecutionLimitsPolicy, wt as Items, xr as WebhookTriggerRoutingDiagnostics, yr as WebhookTriggerMatcher, zr as PersistedRunState, zt as NodeOffloadPolicy } from "./RunIntentService-BCvGdOSY.js";
1
+ import { $n as NodeExecutionRequest, $t as RunId, Ai as EngineExecutionLimitsPolicy, An as BinaryBody, Bn as ExecutionContext, Bt as NodeId, Dr as WebhookTriggerRoutingDiagnostics, Dt as Items, Fn as BinaryStorageWriteResult, Ft as NodeConnectionName, Gr as PersistedRunState, Gt as NodeSchedulerDecision, Ht as NodeOffloadPolicy, In as EngineDeps, It as NodeDefinition, Jn as NodeActivationRequest, Jt as ParentExecutionRef, K as AnyCredentialType, Kn as NodeActivationContinuation, Lr as NodeExecutionSnapshot, Mi as RunEvent, Mn as BinaryStorageReadResult, Mt as MutableRunData, Ni as RunEventBus, Nn as BinaryStorageStatResult, Nt as NodeActivationId, Pi as RunEventSubscription, Pr as EngineRunCounters, Pt as NodeConfigBase, Qn as NodeExecutionContext, Qt as RunDataSnapshot, St as Item, Tr as WebhookTriggerMatcher, Ut as NodeOutputs, Vi as RetryPolicySpec, Vn as ExecutionContextFactory, Wr as PersistedRunSchedulingState, X as CredentialFieldSchema, Xn as NodeActivationScheduler, Z as CredentialHealth, Zn as NodeBinaryAttachmentService, Zt as RunDataFactory, _i as TypeToken, _t as BinaryAttachment, at as CredentialRequirement, bt as ExecutionMode, ci as WorkflowExecutionListingRepository, ct as CredentialSessionService, dt as CredentialTypeDefinition, ei as RunPruneCandidate, ft as CredentialTypeId, gr as WorkflowRepository, hn as WorkflowId, hr as WorkflowNodeInstanceFactory, ir as NodeResolver, jn as BinaryStorage, jt as JsonValue, kr as WorkflowActivationPolicy, l as WorkflowSnapshotCodec, li as WorkflowExecutionPruneRepository, ln as WorkflowDefinition, nn as RunnableNodeInputJson, nr as NodeExecutionStatePublisher, nt as CredentialJsonRecord, oi as RunSummary, or as PreparedNodeActivationDispatch, qr as PersistedWorkflowSnapshotNode, st as CredentialSessionFactoryArgs, tn as RunnableNodeConfig, tr as NodeExecutionScheduler, u as Engine, ui as WorkflowExecutionRepository, ut as CredentialType, wr as WebhookInvocationMatch, wt as ItemInputMapper, xr as HttpMethod, zn as ExecutionBinaryService } from "./RunIntentService-BAKikN8h.js";
2
2
  import { ZodType, input, output, z } from "zod";
3
3
 
4
4
  //#region src/workflowSnapshots/MissingRuntimeFallbacksFactory.d.ts
@@ -89,6 +89,8 @@ declare class NodeExecutor {
89
89
  execute(request: NodeActivationRequest): Promise<NodeOutputs>;
90
90
  private executeMultiInputNode;
91
91
  private executeSingleInputNode;
92
+ private hasExecuteOne;
93
+ private executeItemNode;
92
94
  }
93
95
  //#endregion
94
96
  //#region src/execution/NodeInstanceFactory.d.ts
@@ -130,17 +132,35 @@ interface DefinedNodeRunContext<TConfig$1 extends CredentialJsonRecord, TBinding
130
132
  readonly credentials: DefinedNodeCredentialAccessors<TBindings>;
131
133
  readonly execution: NodeExecutionContext<RunnableNodeConfig<TConfig$1, unknown>>;
132
134
  }
133
- interface DefinedNode<TKey$1 extends string, TConfig$1 extends CredentialJsonRecord, TInputJson, TOutputJson, _TBindings extends DefinedNodeCredentialBindings | undefined = undefined> {
135
+ /**
136
+ * Arguments for {@link defineNode} `executeOne` (engine `ctx` matches {@link ItemNode.executeOne};
137
+ * the second callback parameter adds {@link DefinedNodeRunContext} for credential accessors).
138
+ */
139
+ type DefineNodeExecuteOneArgs<TConfig$1 extends CredentialJsonRecord, TInputJson, TWireJson> = Readonly<{
140
+ input: TInputJson;
141
+ item: Item;
142
+ itemIndex: number;
143
+ items: Items;
144
+ ctx: NodeExecutionContext<RunnableNodeConfig<TInputJson, unknown, TWireJson> & Readonly<{
145
+ config: TConfig$1;
146
+ }>>;
147
+ }>;
148
+ interface DefinedNode<TKey$1 extends string, TConfig$1 extends CredentialJsonRecord, TInputJson, TOutputJson, _TBindings extends DefinedNodeCredentialBindings | undefined = undefined, TWireJson = TInputJson> {
134
149
  readonly kind: "defined-node";
135
150
  readonly key: TKey$1;
136
151
  readonly title: string;
137
152
  readonly description?: string;
138
- create(config: TConfig$1, name?: string, id?: string): RunnableNodeConfig<TInputJson, TOutputJson>;
153
+ create(config: TConfig$1, name?: string, id?: string): RunnableNodeConfig<TInputJson, TOutputJson, TWireJson>;
139
154
  register(context: {
140
155
  registerNode<TValue>(token: TypeToken<TValue>, implementation?: TypeToken<TValue>): void;
141
156
  }): void;
142
157
  }
143
- interface DefineNodeOptions<TKey$1 extends string, TConfig$1 extends CredentialJsonRecord, TInputJson, TOutputJson, TBindings extends DefinedNodeCredentialBindings | undefined = undefined> {
158
+ /**
159
+ * Plugin / DSL-friendly node: **one item in, one item out** per engine activation step.
160
+ * The engine applies {@link RunnableNodeConfig.mapInput} (if any) + {@link RunnableNodeConfig.inputSchema}
161
+ * before `executeOne`. Use {@link defineBatchNode} for legacy batch `run(items, …)` semantics.
162
+ */
163
+ interface DefineNodeOptions<TKey$1 extends string, TConfig$1 extends CredentialJsonRecord, TInputJson, TOutputJson, TBindings extends DefinedNodeCredentialBindings | undefined = undefined, TWireJson = TInputJson> {
144
164
  readonly key: TKey$1;
145
165
  readonly title: string;
146
166
  readonly description?: string;
@@ -149,12 +169,35 @@ interface DefineNodeOptions<TKey$1 extends string, TConfig$1 extends CredentialJ
149
169
  * The Next host resolves Lucide (`lucide:…`), built-in SVGs (`builtin:…`), Simple Icons (`si:…`), and image URLs (`https:`, `data:`, `/…`).
150
170
  */
151
171
  readonly icon?: string;
172
+ /** Default values / form hints for **static** node configuration (credentials, retry, IDs), not per-item payload. */
173
+ readonly input?: Readonly<Record<keyof TConfig$1 & string, unknown>>;
174
+ readonly configSchema?: z.ZodType<TConfig$1>;
175
+ readonly credentials?: TBindings;
176
+ /**
177
+ * Validates **`input`** after optional {@link mapInput} (engine also accepts `inputSchema` on the node class).
178
+ */
179
+ readonly inputSchema?: ZodType<TInputJson>;
180
+ /**
181
+ * Maps wire JSON (`item.json` from upstream) to execute input before validation.
182
+ */
183
+ readonly mapInput?: ItemInputMapper<TWireJson, TInputJson>;
184
+ executeOne(args: DefineNodeExecuteOneArgs<TConfig$1, TInputJson, TWireJson>, context: DefinedNodeRunContext<TConfig$1, TBindings>): MaybePromise$1<TOutputJson>;
185
+ }
186
+ /**
187
+ * Batch-oriented defined node (legacy): receives all items at once via `run`.
188
+ */
189
+ interface DefineBatchNodeOptions<TKey$1 extends string, TConfig$1 extends CredentialJsonRecord, TInputJson, TOutputJson, TBindings extends DefinedNodeCredentialBindings | undefined = undefined> {
190
+ readonly key: TKey$1;
191
+ readonly title: string;
192
+ readonly description?: string;
193
+ readonly icon?: string;
152
194
  readonly input?: Readonly<Record<keyof TConfig$1 & string, unknown>>;
153
195
  readonly configSchema?: z.ZodType<TConfig$1>;
154
196
  readonly credentials?: TBindings;
155
197
  run(items: ReadonlyArray<TInputJson>, context: DefinedNodeRunContext<TConfig$1, TBindings>): MaybePromise$1<ReadonlyArray<TOutputJson>>;
156
198
  }
157
- declare function defineNode<TKey$1 extends string, TConfig$1 extends CredentialJsonRecord, TInputJson, TOutputJson, TBindings extends DefinedNodeCredentialBindings | undefined = undefined>(options: DefineNodeOptions<TKey$1, TConfig$1, TInputJson, TOutputJson, TBindings>): DefinedNode<TKey$1, TConfig$1, TInputJson, TOutputJson, TBindings>;
199
+ declare function defineNode<TKey$1 extends string, TConfig$1 extends CredentialJsonRecord, TInputJson, TOutputJson, TBindings extends DefinedNodeCredentialBindings | undefined = undefined, TWireJson = TInputJson>(options: DefineNodeOptions<TKey$1, TConfig$1, TInputJson, TOutputJson, TBindings, TWireJson>): DefinedNode<TKey$1, TConfig$1, TInputJson, TOutputJson, TBindings, TWireJson>;
200
+ declare function defineBatchNode<TKey$1 extends string, TConfig$1 extends CredentialJsonRecord, TInputJson, TOutputJson, TBindings extends DefinedNodeCredentialBindings | undefined = undefined>(options: DefineBatchNodeOptions<TKey$1, TConfig$1, TInputJson, TOutputJson, TBindings>): DefinedNode<TKey$1, TConfig$1, TInputJson, TOutputJson, TBindings, TInputJson>;
158
201
  //#endregion
159
202
  //#region src/authoring/DefinedNodeRegistry.d.ts
160
203
  declare class DefinedNodeRegistry {
@@ -185,7 +228,7 @@ declare function defineCredential<TPublicSource extends CredentialFieldMap<any>
185
228
  };
186
229
  //#endregion
187
230
  //#region src/ai/NodeBackedToolConfig.d.ts
188
- declare class NodeBackedToolConfig<TNodeConfig extends RunnableNodeConfig<any, any>, TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny> implements ToolConfig {
231
+ declare class NodeBackedToolConfig<TNodeConfig extends RunnableNodeConfig<any, any, any>, TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny> implements ToolConfig {
189
232
  readonly name: string;
190
233
  readonly node: TNodeConfig;
191
234
  readonly type: TypeToken<unknown>;
@@ -208,7 +251,7 @@ declare class NodeBackedToolConfig<TNodeConfig extends RunnableNodeConfig<any, a
208
251
  //#endregion
209
252
  //#region src/ai/AgentToolFactory.d.ts
210
253
  declare class AgentToolFactoryImpl {
211
- asTool<TNodeConfig extends RunnableNodeConfig<any, any>, TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny>(node: TNodeConfig, options: Readonly<{
254
+ asTool<TNodeConfig extends RunnableNodeConfig<any, any, any>, TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny>(node: TNodeConfig, options: Readonly<{
212
255
  name?: string;
213
256
  } & NodeBackedToolConfigOptions<TNodeConfig, TInputSchema, TOutputSchema>>): NodeBackedToolConfig<TNodeConfig, TInputSchema, TOutputSchema>;
214
257
  private withDefaultAgentInputMapper;
@@ -219,7 +262,13 @@ declare const AgentToolFactory: AgentToolFactoryImpl;
219
262
  //#endregion
220
263
  //#region src/ai/AgentMessageConfigNormalizerFactory.d.ts
221
264
  declare class AgentMessageConfigNormalizer {
265
+ /**
266
+ * Prefer {@code input.messages} when present (ItemNode / engine-mapped payloads); otherwise resolve from
267
+ * {@link AgentNodeConfig.messages} templates.
268
+ */
269
+ static resolveFromInputOrConfig<TInputJson, TOutputJson>(input: unknown, config: AgentNodeConfig<TInputJson, TOutputJson>, args: AgentMessageBuildArgs<TInputJson>): ReadonlyArray<AgentMessageDto>;
222
270
  static normalize<TInputJson, TOutputJson>(config: AgentNodeConfig<TInputJson, TOutputJson>, args: AgentMessageBuildArgs<TInputJson>): ReadonlyArray<AgentMessageDto>;
271
+ private static tryMessagesFromStructuredInput;
223
272
  private static normalizeRichMessages;
224
273
  private static lineToDto;
225
274
  }
@@ -328,7 +377,7 @@ interface ChatModelFactory<TConfig$1 extends ChatModelConfig = ChatModelConfig>
328
377
  ctx: NodeExecutionContext<any>;
329
378
  }>): Promise<LangChainChatModelLike> | LangChainChatModelLike;
330
379
  }
331
- type NodeBackedToolInputMapperArgs<TNodeConfig extends RunnableNodeConfig<any, any>, TToolInput = unknown> = Readonly<{
380
+ type NodeBackedToolInputMapperArgs<TNodeConfig extends RunnableNodeConfig<any, any, any>, TToolInput = unknown> = Readonly<{
332
381
  input: TToolInput;
333
382
  item: Item;
334
383
  itemIndex: number;
@@ -336,7 +385,7 @@ type NodeBackedToolInputMapperArgs<TNodeConfig extends RunnableNodeConfig<any, a
336
385
  ctx: NodeExecutionContext<any>;
337
386
  node: TNodeConfig;
338
387
  }>;
339
- type NodeBackedToolOutputMapperArgs<TNodeConfig extends RunnableNodeConfig<any, any>, TToolInput = unknown> = Readonly<{
388
+ type NodeBackedToolOutputMapperArgs<TNodeConfig extends RunnableNodeConfig<any, any, any>, TToolInput = unknown> = Readonly<{
340
389
  input: TToolInput;
341
390
  item: Item;
342
391
  itemIndex: number;
@@ -345,9 +394,9 @@ type NodeBackedToolOutputMapperArgs<TNodeConfig extends RunnableNodeConfig<any,
345
394
  node: TNodeConfig;
346
395
  outputs: NodeOutputs;
347
396
  }>;
348
- type NodeBackedToolInputMapper<TNodeConfig extends RunnableNodeConfig<any, any>, TToolInput = unknown> = (args: NodeBackedToolInputMapperArgs<TNodeConfig, TToolInput>) => Item<RunnableNodeInputJson<TNodeConfig>> | RunnableNodeInputJson<TNodeConfig>;
349
- type NodeBackedToolOutputMapper<TNodeConfig extends RunnableNodeConfig<any, any>, TToolInput = unknown, TToolOutput = unknown> = (args: NodeBackedToolOutputMapperArgs<TNodeConfig, TToolInput>) => TToolOutput;
350
- type NodeBackedToolConfigOptions<TNodeConfig extends RunnableNodeConfig<any, any>, TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny> = Readonly<{
397
+ type NodeBackedToolInputMapper<TNodeConfig extends RunnableNodeConfig<any, any, any>, TToolInput = unknown> = (args: NodeBackedToolInputMapperArgs<TNodeConfig, TToolInput>) => Item<RunnableNodeInputJson<TNodeConfig>> | RunnableNodeInputJson<TNodeConfig>;
398
+ type NodeBackedToolOutputMapper<TNodeConfig extends RunnableNodeConfig<any, any, any>, TToolInput = unknown, TToolOutput = unknown> = (args: NodeBackedToolOutputMapperArgs<TNodeConfig, TToolInput>) => TToolOutput;
399
+ type NodeBackedToolConfigOptions<TNodeConfig extends RunnableNodeConfig<any, any, any>, TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny> = Readonly<{
351
400
  description?: string;
352
401
  presentation?: AgentCanvasPresentation;
353
402
  inputSchema: TInputSchema;
@@ -355,7 +404,7 @@ type NodeBackedToolConfigOptions<TNodeConfig extends RunnableNodeConfig<any, any
355
404
  mapInput?: NodeBackedToolInputMapper<TNodeConfig, input<TInputSchema>>;
356
405
  mapOutput?: NodeBackedToolOutputMapper<TNodeConfig, input<TInputSchema>, output<TOutputSchema>>;
357
406
  }>;
358
- interface AgentNodeConfig<TInputJson = unknown, TOutputJson = unknown> extends RunnableNodeConfig<TInputJson, TOutputJson> {
407
+ interface AgentNodeConfig<TInputJson = unknown, TOutputJson = unknown, TWireJson = TInputJson> extends RunnableNodeConfig<TInputJson, TOutputJson, TWireJson> {
359
408
  readonly messages: AgentMessageConfig<TInputJson>;
360
409
  readonly chatModel: ChatModelConfig;
361
410
  readonly tools?: ReadonlyArray<ToolConfig>;
@@ -654,5 +703,5 @@ declare class LocalOnlyScheduler implements NodeExecutionScheduler {
654
703
  }>;
655
704
  }
656
705
  //#endregion
657
- export { LangChainChatModelLike as $, AgentConnectionNodeRole as A, AsyncSleeper as At, AgentMessageTemplate as B, PersistedRuntimeTypeKind as C, Clock as Ct, AgentConnectionCredentialSource as D, InProcessRetryRunner as Dt, InMemoryRunEventBus as E, NodeExecutor as Et, AgentMessageBuildArgs as F, AgentToolCall as G, AgentModelInvocationOptions as H, AgentMessageConfig as I, AgentToolExecuteArgs as J, AgentToolCallPlanner as K, AgentMessageDto as L, AgentCanvasPresentation as M, NodeEventPublisher as Mt, AgentGuardrailConfig as N, EngineCompositionDeps as Nt, AgentConnectionNodeCollector as O, DefaultExecutionContextFactory as Ot, AgentGuardrailDefaults as P, EngineFactory as Pt, ChatModelFactory as Q, AgentMessageLine as R, PersistedRuntimeTypeDecoratorOptions as S, defineNode as St, EventPublishingWorkflowExecutionRepository as T, NodeInstanceFactory as Tt, AgentNodeConfig as U, AgentMessageTemplateContent as V, AgentTool as W, AgentTurnLimitBehavior as X, AgentToolToken as Y, ChatModelConfig as Z, tool as _, DefinedNode as _t, ConfigDrivenOffloadPolicy as a, Tool as at, PersistedRuntimeTypeMetadataStore as b, DefinedNodeCredentialBindings as bt, InMemoryWorkflowExecutionRepository as c, ZodSchemaAny as ct, DefaultExecutionBinaryService as d, AgentToolFactory as dt, NodeBackedToolConfigOptions as et, UnavailableBinaryStorage as f, NodeBackedToolConfig as ft, node as g, DefineNodeOptions as gt, getPersistedRuntimeTypeMetadata as h, DefinedNodeRegistry as ht, InlineDrivingScheduler as i, NodeBackedToolOutputMapperArgs as it, AgentAttachmentRole as j, CredentialResolverFactory as jt, AgentConnectionNodeDescriptor as k, DefaultAsyncSleeper as kt, InMemoryRunDataFactory as l, AgentConfigInspector as lt, chatModel as m, defineCredential as mt, HintOnlyOffloadPolicy as n, NodeBackedToolInputMapperArgs as nt, WorkflowRepositoryWebhookTriggerMatcher as o, ToolConfig as ot, ItemsInputNormalizer as p, DefineCredentialOptions as pt, AgentToolDefinition as q, DefaultDrivingScheduler as r, NodeBackedToolOutputMapper as rt, RunSummaryMapper as s, ToolExecuteArgs as st, LocalOnlyScheduler as t, NodeBackedToolInputMapper as tt, InMemoryBinaryStorage as u, AgentMessageConfigNormalizer as ut, StackTraceCallSitePathResolver as v, DefinedNodeCredentialAccessors as vt, PersistedRuntimeTypeMetadata as w, SystemClock as wt, InjectableRuntimeDecoratorComposer as x, DefinedNodeRunContext as xt, PersistedRuntimeTypeNameResolver as y, DefinedNodeCredentialBinding as yt, AgentMessageRole as z };
658
- //# sourceMappingURL=index-CueSzHsf.d.ts.map
706
+ export { LangChainChatModelLike as $, AgentConnectionNodeRole as A, InProcessRetryRunner as At, AgentMessageTemplate as B, PersistedRuntimeTypeKind as C, DefinedNodeRunContext as Ct, AgentConnectionCredentialSource as D, SystemClock as Dt, InMemoryRunEventBus as E, Clock as Et, AgentMessageBuildArgs as F, NodeEventPublisher as Ft, AgentToolCall as G, AgentModelInvocationOptions as H, AgentMessageConfig as I, EngineCompositionDeps as It, AgentToolExecuteArgs as J, AgentToolCallPlanner as K, AgentMessageDto as L, EngineFactory as Lt, AgentCanvasPresentation as M, DefaultAsyncSleeper as Mt, AgentGuardrailConfig as N, AsyncSleeper as Nt, AgentConnectionNodeCollector as O, NodeInstanceFactory as Ot, AgentGuardrailDefaults as P, CredentialResolverFactory as Pt, ChatModelFactory as Q, AgentMessageLine as R, PersistedRuntimeTypeDecoratorOptions as S, DefinedNodeCredentialBindings as St, EventPublishingWorkflowExecutionRepository as T, defineNode as Tt, AgentNodeConfig as U, AgentMessageTemplateContent as V, AgentTool as W, AgentTurnLimitBehavior as X, AgentToolToken as Y, ChatModelConfig as Z, tool as _, DefineNodeExecuteOneArgs as _t, ConfigDrivenOffloadPolicy as a, Tool as at, PersistedRuntimeTypeMetadataStore as b, DefinedNodeCredentialAccessors as bt, InMemoryWorkflowExecutionRepository as c, ZodSchemaAny as ct, DefaultExecutionBinaryService as d, AgentToolFactory as dt, NodeBackedToolConfigOptions as et, UnavailableBinaryStorage as f, NodeBackedToolConfig as ft, node as g, DefineBatchNodeOptions as gt, getPersistedRuntimeTypeMetadata as h, DefinedNodeRegistry as ht, InlineDrivingScheduler as i, NodeBackedToolOutputMapperArgs as it, AgentAttachmentRole as j, DefaultExecutionContextFactory as jt, AgentConnectionNodeDescriptor as k, NodeExecutor as kt, InMemoryRunDataFactory as l, AgentConfigInspector as lt, chatModel as m, defineCredential as mt, HintOnlyOffloadPolicy as n, NodeBackedToolInputMapperArgs as nt, WorkflowRepositoryWebhookTriggerMatcher as o, ToolConfig as ot, ItemsInputNormalizer as p, DefineCredentialOptions as pt, AgentToolDefinition as q, DefaultDrivingScheduler as r, NodeBackedToolOutputMapper as rt, RunSummaryMapper as s, ToolExecuteArgs as st, LocalOnlyScheduler as t, NodeBackedToolInputMapper as tt, InMemoryBinaryStorage as u, AgentMessageConfigNormalizer as ut, StackTraceCallSitePathResolver as v, DefineNodeOptions as vt, PersistedRuntimeTypeMetadata as w, defineBatchNode as wt, InjectableRuntimeDecoratorComposer as x, DefinedNodeCredentialBinding as xt, PersistedRuntimeTypeNameResolver as y, DefinedNode as yt, AgentMessageRole as z };
707
+ //# sourceMappingURL=index-uCm9l0nw.d.ts.map
package/dist/index.cjs CHANGED
@@ -1,11 +1,11 @@
1
- const require_RunIntentService = require('./RunIntentService-DcxXf_AM.cjs');
1
+ const require_runtime = require('./runtime-ZJUpWmPH.cjs');
2
2
  const require_workflowActivationPolicy = require('./workflowActivationPolicy-BzyzXLa_.cjs');
3
3
  let zod = require("zod");
4
- zod = require_RunIntentService.__toESM(zod);
4
+ zod = require_runtime.__toESM(zod);
5
5
  let node_crypto = require("node:crypto");
6
- node_crypto = require_RunIntentService.__toESM(node_crypto);
6
+ node_crypto = require_runtime.__toESM(node_crypto);
7
7
  let tsyringe = require("tsyringe");
8
- tsyringe = require_RunIntentService.__toESM(tsyringe);
8
+ tsyringe = require_runtime.__toESM(tsyringe);
9
9
 
10
10
  //#region src/contracts/Clock.ts
11
11
  var SystemClock = class {
@@ -64,6 +64,60 @@ const definedNodeCredentialAccessorFactory = { create(bindings, ctx) {
64
64
  return Object.fromEntries(entries);
65
65
  } };
66
66
  function defineNode(options) {
67
+ const credentialRequirements = definedNodeCredentialRequirementFactory.create(options.credentials);
68
+ const DefinedNodeRuntime = class {
69
+ kind = "node";
70
+ outputPorts = ["main"];
71
+ inputSchema = options.inputSchema;
72
+ async executeOne(args) {
73
+ const ctx = args.ctx;
74
+ const context = {
75
+ config: ctx.config.config,
76
+ credentials: definedNodeCredentialAccessorFactory.create(options.credentials, ctx),
77
+ execution: ctx
78
+ };
79
+ const payload = {
80
+ input: args.input,
81
+ item: args.item,
82
+ itemIndex: args.itemIndex,
83
+ items: args.items,
84
+ ctx
85
+ };
86
+ return await options.executeOne(payload, context);
87
+ }
88
+ };
89
+ require_runtime.node({ name: options.key })(DefinedNodeRuntime);
90
+ const DefinedRunnableNodeConfig = class {
91
+ kind = "node";
92
+ type = DefinedNodeRuntime;
93
+ icon = options.icon;
94
+ inputSchema = options.inputSchema;
95
+ mapInput = options.mapInput;
96
+ constructor(name, config, id) {
97
+ this.name = name;
98
+ this.config = config;
99
+ this.id = id;
100
+ }
101
+ getCredentialRequirements() {
102
+ return credentialRequirements;
103
+ }
104
+ };
105
+ const definition = {
106
+ kind: "defined-node",
107
+ key: options.key,
108
+ title: options.title,
109
+ description: options.description,
110
+ create(config, name = options.title, id) {
111
+ return new DefinedRunnableNodeConfig(name, config, id);
112
+ },
113
+ register(context) {
114
+ context.registerNode(DefinedNodeRuntime);
115
+ }
116
+ };
117
+ DefinedNodeRegistry.register(definition);
118
+ return definition;
119
+ }
120
+ function defineBatchNode(options) {
67
121
  const credentialRequirements = definedNodeCredentialRequirementFactory.create(options.credentials);
68
122
  const DefinedNodeRuntime = class {
69
123
  kind = "node";
@@ -83,7 +137,7 @@ function defineNode(options) {
83
137
  }) };
84
138
  }
85
139
  };
86
- require_RunIntentService.node({ name: options.key })(DefinedNodeRuntime);
140
+ require_runtime.node({ name: options.key })(DefinedNodeRuntime);
87
141
  const DefinedRunnableNodeConfig = class {
88
142
  kind = "node";
89
143
  type = DefinedNodeRuntime;
@@ -289,11 +343,38 @@ const AgentToolFactory = new AgentToolFactoryImpl();
289
343
  //#endregion
290
344
  //#region src/ai/AgentMessageConfigNormalizerFactory.ts
291
345
  var AgentMessageConfigNormalizer = class {
346
+ /**
347
+ * Prefer {@code input.messages} when present (ItemNode / engine-mapped payloads); otherwise resolve from
348
+ * {@link AgentNodeConfig.messages} templates.
349
+ */
350
+ static resolveFromInputOrConfig(input, config, args) {
351
+ const fromInput = this.tryMessagesFromStructuredInput(input);
352
+ if (fromInput.length > 0) return fromInput;
353
+ return this.normalize(config, args);
354
+ }
292
355
  static normalize(config, args) {
293
356
  const fromMessages = this.normalizeRichMessages(config.messages, args);
294
357
  if (fromMessages.length > 0) return fromMessages;
295
358
  throw new Error("AIAgent messages must be a non-empty array, or an object with a non-empty prompt array and/or buildMessages that returns messages.");
296
359
  }
360
+ static tryMessagesFromStructuredInput(input) {
361
+ if (!input || typeof input !== "object") return [];
362
+ const raw = input.messages;
363
+ if (!Array.isArray(raw) || raw.length === 0) return [];
364
+ const out = [];
365
+ for (const m of raw) {
366
+ if (!m || typeof m !== "object") continue;
367
+ const role = m.role;
368
+ const content = m.content;
369
+ if (role !== "system" && role !== "user" && role !== "assistant") continue;
370
+ if (typeof content !== "string") continue;
371
+ out.push({
372
+ role,
373
+ content
374
+ });
375
+ }
376
+ return out;
377
+ }
297
378
  static normalizeRichMessages(config, args) {
298
379
  if (Array.isArray(config)) return config.map((line) => this.lineToDto(line, args));
299
380
  const structured = config;
@@ -329,7 +410,7 @@ const AgentConnectionNodeCollector = new class {
329
410
  }
330
411
  collectInto(parentNodeId, agentConfig, collected) {
331
412
  collected.push({
332
- nodeId: require_RunIntentService.ConnectionNodeIdFactory.languageModelConnectionNodeId(parentNodeId),
413
+ nodeId: require_runtime.ConnectionNodeIdFactory.languageModelConnectionNodeId(parentNodeId),
333
414
  parentNodeId,
334
415
  connectionName: "llm",
335
416
  role: "languageModel",
@@ -339,7 +420,7 @@ const AgentConnectionNodeCollector = new class {
339
420
  credentialSource: agentConfig.chatModel
340
421
  });
341
422
  for (const tool$1 of agentConfig.tools ?? []) {
342
- const toolNodeId = require_RunIntentService.ConnectionNodeIdFactory.toolConnectionNodeId(parentNodeId, tool$1.name);
423
+ const toolNodeId = require_runtime.ConnectionNodeIdFactory.toolConnectionNodeId(parentNodeId, tool$1.name);
343
424
  const isNestedAgent = this.isNodeBackedAgentTool(tool$1);
344
425
  collected.push({
345
426
  nodeId: toolNodeId,
@@ -573,24 +654,24 @@ exports.AgentToolFactory = AgentToolFactory;
573
654
  exports.AllWorkflowsActiveWorkflowActivationPolicy = require_workflowActivationPolicy.AllWorkflowsActiveWorkflowActivationPolicy;
574
655
  exports.ChainCursor = require_workflowActivationPolicy.ChainCursor;
575
656
  exports.ConnectionInvocationIdFactory = ConnectionInvocationIdFactory;
576
- exports.ConnectionNodeIdFactory = require_RunIntentService.ConnectionNodeIdFactory;
577
- exports.CoreTokens = require_RunIntentService.CoreTokens;
578
- exports.CredentialResolverFactory = require_RunIntentService.CredentialResolverFactory;
657
+ exports.ConnectionNodeIdFactory = require_runtime.ConnectionNodeIdFactory;
658
+ exports.CoreTokens = require_runtime.CoreTokens;
659
+ exports.CredentialResolverFactory = require_runtime.CredentialResolverFactory;
579
660
  exports.CredentialUnboundError = CredentialUnboundError;
580
- exports.DefaultAsyncSleeper = require_RunIntentService.DefaultAsyncSleeper;
581
- exports.DefaultExecutionBinaryService = require_RunIntentService.DefaultExecutionBinaryService;
582
- exports.DefaultExecutionContextFactory = require_RunIntentService.DefaultExecutionContextFactory;
661
+ exports.DefaultAsyncSleeper = require_runtime.DefaultAsyncSleeper;
662
+ exports.DefaultExecutionBinaryService = require_runtime.DefaultExecutionBinaryService;
663
+ exports.DefaultExecutionContextFactory = require_runtime.DefaultExecutionContextFactory;
583
664
  exports.DefaultWorkflowGraphFactory = DefaultWorkflowGraphFactory;
584
665
  exports.DefinedNodeRegistry = DefinedNodeRegistry;
585
- exports.EngineExecutionLimitsPolicy = require_RunIntentService.EngineExecutionLimitsPolicy;
666
+ exports.EngineExecutionLimitsPolicy = require_runtime.EngineExecutionLimitsPolicy;
586
667
  exports.EventPublishingWorkflowExecutionRepository = EventPublishingWorkflowExecutionRepository;
587
668
  exports.ExpRetryPolicy = ExpRetryPolicy;
588
- exports.InMemoryBinaryStorage = require_RunIntentService.InMemoryBinaryStorage;
589
- exports.InMemoryLiveWorkflowRepository = require_RunIntentService.InMemoryLiveWorkflowRepository;
590
- exports.InMemoryRunDataFactory = require_RunIntentService.InMemoryRunDataFactory;
669
+ exports.InMemoryBinaryStorage = require_runtime.InMemoryBinaryStorage;
670
+ exports.InMemoryLiveWorkflowRepository = require_runtime.InMemoryLiveWorkflowRepository;
671
+ exports.InMemoryRunDataFactory = require_runtime.InMemoryRunDataFactory;
591
672
  exports.InMemoryRunEventBus = require_workflowActivationPolicy.InMemoryRunEventBus;
592
- exports.InProcessRetryRunner = require_RunIntentService.InProcessRetryRunner;
593
- exports.InjectableRuntimeDecoratorComposer = require_RunIntentService.InjectableRuntimeDecoratorComposer;
673
+ exports.InProcessRetryRunner = require_runtime.InProcessRetryRunner;
674
+ exports.InjectableRuntimeDecoratorComposer = require_runtime.InjectableRuntimeDecoratorComposer;
594
675
  Object.defineProperty(exports, 'ItemsInputNormalizer', {
595
676
  enumerable: true,
596
677
  get: function () {
@@ -599,27 +680,28 @@ Object.defineProperty(exports, 'ItemsInputNormalizer', {
599
680
  });
600
681
  exports.NoRetryPolicy = NoRetryPolicy;
601
682
  exports.NodeBackedToolConfig = NodeBackedToolConfig;
602
- exports.NodeEventPublisher = require_RunIntentService.NodeEventPublisher;
603
- exports.PersistedRuntimeTypeMetadataStore = require_RunIntentService.PersistedRuntimeTypeMetadataStore;
604
- exports.PersistedRuntimeTypeNameResolver = require_RunIntentService.PersistedRuntimeTypeNameResolver;
683
+ exports.NodeEventPublisher = require_runtime.NodeEventPublisher;
684
+ exports.PersistedRuntimeTypeMetadataStore = require_runtime.PersistedRuntimeTypeMetadataStore;
685
+ exports.PersistedRuntimeTypeNameResolver = require_runtime.PersistedRuntimeTypeNameResolver;
605
686
  exports.RetryPolicy = RetryPolicy;
606
- exports.RunFinishedAtFactory = require_RunIntentService.RunFinishedAtFactory;
607
- exports.RunIntentService = require_RunIntentService.RunIntentService;
608
- exports.StackTraceCallSitePathResolver = require_RunIntentService.StackTraceCallSitePathResolver;
687
+ exports.RunFinishedAtFactory = require_runtime.RunFinishedAtFactory;
688
+ exports.RunIntentService = require_runtime.RunIntentService;
689
+ exports.StackTraceCallSitePathResolver = require_runtime.StackTraceCallSitePathResolver;
609
690
  exports.SystemClock = SystemClock;
610
- exports.UnavailableBinaryStorage = require_RunIntentService.UnavailableBinaryStorage;
691
+ exports.UnavailableBinaryStorage = require_runtime.UnavailableBinaryStorage;
611
692
  exports.WhenBuilder = require_workflowActivationPolicy.WhenBuilder;
612
693
  exports.WorkflowBuilder = require_workflowActivationPolicy.WorkflowBuilder;
613
- exports.WorkflowExecutableNodeClassifier = require_RunIntentService.WorkflowExecutableNodeClassifier;
614
- exports.WorkflowExecutableNodeClassifierFactory = require_RunIntentService.WorkflowExecutableNodeClassifierFactory;
694
+ exports.WorkflowExecutableNodeClassifier = require_runtime.WorkflowExecutableNodeClassifier;
695
+ exports.WorkflowExecutableNodeClassifierFactory = require_runtime.WorkflowExecutableNodeClassifierFactory;
615
696
  exports.branchRef = branchRef;
616
- exports.chatModel = require_RunIntentService.chatModel;
697
+ exports.chatModel = require_runtime.chatModel;
617
698
  Object.defineProperty(exports, 'container', {
618
699
  enumerable: true,
619
700
  get: function () {
620
701
  return tsyringe.container;
621
702
  }
622
703
  });
704
+ exports.defineBatchNode = defineBatchNode;
623
705
  exports.defineCredential = defineCredential;
624
706
  exports.defineNode = defineNode;
625
707
  Object.defineProperty(exports, 'delay', {
@@ -628,7 +710,7 @@ Object.defineProperty(exports, 'delay', {
628
710
  return tsyringe.delay;
629
711
  }
630
712
  });
631
- exports.getPersistedRuntimeTypeMetadata = require_RunIntentService.getPersistedRuntimeTypeMetadata;
713
+ exports.getPersistedRuntimeTypeMetadata = require_runtime.getPersistedRuntimeTypeMetadata;
632
714
  Object.defineProperty(exports, 'inject', {
633
715
  enumerable: true,
634
716
  get: function () {
@@ -659,7 +741,7 @@ Object.defineProperty(exports, 'instancePerContainerCachingFactory', {
659
741
  return tsyringe.instancePerContainerCachingFactory;
660
742
  }
661
743
  });
662
- exports.node = require_RunIntentService.node;
744
+ exports.node = require_runtime.node;
663
745
  Object.defineProperty(exports, 'predicateAwareClassFactory', {
664
746
  enumerable: true,
665
747
  get: function () {
@@ -678,5 +760,5 @@ Object.defineProperty(exports, 'singleton', {
678
760
  return tsyringe.singleton;
679
761
  }
680
762
  });
681
- exports.tool = require_RunIntentService.tool;
763
+ exports.tool = require_runtime.tool;
682
764
  //# sourceMappingURL=index.cjs.map