@codemation/core 1.0.0 → 1.0.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 (58) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/{EngineRuntimeRegistration.types-BP6tsaNP.d.ts → EngineRuntimeRegistration.types-kxQA5NLt.d.ts} +2 -2
  3. package/dist/{EngineWorkflowRunnerService-DzOCa1BW.d.cts → EngineWorkflowRunnerService-Ba2AvBnL.d.cts} +2 -2
  4. package/dist/{InMemoryRunDataFactory-1iz7_SnO.d.cts → InMemoryRunDataFactory-Ou4tQUOS.d.cts} +2 -2
  5. package/dist/{RunIntentService-S-1lW-gS.d.cts → RunIntentService-Dyh_dH0k.d.cts} +528 -467
  6. package/dist/{RunIntentService-BqhmdoA1.d.ts → RunIntentService-dteLjNiT.d.ts} +568 -462
  7. package/dist/bootstrap/index.cjs +2 -2
  8. package/dist/bootstrap/index.d.cts +3 -3
  9. package/dist/bootstrap/index.d.ts +3 -3
  10. package/dist/bootstrap/index.js +2 -2
  11. package/dist/{bootstrap-jqh1kCNI.js → bootstrap-CL68rqWg.js} +3 -2
  12. package/dist/bootstrap-CL68rqWg.js.map +1 -0
  13. package/dist/{bootstrap-BfZE19lK.cjs → bootstrap-Cko6udwL.cjs} +3 -2
  14. package/dist/bootstrap-Cko6udwL.cjs.map +1 -0
  15. package/dist/{index-CGs3Hnoz.d.ts → index-CyfGTfU1.d.ts} +51 -3
  16. package/dist/index.cjs +10 -11
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +96 -3
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +2 -11
  21. package/dist/index.js.map +1 -1
  22. package/dist/{runtime-u6O644ST.js → runtime-284ok0cm.js} +200 -30
  23. package/dist/runtime-284ok0cm.js.map +1 -0
  24. package/dist/{runtime-DWKfb0BI.cjs → runtime-B3Og-_St.cjs} +222 -28
  25. package/dist/runtime-B3Og-_St.cjs.map +1 -0
  26. package/dist/testing.cjs +2 -2
  27. package/dist/testing.d.cts +2 -2
  28. package/dist/testing.d.ts +2 -2
  29. package/dist/testing.js +2 -2
  30. package/package.json +1 -1
  31. package/src/ai/AiHost.ts +9 -0
  32. package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +4 -0
  33. package/src/browser.ts +1 -0
  34. package/src/contracts/CodemationTelemetryAttributeNames.ts +6 -0
  35. package/src/contracts/NoOpNodeExecutionTelemetry.ts +2 -11
  36. package/src/contracts/NoOpTelemetrySpanScope.ts +46 -10
  37. package/src/contracts/executionPersistenceContracts.ts +30 -0
  38. package/src/contracts/runTypes.ts +10 -0
  39. package/src/contracts/runtimeTypes.ts +8 -0
  40. package/src/contracts/telemetryTypes.ts +8 -0
  41. package/src/contracts/workflowTypes.ts +6 -0
  42. package/src/events/ConnectionInvocationEventPublisher.ts +46 -0
  43. package/src/events/index.ts +1 -0
  44. package/src/events/runEvents.ts +25 -0
  45. package/src/execution/ChildExecutionScopeFactory.ts +58 -0
  46. package/src/execution/ExecutionTelemetryCostTrackingDecoratorFactory.ts +18 -0
  47. package/src/execution/NodeExecutor.ts +10 -2
  48. package/src/execution/NodeRunStateWriter.ts +7 -0
  49. package/src/execution/NodeRunStateWriterFactory.ts +7 -0
  50. package/src/execution/index.ts +1 -0
  51. package/src/index.ts +1 -0
  52. package/src/runtime/EngineFactory.ts +1 -0
  53. package/src/workflow/definition/NodeIterationIdFactory.ts +26 -0
  54. package/src/workflow/index.ts +1 -0
  55. package/dist/bootstrap-BfZE19lK.cjs.map +0 -1
  56. package/dist/bootstrap-jqh1kCNI.js.map +0 -1
  57. package/dist/runtime-DWKfb0BI.cjs.map +0 -1
  58. package/dist/runtime-u6O644ST.js.map +0 -1
@@ -2,56 +2,383 @@ import { ReadableStream } from "node:stream/web";
2
2
  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";
3
3
  import { ZodType } from "zod";
4
4
 
