@dxos/edge-client 0.8.4-main.c85a9c8dae → 0.8.4-main.cb12b3f963

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 (33) hide show
  1. package/dist/lib/neutral/{chunk-VESGVCLQ.mjs → chunk-ZIQ5T3A7.mjs} +6 -40
  2. package/dist/lib/neutral/{chunk-VESGVCLQ.mjs.map → chunk-ZIQ5T3A7.mjs.map} +2 -2
  3. package/dist/lib/neutral/edge-ws-muxer.mjs +1 -1
  4. package/dist/lib/neutral/index.mjs +162 -360
  5. package/dist/lib/neutral/index.mjs.map +3 -3
  6. package/dist/lib/neutral/meta.json +1 -1
  7. package/dist/lib/neutral/testing/index.mjs +6 -31
  8. package/dist/lib/neutral/testing/index.mjs.map +2 -2
  9. package/dist/types/src/auth.d.ts.map +1 -1
  10. package/dist/types/src/edge-client.d.ts +5 -2
  11. package/dist/types/src/edge-client.d.ts.map +1 -1
  12. package/dist/types/src/edge-http-client.d.ts +58 -30
  13. package/dist/types/src/edge-http-client.d.ts.map +1 -1
  14. package/dist/types/src/edge-identity.d.ts.map +1 -1
  15. package/dist/types/src/edge-ws-connection.d.ts +1 -0
  16. package/dist/types/src/edge-ws-connection.d.ts.map +1 -1
  17. package/dist/types/src/edge-ws-muxer.d.ts.map +1 -1
  18. package/dist/types/src/errors.d.ts.map +1 -1
  19. package/dist/types/src/http-client.d.ts +2 -2
  20. package/dist/types/src/http-client.d.ts.map +1 -1
  21. package/dist/types/src/protocol.d.ts +1 -1
  22. package/dist/types/src/protocol.d.ts.map +1 -1
  23. package/dist/types/src/testing/test-server.d.ts.map +1 -1
  24. package/dist/types/src/testing/test-utils.d.ts.map +1 -1
  25. package/dist/types/src/utils.d.ts +1 -1
  26. package/dist/types/src/utils.d.ts.map +1 -1
  27. package/dist/types/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +18 -23
  29. package/src/edge-client.test.ts +16 -11
  30. package/src/edge-client.ts +19 -3
  31. package/src/edge-http-client.test.ts +2 -1
  32. package/src/edge-http-client.ts +154 -51
  33. package/src/edge-ws-connection.ts +2 -1
@@ -6,7 +6,7 @@ import {
6
6
  getTypename,
7
7
  protocol,
8
8
  toUint8Array
9
- } from "./chunk-VESGVCLQ.mjs";
9
+ } from "./chunk-ZIQ5T3A7.mjs";
10
10
 
11
11
  // src/index.ts
12
12
  export * from "@dxos/protocols/buf/dxos/edge/messenger_pb";
@@ -60,15 +60,7 @@ var createChainEdgeIdentity = async (signer, identityKey, peerKey, chain, creden
60
60
  identityKey: identityKey.toHex(),
61
61
  peerKey: peerKey.toHex(),
62
62
  presentCredentials: async ({ challenge }) => {
63
- invariant(chain, void 0, {
64
- F: __dxlog_file,
65
- L: 75,
66
- S: void 0,
67
- A: [
68
- "chain",
69
- ""
70
- ]
71
- });
63
+ invariant(chain, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 56, S: void 0, A: ["chain", ""] });
72
64
  return signPresentation({
73
65
  presentation: {
74
66
  credentials: credentialsToSign
@@ -124,6 +116,7 @@ var createStubEdgeIdentity = () => {
124
116
 
125
117
  // src/edge-client.ts
126
118
  import { Event, PersistentLifecycle, Trigger, TriggerState, scheduleMicroTask, scheduleTaskInterval as scheduleTaskInterval2 } from "@dxos/async";
119
+ import { TRACE_SPAN_ATTRIBUTE } from "@dxos/context";
127
120
  import { Resource as Resource2 } from "@dxos/context";
128
121
  import { log as log2, logInfo as logInfo2 } from "@dxos/log";
129
122
  import { EdgeStatus } from "@dxos/protocols/proto/dxos/client/services";
@@ -133,35 +126,11 @@ import { invariant as invariant2 } from "@dxos/invariant";
133
126
  import { schema } from "@dxos/protocols/proto";
134
127
  var __dxlog_file2 = "/__w/dxos/dxos/packages/core/mesh/edge-client/src/edge-identity.ts";
135
128
  var handleAuthChallenge = async (failedResponse, identity) => {
136
- invariant2(failedResponse.status === 401, void 0, {
137
- F: __dxlog_file2,
138
- L: 21,
139
- S: void 0,
140
- A: [
141
- "failedResponse.status === 401",
142
- ""
143
- ]
144
- });
129
+ invariant2(failedResponse.status === 401, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 7, S: void 0, A: ["failedResponse.status === 401", ""] });
145
130
  const headerValue = failedResponse.headers.get("Www-Authenticate");
146
- invariant2(headerValue?.startsWith("VerifiablePresentation challenge="), void 0, {
147
- F: __dxlog_file2,
148
- L: 24,
149
- S: void 0,
150
- A: [
151
- "headerValue?.startsWith('VerifiablePresentation challenge=')",
152
- ""
153
- ]
154
- });
131
+ invariant2(headerValue?.startsWith("VerifiablePresentation challenge="), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 9, S: void 0, A: ["headerValue?.startsWith('VerifiablePresentation challenge=')", ""] });
155
132
  const challenge = headerValue?.slice("VerifiablePresentation challenge=".length);
156
- invariant2(challenge, void 0, {
157
- F: __dxlog_file2,
158
- L: 27,
159
- S: void 0,
160
- A: [
161
- "challenge",
162
- ""
163
- ]
164
- });
133
+ invariant2(challenge, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 11, S: void 0, A: ["challenge", ""] });
165
134
  const presentation = await identity.presentCredentials({
166
135
  challenge: Buffer.from(challenge, "base64")
167
136
  });
@@ -177,13 +146,13 @@ import { log, logInfo } from "@dxos/log";
177
146
  import { EdgeWebsocketProtocol } from "@dxos/protocols";
178
147
  import { buf } from "@dxos/protocols/buf";
179
148
  import { MessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
149
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/core/mesh/edge-client/src/edge-ws-connection.ts";
180
150
  function _ts_decorate(decorators, target, key, desc) {
181
151
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
182
152
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
183
153
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
184
154
  return c > 3 && r && Object.defineProperty(target, key, r), r;
185
155
  }
186
- var __dxlog_file3 = "/__w/dxos/dxos/packages/core/mesh/edge-client/src/edge-ws-connection.ts";
187
156
  var SIGNAL_KEEPALIVE_INTERVAL = 4e3;
188
157
  var SIGNAL_KEEPALIVE_TIMEOUT = 12e3;
189
158
  var EdgeWsConnection = class extends Resource {
@@ -235,33 +204,12 @@ var EdgeWsConnection = class extends Resource {
235
204
  return this._messagesReceived;
236
205
  }
237
206
  send(message) {
238
- invariant3(this._ws, void 0, {
239
- F: __dxlog_file3,
240
- L: 93,
241
- S: this,
242
- A: [
243
- "this._ws",
244
- ""
245
- ]
246
- });
247
- invariant3(this._wsMuxer, void 0, {
248
- F: __dxlog_file3,
249
- L: 94,
250
- S: this,
251
- A: [
252
- "this._wsMuxer",
253
- ""
254
- ]
255
- });
207
+ invariant3(this._ws, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 72, S: this, A: ["this._ws", ""] });
208
+ invariant3(this._wsMuxer, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 73, S: this, A: ["this._wsMuxer", ""] });
256
209
  log("sending...", {
257
210
  peerKey: this._identity.peerKey,
258
211
  payload: protocol.getPayloadType(message)
259
- }, {
260
- F: __dxlog_file3,
261
- L: 95,
262
- S: this,
263
- C: (f, a) => f(...a)
264
- });
212
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 74, S: this });
265
213
  this._messagesSent++;
266
214
  if (this._ws?.protocol.includes(EdgeWebsocketProtocol.V0)) {
267
215
  const binary = buf.toBinary(MessageSchema, message);
@@ -270,12 +218,7 @@ var EdgeWsConnection = class extends Resource {
270
218
  byteLength: binary.byteLength,
271
219
  serviceId: message.serviceId,
272
220
  payload: protocol.getPayloadType(message)
273
- }, {
274
- F: __dxlog_file3,
275
- L: 100,
276
- S: this,
277
- C: (f, a) => f(...a)
278
- });
221
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 82, S: this });
279
222
  return;
