@versori/run 0.5.10 → 0.7.0-alpha.10

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 (143) hide show
  1. package/esm/deps/jsr.io/@std/fmt/1.0.10/colors.d.ts.map +1 -0
  2. package/esm/deps/jsr.io/@std/fmt/{1.0.9 → 1.0.10}/colors.js +2 -2
  3. package/esm/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
  4. package/esm/src/connection/internal/CredentialHolder.js +1 -1
  5. package/esm/src/connection/internal/FetchBuilder.d.ts +9 -2
  6. package/esm/src/connection/internal/FetchBuilder.d.ts.map +1 -1
  7. package/esm/src/connection/internal/FetchBuilder.js +124 -3
  8. package/esm/src/context/Context.d.ts +5 -0
  9. package/esm/src/context/Context.d.ts.map +1 -1
  10. package/esm/src/context/Context.js +6 -0
  11. package/esm/src/dsl/Workflow.d.ts.map +1 -1
  12. package/esm/src/dsl/Workflow.js +2 -0
  13. package/esm/src/dsl/http/types.d.ts +2 -0
  14. package/esm/src/dsl/http/types.d.ts.map +1 -1
  15. package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
  16. package/esm/src/dsl/http/versori/configloader.js +1 -1
  17. package/esm/src/dsl/http/versori/cronapi.d.ts +2 -3
  18. package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -1
  19. package/esm/src/dsl/http/versori/cronapi.js +14 -15
  20. package/esm/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
  21. package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
  22. package/esm/src/dsl/triggers/WebhookTrigger.js +3 -1
  23. package/esm/src/internal/constants.d.ts +3 -0
  24. package/esm/src/internal/constants.d.ts.map +1 -1
  25. package/esm/src/internal/constants.js +3 -0
  26. package/esm/src/internal/supervisor.d.ts +23 -0
  27. package/esm/src/internal/supervisor.d.ts.map +1 -0
  28. package/esm/src/internal/supervisor.js +267 -0
  29. package/esm/src/interpreter/durable/DurableInterpreter.d.ts +10 -3
  30. package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
  31. package/esm/src/interpreter/durable/DurableInterpreter.js +65 -13
  32. package/esm/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
  33. package/esm/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
  34. package/esm/src/interpreter/durable/Queue.js +1 -1
  35. package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
  36. package/esm/src/interpreter/durable/compilers/catch.js +3 -1
  37. package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
  38. package/esm/src/interpreter/durable/compilers/fn.js +29 -6
  39. package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -1
  40. package/esm/src/interpreter/durable/compilers/http.js +45 -11
  41. package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
  42. package/esm/src/interpreter/durable/compilers/schedule.js +4 -3
  43. package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
  44. package/esm/src/interpreter/durable/compilers/webhook.js +2 -0
  45. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +8 -1
  46. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  47. package/esm/src/interpreter/memory/MemoryInterpreter.js +56 -12
  48. package/esm/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
  49. package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
  50. package/esm/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
  51. package/esm/src/interpreter/memory/compilers/catch.js +5 -0
  52. package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
  53. package/esm/src/interpreter/memory/compilers/fn.js +29 -18
  54. package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
  55. package/esm/src/interpreter/memory/compilers/http.js +44 -10
  56. package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  57. package/esm/src/interpreter/memory/compilers/schedule.js +61 -4
  58. package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  59. package/esm/src/interpreter/memory/compilers/webhook.js +9 -3
  60. package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts +2 -1
  61. package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -1
  62. package/esm/src/interpreter/vanilla/VanillaInterpreter.js +41 -9
  63. package/esm/src/interpreter/vanilla/compilers/schedule.js +1 -1
  64. package/esm/src/issues/Issues.d.ts.map +1 -1
  65. package/esm/src/issues/Issues.js +6 -1
  66. package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
  67. package/package.json +3 -1
  68. package/script/deps/jsr.io/@std/fmt/1.0.10/colors.d.ts.map +1 -0
  69. package/script/deps/jsr.io/@std/fmt/{1.0.9 → 1.0.10}/colors.js +2 -2
  70. package/script/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
  71. package/script/src/connection/internal/CredentialHolder.js +1 -1
  72. package/script/src/connection/internal/FetchBuilder.d.ts +9 -2
  73. package/script/src/connection/internal/FetchBuilder.d.ts.map +1 -1
  74. package/script/src/connection/internal/FetchBuilder.js +147 -3
  75. package/script/src/context/Context.d.ts +5 -0
  76. package/script/src/context/Context.d.ts.map +1 -1
  77. package/script/src/context/Context.js +6 -0
  78. package/script/src/dsl/Workflow.d.ts.map +1 -1
  79. package/script/src/dsl/Workflow.js +2 -0
  80. package/script/src/dsl/http/types.d.ts +2 -0
  81. package/script/src/dsl/http/types.d.ts.map +1 -1
  82. package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
  83. package/script/src/dsl/http/versori/configloader.js +1 -1
  84. package/script/src/dsl/http/versori/cronapi.d.ts +2 -3
  85. package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -1
  86. package/script/src/dsl/http/versori/cronapi.js +14 -15
  87. package/script/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
  88. package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
  89. package/script/src/dsl/triggers/WebhookTrigger.js +3 -1
  90. package/script/src/internal/constants.d.ts +3 -0
  91. package/script/src/internal/constants.d.ts.map +1 -1
  92. package/script/src/internal/constants.js +4 -1
  93. package/script/src/internal/supervisor.d.ts +23 -0
  94. package/script/src/internal/supervisor.d.ts.map +1 -0
  95. package/script/src/internal/supervisor.js +275 -0
  96. package/script/src/interpreter/durable/DurableInterpreter.d.ts +10 -3
  97. package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
  98. package/script/src/interpreter/durable/DurableInterpreter.js +70 -18
  99. package/script/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
  100. package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
  101. package/script/src/interpreter/durable/Queue.js +1 -1
  102. package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
  103. package/script/src/interpreter/durable/compilers/catch.js +3 -1
  104. package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
  105. package/script/src/interpreter/durable/compilers/fn.js +28 -5
  106. package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -1
  107. package/script/src/interpreter/durable/compilers/http.js +45 -11
  108. package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
  109. package/script/src/interpreter/durable/compilers/schedule.js +4 -3
  110. package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
  111. package/script/src/interpreter/durable/compilers/webhook.js +2 -0
  112. package/script/src/interpreter/memory/MemoryInterpreter.d.ts +8 -1
  113. package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  114. package/script/src/interpreter/memory/MemoryInterpreter.js +55 -11
  115. package/script/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
  116. package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
  117. package/script/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
  118. package/script/src/interpreter/memory/compilers/catch.js +5 -0
  119. package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
  120. package/script/src/interpreter/memory/compilers/fn.js +28 -17
  121. package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
  122. package/script/src/interpreter/memory/compilers/http.js +44 -10
  123. package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  124. package/script/src/interpreter/memory/compilers/schedule.js +61 -4
  125. package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  126. package/script/src/interpreter/memory/compilers/webhook.js +9 -3
  127. package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts +2 -1
  128. package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -1
  129. package/script/src/interpreter/vanilla/VanillaInterpreter.js +41 -9
  130. package/script/src/interpreter/vanilla/compilers/schedule.js +1 -1
  131. package/script/src/issues/Issues.d.ts.map +1 -1
  132. package/script/src/issues/Issues.js +6 -1
  133. package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
  134. package/esm/deps/jsr.io/@std/fmt/1.0.9/colors.d.ts.map +0 -1
  135. package/esm/src/dsl/http/versori/constants.d.ts +0 -21
  136. package/esm/src/dsl/http/versori/constants.d.ts.map +0 -1
  137. package/esm/src/dsl/http/versori/constants.js +0 -38
  138. package/script/deps/jsr.io/@std/fmt/1.0.9/colors.d.ts.map +0 -1
  139. package/script/src/dsl/http/versori/constants.d.ts +0 -21
  140. package/script/src/dsl/http/versori/constants.d.ts.map +0 -1
  141. package/script/src/dsl/http/versori/constants.js +0 -41
  142. /package/esm/deps/jsr.io/@std/fmt/{1.0.9 → 1.0.10}/colors.d.ts +0 -0
  143. /package/script/deps/jsr.io/@std/fmt/{1.0.9 → 1.0.10}/colors.d.ts +0 -0
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Versori Group Inc
4
+ *
5
+ * Use of this software is governed by the Business Source License 1.1
6
+ * included in the LICENSE file at the root of this repository.
7
+ *
8
+ * Change Date: 2029-01-01
9
+ * Change License: Apache License, Version 2.0
10
+ *
11
+ * As of the Change Date, in accordance with the Business Source License,
12
+ * use of this software will be governed by the Apache License, Version 2.0.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Fake = exports.enabled = void 0;
16
+ exports.signalReady = signalReady;
17
+ exports.registerWorkflow = registerWorkflow;
18
+ exports.sendTaskStartEvent = sendTaskStartEvent;
19
+ exports.mockAPIRequest = mockAPIRequest;
20
+ const core_1 = require("@opentelemetry/core");
21
+ const ConsoleLogger_js_1 = require("../observability/logging/ConsoleLogger.js");
22
+ const ChainTask_js_1 = require("../dsl/tasks/ChainTask.js");
23
+ const ScheduleTrigger_js_1 = require("../dsl/triggers/ScheduleTrigger.js");
24
+ const WebhookTrigger_js_1 = require("../dsl/triggers/WebhookTrigger.js");
25
+ const DurableTrigger_js_1 = require("../dsl/triggers/DurableTrigger.js");
26
+ const Task_js_1 = require("../dsl/Task.js");
27
+ const CatchTask_js_1 = require("../dsl/tasks/CatchTask.js");
28
+ const FnTask_js_1 = require("../dsl/tasks/FnTask.js");
29
+ const HttpTask_js_1 = require("../dsl/tasks/HttpTask.js");
30
+ const BackgroundTask_js_1 = require("../dsl/tasks/BackgroundTask.js");
31
+ const ParallelTask_js_1 = require("../dsl/tasks/ParallelTask.js");
32
+ const supervisorURL = (function () {
33
+ return Deno.env.get('RUN_SUPERVISOR_URL') || '';
34
+ })();
35
+ exports.enabled = (function () {
36
+ return Deno.env.get('RUN_SUPERVISOR_URL') ? true : false;
37
+ })();
38
+ const flows = (function () {
39
+ try {
40
+ const _cwd = Deno.cwd();
41
+ const flowsFile = Deno.readTextFileSync(_cwd + '/versori-flow.json');
42
+ const flows = JSON.parse(flowsFile);
43
+ const nodes = {};
44
+ for (const node of flows.nodes) {
45
+ nodes[node.id] = {
46
+ description: node?.data?.description,
47
+ steps: node?.data?.steps,
48
+ files: node?.data?.files[0],
49
+ };
50
+ }
51
+ return nodes;
52
+ }
53
+ catch {
54
+ return {};
55
+ }
56
+ })();
57
+ const logger = new ConsoleLogger_js_1.ConsoleLogger('debug');
58
+ function getTriggerData(workflow) {
59
+ if (workflow.trigger instanceof WebhookTrigger_js_1.WebhookTrigger) {
60
+ return {
61
+ id: workflow.trigger.id,
62
+ type: 'webhook',
63
+ method: workflow.trigger.options.method || 'post',
64
+ };
65
+ }
66
+ else if (workflow.trigger instanceof ScheduleTrigger_js_1.ScheduleTrigger) {
67
+ return {
68
+ id: workflow.trigger.id,
69
+ type: 'schedule',
70
+ schedule: workflow.trigger.schedule,
71
+ };
72
+ }
73
+ else if (workflow.trigger instanceof DurableTrigger_js_1.DurableWorkflowTrigger) {
74
+ return {
75
+ id: workflow.trigger.id,
76
+ type: 'durable',
77
+ };
78
+ }
79
+ return null;
80
+ }
81
+ function getTaskData(task) {
82
+ let taskData = [];
83
+ if (task instanceof ChainTask_js_1.ChainTask) {
84
+ taskData = task.tasks.map((t) => getTaskData(t)).flat();
85
+ }
86
+ else if (task instanceof CatchTask_js_1.CatchTask) {
87
+ taskData = [...getTaskData(task._base), ...getTaskData(task._errorHandler)];
88
+ }
89
+ else if (task instanceof BackgroundTask_js_1.BackgroundTask) {
90
+ taskData = getTaskData(task._base);
91
+ }
92
+ else if (task instanceof ParallelTask_js_1.ParallelTask) {
93
+ // I'm not sure if this is correct, but I don't think there are any ParallelTasks out in the wild yet
94
+ taskData = [...getTaskData(task._base), ...getTaskData(task._each)];
95
+ }
96
+ else if (task instanceof FnTask_js_1.FnTask) {
97
+ taskData.push({
98
+ taskId: task.id,
99
+ type: task[Task_js_1.TaskType].toLowerCase(),
100
+ });
101
+ }
102
+ else if (task instanceof HttpTask_js_1.HttpTaskImpl) {
103
+ taskData.push({
104
+ taskId: task.id,
105
+ type: task[Task_js_1.TaskType].toLowerCase(),
106
+ });
107
+ }
108
+ else {
109
+ // yolo
110
+ taskData.push({
111
+ taskId: String(task.id || 'unknown'),
112
+ type: task[Task_js_1.TaskType].toLowerCase(),
113
+ });
114
+ }
115
+ return taskData;
116
+ }
117
+ async function signalReady() {
118
+ if (!exports.enabled) {
119
+ return;
120
+ }
121
+ try {
122
+ await fetch(`${supervisorURL}/ready`, {
123
+ method: 'POST',
124
+ });
125
+ }
126
+ catch (err) {
127
+ logger.error('Failed to signal ready to supervisor', { error: err });
128
+ }
129
+ }
130
+ async function registerWorkflow(workflow) {
131
+ if (!exports.enabled) {
132
+ return;
133
+ }
134
+ const triggerData = getTriggerData(workflow);
135
+ const tasks = getTaskData(workflow.task);
136
+ try {
137
+ if (triggerData) {
138
+ const data = {
139
+ workflowId: triggerData.id,
140
+ trigger: triggerData,
141
+ tasks,
142
+ };
143
+ await fetch(`${supervisorURL}/register-workflow`, {
144
+ method: 'POST',
145
+ body: JSON.stringify(data),
146
+ headers: {
147
+ 'Content-Type': 'application/json',
148
+ },
149
+ });
150
+ }
151
+ }
152
+ catch (err) {
153
+ logger.error('Failed to register workflow with supervisor', { error: err });
154
+ }
155
+ }
156
+ async function sendTaskStartEvent(taskId, ctx, span) {
157
+ if (!exports.enabled) {
158
+ return ctx;
159
+ }
160
+ const data = {
161
+ taskId,
162
+ spanId: span.spanContext().spanId,
163
+ traceId: span.spanContext().traceId,
164
+ startTime: new Date().toISOString(), // assuming current time as start time
165
+ executionId: ctx.executionId,
166
+ workflowId: ctx.workflowId || '',
167
+ };
168
+ try {
169
+ const resp = await fetch(`${supervisorURL}/tasks/start`, {
170
+ method: 'POST',
171
+ body: JSON.stringify(data),
172
+ headers: {
173
+ 'Content-Type': 'application/json',
174
+ },
175
+ });
176
+ if (resp.ok) {
177
+ const bodyString = await resp.text();
178
+ if (!bodyString) {
179
+ return ctx;
180
+ }
181
+ // TODO: XML, CSV yada yada
182
+ const respData = JSON.parse(bodyString);
183
+ return ctx.withData(respData);
184
+ }
185
+ }
186
+ catch (err) {
187
+ logger.error('Failed to send task start event to supervisor', { error: err });
188
+ }
189
+ return ctx;
190
+ }
191
+ async function mockAPIRequest(info, cnx, options) {
192
+ if (!exports.enabled) {
193
+ return new Response();
194
+ }
195
+ const mockRequest = {
196
+ url: info.toString(),
197
+ payload: options?.body || '',
198
+ method: options?.method || 'GET',
199
+ headers: options?.headers,
200
+ connection: cnx?.name,
201
+ connectionId: cnx?.id,
202
+ };
203
+ try {
204
+ const response = await fetch(`${supervisorURL}/ai/fake-fetch-call`, {
205
+ method: 'POST',
206
+ body: JSON.stringify(mockRequest),
207
+ headers: {
208
+ 'Content-Type': 'application/json',
209
+ },
210
+ });
211
+ if (!response.ok) {
212
+ logger.error('Failed to mock api request', { response });
213
+ return new Response();
214
+ }
215
+ const text = await response.text();
216
+ return new Response(text);
217
+ }
218
+ catch (err) {
219
+ logger.error('Failed to mock api request', { error: err });
220
+ return new Response();
221
+ }
222
+ }
223
+ function printableSpan(s) {
224
+ const span = {
225
+ name: s.name,
226
+ startTime: (0, core_1.hrTimeToTimeStamp)(s.startTime),
227
+ endTime: (0, core_1.hrTimeToTimeStamp)(s.endTime),
228
+ duration: (0, core_1.hrTimeToMilliseconds)(s.duration),
229
+ attributes: s.attributes,
230
+ status: s.status,
231
+ ended: s.ended,
232
+ events: s.events,
233
+ parentSpanContext: s.parentSpanContext,
234
+ spanContext: s.spanContext(),
235
+ };
236
+ const nodeDetail = flows[span.attributes['task.id']]; // I know I have coded all of those as string
237
+ if (nodeDetail) {
238
+ span.attributes['description'] = nodeDetail?.description || '';
239
+ span.attributes['steps'] = nodeDetail?.steps || '';
240
+ span.attributes['files'] = nodeDetail?.files || '';
241
+ }
242
+ return span;
243
+ }
244
+ class Fake {
245
+ constructor() {
246
+ this.export = this.export.bind(this);
247
+ this.shutdown = this.shutdown.bind(this);
248
+ this.forceFlush = this.forceFlush.bind(this);
249
+ }
250
+ export(spans, resultCallback) {
251
+ const ss = spans.map(printableSpan);
252
+ try {
253
+ fetch(`${supervisorURL}/receive-spans`, {
254
+ method: 'POST',
255
+ body: JSON.stringify({ spans: ss }),
256
+ headers: {
257
+ 'Content-Type': 'application/json',
258
+ },
259
+ }).catch((err) => {
260
+ logger.error('Failed to send spans to supervisor', { error: err });
261
+ });
262
+ }
263
+ catch (err) {
264
+ logger.error('Failed to send spans to supervisor', { error: err });
265
+ }
266
+ resultCallback({ code: core_1.ExportResultCode.SUCCESS });
267
+ }
268
+ shutdown() {
269
+ return Promise.resolve();
270
+ }
271
+ forceFlush() {
272
+ return Promise.resolve();
273
+ }
274
+ }
275
+ exports.Fake = Fake;
@@ -46,6 +46,11 @@ type Registration = {
46
46
  sigintListener: () => void;
47
47
  subscription?: Subscription;
48
48
  };
