@versori/run 0.5.9 → 0.6.0-alpha.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 (133) hide show
  1. package/esm/src/connection/internal/CredentialHolder.js +1 -1
  2. package/esm/src/connection/internal/FetchBuilder.d.ts +9 -2
  3. package/esm/src/connection/internal/FetchBuilder.d.ts.map +1 -1
  4. package/esm/src/connection/internal/FetchBuilder.js +124 -3
  5. package/esm/src/context/Context.d.ts +5 -0
  6. package/esm/src/context/Context.d.ts.map +1 -1
  7. package/esm/src/context/Context.js +6 -0
  8. package/esm/src/dsl/Workflow.d.ts.map +1 -1
  9. package/esm/src/dsl/Workflow.js +2 -0
  10. package/esm/src/dsl/http/types.d.ts +2 -0
  11. package/esm/src/dsl/http/types.d.ts.map +1 -1
  12. package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
  13. package/esm/src/dsl/http/versori/configloader.js +1 -1
  14. package/esm/src/dsl/http/versori/cronapi.d.ts +2 -3
  15. package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -1
  16. package/esm/src/dsl/http/versori/cronapi.js +14 -15
  17. package/esm/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
  18. package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
  19. package/esm/src/dsl/triggers/WebhookTrigger.js +3 -1
  20. package/esm/src/internal/constants.d.ts +3 -0
  21. package/esm/src/internal/constants.d.ts.map +1 -1
  22. package/esm/src/internal/constants.js +3 -0
  23. package/esm/src/internal/supervisor.d.ts +23 -0
  24. package/esm/src/internal/supervisor.d.ts.map +1 -0
  25. package/esm/src/internal/supervisor.js +267 -0
  26. package/esm/src/interpreter/durable/DurableInterpreter.d.ts +9 -2
  27. package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
  28. package/esm/src/interpreter/durable/DurableInterpreter.js +57 -13
  29. package/esm/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
  30. package/esm/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
  31. package/esm/src/interpreter/durable/Queue.js +1 -1
  32. package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
  33. package/esm/src/interpreter/durable/compilers/catch.js +3 -1
  34. package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
  35. package/esm/src/interpreter/durable/compilers/fn.js +29 -6
  36. package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -1
  37. package/esm/src/interpreter/durable/compilers/http.js +45 -11
  38. package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
  39. package/esm/src/interpreter/durable/compilers/schedule.js +4 -3
  40. package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
  41. package/esm/src/interpreter/durable/compilers/webhook.js +2 -0
  42. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +8 -1
  43. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  44. package/esm/src/interpreter/memory/MemoryInterpreter.js +56 -12
  45. package/esm/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
  46. package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
  47. package/esm/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
  48. package/esm/src/interpreter/memory/compilers/catch.js +5 -0
  49. package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
  50. package/esm/src/interpreter/memory/compilers/fn.js +29 -18
  51. package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
  52. package/esm/src/interpreter/memory/compilers/http.js +44 -10
  53. package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  54. package/esm/src/interpreter/memory/compilers/schedule.js +61 -4
  55. package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  56. package/esm/src/interpreter/memory/compilers/webhook.js +9 -3
  57. package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts +1 -0
  58. package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -1
  59. package/esm/src/interpreter/vanilla/VanillaInterpreter.js +30 -6
  60. package/esm/src/interpreter/vanilla/compilers/schedule.js +1 -1
  61. package/esm/src/issues/Issues.d.ts.map +1 -1
  62. package/esm/src/issues/Issues.js +6 -1
  63. package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
  64. package/package.json +3 -1
  65. package/script/src/connection/internal/CredentialHolder.js +1 -1
  66. package/script/src/connection/internal/FetchBuilder.d.ts +9 -2
  67. package/script/src/connection/internal/FetchBuilder.d.ts.map +1 -1
  68. package/script/src/connection/internal/FetchBuilder.js +147 -3
  69. package/script/src/context/Context.d.ts +5 -0
  70. package/script/src/context/Context.d.ts.map +1 -1
  71. package/script/src/context/Context.js +6 -0
  72. package/script/src/dsl/Workflow.d.ts.map +1 -1
  73. package/script/src/dsl/Workflow.js +2 -0
  74. package/script/src/dsl/http/types.d.ts +2 -0
  75. package/script/src/dsl/http/types.d.ts.map +1 -1
  76. package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
  77. package/script/src/dsl/http/versori/configloader.js +1 -1
  78. package/script/src/dsl/http/versori/cronapi.d.ts +2 -3
  79. package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -1
  80. package/script/src/dsl/http/versori/cronapi.js +14 -15
  81. package/script/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
  82. package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
  83. package/script/src/dsl/triggers/WebhookTrigger.js +3 -1
  84. package/script/src/internal/constants.d.ts +3 -0
  85. package/script/src/internal/constants.d.ts.map +1 -1
  86. package/script/src/internal/constants.js +4 -1
  87. package/script/src/internal/supervisor.d.ts +23 -0
  88. package/script/src/internal/supervisor.d.ts.map +1 -0
  89. package/script/src/internal/supervisor.js +275 -0
  90. package/script/src/interpreter/durable/DurableInterpreter.d.ts +9 -2
  91. package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
  92. package/script/src/interpreter/durable/DurableInterpreter.js +62 -18
  93. package/script/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
  94. package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
  95. package/script/src/interpreter/durable/Queue.js +1 -1
  96. package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
  97. package/script/src/interpreter/durable/compilers/catch.js +3 -1
  98. package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
  99. package/script/src/interpreter/durable/compilers/fn.js +28 -5
  100. package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -1
  101. package/script/src/interpreter/durable/compilers/http.js +45 -11
  102. package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
  103. package/script/src/interpreter/durable/compilers/schedule.js +4 -3
  104. package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
  105. package/script/src/interpreter/durable/compilers/webhook.js +2 -0
  106. package/script/src/interpreter/memory/MemoryInterpreter.d.ts +8 -1
  107. package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  108. package/script/src/interpreter/memory/MemoryInterpreter.js +55 -11
  109. package/script/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
  110. package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
  111. package/script/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
  112. package/script/src/interpreter/memory/compilers/catch.js +5 -0
  113. package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
  114. package/script/src/interpreter/memory/compilers/fn.js +28 -17
  115. package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
  116. package/script/src/interpreter/memory/compilers/http.js +44 -10
  117. package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  118. package/script/src/interpreter/memory/compilers/schedule.js +61 -4
  119. package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  120. package/script/src/interpreter/memory/compilers/webhook.js +9 -3
  121. package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts +1 -0
  122. package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -1
  123. package/script/src/interpreter/vanilla/VanillaInterpreter.js +30 -6
  124. package/script/src/interpreter/vanilla/compilers/schedule.js +1 -1
  125. package/script/src/issues/Issues.d.ts.map +1 -1
  126. package/script/src/issues/Issues.js +6 -1
  127. package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
  128. package/esm/src/dsl/http/versori/constants.d.ts +0 -21
  129. package/esm/src/dsl/http/versori/constants.d.ts.map +0 -1
  130. package/esm/src/dsl/http/versori/constants.js +0 -38
  131. package/script/src/dsl/http/versori/constants.d.ts +0 -21
  132. package/script/src/dsl/http/versori/constants.d.ts.map +0 -1
  133. package/script/src/dsl/http/versori/constants.js +0 -41
