@codemation/core 0.10.2 → 0.11.1

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 (100) hide show
  1. package/CHANGELOG.md +183 -0
  2. package/dist/CostCatalogContract-DZgcUBE4.d.cts +19 -0
  3. package/dist/{EngineRuntimeRegistration.types-ClLuY1FG.d.ts → EngineRuntimeRegistration.types-BQbS9_gs.d.ts} +2 -2
  4. package/dist/{EngineRuntimeRegistration.types-BryWi2mA.d.cts → EngineRuntimeRegistration.types-Cggm5GVY.d.cts} +8 -2
  5. package/dist/{InMemoryRunDataFactory-DeXNJt1O.d.cts → InMemoryRunDataFactory-C7YItvHG.d.cts} +9 -19
  6. package/dist/{InMemoryRunEventBusRegistry-sM4z4n_i.js → InMemoryRunEventBusRegistry-Bwunvt1T.js} +1 -1
  7. package/dist/{InMemoryRunEventBusRegistry-sM4z4n_i.js.map → InMemoryRunEventBusRegistry-Bwunvt1T.js.map} +1 -1
  8. package/dist/{InMemoryRunEventBusRegistry-VM3OWnHo.cjs → InMemoryRunEventBusRegistry-Sa86VxuV.cjs} +1 -1
  9. package/dist/{InMemoryRunEventBusRegistry-VM3OWnHo.cjs.map → InMemoryRunEventBusRegistry-Sa86VxuV.cjs.map} +1 -1
  10. package/dist/ItemsInputNormalizer-C_dpn76M.d.cts +407 -0
  11. package/dist/ItemsInputNormalizer-CwdOhSAK.cjs +43 -0
  12. package/dist/ItemsInputNormalizer-CwdOhSAK.cjs.map +1 -0
  13. package/dist/ItemsInputNormalizer-D-MH8MBs.js +36 -0
  14. package/dist/ItemsInputNormalizer-D-MH8MBs.js.map +1 -0
  15. package/dist/ItemsInputNormalizer-_Mfcd3YU.d.ts +321 -0
  16. package/dist/RunIntentService-BVur7x9n.d.ts +285 -0
  17. package/dist/RunIntentService-CEF-sFfI.d.cts +206 -0
  18. package/dist/{RunIntentService-BqNjrksF.d.cts → agentMcpTypes-ZiNbNsEi.d.cts} +1717 -1809
  19. package/dist/bootstrap/index.cjs +4 -2
  20. package/dist/bootstrap/index.d.cts +8 -3
  21. package/dist/bootstrap/index.d.ts +6 -4
  22. package/dist/bootstrap/index.js +4 -2
  23. package/dist/{bootstrap-DtjQtuvi.cjs → bootstrap-BxuTFTLB.cjs} +41 -34
  24. package/dist/bootstrap-BxuTFTLB.cjs.map +1 -0
  25. package/dist/{bootstrap-BfFKGzyj.js → bootstrap-D_Yyi0wL.js} +9 -2
  26. package/dist/bootstrap-D_Yyi0wL.js.map +1 -0
  27. package/dist/browser.cjs +16 -0
  28. package/dist/browser.d.cts +4 -0
  29. package/dist/browser.d.ts +3 -0
  30. package/dist/browser.js +4 -0
  31. package/dist/contracts-CK0x6w_G.cjs +74 -0
  32. package/dist/contracts-CK0x6w_G.cjs.map +1 -0
  33. package/dist/contracts-DXdfTdpW.js +50 -0
  34. package/dist/contracts-DXdfTdpW.js.map +1 -0
  35. package/dist/contracts.cjs +6 -0
  36. package/dist/contracts.d.cts +5 -0
  37. package/dist/contracts.d.ts +2 -0
  38. package/dist/contracts.js +3 -0
  39. package/dist/di-0Wop7z1y.js +376 -0
  40. package/dist/di-0Wop7z1y.js.map +1 -0
  41. package/dist/di-BlEKdoZS.cjs +489 -0
  42. package/dist/di-BlEKdoZS.cjs.map +1 -0
  43. package/dist/executionPersistenceContracts-BgZMRsTa.d.cts +275 -0
  44. package/dist/{index-CJQtTY_M.d.ts → index-62Ba9f7D.d.ts} +114 -320
  45. package/dist/{RunIntentService-CI-F8qQ7.d.ts → index-zWGtEhrf.d.ts} +1811 -1914
  46. package/dist/index.cjs +76 -71
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.cts +112 -656
  49. package/dist/index.d.ts +5 -3
  50. package/dist/index.js +52 -50
  51. package/dist/index.js.map +1 -1
  52. package/dist/params-B5SENSzZ.d.cts +44 -0
  53. package/dist/{runtime-_ywksLa6.cjs → runtime-DBzq5YBi.cjs} +125 -489
  54. package/dist/runtime-DBzq5YBi.cjs.map +1 -0
  55. package/dist/{runtime-DbMjpb5d.js → runtime-cxmUkk0l.js} +117 -369
  56. package/dist/runtime-cxmUkk0l.js.map +1 -0
  57. package/dist/testing.cjs +23 -21
  58. package/dist/testing.cjs.map +1 -1
  59. package/dist/testing.d.cts +4 -3
  60. package/dist/testing.d.ts +3 -2
  61. package/dist/testing.js +5 -3
  62. package/dist/testing.js.map +1 -1
  63. package/package.json +12 -17
  64. package/src/ai/AgentConnectionNodeCollector.ts +47 -5
  65. package/src/authoring/defineNode.types.ts +21 -1
  66. package/src/authoring/definePollingTrigger.types.ts +20 -0
  67. package/src/binaries/UnavailableBinaryStorage.ts +6 -0
  68. package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +9 -0
  69. package/src/browser.ts +1 -0
  70. package/src/contracts/AgentBindError.ts +11 -0
  71. package/src/contracts/CodemationTelemetryAttributeNames.ts +4 -0
  72. package/src/contracts/NoOpAgentMcpIntegration.ts +13 -0
  73. package/src/contracts/agentMcpTypes.ts +64 -0
  74. package/src/contracts/index.ts +4 -0
  75. package/src/contracts/mcpTypes.ts +29 -0
  76. package/src/contracts/runTypes.ts +8 -0
  77. package/src/contracts/runtimeTypes.ts +4 -0
  78. package/src/contracts/workflowTypes.ts +21 -0
  79. package/src/contracts.ts +3 -0
  80. package/src/credentials/OAuthFlowExecutor.types.ts +45 -0
  81. package/src/di/CoreTokens.ts +7 -0
  82. package/src/execution/InProcessRetryRunner.ts +31 -5
  83. package/src/execution/NodeExecutor.ts +27 -7
  84. package/src/execution/NodeRunStateWriter.ts +2 -0
  85. package/src/index.ts +10 -0
  86. package/src/orchestration/RunContinuationService.ts +6 -2
  87. package/src/runStorage/InMemoryBinaryStorageRegistry.ts +10 -0
  88. package/src/scheduler/InlineDrivingScheduler.ts +26 -22
  89. package/src/types/index.ts +1 -0
  90. package/src/validation/WorkflowEdgePortError.types.ts +16 -0
  91. package/src/validation/WorkflowEdgePortValidator.ts +52 -0
  92. package/src/workflow/definition/ConnectionInvocationIdFactory.ts +4 -3
  93. package/src/workflow/definition/ConnectionNodeIdFactory.ts +25 -0
  94. package/src/workflow/definition/NodeIterationIdFactory.ts +5 -3
  95. package/src/workflowSnapshots/WorkflowSnapshotCodec.ts +42 -10
  96. package/tsdown.config.ts +1 -1
  97. package/dist/bootstrap-BfFKGzyj.js.map +0 -1
  98. package/dist/bootstrap-DtjQtuvi.cjs.map +0 -1
  99. package/dist/runtime-DbMjpb5d.js.map +0 -1
  100. package/dist/runtime-_ywksLa6.cjs.map +0 -1
@@ -16,1825 +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.
207
- */
208
- declare class EngineExecutionLimitsPolicy {
209
- private readonly config;
210
- constructor(config?: EngineExecutionLimitsPolicyConfig);
211
- /**
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.
214
- */
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;
254
- /**
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".
259
- */
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;
334
- }>;
335
- collect?: Readonly<{
336
- expectedInputs: ReadonlyArray<InputPortKey>;
337
- received: Readonly<Record<InputPortKey, Items>>;
338
- }>;
339
- }
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
- * When the node is a SubWorkflow invocation, the run id of the child run it spawned.
364
- * Populated after the child run completes so the UI can deep-link to that specific execution.
365
- */
366
- childRunId?: RunId;
367
- }
368
- /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
369
- type ConnectionInvocationId = string;
370
- /**
371
- * One logical LLM or tool call under an owning workflow node (e.g. AI agent).
372
- * The owning node defines what {@link managedInput} and {@link managedOutput} contain.
373
- */
374
- interface ConnectionInvocationRecord {
375
- readonly invocationId: ConnectionInvocationId;
376
- readonly runId: RunId;
377
- readonly workflowId: WorkflowId;
378
- readonly connectionNodeId: NodeId;
379
- readonly parentAgentNodeId: NodeId;
380
- readonly parentAgentActivationId: NodeActivationId;
381
- readonly status: NodeExecutionStatus;
382
- readonly managedInput?: JsonValue;
383
- readonly managedOutput?: JsonValue;
384
- readonly error?: NodeExecutionError;
385
- readonly queuedAt?: string;
386
- readonly startedAt?: string;
387
- readonly finishedAt?: string;
388
- readonly updatedAt: string;
389
- /** Per-item iteration id minted by the engine when this invocation occurred inside a runnable node's per-item loop. */
390
- readonly iterationId?: NodeIterationId;
391
- /** Item index (0-based) of the iteration that produced this invocation. */
392
- readonly itemIndex?: number;
393
- /** When set, this invocation was produced inside a sub-agent triggered by the named parent invocation. */
394
- readonly parentInvocationId?: ConnectionInvocationId;
395
- }
396
- /** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
397
- type ConnectionInvocationAppendArgs = Readonly<{
398
- invocationId: ConnectionInvocationId;
399
- connectionNodeId: NodeId;
400
- parentAgentNodeId: NodeId;
401
- parentAgentActivationId: NodeActivationId;
402
- status: NodeExecutionStatus;
403
- managedInput?: JsonValue;
404
- managedOutput?: JsonValue;
405
- error?: NodeExecutionError;
406
- queuedAt?: string;
407
- startedAt?: string;
408
- finishedAt?: string;
409
- iterationId?: NodeIterationId;
410
- itemIndex?: number;
411
- parentInvocationId?: ConnectionInvocationId;
412
- }>;
413
- interface RunCurrentState {
414
- outputsByNode: Record<NodeId, NodeOutputs>;
415
- nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
416
- /** Append-only history of connection-scoped invocations (LLM/tool) for inspector and canvas. */
417
- connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
418
- mutableState?: PersistedMutableRunState;
419
- }
420
- interface CurrentStateExecutionRequest {
421
- workflow: WorkflowDefinition;
422
- items?: Items;
423
- parent?: ParentExecutionRef;
424
- executionOptions?: RunExecutionOptions;
425
- workflowSnapshot?: PersistedWorkflowSnapshot;
426
- mutableState?: PersistedMutableRunState;
427
- currentState?: RunCurrentState;
428
- stopCondition?: RunStopCondition;
429
- reset?: RunStateResetRequest;
430
- }
431
- interface ExecutionFrontierPlan {
432
- rootNodeId?: NodeId;
433
- rootNodeInput?: Items;
434
- queue: RunQueueEntry[];
435
- currentState: RunCurrentState;
436
- stopCondition: RunStopCondition;
437
- satisfiedNodeIds: ReadonlyArray<NodeId>;
438
- skippedNodeIds: ReadonlyArray<NodeId>;
439
- clearedNodeIds: ReadonlyArray<NodeId>;
440
- preservedPinnedNodeIds: ReadonlyArray<NodeId>;
441
- }
442
- type RunStatus = "running" | "pending" | "completed" | "failed";
443
- interface RunSummary {
444
- runId: RunId;
445
- workflowId: WorkflowId;
446
- startedAt: string;
447
- status: RunStatus;
448
- /**
449
- * Test-case status for runs dispatched as part of a TestSuiteRun. Carries the
450
- * assertion-rollup-corrected outcome the test orchestrator persists onto the row, so the
451
- * executions list can show "failed" for a run whose workflow completed cleanly but whose
452
- * assertions caught regressions. Absent for non-test runs and legacy rows.
453
- */
454
- testCaseStatus?: TestCaseRunStatus;
455
- /** ISO timestamp when the run finished (derived from node snapshots or store `updatedAt`); omit while running/pending. */
456
- finishedAt?: string;
457
- parent?: ParentExecutionRef;
458
- executionOptions?: RunExecutionOptions;
459
- }
460
- interface PendingNodeExecution {
461
- runId: RunId;
462
- activationId: NodeActivationId;
463
- workflowId: WorkflowId;
464
- nodeId: NodeId;
465
- itemsIn: number;
466
- inputsByPort: NodeInputsByPort;
467
- receiptId: string;
468
- queue?: string;
469
- batchId?: string;
470
- enqueuedAt: string;
471
- }
472
- interface PersistedRunSchedulingState {
473
- pending?: PendingNodeExecution;
474
- queue: RunQueueEntry[];
475
- }
476
- interface PersistedRunState {
477
- runId: RunId;
478
- workflowId: WorkflowId;
479
- startedAt: string;
480
- /** Canonical terminal time for listings and retention when persisted on the run root. */
481
- finishedAt?: string;
482
- /** Optimistic concurrency / CAS on the run aggregate (repository may increment on save). */
483
- revision?: number;
484
- parent?: ParentExecutionRef;
485
- executionOptions?: RunExecutionOptions;
486
- control?: PersistedRunControlState;
487
- workflowSnapshot?: PersistedWorkflowSnapshot;
488
- mutableState?: PersistedMutableRunState;
489
- /** Frozen at createRun from workflow + runtime defaults for prune/storage decisions. */
490
- policySnapshot?: PersistedRunPolicySnapshot;
491
- /** Successful node completions so far (for activation budget). */
492
- engineCounters?: EngineRunCounters;
493
- status: RunStatus;
494
- pending?: PendingNodeExecution;
495
- queue: RunQueueEntry[];
496
- outputsByNode: Record<NodeId, NodeOutputs>;
497
- nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
498
- /** Append-only history of connection invocations (LLM/tool) nested under owning nodes. */
499
- connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
500
- }
501
- interface WorkflowExecutionRepository {
502
- createRun(args: {
503
- runId: RunId;
504
- workflowId: WorkflowId;
505
- startedAt: string;
506
- parent?: ParentExecutionRef;
507
- executionOptions?: RunExecutionOptions;
508
- control?: PersistedRunControlState;
509
- workflowSnapshot?: PersistedWorkflowSnapshot;
510
- mutableState?: PersistedMutableRunState;
511
- policySnapshot?: PersistedRunPolicySnapshot;
512
- engineCounters?: EngineRunCounters;
513
- }): Promise<void>;
514
- load(runId: RunId): Promise<PersistedRunState | undefined>;
515
- loadSchedulingState(runId: RunId): Promise<PersistedRunSchedulingState | undefined>;
516
- save(state: PersistedRunState): Promise<void>;
517
- deleteRun?(runId: RunId): Promise<void>;
518
- }
519
- interface WorkflowExecutionListingRepository {
520
- listRuns(args?: Readonly<{
521
- workflowId?: WorkflowId;
522
- limit?: number;
523
- }>): Promise<ReadonlyArray<RunSummary>>;
524
- }
525
- /** Runs eligible for retention-based pruning (completed or failed, older than cutoff). */
526
- interface RunPruneCandidate {
527
- readonly runId: RunId;
528
- readonly workflowId: WorkflowId;
529
- readonly startedAt: string;
530
- readonly finishedAt: string;
531
- }
532
- interface WorkflowExecutionPruneRepository {
533
- listRunsOlderThan(args: Readonly<{
534
- nowIso: string;
535
- defaultRetentionSeconds: number;
536
- limit?: number;
537
- }>): Promise<ReadonlyArray<RunPruneCandidate>>;
538
- }
539
- type RunResult = {
540
- runId: RunId;
541
- workflowId: WorkflowId;
542
- startedAt: string;
543
- status: "completed";
544
- outputs: Items;
545
- } | {
546
- runId: RunId;
547
- workflowId: WorkflowId;
548
- startedAt: string;
549
- status: "pending";
550
- pending: PendingNodeExecution;
551
- } | {
552
- runId: RunId;
553
- workflowId: WorkflowId;
554
- startedAt: string;
555
- status: "failed";
556
- error: {
557
- message: string;
558
- };
559
- };
560
- type WebhookRunResult = Readonly<{
561
- runId: RunId;
562
- workflowId: WorkflowId;
563
- startedAt: string;
564
- runStatus: "pending" | "completed";
565
- response: Items;
566
- }>;
567
- interface PersistedWorkflowTokenRegistryLike {
568
- register(type: TypeToken<unknown>, packageId: string, persistedNameOverride?: string): string;
569
- getTokenId(type: TypeToken<unknown>): string | undefined;
570
- resolve(tokenId: string): TypeToken<unknown> | undefined;
571
- registerFromWorkflows?(workflows: ReadonlyArray<WorkflowDefinition>): void;
572
- }
573
- interface RunCompletionNotifier {
574
- resolveRunCompletion(result: RunResult): void;
575
- resolveWebhookResponse(result: WebhookRunResult): void;
576
- }
577
- interface RunEventPublisherDeps {
578
- eventBus?: RunEventBus;
579
- }
580
- //#endregion
581
- //#region src/triggers/polling/PollingTriggerDedupWindow.d.ts
582
- /**
583
- * Merges processed-ID windows for polling triggers, capping the total to avoid unbounded growth.
584
- * Plugin code receives an instance of this class via {@link PollingTriggerHandle.dedup}.
585
- */
586
- declare class PollingTriggerDedupWindow {
587
- static readonly defaultCapN = 2000;
588
- merge(previous: ReadonlyArray<string>, incoming: ReadonlyArray<string>, capN?: number): ReadonlyArray<string>;
589
- }
590
- //#endregion
591
- //#region src/triggers/polling/PollingTriggerLogger.d.ts
592
- /**
593
- * Minimal logger surface for the polling-trigger runtime.
594
- * Hosts supply this via {@link EngineDeps.pollingTriggerLogger};
595
- * when absent the runtime is silent.
241
+ * Represents a typed store for a single collection.
242
+ * All rows include auto-managed id, created_at, and updated_at fields.
596
243
  */
