@morsehq-dev/sdk 0.5.0-rc.6 → 0.5.1-rc.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 (104) hide show
  1. package/README.md +11 -10
  2. package/dist/anthropic/index.cjs +11 -11
  3. package/dist/anthropic/index.js +4 -4
  4. package/dist/anthropic-agent-sdk/index.cjs +40 -40
  5. package/dist/anthropic-agent-sdk/index.js +6 -6
  6. package/dist/browser/anthropic/index.cjs +11 -11
  7. package/dist/browser/anthropic/index.js +4 -4
  8. package/dist/browser/anthropic-agent-sdk/index.cjs +40 -40
  9. package/dist/browser/anthropic-agent-sdk/index.js +6 -6
  10. package/dist/browser/{chunk-PHE4P3DN.js → chunk-5IMBYZUB.js} +3 -3
  11. package/dist/browser/{chunk-PHE4P3DN.js.map → chunk-5IMBYZUB.js.map} +1 -1
  12. package/dist/browser/{chunk-MIHCAKQ2.js → chunk-7G266PKE.js} +32 -9
  13. package/dist/browser/chunk-7G266PKE.js.map +1 -0
  14. package/dist/browser/{chunk-FDWPKINR.js → chunk-AX6NEG6X.js} +4 -4
  15. package/dist/browser/{chunk-FDWPKINR.js.map → chunk-AX6NEG6X.js.map} +1 -1
  16. package/dist/browser/{chunk-ZAISDHUV.cjs → chunk-E6WORBIU.cjs} +5 -5
  17. package/dist/browser/{chunk-ZAISDHUV.cjs.map → chunk-E6WORBIU.cjs.map} +1 -1
  18. package/dist/{chunk-B3WEUUUK.cjs → browser/chunk-FYIQARMI.cjs} +7 -7
  19. package/dist/browser/{chunk-NK6D2G5O.cjs.map → chunk-FYIQARMI.cjs.map} +1 -1
  20. package/dist/browser/{chunk-WG45SF7N.cjs → chunk-HJTUPXNE.cjs} +31 -8
  21. package/dist/browser/chunk-HJTUPXNE.cjs.map +1 -0
  22. package/dist/browser/{chunk-TGN4FEKB.cjs → chunk-HNOHWDK3.cjs} +12 -12
  23. package/dist/browser/{chunk-TGN4FEKB.cjs.map → chunk-HNOHWDK3.cjs.map} +1 -1
  24. package/dist/{chunk-LEDIWC2M.js → browser/chunk-PIZVCAW7.js} +4 -4
  25. package/dist/browser/{chunk-TIZ5QRK2.js.map → chunk-PIZVCAW7.js.map} +1 -1
  26. package/dist/browser/{chunk-2LZCQD3J.js → chunk-RDNSY73W.js} +3 -3
  27. package/dist/browser/{chunk-2LZCQD3J.js.map → chunk-RDNSY73W.js.map} +1 -1
  28. package/dist/browser/{chunk-IXCAR4UA.js → chunk-TIMAH323.js} +3 -3
  29. package/dist/browser/{chunk-IXCAR4UA.js.map → chunk-TIMAH323.js.map} +1 -1
  30. package/dist/browser/{chunk-JNF26SQM.js → chunk-VSHCKROM.js} +5 -5
  31. package/dist/browser/{chunk-JNF26SQM.js.map → chunk-VSHCKROM.js.map} +1 -1
  32. package/dist/browser/{chunk-PNUCUOUA.cjs → chunk-YXCWAU36.cjs} +15 -15
  33. package/dist/browser/{chunk-PNUCUOUA.cjs.map → chunk-YXCWAU36.cjs.map} +1 -1
  34. package/dist/browser/{chunk-6YPVIGD2.cjs → chunk-Z26QGUMP.cjs} +6 -6
  35. package/dist/browser/{chunk-6YPVIGD2.cjs.map → chunk-Z26QGUMP.cjs.map} +1 -1
  36. package/dist/browser/{chunk-DQ4JWHYH.cjs → chunk-ZOOYJTDT.cjs} +18 -18
  37. package/dist/browser/{chunk-DQ4JWHYH.cjs.map → chunk-ZOOYJTDT.cjs.map} +1 -1
  38. package/dist/browser/index.cjs +189 -124
  39. package/dist/browser/index.cjs.map +1 -1
  40. package/dist/browser/index.js +111 -46
  41. package/dist/browser/index.js.map +1 -1
  42. package/dist/browser/integrations/pino.cjs +4 -4
  43. package/dist/browser/integrations/pino.js +3 -3
  44. package/dist/browser/langchain/index.cjs +17 -17
  45. package/dist/browser/langchain/index.js +2 -2
  46. package/dist/browser/langgraph/index.cjs +27 -27
  47. package/dist/browser/langgraph/index.js +5 -5
  48. package/dist/browser/openai/index.cjs +11 -11
  49. package/dist/browser/openai/index.js +2 -2
  50. package/dist/browser/openai-agents/index.cjs +34 -34
  51. package/dist/browser/openai-agents/index.js +4 -4
  52. package/dist/browser/vercel-ai/index.cjs +14 -14
  53. package/dist/browser/vercel-ai/index.js +3 -3
  54. package/dist/{browser/chunk-NK6D2G5O.cjs → chunk-2UFTRWUS.cjs} +7 -7
  55. package/dist/{chunk-B3WEUUUK.cjs.map → chunk-2UFTRWUS.cjs.map} +1 -1
  56. package/dist/{chunk-DK3RX7RS.js → chunk-4WUG3RMJ.js} +4 -4
  57. package/dist/{chunk-DK3RX7RS.js.map → chunk-4WUG3RMJ.js.map} +1 -1
  58. package/dist/{chunk-QTATKDEI.js → chunk-5MJS5ECA.js} +3 -3
  59. package/dist/{chunk-QTATKDEI.js.map → chunk-5MJS5ECA.js.map} +1 -1
  60. package/dist/{chunk-Z2AYPTB2.js → chunk-62FWHZXN.js} +5 -5
  61. package/dist/{chunk-Z2AYPTB2.js.map → chunk-62FWHZXN.js.map} +1 -1
  62. package/dist/{browser/chunk-TIZ5QRK2.js → chunk-FHQGPQFR.js} +4 -4
  63. package/dist/{chunk-LEDIWC2M.js.map → chunk-FHQGPQFR.js.map} +1 -1
  64. package/dist/{chunk-AT3YR5SP.cjs → chunk-GATTHW3X.cjs} +5 -5
  65. package/dist/{chunk-AT3YR5SP.cjs.map → chunk-GATTHW3X.cjs.map} +1 -1
  66. package/dist/{chunk-T5UFHQLZ.js → chunk-GQVNZPRF.js} +3 -3
  67. package/dist/{chunk-T5UFHQLZ.js.map → chunk-GQVNZPRF.js.map} +1 -1
  68. package/dist/{chunk-4QY5O46P.cjs → chunk-HCN6Z56N.cjs} +18 -18
  69. package/dist/{chunk-4QY5O46P.cjs.map → chunk-HCN6Z56N.cjs.map} +1 -1
  70. package/dist/{chunk-K4FHTOBB.cjs → chunk-KALB7HJ5.cjs} +12 -12
  71. package/dist/{chunk-K4FHTOBB.cjs.map → chunk-KALB7HJ5.cjs.map} +1 -1
  72. package/dist/{chunk-TEWSIQ6E.cjs → chunk-QLJAATBR.cjs} +6 -6
  73. package/dist/{chunk-TEWSIQ6E.cjs.map → chunk-QLJAATBR.cjs.map} +1 -1
  74. package/dist/{chunk-ZFZTJXIO.cjs → chunk-XBI4AMCW.cjs} +15 -15
  75. package/dist/{chunk-ZFZTJXIO.cjs.map → chunk-XBI4AMCW.cjs.map} +1 -1
  76. package/dist/{chunk-5YJXFU5U.js → chunk-YGKEP2GY.js} +32 -9
  77. package/dist/chunk-YGKEP2GY.js.map +1 -0
  78. package/dist/{chunk-2GWOF5JM.js → chunk-ZMRXUZ5L.js} +3 -3
  79. package/dist/{chunk-2GWOF5JM.js.map → chunk-ZMRXUZ5L.js.map} +1 -1
  80. package/dist/{chunk-UV5FUVNK.cjs → chunk-ZTBAMSCC.cjs} +31 -8
  81. package/dist/chunk-ZTBAMSCC.cjs.map +1 -0
  82. package/dist/index.cjs +196 -131
  83. package/dist/index.cjs.map +1 -1
  84. package/dist/index.d.cts +11 -0
  85. package/dist/index.d.ts +11 -0
  86. package/dist/index.js +112 -47
  87. package/dist/index.js.map +1 -1
  88. package/dist/integrations/pino.cjs +4 -4
  89. package/dist/integrations/pino.js +3 -3
  90. package/dist/langchain/index.cjs +17 -17
  91. package/dist/langchain/index.js +2 -2
  92. package/dist/langgraph/index.cjs +27 -27
  93. package/dist/langgraph/index.js +5 -5
  94. package/dist/openai/index.cjs +11 -11
  95. package/dist/openai/index.js +2 -2
  96. package/dist/openai-agents/index.cjs +34 -34
  97. package/dist/openai-agents/index.js +4 -4
  98. package/dist/vercel-ai/index.cjs +14 -14
  99. package/dist/vercel-ai/index.js +3 -3
  100. package/package.json +1 -1
  101. package/dist/browser/chunk-MIHCAKQ2.js.map +0 -1
  102. package/dist/browser/chunk-WG45SF7N.cjs.map +0 -1
  103. package/dist/chunk-5YJXFU5U.js.map +0 -1
  104. package/dist/chunk-UV5FUVNK.cjs.map +0 -1
