@codemation/core 0.10.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +195 -0
  2. package/dist/{EngineRuntimeRegistration.types-D1fyApMI.d.ts → EngineRuntimeRegistration.types-BZ_1XWAJ.d.ts} +2 -2
  3. package/dist/{EngineRuntimeRegistration.types-pB3FnzqR.d.cts → EngineRuntimeRegistration.types-MPYWsEM0.d.cts} +7 -2
  4. package/dist/{InMemoryRunDataFactory-Xw7v4-sj.d.cts → InMemoryRunDataFactory-hmkh0lzR.d.cts} +8 -3
  5. package/dist/{RunIntentService-BE9CAkbf.d.ts → RunIntentService-BrEq6Jm6.d.ts} +1802 -1605
  6. package/dist/{RunIntentService-siBSjaaY.d.cts → RunIntentService-MUHJ1bhO.d.cts} +1722 -1598
  7. package/dist/bootstrap/index.cjs +2 -2
  8. package/dist/bootstrap/index.d.cts +6 -3
  9. package/dist/bootstrap/index.d.ts +4 -3
  10. package/dist/bootstrap/index.js +2 -2
  11. package/dist/{bootstrap-D3r505ko.js → bootstrap-Dgzsjoj7.js} +7 -2
  12. package/dist/bootstrap-Dgzsjoj7.js.map +1 -0
  13. package/dist/{bootstrap-Cm5ruQxx.cjs → bootstrap-dVmpU1ju.cjs} +7 -2
  14. package/dist/bootstrap-dVmpU1ju.cjs.map +1 -0
  15. package/dist/{index-DeLl1Tne.d.ts → index-Bes88mxT.d.ts} +113 -6
  16. package/dist/index.cjs +71 -3
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +173 -6
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +69 -4
  21. package/dist/index.js.map +1 -1
  22. package/dist/{runtime-BGNbRnqs.js → runtime-Duf3ClPw.js} +202 -53
  23. package/dist/runtime-Duf3ClPw.js.map +1 -0
  24. package/dist/{runtime-DKXJwTNv.cjs → runtime-vH0EeZzH.cjs} +208 -53
  25. package/dist/runtime-vH0EeZzH.cjs.map +1 -0
  26. package/dist/testing.cjs +6 -2
  27. package/dist/testing.cjs.map +1 -1
  28. package/dist/testing.d.cts +3 -3
  29. package/dist/testing.d.ts +2 -2
  30. package/dist/testing.js +6 -2
  31. package/dist/testing.js.map +1 -1
  32. package/package.json +4 -13
  33. package/src/ai/AgentConnectionNodeCollector.ts +47 -5
  34. package/src/authoring/defineNode.types.ts +21 -1
  35. package/src/authoring/definePollingTrigger.types.ts +20 -0
  36. package/src/binaries/UnavailableBinaryStorage.ts +6 -0
  37. package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +9 -0
  38. package/src/browser.ts +1 -0
  39. package/src/contracts/AgentBindError.ts +11 -0
  40. package/src/contracts/CodemationTelemetryAttributeNames.ts +4 -0
  41. package/src/contracts/NoOpAgentMcpIntegration.ts +13 -0
  42. package/src/contracts/agentMcpTypes.ts +64 -0
  43. package/src/contracts/executionPersistenceContracts.ts +5 -0
  44. package/src/contracts/index.ts +4 -0
  45. package/src/contracts/mcpTypes.ts +29 -0
  46. package/src/contracts/runTypes.ts +13 -0
  47. package/src/contracts/runtimeTypes.ts +10 -0
  48. package/src/contracts/workflowTypes.ts +21 -0
  49. package/src/contracts.ts +3 -0
  50. package/src/credentials/OAuthFlowExecutor.types.ts +45 -0
  51. package/src/di/CoreTokens.ts +7 -0
  52. package/src/execution/InProcessRetryRunner.ts +31 -5
  53. package/src/execution/NodeExecutionSnapshotFactory.ts +3 -0
  54. package/src/execution/NodeExecutor.ts +27 -7
  55. package/src/execution/NodeRunStateWriter.ts +14 -0
  56. package/src/index.ts +10 -0
  57. package/src/orchestration/RunContinuationService.ts +6 -2
  58. package/src/runStorage/InMemoryBinaryStorageRegistry.ts +10 -0
  59. package/src/scheduler/InlineDrivingScheduler.ts +26 -22
  60. package/src/testing/SubWorkflowRunnerTestNode.ts +1 -0
  61. package/src/types/index.ts +1 -0
  62. package/src/validation/WorkflowEdgePortError.types.ts +16 -0
  63. package/src/validation/WorkflowEdgePortValidator.ts +52 -0
  64. package/src/workflow/definition/ConnectionInvocationIdFactory.ts +4 -3
  65. package/src/workflow/definition/ConnectionNodeIdFactory.ts +25 -0
  66. package/src/workflow/definition/NodeIterationIdFactory.ts +5 -3
  67. package/src/workflowSnapshots/WorkflowSnapshotCodec.ts +42 -10
  68. package/dist/bootstrap-Cm5ruQxx.cjs.map +0 -1
  69. package/dist/bootstrap-D3r505ko.js.map +0 -1
  70. package/dist/runtime-BGNbRnqs.js.map +0 -1
  71. package/dist/runtime-DKXJwTNv.cjs.map +0 -1
@@ -16,1811 +16,1956 @@ type InputPortKey = string;
16
16
  type PersistedTokenId = string;
17
17
  type NodeConnectionName = string;
18
18
  //#endregion
19
- //#region src/contracts/testTriggerTypes.d.ts
19
+ //#region src/triggers/polling/PollingTriggerDedupWindow.d.ts
20
20
  /**
21
- * Identifier minted by the host (or in-memory test runner) for one execution of a test suite.
22
- * One TestSuiteRun produces N child workflow runs, one per item yielded by `generateItems`.
21
+ * Merges processed-ID windows for polling triggers, capping the total to avoid unbounded growth.
22
+ * Plugin code receives an instance of this class via {@link PollingTriggerHandle.dedup}.
23
23
  */
24
- type TestSuiteRunId = string;
24
+ declare class PollingTriggerDedupWindow {
25
+ static readonly defaultCapN = 2000;
26
+ merge(previous: ReadonlyArray<string>, incoming: ReadonlyArray<string>, capN?: number): ReadonlyArray<string>;
27
+ }
28
+ //#endregion
29
+ //#region src/triggers/polling/PollingTriggerLogger.d.ts
25
30
  /**
26
- * Setup context passed to a {@link TestTriggerNodeConfig.generateItems} callback. Distinct from
27
- * {@link import("./runtimeTypes").TriggerSetupContext} on purpose: test triggers are not
28
- * activated by the live trigger lifecycle (webhooks, cron, polling) and never call `emit` —
29
- * the orchestrator pulls from the iterable they return and dispatches one run per item.
31
+ * Minimal logger surface for the polling-trigger runtime.
32
+ * Hosts supply this via {@link EngineDeps.pollingTriggerLogger};
33
+ * when absent the runtime is silent.
30
34
  */
31
- interface TestTriggerSetupContext<TConfig extends TestTriggerNodeConfig<unknown> = TestTriggerNodeConfig<unknown>> {
32
- readonly workflowId: WorkflowId;
33
- readonly nodeId: NodeId;
34
- readonly config: TConfig;
35
- readonly testSuiteRunId: TestSuiteRunId;
35
+ interface PollingTriggerLogger {
36
+ info(message: string): void;
37
+ warn(message: string): void;
38
+ error(message: string, exception?: Error): void;
39
+ debug(message: string): void;
40
+ }
41
+ declare class NoOpPollingTriggerLogger implements PollingTriggerLogger {
42
+ info(): void;
43
+ warn(): void;
44
+ error(): void;
45
+ debug(): void;
46
+ }
47
+ //#endregion
48
+ //#region src/contracts/credentialTypes.d.ts
49
+ type CredentialTypeId = string;
50
+ type CredentialInstanceId = string;
51
+ type CredentialMaterialSourceKind = "db" | "env" | "code";
52
+ type CredentialSetupStatus = "draft" | "ready";
53
+ type CredentialHealthStatus = "unknown" | "healthy" | "failing";
54
+ type CredentialFieldSchema = Readonly<{
55
+ key: string;
56
+ label: string;
57
+ type: "string" | "password" | "textarea" | "json" | "boolean";
58
+ required?: true;
59
+ order?: number;
36
60
  /**
37
- * Resolves a credential session for a slot declared on this trigger's
38
- * {@link import("./workflowTypes").NodeConfigBase.getCredentialRequirements}. Same contract as
39
- * {@link import("./runtimeTypes").ExecutionContext.getCredential}.
61
+ * Where this field appears in the credential dialog. Use `"advanced"` for optional or
62
+ * power-user fields; they render inside a collapsible section (see `CredentialTypeDefinition.advancedSection`).
63
+ * Defaults to `"default"` when omitted.
40
64
  */
41
- getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
42
- /** AbortSignal raised when the suite is cancelled — long-running pulls should bail out. */
43
- readonly signal: AbortSignal;
44
- }
45
- /**
46
- * A trigger config that emits **test cases**. Each item yielded by {@link generateItems}
47
- * becomes one workflow run (with `executionOptions.testContext` set), so 10 yielded items
48
- * → 10 runs marked under the same TestSuiteRun.
49
- *
50
- * The trigger is otherwise a normal {@link TriggerNodeConfig} (so the canvas treats it like
51
- * any other trigger), but its `triggerKind` is `"test"` so the live activation policy skips it.
52
- */
53
- interface TestTriggerNodeConfig<TOutputJson$1 = unknown> extends TriggerNodeConfig<TOutputJson$1, undefined> {
54
- readonly triggerKind: "test";
65
+ visibility?: "default" | "advanced";
66
+ placeholder?: string;
67
+ helpText?: string;
68
+ /** When set, host resolves this field from process.env at runtime; env wins over stored values. */
69
+ envVarName?: string;
55
70
  /**
56
- * Author-supplied async iterable of items, evaluated lazily. Implementations may fetch from
57
- * credentialed APIs, read fixture files, or yield hard-coded items. The orchestrator iterates
58
- * and dispatches one run per item, with concurrency capped by {@link concurrency} (default 4).
71
+ * When set, the dialog shows a copy action for this exact string (e.g. a static OAuth redirect URI
72
+ * pattern or documentation URL). Do not use for secret values.
59
73
  */
60
- generateItems(ctx: TestTriggerSetupContext<TestTriggerNodeConfig<TOutputJson$1>>): AsyncIterable<Item<TOutputJson$1>>;
61
- /** Per-suite-run cap on simultaneously-executing test cases. Default: 4. */
62
- readonly concurrency?: number;
74
+ copyValue?: string;
75
+ /** Accessible label for the copy control (default: Copy). */
76
+ copyButtonLabel?: string;
77
+ }>;
78
+ type CredentialRequirement = Readonly<{
79
+ slotKey: string;
80
+ label: string;
81
+ acceptedTypes: ReadonlyArray<CredentialTypeId>;
82
+ optional?: true;
83
+ helpText?: string;
84
+ helpUrl?: string;
85
+ }>;
86
+ type CredentialBindingKey = Readonly<{
87
+ workflowId: WorkflowId;
88
+ nodeId: NodeId;
89
+ slotKey: string;
90
+ }>;
91
+ type CredentialBinding = Readonly<{
92
+ key: CredentialBindingKey;
93
+ instanceId: CredentialInstanceId;
94
+ updatedAt: string;
95
+ }>;
96
+ type CredentialHealth = Readonly<{
97
+ status: CredentialHealthStatus;
98
+ message?: string;
99
+ testedAt?: string;
100
+ expiresAt?: string;
101
+ details?: Readonly<Record<string, unknown>>;
102
+ }>;
103
+ type OAuth2ProviderFromPublicConfig = Readonly<{
104
+ authorizeUrlFieldKey: string;
105
+ tokenUrlFieldKey: string;
106
+ userInfoUrlFieldKey?: string;
107
+ }>;
108
+ type CredentialOAuth2ScopesFromPublicConfig = Readonly<{
109
+ presetFieldKey: string;
110
+ presetScopes: Readonly<Record<string, ReadonlyArray<string>>>;
111
+ customPresetKey?: string;
112
+ customScopesFieldKey?: string;
113
+ }>;
114
+ type CredentialOAuth2AuthDefinition = Readonly<{
115
+ kind: "oauth2";
116
+ providerId: string;
117
+ scopes: ReadonlyArray<string>;
118
+ scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
119
+ clientIdFieldKey?: string;
120
+ clientSecretFieldKey?: string;
121
+ } | {
122
+ kind: "oauth2";
123
+ providerFromPublicConfig: OAuth2ProviderFromPublicConfig;
124
+ scopes: ReadonlyArray<string>;
125
+ scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
126
+ clientIdFieldKey?: string;
127
+ clientSecretFieldKey?: string;
128
+ } | {
129
+ kind: "oauth2";
63
130
  /**
64
- * Free-form description of where the test cases come from surfaced in the node properties
65
- * panel and the suite-detail header so authors revisiting the workflow six months later
66
- * remember which mailbox / folder / fixture file the cases originate from.
67
- *
68
- * Example: `"All emails in the Gmail label \"test/triage-fixtures\" — 14 messages as of 2026-05-03."`
131
+ * Free-form provider identifier for telemetry, DB rows, and Better Auth provider naming.
132
+ * Not used for any registry lookup URLs come from {@link authorizeUrl} / {@link tokenUrl}.
69
133
  */
70
- readonly description?: string;
134
+ providerId: string;
71
135
  /**
72
- * Resolves a human-readable label for one yielded test case (e.g. email subject). The
73
- * orchestrator calls this once per yielded item, persists the result on the run, and the
74
- * Tests-tab UI uses it to render the case row instead of the opaque runId. Return
75
- * `undefined` to fall back to "Case #N".
136
+ * Authorization endpoint. May contain `{publicFieldKey}` placeholders that the runtime
137
+ * substitutes from the credential's resolved public config (URL-encoded).
138
+ * Example: `https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize`
76
139
  */
77
- caseLabel?(item: Item<TOutputJson$1>): string | undefined;
140
+ authorizeUrl: string;
141
+ /** Token endpoint. Same templating rules as {@link authorizeUrl}. */
142
+ tokenUrl: string;
143
+ /** Optional userinfo endpoint. Same templating rules as {@link authorizeUrl}. */
144
+ userInfoUrl?: string;
145
+ scopes: ReadonlyArray<string>;
146
+ scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
147
+ clientIdFieldKey?: string;
148
+ clientSecretFieldKey?: string;
149
+ }>;
150
+ type CredentialAuthDefinition = CredentialOAuth2AuthDefinition;
151
+ type CredentialAdvancedSectionPresentation = Readonly<{
152
+ /** Collapsible section title (default: "Advanced"). */
153
+ title?: string;
154
+ /** Optional short helper text shown inside the section (above the fields). */
155
+ description?: string;
156
+ /** When true, the advanced section starts expanded. Default: false (collapsed). */
157
+ defaultOpen?: boolean;
158
+ }>;
159
+ type CredentialTypeDefinition = Readonly<{
160
+ typeId: CredentialTypeId;
161
+ displayName: string;
162
+ description?: string;
163
+ publicFields?: ReadonlyArray<CredentialFieldSchema>;
164
+ secretFields?: ReadonlyArray<CredentialFieldSchema>;
165
+ /**
166
+ * Optional labels for the collapsible block that contains every field with `visibility: "advanced"`.
167
+ * If omitted, the UI still shows that block with defaults (title "Advanced", collapsed).
168
+ */
169
+ advancedSection?: CredentialAdvancedSectionPresentation;
170
+ supportedSourceKinds?: ReadonlyArray<CredentialMaterialSourceKind>;
171
+ auth?: CredentialAuthDefinition;
172
+ }>;
173
+ /**
174
+ * JSON-shaped credential field bag (public config, resolved secret material, etc.).
175
+ */
176
+ type CredentialJsonRecord = Readonly<Record<string, unknown>>;
177
+ /**
178
+ * Persisted credential instance with typed `publicConfig`.
179
+ * Hosts may specialize `secretRef` with a stricter union while remaining
180
+ * assignable here for session/test callbacks.
181
+ */
182
+ type CredentialInstanceRecord<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
183
+ instanceId: CredentialInstanceId;
184
+ typeId: CredentialTypeId;
185
+ displayName: string;
186
+ sourceKind: CredentialMaterialSourceKind;
187
+ publicConfig: TPublicConfig;
188
+ secretRef: CredentialJsonRecord;
189
+ tags: ReadonlyArray<string>;
190
+ setupStatus: CredentialSetupStatus;
191
+ createdAt: string;
192
+ updatedAt: string;
193
+ }>;
194
+ /**
195
+ * Arguments passed to `CredentialType.createSession` and `CredentialType.test`.
196
+ * Declare `TPublicConfig` / `TMaterial` on `CredentialType` so implementations are checked
197
+ * against your credential shapes (similar to `NodeExecutionContext.config` for nodes).
198
+ */
199
+ type CredentialSessionFactoryArgs<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
200
+ instance: CredentialInstanceRecord<TPublicConfig>;
201
+ material: TMaterial;
202
+ publicConfig: TPublicConfig;
203
+ }>;
204
+ type CredentialSessionFactory<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<TSession>;
205
+ type CredentialHealthTester<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<CredentialHealth>;
206
+ /**
207
+ * Full credential type implementation: `definition` (UI/schema), `createSession`, and `test`.
208
+ * Use this at registration and config boundaries; `CredentialTypeDefinition` is only the schema slice.
209
+ */
210
+ type CredentialType<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = Readonly<{
211
+ definition: CredentialTypeDefinition;
212
+ createSession: CredentialSessionFactory<TPublicConfig, TMaterial, TSession>;
213
+ test: CredentialHealthTester<TPublicConfig, TMaterial>;
214
+ }>;
215
+ /**
216
+ * Credential type with unspecified generics — used for `CodemationConfig.credentialTypes`, the host registry,
217
+ * and anywhere a concrete `CredentialType<YourPublic, YourMaterial, YourSession>` is placed in a heterogeneous list.
218
+ * Using `any` here avoids unsafe `as` casts while keeping typed `satisfies CredentialType<…>` definitions.
219
+ */
220
+ type AnyCredentialType = CredentialType<any, any, unknown>;
221
+ interface CredentialSessionService {
222
+ getSession<TSession = unknown>(args: Readonly<{
223
+ workflowId: WorkflowId;
224
+ nodeId: NodeId;
225
+ slotKey: string;
226
+ }>): Promise<TSession>;
227
+ }
228
+ interface CredentialTypeRegistry {
229
+ listTypes(): ReadonlyArray<CredentialTypeDefinition>;
230
+ getType(typeId: CredentialTypeId): CredentialTypeDefinition | undefined;
231
+ }
232
+ declare class CredentialUnboundError extends Error {
233
+ readonly bindingKey: CredentialBindingKey;
234
+ readonly acceptedTypes: ReadonlyArray<CredentialTypeId>;
235
+ constructor(bindingKey: CredentialBindingKey, acceptedTypes?: ReadonlyArray<CredentialTypeId>);
236
+ private static createMessage;
78
237
  }
79
238
  //#endregion
80
- //#region src/events/runEvents.d.ts
239
+ //#region src/contracts/collectionTypes.d.ts
81
240
  /**
82
- * Outcome of a single test case (one workflow run dispatched by the test-suite orchestrator).
83
- * - `running`: workflow still in flight
84
- * - `succeeded`: workflow completed AND all assertions passed (or no assertions)
85
- * - `failed`: workflow failed OR (workflow completed but ≥1 assertion failed)
86
- * - `errored` / `cancelled`: workflow itself errored or was cancelled
87
- */
88
- type TestCaseRunStatus = "running" | "succeeded" | "failed" | "errored" | "cancelled";
89
- /** Aggregate outcome of a TestSuiteRun. */
90
- type TestSuiteRunStatus = "succeeded" | "failed" | "partial" | "errored" | "cancelled";
91
- type RunEvent = Readonly<{
92
- kind: "runCreated";
93
- runId: RunId;
94
- workflowId: WorkflowId;
95
- parent?: ParentExecutionRef;
96
- at: string;
97
- }> | Readonly<{
98
- kind: "runSaved";
99
- runId: RunId;
100
- workflowId: WorkflowId;
101
- parent?: ParentExecutionRef;
102
- at: string;
103
- state: PersistedRunState;
104
- }> | Readonly<{
105
- kind: "nodeQueued";
106
- runId: RunId;
107
- workflowId: WorkflowId;
108
- parent?: ParentExecutionRef;
109
- at: string;
110
- snapshot: NodeExecutionSnapshot;
111
- }> | Readonly<{
112
- kind: "nodeStarted";
113
- runId: RunId;
114
- workflowId: WorkflowId;
115
- parent?: ParentExecutionRef;
116
- at: string;
117
- snapshot: NodeExecutionSnapshot;
118
- }> | Readonly<{
119
- kind: "nodeCompleted";
120
- runId: RunId;
121
- workflowId: WorkflowId;
122
- parent?: ParentExecutionRef;
123
- at: string;
124
- snapshot: NodeExecutionSnapshot;
125
- }> | Readonly<{
126
- kind: "nodeFailed";
127
- runId: RunId;
128
- workflowId: WorkflowId;
129
- parent?: ParentExecutionRef;
130
- at: string;
131
- snapshot: NodeExecutionSnapshot;
132
- }> | Readonly<{
133
- kind: "connectionInvocationStarted";
134
- runId: RunId;
135
- workflowId: WorkflowId;
136
- parent?: ParentExecutionRef;
137
- at: string;
138
- record: ConnectionInvocationRecord;
139
- }> | Readonly<{
140
- kind: "connectionInvocationCompleted";
141
- runId: RunId;
142
- workflowId: WorkflowId;
143
- parent?: ParentExecutionRef;
144
- at: string;
145
- record: ConnectionInvocationRecord;
146
- }> | Readonly<{
147
- kind: "connectionInvocationFailed";
148
- runId: RunId;
149
- workflowId: WorkflowId;
150
- parent?: ParentExecutionRef;
151
- at: string;
152
- record: ConnectionInvocationRecord;
153
- }> | Readonly<{
154
- kind: "testSuiteStarted";
155
- testSuiteRunId: TestSuiteRunId;
156
- workflowId: WorkflowId;
157
- triggerNodeId: string;
158
- triggerNodeName?: string;
159
- concurrency: number;
160
- at: string;
161
- }> | Readonly<{
162
- kind: "testSuiteFinished";
163
- testSuiteRunId: TestSuiteRunId;
164
- workflowId: WorkflowId;
165
- status: TestSuiteRunStatus;
166
- totalCases: number;
167
- passedCases: number;
168
- failedCases: number;
169
- at: string;
170
- }> | Readonly<{
171
- kind: "testCaseStarted";
172
- testSuiteRunId: TestSuiteRunId;
173
- testCaseIndex: number;
174
- runId: RunId;
175
- workflowId: WorkflowId;
176
- testCaseLabel?: string;
177
- at: string;
178
- }> | Readonly<{
179
- kind: "testCaseCompleted";
180
- testSuiteRunId: TestSuiteRunId;
181
- testCaseIndex: number;
182
- runId: RunId;
183
- workflowId: WorkflowId;
184
- status: TestCaseRunStatus;
185
- at: string;
186
- }>;
187
- interface RunEventSubscription {
188
- close(): Promise<void>;
189
- }
190
- interface RunEventBus {
191
- publish(event: RunEvent): Promise<void>;
192
- subscribe(onEvent: (event: RunEvent) => void): Promise<RunEventSubscription>;
193
- subscribeToWorkflow(workflowId: WorkflowId, onEvent: (event: RunEvent) => void): Promise<RunEventSubscription>;
194
- }
195
- //#endregion
196
- //#region src/policies/executionLimits/EngineExecutionLimitsPolicy.d.ts
197
- interface EngineExecutionLimitsPolicyConfig {
198
- readonly defaultMaxNodeActivations: number;
199
- readonly hardMaxNodeActivations: number;
200
- readonly defaultMaxSubworkflowDepth: number;
201
- readonly hardMaxSubworkflowDepth: number;
202
- }
203
- /** Framework defaults for {@link EngineExecutionLimitsPolicy} (merged with host `runtime.engineExecutionLimits`). */
204
- declare const ENGINE_EXECUTION_LIMITS_DEFAULTS: EngineExecutionLimitsPolicyConfig;
205
- /**
206
- * Resolves per-run execution limits: defaults, hard ceilings, and subworkflow depth for new runs.
241
+ * Represents a typed store for a single collection.
242
+ * All rows include auto-managed id, created_at, and updated_at fields.
207
243
  */
