@nebulaos/core 0.1.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 (150) hide show
  1. package/README.md +206 -0
  2. package/dist/__tests__/mocks/mock-provider.d.ts +15 -0
  3. package/dist/__tests__/mocks/mock-provider.js +44 -0
  4. package/dist/agent/Agent.d.ts +96 -0
  5. package/dist/agent/Agent.js +861 -0
  6. package/dist/agent/BaseAgent.d.ts +53 -0
  7. package/dist/agent/BaseAgent.js +126 -0
  8. package/dist/agent/events/events.d.ts +14 -0
  9. package/dist/agent/events/events.js +2 -0
  10. package/dist/agent/events/events.spec.d.ts +1 -0
  11. package/dist/agent/events/events.spec.js +75 -0
  12. package/dist/agent/instruction/index.d.ts +23 -0
  13. package/dist/agent/instruction/index.js +76 -0
  14. package/dist/agent/memory/in-memory.d.ts +24 -0
  15. package/dist/agent/memory/in-memory.js +78 -0
  16. package/dist/agent/memory/index.d.ts +2 -0
  17. package/dist/agent/memory/index.js +18 -0
  18. package/dist/agent/memory/memory.d.ts +43 -0
  19. package/dist/agent/memory/memory.js +7 -0
  20. package/dist/agent/provider/file-parts.spec.d.ts +1 -0
  21. package/dist/agent/provider/file-parts.spec.js +83 -0
  22. package/dist/agent/provider/index.d.ts +130 -0
  23. package/dist/agent/provider/index.js +8 -0
  24. package/dist/agent/skills/index.d.ts +61 -0
  25. package/dist/agent/skills/index.js +9 -0
  26. package/dist/agent/tools/index.d.ts +35 -0
  27. package/dist/agent/tools/index.js +87 -0
  28. package/dist/cost/add-cost.d.ts +10 -0
  29. package/dist/cost/add-cost.js +80 -0
  30. package/dist/cost/add-cost.spec.d.ts +1 -0
  31. package/dist/cost/add-cost.spec.js +36 -0
  32. package/dist/cost/index.d.ts +1 -0
  33. package/dist/cost/index.js +17 -0
  34. package/dist/domain-events/index.d.ts +16 -0
  35. package/dist/domain-events/index.js +38 -0
  36. package/dist/eval/index.d.ts +19 -0
  37. package/dist/eval/index.js +24 -0
  38. package/dist/events/base.d.ts +5 -0
  39. package/dist/events/base.js +2 -0
  40. package/dist/events/schemas.d.ts +3463 -0
  41. package/dist/events/schemas.js +244 -0
  42. package/dist/execution-context/index.d.ts +21 -0
  43. package/dist/execution-context/index.js +17 -0
  44. package/dist/index.cjs +2958 -0
  45. package/dist/index.cjs.map +1 -0
  46. package/dist/index.d.cts +3425 -0
  47. package/dist/index.d.ts +22 -0
  48. package/dist/index.js +53 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/lgpd/index.d.ts +7 -0
  51. package/dist/lgpd/index.js +21 -0
  52. package/dist/logger/agent-logger.d.ts +16 -0
  53. package/dist/logger/agent-logger.js +110 -0
  54. package/dist/logger/formatters.d.ts +32 -0
  55. package/dist/logger/formatters.js +146 -0
  56. package/dist/logger/index.d.ts +30 -0
  57. package/dist/logger/index.js +88 -0
  58. package/dist/logger/styles.d.ts +46 -0
  59. package/dist/logger/styles.js +53 -0
  60. package/dist/logger/workflow-logger.d.ts +16 -0
  61. package/dist/logger/workflow-logger.js +79 -0
  62. package/dist/multi-agent/agent-as-tool/AgentAsTool.d.ts +16 -0
  63. package/dist/multi-agent/agent-as-tool/AgentAsTool.js +54 -0
  64. package/dist/multi-agent/agent-as-tool/AgentAsTool.spec.d.ts +1 -0
  65. package/dist/multi-agent/agent-as-tool/AgentAsTool.spec.js +76 -0
  66. package/dist/multi-agent/committee-team/CommitteeTeam.d.ts +16 -0
  67. package/dist/multi-agent/committee-team/CommitteeTeam.js +150 -0
  68. package/dist/multi-agent/committee-team/CommitteeTeam.spec.d.ts +1 -0
  69. package/dist/multi-agent/committee-team/CommitteeTeam.spec.js +43 -0
  70. package/dist/multi-agent/handoff-team/HandoffTeam.d.ts +16 -0
  71. package/dist/multi-agent/handoff-team/HandoffTeam.js +185 -0
  72. package/dist/multi-agent/handoff-team/HandoffTeam.spec.d.ts +1 -0
  73. package/dist/multi-agent/handoff-team/HandoffTeam.spec.js +105 -0
  74. package/dist/multi-agent/hierarchical-team/HierarchicalTeam.d.ts +18 -0
  75. package/dist/multi-agent/hierarchical-team/HierarchicalTeam.js +164 -0
  76. package/dist/multi-agent/hierarchical-team/HierarchicalTeam.spec.d.ts +1 -0
  77. package/dist/multi-agent/hierarchical-team/HierarchicalTeam.spec.js +53 -0
  78. package/dist/multi-agent/index.d.ts +10 -0
  79. package/dist/multi-agent/index.js +26 -0
  80. package/dist/multi-agent/pipeline-team/PipelineTeam.d.ts +13 -0
  81. package/dist/multi-agent/pipeline-team/PipelineTeam.js +104 -0
  82. package/dist/multi-agent/pipeline-team/PipelineTeam.spec.d.ts +1 -0
  83. package/dist/multi-agent/pipeline-team/PipelineTeam.spec.js +54 -0
  84. package/dist/multi-agent/router-team/RouterTeam.d.ts +15 -0
  85. package/dist/multi-agent/router-team/RouterTeam.js +153 -0
  86. package/dist/multi-agent/router-team/RouterTeam.spec.d.ts +1 -0
  87. package/dist/multi-agent/router-team/RouterTeam.spec.js +69 -0
  88. package/dist/multi-agent/types/index.d.ts +349 -0
  89. package/dist/multi-agent/types/index.js +79 -0
  90. package/dist/multi-agent/utils/guardrails.d.ts +6 -0
  91. package/dist/multi-agent/utils/guardrails.js +34 -0
  92. package/dist/multi-agent/utils/memory.d.ts +8 -0
  93. package/dist/multi-agent/utils/memory.js +40 -0
  94. package/dist/multi-agent/utils/prompts.d.ts +4 -0
  95. package/dist/multi-agent/utils/prompts.js +25 -0
  96. package/dist/tracing/index.d.ts +89 -0
  97. package/dist/tracing/index.js +188 -0
  98. package/dist/tsup.config.d.ts +2 -0
  99. package/dist/tsup.config.js +11 -0
  100. package/dist/utils/schema-to-zod.d.ts +7 -0
  101. package/dist/utils/schema-to-zod.js +36 -0
  102. package/dist/workflow/Workflow.d.ts +106 -0
  103. package/dist/workflow/Workflow.js +204 -0
  104. package/dist/workflow/adapters.d.ts +61 -0
  105. package/dist/workflow/adapters.js +29 -0
  106. package/dist/workflow/definition/DefinitionBuilder.d.ts +9 -0
  107. package/dist/workflow/definition/DefinitionBuilder.js +91 -0
  108. package/dist/workflow/definition/DefinitionBuilder.spec.d.ts +1 -0
  109. package/dist/workflow/definition/DefinitionBuilder.spec.js +66 -0
  110. package/dist/workflow/definition/DefinitionHasher.d.ts +8 -0
  111. package/dist/workflow/definition/DefinitionHasher.js +11 -0
  112. package/dist/workflow/definition/DefinitionHasher.spec.d.ts +1 -0
  113. package/dist/workflow/definition/DefinitionHasher.spec.js +28 -0
  114. package/dist/workflow/definition/types.d.ts +27 -0
  115. package/dist/workflow/definition/types.js +2 -0
  116. package/dist/workflow/events.d.ts +9 -0
  117. package/dist/workflow/events.js +2 -0
  118. package/dist/workflow/execution/AgentNodeIntegration.spec.d.ts +1 -0
  119. package/dist/workflow/execution/AgentNodeIntegration.spec.js +50 -0
  120. package/dist/workflow/execution/NodeExecutor.d.ts +9 -0
  121. package/dist/workflow/execution/NodeExecutor.js +43 -0
  122. package/dist/workflow/execution/NodeExecutor.spec.d.ts +1 -0
  123. package/dist/workflow/execution/NodeExecutor.spec.js +45 -0
  124. package/dist/workflow/execution/WorkflowEventBus.d.ts +14 -0
  125. package/dist/workflow/execution/WorkflowEventBus.js +42 -0
  126. package/dist/workflow/execution/WorkflowEventBus.spec.d.ts +1 -0
  127. package/dist/workflow/execution/WorkflowEventBus.spec.js +78 -0
  128. package/dist/workflow/execution/WorkflowRunner.d.ts +26 -0
  129. package/dist/workflow/execution/WorkflowRunner.js +212 -0
  130. package/dist/workflow/execution/WorkflowRunner.spec.d.ts +1 -0
  131. package/dist/workflow/execution/WorkflowRunner.spec.js +92 -0
  132. package/dist/workflow/execution/WorkflowTelemetry.d.ts +13 -0
  133. package/dist/workflow/execution/WorkflowTelemetry.js +43 -0
  134. package/dist/workflow/execution/WorkflowTelemetry.spec.d.ts +1 -0
  135. package/dist/workflow/execution/WorkflowTelemetry.spec.js +31 -0
  136. package/dist/workflow/graph/NodeNameRegistry.d.ts +20 -0
  137. package/dist/workflow/graph/NodeNameRegistry.js +21 -0
  138. package/dist/workflow/graph/NodeNameRegistry.spec.d.ts +1 -0
  139. package/dist/workflow/graph/NodeNameRegistry.spec.js +18 -0
  140. package/dist/workflow/graph/WorkflowGraph.d.ts +14 -0
  141. package/dist/workflow/graph/WorkflowGraph.js +23 -0
  142. package/dist/workflow/graph/nodes.d.ts +26 -0
  143. package/dist/workflow/graph/nodes.js +2 -0
  144. package/dist/workflow/queue/WorkflowQueueService.d.ts +22 -0
  145. package/dist/workflow/queue/WorkflowQueueService.js +47 -0
  146. package/dist/workflow/state/WorkflowStateService.d.ts +7 -0
  147. package/dist/workflow/state/WorkflowStateService.js +20 -0
  148. package/dist/workflow/types.d.ts +16 -0
  149. package/dist/workflow/types.js +2 -0
  150. package/package.json +56 -0
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NebulaEventSchema = exports.ExecutionCostIncurredSchema = exports.ToolExecutionErrorSchema = exports.ToolExecutionEndSchema = exports.ToolExecutionStartSchema = exports.WorkflowNodeEndSchema = exports.WorkflowNodeStartSchema = exports.WorkflowRunErrorSchema = exports.WorkflowRunEndSchema = exports.WorkflowRunStartSchema = exports.AgentToolResultSchema = exports.AgentToolCallSchema = exports.AgentLLMResponseSchema = exports.AgentLLMCallSchema = exports.AgentExecutionErrorSchema = exports.AgentExecutionEndSchema = exports.AgentExecutionStartSchema = exports.ModelSchema = exports.ErrorSchema = exports.UsageSchema = exports.EventCommonSchema = exports.TraceContextSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ // =============================================================================
6
+ // Common Fields
7
+ // =============================================================================
8
+ exports.TraceContextSchema = zod_1.z.object({
9
+ traceId: zod_1.z.string().describe("Unique identifier for the trace"),
10
+ spanId: zod_1.z.string().describe("Unique identifier for the current span"),
11
+ parentSpanId: zod_1.z.string().optional().describe("Identifier of the parent span, if any"),
12
+ });
13
+ exports.EventCommonSchema = zod_1.z.object({
14
+ type: zod_1.z.string().describe("Event type identifier (e.g., 'agent:execution:start')"),
15
+ timestamp: zod_1.z.string().datetime().describe("ISO 8601 timestamp of when the event occurred"),
16
+ trace: exports.TraceContextSchema,
17
+ correlationId: zod_1.z.string().optional().describe("Optional external correlation ID"),
18
+ executionId: zod_1.z.string().optional().describe("Logical execution ID"),
19
+ rootExecutionId: zod_1.z.string().optional().describe("Top-level (root) execution ID"),
20
+ parentExecutionId: zod_1.z.string().optional().describe("Immediate parent execution ID"),
21
+ });
22
+ exports.UsageSchema = zod_1.z.object({
23
+ promptTokens: zod_1.z.number(),
24
+ completionTokens: zod_1.z.number(),
25
+ totalTokens: zod_1.z.number(),
26
+ reasoningTokens: zod_1.z.number().optional(),
27
+ });
28
+ exports.ErrorSchema = zod_1.z.object({
29
+ name: zod_1.z.string().optional(),
30
+ message: zod_1.z.string(),
31
+ code: zod_1.z.string().optional(),
32
+ stack: zod_1.z.string().optional(),
33
+ details: zod_1.z.any().optional(),
34
+ });
35
+ exports.ModelSchema = zod_1.z.object({
36
+ provider: zod_1.z.string(),
37
+ model: zod_1.z.string(),
38
+ temperature: zod_1.z.number().optional(),
39
+ maxTokens: zod_1.z.number().optional(),
40
+ topP: zod_1.z.number().optional(),
41
+ frequencyPenalty: zod_1.z.number().optional(),
42
+ presencePenalty: zod_1.z.number().optional(),
43
+ }).passthrough(); // Allow any other provider-specific config
44
+ // =============================================================================
45
+ // Agent Events
46
+ // =============================================================================
47
+ exports.AgentExecutionStartSchema = exports.EventCommonSchema.extend({
48
+ type: zod_1.z.literal("agent:execution:start"),
49
+ data: zod_1.z.object({
50
+ agentId: zod_1.z.string().describe("Stable agent identifier (usually matches runtimeResourceId)"),
51
+ agentName: zod_1.z.string(),
52
+ input: zod_1.z.any().optional().describe("Input arguments for the execution"),
53
+ metadata: zod_1.z.record(zod_1.z.any()).optional(),
54
+ }),
55
+ });
56
+ exports.AgentExecutionEndSchema = exports.EventCommonSchema.extend({
57
+ type: zod_1.z.literal("agent:execution:end"),
58
+ data: zod_1.z.object({
59
+ agentId: zod_1.z.string().describe("Stable agent identifier (usually matches runtimeResourceId)"),
60
+ agentName: zod_1.z.string(),
61
+ status: zod_1.z.enum(["success", "error", "truncated"]),
62
+ output: zod_1.z.any().optional().describe("Final output of the execution"),
63
+ durationMs: zod_1.z.number(),
64
+ usage: exports.UsageSchema.optional().describe("Total token usage for this execution"),
65
+ }),
66
+ });
67
+ exports.AgentExecutionErrorSchema = exports.EventCommonSchema.extend({
68
+ type: zod_1.z.literal("agent:execution:error"),
69
+ data: zod_1.z.object({
70
+ agentId: zod_1.z.string().describe("Stable agent identifier (usually matches runtimeResourceId)"),
71
+ agentName: zod_1.z.string(),
72
+ error: exports.ErrorSchema,
73
+ durationMs: zod_1.z.number().optional(),
74
+ }),
75
+ });
76
+ exports.AgentLLMCallSchema = exports.EventCommonSchema.extend({
77
+ type: zod_1.z.literal("agent:llm:call"),
78
+ data: zod_1.z.object({
79
+ agentId: zod_1.z.string().describe("Stable agent identifier (usually matches runtimeResourceId)"),
80
+ agentName: zod_1.z.string(),
81
+ step: zod_1.z.number().int().positive().describe("Current execution step"),
82
+ model: exports.ModelSchema,
83
+ messages: zod_1.z.array(zod_1.z.any()).describe("Messages sent to the LLM"),
84
+ tools: zod_1.z.array(zod_1.z.any()).optional().describe("Tools definitions sent to the LLM"),
85
+ responseFormat: zod_1.z.any().optional(),
86
+ }),
87
+ });
88
+ exports.AgentLLMResponseSchema = exports.EventCommonSchema.extend({
89
+ type: zod_1.z.literal("agent:llm:response"),
90
+ data: zod_1.z.object({
91
+ agentId: zod_1.z.string().describe("Stable agent identifier (usually matches runtimeResourceId)"),
92
+ agentName: zod_1.z.string(),
93
+ step: zod_1.z.number().int().positive(),
94
+ model: exports.ModelSchema,
95
+ content: zod_1.z.any().describe("Content returned by the LLM"),
96
+ toolCalls: zod_1.z.array(zod_1.z.any()).optional(),
97
+ finishReason: zod_1.z.string().optional(),
98
+ usage: exports.UsageSchema.optional(),
99
+ durationMs: zod_1.z.number().optional(),
100
+ }),
101
+ });
102
+ exports.AgentToolCallSchema = exports.EventCommonSchema.extend({
103
+ type: zod_1.z.literal("agent:tool:call"),
104
+ data: zod_1.z.object({
105
+ agentId: zod_1.z.string().describe("Stable agent identifier (usually matches runtimeResourceId)"),
106
+ agentName: zod_1.z.string(),
107
+ toolName: zod_1.z.string(),
108
+ toolCallId: zod_1.z.string(),
109
+ args: zod_1.z.any().describe("Arguments passed to the tool"),
110
+ }),
111
+ });
112
+ exports.AgentToolResultSchema = exports.EventCommonSchema.extend({
113
+ type: zod_1.z.literal("agent:tool:result"),
114
+ data: zod_1.z.object({
115
+ agentId: zod_1.z.string().describe("Stable agent identifier (usually matches runtimeResourceId)"),
116
+ agentName: zod_1.z.string(),
117
+ toolName: zod_1.z.string(),
118
+ toolCallId: zod_1.z.string(),
119
+ output: zod_1.z.any().optional().describe("Result returned by the tool"),
120
+ error: zod_1.z.string().optional().describe("Error message if tool failed"),
121
+ durationMs: zod_1.z.number().optional(),
122
+ }),
123
+ });
124
+ // =============================================================================
125
+ // Workflow Events
126
+ // =============================================================================
127
+ exports.WorkflowRunStartSchema = exports.EventCommonSchema.extend({
128
+ type: zod_1.z.literal("workflow:run:start"),
129
+ data: zod_1.z.object({
130
+ workflowId: zod_1.z.string(),
131
+ definitionVersion: zod_1.z.string(),
132
+ input: zod_1.z.any().optional(),
133
+ metadata: zod_1.z.record(zod_1.z.any()).optional(),
134
+ }),
135
+ });
136
+ exports.WorkflowRunEndSchema = exports.EventCommonSchema.extend({
137
+ type: zod_1.z.literal("workflow:run:end"),
138
+ data: zod_1.z.object({
139
+ workflowId: zod_1.z.string(),
140
+ definitionVersion: zod_1.z.string(),
141
+ status: zod_1.z.enum(["success", "error", "truncated"]),
142
+ output: zod_1.z.any().optional(),
143
+ durationMs: zod_1.z.number(),
144
+ }),
145
+ });
146
+ exports.WorkflowRunErrorSchema = exports.EventCommonSchema.extend({
147
+ type: zod_1.z.literal("workflow:run:error"),
148
+ data: zod_1.z.object({
149
+ workflowId: zod_1.z.string(),
150
+ definitionVersion: zod_1.z.string(),
151
+ error: exports.ErrorSchema,
152
+ durationMs: zod_1.z.number().optional(),
153
+ }),
154
+ });
155
+ exports.WorkflowNodeStartSchema = exports.EventCommonSchema.extend({
156
+ type: zod_1.z.literal("workflow:node:start"),
157
+ data: zod_1.z.object({
158
+ workflowId: zod_1.z.string(),
159
+ nodeId: zod_1.z.string(),
160
+ nodeType: zod_1.z.enum(["start", "step", "agent", "branch", "parallel", "finish"]),
161
+ attempt: zod_1.z.number().int().positive().default(1),
162
+ input: zod_1.z.any().optional(),
163
+ }),
164
+ });
165
+ exports.WorkflowNodeEndSchema = exports.EventCommonSchema.extend({
166
+ type: zod_1.z.literal("workflow:node:end"),
167
+ data: zod_1.z.object({
168
+ workflowId: zod_1.z.string(),
169
+ nodeId: zod_1.z.string(),
170
+ nodeType: zod_1.z.enum(["start", "step", "agent", "branch", "parallel", "finish"]),
171
+ attempt: zod_1.z.number().int().positive().default(1),
172
+ status: zod_1.z.enum(["success", "error"]),
173
+ durationMs: zod_1.z.number(),
174
+ output: zod_1.z.any().optional(),
175
+ error: exports.ErrorSchema.optional(),
176
+ }),
177
+ });
178
+ // =============================================================================
179
+ // Tool Execution Events (first-class executions)
180
+ // =============================================================================
181
+ exports.ToolExecutionStartSchema = exports.EventCommonSchema.extend({
182
+ type: zod_1.z.literal("tool:execution:start"),
183
+ data: zod_1.z.object({
184
+ toolId: zod_1.z.string().describe("Stable tool identifier (matches runtimeResourceId)"),
185
+ toolName: zod_1.z.string().describe("Tool name (usually same as toolId)"),
186
+ toolCallId: zod_1.z.string().optional().describe("Underlying LLM tool call id, when applicable"),
187
+ input: zod_1.z.any().optional().describe("Raw tool input"),
188
+ }),
189
+ });
190
+ exports.ToolExecutionEndSchema = exports.EventCommonSchema.extend({
191
+ type: zod_1.z.literal("tool:execution:end"),
192
+ data: zod_1.z.object({
193
+ toolId: zod_1.z.string().describe("Stable tool identifier (matches runtimeResourceId)"),
194
+ toolName: zod_1.z.string().describe("Tool name (usually same as toolId)"),
195
+ toolCallId: zod_1.z.string().optional(),
196
+ status: zod_1.z.enum(["success", "error"]),
197
+ output: zod_1.z.any().optional().describe("Tool output (may be non-JSON)"),
198
+ durationMs: zod_1.z.number(),
199
+ }),
200
+ });
201
+ exports.ToolExecutionErrorSchema = exports.EventCommonSchema.extend({
202
+ type: zod_1.z.literal("tool:execution:error"),
203
+ data: zod_1.z.object({
204
+ toolId: zod_1.z.string().describe("Stable tool identifier (matches runtimeResourceId)"),
205
+ toolName: zod_1.z.string().describe("Tool name (usually same as toolId)"),
206
+ toolCallId: zod_1.z.string().optional(),
207
+ error: exports.ErrorSchema,
208
+ durationMs: zod_1.z.number().optional(),
209
+ }),
210
+ });
211
+ // =============================================================================
212
+ // Execution Cost Events
213
+ // =============================================================================
214
+ exports.ExecutionCostIncurredSchema = exports.EventCommonSchema.extend({
215
+ type: zod_1.z.literal("execution:cost:incurred"),
216
+ data: zod_1.z.object({
217
+ amount: zod_1.z.string(),
218
+ description: zod_1.z.string().optional(),
219
+ source: zod_1.z.string().optional(),
220
+ idempotencyKey: zod_1.z.string().optional(),
221
+ metadata: zod_1.z.record(zod_1.z.any()).optional(),
222
+ }),
223
+ });
224
+ // =============================================================================
225
+ // Discriminated Union
226
+ // =============================================================================
227
+ exports.NebulaEventSchema = zod_1.z.discriminatedUnion("type", [
228
+ exports.AgentExecutionStartSchema,
229
+ exports.AgentExecutionEndSchema,
230
+ exports.AgentExecutionErrorSchema,
231
+ exports.AgentLLMCallSchema,
232
+ exports.AgentLLMResponseSchema,
233
+ exports.AgentToolCallSchema,
234
+ exports.AgentToolResultSchema,
235
+ exports.WorkflowRunStartSchema,
236
+ exports.WorkflowRunEndSchema,
237
+ exports.WorkflowRunErrorSchema,
238
+ exports.WorkflowNodeStartSchema,
239
+ exports.WorkflowNodeEndSchema,
240
+ exports.ToolExecutionStartSchema,
241
+ exports.ToolExecutionEndSchema,
242
+ exports.ToolExecutionErrorSchema,
243
+ exports.ExecutionCostIncurredSchema,
244
+ ]);
@@ -0,0 +1,21 @@
1
+ export interface ExecutionContextState {
2
+ /**
3
+ * Current logical execution id.
4
+ * For top-level runs triggered by Cloud, this is the Cloud Execution.id.
5
+ * For sub-executions, this is a new stable UUID.
6
+ */
7
+ executionId: string;
8
+ /**
9
+ * Root execution id (top-level).
10
+ */
11
+ rootExecutionId: string;
12
+ /**
13
+ * Immediate parent execution id (nullable for root executions).
14
+ */
15
+ parentExecutionId?: string;
16
+ }
17
+ export declare class ExecutionContext {
18
+ static get(): ExecutionContextState | undefined;
19
+ static getOrUndefined(): ExecutionContextState | undefined;
20
+ static run<T>(ctx: ExecutionContextState, fn: () => Promise<T>): Promise<T>;
21
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExecutionContext = void 0;
4
+ const node_async_hooks_1 = require("node:async_hooks");
5
+ const storage = new node_async_hooks_1.AsyncLocalStorage();
6
+ class ExecutionContext {
7
+ static get() {
8
+ return storage.getStore();
9
+ }
10
+ static getOrUndefined() {
11
+ return storage.getStore();
12
+ }
13
+ static run(ctx, fn) {
14
+ return storage.run(ctx, fn);
15
+ }
16
+ }
17
+ exports.ExecutionContext = ExecutionContext;