5
- //#region src/events/runEvents.d.ts
6
- type RunEvent = Readonly<{
7
- kind: "runCreated";
8
- runId: RunId;
9
- workflowId: WorkflowId;
10
- parent?: ParentExecutionRef;
11
- at: string;
5
+ //#region src/contracts/runTypes.d.ts
6
+ interface RunExecutionOptions {
7
+ /** Run-intent override: force the inline scheduler and bypass node-level offload decisions. */
8
+ localOnly?: boolean;
9
+ /** Marks runs started from webhook handling so orchestration can apply webhook-specific continuation rules. */
10
+ webhook?: boolean;
11
+ mode?: "manual" | "debug";
12
+ sourceWorkflowId?: WorkflowId;
13
+ sourceRunId?: RunId;
14
+ derivedFromRunId?: RunId;
15
+ isMutable?: boolean;
16
+ /** Set by the engine for this run: 0 = root, 1 = first child subworkflow, … */
17
+ subworkflowDepth?: number;
18
+ /** Effective cap after engine policy merge (successful node completions per run). */
19
+ maxNodeActivations?: number;
20
+ /** Effective cap after engine policy merge (subworkflow nesting). */
21
+ maxSubworkflowDepth?: number;
22
+ }
23
+ /** Engine-owned counters persisted with the run (worker-safe). */
24
+ interface EngineRunCounters {
25
+ completedNodeActivations: number;
26
+ }
27
+ type RunStopCondition = Readonly<{
28
+ kind: "workflowCompleted";
12
29
  }> | Readonly<{
13
- kind: "runSaved";
30
+ kind: "nodeCompleted";
31
+ nodeId: NodeId;
32
+ }>;
33
+ interface RunStateResetRequest {
34
+ clearFromNodeId: NodeId;
35
+ }
36
+ interface PersistedRunControlState {
37
+ stopCondition?: RunStopCondition;
38
+ }
39
+ interface PersistedWorkflowSnapshotNode {
40
+ id: NodeId;
41
+ kind: NodeKind;
42
+ name?: string;
43
+ nodeTokenId: PersistedTokenId;
44
+ configTokenId: PersistedTokenId;
45
+ tokenName?: string;
46
+ configTokenName?: string;
47
+ config: unknown;
48
+ }
49
+ interface PersistedWorkflowSnapshot {
50
+ id: WorkflowId;
51
+ name: string;
52
+ nodes: ReadonlyArray<PersistedWorkflowSnapshotNode>;
53
+ edges: ReadonlyArray<Edge>;
54
+ /** When the snapshot was built from a live workflow definition that configured a workflow error handler. */
55
+ workflowErrorHandlerConfigured?: boolean;
56
+ /** Connection metadata for child nodes not in the execution graph (e.g. AI agent attachments). */
57
+ connections?: ReadonlyArray<WorkflowNodeConnection>;
58
+ }
59
+ type PinnedNodeOutputsByPort = Readonly<Record<OutputPortKey, Items>>;
60
+ interface PersistedMutableNodeState {
61
+ pinnedOutputsByPort?: PinnedNodeOutputsByPort;
62
+ lastDebugInput?: Items;
63
+ }
64
+ interface PersistedMutableRunState {
65
+ nodesById: Readonly<Record<NodeId, PersistedMutableNodeState>>;
66
+ }
67
+ type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
68
+ interface RunQueueEntry {
69
+ nodeId: NodeId;
70
+ input: Items;
71
+ toInput?: InputPortKey;
72
+ batchId?: string;
73
+ from?: Readonly<{
74
+ nodeId: NodeId;
75
+ output: OutputPortKey;
76
+ }>;
77
+ collect?: Readonly<{
78
+ expectedInputs: ReadonlyArray<InputPortKey>;
79
+ received: Readonly<Record<InputPortKey, Items>>;
80
+ }>;
81
+ }
82
+ type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
83
+ interface NodeExecutionError {
84
+ message: string;
85
+ name?: string;
86
+ stack?: string;
87
+ details?: JsonValue;
88
+ }
89
+ interface NodeExecutionSnapshot {
14
90
  runId: RunId;
15
91
  workflowId: WorkflowId;
92
+ nodeId: NodeId;
93
+ activationId?: NodeActivationId;
16
94
  parent?: ParentExecutionRef;
17
- at: string;
18
- state: PersistedRunState;
19
- }> | Readonly<{
20
- kind: "nodeQueued";
21
- runId: RunId;
22
- workflowId: WorkflowId;
95
+ status: NodeExecutionStatus;
96
+ usedPinnedOutput?: boolean;
97
+ queuedAt?: string;
98
+ startedAt?: string;
99
+ finishedAt?: string;
100
+ updatedAt: string;
101
+ inputsByPort?: NodeInputsByPort;
102
+ outputs?: NodeOutputs;
103
+ error?: NodeExecutionError;
104
+ }
105
+ /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
106
+ type ConnectionInvocationId = string;
107
+ /**
108
+ * One logical LLM or tool call under an owning workflow node (e.g. AI agent).
109
+ * The owning node defines what {@link managedInput} and {@link managedOutput} contain.
110
+ */
111
+ interface ConnectionInvocationRecord {
112
+ readonly invocationId: ConnectionInvocationId;
113
+ readonly runId: RunId;
114
+ readonly workflowId: WorkflowId;
115
+ readonly connectionNodeId: NodeId;
116
+ readonly parentAgentNodeId: NodeId;
117
+ readonly parentAgentActivationId: NodeActivationId;
118
+ readonly status: NodeExecutionStatus;
119
+ readonly managedInput?: JsonValue;
120
+ readonly managedOutput?: JsonValue;
121
+ readonly error?: NodeExecutionError;
122
+ readonly queuedAt?: string;
123
+ readonly startedAt?: string;
124
+ readonly finishedAt?: string;
125
+ readonly updatedAt: string;
126
+ /** Per-item iteration id minted by the engine when this invocation occurred inside a runnable node's per-item loop. */
127
+ readonly iterationId?: NodeIterationId;
128
+ /** Item index (0-based) of the iteration that produced this invocation. */
129
+ readonly itemIndex?: number;
130
+ /** When set, this invocation was produced inside a sub-agent triggered by the named parent invocation. */
131
+ readonly parentInvocationId?: ConnectionInvocationId;
132
+ }
133
+ /** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
134
+ type ConnectionInvocationAppendArgs = Readonly<{
135
+ invocationId: ConnectionInvocationId;
136
+ connectionNodeId: NodeId;
137
+ parentAgentNodeId: NodeId;
138
+ parentAgentActivationId: NodeActivationId;
139
+ status: NodeExecutionStatus;
140
+ managedInput?: JsonValue;
141
+ managedOutput?: JsonValue;
142
+ error?: NodeExecutionError;
143
+ queuedAt?: string;
144
+ startedAt?: string;
145
+ finishedAt?: string;
146
+ iterationId?: NodeIterationId;
147
+ itemIndex?: number;
148
+ parentInvocationId?: ConnectionInvocationId;
149
+ }>;
150
+ interface RunCurrentState {
151
+ outputsByNode: Record<NodeId, NodeOutputs>;
152
+ nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
153
+ /** Append-only history of connection-scoped invocations (LLM/tool) for inspector and canvas. */
154
+ connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
155
+ mutableState?: PersistedMutableRunState;
156
+ }
157
+ interface CurrentStateExecutionRequest {
158
+ workflow: WorkflowDefinition;
159
+ items?: Items;
23
160
  parent?: ParentExecutionRef;
24
- at: string;
25
- snapshot: NodeExecutionSnapshot;
26
- }> | Readonly<{
27
- kind: "nodeStarted";
161
+ executionOptions?: RunExecutionOptions;
162
+ workflowSnapshot?: PersistedWorkflowSnapshot;
163
+ mutableState?: PersistedMutableRunState;
164
+ currentState?: RunCurrentState;
165
+ stopCondition?: RunStopCondition;
166
+ reset?: RunStateResetRequest;
167
+ }
168
+ interface ExecutionFrontierPlan {
169
+ rootNodeId?: NodeId;
170
+ rootNodeInput?: Items;
171
+ queue: RunQueueEntry[];
172
+ currentState: RunCurrentState;
173
+ stopCondition: RunStopCondition;
174
+ satisfiedNodeIds: ReadonlyArray<NodeId>;
175
+ skippedNodeIds: ReadonlyArray<NodeId>;
176
+ clearedNodeIds: ReadonlyArray<NodeId>;
177
+ preservedPinnedNodeIds: ReadonlyArray<NodeId>;
178
+ }
179
+ type RunStatus = "running" | "pending" | "completed" | "failed";
180
+ interface RunSummary {
28
181
  runId: RunId;
29
182
  workflowId: WorkflowId;
183
+ startedAt: string;
184
+ status: RunStatus;
185
+ /** ISO timestamp when the run finished (derived from node snapshots or store `updatedAt`); omit while running/pending. */
186
+ finishedAt?: string;
30
187
  parent?: ParentExecutionRef;
31
- at: string;
32
- snapshot: NodeExecutionSnapshot;
33
- }> | Readonly<{
34
- kind: "nodeCompleted";
188
+ executionOptions?: RunExecutionOptions;
189
+ }
190
+ interface PendingNodeExecution {
35
191
  runId: RunId;
192
+ activationId: NodeActivationId;
36
193
  workflowId: WorkflowId;
37
- parent?: ParentExecutionRef;
38
- at: string;
39
- snapshot: NodeExecutionSnapshot;
40
- }> | Readonly<{
41
- kind: "nodeFailed";
194
+ nodeId: NodeId;
195
+ itemsIn: number;
196
+ inputsByPort: NodeInputsByPort;
197
+ receiptId: string;
198
+ queue?: string;
199
+ batchId?: string;
200
+ enqueuedAt: string;
201
+ }
202
+ interface PersistedRunSchedulingState {
203
+ pending?: PendingNodeExecution;
204
+ queue: RunQueueEntry[];
205
+ }
206
+ interface PersistedRunState {
42
207
  runId: RunId;
43
208
  workflowId: WorkflowId;
209
+ startedAt: string;
210
+ /** Canonical terminal time for listings and retention when persisted on the run root. */
211
+ finishedAt?: string;
212
+ /** Optimistic concurrency / CAS on the run aggregate (repository may increment on save). */
213
+ revision?: number;
44
214
  parent?: ParentExecutionRef;
45
- at: string;
46
- snapshot: NodeExecutionSnapshot;
47
- }>;
48
- interface RunEventSubscription {
49
- close(): Promise<void>;
215
+ executionOptions?: RunExecutionOptions;
216
+ control?: PersistedRunControlState;
217
+ workflowSnapshot?: PersistedWorkflowSnapshot;
218
+ mutableState?: PersistedMutableRunState;
219
+ /** Frozen at createRun from workflow + runtime defaults for prune/storage decisions. */
220
+ policySnapshot?: PersistedRunPolicySnapshot;
221
+ /** Successful node completions so far (for activation budget). */
222
+ engineCounters?: EngineRunCounters;
223
+ status: RunStatus;
224
+ pending?: PendingNodeExecution;
225
+ queue: RunQueueEntry[];
226
+ outputsByNode: Record<NodeId, NodeOutputs>;
227
+ nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
228
+ /** Append-only history of connection invocations (LLM/tool) nested under owning nodes. */
229
+ connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
50
230
  }