280
223
  }
281
224
  this._recordBytes(binary.byteLength, 0);
@@ -283,12 +226,7 @@ var EdgeWsConnection = class extends Resource {
283
226
  } else {
284
227
  const binary = buf.toBinary(MessageSchema, message);
285
228
  this._recordBytes(binary.byteLength, 0);
286
- this._wsMuxer.send(message).catch((e) => log.catch(e, void 0, {
287
- F: __dxlog_file3,
288
- L: 113,
289
- S: this,
290
- C: (f, a) => f(...a)
291
- }));
229
+ this._wsMuxer.send(message).catch((e) => log.catch(e, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 95, S: this }));
292
230
  }
293
231
  }
294
232
  async _open() {
@@ -300,17 +238,14 @@ var EdgeWsConnection = class extends Resource {
300
238
  this._connectionInfo.protocolHeader
301
239
  ] : [
302
240
  ...baseProtocols
303
- ]);
241
+ ], this._connectionInfo.headers ? {
242
+ headers: this._connectionInfo.headers
243
+ } : void 0);
304
244
  const muxer = new WebSocketMuxer(this._ws);
305
245
  this._wsMuxer = muxer;
306
246
  this._ws.onopen = () => {
307
247
  if (this.isOpen) {
308
- log("connected", void 0, {
309
- F: __dxlog_file3,
310
- L: 130,
311
- S: this,
312
- C: (f, a) => f(...a)
313
- });
248
+ log("connected", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 114, S: this });
314
249
  this._openTimestamp = Date.now();
315
250
  this._callbacks.onConnected();
316
251
  this._scheduleHeartbeats();
@@ -318,12 +253,7 @@ var EdgeWsConnection = class extends Resource {
318
253
  } else {
319
254
  log.verbose("connected after becoming inactive", {
320
255
  currentIdentity: this._identity
321
- }, {
322
- F: __dxlog_file3,
323
- L: 136,
324
- S: this,
325
- C: (f, a) => f(...a)
326
- });
256
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 120, S: this });
327
257
  }
328
258
  };
329
259
  this._ws.onclose = (event) => {
@@ -331,12 +261,7 @@ var EdgeWsConnection = class extends Resource {
331
261
  log.warn("server disconnected", {
332
262
  code: event.code,
333
263
  reason: event.reason
334
- }, {
335
- F: __dxlog_file3,
336
- L: 141,
337
- S: this,
338
- C: (f, a) => f(...a)
339
- });
264
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 127, S: this });
340
265
  this._callbacks.onRestartRequired();
341
266
  muxer.destroy();
342
267
  }
@@ -346,34 +271,19 @@ var EdgeWsConnection = class extends Resource {
346
271
  log.warn("edge connection socket error", {
347
272
  error: event.error,
348
273
  info: event.message
349
- }, {
350
- F: __dxlog_file3,
351
- L: 148,
352
- S: this,
353
- C: (f, a) => f(...a)
354
- });
274
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 137, S: this });
355
275
  this._callbacks.onRestartRequired();