49
+ type WebhookRegistry = Map<string, {
50
+ method: string;
51
+ path: string;
52
+ options: any;
53
+ }>;
49
54
  /**
50
55
  * DurableInterpreter is an interpreter for executing Versori workflows with support for durable, queue-based workflow
51
56
  * execution. It supports all trigger types including the {@link workflow} trigger which allows workflows to be started
@@ -76,7 +81,8 @@ export declare class DurableInterpreter {
76
81
  private readonly contextProvider;
77
82
  private readonly webhookRouter;
78
83
  private readonly cronRouter;
79
- private readonly cronRegistry;
84
+ private cronRegistry;
85
+ private webhookRegistry;
80
86
  private readonly platformApi;
81
87
  private readonly cnxFetchFactory;
82
88
  private readonly cronProvider;
@@ -90,9 +96,10 @@ export declare class DurableInterpreter {
90
96
  private cronServer?;
91
97
  private shutdownServer?;
92
98
  private isShuttingDown;
93
- constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, platformApi: PlatformApi, cnxFetchFactory: DirectConnectionFactory, cronProvider: CronProvider, tracer: Tracer, issue: IssueAPI, cfgReader: ConfigReader, queueProvider: QueueAPI, otelSDK?: NodeSDK | undefined);
99
+ private wfRegistration;
100
+ constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, webhookRegistry: WebhookRegistry, platformApi: PlatformApi, cnxFetchFactory: DirectConnectionFactory, cronProvider: CronProvider, tracer: Tracer, issue: IssueAPI, cfgReader: ConfigReader, queueProvider: QueueAPI, otelSDK?: NodeSDK | undefined);
94
101
  static newInstance(options?: DurableInterpreterOptions): Promise<DurableInterpreter>;
95
- register<O>(workflow: Workflow<O>, options?: DurableInterpreterOptions): Registration;
102
+ register<O>(workflow: Workflow<O>, options?: DurableInterpreterOptions): Registration | void;
96
103
  start(): Promise<void>;
97
104
  stop(): Promise<void>;
98
105
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DurableInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/DurableInterpreter.ts"],"names":[],"mappings":"AAaA,OAAsB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,MAAM,MAAM,CAAC;AAEtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAarE,OAAO,EAAE,QAAQ,EAAgB,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAa,MAAM,wBAAwB,CAAC;AAK7D,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAmB,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAA0B,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAa,MAAM,YAAY,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACpC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAE9B;;OAEG;IAC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AAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,YAAY,GAAG,IAAI;IAuEtF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAkO5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CASxB"}
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DurableInterpreter = void 0;
2
7
  /*
3
8
  * Copyright (c) 2025 Versori Group Inc
4
9
  *
@@ -11,11 +16,6 @@
11
16
  * As of the Change Date, in accordance with the Business Source License,
12
17
  * use of this software will be governed by the Apache License, Version 2.0.
13
18
  */