51
- interface RunEventBus {
52
- publish(event: RunEvent): Promise<void>;
53
- subscribe(onEvent: (event: RunEvent) => void): Promise<RunEventSubscription>;
54
- subscribeToWorkflow(workflowId: WorkflowId, onEvent: (event: RunEvent) => void): Promise<RunEventSubscription>;
231
+ interface WorkflowExecutionRepository {
232
+ createRun(args: {
233
+ runId: RunId;
234
+ workflowId: WorkflowId;
235
+ startedAt: string;
236
+ parent?: ParentExecutionRef;
237
+ executionOptions?: RunExecutionOptions;
238
+ control?: PersistedRunControlState;
239
+ workflowSnapshot?: PersistedWorkflowSnapshot;
240
+ mutableState?: PersistedMutableRunState;
241
+ policySnapshot?: PersistedRunPolicySnapshot;
242
+ engineCounters?: EngineRunCounters;
243
+ }): Promise<void>;
244
+ load(runId: RunId): Promise<PersistedRunState | undefined>;
245
+ loadSchedulingState(runId: RunId): Promise<PersistedRunSchedulingState | undefined>;
246
+ save(state: PersistedRunState): Promise<void>;
247
+ deleteRun?(runId: RunId): Promise<void>;
248
+ }
249
+ interface WorkflowExecutionListingRepository {
250
+ listRuns(args?: Readonly<{
251
+ workflowId?: WorkflowId;
252
+ limit?: number;
253
+ }>): Promise<ReadonlyArray<RunSummary>>;
254
+ }
255
+ /** Runs eligible for retention-based pruning (completed or failed, older than cutoff). */
256
+ interface RunPruneCandidate {
257
+ readonly runId: RunId;
258
+ readonly workflowId: WorkflowId;
259
+ readonly startedAt: string;
260
+ readonly finishedAt: string;
261
+ }
262
+ interface WorkflowExecutionPruneRepository {
263
+ listRunsOlderThan(args: Readonly<{
264
+ nowIso: string;
265
+ defaultRetentionSeconds: number;
266
+ limit?: number;
267
+ }>): Promise<ReadonlyArray<RunPruneCandidate>>;
268
+ }
269
+ type RunResult = {
270
+ runId: RunId;
271
+ workflowId: WorkflowId;
272
+ startedAt: string;
273
+ status: "completed";
274
+ outputs: Items;
275
+ } | {
276
+ runId: RunId;
277
+ workflowId: WorkflowId;
278
+ startedAt: string;
279
+ status: "pending";
280
+ pending: PendingNodeExecution;
281
+ } | {
282
+ runId: RunId;
283
+ workflowId: WorkflowId;
284
+ startedAt: string;
285
+ status: "failed";
286
+ error: {
287
+ message: string;
288
+ };
289
+ };
290
+ type WebhookRunResult = Readonly<{
291
+ runId: RunId;
292
+ workflowId: WorkflowId;
293
+ startedAt: string;
294
+ runStatus: "pending" | "completed";
295
+ response: Items;
296
+ }>;
297
+ interface PersistedWorkflowTokenRegistryLike {
298
+ register(type: TypeToken<unknown>, packageId: string, persistedNameOverride?: string): string;
299
+ getTokenId(type: TypeToken<unknown>): string | undefined;
300
+ resolve(tokenId: string): TypeToken<unknown> | undefined;
301
+ registerFromWorkflows?(workflows: ReadonlyArray<WorkflowDefinition>): void;
302
+ }
303
+ interface RunCompletionNotifier {
304
+ resolveRunCompletion(result: RunResult): void;
305
+ resolveWebhookResponse(result: WebhookRunResult): void;
306
+ }
307
+ interface RunEventPublisherDeps {
308
+ eventBus?: RunEventBus;
309
+ }
310
+ //#endregion
311
+ //#region src/events/runEvents.d.ts
312
+ type RunEvent = Readonly<{
313
+ kind: "runCreated";
314
+ runId: RunId;
315
+ workflowId: WorkflowId;
316
+ parent?: ParentExecutionRef;
317
+ at: string;
318
+ }> | Readonly<{
319
+ kind: "runSaved";
320
+ runId: RunId;
321
+ workflowId: WorkflowId;
322
+ parent?: ParentExecutionRef;
323
+ at: string;
324
+ state: PersistedRunState;
325
+ }> | Readonly<{
326
+ kind: "nodeQueued";
327
+ runId: RunId;
328
+ workflowId: WorkflowId;
329
+ parent?: ParentExecutionRef;
330
+ at: string;
331
+ snapshot: NodeExecutionSnapshot;
332
+ }> | Readonly<{
333
+ kind: "nodeStarted";
334
+ runId: RunId;
335
+ workflowId: WorkflowId;
336
+ parent?: ParentExecutionRef;
337
+ at: string;
338
+ snapshot: NodeExecutionSnapshot;
339
+ }> | Readonly<{
340
+ kind: "nodeCompleted";
341
+ runId: RunId;
342
+ workflowId: WorkflowId;
343
+ parent?: ParentExecutionRef;
344
+ at: string;
345
+ snapshot: NodeExecutionSnapshot;
346
+ }> | Readonly<{
347
+ kind: "nodeFailed";
348
+ runId: RunId;
349
+ workflowId: WorkflowId;
350
+ parent?: ParentExecutionRef;
351
+ at: string;
352
+ snapshot: NodeExecutionSnapshot;
353
+ }> | Readonly<{
354
+ kind: "connectionInvocationStarted";
355
+ runId: RunId;
356
+ workflowId: WorkflowId;
357
+ parent?: ParentExecutionRef;
358
+ at: string;
359
+ record: ConnectionInvocationRecord;
360
+ }> | Readonly<{
361
+ kind: "connectionInvocationCompleted";
362
+ runId: RunId;
363
+ workflowId: WorkflowId;
364
+ parent?: ParentExecutionRef;
365
+ at: string;
366
+ record: ConnectionInvocationRecord;
367
+ }> | Readonly<{
368
+ kind: "connectionInvocationFailed";
369
+ runId: RunId;
370
+ workflowId: WorkflowId;
371
+ parent?: ParentExecutionRef;
372
+ at: string;
373
+ record: ConnectionInvocationRecord;
374
+ }>;
375
+ interface RunEventSubscription {
376
+ close(): Promise<void>;
377
+ }
378
+ interface RunEventBus {
379
+ publish(event: RunEvent): Promise<void>;
380
+ subscribe(onEvent: (event: RunEvent) => void): Promise<RunEventSubscription>;
381
+ subscribeToWorkflow(workflowId: WorkflowId, onEvent: (event: RunEvent) => void): Promise<RunEventSubscription>;
55
382
  }
56
383
  //#endregion
57
384
  //#region src/policies/executionLimits/EngineExecutionLimitsPolicy.d.ts
@@ -309,449 +636,171 @@ interface CostTrackingTelemetry {
309
636
  captureUsage(args: CostTrackingUsageRecord): Promise<CostTrackingPriceQuote | undefined>;
310
637
  forScope(scope: TelemetryScope): CostTrackingTelemetry;
311
638
  }
312
- interface CostTrackingTelemetryFactory {
313
- create(args: Readonly<{
314
- telemetry: ExecutionTelemetry;
315
- }>): CostTrackingTelemetry;
316
- }
317
- //#endregion
318
- //#region src/contracts/NoOpTelemetryArtifactReference.d.ts
319
- declare class NoOpTelemetryArtifactReference {
320
- static readonly value: TelemetryArtifactReference;
321
- }
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;
639
+ interface CostTrackingTelemetryFactory {
640
+ create(args: Readonly<{
641
+ telemetry: ExecutionTelemetry;
642
+ }>): CostTrackingTelemetry;
635
643
  }
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;
644
+ //#endregion
645
+ //#region src/contracts/NoOpTelemetryArtifactReference.d.ts
646
+ declare class NoOpTelemetryArtifactReference {
647
+ static readonly value: TelemetryArtifactReference;
647
648
  }
648
- interface PersistedRunSchedulingState {
649
- pending?: PendingNodeExecution;
650
- queue: RunQueueEntry[];
649
+ //#endregion
650
+ //#region src/contracts/NoOpTelemetrySpanScope.d.ts
651
+ declare class NoOpTelemetrySpanScope {
652
+ static readonly value: TelemetrySpanScope;
653
+ /** Internal: the shared no-op {@link NodeExecutionTelemetry} that {@link NoOpNodeExecutionTelemetry} re-exposes. */
654
+ static readonly nodeExecutionTelemetryValue: NodeExecutionTelemetry;
651
655
  }
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>;
656
+ //#endregion
657
+ //#region src/contracts/NoOpNodeExecutionTelemetry.d.ts
658
+ declare class NoOpNodeExecutionTelemetry {
659
+ static readonly value: NodeExecutionTelemetry;
676
660
  }
677
- interface WorkflowExecutionRepository {
678
- createRun(args: {
661
+ //#endregion
662
+ //#region src/contracts/NoOpExecutionTelemetry.d.ts
663
+ declare class NoOpExecutionTelemetry {
664
+ static readonly value: ExecutionTelemetry;
665
+ }
666
+ //#endregion
667
+ //#region src/contracts/NoOpExecutionTelemetryFactory.d.ts
668
+ declare class NoOpExecutionTelemetryFactory implements ExecutionTelemetryFactory {
669
+ create(_: Readonly<{
679
670
  runId: RunId;
680
671
  workflowId: WorkflowId;
681
- startedAt: string;
682
672
  parent?: ParentExecutionRef;
683
- executionOptions?: RunExecutionOptions;
684
- control?: PersistedRunControlState;
685
- workflowSnapshot?: PersistedWorkflowSnapshot;
686
- mutableState?: PersistedMutableRunState;
687
673
  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>;
674
+ }>): ExecutionTelemetry;
694
675
  }
695
- interface WorkflowExecutionListingRepository {
696
- listRuns(args?: Readonly<{
697
- workflowId?: WorkflowId;
698
- limit?: number;
699
- }>): Promise<ReadonlyArray<RunSummary>>;
676
+ //#endregion
677
+ //#region src/contracts/CodemationTelemetryAttributeNames.d.ts
678
+ declare class CodemationTelemetryAttributeNames {
679
+ static readonly workflowId = "codemation.workflow.id";
680
+ static readonly runId = "codemation.run.id";
681
+ static readonly nodeId = "codemation.node.id";
682
+ static readonly activationId = "codemation.activation.id";
683
+ static readonly nodeType = "codemation.node.type";
684
+ static readonly nodeRole = "codemation.node.role";
685
+ static readonly workflowFolder = "codemation.workflow.folder";
686
+ static readonly connectionInvocationId = "codemation.connection.invocation_id";
687
+ static readonly toolName = "codemation.tool.name";
688
+ static readonly traceParentRunId = "codemation.parent.run.id";
689
+ /** Per-item iteration that emitted this span/metric. Set on spans recorded inside a runnable per-item loop. */
690
+ static readonly iterationId = "codemation.iteration.id";
691
+ /** Item index (0-based) of the iteration. */
692
+ static readonly iterationIndex = "codemation.iteration.index";
693
+ /** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
694
+ static readonly parentInvocationId = "codemation.parent.invocation_id";
700
695
  }
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;
696
+ //#endregion
697
+ //#region src/contracts/GenAiTelemetryAttributeNames.d.ts
698
+ declare class GenAiTelemetryAttributeNames {
699
+ static readonly operationName = "gen_ai.operation.name";
700
+ static readonly requestModel = "gen_ai.request.model";
701
+ static readonly usageInputTokens = "gen_ai.usage.input_tokens";
702
+ static readonly usageOutputTokens = "gen_ai.usage.output_tokens";
703
+ static readonly usageTotalTokens = "gen_ai.usage.total_tokens";
704
+ static readonly usageCacheReadInputTokens = "gen_ai.usage.cache_read.input_tokens";
705
+ static readonly usageCacheCreationInputTokens = "gen_ai.usage.cache_creation.input_tokens";
706
+ static readonly usageReasoningTokens = "codemation.gen_ai.usage.reasoning_tokens";
707
707
  }
708
- interface WorkflowExecutionPruneRepository {
709
- listRunsOlderThan(args: Readonly<{
710
- nowIso: string;
711
- defaultRetentionSeconds: number;
712
- limit?: number;
713
- }>): Promise<ReadonlyArray<RunPruneCandidate>>;
708
+ //#endregion
709
+ //#region src/contracts/CodemationTelemetryMetricNames.d.ts
710
+ declare class CodemationTelemetryMetricNames {
711
+ static readonly agentTurns = "codemation.ai.turns";
712
+ static readonly agentToolCalls = "codemation.ai.tool_calls";
713
+ static readonly gmailMessagesEmitted = "codemation.gmail.messages_emitted";
714
+ static readonly gmailAttachments = "codemation.gmail.attachments";
715
+ static readonly gmailAttachmentBytes = "codemation.gmail.attachment_bytes";
714
716
  }
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;
717
+ //#endregion
718
+ //#region src/contracts/telemetryTypes.d.ts
719
+ type TelemetryAttributePrimitive = string | number | boolean | null;
720
+ interface TelemetryAttributes {
721
+ readonly [key: string]: TelemetryAttributePrimitive | undefined;
748
722
  }
749
- interface RunCompletionNotifier {
750
- resolveRunCompletion(result: RunResult): void;
751
- resolveWebhookResponse(result: WebhookRunResult): void;
723
+ interface TelemetryMetricRecord {
724
+ readonly name: string;
725
+ readonly value: number;
726
+ readonly unit?: string;
727
+ readonly attributes?: TelemetryAttributes;
752
728
  }
753
- interface RunEventPublisherDeps {
754
- eventBus?: RunEventBus;
729
+ interface TelemetrySpanEventRecord {
730
+ readonly name: string;
731
+ readonly occurredAt?: Date;
732
+ readonly attributes?: TelemetryAttributes;
733
+ }
734
+ interface TelemetryArtifactAttachment {
735
+ readonly kind: string;
736
+ readonly contentType: string;
737
+ readonly previewText?: string;
738
+ readonly previewJson?: JsonValue;
739
+ readonly payloadText?: string;
740
+ readonly payloadJson?: JsonValue;
741
+ readonly bytes?: number;
742
+ readonly truncated?: boolean;
743
+ readonly expiresAt?: Date;
744
+ }
745
+ interface TelemetryArtifactReference {
746
+ readonly artifactId: string;
747
+ readonly traceId?: string;
748
+ readonly spanId?: string;
749
+ }
750
+ interface TelemetrySpanEnd {
751
+ readonly status?: "ok" | "error";
752
+ readonly statusMessage?: string;
753
+ readonly endedAt?: Date;
754
+ readonly attributes?: TelemetryAttributes;
755
+ }
756
+ interface TelemetryChildSpanStart {
757
+ readonly name: string;
758
+ readonly kind?: "internal" | "client";
759
+ readonly startedAt?: Date;
760
+ readonly attributes?: TelemetryAttributes;
761
+ }
762
+ interface TelemetryScope {
763
+ readonly traceId?: string;
764
+ readonly spanId?: string;
765
+ readonly costTracking?: CostTrackingTelemetry;
766
+ addSpanEvent(args: TelemetrySpanEventRecord): Promise<void> | void;
767
+ recordMetric(args: TelemetryMetricRecord): Promise<void> | void;
768
+ attachArtifact(args: TelemetryArtifactAttachment): Promise<TelemetryArtifactReference> | TelemetryArtifactReference;
769
+ }
770
+ interface TelemetrySpanScope extends TelemetryScope {
771
+ readonly traceId: string;
772
+ readonly spanId: string;
773
+ end(args?: TelemetrySpanEnd): Promise<void> | void;
774
+ /**
775
+ * Lift this span into a {@link NodeExecutionTelemetry} scoped to a different (nodeId, activationId).
776
+ * Children created via the returned telemetry's `startChildSpan` get this span as their parent.
777
+ *
778
+ * Used at the sub-agent boundary so that nested runtime telemetry parents under the agent.tool.call
779
+ * span instead of the orchestrator's node-level span.
780
+ */
781
+ asNodeTelemetry(args: Readonly<{
782
+ nodeId: NodeId;
783
+ activationId: NodeActivationId;
784
+ }>): NodeExecutionTelemetry;
785
+ }
786
+ interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
787
+ startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
788
+ }
789
+ interface ExecutionTelemetry extends TelemetryScope {
790
+ readonly traceId: string;
791
+ readonly spanId: string;
792
+ forNode(args: Readonly<{
793
+ nodeId: NodeId;
794
+ activationId: NodeActivationId;
795
+ }>): NodeExecutionTelemetry;
796
+ }
797
+ interface ExecutionTelemetryFactory {
798
+ create(args: Readonly<{
799
+ runId: RunId;
800
+ workflowId: WorkflowId;
801
+ parent?: ParentExecutionRef;
802
+ policySnapshot?: PersistedRunPolicySnapshot;
803
+ }>): ExecutionTelemetry;
755
804
  }
756
805
  //#endregion
757
806
  //#region src/contracts/workflowActivationPolicy.d.ts
@@ -924,6 +973,12 @@ interface ExecutionContext {
924
973
  telemetry: ExecutionTelemetry;
925
974
  binary: ExecutionBinaryService;
926
975
  getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
976
+ /** Per-item iteration id, set by {@link NodeExecutor} on the ctx passed into runnable `execute`. */
977
+ iterationId?: NodeIterationId;
978
+ /** Item index (0-based) within the current activation's batch; set alongside {@link iterationId}. */
979
+ itemIndex?: number;
980
+ /** When set, this ctx is executing inside a sub-agent triggered by the named parent invocation. */
981
+ parentInvocationId?: ConnectionInvocationId;
927
982
  }
928
983
  interface ExecutionContextFactory {
929
984
  create(args: {
@@ -1350,6 +1405,12 @@ type Items<TJson = unknown> = ReadonlyArray<Item<TJson>>;
1350
1405
  type NodeOutputs = Partial<Record<OutputPortKey, Items>>;
1351
1406
  type RunId = string;
1352
1407
  type NodeActivationId = string;
1408
+ /**
1409
+ * One per-item iteration of a runnable node's execute loop. Refines `NodeActivationId` for
1410
+ * per-item connection invocations and telemetry. Undefined when the executing node is a batch
1411
+ * node or trigger that does not iterate items.
1412
+ */
1413
+ type NodeIterationId = string;
1353
1414
  interface ParentExecutionRef {
1354
1415
  runId: RunId;
1355
1416
  workflowId: WorkflowId;
@@ -1658,5 +1719,5 @@ declare class RunIntentService {
1658
1719
  private createWebhookExecutionOptions;
1659
1720
  }
1660
1721
  //#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
1722
+ export { WorkflowErrorHandlerSpec as $, CredentialBinding as $n, NodeExecutionSnapshot as $r, TestableTriggerNode as $t, NodeOffloadPolicy as A, TelemetryMetricRecord as An, delay as Ar, ExecutionBinaryService as At, RunDataSnapshot as B, NoOpNodeExecutionTelemetry as Bn, ENGINE_EXECUTION_LIMITS_DEFAULTS as Br, NodeActivationScheduler as Bt, NodeErrorHandler as C, WebhookRunResult as Ci, ExecutionTelemetryFactory as Cn, DependencyContainer$1 as Cr, BinaryStorageReadResult as Ct, NodeIdRef as D, TelemetryAttributePrimitive as Dn, RegistrationOptions as Dr, EngineDeps as Dt, NodeId as E, WorkflowExecutionRepository as Ei, TelemetryArtifactReference as En, Lifecycle as Er, BinaryStorageWriteResult as Et, PairedItemRef as F, CodemationTelemetryMetricNames as Fn, instancePerContainerCachingFactory as Fr, MultiInputNode as Ft, RunnableNodeOutputJson as G, CostTrackingTelemetry as Gn, RunEventSubscription as Gr, NodeExecutionScheduler as Gt, RunIdFactory as H, NoOpTelemetryArtifactReference as Hn, EngineExecutionLimitsPolicyConfig as Hr, NodeExecutionContext as Ht, ParentExecutionRef as I, GenAiTelemetryAttributeNames as In, predicateAwareClassFactory as Ir, NodeActivationContinuation as It, TriggerNodeSetupState as J, CostTrackingTelemetryMetricNames as Jn, ConnectionInvocationRecord as Jr, NodeResolver as Jt, TriggerNodeConfig as K, CostTrackingTelemetryAttributeNames as Kn, ConnectionInvocationAppendArgs as Kr, NodeExecutionStatePublisher as Kt, PersistedRunPolicySnapshot as L, CodemationTelemetryAttributeNames as Ln, registry as Lr, NodeActivationReceipt as Lt, NodeRef as M, TelemetrySpanEnd as Mn, injectAll as Mr, ExecutionContextFactory as Mt, NodeSchedulerDecision as N, TelemetrySpanEventRecord as Nn, injectable as Nr, ItemNode as Nt, NodeIterationId as O, TelemetryAttributes as On, TypeToken as Or, EngineHost as Ot, OutputPortKey as P, TelemetrySpanScope as Pn, instanceCachingFactory as Pr, LiveWorkflowRepository as Pt, WorkflowErrorHandler as Q, CredentialAuthDefinition as Qn, NodeExecutionError as Qr, RunnableNodeExecuteArgs as Qt, PersistedTokenId as R, NoOpExecutionTelemetryFactory as Rn, singleton as Rr, NodeActivationRequest as Rt, NodeDefinition as S, RunSummary as Si, ExecutionTelemetry as Sn, Container as Sr, BinaryStorage as St, NodeErrorHandlerSpec as T, WorkflowExecutionPruneRepository as Ti, TelemetryArtifactAttachment as Tn, InjectionToken$1 as Tr, BinaryStorageWriteRequest as Tt, RunnableNodeConfig as U, CostTrackingComponent as Un, RunEvent as Ur, NodeExecutionRequest as Ut, RunId as V, NoOpTelemetrySpanScope as Vn, EngineExecutionLimitsPolicy as Vr, NodeBinaryAttachmentService as Vt, RunnableNodeInputJson as W, CostTrackingPriceQuote as Wn, RunEventBus as Wr, NodeExecutionRequestHandler as Wt, WorkflowDefinition as X, AnyCredentialType as Xn, EngineRunCounters as Xr, PreparedNodeActivationDispatch as Xt, UpstreamRefPlaceholder as Y, CostTrackingUsageRecord as Yn, CurrentStateExecutionRequest as Yr, PersistedTriggerSetupState as Yt, WorkflowErrorContext as Z, CredentialAdvancedSectionPresentation as Zn, ExecutionFrontierPlan as Zr, RunnableNode as Zt, JsonValue as _, RunQueueEntry as _i, WebhookTriggerMatcher as _n, CredentialTypeDefinition as _r, FixedRetryPolicySpec as _t, BinaryAttachment as a, PersistedRunControlState as ai, TriggerSetupStateRepository as an, CredentialInstanceId as ar, WorkflowPrunePolicySpec as at, NodeConfigBase as b, RunStatus as bi, AllWorkflowsActiveWorkflowActivationPolicy as bn, CredentialUnboundError as br, BinaryAttachmentCreateRequest as bt, ExecutionMode as c, PersistedWorkflowSnapshot as ci, WorkflowRepository as cn, CredentialMaterialSourceKind as cr, WorkflowStoragePolicyResolver as ct, ItemBinary as d, PinnedNodeOutputsByPort as di, WorkflowSnapshotFactory as dn, CredentialRequirement as dr, nodeRef as dt, NodeExecutionStatus as ei, TriggerCleanupHandle as en, CredentialBindingKey as er, WorkflowGraph as et, Items as f, RunCompletionNotifier as fi, WorkflowSnapshotResolver as fn, CredentialSessionFactory as fr, runnableNodeInputType as ft, JsonPrimitive as g, RunPruneCandidate as gi, WebhookInvocationMatch as gn, CredentialType as gr, ExponentialRetryPolicySpec as gt, JsonObject as h, RunExecutionOptions as hi, WebhookControlSignal as hn, CredentialSetupStatus as hr, triggerNodeSetupStateType as ht, ActivationIdFactory as i, PersistedMutableRunState as ii, TriggerSetupStateFor as in, CredentialHealthTester as ir, WorkflowPolicyRuntimeDefaults as it, NodeOutputs as j, TelemetryScope as jn, inject as jr, ExecutionContext as jt, NodeKind as k, TelemetryChildSpanStart as kn, container as kr, ExecutableTriggerNode as kt, InputPortKey as l, PersistedWorkflowSnapshotNode as li, WorkflowRunnerResolver as ln, CredentialOAuth2AuthDefinition as lr, WorkflowStoragePolicySpec as lt, JsonNonArray as m, RunEventPublisherDeps as mi, TriggerInstanceId as mn, CredentialSessionService as mr, triggerNodeOutputType as mt, InMemoryLiveWorkflowRepository as n, PendingNodeExecution as ni, TriggerRuntimeDiagnostics as nn, CredentialHealth as nr, WorkflowId as nt, BinaryPreviewKind as o, PersistedRunSchedulingState as oi, TriggerTestItemsContext as on, CredentialInstanceRecord as or, WorkflowStoragePolicyDecisionArgs as ot, JsonArray as p, RunCurrentState as pi, HttpMethod as pn, CredentialSessionFactoryArgs as pr, runnableNodeOutputType as pt, TriggerNodeOutputJson as q, CostTrackingTelemetryFactory as qn, ConnectionInvocationId as qr, NodeExecutor as qt, Engine as r, PersistedMutableNodeState as ri, TriggerSetupContext as rn, CredentialHealthStatus as rr, WorkflowNodeConnection as rt, Edge as s, PersistedRunState as si, WorkflowNodeInstanceFactory as sn, CredentialJsonRecord as sr, WorkflowStoragePolicyMode as st, RunIntentService as t, NodeInputsByPort as ti, TriggerNode as tn, CredentialFieldSchema as tr, WorkflowGraphFactory as tt, Item as u, PersistedWorkflowTokenRegistryLike as ui, WorkflowRunnerService as un, CredentialOAuth2ScopesFromPublicConfig as ur, branchRef as ut, MutableRunData as v, RunResult as vi, WebhookTriggerResolution as vn, CredentialTypeId as vr, NoneRetryPolicySpec as vt, NodeErrorHandlerArgs as w, WorkflowExecutionListingRepository as wi, NodeExecutionTelemetry as wn, Disposable as wr, BinaryStorageStatResult as wt, NodeConnectionName as x, RunStopCondition as xi, WorkflowActivationPolicy as xn, OAuth2ProviderFromPublicConfig as xr, BinaryBody as xt, NodeActivationId as y, RunStateResetRequest as yi, WebhookTriggerRoutingDiagnostics as yn, CredentialTypeRegistry as yr, RetryPolicySpec as yt, RunDataFactory as z, NoOpExecutionTelemetry as zn, CoreTokens as zr, NodeActivationRequestBase as zt };
1723
+ //# sourceMappingURL=RunIntentService-Dyh_dH0k.d.cts.map