208
- declare class EngineExecutionLimitsPolicy {
209
- private readonly config;
210
- constructor(config?: EngineExecutionLimitsPolicyConfig);
244
+ interface CollectionStore<TRow extends Record<string, unknown> = Record<string, unknown>> {
211
245
  /**
212
- * Effective options for a new root run (depth 0): defaults merged with engine ceilings.
213
- * Replaces a separate one-method factory for root-run bootstrap.
246
+ * Insert a new row. id, created_at, and updated_at are auto-populated.
214
247
  */
215
- createRootExecutionOptions(): RunExecutionOptions;
216
- mergeExecutionOptionsForNewRun(parent: ParentExecutionRef | undefined, user: RunExecutionOptions | undefined): RunExecutionOptions;
217
- private capNumber;
218
- }
219
- //#endregion
220
- //#region src/di/CoreTokens.d.ts
221
- declare const CoreTokens: {
222
- readonly PersistedWorkflowTokenRegistry: TypeToken<PersistedWorkflowTokenRegistryLike>;
223
- readonly CredentialSessionService: TypeToken<CredentialSessionService>;
224
- readonly CredentialTypeRegistry: TypeToken<CredentialTypeRegistry>;
225
- readonly WorkflowRunnerService: TypeToken<WorkflowRunnerService>;
226
- readonly LiveWorkflowRepository: TypeToken<LiveWorkflowRepository>;
227
- readonly WorkflowRepository: TypeToken<WorkflowRepository>;
228
- readonly NodeResolver: TypeToken<NodeResolver>;
229
- readonly WorkflowNodeInstanceFactory: TypeToken<WorkflowNodeInstanceFactory>;
230
- readonly RunIdFactory: TypeToken<RunIdFactory>;
231
- readonly ActivationIdFactory: TypeToken<ActivationIdFactory>;
232
- readonly WorkflowExecutionRepository: TypeToken<WorkflowExecutionRepository>;
233
- readonly TriggerSetupStateRepository: TypeToken<TriggerSetupStateRepository>;
234
- readonly NodeActivationScheduler: TypeToken<NodeActivationScheduler>;
235
- readonly RunDataFactory: TypeToken<RunDataFactory>;
236
- readonly ExecutionContextFactory: TypeToken<ExecutionContextFactory>;
237
- readonly RunEventBus: TypeToken<RunEventBus>;
238
- readonly BinaryStorage: TypeToken<BinaryStorage>;
239
- readonly WebhookBasePath: TypeToken<string>;
240
- /** Engine execution limits (defaults + optional host overrides). Consumers may bind a custom instance to override. */
241
- readonly EngineExecutionLimitsPolicy: TypeToken<EngineExecutionLimitsPolicy>;
242
- readonly WorkflowActivationPolicy: TypeToken<WorkflowActivationPolicy>;
243
- };
244
- //#endregion
245
- //#region src/contracts/runTypes.d.ts
246
- /**
247
- * Test-suite linkage for a run. When set, this run was started by a TestSuiteOrchestrator
248
- * as one test case inside a TestSuiteRun. The `IsTestRun` node and host-side persisters key
249
- * off the presence of this field. Subworkflow runs inherit it from their parent run.
250
- */
251
- interface RunTestContext {
252
- readonly testSuiteRunId: string;
253
- readonly testCaseIndex: number;
248
+ insert(row: TRow): Promise<TRow & {
249
+ id: string;
250
+ created_at: Date;
251
+ updated_at: Date;
252
+ }>;
254
253
  /**
255
- * Optional human-friendly label for this test case (e.g. an email subject when fixtures
256
- * are loaded from a mailbox). Resolved per item by `TestTrigger.caseLabel(item)` if set,
257
- * persisted on `Run.test_case_label` so the Tests-tab tree-table can show "RFQ for batch 14"
258
- * instead of "run_1777755971399_bbb86beac1396".
254
+ * Get a single row by id.
259
255
  */
260
- readonly testCaseLabel?: string;
261
- }
262
- interface RunExecutionOptions {
263
- /** Run-intent override: force the inline scheduler and bypass node-level offload decisions. */
264
- localOnly?: boolean;
265
- /** Marks runs started from webhook handling so orchestration can apply webhook-specific continuation rules. */
266
- webhook?: boolean;
267
- mode?: "manual" | "debug";
268
- sourceWorkflowId?: WorkflowId;
269
- sourceRunId?: RunId;
270
- derivedFromRunId?: RunId;
271
- isMutable?: boolean;
272
- /** Set by the engine for this run: 0 = root, 1 = first child subworkflow, … */
273
- subworkflowDepth?: number;
274
- /** Effective cap after engine policy merge (successful node completions per run). */
275
- maxNodeActivations?: number;
276
- /** Effective cap after engine policy merge (subworkflow nesting). */
277
- maxSubworkflowDepth?: number;
278
- /** Present iff started by a TestSuiteOrchestrator; propagates to subworkflow runs via {@link ParentExecutionRef.testContext}. */
279
- testContext?: RunTestContext;
280
- }
281
- /** Engine-owned counters persisted with the run (worker-safe). */
282
- interface EngineRunCounters {
283
- completedNodeActivations: number;
284
- }
285
- type RunStopCondition = Readonly<{
286
- kind: "workflowCompleted";
287
- }> | Readonly<{
288
- kind: "nodeCompleted";
289
- nodeId: NodeId;
290
- }>;
291
- interface RunStateResetRequest {
292
- clearFromNodeId: NodeId;
293
- }
294
- interface PersistedRunControlState {
295
- stopCondition?: RunStopCondition;
296
- }
297
- interface PersistedWorkflowSnapshotNode {
298
- id: NodeId;
299
- kind: NodeKind;
300
- name?: string;
301
- nodeTokenId: PersistedTokenId;
302
- configTokenId: PersistedTokenId;
303
- tokenName?: string;
304
- configTokenName?: string;
305
- config: unknown;
306
- }
307
- interface PersistedWorkflowSnapshot {
308
- id: WorkflowId;
309
- name: string;
310
- nodes: ReadonlyArray<PersistedWorkflowSnapshotNode>;
311
- edges: ReadonlyArray<Edge>;
312
- /** When the snapshot was built from a live workflow definition that configured a workflow error handler. */
313
- workflowErrorHandlerConfigured?: boolean;
314
- /** Connection metadata for child nodes not in the execution graph (e.g. AI agent attachments). */
315
- connections?: ReadonlyArray<WorkflowNodeConnection>;
316
- }
317
- type PinnedNodeOutputsByPort = Readonly<Record<OutputPortKey, Items>>;
318
- interface PersistedMutableNodeState {
319
- pinnedOutputsByPort?: PinnedNodeOutputsByPort;
320
- lastDebugInput?: Items;
321
- }
322
- interface PersistedMutableRunState {
323
- nodesById: Readonly<Record<NodeId, PersistedMutableNodeState>>;
324
- }
325
- type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
326
- interface RunQueueEntry {
327
- nodeId: NodeId;
328
- input: Items;
329
- toInput?: InputPortKey;
330
- batchId?: string;
331
- from?: Readonly<{
332
- nodeId: NodeId;
333
- output: OutputPortKey;
256
+ get(id: string): Promise<(TRow & {
257
+ id: string;
258
+ created_at: Date;
259
+ updated_at: Date;
260
+ }) | null>;
261
+ /**
262
+ * Find a single row matching the provided filter.
263
+ */
264
+ findOne(filter: Partial<TRow>): Promise<(TRow & {
265
+ id: string;
266
+ created_at: Date;
267
+ updated_at: Date;
268
+ }) | null>;
269
+ /**
270
+ * List rows with optional pagination and filtering.
271
+ */
272
+ list(opts?: {
273
+ limit?: number;
274
+ offset?: number;
275
+ where?: Partial<TRow>;
276
+ }): Promise<{
277
+ rows: ReadonlyArray<TRow & {
278
+ id: string;
279
+ created_at: Date;
280
+ updated_at: Date;
281
+ }>;
282
+ total: number;
334
283
  }>;
335
- collect?: Readonly<{
336
- expectedInputs: ReadonlyArray<InputPortKey>;
337
- received: Readonly<Record<InputPortKey, Items>>;
284
+ /**
285
+ * Update a row by id with partial data.
286
+ */
287
+ update(id: string, patch: Partial<TRow>): Promise<TRow & {
288
+ id: string;
289
+ created_at: Date;
290
+ updated_at: Date;
291
+ }>;
292
+ /**
293
+ * Delete a row by id. Hard delete only (no soft delete).
294
+ */
295
+ delete(id: string): Promise<{
296
+ deleted: boolean;
338
297
  }>;
339
298
  }
340
- type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
341
- interface NodeExecutionError {
342
- message: string;
343
- name?: string;
344
- stack?: string;
345
- details?: JsonValue;
346
- }
347
- interface NodeExecutionSnapshot {
348
- runId: RunId;
349
- workflowId: WorkflowId;
350
- nodeId: NodeId;
351
- activationId?: NodeActivationId;
352
- parent?: ParentExecutionRef;
353
- status: NodeExecutionStatus;
354
- usedPinnedOutput?: boolean;
355
- queuedAt?: string;
356
- startedAt?: string;
357
- finishedAt?: string;
358
- updatedAt: string;
359
- inputsByPort?: NodeInputsByPort;
360
- outputs?: NodeOutputs;
361
- error?: NodeExecutionError;
362
- }
363
- /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
364
- type ConnectionInvocationId = string;
365
299
  /**
366
- * One logical LLM or tool call under an owning workflow node (e.g. AI agent).
367
- * The owning node defines what {@link managedInput} and {@link managedOutput} contain.
300
+ * Runtime collections context: keyed by collection name.
368
301
  */
369
- interface ConnectionInvocationRecord {
370
- readonly invocationId: ConnectionInvocationId;
371
- readonly runId: RunId;
372
- readonly workflowId: WorkflowId;
373
- readonly connectionNodeId: NodeId;
374
- readonly parentAgentNodeId: NodeId;
375
- readonly parentAgentActivationId: NodeActivationId;
376
- readonly status: NodeExecutionStatus;
377
- readonly managedInput?: JsonValue;
378
- readonly managedOutput?: JsonValue;
379
- readonly error?: NodeExecutionError;
380
- readonly queuedAt?: string;
381
- readonly startedAt?: string;
382
- readonly finishedAt?: string;
383
- readonly updatedAt: string;
384
- /** Per-item iteration id minted by the engine when this invocation occurred inside a runnable node's per-item loop. */
385
- readonly iterationId?: NodeIterationId;
386
- /** Item index (0-based) of the iteration that produced this invocation. */
387
- readonly itemIndex?: number;
388
- /** When set, this invocation was produced inside a sub-agent triggered by the named parent invocation. */
389
- readonly parentInvocationId?: ConnectionInvocationId;
390
- }
391
- /** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
392
- type ConnectionInvocationAppendArgs = Readonly<{
393
- invocationId: ConnectionInvocationId;
394
- connectionNodeId: NodeId;
395
- parentAgentNodeId: NodeId;
396
- parentAgentActivationId: NodeActivationId;
397
- status: NodeExecutionStatus;
398
- managedInput?: JsonValue;
399
- managedOutput?: JsonValue;
400
- error?: NodeExecutionError;
401
- queuedAt?: string;
402
- startedAt?: string;
403
- finishedAt?: string;
404
- iterationId?: NodeIterationId;
405
- itemIndex?: number;
406
- parentInvocationId?: ConnectionInvocationId;
407
- }>;
408
- interface RunCurrentState {
409
- outputsByNode: Record<NodeId, NodeOutputs>;
410
- nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
411
- /** Append-only history of connection-scoped invocations (LLM/tool) for inspector and canvas. */
412
- connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
413
- mutableState?: PersistedMutableRunState;
302
+ type CollectionsContext = Readonly<Record<string, CollectionStore>>;
303
+ //#endregion
304
+ //#region src/contracts/CostTrackingTelemetryContract.d.ts
305
+ type CostTrackingComponent = "chat" | "ocr" | "rag";
306
+ declare const CostTrackingTelemetryMetricNames: {
307
+ readonly usage: "codemation.cost.usage";
308
+ readonly estimatedCost: "codemation.cost.estimated";
309
+ };
310
+ declare const CostTrackingTelemetryAttributeNames: {
311
+ readonly component: "cost.component";
312
+ readonly provider: "cost.provider";
313
+ readonly operation: "cost.operation";
314
+ readonly pricingKey: "cost.pricing_key";
315
+ readonly usageUnit: "cost.usage_unit";
316
+ readonly currency: "cost.currency";
317
+ readonly currencyScale: "cost.currency_scale";
318
+ readonly estimateKind: "cost.estimate_kind";
319
+ };
320
+ interface CostTrackingUsageRecord {
321
+ readonly component: CostTrackingComponent;
322
+ readonly provider: string;
323
+ readonly operation: string;
324
+ readonly pricingKey: string;
325
+ readonly usageUnit: string;
326
+ readonly quantity: number;
327
+ readonly modelName?: string;
328
+ readonly attributes?: TelemetryAttributes;
414
329
  }
415
- interface CurrentStateExecutionRequest {
416
- workflow: WorkflowDefinition;
417
- items?: Items;
418
- parent?: ParentExecutionRef;
419
- executionOptions?: RunExecutionOptions;
420
- workflowSnapshot?: PersistedWorkflowSnapshot;
421
- mutableState?: PersistedMutableRunState;
422
- currentState?: RunCurrentState;
423
- stopCondition?: RunStopCondition;
424
- reset?: RunStateResetRequest;
330
+ interface CostTrackingPriceQuote {
331
+ readonly currency: string;
332
+ readonly currencyScale: number;
333
+ readonly estimatedAmountMinor: number;
334
+ readonly estimateKind: "catalog";
425
335
  }
426
- interface ExecutionFrontierPlan {
427
- rootNodeId?: NodeId;
428
- rootNodeInput?: Items;
429
- queue: RunQueueEntry[];
430
- currentState: RunCurrentState;
431
- stopCondition: RunStopCondition;
432
- satisfiedNodeIds: ReadonlyArray<NodeId>;
433
- skippedNodeIds: ReadonlyArray<NodeId>;
434
- clearedNodeIds: ReadonlyArray<NodeId>;
435
- preservedPinnedNodeIds: ReadonlyArray<NodeId>;
336
+ interface CostTrackingTelemetry {
337
+ captureUsage(args: CostTrackingUsageRecord): Promise<CostTrackingPriceQuote | undefined>;
338
+ forScope(scope: TelemetryScope): CostTrackingTelemetry;
436
339
  }
437
- type RunStatus = "running" | "pending" | "completed" | "failed";
438
- interface RunSummary {
439
- runId: RunId;
440
- workflowId: WorkflowId;
441
- startedAt: string;
442
- status: RunStatus;
443
- /**
444
- * Test-case status for runs dispatched as part of a TestSuiteRun. Carries the
445
- * assertion-rollup-corrected outcome the test orchestrator persists onto the row, so the
446
- * executions list can show "failed" for a run whose workflow completed cleanly but whose
447
- * assertions caught regressions. Absent for non-test runs and legacy rows.
448
- */
449
- testCaseStatus?: TestCaseRunStatus;
450
- /** ISO timestamp when the run finished (derived from node snapshots or store `updatedAt`); omit while running/pending. */
451
- finishedAt?: string;
452
- parent?: ParentExecutionRef;
453
- executionOptions?: RunExecutionOptions;
340
+ interface CostTrackingTelemetryFactory {
341
+ create(args: Readonly<{
342
+ telemetry: ExecutionTelemetry;
343
+ }>): CostTrackingTelemetry;
454
344
  }
455
- interface PendingNodeExecution {
456
- runId: RunId;
457
- activationId: NodeActivationId;
458
- workflowId: WorkflowId;
459
- nodeId: NodeId;
460
- itemsIn: number;
461
- inputsByPort: NodeInputsByPort;
462
- receiptId: string;
463
- queue?: string;
464
- batchId?: string;
465
- enqueuedAt: string;
345
+ //#endregion
346
+ //#region src/contracts/NoOpTelemetryArtifactReference.d.ts
347
+ declare class NoOpTelemetryArtifactReference {
348
+ static readonly value: TelemetryArtifactReference;
466
349
  }
467
- interface PersistedRunSchedulingState {
468
- pending?: PendingNodeExecution;
469
- queue: RunQueueEntry[];
350
+ //#endregion
351
+ //#region src/contracts/NoOpTelemetrySpanScope.d.ts
352
+ declare class NoOpTelemetrySpanScope {
353
+ static readonly value: TelemetrySpanScope;
354
+ /** Internal: the shared no-op {@link NodeExecutionTelemetry} that {@link NoOpNodeExecutionTelemetry} re-exposes. */
355
+ static readonly nodeExecutionTelemetryValue: NodeExecutionTelemetry;
470
356
  }
471
- interface PersistedRunState {
472
- runId: RunId;
473
- workflowId: WorkflowId;
474
- startedAt: string;
475
- /** Canonical terminal time for listings and retention when persisted on the run root. */
476
- finishedAt?: string;
477
- /** Optimistic concurrency / CAS on the run aggregate (repository may increment on save). */
478
- revision?: number;
479
- parent?: ParentExecutionRef;
480
- executionOptions?: RunExecutionOptions;
481
- control?: PersistedRunControlState;
482
- workflowSnapshot?: PersistedWorkflowSnapshot;
483
- mutableState?: PersistedMutableRunState;
484
- /** Frozen at createRun from workflow + runtime defaults for prune/storage decisions. */
485
- policySnapshot?: PersistedRunPolicySnapshot;
486
- /** Successful node completions so far (for activation budget). */
487
- engineCounters?: EngineRunCounters;
488
- status: RunStatus;
489
- pending?: PendingNodeExecution;
490
- queue: RunQueueEntry[];
491
- outputsByNode: Record<NodeId, NodeOutputs>;
492
- nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
493
- /** Append-only history of connection invocations (LLM/tool) nested under owning nodes. */
494
- connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
357
+ //#endregion
358
+ //#region src/contracts/NoOpNodeExecutionTelemetry.d.ts
359
+ declare class NoOpNodeExecutionTelemetry {
360
+ static readonly value: NodeExecutionTelemetry;
495
361
  }
496
- interface WorkflowExecutionRepository {
497
- createRun(args: {
362
+ //#endregion
363
+ //#region src/contracts/NoOpExecutionTelemetry.d.ts
364
+ declare class NoOpExecutionTelemetry {
365
+ static readonly value: ExecutionTelemetry;
366
+ }
367
+ //#endregion
368
+ //#region src/contracts/NoOpExecutionTelemetryFactory.d.ts
369
+ declare class NoOpExecutionTelemetryFactory implements ExecutionTelemetryFactory {
370
+ create(_: Readonly<{
498
371
  runId: RunId;
499
372
  workflowId: WorkflowId;
500
- startedAt: string;
501
373
  parent?: ParentExecutionRef;
502
- executionOptions?: RunExecutionOptions;
503
- control?: PersistedRunControlState;
504
- workflowSnapshot?: PersistedWorkflowSnapshot;
505
- mutableState?: PersistedMutableRunState;
506
374
  policySnapshot?: PersistedRunPolicySnapshot;
507
- engineCounters?: EngineRunCounters;
508
- }): Promise<void>;
509
- load(runId: RunId): Promise<PersistedRunState | undefined>;
510
- loadSchedulingState(runId: RunId): Promise<PersistedRunSchedulingState | undefined>;
511
- save(state: PersistedRunState): Promise<void>;
512
- deleteRun?(runId: RunId): Promise<void>;
375
+ }>): ExecutionTelemetry;
513
376
  }
514
- interface WorkflowExecutionListingRepository {
515
- listRuns(args?: Readonly<{
516
- workflowId?: WorkflowId;
517
- limit?: number;
518
- }>): Promise<ReadonlyArray<RunSummary>>;
377
+ //#endregion
378
+ //#region src/contracts/CodemationTelemetryAttributeNames.d.ts
379
+ declare class CodemationTelemetryAttributeNames {
380
+ static readonly workflowId = "codemation.workflow.id";
381
+ static readonly runId = "codemation.run.id";
382
+ static readonly nodeId = "codemation.node.id";
383
+ static readonly activationId = "codemation.activation.id";
384
+ static readonly nodeType = "codemation.node.type";
385
+ static readonly nodeRole = "codemation.node.role";
386
+ static readonly workflowFolder = "codemation.workflow.folder";
387
+ static readonly connectionInvocationId = "codemation.connection.invocation_id";
388
+ static readonly toolName = "codemation.tool.name";
389
+ static readonly traceParentRunId = "codemation.parent.run.id";
390
+ /** Per-item iteration that emitted this span/metric. Set on spans recorded inside a runnable per-item loop. */
391
+ static readonly iterationId = "codemation.iteration.id";
392
+ /** Item index (0-based) of the iteration. */
393
+ static readonly iterationIndex = "codemation.iteration.index";
394
+ /** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
395
+ static readonly parentInvocationId = "codemation.parent.invocation_id";
396
+ /** MCP server id on spans created for callTool invocations. */
397
+ static readonly mcpServerId = "mcp.server_id";
398
+ /** MCP tool name on spans created for callTool invocations. */
399
+ static readonly mcpToolName = "mcp.tool_name";
519
400
  }
520
- /** Runs eligible for retention-based pruning (completed or failed, older than cutoff). */
521
- interface RunPruneCandidate {
522
- readonly runId: RunId;
523
- readonly workflowId: WorkflowId;
524
- readonly startedAt: string;
525
- readonly finishedAt: string;
401
+ //#endregion
402
+ //#region src/contracts/GenAiTelemetryAttributeNames.d.ts
403
+ declare class GenAiTelemetryAttributeNames {
404
+ static readonly operationName = "gen_ai.operation.name";
405
+ static readonly requestModel = "gen_ai.request.model";
406
+ static readonly usageInputTokens = "gen_ai.usage.input_tokens";
407
+ static readonly usageOutputTokens = "gen_ai.usage.output_tokens";
408
+ static readonly usageTotalTokens = "gen_ai.usage.total_tokens";
409
+ static readonly usageCacheReadInputTokens = "gen_ai.usage.cache_read.input_tokens";
410
+ static readonly usageCacheCreationInputTokens = "gen_ai.usage.cache_creation.input_tokens";
411
+ static readonly usageReasoningTokens = "codemation.gen_ai.usage.reasoning_tokens";
526
412
  }
527
- interface WorkflowExecutionPruneRepository {
528
- listRunsOlderThan(args: Readonly<{
529
- nowIso: string;
530
- defaultRetentionSeconds: number;
531
- limit?: number;
532
- }>): Promise<ReadonlyArray<RunPruneCandidate>>;
413
+ //#endregion
414
+ //#region src/contracts/CodemationTelemetryMetricNames.d.ts
415
+ declare class CodemationTelemetryMetricNames {
416
+ static readonly agentTurns = "codemation.ai.turns";
417
+ static readonly agentToolCalls = "codemation.ai.tool_calls";
418
+ static readonly gmailMessagesEmitted = "codemation.gmail.messages_emitted";
419
+ static readonly gmailAttachments = "codemation.gmail.attachments";
420
+ static readonly gmailAttachmentBytes = "codemation.gmail.attachment_bytes";
533
421
  }
534
- type RunResult = {
535
- runId: RunId;
536
- workflowId: WorkflowId;
537
- startedAt: string;
538
- status: "completed";
539
- outputs: Items;
540
- } | {
541
- runId: RunId;
542
- workflowId: WorkflowId;
543
- startedAt: string;
544
- status: "pending";
545
- pending: PendingNodeExecution;
546
- } | {
547
- runId: RunId;
548
- workflowId: WorkflowId;
549
- startedAt: string;
550
- status: "failed";
551
- error: {
552
- message: string;
553
- };
554
- };
555
- type WebhookRunResult = Readonly<{
556
- runId: RunId;
557
- workflowId: WorkflowId;
558
- startedAt: string;
559
- runStatus: "pending" | "completed";
560
- response: Items;
561
- }>;
562
- interface PersistedWorkflowTokenRegistryLike {
563
- register(type: TypeToken<unknown>, packageId: string, persistedNameOverride?: string): string;
564
- getTokenId(type: TypeToken<unknown>): string | undefined;
565
- resolve(tokenId: string): TypeToken<unknown> | undefined;
566
- registerFromWorkflows?(workflows: ReadonlyArray<WorkflowDefinition>): void;
422
+ //#endregion
423
+ //#region src/contracts/telemetryTypes.d.ts
424
+ type TelemetryAttributePrimitive = string | number | boolean | null;
425
+ interface TelemetryAttributes {
426
+ readonly [key: string]: TelemetryAttributePrimitive | undefined;
567
427
  }
568
- interface RunCompletionNotifier {
569
- resolveRunCompletion(result: RunResult): void;
570
- resolveWebhookResponse(result: WebhookRunResult): void;
428
+ interface TelemetryMetricRecord {
429
+ readonly name: string;
430
+ readonly value: number;
431
+ readonly unit?: string;
432
+ readonly attributes?: TelemetryAttributes;
571
433
  }
572
- interface RunEventPublisherDeps {
573
- eventBus?: RunEventBus;
434
+ interface TelemetrySpanEventRecord {
435
+ readonly name: string;
436
+ readonly occurredAt?: Date;
437
+ readonly attributes?: TelemetryAttributes;
438
+ }
439
+ interface TelemetryArtifactAttachment {
440
+ readonly kind: string;
441
+ readonly contentType: string;
442
+ readonly previewText?: string;
443
+ readonly previewJson?: JsonValue;
444
+ readonly payloadText?: string;
445
+ readonly payloadJson?: JsonValue;
446
+ readonly bytes?: number;
447
+ readonly truncated?: boolean;
448
+ readonly expiresAt?: Date;
449
+ }
450
+ interface TelemetryArtifactReference {
451
+ readonly artifactId: string;
452
+ readonly traceId?: string;
453
+ readonly spanId?: string;
454
+ }
455
+ interface TelemetrySpanEnd {
456
+ readonly status?: "ok" | "error";
457
+ readonly statusMessage?: string;
458
+ readonly endedAt?: Date;
459
+ readonly attributes?: TelemetryAttributes;
460
+ }
461
+ interface TelemetryChildSpanStart {
462
+ readonly name: string;
463
+ readonly kind?: "internal" | "client";
464
+ readonly startedAt?: Date;
465
+ readonly attributes?: TelemetryAttributes;
466
+ }
467
+ interface TelemetryScope {
468
+ readonly traceId?: string;
469
+ readonly spanId?: string;
470
+ readonly costTracking?: CostTrackingTelemetry;
471
+ addSpanEvent(args: TelemetrySpanEventRecord): Promise<void> | void;
472
+ recordMetric(args: TelemetryMetricRecord): Promise<void> | void;
473
+ attachArtifact(args: TelemetryArtifactAttachment): Promise<TelemetryArtifactReference> | TelemetryArtifactReference;
474
+ }
475
+ interface TelemetrySpanScope extends TelemetryScope {
476
+ readonly traceId: string;
477
+ readonly spanId: string;
478
+ end(args?: TelemetrySpanEnd): Promise<void> | void;
479
+ /**
480
+ * Lift this span into a {@link NodeExecutionTelemetry} scoped to a different (nodeId, activationId).
481
+ * Children created via the returned telemetry's `startChildSpan` get this span as their parent.
482
+ *
483
+ * Used at the sub-agent boundary so that nested runtime telemetry parents under the agent.tool.call
484
+ * span instead of the orchestrator's node-level span.
485
+ */
486
+ asNodeTelemetry(args: Readonly<{
487
+ nodeId: NodeId;
488
+ activationId: NodeActivationId;
489
+ }>): NodeExecutionTelemetry;
490
+ }
491
+ interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
492
+ startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
493
+ }
494
+ interface ExecutionTelemetry extends TelemetryScope {
495
+ readonly traceId: string;
496
+ readonly spanId: string;
497
+ forNode(args: Readonly<{
498
+ nodeId: NodeId;
499
+ activationId: NodeActivationId;
500
+ }>): NodeExecutionTelemetry;
501
+ }
502
+ interface ExecutionTelemetryFactory {
503
+ create(args: Readonly<{
504
+ runId: RunId;
505
+ workflowId: WorkflowId;
506
+ parent?: ParentExecutionRef;
507
+ policySnapshot?: PersistedRunPolicySnapshot;
508
+ }>): ExecutionTelemetry;
574
509
  }
575
510
  //#endregion
576
- //#region src/triggers/polling/PollingTriggerDedupWindow.d.ts
511
+ //#region src/contracts/workflowActivationPolicy.d.ts
577
512
  /**
578
- * Merges processed-ID windows for polling triggers, capping the total to avoid unbounded growth.
579
- * Plugin code receives an instance of this class via {@link PollingTriggerHandle.dedup}.
513
+ * Host-controlled policy: when false, trigger {@link TriggerNode} setup is skipped and webhook routes
514
+ * for that workflow are not registered (see engine trigger runtime + webhook matcher).
580
515
  */
581
- declare class PollingTriggerDedupWindow {
582
- static readonly defaultCapN = 2000;
583
- merge(previous: ReadonlyArray<string>, incoming: ReadonlyArray<string>, capN?: number): ReadonlyArray<string>;
516
+ interface WorkflowActivationPolicy {
517
+ isActive(workflowId: WorkflowId): boolean;
518
+ }
519
+ /** Default for tests and harnesses: every workflow is treated as active (legacy behavior). */
520
+ declare class AllWorkflowsActiveWorkflowActivationPolicy implements WorkflowActivationPolicy {
521
+ isActive(_workflowId: WorkflowId): boolean;
584
522
  }
585
523
  //#endregion
586
- //#region src/triggers/polling/PollingTriggerLogger.d.ts
587
- /**
588
- * Minimal logger surface for the polling-trigger runtime.
589
- * Hosts supply this via {@link EngineDeps.pollingTriggerLogger};
590
- * when absent the runtime is silent.
591
- */
592
- interface PollingTriggerLogger {
593
- info(message: string): void;
524
+ //#region src/contracts/webhookTypes.d.ts
525
+ type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
526
+ interface WebhookControlSignal {
527
+ readonly __webhookControl: true;
528
+ readonly kind: "respondNow" | "respondNowAndContinue";
529
+ readonly responseItems: Items;
530
+ readonly continueItems?: Items;
531
+ }
532
+ interface WebhookTriggerRoutingDiagnostics {
594
533
  warn(message: string): void;
595
- error(message: string, exception?: Error): void;
596
- debug(message: string): void;
534
+ /** Inactive workflows omitted from the webhook route index (optional; host should wire for clarity at boot/reload). */
535
+ info?(message: string): void;
597
536
  }
598
- declare class NoOpPollingTriggerLogger implements PollingTriggerLogger {
599
- info(): void;
600
- warn(): void;
601
- error(): void;
602
- debug(): void;
537
+ interface TriggerInstanceId {
538
+ workflowId: WorkflowId;
539
+ nodeId: NodeId;
603
540
  }
604
- //#endregion
605
- //#region src/contracts/credentialTypes.d.ts
606
- type CredentialTypeId = string;
607
- type CredentialInstanceId = string;
608
- type CredentialMaterialSourceKind = "db" | "env" | "code";
609
- type CredentialSetupStatus = "draft" | "ready";
610
- type CredentialHealthStatus = "unknown" | "healthy" | "failing";
611
- type CredentialFieldSchema = Readonly<{
612
- key: string;
613
- label: string;
614
- type: "string" | "password" | "textarea" | "json" | "boolean";
615
- required?: true;
616
- order?: number;
617
- /**
618
- * Where this field appears in the credential dialog. Use `"advanced"` for optional or
619
- * power-user fields; they render inside a collapsible section (see `CredentialTypeDefinition.advancedSection`).
620
- * Defaults to `"default"` when omitted.
621
- */
622
- visibility?: "default" | "advanced";
623
- placeholder?: string;
624
- helpText?: string;
625
- /** When set, host resolves this field from process.env at runtime; env wins over stored values. */
626
- envVarName?: string;
627
- /**
628
- * When set, the dialog shows a copy action for this exact string (e.g. a static OAuth redirect URI
629
- * pattern or documentation URL). Do not use for secret values.
630
- */
631
- copyValue?: string;
632
- /** Accessible label for the copy control (default: Copy). */
633
- copyButtonLabel?: string;
634
- }>;
635
- type CredentialRequirement = Readonly<{
636
- slotKey: string;
637
- label: string;
638
- acceptedTypes: ReadonlyArray<CredentialTypeId>;
639
- optional?: true;
640
- helpText?: string;
641
- helpUrl?: string;
642
- }>;
643
- type CredentialBindingKey = Readonly<{
541
+ /** Match for an incoming HTTP request: user-defined URL segment + workflow trigger node. */
542
+ interface WebhookInvocationMatch {
543
+ /** Same value as the webhook trigger's configured endpoint key (URL segment under the webhook base path). */
544
+ endpointPath: string;
644
545
  workflowId: WorkflowId;
645
546
  nodeId: NodeId;
646
- slotKey: string;
647
- }>;
648
- type CredentialBinding = Readonly<{
649
- key: CredentialBindingKey;
650
- instanceId: CredentialInstanceId;
651
- updatedAt: string;
652
- }>;
653
- type CredentialHealth = Readonly<{
654
- status: CredentialHealthStatus;
655
- message?: string;
656
- testedAt?: string;
657
- expiresAt?: string;
658
- details?: Readonly<Record<string, unknown>>;
659
- }>;
660
- type OAuth2ProviderFromPublicConfig = Readonly<{
661
- authorizeUrlFieldKey: string;
662
- tokenUrlFieldKey: string;
663
- userInfoUrlFieldKey?: string;
664
- }>;
665
- type CredentialOAuth2ScopesFromPublicConfig = Readonly<{
666
- presetFieldKey: string;
667
- presetScopes: Readonly<Record<string, ReadonlyArray<string>>>;
668
- customPresetKey?: string;
669
- customScopesFieldKey?: string;
670
- }>;
671
- type CredentialOAuth2AuthDefinition = Readonly<{
672
- kind: "oauth2";
673
- providerId: string;
674
- scopes: ReadonlyArray<string>;
675
- scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
676
- clientIdFieldKey?: string;
677
- clientSecretFieldKey?: string;
547
+ methods: ReadonlyArray<HttpMethod>;
548
+ parseJsonBody?: (body: unknown) => unknown;
549
+ }
550
+ /** Result of resolving an HTTP method + endpoint path against the catalog webhook index (404 vs 405 vs match). */
551
+ type WebhookTriggerResolution = {
552
+ status: "notFound";
678
553
  } | {
679
- kind: "oauth2";
680
- providerFromPublicConfig: OAuth2ProviderFromPublicConfig;
681
- scopes: ReadonlyArray<string>;
682
- scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
683
- clientIdFieldKey?: string;
684
- clientSecretFieldKey?: string;
554
+ status: "methodNotAllowed";
555
+ match: WebhookInvocationMatch;
685
556
  } | {
686
- kind: "oauth2";
687
- /**
688
- * Free-form provider identifier for telemetry, DB rows, and Better Auth provider naming.
689
- * Not used for any registry lookup — URLs come from {@link authorizeUrl} / {@link tokenUrl}.
690
- */
691
- providerId: string;
692
- /**
693
- * Authorization endpoint. May contain `{publicFieldKey}` placeholders that the runtime
694
- * substitutes from the credential's resolved public config (URL-encoded).
695
- * Example: `https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize`
696
- */
697
- authorizeUrl: string;
698
- /** Token endpoint. Same templating rules as {@link authorizeUrl}. */
699
- tokenUrl: string;
700
- /** Optional userinfo endpoint. Same templating rules as {@link authorizeUrl}. */
701
- userInfoUrl?: string;
702
- scopes: ReadonlyArray<string>;
703
- scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
704
- clientIdFieldKey?: string;
705
- clientSecretFieldKey?: string;
706
- }>;
707
- type CredentialAuthDefinition = CredentialOAuth2AuthDefinition;
708
- type CredentialAdvancedSectionPresentation = Readonly<{
709
- /** Collapsible section title (default: "Advanced"). */
710
- title?: string;
711
- /** Optional short helper text shown inside the section (above the fields). */
712
- description?: string;
713
- /** When true, the advanced section starts expanded. Default: false (collapsed). */
714
- defaultOpen?: boolean;
715
- }>;
716
- type CredentialTypeDefinition = Readonly<{
717
- typeId: CredentialTypeId;
718
- displayName: string;
719
- description?: string;
720
- publicFields?: ReadonlyArray<CredentialFieldSchema>;
721
- secretFields?: ReadonlyArray<CredentialFieldSchema>;
722
- /**
723
- * Optional labels for the collapsible block that contains every field with `visibility: "advanced"`.
724
- * If omitted, the UI still shows that block with defaults (title "Advanced", collapsed).
725
- */
726
- advancedSection?: CredentialAdvancedSectionPresentation;
727
- supportedSourceKinds?: ReadonlyArray<CredentialMaterialSourceKind>;
728
- auth?: CredentialAuthDefinition;
729
- }>;
730
- /**
731
- * JSON-shaped credential field bag (public config, resolved secret material, etc.).
732
- */
733
- type CredentialJsonRecord = Readonly<Record<string, unknown>>;
734
- /**
735
- * Persisted credential instance with typed `publicConfig`.
736
- * Hosts may specialize `secretRef` with a stricter union while remaining
737
- * assignable here for session/test callbacks.
738
- */
739
- type CredentialInstanceRecord<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
740
- instanceId: CredentialInstanceId;
741
- typeId: CredentialTypeId;
742
- displayName: string;
743
- sourceKind: CredentialMaterialSourceKind;
744
- publicConfig: TPublicConfig;
745
- secretRef: CredentialJsonRecord;
746
- tags: ReadonlyArray<string>;
747
- setupStatus: CredentialSetupStatus;
748
- createdAt: string;
749
- updatedAt: string;
750
- }>;
751
- /**
752
- * Arguments passed to `CredentialType.createSession` and `CredentialType.test`.
753
- * Declare `TPublicConfig` / `TMaterial` on `CredentialType` so implementations are checked
754
- * against your credential shapes (similar to `NodeExecutionContext.config` for nodes).
755
- */
756
- type CredentialSessionFactoryArgs<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
757
- instance: CredentialInstanceRecord<TPublicConfig>;
758
- material: TMaterial;
759
- publicConfig: TPublicConfig;
760
- }>;
761
- type CredentialSessionFactory<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<TSession>;
762
- type CredentialHealthTester<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<CredentialHealth>;
763
- /**
764
- * Full credential type implementation: `definition` (UI/schema), `createSession`, and `test`.
765
- * Use this at registration and config boundaries; `CredentialTypeDefinition` is only the schema slice.
766
- */
767
- type CredentialType<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = Readonly<{
768
- definition: CredentialTypeDefinition;
769
- createSession: CredentialSessionFactory<TPublicConfig, TMaterial, TSession>;
770
- test: CredentialHealthTester<TPublicConfig, TMaterial>;
771
- }>;
557
+ status: "ok";
558
+ match: WebhookInvocationMatch;
559
+ };
772
560
  /**
773
- * Credential type with unspecified generics used for `CodemationConfig.credentialTypes`, the host registry,
774
- * and anywhere a concrete `CredentialType<YourPublic, YourMaterial, YourSession>` is placed in a heterogeneous list.
775
- * Using `any` here avoids unsafe `as` casts while keeping typed `satisfies CredentialType<…>` definitions.
561
+ * Resolves webhook routes from workflow definitions (catalog-backed index, no registration at trigger setup).
776
562
  */
777
- type AnyCredentialType = CredentialType<any, any, unknown>;
778
- interface CredentialSessionService {
779
- getSession<TSession = unknown>(args: Readonly<{
563
+ interface WebhookTriggerMatcher {
564
+ match(args: {
565
+ endpointPath: string;
566
+ method: HttpMethod;
567
+ }): WebhookInvocationMatch | undefined;
568
+ lookup(endpointPath: string): WebhookInvocationMatch | undefined;
569
+ onEngineWorkflowsLoaded?(): void;
570
+ onEngineStopped?(): void;
571
+ /** Rebuild route index after activation changes without stopping the engine. */
572
+ reloadWebhookRoutes?(): void;
573
+ }
574
+ //#endregion
575
+ //#region src/contracts/runtimeTypes.d.ts
576
+ interface WorkflowRunnerService {
577
+ runById(args: {
780
578
  workflowId: WorkflowId;
781
- nodeId: NodeId;
782
- slotKey: string;
783
- }>): Promise<TSession>;
579
+ startAt?: NodeId;
580
+ items: Items;
581
+ parent?: ParentExecutionRef;
582
+ }): Promise<RunResult>;
583
+ }
584
+ interface WorkflowRunnerResolver {
585
+ resolve(): WorkflowRunnerService | undefined;
586
+ }
587
+ interface WorkflowRepository {
588
+ list(): ReadonlyArray<WorkflowDefinition>;
589
+ get(workflowId: WorkflowId): WorkflowDefinition | undefined;
784
590
  }
785
- interface CredentialTypeRegistry {
786
- listTypes(): ReadonlyArray<CredentialTypeDefinition>;
787
- getType(typeId: CredentialTypeId): CredentialTypeDefinition | undefined;
591
+ interface LiveWorkflowRepository extends WorkflowRepository {
592
+ setWorkflows(workflows: ReadonlyArray<WorkflowDefinition>): void;
788
593
  }
789
- declare class CredentialUnboundError extends Error {
790
- readonly bindingKey: CredentialBindingKey;
791
- readonly acceptedTypes: ReadonlyArray<CredentialTypeId>;
792
- constructor(bindingKey: CredentialBindingKey, acceptedTypes?: ReadonlyArray<CredentialTypeId>);
793
- private static createMessage;
594
+ interface NodeResolver {
595
+ resolve<T>(token: TypeToken<T>): T;
794
596
  }
795
- //#endregion
796
- //#region src/contracts/collectionTypes.d.ts
797
- /**
798
- * Represents a typed store for a single collection.
799
- * All rows include auto-managed id, created_at, and updated_at fields.
800
- */
801
- interface CollectionStore<TRow extends Record<string, unknown> = Record<string, unknown>> {
802
- /**
803
- * Insert a new row. id, created_at, and updated_at are auto-populated.
804
- */
805
- insert(row: TRow): Promise<TRow & {
806
- id: string;
807
- created_at: Date;
808
- updated_at: Date;
809
- }>;
810
- /**
811
- * Get a single row by id.
812
- */
813
- get(id: string): Promise<(TRow & {
814
- id: string;
815
- created_at: Date;
816
- updated_at: Date;
817
- }) | null>;
818
- /**
819
- * Find a single row matching the provided filter.
820
- */
821
- findOne(filter: Partial<TRow>): Promise<(TRow & {
822
- id: string;
823
- created_at: Date;
824
- updated_at: Date;
825
- }) | null>;
597
+ interface NodeExecutionStatePublisher {
598
+ markQueued(args: {
599
+ nodeId: NodeId;
600
+ activationId?: NodeActivationId;
601
+ inputsByPort?: NodeInputsByPort;
602
+ }): Promise<void>;
603
+ markRunning(args: {
604
+ nodeId: NodeId;
605
+ activationId?: NodeActivationId;
606
+ inputsByPort?: NodeInputsByPort;
607
+ }): Promise<void>;
608
+ markCompleted(args: {
609
+ nodeId: NodeId;
610
+ activationId?: NodeActivationId;
611
+ inputsByPort?: NodeInputsByPort;
612
+ outputs?: NodeOutputs;
613
+ }): Promise<void>;
614
+ markFailed(args: {
615
+ nodeId: NodeId;
616
+ activationId?: NodeActivationId;
617
+ inputsByPort?: NodeInputsByPort;
618
+ error: Error;
619
+ }): Promise<void>;
620
+ appendConnectionInvocation(args: ConnectionInvocationAppendArgs): Promise<void>;
826
621
  /**
827
- * List rows with optional pagination and filtering.
622
+ * Annotates the current snapshot for `nodeId` with the id of the child run spawned by a
623
+ * SubWorkflow invocation. Called from `SubWorkflowNode.execute` after `runById` resolves.
624
+ * The engine's subsequent `markCompleted` call preserves the value via `previous.childRunId`.
828
625
  */
829
- list(opts?: {
830
- limit?: number;
831
- offset?: number;
832
- where?: Partial<TRow>;
833
- }): Promise<{
834
- rows: ReadonlyArray<TRow & {
835
- id: string;
836
- created_at: Date;
837
- updated_at: Date;
838
- }>;
839
- total: number;
840
- }>;
626
+ setChildRunId?(args: {
627
+ nodeId: NodeId;
628
+ childRunId: RunId;
629
+ }): Promise<void>;
630
+ }
631
+ type BinaryBody = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array> | Uint8Array | ArrayBuffer;
632
+ interface BinaryStorageWriteRequest {
633
+ storageKey: string;
634
+ body: BinaryBody;
635
+ }
636
+ interface BinaryStorageWriteResult {
637
+ storageKey: string;
638
+ size: number;
639
+ sha256?: string;
640
+ }
641
+ interface BinaryStorageReadResult {
642
+ body: ReadableStream<Uint8Array>;
643
+ size?: number;
644
+ }
645
+ interface BinaryStorageStatResult {
646
+ exists: boolean;
647
+ size?: number;
648
+ }
649
+ interface BinaryStorage {
650
+ readonly driverName: string;
651
+ write(args: BinaryStorageWriteRequest): Promise<BinaryStorageWriteResult>;
652
+ openReadStream(storageKey: string): Promise<BinaryStorageReadResult | undefined>;
653
+ stat(storageKey: string): Promise<BinaryStorageStatResult>;
654
+ delete(storageKey: string): Promise<void>;
655
+ /** Deletes multiple objects in bulk. Keys are batched internally. */
656
+ deleteMany(storageKeys: ReadonlyArray<string>): Promise<void>;
657
+ /** Lists all keys sharing a common prefix. Returns keys in arbitrary order. */
658
+ listByPrefix(prefix: string): Promise<ReadonlyArray<string>>;
659
+ }
660
+ interface BinaryAttachmentCreateRequest {
661
+ name: string;
662
+ body: BinaryBody;
663
+ mimeType: string;
664
+ filename?: string;
665
+ previewKind?: BinaryAttachment["previewKind"];
666
+ }
667
+ interface NodeBinaryAttachmentService extends ExecutionBinaryService {
668
+ attach(args: BinaryAttachmentCreateRequest): Promise<BinaryAttachment>;
669
+ withAttachment<TJson>(item: Item<TJson>, name: string, attachment: BinaryAttachment): Item<TJson>;
670
+ }
671
+ interface ExecutionBinaryService {
672
+ forNode(args: {
673
+ nodeId: NodeId;
674
+ activationId: NodeActivationId;
675
+ }): NodeBinaryAttachmentService;
676
+ openReadStream(attachment: BinaryAttachment): Promise<BinaryStorageReadResult | undefined>;
677
+ }
678
+ interface ExecutionContext {
679
+ runId: RunId;
680
+ workflowId: WorkflowId;
681
+ parent?: ParentExecutionRef;
682
+ /** This run's subworkflow depth (0 = root). */
683
+ subworkflowDepth: number;
684
+ /** Effective activation budget cap for this run (after policy merge). */
685
+ engineMaxNodeActivations: number;
686
+ /** Effective subworkflow nesting cap for this run (after policy merge). */
687
+ engineMaxSubworkflowDepth: number;
688
+ now: () => Date;
689
+ data: RunDataSnapshot;
690
+ nodeState?: NodeExecutionStatePublisher;
691
+ telemetry: ExecutionTelemetry;
692
+ binary: ExecutionBinaryService;
693
+ getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
694
+ /** Per-item iteration id, set by {@link NodeExecutor} on the ctx passed into runnable `execute`. */
695
+ iterationId?: NodeIterationId;
696
+ /** Item index (0-based) within the current activation's batch; set alongside {@link iterationId}. */
697
+ itemIndex?: number;
698
+ /** When set, this ctx is executing inside a sub-agent triggered by the named parent invocation. */
699
+ parentInvocationId?: ConnectionInvocationId;
841
700
  /**
842
- * Update a row by id with partial data.
701
+ * Present iff the run was started by a TestSuiteOrchestrator. The {@link IsTestRunNode}
702
+ * branches on this; assertion-emitting nodes use it to decide whether to record results.
843
703
  */
844
- update(id: string, patch: Partial<TRow>): Promise<TRow & {
845
- id: string;
846
- created_at: Date;
847
- updated_at: Date;
848
- }>;
704
+ testContext?: RunTestContext;
849
705
  /**
850
- * Delete a row by id. Hard delete only (no soft delete).
706
+ * Collections registered in the codemation config, keyed by collection name.
851
707
  */
852
- delete(id: string): Promise<{
853
- deleted: boolean;
854
- }>;
855
- }
856
- /**
857
- * Runtime collections context: keyed by collection name.
858
- */
859
- type CollectionsContext = Readonly<Record<string, CollectionStore>>;
860
- //#endregion
861
- //#region src/contracts/CostTrackingTelemetryContract.d.ts
862
- type CostTrackingComponent = "chat" | "ocr" | "rag";
863
- declare const CostTrackingTelemetryMetricNames: {
864
- readonly usage: "codemation.cost.usage";
865
- readonly estimatedCost: "codemation.cost.estimated";
866
- };
867
- declare const CostTrackingTelemetryAttributeNames: {
868
- readonly component: "cost.component";
869
- readonly provider: "cost.provider";
870
- readonly operation: "cost.operation";
871
- readonly pricingKey: "cost.pricing_key";
872
- readonly usageUnit: "cost.usage_unit";
873
- readonly currency: "cost.currency";
874
- readonly currencyScale: "cost.currency_scale";
875
- readonly estimateKind: "cost.estimate_kind";
876
- };
877
- interface CostTrackingUsageRecord {
878
- readonly component: CostTrackingComponent;
879
- readonly provider: string;
880
- readonly operation: string;
881
- readonly pricingKey: string;
882
- readonly usageUnit: string;
883
- readonly quantity: number;
884
- readonly modelName?: string;
885
- readonly attributes?: TelemetryAttributes;
708
+ readonly collections?: CollectionsContext;
886
709
  }
887
- interface CostTrackingPriceQuote {
888
- readonly currency: string;
889
- readonly currencyScale: number;
890
- readonly estimatedAmountMinor: number;
891
- readonly estimateKind: "catalog";
710
+ interface ExecutionContextFactory {
711
+ create(args: {
712
+ runId: RunId;
713
+ workflowId: WorkflowId;
714
+ parent?: ParentExecutionRef;
715
+ policySnapshot?: PersistedRunPolicySnapshot;
716
+ subworkflowDepth: number;
717
+ engineMaxNodeActivations: number;
718
+ engineMaxSubworkflowDepth: number;
719
+ data: RunDataSnapshot;
720
+ nodeState?: NodeExecutionStatePublisher;
721
+ telemetry?: ExecutionTelemetry;
722
+ getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
723
+ testContext?: RunTestContext;
724
+ }): ExecutionContext;
892
725
  }
893
- interface CostTrackingTelemetry {
894
- captureUsage(args: CostTrackingUsageRecord): Promise<CostTrackingPriceQuote | undefined>;
895
- forScope(scope: TelemetryScope): CostTrackingTelemetry;
726
+ interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase> extends ExecutionContext {
727
+ nodeId: NodeId;
728
+ activationId: NodeActivationId;
729
+ config: TConfig;
730
+ telemetry: NodeExecutionTelemetry;
731
+ binary: NodeBinaryAttachmentService;
896
732
  }
897
- interface CostTrackingTelemetryFactory {
898
- create(args: Readonly<{
899
- telemetry: ExecutionTelemetry;
900
- }>): CostTrackingTelemetry;
733
+ interface PollingTriggerHandle {
734
+ /**
735
+ * Start the polling loop. The runtime registers its own cleanup handle so callers do not need to
736
+ * call {@link TriggerSetupContext.registerCleanup} for the loop.
737
+ * @returns The state returned by the first cycle (or `undefined` when the overlap guard fired).
738
+ */
739
+ start<TState, TItem>(args: {
740
+ intervalMs: number;
741
+ seedState?: TState;
742
+ runCycle: (cycleCtx: {
743
+ previousState: TState | undefined;
744
+ signal: AbortSignal;
745
+ }) => Promise<{
746
+ items: Items<TItem>;
747
+ nextState: TState;
748
+ }>;
749
+ }): Promise<TState | undefined>;
750
+ /** Convenience dedup-window helper. */
751
+ readonly dedup: PollingTriggerDedupWindow;
901
752
  }
902
- //#endregion
903
- //#region src/contracts/NoOpTelemetryArtifactReference.d.ts
904
- declare class NoOpTelemetryArtifactReference {
905
- static readonly value: TelemetryArtifactReference;
753
+ interface TriggerSetupContext<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>, TSetupState$1 extends JsonValue | undefined = TriggerNodeSetupState<TConfig>> extends ExecutionContext {
754
+ trigger: TriggerInstanceId;
755
+ config: TConfig;
756
+ previousState: TSetupState$1;
757
+ registerCleanup(cleanup: TriggerCleanupHandle): void;
758
+ emit(items: Items): Promise<void>;
759
+ /** Generic polling-trigger surface. Pre-binds trigger id, emit, and registerCleanup. */
760
+ readonly polling: PollingTriggerHandle;
906
761
  }
907
- //#endregion
908
- //#region src/contracts/NoOpTelemetrySpanScope.d.ts
909
- declare class NoOpTelemetrySpanScope {
910
- static readonly value: TelemetrySpanScope;
911
- /** Internal: the shared no-op {@link NodeExecutionTelemetry} that {@link NoOpNodeExecutionTelemetry} re-exposes. */
912
- static readonly nodeExecutionTelemetryValue: NodeExecutionTelemetry;
762
+ interface TriggerTestItemsContext<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>, TSetupState$1 extends JsonValue | undefined = TriggerNodeSetupState<TConfig>> extends ExecutionContext {
763
+ trigger: TriggerInstanceId;
764
+ nodeId: NodeId;
765
+ config: TConfig;
766
+ previousState: TSetupState$1;
913
767
  }
914
- //#endregion
915
- //#region src/contracts/NoOpNodeExecutionTelemetry.d.ts
916
- declare class NoOpNodeExecutionTelemetry {
917
- static readonly value: NodeExecutionTelemetry;
768
+ /**
769
+ * Trigger setup state is intentionally engine-owned so future ownership and
770
+ * leader-election metadata can be coordinated centrally rather than pushed into
771
+ * package-level setup code.
772
+ */
773
+ interface PersistedTriggerSetupState<TState extends JsonValue | undefined = JsonValue | undefined> {
774
+ trigger: TriggerInstanceId;
775
+ updatedAt: string;
776
+ state: TState;
918
777
  }
919
- //#endregion
920
- //#region src/contracts/NoOpExecutionTelemetry.d.ts
921
- declare class NoOpExecutionTelemetry {
922
- static readonly value: ExecutionTelemetry;
778
+ interface TriggerSetupStateRepository {
779
+ load(trigger: TriggerInstanceId): Promise<PersistedTriggerSetupState | undefined>;
780
+ save(state: PersistedTriggerSetupState): Promise<void>;
781
+ delete(trigger: TriggerInstanceId): Promise<void>;
923
782
  }
924
- //#endregion
925
- //#region src/contracts/NoOpExecutionTelemetryFactory.d.ts
926
- declare class NoOpExecutionTelemetryFactory implements ExecutionTelemetryFactory {
927
- create(_: Readonly<{
928
- runId: RunId;
929
- workflowId: WorkflowId;
930
- parent?: ParentExecutionRef;
931
- policySnapshot?: PersistedRunPolicySnapshot;
932
- }>): ExecutionTelemetry;
783
+ interface TriggerCleanupHandle {
784
+ stop(): Promise<void> | void;
933
785
  }
934
- //#endregion
935
- //#region src/contracts/CodemationTelemetryAttributeNames.d.ts
936
- declare class CodemationTelemetryAttributeNames {
937
- static readonly workflowId = "codemation.workflow.id";
938
- static readonly runId = "codemation.run.id";
939
- static readonly nodeId = "codemation.node.id";
940
- static readonly activationId = "codemation.activation.id";
941
- static readonly nodeType = "codemation.node.type";
942
- static readonly nodeRole = "codemation.node.role";
943
- static readonly workflowFolder = "codemation.workflow.folder";
944
- static readonly connectionInvocationId = "codemation.connection.invocation_id";
945
- static readonly toolName = "codemation.tool.name";
946
- static readonly traceParentRunId = "codemation.parent.run.id";
947
- /** Per-item iteration that emitted this span/metric. Set on spans recorded inside a runnable per-item loop. */
948
- static readonly iterationId = "codemation.iteration.id";
949
- /** Item index (0-based) of the iteration. */
950
- static readonly iterationIndex = "codemation.iteration.index";
951
- /** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
952
- static readonly parentInvocationId = "codemation.parent.invocation_id";
786
+ interface EngineHost {
787
+ credentialSessions: CredentialSessionService;
788
+ workflows?: WorkflowRunnerService;
953
789
  }
954
- //#endregion
955
- //#region src/contracts/GenAiTelemetryAttributeNames.d.ts
956
- declare class GenAiTelemetryAttributeNames {
957
- static readonly operationName = "gen_ai.operation.name";
958
- static readonly requestModel = "gen_ai.request.model";
959
- static readonly usageInputTokens = "gen_ai.usage.input_tokens";
960
- static readonly usageOutputTokens = "gen_ai.usage.output_tokens";
961
- static readonly usageTotalTokens = "gen_ai.usage.total_tokens";
962
- static readonly usageCacheReadInputTokens = "gen_ai.usage.cache_read.input_tokens";
963
- static readonly usageCacheCreationInputTokens = "gen_ai.usage.cache_creation.input_tokens";
964
- static readonly usageReasoningTokens = "codemation.gen_ai.usage.reasoning_tokens";
790
+ /**
791
+ * Per-item runnable node: return JSON, an array to fan-out on `main`, an explicit `Item`, or {@link emitPorts}
792
+ * for multi-port emission. Engine applies `inputSchema.parse(item.json)` and passes the result as `args.input`
793
+ * (wire `item.json` is unchanged). Transform helpers may opt into binary preservation, while routers and
794
+ * pass-through nodes should return explicit items when they need to preserve full item state.
795
+ */
796
+ interface RunnableNodeExecuteArgs<TConfig extends RunnableNodeConfig<any, any> = RunnableNodeConfig<any, any>, TInputJson$1 = unknown> {
797
+ readonly input: TInputJson$1;
798
+ readonly item: Item;
799
+ readonly itemIndex: number;
800
+ readonly items: Items;
801
+ readonly ctx: NodeExecutionContext<TConfig>;
965
802
  }
966
- //#endregion
967
- //#region src/contracts/CodemationTelemetryMetricNames.d.ts
968
- declare class CodemationTelemetryMetricNames {
969
- static readonly agentTurns = "codemation.ai.turns";
970
- static readonly agentToolCalls = "codemation.ai.tool_calls";
971
- static readonly gmailMessagesEmitted = "codemation.gmail.messages_emitted";
972
- static readonly gmailAttachments = "codemation.gmail.attachments";
973
- static readonly gmailAttachmentBytes = "codemation.gmail.attachment_bytes";
803
+ interface RunnableNode<TConfig extends RunnableNodeConfig<any, any> = RunnableNodeConfig<any, any>, TInputJson$1 = unknown, _TOutputJson = unknown> {
804
+ readonly kind: "node";
805
+ /**
806
+ * Declared output ports (e.g. `["main"]`).
807
+ *
808
+ * Prefer describing dynamic router ports (Switch) and fixed multi-ports (If true/false)
809
+ * via {@link NodeConfigBase.declaredOutputPorts}. Engine defaults to `["main"]` when omitted.
810
+ */
811
+ readonly outputPorts?: ReadonlyArray<OutputPortKey>;
812
+ /** When omitted, engine uses {@link RunnableNodeConfig.inputSchema} or `z.unknown()`. */
813
+ readonly inputSchema?: ZodType<TInputJson$1>;
814
+ execute(args: RunnableNodeExecuteArgs<TConfig, TInputJson$1>): Promise<unknown> | unknown;
974
815
  }
975
- //#endregion
976
- //#region src/contracts/telemetryTypes.d.ts
977
- type TelemetryAttributePrimitive = string | number | boolean | null;
978
- interface TelemetryAttributes {
979
- readonly [key: string]: TelemetryAttributePrimitive | undefined;
816
+ /** @deprecated Use {@link RunnableNode} */
817
+ type ItemNode<TConfig extends RunnableNodeConfig<any, any> = RunnableNodeConfig<any, any>, TInputJson$1 = unknown, TOutputJson$1 = unknown> = RunnableNode<TConfig, TInputJson$1, TOutputJson$1>;
818
+ interface MultiInputNode<TConfig extends NodeConfigBase = NodeConfigBase> {
819
+ kind: "node";
820
+ /**
821
+ * Declared output ports (typically `["main"]`).
822
+ *
823
+ * Prefer describing ports for authoring/canvas via {@link NodeConfigBase.declaredOutputPorts}.
824
+ * Engine defaults to `["main"]` when omitted.
825
+ */
826
+ outputPorts?: ReadonlyArray<OutputPortKey>;
827
+ executeMulti(inputsByPort: NodeInputsByPort, ctx: NodeExecutionContext<TConfig>): Promise<NodeOutputs>;
980
828
  }
981
- interface TelemetryMetricRecord {
982
- readonly name: string;
983
- readonly value: number;
984
- readonly unit?: string;
985
- readonly attributes?: TelemetryAttributes;
829
+ type TriggerSetupStateFor<TConfig extends TriggerNodeConfig<any, any>> = TriggerNodeSetupState<TConfig>;
830
+ interface TriggerNode<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>> {
831
+ kind: "trigger";
832
+ outputPorts: readonly ["main"];
833
+ setup(ctx: TriggerSetupContext<TConfig>): Promise<TriggerSetupStateFor<TConfig>>;
834
+ execute(items: Items, ctx: NodeExecutionContext<TConfig>): Promise<NodeOutputs>;
986
835
  }
987
- interface TelemetrySpanEventRecord {
988
- readonly name: string;
989
- readonly occurredAt?: Date;
990
- readonly attributes?: TelemetryAttributes;
836
+ interface TestableTriggerNode<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>> extends TriggerNode<TConfig> {
837
+ getTestItems(ctx: TriggerTestItemsContext<TConfig>): Promise<Items>;
991
838
  }
992
- interface TelemetryArtifactAttachment {
993
- readonly kind: string;
994
- readonly contentType: string;
995
- readonly previewText?: string;
996
- readonly previewJson?: JsonValue;
997
- readonly payloadText?: string;
998
- readonly payloadJson?: JsonValue;
999
- readonly bytes?: number;
1000
- readonly truncated?: boolean;
1001
- readonly expiresAt?: Date;
839
+ type ExecutableTriggerNode<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>> = TriggerNode<TConfig>;
840
+ interface NodeExecutionRequest {
841
+ runId: RunId;
842
+ activationId: NodeActivationId;
843
+ workflowId: WorkflowId;
844
+ nodeId: NodeId;
845
+ input: Items;
846
+ parent?: ParentExecutionRef;
847
+ queue?: string;
848
+ executionOptions?: RunExecutionOptions;
1002
849
  }
1003
- interface TelemetryArtifactReference {
1004
- readonly artifactId: string;
1005
- readonly traceId?: string;
1006
- readonly spanId?: string;
850
+ interface NodeExecutionScheduler {
851
+ enqueue(request: NodeExecutionRequest): Promise<{
852
+ receiptId: string;
853
+ }>;
854
+ cancel?(receiptId: string): Promise<void>;
1007
855
  }
1008
- interface TelemetrySpanEnd {
1009
- readonly status?: "ok" | "error";
1010
- readonly statusMessage?: string;
1011
- readonly endedAt?: Date;
1012
- readonly attributes?: TelemetryAttributes;
856
+ interface NodeExecutionRequestHandler {
857
+ handleNodeExecutionRequest(request: NodeExecutionRequest): Promise<void>;
1013
858
  }
1014
- interface TelemetryChildSpanStart {
1015
- readonly name: string;
1016
- readonly kind?: "internal" | "client";
1017
- readonly startedAt?: Date;
1018
- readonly attributes?: TelemetryAttributes;
859
+ type NodeActivationRequestBase = Readonly<{
860
+ runId: RunId;
861
+ activationId: NodeActivationId;
862
+ workflowId: WorkflowId;
863
+ nodeId: NodeId;
864
+ parent?: ParentExecutionRef;
865
+ executionOptions?: RunExecutionOptions;
866
+ batchId?: string;
867
+ ctx: NodeExecutionContext;
868
+ }>;
869
+ type NodeActivationRequest = (NodeActivationRequestBase & Readonly<{
870
+ kind: "single";
871
+ input: Items;
872
+ }>) | (NodeActivationRequestBase & Readonly<{
873
+ kind: "multi";
874
+ inputsByPort: NodeInputsByPort;
875
+ }>);
876
+ interface NodeActivationReceipt {
877
+ receiptId: string;
878
+ mode?: "local" | "worker";
879
+ queue?: string;
1019
880
  }
1020
- interface TelemetryScope {
1021
- readonly traceId?: string;
1022
- readonly spanId?: string;
1023
- readonly costTracking?: CostTrackingTelemetry;
1024
- addSpanEvent(args: TelemetrySpanEventRecord): Promise<void> | void;
1025
- recordMetric(args: TelemetryMetricRecord): Promise<void> | void;
1026
- attachArtifact(args: TelemetryArtifactAttachment): Promise<TelemetryArtifactReference> | TelemetryArtifactReference;
881
+ interface PreparedNodeActivationDispatch {
882
+ readonly receipt: NodeActivationReceipt;
883
+ dispatch(): Promise<void>;
1027
884
  }
1028
- interface TelemetrySpanScope extends TelemetryScope {
1029
- readonly traceId: string;
1030
- readonly spanId: string;
1031
- end(args?: TelemetrySpanEnd): Promise<void> | void;
1032
- /**
1033
- * Lift this span into a {@link NodeExecutionTelemetry} scoped to a different (nodeId, activationId).
1034
- * Children created via the returned telemetry's `startChildSpan` get this span as their parent.
1035
- *
1036
- * Used at the sub-agent boundary so that nested runtime telemetry parents under the agent.tool.call
1037
- * span instead of the orchestrator's node-level span.
1038
- */
1039
- asNodeTelemetry(args: Readonly<{
885
+ interface NodeActivationContinuation {
886
+ markNodeRunning(args: {
887
+ runId: RunId;
888
+ activationId: NodeActivationId;
1040
889
  nodeId: NodeId;
890
+ inputsByPort: NodeInputsByPort;
891
+ }): Promise<void>;
892
+ resumeFromNodeResult(args: {
893
+ runId: RunId;
1041
894
  activationId: NodeActivationId;
1042
- }>): NodeExecutionTelemetry;
1043
- }
1044
- interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
1045
- startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
1046
- }
1047
- interface ExecutionTelemetry extends TelemetryScope {
1048
- readonly traceId: string;
1049
- readonly spanId: string;
1050
- forNode(args: Readonly<{
1051
895
  nodeId: NodeId;
896
+ outputs: NodeOutputs;
897
+ }): Promise<RunResult>;
898
+ resumeFromNodeError(args: {
899
+ runId: RunId;
1052
900
  activationId: NodeActivationId;
1053
- }>): NodeExecutionTelemetry;
901
+ nodeId: NodeId;
902
+ error: Error;
903
+ }): Promise<RunResult>;
1054
904
  }
1055
- interface ExecutionTelemetryFactory {
1056
- create(args: Readonly<{
1057
- runId: RunId;
1058
- workflowId: WorkflowId;
1059
- parent?: ParentExecutionRef;
1060
- policySnapshot?: PersistedRunPolicySnapshot;
1061
- }>): ExecutionTelemetry;
905
+ interface NodeActivationScheduler {
906
+ setContinuation?(continuation: NodeActivationContinuation): void;
907
+ prepareDispatch(request: NodeActivationRequest): Promise<PreparedNodeActivationDispatch>;
908
+ cancel?(receiptId: string): Promise<void>;
1062
909
  }
1063
- //#endregion
1064
- //#region src/contracts/workflowActivationPolicy.d.ts
1065
- /**
1066
- * Host-controlled policy: when false, trigger {@link TriggerNode} setup is skipped and webhook routes
1067
- * for that workflow are not registered (see engine trigger runtime + webhook matcher).
1068
- */
1069
- interface WorkflowActivationPolicy {
1070
- isActive(workflowId: WorkflowId): boolean;
910
+ interface WorkflowNodeInstanceFactory {
911
+ createNodes(workflow: WorkflowDefinition): ReadonlyMap<NodeId, unknown>;
912
+ createByType(type: TypeToken<unknown>): unknown;
1071
913
  }
1072
- /** Default for tests and harnesses: every workflow is treated as active (legacy behavior). */
1073
- declare class AllWorkflowsActiveWorkflowActivationPolicy implements WorkflowActivationPolicy {
1074
- isActive(_workflowId: WorkflowId): boolean;
914
+ interface NodeExecutor {
915
+ execute(request: NodeActivationRequest): Promise<NodeOutputs>;
1075
916
  }
1076
- //#endregion
1077
- //#region src/contracts/webhookTypes.d.ts
1078
- type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
1079
- interface WebhookControlSignal {
1080
- readonly __webhookControl: true;
1081
- readonly kind: "respondNow" | "respondNowAndContinue";
1082
- readonly responseItems: Items;
1083
- readonly continueItems?: Items;
917
+ interface WorkflowSnapshotFactory {
918
+ create(workflow: WorkflowDefinition): PersistedWorkflowSnapshot;
1084
919
  }
1085
- interface WebhookTriggerRoutingDiagnostics {
1086
- warn(message: string): void;
1087
- /** Inactive workflows omitted from the webhook route index (optional; host should wire for clarity at boot/reload). */
1088
- info?(message: string): void;
920
+ interface WorkflowSnapshotResolver {
921
+ resolve(args: {
922
+ workflowId: WorkflowId;
923
+ workflowSnapshot?: PersistedWorkflowSnapshot;
924
+ }): WorkflowDefinition | undefined;
1089
925
  }
1090
- interface TriggerInstanceId {
1091
- workflowId: WorkflowId;
1092
- nodeId: NodeId;
926
+ /** Optional host wiring for trigger lifecycle logs (boot skip + activation sync). */
927
+ interface TriggerRuntimeDiagnostics {
928
+ info(message: string): void;
929
+ warn(message: string): void;
1093
930
  }
1094
- /** Match for an incoming HTTP request: user-defined URL segment + workflow trigger node. */
1095
- interface WebhookInvocationMatch {
1096
- /** Same value as the webhook trigger's configured endpoint key (URL segment under the webhook base path). */
1097
- endpointPath: string;
1098
- workflowId: WorkflowId;
1099
- nodeId: NodeId;
1100
- methods: ReadonlyArray<HttpMethod>;
1101
- parseJsonBody?: (body: unknown) => unknown;
931
+ interface EngineDeps {
932
+ credentialSessions: CredentialSessionService;
933
+ liveWorkflowRepository: LiveWorkflowRepository;
934
+ workflowRepository: WorkflowRepository;
935
+ /** When {@link AllWorkflowsActiveWorkflowActivationPolicy}, all workflows behave as active (tests). */
936
+ workflowActivationPolicy: WorkflowActivationPolicy;
937
+ nodeResolver: NodeResolver;
938
+ triggerSetupStateRepository: TriggerSetupStateRepository;
939
+ webhookTriggerMatcher: WebhookTriggerMatcher;
940
+ runIdFactory: RunIdFactory;
941
+ activationIdFactory: ActivationIdFactory;
942
+ workflowExecutionRepository: WorkflowExecutionRepository;
943
+ activationScheduler: NodeActivationScheduler;
944
+ runDataFactory: RunDataFactory;
945
+ executionContextFactory: ExecutionContextFactory;
946
+ executionTelemetryFactory?: ExecutionTelemetryFactory;
947
+ nodeExecutor: NodeExecutor;
948
+ eventBus?: RunEventBus;
949
+ tokenRegistry: PersistedWorkflowTokenRegistryLike;
950
+ workflowNodeInstanceFactory: WorkflowNodeInstanceFactory;
951
+ /** Defaults for prune/storage snapshot when workflow omits explicit policy fields. */
952
+ workflowPolicyRuntimeDefaults?: WorkflowPolicyRuntimeDefaults;
953
+ /** When set, logs inactive-workflow skips at boot and trigger start/stop on activation changes. */
954
+ triggerRuntimeDiagnostics?: TriggerRuntimeDiagnostics;
955
+ /** When set, the polling-trigger runtime uses this logger for cycle info/debug/error. */
956
+ pollingTriggerLogger?: PollingTriggerLogger;
1102
957
  }
1103
- /** Result of resolving an HTTP method + endpoint path against the catalog webhook index (404 vs 405 vs match). */
1104
- type WebhookTriggerResolution = {
1105
- status: "notFound";
1106
- } | {
1107
- status: "methodNotAllowed";
1108
- match: WebhookInvocationMatch;
1109
- } | {
1110
- status: "ok";
1111
- match: WebhookInvocationMatch;
1112
- };
958
+ //#endregion
959
+ //#region src/contracts/retryPolicySpec.types.d.ts
1113
960
  /**
1114
- * Resolves webhook routes from workflow definitions (catalog-backed index, no registration at trigger setup).
961
+ * In-process retry policy for runnable nodes. Serialized configs use the same
962
+ * `kind` discriminator (`JSON.stringify` / persisted workflows).
963
+ *
964
+ * `maxAttempts` is the total number of tries including the first (e.g. 3 means up to 2 delays after failures).
1115
965
  */
1116
- interface WebhookTriggerMatcher {
1117
- match(args: {
1118
- endpointPath: string;
1119
- method: HttpMethod;
1120
- }): WebhookInvocationMatch | undefined;
1121
- lookup(endpointPath: string): WebhookInvocationMatch | undefined;
1122
- onEngineWorkflowsLoaded?(): void;
1123
- onEngineStopped?(): void;
1124
- /** Rebuild route index after activation changes without stopping the engine. */
1125
- reloadWebhookRoutes?(): void;
1126
- }
1127
- //#endregion
1128
- //#region src/contracts/runtimeTypes.d.ts
1129
- interface WorkflowRunnerService {
1130
- runById(args: {
1131
- workflowId: WorkflowId;
1132
- startAt?: NodeId;
1133
- items: Items;
1134
- parent?: ParentExecutionRef;
1135
- }): Promise<RunResult>;
1136
- }
1137
- interface WorkflowRunnerResolver {
1138
- resolve(): WorkflowRunnerService | undefined;
966
+ type RetryPolicySpec = NoneRetryPolicySpec | FixedRetryPolicySpec | ExponentialRetryPolicySpec;
967
+ interface NoneRetryPolicySpec {
968
+ readonly kind: "none";
1139
969
  }
1140
- interface WorkflowRepository {
1141
- list(): ReadonlyArray<WorkflowDefinition>;
1142
- get(workflowId: WorkflowId): WorkflowDefinition | undefined;
970
+ interface FixedRetryPolicySpec {
971
+ readonly kind: "fixed";
972
+ /** Total attempts including the first execution. Must be >= 1. */
973
+ readonly maxAttempts: number;
974
+ readonly delayMs: number;
1143
975
  }
1144
- interface LiveWorkflowRepository extends WorkflowRepository {
1145
- setWorkflows(workflows: ReadonlyArray<WorkflowDefinition>): void;
976
+ interface ExponentialRetryPolicySpec {
977
+ readonly kind: "exponential";
978
+ /** Total attempts including the first execution. Must be >= 1. */
979
+ readonly maxAttempts: number;
980
+ readonly initialDelayMs: number;
981
+ readonly multiplier: number;
982
+ readonly maxDelayMs?: number;
983
+ /** When true, each delay is multiplied by a random factor in [1, 1.2). */
984
+ readonly jitter?: boolean;
1146
985
  }
1147
- interface NodeResolver {
1148
- resolve<T>(token: TypeToken<T>): T;
986
+ //#endregion
987
+ //#region src/contracts/workflowTypes.d.ts
988
+ type NodeIdRef<TJson = unknown> = NodeId & Readonly<{
989
+ __codemationNodeJson?: TJson;
990
+ }>;
991
+ type NodeKind = "trigger" | "node";
992
+ type JsonPrimitive = string | number | boolean | null;
993
+ interface JsonObject {
994
+ readonly [key: string]: JsonValue;
1149
995
  }
1150
- interface NodeExecutionStatePublisher {
1151
- markQueued(args: {
1152
- nodeId: NodeId;
1153
- activationId?: NodeActivationId;
1154
- inputsByPort?: NodeInputsByPort;
1155
- }): Promise<void>;
1156
- markRunning(args: {
1157
- nodeId: NodeId;
1158
- activationId?: NodeActivationId;
1159
- inputsByPort?: NodeInputsByPort;
1160
- }): Promise<void>;
1161
- markCompleted(args: {
996
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
997
+ type JsonArray = ReadonlyArray<JsonValue>;
998
+ /** JSON value that is not a top-level array (nested arrays inside objects are allowed). */
999
+ type JsonNonArray = JsonPrimitive | JsonObject;
1000
+ interface Edge {
1001
+ from: {
1162
1002
  nodeId: NodeId;
1163
- activationId?: NodeActivationId;
1164
- inputsByPort?: NodeInputsByPort;
1165
- outputs?: NodeOutputs;
1166
- }): Promise<void>;
1167
- markFailed(args: {
1003
+ output: OutputPortKey;
1004
+ };
1005
+ to: {
1168
1006
  nodeId: NodeId;
1169
- activationId?: NodeActivationId;
1170
- inputsByPort?: NodeInputsByPort;
1171
- error: Error;
1172
- }): Promise<void>;
1173
- appendConnectionInvocation(args: ConnectionInvocationAppendArgs): Promise<void>;
1174
- }
1175
- type BinaryBody = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array> | Uint8Array | ArrayBuffer;
1176
- interface BinaryStorageWriteRequest {
1177
- storageKey: string;
1178
- body: BinaryBody;
1179
- }
1180
- interface BinaryStorageWriteResult {
1181
- storageKey: string;
1182
- size: number;
1183
- sha256?: string;
1184
- }
1185
- interface BinaryStorageReadResult {
1186
- body: ReadableStream<Uint8Array>;
1187
- size?: number;
1188
- }
1189
- interface BinaryStorageStatResult {
1190
- exists: boolean;
1191
- size?: number;
1007
+ input: InputPortKey;
1008
+ };
1192
1009
  }
1193
- interface BinaryStorage {
1194
- readonly driverName: string;
1195
- write(args: BinaryStorageWriteRequest): Promise<BinaryStorageWriteResult>;
1196
- openReadStream(storageKey: string): Promise<BinaryStorageReadResult | undefined>;
1197
- stat(storageKey: string): Promise<BinaryStorageStatResult>;
1198
- delete(storageKey: string): Promise<void>;
1010
+ /**
1011
+ * Named connection from a parent node to child nodes that exist in {@link WorkflowDefinition.nodes}
1012
+ * but are not traversed by the main execution graph. Parents are commonly executable nodes, but may
1013
+ * also be connection-owned nodes for recursive agent attachments.
1014
+ */
1015
+ interface WorkflowNodeConnection {
1016
+ readonly parentNodeId: NodeId;
1017
+ readonly connectionName: NodeConnectionName;
1018
+ readonly childNodeIds: ReadonlyArray<NodeId>;
1199
1019
  }
1200
- interface BinaryAttachmentCreateRequest {
1020
+ interface WorkflowDefinition {
1021
+ id: WorkflowId;
1201
1022
  name: string;
1202
- body: BinaryBody;
1203
- mimeType: string;
1204
- filename?: string;
1205
- previewKind?: BinaryAttachment["previewKind"];
1206
- }
1207
- interface NodeBinaryAttachmentService extends ExecutionBinaryService {
1208
- attach(args: BinaryAttachmentCreateRequest): Promise<BinaryAttachment>;
1209
- withAttachment<TJson>(item: Item<TJson>, name: string, attachment: BinaryAttachment): Item<TJson>;
1023
+ nodes: NodeDefinition[];
1024
+ edges: Edge[];
1025
+ /**
1026
+ * Optional metadata: which nodes are connection-owned children (e.g. AI agent `llm` / `tools` slots).
1027
+ * When omitted, all nodes in {@link nodes} are treated as executable for topology.
1028
+ */
1029
+ readonly connections?: ReadonlyArray<WorkflowNodeConnection>;
1030
+ /** Directory + file-stem path under a workflow discovery root (for UI grouping only). */
1031
+ discoveryPathSegments?: readonly string[];
1032
+ /** Retention for run JSON and binaries (seconds). Host/env may supply defaults when omitted. */
1033
+ readonly prunePolicy?: WorkflowPrunePolicySpec;
1034
+ /** Whether to keep run data after completion. Host/env may supply defaults when omitted. */
1035
+ readonly storagePolicy?: WorkflowStoragePolicySpec;
1036
+ /** Invoked after a node fails permanently (retries exhausted) and node error handler did not recover. */
1037
+ readonly workflowErrorHandler?: WorkflowErrorHandlerSpec;
1210
1038
  }
1211
- interface ExecutionBinaryService {
1212
- forNode(args: {
1039
+ interface WorkflowGraph {
1040
+ next(nodeId: NodeId, output: OutputPortKey): ReadonlyArray<Readonly<{
1213
1041
  nodeId: NodeId;
1214
- activationId: NodeActivationId;
1215
- }): NodeBinaryAttachmentService;
1216
- openReadStream(attachment: BinaryAttachment): Promise<BinaryStorageReadResult | undefined>;
1042
+ input: InputPortKey;
1043
+ }>>;
1217
1044
  }
1218
- interface ExecutionContext {
1219
- runId: RunId;
1220
- workflowId: WorkflowId;
1221
- parent?: ParentExecutionRef;
1222
- /** This run's subworkflow depth (0 = root). */
1223
- subworkflowDepth: number;
1224
- /** Effective activation budget cap for this run (after policy merge). */
1225
- engineMaxNodeActivations: number;
1226
- /** Effective subworkflow nesting cap for this run (after policy merge). */
1227
- engineMaxSubworkflowDepth: number;
1228
- now: () => Date;
1229
- data: RunDataSnapshot;
1230
- nodeState?: NodeExecutionStatePublisher;
1231
- telemetry: ExecutionTelemetry;
1232
- binary: ExecutionBinaryService;
1233
- getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
1234
- /** Per-item iteration id, set by {@link NodeExecutor} on the ctx passed into runnable `execute`. */
1235
- iterationId?: NodeIterationId;
1236
- /** Item index (0-based) within the current activation's batch; set alongside {@link iterationId}. */
1237
- itemIndex?: number;
1238
- /** When set, this ctx is executing inside a sub-agent triggered by the named parent invocation. */
1239
- parentInvocationId?: ConnectionInvocationId;
1045
+ interface WorkflowGraphFactory {
1046
+ create(def: WorkflowDefinition): WorkflowGraph;
1047
+ }
1048
+ interface NodeConfigBase {
1049
+ readonly kind: NodeKind;
1050
+ readonly type: TypeToken<unknown>;
1051
+ readonly name?: string;
1052
+ readonly id?: NodeId;
1053
+ readonly icon?: string;
1054
+ readonly execution?: Readonly<{
1055
+ hint?: "local" | "worker";
1056
+ queue?: string;
1057
+ }>;
1058
+ /** In-process execute retries (runnable nodes). Triggers typically omit this. */
1059
+ readonly retryPolicy?: RetryPolicySpec;
1060
+ /** Recover from execute failures; return outputs to continue, or rethrow to fail the node. */
1061
+ readonly nodeErrorHandler?: NodeErrorHandlerSpec;
1240
1062
  /**
1241
- * Present iff the run was started by a TestSuiteOrchestrator. The {@link IsTestRunNode}
1242
- * branches on this; assertion-emitting nodes use it to decide whether to record results.
1063
+ * When true, edges carrying zero items on an output port still schedule single-input downstream nodes.
1064
+ * Decided from the **source** node that produced the (empty) output. Default (false/undefined): empty
1065
+ * main batches skip downstream execution and propagate the empty path.
1243
1066
  */
1244
- testContext?: RunTestContext;
1067
+ readonly continueWhenEmptyOutput?: boolean;
1245
1068
  /**
1246
- * Collections registered in the codemation config, keyed by collection name.
1069
+ * Declared I/O port names for canvas authoring (unioned with ports inferred from edges).
1070
+ * Use for dynamic routers (Switch) and future error ports.
1247
1071
  */
1248
- readonly collections?: CollectionsContext;
1249
- }
1250
- interface ExecutionContextFactory {
1251
- create(args: {
1252
- runId: RunId;
1253
- workflowId: WorkflowId;
1254
- parent?: ParentExecutionRef;
1255
- policySnapshot?: PersistedRunPolicySnapshot;
1256
- subworkflowDepth: number;
1257
- engineMaxNodeActivations: number;
1258
- engineMaxSubworkflowDepth: number;
1259
- data: RunDataSnapshot;
1260
- nodeState?: NodeExecutionStatePublisher;
1261
- telemetry?: ExecutionTelemetry;
1262
- getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
1263
- testContext?: RunTestContext;
1264
- }): ExecutionContext;
1265
- }
1266
- interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase> extends ExecutionContext {
1267
- nodeId: NodeId;
1268
- activationId: NodeActivationId;
1269
- config: TConfig;
1270
- telemetry: NodeExecutionTelemetry;
1271
- binary: NodeBinaryAttachmentService;
1272
- }
1273
- interface PollingTriggerHandle {
1072
+ readonly declaredOutputPorts?: ReadonlyArray<OutputPortKey>;
1073
+ readonly declaredInputPorts?: ReadonlyArray<InputPortKey>;
1074
+ getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;
1274
1075
  /**
1275
- * Start the polling loop. The runtime registers its own cleanup handle so callers do not need to
1276
- * call {@link TriggerSetupContext.registerCleanup} for the loop.
1277
- * @returns The state returned by the first cycle (or `undefined` when the overlap guard fired).
1076
+ * Marker: this node emits {@link import("./assertionTypes").AssertionResult}-shaped items on its
1077
+ * `main` port. The TestSuiteOrchestrator (and host-side TestAssertionPersister) listen for
1078
+ * `nodeCompleted` events from nodes with this flag set, and persist their output items as
1079
+ * TestAssertion records (only when the run carries a `testContext`). Set on assertion node
1080
+ * configs (e.g. `AssertionNodeConfig`, `StringEqualsAssertionNodeConfig`).
1278
1081
  */
1279
- start<TState, TItem>(args: {
1280
- intervalMs: number;
1281
- seedState?: TState;
1282
- runCycle: (cycleCtx: {
1283
- previousState: TState | undefined;
1284
- signal: AbortSignal;
1285
- }) => Promise<{
1286
- items: Items<TItem>;
1287
- nextState: TState;
1288
- }>;
1289
- }): Promise<TState | undefined>;
1290
- /** Convenience dedup-window helper. */
1291
- readonly dedup: PollingTriggerDedupWindow;
1292
- }
1293
- interface TriggerSetupContext<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>, TSetupState$1 extends JsonValue | undefined = TriggerNodeSetupState<TConfig>> extends ExecutionContext {
1294
- trigger: TriggerInstanceId;
1295
- config: TConfig;
1296
- previousState: TSetupState$1;
1297
- registerCleanup(cleanup: TriggerCleanupHandle): void;
1298
- emit(items: Items): Promise<void>;
1299
- /** Generic polling-trigger surface. Pre-binds trigger id, emit, and registerCleanup. */
1300
- readonly polling: PollingTriggerHandle;
1301
- }
1302
- interface TriggerTestItemsContext<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>, TSetupState$1 extends JsonValue | undefined = TriggerNodeSetupState<TConfig>> extends ExecutionContext {
1303
- trigger: TriggerInstanceId;
1304
- nodeId: NodeId;
1305
- config: TConfig;
1306
- previousState: TSetupState$1;
1082
+ readonly emitsAssertions?: true;
1083
+ /**
1084
+ * Static configuration summary surfaced in the workflow inspector — the design-time
1085
+ * "what does this node do" panel that renders before any run telemetry exists.
1086
+ *
1087
+ * Return 2–6 short label/value pairs derived from this config (method + url for an HTTP
1088
+ * call, model + tool list for an agent, schedule + timezone for a cron trigger, etc.).
1089
+ * Values are truncated by the UI; aim for one line each. Return `undefined` to opt out
1090
+ * — the inspector hides the section when no rows are produced.
1091
+ *
1092
+ * Implement on the config class instance so the function can read sibling config fields.
1093
+ * `defineNode({ inspectorSummary })` plumbs through to this.
1094
+ */
1095
+ inspectorSummary?(): ReadonlyArray<NodeInspectorSummaryRow> | undefined;
1307
1096
  }
1308
1097
  /**
1309
- * Trigger setup state is intentionally engine-owned so future ownership and
1310
- * leader-election metadata can be coordinated centrally rather than pushed into
1311
- * package-level setup code.
1098
+ * One row of a node's static configuration summary. See {@link NodeConfigBase.inspectorSummary}.
1312
1099
  */
1313
- interface PersistedTriggerSetupState<TState extends JsonValue | undefined = JsonValue | undefined> {
1314
- trigger: TriggerInstanceId;
1315
- updatedAt: string;
1316
- state: TState;
1317
- }
1318
- interface TriggerSetupStateRepository {
1319
- load(trigger: TriggerInstanceId): Promise<PersistedTriggerSetupState | undefined>;
1320
- save(state: PersistedTriggerSetupState): Promise<void>;
1321
- delete(trigger: TriggerInstanceId): Promise<void>;
1322
- }
1323
- interface TriggerCleanupHandle {
1324
- stop(): Promise<void> | void;
1325
- }
1326
- interface EngineHost {
1327
- credentialSessions: CredentialSessionService;
1328
- workflows?: WorkflowRunnerService;
1100
+ interface NodeInspectorSummaryRow {
1101
+ readonly label: string;
1102
+ readonly value: string;
1329
1103
  }
1104
+ declare const runnableNodeInputType: unique symbol;
1105
+ declare const runnableNodeOutputType: unique symbol;
1106
+ declare const triggerNodeOutputType: unique symbol;
1330
1107
  /**
1331
- * Per-item runnable node: return JSON, an array to fan-out on `main`, an explicit `Item`, or {@link emitPorts}
1332
- * for multi-port emission. Engine applies `inputSchema.parse(item.json)` and passes the result as `args.input`
1333
- * (wire `item.json` is unchanged). Transform helpers may opt into binary preservation, while routers and
1334
- * pass-through nodes should return explicit items when they need to preserve full item state.
1108
+ * Runnable node: **`TInputJson`** is what **`inputSchema`** validates on **`item.json`** (the wire payload).
1109
+ * **`TOutputJson`** is emitted `item.json` on outputs.
1335
1110
  */
1336
- interface RunnableNodeExecuteArgs<TConfig extends RunnableNodeConfig<any, any> = RunnableNodeConfig<any, any>, TInputJson$1 = unknown> {
1337
- readonly input: TInputJson$1;
1338
- readonly item: Item;
1339
- readonly itemIndex: number;
1340
- readonly items: Items;
1341
- readonly ctx: NodeExecutionContext<TConfig>;
1342
- }
1343
- interface RunnableNode<TConfig extends RunnableNodeConfig<any, any> = RunnableNodeConfig<any, any>, TInputJson$1 = unknown, _TOutputJson = unknown> {
1111
+ interface RunnableNodeConfig<TInputJson$1 = unknown, TOutputJson$1 = unknown> extends NodeConfigBase {
1344
1112
  readonly kind: "node";
1113
+ readonly [runnableNodeInputType]?: TInputJson$1;
1114
+ readonly [runnableNodeOutputType]?: TOutputJson$1;
1345
1115
  /**
1346
- * Declared output ports (e.g. `["main"]`).
1347
- *
1348
- * Prefer describing dynamic router ports (Switch) and fixed multi-ports (If true/false)
1349
- * via {@link NodeConfigBase.declaredOutputPorts}. Engine defaults to `["main"]` when omitted.
1116
+ * Optional Zod input contract for {@link RunnableNode} when not set on the node class.
1117
+ * Resolution order: node instance `inputSchema`, then config `inputSchema`, then `z.unknown()`.
1350
1118
  */
1351
- readonly outputPorts?: ReadonlyArray<OutputPortKey>;
1352
- /** When omitted, engine uses {@link RunnableNodeConfig.inputSchema} or `z.unknown()`. */
1353
1119
  readonly inputSchema?: ZodType<TInputJson$1>;
1354
- execute(args: RunnableNodeExecuteArgs<TConfig, TInputJson$1>): Promise<unknown> | unknown;
1120
+ /**
1121
+ * When an activation receives **zero** input items, the engine normally runs `execute` zero times.
1122
+ * Set to **`runOnce`** to run `execute` once with an empty `items` batch (and a synthetic wire item for schema parsing).
1123
+ * Used by batch-style callback nodes (built-in `Callback`) so `callback([], ctx)` still runs.
1124
+ */
1125
+ readonly emptyBatchExecution?: "skip" | "runOnce";
1355
1126
  }
1356
- /** @deprecated Use {@link RunnableNode} */
1357
- type ItemNode<TConfig extends RunnableNodeConfig<any, any> = RunnableNodeConfig<any, any>, TInputJson$1 = unknown, TOutputJson$1 = unknown> = RunnableNode<TConfig, TInputJson$1, TOutputJson$1>;
1358
- interface MultiInputNode<TConfig extends NodeConfigBase = NodeConfigBase> {
1359
- kind: "node";
1127
+ declare const triggerNodeSetupStateType: unique symbol;
1128
+ interface TriggerNodeConfig<TOutputJson$1 = unknown, TSetupState$1 extends JsonValue | undefined = undefined> extends NodeConfigBase {
1129
+ readonly kind: "trigger";
1130
+ readonly [triggerNodeOutputType]?: TOutputJson$1;
1131
+ readonly [triggerNodeSetupStateType]?: TSetupState$1;
1132
+ /**
1133
+ * Distinguishes triggers driven by the live activation policy (webhooks, cron, polling) from
1134
+ * triggers driven only by the {@link TestSuiteOrchestrator}. `WorkflowActivation` skips
1135
+ * `"test"` triggers; the orchestrator skips `"live"` triggers. Defaults to `"live"` when omitted.
1136
+ */
1137
+ readonly triggerKind?: "live" | "test";
1138
+ }
1139
+ type RunnableNodeInputJson<TConfig extends RunnableNodeConfig<any, any>> = TConfig extends RunnableNodeConfig<infer TInputJson, any> ? TInputJson : never;
1140
+ type RunnableNodeOutputJson<TConfig extends RunnableNodeConfig<any, any>> = TConfig extends RunnableNodeConfig<any, infer TOutputJson> ? TOutputJson : never;
1141
+ type TriggerNodeOutputJson<TConfig extends TriggerNodeConfig<any, any>> = TConfig extends TriggerNodeConfig<infer TOutputJson, any> ? TOutputJson : never;
1142
+ type TriggerNodeSetupState<TConfig extends TriggerNodeConfig<any, any>> = TConfig extends TriggerNodeConfig<any, infer TSetupState> ? TSetupState : never;
1143
+ interface NodeDefinition {
1144
+ id: NodeId;
1145
+ kind: NodeKind;
1146
+ type: TypeToken<unknown>;
1147
+ name?: string;
1148
+ config: NodeConfigBase;
1149
+ }
1150
+ interface NodeRef {
1151
+ id: NodeId;
1152
+ kind: NodeKind;
1153
+ name?: string;
1154
+ }
1155
+ declare function nodeRef<TJson>(nodeId: NodeId): NodeIdRef<TJson>;
1156
+ type PairedItemRef = Readonly<{
1157
+ nodeId: NodeId;
1158
+ output: OutputPortKey;
1159
+ itemIndex: number;
1160
+ }>;
1161
+ type BinaryPreviewKind = "image" | "audio" | "video" | "download";
1162
+ type BinaryAttachment = Readonly<{
1163
+ id: string;
1164
+ storageKey: string;
1165
+ mimeType: string;
1166
+ size: number;
1167
+ storageDriver: string;
1168
+ previewKind: BinaryPreviewKind;
1169
+ createdAt: string;
1170
+ runId: RunId;
1171
+ workflowId: WorkflowId;
1172
+ nodeId: NodeId;
1173
+ activationId: NodeActivationId;
1174
+ filename?: string;
1175
+ sha256?: string;
1176
+ }>;
1177
+ type ItemBinary = Readonly<Record<string, BinaryAttachment>>;
1178
+ type Item<TJson = unknown> = Readonly<{
1179
+ json: TJson;
1180
+ binary?: ItemBinary;
1181
+ meta?: Readonly<Record<string, unknown>>;
1182
+ paired?: ReadonlyArray<PairedItemRef>;
1183
+ }>;
1184
+ type Items<TJson = unknown> = ReadonlyArray<Item<TJson>>;
1185
+ type NodeOutputs = Partial<Record<OutputPortKey, Items>>;
1186
+ type RunId = string;
1187
+ type NodeActivationId = string;
1188
+ /**
1189
+ * One per-item iteration of a runnable node's execute loop. Refines `NodeActivationId` for
1190
+ * per-item connection invocations and telemetry. Undefined when the executing node is a batch
1191
+ * node or trigger that does not iterate items.
1192
+ */
1193
+ type NodeIterationId = string;
1194
+ interface ParentExecutionRef {
1195
+ runId: RunId;
1196
+ workflowId: WorkflowId;
1197
+ nodeId: NodeId;
1198
+ /** Subworkflow depth of the **spawning** run (0 = root). Passed when starting a child run. */
1199
+ subworkflowDepth?: number;
1200
+ /** Effective max node activations from the parent run (propagated to child policy merge). */
1201
+ engineMaxNodeActivations?: number;
1202
+ /** Effective max subworkflow depth from the parent run (propagated to child policy merge). */
1203
+ engineMaxSubworkflowDepth?: number;
1360
1204
  /**
1361
- * Declared output ports (typically `["main"]`).
1362
- *
1363
- * Prefer describing ports for authoring/canvas via {@link NodeConfigBase.declaredOutputPorts}.
1364
- * Engine defaults to `["main"]` when omitted.
1205
+ * Test-suite linkage inherited by the child subworkflow run. Set by whichever node
1206
+ * spawns the subworkflow when its own `ctx.testContext` is present, so assertions
1207
+ * emitted inside a subworkflow land under the correct parent test case.
1365
1208
  */
1366
- outputPorts?: ReadonlyArray<OutputPortKey>;
1367
- executeMulti(inputsByPort: NodeInputsByPort, ctx: NodeExecutionContext<TConfig>): Promise<NodeOutputs>;
1209
+ testContext?: RunTestContext;
1368
1210
  }
1369
- type TriggerSetupStateFor<TConfig extends TriggerNodeConfig<any, any>> = TriggerNodeSetupState<TConfig>;
1370
- interface TriggerNode<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>> {
1371
- kind: "trigger";
1372
- outputPorts: readonly ["main"];
1373
- setup(ctx: TriggerSetupContext<TConfig>): Promise<TriggerSetupStateFor<TConfig>>;
1374
- execute(items: Items, ctx: NodeExecutionContext<TConfig>): Promise<NodeOutputs>;
1211
+ interface RunDataSnapshot {
1212
+ getOutputs(nodeId: NodeId): NodeOutputs | undefined;
1213
+ getOutputItems<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, output?: OutputPortKey): Items<TJson>;
1214
+ getOutputItem<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, itemIndex: number, output?: OutputPortKey): Item<TJson> | undefined;
1375
1215
  }
1376
- interface TestableTriggerNode<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>> extends TriggerNode<TConfig> {
1377
- getTestItems(ctx: TriggerTestItemsContext<TConfig>): Promise<Items>;
1216
+ interface MutableRunData extends RunDataSnapshot {
1217
+ setOutputs(nodeId: NodeId, outputs: NodeOutputs): void;
1218
+ dump(): Record<NodeId, NodeOutputs>;
1378
1219
  }
1379
- type ExecutableTriggerNode<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>> = TriggerNode<TConfig>;
1380
- interface NodeExecutionRequest {
1381
- runId: RunId;
1382
- activationId: NodeActivationId;
1383
- workflowId: WorkflowId;
1384
- nodeId: NodeId;
1385
- input: Items;
1386
- parent?: ParentExecutionRef;
1387
- queue?: string;
1388
- executionOptions?: RunExecutionOptions;
1220
+ interface RunDataFactory {
1221
+ create(initial?: Record<NodeId, NodeOutputs>): MutableRunData;
1389
1222
  }
1390
- interface NodeExecutionScheduler {
1391
- enqueue(request: NodeExecutionRequest): Promise<{
1392
- receiptId: string;
1393
- }>;
1394
- cancel?(receiptId: string): Promise<void>;
1223
+ interface RunIdFactory {
1224
+ makeRunId(): RunId;
1395
1225
  }
1396
- interface NodeExecutionRequestHandler {
1397
- handleNodeExecutionRequest(request: NodeExecutionRequest): Promise<void>;
1226
+ interface ActivationIdFactory {
1227
+ makeActivationId(): NodeActivationId;
1398
1228
  }
1399
- type NodeActivationRequestBase = Readonly<{
1400
- runId: RunId;
1401
- activationId: NodeActivationId;
1402
- workflowId: WorkflowId;
1403
- nodeId: NodeId;
1404
- parent?: ParentExecutionRef;
1405
- executionOptions?: RunExecutionOptions;
1406
- batchId?: string;
1407
- ctx: NodeExecutionContext;
1408
- }>;
1409
- type NodeActivationRequest = (NodeActivationRequestBase & Readonly<{
1410
- kind: "single";
1411
- input: Items;
1412
- }>) | (NodeActivationRequestBase & Readonly<{
1413
- kind: "multi";
1414
- inputsByPort: NodeInputsByPort;
1415
- }>);
1416
- interface NodeActivationReceipt {
1417
- receiptId: string;
1418
- mode?: "local" | "worker";
1229
+ type UpstreamRefPlaceholder = `$${number}`;
1230
+ declare const branchRef: (index: number) => UpstreamRefPlaceholder;
1231
+ type ExecutionMode = "local" | "worker";
1232
+ interface NodeSchedulerDecision {
1233
+ mode: ExecutionMode;
1419
1234
  queue?: string;
1420
1235
  }
1421
- interface PreparedNodeActivationDispatch {
1422
- readonly receipt: NodeActivationReceipt;
1423
- dispatch(): Promise<void>;
1424
- }
1425
- interface NodeActivationContinuation {
1426
- markNodeRunning(args: {
1427
- runId: RunId;
1428
- activationId: NodeActivationId;
1429
- nodeId: NodeId;
1430
- inputsByPort: NodeInputsByPort;
1431
- }): Promise<void>;
1432
- resumeFromNodeResult(args: {
1433
- runId: RunId;
1434
- activationId: NodeActivationId;
1435
- nodeId: NodeId;
1436
- outputs: NodeOutputs;
1437
- }): Promise<RunResult>;
1438
- resumeFromNodeError(args: {
1439
- runId: RunId;
1440
- activationId: NodeActivationId;
1236
+ interface NodeOffloadPolicy {
1237
+ decide(args: {
1238
+ workflowId: WorkflowId;
1441
1239
  nodeId: NodeId;
1442
- error: Error;
1443
- }): Promise<RunResult>;
1240
+ config: NodeConfigBase;
1241
+ }): NodeSchedulerDecision;
1444
1242
  }
1445
- interface NodeActivationScheduler {
1446
- setContinuation?(continuation: NodeActivationContinuation): void;
1447
- prepareDispatch(request: NodeActivationRequest): Promise<PreparedNodeActivationDispatch>;
1448
- cancel?(receiptId: string): Promise<void>;
1243
+ /** Whether to persist run execution data after the workflow finishes. */
1244
+ type WorkflowStoragePolicyMode = "ALL" | "SUCCESS" | "ERROR" | "NEVER";
1245
+ type WorkflowStoragePolicySpec = WorkflowStoragePolicyMode | TypeToken<WorkflowStoragePolicyResolver>;
1246
+ interface WorkflowStoragePolicyResolver {
1247
+ shouldPersist(args: WorkflowStoragePolicyDecisionArgs): boolean | Promise<boolean>;
1449
1248
  }
1450
- interface WorkflowNodeInstanceFactory {
1451
- createNodes(workflow: WorkflowDefinition): ReadonlyMap<NodeId, unknown>;
1452
- createByType(type: TypeToken<unknown>): unknown;
1249
+ interface WorkflowStoragePolicyDecisionArgs {
1250
+ readonly runId: RunId;
1251
+ readonly workflowId: WorkflowId;
1252
+ readonly workflow: WorkflowDefinition;
1253
+ readonly finalStatus: "completed" | "failed";
1254
+ readonly startedAt: string;
1255
+ readonly finishedAt: string;
1453
1256
  }
1454
- interface NodeExecutor {
1455
- execute(request: NodeActivationRequest): Promise<NodeOutputs>;
1257
+ interface WorkflowPrunePolicySpec {
1258
+ readonly runDataRetentionSeconds?: number;
1259
+ readonly binaryRetentionSeconds?: number;
1260
+ readonly telemetrySpanRetentionSeconds?: number;
1261
+ readonly telemetryArtifactRetentionSeconds?: number;
1262
+ readonly telemetryMetricRetentionSeconds?: number;
1456
1263
  }
1457
- interface WorkflowSnapshotFactory {
1458
- create(workflow: WorkflowDefinition): PersistedWorkflowSnapshot;
1264
+ interface PersistedRunPolicySnapshot {
1265
+ readonly retentionSeconds?: number;
1266
+ readonly binaryRetentionSeconds?: number;
1267
+ readonly telemetrySpanRetentionSeconds?: number;
1268
+ readonly telemetryArtifactRetentionSeconds?: number;
1269
+ readonly telemetryMetricRetentionSeconds?: number;
1270
+ readonly storagePolicy: WorkflowStoragePolicyMode;
1459
1271
  }
1460
- interface WorkflowSnapshotResolver {
1461
- resolve(args: {
1462
- workflowId: WorkflowId;
1463
- workflowSnapshot?: PersistedWorkflowSnapshot;
1464
- }): WorkflowDefinition | undefined;
1272
+ interface WorkflowErrorHandler {
1273
+ onError(ctx: WorkflowErrorContext): void | Promise<void>;
1465
1274
  }
1466
- /** Optional host wiring for trigger lifecycle logs (boot skip + activation sync). */
1467
- interface TriggerRuntimeDiagnostics {
1468
- info(message: string): void;
1469
- warn(message: string): void;
1275
+ interface WorkflowErrorContext {
1276
+ readonly runId: RunId;
1277
+ readonly workflowId: WorkflowId;
1278
+ readonly workflow: WorkflowDefinition;
1279
+ readonly failedNodeId: NodeId;
1280
+ readonly error: Error;
1281
+ readonly startedAt: string;
1282
+ readonly finishedAt: string;
1470
1283
  }
1471
- interface EngineDeps {
1472
- credentialSessions: CredentialSessionService;
1473
- liveWorkflowRepository: LiveWorkflowRepository;
1474
- workflowRepository: WorkflowRepository;
1475
- /** When {@link AllWorkflowsActiveWorkflowActivationPolicy}, all workflows behave as active (tests). */
1476
- workflowActivationPolicy: WorkflowActivationPolicy;
1477
- nodeResolver: NodeResolver;
1478
- triggerSetupStateRepository: TriggerSetupStateRepository;
1479
- webhookTriggerMatcher: WebhookTriggerMatcher;
1480
- runIdFactory: RunIdFactory;
1481
- activationIdFactory: ActivationIdFactory;
1482
- workflowExecutionRepository: WorkflowExecutionRepository;
1483
- activationScheduler: NodeActivationScheduler;
1484
- runDataFactory: RunDataFactory;
1485
- executionContextFactory: ExecutionContextFactory;
1486
- executionTelemetryFactory?: ExecutionTelemetryFactory;
1487
- nodeExecutor: NodeExecutor;
1488
- eventBus?: RunEventBus;
1489
- tokenRegistry: PersistedWorkflowTokenRegistryLike;
1490
- workflowNodeInstanceFactory: WorkflowNodeInstanceFactory;
1491
- /** Defaults for prune/storage snapshot when workflow omits explicit policy fields. */
1492
- workflowPolicyRuntimeDefaults?: WorkflowPolicyRuntimeDefaults;
1493
- /** When set, logs inactive-workflow skips at boot and trigger start/stop on activation changes. */
1494
- triggerRuntimeDiagnostics?: TriggerRuntimeDiagnostics;
1495
- /** When set, the polling-trigger runtime uses this logger for cycle info/debug/error. */
1496
- pollingTriggerLogger?: PollingTriggerLogger;
1284
+ type WorkflowErrorHandlerSpec = TypeToken<WorkflowErrorHandler> | WorkflowErrorHandler;
1285
+ interface NodeErrorHandlerArgs<TConfig extends NodeConfigBase = NodeConfigBase> {
1286
+ readonly kind: "single" | "multi";
1287
+ readonly items: Items;
1288
+ readonly inputsByPort: Readonly<Record<InputPortKey, Items>> | undefined;
1289
+ readonly ctx: NodeExecutionContext<TConfig>;
1290
+ readonly error: Error;
1291
+ }
1292
+ interface NodeErrorHandler {
1293
+ handle<TConfig extends NodeConfigBase>(args: NodeErrorHandlerArgs<TConfig>): Promise<NodeOutputs>;
1294
+ }
1295
+ type NodeErrorHandlerSpec = TypeToken<NodeErrorHandler> | NodeErrorHandler;
1296
+ /** Runtime defaults when workflow omits prune/storage fields (typically from host env). */
1297
+ interface WorkflowPolicyRuntimeDefaults {
1298
+ readonly retentionSeconds?: number;
1299
+ readonly binaryRetentionSeconds?: number;
1300
+ readonly telemetrySpanRetentionSeconds?: number;
1301
+ readonly telemetryArtifactRetentionSeconds?: number;
1302
+ readonly telemetryMetricRetentionSeconds?: number;
1303
+ readonly storagePolicy?: WorkflowStoragePolicyMode;
1304
+ }
1305
+ //#endregion
1306
+ //#region src/contracts/testTriggerTypes.d.ts
1307
+ /**
1308
+ * Identifier minted by the host (or in-memory test runner) for one execution of a test suite.
1309
+ * One TestSuiteRun produces N child workflow runs, one per item yielded by `generateItems`.
1310
+ */
1311
+ type TestSuiteRunId = string;
1312
+ /**
1313
+ * Setup context passed to a {@link TestTriggerNodeConfig.generateItems} callback. Distinct from
1314
+ * {@link import("./runtimeTypes").TriggerSetupContext} on purpose: test triggers are not
1315
+ * activated by the live trigger lifecycle (webhooks, cron, polling) and never call `emit` —
1316
+ * the orchestrator pulls from the iterable they return and dispatches one run per item.
1317
+ */
1318
+ interface TestTriggerSetupContext<TConfig extends TestTriggerNodeConfig<unknown> = TestTriggerNodeConfig<unknown>> {
1319
+ readonly workflowId: WorkflowId;
1320
+ readonly nodeId: NodeId;
1321
+ readonly config: TConfig;
1322
+ readonly testSuiteRunId: TestSuiteRunId;
1323
+ /**
1324
+ * Resolves a credential session for a slot declared on this trigger's
1325
+ * {@link import("./workflowTypes").NodeConfigBase.getCredentialRequirements}. Same contract as
1326
+ * {@link import("./runtimeTypes").ExecutionContext.getCredential}.
1327
+ */
1328
+ getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
1329
+ /** AbortSignal raised when the suite is cancelled — long-running pulls should bail out. */
1330
+ readonly signal: AbortSignal;
1331
+ }
1332
+ /**
1333
+ * A trigger config that emits **test cases**. Each item yielded by {@link generateItems}
1334
+ * becomes one workflow run (with `executionOptions.testContext` set), so 10 yielded items
1335
+ * → 10 runs marked under the same TestSuiteRun.
1336
+ *
1337
+ * The trigger is otherwise a normal {@link TriggerNodeConfig} (so the canvas treats it like
1338
+ * any other trigger), but its `triggerKind` is `"test"` so the live activation policy skips it.
1339
+ */
1340
+ interface TestTriggerNodeConfig<TOutputJson$1 = unknown> extends TriggerNodeConfig<TOutputJson$1, undefined> {
1341
+ readonly triggerKind: "test";
1342
+ /**
1343
+ * Author-supplied async iterable of items, evaluated lazily. Implementations may fetch from
1344
+ * credentialed APIs, read fixture files, or yield hard-coded items. The orchestrator iterates
1345
+ * and dispatches one run per item, with concurrency capped by {@link concurrency} (default 4).
1346
+ */
1347
+ generateItems(ctx: TestTriggerSetupContext<TestTriggerNodeConfig<TOutputJson$1>>): AsyncIterable<Item<TOutputJson$1>>;
1348
+ /** Per-suite-run cap on simultaneously-executing test cases. Default: 4. */
1349
+ readonly concurrency?: number;
1350
+ /**
1351
+ * Free-form description of where the test cases come from — surfaced in the node properties
1352
+ * panel and the suite-detail header so authors revisiting the workflow six months later
1353
+ * remember which mailbox / folder / fixture file the cases originate from.
1354
+ *
1355
+ * Example: `"All emails in the Gmail label \"test/triage-fixtures\" — 14 messages as of 2026-05-03."`
1356
+ */
1357
+ readonly description?: string;
1358
+ /**
1359
+ * Resolves a human-readable label for one yielded test case (e.g. email subject). The
1360
+ * orchestrator calls this once per yielded item, persists the result on the run, and the
1361
+ * Tests-tab UI uses it to render the case row instead of the opaque runId. Return
1362
+ * `undefined` to fall back to "Case #N".
1363
+ */
1364
+ caseLabel?(item: Item<TOutputJson$1>): string | undefined;
1497
1365
  }
1498
1366
  //#endregion
1499
- //#region src/contracts/retryPolicySpec.types.d.ts
1367
+ //#region src/events/runEvents.d.ts
1500
1368
  /**
1501
- * In-process retry policy for runnable nodes. Serialized configs use the same
1502
- * `kind` discriminator (`JSON.stringify` / persisted workflows).
1503
- *
1504
- * `maxAttempts` is the total number of tries including the first (e.g. 3 means up to 2 delays after failures).
1369
+ * Outcome of a single test case (one workflow run dispatched by the test-suite orchestrator).
1370
+ * - `running`: workflow still in flight
1371
+ * - `succeeded`: workflow completed AND all assertions passed (or no assertions)
1372
+ * - `failed`: workflow failed OR (workflow completed but ≥1 assertion failed)
1373
+ * - `errored` / `cancelled`: workflow itself errored or was cancelled
1505
1374
  */
1506
- type RetryPolicySpec = NoneRetryPolicySpec | FixedRetryPolicySpec | ExponentialRetryPolicySpec;
1507
- interface NoneRetryPolicySpec {
1508
- readonly kind: "none";
1509
- }
1510
- interface FixedRetryPolicySpec {
1511
- readonly kind: "fixed";
1512
- /** Total attempts including the first execution. Must be >= 1. */
1513
- readonly maxAttempts: number;
1514
- readonly delayMs: number;
1375
+ type TestCaseRunStatus = "running" | "succeeded" | "failed" | "errored" | "cancelled";
1376
+ /** Aggregate outcome of a TestSuiteRun. */
1377
+ type TestSuiteRunStatus = "succeeded" | "failed" | "partial" | "errored" | "cancelled";
1378
+ type RunEvent = Readonly<{
1379
+ kind: "runCreated";
1380
+ runId: RunId;
1381
+ workflowId: WorkflowId;
1382
+ parent?: ParentExecutionRef;
1383
+ at: string;
1384
+ }> | Readonly<{
1385
+ kind: "runSaved";
1386
+ runId: RunId;
1387
+ workflowId: WorkflowId;
1388
+ parent?: ParentExecutionRef;
1389
+ at: string;
1390
+ state: PersistedRunState;
1391
+ }> | Readonly<{
1392
+ kind: "nodeQueued";
1393
+ runId: RunId;
1394
+ workflowId: WorkflowId;
1395
+ parent?: ParentExecutionRef;
1396
+ at: string;
1397
+ snapshot: NodeExecutionSnapshot;
1398
+ }> | Readonly<{
1399
+ kind: "nodeStarted";
1400
+ runId: RunId;
1401
+ workflowId: WorkflowId;
1402
+ parent?: ParentExecutionRef;
1403
+ at: string;
1404
+ snapshot: NodeExecutionSnapshot;
1405
+ }> | Readonly<{
1406
+ kind: "nodeCompleted";
1407
+ runId: RunId;
1408
+ workflowId: WorkflowId;
1409
+ parent?: ParentExecutionRef;
1410
+ at: string;
1411
+ snapshot: NodeExecutionSnapshot;
1412
+ }> | Readonly<{
1413
+ kind: "nodeFailed";
1414
+ runId: RunId;
1415
+ workflowId: WorkflowId;
1416
+ parent?: ParentExecutionRef;
1417
+ at: string;
1418
+ snapshot: NodeExecutionSnapshot;
1419
+ }> | Readonly<{
1420
+ kind: "connectionInvocationStarted";
1421
+ runId: RunId;
1422
+ workflowId: WorkflowId;
1423
+ parent?: ParentExecutionRef;
1424
+ at: string;
1425
+ record: ConnectionInvocationRecord;
1426
+ }> | Readonly<{
1427
+ kind: "connectionInvocationCompleted";
1428
+ runId: RunId;
1429
+ workflowId: WorkflowId;
1430
+ parent?: ParentExecutionRef;
1431
+ at: string;
1432
+ record: ConnectionInvocationRecord;
1433
+ }> | Readonly<{
1434
+ kind: "connectionInvocationFailed";
1435
+ runId: RunId;
1436
+ workflowId: WorkflowId;
1437
+ parent?: ParentExecutionRef;
1438
+ at: string;
1439
+ record: ConnectionInvocationRecord;
1440
+ }> | Readonly<{
1441
+ kind: "testSuiteStarted";
1442
+ testSuiteRunId: TestSuiteRunId;
1443
+ workflowId: WorkflowId;
1444
+ triggerNodeId: string;
1445
+ triggerNodeName?: string;
1446
+ concurrency: number;
1447
+ at: string;
1448
+ }> | Readonly<{
1449
+ kind: "testSuiteFinished";
1450
+ testSuiteRunId: TestSuiteRunId;
1451
+ workflowId: WorkflowId;
1452
+ status: TestSuiteRunStatus;
1453
+ totalCases: number;
1454
+ passedCases: number;
1455
+ failedCases: number;
1456
+ at: string;
1457
+ }> | Readonly<{
1458
+ kind: "testCaseStarted";
1459
+ testSuiteRunId: TestSuiteRunId;
1460
+ testCaseIndex: number;
1461
+ runId: RunId;
1462
+ workflowId: WorkflowId;
1463
+ testCaseLabel?: string;
1464
+ at: string;
1465
+ }> | Readonly<{
1466
+ kind: "testCaseCompleted";
1467
+ testSuiteRunId: TestSuiteRunId;
1468
+ testCaseIndex: number;
1469
+ runId: RunId;
1470
+ workflowId: WorkflowId;
1471
+ status: TestCaseRunStatus;
1472
+ at: string;
1473
+ }>;
1474
+ interface RunEventSubscription {
1475
+ close(): Promise<void>;
1515
1476
  }
1516
- interface ExponentialRetryPolicySpec {
1517
- readonly kind: "exponential";
1518
- /** Total attempts including the first execution. Must be >= 1. */
1519
- readonly maxAttempts: number;
1520
- readonly initialDelayMs: number;
1521
- readonly multiplier: number;
1522
- readonly maxDelayMs?: number;
1523
- /** When true, each delay is multiplied by a random factor in [1, 1.2). */
1524
- readonly jitter?: boolean;
1477
+ interface RunEventBus {
1478
+ publish(event: RunEvent): Promise<void>;
1479
+ subscribe(onEvent: (event: RunEvent) => void): Promise<RunEventSubscription>;
1480
+ subscribeToWorkflow(workflowId: WorkflowId, onEvent: (event: RunEvent) => void): Promise<RunEventSubscription>;
1525
1481
  }
1526
1482
  //#endregion
1527
- //#region src/contracts/workflowTypes.d.ts
1528
- type NodeIdRef<TJson = unknown> = NodeId & Readonly<{
1529
- __codemationNodeJson?: TJson;
1530
- }>;
1531
- type NodeKind = "trigger" | "node";
1532
- type JsonPrimitive = string | number | boolean | null;
1533
- interface JsonObject {
1534
- readonly [key: string]: JsonValue;
1535
- }
1536
- type JsonValue = JsonPrimitive | JsonObject | JsonArray;
1537
- type JsonArray = ReadonlyArray<JsonValue>;
1538
- /** JSON value that is not a top-level array (nested arrays inside objects are allowed). */
1539
- type JsonNonArray = JsonPrimitive | JsonObject;
1540
- interface Edge {
1541
- from: {
1542
- nodeId: NodeId;
1543
- output: OutputPortKey;
1544
- };
1545
- to: {
1546
- nodeId: NodeId;
1547
- input: InputPortKey;
1548
- };
1483
+ //#region src/policies/executionLimits/EngineExecutionLimitsPolicy.d.ts
1484
+ interface EngineExecutionLimitsPolicyConfig {
1485
+ readonly defaultMaxNodeActivations: number;
1486
+ readonly hardMaxNodeActivations: number;
1487
+ readonly defaultMaxSubworkflowDepth: number;
1488
+ readonly hardMaxSubworkflowDepth: number;
1549
1489
  }
1490
+ /** Framework defaults for {@link EngineExecutionLimitsPolicy} (merged with host `runtime.engineExecutionLimits`). */
1491
+ declare const ENGINE_EXECUTION_LIMITS_DEFAULTS: EngineExecutionLimitsPolicyConfig;
1550
1492
  /**
1551
- * Named connection from a parent node to child nodes that exist in {@link WorkflowDefinition.nodes}
1552
- * but are not traversed by the main execution graph. Parents are commonly executable nodes, but may
1553
- * also be connection-owned nodes for recursive agent attachments.
1493
+ * Resolves per-run execution limits: defaults, hard ceilings, and subworkflow depth for new runs.
1554
1494
  */
1555
- interface WorkflowNodeConnection {
1556
- readonly parentNodeId: NodeId;
1557
- readonly connectionName: NodeConnectionName;
1558
- readonly childNodeIds: ReadonlyArray<NodeId>;
1559
- }
1560
- interface WorkflowDefinition {
1561
- id: WorkflowId;
1562
- name: string;
1563
- nodes: NodeDefinition[];
1564
- edges: Edge[];
1495
+ declare class EngineExecutionLimitsPolicy {
1496
+ private readonly config;
1497
+ constructor(config?: EngineExecutionLimitsPolicyConfig);
1565
1498
  /**
1566
- * Optional metadata: which nodes are connection-owned children (e.g. AI agent `llm` / `tools` slots).
1567
- * When omitted, all nodes in {@link nodes} are treated as executable for topology.
1499
+ * Effective options for a new root run (depth 0): defaults merged with engine ceilings.
1500
+ * Replaces a separate one-method factory for root-run bootstrap.
1568
1501
  */
1569
- readonly connections?: ReadonlyArray<WorkflowNodeConnection>;
1570
- /** Directory + file-stem path under a workflow discovery root (for UI grouping only). */
1571
- discoveryPathSegments?: readonly string[];
1572
- /** Retention for run JSON and binaries (seconds). Host/env may supply defaults when omitted. */
1573
- readonly prunePolicy?: WorkflowPrunePolicySpec;
1574
- /** Whether to keep run data after completion. Host/env may supply defaults when omitted. */
1575
- readonly storagePolicy?: WorkflowStoragePolicySpec;
1576
- /** Invoked after a node fails permanently (retries exhausted) and node error handler did not recover. */
1577
- readonly workflowErrorHandler?: WorkflowErrorHandlerSpec;
1578
- }
1579
- interface WorkflowGraph {
1580
- next(nodeId: NodeId, output: OutputPortKey): ReadonlyArray<Readonly<{
1581
- nodeId: NodeId;
1582
- input: InputPortKey;
1583
- }>>;
1584
- }
1585
- interface WorkflowGraphFactory {
1586
- create(def: WorkflowDefinition): WorkflowGraph;
1502
+ createRootExecutionOptions(): RunExecutionOptions;
1503
+ mergeExecutionOptionsForNewRun(parent: ParentExecutionRef | undefined, user: RunExecutionOptions | undefined): RunExecutionOptions;
1504
+ private capNumber;
1587
1505
  }
1588
- interface NodeConfigBase {
1589
- readonly kind: NodeKind;
1590
- readonly type: TypeToken<unknown>;
1591
- readonly name?: string;
1592
- readonly id?: NodeId;
1593
- readonly icon?: string;
1594
- readonly execution?: Readonly<{
1595
- hint?: "local" | "worker";
1596
- queue?: string;
1597
- }>;
1598
- /** In-process execute retries (runnable nodes). Triggers typically omit this. */
1599
- readonly retryPolicy?: RetryPolicySpec;
1600
- /** Recover from execute failures; return outputs to continue, or rethrow to fail the node. */
1601
- readonly nodeErrorHandler?: NodeErrorHandlerSpec;
1602
- /**
1603
- * When true, edges carrying zero items on an output port still schedule single-input downstream nodes.
1604
- * Decided from the **source** node that produced the (empty) output. Default (false/undefined): empty
1605
- * main batches skip downstream execution and propagate the empty path.
1606
- */
1607
- readonly continueWhenEmptyOutput?: boolean;
1608
- /**
1609
- * Declared I/O port names for canvas authoring (unioned with ports inferred from edges).
1610
- * Use for dynamic routers (Switch) and future error ports.
1611
- */
1612
- readonly declaredOutputPorts?: ReadonlyArray<OutputPortKey>;
1613
- readonly declaredInputPorts?: ReadonlyArray<InputPortKey>;
1614
- getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;
1506
+ //#endregion
1507
+ //#region src/di/CoreTokens.d.ts
1508
+ declare const CoreTokens: {
1509
+ readonly PersistedWorkflowTokenRegistry: TypeToken<PersistedWorkflowTokenRegistryLike>;
1510
+ readonly CredentialSessionService: TypeToken<CredentialSessionService>;
1511
+ readonly CredentialTypeRegistry: TypeToken<CredentialTypeRegistry>;
1512
+ readonly WorkflowRunnerService: TypeToken<WorkflowRunnerService>;
1513
+ readonly LiveWorkflowRepository: TypeToken<LiveWorkflowRepository>;
1514
+ readonly WorkflowRepository: TypeToken<WorkflowRepository>;
1515
+ readonly NodeResolver: TypeToken<NodeResolver>;
1516
+ readonly WorkflowNodeInstanceFactory: TypeToken<WorkflowNodeInstanceFactory>;
1517
+ readonly RunIdFactory: TypeToken<RunIdFactory>;
1518
+ readonly ActivationIdFactory: TypeToken<ActivationIdFactory>;
1519
+ readonly WorkflowExecutionRepository: TypeToken<WorkflowExecutionRepository>;
1520
+ readonly TriggerSetupStateRepository: TypeToken<TriggerSetupStateRepository>;
1521
+ readonly NodeActivationScheduler: TypeToken<NodeActivationScheduler>;
1522
+ readonly RunDataFactory: TypeToken<RunDataFactory>;
1523
+ readonly ExecutionContextFactory: TypeToken<ExecutionContextFactory>;
1524
+ readonly RunEventBus: TypeToken<RunEventBus>;
1525
+ readonly BinaryStorage: TypeToken<BinaryStorage>;
1526
+ readonly WebhookBasePath: TypeToken<string>;
1527
+ /** Engine execution limits (defaults + optional host overrides). Consumers may bind a custom instance to override. */
1528
+ readonly EngineExecutionLimitsPolicy: TypeToken<EngineExecutionLimitsPolicy>;
1529
+ readonly WorkflowActivationPolicy: TypeToken<WorkflowActivationPolicy>;
1615
1530
  /**
1616
- * Marker: this node emits {@link import("./assertionTypes").AssertionResult}-shaped items on its
1617
- * `main` port. The TestSuiteOrchestrator (and host-side TestAssertionPersister) listen for
1618
- * `nodeCompleted` events from nodes with this flag set, and persist their output items as
1619
- * TestAssertion records (only when the run carries a `testContext`). Set on assertion node
1620
- * configs (e.g. `AssertionNodeConfig`, `StringEqualsAssertionNodeConfig`).
1531
+ * Optional. When registered, AIAgentNode uses it to resolve mcpServers bindings,
1532
+ * validate scopes, open pool connections, and prepare the MCP ToolSet map.
1533
+ * Not registered in the default core bootstrap the host provides the implementation.
1621
1534
  */
1622
- readonly emitsAssertions?: true;
1623
- }
1624
- declare const runnableNodeInputType: unique symbol;
1625
- declare const runnableNodeOutputType: unique symbol;
1626
- declare const triggerNodeOutputType: unique symbol;
1535
+ readonly AgentMcpIntegration: TypeToken<AgentMcpIntegration>;
1536
+ };
1537
+ //#endregion
1538
+ //#region src/contracts/runTypes.d.ts
1627
1539
  /**
1628
- * Runnable node: **`TInputJson`** is what **`inputSchema`** validates on **`item.json`** (the wire payload).
1629
- * **`TOutputJson`** is emitted `item.json` on outputs.
1540
+ * Test-suite linkage for a run. When set, this run was started by a TestSuiteOrchestrator
1541
+ * as one test case inside a TestSuiteRun. The `IsTestRun` node and host-side persisters key
1542
+ * off the presence of this field. Subworkflow runs inherit it from their parent run.
1630
1543
  */
1631
- interface RunnableNodeConfig<TInputJson$1 = unknown, TOutputJson$1 = unknown> extends NodeConfigBase {
1632
- readonly kind: "node";
1633
- readonly [runnableNodeInputType]?: TInputJson$1;
1634
- readonly [runnableNodeOutputType]?: TOutputJson$1;
1635
- /**
1636
- * Optional Zod input contract for {@link RunnableNode} when not set on the node class.
1637
- * Resolution order: node instance `inputSchema`, then config `inputSchema`, then `z.unknown()`.
1638
- */
1639
- readonly inputSchema?: ZodType<TInputJson$1>;
1544
+ interface RunTestContext {
1545
+ readonly testSuiteRunId: string;
1546
+ readonly testCaseIndex: number;
1640
1547
  /**
1641
- * When an activation receives **zero** input items, the engine normally runs `execute` zero times.
1642
- * Set to **`runOnce`** to run `execute` once with an empty `items` batch (and a synthetic wire item for schema parsing).
1643
- * Used by batch-style callback nodes (built-in `Callback`) so `callback([], ctx)` still runs.
1548
+ * Optional human-friendly label for this test case (e.g. an email subject when fixtures
1549
+ * are loaded from a mailbox). Resolved per item by `TestTrigger.caseLabel(item)` if set,
1550
+ * persisted on `Run.test_case_label` so the Tests-tab tree-table can show "RFQ for batch 14"
1551
+ * instead of "run_1777755971399_bbb86beac1396".
1644
1552
  */
1645
- readonly emptyBatchExecution?: "skip" | "runOnce";
1553
+ readonly testCaseLabel?: string;
1646
1554
  }
1647
- declare const triggerNodeSetupStateType: unique symbol;
1648
- interface TriggerNodeConfig<TOutputJson$1 = unknown, TSetupState$1 extends JsonValue | undefined = undefined> extends NodeConfigBase {
1649
- readonly kind: "trigger";
1650
- readonly [triggerNodeOutputType]?: TOutputJson$1;
1651
- readonly [triggerNodeSetupStateType]?: TSetupState$1;
1652
- /**
1653
- * Distinguishes triggers driven by the live activation policy (webhooks, cron, polling) from
1654
- * triggers driven only by the {@link TestSuiteOrchestrator}. `WorkflowActivation` skips
1655
- * `"test"` triggers; the orchestrator skips `"live"` triggers. Defaults to `"live"` when omitted.
1656
- */
1657
- readonly triggerKind?: "live" | "test";
1555
+ interface RunExecutionOptions {
1556
+ /** Run-intent override: force the inline scheduler and bypass node-level offload decisions. */
1557
+ localOnly?: boolean;
1558
+ /** Marks runs started from webhook handling so orchestration can apply webhook-specific continuation rules. */
1559
+ webhook?: boolean;
1560
+ mode?: "manual" | "debug";
1561
+ sourceWorkflowId?: WorkflowId;
1562
+ sourceRunId?: RunId;
1563
+ derivedFromRunId?: RunId;
1564
+ isMutable?: boolean;
1565
+ /** Set by the engine for this run: 0 = root, 1 = first child subworkflow, … */
1566
+ subworkflowDepth?: number;
1567
+ /** Effective cap after engine policy merge (successful node completions per run). */
1568
+ maxNodeActivations?: number;
1569
+ /** Effective cap after engine policy merge (subworkflow nesting). */
1570
+ maxSubworkflowDepth?: number;
1571
+ /** Present iff started by a TestSuiteOrchestrator; propagates to subworkflow runs via {@link ParentExecutionRef.testContext}. */
1572
+ testContext?: RunTestContext;
1658
1573
  }
1659
- type RunnableNodeInputJson<TConfig extends RunnableNodeConfig<any, any>> = TConfig extends RunnableNodeConfig<infer TInputJson, any> ? TInputJson : never;
1660
- type RunnableNodeOutputJson<TConfig extends RunnableNodeConfig<any, any>> = TConfig extends RunnableNodeConfig<any, infer TOutputJson> ? TOutputJson : never;
1661
- type TriggerNodeOutputJson<TConfig extends TriggerNodeConfig<any, any>> = TConfig extends TriggerNodeConfig<infer TOutputJson, any> ? TOutputJson : never;
1662
- type TriggerNodeSetupState<TConfig extends TriggerNodeConfig<any, any>> = TConfig extends TriggerNodeConfig<any, infer TSetupState> ? TSetupState : never;
1663
- interface NodeDefinition {
1664
- id: NodeId;
1665
- kind: NodeKind;
1666
- type: TypeToken<unknown>;
1667
- name?: string;
1668
- config: NodeConfigBase;
1574
+ /** Engine-owned counters persisted with the run (worker-safe). */
1575
+ interface EngineRunCounters {
1576
+ completedNodeActivations: number;
1669
1577
  }
1670
- interface NodeRef {
1578
+ type RunStopCondition = Readonly<{
1579
+ kind: "workflowCompleted";
1580
+ }> | Readonly<{
1581
+ kind: "nodeCompleted";
1582
+ nodeId: NodeId;
1583
+ }>;
1584
+ interface RunStateResetRequest {
1585
+ clearFromNodeId: NodeId;
1586
+ }
1587
+ interface PersistedRunControlState {
1588
+ stopCondition?: RunStopCondition;
1589
+ }
1590
+ interface PersistedWorkflowSnapshotNode {
1671
1591
  id: NodeId;
1672
1592
  kind: NodeKind;
1673
1593
  name?: string;
1594
+ nodeTokenId: PersistedTokenId;
1595
+ configTokenId: PersistedTokenId;
1596
+ tokenName?: string;
1597
+ configTokenName?: string;
1598
+ config: unknown;
1599
+ /** Pre-computed static configuration summary; populated by WorkflowSnapshotCodec. */
1600
+ inspectorSummary?: ReadonlyArray<Readonly<{
1601
+ label: string;
1602
+ value: string;
1603
+ }>>;
1674
1604
  }
1675
- declare function nodeRef<TJson>(nodeId: NodeId): NodeIdRef<TJson>;
1676
- type PairedItemRef = Readonly<{
1605
+ interface PersistedWorkflowSnapshot {
1606
+ id: WorkflowId;
1607
+ name: string;
1608
+ nodes: ReadonlyArray<PersistedWorkflowSnapshotNode>;
1609
+ edges: ReadonlyArray<Edge>;
1610
+ /** When the snapshot was built from a live workflow definition that configured a workflow error handler. */
1611
+ workflowErrorHandlerConfigured?: boolean;
1612
+ /** Connection metadata for child nodes not in the execution graph (e.g. AI agent attachments). */
1613
+ connections?: ReadonlyArray<WorkflowNodeConnection>;
1614
+ }
1615
+ type PinnedNodeOutputsByPort = Readonly<Record<OutputPortKey, Items>>;
1616
+ interface PersistedMutableNodeState {
1617
+ pinnedOutputsByPort?: PinnedNodeOutputsByPort;
1618
+ lastDebugInput?: Items;
1619
+ }
1620
+ interface PersistedMutableRunState {
1621
+ nodesById: Readonly<Record<NodeId, PersistedMutableNodeState>>;
1622
+ }
1623
+ type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
1624
+ interface RunQueueEntry {
1677
1625
  nodeId: NodeId;
1678
- output: OutputPortKey;
1679
- itemIndex: number;
1680
- }>;
1681
- type BinaryPreviewKind = "image" | "audio" | "video" | "download";
1682
- type BinaryAttachment = Readonly<{
1683
- id: string;
1684
- storageKey: string;
1685
- mimeType: string;
1686
- size: number;
1687
- storageDriver: string;
1688
- previewKind: BinaryPreviewKind;
1689
- createdAt: string;
1626
+ input: Items;
1627
+ toInput?: InputPortKey;
1628
+ batchId?: string;
1629
+ from?: Readonly<{
1630
+ nodeId: NodeId;
1631
+ output: OutputPortKey;
1632
+ }>;
1633
+ collect?: Readonly<{
1634
+ expectedInputs: ReadonlyArray<InputPortKey>;
1635
+ received: Readonly<Record<InputPortKey, Items>>;
1636
+ }>;
1637
+ }
1638
+ type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
1639
+ interface NodeExecutionError {
1640
+ message: string;
1641
+ name?: string;
1642
+ stack?: string;
1643
+ details?: JsonValue;
1644
+ }
1645
+ interface NodeExecutionSnapshot {
1690
1646
  runId: RunId;
1691
1647
  workflowId: WorkflowId;
1692
1648
  nodeId: NodeId;
1693
- activationId: NodeActivationId;
1694
- filename?: string;
1695
- sha256?: string;
1696
- }>;
1697
- type ItemBinary = Readonly<Record<string, BinaryAttachment>>;
1698
- type Item<TJson = unknown> = Readonly<{
1699
- json: TJson;
1700
- binary?: ItemBinary;
1701
- meta?: Readonly<Record<string, unknown>>;
1702
- paired?: ReadonlyArray<PairedItemRef>;
1703
- }>;
1704
- type Items<TJson = unknown> = ReadonlyArray<Item<TJson>>;
1705
- type NodeOutputs = Partial<Record<OutputPortKey, Items>>;
1706
- type RunId = string;
1707
- type NodeActivationId = string;
1649
+ activationId?: NodeActivationId;
1650
+ parent?: ParentExecutionRef;
1651
+ status: NodeExecutionStatus;
1652
+ usedPinnedOutput?: boolean;
1653
+ queuedAt?: string;
1654
+ startedAt?: string;
1655
+ finishedAt?: string;
1656
+ updatedAt: string;
1657
+ inputsByPort?: NodeInputsByPort;
1658
+ outputs?: NodeOutputs;
1659
+ error?: NodeExecutionError;
1660
+ /**
1661
+ * When the node is a SubWorkflow invocation, the run id of the child run it spawned.
1662
+ * Populated after the child run completes so the UI can deep-link to that specific execution.
1663
+ */
1664
+ childRunId?: RunId;
1665
+ }
1666
+ /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
1667
+ type ConnectionInvocationId = string;
1708
1668
  /**
1709
- * One per-item iteration of a runnable node's execute loop. Refines `NodeActivationId` for
1710
- * per-item connection invocations and telemetry. Undefined when the executing node is a batch
1711
- * node or trigger that does not iterate items.
1669
+ * One logical LLM or tool call under an owning workflow node (e.g. AI agent).
1670
+ * The owning node defines what {@link managedInput} and {@link managedOutput} contain.
1712
1671
  */
1713
- type NodeIterationId = string;
1714
- interface ParentExecutionRef {
1672
+ interface ConnectionInvocationRecord {
1673
+ readonly invocationId: ConnectionInvocationId;
1674
+ readonly runId: RunId;
1675
+ readonly workflowId: WorkflowId;
1676
+ readonly connectionNodeId: NodeId;
1677
+ readonly parentAgentNodeId: NodeId;
1678
+ readonly parentAgentActivationId: NodeActivationId;
1679
+ readonly status: NodeExecutionStatus;
1680
+ readonly managedInput?: JsonValue;
1681
+ readonly managedOutput?: JsonValue;
1682
+ /** Short human-readable description of what this invocation is doing right now (e.g. `"calling search_messages"`). Rendered as a sub-line on the canvas node card. */
1683
+ readonly statusLabel?: string;
1684
+ /** Stable identifier for the thing this invocation acts on (e.g. an MCP tool name like `"search_messages"`). Persists across status transitions so the inspector can show it on completed/failed entries too. Connection nodes that ARE the tool (e.g. node-backed agent tools) leave this unset — the parent node id already identifies the subject. */
1685
+ readonly subjectName?: string;
1686
+ readonly error?: NodeExecutionError;
1687
+ readonly queuedAt?: string;
1688
+ readonly startedAt?: string;
1689
+ readonly finishedAt?: string;
1690
+ readonly updatedAt: string;
1691
+ /** Per-item iteration id minted by the engine when this invocation occurred inside a runnable node's per-item loop. */
1692
+ readonly iterationId?: NodeIterationId;
1693
+ /** Item index (0-based) of the iteration that produced this invocation. */
1694
+ readonly itemIndex?: number;
1695
+ /** When set, this invocation was produced inside a sub-agent triggered by the named parent invocation. */
1696
+ readonly parentInvocationId?: ConnectionInvocationId;
1697
+ }
1698
+ /** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
1699
+ type ConnectionInvocationAppendArgs = Readonly<{
1700
+ invocationId: ConnectionInvocationId;
1701
+ connectionNodeId: NodeId;
1702
+ parentAgentNodeId: NodeId;
1703
+ parentAgentActivationId: NodeActivationId;
1704
+ status: NodeExecutionStatus;
1705
+ managedInput?: JsonValue;
1706
+ managedOutput?: JsonValue;
1707
+ statusLabel?: string;
1708
+ subjectName?: string;
1709
+ error?: NodeExecutionError;
1710
+ queuedAt?: string;
1711
+ startedAt?: string;
1712
+ finishedAt?: string;
1713
+ iterationId?: NodeIterationId;
1714
+ itemIndex?: number;
1715
+ parentInvocationId?: ConnectionInvocationId;
1716
+ }>;
1717
+ interface RunCurrentState {
1718
+ outputsByNode: Record<NodeId, NodeOutputs>;
1719
+ nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
1720
+ /** Append-only history of connection-scoped invocations (LLM/tool) for inspector and canvas. */
1721
+ connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
1722
+ mutableState?: PersistedMutableRunState;
1723
+ }
1724
+ interface CurrentStateExecutionRequest {
1725
+ workflow: WorkflowDefinition;
1726
+ items?: Items;
1727
+ parent?: ParentExecutionRef;
1728
+ executionOptions?: RunExecutionOptions;
1729
+ workflowSnapshot?: PersistedWorkflowSnapshot;
1730
+ mutableState?: PersistedMutableRunState;
1731
+ currentState?: RunCurrentState;
1732
+ stopCondition?: RunStopCondition;
1733
+ reset?: RunStateResetRequest;
1734
+ }
1735
+ interface ExecutionFrontierPlan {
1736
+ rootNodeId?: NodeId;
1737
+ rootNodeInput?: Items;
1738
+ queue: RunQueueEntry[];
1739
+ currentState: RunCurrentState;
1740
+ stopCondition: RunStopCondition;
1741
+ satisfiedNodeIds: ReadonlyArray<NodeId>;
1742
+ skippedNodeIds: ReadonlyArray<NodeId>;
1743
+ clearedNodeIds: ReadonlyArray<NodeId>;
1744
+ preservedPinnedNodeIds: ReadonlyArray<NodeId>;
1745
+ }
1746
+ type RunStatus = "running" | "pending" | "completed" | "failed";
1747
+ interface RunSummary {
1715
1748
  runId: RunId;
1716
1749
  workflowId: WorkflowId;
1717
- nodeId: NodeId;
1718
- /** Subworkflow depth of the **spawning** run (0 = root). Passed when starting a child run. */
1719
- subworkflowDepth?: number;
1720
- /** Effective max node activations from the parent run (propagated to child policy merge). */
1721
- engineMaxNodeActivations?: number;
1722
- /** Effective max subworkflow depth from the parent run (propagated to child policy merge). */
1723
- engineMaxSubworkflowDepth?: number;
1750
+ startedAt: string;
1751
+ status: RunStatus;
1724
1752
  /**
1725
- * Test-suite linkage inherited by the child subworkflow run. Set by whichever node
1726
- * spawns the subworkflow when its own `ctx.testContext` is present, so assertions
1727
- * emitted inside a subworkflow land under the correct parent test case.
1753
+ * Test-case status for runs dispatched as part of a TestSuiteRun. Carries the
1754
+ * assertion-rollup-corrected outcome the test orchestrator persists onto the row, so the
1755
+ * executions list can show "failed" for a run whose workflow completed cleanly but whose
1756
+ * assertions caught regressions. Absent for non-test runs and legacy rows.
1728
1757
  */
1729
- testContext?: RunTestContext;
1730
- }
1731
- interface RunDataSnapshot {
1732
- getOutputs(nodeId: NodeId): NodeOutputs | undefined;
1733
- getOutputItems<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, output?: OutputPortKey): Items<TJson>;
1734
- getOutputItem<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, itemIndex: number, output?: OutputPortKey): Item<TJson> | undefined;
1735
- }
1736
- interface MutableRunData extends RunDataSnapshot {
1737
- setOutputs(nodeId: NodeId, outputs: NodeOutputs): void;
1738
- dump(): Record<NodeId, NodeOutputs>;
1739
- }
1740
- interface RunDataFactory {
1741
- create(initial?: Record<NodeId, NodeOutputs>): MutableRunData;
1758
+ testCaseStatus?: TestCaseRunStatus;
1759
+ /** ISO timestamp when the run finished (derived from node snapshots or store `updatedAt`); omit while running/pending. */
1760
+ finishedAt?: string;
1761
+ parent?: ParentExecutionRef;
1762
+ executionOptions?: RunExecutionOptions;
1742
1763
  }
1743
- interface RunIdFactory {
1744
- makeRunId(): RunId;
1764
+ interface PendingNodeExecution {
1765
+ runId: RunId;
1766
+ activationId: NodeActivationId;
1767
+ workflowId: WorkflowId;
1768
+ nodeId: NodeId;
1769
+ itemsIn: number;
1770
+ inputsByPort: NodeInputsByPort;
1771
+ receiptId: string;
1772
+ queue?: string;
1773
+ batchId?: string;
1774
+ enqueuedAt: string;
1745
1775
  }
1746
- interface ActivationIdFactory {
1747
- makeActivationId(): NodeActivationId;
1776
+ interface PersistedRunSchedulingState {
1777
+ pending?: PendingNodeExecution;
1778
+ queue: RunQueueEntry[];
1748
1779
  }
1749
- type UpstreamRefPlaceholder = `$${number}`;
1750
- declare const branchRef: (index: number) => UpstreamRefPlaceholder;
1751
- type ExecutionMode = "local" | "worker";
1752
- interface NodeSchedulerDecision {
1753
- mode: ExecutionMode;
1754
- queue?: string;
1780
+ interface PersistedRunState {
1781
+ runId: RunId;
1782
+ workflowId: WorkflowId;
1783
+ startedAt: string;
1784
+ /** Canonical terminal time for listings and retention when persisted on the run root. */
1785
+ finishedAt?: string;
1786
+ /** Optimistic concurrency / CAS on the run aggregate (repository may increment on save). */
1787
+ revision?: number;
1788
+ parent?: ParentExecutionRef;
1789
+ executionOptions?: RunExecutionOptions;
1790
+ control?: PersistedRunControlState;
1791
+ workflowSnapshot?: PersistedWorkflowSnapshot;
1792
+ mutableState?: PersistedMutableRunState;
1793
+ /** Frozen at createRun from workflow + runtime defaults for prune/storage decisions. */
1794
+ policySnapshot?: PersistedRunPolicySnapshot;
1795
+ /** Successful node completions so far (for activation budget). */
1796
+ engineCounters?: EngineRunCounters;
1797
+ status: RunStatus;
1798
+ pending?: PendingNodeExecution;
1799
+ queue: RunQueueEntry[];
1800
+ outputsByNode: Record<NodeId, NodeOutputs>;
1801
+ nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
1802
+ /** Append-only history of connection invocations (LLM/tool) nested under owning nodes. */
1803
+ connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
1755
1804
  }
1756
- interface NodeOffloadPolicy {
1757
- decide(args: {
1805
+ interface WorkflowExecutionRepository {
1806
+ createRun(args: {
1807
+ runId: RunId;
1758
1808
  workflowId: WorkflowId;
1759
- nodeId: NodeId;
1760
- config: NodeConfigBase;
1761
- }): NodeSchedulerDecision;
1809
+ startedAt: string;
1810
+ parent?: ParentExecutionRef;
1811
+ executionOptions?: RunExecutionOptions;
1812
+ control?: PersistedRunControlState;
1813
+ workflowSnapshot?: PersistedWorkflowSnapshot;
1814
+ mutableState?: PersistedMutableRunState;
1815
+ policySnapshot?: PersistedRunPolicySnapshot;
1816
+ engineCounters?: EngineRunCounters;
1817
+ }): Promise<void>;
1818
+ load(runId: RunId): Promise<PersistedRunState | undefined>;
1819
+ loadSchedulingState(runId: RunId): Promise<PersistedRunSchedulingState | undefined>;
1820
+ save(state: PersistedRunState): Promise<void>;
1821
+ deleteRun?(runId: RunId): Promise<void>;
1762
1822
  }
1763
- /** Whether to persist run execution data after the workflow finishes. */
1764
- type WorkflowStoragePolicyMode = "ALL" | "SUCCESS" | "ERROR" | "NEVER";
1765
- type WorkflowStoragePolicySpec = WorkflowStoragePolicyMode | TypeToken<WorkflowStoragePolicyResolver>;
1766
- interface WorkflowStoragePolicyResolver {
1767
- shouldPersist(args: WorkflowStoragePolicyDecisionArgs): boolean | Promise<boolean>;
1823
+ interface WorkflowExecutionListingRepository {
1824
+ listRuns(args?: Readonly<{
1825
+ workflowId?: WorkflowId;
1826
+ limit?: number;
1827
+ }>): Promise<ReadonlyArray<RunSummary>>;
1768
1828
  }
1769
- interface WorkflowStoragePolicyDecisionArgs {
1829
+ /** Runs eligible for retention-based pruning (completed or failed, older than cutoff). */
1830
+ interface RunPruneCandidate {
1770
1831
  readonly runId: RunId;
1771
1832
  readonly workflowId: WorkflowId;
1772
- readonly workflow: WorkflowDefinition;
1773
- readonly finalStatus: "completed" | "failed";
1774
1833
  readonly startedAt: string;
1775
1834
  readonly finishedAt: string;
1776
1835
  }
1777
- interface WorkflowPrunePolicySpec {
1778
- readonly runDataRetentionSeconds?: number;
1779
- readonly binaryRetentionSeconds?: number;
1780
- readonly telemetrySpanRetentionSeconds?: number;
1781
- readonly telemetryArtifactRetentionSeconds?: number;
1782
- readonly telemetryMetricRetentionSeconds?: number;
1836
+ interface WorkflowExecutionPruneRepository {
1837
+ listRunsOlderThan(args: Readonly<{
1838
+ nowIso: string;
1839
+ defaultRetentionSeconds: number;
1840
+ limit?: number;
1841
+ }>): Promise<ReadonlyArray<RunPruneCandidate>>;
1783
1842
  }
1784
- interface PersistedRunPolicySnapshot {
1785
- readonly retentionSeconds?: number;
1786
- readonly binaryRetentionSeconds?: number;
1787
- readonly telemetrySpanRetentionSeconds?: number;
1788
- readonly telemetryArtifactRetentionSeconds?: number;
1789
- readonly telemetryMetricRetentionSeconds?: number;
1790
- readonly storagePolicy: WorkflowStoragePolicyMode;
1843
+ type RunResult = {
1844
+ runId: RunId;
1845
+ workflowId: WorkflowId;
1846
+ startedAt: string;
1847
+ status: "completed";
1848
+ outputs: Items;
1849
+ } | {
1850
+ runId: RunId;
1851
+ workflowId: WorkflowId;
1852
+ startedAt: string;
1853
+ status: "pending";
1854
+ pending: PendingNodeExecution;
1855
+ } | {
1856
+ runId: RunId;
1857
+ workflowId: WorkflowId;
1858
+ startedAt: string;
1859
+ status: "failed";
1860
+ error: {
1861
+ message: string;
1862
+ };
1863
+ };
1864
+ type WebhookRunResult = Readonly<{
1865
+ runId: RunId;
1866
+ workflowId: WorkflowId;
1867
+ startedAt: string;
1868
+ runStatus: "pending" | "completed";
1869
+ response: Items;
1870
+ }>;
1871
+ interface PersistedWorkflowTokenRegistryLike {
1872
+ register(type: TypeToken<unknown>, packageId: string, persistedNameOverride?: string): string;
1873
+ getTokenId(type: TypeToken<unknown>): string | undefined;
1874
+ resolve(tokenId: string): TypeToken<unknown> | undefined;
1875
+ registerFromWorkflows?(workflows: ReadonlyArray<WorkflowDefinition>): void;
1791
1876
  }
1792
- interface WorkflowErrorHandler {
1793
- onError(ctx: WorkflowErrorContext): void | Promise<void>;
1877
+ interface RunCompletionNotifier {
1878
+ resolveRunCompletion(result: RunResult): void;
1879
+ resolveWebhookResponse(result: WebhookRunResult): void;
1794
1880
  }
1795
- interface WorkflowErrorContext {
1796
- readonly runId: RunId;
1797
- readonly workflowId: WorkflowId;
1798
- readonly workflow: WorkflowDefinition;
1799
- readonly failedNodeId: NodeId;
1800
- readonly error: Error;
1801
- readonly startedAt: string;
1802
- readonly finishedAt: string;
1881
+ interface RunEventPublisherDeps {
1882
+ eventBus?: RunEventBus;
1803
1883
  }
1804
- type WorkflowErrorHandlerSpec = TypeToken<WorkflowErrorHandler> | WorkflowErrorHandler;
1805
- interface NodeErrorHandlerArgs<TConfig extends NodeConfigBase = NodeConfigBase> {
1806
- readonly kind: "single" | "multi";
1807
- readonly items: Items;
1808
- readonly inputsByPort: Readonly<Record<InputPortKey, Items>> | undefined;
1809
- readonly ctx: NodeExecutionContext<TConfig>;
1810
- readonly error: Error;
1884
+ //#endregion
1885
+ //#region src/contracts/agentMcpTypes.d.ts
1886
+ /**
1887
+ * Emitted as a span event when a credential is missing required scopes
1888
+ * (bind-time) or when callTool returns a permission error (runtime).
1889
+ * The credential type id can be looked up from the credential instance when needed.
1890
+ */
1891
+ interface NeedsReconsentEvent {
1892
+ readonly serverId: string;
1893
+ readonly credentialInstanceId: string;
1894
+ readonly missingScopesHint?: readonly string[];
1811
1895
  }
1812
- interface NodeErrorHandler {
1813
- handle<TConfig extends NodeConfigBase>(args: NodeErrorHandlerArgs<TConfig>): Promise<NodeOutputs>;
1896
+ /**
1897
+ * An opaque MCP tool map: keyed by serverId → (toolName → tool definition).
1898
+ * Typed as unknown so core does not depend on the AI SDK's ToolSet type.
1899
+ * AIAgentNode (in core-nodes, which does depend on ai) casts this to
1900
+ * ReadonlyMap<string, ToolSet> before passing to DeferredMetaToolStrategyFactory.
1901
+ */
1902
+ type AgentMcpToolMap = ReadonlyMap<string, Readonly<Record<string, unknown>>>;
1903
+ /**
1904
+ * Contract implemented by the host. Resolves MCP server bindings for an agent run
1905
+ * via the standard credential-binding table (one slot per declared server, keyed
1906
+ * by `(workflowId, mcpConnectionNodeId, "credential")`), and returns a ready-to-use
1907
+ * tool map with wrapped execute callbacks for telemetry and 403 detection.
1908
+ * Core-nodes imports this interface so AIAgentNode can inject it without
1909
+ * depending on the host.
1910
+ */
1911
+ interface AgentMcpIntegration {
1912
+ /**
1913
+ * Look up the credential binding per server, validate scopes, open pool
1914
+ * connections, and return a tool map keyed by serverId. Each tool's
1915
+ * execute callback includes:
1916
+ * - Telemetry child span (mcp.server_id, mcp.tool_name attributes)
1917
+ * - 403/permission error detection → emits a NeedsReconsentEvent span event
1918
+ *
1919
+ * Throws `AgentBindError` on validation failures (missing server, unbound
1920
+ * credential slot, missing credential instance, insufficient scopes).
1921
+ */
1922
+ prepareMcpTools(args: {
1923
+ readonly workflowId: WorkflowId;
1924
+ readonly agentNodeId: NodeId;
1925
+ readonly serverIds: ReadonlyArray<string>;
1926
+ readonly pinnedMcpTools: readonly string[];
1927
+ readonly emitSpanEvent: (event: TelemetrySpanEventRecord) => void;
1928
+ readonly startChildSpan: (args: {
1929
+ readonly name: string;
1930
+ readonly attributes?: Record<string, string>;
1931
+ }) => {
1932
+ readonly end: (args?: {
1933
+ status?: "ok" | "error";
1934
+ statusMessage?: string;
1935
+ }) => void;
1936
+ };
1937
+ /** Per-MCP-tool-call invocation appender. Optional; when omitted the wrapper emits only telemetry spans. */
1938
+ readonly appendMcpInvocation?: (args: ConnectionInvocationAppendArgs) => Promise<void>;
1939
+ /** Agent activation id to attach to each invocation record (used by canvas + inspector grouping). */
1940
+ readonly parentAgentActivationId?: NodeActivationId;
1941
+ /** Per-item iteration id when the agent runs inside a per-item loop. */
1942
+ readonly iterationId?: NodeIterationId;
1943
+ /** Item index (0-based) of the iteration that owns these tool calls. */
1944
+ readonly itemIndex?: number;
1945
+ /** Parent invocation id when this agent is itself executing as a sub-agent. */
1946
+ readonly parentInvocationId?: ConnectionInvocationId;
1947
+ }): Promise<AgentMcpToolMap>;
1814
1948
  }
1815
- type NodeErrorHandlerSpec = TypeToken<NodeErrorHandler> | NodeErrorHandler;
1816
- /** Runtime defaults when workflow omits prune/storage fields (typically from host env). */
1817
- interface WorkflowPolicyRuntimeDefaults {
1818
- readonly retentionSeconds?: number;
1819
- readonly binaryRetentionSeconds?: number;
1820
- readonly telemetrySpanRetentionSeconds?: number;
1821
- readonly telemetryArtifactRetentionSeconds?: number;
1822
- readonly telemetryMetricRetentionSeconds?: number;
1823
- readonly storagePolicy?: WorkflowStoragePolicyMode;
1949
+ //#endregion
1950
+ //#region src/contracts/AgentBindError.d.ts
1951
+ /**
1952
+ * Thrown at agent bind time when mcpServers declarations cannot be resolved.
1953
+ * Causes include: unknown server id, missing credential instance, insufficient scopes,
1954
+ * and ambiguous shorthand binding (multiple credential instances match).
1955
+ */
1956
+ declare class AgentBindError extends Error {
1957
+ constructor(message: string);
1958
+ }
1959
+ //#endregion
1960
+ //#region src/contracts/NoOpAgentMcpIntegration.d.ts
1961
+ /**
1962
+ * No-op implementation of AgentMcpIntegration.
1963
+ * Registered by the core engine runtime as a fallback when the host does not
1964
+ * supply a real implementation (e.g. in unit tests or headless engine setups).
1965
+ * Always returns an empty tool map so the agent runs with node-backed tools only.
1966
+ */
1967
+ declare class NoOpAgentMcpIntegration implements AgentMcpIntegration {
1968
+ prepareMcpTools(): Promise<AgentMcpToolMap>;
1824
1969
  }
1825
1970
  //#endregion
1826
1971
  //#region src/contracts/assertionTypes.d.ts
@@ -2116,12 +2261,46 @@ interface ExecutionInstanceDto {
2116
2261
  readonly itemIndex?: number;
2117
2262
  /** Parent invocation id when this instance was emitted by a sub-agent triggered by an outer LLM/tool call. */
2118
2263
  readonly parentInvocationId?: string;
2264
+ /**
2265
+ * When this instance is a SubWorkflow node activation, the run id of the child run it spawned.
2266
+ * Used by the UI to deep-link directly to the child execution.
2267
+ */
2268
+ readonly childRunId?: string;
2119
2269
  }
2120
2270
  interface WorkflowDetailSelectionState {
2121
2271
  readonly selectedSlotNodeId: NodeId | null;
2122
2272
  readonly selectedInstanceId: ExecutionInstanceId | null;
2123
2273
  }
2124
2274
  //#endregion
2275
+ //#region src/contracts/mcpTypes.d.ts
2276
+ type McpServerTransport = "http";
2277
+ interface McpServerDeclaration {
2278
+ /** Globally unique slug, e.g. "gmail". Workflow authors reference this. */
2279
+ id: string;
2280
+ displayName: string;
2281
+ description: string;
2282
+ transport: McpServerTransport;
2283
+ url: string;
2284
+ /**
2285
+ * Credential types accepted by this MCP server, matching CredentialRequirement.acceptedTypes.
2286
+ * Absent or empty means no credential is required.
2287
+ */
2288
+ acceptedCredentialTypes?: ReadonlyArray<string>;
2289
+ /**
2290
+ * Documentation only in MVP. The bind-time validator checks
2291
+ * requiredScopes ⊆ CredentialInstance.scopesGranted.
2292
+ */
2293
+ requiredScopes?: string[];
2294
+ /** Non-secret static headers merged onto every MCP request. */
2295
+ staticHeaders?: Record<string, string>;
2296
+ /**
2297
+ * Overrides for tool descriptions advertised by the MCP server.
2298
+ * Applied by the connection pool after tools/list.
2299
+ * Key: exact tool name as returned by the server.
2300
+ */
2301
+ toolDescriptionOverrides?: Record<string, string>;
2302
+ }
2303
+ //#endregion
2125
2304
  //#region src/contracts/emitPorts.d.ts
2126
2305
  declare const EMIT_PORTS_BRAND: unique symbol;
2127
2306
  type PortsEmission = Readonly<{
@@ -2286,6 +2465,9 @@ declare const NodeIdSlugifier: {
2286
2465
  //#region src/workflow/definition/ConnectionInvocationIdFactory.d.ts
2287
2466
  /**
2288
2467
  * Unique ids for persisted connection invocation history rows (LLM/tool calls under an owning node).
2468
+ *
2469
+ * Uses Web Crypto's `randomUUID` so this module is safe in browser-bundle contexts —
2470
+ * paired with `NodeIterationIdFactory` which had the same `node:crypto` regression.
2289
2471
  */
2290
2472
  declare class ConnectionInvocationIdFactory {
2291
2473
  static create(): string;
@@ -2302,6 +2484,12 @@ declare class ConnectionNodeIdFactory {
2302
2484
  static readonly connectionSegment: "__conn__";
2303
2485
  static languageModelConnectionNodeId(parentNodeId: NodeId): NodeId;
2304
2486
  static toolConnectionNodeId(parentNodeId: NodeId, toolName: string): NodeId;
2487
+ static mcpConnectionNodeId(parentNodeId: NodeId, serverId: string): NodeId;
2488
+ static isMcpConnectionNodeId(nodeId: NodeId): boolean;
2489
+ static parseMcpConnectionNodeId(nodeId: NodeId): Readonly<{
2490
+ parentNodeId: NodeId;
2491
+ serverId: string;
2492
+ }> | undefined;
2305
2493
  static isLanguageModelConnectionNodeId(nodeId: NodeId): boolean;
2306
2494
  static isToolConnectionNodeId(nodeId: NodeId): boolean;
2307
2495
  static parseLanguageModelConnectionNodeId(nodeId: NodeId): Readonly<{
@@ -2324,6 +2512,10 @@ declare class ConnectionNodeIdFactory {
2324
2512
  * Activations are per-batch (one scheduled execution of a node, possibly with N items).
2325
2513
  * Iterations refine that to one identifier per item-index inside the batch loop, so per-item
2326
2514
  * connection invocations and telemetry can be grouped without time-window heuristics.
2515
+ *
2516
+ * Uses Web Crypto's `randomUUID` (Node 19+ and all modern browsers) so this module is safe
2517
+ * to include in the browser entry. Importing `node:crypto` here previously leaked into the
2518
+ * canvas client bundle through `browser.ts` and OOM'd consumers' Turbopack builds.
2327
2519
  */
2328
2520
  declare class NodeIterationIdFactory {
2329
2521
  static create(): string;
@@ -2545,6 +2737,11 @@ declare class WorkflowSnapshotCodec {
2545
2737
  create(workflow: WorkflowDefinition): PersistedWorkflowSnapshot;
2546
2738
  hydrate(snapshotNode: PersistedWorkflowSnapshotNode, liveConfig: NodeConfigBase): NodeConfigBase;
2547
2739
  private serializeConfig;
2740
+ /**
2741
+ * Safely call `config.inspectorSummary()` and return a plain JSON-safe array, or undefined.
2742
+ * Returns undefined if the method is absent, throws, or produces no valid rows.
2743
+ */
2744
+ private safeInspectorSummary;
2548
2745
  private injectTokenIds;
2549
2746
  private mergeValue;
2550
2747
  private mergeNestedValue;
@@ -2638,5 +2835,5 @@ declare class RunIntentService {
2638
2835
  private createWebhookExecutionOptions;
2639
2836
  }
2640
2837
  //#endregion
2641
- export { RunRevision as $, InputPortKey as $a, PersistedMutableNodeState as $i, NodeActivationRequestBase as $n, NoOpExecutionTelemetryFactory as $r, PersistedRunPolicySnapshot as $t, RunFinishedAtFactory as A, TypeToken as Aa, CredentialSessionFactoryArgs as Ai, ExponentialRetryPolicySpec as An, WebhookControlSignal as Ar, ItemBinary as At, isUnbrandedPortsEmissionShape as B, singleton as Ba, PollingTriggerLogger as Bi, BinaryStorageWriteResult as Bn, TelemetryArtifactAttachment as Br, NodeDefinition as Bt, AnyTriggerNodeConfig as C, WorkflowExecutionRepository as Ca, CredentialInstanceRecord as Ci, WorkflowStoragePolicySpec as Cn, WorkflowRepository as Cr, deriveAssertionPassed as Ct, BranchStepsArg as D, InjectionToken$1 as Da, CredentialOAuth2ScopesFromPublicConfig as Di, runnableNodeOutputType as Dn, WorkflowSnapshotResolver as Dr, Edge as Dt, BranchOutputGuard as E, Disposable as Ea, CredentialOAuth2AuthDefinition as Ei, runnableNodeInputType as En, WorkflowSnapshotFactory as Er, BinaryPreviewKind as Et, NoRetryPolicy as F, injectable as Fa, CredentialTypeId as Fi, BinaryBody as Fn, AllWorkflowsActiveWorkflowActivationPolicy as Fr, JsonPrimitive as Ft, ExecutionPayloadPolicyFields as G, RunEvent as Ga, CurrentStateExecutionRequest as Gi, ExecutionContext as Gn, TelemetryMetricRecord as Gr, NodeIterationId as Gt, ConnectionInvocationKind as H, ENGINE_EXECUTION_LIMITS_DEFAULTS as Ha, ConnectionInvocationAppendArgs as Hi, EngineHost as Hn, TelemetryAttributePrimitive as Hr, NodeErrorHandlerArgs as Ht, getOriginIndexFromItem as I, instanceCachingFactory as Ia, CredentialTypeRegistry as Ii, BinaryStorage as In, WorkflowActivationPolicy as Ir, JsonValue as It, PersistedExecutionInstanceRecord as J, TestCaseRunStatus as Ja, NodeExecutionError as Ji, LiveWorkflowRepository as Jn, TelemetrySpanEventRecord as Jr, NodeOutputs as Jt, PayloadStorageKind as K, RunEventBus as Ka, EngineRunCounters as Ki, ExecutionContextFactory as Kn, TelemetryScope as Kr, NodeKind as Kt, PortsEmission as L, instancePerContainerCachingFactory as La, CredentialUnboundError as Li, BinaryStorageReadResult as Ln, ExecutionTelemetry as Lr, MutableRunData as Lt, NoOpCostTrackingTelemetry as M, delay as Ma, CredentialSetupStatus as Mi, NoneRetryPolicySpec as Mn, WebhookTriggerMatcher as Mr, JsonArray as Mt, ExpRetryPolicy as N, inject as Na, CredentialType as Ni, RetryPolicySpec as Nn, WebhookTriggerResolution as Nr, JsonNonArray as Nt, StepSequenceOutput as O, Lifecycle as Oa, CredentialRequirement as Oi, triggerNodeOutputType as On, HttpMethod as Or, ExecutionMode as Ot, RetryPolicy as P, injectAll as Pa, CredentialTypeDefinition as Pi, BinaryAttachmentCreateRequest as Pn, WebhookTriggerRoutingDiagnostics as Pr, JsonObject as Pt, RunIterationDto as Q, TestTriggerSetupContext as Qa, PendingNodeExecution as Qi, NodeActivationRequest as Qn, CodemationTelemetryAttributeNames as Qr, ParentExecutionRef as Qt, emitPorts as R, predicateAwareClassFactory as Ra, OAuth2ProviderFromPublicConfig as Ri, BinaryStorageStatResult as Rn, ExecutionTelemetryFactory as Rr, NodeActivationId as Rt, AnyRunnableNodeConfig as S, WorkflowExecutionPruneRepository as Sa, CredentialInstanceId as Si, WorkflowStoragePolicyResolver as Sn, WorkflowNodeInstanceFactory as Sr, DEFAULT_ASSERTION_PASS_THRESHOLD as St, BranchMoreArgs as T, DependencyContainer$1 as Ta, CredentialMaterialSourceKind as Ti, nodeRef as Tn, WorkflowRunnerService as Tr, BinaryAttachment as Tt, ExecutionInstanceDto as U, EngineExecutionLimitsPolicy as Ua, ConnectionInvocationId as Ui, ExecutableTriggerNode as Un, TelemetryAttributes as Ur, NodeErrorHandlerSpec as Ut, BatchId as V, CoreTokens as Va, PollingTriggerDedupWindow as Vi, EngineDeps as Vn, TelemetryArtifactReference as Vr, NodeErrorHandler as Vt, ExecutionInstanceId as W, EngineExecutionLimitsPolicyConfig as Wa, ConnectionInvocationRecord as Wi, ExecutionBinaryService as Wn, TelemetryChildSpanStart as Wr, NodeIdRef as Wt, PersistedRunWorkItemKind as X, TestSuiteRunId as Xa, NodeExecutionStatus as Xi, NodeActivationContinuation as Xn, CodemationTelemetryMetricNames as Xr, NodeSchedulerDecision as Xt, PersistedRunSlotProjectionRecord as Y, TestSuiteRunStatus as Ya, NodeExecutionSnapshot as Yi, MultiInputNode as Yn, TelemetrySpanScope as Yr, NodeRef as Yt, PersistedRunWorkItemRecord as Z, TestTriggerNodeConfig as Za, NodeInputsByPort as Zi, NodeActivationReceipt as Zn, GenAiTelemetryAttributeNames as Zr, PairedItemRef as Zt, NodeIdSlugifier as _, RunStopCondition as _a, CredentialBindingKey as _i, WorkflowNodeConnection as _n, TriggerRuntimeDiagnostics as _r, itemExpr as _t, RunPolicySnapshotFactory as a, PersistedWorkflowSnapshotNode as aa, CostTrackingPriceQuote as ai, RunnableNodeInputJson as an, NodeExecutionScheduler as ar, WorkflowRunDetailDto as at, ChainCursor as b, WebhookRunResult as ba, CredentialHealthStatus as bi, WorkflowStoragePolicyDecisionArgs as bn, TriggerSetupStateRepository as br, AssertionResult as bt, RunTerminalPersistenceCoordinator as c, RunCompletionNotifier as ca, CostTrackingTelemetryFactory as ci, TriggerNodeOutputJson as cn, NodeResolver as cr, Expr as ct, DefaultWorkflowGraphFactory as d, RunExecutionOptions as da, CollectionStore as di, WorkflowDefinition as dn, PreparedNodeActivationDispatch as dr, ItemExpr as dt, PersistedMutableRunState as ea, NoOpExecutionTelemetry as ei, RunDataFactory as en, NodeConnectionName as eo, NodeActivationScheduler as er, RunSlotProjectionState as et, WorkflowExecutableNodeClassifierFactory as f, RunPruneCandidate as fa, CollectionsContext as fi, WorkflowErrorContext as fn, RunnableNode as fr, ItemExprArgs as ft, ConnectionInvocationIdFactory as g, RunStatus as ga, CredentialBinding as gi, WorkflowGraphFactory as gn, TriggerNode as gr, isItemExpr as gt, ConnectionNodeIdFactory as h, RunStateResetRequest as ha, CredentialAuthDefinition as hi, WorkflowGraph as hn, TriggerCleanupHandle as hr, ItemExprResolvedContext as ht, WorkflowSnapshotCodec as i, PersistedWorkflowSnapshot as ia, CostTrackingComponent as ii, RunnableNodeConfig as in, WorkflowId as io, NodeExecutionRequestHandler as ir, WorkflowDetailSelectionState as it, NoOpCostTrackingTelemetryFactory as j, container$1 as ja, CredentialSessionService as ji, FixedRetryPolicySpec as jn, WebhookInvocationMatch as jr, Items as jt, ValidStepSequence as k, RegistrationOptions as ka, CredentialSessionFactory as ki, triggerNodeSetupStateType as kn, TriggerInstanceId as kr, Item as kt, WorkflowStoragePolicyEvaluator as l, RunCurrentState as la, CostTrackingTelemetryMetricNames as li, TriggerNodeSetupState as ln, PersistedTriggerSetupState as lr, Param as lt, NodeIterationIdFactory as m, RunResult as ma, CredentialAdvancedSectionPresentation as mi, WorkflowErrorHandlerSpec as mn, TestableTriggerNode as mr, ItemExprContext as mt, InMemoryLiveWorkflowRepository as n, PersistedRunSchedulingState as na, NoOpTelemetrySpanScope as ni, RunId as nn, OutputPortKey as no, NodeExecutionContext as nr, WorkItemId as nt, EngineExecutionLimitsPolicyFactory as o, PersistedWorkflowTokenRegistryLike as oa, CostTrackingTelemetry as oi, RunnableNodeOutputJson as on, NodeExecutionStatePublisher as or, CostCatalog as ot, WorkflowExecutableNodeClassifier as p, RunQueueEntry as pa, AnyCredentialType as pi, WorkflowErrorHandler as pn, RunnableNodeExecuteArgs as pr, ItemExprCallback as pt, PersistedExecutionInstanceKind as q, RunEventSubscription as qa, ExecutionFrontierPlan as qi, ItemNode as qn, TelemetrySpanEnd as qr, NodeOffloadPolicy as qt, EngineWorkflowRunnerService as r, PersistedRunState as ra, NoOpTelemetryArtifactReference as ri, RunIdFactory as rn, PersistedTokenId as ro, NodeExecutionRequest as rr, WorkItemStatus as rt, WorkflowPolicyErrorServices as s, PinnedNodeOutputsByPort as sa, CostTrackingTelemetryAttributeNames as si, TriggerNodeConfig as sn, NodeExecutor as sr, CostCatalogEntry as st, RunIntentService as t, PersistedRunControlState as ta, NoOpNodeExecutionTelemetry as ti, RunDataSnapshot as tn, NodeId as to, NodeBinaryAttachmentService as tr, SlotExecutionStateDto as tt, Engine as u, RunEventPublisherDeps as ua, CostTrackingUsageRecord as ui, UpstreamRefPlaceholder as un, PollingTriggerHandle as ur, ParamDeep as ut, WorkflowDefinitionError as v, RunSummary as va, CredentialFieldSchema as vi, WorkflowPolicyRuntimeDefaults as vn, TriggerSetupContext as vr, resolveItemExprsForExecution as vt, BooleanWhenOverloads as w, Container as wa, CredentialJsonRecord as wi, branchRef as wn, WorkflowRunnerResolver as wr, ActivationIdFactory as wt, WhenBuilder as x, WorkflowExecutionListingRepository as xa, CredentialHealthTester as xi, WorkflowStoragePolicyMode as xn, TriggerTestItemsContext as xr, AssertionResultProvenance as xt, WorkflowBuilder as y, RunTestContext as ya, CredentialHealth as yi, WorkflowPrunePolicySpec as yn, TriggerSetupStateFor as yr, resolveItemExprsInUnknown as yt, isPortsEmission as z, registry as za, NoOpPollingTriggerLogger as zi, BinaryStorageWriteRequest as zn, NodeExecutionTelemetry as zr, NodeConfigBase as zt };
2642
- //# sourceMappingURL=RunIntentService-BE9CAkbf.d.ts.map
2838
+ export { PersistedRunWorkItemRecord as $, CredentialTypeDefinition as $a, WebhookTriggerRoutingDiagnostics as $i, JsonPrimitive as $n, BinaryAttachmentCreateRequest as $r, RunEventPublisherDeps as $t, RunFinishedAtFactory as A, CollectionStore as Aa, PreparedNodeActivationDispatch as Ai, CoreTokens as An, WorkflowDefinition as Ar, NeedsReconsentEvent as At, isUnbrandedPortsEmissionShape as B, CredentialHealthTester as Ba, TriggerTestItemsContext as Bi, TestTriggerNodeConfig as Bn, WorkflowStoragePolicyMode as Br, NodeInputsByPort as Bt, AnyTriggerNodeConfig as C, CostTrackingComponent as Ca, NodeExecutionRequestHandler as Ci, injectAll as Cn, RunnableNodeConfig as Cr, AssertionResultProvenance as Ct, BranchStepsArg as D, CostTrackingTelemetryFactory as Da, NodeResolver as Di, predicateAwareClassFactory as Dn, TriggerNodeOutputJson as Dr, AgentBindError as Dt, BranchOutputGuard as E, CostTrackingTelemetryAttributeNames as Ea, NodeExecutor as Ei, instancePerContainerCachingFactory as En, TriggerNodeConfig as Er, NoOpAgentMcpIntegration as Et, NoRetryPolicy as F, CredentialBinding as Fa, TriggerNode as Fi, RunEventBus as Fn, WorkflowGraphFactory as Fr, EngineRunCounters as Ft, ExecutionInstanceDto as G, CredentialOAuth2AuthDefinition as Ga, WorkflowSnapshotFactory as Gi, Edge as Gn, runnableNodeInputType as Gr, PersistedRunSchedulingState as Gt, McpServerTransport as H, CredentialInstanceRecord as Ha, WorkflowRepository as Hi, ActivationIdFactory as Hn, WorkflowStoragePolicySpec as Hr, PersistedMutableNodeState as Ht, getOriginIndexFromItem as I, CredentialBindingKey as Ia, TriggerRuntimeDiagnostics as Ii, RunEventSubscription as In, WorkflowNodeConnection as Ir, ExecutionFrontierPlan as It, PayloadStorageKind as J, CredentialSessionFactory as Ja, TriggerInstanceId as Ji, ItemBinary as Jn, triggerNodeSetupStateType as Jr, PersistedWorkflowSnapshotNode as Jt, ExecutionInstanceId as K, CredentialOAuth2ScopesFromPublicConfig as Ka, WorkflowSnapshotResolver as Ki, ExecutionMode as Kn, runnableNodeOutputType as Kr, PersistedRunState as Kt, PortsEmission as L, CredentialFieldSchema as La, TriggerSetupContext as Li, TestCaseRunStatus as Ln, WorkflowPolicyRuntimeDefaults as Lr, NodeExecutionError as Lt, NoOpCostTrackingTelemetry as M, AnyCredentialType as Ma, RunnableNodeExecuteArgs as Mi, EngineExecutionLimitsPolicy as Mn, WorkflowErrorHandler as Mr, ConnectionInvocationId as Mt, ExpRetryPolicy as N, CredentialAdvancedSectionPresentation as Na, TestableTriggerNode as Ni, EngineExecutionLimitsPolicyConfig as Nn, WorkflowErrorHandlerSpec as Nr, ConnectionInvocationRecord as Nt, StepSequenceOutput as O, CostTrackingTelemetryMetricNames as Oa, PersistedTriggerSetupState as Oi, registry as On, TriggerNodeSetupState as Or, AgentMcpIntegration as Ot, RetryPolicy as P, CredentialAuthDefinition as Pa, TriggerCleanupHandle as Pi, RunEvent as Pn, WorkflowGraph as Pr, CurrentStateExecutionRequest as Pt, PersistedRunWorkItemKind as Q, CredentialType as Qa, WebhookTriggerResolution as Qi, JsonObject as Qn, RetryPolicySpec as Qr, RunCurrentState as Qt, emitPorts as R, CredentialHealth as Ra, TriggerSetupStateFor as Ri, TestSuiteRunStatus as Rn, WorkflowPrunePolicySpec as Rr, NodeExecutionSnapshot as Rt, AnyRunnableNodeConfig as S, NoOpTelemetryArtifactReference as Sa, NodeExecutionRequest as Si, inject as Sn, RunIdFactory as Sr, AssertionResult as St, BranchMoreArgs as T, CostTrackingTelemetry as Ta, NodeExecutionStatePublisher as Ti, instanceCachingFactory as Tn, RunnableNodeOutputJson as Tr, deriveAssertionPassed as Tt, BatchId as U, CredentialJsonRecord as Ua, WorkflowRunnerResolver as Ui, BinaryAttachment as Un, branchRef as Ur, PersistedMutableRunState as Ut, McpServerDeclaration as V, CredentialInstanceId as Va, WorkflowNodeInstanceFactory as Vi, TestTriggerSetupContext as Vn, WorkflowStoragePolicyResolver as Vr, PendingNodeExecution as Vt, ConnectionInvocationKind as W, CredentialMaterialSourceKind as Wa, WorkflowRunnerService as Wi, BinaryPreviewKind as Wn, nodeRef as Wr, PersistedRunControlState as Wt, PersistedExecutionInstanceRecord as X, CredentialSessionService as Xa, WebhookInvocationMatch as Xi, JsonArray as Xn, FixedRetryPolicySpec as Xr, PinnedNodeOutputsByPort as Xt, PersistedExecutionInstanceKind as Y, CredentialSessionFactoryArgs as Ya, WebhookControlSignal as Yi, Items as Yn, ExponentialRetryPolicySpec as Yr, PersistedWorkflowTokenRegistryLike as Yt, PersistedRunSlotProjectionRecord as Z, CredentialSetupStatus as Za, WebhookTriggerMatcher as Zi, JsonNonArray as Zn, NoneRetryPolicySpec as Zr, RunCompletionNotifier as Zt, NodeIdSlugifier as _, CodemationTelemetryAttributeNames as _a, NodeActivationRequest as _i, Lifecycle as _n, ParentExecutionRef as _r, ItemExprResolvedContext as _t, RunPolicySnapshotFactory as a, TelemetryArtifactAttachment as aa, BinaryStorageWriteResult as ai, RunStatus as an, PollingTriggerLogger as ao, NodeErrorHandler as ar, WorkItemStatus as at, ChainCursor as b, NoOpNodeExecutionTelemetry as ba, NodeBinaryAttachmentService as bi, container$1 as bn, RunDataSnapshot as br, resolveItemExprsForExecution as bt, RunTerminalPersistenceCoordinator as c, TelemetryAttributes as ca, ExecutableTriggerNode as ci, RunTestContext as cn, NodeConnectionName as co, NodeIdRef as cr, CostCatalog as ct, DefaultWorkflowGraphFactory as d, TelemetryScope as da, ExecutionContextFactory as di, WorkflowExecutionPruneRepository as dn, PersistedTokenId as do, NodeKind as dr, Param as dt, AllWorkflowsActiveWorkflowActivationPolicy as ea, BinaryBody as ei, RunExecutionOptions as en, CredentialTypeId as eo, JsonValue as er, RunIterationDto as et, WorkflowExecutableNodeClassifierFactory as f, TelemetrySpanEnd as fa, ItemNode as fi, WorkflowExecutionRepository as fn, WorkflowId as fo, NodeOffloadPolicy as fr, ParamDeep as ft, ConnectionInvocationIdFactory as g, GenAiTelemetryAttributeNames as ga, NodeActivationReceipt as gi, InjectionToken$1 as gn, PairedItemRef as gr, ItemExprContext as gt, ConnectionNodeIdFactory as h, CodemationTelemetryMetricNames as ha, NodeActivationContinuation as hi, Disposable as hn, NodeSchedulerDecision as hr, ItemExprCallback as ht, WorkflowSnapshotCodec as i, NodeExecutionTelemetry as ia, BinaryStorageWriteRequest as ii, RunStateResetRequest as in, NoOpPollingTriggerLogger as io, NodeDefinition as ir, WorkItemId as it, NoOpCostTrackingTelemetryFactory as j, CollectionsContext as ja, RunnableNode as ji, ENGINE_EXECUTION_LIMITS_DEFAULTS as jn, WorkflowErrorContext as jr, ConnectionInvocationAppendArgs as jt, ValidStepSequence as k, CostTrackingUsageRecord as ka, PollingTriggerHandle as ki, singleton as kn, UpstreamRefPlaceholder as kr, AgentMcpToolMap as kt, WorkflowStoragePolicyEvaluator as l, TelemetryChildSpanStart as la, ExecutionBinaryService as li, WebhookRunResult as ln, NodeId as lo, NodeInspectorSummaryRow as lr, CostCatalogEntry as lt, NodeIterationIdFactory as m, TelemetrySpanScope as ma, MultiInputNode as mi, DependencyContainer$1 as mn, NodeRef as mr, ItemExprArgs as mt, InMemoryLiveWorkflowRepository as n, ExecutionTelemetry as na, BinaryStorageReadResult as ni, RunQueueEntry as nn, CredentialUnboundError as no, NodeActivationId as nr, RunSlotProjectionState as nt, EngineExecutionLimitsPolicyFactory as o, TelemetryArtifactReference as oa, EngineDeps as oi, RunStopCondition as on, PollingTriggerDedupWindow as oo, NodeErrorHandlerArgs as or, WorkflowDetailSelectionState as ot, WorkflowExecutableNodeClassifier as p, TelemetrySpanEventRecord as pa, LiveWorkflowRepository as pi, Container as pn, NodeOutputs as pr, ItemExpr as pt, ExecutionPayloadPolicyFields as q, CredentialRequirement as qa, HttpMethod as qi, Item as qn, triggerNodeOutputType as qr, PersistedWorkflowSnapshot as qt, EngineWorkflowRunnerService as r, ExecutionTelemetryFactory as ra, BinaryStorageStatResult as ri, RunResult as rn, OAuth2ProviderFromPublicConfig as ro, NodeConfigBase as rr, SlotExecutionStateDto as rt, WorkflowPolicyErrorServices as s, TelemetryAttributePrimitive as sa, EngineHost as si, RunSummary as sn, InputPortKey as so, NodeErrorHandlerSpec as sr, WorkflowRunDetailDto as st, RunIntentService as t, WorkflowActivationPolicy as ta, BinaryStorage as ti, RunPruneCandidate as tn, CredentialTypeRegistry as to, MutableRunData as tr, RunRevision as tt, Engine as u, TelemetryMetricRecord as ua, ExecutionContext as ui, WorkflowExecutionListingRepository as un, OutputPortKey as uo, NodeIterationId as ur, Expr as ut, WorkflowDefinitionError as v, NoOpExecutionTelemetryFactory as va, NodeActivationRequestBase as vi, RegistrationOptions as vn, PersistedRunPolicySnapshot as vr, isItemExpr as vt, BooleanWhenOverloads as w, CostTrackingPriceQuote as wa, NodeExecutionScheduler as wi, injectable as wn, RunnableNodeInputJson as wr, DEFAULT_ASSERTION_PASS_THRESHOLD as wt, WhenBuilder as x, NoOpTelemetrySpanScope as xa, NodeExecutionContext as xi, delay as xn, RunId as xr, resolveItemExprsInUnknown as xt, WorkflowBuilder as y, NoOpExecutionTelemetry as ya, NodeActivationScheduler as yi, TypeToken as yn, RunDataFactory as yr, itemExpr as yt, isPortsEmission as z, CredentialHealthStatus as za, TriggerSetupStateRepository as zi, TestSuiteRunId as zn, WorkflowStoragePolicyDecisionArgs as zr, NodeExecutionStatus as zt };
2839
+ //# sourceMappingURL=RunIntentService-BrEq6Jm6.d.ts.map