@codemation/core 0.0.14 → 0.0.15
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/bootstrap/index.d.ts +1 -1
- package/dist/{index-CTjfVHJh.d.ts → index-k0hwnJyT.d.ts} +117 -9
- package/dist/index.cjs +108 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +115 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.js +105 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ai/AgentConfigInspectorFactory.ts +25 -0
- package/src/ai/AgentMessageConfigNormalizerFactory.ts +51 -0
- package/src/ai/AgentToolFactory.ts +18 -0
- package/src/ai/AiHost.ts +121 -21
- package/src/ai/NodeBackedToolConfig.ts +86 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Jn as WebhookTriggerRoutingDiagnostics, Kn as WebhookTriggerMatcher, Lr as TypeToken, Mr as DependencyContainer, Nt as WorkflowDefinition, Xr as EngineExecutionLimitsPolicy, Yr as ENGINE_EXECUTION_LIMITS_DEFAULTS, Zr as EngineExecutionLimitsPolicyConfig, jn as TriggerRuntimeDiagnostics, t as InMemoryLiveWorkflowRepository, xt as PersistedTokenId } from "../InMemoryLiveWorkflowRepository-DxoualoC.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Ct as AsyncSleeper, Dt as EngineFactory, Et as EngineCompositionDeps, Ot as Engine, St as DefaultAsyncSleeper, _ as EngineExecutionLimitsPolicyFactory, a as ConfigDrivenOffloadPolicy, bt as InProcessRetryRunner, c as EngineWorkflowRunnerService, d as InMemoryRunDataFactory, f as InMemoryBinaryStorage, g as RunPolicySnapshotFactory, h as WorkflowStoragePolicyEvaluator, i as InlineDrivingScheduler, l as RunSummaryMapper, m as RunTerminalPersistenceCoordinator, n as HintOnlyOffloadPolicy, o as WorkflowRepositoryWebhookTriggerMatcher, p as WorkflowPolicyErrorServices, r as DefaultDrivingScheduler, s as RunIntentService, t as LocalOnlyScheduler, u as InMemoryWorkflowExecutionRepository, v as DefaultExecutionBinaryService, vt as NodeInstanceFactory, wt as CredentialResolverFactory, xt as DefaultExecutionContextFactory, y as UnavailableBinaryStorage, yt as NodeExecutor } from "../index-k0hwnJyT.js";
|
|
3
3
|
|
|
4
4
|
//#region src/bootstrap/runtime/EngineRuntimeRegistration.types.d.ts
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $r as RunEventBus, $t as BinaryBody, Ar as WorkflowExecutionRepository, Cn as NodeExecutionScheduler, Ct as RunDataSnapshot, Dr as WebhookRunResult, En as NodeResolver, Er as RunSummary, Et as RunnableNodeConfig, Ft as WorkflowErrorHandler, G as BinaryAttachment, Gn as WebhookInvocationMatch, Hn as HttpMethod, I as CredentialSessionService, In as WorkflowNodeInstanceFactory, It as WorkflowErrorHandlerSpec, J as ExecutionMode, Jn as WebhookTriggerRoutingDiagnostics, Kn as WebhookTriggerMatcher, Ln as WorkflowRepository, Lr as TypeToken, N as CredentialRequirement, Nt as WorkflowDefinition, Or as WorkflowExecutionListingRepository, Q as Items, Qr as RunEvent, Sn as NodeExecutionRequestHandler, Sr as RunResult, St as RunDataFactory, Tr as RunStopCondition, Ut as WorkflowStoragePolicyDecisionArgs, Vn as WorkflowSnapshotResolver, Vt as WorkflowPolicyRuntimeDefaults, X as Item, Xn as WorkflowActivationPolicy, Xr as EngineExecutionLimitsPolicy, Zr as EngineExecutionLimitsPolicyConfig, _r as RunCurrentState, an as EngineDeps, at as NodeConfigBase, bn as NodeExecutionContext, br as RunPruneCandidate, bt as PersistedRunPolicySnapshot, cn as ExecutionBinaryService, ct as NodeErrorHandler, dn as LiveWorkflowRepository, dr as PersistedRunState, dt as NodeId, ei as RunEventSubscription, en as BinaryStorage, er as CurrentStateExecutionRequest, gn as NodeActivationRequest, gt as NodeSchedulerDecision, hn as NodeActivationReceipt, in as BinaryStorageWriteResult, ir as NodeExecutionSnapshot, it as NodeActivationId, kr as WorkflowExecutionPruneRepository, ln as ExecutionContext, mn as NodeActivationContinuation, mr as PersistedWorkflowTokenRegistryLike, mt as NodeOutputs, n as WorkflowSnapshotCodec, nn as BinaryStorageStatResult, or as NodeInputsByPort, pr as PersistedWorkflowSnapshotNode, pt as NodeOffloadPolicy, qn as WebhookTriggerResolution, rt as MutableRunData, si as RetryPolicySpec, st as NodeDefinition, tn as BinaryStorageReadResult, tr as EngineRunCounters, un as ExecutionContextFactory, ut as NodeErrorHandlerSpec, vn as NodeActivationScheduler, wn as NodeExecutionStatePublisher, wt as RunId, xn as NodeExecutionRequest, yn as NodeBinaryAttachmentService, yr as RunExecutionOptions, yt as ParentExecutionRef, zt as WorkflowId } from "./InMemoryLiveWorkflowRepository-DxoualoC.js";
|
|
1
|
+
import { $r as RunEventBus, $t as BinaryBody, Ar as WorkflowExecutionRepository, Cn as NodeExecutionScheduler, Ct as RunDataSnapshot, Dr as WebhookRunResult, Dt as RunnableNodeInputJson, En as NodeResolver, Er as RunSummary, Et as RunnableNodeConfig, Ft as WorkflowErrorHandler, G as BinaryAttachment, Gn as WebhookInvocationMatch, Hn as HttpMethod, I as CredentialSessionService, In as WorkflowNodeInstanceFactory, It as WorkflowErrorHandlerSpec, J as ExecutionMode, Jn as WebhookTriggerRoutingDiagnostics, Kn as WebhookTriggerMatcher, Ln as WorkflowRepository, Lr as TypeToken, N as CredentialRequirement, Nt as WorkflowDefinition, Or as WorkflowExecutionListingRepository, Q as Items, Qr as RunEvent, Sn as NodeExecutionRequestHandler, Sr as RunResult, St as RunDataFactory, Tr as RunStopCondition, Ut as WorkflowStoragePolicyDecisionArgs, Vn as WorkflowSnapshotResolver, Vt as WorkflowPolicyRuntimeDefaults, X as Item, Xn as WorkflowActivationPolicy, Xr as EngineExecutionLimitsPolicy, Zr as EngineExecutionLimitsPolicyConfig, _r as RunCurrentState, an as EngineDeps, at as NodeConfigBase, bn as NodeExecutionContext, br as RunPruneCandidate, bt as PersistedRunPolicySnapshot, cn as ExecutionBinaryService, ct as NodeErrorHandler, dn as LiveWorkflowRepository, dr as PersistedRunState, dt as NodeId, ei as RunEventSubscription, en as BinaryStorage, er as CurrentStateExecutionRequest, gn as NodeActivationRequest, gt as NodeSchedulerDecision, hn as NodeActivationReceipt, in as BinaryStorageWriteResult, ir as NodeExecutionSnapshot, it as NodeActivationId, kr as WorkflowExecutionPruneRepository, ln as ExecutionContext, mn as NodeActivationContinuation, mr as PersistedWorkflowTokenRegistryLike, mt as NodeOutputs, n as WorkflowSnapshotCodec, nn as BinaryStorageStatResult, nt as JsonValue, or as NodeInputsByPort, pr as PersistedWorkflowSnapshotNode, pt as NodeOffloadPolicy, qn as WebhookTriggerResolution, rt as MutableRunData, si as RetryPolicySpec, st as NodeDefinition, tn as BinaryStorageReadResult, tr as EngineRunCounters, un as ExecutionContextFactory, ut as NodeErrorHandlerSpec, vn as NodeActivationScheduler, wn as NodeExecutionStatePublisher, wt as RunId, xn as NodeExecutionRequest, yn as NodeBinaryAttachmentService, yr as RunExecutionOptions, yt as ParentExecutionRef, zt as WorkflowId } from "./InMemoryLiveWorkflowRepository-DxoualoC.js";
|
|
2
2
|
import { ZodType, input, output } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/orchestration/Engine.d.ts
|
|
@@ -243,6 +243,49 @@ declare class SystemClock implements Clock {
|
|
|
243
243
|
now(): Date;
|
|
244
244
|
}
|
|
245
245
|
//#endregion
|
|
246
|
+
//#region src/ai/NodeBackedToolConfig.d.ts
|
|
247
|
+
declare class NodeBackedToolConfig<TNodeConfig extends RunnableNodeConfig<any, any>, TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny> implements ToolConfig {
|
|
248
|
+
readonly name: string;
|
|
249
|
+
readonly node: TNodeConfig;
|
|
250
|
+
readonly type: TypeToken<unknown>;
|
|
251
|
+
readonly toolKind: "nodeBacked";
|
|
252
|
+
readonly description?: string;
|
|
253
|
+
readonly presentation?: AgentCanvasPresentation;
|
|
254
|
+
private readonly inputSchemaValue;
|
|
255
|
+
private readonly outputSchemaValue;
|
|
256
|
+
private readonly mapInputValue?;
|
|
257
|
+
private readonly mapOutputValue?;
|
|
258
|
+
constructor(name: string, node: TNodeConfig, options: NodeBackedToolConfigOptions<TNodeConfig, TInputSchema, TOutputSchema>);
|
|
259
|
+
getCredentialRequirements(): ReadonlyArray<CredentialRequirement>;
|
|
260
|
+
getInputSchema(): TInputSchema;
|
|
261
|
+
getOutputSchema(): TOutputSchema;
|
|
262
|
+
toNodeItem(args: NodeBackedToolInputMapperArgs<TNodeConfig, input<TInputSchema>>): Item<RunnableNodeInputJson<TNodeConfig>>;
|
|
263
|
+
toToolOutput(args: NodeBackedToolOutputMapperArgs<TNodeConfig, input<TInputSchema>>): output<TOutputSchema>;
|
|
264
|
+
private readDefaultToolOutput;
|
|
265
|
+
private isItem;
|
|
266
|
+
}
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region src/ai/AgentToolFactory.d.ts
|
|
269
|
+
declare class AgentToolFactoryImpl {
|
|
270
|
+
asTool<TNodeConfig extends RunnableNodeConfig<any, any>, TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny>(node: TNodeConfig, options: Readonly<{
|
|
271
|
+
name?: string;
|
|
272
|
+
} & NodeBackedToolConfigOptions<TNodeConfig, TInputSchema, TOutputSchema>>): NodeBackedToolConfig<TNodeConfig, TInputSchema, TOutputSchema>;
|
|
273
|
+
}
|
|
274
|
+
declare const AgentToolFactory: AgentToolFactoryImpl;
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/ai/AgentMessageConfigNormalizerFactory.d.ts
|
|
277
|
+
declare class AgentMessageConfigNormalizer {
|
|
278
|
+
static normalize<TInputJson, TOutputJson>(config: AgentNodeConfig<TInputJson, TOutputJson>, args: AgentMessageBuildArgs<TInputJson>): ReadonlyArray<AgentMessageDto>;
|
|
279
|
+
private static normalizeRichMessages;
|
|
280
|
+
private static lineToDto;
|
|
281
|
+
}
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/ai/AgentConfigInspectorFactory.d.ts
|
|
284
|
+
declare class AgentConfigInspector {
|
|
285
|
+
static isAgentNodeConfig(config: NodeConfigBase | undefined): config is AgentNodeConfig<any, any>;
|
|
286
|
+
private static hasCompatibleMessageConfiguration;
|
|
287
|
+
}
|
|
288
|
+
//#endregion
|
|
246
289
|
//#region src/ai/AiHost.d.ts
|
|
247
290
|
interface AgentCanvasPresentation<TIcon extends string = string> {
|
|
248
291
|
readonly label?: string;
|
|
@@ -250,7 +293,7 @@ interface AgentCanvasPresentation<TIcon extends string = string> {
|
|
|
250
293
|
}
|
|
251
294
|
type ZodSchemaAny = ZodType<any, any, any>;
|
|
252
295
|
interface ToolConfig {
|
|
253
|
-
readonly type: TypeToken<
|
|
296
|
+
readonly type: TypeToken<unknown>;
|
|
254
297
|
readonly name: string;
|
|
255
298
|
readonly description?: string;
|
|
256
299
|
readonly presentation?: AgentCanvasPresentation;
|
|
@@ -273,6 +316,47 @@ interface Tool<TConfig extends ToolConfig = ToolConfig, TInputSchema extends Zod
|
|
|
273
316
|
type AgentTool<TInputSchema extends ZodSchemaAny = ZodSchemaAny, TOutputSchema extends ZodSchemaAny = ZodSchemaAny> = Tool<ToolConfig, TInputSchema, TOutputSchema>;
|
|
274
317
|
type AgentToolExecuteArgs<TInput = unknown> = ToolExecuteArgs<ToolConfig, TInput>;
|
|
275
318
|
type AgentToolToken = TypeToken<Tool<ToolConfig, ZodSchemaAny, ZodSchemaAny>>;
|
|
319
|
+
type AgentMessageRole = "system" | "user" | "assistant";
|
|
320
|
+
type AgentMessageBuildArgs<TInputJson = unknown> = Readonly<{
|
|
321
|
+
item: Item<TInputJson>;
|
|
322
|
+
itemIndex: number;
|
|
323
|
+
items: Items<TInputJson>;
|
|
324
|
+
ctx: NodeExecutionContext<any>;
|
|
325
|
+
}>;
|
|
326
|
+
interface AgentMessageDto {
|
|
327
|
+
readonly role: AgentMessageRole;
|
|
328
|
+
readonly content: string;
|
|
329
|
+
}
|
|
330
|
+
type AgentMessageTemplateContent<TInputJson = unknown> = string | ((args: AgentMessageBuildArgs<TInputJson>) => string);
|
|
331
|
+
interface AgentMessageTemplate<TInputJson = unknown> {
|
|
332
|
+
readonly role: AgentMessageRole;
|
|
333
|
+
readonly content: AgentMessageTemplateContent<TInputJson>;
|
|
334
|
+
}
|
|
335
|
+
/** A single prompt line: fixed DTO or template with optional function `content`. */
|
|
336
|
+
type AgentMessageLine<TInputJson = unknown> = AgentMessageDto | AgentMessageTemplate<TInputJson>;
|
|
337
|
+
/**
|
|
338
|
+
* Message list for an agent. Prefer a **plain array** of `{ role, content }` (optionally with function `content` for templates).
|
|
339
|
+
* Use the object form only when you need `buildMessages` to append messages after optional `prompt` lines.
|
|
340
|
+
*/
|
|
341
|
+
type AgentMessageConfig<TInputJson = unknown> = ReadonlyArray<AgentMessageLine<TInputJson>> | {
|
|
342
|
+
readonly prompt?: ReadonlyArray<AgentMessageLine<TInputJson>>;
|
|
343
|
+
readonly buildMessages?: (args: AgentMessageBuildArgs<TInputJson>) => ReadonlyArray<AgentMessageDto>;
|
|
344
|
+
};
|
|
345
|
+
type AgentTurnLimitBehavior = "error" | "respondWithLastMessage";
|
|
346
|
+
interface AgentModelInvocationOptions {
|
|
347
|
+
readonly maxTokens?: number;
|
|
348
|
+
readonly providerOptions?: Readonly<Record<string, JsonValue>>;
|
|
349
|
+
}
|
|
350
|
+
interface AgentGuardrailConfig {
|
|
351
|
+
readonly maxTurns?: number;
|
|
352
|
+
readonly onTurnLimitReached?: AgentTurnLimitBehavior;
|
|
353
|
+
readonly modelInvocationOptions?: AgentModelInvocationOptions;
|
|
354
|
+
}
|
|
355
|
+
/** Defaults aligned with common tool-agent iteration limits (many products use ~10 max rounds). */
|
|
356
|
+
declare const AgentGuardrailDefaults: {
|
|
357
|
+
readonly maxTurns: 10;
|
|
358
|
+
readonly onTurnLimitReached: AgentTurnLimitBehavior;
|
|
359
|
+
};
|
|
276
360
|
interface AgentToolDefinition {
|
|
277
361
|
readonly name: string;
|
|
278
362
|
readonly description: string;
|
|
@@ -300,14 +384,38 @@ interface ChatModelFactory<TConfig extends ChatModelConfig = ChatModelConfig> {
|
|
|
300
384
|
ctx: NodeExecutionContext<any>;
|
|
301
385
|
}>): Promise<LangChainChatModelLike> | LangChainChatModelLike;
|
|
302
386
|
}
|
|
387
|
+
type NodeBackedToolInputMapperArgs<TNodeConfig extends RunnableNodeConfig<any, any>, TToolInput = unknown> = Readonly<{
|
|
388
|
+
input: TToolInput;
|
|
389
|
+
item: Item;
|
|
390
|
+
itemIndex: number;
|
|
391
|
+
items: Items;
|
|
392
|
+
ctx: NodeExecutionContext<any>;
|
|
393
|
+
node: TNodeConfig;
|
|
394
|
+
}>;
|
|
395
|
+
type NodeBackedToolOutputMapperArgs<TNodeConfig extends RunnableNodeConfig<any, any>, TToolInput = unknown> = Readonly<{
|
|
396
|
+
input: TToolInput;
|
|
397
|
+
item: Item;
|
|
398
|
+
itemIndex: number;
|
|
399
|
+
items: Items;
|
|
400
|
+
ctx: NodeExecutionContext<any>;
|
|
401
|
+
node: TNodeConfig;
|
|
402
|
+
outputs: NodeOutputs;
|
|
403
|
+
}>;
|
|
404
|
+
type NodeBackedToolInputMapper<TNodeConfig extends RunnableNodeConfig<any, any>, TToolInput = unknown> = (args: NodeBackedToolInputMapperArgs<TNodeConfig, TToolInput>) => Item<RunnableNodeInputJson<TNodeConfig>> | RunnableNodeInputJson<TNodeConfig>;
|
|
405
|
+
type NodeBackedToolOutputMapper<TNodeConfig extends RunnableNodeConfig<any, any>, TToolInput = unknown, TToolOutput = unknown> = (args: NodeBackedToolOutputMapperArgs<TNodeConfig, TToolInput>) => TToolOutput;
|
|
406
|
+
type NodeBackedToolConfigOptions<TNodeConfig extends RunnableNodeConfig<any, any>, TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny> = Readonly<{
|
|
407
|
+
description?: string;
|
|
408
|
+
presentation?: AgentCanvasPresentation;
|
|
409
|
+
inputSchema: TInputSchema;
|
|
410
|
+
outputSchema: TOutputSchema;
|
|
411
|
+
mapInput?: NodeBackedToolInputMapper<TNodeConfig, input<TInputSchema>>;
|
|
412
|
+
mapOutput?: NodeBackedToolOutputMapper<TNodeConfig, input<TInputSchema>, output<TOutputSchema>>;
|
|
413
|
+
}>;
|
|
303
414
|
interface AgentNodeConfig<TInputJson = unknown, TOutputJson = unknown> extends RunnableNodeConfig<TInputJson, TOutputJson> {
|
|
304
|
-
readonly
|
|
305
|
-
readonly userMessageFormatter: (item: Item<TInputJson>, index: number, items: Items<TInputJson>, ctx: NodeExecutionContext<any>) => string;
|
|
415
|
+
readonly messages: AgentMessageConfig<TInputJson>;
|
|
306
416
|
readonly chatModel: ChatModelConfig;
|
|
307
417
|
readonly tools?: ReadonlyArray<ToolConfig>;
|
|
308
|
-
|
|
309
|
-
declare class AgentConfigInspector {
|
|
310
|
-
static isAgentNodeConfig(config: NodeConfigBase | undefined): config is AgentNodeConfig<any, any>;
|
|
418
|
+
readonly guardrails?: AgentGuardrailConfig;
|
|
311
419
|
}
|
|
312
420
|
type AgentAttachmentRole = "languageModel" | "tool";
|
|
313
421
|
//#endregion
|
|
@@ -690,5 +798,5 @@ declare class LocalOnlyScheduler implements NodeExecutionScheduler {
|
|
|
690
798
|
}>;
|
|
691
799
|
}
|
|
692
800
|
//#endregion
|
|
693
|
-
export {
|
|
694
|
-
//# sourceMappingURL=index-
|
|
801
|
+
export { AgentTurnLimitBehavior as $, PersistedRuntimeTypeKind as A, AgentMessageDto as B, node as C, AsyncSleeper as Ct, PersistedRuntimeTypeMetadataStore as D, EngineFactory as Dt, PersistedRuntimeTypeNameResolver as E, EngineCompositionDeps as Et, AgentCanvasPresentation as F, AgentModelInvocationOptions as G, AgentMessageRole as H, AgentGuardrailConfig as I, AgentToolCall as J, AgentNodeConfig as K, AgentGuardrailDefaults as L, EventPublishingWorkflowExecutionRepository as M, InMemoryRunEventBus as N, InjectableRuntimeDecoratorComposer as O, Engine as Ot, AgentAttachmentRole as P, AgentToolToken as Q, AgentMessageBuildArgs as R, getPersistedRuntimeTypeMetadata as S, DefaultAsyncSleeper as St, StackTraceCallSitePathResolver as T, NodeEventPublisher as Tt, AgentMessageTemplate as U, AgentMessageLine as V, AgentMessageTemplateContent as W, AgentToolDefinition as X, AgentToolCallPlanner as Y, AgentToolExecuteArgs as Z, EngineExecutionLimitsPolicyFactory as _, SystemClock as _t, ConfigDrivenOffloadPolicy as a, NodeBackedToolInputMapperArgs as at, ItemsInputNormalizer as b, InProcessRetryRunner as bt, EngineWorkflowRunnerService as c, Tool as ct, InMemoryRunDataFactory as d, ZodSchemaAny as dt, ChatModelConfig as et, InMemoryBinaryStorage as f, AgentConfigInspector as ft, RunPolicySnapshotFactory as g, Clock as gt, WorkflowStoragePolicyEvaluator as h, NodeBackedToolConfig as ht, InlineDrivingScheduler as i, NodeBackedToolInputMapper as it, PersistedRuntimeTypeMetadata as j, PersistedRuntimeTypeDecoratorOptions as k, RunSummaryMapper as l, ToolConfig as lt, RunTerminalPersistenceCoordinator as m, AgentToolFactory as mt, HintOnlyOffloadPolicy as n, LangChainChatModelLike as nt, WorkflowRepositoryWebhookTriggerMatcher as o, NodeBackedToolOutputMapper as ot, WorkflowPolicyErrorServices as p, AgentMessageConfigNormalizer as pt, AgentTool as q, DefaultDrivingScheduler as r, NodeBackedToolConfigOptions as rt, RunIntentService as s, NodeBackedToolOutputMapperArgs as st, LocalOnlyScheduler as t, ChatModelFactory as tt, InMemoryWorkflowExecutionRepository as u, ToolExecuteArgs as ut, DefaultExecutionBinaryService as v, NodeInstanceFactory as vt, tool as w, CredentialResolverFactory as wt, chatModel as x, DefaultExecutionContextFactory as xt, UnavailableBinaryStorage as y, NodeExecutor as yt, AgentMessageConfig as z };
|
|
802
|
+
//# sourceMappingURL=index-k0hwnJyT.d.ts.map
|
package/dist/index.cjs
CHANGED
|
@@ -13,15 +13,117 @@ var SystemClock = class {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
|
-
//#region src/ai/
|
|
16
|
+
//#region src/ai/NodeBackedToolConfig.ts
|
|
17
|
+
var NodeBackedToolConfig = class {
|
|
18
|
+
type;
|
|
19
|
+
toolKind = "nodeBacked";
|
|
20
|
+
description;
|
|
21
|
+
presentation;
|
|
22
|
+
inputSchemaValue;
|
|
23
|
+
outputSchemaValue;
|
|
24
|
+
mapInputValue;
|
|
25
|
+
mapOutputValue;
|
|
26
|
+
constructor(name, node$1, options) {
|
|
27
|
+
this.name = name;
|
|
28
|
+
this.node = node$1;
|
|
29
|
+
this.type = node$1.type;
|
|
30
|
+
this.description = options.description;
|
|
31
|
+
this.presentation = options.presentation;
|
|
32
|
+
this.inputSchemaValue = options.inputSchema;
|
|
33
|
+
this.outputSchemaValue = options.outputSchema;
|
|
34
|
+
this.mapInputValue = options.mapInput;
|
|
35
|
+
this.mapOutputValue = options.mapOutput;
|
|
36
|
+
}
|
|
37
|
+
getCredentialRequirements() {
|
|
38
|
+
return this.node.getCredentialRequirements?.() ?? [];
|
|
39
|
+
}
|
|
40
|
+
getInputSchema() {
|
|
41
|
+
return this.inputSchemaValue;
|
|
42
|
+
}
|
|
43
|
+
getOutputSchema() {
|
|
44
|
+
return this.outputSchemaValue;
|
|
45
|
+
}
|
|
46
|
+
toNodeItem(args) {
|
|
47
|
+
const mapped = this.mapInputValue?.(args) ?? args.input;
|
|
48
|
+
if (this.isItem(mapped)) return mapped;
|
|
49
|
+
return { json: mapped };
|
|
50
|
+
}
|
|
51
|
+
toToolOutput(args) {
|
|
52
|
+
const raw = this.mapOutputValue?.(args) ?? this.readDefaultToolOutput(args.outputs);
|
|
53
|
+
return this.outputSchemaValue.parse(raw);
|
|
54
|
+
}
|
|
55
|
+
readDefaultToolOutput(outputs) {
|
|
56
|
+
const firstMainItem = outputs.main?.[0];
|
|
57
|
+
if (!firstMainItem) throw new Error(`Node-backed tool "${this.name}" did not produce a main output item.`);
|
|
58
|
+
return firstMainItem.json;
|
|
59
|
+
}
|
|
60
|
+
isItem(value) {
|
|
61
|
+
return typeof value === "object" && value !== null && "json" in value;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/ai/AgentToolFactory.ts
|
|
67
|
+
var AgentToolFactoryImpl = class {
|
|
68
|
+
asTool(node$1, options) {
|
|
69
|
+
return new NodeBackedToolConfig(options.name ?? node$1.name ?? "tool", node$1, options);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const AgentToolFactory = new AgentToolFactoryImpl();
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/ai/AgentMessageConfigNormalizerFactory.ts
|
|
76
|
+
var AgentMessageConfigNormalizer = class {
|
|
77
|
+
static normalize(config, args) {
|
|
78
|
+
const fromMessages = this.normalizeRichMessages(config.messages, args);
|
|
79
|
+
if (fromMessages.length > 0) return fromMessages;
|
|
80
|
+
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.");
|
|
81
|
+
}
|
|
82
|
+
static normalizeRichMessages(config, args) {
|
|
83
|
+
if (Array.isArray(config)) return config.map((line) => this.lineToDto(line, args));
|
|
84
|
+
const structured = config;
|
|
85
|
+
const messages = [];
|
|
86
|
+
for (const line of structured.prompt ?? []) messages.push(this.lineToDto(line, args));
|
|
87
|
+
for (const message of structured.buildMessages?.(args) ?? []) messages.push(message);
|
|
88
|
+
return messages;
|
|
89
|
+
}
|
|
90
|
+
static lineToDto(line, args) {
|
|
91
|
+
const content = typeof line.content === "function" ? line.content(args) : line.content;
|
|
92
|
+
return {
|
|
93
|
+
role: line.role,
|
|
94
|
+
content
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/ai/AgentConfigInspectorFactory.ts
|
|
17
101
|
var AgentConfigInspector = class {
|
|
18
102
|
static isAgentNodeConfig(config) {
|
|
19
103
|
if (!config) return false;
|
|
20
104
|
const candidate = config;
|
|
21
|
-
return
|
|
105
|
+
return !!candidate.chatModel && this.hasCompatibleMessageConfiguration(candidate);
|
|
106
|
+
}
|
|
107
|
+
static hasCompatibleMessageConfiguration(candidate) {
|
|
108
|
+
const messages = candidate.messages;
|
|
109
|
+
if (messages === void 0 || messages === null) return false;
|
|
110
|
+
if (Array.isArray(messages)) return messages.length > 0;
|
|
111
|
+
if (typeof messages === "object") {
|
|
112
|
+
const o = messages;
|
|
113
|
+
return Array.isArray(o.prompt) && o.prompt.length > 0 || typeof o.buildMessages === "function";
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
22
116
|
}
|
|
23
117
|
};
|
|
24
118
|
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/ai/AiHost.ts
|
|
121
|
+
/** Defaults aligned with common tool-agent iteration limits (many products use ~10 max rounds). */
|
|
122
|
+
const AgentGuardrailDefaults = {
|
|
123
|
+
maxTurns: 10,
|
|
124
|
+
onTurnLimitReached: "error"
|
|
125
|
+
};
|
|
126
|
+
|
|
25
127
|
//#endregion
|
|
26
128
|
//#region src/workflow/dsl/WhenBuilder.ts
|
|
27
129
|
var WhenBuilder = class WhenBuilder {
|
|
@@ -412,6 +514,9 @@ var AllWorkflowsActiveWorkflowActivationPolicy = class {
|
|
|
412
514
|
|
|
413
515
|
//#endregion
|
|
414
516
|
exports.AgentConfigInspector = AgentConfigInspector;
|
|
517
|
+
exports.AgentGuardrailDefaults = AgentGuardrailDefaults;
|
|
518
|
+
exports.AgentMessageConfigNormalizer = AgentMessageConfigNormalizer;
|
|
519
|
+
exports.AgentToolFactory = AgentToolFactory;
|
|
415
520
|
exports.AllWorkflowsActiveWorkflowActivationPolicy = AllWorkflowsActiveWorkflowActivationPolicy;
|
|
416
521
|
exports.ChainCursor = ChainCursor;
|
|
417
522
|
exports.ConnectionInvocationIdFactory = ConnectionInvocationIdFactory;
|
|
@@ -439,6 +544,7 @@ Object.defineProperty(exports, 'ItemsInputNormalizer', {
|
|
|
439
544
|
}
|
|
440
545
|
});
|
|
441
546
|
exports.NoRetryPolicy = NoRetryPolicy;
|
|
547
|
+
exports.NodeBackedToolConfig = NodeBackedToolConfig;
|
|
442
548
|
exports.NodeEventPublisher = require_RunIntentService.NodeEventPublisher;
|
|
443
549
|
exports.PersistedRuntimeTypeMetadataStore = require_RunIntentService.PersistedRuntimeTypeMetadataStore;
|
|
444
550
|
exports.PersistedRuntimeTypeNameResolver = require_RunIntentService.PersistedRuntimeTypeNameResolver;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["wf: WorkflowBuilder","from: NodeRef","branchPort: OutputPortKey","created: NodeRef[]","prev: NodeRef | null","port: OutputPortKey","wf: WorkflowBuilder","cursor: NodeRef","cursorOutput: OutputPortKey","port: OutputPortKey","prev: NodeRef | null","meta: { id: WorkflowId; name: string }","options?: Readonly<{\n makeMergeNode?: (name: string) => AnyRunnableNodeConfig;\n }>","onClose: () => void","inner: WorkflowExecutionRepository","eventBus: RunEventBus","now: () => Date","ItemsInputNormalizer","maxAttempts: number","delayMs: number","maxAttempts: number","initialDelayMs: number","multiplier: number","maxDelayMs?: number","jitter?: boolean","bindingKey: CredentialBindingKey","acceptedTypes: ReadonlyArray<CredentialTypeId>"],"sources":["../src/contracts/Clock.ts","../src/ai/AiHost.ts","../src/workflow/dsl/WhenBuilder.ts","../src/workflow/dsl/ChainCursorResolver.ts","../src/workflow/dsl/WorkflowBuilder.ts","../src/workflow/definition/ConnectionInvocationIdFactory.ts","../src/workflow/graph/ExecutableGraph.ts","../src/workflow/graph/DefaultWorkflowGraphFactory.ts","../src/events/InMemoryRunEventSubscription.ts","../src/events/InMemoryRunEventBusRegistry.ts","../src/events/EventPublishingWorkflowExecutionRepository.ts","../src/serialization/ItemsInputNormalizer.ts","../src/contracts/NoRetryPolicy.ts","../src/contracts/RetryPolicy.ts","../src/contracts/ExpRetryPolicy.ts","../src/contracts/credentialTypes.ts","../src/contracts/workflowTypes.ts","../src/contracts/workflowActivationPolicy.ts"],"sourcesContent":["/** Port for time; inject `SystemClock` in production and a fake/test clock in tests. */\nexport interface Clock {\n now(): Date;\n}\n\nexport class SystemClock implements Clock {\n now(): Date {\n return new Date();\n }\n}\n","import type { TypeToken } from \"../di\";\n\nimport type { CredentialRequirement } from \"../contracts/credentialTypes\";\n\nimport type { Item, Items, NodeConfigBase, NodeExecutionContext, RunnableNodeConfig } from \"../types\";\n\nimport type { input as ZodInput, output as ZodOutput, ZodType } from \"zod\";\n\nexport interface AgentCanvasPresentation<TIcon extends string = string> {\n readonly label?: string;\n readonly icon?: TIcon;\n}\n\nexport type ZodSchemaAny = ZodType<any, any, any>;\n\nexport interface ToolConfig {\n readonly type: TypeToken<Tool<ToolConfig, ZodSchemaAny, ZodSchemaAny>>;\n readonly name: string;\n readonly description?: string;\n readonly presentation?: AgentCanvasPresentation;\n getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;\n}\n\nexport type ToolExecuteArgs<TConfig extends ToolConfig = ToolConfig, TInput = unknown> = Readonly<{\n config: TConfig;\n input: TInput;\n ctx: NodeExecutionContext<any>;\n item: Item;\n itemIndex: number;\n items: Items;\n}>;\n\nexport interface Tool<\n TConfig extends ToolConfig = ToolConfig,\n TInputSchema extends ZodSchemaAny = ZodSchemaAny,\n TOutputSchema extends ZodSchemaAny = ZodSchemaAny,\n> {\n readonly defaultDescription: string;\n readonly inputSchema: TInputSchema;\n readonly outputSchema: TOutputSchema;\n execute(\n args: ToolExecuteArgs<TConfig, ZodInput<TInputSchema>>,\n ): Promise<ZodOutput<TOutputSchema>> | ZodOutput<TOutputSchema>;\n}\n\nexport type AgentTool<\n TInputSchema extends ZodSchemaAny = ZodSchemaAny,\n TOutputSchema extends ZodSchemaAny = ZodSchemaAny,\n> = Tool<ToolConfig, TInputSchema, TOutputSchema>;\n\nexport type AgentToolExecuteArgs<TInput = unknown> = ToolExecuteArgs<ToolConfig, TInput>;\n\nexport type AgentToolToken = TypeToken<Tool<ToolConfig, ZodSchemaAny, ZodSchemaAny>>;\n\nexport interface AgentToolDefinition {\n readonly name: string;\n readonly description: string;\n readonly inputSchema: ZodSchemaAny;\n}\n\nexport type AgentToolCall = Readonly<{ id?: string; name: string; input: unknown }>;\n\nexport type AgentToolCallPlanner<_TNodeConfig = unknown> = (\n item: Item,\n index: number,\n items: Items,\n ctx: NodeExecutionContext<any>,\n) => ReadonlyArray<AgentToolCall>;\n\nexport interface ChatModelConfig {\n readonly type: TypeToken<ChatModelFactory<ChatModelConfig>>;\n readonly name: string;\n readonly presentation?: AgentCanvasPresentation;\n getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;\n}\n\nexport interface LangChainChatModelLike {\n invoke(input: unknown, options?: unknown): Promise<unknown>;\n bindTools?(tools: ReadonlyArray<unknown>): LangChainChatModelLike;\n}\n\nexport interface ChatModelFactory<TConfig extends ChatModelConfig = ChatModelConfig> {\n create(\n args: Readonly<{ config: TConfig; ctx: NodeExecutionContext<any> }>,\n ): Promise<LangChainChatModelLike> | LangChainChatModelLike;\n}\n\nexport interface AgentNodeConfig<TInputJson = unknown, TOutputJson = unknown> extends RunnableNodeConfig<\n TInputJson,\n TOutputJson\n> {\n readonly systemMessage: string;\n readonly userMessageFormatter: (\n item: Item<TInputJson>,\n index: number,\n items: Items<TInputJson>,\n ctx: NodeExecutionContext<any>,\n ) => string;\n readonly chatModel: ChatModelConfig;\n readonly tools?: ReadonlyArray<ToolConfig>;\n}\n\nexport class AgentConfigInspector {\n static isAgentNodeConfig(config: NodeConfigBase | undefined): config is AgentNodeConfig<any, any> {\n if (!config) return false;\n const candidate = config as Partial<AgentNodeConfig<any, any>>;\n return (\n typeof candidate.systemMessage === \"string\" &&\n typeof candidate.userMessageFormatter === \"function\" &&\n !!candidate.chatModel\n );\n }\n}\n\nexport type AgentAttachmentRole = \"languageModel\" | \"tool\";\n","import type { NodeId, NodeRef, OutputPortKey, UpstreamRefPlaceholder, WorkflowDefinition } from \"../../types\";\n\nimport { WorkflowBuilder } from \"./WorkflowBuilder\";\nimport type { AnyRunnableNodeConfig, BooleanWhenOverloads, ValidStepSequence } from \"./workflowBuilderTypes\";\n\nexport class WhenBuilder<TCurrentJson> {\n constructor(\n private readonly wf: WorkflowBuilder,\n private readonly from: NodeRef,\n private readonly branchPort: OutputPortKey,\n ) {}\n\n addBranch<TSteps extends ReadonlyArray<AnyRunnableNodeConfig>>(\n steps: TSteps & ValidStepSequence<TCurrentJson, TSteps>,\n ): this {\n const created: NodeRef[] = [];\n\n let prev: NodeRef | null = null;\n for (const cfg of steps) {\n const ref = (this.wf as any).add(cfg) as NodeRef;\n created.push(ref);\n if (!prev) (this.wf as any).connect(this.from, ref, this.branchPort, \"in\");\n else (this.wf as any).connect(prev, ref, \"main\", \"in\");\n prev = ref;\n }\n\n for (const cfg of steps) {\n const maybe = cfg as unknown as { upstreamRefs?: Array<{ nodeId: NodeId } | UpstreamRefPlaceholder> };\n if (!Array.isArray(maybe.upstreamRefs) || maybe.upstreamRefs.length === 0) continue;\n\n maybe.upstreamRefs = maybe.upstreamRefs.map((r) => {\n if (typeof r !== \"string\") return r;\n const idx = parseInt(r.slice(1), 10);\n const nodeId = created[idx]?.id;\n return nodeId ? { nodeId } : { nodeId: r };\n });\n }\n\n return this;\n }\n\n readonly when: BooleanWhenOverloads<TCurrentJson, WhenBuilder<TCurrentJson>> = (\n branch: boolean,\n steps: ReadonlyArray<AnyRunnableNodeConfig> | AnyRunnableNodeConfig,\n ...more: AnyRunnableNodeConfig[]\n ): WhenBuilder<TCurrentJson> => {\n const list = Array.isArray(steps) ? steps : [steps, ...more];\n const port: OutputPortKey = branch ? \"true\" : \"false\";\n const b = new WhenBuilder<TCurrentJson>(this.wf, this.from, port);\n b.addBranch(list);\n return b;\n };\n\n build(): WorkflowDefinition {\n return this.wf.build();\n }\n}\n","import type {\n NodeRef,\n OutputPortKey,\n RunnableNodeConfig,\n RunnableNodeOutputJson,\n WorkflowDefinition,\n} from \"../../types\";\n\nimport { WorkflowBuilder } from \"./WorkflowBuilder\";\nimport { WhenBuilder } from \"./WhenBuilder\";\nimport type {\n AnyRunnableNodeConfig,\n BooleanWhenOverloads,\n BranchOutputGuard,\n BranchStepsArg,\n StepSequenceOutput,\n} from \"./workflowBuilderTypes\";\n\ntype ChainCursorWhenOverloads<TCurrentJson> = BooleanWhenOverloads<TCurrentJson, WhenBuilder<TCurrentJson>> & {\n <\n TTrueSteps extends ReadonlyArray<AnyRunnableNodeConfig> | undefined,\n TFalseSteps extends ReadonlyArray<AnyRunnableNodeConfig> | undefined,\n >(\n branches: Readonly<{\n true?: TTrueSteps extends ReadonlyArray<AnyRunnableNodeConfig> ? BranchStepsArg<TCurrentJson, TTrueSteps> : never;\n false?: TFalseSteps extends ReadonlyArray<AnyRunnableNodeConfig>\n ? BranchStepsArg<TCurrentJson, TFalseSteps>\n : never;\n }> &\n BranchOutputGuard<TCurrentJson, TTrueSteps, TFalseSteps>,\n ): ChainCursor<StepSequenceOutput<TCurrentJson, TTrueSteps>>;\n};\n\nexport class ChainCursor<TCurrentJson> {\n constructor(\n private readonly wf: WorkflowBuilder,\n private readonly cursor: NodeRef,\n private readonly cursorOutput: OutputPortKey,\n ) {}\n\n then<TConfig extends RunnableNodeConfig<TCurrentJson, any>>(\n config: TConfig,\n ): ChainCursor<RunnableNodeOutputJson<TConfig>> {\n const next = (this.wf as any).add(config) as NodeRef;\n (this.wf as any).connect(this.cursor, next, this.cursorOutput);\n return new ChainCursor<RunnableNodeOutputJson<TConfig>>(this.wf, next, \"main\");\n }\n\n readonly when: ChainCursorWhenOverloads<TCurrentJson> = ((\n arg1:\n | boolean\n | Readonly<{ true?: ReadonlyArray<AnyRunnableNodeConfig>; false?: ReadonlyArray<AnyRunnableNodeConfig> }>,\n steps?: ReadonlyArray<AnyRunnableNodeConfig> | AnyRunnableNodeConfig,\n ...more: AnyRunnableNodeConfig[]\n ): WhenBuilder<TCurrentJson> | ChainCursor<TCurrentJson> => {\n if (typeof arg1 === \"boolean\") {\n const list = Array.isArray(steps) ? steps : steps ? [steps, ...more] : more;\n const port: OutputPortKey = arg1 ? \"true\" : \"false\";\n const b = new WhenBuilder<TCurrentJson>(this.wf, this.cursor, port);\n b.addBranch(list);\n return b;\n }\n\n const branches = arg1;\n const makeMerge = (this.wf as any).options?.makeMergeNode as ((name: string) => AnyRunnableNodeConfig) | undefined;\n if (!makeMerge) {\n throw new Error(\n 'WorkflowBuilder is missing options.makeMergeNode (required for when({true,false}). Use createWorkflowBuilder from \"@codemation/core-nodes\".',\n );\n }\n\n const wfAny = this.wf as any;\n\n const buildBranch = (\n port: OutputPortKey,\n branchSteps: ReadonlyArray<AnyRunnableNodeConfig> | undefined,\n ): Readonly<{ end: NodeRef; endOutput: OutputPortKey }> => {\n const list = branchSteps ?? [];\n let prev: NodeRef | null = null;\n for (const cfg of list) {\n const ref = wfAny.add(cfg) as NodeRef;\n if (!prev) wfAny.connect(this.cursor, ref, port, \"in\");\n else wfAny.connect(prev, ref, \"main\", \"in\");\n prev = ref;\n }\n if (!prev) return { end: this.cursor, endOutput: port };\n return { end: prev, endOutput: \"main\" };\n };\n\n const t = buildBranch(\"true\", branches.true);\n const f = buildBranch(\"false\", branches.false);\n\n const merge = wfAny.add(makeMerge(\"Merge (auto)\")) as NodeRef;\n wfAny.connect(t.end, merge, t.endOutput, \"true\");\n wfAny.connect(f.end, merge, f.endOutput, \"false\");\n\n return new ChainCursor<TCurrentJson>(this.wf, merge, \"main\");\n }) as ChainCursorWhenOverloads<TCurrentJson>;\n\n build(): WorkflowDefinition {\n return this.wf.build();\n }\n}\n","import type {\n InputPortKey,\n NodeConfigBase,\n NodeDefinition,\n NodeRef,\n OutputPortKey,\n RunnableNodeOutputJson,\n TriggerNodeOutputJson,\n WorkflowDefinition,\n WorkflowId,\n} from \"../../types\";\n\nimport { ChainCursor } from \"./ChainCursorResolver\";\nimport type { AnyRunnableNodeConfig, AnyTriggerNodeConfig } from \"./workflowBuilderTypes\";\n\nexport class WorkflowBuilder {\n private readonly nodes: NodeDefinition[] = [];\n private readonly edges: WorkflowDefinition[\"edges\"] = [];\n private seq = 0;\n\n constructor(\n private readonly meta: { id: WorkflowId; name: string },\n private readonly options?: Readonly<{\n makeMergeNode?: (name: string) => AnyRunnableNodeConfig;\n }>,\n ) {}\n\n private add(config: NodeConfigBase): NodeRef {\n const tokenName = typeof config.type === \"function\" ? config.type.name : String(config.type);\n const id = config.id ?? `${tokenName}:${++this.seq}`;\n this.nodes.push({ id, kind: config.kind, type: config.type, name: config.name, config });\n return { id, kind: config.kind, name: config.name };\n }\n\n private connect(from: NodeRef, to: NodeRef, fromOutput: OutputPortKey = \"main\", toInput: InputPortKey = \"in\"): void {\n this.edges.push({ from: { nodeId: from.id, output: fromOutput }, to: { nodeId: to.id, input: toInput } });\n }\n\n trigger<TConfig extends AnyTriggerNodeConfig>(config: TConfig): ChainCursor<TriggerNodeOutputJson<TConfig>> {\n const ref = this.add(config);\n return new ChainCursor<TriggerNodeOutputJson<TConfig>>(this, ref, \"main\");\n }\n\n start<TConfig extends AnyRunnableNodeConfig>(config: TConfig): ChainCursor<RunnableNodeOutputJson<TConfig>> {\n const ref = this.add(config);\n return new ChainCursor<RunnableNodeOutputJson<TConfig>>(this, ref, \"main\");\n }\n\n build(): WorkflowDefinition {\n return { ...this.meta, nodes: this.nodes, edges: this.edges };\n }\n}\n\nexport { ChainCursor } from \"./ChainCursorResolver\";\nexport { WhenBuilder } from \"./WhenBuilder\";\n","import { randomUUID } from \"node:crypto\";\n\nimport type { NodeId } from \"../../types\";\n\n/**\n * Unique ids for persisted connection invocation history rows (LLM/tool calls under an owning node).\n */\nexport class ConnectionInvocationIdFactory {\n static create(): string {\n return `cinv_${randomUUID()}`;\n }\n\n /** Deterministic id for tests when a stable sequence is needed. */\n static createForTest(runId: string, connectionNodeId: NodeId, sequence: number): string {\n return `cinv_${runId}_${connectionNodeId}_${sequence}`;\n }\n}\n","import type { InputPortKey, NodeId, OutputPortKey, WorkflowDefinition, WorkflowGraph } from \"../../types\";\n\nexport class ExecutableGraph implements WorkflowGraph {\n private readonly outgoingByNodeAndPort = new Map<\n NodeId,\n Map<OutputPortKey, Array<Readonly<{ nodeId: NodeId; input: InputPortKey }>>>\n >();\n\n constructor(def: WorkflowDefinition) {\n for (const e of def.edges) {\n const byPort =\n this.outgoingByNodeAndPort.get(e.from.nodeId) ??\n new Map<OutputPortKey, Array<Readonly<{ nodeId: NodeId; input: InputPortKey }>>>();\n const next = byPort.get(e.from.output) ?? [];\n next.push({ nodeId: e.to.nodeId, input: e.to.input });\n byPort.set(e.from.output, next);\n this.outgoingByNodeAndPort.set(e.from.nodeId, byPort);\n }\n }\n\n next(nodeId: NodeId, output: OutputPortKey): Array<Readonly<{ nodeId: NodeId; input: InputPortKey }>> {\n return this.outgoingByNodeAndPort.get(nodeId)?.get(output) ?? [];\n }\n}\n","import type { WorkflowDefinition, WorkflowGraph, WorkflowGraphFactory } from \"../../types\";\nimport { ExecutableGraph } from \"./ExecutableGraph\";\n\nexport class DefaultWorkflowGraphFactory implements WorkflowGraphFactory {\n create(def: WorkflowDefinition): WorkflowGraph {\n return new ExecutableGraph(def);\n }\n}\n","import type { RunEventSubscription } from \"./runEvents\";\n\nexport class InMemoryRunEventSubscription implements RunEventSubscription {\n constructor(private readonly onClose: () => void) {}\n\n async close(): Promise<void> {\n this.onClose();\n }\n}\n","import type { WorkflowId } from \"../types\";\n\nimport type { RunEvent, RunEventBus, RunEventSubscription } from \"./runEvents\";\n\nimport { InMemoryRunEventSubscription } from \"./InMemoryRunEventSubscription\";\n\nexport class InMemoryRunEventBus implements RunEventBus {\n private readonly globalListeners = new Set<(event: RunEvent) => void>();\n private readonly listenersByWorkflowId = new Map<WorkflowId, Set<(event: RunEvent) => void>>();\n\n async publish(event: RunEvent): Promise<void> {\n for (const listener of this.globalListeners) listener(event);\n for (const listener of this.listenersByWorkflowId.get(event.workflowId) ?? []) listener(event);\n }\n\n async subscribe(onEvent: (event: RunEvent) => void): Promise<RunEventSubscription> {\n this.globalListeners.add(onEvent);\n return new InMemoryRunEventSubscription(() => {\n this.globalListeners.delete(onEvent);\n });\n }\n\n async subscribeToWorkflow(workflowId: WorkflowId, onEvent: (event: RunEvent) => void): Promise<RunEventSubscription> {\n const existing = this.listenersByWorkflowId.get(workflowId) ?? new Set<(event: RunEvent) => void>();\n existing.add(onEvent);\n this.listenersByWorkflowId.set(workflowId, existing);\n\n return new InMemoryRunEventSubscription(() => {\n const listeners = this.listenersByWorkflowId.get(workflowId);\n if (!listeners) return;\n listeners.delete(onEvent);\n if (listeners.size === 0) this.listenersByWorkflowId.delete(workflowId);\n });\n }\n}\n\nexport { InMemoryRunEventSubscription } from \"./InMemoryRunEventSubscription\";\n","import type {\n PersistedRunState,\n RunId,\n RunPruneCandidate,\n RunSummary,\n WorkflowExecutionListingRepository,\n WorkflowExecutionPruneRepository,\n WorkflowExecutionRepository,\n WorkflowId,\n} from \"../types\";\nimport type { RunEventBus } from \"./runEvents\";\n\nexport class EventPublishingWorkflowExecutionRepository\n implements WorkflowExecutionRepository, WorkflowExecutionListingRepository, WorkflowExecutionPruneRepository\n{\n constructor(\n private readonly inner: WorkflowExecutionRepository,\n private readonly eventBus: RunEventBus,\n private readonly now: () => Date = () => new Date(),\n ) {}\n\n async createRun(args: Parameters<WorkflowExecutionRepository[\"createRun\"]>[0]): Promise<void> {\n await this.inner.createRun(args);\n await this.eventBus.publish({\n kind: \"runCreated\",\n runId: args.runId,\n workflowId: args.workflowId,\n parent: args.parent,\n at: this.now().toISOString(),\n });\n }\n\n async load(runId: RunId): Promise<PersistedRunState | undefined> {\n return await this.inner.load(runId);\n }\n\n async save(state: PersistedRunState): Promise<void> {\n await this.inner.save(state);\n await this.eventBus.publish({\n kind: \"runSaved\",\n runId: state.runId,\n workflowId: state.workflowId,\n parent: state.parent,\n at: this.now().toISOString(),\n state,\n });\n }\n\n async deleteRun(runId: RunId): Promise<void> {\n if (!this.inner.deleteRun) return;\n await this.inner.deleteRun(runId);\n }\n\n async listRuns(args?: Readonly<{ workflowId?: WorkflowId; limit?: number }>): Promise<ReadonlyArray<RunSummary>> {\n const listingRepository = this.inner as unknown as Partial<WorkflowExecutionListingRepository>;\n if (!listingRepository.listRuns) return [];\n return await listingRepository.listRuns(args);\n }\n\n async listRunsOlderThan(\n args: Readonly<{ beforeIso: string; limit?: number }>,\n ): Promise<ReadonlyArray<RunPruneCandidate>> {\n const pruneRepository = this.inner as unknown as Partial<WorkflowExecutionPruneRepository>;\n if (!pruneRepository.listRunsOlderThan) return [];\n return await pruneRepository.listRunsOlderThan(args);\n }\n}\n","import type { Item, Items } from \"../contracts/workflowTypes\";\nimport { injectable } from \"../di\";\n\n/**\n * Normalizes external inputs into the engine's canonical `Items` shape.\n * Used at host and builder boundaries where callers may provide either a raw value,\n * a single item-like object, or an array of item-like values.\n */\n@injectable()\nexport class ItemsInputNormalizer {\n normalize(raw: unknown): Items {\n if (raw === undefined || raw === null) {\n return [];\n }\n if (Array.isArray(raw)) {\n return raw.map((value) => this.normalizeItem(value));\n }\n return [this.normalizeItem(raw)];\n }\n\n private normalizeItem(raw: unknown): Item {\n if (!this.isItem(raw)) {\n return { json: raw };\n }\n return {\n json: raw.json,\n ...(raw.binary === undefined ? {} : { binary: raw.binary }),\n ...(raw.meta === undefined ? {} : { meta: raw.meta }),\n ...(raw.paired === undefined ? {} : { paired: raw.paired }),\n };\n }\n\n private isItem(raw: unknown): raw is Item {\n return typeof raw === \"object\" && raw !== null && Object.prototype.hasOwnProperty.call(raw, \"json\");\n }\n}\n","import type { NoneRetryPolicySpec } from \"./retryPolicySpec.types\";\n\nexport class NoRetryPolicy implements NoneRetryPolicySpec {\n readonly kind = \"none\" as const;\n}\n","import type { FixedRetryPolicySpec } from \"./retryPolicySpec.types\";\n\nexport class RetryPolicy implements FixedRetryPolicySpec {\n readonly kind = \"fixed\" as const;\n\n constructor(\n public readonly maxAttempts: number,\n public readonly delayMs: number,\n ) {\n if (!Number.isFinite(maxAttempts) || maxAttempts < 1 || !Number.isInteger(maxAttempts)) {\n throw new Error(`RetryPolicy.maxAttempts must be a positive integer, got ${maxAttempts}`);\n }\n if (!Number.isFinite(delayMs) || delayMs < 0) {\n throw new Error(`RetryPolicy.delayMs must be a non-negative finite number, got ${delayMs}`);\n }\n }\n\n /** Default for HTTP-style transient failures: 3 tries, 1s between attempts. */\n static readonly defaultForHttp: FixedRetryPolicySpec = { kind: \"fixed\", maxAttempts: 3, delayMs: 1000 };\n\n /** Default for LLM / agent calls: 3 tries, 2s fixed backoff. */\n static readonly defaultForAiAgent: FixedRetryPolicySpec = { kind: \"fixed\", maxAttempts: 3, delayMs: 2000 };\n}\n","import type { ExponentialRetryPolicySpec } from \"./retryPolicySpec.types\";\n\nexport class ExpRetryPolicy implements ExponentialRetryPolicySpec {\n readonly kind = \"exponential\" as const;\n\n constructor(\n public readonly maxAttempts: number,\n public readonly initialDelayMs: number,\n public readonly multiplier: number,\n public readonly maxDelayMs?: number,\n public readonly jitter?: boolean,\n ) {\n if (!Number.isFinite(maxAttempts) || maxAttempts < 1 || !Number.isInteger(maxAttempts)) {\n throw new Error(`ExpRetryPolicy.maxAttempts must be a positive integer, got ${maxAttempts}`);\n }\n if (!Number.isFinite(initialDelayMs) || initialDelayMs < 0) {\n throw new Error(`ExpRetryPolicy.initialDelayMs must be a non-negative finite number, got ${initialDelayMs}`);\n }\n if (!Number.isFinite(multiplier) || multiplier < 1) {\n throw new Error(`ExpRetryPolicy.multiplier must be >= 1, got ${multiplier}`);\n }\n }\n}\n","import type { NodeId, WorkflowId } from \"./workflowTypes\";\n\nexport type CredentialTypeId = string;\nexport type CredentialInstanceId = string;\n\nexport type CredentialMaterialSourceKind = \"db\" | \"env\" | \"code\";\nexport type CredentialSetupStatus = \"draft\" | \"ready\";\nexport type CredentialHealthStatus = \"unknown\" | \"healthy\" | \"failing\";\n\nexport type CredentialFieldSchema = Readonly<{\n key: string;\n label: string;\n type: \"string\" | \"password\" | \"textarea\" | \"json\" | \"boolean\";\n required?: true;\n order?: number;\n placeholder?: string;\n helpText?: string;\n /** When set, host resolves this field from process.env at runtime; env wins over stored values. */\n envVarName?: string;\n /**\n * When set, the dialog shows a copy action for this exact string (e.g. a static OAuth redirect URI\n * pattern or documentation URL). Do not use for secret values.\n */\n copyValue?: string;\n /** Accessible label for the copy control (default: Copy). */\n copyButtonLabel?: string;\n}>;\n\nexport type CredentialRequirement = Readonly<{\n slotKey: string;\n label: string;\n acceptedTypes: ReadonlyArray<CredentialTypeId>;\n optional?: true;\n helpText?: string;\n helpUrl?: string;\n}>;\n\nexport type CredentialBindingKey = Readonly<{\n workflowId: WorkflowId;\n nodeId: NodeId;\n slotKey: string;\n}>;\n\nexport type CredentialBinding = Readonly<{\n key: CredentialBindingKey;\n instanceId: CredentialInstanceId;\n updatedAt: string;\n}>;\n\nexport type CredentialHealth = Readonly<{\n status: CredentialHealthStatus;\n message?: string;\n testedAt?: string;\n expiresAt?: string;\n details?: Readonly<Record<string, unknown>>;\n}>;\n\nexport type OAuth2ProviderFromPublicConfig = Readonly<{\n authorizeUrlFieldKey: string;\n tokenUrlFieldKey: string;\n userInfoUrlFieldKey?: string;\n}>;\n\nexport type CredentialOAuth2AuthDefinition = Readonly<\n | {\n kind: \"oauth2\";\n providerId: string;\n scopes: ReadonlyArray<string>;\n clientIdFieldKey?: string;\n clientSecretFieldKey?: string;\n }\n | {\n kind: \"oauth2\";\n providerFromPublicConfig: OAuth2ProviderFromPublicConfig;\n scopes: ReadonlyArray<string>;\n clientIdFieldKey?: string;\n clientSecretFieldKey?: string;\n }\n>;\n\nexport type CredentialAuthDefinition = CredentialOAuth2AuthDefinition;\n\nexport type CredentialTypeDefinition = Readonly<{\n typeId: CredentialTypeId;\n displayName: string;\n description?: string;\n publicFields?: ReadonlyArray<CredentialFieldSchema>;\n secretFields?: ReadonlyArray<CredentialFieldSchema>;\n supportedSourceKinds?: ReadonlyArray<CredentialMaterialSourceKind>;\n auth?: CredentialAuthDefinition;\n}>;\n\n/**\n * JSON-shaped credential field bag (public config, resolved secret material, etc.).\n */\nexport type CredentialJsonRecord = Readonly<Record<string, unknown>>;\n\n/**\n * Persisted credential instance with typed `publicConfig`.\n * Hosts may specialize `secretRef` with a stricter union while remaining\n * assignable here for session/test callbacks.\n */\nexport type CredentialInstanceRecord<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{\n instanceId: CredentialInstanceId;\n typeId: CredentialTypeId;\n displayName: string;\n sourceKind: CredentialMaterialSourceKind;\n publicConfig: TPublicConfig;\n secretRef: CredentialJsonRecord;\n tags: ReadonlyArray<string>;\n setupStatus: CredentialSetupStatus;\n createdAt: string;\n updatedAt: string;\n}>;\n\n/**\n * Arguments passed to `CredentialType.createSession` and `CredentialType.test`.\n * Declare `TPublicConfig` / `TMaterial` on `CredentialType` so implementations are checked\n * against your credential shapes (similar to `NodeExecutionContext.config` for nodes).\n */\nexport type CredentialSessionFactoryArgs<\n TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord,\n TMaterial extends CredentialJsonRecord = CredentialJsonRecord,\n> = Readonly<{\n instance: CredentialInstanceRecord<TPublicConfig>;\n material: TMaterial;\n publicConfig: TPublicConfig;\n}>;\n\nexport type CredentialSessionFactory<\n TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord,\n TMaterial extends CredentialJsonRecord = CredentialJsonRecord,\n TSession = unknown,\n> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<TSession>;\n\nexport type CredentialHealthTester<\n TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord,\n TMaterial extends CredentialJsonRecord = CredentialJsonRecord,\n> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<CredentialHealth>;\n\n/**\n * Full credential type implementation: `definition` (UI/schema), `createSession`, and `test`.\n * Use this at registration and config boundaries; `CredentialTypeDefinition` is only the schema slice.\n */\nexport type CredentialType<\n TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord,\n TMaterial extends CredentialJsonRecord = CredentialJsonRecord,\n TSession = unknown,\n> = Readonly<{\n definition: CredentialTypeDefinition;\n createSession: CredentialSessionFactory<TPublicConfig, TMaterial, TSession>;\n test: CredentialHealthTester<TPublicConfig, TMaterial>;\n}>;\n\n/**\n * Credential type with unspecified generics — used for `CodemationConfig.credentialTypes`, the host registry,\n * and anywhere a concrete `CredentialType<YourPublic, YourMaterial, YourSession>` is placed in a heterogeneous list.\n * Using `any` here avoids unsafe `as` casts while keeping typed `satisfies CredentialType<…>` definitions.\n */\nexport type AnyCredentialType = CredentialType<any, any, unknown>;\n\nexport interface CredentialSessionService {\n getSession<TSession = unknown>(\n args: Readonly<{\n workflowId: WorkflowId;\n nodeId: NodeId;\n slotKey: string;\n }>,\n ): Promise<TSession>;\n}\n\nexport interface CredentialTypeRegistry {\n listTypes(): ReadonlyArray<CredentialTypeDefinition>;\n getType(typeId: CredentialTypeId): CredentialTypeDefinition | undefined;\n}\n\nexport class CredentialUnboundError extends Error {\n constructor(\n public readonly bindingKey: CredentialBindingKey,\n public readonly acceptedTypes: ReadonlyArray<CredentialTypeId> = [],\n ) {\n super(CredentialUnboundError.createMessage(bindingKey, acceptedTypes));\n this.name = \"CredentialUnboundError\";\n }\n\n private static createMessage(\n bindingKey: CredentialBindingKey,\n acceptedTypes: ReadonlyArray<CredentialTypeId>,\n ): string {\n const acceptedTypesSuffix =\n acceptedTypes.length > 0 ? ` Accepted credential types: ${acceptedTypes.join(\", \")}.` : \"\";\n return `Credential slot \"${bindingKey.slotKey}\" is not bound for workflow ${bindingKey.workflowId} node ${bindingKey.nodeId}.${acceptedTypesSuffix}`;\n }\n}\n","import type { TypeToken } from \"../di\";\nimport type { CredentialRequirement } from \"./credentialTypes\";\nimport type { RetryPolicySpec } from \"./retryPolicySpec.types\";\n\nexport type WorkflowId = string;\nexport type NodeId = string;\nexport type OutputPortKey = string;\nexport type InputPortKey = string;\nexport type PersistedTokenId = string;\n\nexport type NodeKind = \"trigger\" | \"node\";\nexport type JsonPrimitive = string | number | boolean | null;\nexport interface JsonObject {\n readonly [key: string]: JsonValue;\n}\nexport type JsonValue = JsonPrimitive | JsonObject | JsonArray;\nexport type JsonArray = ReadonlyArray<JsonValue>;\n\nexport interface Edge {\n from: { nodeId: NodeId; output: OutputPortKey };\n to: { nodeId: NodeId; input: InputPortKey };\n}\n\nexport type NodeConnectionName = string;\n\n/**\n * Named connection from an executable parent node to child nodes that exist in {@link WorkflowDefinition.nodes}\n * but are not traversed by the main execution graph.\n */\nexport interface WorkflowNodeConnection {\n readonly parentNodeId: NodeId;\n readonly connectionName: NodeConnectionName;\n readonly childNodeIds: ReadonlyArray<NodeId>;\n}\n\nexport interface WorkflowDefinition {\n id: WorkflowId;\n name: string;\n nodes: NodeDefinition[];\n edges: Edge[];\n /**\n * Optional metadata: which nodes are connection-owned children (e.g. AI agent `llm` / `tools` slots).\n * When omitted, all nodes in {@link nodes} are treated as executable for topology.\n */\n readonly connections?: ReadonlyArray<WorkflowNodeConnection>;\n /** Directory + file-stem path under a workflow discovery root (for UI grouping only). */\n discoveryPathSegments?: readonly string[];\n /** Retention for run JSON and binaries (seconds). Host/env may supply defaults when omitted. */\n readonly prunePolicy?: WorkflowPrunePolicySpec;\n /** Whether to keep run data after completion. Host/env may supply defaults when omitted. */\n readonly storagePolicy?: WorkflowStoragePolicySpec;\n /** Invoked after a node fails permanently (retries exhausted) and node error handler did not recover. */\n readonly workflowErrorHandler?: WorkflowErrorHandlerSpec;\n}\n\nexport interface WorkflowGraph {\n next(nodeId: NodeId, output: OutputPortKey): ReadonlyArray<Readonly<{ nodeId: NodeId; input: InputPortKey }>>;\n}\n\nexport interface WorkflowGraphFactory {\n create(def: WorkflowDefinition): WorkflowGraph;\n}\n\nexport interface NodeConfigBase {\n readonly kind: NodeKind;\n readonly type: TypeToken<unknown>;\n readonly name?: string;\n readonly id?: NodeId;\n readonly icon?: string;\n readonly execution?: Readonly<{ hint?: \"local\" | \"worker\"; queue?: string }>;\n /** In-process execute retries (runnable nodes). Triggers typically omit this. */\n readonly retryPolicy?: RetryPolicySpec;\n /** Recover from execute failures; return outputs to continue, or rethrow to fail the node. */\n readonly nodeErrorHandler?: NodeErrorHandlerSpec;\n /**\n * When true, edges carrying zero items on an output port still schedule single-input downstream nodes.\n * Decided from the **source** node that produced the (empty) output. Default (false/undefined): empty\n * main batches skip downstream execution and propagate the empty path.\n */\n readonly continueWhenEmptyOutput?: boolean;\n getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;\n}\n\nexport declare const runnableNodeInputType: unique symbol;\nexport declare const runnableNodeOutputType: unique symbol;\nexport declare const triggerNodeOutputType: unique symbol;\n\nexport interface RunnableNodeConfig<TInputJson = unknown, TOutputJson = unknown> extends NodeConfigBase {\n readonly kind: \"node\";\n readonly [runnableNodeInputType]?: TInputJson;\n readonly [runnableNodeOutputType]?: TOutputJson;\n}\n\nexport declare const triggerNodeSetupStateType: unique symbol;\n\nexport interface TriggerNodeConfig<\n TOutputJson = unknown,\n TSetupState extends JsonValue | undefined = undefined,\n> extends NodeConfigBase {\n readonly kind: \"trigger\";\n readonly [triggerNodeOutputType]?: TOutputJson;\n readonly [triggerNodeSetupStateType]?: TSetupState;\n}\n\nexport type RunnableNodeInputJson<TConfig extends RunnableNodeConfig<any, any>> =\n TConfig extends RunnableNodeConfig<infer TInputJson, any> ? TInputJson : never;\n\nexport type RunnableNodeOutputJson<TConfig extends RunnableNodeConfig<any, any>> =\n TConfig extends RunnableNodeConfig<any, infer TOutputJson> ? TOutputJson : never;\n\nexport type TriggerNodeOutputJson<TConfig extends TriggerNodeConfig<any, any>> =\n TConfig extends TriggerNodeConfig<infer TOutputJson, any> ? TOutputJson : never;\n\nexport type TriggerNodeSetupState<TConfig extends TriggerNodeConfig<any, any>> =\n TConfig extends TriggerNodeConfig<any, infer TSetupState> ? TSetupState : never;\n\nexport interface NodeDefinition {\n id: NodeId;\n kind: NodeKind;\n type: TypeToken<unknown>;\n name?: string;\n config: NodeConfigBase;\n}\n\nexport interface NodeRef {\n id: NodeId;\n kind: NodeKind;\n name?: string;\n}\n\nexport type PairedItemRef = Readonly<{ nodeId: NodeId; output: OutputPortKey; itemIndex: number }>;\n\nexport type BinaryPreviewKind = \"image\" | \"audio\" | \"video\" | \"download\";\n\nexport type BinaryAttachment = Readonly<{\n id: string;\n storageKey: string;\n mimeType: string;\n size: number;\n storageDriver: string;\n previewKind: BinaryPreviewKind;\n createdAt: string;\n runId: RunId;\n workflowId: WorkflowId;\n nodeId: NodeId;\n activationId: NodeActivationId;\n filename?: string;\n sha256?: string;\n}>;\n\nexport type ItemBinary = Readonly<Record<string, BinaryAttachment>>;\n\nexport type Item<TJson = unknown> = Readonly<{\n json: TJson;\n binary?: ItemBinary;\n meta?: Readonly<Record<string, unknown>>;\n paired?: ReadonlyArray<PairedItemRef>;\n}>;\n\nexport type Items<TJson = unknown> = ReadonlyArray<Item<TJson>>;\n\nexport type NodeOutputs = Partial<Record<OutputPortKey, Items>>;\n\nexport type RunId = string;\nexport type NodeActivationId = string;\n\nexport interface ParentExecutionRef {\n runId: RunId;\n workflowId: WorkflowId;\n nodeId: NodeId;\n /** Subworkflow depth of the **spawning** run (0 = root). Passed when starting a child run. */\n subworkflowDepth?: number;\n /** Effective max node activations from the parent run (propagated to child policy merge). */\n engineMaxNodeActivations?: number;\n /** Effective max subworkflow depth from the parent run (propagated to child policy merge). */\n engineMaxSubworkflowDepth?: number;\n}\n\nexport interface RunDataSnapshot {\n getOutputs(nodeId: NodeId): NodeOutputs | undefined;\n getOutputItems(nodeId: NodeId, output?: OutputPortKey): Items;\n getOutputItem(nodeId: NodeId, itemIndex: number, output?: OutputPortKey): Item | undefined;\n}\n\nexport interface MutableRunData extends RunDataSnapshot {\n setOutputs(nodeId: NodeId, outputs: NodeOutputs): void;\n dump(): Record<NodeId, NodeOutputs>;\n}\n\nexport interface RunDataFactory {\n create(initial?: Record<NodeId, NodeOutputs>): MutableRunData;\n}\n\nexport interface RunIdFactory {\n makeRunId(): RunId;\n}\n\nexport interface ActivationIdFactory {\n makeActivationId(): NodeActivationId;\n}\n\nexport type UpstreamRefPlaceholder = `$${number}`;\nexport const branchRef = (index: number) => `$${index}` as UpstreamRefPlaceholder;\n\nexport type ExecutionMode = \"local\" | \"worker\";\n\nexport interface NodeSchedulerDecision {\n mode: ExecutionMode;\n queue?: string;\n}\n\nexport interface NodeOffloadPolicy {\n decide(args: { workflowId: WorkflowId; nodeId: NodeId; config: NodeConfigBase }): NodeSchedulerDecision;\n}\n\n/** Whether to persist run execution data after the workflow finishes. */\nexport type WorkflowStoragePolicyMode = \"ALL\" | \"SUCCESS\" | \"ERROR\" | \"NEVER\";\n\nexport type WorkflowStoragePolicySpec = WorkflowStoragePolicyMode | TypeToken<WorkflowStoragePolicyResolver>;\n\nexport interface WorkflowStoragePolicyResolver {\n shouldPersist(args: WorkflowStoragePolicyDecisionArgs): boolean | Promise<boolean>;\n}\n\nexport interface WorkflowStoragePolicyDecisionArgs {\n readonly runId: RunId;\n readonly workflowId: WorkflowId;\n readonly workflow: WorkflowDefinition;\n readonly finalStatus: \"completed\" | \"failed\";\n readonly startedAt: string;\n readonly finishedAt: string;\n}\n\nexport interface WorkflowPrunePolicySpec {\n readonly runDataRetentionSeconds?: number;\n readonly binaryRetentionSeconds?: number;\n}\n\nexport interface PersistedRunPolicySnapshot {\n readonly retentionSeconds?: number;\n readonly binaryRetentionSeconds?: number;\n readonly storagePolicy: WorkflowStoragePolicyMode;\n}\n\nexport interface WorkflowErrorHandler {\n onError(ctx: WorkflowErrorContext): void | Promise<void>;\n}\n\nexport interface WorkflowErrorContext {\n readonly runId: RunId;\n readonly workflowId: WorkflowId;\n readonly workflow: WorkflowDefinition;\n readonly failedNodeId: NodeId;\n readonly error: Error;\n readonly startedAt: string;\n readonly finishedAt: string;\n}\n\nexport type WorkflowErrorHandlerSpec = TypeToken<WorkflowErrorHandler> | WorkflowErrorHandler;\n\nexport interface NodeErrorHandlerArgs<TConfig extends NodeConfigBase = NodeConfigBase> {\n readonly kind: \"single\" | \"multi\";\n readonly items: Items;\n readonly inputsByPort: Readonly<Record<InputPortKey, Items>> | undefined;\n readonly ctx: import(\"./runtimeTypes\").NodeExecutionContext<TConfig>;\n readonly error: Error;\n}\n\nexport interface NodeErrorHandler {\n handle<TConfig extends NodeConfigBase>(args: NodeErrorHandlerArgs<TConfig>): Promise<NodeOutputs>;\n}\n\nexport type NodeErrorHandlerSpec = TypeToken<NodeErrorHandler> | NodeErrorHandler;\n\n/** Runtime defaults when workflow omits prune/storage fields (typically from host env). */\nexport interface WorkflowPolicyRuntimeDefaults {\n readonly retentionSeconds?: number;\n readonly binaryRetentionSeconds?: number;\n readonly storagePolicy?: WorkflowStoragePolicyMode;\n}\n","import type { WorkflowId } from \"./workflowTypes\";\n\n/**\n * Host-controlled policy: when false, trigger {@link TriggerNode} setup is skipped and webhook routes\n * for that workflow are not registered (see engine trigger runtime + webhook matcher).\n */\nexport interface WorkflowActivationPolicy {\n isActive(workflowId: WorkflowId): boolean;\n}\n\n/** Default for tests and harnesses: every workflow is treated as active (legacy behavior). */\nexport class AllWorkflowsActiveWorkflowActivationPolicy implements WorkflowActivationPolicy {\n isActive(_workflowId: WorkflowId): boolean {\n return true;\n }\n}\n"],"mappings":";;;;;;;;AAKA,IAAa,cAAb,MAA0C;CACxC,MAAY;AACV,yBAAO,IAAI,MAAM;;;;;;AC+FrB,IAAa,uBAAb,MAAkC;CAChC,OAAO,kBAAkB,QAAyE;AAChG,MAAI,CAAC,OAAQ,QAAO;EACpB,MAAM,YAAY;AAClB,SACE,OAAO,UAAU,kBAAkB,YACnC,OAAO,UAAU,yBAAyB,cAC1C,CAAC,CAAC,UAAU;;;;;;ACxGlB,IAAa,cAAb,MAAa,YAA0B;CACrC,YACE,AAAiBA,IACjB,AAAiBC,MACjB,AAAiBC,YACjB;EAHiB;EACA;EACA;;CAGnB,UACE,OACM;EACN,MAAMC,UAAqB,EAAE;EAE7B,IAAIC,OAAuB;AAC3B,OAAK,MAAM,OAAO,OAA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AU,YAAY,CACpF,OAAM,IAAI,MAAM,8DAA8D,cAAc;AAE9F,MAAI,CAAC,OAAO,SAAS,eAAe,IAAI,iBAAiB,EACvD,OAAM,IAAI,MAAM,2EAA2E,iBAAiB;AAE9G,MAAI,CAAC,OAAO,SAAS,WAAW,IAAI,aAAa,EAC/C,OAAM,IAAI,MAAM,+CAA+C,aAAa;;;;;;AC6JlF,IAAa,yBAAb,MAAa,+BAA+B,MAAM;CAChD,YACE,AAAgBC,YAChB,AAAgBC,gBAAiD,EAAE,EACnE;AACA,QAAM,uBAAuB,cAAc,YAAY,cAAc,CAAC;EAHtD;EACA;AAGhB,OAAK,OAAO;;CAGd,OAAe,cACb,YACA,eACQ;EACR,MAAM,sBACJ,cAAc,SAAS,IAAI,+BAA+B,cAAc,KAAK,KAAK,CAAC,KAAK;AAC1F,SAAO,oBAAoB,WAAW,QAAQ,8BAA8B,WAAW,WAAW,QAAQ,WAAW,OAAO,GAAG;;;;;;ACWnI,MAAa,aAAa,UAAkB,IAAI;;;;;AC/LhD,IAAa,6CAAb,MAA4F;CAC1F,SAAS,aAAkC;AACzC,SAAO"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["name: string","node: TNodeConfig","node","node","messages: AgentMessageDto[]","wf: WorkflowBuilder","from: NodeRef","branchPort: OutputPortKey","created: NodeRef[]","prev: NodeRef | null","port: OutputPortKey","wf: WorkflowBuilder","cursor: NodeRef","cursorOutput: OutputPortKey","port: OutputPortKey","prev: NodeRef | null","meta: { id: WorkflowId; name: string }","options?: Readonly<{\n makeMergeNode?: (name: string) => AnyRunnableNodeConfig;\n }>","onClose: () => void","inner: WorkflowExecutionRepository","eventBus: RunEventBus","now: () => Date","ItemsInputNormalizer","maxAttempts: number","delayMs: number","maxAttempts: number","initialDelayMs: number","multiplier: number","maxDelayMs?: number","jitter?: boolean","bindingKey: CredentialBindingKey","acceptedTypes: ReadonlyArray<CredentialTypeId>"],"sources":["../src/contracts/Clock.ts","../src/ai/NodeBackedToolConfig.ts","../src/ai/AgentToolFactory.ts","../src/ai/AgentMessageConfigNormalizerFactory.ts","../src/ai/AgentConfigInspectorFactory.ts","../src/ai/AiHost.ts","../src/workflow/dsl/WhenBuilder.ts","../src/workflow/dsl/ChainCursorResolver.ts","../src/workflow/dsl/WorkflowBuilder.ts","../src/workflow/definition/ConnectionInvocationIdFactory.ts","../src/workflow/graph/ExecutableGraph.ts","../src/workflow/graph/DefaultWorkflowGraphFactory.ts","../src/events/InMemoryRunEventSubscription.ts","../src/events/InMemoryRunEventBusRegistry.ts","../src/events/EventPublishingWorkflowExecutionRepository.ts","../src/serialization/ItemsInputNormalizer.ts","../src/contracts/NoRetryPolicy.ts","../src/contracts/RetryPolicy.ts","../src/contracts/ExpRetryPolicy.ts","../src/contracts/credentialTypes.ts","../src/contracts/workflowTypes.ts","../src/contracts/workflowActivationPolicy.ts"],"sourcesContent":["/** Port for time; inject `SystemClock` in production and a fake/test clock in tests. */\nexport interface Clock {\n now(): Date;\n}\n\nexport class SystemClock implements Clock {\n now(): Date {\n return new Date();\n }\n}\n","import type { CredentialRequirement } from \"../contracts/credentialTypes\";\nimport type { TypeToken } from \"../di\";\nimport type { Item, NodeOutputs, RunnableNodeConfig, RunnableNodeInputJson } from \"../types\";\nimport type { input as ZodInput, output as ZodOutput } from \"zod\";\nimport type {\n AgentCanvasPresentation,\n NodeBackedToolConfigOptions,\n NodeBackedToolInputMapper,\n NodeBackedToolInputMapperArgs,\n NodeBackedToolOutputMapper,\n NodeBackedToolOutputMapperArgs,\n ToolConfig,\n ZodSchemaAny,\n} from \"./AiHost\";\n\nexport class NodeBackedToolConfig<\n TNodeConfig extends RunnableNodeConfig<any, any>,\n TInputSchema extends ZodSchemaAny,\n TOutputSchema extends ZodSchemaAny,\n> implements ToolConfig {\n readonly type: TypeToken<unknown>;\n readonly toolKind = \"nodeBacked\" as const;\n readonly description?: string;\n readonly presentation?: AgentCanvasPresentation;\n private readonly inputSchemaValue: TInputSchema;\n private readonly outputSchemaValue: TOutputSchema;\n private readonly mapInputValue?: NodeBackedToolInputMapper<TNodeConfig, ZodInput<TInputSchema>>;\n private readonly mapOutputValue?: NodeBackedToolOutputMapper<\n TNodeConfig,\n ZodInput<TInputSchema>,\n ZodOutput<TOutputSchema>\n >;\n\n constructor(\n public readonly name: string,\n public readonly node: TNodeConfig,\n options: NodeBackedToolConfigOptions<TNodeConfig, TInputSchema, TOutputSchema>,\n ) {\n this.type = node.type;\n this.description = options.description;\n this.presentation = options.presentation;\n this.inputSchemaValue = options.inputSchema;\n this.outputSchemaValue = options.outputSchema;\n this.mapInputValue = options.mapInput;\n this.mapOutputValue = options.mapOutput;\n }\n\n getCredentialRequirements(): ReadonlyArray<CredentialRequirement> {\n return this.node.getCredentialRequirements?.() ?? [];\n }\n\n getInputSchema(): TInputSchema {\n return this.inputSchemaValue;\n }\n\n getOutputSchema(): TOutputSchema {\n return this.outputSchemaValue;\n }\n\n toNodeItem(\n args: NodeBackedToolInputMapperArgs<TNodeConfig, ZodInput<TInputSchema>>,\n ): Item<RunnableNodeInputJson<TNodeConfig>> {\n const mapped = this.mapInputValue?.(args) ?? (args.input as RunnableNodeInputJson<TNodeConfig>);\n if (this.isItem(mapped)) {\n return mapped;\n }\n return { json: mapped };\n }\n\n toToolOutput(args: NodeBackedToolOutputMapperArgs<TNodeConfig, ZodInput<TInputSchema>>): ZodOutput<TOutputSchema> {\n const raw = this.mapOutputValue?.(args) ?? this.readDefaultToolOutput(args.outputs);\n return this.outputSchemaValue.parse(raw) as ZodOutput<TOutputSchema>;\n }\n\n private readDefaultToolOutput(outputs: NodeOutputs): unknown {\n const firstMainItem = outputs.main?.[0];\n if (!firstMainItem) {\n throw new Error(`Node-backed tool \"${this.name}\" did not produce a main output item.`);\n }\n return firstMainItem.json;\n }\n\n private isItem(value: unknown): value is Item {\n return typeof value === \"object\" && value !== null && \"json\" in value;\n }\n}\n","import type { RunnableNodeConfig } from \"../types\";\nimport type { NodeBackedToolConfigOptions, ZodSchemaAny } from \"./AiHost\";\nimport { NodeBackedToolConfig } from \"./NodeBackedToolConfig\";\n\nclass AgentToolFactoryImpl {\n asTool<\n TNodeConfig extends RunnableNodeConfig<any, any>,\n TInputSchema extends ZodSchemaAny,\n TOutputSchema extends ZodSchemaAny,\n >(\n node: TNodeConfig,\n options: Readonly<{ name?: string } & NodeBackedToolConfigOptions<TNodeConfig, TInputSchema, TOutputSchema>>,\n ): NodeBackedToolConfig<TNodeConfig, TInputSchema, TOutputSchema> {\n return new NodeBackedToolConfig(options.name ?? node.name ?? \"tool\", node, options);\n }\n}\n\nexport const AgentToolFactory = new AgentToolFactoryImpl();\n","import type {\n AgentMessageBuildArgs,\n AgentMessageConfig,\n AgentMessageDto,\n AgentMessageLine,\n AgentNodeConfig,\n} from \"./AiHost\";\n\nexport class AgentMessageConfigNormalizer {\n static normalize<TInputJson, TOutputJson>(\n config: AgentNodeConfig<TInputJson, TOutputJson>,\n args: AgentMessageBuildArgs<TInputJson>,\n ): ReadonlyArray<AgentMessageDto> {\n const fromMessages = this.normalizeRichMessages(config.messages, args);\n if (fromMessages.length > 0) {\n return fromMessages;\n }\n throw new Error(\n \"AIAgent messages must be a non-empty array, or an object with a non-empty prompt array and/or buildMessages that returns messages.\",\n );\n }\n\n private static normalizeRichMessages<TInputJson>(\n config: AgentMessageConfig<TInputJson>,\n args: AgentMessageBuildArgs<TInputJson>,\n ): ReadonlyArray<AgentMessageDto> {\n if (Array.isArray(config)) {\n return config.map((line) => this.lineToDto(line, args));\n }\n const structured = config as {\n readonly prompt?: ReadonlyArray<AgentMessageLine<TInputJson>>;\n readonly buildMessages?: (a: AgentMessageBuildArgs<TInputJson>) => ReadonlyArray<AgentMessageDto>;\n };\n const messages: AgentMessageDto[] = [];\n for (const line of structured.prompt ?? []) {\n messages.push(this.lineToDto(line, args));\n }\n for (const message of structured.buildMessages?.(args) ?? []) {\n messages.push(message);\n }\n return messages;\n }\n\n private static lineToDto<TInputJson>(\n line: AgentMessageLine<TInputJson>,\n args: AgentMessageBuildArgs<TInputJson>,\n ): AgentMessageDto {\n const content = typeof line.content === \"function\" ? line.content(args) : line.content;\n return { role: line.role, content };\n }\n}\n","import type { NodeConfigBase } from \"../types\";\nimport type { AgentNodeConfig } from \"./AiHost\";\n\nexport class AgentConfigInspector {\n static isAgentNodeConfig(config: NodeConfigBase | undefined): config is AgentNodeConfig<any, any> {\n if (!config) return false;\n const candidate = config as Partial<AgentNodeConfig<any, any>>;\n return !!candidate.chatModel && this.hasCompatibleMessageConfiguration(candidate);\n }\n\n private static hasCompatibleMessageConfiguration(candidate: Partial<AgentNodeConfig<any, any>>): boolean {\n const messages = candidate.messages;\n if (messages === undefined || messages === null) {\n return false;\n }\n if (Array.isArray(messages)) {\n return messages.length > 0;\n }\n if (typeof messages === \"object\") {\n const o = messages as { prompt?: unknown; buildMessages?: unknown };\n return (Array.isArray(o.prompt) && o.prompt.length > 0) || typeof o.buildMessages === \"function\";\n }\n return false;\n }\n}\n","import type { TypeToken } from \"../di\";\n\nimport type { CredentialRequirement } from \"../contracts/credentialTypes\";\n\nimport type {\n Item,\n Items,\n JsonValue,\n NodeExecutionContext,\n NodeOutputs,\n RunnableNodeConfig,\n RunnableNodeInputJson,\n} from \"../types\";\n\nimport type { input as ZodInput, output as ZodOutput, ZodType } from \"zod\";\n\nexport interface AgentCanvasPresentation<TIcon extends string = string> {\n readonly label?: string;\n readonly icon?: TIcon;\n}\n\nexport type ZodSchemaAny = ZodType<any, any, any>;\n\nexport interface ToolConfig {\n readonly type: TypeToken<unknown>;\n readonly name: string;\n readonly description?: string;\n readonly presentation?: AgentCanvasPresentation;\n getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;\n}\n\nexport type ToolExecuteArgs<TConfig extends ToolConfig = ToolConfig, TInput = unknown> = Readonly<{\n config: TConfig;\n input: TInput;\n ctx: NodeExecutionContext<any>;\n item: Item;\n itemIndex: number;\n items: Items;\n}>;\n\nexport interface Tool<\n TConfig extends ToolConfig = ToolConfig,\n TInputSchema extends ZodSchemaAny = ZodSchemaAny,\n TOutputSchema extends ZodSchemaAny = ZodSchemaAny,\n> {\n readonly defaultDescription: string;\n readonly inputSchema: TInputSchema;\n readonly outputSchema: TOutputSchema;\n execute(\n args: ToolExecuteArgs<TConfig, ZodInput<TInputSchema>>,\n ): Promise<ZodOutput<TOutputSchema>> | ZodOutput<TOutputSchema>;\n}\n\nexport type AgentTool<\n TInputSchema extends ZodSchemaAny = ZodSchemaAny,\n TOutputSchema extends ZodSchemaAny = ZodSchemaAny,\n> = Tool<ToolConfig, TInputSchema, TOutputSchema>;\n\nexport type AgentToolExecuteArgs<TInput = unknown> = ToolExecuteArgs<ToolConfig, TInput>;\n\nexport type AgentToolToken = TypeToken<Tool<ToolConfig, ZodSchemaAny, ZodSchemaAny>>;\n\nexport type AgentMessageRole = \"system\" | \"user\" | \"assistant\";\n\nexport type AgentMessageBuildArgs<TInputJson = unknown> = Readonly<{\n item: Item<TInputJson>;\n itemIndex: number;\n items: Items<TInputJson>;\n ctx: NodeExecutionContext<any>;\n}>;\n\nexport interface AgentMessageDto {\n readonly role: AgentMessageRole;\n readonly content: string;\n}\n\nexport type AgentMessageTemplateContent<TInputJson = unknown> =\n | string\n | ((args: AgentMessageBuildArgs<TInputJson>) => string);\n\nexport interface AgentMessageTemplate<TInputJson = unknown> {\n readonly role: AgentMessageRole;\n readonly content: AgentMessageTemplateContent<TInputJson>;\n}\n\n/** A single prompt line: fixed DTO or template with optional function `content`. */\nexport type AgentMessageLine<TInputJson = unknown> = AgentMessageDto | AgentMessageTemplate<TInputJson>;\n\n/**\n * Message list for an agent. Prefer a **plain array** of `{ role, content }` (optionally with function `content` for templates).\n * Use the object form only when you need `buildMessages` to append messages after optional `prompt` lines.\n */\nexport type AgentMessageConfig<TInputJson = unknown> =\n | ReadonlyArray<AgentMessageLine<TInputJson>>\n | {\n readonly prompt?: ReadonlyArray<AgentMessageLine<TInputJson>>;\n readonly buildMessages?: (args: AgentMessageBuildArgs<TInputJson>) => ReadonlyArray<AgentMessageDto>;\n };\n\nexport type AgentTurnLimitBehavior = \"error\" | \"respondWithLastMessage\";\n\nexport interface AgentModelInvocationOptions {\n readonly maxTokens?: number;\n readonly providerOptions?: Readonly<Record<string, JsonValue>>;\n}\n\nexport interface AgentGuardrailConfig {\n readonly maxTurns?: number;\n readonly onTurnLimitReached?: AgentTurnLimitBehavior;\n readonly modelInvocationOptions?: AgentModelInvocationOptions;\n}\n\n/** Defaults aligned with common tool-agent iteration limits (many products use ~10 max rounds). */\nexport const AgentGuardrailDefaults = {\n maxTurns: 10,\n onTurnLimitReached: \"error\" as AgentTurnLimitBehavior,\n} as const;\n\nexport interface AgentToolDefinition {\n readonly name: string;\n readonly description: string;\n readonly inputSchema: ZodSchemaAny;\n}\n\nexport type AgentToolCall = Readonly<{ id?: string; name: string; input: unknown }>;\n\nexport type AgentToolCallPlanner<_TNodeConfig = unknown> = (\n item: Item,\n index: number,\n items: Items,\n ctx: NodeExecutionContext<any>,\n) => ReadonlyArray<AgentToolCall>;\n\nexport interface ChatModelConfig {\n readonly type: TypeToken<ChatModelFactory<ChatModelConfig>>;\n readonly name: string;\n readonly presentation?: AgentCanvasPresentation;\n getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;\n}\n\nexport interface LangChainChatModelLike {\n invoke(input: unknown, options?: unknown): Promise<unknown>;\n bindTools?(tools: ReadonlyArray<unknown>): LangChainChatModelLike;\n}\n\nexport interface ChatModelFactory<TConfig extends ChatModelConfig = ChatModelConfig> {\n create(\n args: Readonly<{ config: TConfig; ctx: NodeExecutionContext<any> }>,\n ): Promise<LangChainChatModelLike> | LangChainChatModelLike;\n}\n\nexport type NodeBackedToolInputMapperArgs<\n TNodeConfig extends RunnableNodeConfig<any, any>,\n TToolInput = unknown,\n> = Readonly<{\n input: TToolInput;\n item: Item;\n itemIndex: number;\n items: Items;\n ctx: NodeExecutionContext<any>;\n node: TNodeConfig;\n}>;\n\nexport type NodeBackedToolOutputMapperArgs<\n TNodeConfig extends RunnableNodeConfig<any, any>,\n TToolInput = unknown,\n> = Readonly<{\n input: TToolInput;\n item: Item;\n itemIndex: number;\n items: Items;\n ctx: NodeExecutionContext<any>;\n node: TNodeConfig;\n outputs: NodeOutputs;\n}>;\n\nexport type NodeBackedToolInputMapper<TNodeConfig extends RunnableNodeConfig<any, any>, TToolInput = unknown> = (\n args: NodeBackedToolInputMapperArgs<TNodeConfig, TToolInput>,\n) => Item<RunnableNodeInputJson<TNodeConfig>> | RunnableNodeInputJson<TNodeConfig>;\n\nexport type NodeBackedToolOutputMapper<\n TNodeConfig extends RunnableNodeConfig<any, any>,\n TToolInput = unknown,\n TToolOutput = unknown,\n> = (args: NodeBackedToolOutputMapperArgs<TNodeConfig, TToolInput>) => TToolOutput;\n\nexport type NodeBackedToolConfigOptions<\n TNodeConfig extends RunnableNodeConfig<any, any>,\n TInputSchema extends ZodSchemaAny,\n TOutputSchema extends ZodSchemaAny,\n> = Readonly<{\n description?: string;\n presentation?: AgentCanvasPresentation;\n inputSchema: TInputSchema;\n outputSchema: TOutputSchema;\n mapInput?: NodeBackedToolInputMapper<TNodeConfig, ZodInput<TInputSchema>>;\n mapOutput?: NodeBackedToolOutputMapper<TNodeConfig, ZodInput<TInputSchema>, ZodOutput<TOutputSchema>>;\n}>;\n\nexport interface AgentNodeConfig<TInputJson = unknown, TOutputJson = unknown> extends RunnableNodeConfig<\n TInputJson,\n TOutputJson\n> {\n readonly messages: AgentMessageConfig<TInputJson>;\n readonly chatModel: ChatModelConfig;\n readonly tools?: ReadonlyArray<ToolConfig>;\n readonly guardrails?: AgentGuardrailConfig;\n}\n\nexport type AgentAttachmentRole = \"languageModel\" | \"tool\";\n\nexport { NodeBackedToolConfig } from \"./NodeBackedToolConfig\";\nexport { AgentToolFactory } from \"./AgentToolFactory\";\nexport { AgentMessageConfigNormalizer } from \"./AgentMessageConfigNormalizerFactory\";\nexport { AgentConfigInspector } from \"./AgentConfigInspectorFactory\";\n","import type { NodeId, NodeRef, OutputPortKey, UpstreamRefPlaceholder, WorkflowDefinition } from \"../../types\";\n\nimport { WorkflowBuilder } from \"./WorkflowBuilder\";\nimport type { AnyRunnableNodeConfig, BooleanWhenOverloads, ValidStepSequence } from \"./workflowBuilderTypes\";\n\nexport class WhenBuilder<TCurrentJson> {\n constructor(\n private readonly wf: WorkflowBuilder,\n private readonly from: NodeRef,\n private readonly branchPort: OutputPortKey,\n ) {}\n\n addBranch<TSteps extends ReadonlyArray<AnyRunnableNodeConfig>>(\n steps: TSteps & ValidStepSequence<TCurrentJson, TSteps>,\n ): this {\n const created: NodeRef[] = [];\n\n let prev: NodeRef | null = null;\n for (const cfg of steps) {\n const ref = (this.wf as any).add(cfg) as NodeRef;\n created.push(ref);\n if (!prev) (this.wf as any).connect(this.from, ref, this.branchPort, \"in\");\n else (this.wf as any).connect(prev, ref, \"main\", \"in\");\n prev = ref;\n }\n\n for (const cfg of steps) {\n const maybe = cfg as unknown as { upstreamRefs?: Array<{ nodeId: NodeId } | UpstreamRefPlaceholder> };\n if (!Array.isArray(maybe.upstreamRefs) || maybe.upstreamRefs.length === 0) continue;\n\n maybe.upstreamRefs = maybe.upstreamRefs.map((r) => {\n if (typeof r !== \"string\") return r;\n const idx = parseInt(r.slice(1), 10);\n const nodeId = created[idx]?.id;\n return nodeId ? { nodeId } : { nodeId: r };\n });\n }\n\n return this;\n }\n\n readonly when: BooleanWhenOverloads<TCurrentJson, WhenBuilder<TCurrentJson>> = (\n branch: boolean,\n steps: ReadonlyArray<AnyRunnableNodeConfig> | AnyRunnableNodeConfig,\n ...more: AnyRunnableNodeConfig[]\n ): WhenBuilder<TCurrentJson> => {\n const list = Array.isArray(steps) ? steps : [steps, ...more];\n const port: OutputPortKey = branch ? \"true\" : \"false\";\n const b = new WhenBuilder<TCurrentJson>(this.wf, this.from, port);\n b.addBranch(list);\n return b;\n };\n\n build(): WorkflowDefinition {\n return this.wf.build();\n }\n}\n","import type {\n NodeRef,\n OutputPortKey,\n RunnableNodeConfig,\n RunnableNodeOutputJson,\n WorkflowDefinition,\n} from \"../../types\";\n\nimport { WorkflowBuilder } from \"./WorkflowBuilder\";\nimport { WhenBuilder } from \"./WhenBuilder\";\nimport type {\n AnyRunnableNodeConfig,\n BooleanWhenOverloads,\n BranchOutputGuard,\n BranchStepsArg,\n StepSequenceOutput,\n} from \"./workflowBuilderTypes\";\n\ntype ChainCursorWhenOverloads<TCurrentJson> = BooleanWhenOverloads<TCurrentJson, WhenBuilder<TCurrentJson>> & {\n <\n TTrueSteps extends ReadonlyArray<AnyRunnableNodeConfig> | undefined,\n TFalseSteps extends ReadonlyArray<AnyRunnableNodeConfig> | undefined,\n >(\n branches: Readonly<{\n true?: TTrueSteps extends ReadonlyArray<AnyRunnableNodeConfig> ? BranchStepsArg<TCurrentJson, TTrueSteps> : never;\n false?: TFalseSteps extends ReadonlyArray<AnyRunnableNodeConfig>\n ? BranchStepsArg<TCurrentJson, TFalseSteps>\n : never;\n }> &\n BranchOutputGuard<TCurrentJson, TTrueSteps, TFalseSteps>,\n ): ChainCursor<StepSequenceOutput<TCurrentJson, TTrueSteps>>;\n};\n\nexport class ChainCursor<TCurrentJson> {\n constructor(\n private readonly wf: WorkflowBuilder,\n private readonly cursor: NodeRef,\n private readonly cursorOutput: OutputPortKey,\n ) {}\n\n then<TConfig extends RunnableNodeConfig<TCurrentJson, any>>(\n config: TConfig,\n ): ChainCursor<RunnableNodeOutputJson<TConfig>> {\n const next = (this.wf as any).add(config) as NodeRef;\n (this.wf as any).connect(this.cursor, next, this.cursorOutput);\n return new ChainCursor<RunnableNodeOutputJson<TConfig>>(this.wf, next, \"main\");\n }\n\n readonly when: ChainCursorWhenOverloads<TCurrentJson> = ((\n arg1:\n | boolean\n | Readonly<{ true?: ReadonlyArray<AnyRunnableNodeConfig>; false?: ReadonlyArray<AnyRunnableNodeConfig> }>,\n steps?: ReadonlyArray<AnyRunnableNodeConfig> | AnyRunnableNodeConfig,\n ...more: AnyRunnableNodeConfig[]\n ): WhenBuilder<TCurrentJson> | ChainCursor<TCurrentJson> => {\n if (typeof arg1 === \"boolean\") {\n const list = Array.isArray(steps) ? steps : steps ? [steps, ...more] : more;\n const port: OutputPortKey = arg1 ? \"true\" : \"false\";\n const b = new WhenBuilder<TCurrentJson>(this.wf, this.cursor, port);\n b.addBranch(list);\n return b;\n }\n\n const branches = arg1;\n const makeMerge = (this.wf as any).options?.makeMergeNode as ((name: string) => AnyRunnableNodeConfig) | undefined;\n if (!makeMerge) {\n throw new Error(\n 'WorkflowBuilder is missing options.makeMergeNode (required for when({true,false}). Use createWorkflowBuilder from \"@codemation/core-nodes\".',\n );\n }\n\n const wfAny = this.wf as any;\n\n const buildBranch = (\n port: OutputPortKey,\n branchSteps: ReadonlyArray<AnyRunnableNodeConfig> | undefined,\n ): Readonly<{ end: NodeRef; endOutput: OutputPortKey }> => {\n const list = branchSteps ?? [];\n let prev: NodeRef | null = null;\n for (const cfg of list) {\n const ref = wfAny.add(cfg) as NodeRef;\n if (!prev) wfAny.connect(this.cursor, ref, port, \"in\");\n else wfAny.connect(prev, ref, \"main\", \"in\");\n prev = ref;\n }\n if (!prev) return { end: this.cursor, endOutput: port };\n return { end: prev, endOutput: \"main\" };\n };\n\n const t = buildBranch(\"true\", branches.true);\n const f = buildBranch(\"false\", branches.false);\n\n const merge = wfAny.add(makeMerge(\"Merge (auto)\")) as NodeRef;\n wfAny.connect(t.end, merge, t.endOutput, \"true\");\n wfAny.connect(f.end, merge, f.endOutput, \"false\");\n\n return new ChainCursor<TCurrentJson>(this.wf, merge, \"main\");\n }) as ChainCursorWhenOverloads<TCurrentJson>;\n\n build(): WorkflowDefinition {\n return this.wf.build();\n }\n}\n","import type {\n InputPortKey,\n NodeConfigBase,\n NodeDefinition,\n NodeRef,\n OutputPortKey,\n RunnableNodeOutputJson,\n TriggerNodeOutputJson,\n WorkflowDefinition,\n WorkflowId,\n} from \"../../types\";\n\nimport { ChainCursor } from \"./ChainCursorResolver\";\nimport type { AnyRunnableNodeConfig, AnyTriggerNodeConfig } from \"./workflowBuilderTypes\";\n\nexport class WorkflowBuilder {\n private readonly nodes: NodeDefinition[] = [];\n private readonly edges: WorkflowDefinition[\"edges\"] = [];\n private seq = 0;\n\n constructor(\n private readonly meta: { id: WorkflowId; name: string },\n private readonly options?: Readonly<{\n makeMergeNode?: (name: string) => AnyRunnableNodeConfig;\n }>,\n ) {}\n\n private add(config: NodeConfigBase): NodeRef {\n const tokenName = typeof config.type === \"function\" ? config.type.name : String(config.type);\n const id = config.id ?? `${tokenName}:${++this.seq}`;\n this.nodes.push({ id, kind: config.kind, type: config.type, name: config.name, config });\n return { id, kind: config.kind, name: config.name };\n }\n\n private connect(from: NodeRef, to: NodeRef, fromOutput: OutputPortKey = \"main\", toInput: InputPortKey = \"in\"): void {\n this.edges.push({ from: { nodeId: from.id, output: fromOutput }, to: { nodeId: to.id, input: toInput } });\n }\n\n trigger<TConfig extends AnyTriggerNodeConfig>(config: TConfig): ChainCursor<TriggerNodeOutputJson<TConfig>> {\n const ref = this.add(config);\n return new ChainCursor<TriggerNodeOutputJson<TConfig>>(this, ref, \"main\");\n }\n\n start<TConfig extends AnyRunnableNodeConfig>(config: TConfig): ChainCursor<RunnableNodeOutputJson<TConfig>> {\n const ref = this.add(config);\n return new ChainCursor<RunnableNodeOutputJson<TConfig>>(this, ref, \"main\");\n }\n\n build(): WorkflowDefinition {\n return { ...this.meta, nodes: this.nodes, edges: this.edges };\n }\n}\n\nexport { ChainCursor } from \"./ChainCursorResolver\";\nexport { WhenBuilder } from \"./WhenBuilder\";\n","import { randomUUID } from \"node:crypto\";\n\nimport type { NodeId } from \"../../types\";\n\n/**\n * Unique ids for persisted connection invocation history rows (LLM/tool calls under an owning node).\n */\nexport class ConnectionInvocationIdFactory {\n static create(): string {\n return `cinv_${randomUUID()}`;\n }\n\n /** Deterministic id for tests when a stable sequence is needed. */\n static createForTest(runId: string, connectionNodeId: NodeId, sequence: number): string {\n return `cinv_${runId}_${connectionNodeId}_${sequence}`;\n }\n}\n","import type { InputPortKey, NodeId, OutputPortKey, WorkflowDefinition, WorkflowGraph } from \"../../types\";\n\nexport class ExecutableGraph implements WorkflowGraph {\n private readonly outgoingByNodeAndPort = new Map<\n NodeId,\n Map<OutputPortKey, Array<Readonly<{ nodeId: NodeId; input: InputPortKey }>>>\n >();\n\n constructor(def: WorkflowDefinition) {\n for (const e of def.edges) {\n const byPort =\n this.outgoingByNodeAndPort.get(e.from.nodeId) ??\n new Map<OutputPortKey, Array<Readonly<{ nodeId: NodeId; input: InputPortKey }>>>();\n const next = byPort.get(e.from.output) ?? [];\n next.push({ nodeId: e.to.nodeId, input: e.to.input });\n byPort.set(e.from.output, next);\n this.outgoingByNodeAndPort.set(e.from.nodeId, byPort);\n }\n }\n\n next(nodeId: NodeId, output: OutputPortKey): Array<Readonly<{ nodeId: NodeId; input: InputPortKey }>> {\n return this.outgoingByNodeAndPort.get(nodeId)?.get(output) ?? [];\n }\n}\n","import type { WorkflowDefinition, WorkflowGraph, WorkflowGraphFactory } from \"../../types\";\nimport { ExecutableGraph } from \"./ExecutableGraph\";\n\nexport class DefaultWorkflowGraphFactory implements WorkflowGraphFactory {\n create(def: WorkflowDefinition): WorkflowGraph {\n return new ExecutableGraph(def);\n }\n}\n","import type { RunEventSubscription } from \"./runEvents\";\n\nexport class InMemoryRunEventSubscription implements RunEventSubscription {\n constructor(private readonly onClose: () => void) {}\n\n async close(): Promise<void> {\n this.onClose();\n }\n}\n","import type { WorkflowId } from \"../types\";\n\nimport type { RunEvent, RunEventBus, RunEventSubscription } from \"./runEvents\";\n\nimport { InMemoryRunEventSubscription } from \"./InMemoryRunEventSubscription\";\n\nexport class InMemoryRunEventBus implements RunEventBus {\n private readonly globalListeners = new Set<(event: RunEvent) => void>();\n private readonly listenersByWorkflowId = new Map<WorkflowId, Set<(event: RunEvent) => void>>();\n\n async publish(event: RunEvent): Promise<void> {\n for (const listener of this.globalListeners) listener(event);\n for (const listener of this.listenersByWorkflowId.get(event.workflowId) ?? []) listener(event);\n }\n\n async subscribe(onEvent: (event: RunEvent) => void): Promise<RunEventSubscription> {\n this.globalListeners.add(onEvent);\n return new InMemoryRunEventSubscription(() => {\n this.globalListeners.delete(onEvent);\n });\n }\n\n async subscribeToWorkflow(workflowId: WorkflowId, onEvent: (event: RunEvent) => void): Promise<RunEventSubscription> {\n const existing = this.listenersByWorkflowId.get(workflowId) ?? new Set<(event: RunEvent) => void>();\n existing.add(onEvent);\n this.listenersByWorkflowId.set(workflowId, existing);\n\n return new InMemoryRunEventSubscription(() => {\n const listeners = this.listenersByWorkflowId.get(workflowId);\n if (!listeners) return;\n listeners.delete(onEvent);\n if (listeners.size === 0) this.listenersByWorkflowId.delete(workflowId);\n });\n }\n}\n\nexport { InMemoryRunEventSubscription } from \"./InMemoryRunEventSubscription\";\n","import type {\n PersistedRunState,\n RunId,\n RunPruneCandidate,\n RunSummary,\n WorkflowExecutionListingRepository,\n WorkflowExecutionPruneRepository,\n WorkflowExecutionRepository,\n WorkflowId,\n} from \"../types\";\nimport type { RunEventBus } from \"./runEvents\";\n\nexport class EventPublishingWorkflowExecutionRepository\n implements WorkflowExecutionRepository, WorkflowExecutionListingRepository, WorkflowExecutionPruneRepository\n{\n constructor(\n private readonly inner: WorkflowExecutionRepository,\n private readonly eventBus: RunEventBus,\n private readonly now: () => Date = () => new Date(),\n ) {}\n\n async createRun(args: Parameters<WorkflowExecutionRepository[\"createRun\"]>[0]): Promise<void> {\n await this.inner.createRun(args);\n await this.eventBus.publish({\n kind: \"runCreated\",\n runId: args.runId,\n workflowId: args.workflowId,\n parent: args.parent,\n at: this.now().toISOString(),\n });\n }\n\n async load(runId: RunId): Promise<PersistedRunState | undefined> {\n return await this.inner.load(runId);\n }\n\n async save(state: PersistedRunState): Promise<void> {\n await this.inner.save(state);\n await this.eventBus.publish({\n kind: \"runSaved\",\n runId: state.runId,\n workflowId: state.workflowId,\n parent: state.parent,\n at: this.now().toISOString(),\n state,\n });\n }\n\n async deleteRun(runId: RunId): Promise<void> {\n if (!this.inner.deleteRun) return;\n await this.inner.deleteRun(runId);\n }\n\n async listRuns(args?: Readonly<{ workflowId?: WorkflowId; limit?: number }>): Promise<ReadonlyArray<RunSummary>> {\n const listingRepository = this.inner as unknown as Partial<WorkflowExecutionListingRepository>;\n if (!listingRepository.listRuns) return [];\n return await listingRepository.listRuns(args);\n }\n\n async listRunsOlderThan(\n args: Readonly<{ beforeIso: string; limit?: number }>,\n ): Promise<ReadonlyArray<RunPruneCandidate>> {\n const pruneRepository = this.inner as unknown as Partial<WorkflowExecutionPruneRepository>;\n if (!pruneRepository.listRunsOlderThan) return [];\n return await pruneRepository.listRunsOlderThan(args);\n }\n}\n","import type { Item, Items } from \"../contracts/workflowTypes\";\nimport { injectable } from \"../di\";\n\n/**\n * Normalizes external inputs into the engine's canonical `Items` shape.\n * Used at host and builder boundaries where callers may provide either a raw value,\n * a single item-like object, or an array of item-like values.\n */\n@injectable()\nexport class ItemsInputNormalizer {\n normalize(raw: unknown): Items {\n if (raw === undefined || raw === null) {\n return [];\n }\n if (Array.isArray(raw)) {\n return raw.map((value) => this.normalizeItem(value));\n }\n return [this.normalizeItem(raw)];\n }\n\n private normalizeItem(raw: unknown): Item {\n if (!this.isItem(raw)) {\n return { json: raw };\n }\n return {\n json: raw.json,\n ...(raw.binary === undefined ? {} : { binary: raw.binary }),\n ...(raw.meta === undefined ? {} : { meta: raw.meta }),\n ...(raw.paired === undefined ? {} : { paired: raw.paired }),\n };\n }\n\n private isItem(raw: unknown): raw is Item {\n return typeof raw === \"object\" && raw !== null && Object.prototype.hasOwnProperty.call(raw, \"json\");\n }\n}\n","import type { NoneRetryPolicySpec } from \"./retryPolicySpec.types\";\n\nexport class NoRetryPolicy implements NoneRetryPolicySpec {\n readonly kind = \"none\" as const;\n}\n","import type { FixedRetryPolicySpec } from \"./retryPolicySpec.types\";\n\nexport class RetryPolicy implements FixedRetryPolicySpec {\n readonly kind = \"fixed\" as const;\n\n constructor(\n public readonly maxAttempts: number,\n public readonly delayMs: number,\n ) {\n if (!Number.isFinite(maxAttempts) || maxAttempts < 1 || !Number.isInteger(maxAttempts)) {\n throw new Error(`RetryPolicy.maxAttempts must be a positive integer, got ${maxAttempts}`);\n }\n if (!Number.isFinite(delayMs) || delayMs < 0) {\n throw new Error(`RetryPolicy.delayMs must be a non-negative finite number, got ${delayMs}`);\n }\n }\n\n /** Default for HTTP-style transient failures: 3 tries, 1s between attempts. */\n static readonly defaultForHttp: FixedRetryPolicySpec = { kind: \"fixed\", maxAttempts: 3, delayMs: 1000 };\n\n /** Default for LLM / agent calls: 3 tries, 2s fixed backoff. */\n static readonly defaultForAiAgent: FixedRetryPolicySpec = { kind: \"fixed\", maxAttempts: 3, delayMs: 2000 };\n}\n","import type { ExponentialRetryPolicySpec } from \"./retryPolicySpec.types\";\n\nexport class ExpRetryPolicy implements ExponentialRetryPolicySpec {\n readonly kind = \"exponential\" as const;\n\n constructor(\n public readonly maxAttempts: number,\n public readonly initialDelayMs: number,\n public readonly multiplier: number,\n public readonly maxDelayMs?: number,\n public readonly jitter?: boolean,\n ) {\n if (!Number.isFinite(maxAttempts) || maxAttempts < 1 || !Number.isInteger(maxAttempts)) {\n throw new Error(`ExpRetryPolicy.maxAttempts must be a positive integer, got ${maxAttempts}`);\n }\n if (!Number.isFinite(initialDelayMs) || initialDelayMs < 0) {\n throw new Error(`ExpRetryPolicy.initialDelayMs must be a non-negative finite number, got ${initialDelayMs}`);\n }\n if (!Number.isFinite(multiplier) || multiplier < 1) {\n throw new Error(`ExpRetryPolicy.multiplier must be >= 1, got ${multiplier}`);\n }\n }\n}\n","import type { NodeId, WorkflowId } from \"./workflowTypes\";\n\nexport type CredentialTypeId = string;\nexport type CredentialInstanceId = string;\n\nexport type CredentialMaterialSourceKind = \"db\" | \"env\" | \"code\";\nexport type CredentialSetupStatus = \"draft\" | \"ready\";\nexport type CredentialHealthStatus = \"unknown\" | \"healthy\" | \"failing\";\n\nexport type CredentialFieldSchema = Readonly<{\n key: string;\n label: string;\n type: \"string\" | \"password\" | \"textarea\" | \"json\" | \"boolean\";\n required?: true;\n order?: number;\n placeholder?: string;\n helpText?: string;\n /** When set, host resolves this field from process.env at runtime; env wins over stored values. */\n envVarName?: string;\n /**\n * When set, the dialog shows a copy action for this exact string (e.g. a static OAuth redirect URI\n * pattern or documentation URL). Do not use for secret values.\n */\n copyValue?: string;\n /** Accessible label for the copy control (default: Copy). */\n copyButtonLabel?: string;\n}>;\n\nexport type CredentialRequirement = Readonly<{\n slotKey: string;\n label: string;\n acceptedTypes: ReadonlyArray<CredentialTypeId>;\n optional?: true;\n helpText?: string;\n helpUrl?: string;\n}>;\n\nexport type CredentialBindingKey = Readonly<{\n workflowId: WorkflowId;\n nodeId: NodeId;\n slotKey: string;\n}>;\n\nexport type CredentialBinding = Readonly<{\n key: CredentialBindingKey;\n instanceId: CredentialInstanceId;\n updatedAt: string;\n}>;\n\nexport type CredentialHealth = Readonly<{\n status: CredentialHealthStatus;\n message?: string;\n testedAt?: string;\n expiresAt?: string;\n details?: Readonly<Record<string, unknown>>;\n}>;\n\nexport type OAuth2ProviderFromPublicConfig = Readonly<{\n authorizeUrlFieldKey: string;\n tokenUrlFieldKey: string;\n userInfoUrlFieldKey?: string;\n}>;\n\nexport type CredentialOAuth2AuthDefinition = Readonly<\n | {\n kind: \"oauth2\";\n providerId: string;\n scopes: ReadonlyArray<string>;\n clientIdFieldKey?: string;\n clientSecretFieldKey?: string;\n }\n | {\n kind: \"oauth2\";\n providerFromPublicConfig: OAuth2ProviderFromPublicConfig;\n scopes: ReadonlyArray<string>;\n clientIdFieldKey?: string;\n clientSecretFieldKey?: string;\n }\n>;\n\nexport type CredentialAuthDefinition = CredentialOAuth2AuthDefinition;\n\nexport type CredentialTypeDefinition = Readonly<{\n typeId: CredentialTypeId;\n displayName: string;\n description?: string;\n publicFields?: ReadonlyArray<CredentialFieldSchema>;\n secretFields?: ReadonlyArray<CredentialFieldSchema>;\n supportedSourceKinds?: ReadonlyArray<CredentialMaterialSourceKind>;\n auth?: CredentialAuthDefinition;\n}>;\n\n/**\n * JSON-shaped credential field bag (public config, resolved secret material, etc.).\n */\nexport type CredentialJsonRecord = Readonly<Record<string, unknown>>;\n\n/**\n * Persisted credential instance with typed `publicConfig`.\n * Hosts may specialize `secretRef` with a stricter union while remaining\n * assignable here for session/test callbacks.\n */\nexport type CredentialInstanceRecord<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{\n instanceId: CredentialInstanceId;\n typeId: CredentialTypeId;\n displayName: string;\n sourceKind: CredentialMaterialSourceKind;\n publicConfig: TPublicConfig;\n secretRef: CredentialJsonRecord;\n tags: ReadonlyArray<string>;\n setupStatus: CredentialSetupStatus;\n createdAt: string;\n updatedAt: string;\n}>;\n\n/**\n * Arguments passed to `CredentialType.createSession` and `CredentialType.test`.\n * Declare `TPublicConfig` / `TMaterial` on `CredentialType` so implementations are checked\n * against your credential shapes (similar to `NodeExecutionContext.config` for nodes).\n */\nexport type CredentialSessionFactoryArgs<\n TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord,\n TMaterial extends CredentialJsonRecord = CredentialJsonRecord,\n> = Readonly<{\n instance: CredentialInstanceRecord<TPublicConfig>;\n material: TMaterial;\n publicConfig: TPublicConfig;\n}>;\n\nexport type CredentialSessionFactory<\n TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord,\n TMaterial extends CredentialJsonRecord = CredentialJsonRecord,\n TSession = unknown,\n> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<TSession>;\n\nexport type CredentialHealthTester<\n TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord,\n TMaterial extends CredentialJsonRecord = CredentialJsonRecord,\n> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<CredentialHealth>;\n\n/**\n * Full credential type implementation: `definition` (UI/schema), `createSession`, and `test`.\n * Use this at registration and config boundaries; `CredentialTypeDefinition` is only the schema slice.\n */\nexport type CredentialType<\n TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord,\n TMaterial extends CredentialJsonRecord = CredentialJsonRecord,\n TSession = unknown,\n> = Readonly<{\n definition: CredentialTypeDefinition;\n createSession: CredentialSessionFactory<TPublicConfig, TMaterial, TSession>;\n test: CredentialHealthTester<TPublicConfig, TMaterial>;\n}>;\n\n/**\n * Credential type with unspecified generics — used for `CodemationConfig.credentialTypes`, the host registry,\n * and anywhere a concrete `CredentialType<YourPublic, YourMaterial, YourSession>` is placed in a heterogeneous list.\n * Using `any` here avoids unsafe `as` casts while keeping typed `satisfies CredentialType<…>` definitions.\n */\nexport type AnyCredentialType = CredentialType<any, any, unknown>;\n\nexport interface CredentialSessionService {\n getSession<TSession = unknown>(\n args: Readonly<{\n workflowId: WorkflowId;\n nodeId: NodeId;\n slotKey: string;\n }>,\n ): Promise<TSession>;\n}\n\nexport interface CredentialTypeRegistry {\n listTypes(): ReadonlyArray<CredentialTypeDefinition>;\n getType(typeId: CredentialTypeId): CredentialTypeDefinition | undefined;\n}\n\nexport class CredentialUnboundError extends Error {\n constructor(\n public readonly bindingKey: CredentialBindingKey,\n public readonly acceptedTypes: ReadonlyArray<CredentialTypeId> = [],\n ) {\n super(CredentialUnboundError.createMessage(bindingKey, acceptedTypes));\n this.name = \"CredentialUnboundError\";\n }\n\n private static createMessage(\n bindingKey: CredentialBindingKey,\n acceptedTypes: ReadonlyArray<CredentialTypeId>,\n ): string {\n const acceptedTypesSuffix =\n acceptedTypes.length > 0 ? ` Accepted credential types: ${acceptedTypes.join(\", \")}.` : \"\";\n return `Credential slot \"${bindingKey.slotKey}\" is not bound for workflow ${bindingKey.workflowId} node ${bindingKey.nodeId}.${acceptedTypesSuffix}`;\n }\n}\n","import type { TypeToken } from \"../di\";\nimport type { CredentialRequirement } from \"./credentialTypes\";\nimport type { RetryPolicySpec } from \"./retryPolicySpec.types\";\n\nexport type WorkflowId = string;\nexport type NodeId = string;\nexport type OutputPortKey = string;\nexport type InputPortKey = string;\nexport type PersistedTokenId = string;\n\nexport type NodeKind = \"trigger\" | \"node\";\nexport type JsonPrimitive = string | number | boolean | null;\nexport interface JsonObject {\n readonly [key: string]: JsonValue;\n}\nexport type JsonValue = JsonPrimitive | JsonObject | JsonArray;\nexport type JsonArray = ReadonlyArray<JsonValue>;\n\nexport interface Edge {\n from: { nodeId: NodeId; output: OutputPortKey };\n to: { nodeId: NodeId; input: InputPortKey };\n}\n\nexport type NodeConnectionName = string;\n\n/**\n * Named connection from an executable parent node to child nodes that exist in {@link WorkflowDefinition.nodes}\n * but are not traversed by the main execution graph.\n */\nexport interface WorkflowNodeConnection {\n readonly parentNodeId: NodeId;\n readonly connectionName: NodeConnectionName;\n readonly childNodeIds: ReadonlyArray<NodeId>;\n}\n\nexport interface WorkflowDefinition {\n id: WorkflowId;\n name: string;\n nodes: NodeDefinition[];\n edges: Edge[];\n /**\n * Optional metadata: which nodes are connection-owned children (e.g. AI agent `llm` / `tools` slots).\n * When omitted, all nodes in {@link nodes} are treated as executable for topology.\n */\n readonly connections?: ReadonlyArray<WorkflowNodeConnection>;\n /** Directory + file-stem path under a workflow discovery root (for UI grouping only). */\n discoveryPathSegments?: readonly string[];\n /** Retention for run JSON and binaries (seconds). Host/env may supply defaults when omitted. */\n readonly prunePolicy?: WorkflowPrunePolicySpec;\n /** Whether to keep run data after completion. Host/env may supply defaults when omitted. */\n readonly storagePolicy?: WorkflowStoragePolicySpec;\n /** Invoked after a node fails permanently (retries exhausted) and node error handler did not recover. */\n readonly workflowErrorHandler?: WorkflowErrorHandlerSpec;\n}\n\nexport interface WorkflowGraph {\n next(nodeId: NodeId, output: OutputPortKey): ReadonlyArray<Readonly<{ nodeId: NodeId; input: InputPortKey }>>;\n}\n\nexport interface WorkflowGraphFactory {\n create(def: WorkflowDefinition): WorkflowGraph;\n}\n\nexport interface NodeConfigBase {\n readonly kind: NodeKind;\n readonly type: TypeToken<unknown>;\n readonly name?: string;\n readonly id?: NodeId;\n readonly icon?: string;\n readonly execution?: Readonly<{ hint?: \"local\" | \"worker\"; queue?: string }>;\n /** In-process execute retries (runnable nodes). Triggers typically omit this. */\n readonly retryPolicy?: RetryPolicySpec;\n /** Recover from execute failures; return outputs to continue, or rethrow to fail the node. */\n readonly nodeErrorHandler?: NodeErrorHandlerSpec;\n /**\n * When true, edges carrying zero items on an output port still schedule single-input downstream nodes.\n * Decided from the **source** node that produced the (empty) output. Default (false/undefined): empty\n * main batches skip downstream execution and propagate the empty path.\n */\n readonly continueWhenEmptyOutput?: boolean;\n getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;\n}\n\nexport declare const runnableNodeInputType: unique symbol;\nexport declare const runnableNodeOutputType: unique symbol;\nexport declare const triggerNodeOutputType: unique symbol;\n\nexport interface RunnableNodeConfig<TInputJson = unknown, TOutputJson = unknown> extends NodeConfigBase {\n readonly kind: \"node\";\n readonly [runnableNodeInputType]?: TInputJson;\n readonly [runnableNodeOutputType]?: TOutputJson;\n}\n\nexport declare const triggerNodeSetupStateType: unique symbol;\n\nexport interface TriggerNodeConfig<\n TOutputJson = unknown,\n TSetupState extends JsonValue | undefined = undefined,\n> extends NodeConfigBase {\n readonly kind: \"trigger\";\n readonly [triggerNodeOutputType]?: TOutputJson;\n readonly [triggerNodeSetupStateType]?: TSetupState;\n}\n\nexport type RunnableNodeInputJson<TConfig extends RunnableNodeConfig<any, any>> =\n TConfig extends RunnableNodeConfig<infer TInputJson, any> ? TInputJson : never;\n\nexport type RunnableNodeOutputJson<TConfig extends RunnableNodeConfig<any, any>> =\n TConfig extends RunnableNodeConfig<any, infer TOutputJson> ? TOutputJson : never;\n\nexport type TriggerNodeOutputJson<TConfig extends TriggerNodeConfig<any, any>> =\n TConfig extends TriggerNodeConfig<infer TOutputJson, any> ? TOutputJson : never;\n\nexport type TriggerNodeSetupState<TConfig extends TriggerNodeConfig<any, any>> =\n TConfig extends TriggerNodeConfig<any, infer TSetupState> ? TSetupState : never;\n\nexport interface NodeDefinition {\n id: NodeId;\n kind: NodeKind;\n type: TypeToken<unknown>;\n name?: string;\n config: NodeConfigBase;\n}\n\nexport interface NodeRef {\n id: NodeId;\n kind: NodeKind;\n name?: string;\n}\n\nexport type PairedItemRef = Readonly<{ nodeId: NodeId; output: OutputPortKey; itemIndex: number }>;\n\nexport type BinaryPreviewKind = \"image\" | \"audio\" | \"video\" | \"download\";\n\nexport type BinaryAttachment = Readonly<{\n id: string;\n storageKey: string;\n mimeType: string;\n size: number;\n storageDriver: string;\n previewKind: BinaryPreviewKind;\n createdAt: string;\n runId: RunId;\n workflowId: WorkflowId;\n nodeId: NodeId;\n activationId: NodeActivationId;\n filename?: string;\n sha256?: string;\n}>;\n\nexport type ItemBinary = Readonly<Record<string, BinaryAttachment>>;\n\nexport type Item<TJson = unknown> = Readonly<{\n json: TJson;\n binary?: ItemBinary;\n meta?: Readonly<Record<string, unknown>>;\n paired?: ReadonlyArray<PairedItemRef>;\n}>;\n\nexport type Items<TJson = unknown> = ReadonlyArray<Item<TJson>>;\n\nexport type NodeOutputs = Partial<Record<OutputPortKey, Items>>;\n\nexport type RunId = string;\nexport type NodeActivationId = string;\n\nexport interface ParentExecutionRef {\n runId: RunId;\n workflowId: WorkflowId;\n nodeId: NodeId;\n /** Subworkflow depth of the **spawning** run (0 = root). Passed when starting a child run. */\n subworkflowDepth?: number;\n /** Effective max node activations from the parent run (propagated to child policy merge). */\n engineMaxNodeActivations?: number;\n /** Effective max subworkflow depth from the parent run (propagated to child policy merge). */\n engineMaxSubworkflowDepth?: number;\n}\n\nexport interface RunDataSnapshot {\n getOutputs(nodeId: NodeId): NodeOutputs | undefined;\n getOutputItems(nodeId: NodeId, output?: OutputPortKey): Items;\n getOutputItem(nodeId: NodeId, itemIndex: number, output?: OutputPortKey): Item | undefined;\n}\n\nexport interface MutableRunData extends RunDataSnapshot {\n setOutputs(nodeId: NodeId, outputs: NodeOutputs): void;\n dump(): Record<NodeId, NodeOutputs>;\n}\n\nexport interface RunDataFactory {\n create(initial?: Record<NodeId, NodeOutputs>): MutableRunData;\n}\n\nexport interface RunIdFactory {\n makeRunId(): RunId;\n}\n\nexport interface ActivationIdFactory {\n makeActivationId(): NodeActivationId;\n}\n\nexport type UpstreamRefPlaceholder = `$${number}`;\nexport const branchRef = (index: number) => `$${index}` as UpstreamRefPlaceholder;\n\nexport type ExecutionMode = \"local\" | \"worker\";\n\nexport interface NodeSchedulerDecision {\n mode: ExecutionMode;\n queue?: string;\n}\n\nexport interface NodeOffloadPolicy {\n decide(args: { workflowId: WorkflowId; nodeId: NodeId; config: NodeConfigBase }): NodeSchedulerDecision;\n}\n\n/** Whether to persist run execution data after the workflow finishes. */\nexport type WorkflowStoragePolicyMode = \"ALL\" | \"SUCCESS\" | \"ERROR\" | \"NEVER\";\n\nexport type WorkflowStoragePolicySpec = WorkflowStoragePolicyMode | TypeToken<WorkflowStoragePolicyResolver>;\n\nexport interface WorkflowStoragePolicyResolver {\n shouldPersist(args: WorkflowStoragePolicyDecisionArgs): boolean | Promise<boolean>;\n}\n\nexport interface WorkflowStoragePolicyDecisionArgs {\n readonly runId: RunId;\n readonly workflowId: WorkflowId;\n readonly workflow: WorkflowDefinition;\n readonly finalStatus: \"completed\" | \"failed\";\n readonly startedAt: string;\n readonly finishedAt: string;\n}\n\nexport interface WorkflowPrunePolicySpec {\n readonly runDataRetentionSeconds?: number;\n readonly binaryRetentionSeconds?: number;\n}\n\nexport interface PersistedRunPolicySnapshot {\n readonly retentionSeconds?: number;\n readonly binaryRetentionSeconds?: number;\n readonly storagePolicy: WorkflowStoragePolicyMode;\n}\n\nexport interface WorkflowErrorHandler {\n onError(ctx: WorkflowErrorContext): void | Promise<void>;\n}\n\nexport interface WorkflowErrorContext {\n readonly runId: RunId;\n readonly workflowId: WorkflowId;\n readonly workflow: WorkflowDefinition;\n readonly failedNodeId: NodeId;\n readonly error: Error;\n readonly startedAt: string;\n readonly finishedAt: string;\n}\n\nexport type WorkflowErrorHandlerSpec = TypeToken<WorkflowErrorHandler> | WorkflowErrorHandler;\n\nexport interface NodeErrorHandlerArgs<TConfig extends NodeConfigBase = NodeConfigBase> {\n readonly kind: \"single\" | \"multi\";\n readonly items: Items;\n readonly inputsByPort: Readonly<Record<InputPortKey, Items>> | undefined;\n readonly ctx: import(\"./runtimeTypes\").NodeExecutionContext<TConfig>;\n readonly error: Error;\n}\n\nexport interface NodeErrorHandler {\n handle<TConfig extends NodeConfigBase>(args: NodeErrorHandlerArgs<TConfig>): Promise<NodeOutputs>;\n}\n\nexport type NodeErrorHandlerSpec = TypeToken<NodeErrorHandler> | NodeErrorHandler;\n\n/** Runtime defaults when workflow omits prune/storage fields (typically from host env). */\nexport interface WorkflowPolicyRuntimeDefaults {\n readonly retentionSeconds?: number;\n readonly binaryRetentionSeconds?: number;\n readonly storagePolicy?: WorkflowStoragePolicyMode;\n}\n","import type { WorkflowId } from \"./workflowTypes\";\n\n/**\n * Host-controlled policy: when false, trigger {@link TriggerNode} setup is skipped and webhook routes\n * for that workflow are not registered (see engine trigger runtime + webhook matcher).\n */\nexport interface WorkflowActivationPolicy {\n isActive(workflowId: WorkflowId): boolean;\n}\n\n/** Default for tests and harnesses: every workflow is treated as active (legacy behavior). */\nexport class AllWorkflowsActiveWorkflowActivationPolicy implements WorkflowActivationPolicy {\n isActive(_workflowId: WorkflowId): boolean {\n return true;\n }\n}\n"],"mappings":";;;;;;;;AAKA,IAAa,cAAb,MAA0C;CACxC,MAAY;AACV,yBAAO,IAAI,MAAM;;;;;;ACQrB,IAAa,uBAAb,MAIwB;CACtB,AAAS;CACT,AAAS,WAAW;CACpB,AAAS;CACT,AAAS;CACT,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAMjB,YACE,AAAgBA,MAChB,AAAgBC,QAChB,SACA;EAHgB;EACA;AAGhB,OAAK,OAAOC,OAAK;AACjB,OAAK,cAAc,QAAQ;AAC3B,OAAK,eAAe,QAAQ;AAC5B,OAAK,mBAAmB,QAAQ;AAChC,OAAK,oBAAoB,QAAQ;AACjC,OAAK,gBAAgB,QAAQ;AAC7B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