@codemation/core 0.8.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +380 -0
  2. package/dist/{EngineRuntimeRegistration.types-BP6tsaNP.d.ts → EngineRuntimeRegistration.types-D1fyApMI.d.ts} +2 -2
  3. package/dist/{EngineWorkflowRunnerService-DzOCa1BW.d.cts → EngineRuntimeRegistration.types-pB3FnzqR.d.cts} +17 -17
  4. package/dist/{InMemoryRunDataFactory-1iz7_SnO.d.cts → InMemoryRunDataFactory-Xw7v4-sj.d.cts} +31 -29
  5. package/dist/InMemoryRunEventBusRegistry-VM3OWnHo.cjs +47 -0
  6. package/dist/InMemoryRunEventBusRegistry-VM3OWnHo.cjs.map +1 -0
  7. package/dist/InMemoryRunEventBusRegistry-sM4z4n_i.js +41 -0
  8. package/dist/InMemoryRunEventBusRegistry-sM4z4n_i.js.map +1 -0
  9. package/dist/{RunIntentService-BqhmdoA1.d.ts → RunIntentService-BE9CAkbf.d.ts} +966 -471
  10. package/dist/{RunIntentService-S-1lW-gS.d.cts → RunIntentService-siBSjaaY.d.cts} +859 -493
  11. package/dist/bootstrap/index.cjs +5 -2
  12. package/dist/bootstrap/index.d.cts +212 -135
  13. package/dist/bootstrap/index.d.ts +4 -4
  14. package/dist/bootstrap/index.js +3 -3
  15. package/dist/{bootstrap-Bx1u4cbS.cjs → bootstrap-Cm5ruQxx.cjs} +253 -2
  16. package/dist/bootstrap-Cm5ruQxx.cjs.map +1 -0
  17. package/dist/{bootstrap-BoknFKnw.js → bootstrap-D3r505ko.js} +236 -3
  18. package/dist/bootstrap-D3r505ko.js.map +1 -0
  19. package/dist/{index-CVs9rVhl.d.ts → index-DeLl1Tne.d.ts} +632 -230
  20. package/dist/index.cjs +323 -176
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +544 -91
  23. package/dist/index.d.ts +3 -3
  24. package/dist/index.js +299 -166
  25. package/dist/index.js.map +1 -1
  26. package/dist/{runtime-DUW6tIJ1.js → runtime-BGNbRnqs.js} +934 -75
  27. package/dist/runtime-BGNbRnqs.js.map +1 -0
  28. package/dist/{runtime-Dvo2ru5A.cjs → runtime-DKXJwTNv.cjs} +1028 -73
  29. package/dist/runtime-DKXJwTNv.cjs.map +1 -0
  30. package/dist/testing.cjs +4 -4
  31. package/dist/testing.cjs.map +1 -1
  32. package/dist/testing.d.cts +2 -2
  33. package/dist/testing.d.ts +2 -2
  34. package/dist/testing.js +3 -3
  35. package/package.json +7 -2
  36. package/src/ai/AiHost.ts +42 -14
  37. package/src/authoring/DefinedCollectionRegistry.ts +17 -0
  38. package/src/authoring/defineCollection.types.ts +181 -0
  39. package/src/authoring/definePollingTrigger.types.ts +396 -0
  40. package/src/authoring/definePollingTriggerInternals.ts +74 -0
  41. package/src/authoring/index.ts +19 -0
  42. package/src/bootstrap/index.ts +9 -0
  43. package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +8 -0
  44. package/src/browser.ts +1 -0
  45. package/src/contracts/CodemationTelemetryAttributeNames.ts +6 -0
  46. package/src/contracts/NoOpNodeExecutionTelemetry.ts +2 -11
  47. package/src/contracts/NoOpTelemetrySpanScope.ts +46 -10
  48. package/src/contracts/assertionTypes.ts +63 -0
  49. package/src/contracts/baseTypes.ts +12 -0
  50. package/src/contracts/collectionTypes.ts +44 -0
  51. package/src/contracts/credentialTypes.ts +23 -1
  52. package/src/contracts/executionPersistenceContracts.ts +30 -0
  53. package/src/contracts/index.ts +4 -0
  54. package/src/contracts/runTypes.ts +37 -1
  55. package/src/contracts/runtimeTypes.ts +42 -0
  56. package/src/contracts/telemetryTypes.ts +8 -0
  57. package/src/contracts/testTriggerTypes.ts +66 -0
  58. package/src/contracts/workflowTypes.ts +36 -7
  59. package/src/contracts.ts +59 -0
  60. package/src/events/ConnectionInvocationEventPublisher.ts +46 -0
  61. package/src/events/index.ts +1 -0
  62. package/src/events/runEvents.ts +74 -0
  63. package/src/execution/ChildExecutionScopeFactory.ts +55 -0
  64. package/src/execution/DefaultExecutionContextFactory.ts +6 -0
  65. package/src/execution/ExecutionTelemetryCostTrackingDecoratorFactory.ts +18 -0
  66. package/src/execution/NodeExecutor.ts +10 -2
  67. package/src/execution/NodeInstanceFactory.ts +13 -1
  68. package/src/execution/NodeInstantiationError.ts +16 -0
  69. package/src/execution/NodeRunStateWriter.ts +7 -0
  70. package/src/execution/NodeRunStateWriterFactory.ts +7 -0
  71. package/src/execution/WorkflowRunExecutionContextFactory.ts +3 -0
  72. package/src/execution/index.ts +2 -0
  73. package/src/index.ts +8 -0
  74. package/src/orchestration/AbortControllerFactory.ts +9 -0
  75. package/src/orchestration/NodeExecutionRequestHandlerService.ts +1 -0
  76. package/src/orchestration/RunContinuationService.ts +3 -0
  77. package/src/orchestration/RunStartService.ts +122 -3
  78. package/src/orchestration/TestSuiteOrchestrator.ts +350 -0
  79. package/src/orchestration/TestSuiteRunIdFactory.ts +11 -0
  80. package/src/orchestration/TriggerRuntimeService.ts +34 -7
  81. package/src/orchestration/index.ts +9 -0
  82. package/src/runtime/EngineFactory.ts +12 -0
  83. package/src/triggers/polling/PollingTriggerDedupWindow.ts +23 -0
  84. package/src/triggers/polling/PollingTriggerLogger.ts +18 -0
  85. package/src/triggers/polling/PollingTriggerRuntime.ts +122 -0
  86. package/src/triggers/polling/index.ts +5 -0
  87. package/src/types/index.ts +12 -9
  88. package/src/workflow/definition/NodeIterationIdFactory.ts +26 -0
  89. package/src/workflow/dsl/NodeIdSlugifier.ts +18 -0
  90. package/src/workflow/dsl/WorkflowBuilder.ts +71 -3
  91. package/src/workflow/dsl/WorkflowDefinitionError.ts +15 -0
  92. package/src/workflow/index.ts +3 -0
  93. package/dist/InMemoryRunEventBusRegistry-B0_C4OnP.cjs +0 -262
  94. package/dist/InMemoryRunEventBusRegistry-B0_C4OnP.cjs.map +0 -1
  95. package/dist/InMemoryRunEventBusRegistry-C2U83Hmv.js +0 -238
  96. package/dist/InMemoryRunEventBusRegistry-C2U83Hmv.js.map +0 -1
  97. package/dist/bootstrap-BoknFKnw.js.map +0 -1
  98. package/dist/bootstrap-Bx1u4cbS.cjs.map +0 -1
  99. package/dist/runtime-DUW6tIJ1.js.map +0 -1
  100. package/dist/runtime-Dvo2ru5A.cjs.map +0 -1
@@ -1,8 +1,92 @@
1
- import { ReadableStream } from "node:stream/web";
2
1
  import { DependencyContainer as Container, DependencyContainer as DependencyContainer$1, Disposable, InjectionToken as InjectionToken$1, InjectionToken as TypeToken, Lifecycle, RegistrationOptions, container, delay, inject, injectAll, injectable, instanceCachingFactory, instancePerContainerCachingFactory, predicateAwareClassFactory, registry, singleton } from "tsyringe";
2
+ import { ReadableStream } from "node:stream/web";
3
3
  import { ZodType } from "zod";
4
4
 
5
+ //#region src/contracts/baseTypes.d.ts
6
+ /**
7
+ * Minimal base types that have no dependencies on other contracts.
8
+ * Used by credentialTypes, workflowTypes, and other contract layers
9
+ * to avoid circular dependencies.
10
+ */
11
+ type WorkflowId = string;
12
+ type NodeId = string;
13
+ type OutputPortKey = string;
14
+ type InputPortKey = string;
15
+ type PersistedTokenId = string;
16
+ type NodeConnectionName = string;
17
+ //#endregion
18
+ //#region src/contracts/testTriggerTypes.d.ts
19
+ /**
20
+ * Identifier minted by the host (or in-memory test runner) for one execution of a test suite.
21
+ * One TestSuiteRun produces N child workflow runs, one per item yielded by `generateItems`.
22
+ */
23
+ type TestSuiteRunId = string;
24
+ /**
25
+ * Setup context passed to a {@link TestTriggerNodeConfig.generateItems} callback. Distinct from
26
+ * {@link import("./runtimeTypes").TriggerSetupContext} on purpose: test triggers are not
27
+ * activated by the live trigger lifecycle (webhooks, cron, polling) and never call `emit` —
28
+ * the orchestrator pulls from the iterable they return and dispatches one run per item.
29
+ */
30
+ interface TestTriggerSetupContext<TConfig extends TestTriggerNodeConfig<unknown> = TestTriggerNodeConfig<unknown>> {
31
+ readonly workflowId: WorkflowId;
32
+ readonly nodeId: NodeId;
33
+ readonly config: TConfig;
34
+ readonly testSuiteRunId: TestSuiteRunId;
35
+ /**
36
+ * Resolves a credential session for a slot declared on this trigger's
37
+ * {@link import("./workflowTypes").NodeConfigBase.getCredentialRequirements}. Same contract as
38
+ * {@link import("./runtimeTypes").ExecutionContext.getCredential}.
39
+ */
40
+ getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
41
+ /** AbortSignal raised when the suite is cancelled — long-running pulls should bail out. */
42
+ readonly signal: AbortSignal;
43
+ }
44
+ /**
45
+ * A trigger config that emits **test cases**. Each item yielded by {@link generateItems}
46
+ * becomes one workflow run (with `executionOptions.testContext` set), so 10 yielded items
47
+ * → 10 runs marked under the same TestSuiteRun.
48
+ *
49
+ * The trigger is otherwise a normal {@link TriggerNodeConfig} (so the canvas treats it like
50
+ * any other trigger), but its `triggerKind` is `"test"` so the live activation policy skips it.
51
+ */
52
+ interface TestTriggerNodeConfig<TOutputJson$1 = unknown> extends TriggerNodeConfig<TOutputJson$1, undefined> {
53
+ readonly triggerKind: "test";
54
+ /**
55
+ * Author-supplied async iterable of items, evaluated lazily. Implementations may fetch from
56
+ * credentialed APIs, read fixture files, or yield hard-coded items. The orchestrator iterates
57
+ * and dispatches one run per item, with concurrency capped by {@link concurrency} (default 4).
58
+ */
59
+ generateItems(ctx: TestTriggerSetupContext<TestTriggerNodeConfig<TOutputJson$1>>): AsyncIterable<Item<TOutputJson$1>>;
60
+ /** Per-suite-run cap on simultaneously-executing test cases. Default: 4. */
61
+ readonly concurrency?: number;
62
+ /**
63
+ * Free-form description of where the test cases come from — surfaced in the node properties
64
+ * panel and the suite-detail header so authors revisiting the workflow six months later
65
+ * remember which mailbox / folder / fixture file the cases originate from.
66
+ *
67
+ * Example: `"All emails in the Gmail label \"test/triage-fixtures\" — 14 messages as of 2026-05-03."`
68
+ */
69
+ readonly description?: string;
70
+ /**
71
+ * Resolves a human-readable label for one yielded test case (e.g. email subject). The
72
+ * orchestrator calls this once per yielded item, persists the result on the run, and the
73
+ * Tests-tab UI uses it to render the case row instead of the opaque runId. Return
74
+ * `undefined` to fall back to "Case #N".
75
+ */
76
+ caseLabel?(item: Item<TOutputJson$1>): string | undefined;
77
+ }
78
+ //#endregion
5
79
  //#region src/events/runEvents.d.ts