14
- var __importDefault = (this && this.__importDefault) || function (mod) {
15
- return (mod && mod.__esModule) ? mod : { "default": mod };
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.DurableInterpreter = void 0;
19
19
  const api_1 = __importDefault(require("@opentelemetry/api"));
20
20
  const exporter_trace_otlp_proto_1 = require("@opentelemetry/exporter-trace-otlp-proto");
21
21
  const resources_1 = require("@opentelemetry/resources");
@@ -26,9 +26,11 @@ const CredentialsProvider_js_1 = require("../../connection/CredentialsProvider.j
26
26
  const DirectConnectionFactory_js_1 = require("../../connection/DirectConnectionFactory.js");
27
27
  const ContextProvider_js_1 = require("../../context/ContextProvider.js");
28
28
  const configloader_js_1 = require("../../dsl/http/versori/configloader.js");
29
- const constants_js_1 = require("../../dsl/http/versori/constants.js");
30
29
  const cronapi_js_1 = require("../../dsl/http/versori/cronapi.js");
30
+ const DurableTrigger_js_1 = require("../../dsl/triggers/DurableTrigger.js");
31
31
  const Workflow_js_1 = require("../../dsl/Workflow.js");
32
+ const constants_js_1 = require("../../internal/constants.js");
33
+ const supervisor_js_1 = require("../../internal/supervisor.js");
32
34
  const Issues_js_1 = require("../../issues/Issues.js");
33
35
  const MemoryKeyValueProvider_js_1 = require("../../kv/memory/MemoryKeyValueProvider.js");
34
36
  const SDKKeyValueProvider_js_1 = require("../../kv/sdk/SDKKeyValueProvider.js");
@@ -36,8 +38,8 @@ const ConsoleLogger_js_1 = require("../../observability/logging/ConsoleLogger.js
36
38
  const PlatformApi_js_1 = require("../../services/platform/PlatformApi.js");
37
39
  const ObservableCompiler_js_1 = require("./ObservableCompiler.js");
38
40
  const Queue_js_1 = require("./Queue.js");
39
- function getKVProvider(runLocal) {
40
- if (runLocal) {
41
+ function getKVProvider() {
42
+ if (supervisor_js_1.enabled) {
41
43
  return Promise.resolve(new MemoryKeyValueProvider_js_1.MemoryKeyValueProvider());
42
44
  }
43
45
  return SDKKeyValueProvider_js_1.SDKKeyValueProvider.fromEnv();
@@ -67,7 +69,7 @@ function getKVProvider(runLocal) {
67
69
  * ```
68
70
  */
69
71
  class DurableInterpreter {
70
- constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, platformApi, cnxFetchFactory, cronProvider, tracer, issue, cfgReader, queueProvider, otelSDK) {
72
+ constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, webhookRegistry, platformApi, cnxFetchFactory, cronProvider, tracer, issue, cfgReader, queueProvider, otelSDK) {
71
73
  Object.defineProperty(this, "log", {
72
74
  enumerable: true,
73
75
  configurable: true,
@@ -104,6 +106,12 @@ class DurableInterpreter {
104
106
  writable: true,
105
107
  value: cronRegistry
106
108
  });
109
+ Object.defineProperty(this, "webhookRegistry", {
110
+ enumerable: true,
111
+ configurable: true,
112
+ writable: true,
113
+ value: webhookRegistry
114
+ });
107
115
  Object.defineProperty(this, "platformApi", {
108
116
  enumerable: true,
109
117
  configurable: true,
@@ -182,6 +190,13 @@ class DurableInterpreter {
182
190
  writable: true,
183
191
  value: false
184
192
  });
193
+ // Workflow registration promises only used when supervisor is enabled
194
+ Object.defineProperty(this, "wfRegistration", {
195
+ enumerable: true,
196
+ configurable: true,
197
+ writable: true,
198
+ value: []
199
+ });
185
200
  if (typeof this.log === 'undefined') {
186
201
  // this captures the old way of instantiating the DurableInterpreter and provides an
187
202
  // error message back to the user to let them know they should use the new way.
@@ -200,7 +215,6 @@ class DurableInterpreter {
200
215
  const otelTracesURL = Deno.env.get(constants_js_1.envVarOtelTracesURL);
201
216
  let otelSDK;
202
217
  const configReader = configloader_js_1.VersoriConfigReader.fromEnv(log);
203
- const runLocal = Deno.env.get(constants_js_1.envVarLocalRun) === 'true';
204
218
  await waitForReady(log);
205
219
  // Do NOT change those attributes, they are used by the API to filter on
206
220
  const resource = (0, resources_1.resourceFromAttributes)({
@@ -222,6 +236,15 @@ class DurableInterpreter {
222
236
  log.info('Starting OpenTelemetry SDK');
223
237
  otelSDK.start();
224
238
  }
239
+ else if (supervisor_js_1.enabled) {
240
+ otelSDK = new sdk_node_1.NodeSDK({
241
+ traceExporter: new supervisor_js_1.Fake(),
242
+ serviceName: serviceName,
243
+ resource: resource,
244
+ });
245
+ log.info('Starting Testing OpenTelemetry SDK');
246
+ otelSDK.start();
247
+ }
225
248
  const tracer = api_1.default.trace.getTracer(serviceName, version);
226
249
  const queueProvider = await Queue_js_1.QueueImpl.fromEnv(log);
227
250
  const connectionFactory = DirectConnectionFactory_js_1.DirectConnectionFactory.fromEnv(log);
@@ -229,14 +252,14 @@ class DurableInterpreter {
229
252
  if (options.contextProvider) {
230
253
  // no need to set up a key-value provider if options.contextProvider is already
231
254
  // initialised.
232
- return new DurableInterpreter(log, compiler, options.contextProvider, express_1.default.Router(), express_1.default.Router(), new Map(), PlatformApi_js_1.PlatformApiImpl.fromEnv(), connectionFactory, cronapi_js_1.CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, queueProvider, otelSDK);
255
+ return new DurableInterpreter(log, compiler, options.contextProvider, express_1.default.Router(), express_1.default.Router(), new Map(), new Map(), PlatformApi_js_1.PlatformApiImpl.fromEnv(), connectionFactory, cronapi_js_1.CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, queueProvider, otelSDK);
233
256
  }
234
- const kvp = await getKVProvider(runLocal);
257
+ const kvp = await getKVProvider();
235
258
  const platformApi = PlatformApi_js_1.PlatformApiImpl.fromEnv();
236
259
  const organisationId = Deno.env.get(constants_js_1.envVarOrgId) || 'development';
237
260
  const environmentId = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
238
261
  const ctxProvider = new ContextProvider_js_1.ContextProviderImpl(log, kvp, new CredentialsProvider_js_1.CredentialsProviderImpl(connectionFactory.credentials, connectionFactory.tokens, connectionFactory.oauth1, configReader, platformApi), platformApi, organisationId, environmentId, issuesProvider, queueProvider);
239
- return new DurableInterpreter(log, compiler, ctxProvider, express_1.default.Router(), express_1.default.Router(), new Map(), PlatformApi_js_1.PlatformApiImpl.fromEnv(), connectionFactory, cronapi_js_1.CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, queueProvider, otelSDK);
262
+ return new DurableInterpreter(log, compiler, ctxProvider, express_1.default.Router(), express_1.default.Router(), new Map(), new Map(), PlatformApi_js_1.PlatformApiImpl.fromEnv(), connectionFactory, cronapi_js_1.CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, queueProvider, otelSDK);
240
263
  }
241
264
  register(workflow, options) {
242
265
  const localAbortController = new AbortController();
@@ -249,6 +272,13 @@ class DurableInterpreter {
249
272
  const triggerName = 'id' in workflow.trigger && typeof workflow.trigger.id === 'string'
250
273
  ? workflow.trigger.id
251
274
  : workflow.trigger.constructor.name;
275
+ if (supervisor_js_1.enabled && workflow.trigger instanceof DurableTrigger_js_1.DurableWorkflowTrigger) {
276
+ this.log.info('Skipping durable workflow trigger registration (supervisor mode)', {
277
+ triggerName,
278
+ });
279
+ this.wfRegistration.push((0, supervisor_js_1.registerWorkflow)(workflow));
280
+ return;
281
+ }
252
282
  this.log.info('DurableInterpreter.register', { workflow, triggerName });
253
283
  const compilerContext = {
254
284
  compiler: this.compiler,
@@ -256,6 +286,7 @@ class DurableInterpreter {
256
286
  tracer: this.tracer,
257
287
  contextProvider: this.contextProvider,
258
288
  webhookRouter: this.webhookRouter,
289
+ webhookRegistry: this.webhookRegistry,
259
290
  queueProvider: this.queueProvider,
260
291
  cronRouter: this.cronRouter,
261
292
  cronRegistry: this.cronRegistry,
@@ -278,11 +309,14 @@ class DurableInterpreter {
278
309
  },
279
310
  };
280
311
  this.registeredWorkflows.push(registration);
312
+ if (supervisor_js_1.enabled) {
313
+ this.wfRegistration.push((0, supervisor_js_1.registerWorkflow)(workflow));
314
+ }
281
315
  return registration;
282
316
  }
283
- start() {
284
- const port = Deno.env.get('PORT') || 3000;
285
- const cronPort = Deno.env.get('CRON_PORT') || 3001;
317
+ async start() {
318
+ const port = Deno.env.get(constants_js_1.envPort) || 3000;
319
+ const cronPort = Deno.env.get(constants_js_1.envCronPort) || 3001;
286
320
  const webhookApp = (0, express_1.default)();
287
321
  const cronApp = (0, express_1.default)();
288
322
  cronApp.use(express_1.default.json());
@@ -309,11 +343,18 @@ class DurableInterpreter {
309
343
  triggerName: registration.triggerName,
310
344
  error: err instanceof Error ? err.toString() : err,
311
345
  });
346
+ this.tracer.startActiveSpan('done', (span) => {
347
+ span.setAttribute('error.message', err instanceof Error ? err.toString() : err);
348
+ span.setAttribute('execution.id', ctx.executionId);
349
+ span.setAttribute('result', 'fail');
350
+ span.setAttribute('workflow.id', ctx.workflowId || 'unknown-workflow');
351
+ span.end();
352
+ });
312
353
  try {
313
354
  ctx.options.onError?.(ctx.withData(err));
314
355
  }
315
356
  catch (err) {
316
- ctx.log.error('DurableInterpreter.onErrorError: failed to call onError handler', {
357
+ ctx.log.error('DurableInterpreter.onError: failed to call onError handler', {
317
358
  triggerName: registration.triggerName,
318
359
  error: err instanceof Error ? err.toString() : err,
319
360
  });
@@ -331,6 +372,12 @@ class DurableInterpreter {
331
372
  triggerName: registration.triggerName,
332
373
  durationMs,
333
374
  });
375
+ this.tracer.startActiveSpan('done', (span) => {
376
+ span.setAttribute('execution.id', ctx.executionId);
377
+ span.setAttribute('result', 'pass');
378
+ span.setAttribute('workflow.id', ctx.workflowId || 'unknown-workflow');
379
+ span.end();
380
+ });
334
381
  try {
335
382
  ctx.options.onSuccess?.(ctx);
336
383
  }
@@ -392,6 +439,7 @@ class DurableInterpreter {
392
439
  if (this.cronServer) {
393
440
  this.cronServer.close();
394
441
  }
442
+ this.otelSDK?.shutdown();
395
443
  // Remove all signal listeners
396
444
  for (const registration of this.registeredWorkflows) {
397
445
  Deno.removeSignalListener('SIGINT', registration.sigintListener);
@@ -408,6 +456,10 @@ class DurableInterpreter {
408
456
  }
409
457
  };
410
458
  Deno.addSignalListener('SIGINT', this.shutdownServer);
459
+ if (supervisor_js_1.enabled) {
460
+ await Promise.all(this.wfRegistration);
461
+ await (0, supervisor_js_1.signalReady)();
462
+ }
411
463
  return new Promise((resolve) => {
412
464
  let serversClosed = 0;
413
465
  const totalServers = [this.webhookServer, this.cronServer].filter(Boolean).length;
@@ -445,7 +497,7 @@ class DurableInterpreter {
445
497
  }
446
498
  exports.DurableInterpreter = DurableInterpreter;
447
499
  async function waitForReady(log) {
448
- const readyCheckUrl = Deno.env.get('READY_CHECK_URL');
500
+ const readyCheckUrl = Deno.env.get(constants_js_1.envReadyCheckURL);
449
501
  if (!readyCheckUrl) {
450
502
  return Promise.resolve();
451
503
  }
@@ -1,6 +1,7 @@
1
1
  import { Tracer } from '@opentelemetry/api';
2
2
  import { Router } from 'express';
3
3
  import { Observable, OperatorFunction } from 'rxjs';
4
+ import { ConnectionFactory } from '../../connection/types.js';
4
5
  import { ContextImpl } from '../../context/Context.js';
5
6
  import { ContextProvider } from '../../context/ContextProvider.js';
6
7
  import { ConfigReader } from '../../dsl/http/types.js';
@@ -11,7 +12,6 @@ import { Logger } from '../../observability/logging/Logger.js';
11
12
  import { PlatformApi } from '../../services/platform/mod.js';
12
13
  import { ContextOperatorFunction, TaskCompiler, TriggerCompiler } from './compilers/types.js';
13
14
  import { QueueAPI } from './Queue.js';
14
- import { ConnectionFactory } from '../../connection/types.js';
15
15
  export type DurableCompilerContext = {
16
16
  compiler: ObservableCompiler;
17
17
  log: Logger;
@@ -22,6 +22,11 @@ export type DurableCompilerContext = {
22
22
  queueProvider: QueueAPI;
23
23
  issueProvider: IssueAPI;
24
24
  webhookRouter: Router;
25
+ webhookRegistry: Map<string, {
26
+ method: string;
27
+ path: string;
28
+ options: any;
29
+ }>;
25
30
  cronRouter: Router;
26
31
  configReader: ConfigReader;
27
32
  cronRegistry: Map<string, string>;
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableCompiler.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/ObservableCompiler.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAY,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAe,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAU7D,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG9F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,MAAM,sBAAsB,GAAG;IACjC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,GAA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GAAG,CAAC,EAC3D,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAerC,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,SAAS,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAKjF,eAAe,CAAC,GAAG,EAAE,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,eAAe,CAAC,GAAG,EAAE,CAAC,CAAC;CAIjF"}
@@ -13,7 +13,7 @@
13
13
  */
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.MockQueue = exports.QueueImpl = void 0;
16
- const constants_js_1 = require("../../dsl/http/versori/constants.js");
16
+ const constants_js_1 = require("../../internal/constants.js");
17
17
  const mod_js_1 = require("../../mod.js");
18
18
  class QueueImpl {
19
19
  constructor(baseUrl, projectId, environmentId, log) {
@@ -1 +1 @@
1
- {"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/catch.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAuFnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
1
+ {"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/catch.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAyFnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
@@ -25,7 +25,9 @@ function compileCatch(compilerCtx, task) {
25
25
  return compilerCtx.tracer.startActiveSpan(`catch`, (span) => {
26
26
  span.setAttribute('execution.id', ctx.executionId);
27
27
  span.setAttribute('task.type', 'catch');
28
+ span.setAttribute('type', 'task');
28
29
  if (error instanceof Error) {
30
+ span.setAttribute('status', 'fail');
29
31
  span.recordException(error);
30
32
  span.setAttribute('error.message', error.message);
31
33
  span.setAttribute('error.stack', error.stack ?? '');
@@ -63,7 +65,7 @@ function compileCatch(compilerCtx, task) {
63
65
  reason: 'error',
64
66
  severity: 'low',
65
67
  });
66
- span.setAttribute('error', `${error}`);
68
+ span.setAttribute('status', 'fail');
67
69
  span.end();
68
70
  return errorOperator((0, rxjs_1.of)(ctx.withData(new ExecutionError_js_1.ExecutionError(ctx, `${error}`, { cause: error }), { recoveredFromCatch: true })));
69
71
  });
@@ -1 +1 @@
1
- {"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/fn.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAiCnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
1
+ {"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/fn.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAoDnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}