@@ -1,32 +1,59 @@
1
1
  'use strict';
2
2
 
3
- var chunkDQ4JWHYH_cjs = require('./chunk-DQ4JWHYH.cjs');
4
- var chunkTGN4FEKB_cjs = require('./chunk-TGN4FEKB.cjs');
5
- require('./chunk-ZAISDHUV.cjs');
6
- var chunk6YPVIGD2_cjs = require('./chunk-6YPVIGD2.cjs');
3
+ var chunkZOOYJTDT_cjs = require('./chunk-ZOOYJTDT.cjs');
4
+ var chunkHNOHWDK3_cjs = require('./chunk-HNOHWDK3.cjs');
5
+ require('./chunk-E6WORBIU.cjs');
6
+ var chunkZ26QGUMP_cjs = require('./chunk-Z26QGUMP.cjs');
7
7
  require('./chunk-SWQOPFE4.cjs');
8
8
  require('./chunk-RBNCTHK3.cjs');
9
- var chunkWG45SF7N_cjs = require('./chunk-WG45SF7N.cjs');
9
+ var chunkHJTUPXNE_cjs = require('./chunk-HJTUPXNE.cjs');
10
10
 
11
11
  // src/_internal/auto-detect.browser.ts
12
12
  async function installAdapters() {
13
13
  }