597
- interface PollingTriggerLogger {
598
- info(message: string): void;
599
- warn(message: string): void;
600
- error(message: string, exception?: Error): void;
601
- debug(message: string): void;
602
- }
603
- declare class NoOpPollingTriggerLogger implements PollingTriggerLogger {
604
- info(): void;
605
- warn(): void;
606
- error(): void;
607
- debug(): void;
608
- }
609
- //#endregion
610
- //#region src/contracts/credentialTypes.d.ts
611
- type CredentialTypeId = string;
612
- type CredentialInstanceId = string;
613
- type CredentialMaterialSourceKind = "db" | "env" | "code";
614
- type CredentialSetupStatus = "draft" | "ready";
615
- type CredentialHealthStatus = "unknown" | "healthy" | "failing";
616
- type CredentialFieldSchema = Readonly<{
617
- key: string;
618
- label: string;
619
- type: "string" | "password" | "textarea" | "json" | "boolean";
620
- required?: true;
621
- order?: number;
244
+ interface CollectionStore<TRow extends Record<string, unknown> = Record<string, unknown>> {
622
245
  /**
623
- * Where this field appears in the credential dialog. Use `"advanced"` for optional or
624
- * power-user fields; they render inside a collapsible section (see `CredentialTypeDefinition.advancedSection`).
625
- * Defaults to `"default"` when omitted.
246
+ * Insert a new row. id, created_at, and updated_at are auto-populated.
626
247
  */
627
- visibility?: "default" | "advanced";
628
- placeholder?: string;
629
- helpText?: string;
630
- /** When set, host resolves this field from process.env at runtime; env wins over stored values. */
631
- envVarName?: string;
248
+ insert(row: TRow): Promise<TRow & {
249
+ id: string;
250
+ created_at: Date;
251
+ updated_at: Date;
252
+ }>;
632
253
  /**
633
- * When set, the dialog shows a copy action for this exact string (e.g. a static OAuth redirect URI
634
- * pattern or documentation URL). Do not use for secret values.
254
+ * Get a single row by id.
635
255
  */
636
- copyValue?: string;
637
- /** Accessible label for the copy control (default: Copy). */
638
- copyButtonLabel?: string;
639
- }>;
640
- type CredentialRequirement = Readonly<{
641
- slotKey: string;
642
- label: string;
643
- acceptedTypes: ReadonlyArray<CredentialTypeId>;
644
- optional?: true;
645
- helpText?: string;
646
- helpUrl?: string;
647
- }>;
648
- type CredentialBindingKey = Readonly<{
649
- workflowId: WorkflowId;
650
- nodeId: NodeId;
651
- slotKey: string;
652
- }>;
653
- type CredentialBinding = Readonly<{
654
- key: CredentialBindingKey;
655
- instanceId: CredentialInstanceId;
656
- updatedAt: string;
657
- }>;
658
- type CredentialHealth = Readonly<{
659
- status: CredentialHealthStatus;
660
- message?: string;
661
- testedAt?: string;
662
- expiresAt?: string;
663
- details?: Readonly<Record<string, unknown>>;
664
- }>;
665
- type OAuth2ProviderFromPublicConfig = Readonly<{
666
- authorizeUrlFieldKey: string;
667
- tokenUrlFieldKey: string;
668
- userInfoUrlFieldKey?: string;
669
- }>;
670
- type CredentialOAuth2ScopesFromPublicConfig = Readonly<{
671
- presetFieldKey: string;
672
- presetScopes: Readonly<Record<string, ReadonlyArray<string>>>;
673
- customPresetKey?: string;
674
- customScopesFieldKey?: string;
675
- }>;
676
- type CredentialOAuth2AuthDefinition = Readonly<{
677
- kind: "oauth2";
678
- providerId: string;
679
- scopes: ReadonlyArray<string>;
680
- scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
681
- clientIdFieldKey?: string;
682
- clientSecretFieldKey?: string;
683
- } | {
684
- kind: "oauth2";
685
- providerFromPublicConfig: OAuth2ProviderFromPublicConfig;
686
- scopes: ReadonlyArray<string>;
687
- scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
688
- clientIdFieldKey?: string;
689
- clientSecretFieldKey?: string;
690
- } | {
691
- kind: "oauth2";
256
+ get(id: string): Promise<(TRow & {
257
+ id: string;
258
+ created_at: Date;
259
+ updated_at: Date;
260
+ }) | null>;
692
261
  /**
693
- * Free-form provider identifier for telemetry, DB rows, and Better Auth provider naming.
694
- * Not used for any registry lookup — URLs come from {@link authorizeUrl} / {@link tokenUrl}.
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.
695
271
  */
696
- providerId: string;
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;
283
+ }>;
697
284
  /**
698
- * Authorization endpoint. May contain `{publicFieldKey}` placeholders that the runtime
699
- * substitutes from the credential's resolved public config (URL-encoded).
700
- * Example: `https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize`
285
+ * Update a row by id with partial data.
701
286
  */
702
- authorizeUrl: string;
703
- /** Token endpoint. Same templating rules as {@link authorizeUrl}. */
704
- tokenUrl: string;
705
- /** Optional userinfo endpoint. Same templating rules as {@link authorizeUrl}. */
706
- userInfoUrl?: string;
707
- scopes: ReadonlyArray<string>;
708
- scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
709
- clientIdFieldKey?: string;
710
- clientSecretFieldKey?: string;
711
- }>;
712
- type CredentialAuthDefinition = CredentialOAuth2AuthDefinition;
713
- type CredentialAdvancedSectionPresentation = Readonly<{
714
- /** Collapsible section title (default: "Advanced"). */
715
- title?: string;
716
- /** Optional short helper text shown inside the section (above the fields). */
717
- description?: string;
718
- /** When true, the advanced section starts expanded. Default: false (collapsed). */
719
- defaultOpen?: boolean;
720
- }>;
721
- type CredentialTypeDefinition = Readonly<{
722
- typeId: CredentialTypeId;
723
- displayName: string;
724
- description?: string;
725
- publicFields?: ReadonlyArray<CredentialFieldSchema>;
726
- secretFields?: ReadonlyArray<CredentialFieldSchema>;
287
+ update(id: string, patch: Partial<TRow>): Promise<TRow & {
288
+ id: string;
289
+ created_at: Date;
290
+ updated_at: Date;
291
+ }>;
727
292
  /**
728
- * Optional labels for the collapsible block that contains every field with `visibility: "advanced"`.
729
- * If omitted, the UI still shows that block with defaults (title "Advanced", collapsed).
293
+ * Delete a row by id. Hard delete only (no soft delete).
730
294
  */
731
- advancedSection?: CredentialAdvancedSectionPresentation;
732
- supportedSourceKinds?: ReadonlyArray<CredentialMaterialSourceKind>;
733
- auth?: CredentialAuthDefinition;
734
- }>;
735
- /**
736
- * JSON-shaped credential field bag (public config, resolved secret material, etc.).
737
- */
738
- type CredentialJsonRecord = Readonly<Record<string, unknown>>;
739
- /**
740
- * Persisted credential instance with typed `publicConfig`.
741
- * Hosts may specialize `secretRef` with a stricter union while remaining
742
- * assignable here for session/test callbacks.
743
- */
744
- type CredentialInstanceRecord<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
745
- instanceId: CredentialInstanceId;
746
- typeId: CredentialTypeId;
747
- displayName: string;
748
- sourceKind: CredentialMaterialSourceKind;
749
- publicConfig: TPublicConfig;
750
- secretRef: CredentialJsonRecord;
751
- tags: ReadonlyArray<string>;
752
- setupStatus: CredentialSetupStatus;
753
- createdAt: string;
754
- updatedAt: string;
755
- }>;
756
- /**
757
- * Arguments passed to `CredentialType.createSession` and `CredentialType.test`.
758
- * Declare `TPublicConfig` / `TMaterial` on `CredentialType` so implementations are checked
759
- * against your credential shapes (similar to `NodeExecutionContext.config` for nodes).
760
- */
761
- type CredentialSessionFactoryArgs<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
762
- instance: CredentialInstanceRecord<TPublicConfig>;
763
- material: TMaterial;
764
- publicConfig: TPublicConfig;
765
- }>;
766
- type CredentialSessionFactory<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<TSession>;
767
- type CredentialHealthTester<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<CredentialHealth>;
768
- /**
769
- * Full credential type implementation: `definition` (UI/schema), `createSession`, and `test`.
770
- * Use this at registration and config boundaries; `CredentialTypeDefinition` is only the schema slice.
771
- */
772
- type CredentialType<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = Readonly<{
773
- definition: CredentialTypeDefinition;
774
- createSession: CredentialSessionFactory<TPublicConfig, TMaterial, TSession>;
775
- test: CredentialHealthTester<TPublicConfig, TMaterial>;
776
- }>;
295
+ delete(id: string): Promise<{
296
+ deleted: boolean;
297
+ }>;
298
+ }
777
299
  /**
778
- * Credential type with unspecified generics used for `CodemationConfig.credentialTypes`, the host registry,
779
- * and anywhere a concrete `CredentialType<YourPublic, YourMaterial, YourSession>` is placed in a heterogeneous list.
780
- * Using `any` here avoids unsafe `as` casts while keeping typed `satisfies CredentialType<…>` definitions.
300
+ * Runtime collections context: keyed by collection name.
781
301
  */
782
- type AnyCredentialType = CredentialType<any, any, unknown>;
783
- interface CredentialSessionService {
784
- getSession<TSession = unknown>(args: Readonly<{
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;
329
+ }
330
+ interface CostTrackingPriceQuote {
331
+ readonly currency: string;
332
+ readonly currencyScale: number;
333
+ readonly estimatedAmountMinor: number;
334
+ readonly estimateKind: "catalog";
335
+ }
336
+ interface CostTrackingTelemetry {
337
+ captureUsage(args: CostTrackingUsageRecord): Promise<CostTrackingPriceQuote | undefined>;
338
+ forScope(scope: TelemetryScope): CostTrackingTelemetry;
339
+ }
340
+ interface CostTrackingTelemetryFactory {
341
+ create(args: Readonly<{
342
+ telemetry: ExecutionTelemetry;
343
+ }>): CostTrackingTelemetry;
344
+ }
345
+ //#endregion
346
+ //#region src/contracts/NoOpTelemetryArtifactReference.d.ts
347
+ declare class NoOpTelemetryArtifactReference {
348
+ static readonly value: TelemetryArtifactReference;
349
+ }
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;
356
+ }
357
+ //#endregion
358
+ //#region src/contracts/NoOpNodeExecutionTelemetry.d.ts
359
+ declare class NoOpNodeExecutionTelemetry {
360
+ static readonly value: NodeExecutionTelemetry;
361
+ }
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<{
371
+ runId: RunId;
785
372
  workflowId: WorkflowId;
373
+ parent?: ParentExecutionRef;
374
+ policySnapshot?: PersistedRunPolicySnapshot;
375
+ }>): ExecutionTelemetry;
376
+ }
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";
400
+ }
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";
412
+ }
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";
421
+ }
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;
427
+ }
428
+ interface TelemetryMetricRecord {
429
+ readonly name: string;
430
+ readonly value: number;
431
+ readonly unit?: string;
432
+ readonly attributes?: TelemetryAttributes;
433
+ }
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<{
786
487
  nodeId: NodeId;
787
- slotKey: string;
788
- }>): Promise<TSession>;
488
+ activationId: NodeActivationId;
489
+ }>): NodeExecutionTelemetry;
789
490
  }
790
- interface CredentialTypeRegistry {
791
- listTypes(): ReadonlyArray<CredentialTypeDefinition>;
792
- getType(typeId: CredentialTypeId): CredentialTypeDefinition | undefined;
491
+ interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
492
+ startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
793
493
  }
794
- declare class CredentialUnboundError extends Error {
795
- readonly bindingKey: CredentialBindingKey;
796
- readonly acceptedTypes: ReadonlyArray<CredentialTypeId>;
797
- constructor(bindingKey: CredentialBindingKey, acceptedTypes?: ReadonlyArray<CredentialTypeId>);
798
- private static createMessage;
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;
799
509
  }
800
510
  //#endregion