@@ -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,10 @@ 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");
31
30
  const Workflow_js_1 = require("../../dsl/Workflow.js");
31
+ const constants_js_1 = require("../../internal/constants.js");
32
+ const supervisor_js_1 = require("../../internal/supervisor.js");
32
33
  const Issues_js_1 = require("../../issues/Issues.js");
33
34
  const MemoryKeyValueProvider_js_1 = require("../../kv/memory/MemoryKeyValueProvider.js");
34
35
  const SDKKeyValueProvider_js_1 = require("../../kv/sdk/SDKKeyValueProvider.js");
@@ -36,8 +37,8 @@ const ConsoleLogger_js_1 = require("../../observability/logging/ConsoleLogger.js
36
37
  const PlatformApi_js_1 = require("../../services/platform/PlatformApi.js");
37
38
  const ObservableCompiler_js_1 = require("./ObservableCompiler.js");
38
39
  const Queue_js_1 = require("./Queue.js");
39
- function getKVProvider(runLocal) {
40
- if (runLocal) {
40
+ function getKVProvider() {
41
+ if (supervisor_js_1.enabled) {
41
42
  return Promise.resolve(new MemoryKeyValueProvider_js_1.MemoryKeyValueProvider());
42
43
  }
43
44
  return SDKKeyValueProvider_js_1.SDKKeyValueProvider.fromEnv();
@@ -67,7 +68,7 @@ function getKVProvider(runLocal) {
67
68
  * ```
68
69
  */
69
70
  class DurableInterpreter {
70
- constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, platformApi, cnxFetchFactory, cronProvider, tracer, issue, cfgReader, queueProvider, otelSDK) {
71
+ constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, webhookRegistry, platformApi, cnxFetchFactory, cronProvider, tracer, issue, cfgReader, queueProvider, otelSDK) {
71
72
  Object.defineProperty(this, "log", {
72
73
  enumerable: true,
73
74
  configurable: true,
@@ -104,6 +105,12 @@ class DurableInterpreter {
104
105
  writable: true,
105
106
  value: cronRegistry
106
107
  });
108
+ Object.defineProperty(this, "webhookRegistry", {
109
+ enumerable: true,
110
+ configurable: true,
111
+ writable: true,
112
+ value: webhookRegistry
113
+ });
107
114
  Object.defineProperty(this, "platformApi", {
108
115
  enumerable: true,
109
116
  configurable: true,
@@ -182,6 +189,13 @@ class DurableInterpreter {
182
189
  writable: true,
183
190
  value: false
184
191
  });
192
+ // Workflow registration promises only used when supervisor is enabled
193
+ Object.defineProperty(this, "wfRegistration", {
194
+ enumerable: true,
195
+ configurable: true,
196
+ writable: true,
197
+ value: []
198
+ });
185
199
  if (typeof this.log === 'undefined') {
186
200
  // this captures the old way of instantiating the DurableInterpreter and provides an
187
201
  // error message back to the user to let them know they should use the new way.
@@ -200,7 +214,6 @@ class DurableInterpreter {
200
214
  const otelTracesURL = Deno.env.get(constants_js_1.envVarOtelTracesURL);
201
215
  let otelSDK;
202
216
  const configReader = configloader_js_1.VersoriConfigReader.fromEnv(log);
203
- const runLocal = Deno.env.get(constants_js_1.envVarLocalRun) === 'true';
204
217
  await waitForReady(log);
205
218
  // Do NOT change those attributes, they are used by the API to filter on
206
219
  const resource = (0, resources_1.resourceFromAttributes)({
@@ -222,6 +235,15 @@ class DurableInterpreter {
222
235
  log.info('Starting OpenTelemetry SDK');
223
236
  otelSDK.start();
224
237
  }
238
+ else if (supervisor_js_1.enabled) {
239
+ otelSDK = new sdk_node_1.NodeSDK({
240
+ traceExporter: new supervisor_js_1.Fake(),
241
+ serviceName: serviceName,
242
+ resource: resource,
243
+ });
244
+ log.info('Starting Testing OpenTelemetry SDK');
245
+ otelSDK.start();
246
+ }
225
247
  const tracer = api_1.default.trace.getTracer(serviceName, version);
226
248
  const queueProvider = await Queue_js_1.QueueImpl.fromEnv(log);
227
249
  const connectionFactory = DirectConnectionFactory_js_1.DirectConnectionFactory.fromEnv(log);
@@ -229,14 +251,14 @@ class DurableInterpreter {
229
251
  if (options.contextProvider) {
230
252
  // no need to set up a key-value provider if options.contextProvider is already
231
253
  // 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);
254
+ 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
255
  }
234
- const kvp = await getKVProvider(runLocal);
256
+ const kvp = await getKVProvider();
235
257
  const platformApi = PlatformApi_js_1.PlatformApiImpl.fromEnv();
236
258
  const organisationId = Deno.env.get(constants_js_1.envVarOrgId) || 'development';
237
259
  const environmentId = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
238
260
  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);
261
+ 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
262
  }
241
263
  register(workflow, options) {
242
264
  const localAbortController = new AbortController();
@@ -256,6 +278,7 @@ class DurableInterpreter {
256
278
  tracer: this.tracer,
257
279
  contextProvider: this.contextProvider,
258
280
  webhookRouter: this.webhookRouter,
281
+ webhookRegistry: this.webhookRegistry,
259
282
  queueProvider: this.queueProvider,
260
283
  cronRouter: this.cronRouter,
261
284
  cronRegistry: this.cronRegistry,
@@ -278,11 +301,14 @@ class DurableInterpreter {
278
301
  },
279
302
  };
280
303
  this.registeredWorkflows.push(registration);
304
+ if (supervisor_js_1.enabled) {
305
+ this.wfRegistration.push((0, supervisor_js_1.registerWorkflow)(workflow));
306
+ }
281
307
  return registration;
282
308
  }
283
- start() {
284
- const port = Deno.env.get('PORT') || 3000;
285
- const cronPort = Deno.env.get('CRON_PORT') || 3001;
309
+ async start() {
310
+ const port = Deno.env.get(constants_js_1.envPort) || 3000;
311
+ const cronPort = Deno.env.get(constants_js_1.envCronPort) || 3001;
286
312
  const webhookApp = (0, express_1.default)();
287
313
  const cronApp = (0, express_1.default)();
288
314
  cronApp.use(express_1.default.json());
@@ -309,11 +335,18 @@ class DurableInterpreter {
309
335
  triggerName: registration.triggerName,
310
336
  error: err instanceof Error ? err.toString() : err,
311
337
  });
338
+ this.tracer.startActiveSpan('done', (span) => {
339
+ span.setAttribute('error.message', err instanceof Error ? err.toString() : err);
340
+ span.setAttribute('execution.id', ctx.executionId);
341
+ span.setAttribute('result', 'fail');
342
+ span.setAttribute('workflow.id', ctx.workflowId || 'unknown-workflow');
343
+ span.end();
344
+ });
312
345
  try {
313
346
  ctx.options.onError?.(ctx.withData(err));
314
347
  }
315
348
  catch (err) {
316
- ctx.log.error('DurableInterpreter.onErrorError: failed to call onError handler', {
349
+ ctx.log.error('DurableInterpreter.onError: failed to call onError handler', {
317
350
  triggerName: registration.triggerName,
318
351
  error: err instanceof Error ? err.toString() : err,
319
352
  });
@@ -331,6 +364,12 @@ class DurableInterpreter {
331
364
  triggerName: registration.triggerName,
332
365
  durationMs,
333
366
  });
367
+ this.tracer.startActiveSpan('done', (span) => {
368
+ span.setAttribute('execution.id', ctx.executionId);
369
+ span.setAttribute('result', 'pass');
370
+ span.setAttribute('workflow.id', ctx.workflowId || 'unknown-workflow');
371
+ span.end();
372
+ });
334
373
  try {
335
374
  ctx.options.onSuccess?.(ctx);
336
375
  }
@@ -392,6 +431,7 @@ class DurableInterpreter {
392
431
  if (this.cronServer) {
393
432
  this.cronServer.close();
394
433
  }
434
+ this.otelSDK?.shutdown();
395
435
  // Remove all signal listeners
396
436
  for (const registration of this.registeredWorkflows) {
397
437
  Deno.removeSignalListener('SIGINT', registration.sigintListener);
@@ -408,6 +448,10 @@ class DurableInterpreter {
408
448
  }
409
449
  };
410
450
  Deno.addSignalListener('SIGINT', this.shutdownServer);
451
+ if (supervisor_js_1.enabled) {
452
+ await Promise.all(this.wfRegistration);
453
+ await (0, supervisor_js_1.signalReady)();
454
+ }
411
455
  return new Promise((resolve) => {
412
456
  let serversClosed = 0;
413
457
  const totalServers = [this.webhookServer, this.cronServer].filter(Boolean).length;
@@ -445,7 +489,7 @@ class DurableInterpreter {
445
489
  }
446
490
  exports.DurableInterpreter = DurableInterpreter;
447
491
  async function waitForReady(log) {
448
- const readyCheckUrl = Deno.env.get('READY_CHECK_URL');
492
+ const readyCheckUrl = Deno.env.get(constants_js_1.envReadyCheckURL);
449
493
  if (!readyCheckUrl) {
450
494
  return Promise.resolve();
451
495
  }
@@ -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,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,WAAW,EAAE,WAAW,CAAC;IACzB,aAAa,EAAE,QAAQ,CAAC;IACxB,aAAa,EAAE,QAAQ,CAAC;IACxB,aAAa,EAAE,MAAM,CAA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AAC,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"}
@@ -15,18 +15,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.fnCompiler = void 0;
16
16
  const rxjs_1 = require("rxjs");
17
17
  const FnTask_js_1 = require("../../../dsl/tasks/FnTask.js");
18
+ const supervisor_js_1 = require("../../../internal/supervisor.js");
18
19
  function compileFn(compilerCtx, task) {
19
- return (src) => src.pipe((0, rxjs_1.tap)({
20
- complete: () => compilerCtx.log.debug('fn.complete'),
21
- }), (0, rxjs_1.mergeMap)(async (ctx) => {
20
+ return (src) => src.pipe((0, rxjs_1.mergeMap)(async (ctx) => {
22
21
  return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
22
+ await (0, supervisor_js_1.sendTaskStartEvent)(task.id, ctx, span);
23
23
  span.setAttribute('task.id', task.id);
24
+ span.setAttribute('type', 'task');
25
+ span.setAttribute('task.type', 'fn');
24
26
  span.setAttribute('execution.id', ctx.executionId);
27
+ span.setAttribute('workflow.id', ctx.options.workflowId || 'unknown-workflow');
25
28
  try {
29
+ const spanContext = span.spanContext();
30
+ const ctxWithLogger = ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
31
+ let result;
26
32
  if (typeof ctx.idx === 'number') {
27
- return ctx.withData(await task._fn(ctx, ctx.idx));
33
+ result = ctx.withData(await task._fn(ctxWithLogger, ctx.idx));
28
34
  }
29
- return ctx.withData(await task._fn(ctx));
35
+ else {
36
+ result = ctx.withData(await task._fn(ctxWithLogger));
37
+ }
38
+ if (supervisor_js_1.enabled) {
39
+ span.setAttribute('response.body', JSON.stringify(result.data));
40
+ }
41
+ span.setAttribute('status', 'pass');
42
+ return result;
43
+ }
44
+ catch (error) {
45
+ if (error instanceof Error) {
46
+ span.setAttribute('status', 'fail');
47
+ span.recordException(error);
48
+ }
49
+ else {
50
+ span.recordException(new Error(String(error)));
51
+ }
52
+ throw error;
30
53
  }
31
54
  finally {
32
55
  span.end();
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/http.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAwFnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/http.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAG/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAyHnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
@@ -14,19 +14,32 @@
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.httpCompiler = void 0;
16
16
  const rxjs_1 = require("rxjs");
17
- const operators_1 = require("rxjs/operators");
18
- const HttpTask_js_1 = require("../../../dsl/tasks/HttpTask.js");
19
17
  const DynamicFetchFactory_js_1 = require("../../../connection/DynamicFetchFactory.js");
18
+ const FetchBuilder_js_1 = require("../../../connection/internal/FetchBuilder.js");
20
19
  const StaticFetchFactory_js_1 = require("../../../connection/StaticFetchFactory.js");
20
+ const HttpTask_js_1 = require("../../../dsl/tasks/HttpTask.js");
21
+ const supervisor_js_1 = require("../../../internal/supervisor.js");
21
22
  function compileHttp(compilerCtx, task) {
22
23
  const cnxMap = compilerCtx.configReader.getCnxMapping(task.opts.connection);
23
24
  let fetchFactory;
24
25
  if (!cnxMap) {
25
- compilerCtx.log.error(`Connection ${task.opts.connection} not found, using default fetch with no credentials`);
26
- fetchFactory = Promise.resolve(new StaticFetchFactory_js_1.StaticFetchFactory(globalThis.fetch));
26
+ compilerCtx.log.warn(`Connection ${task.opts.connection} not found, using default fetch with no credentials`);
27
+ if (supervisor_js_1.enabled) {
28
+ // missing connection map and we are in supervised mode, so we use the fake fetcher
29
+ fetchFactory = Promise.resolve(new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
30
+ }
31
+ else {
32
+ // missing connection map and not in supervised mode, so we use global fetch
33
+ fetchFactory = Promise.resolve(new StaticFetchFactory_js_1.StaticFetchFactory(globalThis.fetch));
34
+ }
27
35
  }
28
36
  else if (cnxMap.dynamic) {
29
- fetchFactory = Promise.resolve(new DynamicFetchFactory_js_1.DynamicFetchFactory(compilerCtx.cnxFactory, compilerCtx.platformApi, compilerCtx.organisationId, cnxMap.templateId));
37
+ if (cnxMap.mockWithAI) {
38
+ fetchFactory = Promise.resolve(new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
39
+ }
40
+ else {
41
+ fetchFactory = Promise.resolve(new DynamicFetchFactory_js_1.DynamicFetchFactory(compilerCtx.cnxFactory, compilerCtx.platformApi, compilerCtx.organisationId, cnxMap.templateId));
42
+ }
30
43
  }
31
44
  else {
32
45
  fetchFactory = compilerCtx.platformApi.getConnection({
@@ -36,8 +49,21 @@ function compileHttp(compilerCtx, task) {
36
49
  },
37
50
  throwOnError: true,
38
51
  })
39
- .then(({ data }) => Promise.all([compilerCtx.cnxFactory.fetcher(data), data.baseUrl ?? '']))
40
- .then(([fetcher, baseUrl]) => new StaticFetchFactory_js_1.StaticFetchFactory(fetcher, baseUrl));
52
+ .then(({ data }) => {
53
+ if (cnxMap.mockWithAI) {
54
+ // use the fake fetcher that calls the supervisor to generate a mock reponse
55
+ return new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, data).buildSupervisedFetch());
56
+ }
57
+ return Promise.all([compilerCtx.cnxFactory.fetcher(data), data.baseUrl ?? ''])
58
+ .then(([fetcher, baseUrl]) => new StaticFetchFactory_js_1.StaticFetchFactory(fetcher, baseUrl));
59
+ })
60
+ .catch((err) => {
61
+ compilerCtx.log.error(`Failed to get connection ${task.opts.connection}`, err);
62
+ if (supervisor_js_1.enabled) {
63
+ return new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, { name: task.opts.connection }).build());
64
+ }
65
+ throw err;
66
+ });
41
67
  }
42
68
  async function http(ctx) {
43
69
  const [fetch, baseUrl] = await fetchFactory.then((ff) => Promise.all([ff.fetcher(ctx), ff.baseUrl(ctx)]));
@@ -45,19 +71,27 @@ function compileHttp(compilerCtx, task) {
45
71
  const result = await task.fn(httpContext);
46
72
  return ctx.withData(result);
47
73
  }
48
- return (src) => src.pipe((0, operators_1.tap)({
49
- complete: () => compilerCtx.log.debug('http.complete'),
50
- }), (0, rxjs_1.mergeMap)((ctx) => {
74
+ return (src) => src.pipe((0, rxjs_1.mergeMap)((ctx) => {
51
75
  return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
76
+ await (0, supervisor_js_1.sendTaskStartEvent)(task.id, ctx, span);
52
77
  span.setAttribute('task.id', task.id);
53
78
  span.setAttribute('task.type', 'http');
79
+ span.setAttribute('type', 'task');
54
80
  span.setAttribute('execution.id', ctx.executionId);
55
81
  span.setAttribute('connection.name', task.opts.connection);
82
+ span.setAttribute('workflow.id', ctx.options.workflowId || 'unknown-workflow');
83
+ const spanContext = span.spanContext();
56
84
  try {
57
- return await http(ctx);
85
+ const result = await http(ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId })));
86
+ if (supervisor_js_1.enabled) {
87
+ span.setAttribute('response.body', JSON.stringify(result.data));
88
+ }
89
+ span.setAttribute('status', 'pass');
90
+ return result;
58
91
  }
59
92
  catch (error) {
60
93
  if (error instanceof Error) {
94
+ span.setAttribute('status', 'fail');
61
95
  span.recordException(error);
62
96
  }
63
97
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/schedule.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAkJ7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
1
+ {"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/schedule.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAQzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAqJ7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
@@ -14,8 +14,8 @@
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.scheduleCompiler = void 0;
16
16
  const rxjs_1 = require("rxjs");
17
- const constants_js_1 = require("../../../dsl/http/versori/constants.js");
18
17
  const ScheduleTrigger_js_1 = require("../../../dsl/triggers/ScheduleTrigger.js");
18
+ const constants_js_1 = require("../../../internal/constants.js");
19
19
  function compileSchedule(ctx, trigger, signal) {
20
20
  return new rxjs_1.Observable((subscriber) => {
21
21
  // Add HTTP endpoint for manual triggering
@@ -55,7 +55,7 @@ function compileSchedule(ctx, trigger, signal) {
55
55
  });
56
56
  return;
57
57
  }
58
- const executionCtx = ctx.contextProvider.create(activation[0], {});
58
+ const executionCtx = ctx.contextProvider.create(activation[0], {}, { workflowId: trigger.id });
59
59
  span.setAttribute('execution.id', executionCtx.executionId);
60
60
  try {
61
61
  subscriber.next(executionCtx);
@@ -87,7 +87,7 @@ function compileSchedule(ctx, trigger, signal) {
87
87
  return;
88
88
  }
89
89
  activations.forEach((activation) => {
90
- const executionCtx = ctx.contextProvider.create(activation, {});
90
+ const executionCtx = ctx.contextProvider.create(activation, {}, { workflowId: trigger.id });
91
91
  try {
92
92
  subscriber.next(executionCtx);
93
93
  }
@@ -106,6 +106,7 @@ function compileSchedule(ctx, trigger, signal) {
106
106
  await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
107
107
  span.setAttribute('task.id', trigger.id);
108
108
  span.setAttribute('task.type', 'schedule');
109
+ span.setAttribute('type', 'task');
109
110
  span.setAttribute('schedule', trigger.schedule);
110
111
  span.setAttribute('project.id', projectId);
111
112
  span.setAttribute('environment.id', environmentId);
@@ -1 +1 @@
1
- {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/webhook.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CAySxE,CAAC"}
1
+ {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/webhook.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CA4SxE,CAAC"}
@@ -90,6 +90,7 @@ exports.webhookCompiler = {
90
90
  onError = trigger.options.response.onError;
91
91
  }
92
92
  const ctxOptionsFn = (req, res) => ({
93
+ workflowId: trigger.id,
93
94
  onSuccess: (ctx) => {
94
95
  if (isSync) {
95
96
  sendResponse(res, onSuccess(ctx));
@@ -110,6 +111,7 @@ exports.webhookCompiler = {
110
111
  else {
111
112
  routeMiddleware.push(express_1.default.raw({ type: '*/*', limit: '50mb' }));
112
113
  }
114
+ ctx.webhookRegistry.set(trigger.id, { method, path: `/${trigger.id}`, options: trigger.options });
113
115
  return new rxjs_1.Observable((subscriber) => {
114
116
  if (!ctx.webhookRouter) {
115
117
  throw new Error('Router not available in compiler context');
@@ -44,6 +44,11 @@ type Registration = {
44
44
  sigintListener: () => void;
45
45
  subscription?: Subscription;
46
46
  };
47
+ type WebhookRegistry = Map<string, {
48
+ method: string;
49
+ path: string;
50
+ options: any;
51
+ }>;
47
52
  /**
48
53
  * MemoryInterpreter is the default interpreter for executing Versori workflows. It handles registration and execution
49
54
  * of workflows triggered by schedules and webhooks.
@@ -72,6 +77,7 @@ export declare class MemoryInterpreter {
72
77
  private readonly webhookRouter;
73
78
  private readonly cronRouter;
74
79
  private cronRegistry;
80
+ private webhookRegistry;
75
81
  private readonly cnxFactory;
76
82
  private readonly cronProvider;
77
83
  private readonly tracer;
@@ -83,7 +89,8 @@ export declare class MemoryInterpreter {
83
89
  private cronServer?;
84
90
  private shutdownServer?;
85
91
  private isShuttingDown;
86
- constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, cnxFactory: DirectConnectionFactory, cronProvider: CronProvider, tracer: Tracer, issuesProvider: IssueAPI, cfgReader: ConfigReader, otelSDK?: NodeSDK | undefined);
92
+ private wfRegistration;
93
+ constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, webhookRegistry: WebhookRegistry, cnxFactory: DirectConnectionFactory, cronProvider: CronProvider, tracer: Tracer, issuesProvider: IssueAPI, cfgReader: ConfigReader, otelSDK?: NodeSDK | undefined);
87
94
  static newInstance(options?: MemoryInterpreterOptions): Promise<MemoryInterpreter>;
88
95
  register<O>(workflow: Workflow<O>, options?: MemoryInterpreterOptions): Registration;
89
96
  start(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"AAaA,OAAsB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,OAAO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