@dxos/edge-client 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/edge-client",
3
- "version": "0.8.4-main.9be5663bfe",
3
+ "version": "0.8.4-main.abd8ff62ef",
4
4
  "description": "EDGE Client",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -30,13 +30,6 @@
30
30
  }
31
31
  },
32
32
  "types": "dist/types/src/index.d.ts",
33
- "typesVersions": {
34
- "*": {
35
- "testing": [
36
- "dist/types/src/testing/index.d.ts"
37
- ]
38
- }
39
- },
40
33
  "files": [
41
34
  "dist",
42
35
  "src",
@@ -47,23 +40,23 @@
47
40
  "@opentelemetry/api": "^1.9.0",
48
41
  "isomorphic-ws": "^5.0.0",
49
42
  "ws": "^8.17.1",
50
- "@dxos/async": "0.8.4-main.9be5663bfe",
51
- "@dxos/context": "0.8.4-main.9be5663bfe",
52
- "@dxos/debug": "0.8.4-main.9be5663bfe",
53
- "@dxos/crypto": "0.8.4-main.9be5663bfe",
54
- "@dxos/credentials": "0.8.4-main.9be5663bfe",
55
- "@dxos/effect": "0.8.4-main.9be5663bfe",
56
- "@dxos/invariant": "0.8.4-main.9be5663bfe",
57
- "@dxos/keyring": "0.8.4-main.9be5663bfe",
58
- "@dxos/log": "0.8.4-main.9be5663bfe",
59
- "@dxos/node-std": "0.8.4-main.9be5663bfe",
60
- "@dxos/keys": "0.8.4-main.9be5663bfe",
61
- "@dxos/protocols": "0.8.4-main.9be5663bfe",
62
- "@dxos/tracing": "0.8.4-main.9be5663bfe",
63
- "@dxos/util": "0.8.4-main.9be5663bfe"
43
+ "@dxos/async": "0.8.4-main.abd8ff62ef",
44
+ "@dxos/context": "0.8.4-main.abd8ff62ef",
45
+ "@dxos/crypto": "0.8.4-main.abd8ff62ef",
46
+ "@dxos/credentials": "0.8.4-main.abd8ff62ef",
47
+ "@dxos/debug": "0.8.4-main.abd8ff62ef",
48
+ "@dxos/effect": "0.8.4-main.abd8ff62ef",
49
+ "@dxos/invariant": "0.8.4-main.abd8ff62ef",
50
+ "@dxos/keys": "0.8.4-main.abd8ff62ef",
51
+ "@dxos/keyring": "0.8.4-main.abd8ff62ef",
52
+ "@dxos/node-std": "0.8.4-main.abd8ff62ef",
53
+ "@dxos/log": "0.8.4-main.abd8ff62ef",
54
+ "@dxos/protocols": "0.8.4-main.abd8ff62ef",
55
+ "@dxos/tracing": "0.8.4-main.abd8ff62ef",
56
+ "@dxos/util": "0.8.4-main.abd8ff62ef"
64
57
  },
65
58
  "devDependencies": {
66
- "@dxos/test-utils": "0.8.4-main.9be5663bfe"
59
+ "@dxos/test-utils": "0.8.4-main.abd8ff62ef"
67
60
  },