801
- //#region src/contracts/collectionTypes.d.ts
511
+ //#region src/contracts/workflowActivationPolicy.d.ts
802
512
  /**
803
- * Represents a typed store for a single collection.
804
- * All rows include auto-managed id, created_at, and updated_at fields.
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).
805
515
  */
806
- interface CollectionStore<TRow extends Record<string, unknown> = Record<string, unknown>> {
807
- /**
808
- * Insert a new row. id, created_at, and updated_at are auto-populated.
809
- */
810
- insert(row: TRow): Promise<TRow & {
811
- id: string;
812
- created_at: Date;
813
- updated_at: Date;
814
- }>;
815
- /**
816
- * Get a single row by id.
817
- */
818
- get(id: string): Promise<(TRow & {
819
- id: string;
820
- created_at: Date;
821
- updated_at: Date;
822
- }) | null>;
823
- /**
824
- * Find a single row matching the provided filter.
825
- */
826
- findOne(filter: Partial<TRow>): Promise<(TRow & {
827
- id: string;
828
- created_at: Date;
829
- updated_at: Date;
830
- }) | null>;
831
- /**
832
- * List rows with optional pagination and filtering.
833
- */
834
- list(opts?: {
835
- limit?: number;
836
- offset?: number;
837
- where?: Partial<TRow>;
838
- }): Promise<{
839
- rows: ReadonlyArray<TRow & {
840
- id: string;
841
- created_at: Date;
842
- updated_at: Date;
843
- }>;
844
- total: number;
845
- }>;
846
- /**
847
- * Update a row by id with partial data.
848
- */
849
- update(id: string, patch: Partial<TRow>): Promise<TRow & {
850
- id: string;
851
- created_at: Date;
852
- updated_at: Date;
853
- }>;
854
- /**
855
- * Delete a row by id. Hard delete only (no soft delete).
856
- */
857
- delete(id: string): Promise<{
858
- deleted: boolean;
859
- }>;
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;
522
+ }
523
+ //#endregion
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 {
533
+ warn(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;
536
+ }
537
+ interface TriggerInstanceId {
538
+ workflowId: WorkflowId;
539
+ nodeId: NodeId;
540
+ }
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;
545
+ workflowId: WorkflowId;
546
+ nodeId: NodeId;
547
+ methods: ReadonlyArray<HttpMethod>;
548
+ parseJsonBody?: (body: unknown) => unknown;
860
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";
553
+ } | {
554
+ status: "methodNotAllowed";
555
+ match: WebhookInvocationMatch;
556
+ } | {
557
+ status: "ok";
558
+ match: WebhookInvocationMatch;
559
+ };
861
560
  /**
862
- * Runtime collections context: keyed by collection name.
561
+ * Resolves webhook routes from workflow definitions (catalog-backed index, no registration at trigger setup).
863
562
  */
864
- type CollectionsContext = Readonly<Record<string, CollectionStore>>;
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
+ }
865
574
  //#endregion