14
14
 
15
15
  // src/index.ts
16
- chunkWG45SF7N_cjs.init_env();
16
+ chunkHJTUPXNE_cjs.init_env();
17
17
 
18
18
  // src/_internal/db-capture.browser.ts
19
19
  function maybeEnableDbCaptureFromEnv() {
20
20
  }
21
21
 
22
22
  // src/index.ts
23
- chunkWG45SF7N_cjs.init_otel_provider_browser();
24
- chunkWG45SF7N_cjs.init_redaction();
23
+ chunkHJTUPXNE_cjs.init_otel_provider_browser();
24
+ chunkHJTUPXNE_cjs.init_redaction();
25
25
 
26
26
  // src/_internal/transport.ts
27
- chunkWG45SF7N_cjs.init_diagnostics();
28
- var SDK_VERSION = "0.5.0-rc.6" ;
27
+ chunkHJTUPXNE_cjs.init_diagnostics();
28
+ var SDK_VERSION = "0.5.1-rc.1" ;
29
29
  var RETRY_AFTER_CAP_SECONDS = 30;
30
+ var MAX_SEND_ATTEMPTS = 3;
31
+ var BACKOFF_BASE_MS = 500;
32
+ var BACKOFF_MAX_MS = 1e4;
33
+ var DEFAULT_FLUSH_TIMEOUT_MS = 1e4;
34
+ function backoffDelayMs(attempt) {
35
+ const base = Math.min(BACKOFF_MAX_MS, BACKOFF_BASE_MS * 2 ** (attempt - 1));
36
+ return base * (0.5 + Math.random());
37
+ }
38
+ function dropReasonFor(attempt, closed, deadline) {
39
+ if (closed) return chunkHJTUPXNE_cjs.REASON_SHUTDOWN_DROP;
40
+ if (attempt === 1 && Date.now() >= deadline) return chunkHJTUPXNE_cjs.REASON_SEND_FAILED;
41
+ return chunkHJTUPXNE_cjs.REASON_RETRY_EXHAUSTED;
42
+ }
43
+ function withDeadline(promise, deadline) {
44
+ const remaining = Math.max(0, deadline - Date.now());
45
+ let timer;
46
+ return Promise.race([
47
+ promise,
48
+ new Promise((_, reject) => {
49
+ timer = setTimeout(() => reject(new Error("morse: flush deadline exceeded")), remaining);
50
+ })
51
+ ]).finally(() => clearTimeout(timer));
52
+ }
53
+ function sleepUntil(ms, deadline) {
54
+ const remaining = Math.max(0, Math.min(ms, deadline - Date.now()));
55
+ return new Promise((resolve) => setTimeout(resolve, remaining));
56
+ }
30
57
  function parseRetryAfter(value) {
31
58
  if (!value) return null;
32
59
  const seconds = Number(value);
@@ -104,6 +131,7 @@ var BatchTransport = class {
104
131
  maxBatchSize;
105
132
  maxQueueSize;
106
133
  fetchTimeoutMs;
134
+ flushTimeoutMs;
107
135
  fetchImpl;
108
136
  queue = [];
109
137
  timer = null;
@@ -117,6 +145,7 @@ var BatchTransport = class {
117
145
  this.maxBatchSize = opts.maxBatchSize ?? 100;
118
146
  this.maxQueueSize = opts.maxQueueSize ?? 1e4;
119
147
  this.fetchTimeoutMs = opts.fetchTimeoutMs ?? 5e3;
148
+ this.flushTimeoutMs = opts.flushTimeoutMs ?? DEFAULT_FLUSH_TIMEOUT_MS;
120
149
  this.fetchImpl = opts.fetchImpl ?? globalThis.fetch.bind(globalThis);
121
150
  const intervalMs = Math.max(50, Math.round(this.flushIntervalSeconds * 1e3));
122
151
  this.timer = setInterval(() => {
@@ -130,11 +159,11 @@ var BatchTransport = class {
130
159
  /** Enqueue an event. Non-blocking. Returns false if the queue is full. */
131
160
  track(event) {
132
161
  if (this.closed) {
133
- chunkWG45SF7N_cjs.recordDrop(chunkWG45SF7N_cjs.REASON_SHUTDOWN_DROP, "trace");
162
+ chunkHJTUPXNE_cjs.recordDrop(chunkHJTUPXNE_cjs.REASON_SHUTDOWN_DROP, "trace");
134
163
  return false;
135
164
  }
136
165
  if (this.queue.length >= this.maxQueueSize) {
137
- chunkWG45SF7N_cjs.recordDrop(chunkWG45SF7N_cjs.REASON_QUEUE_FULL, "trace");
166
+ chunkHJTUPXNE_cjs.recordDrop(chunkHJTUPXNE_cjs.REASON_QUEUE_FULL, "trace");
138
167
  return false;
139
168
  }
140
169
  this.queue.push(event);
@@ -207,56 +236,92 @@ var BatchTransport = class {
207
236
  await this.post(deriveLogsEndpoint(this.endpoint), { logs: logEntries });
208
237
  }
209
238
  }
210
- async post(url, payload) {
211
- const controller = new AbortController();
212
- const timeoutId = setTimeout(() => controller.abort(), this.fetchTimeoutMs);
239
+ async post(url, payload, deadline = Date.now() + this.flushTimeoutMs) {
240
+ let body;
213
241
  try {
214
- const resp = await this.fetchImpl(url, {
215
- method: "POST",
216
- headers: {
217
- Authorization: `Bearer ${this.apiKey}`,
218
- "Content-Type": "application/json",
219
- "User-Agent": `morse-typescript/${SDK_VERSION}`
220
- },
221
- body: JSON.stringify(payload),
222
- signal: controller.signal
242
+ body = JSON.stringify(payload);
243
+ } catch (err) {
244
+ chunkHJTUPXNE_cjs.recordDrop(chunkHJTUPXNE_cjs.REASON_ENCODE_FAILED, categoryOf(payload), countPayloadEntries(payload));
245
+ chunkHJTUPXNE_cjs.report(err, {
246
+ fingerprint: "morse.transport.post.encode",
247
+ extra: { endpoint_host: hostnameOf(url), sdk_version: SDK_VERSION }
223
248
  });
224
- chunkWG45SF7N_cjs.setLevel(resp.headers.get("X-Morse-Diagnostics"));
225
- const droppedCount = countPayloadEntries(payload);
226
- const droppedCategory = categoryOf(payload);
227
- if (resp.status === 429) {
228
- await recordQuotaState(resp);
229
- chunkWG45SF7N_cjs.recordDrop(chunkWG45SF7N_cjs.REASON_QUOTA_REJECTED, droppedCategory, droppedCount);
249
+ return;
250
+ }
251
+ const droppedCount = countPayloadEntries(payload);
252
+ const droppedCategory = categoryOf(payload);
253
+ for (let attempt = 1; attempt <= MAX_SEND_ATTEMPTS; attempt++) {
254
+ const lastAttempt = attempt >= MAX_SEND_ATTEMPTS;
255
+ const outOfTime = Date.now() >= deadline;
256
+ if (outOfTime && attempt > 1) {
257
+ chunkHJTUPXNE_cjs.recordDrop(chunkHJTUPXNE_cjs.REASON_RETRY_EXHAUSTED, droppedCategory, droppedCount);
258
+ return;
230
259
  }
231
- if (!resp.ok) {
260
+ const controller = new AbortController();
261
+ const timeoutId = setTimeout(() => controller.abort(), this.fetchTimeoutMs);
262
+ try {
263
+ const resp = await withDeadline(
264
+ this.fetchImpl(url, {
265
+ method: "POST",
266
+ headers: {
267
+ Authorization: `Bearer ${this.apiKey}`,
268
+ "Content-Type": "application/json",
269
+ "User-Agent": `morse-typescript/${SDK_VERSION}`
270
+ },
271
+ body,
272
+ signal: controller.signal
273
+ }),
274
+ deadline
275
+ );
276
+ chunkHJTUPXNE_cjs.setLevel(resp.headers.get("X-Morse-Diagnostics"));
277
+ if (resp.ok) return;
278
+ if (resp.status === 429) await recordQuotaState(resp);
232
279
  let bodySnippet = "";
233
280
  try {
234
- const text = await resp.text();
235
- bodySnippet = text.slice(0, 200);
281
+ bodySnippet = (await resp.text()).slice(0, 200);
236
282
  } catch {
237
283
  }
238
- if (resp.status !== 429) {
239
- chunkWG45SF7N_cjs.recordDrop(chunkWG45SF7N_cjs.REASON_RETRY_EXHAUSTED, droppedCategory, droppedCount);
240
- }
241
- chunkWG45SF7N_cjs.report(new Error(`morse: batch POST returned ${resp.status} ${bodySnippet}`), {
284
+ chunkHJTUPXNE_cjs.report(new Error(`morse: batch POST returned ${resp.status} ${bodySnippet}`), {
242
285
  fingerprint: "morse.transport.post.non_2xx",
243
- extra: {
244
- endpoint_host: hostnameOf(url),
245
- sdk_version: SDK_VERSION
286
+ extra: { endpoint_host: hostnameOf(url), sdk_version: SDK_VERSION }
287
+ });
288
+ if (resp.status === 429) {
289
+ if (lastAttempt) {
290
+ chunkHJTUPXNE_cjs.recordDrop(chunkHJTUPXNE_cjs.REASON_QUOTA_REJECTED, droppedCategory, droppedCount);
291
+ return;
246
292
  }
293
+ const retryAfter = parseRetryAfter(resp.headers.get("Retry-After"));
294
+ await sleepUntil((retryAfter ?? 0) * 1e3 + backoffDelayMs(attempt), deadline);
295
+ continue;
296
+ }
297
+ if (resp.status < 500) {
298
+ chunkHJTUPXNE_cjs.recordDrop(
299
+ resp.status === 401 || resp.status === 403 ? chunkHJTUPXNE_cjs.REASON_AUTH_REJECTED : chunkHJTUPXNE_cjs.REASON_ENDPOINT_REJECTED,
300
+ droppedCategory,
301
+ droppedCount
302
+ );
303
+ return;
304
+ }
305
+ if (lastAttempt || this.closed || Date.now() >= deadline) {
306
+ chunkHJTUPXNE_cjs.recordDrop(dropReasonFor(attempt, this.closed, deadline), droppedCategory, droppedCount);
307
+ return;
308
+ }
309
+ await sleepUntil(backoffDelayMs(attempt), deadline);
310
+ continue;
311
+ } catch (err) {
312
+ chunkHJTUPXNE_cjs.report(err, {
313
+ fingerprint: "morse.transport.post.network",
314
+ extra: { endpoint_host: hostnameOf(url), sdk_version: SDK_VERSION }
247
315
  });
248
- }
249
- } catch (err) {
250
- chunkWG45SF7N_cjs.recordDrop(chunkWG45SF7N_cjs.REASON_RETRY_EXHAUSTED, categoryOf(payload), countPayloadEntries(payload));
251
- chunkWG45SF7N_cjs.report(err, {
252
- fingerprint: "morse.transport.post.network",
253
- extra: {
254
- endpoint_host: hostnameOf(url),
255
- sdk_version: SDK_VERSION
316
+ if (lastAttempt || this.closed || Date.now() >= deadline) {
317
+ chunkHJTUPXNE_cjs.recordDrop(dropReasonFor(attempt, this.closed, deadline), droppedCategory, droppedCount);
318
+ return;
256
319
  }
257
- });
258
- } finally {
259
- clearTimeout(timeoutId);
320
+ await sleepUntil(backoffDelayMs(attempt), deadline);
321
+ continue;
322
+ } finally {
323
+ clearTimeout(timeoutId);
324
+ }
260
325
  }
261
326
  }
262
327
  };
@@ -292,10 +357,10 @@ function categoryOf(payload) {
292
357
  }
293
358
 
294
359
  // src/index.ts
295
- chunkWG45SF7N_cjs.init_tracing();
296
- chunkWG45SF7N_cjs.init_diagnostics();
297
- chunkWG45SF7N_cjs.init_spans();
298
- chunkWG45SF7N_cjs.init_propagation();
360
+ chunkHJTUPXNE_cjs.init_tracing();
361
+ chunkHJTUPXNE_cjs.init_diagnostics();
362
+ chunkHJTUPXNE_cjs.init_spans();
363
+ chunkHJTUPXNE_cjs.init_propagation();
299
364
  var version = SDK_VERSION;
300
365
  var singleton = null;
301
366
  var transportFactory = (opts) => new BatchTransport(opts);
@@ -315,9 +380,9 @@ function logDestinationOnce(endpoint) {
315
380
  }
316
381
  function resolveEndpoint(explicit) {
317
382
  if (explicit && explicit.length > 0) return explicit;
318
- const fromEnv = chunkWG45SF7N_cjs.getEndpoint();
383
+ const fromEnv = chunkHJTUPXNE_cjs.getEndpoint();
319
384
  if (fromEnv) return fromEnv;
320
- return chunkWG45SF7N_cjs.DEFAULT_ENDPOINT;
385
+ return chunkHJTUPXNE_cjs.DEFAULT_ENDPOINT;
321
386
  }
322
387
  var OTLP_TRACES_PATH = "/api/v1/otlp/v1/traces";
323
388
  function deriveOtlpEndpoint(tracesEndpoint) {
@@ -332,10 +397,10 @@ function deriveOtlpEndpoint(tracesEndpoint) {
332
397
  }
333
398
  }
334
399
  function buildSingleton(opts, redaction) {
335
- if (chunkWG45SF7N_cjs.isDisabled()) {
400
+ if (chunkHJTUPXNE_cjs.isDisabled()) {
336
401
  return null;
337
402
  }
338
- const apiKey = opts.apiKey ?? chunkWG45SF7N_cjs.getApiKey();
403
+ const apiKey = opts.apiKey ?? chunkHJTUPXNE_cjs.getApiKey();
339
404
  if (!apiKey) {
340
405
  if (!noApiKeyWarningEmitted) {
341
406
  logger(
@@ -347,24 +412,24 @@ function buildSingleton(opts, redaction) {
347
412
  return null;
348
413
  }
349
414
  const endpoint = resolveEndpoint(opts.endpoint);
350
- const flushIntervalSeconds = opts.flushIntervalSeconds ?? chunkWG45SF7N_cjs.getFlushIntervalSeconds();
415
+ const flushIntervalSeconds = opts.flushIntervalSeconds ?? chunkHJTUPXNE_cjs.getFlushIntervalSeconds();
351
416
  const transport = transportFactory({ apiKey, endpoint, flushIntervalSeconds });
352
- chunkWG45SF7N_cjs.setTransport(transport);
353
- chunkWG45SF7N_cjs.setRedactionConfig(redaction);
354
- chunkWG45SF7N_cjs.setDiagnosticsClientConfig({ apiKey, endpoint });
355
- const explicitSource = chunkWG45SF7N_cjs.isValidInternalSource(opts.source) ? opts.source : void 0;
356
- const resolvedSource = explicitSource ?? chunkWG45SF7N_cjs.getInternalSource() ?? null;
357
- chunkWG45SF7N_cjs.setSource(resolvedSource);
417
+ chunkHJTUPXNE_cjs.setTransport(transport);
418
+ chunkHJTUPXNE_cjs.setRedactionConfig(redaction);
419
+ chunkHJTUPXNE_cjs.setDiagnosticsClientConfig({ apiKey, endpoint });
420
+ const explicitSource = chunkHJTUPXNE_cjs.isValidInternalSource(opts.source) ? opts.source : void 0;
421
+ const resolvedSource = explicitSource ?? chunkHJTUPXNE_cjs.getInternalSource() ?? null;
422
+ chunkHJTUPXNE_cjs.setSource(resolvedSource);
358
423
  logDestinationOnce(endpoint);
359
424
  try {
360
- chunkWG45SF7N_cjs.getEngine().configure({
425
+ chunkHJTUPXNE_cjs.getEngine().configure({
361
426
  endpoint: deriveOtlpEndpoint(endpoint),
362
427
  apiKey,
363
- sampleRate: chunkWG45SF7N_cjs.getSampleRate(),
428
+ sampleRate: chunkHJTUPXNE_cjs.getSampleRate(),
364
429
  scheduleDelayMillis: flushIntervalSeconds * 1e3,
365
- maxQueueSize: chunkWG45SF7N_cjs.getMaxQueueSize(),
366
- maxExportBatchSize: chunkWG45SF7N_cjs.getMaxBatchSize(),
367
- maxFieldBytes: chunkWG45SF7N_cjs.getMaxFieldBytes(),
430
+ maxQueueSize: chunkHJTUPXNE_cjs.getMaxQueueSize(),
431
+ maxExportBatchSize: chunkHJTUPXNE_cjs.getMaxBatchSize(),
432
+ maxFieldBytes: chunkHJTUPXNE_cjs.getMaxFieldBytes(),
368
433
  // 10s (not the exporter's un-overridden 30s ceiling): a genuine
369
434
  // network blip still gets several retries with backoff; a fully dead
370
435
  // endpoint fails within a bounded, shutdown-friendly window instead
@@ -373,32 +438,32 @@ function buildSingleton(opts, redaction) {
373
438
  redactionConfig: redaction
374
439
  });
375
440
  } catch (err) {
376
- chunkWG45SF7N_cjs.report(err, { fingerprint: "morse.otel_provider.configure" });
441
+ chunkHJTUPXNE_cjs.report(err, { fingerprint: "morse.otel_provider.configure" });
377
442
  }
378
443
  void installAdapters().catch(() => {
379
444
  });
380
445
  try {
381
446
  maybeEnableDbCaptureFromEnv();
382
447
  } catch (err) {
383
- chunkWG45SF7N_cjs.report(err, { fingerprint: "morse.db_capture.register" });
448
+ chunkHJTUPXNE_cjs.report(err, { fingerprint: "morse.db_capture.register" });
384
449
  }
385
450
  return { apiKey, endpoint, transport, redaction };
386
451
  }
387
452
  function ensureInitialized() {
388
- if (chunkWG45SF7N_cjs.isDisabled()) return null;
453
+ if (chunkHJTUPXNE_cjs.isDisabled()) return null;
389
454
  if (singleton !== null) return singleton;
390
- singleton = buildSingleton({}, chunkWG45SF7N_cjs.buildRedactionConfig());
455
+ singleton = buildSingleton({}, chunkHJTUPXNE_cjs.buildRedactionConfig());
391
456
  return singleton;
392
457
  }
393
- chunkTGN4FEKB_cjs._setEnsureInitialized(() => {
458
+ chunkHNOHWDK3_cjs._setEnsureInitialized(() => {
394
459
  ensureInitialized();
395
460
  });
396
461
  function init(options = {}) {
397
- if (chunkWG45SF7N_cjs.isDisabled()) {
462
+ if (chunkHJTUPXNE_cjs.isDisabled()) {
398
463
  logger("info", "morse: MORSE_DISABLED=1 \u2014 SDK is a no-op");
399
464
  return;
400
465
  }
401
- const redaction = chunkWG45SF7N_cjs.buildRedactionConfig(options.redaction);
466
+ const redaction = chunkHJTUPXNE_cjs.buildRedactionConfig(options.redaction);
402
467
  try {
403
468
  if (singleton !== null) {
404
469
  void singleton.transport.shutdown();
@@ -406,10 +471,10 @@ function init(options = {}) {
406
471
  }
407
472
  singleton = buildSingleton(options, redaction);
408
473
  } catch (err) {
409
- chunkWG45SF7N_cjs.report(err, { fingerprint: "morse.init" });
474
+ chunkHJTUPXNE_cjs.report(err, { fingerprint: "morse.init" });
410
475
  }
411
476
  }
412
- var track = chunk6YPVIGD2_cjs.absorbErrorsSync(
477
+ var track = chunkZ26QGUMP_cjs.absorbErrorsSync(
413
478
  (options) => {
414
479
  const state = ensureInitialized();
415
480
  if (!state) return;
@@ -417,33 +482,33 @@ var track = chunk6YPVIGD2_cjs.absorbErrorsSync(
417
482
  agent_id: options.agentId,
418
483
  ...options.runData
419
484
  };
420
- const redacted = chunkWG45SF7N_cjs.redactValue(payload, state.redaction);
485
+ const redacted = chunkHJTUPXNE_cjs.redactValue(payload, state.redaction);
421
486
  state.transport.track(redacted);
422
487
  },
423
488
  { fingerprint: "morse.track" }
424
489
  );
425
- var batchTrack = chunk6YPVIGD2_cjs.absorbErrorsSync(
490
+ var batchTrack = chunkZ26QGUMP_cjs.absorbErrorsSync(
426
491
  (runs) => {
427
492
  const state = ensureInitialized();
428
493
  if (!state) return;
429
494
  for (const run2 of runs) {
430
- const redacted = chunkWG45SF7N_cjs.redactValue(run2, state.redaction);
495
+ const redacted = chunkHJTUPXNE_cjs.redactValue(run2, state.redaction);
431
496
  state.transport.track(redacted);
432
497
  }
433
498
  },
434
499
  { fingerprint: "morse.batch_track" }
435
500
  );
436
- var record = chunk6YPVIGD2_cjs.absorbErrorsSync(
501
+ var record = chunkZ26QGUMP_cjs.absorbErrorsSync(
437
502
  (rec) => {
438
503
  const state = ensureInitialized();
439
504
  if (!state) return;
440
- const traceId = chunkWG45SF7N_cjs.generateTraceId();
441
- const now = chunkWG45SF7N_cjs.nowIso();
505
+ const traceId = chunkHJTUPXNE_cjs.generateTraceId();
506
+ const now = chunkHJTUPXNE_cjs.nowIso();
442
507
  const resolvedStatus = rec.errorMessage ? "failed" : rec.status ?? "completed";
443
508
  const span2 = {
444
509
  trace_id: traceId,
445
- span_id: chunkWG45SF7N_cjs.generateSpanId(),
446
- type: chunkWG45SF7N_cjs.SpanType.AGENT,
510
+ span_id: chunkHJTUPXNE_cjs.generateSpanId(),
511
+ type: chunkHJTUPXNE_cjs.SpanType.AGENT,
447
512
  name: rec.agent,
448
513
  started_at: now,
449
514
  ended_at: now,
@@ -468,58 +533,58 @@ var record = chunk6YPVIGD2_cjs.absorbErrorsSync(
468
533
  success: rec.success,
469
534
  outcome: rec.outcome
470
535
  };
471
- const entry = chunkWG45SF7N_cjs.buildTraceEntry(traceFields, [span2]);
472
- const redacted = chunkWG45SF7N_cjs.redactValue(entry, state.redaction);
473
- chunkWG45SF7N_cjs.sendTrace(redacted);
536
+ const entry = chunkHJTUPXNE_cjs.buildTraceEntry(traceFields, [span2]);
537
+ const redacted = chunkHJTUPXNE_cjs.redactValue(entry, state.redaction);
538
+ chunkHJTUPXNE_cjs.sendTrace(redacted);
474
539
  },
475
540
  { fingerprint: "morse.record" }
476
541
  );
477
542
  function run(nameOrOpts, fn) {
478
543
  const opts = typeof nameOrOpts === "string" ? { agentName: nameOrOpts } : nameOrOpts;
479
544
  ensureInitialized();
480
- return chunkWG45SF7N_cjs.runSync(opts, fn);
545
+ return chunkHJTUPXNE_cjs.runSync(opts, fn);
481
546
  }
482
547
  function runTraced(options, fn) {
483
548
  ensureInitialized();
484
- return chunkWG45SF7N_cjs.runAsync(options, fn);
549
+ return chunkHJTUPXNE_cjs.runAsync(options, fn);
485
550
  }
486
551
  function setContext2(dims) {
487
- chunkWG45SF7N_cjs.setContext(dims);
552
+ chunkHJTUPXNE_cjs.setContext(dims);
488
553
  }
489
554
  function startSpan2(options) {
490
- return chunkWG45SF7N_cjs.startSpan(options);
555
+ return chunkHJTUPXNE_cjs.startSpan(options);
491
556
  }
492
557
  function span(options, fn) {
493
- return chunkWG45SF7N_cjs.spanSync(options, fn);
558
+ return chunkHJTUPXNE_cjs.spanSync(options, fn);
494
559
  }
495
560
  function spanAsync2(options, fn) {
496
- return chunkWG45SF7N_cjs.spanAsync(options, fn);
561
+ return chunkHJTUPXNE_cjs.spanAsync(options, fn);
497
562
  }
498
- var flush = chunk6YPVIGD2_cjs.absorbErrorsAsync(
563
+ var flush = chunkZ26QGUMP_cjs.absorbErrorsAsync(
499
564
  async () => {
500
565
  if (singleton !== null) {
501
566
  await singleton.transport.flush();
502
- await chunkWG45SF7N_cjs.getEngine().flush();
567
+ await chunkHJTUPXNE_cjs.getEngine().flush();
503
568
  }
504
569
  },
505
570
  { fingerprint: "morse.flush" }
506
571
  );
507
- var quotaState2 = chunk6YPVIGD2_cjs.absorbErrorsSync(
572
+ var quotaState2 = chunkZ26QGUMP_cjs.absorbErrorsSync(
508
573
  () => {
509
574
  if (singleton === null) return null;
510
575
  return getQuotaState();
511
576
  },
512
577
  { fingerprint: "morse.quota_state" }
513
578
  );
514
- var shutdown = chunk6YPVIGD2_cjs.absorbErrorsAsync(
579
+ var shutdown = chunkZ26QGUMP_cjs.absorbErrorsAsync(
515
580
  async () => {
516
581
  if (singleton !== null) {
517
582
  await singleton.transport.shutdown();
518
- await chunkWG45SF7N_cjs.getEngine().flush();
519
- chunkWG45SF7N_cjs.getEngine().shutdown();
520
- await chunkWG45SF7N_cjs.flushOnce();
583
+ await chunkHJTUPXNE_cjs.getEngine().flush();
584
+ chunkHJTUPXNE_cjs.getEngine().shutdown();
585
+ await chunkHJTUPXNE_cjs.flushOnce();
521
586
  singleton = null;
522
- chunkWG45SF7N_cjs.setTransport(null);
587
+ chunkHJTUPXNE_cjs.setTransport(null);
523
588
  }
524
589
  },
525
590
  { fingerprint: "morse.shutdown" }
@@ -528,14 +593,14 @@ function _resetForTesting4() {
528
593
  if (singleton !== null) {
529
594
  void singleton.transport.shutdown();
530
595
  singleton = null;
531
- chunkWG45SF7N_cjs.setTransport(null);
596
+ chunkHJTUPXNE_cjs.setTransport(null);
532
597
  }
533
- chunkWG45SF7N_cjs.getEngine().resetForTesting();
598
+ chunkHJTUPXNE_cjs.getEngine().resetForTesting();
534
599
  noApiKeyWarningEmitted = false;
535
600
  lastLoggedEndpoint = null;
536
- chunkWG45SF7N_cjs.setSource(null);
537
- chunkWG45SF7N_cjs._resetForTesting2();
538
- chunkWG45SF7N_cjs._resetForTesting();
601
+ chunkHJTUPXNE_cjs.setSource(null);
602
+ chunkHJTUPXNE_cjs._resetForTesting2();
603
+ chunkHJTUPXNE_cjs._resetForTesting();
539
604
  _resetQuotaStateForTesting();
540
605
  transportFactory = (opts) => new BatchTransport(opts);
541
606
  }
@@ -543,59 +608,59 @@ function _setTransportFactoryForTesting(factory) {
543
608
  transportFactory = factory;
544
609
  }
545
610
  function _getLastTraceForTesting() {
546
- return chunkWG45SF7N_cjs.getLastTrace();
611
+ return chunkHJTUPXNE_cjs.getLastTrace();
547
612
  }
548
613
  function _getActiveTraceStateForTesting() {
549
- return chunkWG45SF7N_cjs.getActiveTraceState();
614
+ return chunkHJTUPXNE_cjs.getActiveTraceState();
550
615
  }
551
616
 
552
617
  Object.defineProperty(exports, "MAX_SEGMENT_CONTENT_BYTES", {
553
618
  enumerable: true,
554
- get: function () { return chunkDQ4JWHYH_cjs.MAX_SEGMENT_CONTENT_BYTES; }
619
+ get: function () { return chunkZOOYJTDT_cjs.MAX_SEGMENT_CONTENT_BYTES; }
555
620
  });
556
621
  Object.defineProperty(exports, "extractAnthropicSegments", {
557
622
  enumerable: true,
558
- get: function () { return chunkDQ4JWHYH_cjs.extractAnthropicSegments; }
623
+ get: function () { return chunkZOOYJTDT_cjs.extractAnthropicSegments; }
559
624
  });
560
625
  Object.defineProperty(exports, "instrumentAnthropic", {
561
626
  enumerable: true,
562
- get: function () { return chunkDQ4JWHYH_cjs.instrumentAnthropic; }
627
+ get: function () { return chunkZOOYJTDT_cjs.instrumentAnthropic; }
563
628
  });
564
629
  Object.defineProperty(exports, "isAnthropicWrapped", {
565
630
  enumerable: true,
566
- get: function () { return chunkDQ4JWHYH_cjs.isAnthropicWrapped; }
631
+ get: function () { return chunkZOOYJTDT_cjs.isAnthropicWrapped; }
567
632
  });
568
633
  Object.defineProperty(exports, "uninstallAnthropic", {
569
634
  enumerable: true,
570
- get: function () { return chunkDQ4JWHYH_cjs.uninstallAnthropic; }
635
+ get: function () { return chunkZOOYJTDT_cjs.uninstallAnthropic; }
571
636
  });
572
637
  Object.defineProperty(exports, "wrapAnthropic", {
573
638
  enumerable: true,
574
- get: function () { return chunkDQ4JWHYH_cjs.wrapAnthropic; }
639
+ get: function () { return chunkZOOYJTDT_cjs.wrapAnthropic; }
575
640
  });
576
641
  Object.defineProperty(exports, "log", {
577
642
  enumerable: true,
578
- get: function () { return chunkTGN4FEKB_cjs.log; }
643
+ get: function () { return chunkHNOHWDK3_cjs.log; }
579
644
  });
580
645
  Object.defineProperty(exports, "W3C_TRACEPARENT_HEADER", {
581
646
  enumerable: true,
582
- get: function () { return chunkWG45SF7N_cjs.W3C_TRACEPARENT_HEADER; }
647
+ get: function () { return chunkHJTUPXNE_cjs.W3C_TRACEPARENT_HEADER; }
583
648
  });
584
649
  Object.defineProperty(exports, "extractTraceparent", {
585
650
  enumerable: true,
586
- get: function () { return chunkWG45SF7N_cjs.extractTraceparent; }
651
+ get: function () { return chunkHJTUPXNE_cjs.extractTraceparent; }
587
652
  });
588
653
  Object.defineProperty(exports, "formatTraceparent", {
589
654
  enumerable: true,
590
- get: function () { return chunkWG45SF7N_cjs.formatTraceparent; }
655
+ get: function () { return chunkHJTUPXNE_cjs.formatTraceparent; }
591
656
  });
592
657
  Object.defineProperty(exports, "injectIntoRequestInit", {
593
658
  enumerable: true,
594
- get: function () { return chunkWG45SF7N_cjs.injectIntoRequestInit; }
659
+ get: function () { return chunkHJTUPXNE_cjs.injectIntoRequestInit; }
595
660
  });
596
661
  Object.defineProperty(exports, "injectTraceparent", {
597
662
  enumerable: true,
598
- get: function () { return chunkWG45SF7N_cjs.injectTraceparent; }
663
+ get: function () { return chunkHJTUPXNE_cjs.injectTraceparent; }
599
664
  });
600
665
  exports._getActiveTraceStateForTesting = _getActiveTraceStateForTesting;
601
666
  exports._getLastTraceForTesting = _getLastTraceForTesting;