80
+ /**
81
+ * Outcome of a single test case (one workflow run dispatched by the test-suite orchestrator).
82
+ * - `running`: workflow still in flight
83
+ * - `succeeded`: workflow completed AND all assertions passed (or no assertions)
84
+ * - `failed`: workflow failed OR (workflow completed but ≥1 assertion failed)
85
+ * - `errored` / `cancelled`: workflow itself errored or was cancelled
86
+ */
87
+ type TestCaseRunStatus = "running" | "succeeded" | "failed" | "errored" | "cancelled";
88
+ /** Aggregate outcome of a TestSuiteRun. */
89
+ type TestSuiteRunStatus = "succeeded" | "failed" | "partial" | "errored" | "cancelled";
6
90
  type RunEvent = Readonly<{
7
91
  kind: "runCreated";
8
92
  runId: RunId;
@@ -44,6 +128,60 @@ type RunEvent = Readonly<{
44
128
  parent?: ParentExecutionRef;
45
129
  at: string;
46
130
  snapshot: NodeExecutionSnapshot;
131
+ }> | Readonly<{
132
+ kind: "connectionInvocationStarted";
133
+ runId: RunId;
134
+ workflowId: WorkflowId;
135
+ parent?: ParentExecutionRef;
136
+ at: string;
137
+ record: ConnectionInvocationRecord;
138
+ }> | Readonly<{
139
+ kind: "connectionInvocationCompleted";
140
+ runId: RunId;
141
+ workflowId: WorkflowId;
142
+ parent?: ParentExecutionRef;
143
+ at: string;
144
+ record: ConnectionInvocationRecord;
145
+ }> | Readonly<{
146
+ kind: "connectionInvocationFailed";
147
+ runId: RunId;
148
+ workflowId: WorkflowId;
149
+ parent?: ParentExecutionRef;
150
+ at: string;
151
+ record: ConnectionInvocationRecord;
152
+ }> | Readonly<{
153
+ kind: "testSuiteStarted";
154
+ testSuiteRunId: TestSuiteRunId;
155
+ workflowId: WorkflowId;
156
+ triggerNodeId: string;
157
+ triggerNodeName?: string;
158
+ concurrency: number;
159
+ at: string;
160
+ }> | Readonly<{
161
+ kind: "testSuiteFinished";
162
+ testSuiteRunId: TestSuiteRunId;
163
+ workflowId: WorkflowId;
164
+ status: TestSuiteRunStatus;
165
+ totalCases: number;
166
+ passedCases: number;
167
+ failedCases: number;
168
+ at: string;
169
+ }> | Readonly<{
170
+ kind: "testCaseStarted";
171
+ testSuiteRunId: TestSuiteRunId;
172
+ testCaseIndex: number;
173
+ runId: RunId;
174
+ workflowId: WorkflowId;
175
+ testCaseLabel?: string;
176
+ at: string;
177
+ }> | Readonly<{
178
+ kind: "testCaseCompleted";
179
+ testSuiteRunId: TestSuiteRunId;
180
+ testCaseIndex: number;
181
+ runId: RunId;
182
+ workflowId: WorkflowId;
183
+ status: TestCaseRunStatus;
184
+ at: string;
47
185
  }>;
48
186
  interface RunEventSubscription {
49
187
  close(): Promise<void>;
@@ -103,72 +241,432 @@ declare const CoreTokens: {
103
241
  readonly WorkflowActivationPolicy: TypeToken<WorkflowActivationPolicy>;
104
242
  };
105
243
  //#endregion
106
- //#region src/contracts/credentialTypes.d.ts
107
- type CredentialTypeId = string;
108
- type CredentialInstanceId = string;
109
- type CredentialMaterialSourceKind = "db" | "env" | "code";
110
- type CredentialSetupStatus = "draft" | "ready";
111
- type CredentialHealthStatus = "unknown" | "healthy" | "failing";
112
- type CredentialFieldSchema = Readonly<{
113
- key: string;
114
- label: string;
115
- type: "string" | "password" | "textarea" | "json" | "boolean";
116
- required?: true;
117
- order?: number;
118
- /**
119
- * Where this field appears in the credential dialog. Use `"advanced"` for optional or
120
- * power-user fields; they render inside a collapsible section (see `CredentialTypeDefinition.advancedSection`).
121
- * Defaults to `"default"` when omitted.
122
- */
123
- visibility?: "default" | "advanced";
124
- placeholder?: string;
125
- helpText?: string;
126
- /** When set, host resolves this field from process.env at runtime; env wins over stored values. */
127
- envVarName?: string;
244
+ //#region src/contracts/runTypes.d.ts
245
+ /**
246
+ * Test-suite linkage for a run. When set, this run was started by a TestSuiteOrchestrator
247
+ * as one test case inside a TestSuiteRun. The `IsTestRun` node and host-side persisters key
248
+ * off the presence of this field. Subworkflow runs inherit it from their parent run.
249
+ */
250
+ interface RunTestContext {
251
+ readonly testSuiteRunId: string;
252
+ readonly testCaseIndex: number;
128
253
  /**
129
- * When set, the dialog shows a copy action for this exact string (e.g. a static OAuth redirect URI
130
- * pattern or documentation URL). Do not use for secret values.
254
+ * Optional human-friendly label for this test case (e.g. an email subject when fixtures
255
+ * are loaded from a mailbox). Resolved per item by `TestTrigger.caseLabel(item)` if set,
256
+ * persisted on `Run.test_case_label` so the Tests-tab tree-table can show "RFQ for batch 14"
257
+ * instead of "run_1777755971399_bbb86beac1396".
131
258
  */
132
- copyValue?: string;
133
- /** Accessible label for the copy control (default: Copy). */
134
- copyButtonLabel?: string;
135
- }>;
136
- type CredentialRequirement = Readonly<{
137
- slotKey: string;
138
- label: string;
139
- acceptedTypes: ReadonlyArray<CredentialTypeId>;
140
- optional?: true;
141
- helpText?: string;
142
- helpUrl?: string;
259
+ readonly testCaseLabel?: string;
260
+ }
261
+ interface RunExecutionOptions {
262
+ /** Run-intent override: force the inline scheduler and bypass node-level offload decisions. */
263
+ localOnly?: boolean;
264
+ /** Marks runs started from webhook handling so orchestration can apply webhook-specific continuation rules. */
265
+ webhook?: boolean;
266
+ mode?: "manual" | "debug";
267
+ sourceWorkflowId?: WorkflowId;
268
+ sourceRunId?: RunId;
269
+ derivedFromRunId?: RunId;
270
+ isMutable?: boolean;
271
+ /** Set by the engine for this run: 0 = root, 1 = first child subworkflow, … */
272
+ subworkflowDepth?: number;
273
+ /** Effective cap after engine policy merge (successful node completions per run). */
274
+ maxNodeActivations?: number;
275
+ /** Effective cap after engine policy merge (subworkflow nesting). */
276
+ maxSubworkflowDepth?: number;
277
+ /** Present iff started by a TestSuiteOrchestrator; propagates to subworkflow runs via {@link ParentExecutionRef.testContext}. */
278
+ testContext?: RunTestContext;
279
+ }
280
+ /** Engine-owned counters persisted with the run (worker-safe). */
281
+ interface EngineRunCounters {
282
+ completedNodeActivations: number;
283
+ }
284
+ type RunStopCondition = Readonly<{
285
+ kind: "workflowCompleted";
286
+ }> | Readonly<{
287
+ kind: "nodeCompleted";
288
+ nodeId: NodeId;
143
289
  }>;
144
- type CredentialBindingKey = Readonly<{
290
+ interface RunStateResetRequest {
291
+ clearFromNodeId: NodeId;
292
+ }
293
+ interface PersistedRunControlState {
294
+ stopCondition?: RunStopCondition;
295
+ }
296
+ interface PersistedWorkflowSnapshotNode {
297
+ id: NodeId;
298
+ kind: NodeKind;
299
+ name?: string;
300
+ nodeTokenId: PersistedTokenId;
301
+ configTokenId: PersistedTokenId;
302
+ tokenName?: string;
303
+ configTokenName?: string;
304
+ config: unknown;
305
+ }
306
+ interface PersistedWorkflowSnapshot {
307
+ id: WorkflowId;
308
+ name: string;
309
+ nodes: ReadonlyArray<PersistedWorkflowSnapshotNode>;
310
+ edges: ReadonlyArray<Edge>;
311
+ /** When the snapshot was built from a live workflow definition that configured a workflow error handler. */
312
+ workflowErrorHandlerConfigured?: boolean;
313
+ /** Connection metadata for child nodes not in the execution graph (e.g. AI agent attachments). */
314
+ connections?: ReadonlyArray<WorkflowNodeConnection>;
315
+ }
316
+ type PinnedNodeOutputsByPort = Readonly<Record<OutputPortKey, Items>>;
317
+ interface PersistedMutableNodeState {
318
+ pinnedOutputsByPort?: PinnedNodeOutputsByPort;
319
+ lastDebugInput?: Items;
320
+ }
321
+ interface PersistedMutableRunState {
322
+ nodesById: Readonly<Record<NodeId, PersistedMutableNodeState>>;
323
+ }
324
+ type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
325
+ interface RunQueueEntry {
326
+ nodeId: NodeId;
327
+ input: Items;
328
+ toInput?: InputPortKey;
329
+ batchId?: string;
330
+ from?: Readonly<{
331
+ nodeId: NodeId;
332
+ output: OutputPortKey;
333
+ }>;
334
+ collect?: Readonly<{
335
+ expectedInputs: ReadonlyArray<InputPortKey>;
336
+ received: Readonly<Record<InputPortKey, Items>>;
337
+ }>;
338
+ }
339
+ type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
340
+ interface NodeExecutionError {
341
+ message: string;
342
+ name?: string;
343
+ stack?: string;
344
+ details?: JsonValue;
345
+ }
346
+ interface NodeExecutionSnapshot {
347
+ runId: RunId;
145
348
  workflowId: WorkflowId;
146
349
  nodeId: NodeId;
147
- slotKey: string;
148
- }>;
149
- type CredentialBinding = Readonly<{
150
- key: CredentialBindingKey;
151
- instanceId: CredentialInstanceId;
350
+ activationId?: NodeActivationId;
351
+ parent?: ParentExecutionRef;
352
+ status: NodeExecutionStatus;
353
+ usedPinnedOutput?: boolean;
354
+ queuedAt?: string;
355
+ startedAt?: string;
356
+ finishedAt?: string;
152
357
  updatedAt: string;
358
+ inputsByPort?: NodeInputsByPort;
359
+ outputs?: NodeOutputs;
360
+ error?: NodeExecutionError;
361
+ }
362
+ /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
363
+ type ConnectionInvocationId = string;
364
+ /**
365
+ * One logical LLM or tool call under an owning workflow node (e.g. AI agent).
366
+ * The owning node defines what {@link managedInput} and {@link managedOutput} contain.
367
+ */
368
+ interface ConnectionInvocationRecord {
369
+ readonly invocationId: ConnectionInvocationId;
370
+ readonly runId: RunId;
371
+ readonly workflowId: WorkflowId;
372
+ readonly connectionNodeId: NodeId;
373
+ readonly parentAgentNodeId: NodeId;
374
+ readonly parentAgentActivationId: NodeActivationId;
375
+ readonly status: NodeExecutionStatus;
376
+ readonly managedInput?: JsonValue;
377
+ readonly managedOutput?: JsonValue;
378
+ readonly error?: NodeExecutionError;
379
+ readonly queuedAt?: string;
380
+ readonly startedAt?: string;
381
+ readonly finishedAt?: string;
382
+ readonly updatedAt: string;
383
+ /** Per-item iteration id minted by the engine when this invocation occurred inside a runnable node's per-item loop. */
384
+ readonly iterationId?: NodeIterationId;
385
+ /** Item index (0-based) of the iteration that produced this invocation. */
386
+ readonly itemIndex?: number;
387
+ /** When set, this invocation was produced inside a sub-agent triggered by the named parent invocation. */
388
+ readonly parentInvocationId?: ConnectionInvocationId;
389
+ }
390
+ /** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
391
+ type ConnectionInvocationAppendArgs = Readonly<{
392
+ invocationId: ConnectionInvocationId;
393
+ connectionNodeId: NodeId;
394
+ parentAgentNodeId: NodeId;
395
+ parentAgentActivationId: NodeActivationId;
396
+ status: NodeExecutionStatus;
397
+ managedInput?: JsonValue;
398
+ managedOutput?: JsonValue;
399
+ error?: NodeExecutionError;
400
+ queuedAt?: string;
401
+ startedAt?: string;
402
+ finishedAt?: string;
403
+ iterationId?: NodeIterationId;
404
+ itemIndex?: number;
405
+ parentInvocationId?: ConnectionInvocationId;
406
+ }>;
407
+ interface RunCurrentState {
408
+ outputsByNode: Record<NodeId, NodeOutputs>;
409
+ nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
410
+ /** Append-only history of connection-scoped invocations (LLM/tool) for inspector and canvas. */
411
+ connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
412
+ mutableState?: PersistedMutableRunState;
413
+ }
414
+ interface CurrentStateExecutionRequest {
415
+ workflow: WorkflowDefinition;
416
+ items?: Items;
417
+ parent?: ParentExecutionRef;
418
+ executionOptions?: RunExecutionOptions;
419
+ workflowSnapshot?: PersistedWorkflowSnapshot;
420
+ mutableState?: PersistedMutableRunState;
421
+ currentState?: RunCurrentState;
422
+ stopCondition?: RunStopCondition;
423
+ reset?: RunStateResetRequest;
424
+ }
425
+ interface ExecutionFrontierPlan {
426
+ rootNodeId?: NodeId;
427
+ rootNodeInput?: Items;
428
+ queue: RunQueueEntry[];
429
+ currentState: RunCurrentState;
430
+ stopCondition: RunStopCondition;
431
+ satisfiedNodeIds: ReadonlyArray<NodeId>;
432
+ skippedNodeIds: ReadonlyArray<NodeId>;
433
+ clearedNodeIds: ReadonlyArray<NodeId>;
434
+ preservedPinnedNodeIds: ReadonlyArray<NodeId>;
435
+ }
436
+ type RunStatus = "running" | "pending" | "completed" | "failed";
437
+ interface RunSummary {
438
+ runId: RunId;
439
+ workflowId: WorkflowId;
440
+ startedAt: string;
441
+ status: RunStatus;
442
+ /**
443
+ * Test-case status for runs dispatched as part of a TestSuiteRun. Carries the
444
+ * assertion-rollup-corrected outcome the test orchestrator persists onto the row, so the
445
+ * executions list can show "failed" for a run whose workflow completed cleanly but whose
446
+ * assertions caught regressions. Absent for non-test runs and legacy rows.
447
+ */
448
+ testCaseStatus?: TestCaseRunStatus;
449
+ /** ISO timestamp when the run finished (derived from node snapshots or store `updatedAt`); omit while running/pending. */
450
+ finishedAt?: string;
451
+ parent?: ParentExecutionRef;
452
+ executionOptions?: RunExecutionOptions;
453
+ }
454
+ interface PendingNodeExecution {
455
+ runId: RunId;
456
+ activationId: NodeActivationId;
457
+ workflowId: WorkflowId;
458
+ nodeId: NodeId;
459
+ itemsIn: number;
460
+ inputsByPort: NodeInputsByPort;
461
+ receiptId: string;
462
+ queue?: string;
463
+ batchId?: string;
464
+ enqueuedAt: string;
465
+ }
466
+ interface PersistedRunSchedulingState {
467
+ pending?: PendingNodeExecution;
468
+ queue: RunQueueEntry[];
469
+ }
470
+ interface PersistedRunState {
471
+ runId: RunId;
472
+ workflowId: WorkflowId;
473
+ startedAt: string;
474
+ /** Canonical terminal time for listings and retention when persisted on the run root. */
475
+ finishedAt?: string;
476
+ /** Optimistic concurrency / CAS on the run aggregate (repository may increment on save). */
477
+ revision?: number;
478
+ parent?: ParentExecutionRef;
479
+ executionOptions?: RunExecutionOptions;
480
+ control?: PersistedRunControlState;
481
+ workflowSnapshot?: PersistedWorkflowSnapshot;
482
+ mutableState?: PersistedMutableRunState;
483
+ /** Frozen at createRun from workflow + runtime defaults for prune/storage decisions. */
484
+ policySnapshot?: PersistedRunPolicySnapshot;
485
+ /** Successful node completions so far (for activation budget). */
486
+ engineCounters?: EngineRunCounters;
487
+ status: RunStatus;
488
+ pending?: PendingNodeExecution;
489
+ queue: RunQueueEntry[];
490
+ outputsByNode: Record<NodeId, NodeOutputs>;
491
+ nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
492
+ /** Append-only history of connection invocations (LLM/tool) nested under owning nodes. */
493
+ connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
494
+ }
495
+ interface WorkflowExecutionRepository {
496
+ createRun(args: {
497
+ runId: RunId;
498
+ workflowId: WorkflowId;
499
+ startedAt: string;
500
+ parent?: ParentExecutionRef;
501
+ executionOptions?: RunExecutionOptions;
502
+ control?: PersistedRunControlState;
503
+ workflowSnapshot?: PersistedWorkflowSnapshot;
504
+ mutableState?: PersistedMutableRunState;
505
+ policySnapshot?: PersistedRunPolicySnapshot;
506
+ engineCounters?: EngineRunCounters;
507
+ }): Promise<void>;
508
+ load(runId: RunId): Promise<PersistedRunState | undefined>;
509
+ loadSchedulingState(runId: RunId): Promise<PersistedRunSchedulingState | undefined>;
510
+ save(state: PersistedRunState): Promise<void>;
511
+ deleteRun?(runId: RunId): Promise<void>;
512
+ }
513
+ interface WorkflowExecutionListingRepository {
514
+ listRuns(args?: Readonly<{
515
+ workflowId?: WorkflowId;
516
+ limit?: number;
517
+ }>): Promise<ReadonlyArray<RunSummary>>;
518
+ }
519
+ /** Runs eligible for retention-based pruning (completed or failed, older than cutoff). */
520
+ interface RunPruneCandidate {
521
+ readonly runId: RunId;
522
+ readonly workflowId: WorkflowId;
523
+ readonly startedAt: string;
524
+ readonly finishedAt: string;
525
+ }
526
+ interface WorkflowExecutionPruneRepository {
527
+ listRunsOlderThan(args: Readonly<{
528
+ nowIso: string;
529
+ defaultRetentionSeconds: number;
530
+ limit?: number;
531
+ }>): Promise<ReadonlyArray<RunPruneCandidate>>;
532
+ }
533
+ type RunResult = {
534
+ runId: RunId;
535
+ workflowId: WorkflowId;
536
+ startedAt: string;
537
+ status: "completed";
538
+ outputs: Items;
539
+ } | {
540
+ runId: RunId;
541
+ workflowId: WorkflowId;
542
+ startedAt: string;
543
+ status: "pending";
544
+ pending: PendingNodeExecution;
545
+ } | {
546
+ runId: RunId;
547
+ workflowId: WorkflowId;
548
+ startedAt: string;
549
+ status: "failed";
550
+ error: {
551
+ message: string;
552
+ };
553
+ };
554
+ type WebhookRunResult = Readonly<{
555
+ runId: RunId;
556
+ workflowId: WorkflowId;
557
+ startedAt: string;
558
+ runStatus: "pending" | "completed";
559
+ response: Items;
560
+ }>;
561
+ interface PersistedWorkflowTokenRegistryLike {
562
+ register(type: TypeToken<unknown>, packageId: string, persistedNameOverride?: string): string;
563
+ getTokenId(type: TypeToken<unknown>): string | undefined;
564
+ resolve(tokenId: string): TypeToken<unknown> | undefined;
565
+ registerFromWorkflows?(workflows: ReadonlyArray<WorkflowDefinition>): void;
566
+ }
567
+ interface RunCompletionNotifier {
568
+ resolveRunCompletion(result: RunResult): void;
569
+ resolveWebhookResponse(result: WebhookRunResult): void;
570
+ }
571
+ interface RunEventPublisherDeps {
572
+ eventBus?: RunEventBus;
573
+ }
574
+ //#endregion
575
+ //#region src/triggers/polling/PollingTriggerDedupWindow.d.ts
576
+ /**
577
+ * Merges processed-ID windows for polling triggers, capping the total to avoid unbounded growth.
578
+ * Plugin code receives an instance of this class via {@link PollingTriggerHandle.dedup}.
579
+ */
580
+ declare class PollingTriggerDedupWindow {
581
+ static readonly defaultCapN = 2000;
582
+ merge(previous: ReadonlyArray<string>, incoming: ReadonlyArray<string>, capN?: number): ReadonlyArray<string>;
583
+ }
584
+ //#endregion
585
+ //#region src/triggers/polling/PollingTriggerLogger.d.ts
586
+ /**
587
+ * Minimal logger surface for the polling-trigger runtime.
588
+ * Hosts supply this via {@link EngineDeps.pollingTriggerLogger};
589
+ * when absent the runtime is silent.
590
+ */
591
+ interface PollingTriggerLogger {
592
+ info(message: string): void;
593
+ warn(message: string): void;
594
+ error(message: string, exception?: Error): void;
595
+ debug(message: string): void;
596
+ }
597
+ declare class NoOpPollingTriggerLogger implements PollingTriggerLogger {
598
+ info(): void;
599
+ warn(): void;
600
+ error(): void;
601
+ debug(): void;
602
+ }
603
+ //#endregion
604
+ //#region src/contracts/credentialTypes.d.ts
605
+ type CredentialTypeId = string;
606
+ type CredentialInstanceId = string;
607
+ type CredentialMaterialSourceKind = "db" | "env" | "code";
608
+ type CredentialSetupStatus = "draft" | "ready";
609
+ type CredentialHealthStatus = "unknown" | "healthy" | "failing";
610
+ type CredentialFieldSchema = Readonly<{
611
+ key: string;
612
+ label: string;
613
+ type: "string" | "password" | "textarea" | "json" | "boolean";
614
+ required?: true;
615
+ order?: number;
616
+ /**
617
+ * Where this field appears in the credential dialog. Use `"advanced"` for optional or
618
+ * power-user fields; they render inside a collapsible section (see `CredentialTypeDefinition.advancedSection`).
619
+ * Defaults to `"default"` when omitted.
620
+ */
621
+ visibility?: "default" | "advanced";
622
+ placeholder?: string;
623
+ helpText?: string;
624
+ /** When set, host resolves this field from process.env at runtime; env wins over stored values. */
625
+ envVarName?: string;
626
+ /**
627
+ * When set, the dialog shows a copy action for this exact string (e.g. a static OAuth redirect URI
628
+ * pattern or documentation URL). Do not use for secret values.
629
+ */
630
+ copyValue?: string;
631
+ /** Accessible label for the copy control (default: Copy). */
632
+ copyButtonLabel?: string;
633
+ }>;
634
+ type CredentialRequirement = Readonly<{
635
+ slotKey: string;
636
+ label: string;
637
+ acceptedTypes: ReadonlyArray<CredentialTypeId>;
638
+ optional?: true;
639
+ helpText?: string;
640
+ helpUrl?: string;
641
+ }>;
642
+ type CredentialBindingKey = Readonly<{
643
+ workflowId: WorkflowId;
644
+ nodeId: NodeId;
645
+ slotKey: string;
646
+ }>;
647
+ type CredentialBinding = Readonly<{
648
+ key: CredentialBindingKey;
649
+ instanceId: CredentialInstanceId;
650
+ updatedAt: string;
651
+ }>;
652
+ type CredentialHealth = Readonly<{
653
+ status: CredentialHealthStatus;
654
+ message?: string;
655
+ testedAt?: string;
656
+ expiresAt?: string;
657
+ details?: Readonly<Record<string, unknown>>;
658
+ }>;
659
+ type OAuth2ProviderFromPublicConfig = Readonly<{
660
+ authorizeUrlFieldKey: string;
661
+ tokenUrlFieldKey: string;
662
+ userInfoUrlFieldKey?: string;
663
+ }>;
664
+ type CredentialOAuth2ScopesFromPublicConfig = Readonly<{
665
+ presetFieldKey: string;
666
+ presetScopes: Readonly<Record<string, ReadonlyArray<string>>>;
667
+ customPresetKey?: string;
668
+ customScopesFieldKey?: string;
153
669
  }>;
154
- type CredentialHealth = Readonly<{
155
- status: CredentialHealthStatus;
156
- message?: string;
157
- testedAt?: string;
158
- expiresAt?: string;
159
- details?: Readonly<Record<string, unknown>>;
160
- }>;
161
- type OAuth2ProviderFromPublicConfig = Readonly<{
162
- authorizeUrlFieldKey: string;
163
- tokenUrlFieldKey: string;
164
- userInfoUrlFieldKey?: string;
165
- }>;
166
- type CredentialOAuth2ScopesFromPublicConfig = Readonly<{
167
- presetFieldKey: string;
168
- presetScopes: Readonly<Record<string, ReadonlyArray<string>>>;
169
- customPresetKey?: string;
170
- customScopesFieldKey?: string;
171
- }>;
172
670
  type CredentialOAuth2AuthDefinition = Readonly<{
173
671
  kind: "oauth2";
174
672
  providerId: string;
@@ -183,6 +681,27 @@ type CredentialOAuth2AuthDefinition = Readonly<{
183
681
  scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
184
682
  clientIdFieldKey?: string;
185
683
  clientSecretFieldKey?: string;
684
+ } | {
685
+ kind: "oauth2";
686
+ /**
687
+ * Free-form provider identifier for telemetry, DB rows, and Better Auth provider naming.
688
+ * Not used for any registry lookup — URLs come from {@link authorizeUrl} / {@link tokenUrl}.
689
+ */
690
+ providerId: string;
691
+ /**
692
+ * Authorization endpoint. May contain `{publicFieldKey}` placeholders that the runtime
693
+ * substitutes from the credential's resolved public config (URL-encoded).
694
+ * Example: `https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize`
695
+ */
696
+ authorizeUrl: string;
697
+ /** Token endpoint. Same templating rules as {@link authorizeUrl}. */
698
+ tokenUrl: string;
699
+ /** Optional userinfo endpoint. Same templating rules as {@link authorizeUrl}. */
700
+ userInfoUrl?: string;
701
+ scopes: ReadonlyArray<string>;
702
+ scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
703
+ clientIdFieldKey?: string;
704
+ clientSecretFieldKey?: string;
186
705
  }>;
187
706
  type CredentialAuthDefinition = CredentialOAuth2AuthDefinition;
188
707
  type CredentialAdvancedSectionPresentation = Readonly<{
@@ -273,11 +792,76 @@ declare class CredentialUnboundError extends Error {
273
792
  private static createMessage;
274
793
  }
275
794
  //#endregion
276
- //#region src/contracts/CostTrackingTelemetryContract.d.ts
277
- type CostTrackingComponent = "chat" | "ocr" | "rag";
278
- declare const CostTrackingTelemetryMetricNames: {
279
- readonly usage: "codemation.cost.usage";
280
- readonly estimatedCost: "codemation.cost.estimated";
795
+ //#region src/contracts/collectionTypes.d.ts
796
+ /**
797
+ * Represents a typed store for a single collection.
798
+ * All rows include auto-managed id, created_at, and updated_at fields.
799
+ */
800
+ interface CollectionStore<TRow extends Record<string, unknown> = Record<string, unknown>> {
801
+ /**
802
+ * Insert a new row. id, created_at, and updated_at are auto-populated.
803
+ */
804
+ insert(row: TRow): Promise<TRow & {
805
+ id: string;
806
+ created_at: Date;
807
+ updated_at: Date;
808
+ }>;
809
+ /**
810
+ * Get a single row by id.
811
+ */
812
+ get(id: string): Promise<(TRow & {
813
+ id: string;
814
+ created_at: Date;
815
+ updated_at: Date;
816
+ }) | null>;
817
+ /**
818
+ * Find a single row matching the provided filter.
819
+ */
820
+ findOne(filter: Partial<TRow>): Promise<(TRow & {
821
+ id: string;
822
+ created_at: Date;
823
+ updated_at: Date;
824
+ }) | null>;
825
+ /**
826
+ * List rows with optional pagination and filtering.
827
+ */
828
+ list(opts?: {
829
+ limit?: number;
830
+ offset?: number;
831
+ where?: Partial<TRow>;
832
+ }): Promise<{
833
+ rows: ReadonlyArray<TRow & {
834
+ id: string;
835
+ created_at: Date;
836
+ updated_at: Date;
837
+ }>;
838
+ total: number;
839
+ }>;
840
+ /**
841
+ * Update a row by id with partial data.
842
+ */
843
+ update(id: string, patch: Partial<TRow>): Promise<TRow & {
844
+ id: string;
845
+ created_at: Date;
846
+ updated_at: Date;
847
+ }>;
848
+ /**
849
+ * Delete a row by id. Hard delete only (no soft delete).
850
+ */
851
+ delete(id: string): Promise<{
852
+ deleted: boolean;
853
+ }>;
854
+ }
855
+ /**
856
+ * Runtime collections context: keyed by collection name.
857
+ */
858
+ type CollectionsContext = Readonly<Record<string, CollectionStore>>;
859
+ //#endregion
860
+ //#region src/contracts/CostTrackingTelemetryContract.d.ts
861
+ type CostTrackingComponent = "chat" | "ocr" | "rag";
862
+ declare const CostTrackingTelemetryMetricNames: {
863
+ readonly usage: "codemation.cost.usage";
864
+ readonly estimatedCost: "codemation.cost.estimated";
281
865
  };
282
866
  declare const CostTrackingTelemetryAttributeNames: {
283
867
  readonly component: "cost.component";
@@ -319,439 +903,161 @@ interface CostTrackingTelemetryFactory {
319
903
  declare class NoOpTelemetryArtifactReference {
320
904
  static readonly value: TelemetryArtifactReference;
321
905
  }
322
- //#endregion
323
- //#region src/contracts/NoOpTelemetrySpanScope.d.ts
324
- declare class NoOpTelemetrySpanScope {
325
- static readonly value: TelemetrySpanScope;
326
- }
327
- //#endregion
328
- //#region src/contracts/NoOpNodeExecutionTelemetry.d.ts
329
- declare class NoOpNodeExecutionTelemetry {
330
- static readonly value: NodeExecutionTelemetry;
331
- }
332
- //#endregion
333
- //#region src/contracts/NoOpExecutionTelemetry.d.ts
334
- declare class NoOpExecutionTelemetry {
335
- static readonly value: ExecutionTelemetry;
336
- }
337
- //#endregion
338
- //#region src/contracts/NoOpExecutionTelemetryFactory.d.ts
339
- declare class NoOpExecutionTelemetryFactory implements ExecutionTelemetryFactory {
340
- create(_: Readonly<{
341
- runId: RunId;
342
- workflowId: WorkflowId;
343
- parent?: ParentExecutionRef;
344
- policySnapshot?: PersistedRunPolicySnapshot;
345
- }>): ExecutionTelemetry;
346
- }
347
- //#endregion
348
- //#region src/contracts/CodemationTelemetryAttributeNames.d.ts
349
- declare class CodemationTelemetryAttributeNames {
350
- static readonly workflowId = "codemation.workflow.id";
351
- static readonly runId = "codemation.run.id";
352
- static readonly nodeId = "codemation.node.id";
353
- static readonly activationId = "codemation.activation.id";
354
- static readonly nodeType = "codemation.node.type";
355
- static readonly nodeRole = "codemation.node.role";
356
- static readonly workflowFolder = "codemation.workflow.folder";
357
- static readonly connectionInvocationId = "codemation.connection.invocation_id";
358
- static readonly toolName = "codemation.tool.name";
359
- static readonly traceParentRunId = "codemation.parent.run.id";
360
- }
361
- //#endregion
362
- //#region src/contracts/GenAiTelemetryAttributeNames.d.ts
363
- declare class GenAiTelemetryAttributeNames {
364
- static readonly operationName = "gen_ai.operation.name";
365
- static readonly requestModel = "gen_ai.request.model";
366
- static readonly usageInputTokens = "gen_ai.usage.input_tokens";
367
- static readonly usageOutputTokens = "gen_ai.usage.output_tokens";
368
- static readonly usageTotalTokens = "gen_ai.usage.total_tokens";
369
- static readonly usageCacheReadInputTokens = "gen_ai.usage.cache_read.input_tokens";
370
- static readonly usageCacheCreationInputTokens = "gen_ai.usage.cache_creation.input_tokens";
371
- static readonly usageReasoningTokens = "codemation.gen_ai.usage.reasoning_tokens";
372
- }
373
- //#endregion
374
- //#region src/contracts/CodemationTelemetryMetricNames.d.ts
375
- declare class CodemationTelemetryMetricNames {
376
- static readonly agentTurns = "codemation.ai.turns";
377
- static readonly agentToolCalls = "codemation.ai.tool_calls";
378
- static readonly gmailMessagesEmitted = "codemation.gmail.messages_emitted";
379
- static readonly gmailAttachments = "codemation.gmail.attachments";
380
- static readonly gmailAttachmentBytes = "codemation.gmail.attachment_bytes";
381
- }
382
- //#endregion
383
- //#region src/contracts/telemetryTypes.d.ts
384
- type TelemetryAttributePrimitive = string | number | boolean | null;
385
- interface TelemetryAttributes {
386
- readonly [key: string]: TelemetryAttributePrimitive | undefined;
387
- }
388
- interface TelemetryMetricRecord {
389
- readonly name: string;
390
- readonly value: number;
391
- readonly unit?: string;
392
- readonly attributes?: TelemetryAttributes;
393
- }
394
- interface TelemetrySpanEventRecord {
395
- readonly name: string;
396
- readonly occurredAt?: Date;
397
- readonly attributes?: TelemetryAttributes;
398
- }
399
- interface TelemetryArtifactAttachment {
400
- readonly kind: string;
401
- readonly contentType: string;
402
- readonly previewText?: string;
403
- readonly previewJson?: JsonValue;
404
- readonly payloadText?: string;
405
- readonly payloadJson?: JsonValue;
406
- readonly bytes?: number;
407
- readonly truncated?: boolean;
408
- readonly expiresAt?: Date;
409
- }
410
- interface TelemetryArtifactReference {
411
- readonly artifactId: string;
412
- readonly traceId?: string;
413
- readonly spanId?: string;
414
- }
415
- interface TelemetrySpanEnd {
416
- readonly status?: "ok" | "error";
417
- readonly statusMessage?: string;
418
- readonly endedAt?: Date;
419
- readonly attributes?: TelemetryAttributes;
420
- }
421
- interface TelemetryChildSpanStart {
422
- readonly name: string;
423
- readonly kind?: "internal" | "client";
424
- readonly startedAt?: Date;
425
- readonly attributes?: TelemetryAttributes;
426
- }
427
- interface TelemetryScope {
428
- readonly traceId?: string;
429
- readonly spanId?: string;
430
- readonly costTracking?: CostTrackingTelemetry;
431
- addSpanEvent(args: TelemetrySpanEventRecord): Promise<void> | void;
432
- recordMetric(args: TelemetryMetricRecord): Promise<void> | void;
433
- attachArtifact(args: TelemetryArtifactAttachment): Promise<TelemetryArtifactReference> | TelemetryArtifactReference;
434
- }
435
- interface TelemetrySpanScope extends TelemetryScope {
436
- readonly traceId: string;
437
- readonly spanId: string;
438
- end(args?: TelemetrySpanEnd): Promise<void> | void;
439
- }
440
- interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
441
- startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
442
- }
443
- interface ExecutionTelemetry extends TelemetryScope {
444
- readonly traceId: string;
445
- readonly spanId: string;
446
- forNode(args: Readonly<{
447
- nodeId: NodeId;
448
- activationId: NodeActivationId;
449
- }>): NodeExecutionTelemetry;
450
- }
451
- interface ExecutionTelemetryFactory {
452
- create(args: Readonly<{
453
- runId: RunId;
454
- workflowId: WorkflowId;
455
- parent?: ParentExecutionRef;
456
- policySnapshot?: PersistedRunPolicySnapshot;
457
- }>): ExecutionTelemetry;
458
- }
459
- //#endregion
460
- //#region src/contracts/runTypes.d.ts
461
- interface RunExecutionOptions {
462
- /** Run-intent override: force the inline scheduler and bypass node-level offload decisions. */
463
- localOnly?: boolean;
464
- /** Marks runs started from webhook handling so orchestration can apply webhook-specific continuation rules. */
465
- webhook?: boolean;
466
- mode?: "manual" | "debug";
467
- sourceWorkflowId?: WorkflowId;
468
- sourceRunId?: RunId;
469
- derivedFromRunId?: RunId;
470
- isMutable?: boolean;
471
- /** Set by the engine for this run: 0 = root, 1 = first child subworkflow, … */
472
- subworkflowDepth?: number;
473
- /** Effective cap after engine policy merge (successful node completions per run). */
474
- maxNodeActivations?: number;
475
- /** Effective cap after engine policy merge (subworkflow nesting). */
476
- maxSubworkflowDepth?: number;
477
- }
478
- /** Engine-owned counters persisted with the run (worker-safe). */
479
- interface EngineRunCounters {
480
- completedNodeActivations: number;
481
- }
482
- type RunStopCondition = Readonly<{
483
- kind: "workflowCompleted";
484
- }> | Readonly<{
485
- kind: "nodeCompleted";
486
- nodeId: NodeId;
487
- }>;
488
- interface RunStateResetRequest {
489
- clearFromNodeId: NodeId;
490
- }
491
- interface PersistedRunControlState {
492
- stopCondition?: RunStopCondition;
493
- }
494
- interface PersistedWorkflowSnapshotNode {
495
- id: NodeId;
496
- kind: NodeKind;
497
- name?: string;
498
- nodeTokenId: PersistedTokenId;
499
- configTokenId: PersistedTokenId;
500
- tokenName?: string;
501
- configTokenName?: string;
502
- config: unknown;
503
- }
504
- interface PersistedWorkflowSnapshot {
505
- id: WorkflowId;
506
- name: string;
507
- nodes: ReadonlyArray<PersistedWorkflowSnapshotNode>;
508
- edges: ReadonlyArray<Edge>;
509
- /** When the snapshot was built from a live workflow definition that configured a workflow error handler. */
510
- workflowErrorHandlerConfigured?: boolean;
511
- /** Connection metadata for child nodes not in the execution graph (e.g. AI agent attachments). */
512
- connections?: ReadonlyArray<WorkflowNodeConnection>;
513
- }
514
- type PinnedNodeOutputsByPort = Readonly<Record<OutputPortKey, Items>>;
515
- interface PersistedMutableNodeState {
516
- pinnedOutputsByPort?: PinnedNodeOutputsByPort;
517
- lastDebugInput?: Items;
518
- }
519
- interface PersistedMutableRunState {
520
- nodesById: Readonly<Record<NodeId, PersistedMutableNodeState>>;
521
- }
522
- type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
523
- interface RunQueueEntry {
524
- nodeId: NodeId;
525
- input: Items;
526
- toInput?: InputPortKey;
527
- batchId?: string;
528
- from?: Readonly<{
529
- nodeId: NodeId;
530
- output: OutputPortKey;
531
- }>;
532
- collect?: Readonly<{
533
- expectedInputs: ReadonlyArray<InputPortKey>;
534
- received: Readonly<Record<InputPortKey, Items>>;
535
- }>;
536
- }
537
- type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
538
- interface NodeExecutionError {
539
- message: string;
540
- name?: string;
541
- stack?: string;
542
- details?: JsonValue;
543
- }
544
- interface NodeExecutionSnapshot {
545
- runId: RunId;
546
- workflowId: WorkflowId;
547
- nodeId: NodeId;
548
- activationId?: NodeActivationId;
549
- parent?: ParentExecutionRef;
550
- status: NodeExecutionStatus;
551
- usedPinnedOutput?: boolean;
552
- queuedAt?: string;
553
- startedAt?: string;
554
- finishedAt?: string;
555
- updatedAt: string;
556
- inputsByPort?: NodeInputsByPort;
557
- outputs?: NodeOutputs;
558
- error?: NodeExecutionError;
559
- }
560
- /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
561
- type ConnectionInvocationId = string;
562
- /**
563
- * One logical LLM or tool call under an owning workflow node (e.g. AI agent).
564
- * The owning node defines what {@link managedInput} and {@link managedOutput} contain.
565
- */
566
- interface ConnectionInvocationRecord {
567
- readonly invocationId: ConnectionInvocationId;
568
- readonly runId: RunId;
569
- readonly workflowId: WorkflowId;
570
- readonly connectionNodeId: NodeId;
571
- readonly parentAgentNodeId: NodeId;
572
- readonly parentAgentActivationId: NodeActivationId;
573
- readonly status: NodeExecutionStatus;
574
- readonly managedInput?: JsonValue;
575
- readonly managedOutput?: JsonValue;
576
- readonly error?: NodeExecutionError;
577
- readonly queuedAt?: string;
578
- readonly startedAt?: string;
579
- readonly finishedAt?: string;
580
- readonly updatedAt: string;
581
- }
582
- /** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
583
- type ConnectionInvocationAppendArgs = Readonly<{
584
- invocationId: ConnectionInvocationId;
585
- connectionNodeId: NodeId;
586
- parentAgentNodeId: NodeId;
587
- parentAgentActivationId: NodeActivationId;
588
- status: NodeExecutionStatus;
589
- managedInput?: JsonValue;
590
- managedOutput?: JsonValue;
591
- error?: NodeExecutionError;
592
- queuedAt?: string;
593
- startedAt?: string;
594
- finishedAt?: string;
595
- }>;
596
- interface RunCurrentState {
597
- outputsByNode: Record<NodeId, NodeOutputs>;
598
- nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
599
- /** Append-only history of connection-scoped invocations (LLM/tool) for inspector and canvas. */
600
- connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
601
- mutableState?: PersistedMutableRunState;
602
- }
603
- interface CurrentStateExecutionRequest {
604
- workflow: WorkflowDefinition;
605
- items?: Items;
606
- parent?: ParentExecutionRef;
607
- executionOptions?: RunExecutionOptions;
608
- workflowSnapshot?: PersistedWorkflowSnapshot;
609
- mutableState?: PersistedMutableRunState;
610
- currentState?: RunCurrentState;
611
- stopCondition?: RunStopCondition;
612
- reset?: RunStateResetRequest;
613
- }
614
- interface ExecutionFrontierPlan {
615
- rootNodeId?: NodeId;
616
- rootNodeInput?: Items;
617
- queue: RunQueueEntry[];
618
- currentState: RunCurrentState;
619
- stopCondition: RunStopCondition;
620
- satisfiedNodeIds: ReadonlyArray<NodeId>;
621
- skippedNodeIds: ReadonlyArray<NodeId>;
622
- clearedNodeIds: ReadonlyArray<NodeId>;
623
- preservedPinnedNodeIds: ReadonlyArray<NodeId>;
624
- }
625
- type RunStatus = "running" | "pending" | "completed" | "failed";
626
- interface RunSummary {
627
- runId: RunId;
628
- workflowId: WorkflowId;
629
- startedAt: string;
630
- status: RunStatus;
631
- /** ISO timestamp when the run finished (derived from node snapshots or store `updatedAt`); omit while running/pending. */
632
- finishedAt?: string;
633
- parent?: ParentExecutionRef;
634
- executionOptions?: RunExecutionOptions;
635
- }
636
- interface PendingNodeExecution {
637
- runId: RunId;
638
- activationId: NodeActivationId;
639
- workflowId: WorkflowId;
640
- nodeId: NodeId;
641
- itemsIn: number;
642
- inputsByPort: NodeInputsByPort;
643
- receiptId: string;
644
- queue?: string;
645
- batchId?: string;
646
- enqueuedAt: string;
906
+ //#endregion
907
+ //#region src/contracts/NoOpTelemetrySpanScope.d.ts
908
+ declare class NoOpTelemetrySpanScope {
909
+ static readonly value: TelemetrySpanScope;
910
+ /** Internal: the shared no-op {@link NodeExecutionTelemetry} that {@link NoOpNodeExecutionTelemetry} re-exposes. */
911
+ static readonly nodeExecutionTelemetryValue: NodeExecutionTelemetry;
647
912
  }
648
- interface PersistedRunSchedulingState {
649
- pending?: PendingNodeExecution;
650
- queue: RunQueueEntry[];
913
+ //#endregion
914
+ //#region src/contracts/NoOpNodeExecutionTelemetry.d.ts
915
+ declare class NoOpNodeExecutionTelemetry {
916
+ static readonly value: NodeExecutionTelemetry;
651
917
  }
652
- interface PersistedRunState {
653
- runId: RunId;
654
- workflowId: WorkflowId;
655
- startedAt: string;
656
- /** Canonical terminal time for listings and retention when persisted on the run root. */
657
- finishedAt?: string;
658
- /** Optimistic concurrency / CAS on the run aggregate (repository may increment on save). */
659
- revision?: number;
660
- parent?: ParentExecutionRef;
661
- executionOptions?: RunExecutionOptions;
662
- control?: PersistedRunControlState;
663
- workflowSnapshot?: PersistedWorkflowSnapshot;
664
- mutableState?: PersistedMutableRunState;
665
- /** Frozen at createRun from workflow + runtime defaults for prune/storage decisions. */
666
- policySnapshot?: PersistedRunPolicySnapshot;
667
- /** Successful node completions so far (for activation budget). */
668
- engineCounters?: EngineRunCounters;
669
- status: RunStatus;
670
- pending?: PendingNodeExecution;
671
- queue: RunQueueEntry[];
672
- outputsByNode: Record<NodeId, NodeOutputs>;
673
- nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
674
- /** Append-only history of connection invocations (LLM/tool) nested under owning nodes. */
675
- connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
918
+ //#endregion
919
+ //#region src/contracts/NoOpExecutionTelemetry.d.ts
920
+ declare class NoOpExecutionTelemetry {
921
+ static readonly value: ExecutionTelemetry;
676
922
  }
677
- interface WorkflowExecutionRepository {
678
- createRun(args: {
923
+ //#endregion
924
+ //#region src/contracts/NoOpExecutionTelemetryFactory.d.ts
925
+ declare class NoOpExecutionTelemetryFactory implements ExecutionTelemetryFactory {
926
+ create(_: Readonly<{
679
927
  runId: RunId;
680
928
  workflowId: WorkflowId;
681
- startedAt: string;
682
929
  parent?: ParentExecutionRef;
683
- executionOptions?: RunExecutionOptions;
684
- control?: PersistedRunControlState;
685
- workflowSnapshot?: PersistedWorkflowSnapshot;
686
- mutableState?: PersistedMutableRunState;
687
930
  policySnapshot?: PersistedRunPolicySnapshot;
688
- engineCounters?: EngineRunCounters;
689
- }): Promise<void>;
690
- load(runId: RunId): Promise<PersistedRunState | undefined>;
691
- loadSchedulingState(runId: RunId): Promise<PersistedRunSchedulingState | undefined>;
692
- save(state: PersistedRunState): Promise<void>;
693
- deleteRun?(runId: RunId): Promise<void>;
931
+ }>): ExecutionTelemetry;
694
932
  }
695
- interface WorkflowExecutionListingRepository {
696
- listRuns(args?: Readonly<{
697
- workflowId?: WorkflowId;
698
- limit?: number;
699
- }>): Promise<ReadonlyArray<RunSummary>>;
933
+ //#endregion
934
+ //#region src/contracts/CodemationTelemetryAttributeNames.d.ts
935
+ declare class CodemationTelemetryAttributeNames {
936
+ static readonly workflowId = "codemation.workflow.id";
937
+ static readonly runId = "codemation.run.id";
938
+ static readonly nodeId = "codemation.node.id";
939
+ static readonly activationId = "codemation.activation.id";
940
+ static readonly nodeType = "codemation.node.type";
941
+ static readonly nodeRole = "codemation.node.role";
942
+ static readonly workflowFolder = "codemation.workflow.folder";
943
+ static readonly connectionInvocationId = "codemation.connection.invocation_id";
944
+ static readonly toolName = "codemation.tool.name";
945
+ static readonly traceParentRunId = "codemation.parent.run.id";
946
+ /** Per-item iteration that emitted this span/metric. Set on spans recorded inside a runnable per-item loop. */
947
+ static readonly iterationId = "codemation.iteration.id";
948
+ /** Item index (0-based) of the iteration. */
949
+ static readonly iterationIndex = "codemation.iteration.index";
950
+ /** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
951
+ static readonly parentInvocationId = "codemation.parent.invocation_id";
700
952
  }
701
- /** Runs eligible for retention-based pruning (completed or failed, older than cutoff). */
702
- interface RunPruneCandidate {
703
- readonly runId: RunId;
704
- readonly workflowId: WorkflowId;
705
- readonly startedAt: string;
706
- readonly finishedAt: string;
953
+ //#endregion
954
+ //#region src/contracts/GenAiTelemetryAttributeNames.d.ts
955
+ declare class GenAiTelemetryAttributeNames {
956
+ static readonly operationName = "gen_ai.operation.name";
957
+ static readonly requestModel = "gen_ai.request.model";
958
+ static readonly usageInputTokens = "gen_ai.usage.input_tokens";
959
+ static readonly usageOutputTokens = "gen_ai.usage.output_tokens";
960
+ static readonly usageTotalTokens = "gen_ai.usage.total_tokens";
961
+ static readonly usageCacheReadInputTokens = "gen_ai.usage.cache_read.input_tokens";
962
+ static readonly usageCacheCreationInputTokens = "gen_ai.usage.cache_creation.input_tokens";
963
+ static readonly usageReasoningTokens = "codemation.gen_ai.usage.reasoning_tokens";
707
964
  }
708
- interface WorkflowExecutionPruneRepository {
709
- listRunsOlderThan(args: Readonly<{
710
- nowIso: string;
711
- defaultRetentionSeconds: number;
712
- limit?: number;
713
- }>): Promise<ReadonlyArray<RunPruneCandidate>>;
965
+ //#endregion
966
+ //#region src/contracts/CodemationTelemetryMetricNames.d.ts
967
+ declare class CodemationTelemetryMetricNames {
968
+ static readonly agentTurns = "codemation.ai.turns";
969
+ static readonly agentToolCalls = "codemation.ai.tool_calls";
970
+ static readonly gmailMessagesEmitted = "codemation.gmail.messages_emitted";
971
+ static readonly gmailAttachments = "codemation.gmail.attachments";
972
+ static readonly gmailAttachmentBytes = "codemation.gmail.attachment_bytes";
714
973
  }
715
- type RunResult = {
716
- runId: RunId;
717
- workflowId: WorkflowId;
718
- startedAt: string;
719
- status: "completed";
720
- outputs: Items;
721
- } | {
722
- runId: RunId;
723
- workflowId: WorkflowId;
724
- startedAt: string;
725
- status: "pending";
726
- pending: PendingNodeExecution;
727
- } | {
728
- runId: RunId;
729
- workflowId: WorkflowId;
730
- startedAt: string;
731
- status: "failed";
732
- error: {
733
- message: string;
734
- };
735
- };
736
- type WebhookRunResult = Readonly<{
737
- runId: RunId;
738
- workflowId: WorkflowId;
739
- startedAt: string;
740
- runStatus: "pending" | "completed";
741
- response: Items;
742
- }>;
743
- interface PersistedWorkflowTokenRegistryLike {
744
- register(type: TypeToken<unknown>, packageId: string, persistedNameOverride?: string): string;
745
- getTokenId(type: TypeToken<unknown>): string | undefined;
746
- resolve(tokenId: string): TypeToken<unknown> | undefined;
747
- registerFromWorkflows?(workflows: ReadonlyArray<WorkflowDefinition>): void;
974
+ //#endregion
975
+ //#region src/contracts/telemetryTypes.d.ts
976
+ type TelemetryAttributePrimitive = string | number | boolean | null;
977
+ interface TelemetryAttributes {
978
+ readonly [key: string]: TelemetryAttributePrimitive | undefined;
748
979
  }
749
- interface RunCompletionNotifier {
750
- resolveRunCompletion(result: RunResult): void;
751
- resolveWebhookResponse(result: WebhookRunResult): void;
980
+ interface TelemetryMetricRecord {
981
+ readonly name: string;
982
+ readonly value: number;
983
+ readonly unit?: string;
984
+ readonly attributes?: TelemetryAttributes;
752
985
  }
753
- interface RunEventPublisherDeps {
754
- eventBus?: RunEventBus;
986
+ interface TelemetrySpanEventRecord {
987
+ readonly name: string;
988
+ readonly occurredAt?: Date;
989
+ readonly attributes?: TelemetryAttributes;
990
+ }
991
+ interface TelemetryArtifactAttachment {
992
+ readonly kind: string;
993
+ readonly contentType: string;
994
+ readonly previewText?: string;
995
+ readonly previewJson?: JsonValue;
996
+ readonly payloadText?: string;
997
+ readonly payloadJson?: JsonValue;
998
+ readonly bytes?: number;
999
+ readonly truncated?: boolean;
1000
+ readonly expiresAt?: Date;
1001
+ }
1002
+ interface TelemetryArtifactReference {
1003
+ readonly artifactId: string;
1004
+ readonly traceId?: string;
1005
+ readonly spanId?: string;
1006
+ }
1007
+ interface TelemetrySpanEnd {
1008
+ readonly status?: "ok" | "error";
1009
+ readonly statusMessage?: string;
1010
+ readonly endedAt?: Date;
1011
+ readonly attributes?: TelemetryAttributes;
1012
+ }
1013
+ interface TelemetryChildSpanStart {
1014
+ readonly name: string;
1015
+ readonly kind?: "internal" | "client";
1016
+ readonly startedAt?: Date;
1017
+ readonly attributes?: TelemetryAttributes;
1018
+ }
1019
+ interface TelemetryScope {
1020
+ readonly traceId?: string;
1021
+ readonly spanId?: string;
1022
+ readonly costTracking?: CostTrackingTelemetry;
1023
+ addSpanEvent(args: TelemetrySpanEventRecord): Promise<void> | void;
1024
+ recordMetric(args: TelemetryMetricRecord): Promise<void> | void;
1025
+ attachArtifact(args: TelemetryArtifactAttachment): Promise<TelemetryArtifactReference> | TelemetryArtifactReference;
1026
+ }
1027
+ interface TelemetrySpanScope extends TelemetryScope {
1028
+ readonly traceId: string;
1029
+ readonly spanId: string;
1030
+ end(args?: TelemetrySpanEnd): Promise<void> | void;
1031
+ /**
1032
+ * Lift this span into a {@link NodeExecutionTelemetry} scoped to a different (nodeId, activationId).
1033
+ * Children created via the returned telemetry's `startChildSpan` get this span as their parent.
1034
+ *
1035
+ * Used at the sub-agent boundary so that nested runtime telemetry parents under the agent.tool.call
1036
+ * span instead of the orchestrator's node-level span.
1037
+ */
1038
+ asNodeTelemetry(args: Readonly<{
1039
+ nodeId: NodeId;
1040
+ activationId: NodeActivationId;
1041
+ }>): NodeExecutionTelemetry;
1042
+ }
1043
+ interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
1044
+ startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
1045
+ }
1046
+ interface ExecutionTelemetry extends TelemetryScope {
1047
+ readonly traceId: string;
1048
+ readonly spanId: string;
1049
+ forNode(args: Readonly<{
1050
+ nodeId: NodeId;
1051
+ activationId: NodeActivationId;
1052
+ }>): NodeExecutionTelemetry;
1053
+ }
1054
+ interface ExecutionTelemetryFactory {
1055
+ create(args: Readonly<{
1056
+ runId: RunId;
1057
+ workflowId: WorkflowId;
1058
+ parent?: ParentExecutionRef;
1059
+ policySnapshot?: PersistedRunPolicySnapshot;
1060
+ }>): ExecutionTelemetry;
755
1061
  }
756
1062
  //#endregion
757
1063
  //#region src/contracts/workflowActivationPolicy.d.ts
@@ -924,6 +1230,21 @@ interface ExecutionContext {
924
1230
  telemetry: ExecutionTelemetry;
925
1231
  binary: ExecutionBinaryService;
926
1232
  getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
1233
+ /** Per-item iteration id, set by {@link NodeExecutor} on the ctx passed into runnable `execute`. */
1234
+ iterationId?: NodeIterationId;
1235
+ /** Item index (0-based) within the current activation's batch; set alongside {@link iterationId}. */
1236
+ itemIndex?: number;
1237
+ /** When set, this ctx is executing inside a sub-agent triggered by the named parent invocation. */
1238
+ parentInvocationId?: ConnectionInvocationId;
1239
+ /**
1240
+ * Present iff the run was started by a TestSuiteOrchestrator. The {@link IsTestRunNode}
1241
+ * branches on this; assertion-emitting nodes use it to decide whether to record results.
1242
+ */
1243
+ testContext?: RunTestContext;
1244
+ /**
1245
+ * Collections registered in the codemation config, keyed by collection name.
1246
+ */
1247
+ readonly collections?: CollectionsContext;
927
1248
  }
928
1249
  interface ExecutionContextFactory {
929
1250
  create(args: {
@@ -938,6 +1259,7 @@ interface ExecutionContextFactory {
938
1259
  nodeState?: NodeExecutionStatePublisher;
939
1260
  telemetry?: ExecutionTelemetry;
940
1261
  getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
1262
+ testContext?: RunTestContext;
941
1263
  }): ExecutionContext;
942
1264
  }
943
1265
  interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase> extends ExecutionContext {
@@ -947,12 +1269,34 @@ interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase>
947
1269
  telemetry: NodeExecutionTelemetry;
948
1270
  binary: NodeBinaryAttachmentService;
949
1271
  }
1272
+ interface PollingTriggerHandle {
1273
+ /**
1274
+ * Start the polling loop. The runtime registers its own cleanup handle so callers do not need to
1275
+ * call {@link TriggerSetupContext.registerCleanup} for the loop.
1276
+ * @returns The state returned by the first cycle (or `undefined` when the overlap guard fired).
1277
+ */
1278
+ start<TState, TItem>(args: {
1279
+ intervalMs: number;
1280
+ seedState?: TState;
1281
+ runCycle: (cycleCtx: {
1282
+ previousState: TState | undefined;
1283
+ signal: AbortSignal;
1284
+ }) => Promise<{
1285
+ items: Items<TItem>;
1286
+ nextState: TState;
1287
+ }>;
1288
+ }): Promise<TState | undefined>;
1289
+ /** Convenience dedup-window helper. */
1290
+ readonly dedup: PollingTriggerDedupWindow;
1291
+ }
950
1292
  interface TriggerSetupContext<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>, TSetupState$1 extends JsonValue | undefined = TriggerNodeSetupState<TConfig>> extends ExecutionContext {
951
1293
  trigger: TriggerInstanceId;
952
1294
  config: TConfig;
953
1295
  previousState: TSetupState$1;
954
1296
  registerCleanup(cleanup: TriggerCleanupHandle): void;
955
1297
  emit(items: Items): Promise<void>;
1298
+ /** Generic polling-trigger surface. Pre-binds trigger id, emit, and registerCleanup. */
1299
+ readonly polling: PollingTriggerHandle;
956
1300
  }
957
1301
  interface TriggerTestItemsContext<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>, TSetupState$1 extends JsonValue | undefined = TriggerNodeSetupState<TConfig>> extends ExecutionContext {
958
1302
  trigger: TriggerInstanceId;
@@ -1147,6 +1491,8 @@ interface EngineDeps {
1147
1491
  workflowPolicyRuntimeDefaults?: WorkflowPolicyRuntimeDefaults;
1148
1492
  /** When set, logs inactive-workflow skips at boot and trigger start/stop on activation changes. */
1149
1493
  triggerRuntimeDiagnostics?: TriggerRuntimeDiagnostics;
1494
+ /** When set, the polling-trigger runtime uses this logger for cycle info/debug/error. */
1495
+ pollingTriggerLogger?: PollingTriggerLogger;
1150
1496
  }
1151
1497
  //#endregion
1152
1498
  //#region src/contracts/retryPolicySpec.types.d.ts
@@ -1178,14 +1524,9 @@ interface ExponentialRetryPolicySpec {
1178
1524
  }
1179
1525
  //#endregion
1180
1526
  //#region src/contracts/workflowTypes.d.ts
1181
- type WorkflowId = string;
1182
- type NodeId = string;
1183
1527
  type NodeIdRef<TJson = unknown> = NodeId & Readonly<{
1184
1528
  __codemationNodeJson?: TJson;
1185
1529
  }>;
1186
- type OutputPortKey = string;
1187
- type InputPortKey = string;
1188
- type PersistedTokenId = string;
1189
1530
  type NodeKind = "trigger" | "node";
1190
1531
  type JsonPrimitive = string | number | boolean | null;
1191
1532
  interface JsonObject {
@@ -1205,7 +1546,6 @@ interface Edge {
1205
1546
  input: InputPortKey;
1206
1547
  };
1207
1548
  }
1208
- type NodeConnectionName = string;
1209
1549
  /**
1210
1550
  * Named connection from a parent node to child nodes that exist in {@link WorkflowDefinition.nodes}
1211
1551
  * but are not traversed by the main execution graph. Parents are commonly executable nodes, but may
@@ -1271,6 +1611,14 @@ interface NodeConfigBase {
1271
1611
  readonly declaredOutputPorts?: ReadonlyArray<OutputPortKey>;
1272
1612
  readonly declaredInputPorts?: ReadonlyArray<InputPortKey>;
1273
1613
  getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;
1614
+ /**
1615
+ * Marker: this node emits {@link import("./assertionTypes").AssertionResult}-shaped items on its
1616
+ * `main` port. The TestSuiteOrchestrator (and host-side TestAssertionPersister) listen for
1617
+ * `nodeCompleted` events from nodes with this flag set, and persist their output items as
1618
+ * TestAssertion records (only when the run carries a `testContext`). Set on assertion node
1619
+ * configs (e.g. `AssertionNodeConfig`, `StringEqualsAssertionNodeConfig`).
1620
+ */
1621
+ readonly emitsAssertions?: true;
1274
1622
  }
1275
1623
  declare const runnableNodeInputType: unique symbol;
1276
1624
  declare const runnableNodeOutputType: unique symbol;
@@ -1300,6 +1648,12 @@ interface TriggerNodeConfig<TOutputJson$1 = unknown, TSetupState$1 extends JsonV
1300
1648
  readonly kind: "trigger";
1301
1649
  readonly [triggerNodeOutputType]?: TOutputJson$1;
1302
1650
  readonly [triggerNodeSetupStateType]?: TSetupState$1;
1651
+ /**
1652
+ * Distinguishes triggers driven by the live activation policy (webhooks, cron, polling) from
1653
+ * triggers driven only by the {@link TestSuiteOrchestrator}. `WorkflowActivation` skips
1654
+ * `"test"` triggers; the orchestrator skips `"live"` triggers. Defaults to `"live"` when omitted.
1655
+ */
1656
+ readonly triggerKind?: "live" | "test";
1303
1657
  }
1304
1658
  type RunnableNodeInputJson<TConfig extends RunnableNodeConfig<any, any>> = TConfig extends RunnableNodeConfig<infer TInputJson, any> ? TInputJson : never;
1305
1659
  type RunnableNodeOutputJson<TConfig extends RunnableNodeConfig<any, any>> = TConfig extends RunnableNodeConfig<any, infer TOutputJson> ? TOutputJson : never;
@@ -1350,6 +1704,12 @@ type Items<TJson = unknown> = ReadonlyArray<Item<TJson>>;
1350
1704
  type NodeOutputs = Partial<Record<OutputPortKey, Items>>;
1351
1705
  type RunId = string;
1352
1706
  type NodeActivationId = string;
1707
+ /**
1708
+ * One per-item iteration of a runnable node's execute loop. Refines `NodeActivationId` for
1709
+ * per-item connection invocations and telemetry. Undefined when the executing node is a batch
1710
+ * node or trigger that does not iterate items.
1711
+ */
1712
+ type NodeIterationId = string;
1353
1713
  interface ParentExecutionRef {
1354
1714
  runId: RunId;
1355
1715
  workflowId: WorkflowId;
@@ -1360,6 +1720,12 @@ interface ParentExecutionRef {
1360
1720
  engineMaxNodeActivations?: number;
1361
1721
  /** Effective max subworkflow depth from the parent run (propagated to child policy merge). */
1362
1722
  engineMaxSubworkflowDepth?: number;
1723
+ /**
1724
+ * Test-suite linkage inherited by the child subworkflow run. Set by whichever node
1725
+ * spawns the subworkflow when its own `ctx.testContext` is present, so assertions
1726
+ * emitted inside a subworkflow land under the correct parent test case.
1727
+ */
1728
+ testContext?: RunTestContext;
1363
1729
  }
1364
1730
  interface RunDataSnapshot {
1365
1731
  getOutputs(nodeId: NodeId): NodeOutputs | undefined;
@@ -1658,5 +2024,5 @@ declare class RunIntentService {
1658
2024
  private createWebhookExecutionOptions;
1659
2025
  }
1660
2026
  //#endregion
1661
- export { WorkflowGraph as $, WorkflowExecutionListingRepository as $n, CredentialTypeRegistry as $r, TriggerCleanupHandle as $t, NodeOutputs as A, NodeInputsByPort as An, AnyCredentialType as Ar, ExecutionContext as At, RunId as B, PinnedNodeOutputsByPort as Bn, CredentialInstanceRecord as Br, NodeBinaryAttachmentService as Bt, NodeErrorHandler as C, RunEvent as Ci, ConnectionInvocationRecord as Cn, CostTrackingComponent as Cr, BinaryStorageStatResult as Ct, NodeIdRef as D, NodeExecutionError as Dn, CostTrackingTelemetryFactory as Dr, EngineHost as Dt, NodeId as E, ExecutionFrontierPlan as En, CostTrackingTelemetryAttributeNames as Er, EngineDeps as Et, ParentExecutionRef as F, PersistedRunSchedulingState as Fn, CredentialFieldSchema as Fr, NodeActivationContinuation as Ft, TriggerNodeConfig as G, RunPruneCandidate as Gn, CredentialRequirement as Gr, NodeExecutionStatePublisher as Gt, RunnableNodeConfig as H, RunCurrentState as Hn, CredentialMaterialSourceKind as Hr, NodeExecutionRequest as Ht, PersistedRunPolicySnapshot as I, PersistedRunState as In, CredentialHealth as Ir, NodeActivationReceipt as It, UpstreamRefPlaceholder as J, RunStateResetRequest as Jn, CredentialSessionService as Jr, PersistedTriggerSetupState as Jt, TriggerNodeOutputJson as K, RunQueueEntry as Kn, CredentialSessionFactory as Kr, NodeExecutor as Kt, PersistedTokenId as L, PersistedWorkflowSnapshot as Ln, CredentialHealthStatus as Lr, NodeActivationRequest as Lt, NodeSchedulerDecision as M, PersistedMutableNodeState as Mn, CredentialAuthDefinition as Mr, ItemNode as Mt, OutputPortKey as N, PersistedMutableRunState as Nn, CredentialBinding as Nr, LiveWorkflowRepository as Nt, NodeKind as O, NodeExecutionSnapshot as On, CostTrackingTelemetryMetricNames as Or, ExecutableTriggerNode as Ot, PairedItemRef as P, PersistedRunControlState as Pn, CredentialBindingKey as Pr, MultiInputNode as Pt, WorkflowErrorHandlerSpec as Q, WebhookRunResult as Qn, CredentialTypeId as Qr, TestableTriggerNode as Qt, RunDataFactory as R, PersistedWorkflowSnapshotNode as Rn, CredentialHealthTester as Rr, NodeActivationRequestBase as Rt, NodeDefinition as S, EngineExecutionLimitsPolicyConfig as Si, ConnectionInvocationId as Sn, NoOpTelemetryArtifactReference as Sr, BinaryStorageReadResult as St, NodeErrorHandlerSpec as T, RunEventSubscription as Ti, EngineRunCounters as Tn, CostTrackingTelemetry as Tr, BinaryStorageWriteResult as Tt, RunnableNodeInputJson as U, RunEventPublisherDeps as Un, CredentialOAuth2AuthDefinition as Ur, NodeExecutionRequestHandler as Ut, RunIdFactory as V, RunCompletionNotifier as Vn, CredentialJsonRecord as Vr, NodeExecutionContext as Vt, RunnableNodeOutputJson as W, RunExecutionOptions as Wn, CredentialOAuth2ScopesFromPublicConfig as Wr, NodeExecutionScheduler as Wt, WorkflowErrorContext as X, RunStopCondition as Xn, CredentialType as Xr, RunnableNode as Xt, WorkflowDefinition as Y, RunStatus as Yn, CredentialSetupStatus as Yr, PreparedNodeActivationDispatch as Yt, WorkflowErrorHandler as Z, RunSummary as Zn, CredentialTypeDefinition as Zr, RunnableNodeExecuteArgs as Zt, JsonValue as _, registry as _i, WebhookTriggerResolution as _n, CodemationTelemetryAttributeNames as _r, NoneRetryPolicySpec as _t, BinaryAttachment as a, InjectionToken$1 as ai, TriggerTestItemsContext as an, TelemetryArtifactAttachment as ar, WorkflowStoragePolicyDecisionArgs as at, NodeConfigBase as b, ENGINE_EXECUTION_LIMITS_DEFAULTS as bi, WorkflowActivationPolicy as bn, NoOpNodeExecutionTelemetry as br, BinaryBody as bt, ExecutionMode as c, TypeToken as ci, WorkflowRunnerResolver as cn, TelemetryAttributes as cr, WorkflowStoragePolicySpec as ct, ItemBinary as d, inject as di, WorkflowSnapshotResolver as dn, TelemetryScope as dr, runnableNodeInputType as dt, CredentialUnboundError as ei, TriggerNode as en, WorkflowExecutionPruneRepository as er, WorkflowGraphFactory as et, Items as f, injectAll as fi, HttpMethod as fn, TelemetrySpanEnd as fr, runnableNodeOutputType as ft, JsonPrimitive as g, predicateAwareClassFactory as gi, WebhookTriggerMatcher as gn, GenAiTelemetryAttributeNames as gr, FixedRetryPolicySpec as gt, JsonObject as h, instancePerContainerCachingFactory as hi, WebhookInvocationMatch as hn, CodemationTelemetryMetricNames as hr, ExponentialRetryPolicySpec as ht, ActivationIdFactory as i, Disposable as ii, TriggerSetupStateRepository as in, NodeExecutionTelemetry as ir, WorkflowPrunePolicySpec as it, NodeRef as j, PendingNodeExecution as jn, CredentialAdvancedSectionPresentation as jr, ExecutionContextFactory as jt, NodeOffloadPolicy as k, NodeExecutionStatus as kn, CostTrackingUsageRecord as kr, ExecutionBinaryService as kt, InputPortKey as l, container as li, WorkflowRunnerService as ln, TelemetryChildSpanStart as lr, branchRef as lt, JsonNonArray as m, instanceCachingFactory as mi, WebhookControlSignal as mn, TelemetrySpanScope as mr, triggerNodeSetupStateType as mt, InMemoryLiveWorkflowRepository as n, Container as ni, TriggerSetupContext as nn, ExecutionTelemetry as nr, WorkflowNodeConnection as nt, BinaryPreviewKind as o, Lifecycle as oi, WorkflowNodeInstanceFactory as on, TelemetryArtifactReference as or, WorkflowStoragePolicyMode as ot, JsonArray as p, injectable as pi, TriggerInstanceId as pn, TelemetrySpanEventRecord as pr, triggerNodeOutputType as pt, TriggerNodeSetupState as q, RunResult as qn, CredentialSessionFactoryArgs as qr, NodeResolver as qt, Engine as r, DependencyContainer$1 as ri, TriggerSetupStateFor as rn, ExecutionTelemetryFactory as rr, WorkflowPolicyRuntimeDefaults as rt, Edge as s, RegistrationOptions as si, WorkflowRepository as sn, TelemetryAttributePrimitive as sr, WorkflowStoragePolicyResolver as st, RunIntentService as t, OAuth2ProviderFromPublicConfig as ti, TriggerRuntimeDiagnostics as tn, WorkflowExecutionRepository as tr, WorkflowId as tt, Item as u, delay as ui, WorkflowSnapshotFactory as un, TelemetryMetricRecord as ur, nodeRef as ut, MutableRunData as v, singleton as vi, WebhookTriggerRoutingDiagnostics as vn, NoOpExecutionTelemetryFactory as vr, RetryPolicySpec as vt, NodeErrorHandlerArgs as w, RunEventBus as wi, CurrentStateExecutionRequest as wn, CostTrackingPriceQuote as wr, BinaryStorageWriteRequest as wt, NodeConnectionName as x, EngineExecutionLimitsPolicy as xi, ConnectionInvocationAppendArgs as xn, NoOpTelemetrySpanScope as xr, BinaryStorage as xt, NodeActivationId as y, CoreTokens as yi, AllWorkflowsActiveWorkflowActivationPolicy as yn, NoOpExecutionTelemetry as yr, BinaryAttachmentCreateRequest as yt, RunDataSnapshot as z, PersistedWorkflowTokenRegistryLike as zn, CredentialInstanceId as zr, NodeActivationScheduler as zt };
1662
- //# sourceMappingURL=RunIntentService-S-1lW-gS.d.cts.map
2027
+ export { WorkflowPrunePolicySpec as $, CredentialHealth as $n, RunTestContext as $r, TriggerSetupStateFor as $t, NodeSchedulerDecision as A, TestSuiteRunId as Ai, CodemationTelemetryMetricNames as An, NodeExecutionStatus as Ar, NodeActivationContinuation as At, RunnableNodeOutputJson as B, CostTrackingTelemetry as Bn, PersistedWorkflowTokenRegistryLike as Br, NodeExecutionStatePublisher as Bt, NodeErrorHandlerSpec as C, EngineExecutionLimitsPolicy as Ci, TelemetryAttributes as Cn, ConnectionInvocationId as Cr, ExecutableTriggerNode as Ct, NodeOffloadPolicy as D, RunEventSubscription as Di, TelemetrySpanEnd as Dn, ExecutionFrontierPlan as Dr, ItemNode as Dt, NodeKind as E, RunEventBus as Ei, TelemetryScope as En, EngineRunCounters as Er, ExecutionContextFactory as Et, RunDataSnapshot as F, NodeId as Fi, NoOpNodeExecutionTelemetry as Fn, PersistedRunControlState as Fr, NodeBinaryAttachmentService as Ft, WorkflowDefinition as G, CollectionStore as Gn, RunExecutionOptions as Gr, PreparedNodeActivationDispatch as Gt, TriggerNodeOutputJson as H, CostTrackingTelemetryFactory as Hn, RunCompletionNotifier as Hr, NodeResolver as Ht, RunId as I, OutputPortKey as Ii, NoOpTelemetrySpanScope as In, PersistedRunSchedulingState as Ir, NodeExecutionContext as It, WorkflowErrorHandlerSpec as J, CredentialAdvancedSectionPresentation as Jn, RunResult as Jr, TestableTriggerNode as Jt, WorkflowErrorContext as K, CollectionsContext as Kn, RunPruneCandidate as Kr, RunnableNode as Kt, RunIdFactory as L, PersistedTokenId as Li, NoOpTelemetryArtifactReference as Ln, PersistedRunState as Lr, NodeExecutionRequest as Lt, ParentExecutionRef as M, TestTriggerSetupContext as Mi, CodemationTelemetryAttributeNames as Mn, PendingNodeExecution as Mr, NodeActivationRequest as Mt, PersistedRunPolicySnapshot as N, InputPortKey as Ni, NoOpExecutionTelemetryFactory as Nn, PersistedMutableNodeState as Nr, NodeActivationRequestBase as Nt, NodeOutputs as O, TestCaseRunStatus as Oi, TelemetrySpanEventRecord as On, NodeExecutionError as Or, LiveWorkflowRepository as Ot, RunDataFactory as P, NodeConnectionName as Pi, NoOpExecutionTelemetry as Pn, PersistedMutableRunState as Pr, NodeActivationScheduler as Pt, WorkflowPolicyRuntimeDefaults as Q, CredentialFieldSchema as Qn, RunSummary as Qr, TriggerSetupContext as Qt, RunnableNodeConfig as R, WorkflowId as Ri, CostTrackingComponent as Rn, PersistedWorkflowSnapshot as Rr, NodeExecutionRequestHandler as Rt, NodeErrorHandlerArgs as S, ENGINE_EXECUTION_LIMITS_DEFAULTS as Si, TelemetryAttributePrimitive as Sn, ConnectionInvocationAppendArgs as Sr, EngineHost as St, NodeIterationId as T, RunEvent as Ti, TelemetryMetricRecord as Tn, CurrentStateExecutionRequest as Tr, ExecutionContext as Tt, TriggerNodeSetupState as U, CostTrackingTelemetryMetricNames as Un, RunCurrentState as Ur, PersistedTriggerSetupState as Ut, TriggerNodeConfig as V, CostTrackingTelemetryAttributeNames as Vn, PinnedNodeOutputsByPort as Vr, NodeExecutor as Vt, UpstreamRefPlaceholder as W, CostTrackingUsageRecord as Wn, RunEventPublisherDeps as Wr, PollingTriggerHandle as Wt, WorkflowGraphFactory as X, CredentialBinding as Xn, RunStatus as Xr, TriggerNode as Xt, WorkflowGraph as Y, CredentialAuthDefinition as Yn, RunStateResetRequest as Yr, TriggerCleanupHandle as Yt, WorkflowNodeConnection as Z, CredentialBindingKey as Zn, RunStopCondition as Zr, TriggerRuntimeDiagnostics as Zt, MutableRunData as _, instancePerContainerCachingFactory as _i, ExecutionTelemetry as _n, CredentialUnboundError as _r, BinaryStorageReadResult as _t, BinaryAttachment as a, DependencyContainer$1 as ai, WorkflowRunnerService as an, CredentialMaterialSourceKind as ar, nodeRef as at, NodeDefinition as b, singleton as bi, TelemetryArtifactAttachment as bn, PollingTriggerLogger as br, BinaryStorageWriteResult as bt, ExecutionMode as c, Lifecycle as ci, HttpMethod as cn, CredentialRequirement as cr, triggerNodeOutputType as ct, Items as d, container as di, WebhookInvocationMatch as dn, CredentialSessionService as dr, FixedRetryPolicySpec as dt, WebhookRunResult as ei, TriggerSetupStateRepository as en, CredentialHealthStatus as er, WorkflowStoragePolicyDecisionArgs as et, JsonArray as f, delay as fi, WebhookTriggerMatcher as fn, CredentialSetupStatus as fr, NoneRetryPolicySpec as ft, JsonValue as g, instanceCachingFactory as gi, WorkflowActivationPolicy as gn, CredentialTypeRegistry as gr, BinaryStorage as gt, JsonPrimitive as h, injectable as hi, AllWorkflowsActiveWorkflowActivationPolicy as hn, CredentialTypeId as hr, BinaryBody as ht, ActivationIdFactory as i, Container as ii, WorkflowRunnerResolver as in, CredentialJsonRecord as ir, branchRef as it, PairedItemRef as j, TestTriggerNodeConfig as ji, GenAiTelemetryAttributeNames as jn, NodeInputsByPort as jr, NodeActivationReceipt as jt, NodeRef as k, TestSuiteRunStatus as ki, TelemetrySpanScope as kn, NodeExecutionSnapshot as kr, MultiInputNode as kt, Item as l, RegistrationOptions as li, TriggerInstanceId as ln, CredentialSessionFactory as lr, triggerNodeSetupStateType as lt, JsonObject as m, injectAll as mi, WebhookTriggerRoutingDiagnostics as mn, CredentialTypeDefinition as mr, BinaryAttachmentCreateRequest as mt, InMemoryLiveWorkflowRepository as n, WorkflowExecutionPruneRepository as ni, WorkflowNodeInstanceFactory as nn, CredentialInstanceId as nr, WorkflowStoragePolicyResolver as nt, BinaryPreviewKind as o, Disposable as oi, WorkflowSnapshotFactory as on, CredentialOAuth2AuthDefinition as or, runnableNodeInputType as ot, JsonNonArray as p, inject as pi, WebhookTriggerResolution as pn, CredentialType as pr, RetryPolicySpec as pt, WorkflowErrorHandler as q, AnyCredentialType as qn, RunQueueEntry as qr, RunnableNodeExecuteArgs as qt, Engine as r, WorkflowExecutionRepository as ri, WorkflowRepository as rn, CredentialInstanceRecord as rr, WorkflowStoragePolicySpec as rt, Edge as s, InjectionToken$1 as si, WorkflowSnapshotResolver as sn, CredentialOAuth2ScopesFromPublicConfig as sr, runnableNodeOutputType as st, RunIntentService as t, WorkflowExecutionListingRepository as ti, TriggerTestItemsContext as tn, CredentialHealthTester as tr, WorkflowStoragePolicyMode as tt, ItemBinary as u, TypeToken as ui, WebhookControlSignal as un, CredentialSessionFactoryArgs as ur, ExponentialRetryPolicySpec as ut, NodeActivationId as v, predicateAwareClassFactory as vi, ExecutionTelemetryFactory as vn, OAuth2ProviderFromPublicConfig as vr, BinaryStorageStatResult as vt, NodeIdRef as w, EngineExecutionLimitsPolicyConfig as wi, TelemetryChildSpanStart as wn, ConnectionInvocationRecord as wr, ExecutionBinaryService as wt, NodeErrorHandler as x, CoreTokens as xi, TelemetryArtifactReference as xn, PollingTriggerDedupWindow as xr, EngineDeps as xt, NodeConfigBase as y, registry as yi, NodeExecutionTelemetry as yn, NoOpPollingTriggerLogger as yr, BinaryStorageWriteRequest as yt, RunnableNodeInputJson as z, CostTrackingPriceQuote as zn, PersistedWorkflowSnapshotNode as zr, NodeExecutionScheduler as zt };
2028
+ //# sourceMappingURL=RunIntentService-siBSjaaY.d.cts.map