356
276
  } else {
357
277
  log.verbose("error ignored on closed connection", {
358
278
  error: event.error
359
- }, {
360
- F: __dxlog_file3,
361
- L: 151,
362
- S: this,
363
- C: (f, a) => f(...a)
364
- });
279
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 143, S: this });
365
280
  }
366
281
  };
367
282
  this._ws.onmessage = async (event) => {
368
283
  if (!this.isOpen) {
369
284
  log.verbose("message ignored on closed connection", {
370
285
  event: event.type
371
- }, {
372
- F: __dxlog_file3,
373
- L: 159,
374
- S: this,
375
- C: (f, a) => f(...a)
376
- });
286
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 152, S: this });
377
287
  return;
378
288
  }
379
289
  this._lastReceivedMessageTimestamp = Date.now();
@@ -396,12 +306,7 @@ var EdgeWsConnection = class extends Resource {
396
306
  log("received", {
397
307
  from: message.source,
398
308
  payload: protocol.getPayloadType(message)
399
- }, {
400
- F: __dxlog_file3,
401
- L: 185,
402
- S: this,
403
- C: (f, a) => f(...a)
404
- });
309
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 175, S: this });
405
310
  this._callbacks.onMessage(message);
406
311
  }
407
312
  };
@@ -420,24 +325,11 @@ var EdgeWsConnection = class extends Resource {
420
325
  }
421
326
  log.warn("error closing websocket", {
422
327
  err
423
- }, {
424
- F: __dxlog_file3,
425
- L: 203,
426
- S: this,
427
- C: (f, a) => f(...a)
428
- });
328
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 194, S: this });
429
329
  }
430
330
  }
431
331
  _scheduleHeartbeats() {
432
- invariant3(this._ws, void 0, {
433
- F: __dxlog_file3,
434
- L: 208,
435
- S: this,
436
- A: [
437
- "this._ws",
438
- ""
439
- ]
440
- });
332
+ invariant3(this._ws, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 200, S: this, A: ["this._ws", ""] });
441
333
  scheduleTaskInterval(this._ctx, async () => {
442
334
  this._pingTimestamp = Date.now();
443
335
  this._ws?.send("__ping__");
@@ -451,21 +343,13 @@ var EdgeWsConnection = class extends Resource {
451
343
  return;
452
344
  }
453
345
  void this._inactivityTimeoutCtx?.dispose();
454
- this._inactivityTimeoutCtx = new Context(void 0, {
455
- F: __dxlog_file3,
456
- L: 229
457
- });
346
+ this._inactivityTimeoutCtx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 216 });
458
347
  scheduleTask(this._inactivityTimeoutCtx, () => {
459
348
  if (this.isOpen) {
460
349
  if (Date.now() - this._lastReceivedMessageTimestamp > SIGNAL_KEEPALIVE_TIMEOUT) {
461
350
  log.warn("restart due to inactivity timeout", {
462
351
  lastReceivedMessageTimestamp: this._lastReceivedMessageTimestamp
463
- }, {
464
- F: __dxlog_file3,
465
- L: 235,
466
- S: this,
467
- C: (f, a) => f(...a)
468
- });
352
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 220, S: this });
469
353
  this._callbacks.onRestartRequired();
470
354
  } else {
471
355
  this._rescheduleHeartbeatTimeout();
@@ -540,13 +424,13 @@ var getEdgeUrlWithProtocol = (baseUrl, protocol2) => {
540
424
  };
541
425
 
542
426
  // src/edge-client.ts
427
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
543
428
  function _ts_decorate2(decorators, target, key, desc) {
544
429
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
545
430
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
546
431
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
547
432
  return c > 3 && r && Object.defineProperty(target, key, r), r;
548
433
  }
549
- var __dxlog_file4 = "/__w/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
550
434
  var DEFAULT_TIMEOUT = 1e4;
551
435
  var STATUS_REFRESH_INTERVAL = 1e3;
552
436
  var EdgeClient = class extends Resource2 {
@@ -598,12 +482,7 @@ var EdgeClient = class extends Resource2 {
598
482
  log2("Edge identity changed", {
599
483
  identity,
600
484
  oldIdentity: this._identity
601
- }, {
602
- F: __dxlog_file4,
603
- L: 118,
604
- S: this,
605
- C: (f, a) => f(...a)
606
- });
485
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 74, S: this });
607
486
  this._identity = identity;
608
487
  this._closeCurrentConnection(new EdgeIdentityChangedError());
609
488
  void this._persistentLifecycle.scheduleRestart();
@@ -613,14 +492,9 @@ var EdgeClient = class extends Resource2 {
613
492
  * Send message.
614
493
  * NOTE: The message is guaranteed to be delivered but the service must respond with a message to confirm processing.
615
494
  */
616
- async send(message) {
495
+ async send(ctx, message) {
617
496
  if (this._ready.state !== TriggerState.RESOLVED) {
618
- log2("waiting for websocket", void 0, {
619
- F: __dxlog_file4,
620
- L: 131,
621
- S: this,
622
- C: (f, a) => f(...a)
623
- });
497
+ log2("waiting for websocket", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 88, S: this });
624
498
  await this._ready.wait({
625
499
  timeout: this._config.timeout ?? DEFAULT_TIMEOUT
626
500
  });
@@ -631,6 +505,14 @@ var EdgeClient = class extends Resource2 {
631
505
  if (message.source && (message.source.peerKey !== this._identity.peerKey || message.source.identityKey !== this.identityKey)) {
632
506
  throw new EdgeIdentityChangedError();
633
507
  }
508
+ const traceCtx = ctx.getAttribute(TRACE_SPAN_ATTRIBUTE);
509
+ if (traceCtx) {
510
+ message.traceContext = {
511
+ $typeName: "dxos.edge.messenger.TraceContext",
512
+ traceparent: traceCtx.traceparent,
513
+ tracestate: traceCtx.tracestate
514
+ };
515
+ }
634
516
  this._currentConnection.send(message);
635
517
  }
636
518
  onMessage(listener) {
@@ -645,12 +527,7 @@ var EdgeClient = class extends Resource2 {
645
527
  try {
646
528
  listener();
647
529
  } catch (error) {
648
- log2.catch(error, void 0, {
649
- F: __dxlog_file4,
650
- L: 164,
651
- S: this,
652
- C: (f, a) => f(...a)
653
- });
530
+ log2.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 123, S: this });
654
531
  }
655
532
  }
656
533
  });
@@ -663,21 +540,11 @@ var EdgeClient = class extends Resource2 {
663
540
  async _open() {
664
541
  log2("opening...", {
665
542
  info: this.info
666
- }, {
667
- F: __dxlog_file4,
668
- L: 177,
669
- S: this,
670
- C: (f, a) => f(...a)
671
- });
543
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 133, S: this });
672
544
  this._persistentLifecycle.open().catch((err) => {
673
545
  log2.warn("Error while opening connection", {
674
546
  err
675
- }, {
676
- F: __dxlog_file4,
677
- L: 179,
678
- S: this,
679
- C: (f, a) => f(...a)
680
- });
547
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 137, S: this });
681
548
  });