68
61
  "peerDependencies": {
69
62
  "effect": "3.20.0"
@@ -2,8 +2,6 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { type Context as OtelContext, propagation } from '@opentelemetry/api';
6
-
7
5
  import {
8
6
  Event,
9
7
  PersistentLifecycle,
@@ -12,12 +10,11 @@ import {
12
10
  scheduleMicroTask,
13
11
  scheduleTaskInterval,
14
12
  } from '@dxos/async';
15
- import { Context } from '@dxos/context';
13
+ import { Context, TRACE_SPAN_ATTRIBUTE, type TraceContextData } from '@dxos/context';
16
14
  import { type Lifecycle, Resource } from '@dxos/context';
17
15
  import { log, logInfo } from '@dxos/log';
18
16
  import { type Message } from '@dxos/protocols/buf/dxos/edge/messenger_pb';
19
17
  import { EdgeStatus } from '@dxos/protocols/proto/dxos/client/services';
20
- import { TRACE_PROCESSOR, TRACE_SPAN_ATTRIBUTE } from '@dxos/tracing';
21
18
 
22
19
  import { protocol } from './defs';
23
20
  import { type EdgeIdentity, handleAuthChallenge } from './edge-identity';
@@ -149,22 +146,12 @@ export class EdgeClient extends Resource implements EdgeConnection {
149
146
  throw new EdgeIdentityChangedError();
150
147
  }
151
148
 
152
- // Same W3C Trace Context flow as EdgeHttpClient.getTraceHeaders: resolve OTEL context from the
153
- // DXOS span id, then propagation.inject into a carrier. Here the carrier is the protobuf field
154
- // (WebSocket cannot set HTTP headers on the browser API).
155
- const spanId = ctx.getAttribute(TRACE_SPAN_ATTRIBUTE);
156
- const otlpContext =
157
- typeof spanId === 'number'
158
- ? (TRACE_PROCESSOR.remoteTracing.getSpanContext(spanId) as OtelContext | undefined)
159
- : undefined;
160
-
161
- if (otlpContext) {
162
- const activeSpan: Record<string, string> = {};
163
- propagation.inject(otlpContext, activeSpan);
149
+ const traceCtx = ctx.getAttribute(TRACE_SPAN_ATTRIBUTE) as TraceContextData | undefined;
150
+ if (traceCtx) {
164
151
  message.traceContext = {
165
152
  $typeName: 'dxos.edge.messenger.TraceContext',
166
- traceparent: activeSpan.traceparent,
167
- tracestate: activeSpan.tracestate,
153
+ traceparent: traceCtx.traceparent,
154
+ tracestate: traceCtx.tracestate,
168
155
  };
169
156
  }
170
157
 
@@ -4,12 +4,11 @@
4
4
 
5
5
  import * as FetchHttpClient from '@effect/platform/FetchHttpClient';
6
6
  import * as HttpClient from '@effect/platform/HttpClient';
7
- import { type Context as OtelContext, propagation } from '@opentelemetry/api';
8
7
  import * as Effect from 'effect/Effect';
9
8
  import * as Function from 'effect/Function';
10
9
 
11
10
  import { sleep } from '@dxos/async';
12
- import { Context } from '@dxos/context';
11
+ import { Context, TRACE_SPAN_ATTRIBUTE, type TraceContextData } from '@dxos/context';
13
12
  import { runAndForwardErrors } from '@dxos/effect';
14
13
  import { invariant } from '@dxos/invariant';
15
14
  import { type PublicKey, type SpaceId } from '@dxos/keys';
@@ -29,6 +28,7 @@ import {
29
28
  type ExportBundleResponse,
30
29
  type FeedProtocol,
31
30
  type GetAgentStatusResponseBody,
31
+ type GetPluginsResponseBody,
32
32
  type GetNotarizationResponseBody,
33
33
  type ImportBundleRequest,
34
34
  type InitiateOAuthFlowRequest,
@@ -46,13 +46,23 @@ import {
46
46
  type QueryRequest as QueryRequestProto,
47
47
  type QueryResponse as QueryResponseProto,
48
48
  } from '@dxos/protocols/proto/dxos/echo/query';
49
- import { TRACE_PROCESSOR, TRACE_SPAN_ATTRIBUTE } from '@dxos/tracing';
50
49
  import { createUrl } from '@dxos/util';
51
50
 
52
51
  import { type EdgeIdentity, handleAuthChallenge } from './edge-identity';
53
52
  import { HttpConfig, encodeAuthHeader, withLogging, withRetryConfig } from './http-client';
54
53
  import { getEdgeUrlWithProtocol } from './utils';
55
54
 
55
+ /**
56
+ * HTTP wire shape returned by `/queue/.../query`. Unlike `FeedProtocol.QueryResult`
57
+ * (the RPC proto type, which transports object payloads as JSON strings), the edge
58
+ * HTTP endpoint embeds each object directly in the response JSON.
59
+ */
60
+ export type EdgeQueryQueueResponse = {
61
+ objects?: unknown[];
62
+ nextCursor?: string;
63
+ prevCursor?: string;
64
+ };
65
+
56
66
  const DEFAULT_RETRY_TIMEOUT = 1500;
57
67
  const DEFAULT_RETRY_JITTER = 500;
58
68
  const DEFAULT_MAX_RETRIES_COUNT = 3;
@@ -239,7 +249,7 @@ export class EdgeHttpClient {
239
249
  spaceId: SpaceId,
240
250
  query: FeedProtocol.QueueQuery,
241
251
  args?: EdgeHttpCallArgs,
242
- ): Promise<FeedProtocol.QueryResult> {
252
+ ): Promise<EdgeQueryQueueResponse> {
243
253
  const queueId = query.queueIds?.[0];
244
254
  invariant(queueId, 'queueId required');
245
255
  return this._call(
@@ -413,6 +423,18 @@ export class EdgeHttpClient {
413
423
  return this._call(ctx, new URL(`/spaces/${spaceId}/exec-query`, this.baseUrl), { ...args, body, method: 'POST' });
414
424
  }
415
425
 
426
+ //
427
+ // Registry
428
+ //
429
+
430
+ /**
431
+ * Fetches the hydrated plugin directory from the Edge registry service.
432
+ * Unauthenticated; safe to call without an identity.
433
+ */
434
+ public async getRegistryPlugins(ctx: Context, args?: EdgeHttpCallArgs): Promise<GetPluginsResponseBody> {
435
+ return this._call(ctx, new URL('/registry/plugins', this.baseUrl), { ...args, method: 'GET' });
436
+ }
437
+
416
438
  //
417
439
  // Import/Export space.
418
440
  //
@@ -572,19 +594,16 @@ const createRequest = (
572
594
  * Extract W3C Trace Context headers (traceparent/tracestate) from a DXOS Context.
573
595
  */
574
596
  const getTraceHeaders = (ctx: Context): Record<string, string> | undefined => {
575
- const spanId = ctx.getAttribute(TRACE_SPAN_ATTRIBUTE);
576
- const otlpContext =
577
- typeof spanId === 'number'
578
- ? (TRACE_PROCESSOR.remoteTracing.getSpanContext(spanId) as OtelContext | undefined)
579
- : undefined;
580
-
581
- if (!otlpContext) {
597
+ const traceCtx = ctx.getAttribute(TRACE_SPAN_ATTRIBUTE) as TraceContextData | undefined;
598
+ if (!traceCtx) {
582
599
  return undefined;
583
600
  }
584
601
 
585
- const headers: Record<string, string> = {};
586
- propagation.inject(otlpContext, headers);
587
- return Object.keys(headers).length > 0 ? headers : undefined;
602
+ const headers: Record<string, string> = { traceparent: traceCtx.traceparent };
603
+ if (traceCtx.tracestate) {
604
+ headers.tracestate = traceCtx.tracestate;
605
+ }
606
+ return headers;
588
607
  };
589
608
 
590
609
  /**