@trigger.dev/core 0.0.0-v3-canary-20240325172431 → 0.0.0-v3-pnpm-fix-20240404110601

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.
package/dist/v3/index.mjs CHANGED
@@ -1,20 +1,21 @@
1
1
  import { z } from 'zod';
2
2
  import { SpanStatusCode, trace, propagation, context, DiagLogLevel, diag, DiagConsoleLogger, SpanKind } from '@opentelemetry/api';
3
3
  import { AsyncLocalStorage } from 'node:async_hooks';
4
- import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
5
4
  import { io } from 'socket.io-client';
6
5
  import { randomUUID } from 'crypto';
7
6
  import nodePath from 'node:path';
8
7
  import { SeverityNumber, logs } from '@opentelemetry/api-logs';
9
8
  import { PreciseDate } from '@google-cloud/precise-date';
10
9
  import humanizeDuration from 'humanize-duration';
10
+ import { setTimeout as setTimeout$1 } from 'node:timers/promises';
11
11
  import util from 'node:util';
12
12
  import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';
13
13
  import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
14
14
  import { registerInstrumentations } from '@opentelemetry/instrumentation';
15
15
  import { Resource, detectResourcesSync, processDetectorSync } from '@opentelemetry/resources';
16
- import { LoggerProvider, SimpleLogRecordProcessor } from '@opentelemetry/sdk-logs';
17
- import { NodeTracerProvider, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node';
16
+ import { LoggerProvider, BatchLogRecordProcessor, SimpleLogRecordProcessor } from '@opentelemetry/sdk-logs';
17
+ import { NodeTracerProvider, BatchSpanProcessor, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node';
18
+ import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
18
19
 
19
20
  var __defProp = Object.defineProperty;
20
21
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -216,6 +217,32 @@ var BatchTaskRunExecutionResult = z.object({
216
217
  });
217
218
 
218
219
  // src/v3/schemas/messages.ts
220
+ var EnvironmentType = z.enum([
221
+ "PRODUCTION",
222
+ "STAGING",
223
+ "DEVELOPMENT",
224
+ "PREVIEW"
225
+ ]);
226
+ var MachineCpu = z.union([
227
+ z.literal(0.25),
228
+ z.literal(0.5),
229
+ z.literal(1),
230
+ z.literal(2),
231
+ z.literal(4)
232
+ ]).default(0.5);
233
+ var MachineMemory = z.union([
234
+ z.literal(0.25),
235
+ z.literal(0.5),
236
+ z.literal(1),
237
+ z.literal(2),
238
+ z.literal(4),
239
+ z.literal(8)
240
+ ]).default(1);
241
+ var Machine = z.object({
242
+ version: z.literal("v1").default("v1"),
243
+ cpu: MachineCpu,
244
+ memory: MachineMemory
245
+ });
219
246
  var TaskRunExecutionPayload = z.object({
220
247
  execution: TaskRunExecution,
221
248
  traceContext: z.record(z.unknown()),
@@ -245,11 +272,16 @@ var BackgroundWorkerServerMessages = z.discriminatedUnion("type", [
245
272
  }),
246
273
  z.object({
247
274
  type: z.literal("SCHEDULE_ATTEMPT"),
248
- id: z.string(),
249
275
  image: z.string(),
276
+ version: z.string(),
277
+ machine: Machine,
278
+ // identifiers
279
+ id: z.string(),
250
280
  envId: z.string(),
251
- runId: z.string(),
252
- version: z.string()
281
+ envType: EnvironmentType,
282
+ orgId: z.string(),
283
+ projectId: z.string(),
284
+ runId: z.string()
253
285
  })
254
286
  ]);
255
287
  var serverWebsocketMessages = {
@@ -402,7 +434,7 @@ var QueueOptions = z.object({
402
434
  /** An optional property that specifies the maximum number of concurrent run executions.
403
435
  *
404
436
  * If this property is omitted, the task can potentially use up the full concurrency of an environment. */
405
- concurrencyLimit: z.number().int().min(1).max(1e3).optional(),
437
+ concurrencyLimit: z.number().int().min(0).max(1e3).optional(),
406
438
  /** @deprecated This feature is coming soon */
407
439
  rateLimit: RateLimitOptions.optional()
408
440
  });
@@ -411,7 +443,8 @@ var TaskMetadata = z.object({
411
443
  exportName: z.string(),
412
444
  packageVersion: z.string(),
413
445
  queue: QueueOptions.optional(),
414
- retry: RetryOptions.optional()
446
+ retry: RetryOptions.optional(),
447
+ machine: Machine.partial().optional()
415
448
  });
416
449
  var TaskMetadataWithFilePath = TaskMetadata.extend({
417
450
  filePath: z.string()
@@ -428,6 +461,13 @@ var UncaughtExceptionMessage = z.object({
428
461
  "unhandledRejection"
429
462
  ])
430
463
  });
464
+ var TaskMetadataFailedToParseData = z.object({
465
+ version: z.literal("v1").default("v1"),
466
+ tasks: z.unknown(),
467
+ zodIssues: z.custom((v) => {
468
+ return Array.isArray(v) && v.every((issue) => typeof issue === "object" && "message" in issue);
469
+ })
470
+ });
431
471
  var childToWorkerMessages = {
432
472
  TASK_RUN_COMPLETED: z.object({
433
473
  version: z.literal("v1").default("v1"),
@@ -438,6 +478,7 @@ var childToWorkerMessages = {
438
478
  version: z.literal("v1").default("v1"),
439
479
  tasks: TaskMetadataWithFilePath.array()
440
480
  }),
481
+ TASKS_FAILED_TO_PARSE: TaskMetadataFailedToParseData,
441
482
  TASK_HEARTBEAT: z.object({
442
483
  version: z.literal("v1").default("v1"),
443
484
  id: z.string()
@@ -472,6 +513,9 @@ var ProdChildToWorkerMessages = {
472
513
  tasks: TaskMetadataWithFilePath.array()
473
514
  })
474
515
  },
516
+ TASKS_FAILED_TO_PARSE: {
517
+ message: TaskMetadataFailedToParseData
518
+ },
475
519
  TASK_HEARTBEAT: {
476
520
  message: z.object({
477
521
  version: z.literal("v1").default("v1"),
@@ -555,7 +599,8 @@ var TaskResource = z.object({
555
599
  filePath: z.string(),
556
600
  exportName: z.string(),
557
601
  queue: QueueOptions.optional(),
558
- retry: RetryOptions.optional()
602
+ retry: RetryOptions.optional(),
603
+ machine: Machine.partial().optional()
559
604
  });
560
605
  var BackgroundWorkerMetadata = z.object({
561
606
  packageVersion: z.string(),
@@ -666,6 +711,11 @@ var InitializeDeploymentRequestBody = z.object({
666
711
  contentHash: z.string(),
667
712
  userId: z.string().optional()
668
713
  });
714
+ var DeploymentErrorData = z.object({
715
+ name: z.string(),
716
+ message: z.string(),
717
+ stack: z.string().optional()
718
+ });
669
719
  var GetDeploymentResponseBody = z.object({
670
720
  id: z.string(),
671
721
  status: z.enum([
@@ -681,11 +731,7 @@ var GetDeploymentResponseBody = z.object({
681
731
  shortCode: z.string(),
682
732
  version: z.string(),
683
733
  imageReference: z.string().optional(),
684
- errorData: z.object({
685
- name: z.string(),
686
- message: z.string(),
687
- stack: z.string().optional()
688
- }).optional().nullable(),
734
+ errorData: DeploymentErrorData.optional().nullable(),
689
735
  worker: z.object({
690
736
  id: z.string(),
691
737
  version: z.string(),
@@ -697,6 +743,17 @@ var GetDeploymentResponseBody = z.object({
697
743
  }))
698
744
  }).optional()
699
745
  });
746
+ var CreateUploadPayloadUrlResponseBody = z.object({
747
+ presignedUrl: z.string()
748
+ });
749
+ var PostStartCauses = z.enum([
750
+ "index",
751
+ "create",
752
+ "restore"
753
+ ]);
754
+ var PreStopCauses = z.enum([
755
+ "terminate"
756
+ ]);
700
757
  var RegexSchema = z.custom((val) => {
701
758
  try {
702
759
  return typeof val.test === "function";
@@ -719,11 +776,8 @@ var Config = z.object({
719
776
  dependenciesToBundle: z.array(z.union([
720
777
  z.string(),
721
778
  RegexSchema
722
- ])).optional()
723
- });
724
- var Machine = z.object({
725
- cpu: z.string().default("1").optional(),
726
- memory: z.string().default("500Mi").optional()
779
+ ])).optional(),
780
+ logLevel: z.string().optional()
727
781
  });
728
782
  var WaitReason = z.enum([
729
783
  "WAIT_FOR_DURATION",
@@ -761,9 +815,13 @@ var PlatformToProviderMessages = {
761
815
  version: z.literal("v1").default("v1"),
762
816
  imageTag: z.string(),
763
817
  shortCode: z.string(),
764
- envId: z.string(),
765
818
  apiKey: z.string(),
766
- apiUrl: z.string()
819
+ apiUrl: z.string(),
820
+ // identifiers
821
+ envId: z.string(),
822
+ envType: EnvironmentType,
823
+ orgId: z.string(),
824
+ projectId: z.string()
767
825
  }),
768
826
  callback: z.discriminatedUnion("success", [
769
827
  z.object({
@@ -779,25 +837,25 @@ var PlatformToProviderMessages = {
779
837
  })
780
838
  ])
781
839
  },
782
- INVOKE: {
783
- message: z.object({
784
- version: z.literal("v1").default("v1"),
785
- name: z.string(),
786
- machine: Machine
787
- })
788
- },
840
+ // TODO: this should be a shared queue message instead
789
841
  RESTORE: {
790
842
  message: z.object({
791
843
  version: z.literal("v1").default("v1"),
792
- checkpointId: z.string(),
793
- runId: z.string(),
794
844
  type: z.enum([
795
845
  "DOCKER",
796
846
  "KUBERNETES"
797
847
  ]),
798
848
  location: z.string(),
799
849
  reason: z.string().optional(),
800
- imageRef: z.string()
850
+ imageRef: z.string(),
851
+ machine: Machine,
852
+ // identifiers
853
+ checkpointId: z.string(),
854
+ envId: z.string(),
855
+ envType: EnvironmentType,
856
+ orgId: z.string(),
857
+ projectId: z.string(),
858
+ runId: z.string()
801
859
  })
802
860
  },
803
861
  DELETE: {
@@ -1354,7 +1412,11 @@ var SpanMessagingEvent = z.object({
1354
1412
  });
1355
1413
 
1356
1414
  // src/zodfetch.ts
1357
- async function zodfetch(schema, url, requestInit) {
1415
+ async function zodfetch(schema, url, requestInit, options) {
1416
+ return await _doZodFetch(schema, url, requestInit, options);
1417
+ }
1418
+ __name(zodfetch, "zodfetch");
1419
+ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
1358
1420
  try {
1359
1421
  const response = await fetch(url, requestInit);
1360
1422
  if ((!requestInit || requestInit.method === "GET") && response.status === 404) {
@@ -1363,7 +1425,7 @@ async function zodfetch(schema, url, requestInit) {
1363
1425
  error: `404: ${response.statusText}`
1364
1426
  };
1365
1427
  }
1366
- if (response.status >= 400 && response.status < 500) {
1428
+ if (response.status >= 400 && response.status < 500 && response.status !== 429) {
1367
1429
  const body = await response.json();
1368
1430
  if (!body.error) {
1369
1431
  return {
@@ -1376,6 +1438,27 @@ async function zodfetch(schema, url, requestInit) {
1376
1438
  error: body.error
1377
1439
  };
1378
1440
  }
1441
+ if (response.status === 429 || response.status >= 500) {
1442
+ if (!options?.retry) {
1443
+ return {
1444
+ ok: false,
1445
+ error: `Failed to fetch ${url}, got status code ${response.status}`
1446
+ };
1447
+ }
1448
+ const retry = {
1449
+ ...defaultRetryOptions,
1450
+ ...options.retry
1451
+ };
1452
+ if (attempt > retry.maxAttempts) {
1453
+ return {
1454
+ ok: false,
1455
+ error: `Failed to fetch ${url}, got status code ${response.status}`
1456
+ };
1457
+ }
1458
+ const delay = calculateNextRetryDelay(retry, attempt);
1459
+ await new Promise((resolve) => setTimeout(resolve, delay));
1460
+ return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
1461
+ }
1379
1462
  if (response.status !== 200) {
1380
1463
  return {
1381
1464
  ok: false,
@@ -1401,13 +1484,28 @@ async function zodfetch(schema, url, requestInit) {
1401
1484
  error: parsedResult.error.message
1402
1485
  };
1403
1486
  } catch (error) {
1487
+ if (options?.retry) {
1488
+ const retry = {
1489
+ ...defaultRetryOptions,
1490
+ ...options.retry
1491
+ };
1492
+ if (attempt > retry.maxAttempts) {
1493
+ return {
1494
+ ok: false,
1495
+ error: error instanceof Error ? error.message : JSON.stringify(error)
1496
+ };
1497
+ }
1498
+ const delay = calculateNextRetryDelay(retry, attempt);
1499
+ await new Promise((resolve) => setTimeout(resolve, delay));
1500
+ return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
1501
+ }
1404
1502
  return {
1405
1503
  ok: false,
1406
1504
  error: error instanceof Error ? error.message : JSON.stringify(error)
1407
1505
  };
1408
1506
  }
1409
1507
  }
1410
- __name(zodfetch, "zodfetch");
1508
+ __name(_doZodFetch, "_doZodFetch");
1411
1509
 
1412
1510
  // src/v3/utils/flattenAttributes.ts
1413
1511
  function flattenAttributes(obj, prefix) {
@@ -1541,6 +1639,7 @@ var SemanticInternalAttributes = {
1541
1639
  SPAN_PARTIAL: "$span.partial",
1542
1640
  SPAN_ID: "$span.span_id",
1543
1641
  OUTPUT: "$output",
1642
+ OUTPUT_TYPE: "$mime_type_output",
1544
1643
  STYLE: "$style",
1545
1644
  STYLE_ICON: "$style.icon",
1546
1645
  STYLE_VARIANT: "$style.variant",
@@ -1548,6 +1647,7 @@ var SemanticInternalAttributes = {
1548
1647
  METADATA: "$metadata",
1549
1648
  TRIGGER: "$trigger",
1550
1649
  PAYLOAD: "$payload",
1650
+ PAYLOAD_TYPE: "$mime_type_payload",
1551
1651
  SHOW: "$show",
1552
1652
  SHOW_ACTIONS: "$show.actions",
1553
1653
  WORKER_ID: "worker.id",
@@ -1574,10 +1674,6 @@ var _TaskContextManager = class _TaskContextManager {
1574
1674
  const store = __privateMethod(this, _getStore, getStore_fn).call(this);
1575
1675
  return store?.ctx;
1576
1676
  }
1577
- get payload() {
1578
- const store = __privateMethod(this, _getStore, getStore_fn).call(this);
1579
- return store?.payload;
1580
- }
1581
1677
  get worker() {
1582
1678
  const store = __privateMethod(this, _getStore, getStore_fn).call(this);
1583
1679
  return store?.worker;
@@ -1586,19 +1682,11 @@ var _TaskContextManager = class _TaskContextManager {
1586
1682
  if (this.ctx) {
1587
1683
  return {
1588
1684
  ...this.contextAttributes,
1589
- ...this.workerAttributes,
1590
- ...this.payloadAttributes,
1591
- [SemanticResourceAttributes.SERVICE_NAME]: this.ctx.task.id
1685
+ ...this.workerAttributes
1592
1686
  };
1593
1687
  }
1594
1688
  return {};
1595
1689
  }
1596
- get payloadAttributes() {
1597
- if (this.payload) {
1598
- return flattenAttributes(this.payload, "payload");
1599
- }
1600
- return {};
1601
- }
1602
1690
  get workerAttributes() {
1603
1691
  if (this.worker) {
1604
1692
  return {
@@ -1703,6 +1791,15 @@ function getEnvVar(name) {
1703
1791
  __name(getEnvVar, "getEnvVar");
1704
1792
 
1705
1793
  // src/v3/apiClient/index.ts
1794
+ var zodFetchOptions = {
1795
+ retry: {
1796
+ maxAttempts: 5,
1797
+ minTimeoutInMs: 1e3,
1798
+ maxTimeoutInMs: 3e4,
1799
+ factor: 2,
1800
+ randomize: false
1801
+ }
1802
+ };
1706
1803
  var _getHeaders, getHeaders_fn;
1707
1804
  var _ApiClient = class _ApiClient {
1708
1805
  constructor(baseUrl, accessToken) {
@@ -1715,14 +1812,26 @@ var _ApiClient = class _ApiClient {
1715
1812
  method: "POST",
1716
1813
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
1717
1814
  body: JSON.stringify(body)
1718
- });
1815
+ }, zodFetchOptions);
1719
1816
  }
1720
1817
  batchTriggerTask(taskId, body, options) {
1721
1818
  return zodfetch(BatchTriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${taskId}/batch`, {
1722
1819
  method: "POST",
1723
1820
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
1724
1821
  body: JSON.stringify(body)
1725
- });
1822
+ }, zodFetchOptions);
1823
+ }
1824
+ createUploadPayloadUrl(filename) {
1825
+ return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
1826
+ method: "PUT",
1827
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1828
+ }, zodFetchOptions);
1829
+ }
1830
+ getPayloadUrl(filename) {
1831
+ return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
1832
+ method: "GET",
1833
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1834
+ }, zodFetchOptions);
1726
1835
  }
1727
1836
  };
1728
1837
  _getHeaders = new WeakSet();
@@ -1749,7 +1858,7 @@ var _ApiClientManager = class _ApiClientManager {
1749
1858
  }
1750
1859
  get baseURL() {
1751
1860
  const store = __privateMethod(this, _getStore2, getStore_fn2).call(this);
1752
- return store?.baseURL ?? getEnvVar("TRIGGER_API_URL");
1861
+ return store?.baseURL ?? getEnvVar("TRIGGER_API_URL") ?? "https://api.trigger.dev";
1753
1862
  }
1754
1863
  get accessToken() {
1755
1864
  const store = __privateMethod(this, _getStore2, getStore_fn2).call(this);
@@ -1772,6 +1881,15 @@ getStore_fn2 = /* @__PURE__ */ __name(function() {
1772
1881
  __name(_ApiClientManager, "ApiClientManager");
1773
1882
  var ApiClientManager = _ApiClientManager;
1774
1883
  var apiClientManager = new ApiClientManager();
1884
+ var _ZodSchemaParsedError = class _ZodSchemaParsedError extends Error {
1885
+ constructor(error, payload) {
1886
+ super(error.message);
1887
+ this.error = error;
1888
+ this.payload = payload;
1889
+ }
1890
+ };
1891
+ __name(_ZodSchemaParsedError, "ZodSchemaParsedError");
1892
+ var ZodSchemaParsedError = _ZodSchemaParsedError;
1775
1893
  var ZodMessageSchema = z.object({
1776
1894
  version: z.literal("v1").default("v1"),
1777
1895
  type: z.string(),
@@ -1868,7 +1986,7 @@ var _ZodMessageSender = class _ZodMessageSender {
1868
1986
  }
1869
1987
  const parsedPayload = schema.safeParse(payload);
1870
1988
  if (!parsedPayload.success) {
1871
- throw new Error(`Failed to parse message payload: ${JSON.stringify(parsedPayload.error)}`);
1989
+ throw new ZodSchemaParsedError(parsedPayload.error, payload);
1872
1990
  }
1873
1991
  await __privateGet(this, _sender).call(this, {
1874
1992
  type,
@@ -2037,16 +2155,23 @@ var _ZodSocketConnection = class _ZodSocketConnection {
2037
2155
  __privateAdd(this, _sender2, void 0);
2038
2156
  __privateAdd(this, _handler, void 0);
2039
2157
  __privateAdd(this, _logger, void 0);
2040
- this.socket = io(`ws://${opts.host}:${opts.port}/${opts.namespace}`, {
2158
+ const uri = `${opts.secure ? "wss" : "ws"}://${opts.host}:${opts.port ?? (opts.secure ? "443" : "80")}/${opts.namespace}`;
2159
+ const logger2 = new SimpleStructuredLogger(opts.namespace, LogLevel.info);
2160
+ logger2.log("new zod socket", {
2161
+ uri
2162
+ });
2163
+ this.socket = io(uri, {
2041
2164
  transports: [
2042
2165
  "websocket"
2043
2166
  ],
2044
2167
  auth: {
2045
2168
  token: opts.authToken
2046
2169
  },
2047
- extraHeaders: opts.extraHeaders
2170
+ extraHeaders: opts.extraHeaders,
2171
+ reconnectionDelay: 500,
2172
+ reconnectionDelayMax: 1e3
2048
2173
  });
2049
- __privateSet(this, _logger, new SimpleStructuredLogger(opts.namespace, LogLevel.info, {
2174
+ __privateSet(this, _logger, logger2.child({
2050
2175
  socketId: this.socket.id
2051
2176
  }));
2052
2177
  __privateSet(this, _handler, new ZodSocketMessageHandler({
@@ -2365,7 +2490,7 @@ var _ZodIpcConnection = class _ZodIpcConnection {
2365
2490
  }
2366
2491
  const parsedPayload = schema.safeParse(payload);
2367
2492
  if (!parsedPayload.success) {
2368
- throw new Error(`Failed to parse message payload: ${JSON.stringify(parsedPayload.error)}`);
2493
+ throw new ZodSchemaParsedError(parsedPayload.error, payload);
2369
2494
  }
2370
2495
  await __privateMethod(this, _sendPacket, sendPacket_fn).call(this, {
2371
2496
  type: "EVENT",
@@ -2554,6 +2679,41 @@ function correctStackTraceLine(line, projectDir) {
2554
2679
  return line;
2555
2680
  }
2556
2681
  __name(correctStackTraceLine, "correctStackTraceLine");
2682
+ function groupTaskMetadataIssuesByTask(tasks, issues) {
2683
+ return issues.reduce((acc, issue) => {
2684
+ if (issue.path.length === 0) {
2685
+ return acc;
2686
+ }
2687
+ const taskIndex = issue.path[1];
2688
+ if (typeof taskIndex !== "number") {
2689
+ return acc;
2690
+ }
2691
+ const task = tasks[taskIndex];
2692
+ if (!task) {
2693
+ return acc;
2694
+ }
2695
+ const restOfPath = issue.path.slice(2);
2696
+ const taskId = task.id;
2697
+ const taskName = task.exportName;
2698
+ const filePath = task.filePath;
2699
+ const key = taskIndex;
2700
+ const existing = acc[key] ?? {
2701
+ id: taskId,
2702
+ exportName: taskName,
2703
+ filePath,
2704
+ issues: []
2705
+ };
2706
+ existing.issues.push({
2707
+ message: issue.message,
2708
+ path: restOfPath.length === 0 ? void 0 : restOfPath.join(".")
2709
+ });
2710
+ return {
2711
+ ...acc,
2712
+ [key]: existing
2713
+ };
2714
+ }, {});
2715
+ }
2716
+ __name(groupTaskMetadataIssuesByTask, "groupTaskMetadataIssuesByTask");
2557
2717
 
2558
2718
  // src/v3/utils/platform.ts
2559
2719
  var _globalThis = typeof globalThis === "object" ? globalThis : global;
@@ -2703,27 +2863,58 @@ function iconStringForSeverity(severityNumber) {
2703
2863
  }
2704
2864
  }
2705
2865
  __name(iconStringForSeverity, "iconStringForSeverity");
2706
- function preciseDateOriginNow() {
2707
- return {
2708
- hrtime: process.hrtime(),
2709
- timestamp: new PreciseDate()
2710
- };
2711
- }
2712
- __name(preciseDateOriginNow, "preciseDateOriginNow");
2713
- function calculatePreciseDateHrTime(origin) {
2714
- const elapsedHrTime = process.hrtime(origin.hrtime);
2715
- const elapsedNanoseconds = BigInt(elapsedHrTime[0]) * BigInt(1e9) + BigInt(elapsedHrTime[1]);
2716
- const preciseDate = new PreciseDate(origin.timestamp.getFullTime() + elapsedNanoseconds);
2717
- const dateStruct = preciseDate.toStruct();
2718
- return [
2719
- dateStruct.seconds,
2720
- dateStruct.nanos
2721
- ];
2722
- }
2723
- __name(calculatePreciseDateHrTime, "calculatePreciseDateHrTime");
2866
+ var _SimpleClock = class _SimpleClock {
2867
+ preciseNow() {
2868
+ const now = new PreciseDate();
2869
+ const nowStruct = now.toStruct();
2870
+ return [
2871
+ nowStruct.seconds,
2872
+ nowStruct.nanos
2873
+ ];
2874
+ }
2875
+ reset() {
2876
+ }
2877
+ };
2878
+ __name(_SimpleClock, "SimpleClock");
2879
+ var SimpleClock = _SimpleClock;
2880
+
2881
+ // src/v3/clock/index.ts
2882
+ var API_NAME2 = "clock";
2883
+ var SIMPLE_CLOCK = new SimpleClock();
2884
+ var _getClock, getClock_fn;
2885
+ var _ClockAPI = class _ClockAPI {
2886
+ constructor() {
2887
+ __privateAdd(this, _getClock);
2888
+ }
2889
+ static getInstance() {
2890
+ if (!this._instance) {
2891
+ this._instance = new _ClockAPI();
2892
+ }
2893
+ return this._instance;
2894
+ }
2895
+ setGlobalClock(clock2) {
2896
+ return registerGlobal(API_NAME2, clock2);
2897
+ }
2898
+ preciseNow() {
2899
+ return __privateMethod(this, _getClock, getClock_fn).call(this).preciseNow();
2900
+ }
2901
+ reset() {
2902
+ __privateMethod(this, _getClock, getClock_fn).call(this).reset();
2903
+ }
2904
+ };
2905
+ _getClock = new WeakSet();
2906
+ getClock_fn = /* @__PURE__ */ __name(function() {
2907
+ return getGlobal(API_NAME2) ?? SIMPLE_CLOCK;
2908
+ }, "#getClock");
2909
+ __name(_ClockAPI, "ClockAPI");
2910
+ var ClockAPI = _ClockAPI;
2911
+
2912
+ // src/v3/clock-api.ts
2913
+ var clock = ClockAPI.getInstance();
2724
2914
 
2725
2915
  // src/v3/logger/taskLogger.ts
2726
2916
  var logLevels = [
2917
+ "none",
2727
2918
  "error",
2728
2919
  "warn",
2729
2920
  "log",
@@ -2739,37 +2930,36 @@ var _OtelTaskLogger = class _OtelTaskLogger {
2739
2930
  this._level = logLevels.indexOf(_config.level);
2740
2931
  }
2741
2932
  debug(message, properties) {
2742
- if (this._level < 4)
2933
+ if (this._level < 5)
2743
2934
  return;
2744
- __privateMethod(this, _emitLog, emitLog_fn).call(this, message, "debug", SeverityNumber.DEBUG, properties);
2935
+ __privateMethod(this, _emitLog, emitLog_fn).call(this, message, __privateMethod(this, _getTimestampInHrTime, getTimestampInHrTime_fn).call(this), "debug", SeverityNumber.DEBUG, properties);
2745
2936
  }
2746
2937
  log(message, properties) {
2747
- if (this._level < 2)
2938
+ if (this._level < 3)
2748
2939
  return;
2749
- __privateMethod(this, _emitLog, emitLog_fn).call(this, message, "log", SeverityNumber.INFO, properties);
2940
+ __privateMethod(this, _emitLog, emitLog_fn).call(this, message, __privateMethod(this, _getTimestampInHrTime, getTimestampInHrTime_fn).call(this), "log", SeverityNumber.INFO, properties);
2750
2941
  }
2751
2942
  info(message, properties) {
2752
- if (this._level < 3)
2943
+ if (this._level < 4)
2753
2944
  return;
2754
- __privateMethod(this, _emitLog, emitLog_fn).call(this, message, "info", SeverityNumber.INFO, properties);
2945
+ __privateMethod(this, _emitLog, emitLog_fn).call(this, message, __privateMethod(this, _getTimestampInHrTime, getTimestampInHrTime_fn).call(this), "info", SeverityNumber.INFO, properties);
2755
2946
  }
2756
2947
  warn(message, properties) {
2757
- if (this._level < 1)
2948
+ if (this._level < 2)
2758
2949
  return;
2759
- __privateMethod(this, _emitLog, emitLog_fn).call(this, message, "warn", SeverityNumber.WARN, properties);
2950
+ __privateMethod(this, _emitLog, emitLog_fn).call(this, message, __privateMethod(this, _getTimestampInHrTime, getTimestampInHrTime_fn).call(this), "warn", SeverityNumber.WARN, properties);
2760
2951
  }
2761
2952
  error(message, properties) {
2762
- if (this._level < 0)
2953
+ if (this._level < 1)
2763
2954
  return;
2764
- __privateMethod(this, _emitLog, emitLog_fn).call(this, message, "error", SeverityNumber.ERROR, properties);
2955
+ __privateMethod(this, _emitLog, emitLog_fn).call(this, message, __privateMethod(this, _getTimestampInHrTime, getTimestampInHrTime_fn).call(this), "error", SeverityNumber.ERROR, properties);
2765
2956
  }
2766
2957
  trace(name, fn, options) {
2767
2958
  return this._config.tracer.startActiveSpan(name, fn, options);
2768
2959
  }
2769
2960
  };
2770
2961
  _emitLog = new WeakSet();
2771
- emitLog_fn = /* @__PURE__ */ __name(function(message, severityText, severityNumber, properties) {
2772
- const timestamp = __privateMethod(this, _getTimestampInHrTime, getTimestampInHrTime_fn).call(this);
2962
+ emitLog_fn = /* @__PURE__ */ __name(function(message, timestamp, severityText, severityNumber, properties) {
2773
2963
  let attributes = {
2774
2964
  ...flattenAttributes(properties)
2775
2965
  };
@@ -2787,7 +2977,7 @@ emitLog_fn = /* @__PURE__ */ __name(function(message, severityText, severityNumb
2787
2977
  }, "#emitLog");
2788
2978
  _getTimestampInHrTime = new WeakSet();
2789
2979
  getTimestampInHrTime_fn = /* @__PURE__ */ __name(function() {
2790
- return calculatePreciseDateHrTime(this._config.preciseDateOrigin);
2980
+ return clock.preciseNow();
2791
2981
  }, "#getTimestampInHrTime");
2792
2982
  __name(_OtelTaskLogger, "OtelTaskLogger");
2793
2983
  var OtelTaskLogger = _OtelTaskLogger;
@@ -2810,7 +3000,7 @@ __name(_NoopTaskLogger, "NoopTaskLogger");
2810
3000
  var NoopTaskLogger = _NoopTaskLogger;
2811
3001
 
2812
3002
  // src/v3/logger/index.ts
2813
- var API_NAME2 = "logger";
3003
+ var API_NAME3 = "logger";
2814
3004
  var NOOP_TASK_LOGGER = new NoopTaskLogger();
2815
3005
  var _getTaskLogger, getTaskLogger_fn;
2816
3006
  var _LoggerAPI = class _LoggerAPI {
@@ -2824,10 +3014,10 @@ var _LoggerAPI = class _LoggerAPI {
2824
3014
  return this._instance;
2825
3015
  }
2826
3016
  disable() {
2827
- unregisterGlobal(API_NAME2);
3017
+ unregisterGlobal(API_NAME3);
2828
3018
  }
2829
3019
  setGlobalTaskLogger(taskLogger) {
2830
- return registerGlobal(API_NAME2, taskLogger);
3020
+ return registerGlobal(API_NAME3, taskLogger);
2831
3021
  }
2832
3022
  debug(message, metadata) {
2833
3023
  __privateMethod(this, _getTaskLogger, getTaskLogger_fn).call(this).debug(message, metadata);
@@ -2850,13 +3040,57 @@ var _LoggerAPI = class _LoggerAPI {
2850
3040
  };
2851
3041
  _getTaskLogger = new WeakSet();
2852
3042
  getTaskLogger_fn = /* @__PURE__ */ __name(function() {
2853
- return getGlobal(API_NAME2) ?? NOOP_TASK_LOGGER;
3043
+ return getGlobal(API_NAME3) ?? NOOP_TASK_LOGGER;
2854
3044
  }, "#getTaskLogger");
2855
3045
  __name(_LoggerAPI, "LoggerAPI");
2856
3046
  var LoggerAPI = _LoggerAPI;
2857
3047
 
2858
3048
  // src/v3/logger-api.ts
2859
3049
  var logger = LoggerAPI.getInstance();
3050
+
3051
+ // src/v3/limits.ts
3052
+ var OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = 256;
3053
+ var OTEL_LOG_ATTRIBUTE_COUNT_LIMIT = 256;
3054
+ var OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT = 1028;
3055
+ var OTEL_LOG_ATTRIBUTE_VALUE_LENGTH_LIMIT = 1028;
3056
+ var OTEL_SPAN_EVENT_COUNT_LIMIT = 10;
3057
+ var OTEL_LINK_COUNT_LIMIT = 2;
3058
+ var OTEL_ATTRIBUTE_PER_LINK_COUNT_LIMIT = 10;
3059
+ var OTEL_ATTRIBUTE_PER_EVENT_COUNT_LIMIT = 10;
3060
+ var OFFLOAD_IO_PACKET_LENGTH_LIMIT = 128 * 1024;
3061
+ function imposeAttributeLimits(attributes) {
3062
+ const newAttributes = {};
3063
+ for (const [key, value] of Object.entries(attributes)) {
3064
+ if (calculateAttributeValueLength(value) > OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT) {
3065
+ continue;
3066
+ }
3067
+ if (Object.keys(newAttributes).length >= OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT) {
3068
+ break;
3069
+ }
3070
+ newAttributes[key] = value;
3071
+ }
3072
+ return newAttributes;
3073
+ }
3074
+ __name(imposeAttributeLimits, "imposeAttributeLimits");
3075
+ function calculateAttributeValueLength(value) {
3076
+ if (value === void 0 || value === null) {
3077
+ return 0;
3078
+ }
3079
+ if (typeof value === "string") {
3080
+ return value.length;
3081
+ }
3082
+ if (typeof value === "number") {
3083
+ return 8;
3084
+ }
3085
+ if (typeof value === "boolean") {
3086
+ return 4;
3087
+ }
3088
+ if (Array.isArray(value)) {
3089
+ return value.reduce((acc, v) => acc + calculateAttributeValueLength(v), 0);
3090
+ }
3091
+ return 0;
3092
+ }
3093
+ __name(calculateAttributeValueLength, "calculateAttributeValueLength");
2860
3094
  function dateDifference(date1, date2) {
2861
3095
  return Math.abs(date1.getTime() - date2.getTime());
2862
3096
  }
@@ -3021,11 +3255,10 @@ var _DevRuntimeManager = class _DevRuntimeManager {
3021
3255
  };
3022
3256
  __name(_DevRuntimeManager, "DevRuntimeManager");
3023
3257
  var DevRuntimeManager = _DevRuntimeManager;
3024
-
3025
- // src/v3/runtime/prodRuntimeManager.ts
3026
3258
  var _ProdRuntimeManager = class _ProdRuntimeManager {
3027
- constructor(ipc) {
3259
+ constructor(ipc, options = {}) {
3028
3260
  this.ipc = ipc;
3261
+ this.options = options;
3029
3262
  this._taskWaits = /* @__PURE__ */ new Map();
3030
3263
  this._batchWaits = /* @__PURE__ */ new Map();
3031
3264
  this._tasks = /* @__PURE__ */ new Map();
@@ -3041,12 +3274,9 @@ var _ProdRuntimeManager = class _ProdRuntimeManager {
3041
3274
  return this._tasks.get(id);
3042
3275
  }
3043
3276
  async waitForDuration(ms) {
3044
- let timeout;
3045
3277
  const now = Date.now();
3046
- const resolveAfterDuration = new Promise((resolve) => {
3047
- timeout = setTimeout(resolve, ms);
3048
- });
3049
- if (ms < 1e4) {
3278
+ const resolveAfterDuration = setTimeout$1(ms, "duration");
3279
+ if (ms <= this.waitThresholdInMs) {
3050
3280
  await resolveAfterDuration;
3051
3281
  return;
3052
3282
  }
@@ -3070,13 +3300,13 @@ var _ProdRuntimeManager = class _ProdRuntimeManager {
3070
3300
  resolveAfterDuration
3071
3301
  ]);
3072
3302
  this.ipc.send("CANCEL_CHECKPOINT", {});
3073
- clearTimeout(timeout);
3074
3303
  }
3075
3304
  resumeAfterRestore() {
3076
3305
  if (!this._waitForRestore) {
3077
3306
  return;
3078
3307
  }
3079
- this._waitForRestore.resolve();
3308
+ clock.reset();
3309
+ this._waitForRestore.resolve("restore");
3080
3310
  this._waitForRestore = void 0;
3081
3311
  }
3082
3312
  async waitUntil(date) {
@@ -3131,9 +3361,49 @@ var _ProdRuntimeManager = class _ProdRuntimeManager {
3131
3361
  }
3132
3362
  this._taskWaits.delete(execution.run.id);
3133
3363
  }
3364
+ get waitThresholdInMs() {
3365
+ return this.options.waitThresholdInMs ?? 3e4;
3366
+ }
3134
3367
  };
3135
3368
  __name(_ProdRuntimeManager, "ProdRuntimeManager");
3136
3369
  var ProdRuntimeManager = _ProdRuntimeManager;
3370
+ var _originClockTime, originClockTime_get, _originPreciseDate, originPreciseDate_get;
3371
+ var _PreciseWallClock = class _PreciseWallClock {
3372
+ constructor(options = {}) {
3373
+ __privateAdd(this, _originClockTime);
3374
+ __privateAdd(this, _originPreciseDate);
3375
+ this._origin = {
3376
+ clockTime: options.origin ?? process.hrtime(),
3377
+ preciseDate: options.now ?? new PreciseDate()
3378
+ };
3379
+ }
3380
+ preciseNow() {
3381
+ const elapsedHrTime = process.hrtime(__privateGet(this, _originClockTime, originClockTime_get));
3382
+ const elapsedNanoseconds = BigInt(elapsedHrTime[0]) * BigInt(1e9) + BigInt(elapsedHrTime[1]);
3383
+ const preciseDate = new PreciseDate(__privateGet(this, _originPreciseDate, originPreciseDate_get).getFullTime() + elapsedNanoseconds);
3384
+ const dateStruct = preciseDate.toStruct();
3385
+ return [
3386
+ dateStruct.seconds,
3387
+ dateStruct.nanos
3388
+ ];
3389
+ }
3390
+ reset() {
3391
+ this._origin = {
3392
+ clockTime: process.hrtime(),
3393
+ preciseDate: new PreciseDate()
3394
+ };
3395
+ }
3396
+ };
3397
+ _originClockTime = new WeakSet();
3398
+ originClockTime_get = /* @__PURE__ */ __name(function() {
3399
+ return this._origin.clockTime;
3400
+ }, "#originClockTime");
3401
+ _originPreciseDate = new WeakSet();
3402
+ originPreciseDate_get = /* @__PURE__ */ __name(function() {
3403
+ return this._origin.preciseDate;
3404
+ }, "#originPreciseDate");
3405
+ __name(_PreciseWallClock, "PreciseWallClock");
3406
+ var PreciseWallClock = _PreciseWallClock;
3137
3407
  var _TriggerTracer = class _TriggerTracer {
3138
3408
  constructor(_config) {
3139
3409
  this._config = _config;
@@ -3162,7 +3432,8 @@ var _TriggerTracer = class _TriggerTracer {
3162
3432
  const attributes = options?.attributes ?? {};
3163
3433
  return this.tracer.startActiveSpan(name, {
3164
3434
  ...options,
3165
- attributes
3435
+ attributes,
3436
+ startTime: clock.preciseNow()
3166
3437
  }, parentContext, async (span) => {
3167
3438
  this.tracer.startSpan(name, {
3168
3439
  ...options,
@@ -3183,7 +3454,7 @@ var _TriggerTracer = class _TriggerTracer {
3183
3454
  });
3184
3455
  throw e;
3185
3456
  } finally {
3186
- span.end();
3457
+ span.end(clock.preciseNow());
3187
3458
  }
3188
3459
  });
3189
3460
  }
@@ -3206,12 +3477,11 @@ __name(_TriggerTracer, "TriggerTracer");
3206
3477
  var TriggerTracer = _TriggerTracer;
3207
3478
  var _handleLog, handleLog_fn, _getTimestampInHrTime2, getTimestampInHrTime_fn2, _getAttributes, getAttributes_fn;
3208
3479
  var _ConsoleInterceptor = class _ConsoleInterceptor {
3209
- constructor(logger2, preciseDateOrigin) {
3480
+ constructor(logger2) {
3210
3481
  __privateAdd(this, _handleLog);
3211
3482
  __privateAdd(this, _getTimestampInHrTime2);
3212
3483
  __privateAdd(this, _getAttributes);
3213
3484
  this.logger = logger2;
3214
- this.preciseDateOrigin = preciseDateOrigin;
3215
3485
  }
3216
3486
  // Intercept the console and send logs to the OpenTelemetry logger
3217
3487
  // during the execution of the callback
@@ -3236,22 +3506,21 @@ var _ConsoleInterceptor = class _ConsoleInterceptor {
3236
3506
  }
3237
3507
  }
3238
3508
  log(...args) {
3239
- __privateMethod(this, _handleLog, handleLog_fn).call(this, SeverityNumber.INFO, "Log", ...args);
3509
+ __privateMethod(this, _handleLog, handleLog_fn).call(this, SeverityNumber.INFO, __privateMethod(this, _getTimestampInHrTime2, getTimestampInHrTime_fn2).call(this), "Log", ...args);
3240
3510
  }
3241
3511
  info(...args) {
3242
- __privateMethod(this, _handleLog, handleLog_fn).call(this, SeverityNumber.INFO, "Info", ...args);
3512
+ __privateMethod(this, _handleLog, handleLog_fn).call(this, SeverityNumber.INFO, __privateMethod(this, _getTimestampInHrTime2, getTimestampInHrTime_fn2).call(this), "Info", ...args);
3243
3513
  }
3244
3514
  warn(...args) {
3245
- __privateMethod(this, _handleLog, handleLog_fn).call(this, SeverityNumber.WARN, "Warn", ...args);
3515
+ __privateMethod(this, _handleLog, handleLog_fn).call(this, SeverityNumber.WARN, __privateMethod(this, _getTimestampInHrTime2, getTimestampInHrTime_fn2).call(this), "Warn", ...args);
3246
3516
  }
3247
3517
  error(...args) {
3248
- __privateMethod(this, _handleLog, handleLog_fn).call(this, SeverityNumber.ERROR, "Error", ...args);
3518
+ __privateMethod(this, _handleLog, handleLog_fn).call(this, SeverityNumber.ERROR, __privateMethod(this, _getTimestampInHrTime2, getTimestampInHrTime_fn2).call(this), "Error", ...args);
3249
3519
  }
3250
3520
  };
3251
3521
  _handleLog = new WeakSet();
3252
- handleLog_fn = /* @__PURE__ */ __name(function(severityNumber, severityText, ...args) {
3522
+ handleLog_fn = /* @__PURE__ */ __name(function(severityNumber, timestamp, severityText, ...args) {
3253
3523
  const body = util.format(...args);
3254
- const timestamp = __privateMethod(this, _getTimestampInHrTime2, getTimestampInHrTime_fn2).call(this);
3255
3524
  const parsed = tryParseJSON(body);
3256
3525
  if (parsed.ok) {
3257
3526
  this.logger.emit({
@@ -3276,7 +3545,7 @@ handleLog_fn = /* @__PURE__ */ __name(function(severityNumber, severityText, ...
3276
3545
  }, "#handleLog");
3277
3546
  _getTimestampInHrTime2 = new WeakSet();
3278
3547
  getTimestampInHrTime_fn2 = /* @__PURE__ */ __name(function() {
3279
- return calculatePreciseDateHrTime(this.preciseDateOrigin);
3548
+ return clock.preciseNow();
3280
3549
  }, "#getTimestampInHrTime");
3281
3550
  _getAttributes = new WeakSet();
3282
3551
  getAttributes_fn = /* @__PURE__ */ __name(function(severityNumber1) {
@@ -3650,19 +3919,24 @@ var _TracingSDK = class _TracingSDK {
3650
3919
  forceFlushTimeoutMillis: config.forceFlushTimeoutMillis ?? 500,
3651
3920
  resource: commonResources,
3652
3921
  spanLimits: {
3653
- attributeCountLimit: 1e3,
3654
- attributeValueLengthLimit: 1e3,
3655
- eventCountLimit: 100,
3656
- attributePerEventCountLimit: 100,
3657
- linkCountLimit: 10,
3658
- attributePerLinkCountLimit: 100
3922
+ attributeCountLimit: OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT,
3923
+ attributeValueLengthLimit: OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT,
3924
+ eventCountLimit: OTEL_SPAN_EVENT_COUNT_LIMIT,
3925
+ attributePerEventCountLimit: OTEL_ATTRIBUTE_PER_EVENT_COUNT_LIMIT,
3926
+ linkCountLimit: OTEL_LINK_COUNT_LIMIT,
3927
+ attributePerLinkCountLimit: OTEL_ATTRIBUTE_PER_LINK_COUNT_LIMIT
3659
3928
  }
3660
3929
  });
3661
3930
  const spanExporter = new OTLPTraceExporter({
3662
3931
  url: `${config.url}/v1/traces`,
3663
3932
  timeoutMillis: config.forceFlushTimeoutMillis ?? 1e3
3664
3933
  });
3665
- traceProvider.addSpanProcessor(new TaskContextSpanProcessor(new SimpleSpanProcessor(spanExporter)));
3934
+ traceProvider.addSpanProcessor(new TaskContextSpanProcessor(getEnvVar("OTEL_BATCH_PROCESSING_ENABLED") === "1" ? new BatchSpanProcessor(spanExporter, {
3935
+ maxExportBatchSize: parseInt(getEnvVar("OTEL_SPAN_MAX_EXPORT_BATCH_SIZE") ?? "64"),
3936
+ scheduledDelayMillis: parseInt(getEnvVar("OTEL_SPAN_SCHEDULED_DELAY_MILLIS") ?? "200"),
3937
+ exportTimeoutMillis: parseInt(getEnvVar("OTEL_SPAN_EXPORT_TIMEOUT_MILLIS") ?? "30000"),
3938
+ maxQueueSize: parseInt(getEnvVar("OTEL_SPAN_MAX_QUEUE_SIZE") ?? "512")
3939
+ }) : new SimpleSpanProcessor(spanExporter)));
3666
3940
  traceProvider.register();
3667
3941
  registerInstrumentations({
3668
3942
  instrumentations: config.instrumentations ?? [],
@@ -3674,11 +3948,16 @@ var _TracingSDK = class _TracingSDK {
3674
3948
  const loggerProvider = new LoggerProvider({
3675
3949
  resource: commonResources,
3676
3950
  logRecordLimits: {
3677
- attributeCountLimit: 1e3,
3678
- attributeValueLengthLimit: 1e3
3951
+ attributeCountLimit: OTEL_LOG_ATTRIBUTE_COUNT_LIMIT,
3952
+ attributeValueLengthLimit: OTEL_LOG_ATTRIBUTE_VALUE_LENGTH_LIMIT
3679
3953
  }
3680
3954
  });
3681
- loggerProvider.addLogRecordProcessor(new TaskContextLogProcessor(new SimpleLogRecordProcessor(logExporter)));
3955
+ loggerProvider.addLogRecordProcessor(new TaskContextLogProcessor(getEnvVar("OTEL_BATCH_PROCESSING_ENABLED") === "1" ? new BatchLogRecordProcessor(logExporter, {
3956
+ maxExportBatchSize: parseInt(getEnvVar("OTEL_LOG_MAX_EXPORT_BATCH_SIZE") ?? "64"),
3957
+ scheduledDelayMillis: parseInt(getEnvVar("OTEL_LOG_SCHEDULED_DELAY_MILLIS") ?? "200"),
3958
+ exportTimeoutMillis: parseInt(getEnvVar("OTEL_LOG_EXPORT_TIMEOUT_MILLIS") ?? "30000"),
3959
+ maxQueueSize: parseInt(getEnvVar("OTEL_LOG_MAX_QUEUE_SIZE") ?? "512")
3960
+ }) : new SimpleLogRecordProcessor(logExporter)));
3682
3961
  this._logProvider = loggerProvider;
3683
3962
  this._spanExporter = spanExporter;
3684
3963
  this._traceProvider = traceProvider;
@@ -3687,11 +3966,11 @@ var _TracingSDK = class _TracingSDK {
3687
3966
  this.getTracer = traceProvider.getTracer.bind(traceProvider);
3688
3967
  }
3689
3968
  async flush() {
3690
- await this._spanExporter.forceFlush?.();
3969
+ await this._traceProvider.forceFlush();
3691
3970
  await this._logProvider.forceFlush();
3692
3971
  }
3693
3972
  async shutdown() {
3694
- await this._spanExporter.shutdown();
3973
+ await this._traceProvider.shutdown();
3695
3974
  await this._logProvider.shutdown();
3696
3975
  }
3697
3976
  };
@@ -3742,6 +4021,275 @@ function recordSpanException(span, error) {
3742
4021
  });
3743
4022
  }
3744
4023
  __name(recordSpanException, "recordSpanException");
4024
+
4025
+ // src/v3/utils/ioSerialization.ts
4026
+ async function parsePacket(value) {
4027
+ if (!value.data) {
4028
+ return void 0;
4029
+ }
4030
+ switch (value.dataType) {
4031
+ case "application/json":
4032
+ return JSON.parse(value.data);
4033
+ case "application/super+json":
4034
+ const { parse } = await loadSuperJSON();
4035
+ return parse(value.data);
4036
+ case "text/plain":
4037
+ return value.data;
4038
+ case "application/store":
4039
+ throw new Error(`Cannot parse an application/store packet (${value.data}). Needs to be imported first.`);
4040
+ default:
4041
+ return value.data;
4042
+ }
4043
+ }
4044
+ __name(parsePacket, "parsePacket");
4045
+ async function stringifyIO(value) {
4046
+ if (value === void 0) {
4047
+ return {
4048
+ dataType: "application/json"
4049
+ };
4050
+ }
4051
+ if (typeof value === "string") {
4052
+ return {
4053
+ data: value,
4054
+ dataType: "text/plain"
4055
+ };
4056
+ }
4057
+ try {
4058
+ const { stringify } = await loadSuperJSON();
4059
+ const data = stringify(value);
4060
+ return {
4061
+ data,
4062
+ dataType: "application/super+json"
4063
+ };
4064
+ } catch {
4065
+ return {
4066
+ dataType: "application/json"
4067
+ };
4068
+ }
4069
+ }
4070
+ __name(stringifyIO, "stringifyIO");
4071
+ async function conditionallyExportPacket(packet, pathPrefix, tracer) {
4072
+ if (apiClientManager.client) {
4073
+ const { needsOffloading, size } = packetRequiresOffloading(packet);
4074
+ if (needsOffloading) {
4075
+ if (!tracer) {
4076
+ return await exportPacket(packet, pathPrefix);
4077
+ } else {
4078
+ const result = await tracer.startActiveSpan("store.uploadOutput", async (span) => {
4079
+ return await exportPacket(packet, pathPrefix);
4080
+ }, {
4081
+ attributes: {
4082
+ byteLength: size,
4083
+ [SemanticInternalAttributes.STYLE_ICON]: "cloud-upload"
4084
+ }
4085
+ });
4086
+ return result ?? packet;
4087
+ }
4088
+ }
4089
+ }
4090
+ return packet;
4091
+ }
4092
+ __name(conditionallyExportPacket, "conditionallyExportPacket");
4093
+ function packetRequiresOffloading(packet) {
4094
+ if (!packet.data) {
4095
+ return {
4096
+ needsOffloading: false,
4097
+ size: 0
4098
+ };
4099
+ }
4100
+ const byteSize = Buffer.byteLength(packet.data, "utf8");
4101
+ return {
4102
+ needsOffloading: byteSize >= OFFLOAD_IO_PACKET_LENGTH_LIMIT,
4103
+ size: byteSize
4104
+ };
4105
+ }
4106
+ __name(packetRequiresOffloading, "packetRequiresOffloading");
4107
+ async function exportPacket(packet, pathPrefix) {
4108
+ const filename = `${pathPrefix}.${getPacketExtension(packet.dataType)}`;
4109
+ const presignedResponse = await apiClientManager.client.createUploadPayloadUrl(filename);
4110
+ if (presignedResponse.ok) {
4111
+ const uploadResponse = await fetch(presignedResponse.data.presignedUrl, {
4112
+ method: "PUT",
4113
+ headers: {
4114
+ "Content-Type": packet.dataType
4115
+ },
4116
+ body: packet.data
4117
+ });
4118
+ if (!uploadResponse.ok) {
4119
+ throw new Error(`Failed to upload output to ${presignedResponse.data.presignedUrl}: ${uploadResponse.statusText}`);
4120
+ }
4121
+ return {
4122
+ data: filename,
4123
+ dataType: "application/store"
4124
+ };
4125
+ }
4126
+ return packet;
4127
+ }
4128
+ __name(exportPacket, "exportPacket");
4129
+ async function conditionallyImportPacket(packet, tracer) {
4130
+ if (packet.dataType !== "application/store") {
4131
+ return packet;
4132
+ }
4133
+ if (!tracer) {
4134
+ return await importPacket(packet);
4135
+ } else {
4136
+ const result = await tracer.startActiveSpan("store.downloadPayload", async (span) => {
4137
+ return await importPacket(packet, span);
4138
+ }, {
4139
+ attributes: {
4140
+ [SemanticInternalAttributes.STYLE_ICON]: "cloud-download"
4141
+ }
4142
+ });
4143
+ return result ?? packet;
4144
+ }
4145
+ }
4146
+ __name(conditionallyImportPacket, "conditionallyImportPacket");
4147
+ async function importPacket(packet, span) {
4148
+ if (!packet.data) {
4149
+ return packet;
4150
+ }
4151
+ if (!apiClientManager.client) {
4152
+ return packet;
4153
+ }
4154
+ const presignedResponse = await apiClientManager.client.getPayloadUrl(packet.data);
4155
+ if (presignedResponse.ok) {
4156
+ const response = await fetch(presignedResponse.data.presignedUrl);
4157
+ if (!response.ok) {
4158
+ throw new Error(`Failed to import packet ${presignedResponse.data.presignedUrl}: ${response.statusText}`);
4159
+ }
4160
+ const data = await response.text();
4161
+ span?.setAttribute("size", Buffer.byteLength(data, "utf8"));
4162
+ return {
4163
+ data,
4164
+ dataType: response.headers.get("content-type") ?? "application/json"
4165
+ };
4166
+ }
4167
+ return packet;
4168
+ }
4169
+ __name(importPacket, "importPacket");
4170
+ async function createPacketAttributes(packet, dataKey, dataTypeKey) {
4171
+ if (!packet.data) {
4172
+ return;
4173
+ }
4174
+ switch (packet.dataType) {
4175
+ case "application/json":
4176
+ return {
4177
+ ...flattenAttributes(packet, dataKey),
4178
+ [dataTypeKey]: packet.dataType
4179
+ };
4180
+ case "application/super+json":
4181
+ const { parse } = await loadSuperJSON();
4182
+ if (typeof packet.data === "undefined" || packet.data === null) {
4183
+ return;
4184
+ }
4185
+ try {
4186
+ const parsed = parse(packet.data);
4187
+ const jsonified = JSON.parse(JSON.stringify(parsed, safeReplacer));
4188
+ return {
4189
+ ...flattenAttributes(jsonified, dataKey),
4190
+ [dataTypeKey]: "application/json"
4191
+ };
4192
+ } catch {
4193
+ return;
4194
+ }
4195
+ case "application/store":
4196
+ return {
4197
+ [dataKey]: packet.data,
4198
+ [dataTypeKey]: packet.dataType
4199
+ };
4200
+ case "text/plain":
4201
+ return {
4202
+ [dataKey]: packet.data,
4203
+ [dataTypeKey]: packet.dataType
4204
+ };
4205
+ default:
4206
+ return;
4207
+ }
4208
+ }
4209
+ __name(createPacketAttributes, "createPacketAttributes");
4210
+ async function createPacketAttributesAsJson(data, dataType) {
4211
+ if (typeof data === "string" || typeof data === "number" || typeof data === "boolean" || data === null || data === void 0) {
4212
+ return data;
4213
+ }
4214
+ switch (dataType) {
4215
+ case "application/json":
4216
+ return imposeAttributeLimits(flattenAttributes(data, void 0));
4217
+ case "application/super+json":
4218
+ const { deserialize } = await loadSuperJSON();
4219
+ const deserialized = deserialize(data);
4220
+ const jsonify = safeJsonParse(JSON.stringify(deserialized, safeReplacer));
4221
+ return imposeAttributeLimits(flattenAttributes(jsonify, void 0));
4222
+ case "application/store":
4223
+ return data;
4224
+ default:
4225
+ return {};
4226
+ }
4227
+ }
4228
+ __name(createPacketAttributesAsJson, "createPacketAttributesAsJson");
4229
+ async function prettyPrintPacket(rawData, dataType) {
4230
+ if (rawData === void 0) {
4231
+ return "";
4232
+ }
4233
+ if (dataType === "application/super+json") {
4234
+ const { deserialize } = await loadSuperJSON();
4235
+ return await prettyPrintPacket(deserialize(rawData), "application/json");
4236
+ }
4237
+ if (dataType === "application/json") {
4238
+ return JSON.stringify(rawData, safeReplacer, 2);
4239
+ }
4240
+ if (typeof rawData === "string") {
4241
+ return rawData;
4242
+ }
4243
+ return JSON.stringify(rawData, safeReplacer, 2);
4244
+ }
4245
+ __name(prettyPrintPacket, "prettyPrintPacket");
4246
+ function safeReplacer(key, value) {
4247
+ if (typeof value === "bigint") {
4248
+ return value.toString();
4249
+ }
4250
+ if (value instanceof RegExp) {
4251
+ return value.toString();
4252
+ }
4253
+ if (value instanceof Set) {
4254
+ return Array.from(value);
4255
+ }
4256
+ if (value instanceof Map) {
4257
+ const obj = {};
4258
+ value.forEach((v, k) => {
4259
+ obj[k] = v;
4260
+ });
4261
+ return obj;
4262
+ }
4263
+ return value;
4264
+ }
4265
+ __name(safeReplacer, "safeReplacer");
4266
+ function getPacketExtension(outputType) {
4267
+ switch (outputType) {
4268
+ case "application/json":
4269
+ return "json";
4270
+ case "application/super+json":
4271
+ return "json";
4272
+ case "text/plain":
4273
+ return "txt";
4274
+ default:
4275
+ return "txt";
4276
+ }
4277
+ }
4278
+ __name(getPacketExtension, "getPacketExtension");
4279
+ async function loadSuperJSON() {
4280
+ return await import('superjson');
4281
+ }
4282
+ __name(loadSuperJSON, "loadSuperJSON");
4283
+ function safeJsonParse(value) {
4284
+ try {
4285
+ return JSON.parse(value);
4286
+ } catch {
4287
+ return;
4288
+ }
4289
+ }
4290
+ __name(safeJsonParse, "safeJsonParse");
4291
+
4292
+ // src/v3/workers/taskExecutor.ts
3745
4293
  var _callRun, callRun_fn, _callTaskInit, callTaskInit_fn, _callTaskCleanup, callTaskCleanup_fn, _handleError, handleError_fn;
3746
4294
  var _TaskExecutor = class _TaskExecutor {
3747
4295
  constructor(task, options) {
@@ -3758,12 +4306,14 @@ var _TaskExecutor = class _TaskExecutor {
3758
4306
  this._handleErrorFn = options.handleErrorFn;
3759
4307
  }
3760
4308
  async execute(execution, worker, traceContext) {
3761
- const parsedPayload = JSON.parse(execution.run.payload);
3762
4309
  const ctx = TaskRunContext.parse(execution);
3763
4310
  const attemptMessage = `Attempt ${execution.attempt.number}`;
4311
+ const originalPacket = {
4312
+ data: execution.run.payload,
4313
+ dataType: execution.run.payloadType
4314
+ };
3764
4315
  const result = await taskContextManager.runWith({
3765
4316
  ctx,
3766
- payload: parsedPayload,
3767
4317
  worker
3768
4318
  }, async () => {
3769
4319
  this._tracingSDK.asyncResourceDetector.resolveWithAttributes({
@@ -3773,17 +4323,25 @@ var _TaskExecutor = class _TaskExecutor {
3773
4323
  });
3774
4324
  return await this._tracer.startActiveSpan(attemptMessage, async (span) => {
3775
4325
  return await this._consoleInterceptor.intercept(console, async () => {
3776
- const init = await __privateMethod(this, _callTaskInit, callTaskInit_fn).call(this, parsedPayload, ctx);
4326
+ let parsedPayload;
4327
+ let initOutput;
3777
4328
  try {
3778
- const output = await __privateMethod(this, _callRun, callRun_fn).call(this, parsedPayload, ctx, init);
4329
+ const payloadPacket = await conditionallyImportPacket(originalPacket, this._tracer);
4330
+ parsedPayload = await parsePacket(payloadPacket);
4331
+ initOutput = await __privateMethod(this, _callTaskInit, callTaskInit_fn).call(this, parsedPayload, ctx);
4332
+ const output = await __privateMethod(this, _callRun, callRun_fn).call(this, parsedPayload, ctx, initOutput);
3779
4333
  try {
3780
- span.setAttributes(flattenAttributes(output, SemanticInternalAttributes.OUTPUT));
3781
- const serializedOutput = JSON.stringify(output);
4334
+ const stringifiedOutput = await stringifyIO(output);
4335
+ const finalOutput = await conditionallyExportPacket(stringifiedOutput, `${execution.attempt.id}/output`, this._tracer);
4336
+ const attributes = await createPacketAttributes(finalOutput, SemanticInternalAttributes.OUTPUT, SemanticInternalAttributes.OUTPUT_TYPE);
4337
+ if (attributes) {
4338
+ span.setAttributes(attributes);
4339
+ }
3782
4340
  return {
3783
4341
  ok: true,
3784
4342
  id: execution.attempt.id,
3785
- output: serializedOutput,
3786
- outputType: "application/json"
4343
+ output: finalOutput.data,
4344
+ outputType: finalOutput.dataType
3787
4345
  };
3788
4346
  } catch (stringifyError) {
3789
4347
  recordSpanException(span, stringifyError);
@@ -3821,14 +4379,13 @@ var _TaskExecutor = class _TaskExecutor {
3821
4379
  };
3822
4380
  }
3823
4381
  } finally {
3824
- await __privateMethod(this, _callTaskCleanup, callTaskCleanup_fn).call(this, parsedPayload, ctx, init);
4382
+ await __privateMethod(this, _callTaskCleanup, callTaskCleanup_fn).call(this, parsedPayload, ctx, initOutput);
3825
4383
  }
3826
4384
  });
3827
4385
  }, {
3828
4386
  kind: SpanKind.CONSUMER,
3829
4387
  attributes: {
3830
4388
  [SemanticInternalAttributes.STYLE_ICON]: "attempt",
3831
- ...flattenAttributes(parsedPayload, SemanticInternalAttributes.PAYLOAD),
3832
4389
  ...accessoryAttributes({
3833
4390
  items: [
3834
4391
  {
@@ -3999,6 +4556,7 @@ var dependencies = {
3999
4556
  "humanize-duration": "^3.27.3",
4000
4557
  "socket.io": "^4.7.4",
4001
4558
  "socket.io-client": "^4.7.4",
4559
+ superjson: "^2.2.1",
4002
4560
  ulidx: "^2.2.1",
4003
4561
  zod: "3.22.3",
4004
4562
  "zod-error": "1.5.0"
@@ -4020,6 +4578,6 @@ function parseBatchTriggerTaskRequestBody(body) {
4020
4578
  }
4021
4579
  __name(parseBatchTriggerTaskRequestBody, "parseBatchTriggerTaskRequestBody");
4022
4580
 
4023
- export { ApiClient, ApiClientManager, BackgroundWorkerClientMessages, BackgroundWorkerMetadata, BackgroundWorkerProperties, BackgroundWorkerServerMessages, BatchTaskRunExecutionResult, BatchTriggerTaskRequestBody, BatchTriggerTaskResponse, CancellationSpanEvent, ClientToSharedQueueMessages, Config, ConsoleInterceptor, CoordinatorToPlatformMessages, CoordinatorToProdWorkerMessages, CreateAuthorizationCodeResponseSchema, CreateBackgroundWorkerRequestBody, CreateBackgroundWorkerResponse, DevRuntimeManager, EventFilter, ExceptionEventProperties, ExceptionSpanEvent, ExternalBuildData, FetchRetryBackoffStrategy, FetchRetryByStatusOptions, FetchRetryHeadersStrategy, FetchRetryOptions, FetchRetryStrategy, FetchTimeoutOptions, FixedWindowRateLimit, GetBatchResponseBody, GetDeploymentResponseBody, GetEnvironmentVariablesResponseBody, GetPersonalAccessTokenRequestSchema, GetPersonalAccessTokenResponseSchema, GetProjectEnvResponse, GetProjectResponseBody, GetProjectsResponseBody, ImageDetailsMetadata, InitializeDeploymentRequestBody, InitializeDeploymentResponseBody, LogLevel, Machine, OtelTaskLogger, OtherSpanEvent, PRIMARY_VARIANT, PlatformToCoordinatorMessages, PlatformToProviderMessages, ProdChildToWorkerMessages, ProdRuntimeManager, ProdTaskRunExecution, ProdTaskRunExecutionPayload, ProdWorkerSocketData, ProdWorkerToChildMessages, ProdWorkerToCoordinatorMessages, ProviderToPlatformMessages, QueueOptions, RateLimitOptions, RetryOptions, SemanticInternalAttributes, SharedQueueToClientMessages, SimpleStructuredLogger, SlidingWindowRateLimit, SpanEvent, SpanEvents, SpanMessagingEvent, StartDeploymentIndexingRequestBody, StartDeploymentIndexingResponseBody, TaskContextSpanProcessor, TaskEventStyle, TaskExecutor, TaskMetadata, TaskMetadataWithFilePath, TaskResource, TaskRun, TaskRunBuiltInError, TaskRunContext, TaskRunCustomErrorObject, TaskRunError, TaskRunErrorCodes, TaskRunExecution, TaskRunExecutionAttempt, TaskRunExecutionBatch, TaskRunExecutionEnvironment, TaskRunExecutionOrganization, TaskRunExecutionPayload, TaskRunExecutionProject, TaskRunExecutionQueue, TaskRunExecutionResult, TaskRunExecutionRetry, TaskRunExecutionTask, TaskRunFailedExecutionResult, TaskRunInternalError, TaskRunStringError, TaskRunSuccessfulExecutionResult, TracingSDK, TriggerTaskRequestBody, TriggerTaskResponse, TriggerTracer, UncaughtExceptionMessage, WaitReason, WhoAmIResponseSchema, ZodIpcConnection, ZodMessageHandler, ZodMessageSchema, ZodMessageSender, ZodNamespace, ZodSocketConnection, ZodSocketMessageHandler, ZodSocketMessageSender, accessoryAttributes, apiClientManager, calculateNextRetryDelay, calculatePreciseDateHrTime, calculateResetAt2 as calculateResetAt, childToWorkerMessages, clientWebsocketMessages, correctErrorStackTrace, createErrorTaskError, defaultFetchRetryOptions, defaultRetryOptions, detectDependencyVersion, eventFilterMatches, flattenAttributes, formatDuration, formatDurationInDays, formatDurationMilliseconds, formatDurationNanoseconds, getEnvVar, iconStringForSeverity, isCancellationSpanEvent, isExceptionSpanEvent, logger, millisecondsToNanoseconds, nanosecondsToMilliseconds, omit, parseBatchTriggerTaskRequestBody, parseError, parseTriggerTaskRequestBody, preciseDateOriginNow, primitiveValueOrflattenedAttributes, recordSpanException, runtime, serverWebsocketMessages, stringPatternMatchers, taskContextManager, unflattenAttributes, workerToChildMessages };
4581
+ export { ApiClient, ApiClientManager, BackgroundWorkerClientMessages, BackgroundWorkerMetadata, BackgroundWorkerProperties, BackgroundWorkerServerMessages, BatchTaskRunExecutionResult, BatchTriggerTaskRequestBody, BatchTriggerTaskResponse, CancellationSpanEvent, ClientToSharedQueueMessages, Config, ConsoleInterceptor, CoordinatorToPlatformMessages, CoordinatorToProdWorkerMessages, CreateAuthorizationCodeResponseSchema, CreateBackgroundWorkerRequestBody, CreateBackgroundWorkerResponse, CreateUploadPayloadUrlResponseBody, DeploymentErrorData, DevRuntimeManager, PreciseWallClock as DurableClock, EnvironmentType, EventFilter, ExceptionEventProperties, ExceptionSpanEvent, ExternalBuildData, FetchRetryBackoffStrategy, FetchRetryByStatusOptions, FetchRetryHeadersStrategy, FetchRetryOptions, FetchRetryStrategy, FetchTimeoutOptions, FixedWindowRateLimit, GetBatchResponseBody, GetDeploymentResponseBody, GetEnvironmentVariablesResponseBody, GetPersonalAccessTokenRequestSchema, GetPersonalAccessTokenResponseSchema, GetProjectEnvResponse, GetProjectResponseBody, GetProjectsResponseBody, ImageDetailsMetadata, InitializeDeploymentRequestBody, InitializeDeploymentResponseBody, LogLevel, Machine, MachineCpu, MachineMemory, OFFLOAD_IO_PACKET_LENGTH_LIMIT, OTEL_ATTRIBUTE_PER_EVENT_COUNT_LIMIT, OTEL_ATTRIBUTE_PER_LINK_COUNT_LIMIT, OTEL_LINK_COUNT_LIMIT, OTEL_LOG_ATTRIBUTE_COUNT_LIMIT, OTEL_LOG_ATTRIBUTE_VALUE_LENGTH_LIMIT, OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT, OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT, OTEL_SPAN_EVENT_COUNT_LIMIT, OtelTaskLogger, OtherSpanEvent, PRIMARY_VARIANT, PlatformToCoordinatorMessages, PlatformToProviderMessages, PostStartCauses, PreStopCauses, ProdChildToWorkerMessages, ProdRuntimeManager, ProdTaskRunExecution, ProdTaskRunExecutionPayload, ProdWorkerSocketData, ProdWorkerToChildMessages, ProdWorkerToCoordinatorMessages, ProviderToPlatformMessages, QueueOptions, RateLimitOptions, RetryOptions, SemanticInternalAttributes, SharedQueueToClientMessages, SimpleStructuredLogger, SlidingWindowRateLimit, SpanEvent, SpanEvents, SpanMessagingEvent, StartDeploymentIndexingRequestBody, StartDeploymentIndexingResponseBody, TaskContextSpanProcessor, TaskEventStyle, TaskExecutor, TaskMetadata, TaskMetadataFailedToParseData, TaskMetadataWithFilePath, TaskResource, TaskRun, TaskRunBuiltInError, TaskRunContext, TaskRunCustomErrorObject, TaskRunError, TaskRunErrorCodes, TaskRunExecution, TaskRunExecutionAttempt, TaskRunExecutionBatch, TaskRunExecutionEnvironment, TaskRunExecutionOrganization, TaskRunExecutionPayload, TaskRunExecutionProject, TaskRunExecutionQueue, TaskRunExecutionResult, TaskRunExecutionRetry, TaskRunExecutionTask, TaskRunFailedExecutionResult, TaskRunInternalError, TaskRunStringError, TaskRunSuccessfulExecutionResult, TracingSDK, TriggerTaskRequestBody, TriggerTaskResponse, TriggerTracer, UncaughtExceptionMessage, WaitReason, WhoAmIResponseSchema, ZodIpcConnection, ZodMessageHandler, ZodMessageSchema, ZodMessageSender, ZodNamespace, ZodSchemaParsedError, ZodSocketConnection, ZodSocketMessageHandler, ZodSocketMessageSender, accessoryAttributes, apiClientManager, calculateNextRetryDelay, calculateResetAt2 as calculateResetAt, childToWorkerMessages, clientWebsocketMessages, clock, conditionallyExportPacket, conditionallyImportPacket, correctErrorStackTrace, createErrorTaskError, createPacketAttributes, createPacketAttributesAsJson, defaultFetchRetryOptions, defaultRetryOptions, detectDependencyVersion, eventFilterMatches, flattenAttributes, formatDuration, formatDurationInDays, formatDurationMilliseconds, formatDurationNanoseconds, getEnvVar, groupTaskMetadataIssuesByTask, iconStringForSeverity, imposeAttributeLimits, isCancellationSpanEvent, isExceptionSpanEvent, logLevels, logger, millisecondsToNanoseconds, nanosecondsToMilliseconds, omit, packetRequiresOffloading, parseBatchTriggerTaskRequestBody, parseError, parsePacket, parseTriggerTaskRequestBody, prettyPrintPacket, primitiveValueOrflattenedAttributes, recordSpanException, runtime, serverWebsocketMessages, stringPatternMatchers, stringifyIO, taskContextManager, unflattenAttributes, workerToChildMessages };
4024
4582
  //# sourceMappingURL=out.js.map
4025
4583
  //# sourceMappingURL=index.mjs.map