682
549
  scheduleTaskInterval2(this._ctx, async () => {
683
550
  if (!this._currentConnection) {
@@ -692,12 +559,7 @@ var EdgeClient = class extends Resource2 {
692
559
  async _close() {
693
560
  log2("closing...", {
694
561
  peerKey: this._identity.peerKey
695
- }, {
696
- F: __dxlog_file4,
697
- L: 199,
698
- S: this,
699
- C: (f, a) => f(...a)
700
- });
562
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 152, S: this });
701
563
  this._closeCurrentConnection();
702
564
  await this._persistentLifecycle.close();
703
565
  }
@@ -709,12 +571,7 @@ var EdgeClient = class extends Resource2 {
709
571
  const path = `/ws/${identity.identityKey}/${identity.peerKey}`;
710
572
  const protocolHeader = this._config.disableAuth ? void 0 : await this._createAuthHeader(path);
711
573
  if (this._identity !== identity) {
712
- log2("identity changed during auth header request", void 0, {
713
- F: __dxlog_file4,
714
- L: 213,
715
- S: this,
716
- C: (f, a) => f(...a)
717
- });
574
+ log2("identity changed during auth header request", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 166, S: this });
718
575
  return void 0;
719
576
  }
720
577
  const restartRequired = new Trigger();
@@ -722,27 +579,20 @@ var EdgeClient = class extends Resource2 {
722
579
  log2("Opening websocket", {
723
580
  url: url.toString(),
724
581
  protocolHeader
725
- }, {
726
- F: __dxlog_file4,
727
- L: 219,
728
- S: this,
729
- C: (f, a) => f(...a)
730
- });
582
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 171, S: this });
731
583
  const connection = new EdgeWsConnection(identity, {
732
584
  url,
733
- protocolHeader
585
+ protocolHeader,
586
+ headers: this._config.clientTag ? {
587
+ "X-DXOS-Client-Tag": this._config.clientTag
588
+ } : void 0
734
589
  }, {
735
590
  onConnected: () => {
736
591
  if (this._isActive(connection)) {
737
592
  this._ready.wake();
738
593
  this._notifyReconnected();
739
594
  } else {
740
- log2.verbose("connected callback ignored, because connection is not active", void 0, {
741
- F: __dxlog_file4,
742
- L: 229,
743
- S: this,
744
- C: (f, a) => f(...a)
745
- });
595
+ log2.verbose("connected callback ignored, because connection is not active", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 187, S: this });
746
596
  }
747
597
  },
748
598
  onRestartRequired: () => {
@@ -750,12 +600,7 @@ var EdgeClient = class extends Resource2 {
750
600
  this._closeCurrentConnection();
751
601
  void this._persistentLifecycle.scheduleRestart();
752
602
  } else {
753
- log2.verbose("restart requested by inactive connection", void 0, {
754
- F: __dxlog_file4,
755
- L: 237,
756
- S: this,
757
- C: (f, a) => f(...a)
758
- });
603
+ log2.verbose("restart requested by inactive connection", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 195, S: this });
759
604
  }
760
605
  restartRequired.wake();
761
606
  },
@@ -766,12 +611,7 @@ var EdgeClient = class extends Resource2 {
766
611
  log2.verbose("ignored a message on inactive connection", {
767
612
  from: message.source,
768
613
  type: message.payload?.typeUrl
769
- }, {
770
- F: __dxlog_file4,
771
- L: 245,
772
- S: this,
773
- C: (f, a) => f(...a)
774
- });
614
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 203, S: this });
775
615
  }
776
616
  }
777
617
  });
@@ -803,12 +643,7 @@ var EdgeClient = class extends Resource2 {
803
643
  } catch (err) {
804
644
  log2.error("ws reconnect listener failed", {
805
645
  err
806
- }, {
807
- F: __dxlog_file4,
808
- L: 280,
809
- S: this,
810
- C: (f, a) => f(...a)
811
- });
646
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 238, S: this });
812
647
  }
813
648
  }
814
649
  }
@@ -820,12 +655,7 @@ var EdgeClient = class extends Resource2 {
820
655
  log2.error("ws incoming message processing failed", {
821
656
  err,
822
657
  payload: protocol.getPayloadType(message)
823
- }, {
824
- F: __dxlog_file4,
825
- L: 290,
826
- S: this,
827
- C: (f, a) => f(...a)
828
- });
658
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 249, S: this });
829
659
  }
830
660
  }
831
661
  }
@@ -841,12 +671,7 @@ var EdgeClient = class extends Resource2 {
841
671
  log2.warn("no auth challenge from edge", {
842
672
  status: response.status,
843
673
  statusText: response.statusText
844
- }, {
845
- F: __dxlog_file4,
846
- L: 302,
847
- S: this,
848
- C: (f, a) => f(...a)
849
- });
674
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 265, S: this });
850
675
  return void 0;
