import "reflect-metadata"; import { ReadableStream } from "node:stream/web"; import { ZodType, z } from "zod"; import { DependencyContainer, DependencyContainer as Container, InjectionToken as TypeToken } from "tsyringe"; //#region ../core/src/contracts/testTriggerTypes.d.ts type TestSuiteRunId = string; //#endregion //#region ../core/src/contracts/baseTypes.d.ts type WorkflowId = string; type NodeId = string; type OutputPortKey = string; type InputPortKey = string; type PersistedTokenId = string; type NodeConnectionName = string; //#endregion //#region ../core/src/contracts/CostTrackingTelemetryContract.d.ts type CostTrackingComponent = "chat" | "ocr" | "rag"; interface CostTrackingUsageRecord { readonly component: CostTrackingComponent; readonly provider: string; readonly operation: string; readonly pricingKey: string; readonly usageUnit: string; readonly quantity: number; readonly modelName?: string; readonly attributes?: TelemetryAttributes; } interface CostTrackingPriceQuote { readonly currency: string; readonly currencyScale: number; readonly estimatedAmountMinor: number; readonly estimateKind: "catalog"; } interface CostTrackingTelemetry { captureUsage(args: CostTrackingUsageRecord): Promise; forScope(scope: TelemetryScope): CostTrackingTelemetry; } //#endregion //#region ../core/src/contracts/telemetryTypes.d.ts type TelemetryAttributePrimitive = string | number | boolean | null; interface TelemetryAttributes { readonly [key: string]: TelemetryAttributePrimitive | undefined; } interface TelemetryMetricRecord { readonly name: string; readonly value: number; readonly unit?: string; readonly attributes?: TelemetryAttributes; } interface TelemetrySpanEventRecord { readonly name: string; readonly occurredAt?: Date; readonly attributes?: TelemetryAttributes; } interface TelemetryArtifactAttachment { readonly kind: string; readonly contentType: string; readonly previewText?: string; readonly previewJson?: JsonValue; readonly payloadText?: string; readonly payloadJson?: JsonValue; readonly bytes?: number; readonly truncated?: boolean; readonly expiresAt?: Date; } interface TelemetryArtifactReference { readonly artifactId: string; readonly traceId?: string; readonly spanId?: string; } interface TelemetrySpanEnd { readonly status?: "ok" | "error"; readonly statusMessage?: string; readonly endedAt?: Date; readonly attributes?: TelemetryAttributes; } interface TelemetryChildSpanStart { readonly name: string; readonly kind?: "internal" | "client"; readonly startedAt?: Date; readonly attributes?: TelemetryAttributes; } interface TelemetryScope { readonly traceId?: string; readonly spanId?: string; readonly costTracking?: CostTrackingTelemetry; addSpanEvent(args: TelemetrySpanEventRecord): Promise | void; recordMetric(args: TelemetryMetricRecord): Promise | void; attachArtifact(args: TelemetryArtifactAttachment): Promise | TelemetryArtifactReference; } interface TelemetrySpanScope extends TelemetryScope { readonly traceId: string; readonly spanId: string; end(args?: TelemetrySpanEnd): Promise | void; asNodeTelemetry(args: Readonly<{ nodeId: NodeId; activationId: NodeActivationId; }>): NodeExecutionTelemetry; } interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope { startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope; } interface ExecutionTelemetry extends TelemetryScope { readonly traceId: string; readonly spanId: string; forNode(args: Readonly<{ nodeId: NodeId; activationId: NodeActivationId; }>): NodeExecutionTelemetry; } //#endregion //#region ../core/src/contracts/itemExpr.d.ts type ItemExprResolvedContext = Readonly<{ runId: RunId; workflowId: WorkflowId; nodeId: NodeId; activationId: NodeActivationId; data: RunDataSnapshot; }>; type ItemExprContext = ItemExprResolvedContext; type ItemExprArgs = Readonly<{ item: Item; itemIndex: number; items: Items; ctx: ItemExprContext; }>; type ItemExprCallback = (args: ItemExprArgs) => T | Promise; type ItemExpr = Readonly<{ readonly __codemationItemExpr: "codemation.itemExpr"; readonly fn: ItemExprCallback; }>; //#endregion //#region ../core/src/contracts/params.d.ts type Expr = ItemExpr; type ParamDeep = Expr | (T extends readonly (infer U)[] ? ReadonlyArray> : never) | (T extends object ? { [K in keyof T]: ParamDeep } : T); //#endregion //#region ../core/src/contracts/retryPolicySpec.types.d.ts type RetryPolicySpec = NoneRetryPolicySpec | FixedRetryPolicySpec | ExponentialRetryPolicySpec; interface NoneRetryPolicySpec { readonly kind: "none"; } interface FixedRetryPolicySpec { readonly kind: "fixed"; readonly maxAttempts: number; readonly delayMs: number; } interface ExponentialRetryPolicySpec { readonly kind: "exponential"; readonly maxAttempts: number; readonly initialDelayMs: number; readonly multiplier: number; readonly maxDelayMs?: number; readonly jitter?: boolean; } //#endregion //#region ../core/src/contracts/executionPersistenceContracts.d.ts type ExecutionInstanceId = string; type BatchId = string; type PersistedExecutionInstanceKind = "workflowNodeActivation" | "connectionInvocation"; type ConnectionInvocationKind = "languageModel" | "tool" | "nestedAgent"; interface WorkflowRunDetailDto { readonly runId: RunId; readonly workflowId: WorkflowId; readonly startedAt: string; readonly finishedAt?: string; readonly status: RunStatus; readonly workflowSnapshot?: PersistedWorkflowSnapshot; readonly mutableState?: PersistedMutableRunState; readonly slotStates: ReadonlyArray; readonly executionInstances: ReadonlyArray; readonly iterations?: ReadonlyArray; } interface RunIterationDto { readonly iterationId: string; readonly agentNodeId: NodeId; readonly activationId: NodeActivationId; readonly itemIndex: number; readonly itemSummary?: string; readonly status: NodeExecutionStatus; readonly startedAt?: string; readonly finishedAt?: string; readonly invocationIds: ReadonlyArray; readonly parentInvocationId?: string; readonly estimatedCostMinorByCurrency?: Readonly>; readonly estimatedCostCurrencyScaleByCurrency?: Readonly>; } interface SlotExecutionStateDto { readonly slotNodeId: NodeId; readonly latestInstanceId?: ExecutionInstanceId; readonly latestTerminalInstanceId?: ExecutionInstanceId; readonly latestRunningInstanceId?: ExecutionInstanceId; readonly status?: NodeExecutionStatus; readonly invocationCount: number; readonly runCount: number; } interface ExecutionInstanceDto { readonly instanceId: ExecutionInstanceId; readonly slotNodeId: NodeId; readonly workflowNodeId: NodeId; readonly parentInstanceId?: ExecutionInstanceId; readonly kind: PersistedExecutionInstanceKind; readonly connectionKind?: ConnectionInvocationKind; readonly runIndex: number; readonly batchId: BatchId; readonly activationId?: NodeActivationId; readonly status: NodeExecutionStatus; readonly queuedAt?: string; readonly startedAt?: string; readonly finishedAt?: string; readonly itemCount: number; readonly inputJson?: JsonValue; readonly outputJson?: JsonValue; readonly error?: Readonly; readonly iterationId?: string; readonly itemIndex?: number; readonly parentInvocationId?: string; readonly childRunId?: string; } //#endregion //#region ../core/src/contracts/webhookTypes.d.ts type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; interface WebhookInvocationMatch { endpointPath: string; workflowId: WorkflowId; nodeId: NodeId; methods: ReadonlyArray; parseJsonBody?: (body: unknown) => unknown; } type WebhookTriggerResolution = { status: "notFound"; } | { status: "methodNotAllowed"; match: WebhookInvocationMatch; } | { status: "ok"; match: WebhookInvocationMatch; }; interface WebhookTriggerMatcher { match(args: { endpointPath: string; method: HttpMethod; }): WebhookInvocationMatch | undefined; lookup(endpointPath: string): WebhookInvocationMatch | undefined; onEngineWorkflowsLoaded?(): void; onEngineStopped?(): void; reloadWebhookRoutes?(): void; } //#endregion //#region ../core/src/contracts/credentialTypes.d.ts type CredentialTypeId = string; type CredentialInstanceId = string; type CredentialMaterialSourceKind = "db" | "env" | "code"; type CredentialSetupStatus = "draft" | "ready"; type CredentialHealthStatus = "unknown" | "healthy" | "failing"; type CredentialFieldSchema = Readonly<{ key: string; label: string; type: "string" | "password" | "textarea" | "json" | "boolean"; required?: true; order?: number; visibility?: "default" | "advanced"; placeholder?: string; helpText?: string; envVarName?: string; copyValue?: string; copyButtonLabel?: string; }>; type CredentialRequirement = Readonly<{ slotKey: string; label: string; acceptedTypes: ReadonlyArray; optional?: true; helpText?: string; helpUrl?: string; }>; type CredentialBindingKey = Readonly<{ workflowId: WorkflowId; nodeId: NodeId; slotKey: string; }>; type CredentialBinding = Readonly<{ key: CredentialBindingKey; instanceId: CredentialInstanceId; updatedAt: string; }>; type CredentialHealth = Readonly<{ status: CredentialHealthStatus; message?: string; testedAt?: string; expiresAt?: string; details?: Readonly>; }>; type OAuth2ProviderFromPublicConfig = Readonly<{ authorizeUrlFieldKey: string; tokenUrlFieldKey: string; userInfoUrlFieldKey?: string; }>; type CredentialOAuth2ScopesFromPublicConfig = Readonly<{ presetFieldKey: string; presetScopes: Readonly>>; customPresetKey?: string; customScopesFieldKey?: string; }>; type CredentialOAuth2AuthDefinition = Readonly<{ kind: "oauth2"; providerId: string; scopes: ReadonlyArray; scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig; clientIdFieldKey?: string; clientSecretFieldKey?: string; } | { kind: "oauth2"; providerFromPublicConfig: OAuth2ProviderFromPublicConfig; scopes: ReadonlyArray; scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig; clientIdFieldKey?: string; clientSecretFieldKey?: string; } | { kind: "oauth2"; providerId: string; authorizeUrl: string; tokenUrl: string; userInfoUrl?: string; scopes: ReadonlyArray; scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig; clientIdFieldKey?: string; clientSecretFieldKey?: string; }>; type CredentialAuthDefinition = CredentialOAuth2AuthDefinition; type CredentialAdvancedSectionPresentation = Readonly<{ title?: string; description?: string; defaultOpen?: boolean; }>; type CredentialTypeDefinition = Readonly<{ typeId: CredentialTypeId; displayName: string; description?: string; publicFields?: ReadonlyArray; secretFields?: ReadonlyArray; advancedSection?: CredentialAdvancedSectionPresentation; supportedSourceKinds?: ReadonlyArray; auth?: CredentialAuthDefinition; }>; type CredentialJsonRecord = Readonly>; type CredentialInstanceRecord = Readonly<{ instanceId: CredentialInstanceId; typeId: CredentialTypeId; displayName: string; sourceKind: CredentialMaterialSourceKind; publicConfig: TPublicConfig; secretRef: CredentialJsonRecord; tags: ReadonlyArray; setupStatus: CredentialSetupStatus; createdAt: string; updatedAt: string; material: Readonly<{ source: "local" | "control-plane"; ref: string; }>; }>; type CredentialSessionFactoryArgs = Readonly<{ instance: CredentialInstanceRecord; material: TMaterial; publicConfig: TPublicConfig; }>; type CredentialSessionFactory = (args: CredentialSessionFactoryArgs) => Promise; type CredentialAccessTokenSessionArgs = Readonly<{ accessToken: string; grantedScopes: ReadonlyArray; publicConfig: TPublicConfig; }>; type CredentialAccessTokenSessionFactory = (args: CredentialAccessTokenSessionArgs) => Promise; type CredentialHealthTester = (args: CredentialSessionFactoryArgs) => Promise; type CredentialType = Readonly<{ definition: CredentialTypeDefinition; createSession: CredentialSessionFactory; createSessionFromAccessToken?: CredentialAccessTokenSessionFactory; test: CredentialHealthTester; }>; type AnyCredentialType = CredentialType; interface CredentialSessionService { getSession(args: Readonly<{ workflowId: WorkflowId; nodeId: NodeId; slotKey: string; }>): Promise; } interface CredentialTypeRegistry { listTypes(): ReadonlyArray; getType(typeId: CredentialTypeId): CredentialTypeDefinition | undefined; } //#endregion //#region ../core/src/contracts/mcpTypes.d.ts type McpServerTransport = "http"; interface McpServerDeclaration { id: string; displayName: string; description: string; transport: McpServerTransport; url: string; acceptedCredentialTypes?: ReadonlyArray; requiredScopes?: string[]; staticHeaders?: Record; toolDescriptionOverrides?: Record; } //#endregion //#region ../core/src/contracts/collectionTypes.d.ts interface CollectionStore = Record> { insert(row: TRow): Promise; get(id: string): Promise<(TRow & { id: string; created_at: Date; updated_at: Date; }) | null>; findOne(filter: Partial): Promise<(TRow & { id: string; created_at: Date; updated_at: Date; }) | null>; list(opts?: { limit?: number; offset?: number; where?: Partial; }): Promise<{ rows: ReadonlyArray; total: number; }>; update(id: string, patch: Partial): Promise; delete(id: string): Promise<{ deleted: boolean; }>; } type CollectionsContext = Readonly>; //#endregion //#region ../core/src/contracts/workflowActivationPolicy.d.ts interface WorkflowActivationPolicy { isActive(workflowId: WorkflowId): boolean; } //#endregion //#region ../core/src/authoring/nodeBaseOptions.types.d.ts interface NodeBaseOptions { readonly id?: string; readonly description?: string; } //#endregion //#region ../core/src/authoring/defineNode.types.d.ts type ResolvableCredentialType = AnyCredentialType | CredentialTypeId; type DefinedNodeCredentialBinding = ResolvableCredentialType | Readonly<{ readonly type: ResolvableCredentialType | ReadonlyArray; readonly label?: string; readonly optional?: true; readonly helpText?: string; readonly helpUrl?: string; }>; type DefinedNodeCredentialBindings = Readonly>; type DefinedNodeConfigInput = ParamDeep; interface DefinedNode { readonly kind: "defined-node"; readonly key: TKey$1; readonly title: string; readonly description?: string; create(config: DefinedNodeConfigInput, name?: string, idOrOptions?: string | NodeBaseOptions): RunnableNodeConfig; register(context: { registerNode(token: TypeToken, implementation?: TypeToken): void; }): void; } //#endregion //#region ../core/src/authoring/defineHumanApprovalNode.types.d.ts interface HumanApprovalDecisionResult { readonly status: "approved" | "rejected" | "timed-out" | "auto-accepted"; readonly actor?: HumanTaskActor; readonly decidedAt?: Date; readonly note?: string; readonly payload?: Record; } type HumanApprovalOutputJson> = TInputJson$1 & { readonly decision: HumanApprovalDecisionResult; }; interface DefinedHumanApprovalNode, TBindings extends DefinedNodeCredentialBindings | undefined = undefined> extends DefinedNode, TBindings> { readonly humanApprovalToolBehavior: { onRejected: "return" | "halt"; }; } //#endregion //#region ../core/src/workflow/dsl/workflowBuilderTypes.d.ts type AnyRunnableNodeConfig = RunnableNodeConfig; type AnyTriggerNodeConfig = TriggerNodeConfig; type ValidStepSequence> = TSteps extends readonly [] ? readonly [] : TSteps extends readonly [infer TFirst, ...infer TRest] ? TFirst extends RunnableNodeConfig ? TRest extends ReadonlyArray ? readonly [TFirst, ...ValidStepSequence] : never : never : TSteps; type StepSequenceOutput | undefined> = TSteps extends ReadonlyArray ? TSteps extends readonly [] ? TCurrentJson : TSteps extends readonly [infer TFirst, ...infer TRest] ? TFirst extends RunnableNodeConfig ? TRest extends ReadonlyArray ? StepSequenceOutput : never : never : TCurrentJson : TCurrentJson; type TypesMatch = [TLeft] extends [TRight] ? ([TRight] extends [TLeft] ? true : false) : false; type BranchOutputGuard | undefined, TFalseSteps extends ReadonlyArray | undefined> = TypesMatch, StepSequenceOutput> extends true ? unknown : never; type BranchStepsArg> = TSteps & ValidStepSequence; type BranchMoreArgs, TRestSteps extends ReadonlyArray> = TRestSteps & ValidStepSequence, TRestSteps>; type BooleanWhenOverloads = { >(branch: boolean, steps: BranchStepsArg): TReturn; , TRestSteps extends ReadonlyArray>(branch: boolean, step: TFirstStep, ...more: BranchMoreArgs): TReturn; }; //#endregion //#region ../core/src/workflow/dsl/WhenBuilder.d.ts type WhenEndpoint = Readonly<{ node: NodeRef; output: OutputPortKey; inputPortHint?: InputPortKey; }>; declare class WhenBuilder { private readonly wf; private readonly from; private readonly branchPort; private readonly priorEndpoints; private armEndpoint; constructor(wf: WorkflowBuilder, from: NodeRef, branchPort: OutputPortKey, priorEndpoints?: ReadonlyArray); addBranch>(steps: TSteps & ValidStepSequence): this; readonly when: BooleanWhenOverloads>; then>(config: TConfig): ChainCursor>; humanApproval, TBindings extends DefinedNodeCredentialBindings | undefined = undefined>(node: DefinedHumanApprovalNode, TBindings>, config: TConfig, metadata?: { name?: string; nodeId?: string; }): ChainCursor>>; build(): WorkflowDefinition; private get accumulatedEndpoints(); private toCursor; } //#endregion //#region ../core/src/workflow/dsl/ChainCursorResolver.d.ts type ChainCursorEndpoint = Readonly<{ node: NodeRef; output: OutputPortKey; inputPortHint?: InputPortKey; }>; type ChainCursorWhenOverloads = BooleanWhenOverloads> & { | undefined, TFalseSteps extends ReadonlyArray | undefined>(branches: Readonly<{ true?: TTrueSteps extends ReadonlyArray ? BranchStepsArg : never; false?: TFalseSteps extends ReadonlyArray ? BranchStepsArg : never; }> & BranchOutputGuard): ChainCursor>; }; declare class ChainCursor { private readonly wf; private readonly endpoints; constructor(wf: WorkflowBuilder, endpoints: ReadonlyArray); then>(config: TConfig): ChainCursor>; thenMerge>(config: TConfig): ChainCursor>; thenIntoInputHints>(config: TConfig): ChainCursor>; readonly when: ChainCursorWhenOverloads; route(branches: Readonly) => ChainCursor | undefined>>): ChainCursor; humanApproval, TBindings extends DefinedNodeCredentialBindings | undefined = undefined>(node: DefinedHumanApprovalNode, TBindings>, config: TConfig, metadata?: { name?: string; nodeId?: string; }): ChainCursor>>; build(): WorkflowDefinition; private resolveSharedInputPortHint; } //#endregion //#region ../core/src/workflow/dsl/WorkflowBuilder.d.ts declare class WorkflowBuilder { private readonly meta; private readonly options?; private readonly nodes; private readonly edges; constructor(meta: { id: WorkflowId; name: string; }, options?: Readonly> | undefined); private add; private connect; trigger(config: TConfig): ChainCursor>; start(config: TConfig): ChainCursor>; build(): WorkflowDefinition; private validateNodeIds; } //#endregion //#region ../core/src/events/runEvents.d.ts type TestCaseRunStatus = "running" | "succeeded" | "failed" | "errored" | "cancelled"; type TestSuiteRunStatus = "succeeded" | "failed" | "partial" | "errored" | "cancelled"; type RunEvent = Readonly<{ kind: "runCreated"; runId: RunId; workflowId: WorkflowId; parent?: ParentExecutionRef; at: string; }> | Readonly<{ kind: "runSaved"; runId: RunId; workflowId: WorkflowId; parent?: ParentExecutionRef; at: string; state: PersistedRunState; }> | Readonly<{ kind: "nodeQueued"; runId: RunId; workflowId: WorkflowId; parent?: ParentExecutionRef; at: string; snapshot: NodeExecutionSnapshot; }> | Readonly<{ kind: "nodeStarted"; runId: RunId; workflowId: WorkflowId; parent?: ParentExecutionRef; at: string; snapshot: NodeExecutionSnapshot; }> | Readonly<{ kind: "nodeCompleted"; runId: RunId; workflowId: WorkflowId; parent?: ParentExecutionRef; at: string; snapshot: NodeExecutionSnapshot; }> | Readonly<{ kind: "nodeFailed"; runId: RunId; workflowId: WorkflowId; parent?: ParentExecutionRef; at: string; snapshot: NodeExecutionSnapshot; }> | Readonly<{ kind: "connectionInvocationStarted"; runId: RunId; workflowId: WorkflowId; parent?: ParentExecutionRef; at: string; record: ConnectionInvocationRecord; }> | Readonly<{ kind: "connectionInvocationCompleted"; runId: RunId; workflowId: WorkflowId; parent?: ParentExecutionRef; at: string; record: ConnectionInvocationRecord; }> | Readonly<{ kind: "connectionInvocationFailed"; runId: RunId; workflowId: WorkflowId; parent?: ParentExecutionRef; at: string; record: ConnectionInvocationRecord; }> | Readonly<{ kind: "testSuiteStarted"; testSuiteRunId: TestSuiteRunId; workflowId: WorkflowId; triggerNodeId: string; triggerNodeName?: string; concurrency: number; at: string; }> | Readonly<{ kind: "testSuiteFinished"; testSuiteRunId: TestSuiteRunId; workflowId: WorkflowId; status: TestSuiteRunStatus; totalCases: number; passedCases: number; failedCases: number; at: string; }> | Readonly<{ kind: "testCaseStarted"; testSuiteRunId: TestSuiteRunId; testCaseIndex: number; runId: RunId; workflowId: WorkflowId; testCaseLabel?: string; at: string; }> | Readonly<{ kind: "testCaseCompleted"; testSuiteRunId: TestSuiteRunId; testCaseIndex: number; runId: RunId; workflowId: WorkflowId; status: TestCaseRunStatus; at: string; }>; interface RunEventSubscription { close(): Promise; } interface RunEventBus { publish(event: RunEvent): Promise; subscribe(onEvent: (event: RunEvent) => void): Promise; subscribeToWorkflow(workflowId: WorkflowId, onEvent: (event: RunEvent) => void): Promise; } //#endregion //#region ../core/src/policies/executionLimits/EngineExecutionLimitsPolicy.d.ts interface EngineExecutionLimitsPolicyConfig { readonly defaultMaxNodeActivations: number; readonly hardMaxNodeActivations: number; readonly defaultMaxSubworkflowDepth: number; readonly hardMaxSubworkflowDepth: number; } //#endregion //#region ../core/src/contracts/runTypes.d.ts interface RunTestContext { readonly testSuiteRunId: string; readonly testCaseIndex: number; readonly testCaseLabel?: string; } interface RunExecutionOptions { localOnly?: boolean; webhook?: boolean; mode?: "manual" | "debug"; sourceWorkflowId?: WorkflowId; sourceRunId?: RunId; derivedFromRunId?: RunId; isMutable?: boolean; subworkflowDepth?: number; maxNodeActivations?: number; maxSubworkflowDepth?: number; testContext?: RunTestContext; } interface EngineRunCounters { completedNodeActivations: number; } type RunStopCondition = Readonly<{ kind: "workflowCompleted"; }> | Readonly<{ kind: "nodeCompleted"; nodeId: NodeId; }>; interface RunStateResetRequest { clearFromNodeId: NodeId; } interface PersistedRunControlState { stopCondition?: RunStopCondition; } interface PersistedWorkflowSnapshotNode { id: NodeId; kind: NodeKind; name?: string; nodeTokenId: PersistedTokenId; configTokenId: PersistedTokenId; tokenName?: string; configTokenName?: string; config: unknown; inspectorSummary?: ReadonlyArray>; } interface PersistedWorkflowSnapshot { id: WorkflowId; name: string; nodes: ReadonlyArray; edges: ReadonlyArray; workflowErrorHandlerConfigured?: boolean; connections?: ReadonlyArray; } type PinnedNodeOutputsByPort = Readonly>; interface PersistedMutableNodeState { pinnedOutputsByPort?: PinnedNodeOutputsByPort; lastDebugInput?: Items; } interface PersistedMutableRunState { nodesById: Readonly>; } type NodeInputsByPort = Readonly>; interface RunQueueEntry { nodeId: NodeId; input: Items; toInput?: InputPortKey; batchId?: string; from?: Readonly<{ nodeId: NodeId; output: OutputPortKey; }>; collect?: Readonly<{ expectedInputs: ReadonlyArray; received: Readonly>; }>; } type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped" | "hitl-approved" | "hitl-rejected" | "hitl-timeout" | "hitl-auto-accepted" | "hitl-cancelled"; interface NodeExecutionError { message: string; name?: string; stack?: string; details?: JsonValue; } interface NodeExecutionSnapshot { runId: RunId; workflowId: WorkflowId; nodeId: NodeId; activationId?: NodeActivationId; parent?: ParentExecutionRef; status: NodeExecutionStatus; usedPinnedOutput?: boolean; queuedAt?: string; startedAt?: string; finishedAt?: string; updatedAt: string; inputsByPort?: NodeInputsByPort; outputs?: NodeOutputs; error?: NodeExecutionError; childRunId?: RunId; } type ConnectionInvocationId = string; interface ConnectionInvocationRecord { readonly invocationId: ConnectionInvocationId; readonly runId: RunId; readonly workflowId: WorkflowId; readonly connectionNodeId: NodeId; readonly parentAgentNodeId: NodeId; readonly parentAgentActivationId: NodeActivationId; readonly status: NodeExecutionStatus; readonly managedInput?: JsonValue; readonly managedOutput?: JsonValue; readonly statusLabel?: string; readonly subjectName?: string; readonly error?: NodeExecutionError; readonly queuedAt?: string; readonly startedAt?: string; readonly finishedAt?: string; readonly updatedAt: string; readonly iterationId?: NodeIterationId; readonly itemIndex?: number; readonly parentInvocationId?: ConnectionInvocationId; } type ConnectionInvocationAppendArgs = Readonly<{ invocationId: ConnectionInvocationId; connectionNodeId: NodeId; parentAgentNodeId: NodeId; parentAgentActivationId: NodeActivationId; status: NodeExecutionStatus; managedInput?: JsonValue; managedOutput?: JsonValue; statusLabel?: string; subjectName?: string; error?: NodeExecutionError; queuedAt?: string; startedAt?: string; finishedAt?: string; iterationId?: NodeIterationId; itemIndex?: number; parentInvocationId?: ConnectionInvocationId; }>; interface RunCurrentState { outputsByNode: Record; nodeSnapshotsByNodeId: Record; connectionInvocations?: ReadonlyArray; mutableState?: PersistedMutableRunState; } interface CurrentStateExecutionRequest { workflow: WorkflowDefinition; items?: Items; parent?: ParentExecutionRef; executionOptions?: RunExecutionOptions; workflowSnapshot?: PersistedWorkflowSnapshot; mutableState?: PersistedMutableRunState; currentState?: RunCurrentState; stopCondition?: RunStopCondition; reset?: RunStateResetRequest; } type RunStatus = "running" | "pending" | "completed" | "failed" | "suspended" | "halted"; type RunHaltReason = "hitl-rejected" | "hitl-timeout" | "hitl-cancelled"; interface RunSummary { runId: RunId; workflowId: WorkflowId; startedAt: string; status: RunStatus; testCaseStatus?: TestCaseRunStatus; finishedAt?: string; parent?: ParentExecutionRef; executionOptions?: RunExecutionOptions; } interface PendingNodeExecution { runId: RunId; activationId: NodeActivationId; workflowId: WorkflowId; nodeId: NodeId; itemsIn: number; inputsByPort: NodeInputsByPort; receiptId: string; queue?: string; batchId?: string; enqueuedAt: string; } interface PersistedRunSchedulingState { pending?: PendingNodeExecution; queue: RunQueueEntry[]; } interface PersistedSuspensionEntry { readonly taskId: string; readonly nodeId: NodeId; readonly activationId: NodeActivationId; readonly itemIndex: number; readonly decisionSchemaHash: string; readonly deliveryRef: JsonValue; readonly timeoutAt: string; readonly onTimeout: "halt" | "auto-accept"; } interface PendingResumeEntry { readonly activationId: NodeActivationId; readonly nodeId: NodeId; readonly resumeContext: unknown; } interface PersistedRunState { runId: RunId; workflowId: WorkflowId; startedAt: string; finishedAt?: string; revision?: number; parent?: ParentExecutionRef; executionOptions?: RunExecutionOptions; control?: PersistedRunControlState; workflowSnapshot?: PersistedWorkflowSnapshot; mutableState?: PersistedMutableRunState; policySnapshot?: PersistedRunPolicySnapshot; engineCounters?: EngineRunCounters; status: RunStatus; reason?: RunHaltReason; pending?: PendingNodeExecution; queue: RunQueueEntry[]; outputsByNode: Record; nodeSnapshotsByNodeId: Record; connectionInvocations?: ReadonlyArray; suspension?: ReadonlyArray; pendingResume?: PendingResumeEntry; } interface WorkflowExecutionRepository { createRun(args: { runId: RunId; workflowId: WorkflowId; startedAt: string; parent?: ParentExecutionRef; executionOptions?: RunExecutionOptions; control?: PersistedRunControlState; workflowSnapshot?: PersistedWorkflowSnapshot; mutableState?: PersistedMutableRunState; policySnapshot?: PersistedRunPolicySnapshot; engineCounters?: EngineRunCounters; }): Promise; load(runId: RunId): Promise; loadSchedulingState(runId: RunId): Promise; save(state: PersistedRunState): Promise; deleteRun?(runId: RunId): Promise; } interface RunPruneCandidate { readonly runId: RunId; readonly workflowId: WorkflowId; readonly startedAt: string; readonly finishedAt: string; } type RunResult = { runId: RunId; workflowId: WorkflowId; startedAt: string; status: "completed"; outputs: Items; } | { runId: RunId; workflowId: WorkflowId; startedAt: string; status: "pending"; pending: PendingNodeExecution; } | { runId: RunId; workflowId: WorkflowId; startedAt: string; status: "failed"; error: { message: string; }; } | { runId: RunId; workflowId: WorkflowId; startedAt: string; status: "halted"; reason: RunHaltReason; }; type WebhookRunResult = Readonly<{ runId: RunId; workflowId: WorkflowId; startedAt: string; runStatus: "pending" | "completed"; response: Items; }>; interface PersistedWorkflowTokenRegistryLike { register(type: TypeToken, packageId: string, persistedNameOverride?: string): string; getTokenId(type: TypeToken): string | undefined; resolve(tokenId: string): TypeToken | undefined; registerFromWorkflows?(workflows: ReadonlyArray): void; } //#endregion //#region ../core/src/contracts/workflowTypes.d.ts type NodeIdRef = NodeId & Readonly<{ __codemationNodeJson?: TJson; }>; type NodeKind = "trigger" | "node"; type JsonPrimitive = string | number | boolean | null; interface JsonObject { readonly [key: string]: JsonValue; } type JsonValue = JsonPrimitive | JsonObject | JsonArray; type JsonArray = ReadonlyArray; interface Edge { from: { nodeId: NodeId; output: OutputPortKey; }; to: { nodeId: NodeId; input: InputPortKey; }; } interface WorkflowNodeConnection { readonly parentNodeId: NodeId; readonly connectionName: NodeConnectionName; readonly childNodeIds: ReadonlyArray; } interface WorkflowDefinition { id: WorkflowId; name: string; nodes: NodeDefinition[]; edges: Edge[]; readonly connections?: ReadonlyArray; discoveryPathSegments?: readonly string[]; readonly prunePolicy?: WorkflowPrunePolicySpec; readonly storagePolicy?: WorkflowStoragePolicySpec; readonly workflowErrorHandler?: WorkflowErrorHandlerSpec; } interface NodeConfigBase { readonly kind: NodeKind; readonly type: TypeToken; readonly name?: string; readonly id?: NodeId; readonly icon?: string; readonly description?: string; readonly execution?: Readonly<{ hint?: "local" | "worker"; queue?: string; }>; readonly retryPolicy?: RetryPolicySpec; readonly nodeErrorHandler?: NodeErrorHandlerSpec; readonly continueWhenEmptyOutput?: boolean; readonly declaredOutputPorts?: ReadonlyArray; readonly declaredInputPorts?: ReadonlyArray; getCredentialRequirements?(): ReadonlyArray; readonly emitsAssertions?: true; inspectorSummary?(): ReadonlyArray | undefined; } interface NodeInspectorSummaryRow { readonly label: string; readonly value: string; } declare const runnableNodeInputType: unique symbol; declare const runnableNodeOutputType: unique symbol; declare const triggerNodeOutputType: unique symbol; interface RunnableNodeConfig extends NodeConfigBase { readonly kind: "node"; readonly [runnableNodeInputType]?: TInputJson$1; readonly [runnableNodeOutputType]?: TOutputJson$1; readonly inputSchema?: ZodType; readonly emptyBatchExecution?: "skip" | "runOnce"; } declare const triggerNodeSetupStateType: unique symbol; interface TriggerNodeConfig extends NodeConfigBase { readonly kind: "trigger"; readonly [triggerNodeOutputType]?: TOutputJson$1; readonly [triggerNodeSetupStateType]?: TSetupState$1; readonly triggerKind?: "live" | "test"; } type RunnableNodeOutputJson> = TConfig extends RunnableNodeConfig ? TOutputJson : never; type TriggerNodeOutputJson> = TConfig extends TriggerNodeConfig ? TOutputJson : never; interface NodeDefinition { id: NodeId; kind: NodeKind; type: TypeToken; name?: string; config: NodeConfigBase; } interface NodeRef { id: NodeId; kind: NodeKind; name?: string; } type PairedItemRef = Readonly<{ nodeId: NodeId; output: OutputPortKey; itemIndex: number; }>; type BinaryPreviewKind = "image" | "audio" | "video" | "download"; type BinaryAttachment = Readonly<{ id: string; storageKey: string; mimeType: string; size: number; storageDriver: string; previewKind: BinaryPreviewKind; createdAt: string; runId: RunId; workflowId: WorkflowId; nodeId: NodeId; activationId: NodeActivationId; filename?: string; sha256?: string; }>; type ItemBinary = Readonly>; type Item = Readonly<{ json: TJson; binary?: ItemBinary; meta?: Readonly>; paired?: ReadonlyArray; }>; type Items = ReadonlyArray>; type NodeOutputs = Partial>; type RunId = string; type NodeActivationId = string; type NodeIterationId = string; interface ParentExecutionRef { runId: RunId; workflowId: WorkflowId; nodeId: NodeId; subworkflowDepth?: number; engineMaxNodeActivations?: number; engineMaxSubworkflowDepth?: number; testContext?: RunTestContext; } interface RunDataSnapshot { getOutputs(nodeId: NodeId): NodeOutputs | undefined; getOutputItems(nodeId: NodeId | NodeIdRef, output?: OutputPortKey): Items; getOutputItem(nodeId: NodeId | NodeIdRef, itemIndex: number, output?: OutputPortKey): Item | undefined; } interface RunIdFactory { makeRunId(): RunId; } interface ActivationIdFactory { makeActivationId(): NodeActivationId; } type WorkflowStoragePolicyMode = "ALL" | "SUCCESS" | "ERROR" | "NEVER"; type WorkflowStoragePolicySpec = WorkflowStoragePolicyMode | TypeToken; interface WorkflowStoragePolicyResolver { shouldPersist(args: WorkflowStoragePolicyDecisionArgs): boolean | Promise; } interface WorkflowStoragePolicyDecisionArgs { readonly runId: RunId; readonly workflowId: WorkflowId; readonly workflow: WorkflowDefinition; readonly finalStatus: "completed" | "failed"; readonly startedAt: string; readonly finishedAt: string; } interface WorkflowPrunePolicySpec { readonly runDataRetentionSeconds?: number; readonly binaryRetentionSeconds?: number; readonly telemetrySpanRetentionSeconds?: number; readonly telemetryArtifactRetentionSeconds?: number; readonly telemetryMetricRetentionSeconds?: number; } interface PersistedRunPolicySnapshot { readonly retentionSeconds?: number; readonly binaryRetentionSeconds?: number; readonly telemetrySpanRetentionSeconds?: number; readonly telemetryArtifactRetentionSeconds?: number; readonly telemetryMetricRetentionSeconds?: number; readonly storagePolicy: WorkflowStoragePolicyMode; } interface WorkflowErrorHandler { onError(ctx: WorkflowErrorContext): void | Promise; } interface WorkflowErrorContext { readonly runId: RunId; readonly workflowId: WorkflowId; readonly workflow: WorkflowDefinition; readonly failedNodeId: NodeId; readonly error: Error; readonly startedAt: string; readonly finishedAt: string; } type WorkflowErrorHandlerSpec = TypeToken | WorkflowErrorHandler; interface NodeErrorHandlerArgs { readonly kind: "single" | "multi"; readonly items: Items; readonly inputsByPort: Readonly> | undefined; readonly ctx: NodeExecutionContext; readonly error: Error; } interface NodeErrorHandler { handle(args: NodeErrorHandlerArgs): Promise; } type NodeErrorHandlerSpec = TypeToken | NodeErrorHandler; //#endregion //#region ../core/src/contracts/runtimeTypes.d.ts type HumanTaskId = string; interface HumanTaskHandle { readonly taskId: HumanTaskId; readonly runId: string; readonly nodeId: string; readonly expiresAt: Date; readonly resumeUrl: string; readonly metadata?: Readonly>; } interface HumanTaskActor { readonly actorId: string; readonly displayName?: string; } interface ResumeContext { readonly decision: Readonly<{ kind: "decided"; value: unknown; actor: HumanTaskActor; decidedAt: Date; }> | Readonly<{ kind: "timed_out"; at: Date; }> | Readonly<{ kind: "auto_accepted"; at: Date; }>; readonly delivery: JsonValue; readonly task: HumanTaskHandle; } interface WorkflowRepository { list(): ReadonlyArray; get(workflowId: WorkflowId): WorkflowDefinition | undefined; } interface LiveWorkflowRepository extends WorkflowRepository { setWorkflows(workflows: ReadonlyArray): void; } interface NodeExecutionStatePublisher { markQueued(args: { nodeId: NodeId; activationId?: NodeActivationId; inputsByPort?: NodeInputsByPort; }): Promise; markRunning(args: { nodeId: NodeId; activationId?: NodeActivationId; inputsByPort?: NodeInputsByPort; }): Promise; markCompleted(args: { nodeId: NodeId; activationId?: NodeActivationId; inputsByPort?: NodeInputsByPort; outputs?: NodeOutputs; }): Promise; markFailed(args: { nodeId: NodeId; activationId?: NodeActivationId; inputsByPort?: NodeInputsByPort; error: Error; }): Promise; appendConnectionInvocation(args: ConnectionInvocationAppendArgs): Promise; setChildRunId?(args: { nodeId: NodeId; childRunId: RunId; }): Promise; } type BinaryBody = ReadableStream | AsyncIterable | Uint8Array | ArrayBuffer; interface BinaryStorageWriteRequest { storageKey: string; body: BinaryBody; } interface BinaryStorageWriteResult { storageKey: string; size: number; sha256?: string; } interface BinaryStorageReadResult { body: ReadableStream; size?: number; } interface BinaryStorageStatResult { exists: boolean; size?: number; } interface BinaryStorage { readonly driverName: string; write(args: BinaryStorageWriteRequest): Promise; openReadStream(storageKey: string): Promise; stat(storageKey: string): Promise; delete(storageKey: string): Promise; deleteMany(storageKeys: ReadonlyArray): Promise; listByPrefix(prefix: string): Promise>; } interface BinaryAttachmentCreateRequest { name: string; body: BinaryBody; mimeType: string; filename?: string; previewKind?: BinaryAttachment["previewKind"]; } interface NodeBinaryAttachmentService extends ExecutionBinaryService { attach(args: BinaryAttachmentCreateRequest): Promise; withAttachment(item: Item, name: string, attachment: BinaryAttachment): Item; } interface ExecutionBinaryService { forNode(args: { nodeId: NodeId; activationId: NodeActivationId; }): NodeBinaryAttachmentService; openReadStream(attachment: BinaryAttachment): Promise; getBytes(attachment: BinaryAttachment, maxBytes?: number): Promise; getText(attachment: BinaryAttachment, maxBytes?: number): Promise; getJson(attachment: BinaryAttachment, maxBytes?: number): Promise; } interface ExecutionContext { runId: RunId; workflowId: WorkflowId; parent?: ParentExecutionRef; subworkflowDepth: number; engineMaxNodeActivations: number; engineMaxSubworkflowDepth: number; now: () => Date; data: RunDataSnapshot; nodeState?: NodeExecutionStatePublisher; telemetry: ExecutionTelemetry; binary: ExecutionBinaryService; getCredential(slotKey: string): Promise; iterationId?: NodeIterationId; itemIndex?: number; parentInvocationId?: ConnectionInvocationId; testContext?: RunTestContext; readonly collections?: CollectionsContext; resolve(token: TypeToken): T; } interface NodeExecutionContext extends ExecutionContext { nodeId: NodeId; activationId: NodeActivationId; config: TConfig; telemetry: NodeExecutionTelemetry; binary: NodeBinaryAttachmentService; resumeContext?: ResumeContext; } interface NodeExecutionRequest { runId: RunId; activationId: NodeActivationId; workflowId: WorkflowId; nodeId: NodeId; input: Items; parent?: ParentExecutionRef; queue?: string; executionOptions?: RunExecutionOptions; } interface NodeExecutionScheduler { enqueue(request: NodeExecutionRequest): Promise<{ receiptId: string; }>; cancel?(receiptId: string): Promise; } interface NodeExecutionRequestHandler { handleNodeExecutionRequest(request: NodeExecutionRequest): Promise; } interface NodeActivationContinuation { markNodeRunning(args: { runId: RunId; activationId: NodeActivationId; nodeId: NodeId; inputsByPort: NodeInputsByPort; }): Promise; resumeFromNodeResult(args: { runId: RunId; activationId: NodeActivationId; nodeId: NodeId; outputs: NodeOutputs; }): Promise; resumeFromNodeError(args: { runId: RunId; activationId: NodeActivationId; nodeId: NodeId; error: Error; }): Promise; } interface WorkflowSnapshotResolver { resolve(args: { workflowId: WorkflowId; workflowSnapshot?: PersistedWorkflowSnapshot; }): WorkflowDefinition | undefined; } //#endregion //#region ../core/src/ai/AiHost.d.ts interface AgentCanvasPresentation { readonly label?: string; readonly icon?: TIcon; } interface ToolConfig { readonly type: TypeToken; readonly name: string; readonly description?: string; readonly presentation?: AgentCanvasPresentation; getCredentialRequirements?(): ReadonlyArray; } type AgentMessageRole = "system" | "user" | "assistant"; type AgentMessageBuildArgs = Readonly<{ item: Item; itemIndex: number; items: Items; ctx: NodeExecutionContext; }>; interface AgentMessageDto { readonly role: AgentMessageRole; readonly content: string; } type AgentMessageTemplateContent = string | ((args: AgentMessageBuildArgs) => string); interface AgentMessageTemplate { readonly role: AgentMessageRole; readonly content: AgentMessageTemplateContent; } type AgentMessageLine = AgentMessageDto | AgentMessageTemplate; type AgentMessageConfig = Expr>, TInputJson$1> | ReadonlyArray> | { readonly prompt?: ReadonlyArray>; readonly buildMessages?: (args: AgentMessageBuildArgs) => ReadonlyArray; }; type AgentTurnLimitBehavior = "error" | "respondWithLastMessage"; interface AgentModelInvocationOptions { readonly maxTokens?: number; readonly providerOptions?: Readonly>; } interface AgentGuardrailConfig { readonly maxTurns?: number; readonly onTurnLimitReached?: AgentTurnLimitBehavior; readonly modelInvocationOptions?: AgentModelInvocationOptions; } interface ChatModelConfig { readonly type: TypeToken>; readonly name: string; readonly provider?: string; readonly modelName?: string; readonly presentation?: AgentCanvasPresentation; getCredentialRequirements?(): ReadonlyArray; } interface ChatLanguageModel { readonly languageModel: unknown; readonly modelName: string; readonly provider?: string; readonly defaultCallOptions?: ChatLanguageModelCallOptions; } interface ChatLanguageModelCallOptions { readonly maxOutputTokens?: number; readonly temperature?: number; readonly providerOptions?: Readonly>>>; } interface ChatModelFactory { create(args: Readonly<{ config: TConfig; ctx: NodeExecutionContext; }>): Promise | ChatLanguageModel; } //#endregion export { RunEventBus as $, RunId as A, WorkflowRunDetailDto as At, RunExecutionOptions as B, JsonValue as C, CredentialTypeDefinition as Ct, NodeOutputs as D, WebhookInvocationMatch as Dt, NodeInspectorSummaryRow as E, HttpMethod as Et, CurrentStateExecutionRequest as F, NodeId as Ft, RunSummary as G, RunResult as H, NodeInputsByPort as I, WorkflowId as It, Container as J, WebhookRunResult as K, PersistedRunState as L, RunnableNodeConfig as M, TelemetryAttributes as Mt, RunnableNodeOutputJson as N, TelemetryMetricRecord as Nt, ParentExecutionRef as O, WebhookTriggerMatcher as Ot, WorkflowDefinition as P, TelemetrySpanEventRecord as Pt, RunEvent as Q, PersistedWorkflowTokenRegistryLike as R, Items as S, CredentialType as St, NodeDefinition as T, CredentialTypeRegistry as Tt, RunStatus as U, RunPruneCandidate as V, RunStopCondition as W, TypeToken as X, DependencyContainer as Y, EngineExecutionLimitsPolicyConfig as Z, WorkflowRepository as _, CredentialOAuth2AuthDefinition as _t, BinaryBody as a, DefinedNodeConfigInput as at, BinaryAttachment as b, CredentialSessionService as bt, BinaryStorageStatResult as c, AnyCredentialType as ct, NodeActivationContinuation as d, CredentialFieldSchema as dt, TestCaseRunStatus as et, NodeExecutionContext as f, CredentialHealth as ft, ResumeContext as g, CredentialMaterialSourceKind as gt, NodeExecutionScheduler as h, CredentialJsonRecord as ht, ToolConfig as i, DefinedNode as it, RunIdFactory as j, TelemetryArtifactAttachment as jt, PersistedRunPolicySnapshot as k, WebhookTriggerResolution as kt, BinaryStorageWriteResult as l, CredentialBinding as lt, NodeExecutionRequestHandler as m, CredentialInstanceRecord as mt, AgentMessageConfig as n, ChainCursor as nt, BinaryStorage as o, WorkflowActivationPolicy as ot, NodeExecutionRequest as p, CredentialInstanceId as pt, WorkflowExecutionRepository as q, ChatModelConfig as r, AnyRunnableNodeConfig as rt, BinaryStorageReadResult as s, McpServerDeclaration as st, AgentGuardrailConfig as t, TestSuiteRunStatus as tt, LiveWorkflowRepository as u, CredentialBindingKey as ut, WorkflowSnapshotResolver as v, CredentialRequirement as vt, NodeActivationId as w, CredentialTypeId as wt, Item as x, CredentialSetupStatus as xt, ActivationIdFactory as y, CredentialSessionFactoryArgs as yt, RunCurrentState as z }; //# sourceMappingURL=ItemsInputNormalizer-C2gLv7d9.d.ts.map