866
- //#region src/contracts/CostTrackingTelemetryContract.d.ts
867
- type CostTrackingComponent = "chat" | "ocr" | "rag";
868
- declare const CostTrackingTelemetryMetricNames: {
869
- readonly usage: "codemation.cost.usage";
870
- readonly estimatedCost: "codemation.cost.estimated";
871
- };
872
- declare const CostTrackingTelemetryAttributeNames: {
873
- readonly component: "cost.component";
874
- readonly provider: "cost.provider";
875
- readonly operation: "cost.operation";
876
- readonly pricingKey: "cost.pricing_key";
877
- readonly usageUnit: "cost.usage_unit";
878
- readonly currency: "cost.currency";
879
- readonly currencyScale: "cost.currency_scale";
880
- readonly estimateKind: "cost.estimate_kind";
881
- };
882
- interface CostTrackingUsageRecord {
883
- readonly component: CostTrackingComponent;
884
- readonly provider: string;
885
- readonly operation: string;
886
- readonly pricingKey: string;
887
- readonly usageUnit: string;
888
- readonly quantity: number;
889
- readonly modelName?: string;
890
- readonly attributes?: TelemetryAttributes;
575
+ //#region src/contracts/runtimeTypes.d.ts
576
+ interface WorkflowRunnerService {
577
+ runById(args: {
578
+ workflowId: WorkflowId;
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;
590
+ }
591
+ interface LiveWorkflowRepository extends WorkflowRepository {
592
+ setWorkflows(workflows: ReadonlyArray<WorkflowDefinition>): void;
593
+ }
594
+ interface NodeResolver {
595
+ resolve<T>(token: TypeToken<T>): T;
596
+ }
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>;
621
+ /**
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`.
625
+ */
626
+ setChildRunId?(args: {
627
+ nodeId: NodeId;
628
+ childRunId: RunId;
629
+ }): Promise<void>;
891
630
  }
892
- interface CostTrackingPriceQuote {
893
- readonly currency: string;
894
- readonly currencyScale: number;
895
- readonly estimatedAmountMinor: number;
896
- readonly estimateKind: "catalog";
631
+ type BinaryBody = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array> | Uint8Array | ArrayBuffer;
632
+ interface BinaryStorageWriteRequest {
633
+ storageKey: string;
634
+ body: BinaryBody;
897
635
  }
898
- interface CostTrackingTelemetry {
899
- captureUsage(args: CostTrackingUsageRecord): Promise<CostTrackingPriceQuote | undefined>;
900
- forScope(scope: TelemetryScope): CostTrackingTelemetry;
636
+ interface BinaryStorageWriteResult {
637
+ storageKey: string;
638
+ size: number;
639
+ sha256?: string;
901
640
  }
902
- interface CostTrackingTelemetryFactory {
903
- create(args: Readonly<{
904
- telemetry: ExecutionTelemetry;
905
- }>): CostTrackingTelemetry;
641
+ interface BinaryStorageReadResult {
642
+ body: ReadableStream<Uint8Array>;
643
+ size?: number;
906
644
  }
907
- //#endregion
908
- //#region src/contracts/NoOpTelemetryArtifactReference.d.ts
909
- declare class NoOpTelemetryArtifactReference {
910
- static readonly value: TelemetryArtifactReference;
645
+ interface BinaryStorageStatResult {
646
+ exists: boolean;
647
+ size?: number;
911
648
  }
912
- //#endregion
913
- //#region src/contracts/NoOpTelemetrySpanScope.d.ts
914
- declare class NoOpTelemetrySpanScope {
915
- static readonly value: TelemetrySpanScope;
916
- /** Internal: the shared no-op {@link NodeExecutionTelemetry} that {@link NoOpNodeExecutionTelemetry} re-exposes. */
917
- static readonly nodeExecutionTelemetryValue: NodeExecutionTelemetry;
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>>;
918
659
  }
919
- //#endregion
920
- //#region src/contracts/NoOpNodeExecutionTelemetry.d.ts
921
- declare class NoOpNodeExecutionTelemetry {
922
- static readonly value: NodeExecutionTelemetry;
660
+ interface BinaryAttachmentCreateRequest {
661
+ name: string;
662
+ body: BinaryBody;
663
+ mimeType: string;
664
+ filename?: string;
665
+ previewKind?: BinaryAttachment["previewKind"];
923
666
  }
924
- //#endregion
925
- //#region src/contracts/NoOpExecutionTelemetry.d.ts
926
- declare class NoOpExecutionTelemetry {
927
- static readonly value: ExecutionTelemetry;
667
+ interface NodeBinaryAttachmentService extends ExecutionBinaryService {
668
+ attach(args: BinaryAttachmentCreateRequest): Promise<BinaryAttachment>;
669
+ withAttachment<TJson>(item: Item<TJson>, name: string, attachment: BinaryAttachment): Item<TJson>;
928
670
  }
929
- //#endregion
930
- //#region src/contracts/NoOpExecutionTelemetryFactory.d.ts
931
- declare class NoOpExecutionTelemetryFactory implements ExecutionTelemetryFactory {
932
- create(_: Readonly<{
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;
700
+ /**
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.
703
+ */
704
+ testContext?: RunTestContext;
705
+ /**
706
+ * Collections registered in the codemation config, keyed by collection name.
707
+ */
708
+ readonly collections?: CollectionsContext;
709
+ }
710
+ interface ExecutionContextFactory {
711
+ create(args: {
933
712
  runId: RunId;
934
713
  workflowId: WorkflowId;
935
714
  parent?: ParentExecutionRef;
936
715
  policySnapshot?: PersistedRunPolicySnapshot;
937
- }>): ExecutionTelemetry;
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;
938
725
  }
939
- //#endregion
940
- //#region src/contracts/CodemationTelemetryAttributeNames.d.ts
941
- declare class CodemationTelemetryAttributeNames {
942
- static readonly workflowId = "codemation.workflow.id";
943
- static readonly runId = "codemation.run.id";
944
- static readonly nodeId = "codemation.node.id";
945
- static readonly activationId = "codemation.activation.id";
946
- static readonly nodeType = "codemation.node.type";
947
- static readonly nodeRole = "codemation.node.role";
948
- static readonly workflowFolder = "codemation.workflow.folder";
949
- static readonly connectionInvocationId = "codemation.connection.invocation_id";
950
- static readonly toolName = "codemation.tool.name";
951
- static readonly traceParentRunId = "codemation.parent.run.id";
952
- /** Per-item iteration that emitted this span/metric. Set on spans recorded inside a runnable per-item loop. */
953
- static readonly iterationId = "codemation.iteration.id";
954
- /** Item index (0-based) of the iteration. */
955
- static readonly iterationIndex = "codemation.iteration.index";
956
- /** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
957
- static readonly parentInvocationId = "codemation.parent.invocation_id";
726
+ interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase> extends ExecutionContext {
727
+ nodeId: NodeId;
728
+ activationId: NodeActivationId;
729
+ config: TConfig;
730
+ telemetry: NodeExecutionTelemetry;
731
+ binary: NodeBinaryAttachmentService;
958
732
  }
959
- //#endregion
960
- //#region src/contracts/GenAiTelemetryAttributeNames.d.ts
961
- declare class GenAiTelemetryAttributeNames {
962
- static readonly operationName = "gen_ai.operation.name";
963
- static readonly requestModel = "gen_ai.request.model";
964
- static readonly usageInputTokens = "gen_ai.usage.input_tokens";
965
- static readonly usageOutputTokens = "gen_ai.usage.output_tokens";
966
- static readonly usageTotalTokens = "gen_ai.usage.total_tokens";
967
- static readonly usageCacheReadInputTokens = "gen_ai.usage.cache_read.input_tokens";
968
- static readonly usageCacheCreationInputTokens = "gen_ai.usage.cache_creation.input_tokens";
969
- static readonly usageReasoningTokens = "codemation.gen_ai.usage.reasoning_tokens";
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;
970
752
  }
971
- //#endregion
972
- //#region src/contracts/CodemationTelemetryMetricNames.d.ts
973
- declare class CodemationTelemetryMetricNames {
974
- static readonly agentTurns = "codemation.ai.turns";
975
- static readonly agentToolCalls = "codemation.ai.tool_calls";
976
- static readonly gmailMessagesEmitted = "codemation.gmail.messages_emitted";
977
- static readonly gmailAttachments = "codemation.gmail.attachments";
978
- static readonly gmailAttachmentBytes = "codemation.gmail.attachment_bytes";
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;
979
761
  }
980
- //#endregion
981
- //#region src/contracts/telemetryTypes.d.ts
982
- type TelemetryAttributePrimitive = string | number | boolean | null;
983
- interface TelemetryAttributes {
984
- readonly [key: string]: TelemetryAttributePrimitive | undefined;
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;
767
+ }
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;
777
+ }
778
+ interface TriggerSetupStateRepository {
779
+ load(trigger: TriggerInstanceId): Promise<PersistedTriggerSetupState | undefined>;
780
+ save(state: PersistedTriggerSetupState): Promise<void>;
781
+ delete(trigger: TriggerInstanceId): Promise<void>;
782
+ }
783
+ interface TriggerCleanupHandle {
784
+ stop(): Promise<void> | void;
785
+ }
786
+ interface EngineHost {
787
+ credentialSessions: CredentialSessionService;
788
+ workflows?: WorkflowRunnerService;
789
+ }
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>;
802
+ }
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;
815
+ }
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>;
985
828
  }
986
- interface TelemetryMetricRecord {
987
- readonly name: string;
988
- readonly value: number;
989
- readonly unit?: string;
990
- 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>;
991
835
  }
992
- interface TelemetrySpanEventRecord {
993
- readonly name: string;
994
- readonly occurredAt?: Date;
995
- readonly attributes?: TelemetryAttributes;
836
+ interface TestableTriggerNode<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>> extends TriggerNode<TConfig> {
837
+ getTestItems(ctx: TriggerTestItemsContext<TConfig>): Promise<Items>;
996
838
  }
997
- interface TelemetryArtifactAttachment {
998
- readonly kind: string;
999
- readonly contentType: string;
1000
- readonly previewText?: string;
1001
- readonly previewJson?: JsonValue;
1002
- readonly payloadText?: string;
1003
- readonly payloadJson?: JsonValue;
1004
- readonly bytes?: number;
1005
- readonly truncated?: boolean;
1006
- 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;
1007
849
  }
1008
- interface TelemetryArtifactReference {
1009
- readonly artifactId: string;
1010
- readonly traceId?: string;
1011
- readonly spanId?: string;
850
+ interface NodeExecutionScheduler {
851
+ enqueue(request: NodeExecutionRequest): Promise<{
852
+ receiptId: string;
853
+ }>;
854
+ cancel?(receiptId: string): Promise<void>;
1012
855
  }
1013
- interface TelemetrySpanEnd {
1014
- readonly status?: "ok" | "error";
1015
- readonly statusMessage?: string;
1016
- readonly endedAt?: Date;
1017
- readonly attributes?: TelemetryAttributes;
856
+ interface NodeExecutionRequestHandler {
857
+ handleNodeExecutionRequest(request: NodeExecutionRequest): Promise<void>;
1018
858
  }
1019
- interface TelemetryChildSpanStart {
1020
- readonly name: string;
1021
- readonly kind?: "internal" | "client";
1022
- readonly startedAt?: Date;
1023
- 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;
1024
880
  }
1025
- interface TelemetryScope {
1026
- readonly traceId?: string;
1027
- readonly spanId?: string;
1028
- readonly costTracking?: CostTrackingTelemetry;
1029
- addSpanEvent(args: TelemetrySpanEventRecord): Promise<void> | void;
1030
- recordMetric(args: TelemetryMetricRecord): Promise<void> | void;
1031
- attachArtifact(args: TelemetryArtifactAttachment): Promise<TelemetryArtifactReference> | TelemetryArtifactReference;
881
+ interface PreparedNodeActivationDispatch {
882
+ readonly receipt: NodeActivationReceipt;
883
+ dispatch(): Promise<void>;
1032
884
  }
1033
- interface TelemetrySpanScope extends TelemetryScope {
1034
- readonly traceId: string;
1035
- readonly spanId: string;
1036
- end(args?: TelemetrySpanEnd): Promise<void> | void;
1037
- /**
1038
- * Lift this span into a {@link NodeExecutionTelemetry} scoped to a different (nodeId, activationId).
1039
- * Children created via the returned telemetry's `startChildSpan` get this span as their parent.
1040
- *
1041
- * Used at the sub-agent boundary so that nested runtime telemetry parents under the agent.tool.call
1042
- * span instead of the orchestrator's node-level span.
1043
- */
1044
- asNodeTelemetry(args: Readonly<{
885
+ interface NodeActivationContinuation {
886
+ markNodeRunning(args: {
887
+ runId: RunId;
888
+ activationId: NodeActivationId;
1045
889
  nodeId: NodeId;
890
+ inputsByPort: NodeInputsByPort;
891
+ }): Promise<void>;
892
+ resumeFromNodeResult(args: {
893
+ runId: RunId;
1046
894
  activationId: NodeActivationId;
1047
- }>): NodeExecutionTelemetry;
1048
- }
1049
- interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
1050
- startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
1051
- }
1052
- interface ExecutionTelemetry extends TelemetryScope {
1053
- readonly traceId: string;
1054
- readonly spanId: string;
1055
- forNode(args: Readonly<{
1056
895
  nodeId: NodeId;
896
+ outputs: NodeOutputs;
897
+ }): Promise<RunResult>;
898
+ resumeFromNodeError(args: {
899
+ runId: RunId;
1057
900
  activationId: NodeActivationId;
1058
- }>): NodeExecutionTelemetry;
901
+ nodeId: NodeId;
902
+ error: Error;
903
+ }): Promise<RunResult>;
1059
904
  }
1060
- interface ExecutionTelemetryFactory {
1061
- create(args: Readonly<{
1062
- runId: RunId;
1063
- workflowId: WorkflowId;
1064
- parent?: ParentExecutionRef;
1065
- policySnapshot?: PersistedRunPolicySnapshot;
1066
- }>): ExecutionTelemetry;
905
+ interface NodeActivationScheduler {
906
+ setContinuation?(continuation: NodeActivationContinuation): void;
907
+ prepareDispatch(request: NodeActivationRequest): Promise<PreparedNodeActivationDispatch>;
908
+ cancel?(receiptId: string): Promise<void>;
1067
909
  }
1068
- //#endregion
1069
- //#region src/contracts/workflowActivationPolicy.d.ts
1070
- /**
1071
- * Host-controlled policy: when false, trigger {@link TriggerNode} setup is skipped and webhook routes
1072
- * for that workflow are not registered (see engine trigger runtime + webhook matcher).
1073
- */
1074
- interface WorkflowActivationPolicy {
1075
- isActive(workflowId: WorkflowId): boolean;
910
+ interface WorkflowNodeInstanceFactory {
911
+ createNodes(workflow: WorkflowDefinition): ReadonlyMap<NodeId, unknown>;
912
+ createByType(type: TypeToken<unknown>): unknown;
1076
913
  }
1077
- /** Default for tests and harnesses: every workflow is treated as active (legacy behavior). */
1078
- declare class AllWorkflowsActiveWorkflowActivationPolicy implements WorkflowActivationPolicy {
1079
- isActive(_workflowId: WorkflowId): boolean;
914
+ interface NodeExecutor {
915
+ execute(request: NodeActivationRequest): Promise<NodeOutputs>;
1080
916
  }
1081
- //#endregion
1082
- //#region src/contracts/webhookTypes.d.ts
1083
- type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
1084
- interface WebhookControlSignal {
1085
- readonly __webhookControl: true;
1086
- readonly kind: "respondNow" | "respondNowAndContinue";
1087
- readonly responseItems: Items;
1088
- readonly continueItems?: Items;
917
+ interface WorkflowSnapshotFactory {
918
+ create(workflow: WorkflowDefinition): PersistedWorkflowSnapshot;
1089
919
  }
1090
- interface WebhookTriggerRoutingDiagnostics {
1091
- warn(message: string): void;
1092
- /** Inactive workflows omitted from the webhook route index (optional; host should wire for clarity at boot/reload). */
1093
- info?(message: string): void;
920
+ interface WorkflowSnapshotResolver {
921
+ resolve(args: {
922
+ workflowId: WorkflowId;
923
+ workflowSnapshot?: PersistedWorkflowSnapshot;
924
+ }): WorkflowDefinition | undefined;
1094
925
  }
1095
- interface TriggerInstanceId {
1096
- workflowId: WorkflowId;
1097
- 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;
1098
930
  }
1099
- /** Match for an incoming HTTP request: user-defined URL segment + workflow trigger node. */
1100
- interface WebhookInvocationMatch {
1101
- /** Same value as the webhook trigger's configured endpoint key (URL segment under the webhook base path). */
1102
- endpointPath: string;
1103
- workflowId: WorkflowId;
1104
- nodeId: NodeId;
1105
- methods: ReadonlyArray<HttpMethod>;
1106
- 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;
1107
957
  }
1108
- /** Result of resolving an HTTP method + endpoint path against the catalog webhook index (404 vs 405 vs match). */
1109
- type WebhookTriggerResolution = {
1110
- status: "notFound";
1111
- } | {
1112
- status: "methodNotAllowed";
1113
- match: WebhookInvocationMatch;
1114
- } | {
1115
- status: "ok";
1116
- match: WebhookInvocationMatch;
1117
- };
958
+ //#endregion
959
+ //#region src/contracts/retryPolicySpec.types.d.ts
1118
960
  /**
1119
- * 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).
1120
965
  */
1121
- interface WebhookTriggerMatcher {
1122
- match(args: {
1123
- endpointPath: string;
1124
- method: HttpMethod;
1125
- }): WebhookInvocationMatch | undefined;
1126
- lookup(endpointPath: string): WebhookInvocationMatch | undefined;
1127
- onEngineWorkflowsLoaded?(): void;
1128
- onEngineStopped?(): void;
1129
- /** Rebuild route index after activation changes without stopping the engine. */
1130
- reloadWebhookRoutes?(): void;
1131
- }
1132
- //#endregion
1133
- //#region src/contracts/runtimeTypes.d.ts
1134
- interface WorkflowRunnerService {
1135
- runById(args: {
1136
- workflowId: WorkflowId;
1137
- startAt?: NodeId;
1138
- items: Items;
1139
- parent?: ParentExecutionRef;
1140
- }): Promise<RunResult>;
1141
- }
1142
- interface WorkflowRunnerResolver {
1143
- resolve(): WorkflowRunnerService | undefined;
966
+ type RetryPolicySpec = NoneRetryPolicySpec | FixedRetryPolicySpec | ExponentialRetryPolicySpec;
967
+ interface NoneRetryPolicySpec {
968
+ readonly kind: "none";
1144
969
  }
1145
- interface WorkflowRepository {
1146
- list(): ReadonlyArray<WorkflowDefinition>;
1147
- 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;
1148
975
  }
1149
- interface LiveWorkflowRepository extends WorkflowRepository {
1150
- 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;
1151
985
  }
1152
- interface NodeResolver {
1153
- 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;
1154
995
  }
1155
- interface NodeExecutionStatePublisher {
1156
- markQueued(args: {
1157
- nodeId: NodeId;
1158
- activationId?: NodeActivationId;
1159
- inputsByPort?: NodeInputsByPort;
1160
- }): Promise<void>;
1161
- markRunning(args: {
1162
- nodeId: NodeId;
1163
- activationId?: NodeActivationId;
1164
- inputsByPort?: NodeInputsByPort;
1165
- }): Promise<void>;
1166
- markCompleted(args: {
1167
- nodeId: NodeId;
1168
- activationId?: NodeActivationId;
1169
- inputsByPort?: NodeInputsByPort;
1170
- outputs?: NodeOutputs;
1171
- }): Promise<void>;
1172
- markFailed(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: {
1173
1002
  nodeId: NodeId;
1174
- activationId?: NodeActivationId;
1175
- inputsByPort?: NodeInputsByPort;
1176
- error: Error;
1177
- }): Promise<void>;
1178
- appendConnectionInvocation(args: ConnectionInvocationAppendArgs): Promise<void>;
1179
- /**
1180
- * Annotates the current snapshot for `nodeId` with the id of the child run spawned by a
1181
- * SubWorkflow invocation. Called from `SubWorkflowNode.execute` after `runById` resolves.
1182
- * The engine's subsequent `markCompleted` call preserves the value via `previous.childRunId`.
1183
- */
1184
- setChildRunId?(args: {
1003
+ output: OutputPortKey;
1004
+ };
1005
+ to: {
1185
1006
  nodeId: NodeId;
1186
- childRunId: RunId;
1187
- }): Promise<void>;
1188
- }
1189
- type BinaryBody = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array> | Uint8Array | ArrayBuffer;
1190
- interface BinaryStorageWriteRequest {
1191
- storageKey: string;
1192
- body: BinaryBody;
1193
- }
1194
- interface BinaryStorageWriteResult {
1195
- storageKey: string;
1196
- size: number;
1197
- sha256?: string;
1198
- }
1199
- interface BinaryStorageReadResult {
1200
- body: ReadableStream<Uint8Array>;
1201
- size?: number;
1202
- }
1203
- interface BinaryStorageStatResult {
1204
- exists: boolean;
1205
- size?: number;
1007
+ input: InputPortKey;
1008
+ };
1206
1009
  }
1207
- interface BinaryStorage {
1208
- readonly driverName: string;
1209
- write(args: BinaryStorageWriteRequest): Promise<BinaryStorageWriteResult>;
1210
- openReadStream(storageKey: string): Promise<BinaryStorageReadResult | undefined>;
1211
- stat(storageKey: string): Promise<BinaryStorageStatResult>;
1212
- 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>;
1213
1019
  }
1214
- interface BinaryAttachmentCreateRequest {
1020
+ interface WorkflowDefinition {
1021
+ id: WorkflowId;
1215
1022
  name: string;
1216
- body: BinaryBody;
1217
- mimeType: string;
1218
- filename?: string;
1219
- previewKind?: BinaryAttachment["previewKind"];
1220
- }
1221
- interface NodeBinaryAttachmentService extends ExecutionBinaryService {
1222
- attach(args: BinaryAttachmentCreateRequest): Promise<BinaryAttachment>;
1223
- 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;
1224
1038
  }
1225
- interface ExecutionBinaryService {
1226
- forNode(args: {
1039
+ interface WorkflowGraph {
1040
+ next(nodeId: NodeId, output: OutputPortKey): ReadonlyArray<Readonly<{
1227
1041
  nodeId: NodeId;
1228
- activationId: NodeActivationId;
1229
- }): NodeBinaryAttachmentService;
1230
- openReadStream(attachment: BinaryAttachment): Promise<BinaryStorageReadResult | undefined>;
1042
+ input: InputPortKey;
1043
+ }>>;
1231
1044
  }
1232
- interface ExecutionContext {
1233
- runId: RunId;
1234
- workflowId: WorkflowId;
1235
- parent?: ParentExecutionRef;
1236
- /** This run's subworkflow depth (0 = root). */
1237
- subworkflowDepth: number;
1238
- /** Effective activation budget cap for this run (after policy merge). */
1239
- engineMaxNodeActivations: number;
1240
- /** Effective subworkflow nesting cap for this run (after policy merge). */
1241
- engineMaxSubworkflowDepth: number;
1242
- now: () => Date;
1243
- data: RunDataSnapshot;
1244
- nodeState?: NodeExecutionStatePublisher;
1245
- telemetry: ExecutionTelemetry;
1246
- binary: ExecutionBinaryService;
1247
- getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
1248
- /** Per-item iteration id, set by {@link NodeExecutor} on the ctx passed into runnable `execute`. */
1249
- iterationId?: NodeIterationId;
1250
- /** Item index (0-based) within the current activation's batch; set alongside {@link iterationId}. */
1251
- itemIndex?: number;
1252
- /** When set, this ctx is executing inside a sub-agent triggered by the named parent invocation. */
1253
- 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;
1254
1062
  /**
1255
- * Present iff the run was started by a TestSuiteOrchestrator. The {@link IsTestRunNode}
1256
- * 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.
1257
1066
  */
1258
- testContext?: RunTestContext;
1067
+ readonly continueWhenEmptyOutput?: boolean;
1259
1068
  /**
1260
- * 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.
1261
1071
  */
1262
- readonly collections?: CollectionsContext;
1263
- }
1264
- interface ExecutionContextFactory {
1265
- create(args: {
1266
- runId: RunId;
1267
- workflowId: WorkflowId;
1268
- parent?: ParentExecutionRef;
1269
- policySnapshot?: PersistedRunPolicySnapshot;
1270
- subworkflowDepth: number;
1271
- engineMaxNodeActivations: number;
1272
- engineMaxSubworkflowDepth: number;
1273
- data: RunDataSnapshot;
1274
- nodeState?: NodeExecutionStatePublisher;
1275
- telemetry?: ExecutionTelemetry;
1276
- getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
1277
- testContext?: RunTestContext;
1278
- }): ExecutionContext;
1279
- }
1280
- interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase> extends ExecutionContext {
1281
- nodeId: NodeId;
1282
- activationId: NodeActivationId;
1283
- config: TConfig;
1284
- telemetry: NodeExecutionTelemetry;
1285
- binary: NodeBinaryAttachmentService;
1286
- }
1287
- interface PollingTriggerHandle {
1072
+ readonly declaredOutputPorts?: ReadonlyArray<OutputPortKey>;
1073
+ readonly declaredInputPorts?: ReadonlyArray<InputPortKey>;
1074
+ getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;
1288
1075
  /**
1289
- * Start the polling loop. The runtime registers its own cleanup handle so callers do not need to
1290
- * call {@link TriggerSetupContext.registerCleanup} for the loop.
1291
- * @returns The state returned by the first cycle (or `undefined` when the overlap guard fired).
1292
- */
1293
- start<TState, TItem>(args: {
1294
- intervalMs: number;
1295
- seedState?: TState;
1296
- runCycle: (cycleCtx: {
1297
- previousState: TState | undefined;
1298
- signal: AbortSignal;
1299
- }) => Promise<{
1300
- items: Items<TItem>;
1301
- nextState: TState;
1302
- }>;
1303
- }): Promise<TState | undefined>;
1304
- /** Convenience dedup-window helper. */
1305
- readonly dedup: PollingTriggerDedupWindow;
1306
- }
1307
- interface TriggerSetupContext<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>, TSetupState$1 extends JsonValue | undefined = TriggerNodeSetupState<TConfig>> extends ExecutionContext {
1308
- trigger: TriggerInstanceId;
1309
- config: TConfig;
1310
- previousState: TSetupState$1;
1311
- registerCleanup(cleanup: TriggerCleanupHandle): void;
1312
- emit(items: Items): Promise<void>;
1313
- /** Generic polling-trigger surface. Pre-binds trigger id, emit, and registerCleanup. */
1314
- readonly polling: PollingTriggerHandle;
1315
- }
1316
- interface TriggerTestItemsContext<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>, TSetupState$1 extends JsonValue | undefined = TriggerNodeSetupState<TConfig>> extends ExecutionContext {
1317
- trigger: TriggerInstanceId;
1318
- nodeId: NodeId;
1319
- config: TConfig;
1320
- previousState: TSetupState$1;
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`).
1081
+ */
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;
1321
1096
  }
1322
1097
  /**
1323
- * Trigger setup state is intentionally engine-owned so future ownership and
1324
- * leader-election metadata can be coordinated centrally rather than pushed into
1325
- * package-level setup code.
1098
+ * One row of a node's static configuration summary. See {@link NodeConfigBase.inspectorSummary}.
1326
1099
  */
1327
- interface PersistedTriggerSetupState<TState extends JsonValue | undefined = JsonValue | undefined> {
1328
- trigger: TriggerInstanceId;
1329
- updatedAt: string;
1330
- state: TState;
1331
- }
1332
- interface TriggerSetupStateRepository {
1333
- load(trigger: TriggerInstanceId): Promise<PersistedTriggerSetupState | undefined>;
1334
- save(state: PersistedTriggerSetupState): Promise<void>;
1335
- delete(trigger: TriggerInstanceId): Promise<void>;
1336
- }
1337
- interface TriggerCleanupHandle {
1338
- stop(): Promise<void> | void;
1339
- }
1340
- interface EngineHost {
1341
- credentialSessions: CredentialSessionService;
1342
- workflows?: WorkflowRunnerService;
1100
+ interface NodeInspectorSummaryRow {
1101
+ readonly label: string;
1102
+ readonly value: string;
1343
1103
  }
1104
+ declare const runnableNodeInputType: unique symbol;
1105
+ declare const runnableNodeOutputType: unique symbol;
1106
+ declare const triggerNodeOutputType: unique symbol;
1344
1107
  /**
1345
- * Per-item runnable node: return JSON, an array to fan-out on `main`, an explicit `Item`, or {@link emitPorts}
1346
- * for multi-port emission. Engine applies `inputSchema.parse(item.json)` and passes the result as `args.input`
1347
- * (wire `item.json` is unchanged). Transform helpers may opt into binary preservation, while routers and
1348
- * 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.
1349
1110
  */
1350
- interface RunnableNodeExecuteArgs<TConfig extends RunnableNodeConfig<any, any> = RunnableNodeConfig<any, any>, TInputJson$1 = unknown> {
1351
- readonly input: TInputJson$1;
1352
- readonly item: Item;
1353
- readonly itemIndex: number;
1354
- readonly items: Items;
1355
- readonly ctx: NodeExecutionContext<TConfig>;
1356
- }
1357
- 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 {
1358
1112
  readonly kind: "node";
1113
+ readonly [runnableNodeInputType]?: TInputJson$1;
1114
+ readonly [runnableNodeOutputType]?: TOutputJson$1;
1359
1115
  /**
1360
- * Declared output ports (e.g. `["main"]`).
1361
- *
1362
- * Prefer describing dynamic router ports (Switch) and fixed multi-ports (If true/false)
1363
- * 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()`.
1364
1118
  */
1365
- readonly outputPorts?: ReadonlyArray<OutputPortKey>;
1366
- /** When omitted, engine uses {@link RunnableNodeConfig.inputSchema} or `z.unknown()`. */
1367
1119
  readonly inputSchema?: ZodType<TInputJson$1>;
1368
- 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";
1369
1126
  }
1370
- /** @deprecated Use {@link RunnableNode} */
1371
- type ItemNode<TConfig extends RunnableNodeConfig<any, any> = RunnableNodeConfig<any, any>, TInputJson$1 = unknown, TOutputJson$1 = unknown> = RunnableNode<TConfig, TInputJson$1, TOutputJson$1>;
1372
- interface MultiInputNode<TConfig extends NodeConfigBase = NodeConfigBase> {
1373
- 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;
1374
1132
  /**
1375
- * Declared output ports (typically `["main"]`).
1376
- *
1377
- * Prefer describing ports for authoring/canvas via {@link NodeConfigBase.declaredOutputPorts}.
1378
- * Engine defaults to `["main"]` when omitted.
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.
1379
1136
  */
1380
- outputPorts?: ReadonlyArray<OutputPortKey>;
1381
- executeMulti(inputsByPort: NodeInputsByPort, ctx: NodeExecutionContext<TConfig>): Promise<NodeOutputs>;
1137
+ readonly triggerKind?: "live" | "test";
1382
1138
  }
1383
- type TriggerSetupStateFor<TConfig extends TriggerNodeConfig<any, any>> = TriggerNodeSetupState<TConfig>;
1384
- interface TriggerNode<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>> {
1385
- kind: "trigger";
1386
- outputPorts: readonly ["main"];
1387
- setup(ctx: TriggerSetupContext<TConfig>): Promise<TriggerSetupStateFor<TConfig>>;
1388
- execute(items: Items, ctx: NodeExecutionContext<TConfig>): Promise<NodeOutputs>;
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;
1389
1149
  }
1390
- interface TestableTriggerNode<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>> extends TriggerNode<TConfig> {
1391
- getTestItems(ctx: TriggerTestItemsContext<TConfig>): Promise<Items>;
1150
+ interface NodeRef {
1151
+ id: NodeId;
1152
+ kind: NodeKind;
1153
+ name?: string;
1392
1154
  }
1393
- type ExecutableTriggerNode<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>> = TriggerNode<TConfig>;
1394
- interface NodeExecutionRequest {
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;
1395
1170
  runId: RunId;
1171
+ workflowId: WorkflowId;
1172
+ nodeId: NodeId;
1396
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;
1397
1196
  workflowId: WorkflowId;
1398
1197
  nodeId: NodeId;
1399
- input: Items;
1400
- parent?: ParentExecutionRef;
1401
- queue?: string;
1402
- executionOptions?: RunExecutionOptions;
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;
1204
+ /**
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.
1208
+ */
1209
+ testContext?: RunTestContext;
1403
1210
  }
1404
- interface NodeExecutionScheduler {
1405
- enqueue(request: NodeExecutionRequest): Promise<{
1406
- receiptId: string;
1407
- }>;
1408
- cancel?(receiptId: string): Promise<void>;
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;
1409
1215
  }
1410
- interface NodeExecutionRequestHandler {
1411
- handleNodeExecutionRequest(request: NodeExecutionRequest): Promise<void>;
1216
+ interface MutableRunData extends RunDataSnapshot {
1217
+ setOutputs(nodeId: NodeId, outputs: NodeOutputs): void;
1218
+ dump(): Record<NodeId, NodeOutputs>;
1412
1219
  }
1413
- type NodeActivationRequestBase = Readonly<{
1414
- runId: RunId;
1415
- activationId: NodeActivationId;
1416
- workflowId: WorkflowId;
1417
- nodeId: NodeId;
1418
- parent?: ParentExecutionRef;
1419
- executionOptions?: RunExecutionOptions;
1420
- batchId?: string;
1421
- ctx: NodeExecutionContext;
1422
- }>;
1423
- type NodeActivationRequest = (NodeActivationRequestBase & Readonly<{
1424
- kind: "single";
1425
- input: Items;
1426
- }>) | (NodeActivationRequestBase & Readonly<{
1427
- kind: "multi";
1428
- inputsByPort: NodeInputsByPort;
1429
- }>);
1430
- interface NodeActivationReceipt {
1431
- receiptId: string;
1432
- mode?: "local" | "worker";
1433
- queue?: string;
1220
+ interface RunDataFactory {
1221
+ create(initial?: Record<NodeId, NodeOutputs>): MutableRunData;
1434
1222
  }
1435
- interface PreparedNodeActivationDispatch {
1436
- readonly receipt: NodeActivationReceipt;
1437
- dispatch(): Promise<void>;
1223
+ interface RunIdFactory {
1224
+ makeRunId(): RunId;
1438
1225
  }
1439
- interface NodeActivationContinuation {
1440
- markNodeRunning(args: {
1441
- runId: RunId;
1442
- activationId: NodeActivationId;
1443
- nodeId: NodeId;
1444
- inputsByPort: NodeInputsByPort;
1445
- }): Promise<void>;
1446
- resumeFromNodeResult(args: {
1447
- runId: RunId;
1448
- activationId: NodeActivationId;
1449
- nodeId: NodeId;
1450
- outputs: NodeOutputs;
1451
- }): Promise<RunResult>;
1452
- resumeFromNodeError(args: {
1453
- runId: RunId;
1454
- activationId: NodeActivationId;
1226
+ interface ActivationIdFactory {
1227
+ makeActivationId(): NodeActivationId;
1228
+ }
1229
+ type UpstreamRefPlaceholder = `$${number}`;
1230
+ declare const branchRef: (index: number) => UpstreamRefPlaceholder;
1231
+ type ExecutionMode = "local" | "worker";
1232
+ interface NodeSchedulerDecision {
1233
+ mode: ExecutionMode;
1234
+ queue?: string;
1235
+ }
1236
+ interface NodeOffloadPolicy {
1237
+ decide(args: {
1238
+ workflowId: WorkflowId;
1455
1239
  nodeId: NodeId;
1456
- error: Error;
1457
- }): Promise<RunResult>;
1240
+ config: NodeConfigBase;
1241
+ }): NodeSchedulerDecision;
1458
1242
  }
1459
- interface NodeActivationScheduler {
1460
- setContinuation?(continuation: NodeActivationContinuation): void;
1461
- prepareDispatch(request: NodeActivationRequest): Promise<PreparedNodeActivationDispatch>;
1462
- 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>;
1248
+ }
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;
1256
+ }
1257
+ interface WorkflowPrunePolicySpec {
1258
+ readonly runDataRetentionSeconds?: number;
1259
+ readonly binaryRetentionSeconds?: number;
1260
+ readonly telemetrySpanRetentionSeconds?: number;
1261
+ readonly telemetryArtifactRetentionSeconds?: number;
1262
+ readonly telemetryMetricRetentionSeconds?: number;
1463
1263
  }
1464
- interface WorkflowNodeInstanceFactory {
1465
- createNodes(workflow: WorkflowDefinition): ReadonlyMap<NodeId, unknown>;
1466
- createByType(type: TypeToken<unknown>): unknown;
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;
1467
1271
  }
1468
- interface NodeExecutor {
1469
- execute(request: NodeActivationRequest): Promise<NodeOutputs>;
1272
+ interface WorkflowErrorHandler {
1273
+ onError(ctx: WorkflowErrorContext): void | Promise<void>;
1470
1274
  }
1471
- interface WorkflowSnapshotFactory {
1472
- create(workflow: WorkflowDefinition): PersistedWorkflowSnapshot;
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;
1473
1283
  }
1474
- interface WorkflowSnapshotResolver {
1475
- resolve(args: {
1476
- workflowId: WorkflowId;
1477
- workflowSnapshot?: PersistedWorkflowSnapshot;
1478
- }): WorkflowDefinition | undefined;
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;
1479
1291
  }
1480
- /** Optional host wiring for trigger lifecycle logs (boot skip + activation sync). */
1481
- interface TriggerRuntimeDiagnostics {
1482
- info(message: string): void;
1483
- warn(message: string): void;
1292
+ interface NodeErrorHandler {
1293
+ handle<TConfig extends NodeConfigBase>(args: NodeErrorHandlerArgs<TConfig>): Promise<NodeOutputs>;
1484
1294
  }
1485
- interface EngineDeps {
1486
- credentialSessions: CredentialSessionService;
1487
- liveWorkflowRepository: LiveWorkflowRepository;
1488
- workflowRepository: WorkflowRepository;
1489
- /** When {@link AllWorkflowsActiveWorkflowActivationPolicy}, all workflows behave as active (tests). */
1490
- workflowActivationPolicy: WorkflowActivationPolicy;
1491
- nodeResolver: NodeResolver;
1492
- triggerSetupStateRepository: TriggerSetupStateRepository;
1493
- webhookTriggerMatcher: WebhookTriggerMatcher;
1494
- runIdFactory: RunIdFactory;
1495
- activationIdFactory: ActivationIdFactory;
1496
- workflowExecutionRepository: WorkflowExecutionRepository;
1497
- activationScheduler: NodeActivationScheduler;
1498
- runDataFactory: RunDataFactory;
1499
- executionContextFactory: ExecutionContextFactory;
1500
- executionTelemetryFactory?: ExecutionTelemetryFactory;
1501
- nodeExecutor: NodeExecutor;
1502
- eventBus?: RunEventBus;
1503
- tokenRegistry: PersistedWorkflowTokenRegistryLike;
1504
- workflowNodeInstanceFactory: WorkflowNodeInstanceFactory;
1505
- /** Defaults for prune/storage snapshot when workflow omits explicit policy fields. */
1506
- workflowPolicyRuntimeDefaults?: WorkflowPolicyRuntimeDefaults;
1507
- /** When set, logs inactive-workflow skips at boot and trigger start/stop on activation changes. */
1508
- triggerRuntimeDiagnostics?: TriggerRuntimeDiagnostics;
1509
- /** When set, the polling-trigger runtime uses this logger for cycle info/debug/error. */
1510
- pollingTriggerLogger?: PollingTriggerLogger;
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;
1511
1304
  }
1512
1305
  //#endregion
1513
- //#region src/contracts/retryPolicySpec.types.d.ts
1306
+ //#region src/contracts/testTriggerTypes.d.ts
1514
1307
  /**
1515
- * In-process retry policy for runnable nodes. Serialized configs use the same
1516
- * `kind` discriminator (`JSON.stringify` / persisted workflows).
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.
1517
1336
  *
1518
- * `maxAttempts` is the total number of tries including the first (e.g. 3 means up to 2 delays after failures).
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.
1519
1339
  */
1520
- type RetryPolicySpec = NoneRetryPolicySpec | FixedRetryPolicySpec | ExponentialRetryPolicySpec;
1521
- interface NoneRetryPolicySpec {
1522
- readonly kind: "none";
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;
1523
1365
  }
1524
- interface FixedRetryPolicySpec {
1525
- readonly kind: "fixed";
1526
- /** Total attempts including the first execution. Must be >= 1. */
1527
- readonly maxAttempts: number;
1528
- readonly delayMs: number;
1366
+ //#endregion
1367
+ //#region src/events/runEvents.d.ts
1368
+ /**
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
1374
+ */
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>;
1529
1476
  }
1530
- interface ExponentialRetryPolicySpec {
1531
- readonly kind: "exponential";
1532
- /** Total attempts including the first execution. Must be >= 1. */
1533
- readonly maxAttempts: number;
1534
- readonly initialDelayMs: number;
1535
- readonly multiplier: number;
1536
- readonly maxDelayMs?: number;
1537
- /** When true, each delay is multiplied by a random factor in [1, 1.2). */
1538
- 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>;
1539
1481
  }
1540
1482
  //#endregion
1541
- //#region src/contracts/workflowTypes.d.ts
1542
- type NodeIdRef<TJson = unknown> = NodeId & Readonly<{
1543
- __codemationNodeJson?: TJson;
1544
- }>;
1545
- type NodeKind = "trigger" | "node";
1546
- type JsonPrimitive = string | number | boolean | null;
1547
- interface JsonObject {
1548
- readonly [key: string]: JsonValue;
1549
- }
1550
- type JsonValue = JsonPrimitive | JsonObject | JsonArray;
1551
- type JsonArray = ReadonlyArray<JsonValue>;
1552
- /** JSON value that is not a top-level array (nested arrays inside objects are allowed). */
1553
- type JsonNonArray = JsonPrimitive | JsonObject;
1554
- interface Edge {
1555
- from: {
1556
- nodeId: NodeId;
1557
- output: OutputPortKey;
1558
- };
1559
- to: {
1560
- nodeId: NodeId;
1561
- input: InputPortKey;
1562
- };
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;
1563
1489
  }
1490
+ /** Framework defaults for {@link EngineExecutionLimitsPolicy} (merged with host `runtime.engineExecutionLimits`). */
1491
+ declare const ENGINE_EXECUTION_LIMITS_DEFAULTS: EngineExecutionLimitsPolicyConfig;
1564
1492
  /**
1565
- * Named connection from a parent node to child nodes that exist in {@link WorkflowDefinition.nodes}
1566
- * but are not traversed by the main execution graph. Parents are commonly executable nodes, but may
1567
- * also be connection-owned nodes for recursive agent attachments.
1493
+ * Resolves per-run execution limits: defaults, hard ceilings, and subworkflow depth for new runs.
1568
1494
  */
1569
- interface WorkflowNodeConnection {
1570
- readonly parentNodeId: NodeId;
1571
- readonly connectionName: NodeConnectionName;
1572
- readonly childNodeIds: ReadonlyArray<NodeId>;
1573
- }
1574
- interface WorkflowDefinition {
1575
- id: WorkflowId;
1576
- name: string;
1577
- nodes: NodeDefinition[];
1578
- edges: Edge[];
1495
+ declare class EngineExecutionLimitsPolicy {
1496
+ private readonly config;
1497
+ constructor(config?: EngineExecutionLimitsPolicyConfig);
1579
1498
  /**
1580
- * Optional metadata: which nodes are connection-owned children (e.g. AI agent `llm` / `tools` slots).
1581
- * 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.
1582
1501
  */
1583
- readonly connections?: ReadonlyArray<WorkflowNodeConnection>;
1584
- /** Directory + file-stem path under a workflow discovery root (for UI grouping only). */
1585
- discoveryPathSegments?: readonly string[];
1586
- /** Retention for run JSON and binaries (seconds). Host/env may supply defaults when omitted. */
1587
- readonly prunePolicy?: WorkflowPrunePolicySpec;
1588
- /** Whether to keep run data after completion. Host/env may supply defaults when omitted. */
1589
- readonly storagePolicy?: WorkflowStoragePolicySpec;
1590
- /** Invoked after a node fails permanently (retries exhausted) and node error handler did not recover. */
1591
- readonly workflowErrorHandler?: WorkflowErrorHandlerSpec;
1592
- }
1593
- interface WorkflowGraph {
1594
- next(nodeId: NodeId, output: OutputPortKey): ReadonlyArray<Readonly<{
1595
- nodeId: NodeId;
1596
- input: InputPortKey;
1597
- }>>;
1598
- }
1599
- interface WorkflowGraphFactory {
1600
- create(def: WorkflowDefinition): WorkflowGraph;
1502
+ createRootExecutionOptions(): RunExecutionOptions;
1503
+ mergeExecutionOptionsForNewRun(parent: ParentExecutionRef | undefined, user: RunExecutionOptions | undefined): RunExecutionOptions;
1504
+ private capNumber;
1601
1505
  }
1602
- interface NodeConfigBase {
1603
- readonly kind: NodeKind;
1604
- readonly type: TypeToken<unknown>;
1605
- readonly name?: string;
1606
- readonly id?: NodeId;
1607
- readonly icon?: string;
1608
- readonly execution?: Readonly<{
1609
- hint?: "local" | "worker";
1610
- queue?: string;
1611
- }>;
1612
- /** In-process execute retries (runnable nodes). Triggers typically omit this. */
1613
- readonly retryPolicy?: RetryPolicySpec;
1614
- /** Recover from execute failures; return outputs to continue, or rethrow to fail the node. */
1615
- readonly nodeErrorHandler?: NodeErrorHandlerSpec;
1616
- /**
1617
- * When true, edges carrying zero items on an output port still schedule single-input downstream nodes.
1618
- * Decided from the **source** node that produced the (empty) output. Default (false/undefined): empty
1619
- * main batches skip downstream execution and propagate the empty path.
1620
- */
1621
- readonly continueWhenEmptyOutput?: boolean;
1622
- /**
1623
- * Declared I/O port names for canvas authoring (unioned with ports inferred from edges).
1624
- * Use for dynamic routers (Switch) and future error ports.
1625
- */
1626
- readonly declaredOutputPorts?: ReadonlyArray<OutputPortKey>;
1627
- readonly declaredInputPorts?: ReadonlyArray<InputPortKey>;
1628
- 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>;
1629
1530
  /**
1630
- * Marker: this node emits {@link import("./assertionTypes").AssertionResult}-shaped items on its
1631
- * `main` port. The TestSuiteOrchestrator (and host-side TestAssertionPersister) listen for
1632
- * `nodeCompleted` events from nodes with this flag set, and persist their output items as
1633
- * TestAssertion records (only when the run carries a `testContext`). Set on assertion node
1634
- * 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.
1635
1534
  */
1636
- readonly emitsAssertions?: true;
1637
- }
1638
- declare const runnableNodeInputType: unique symbol;
1639
- declare const runnableNodeOutputType: unique symbol;
1640
- declare const triggerNodeOutputType: unique symbol;
1535
+ readonly AgentMcpIntegration: TypeToken<AgentMcpIntegration>;
1536
+ };
1537
+ //#endregion
1538
+ //#region src/contracts/runTypes.d.ts
1641
1539
  /**
1642
- * Runnable node: **`TInputJson`** is what **`inputSchema`** validates on **`item.json`** (the wire payload).
1643
- * **`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.
1644
1543
  */
1645
- interface RunnableNodeConfig<TInputJson$1 = unknown, TOutputJson$1 = unknown> extends NodeConfigBase {
1646
- readonly kind: "node";
1647
- readonly [runnableNodeInputType]?: TInputJson$1;
1648
- readonly [runnableNodeOutputType]?: TOutputJson$1;
1649
- /**
1650
- * Optional Zod input contract for {@link RunnableNode} when not set on the node class.
1651
- * Resolution order: node instance `inputSchema`, then config `inputSchema`, then `z.unknown()`.
1652
- */
1653
- readonly inputSchema?: ZodType<TInputJson$1>;
1544
+ interface RunTestContext {
1545
+ readonly testSuiteRunId: string;
1546
+ readonly testCaseIndex: number;
1654
1547
  /**
1655
- * When an activation receives **zero** input items, the engine normally runs `execute` zero times.
1656
- * Set to **`runOnce`** to run `execute` once with an empty `items` batch (and a synthetic wire item for schema parsing).
1657
- * 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".
1658
1552
  */
1659
- readonly emptyBatchExecution?: "skip" | "runOnce";
1553
+ readonly testCaseLabel?: string;
1660
1554
  }
1661
- declare const triggerNodeSetupStateType: unique symbol;
1662
- interface TriggerNodeConfig<TOutputJson$1 = unknown, TSetupState$1 extends JsonValue | undefined = undefined> extends NodeConfigBase {
1663
- readonly kind: "trigger";
1664
- readonly [triggerNodeOutputType]?: TOutputJson$1;
1665
- readonly [triggerNodeSetupStateType]?: TSetupState$1;
1666
- /**
1667
- * Distinguishes triggers driven by the live activation policy (webhooks, cron, polling) from
1668
- * triggers driven only by the {@link TestSuiteOrchestrator}. `WorkflowActivation` skips
1669
- * `"test"` triggers; the orchestrator skips `"live"` triggers. Defaults to `"live"` when omitted.
1670
- */
1671
- 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;
1672
1573
  }
1673
- type RunnableNodeInputJson<TConfig extends RunnableNodeConfig<any, any>> = TConfig extends RunnableNodeConfig<infer TInputJson, any> ? TInputJson : never;
1674
- type RunnableNodeOutputJson<TConfig extends RunnableNodeConfig<any, any>> = TConfig extends RunnableNodeConfig<any, infer TOutputJson> ? TOutputJson : never;
1675
- type TriggerNodeOutputJson<TConfig extends TriggerNodeConfig<any, any>> = TConfig extends TriggerNodeConfig<infer TOutputJson, any> ? TOutputJson : never;
1676
- type TriggerNodeSetupState<TConfig extends TriggerNodeConfig<any, any>> = TConfig extends TriggerNodeConfig<any, infer TSetupState> ? TSetupState : never;
1677
- interface NodeDefinition {
1574
+ /** Engine-owned counters persisted with the run (worker-safe). */
1575
+ interface EngineRunCounters {
1576
+ completedNodeActivations: number;
1577
+ }
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 {
1678
1591
  id: NodeId;
1679
1592
  kind: NodeKind;
1680
- type: TypeToken<unknown>;
1681
1593
  name?: string;
1682
- config: NodeConfigBase;
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
+ }>>;
1604
+ }
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 {
1625
+ nodeId: NodeId;
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
+ }>;
1683
1637
  }
1684
- interface NodeRef {
1685
- id: NodeId;
1686
- kind: NodeKind;
1638
+ type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
1639
+ interface NodeExecutionError {
1640
+ message: string;
1687
1641
  name?: string;
1642
+ stack?: string;
1643
+ details?: JsonValue;
1688
1644
  }
1689
- declare function nodeRef<TJson>(nodeId: NodeId): NodeIdRef<TJson>;
1690
- type PairedItemRef = Readonly<{
1691
- nodeId: NodeId;
1692
- output: OutputPortKey;
1693
- itemIndex: number;
1694
- }>;
1695
- type BinaryPreviewKind = "image" | "audio" | "video" | "download";
1696
- type BinaryAttachment = Readonly<{
1697
- id: string;
1698
- storageKey: string;
1699
- mimeType: string;
1700
- size: number;
1701
- storageDriver: string;
1702
- previewKind: BinaryPreviewKind;
1703
- createdAt: string;
1704
- runId: RunId;
1705
- workflowId: WorkflowId;
1706
- nodeId: NodeId;
1707
- activationId: NodeActivationId;
1708
- filename?: string;
1709
- sha256?: string;
1710
- }>;
1711
- type ItemBinary = Readonly<Record<string, BinaryAttachment>>;
1712
- type Item<TJson = unknown> = Readonly<{
1713
- json: TJson;
1714
- binary?: ItemBinary;
1715
- meta?: Readonly<Record<string, unknown>>;
1716
- paired?: ReadonlyArray<PairedItemRef>;
1717
- }>;
1718
- type Items<TJson = unknown> = ReadonlyArray<Item<TJson>>;
1719
- type NodeOutputs = Partial<Record<OutputPortKey, Items>>;
1720
- type RunId = string;
1721
- type NodeActivationId = string;
1722
- /**
1723
- * One per-item iteration of a runnable node's execute loop. Refines `NodeActivationId` for
1724
- * per-item connection invocations and telemetry. Undefined when the executing node is a batch
1725
- * node or trigger that does not iterate items.
1726
- */
1727
- type NodeIterationId = string;
1728
- interface ParentExecutionRef {
1645
+ interface NodeExecutionSnapshot {
1729
1646
  runId: RunId;
1730
1647
  workflowId: WorkflowId;
1731
1648
  nodeId: NodeId;
1732
- /** Subworkflow depth of the **spawning** run (0 = root). Passed when starting a child run. */
1733
- subworkflowDepth?: number;
1734
- /** Effective max node activations from the parent run (propagated to child policy merge). */
1735
- engineMaxNodeActivations?: number;
1736
- /** Effective max subworkflow depth from the parent run (propagated to child policy merge). */
1737
- engineMaxSubworkflowDepth?: number;
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;
1738
1660
  /**
1739
- * Test-suite linkage inherited by the child subworkflow run. Set by whichever node
1740
- * spawns the subworkflow when its own `ctx.testContext` is present, so assertions
1741
- * emitted inside a subworkflow land under the correct parent test case.
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.
1742
1663
  */
1743
- testContext?: RunTestContext;
1664
+ childRunId?: RunId;
1744
1665
  }
1745
- interface RunDataSnapshot {
1746
- getOutputs(nodeId: NodeId): NodeOutputs | undefined;
1747
- getOutputItems<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, output?: OutputPortKey): Items<TJson>;
1748
- getOutputItem<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, itemIndex: number, output?: OutputPortKey): Item<TJson> | undefined;
1666
+ /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
1667
+ type ConnectionInvocationId = string;
1668
+ /**
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.
1671
+ */
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;
1749
1697
  }
1750
- interface MutableRunData extends RunDataSnapshot {
1751
- setOutputs(nodeId: NodeId, outputs: NodeOutputs): void;
1752
- dump(): Record<NodeId, NodeOutputs>;
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;
1753
1723
  }
1754
- interface RunDataFactory {
1755
- create(initial?: Record<NodeId, NodeOutputs>): MutableRunData;
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;
1756
1734
  }
1757
- interface RunIdFactory {
1758
- makeRunId(): RunId;
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>;
1759
1745
  }
1760
- interface ActivationIdFactory {
1761
- makeActivationId(): NodeActivationId;
1746
+ type RunStatus = "running" | "pending" | "completed" | "failed";
1747
+ interface RunSummary {
1748
+ runId: RunId;
1749
+ workflowId: WorkflowId;
1750
+ startedAt: string;
1751
+ status: RunStatus;
1752
+ /**
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.
1757
+ */
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;
1762
1763
  }
1763
- type UpstreamRefPlaceholder = `$${number}`;
1764
- declare const branchRef: (index: number) => UpstreamRefPlaceholder;
1765
- type ExecutionMode = "local" | "worker";
1766
- interface NodeSchedulerDecision {
1767
- mode: ExecutionMode;
1764
+ interface PendingNodeExecution {
1765
+ runId: RunId;
1766
+ activationId: NodeActivationId;
1767
+ workflowId: WorkflowId;
1768
+ nodeId: NodeId;
1769
+ itemsIn: number;
1770
+ inputsByPort: NodeInputsByPort;
1771
+ receiptId: string;
1768
1772
  queue?: string;
1773
+ batchId?: string;
1774
+ enqueuedAt: string;
1769
1775
  }
1770
- interface NodeOffloadPolicy {
1771
- decide(args: {
1772
- workflowId: WorkflowId;
1773
- nodeId: NodeId;
1774
- config: NodeConfigBase;
1775
- }): NodeSchedulerDecision;
1776
+ interface PersistedRunSchedulingState {
1777
+ pending?: PendingNodeExecution;
1778
+ queue: RunQueueEntry[];
1776
1779
  }
1777
- /** Whether to persist run execution data after the workflow finishes. */
1778
- type WorkflowStoragePolicyMode = "ALL" | "SUCCESS" | "ERROR" | "NEVER";
1779
- type WorkflowStoragePolicySpec = WorkflowStoragePolicyMode | TypeToken<WorkflowStoragePolicyResolver>;
1780
- interface WorkflowStoragePolicyResolver {
1781
- shouldPersist(args: WorkflowStoragePolicyDecisionArgs): boolean | Promise<boolean>;
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>;
1804
+ }
1805
+ interface WorkflowExecutionRepository {
1806
+ createRun(args: {
1807
+ runId: RunId;
1808
+ workflowId: WorkflowId;
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>;
1782
1822
  }
1783
- interface WorkflowStoragePolicyDecisionArgs {
1823
+ interface WorkflowExecutionListingRepository {
1824
+ listRuns(args?: Readonly<{
1825
+ workflowId?: WorkflowId;
1826
+ limit?: number;
1827
+ }>): Promise<ReadonlyArray<RunSummary>>;
1828
+ }
1829
+ /** Runs eligible for retention-based pruning (completed or failed, older than cutoff). */
1830
+ interface RunPruneCandidate {
1784
1831
  readonly runId: RunId;
1785
1832
  readonly workflowId: WorkflowId;
1786
- readonly workflow: WorkflowDefinition;
1787
- readonly finalStatus: "completed" | "failed";
1788
1833
  readonly startedAt: string;
1789
1834
  readonly finishedAt: string;
1790
1835
  }
1791
- interface WorkflowPrunePolicySpec {
1792
- readonly runDataRetentionSeconds?: number;
1793
- readonly binaryRetentionSeconds?: number;
1794
- readonly telemetrySpanRetentionSeconds?: number;
1795
- readonly telemetryArtifactRetentionSeconds?: number;
1796
- readonly telemetryMetricRetentionSeconds?: number;
1836
+ interface WorkflowExecutionPruneRepository {
1837
+ listRunsOlderThan(args: Readonly<{
1838
+ nowIso: string;
1839
+ defaultRetentionSeconds: number;
1840
+ limit?: number;
1841
+ }>): Promise<ReadonlyArray<RunPruneCandidate>>;
1797
1842
  }
1798
- interface PersistedRunPolicySnapshot {
1799
- readonly retentionSeconds?: number;
1800
- readonly binaryRetentionSeconds?: number;
1801
- readonly telemetrySpanRetentionSeconds?: number;
1802
- readonly telemetryArtifactRetentionSeconds?: number;
1803
- readonly telemetryMetricRetentionSeconds?: number;
1804
- 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;
1805
1876
  }
1806
- interface WorkflowErrorHandler {
1807
- onError(ctx: WorkflowErrorContext): void | Promise<void>;
1877
+ interface RunCompletionNotifier {
1878
+ resolveRunCompletion(result: RunResult): void;
1879
+ resolveWebhookResponse(result: WebhookRunResult): void;
1808
1880
  }
1809
- interface WorkflowErrorContext {
1810
- readonly runId: RunId;
1811
- readonly workflowId: WorkflowId;
1812
- readonly workflow: WorkflowDefinition;
1813
- readonly failedNodeId: NodeId;
1814
- readonly error: Error;
1815
- readonly startedAt: string;
1816
- readonly finishedAt: string;
1881
+ interface RunEventPublisherDeps {
1882
+ eventBus?: RunEventBus;
1817
1883
  }
1818
- type WorkflowErrorHandlerSpec = TypeToken<WorkflowErrorHandler> | WorkflowErrorHandler;
1819
- interface NodeErrorHandlerArgs<TConfig extends NodeConfigBase = NodeConfigBase> {
1820
- readonly kind: "single" | "multi";
1821
- readonly items: Items;
1822
- readonly inputsByPort: Readonly<Record<InputPortKey, Items>> | undefined;
1823
- readonly ctx: NodeExecutionContext<TConfig>;
1824
- 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[];
1825
1895
  }
1826
- interface NodeErrorHandler {
1827
- 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>;
1828
1948
  }
1829
- type NodeErrorHandlerSpec = TypeToken<NodeErrorHandler> | NodeErrorHandler;
1830
- /** Runtime defaults when workflow omits prune/storage fields (typically from host env). */
1831
- interface WorkflowPolicyRuntimeDefaults {
1832
- readonly retentionSeconds?: number;
1833
- readonly binaryRetentionSeconds?: number;
1834
- readonly telemetrySpanRetentionSeconds?: number;
1835
- readonly telemetryArtifactRetentionSeconds?: number;
1836
- readonly telemetryMetricRetentionSeconds?: number;
1837
- 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>;
1838
1969
  }
1839
1970
  //#endregion
1840
1971
  //#region src/contracts/assertionTypes.d.ts
@@ -2141,6 +2272,35 @@ interface WorkflowDetailSelectionState {
2141
2272
  readonly selectedInstanceId: ExecutionInstanceId | null;
2142
2273
  }
2143
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
2144
2304
  //#region src/contracts/emitPorts.d.ts
2145
2305
  declare const EMIT_PORTS_BRAND: unique symbol;
2146
2306
  type PortsEmission = Readonly<{
@@ -2305,6 +2465,9 @@ declare const NodeIdSlugifier: {
2305
2465
  //#region src/workflow/definition/ConnectionInvocationIdFactory.d.ts
2306
2466
  /**
2307
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.
2308
2471
  */
2309
2472
  declare class ConnectionInvocationIdFactory {
2310
2473
  static create(): string;
@@ -2321,6 +2484,12 @@ declare class ConnectionNodeIdFactory {
2321
2484
  static readonly connectionSegment: "__conn__";
2322
2485
  static languageModelConnectionNodeId(parentNodeId: NodeId): NodeId;
2323
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;
2324
2493
  static isLanguageModelConnectionNodeId(nodeId: NodeId): boolean;
2325
2494
  static isToolConnectionNodeId(nodeId: NodeId): boolean;
2326
2495
  static parseLanguageModelConnectionNodeId(nodeId: NodeId): Readonly<{
@@ -2343,6 +2512,10 @@ declare class ConnectionNodeIdFactory {
2343
2512
  * Activations are per-batch (one scheduled execution of a node, possibly with N items).
2344
2513
  * Iterations refine that to one identifier per item-index inside the batch loop, so per-item
2345
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.
2346
2519
  */
2347
2520
  declare class NodeIterationIdFactory {
2348
2521
  static create(): string;
@@ -2381,281 +2554,5 @@ declare class DefaultWorkflowGraphFactory implements WorkflowGraphFactory {
2381
2554
  create(def: WorkflowDefinition): WorkflowGraph;
2382
2555
  }
2383
2556
  //#endregion
2384
- //#region src/orchestration/Engine.d.ts
2385
- interface EngineTriggerRuntime {
2386
- startTriggers(): Promise<void>;
2387
- stop(): Promise<void>;
2388
- syncWorkflowTriggersForActivation(workflowId: WorkflowId): Promise<void>;
2389
- createTriggerTestItems(args: {
2390
- workflow: WorkflowDefinition;
2391
- nodeId: NodeId;
2392
- }): Promise<Items | undefined>;
2393
- }
2394
- interface EngineRunStartService {
2395
- runWorkflow(wf: WorkflowDefinition, startAt: NodeId, items: Items, parent?: ParentExecutionRef, executionOptions?: RunExecutionOptions, persistedStateOverrides?: Readonly<{
2396
- workflowSnapshot?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["workflowSnapshot"];
2397
- mutableState?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["mutableState"];
2398
- }>): Promise<RunResult>;
2399
- runWorkflowFromState(request: CurrentStateExecutionRequest): Promise<RunResult>;
2400
- }
2401
- interface EngineRunContinuationService {
2402
- markNodeRunning(args: {
2403
- runId: RunId;
2404
- activationId: NodeActivationId;
2405
- nodeId: NodeId;
2406
- inputsByPort: NodeInputsByPort;
2407
- }): Promise<void>;
2408
- resumeFromNodeResult(args: {
2409
- runId: RunId;
2410
- activationId: NodeActivationId;
2411
- nodeId: NodeId;
2412
- outputs: NodeOutputs;
2413
- }): Promise<RunResult>;
2414
- resumeFromNodeError(args: {
2415
- runId: RunId;
2416
- activationId: NodeActivationId;
2417
- nodeId: NodeId;
2418
- error: Error;
2419
- }): Promise<RunResult>;
2420
- resumeFromStepResult(args: {
2421
- runId: RunId;
2422
- activationId: NodeActivationId;
2423
- nodeId: NodeId;
2424
- outputs: NodeOutputs;
2425
- }): Promise<RunResult>;
2426
- resumeFromStepError(args: {
2427
- runId: RunId;
2428
- activationId: NodeActivationId;
2429
- nodeId: NodeId;
2430
- error: Error;
2431
- }): Promise<RunResult>;
2432
- waitForCompletion(runId: RunId): Promise<Extract<RunResult, {
2433
- status: "completed" | "failed";
2434
- }>>;
2435
- waitForWebhookResponse(runId: RunId): Promise<WebhookRunResult>;
2436
- }
2437
- interface EngineNodeExecutionRequestHandler {
2438
- handleNodeExecutionRequest(request: NodeExecutionRequest): Promise<void>;
2439
- }
2440
- interface EngineFacadeDeps {
2441
- liveWorkflowRepository: LiveWorkflowRepository;
2442
- tokenRegistry: PersistedWorkflowTokenRegistryLike;
2443
- webhookTriggerMatcher: WebhookTriggerMatcher;
2444
- workflowSnapshotResolver: WorkflowSnapshotResolver;
2445
- triggerRuntime: EngineTriggerRuntime;
2446
- runStartService: EngineRunStartService;
2447
- runContinuationService: EngineRunContinuationService;
2448
- nodeExecutionRequestHandler: EngineNodeExecutionRequestHandler;
2449
- }
2450
- /**
2451
- * Runtime facade for orchestration, continuation, triggers, and webhook routing.
2452
- * Prefer {@link import("../intents/RunIntentService").RunIntentService} for host/HTTP invocation boundaries.
2453
- * The class token is exported from `@codemation/core/bootstrap` (not the main `@codemation/core` barrel).
2454
- */
2455
- declare class Engine implements NodeActivationContinuation, NodeExecutionRequestHandler {
2456
- private readonly deps;
2457
- constructor(deps: EngineFacadeDeps);
2458
- loadWorkflows(workflows: ReadonlyArray<WorkflowDefinition>): void;
2459
- getTokenRegistry(): EngineFacadeDeps["tokenRegistry"];
2460
- resolveWorkflowSnapshot(args: {
2461
- workflowId: WorkflowId;
2462
- workflowSnapshot?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["workflowSnapshot"];
2463
- }): WorkflowDefinition | undefined;
2464
- startTriggers(): Promise<void>;
2465
- syncWorkflowTriggersForActivation(workflowId: WorkflowId): Promise<void>;
2466
- start(workflows: WorkflowDefinition[]): Promise<void>;
2467
- stop(): Promise<void>;
2468
- resolveWebhookTrigger(args: {
2469
- endpointPath: string;
2470
- method: HttpMethod;
2471
- }): WebhookTriggerResolution;
2472
- createTriggerTestItems(args: {
2473
- workflow: WorkflowDefinition;
2474
- nodeId: NodeId;
2475
- }): Promise<Items | undefined>;
2476
- runWorkflow(wf: WorkflowDefinition, startAt: NodeId, items: Items, parent?: ParentExecutionRef, executionOptions?: RunExecutionOptions, persistedStateOverrides?: Readonly<{
2477
- workflowSnapshot?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["workflowSnapshot"];
2478
- mutableState?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["mutableState"];
2479
- }>): Promise<RunResult>;
2480
- runWorkflowFromState(request: CurrentStateExecutionRequest): Promise<RunResult>;
2481
- markNodeRunning(args: {
2482
- runId: RunId;
2483
- activationId: NodeActivationId;
2484
- nodeId: NodeId;
2485
- inputsByPort: NodeInputsByPort;
2486
- }): Promise<void>;
2487
- resumeFromNodeResult(args: {
2488
- runId: RunId;
2489
- activationId: NodeActivationId;
2490
- nodeId: NodeId;
2491
- outputs: NodeOutputs;
2492
- }): Promise<RunResult>;
2493
- resumeFromNodeError(args: {
2494
- runId: RunId;
2495
- activationId: NodeActivationId;
2496
- nodeId: NodeId;
2497
- error: Error;
2498
- }): Promise<RunResult>;
2499
- resumeFromStepResult(args: {
2500
- runId: RunId;
2501
- activationId: NodeActivationId;
2502
- nodeId: NodeId;
2503
- outputs: NodeOutputs;
2504
- }): Promise<RunResult>;
2505
- resumeFromStepError(args: {
2506
- runId: RunId;
2507
- activationId: NodeActivationId;
2508
- nodeId: NodeId;
2509
- error: Error;
2510
- }): Promise<RunResult>;
2511
- waitForCompletion(runId: RunId): Promise<Extract<RunResult, {
2512
- status: "completed" | "failed";
2513
- }>>;
2514
- waitForWebhookResponse(runId: RunId): Promise<WebhookRunResult>;
2515
- handleNodeExecutionRequest(request: NodeExecutionRequest): Promise<void>;
2516
- }
2517
- //#endregion
2518
- //#region src/policies/storage/WorkflowStoragePolicyEvaluator.d.ts
2519
- declare class WorkflowStoragePolicyEvaluator {
2520
- private readonly nodeResolver;
2521
- constructor(nodeResolver: NodeResolver);
2522
- shouldPersist(workflow: WorkflowDefinition, snapshot: PersistedRunPolicySnapshot | undefined, args: WorkflowStoragePolicyDecisionArgs): Promise<boolean>;
2523
- private modeMatches;
2524
- }
2525
- //#endregion
2526
- //#region src/policies/storage/RunTerminalPersistenceCoordinator.d.ts
2527
- declare class RunTerminalPersistenceCoordinator {
2528
- private readonly runRepository;
2529
- private readonly storageEvaluator;
2530
- constructor(runRepository: WorkflowExecutionRepository, storageEvaluator: WorkflowStoragePolicyEvaluator);
2531
- maybeDeleteAfterTerminalState(args: {
2532
- workflow: WorkflowDefinition;
2533
- state: PersistedRunState;
2534
- finalStatus: "completed" | "failed";
2535
- finishedAt: string;
2536
- }): Promise<void>;
2537
- }
2538
- //#endregion
2539
- //#region src/policies/WorkflowPolicyErrorServices.d.ts
2540
- declare class WorkflowPolicyErrorServices {
2541
- private readonly nodeResolver;
2542
- constructor(nodeResolver: NodeResolver);
2543
- resolveNodeErrorHandler(spec: NodeErrorHandlerSpec | undefined): NodeErrorHandler | undefined;
2544
- resolveWorkflowErrorHandler(spec: WorkflowErrorHandlerSpec | undefined): WorkflowErrorHandler | undefined;
2545
- }
2546
- //#endregion
2547
- //#region src/policies/executionLimits/EngineExecutionLimitsPolicyFactory.d.ts
2548
- /**
2549
- * Builds {@link EngineExecutionLimitsPolicy} by merging {@link ENGINE_EXECUTION_LIMITS_DEFAULTS} with optional `overrides` (e.g. host `runtime.engineExecutionLimits`).
2550
- */
2551
- declare class EngineExecutionLimitsPolicyFactory {
2552
- create(overrides?: Partial<EngineExecutionLimitsPolicyConfig>): EngineExecutionLimitsPolicy;
2553
- }
2554
- //#endregion
2555
- //#region src/policies/storage/RunPolicySnapshotFactory.d.ts
2556
- declare class RunPolicySnapshotFactory {
2557
- static create(workflow: WorkflowDefinition, defaults?: WorkflowPolicyRuntimeDefaults): PersistedRunPolicySnapshot;
2558
- }
2559
- //#endregion
2560
- //#region src/workflowSnapshots/WorkflowSnapshotCodec.d.ts
2561
- declare class WorkflowSnapshotCodec {
2562
- private readonly tokenRegistry;
2563
- constructor(tokenRegistry: PersistedWorkflowTokenRegistryLike);
2564
- create(workflow: WorkflowDefinition): PersistedWorkflowSnapshot;
2565
- hydrate(snapshotNode: PersistedWorkflowSnapshotNode, liveConfig: NodeConfigBase): NodeConfigBase;
2566
- private serializeConfig;
2567
- private injectTokenIds;
2568
- private mergeValue;
2569
- private mergeNestedValue;
2570
- private restoreNonSerializableProperties;
2571
- private restoreTypeProperty;
2572
- private resolveTokenId;
2573
- private resolveTokenName;
2574
- private asTypeToken;
2575
- private asRecord;
2576
- }
2577
- //#endregion
2578
- //#region src/runtime/EngineWorkflowRunnerService.d.ts
2579
- declare class EngineWorkflowRunnerService {
2580
- private readonly engine;
2581
- private readonly workflowRepository;
2582
- constructor(engine: Engine, workflowRepository: WorkflowRepository);
2583
- runById(args: {
2584
- workflowId: WorkflowId;
2585
- startAt?: NodeId;
2586
- items: Items;
2587
- parent?: ParentExecutionRef;
2588
- }): Promise<RunResult>;
2589
- private findDefaultStartNodeId;
2590
- }
2591
- //#endregion
2592
- //#region src/runtime/InMemoryLiveWorkflowRepository.d.ts
2593
- declare class InMemoryLiveWorkflowRepository implements LiveWorkflowRepository {
2594
- private readonly workflowsById;
2595
- setWorkflows(workflows: ReadonlyArray<WorkflowDefinition>): void;
2596
- list(): ReadonlyArray<WorkflowDefinition>;
2597
- get(workflowId: WorkflowId): WorkflowDefinition | undefined;
2598
- }
2599
- //#endregion
2600
- //#region src/runtime/RunIntentService.d.ts
2601
- type StartWorkflowIntent = {
2602
- workflow: WorkflowDefinition;
2603
- startAt?: string;
2604
- items: Items;
2605
- synthesizeTriggerItems?: boolean;
2606
- parent?: CurrentStateExecutionRequest["parent"];
2607
- executionOptions?: RunExecutionOptions;
2608
- workflowSnapshot?: CurrentStateExecutionRequest["workflowSnapshot"];
2609
- mutableState?: CurrentStateExecutionRequest["mutableState"];
2610
- currentState?: RunCurrentState;
2611
- stopCondition?: RunStopCondition;
2612
- reset?: CurrentStateExecutionRequest["reset"];
2613
- };
2614
- type RerunFromNodeIntent = {
2615
- workflow: WorkflowDefinition;
2616
- nodeId: NodeId;
2617
- currentState: RunCurrentState;
2618
- items?: Items;
2619
- synthesizeTriggerItems?: boolean;
2620
- parent?: CurrentStateExecutionRequest["parent"];
2621
- executionOptions?: RunExecutionOptions;
2622
- workflowSnapshot?: CurrentStateExecutionRequest["workflowSnapshot"];
2623
- mutableState?: CurrentStateExecutionRequest["mutableState"];
2624
- };
2625
- type MatchedWebhookRunIntent = {
2626
- endpointPath: string;
2627
- method: HttpMethod;
2628
- requestItem: Items[number];
2629
- };
2630
- type WebhookMatchRunIntent = {
2631
- match: WebhookInvocationMatch;
2632
- requestItem: Items[number];
2633
- };
2634
- declare class RunIntentService {
2635
- private readonly engine;
2636
- private readonly workflowRepository;
2637
- constructor(engine: Engine, workflowRepository: WorkflowRepository);
2638
- startWorkflow(args: StartWorkflowIntent): Promise<RunResult>;
2639
- rerunFromNode(args: RerunFromNodeIntent): Promise<RunResult>;
2640
- private resolveStartWorkflowItems;
2641
- private resolveRerunItems;
2642
- private resolveStartWorkflowTriggerNodeId;
2643
- private resolveRerunTriggerNodeId;
2644
- private firstTriggerNodeId;
2645
- private isTriggerNode;
2646
- private hasNonEmptyItems;
2647
- resolveWebhookTrigger(args: {
2648
- endpointPath: string;
2649
- method: HttpMethod;
2650
- }): WebhookTriggerResolution;
2651
- runMatchedWebhook(args: MatchedWebhookRunIntent): Promise<WebhookRunResult>;
2652
- runWebhookMatch(args: WebhookMatchRunIntent): Promise<WebhookRunResult>;
2653
- /**
2654
- * Webhook-triggered runs always force inline execution first.
2655
- * This is the highest-precedence scheduler override: it wins over node hints and container defaults.
2656
- */
2657
- private createWebhookExecutionOptions;
2658
- }
2659
- //#endregion
2660
- 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 };
2661
- //# sourceMappingURL=RunIntentService-CI-F8qQ7.d.ts.map
2557
+ export { CostCatalogEntry as $, NodeId as $a, TelemetryChildSpanStart as $i, NodeInspectorSummaryRow as $n, ExecutionBinaryService as $r, WebhookRunResult as $t, isUnbrandedPortsEmissionShape as A, CredentialHealthTester as Aa, TriggerTestItemsContext as Ai, TestTriggerNodeConfig as An, WorkflowStoragePolicyMode as Ar, NodeInputsByPort as At, PersistedExecutionInstanceRecord as B, CredentialSessionService as Ba, WebhookInvocationMatch as Bi, JsonArray as Bn, FixedRetryPolicySpec as Br, PinnedNodeOutputsByPort as Bt, ExpRetryPolicy as C, CredentialAdvancedSectionPresentation as Ca, TestableTriggerNode as Ci, EngineExecutionLimitsPolicyConfig as Cn, WorkflowErrorHandlerSpec as Cr, ConnectionInvocationRecord as Ct, PortsEmission as D, CredentialFieldSchema as Da, TriggerSetupContext as Di, TestCaseRunStatus as Dn, WorkflowPolicyRuntimeDefaults as Dr, NodeExecutionError as Dt, getOriginIndexFromItem as E, CredentialBindingKey as Ea, TriggerRuntimeDiagnostics as Ei, RunEventSubscription as En, WorkflowNodeConnection as Er, ExecutionFrontierPlan as Et, ExecutionInstanceDto as F, CredentialOAuth2AuthDefinition as Fa, WorkflowSnapshotFactory as Fi, Edge as Fn, runnableNodeInputType as Fr, PersistedRunSchedulingState as Ft, RunRevision as G, CredentialTypeRegistry as Ga, WorkflowActivationPolicy as Gi, MutableRunData as Gn, BinaryStorage as Gr, RunPruneCandidate as Gt, PersistedRunWorkItemKind as H, CredentialType as Ha, WebhookTriggerResolution as Hi, JsonObject as Hn, RetryPolicySpec as Hr, RunCurrentState as Ht, ExecutionInstanceId as I, CredentialOAuth2ScopesFromPublicConfig as Ia, WorkflowSnapshotResolver as Ii, ExecutionMode as In, runnableNodeOutputType as Ir, PersistedRunState as It, WorkItemId as J, NoOpPollingTriggerLogger as Ja, NodeExecutionTelemetry as Ji, NodeDefinition as Jn, BinaryStorageWriteRequest as Jr, RunStateResetRequest as Jt, RunSlotProjectionState as K, CredentialUnboundError as Ka, ExecutionTelemetry as Ki, NodeActivationId as Kn, BinaryStorageReadResult as Kr, RunQueueEntry as Kt, ExecutionPayloadPolicyFields as L, CredentialRequirement as La, HttpMethod as Li, Item as Ln, triggerNodeOutputType as Lr, PersistedWorkflowSnapshot as Lt, McpServerTransport as M, CredentialInstanceRecord as Ma, WorkflowRepository as Mi, ActivationIdFactory as Mn, WorkflowStoragePolicySpec as Mr, PersistedMutableNodeState as Mt, BatchId as N, CredentialJsonRecord as Na, WorkflowRunnerResolver as Ni, BinaryAttachment as Nn, branchRef as Nr, PersistedMutableRunState as Nt, emitPorts as O, CredentialHealth as Oa, TriggerSetupStateFor as Oi, TestSuiteRunStatus as On, WorkflowPrunePolicySpec as Or, NodeExecutionSnapshot as Ot, ConnectionInvocationKind as P, CredentialMaterialSourceKind as Pa, WorkflowRunnerService as Pi, BinaryPreviewKind as Pn, nodeRef as Pr, PersistedRunControlState as Pt, CostCatalog as Q, NodeConnectionName as Qa, TelemetryAttributes as Qi, NodeIdRef as Qn, ExecutableTriggerNode as Qr, RunTestContext as Qt, PayloadStorageKind as R, CredentialSessionFactory as Ra, TriggerInstanceId as Ri, ItemBinary as Rn, triggerNodeSetupStateType as Rr, PersistedWorkflowSnapshotNode as Rt, NoOpCostTrackingTelemetry as S, AnyCredentialType as Sa, RunnableNodeExecuteArgs as Si, EngineExecutionLimitsPolicy as Sn, WorkflowErrorHandler as Sr, ConnectionInvocationId as St, NoRetryPolicy as T, CredentialBinding as Ta, TriggerNode as Ti, RunEventBus as Tn, WorkflowGraphFactory as Tr, EngineRunCounters as Tt, PersistedRunWorkItemRecord as U, CredentialTypeDefinition as Ua, WebhookTriggerRoutingDiagnostics as Ui, JsonPrimitive as Un, BinaryAttachmentCreateRequest as Ur, RunEventPublisherDeps as Ut, PersistedRunSlotProjectionRecord as V, CredentialSetupStatus as Va, WebhookTriggerMatcher as Vi, JsonNonArray as Vn, NoneRetryPolicySpec as Vr, RunCompletionNotifier as Vt, RunIterationDto as W, CredentialTypeId as Wa, AllWorkflowsActiveWorkflowActivationPolicy as Wi, JsonValue as Wn, BinaryBody as Wr, RunExecutionOptions as Wt, WorkflowDetailSelectionState as X, PollingTriggerDedupWindow as Xa, TelemetryArtifactReference as Xi, NodeErrorHandlerArgs as Xn, EngineDeps as Xr, RunStopCondition as Xt, WorkItemStatus as Y, PollingTriggerLogger as Ya, TelemetryArtifactAttachment as Yi, NodeErrorHandler as Yn, BinaryStorageWriteResult as Yr, RunStatus as Yt, WorkflowRunDetailDto as Z, InputPortKey as Za, TelemetryAttributePrimitive as Zi, NodeErrorHandlerSpec as Zn, EngineHost as Zr, RunSummary as Zt, BranchStepsArg as _, CostTrackingTelemetryFactory as _a, NodeResolver as _i, predicateAwareClassFactory as _n, TriggerNodeOutputJson as _r, AgentBindError as _t, ConnectionNodeIdFactory as a, CodemationTelemetryMetricNames as aa, NodeActivationContinuation as ai, Disposable as an, NodeSchedulerDecision as ar, ItemExprCallback as at, RunFinishedAtFactory as b, CollectionStore as ba, PreparedNodeActivationDispatch as bi, CoreTokens as bn, WorkflowDefinition as br, NeedsReconsentEvent as bt, WorkflowDefinitionError as c, NoOpExecutionTelemetryFactory as ca, NodeActivationRequestBase as ci, RegistrationOptions as cn, PersistedRunPolicySnapshot as cr, isItemExpr as ct, WhenBuilder as d, NoOpTelemetrySpanScope as da, NodeExecutionContext as di, delay as dn, RunId as dr, resolveItemExprsInUnknown as dt, TelemetryMetricRecord as ea, ExecutionContext as ei, WorkflowExecutionListingRepository as en, OutputPortKey as eo, NodeIterationId as er, Expr as et, AnyRunnableNodeConfig as f, NoOpTelemetryArtifactReference as fa, NodeExecutionRequest as fi, inject as fn, RunIdFactory as fr, AssertionResult as ft, BranchOutputGuard as g, CostTrackingTelemetryAttributeNames as ga, NodeExecutor as gi, instancePerContainerCachingFactory as gn, TriggerNodeConfig as gr, NoOpAgentMcpIntegration as gt, BranchMoreArgs as h, CostTrackingTelemetry as ha, NodeExecutionStatePublisher as hi, instanceCachingFactory as hn, RunnableNodeOutputJson as hr, deriveAssertionPassed as ht, NodeIterationIdFactory as i, TelemetrySpanScope as ia, MultiInputNode as ii, DependencyContainer$1 as in, NodeRef as ir, ItemExprArgs as it, McpServerDeclaration as j, CredentialInstanceId as ja, WorkflowNodeInstanceFactory as ji, TestTriggerSetupContext as jn, WorkflowStoragePolicyResolver as jr, PendingNodeExecution as jt, isPortsEmission as k, CredentialHealthStatus as ka, TriggerSetupStateRepository as ki, TestSuiteRunId as kn, WorkflowStoragePolicyDecisionArgs as kr, NodeExecutionStatus as kt, WorkflowBuilder as l, NoOpExecutionTelemetry as la, NodeActivationScheduler as li, TypeToken as ln, RunDataFactory as lr, itemExpr as lt, BooleanWhenOverloads as m, CostTrackingPriceQuote as ma, NodeExecutionScheduler as mi, injectable as mn, RunnableNodeInputJson as mr, DEFAULT_ASSERTION_PASS_THRESHOLD as mt, WorkflowExecutableNodeClassifierFactory as n, TelemetrySpanEnd as na, ItemNode as ni, WorkflowExecutionRepository as nn, WorkflowId as no, NodeOffloadPolicy as nr, ParamDeep as nt, ConnectionInvocationIdFactory as o, GenAiTelemetryAttributeNames as oa, NodeActivationReceipt as oi, InjectionToken$1 as on, PairedItemRef as or, ItemExprContext as ot, AnyTriggerNodeConfig as p, CostTrackingComponent as pa, NodeExecutionRequestHandler as pi, injectAll as pn, RunnableNodeConfig as pr, AssertionResultProvenance as pt, SlotExecutionStateDto as q, OAuth2ProviderFromPublicConfig as qa, ExecutionTelemetryFactory as qi, NodeConfigBase as qn, BinaryStorageStatResult as qr, RunResult as qt, WorkflowExecutableNodeClassifier as r, TelemetrySpanEventRecord as ra, LiveWorkflowRepository as ri, Container as rn, NodeOutputs as rr, ItemExpr as rt, NodeIdSlugifier as s, CodemationTelemetryAttributeNames as sa, NodeActivationRequest as si, Lifecycle as sn, ParentExecutionRef as sr, ItemExprResolvedContext as st, DefaultWorkflowGraphFactory as t, TelemetryScope as ta, ExecutionContextFactory as ti, WorkflowExecutionPruneRepository as tn, PersistedTokenId as to, NodeKind as tr, Param as tt, ChainCursor as u, NoOpNodeExecutionTelemetry as ua, NodeBinaryAttachmentService as ui, container$1 as un, RunDataSnapshot as ur, resolveItemExprsForExecution as ut, StepSequenceOutput as v, CostTrackingTelemetryMetricNames as va, PersistedTriggerSetupState as vi, registry as vn, TriggerNodeSetupState as vr, AgentMcpIntegration as vt, RetryPolicy as w, CredentialAuthDefinition as wa, TriggerCleanupHandle as wi, RunEvent as wn, WorkflowGraph as wr, CurrentStateExecutionRequest as wt, NoOpCostTrackingTelemetryFactory as x, CollectionsContext as xa, RunnableNode as xi, ENGINE_EXECUTION_LIMITS_DEFAULTS as xn, WorkflowErrorContext as xr, ConnectionInvocationAppendArgs as xt, ValidStepSequence as y, CostTrackingUsageRecord as ya, PollingTriggerHandle as yi, singleton as yn, UpstreamRefPlaceholder as yr, AgentMcpToolMap as yt, PersistedExecutionInstanceKind as z, CredentialSessionFactoryArgs as za, WebhookControlSignal as zi, Items as zn, ExponentialRetryPolicySpec as zr, PersistedWorkflowTokenRegistryLike as zt };
2558
+ //# sourceMappingURL=index-zWGtEhrf.d.ts.map