851
676
  }
852
677
  }
@@ -866,11 +691,11 @@ import * as HttpClient from "@effect/platform/HttpClient";
866
691
  import * as Effect2 from "effect/Effect";
867
692
  import * as Function from "effect/Function";
868
693
  import { sleep } from "@dxos/async";
869
- import { Context as Context3 } from "@dxos/context";
694
+ import { TRACE_SPAN_ATTRIBUTE as TRACE_SPAN_ATTRIBUTE2 } from "@dxos/context";
870
695
  import { runAndForwardErrors } from "@dxos/effect";
871
696
  import { invariant as invariant4 } from "@dxos/invariant";
872
697
  import { log as log4 } from "@dxos/log";
873
- import { EdgeAuthChallengeError, EdgeCallFailedError } from "@dxos/protocols";
698
+ import { EDGE_CLIENT_TAG_HEADER, EdgeAuthChallengeError, EdgeCallFailedError } from "@dxos/protocols";
874
699
  import { createUrl } from "@dxos/util";
875
700
 
876
701
  // src/http-client.ts
@@ -904,12 +729,7 @@ var withRetryConfig = (effect) => Effect.gen(function* () {
904
729
  var withLogging = (effect) => effect.pipe(Effect.tap((res) => {
905
730
  log3.info("response", {
906
731
  status: res.status
907
- }, {
908
- F: __dxlog_file5,
909
- L: 66,
910
- S: void 0,
911
- C: (f, a) => f(...a)
912
- });
732
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 31, S: void 0 });
913
733
  }));
914
734
  var encodeAuthHeader = (challenge) => {
915
735
  const encodedChallenge = Buffer.from(challenge).toString("base64");
@@ -924,21 +744,18 @@ var DEFAULT_MAX_RETRIES_COUNT = 3;
924
744
  var WARNING_BODY_SIZE = 10 * 1024 * 1024;
925
745
  var EdgeHttpClient = class {
926
746
  _baseUrl;
747
+ _clientTag;
927
748
  _edgeIdentity;
928
749
  /**
929
750
  * Auth header is cached until receiving the next 401 from EDGE, at which point it gets refreshed.
930
751
  */
931
752
  _authHeader;
932
- constructor(baseUrl) {
753
+ constructor(baseUrl, options) {
933
754
  this._baseUrl = getEdgeUrlWithProtocol(baseUrl, "http");
755
+ this._clientTag = options?.clientTag;
934
756
  log4("created", {
935
757
  url: this._baseUrl
936
- }, {
937
- F: __dxlog_file6,
938
- L: 110,
939
- S: this,
940
- C: (f, a) => f(...a)
941
- });
758
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 32, S: this });
942
759
  }
943
760
  get baseUrl() {
944
761
  return this._baseUrl;
@@ -952,8 +769,8 @@ var EdgeHttpClient = class {
952
769
  //
953
770
  // Status
954
771
  //
955
- async getStatus(args) {
956
- return this._call(new URL("/status", this.baseUrl), {
772
+ async getStatus(ctx, args) {
773
+ return this._call(ctx, new URL("/status", this.baseUrl), {
957
774
  ...args,
958
775
  method: "GET",
959
776
  auth: true
@@ -962,15 +779,15 @@ var EdgeHttpClient = class {
962
779
  //
963
780
  // Agents
964
781
  //
965
- createAgent(body, args) {
966
- return this._call(new URL("/agents/create", this.baseUrl), {
782
+ createAgent(ctx, body, args) {
783
+ return this._call(ctx, new URL("/agents/create", this.baseUrl), {
967
784
  ...args,
968
785
  method: "POST",
969
786
  body
970
787
  });
971
788
  }
972
- getAgentStatus(request, args) {
973
- return this._call(new URL(`/users/${request.ownerIdentityKey.toHex()}/agent/status`, this.baseUrl), {
789
+ getAgentStatus(ctx, request, args) {
790
+ return this._call(ctx, new URL(`/users/${request.ownerIdentityKey.toHex()}/agent/status`, this.baseUrl), {
974
791
  ...args,
975
792
  method: "GET"
976
793
  });
@@ -978,14 +795,14 @@ var EdgeHttpClient = class {
978
795
  //
979
796
  // Credentials
980
797
  //
981
- getCredentialsForNotarization(spaceId, args) {
982
- return this._call(new URL(`/spaces/${spaceId}/notarization`, this.baseUrl), {
798
+ getCredentialsForNotarization(ctx, spaceId, args) {
799
+ return this._call(ctx, new URL(`/spaces/${spaceId}/notarization`, this.baseUrl), {
983
800
  ...args,
984
801
  method: "GET"
985
802
  });
986
803
  }
987
- async notarizeCredentials(spaceId, body, args) {
988
- await this._call(new URL(`/spaces/${spaceId}/notarization`, this.baseUrl), {
804
+ async notarizeCredentials(ctx, spaceId, body, args) {
805
+ await this._call(ctx, new URL(`/spaces/${spaceId}/notarization`, this.baseUrl), {
989
806
  ...args,
990
807
  body,
991
808
  method: "POST"
@@ -994,8 +811,8 @@ var EdgeHttpClient = class {
994
811
  //
995
812
  // Identity
996
813
  //
997
- async recoverIdentity(body, args) {
998
- return this._call(new URL("/identity/recover", this.baseUrl), {
814
+ async recoverIdentity(ctx, body, args) {
815
+ return this._call(ctx, new URL("/identity/recover", this.baseUrl), {
999
816
  ...args,
1000
817
  body,
1001
818
  method: "POST"
@@ -1004,8 +821,8 @@ var EdgeHttpClient = class {
1004
821
  //
1005
822
  // Invitations
1006
823
  //
1007
- async joinSpaceByInvitation(spaceId, body, args) {
1008
- return this._call(new URL(`/spaces/${spaceId}/join`, this.baseUrl), {
824
+ async joinSpaceByInvitation(ctx, spaceId, body, args) {
825
+ return this._call(ctx, new URL(`/spaces/${spaceId}/join`, this.baseUrl), {
1009
826
  ...args,
1010
827
  body,
1011
828
  method: "POST"
@@ -1014,8 +831,8 @@ var EdgeHttpClient = class {
1014
831
  //
1015
832
  // OAuth and credentials
1016
833
  //
1017
- async initiateOAuthFlow(body, args) {
1018
- return this._call(new URL("/oauth/initiate", this.baseUrl), {
834
+ async initiateOAuthFlow(ctx, body, args) {
835
+ return this._call(ctx, new URL("/oauth/initiate", this.baseUrl), {
1019
836
  ...args,
1020
837
  body,
1021
838
  method: "POST"
@@ -1024,8 +841,8 @@ var EdgeHttpClient = class {
1024
841
  //
1025
842
  // Spaces
1026
843
  //
1027
- async createSpace(body, args) {
1028
- return this._call(new URL("/spaces/create", this.baseUrl), {
844
+ async createSpace(ctx, body, args) {
845
+ return this._call(ctx, new URL("/spaces/create", this.baseUrl), {
1029
846
  ...args,
1030
847
  body,
1031
848
  method: "POST"
@@ -1034,18 +851,10 @@ var EdgeHttpClient = class {
1034
851
  //
1035
852
  // Queues
1036
853
  //
1037
- async queryQueue(subspaceTag, spaceId, query, args) {
854
+ async queryQueue(ctx, subspaceTag, spaceId, query, args) {
1038
855
  const queueId = query.queueIds?.[0];
1039
- invariant4(queueId, "queueId required", {
1040
- F: __dxlog_file6,
1041
- L: 219,
1042
- S: this,
1043
- A: [
1044
- "queueId",
1045
- "'queueId required'"
1046
- ]
1047
- });
1048
- return this._call(createUrl(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}/query`, this.baseUrl), {
856
+ invariant4(queueId, "queueId required", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 132, S: this, A: ["queueId", "'queueId required'"] });
857
+ return this._call(ctx, createUrl(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}/query`, this.baseUrl), {
1049
858
  after: query.after,
1050
859
  before: query.before,
1051
860
  limit: query.limit,
@@ -1056,8 +865,8 @@ var EdgeHttpClient = class {
1056
865
  method: "GET"
1057
866
  });
1058
867
  }
1059
- async insertIntoQueue(subspaceTag, spaceId, queueId, objects, args) {
1060
- return this._call(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, this.baseUrl), {
868
+ async insertIntoQueue(ctx, subspaceTag, spaceId, queueId, objects, args) {
869
+ return this._call(ctx, new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, this.baseUrl), {
1061
870
  ...args,
1062
871
  body: {
1063
872
  objects
@@ -1065,8 +874,8 @@ var EdgeHttpClient = class {
1065
874
  method: "POST"
1066
875
  });
1067
876
  }
1068
- async deleteFromQueue(subspaceTag, spaceId, queueId, objectIds, args) {
1069
- return this._call(createUrl(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, this.baseUrl), {
877
+ async deleteFromQueue(ctx, subspaceTag, spaceId, queueId, objectIds, args) {
878
+ return this._call(ctx, createUrl(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, this.baseUrl), {
1070
879
  ids: objectIds.join(",")
1071
880
  }), {
1072
881
  ...args,
@@ -1076,7 +885,7 @@ var EdgeHttpClient = class {
1076
885
  //
1077
886
  // Functions
1078
887
  //
1079
- async uploadFunction(pathParts, body, args) {
888
+ async uploadFunction(ctx, pathParts, body, args) {
1080
889
  const formData = new FormData();
1081
890
  formData.append("name", body.name ?? "");
1082
891
  formData.append("version", body.version);
@@ -1096,20 +905,20 @@ var EdgeHttpClient = class {
1096
905
  pathParts.functionId
1097
906
  ] : []
1098
907
  ].join("/");
1099
- return this._call(new URL(path, this.baseUrl), {
908
+ return this._call(ctx, new URL(path, this.baseUrl), {
1100
909
  ...args,
1101
910
  body: formData,
1102
911
  method: "PUT",
1103
912
  json: false
1104
913
  });
1105
914
  }
1106
- async listFunctions(args) {
1107
- return this._call(new URL("/functions", this.baseUrl), {
915
+ async listFunctions(ctx, args) {
916
+ return this._call(ctx, new URL("/functions", this.baseUrl), {
1108
917
  ...args,
1109
918
  method: "GET"
1110
919
  });
1111
920
  }
1112
- async invokeFunction(params, input, args) {
921
+ async invokeFunction(ctx, params, input, args) {
1113
922
  const url = new URL(`/functions/${params.functionId}`, this.baseUrl);
1114
923
  if (params.version) {
1115
924
  url.searchParams.set("version", params.version);
@@ -1123,7 +932,7 @@ var EdgeHttpClient = class {
1123
932
  if (params.subrequestsLimit) {
1124
933
  url.searchParams.set("subrequestsLimit", params.subrequestsLimit.toString());
1125
934
  }
1126
- return this._call(url, {
935
+ return this._call(ctx, url, {
1127
936
  ...args,
1128
937
  body: input,
1129
938
  method: "POST"
@@ -1132,8 +941,8 @@ var EdgeHttpClient = class {
1132
941
  //
1133
942
  // Workflows
1134
943
  //
1135
- async executeWorkflow(spaceId, graphId, input, args) {
1136
- return this._call(new URL(`/workflows/${spaceId}/${graphId}`, this.baseUrl), {
944
+ async executeWorkflow(ctx, spaceId, graphId, input, args) {
945
+ return this._call(ctx, new URL(`/workflows/${spaceId}/${graphId}`, this.baseUrl), {
1137
946
  ...args,
1138
947
  body: input,
1139
948
  method: "POST"
@@ -1142,13 +951,13 @@ var EdgeHttpClient = class {
1142
951
  //
1143
952
  // Triggers
1144
953
  //
1145
- async getCronTriggers(spaceId) {
1146
- return this._call(new URL(`/test/functions/${spaceId}/triggers/crons`, this.baseUrl), {
954
+ async getCronTriggers(ctx, spaceId) {
955
+ return this._call(ctx, new URL(`/functions/${spaceId}/triggers/crons`, this.baseUrl), {
1147
956
  method: "GET"
1148
957
  });
1149
958
  }
1150
- async forceRunCronTrigger(spaceId, triggerId) {
1151
- return this._call(new URL(`/test/functions/${spaceId}/triggers/crons/${triggerId}/run`, this.baseUrl), {
959
+ async forceRunCronTrigger(ctx, spaceId, triggerId) {
960
+ return this._call(ctx, new URL(`/functions/${spaceId}/triggers/crons/${triggerId}/run`, this.baseUrl), {
1152
961
  method: "POST"
1153
962
  });
1154
963
  }
@@ -1158,25 +967,51 @@ var EdgeHttpClient = class {
1158
967
  /**
1159
968
  * Execute a QueryAST query against a space.
1160
969
  */
1161
- async execQuery(spaceId, body, args) {
1162
- return this._call(new URL(`/spaces/${spaceId}/exec-query`, this.baseUrl), {
970
+ async execQuery(ctx, spaceId, body, args) {
971
+ return this._call(ctx, new URL(`/spaces/${spaceId}/exec-query`, this.baseUrl), {
1163
972
  ...args,
1164
973
  body,
1165
974
  method: "POST"
1166
975
  });
1167
976
  }
1168
977
  //
978
+ // Registry
979
+ //
980
+ /**
981
+ * Fetches the hydrated plugin directory from the Edge registry service.
982
+ * Unauthenticated; safe to call without an identity.
983
+ */
984
+ async getRegistryPlugins(ctx, args) {
985
+ return this._call(ctx, new URL("/registry/plugins", this.baseUrl), {
986
+ ...args,
987
+ method: "GET"
988
+ });
989
+ }
990
+ /**
991
+ * Fetches the available release versions for a given plugin repo. `repo` is the
992
+ * GitHub `owner/name` form; this method takes care of URL-encoding before issuing
993
+ * the request. Unauthenticated; same surface area as {@link getRegistryPlugins}.
994
+ *
995
+ * Versions are returned newest first, suitable for direct rendering in a picker.
996
+ */
997
+ async getRegistryPluginVersions(ctx, repo, args) {
998
+ return this._call(ctx, new URL(`/registry/plugins/${encodeURIComponent(repo)}/versions`, this.baseUrl), {
999
+ ...args,
1000
+ method: "GET"
1001
+ });
1002
+ }
1003
+ //
1169
1004
  // Import/Export space.
1170
1005
  //
1171
- async importBundle(spaceId, body, args) {
1172
- return this._call(new URL(`/spaces/${spaceId}/import`, this.baseUrl), {
1006
+ async importBundle(ctx, spaceId, body, args) {
1007
+ return this._call(ctx, new URL(`/spaces/${spaceId}/import`, this.baseUrl), {
1173
1008
  ...args,
1174
1009
  body,
1175
1010
  method: "PUT"
1176
1011
  });
1177
1012
  }
1178
- async exportBundle(spaceId, body, args) {
1179
- return this._call(new URL(`/spaces/${spaceId}/export`, this.baseUrl), {
1013
+ async exportBundle(ctx, spaceId, body, args) {
1014
+ return this._call(ctx, new URL(`/spaces/${spaceId}/export`, this.baseUrl), {
1180
1015
  ...args,
1181
1016
  body,
1182
1017
  method: "POST"
@@ -1189,21 +1024,13 @@ var EdgeHttpClient = class {
1189
1024
  return Function.pipe(HttpClient.get(url), withLogging, withRetryConfig, Effect2.provide(FetchHttpClient.layer), Effect2.provide(HttpConfig.default), Effect2.withSpan("EdgeHttpClient"), runAndForwardErrors);
1190
1025
  }
1191
1026
  // TODO(burdon): Refactor with effect (see edge-http-client.test.ts).
1192
- async _call(url, args) {
1027
+ async _call(ctx, url, args) {
1193
1028
  const shouldRetry = createRetryHandler(args);
1194
- const requestContext = args.context ?? Context3.default(void 0, {
1195
- F: __dxlog_file6,
1196
- L: 426
1197
- });
1198
1029
  log4("fetch", {
1199
1030
  url,
1200
1031
  request: args.body
1201
- }, {
1202
- F: __dxlog_file6,
1203
- L: 427,
1204
- S: this,
1205
- C: (f, a) => f(...a)
1206
- });
1032
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 302, S: this });
1033
+ const traceHeaders = getTraceHeaders(ctx);
1207
1034
  let handledAuth = false;
1208
1035
  const tryCount = 1;
1209
1036
  while (true) {
@@ -1215,29 +1042,16 @@ var EdgeHttpClient = class {
1215
1042
  this._authHeader = await this._handleUnauthorized(response2);
1216
1043
  }
1217
1044
  }
1218
- const request = createRequest(args, this._authHeader);
1045
+ const request = createRequest(args, this._authHeader, traceHeaders, this._clientTag);
1219
1046
  log4("call edge", {
1220
1047
  url,
1221
1048
  tryCount,
1222
1049
  authHeader: !!this._authHeader
1223
- }, {
1224
- F: __dxlog_file6,
1225
- L: 442,
1226
- S: this,
1227
- C: (f, a) => f(...a)
1228
- });
1050
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 319, S: this });
1229
1051
  const response = await fetch(url, request);
1230
1052
  if (response.ok) {
1231
1053
  const body2 = await response.clone().json();
1232
- invariant4(body2, "Expected body to be present", {
1233
- F: __dxlog_file6,
1234
- L: 447,
1235
- S: this,
1236
- A: [
1237
- "body",
1238
- "'Expected body to be present'"
1239
- ]
1240
- });
1054
+ invariant4(body2, "Expected body to be present", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 327, S: this, A: ["body", "'Expected body to be present'"] });
1241
1055
  if (!("success" in body2)) {
1242
1056
  return body2;
1243
1057
  }
@@ -1250,44 +1064,23 @@ var EdgeHttpClient = class {
1250
1064
  continue;
1251
1065
  }
1252
1066
  const body = response.headers.get("Content-Type") === "application/json" ? await response.clone().json() : void 0;
1253
- invariant4(!body?.success, "Expected body to not be a failure response or undefined.", {
1254
- F: __dxlog_file6,
1255
- L: 463,
1256
- S: this,
1257
- A: [
1258
- "!body?.success",
1259
- "'Expected body to not be a failure response or undefined.'"
1260
- ]
1261
- });
1067
+ invariant4(!body?.success, "Expected body to not be a failure response or undefined.", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 340, S: this, A: ["!body?.success", "'Expected body to not be a failure response or undefined.'"] });
1262
1068
  if (body?.data?.type === "auth_challenge" && typeof body?.data?.challenge === "string") {
1263
1069
  processingError = new EdgeAuthChallengeError(body.data.challenge, body.data);
1264
1070
  } else if (body?.success === false) {
1265
1071
  processingError = EdgeCallFailedError.fromUnsuccessfulResponse(response, body);
1266
1072
  } else {
1267
- invariant4(!response.ok, "Expected response to not be ok.", {
1268
- F: __dxlog_file6,
1269
- L: 470,
1270
- S: this,
1271
- A: [
1272
- "!response.ok",
1273
- "'Expected response to not be ok.'"
1274
- ]
1275
- });
1073
+ invariant4(!response.ok, "Expected response to not be ok.", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 346, S: this, A: ["!response.ok", "'Expected response to not be ok.'"] });
1276
1074
  processingError = await EdgeCallFailedError.fromHttpFailure(response);
1277
1075
  }
1278
1076
  } catch (error) {
1279
1077
  processingError = EdgeCallFailedError.fromProcessingFailureCause(error);
1280
1078
  }
1281
- if (processingError?.isRetryable && await shouldRetry(requestContext, processingError.retryAfterMs)) {
1079
+ if (processingError?.isRetryable && await shouldRetry(ctx, processingError.retryAfterMs)) {
1282
1080
  log4.verbose("retrying edge request", {
1283
1081
  url,
1284
1082
  processingError
1285
- }, {
1286
- F: __dxlog_file6,
1287
- L: 478,
1288
- S: this,
1289
- C: (f, a) => f(...a)
1290
- });
1083
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 353, S: this });
1291
1084
  } else {
1292
1085
  throw processingError;
1293
1086
  }
@@ -1295,19 +1088,14 @@ var EdgeHttpClient = class {
1295
1088
  }
1296
1089
  async _handleUnauthorized(response) {
1297
1090
  if (!this._edgeIdentity) {
1298
- log4.warn("unauthorized response received before identity was set", void 0, {
1299
- F: __dxlog_file6,
1300
- L: 487,
1301
- S: this,
1302
- C: (f, a) => f(...a)
1303
- });
1091
+ log4.warn("unauthorized response received before identity was set", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 364, S: this });
1304
1092
  throw await EdgeCallFailedError.fromHttpFailure(response);
1305
1093
  }
1306
1094
  const challenge = await handleAuthChallenge(response, this._edgeIdentity);
1307
1095
  return encodeAuthHeader(challenge);
1308
1096
  }
1309
1097
  };
1310
- var createRequest = ({ method, body, json = true }, authHeader) => {
1098
+ var createRequest = ({ method, body, json = true }, authHeader, traceHeaders, clientTag) => {
1311
1099
  let requestBody;
1312
1100
  const headers = {};
1313
1101
  if (json) {
@@ -1319,22 +1107,36 @@ var createRequest = ({ method, body, json = true }, authHeader) => {
1319
1107
  if (typeof requestBody === "string" && requestBody.length > WARNING_BODY_SIZE) {
1320
1108
  log4.warn("Request with large body", {
1321
1109
  bodySize: requestBody.length
1322
- }, {
1323
- F: __dxlog_file6,
1324
- L: 511,
1325
- S: void 0,
1326
- C: (f, a) => f(...a)
1327
- });
1110
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 381, S: void 0 });
1328
1111
  }
1329
1112
  if (authHeader) {
1330
1113
  headers["Authorization"] = authHeader;
1331
1114
  }
1115
+ if (traceHeaders) {
1116
+ Object.assign(headers, traceHeaders);
1117
+ }
1118
+ if (clientTag) {
1119
+ headers[EDGE_CLIENT_TAG_HEADER] = clientTag;
1120
+ }
1332
1121
  return {
1333
1122
  method,
1334
1123
  body: requestBody,
1335
1124
  headers
1336
1125
  };
1337
1126
  };
1127
+ var getTraceHeaders = (ctx) => {
1128
+ const traceCtx = ctx.getAttribute(TRACE_SPAN_ATTRIBUTE2);
1129
+ if (!traceCtx) {
1130
+ return void 0;
1131
+ }
1132
+ const headers = {
1133
+ traceparent: traceCtx.traceparent
1134
+ };
1135
+ if (traceCtx.tracestate) {
1136
+ headers.tracestate = traceCtx.tracestate;
1137
+ }
1138
+ return headers;
1139
+ };
1338
1140
  var createRetryHandler = ({ retry: retry2 }) => {
1339
1141
  if (!retry2 || retry2.count < 1) {
1340
1142
  return async () => false;