@dxos/edge-client 0.16.0 → 0.17.0

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.
@@ -1,5 +1,5 @@
1
1
  import { proxyFetchLegacy } from "./cors-proxy.mjs";
2
- import { C as clientVersionProtocol, S as clientVersionHeaders, _ as handleAuthChallenge, a as getEdgeUrlWithProtocol, b as readAuthChallenge, c as withLogging, d as EdgeClientError, f as EdgeConnectionClosedError, g as fetchAuthChallengeInfo, h as fetchAuthChallenge, i as BaseHttpClient, l as withRetry, m as authenticateViaChallengeEndpoint, n as EdgeHttpClient, o as HttpConfig, p as EdgeIdentityChangedError, r as EdgeHttpClientService, s as encodeAuthHeader, t as BrainFactFeeds, u as withRetryConfig, v as parseChallengeHeader, w as readJsonBody, x as assertClientSupported, y as presentCredentialsForChallenge } from "./chunk-edge-http-client.mjs";
2
+ import { C as presentCredentialsForChallenge, D as clientVersionProtocol, E as clientVersionHeaders, O as readJsonBody, S as parseChallengeHeader, T as assertClientSupported, _ as EdgeIdentityChangedError, a as EdgeHttpClientService, b as fetchAuthChallengeInfo, c as BaseHttpClient, d as encodeAuthHeader, f as withLogging, g as EdgeConnectionClosedError, h as EdgeClientError, i as EdgeHttpClient, l as getEdgeUrlWithProtocol, m as withRetryConfig, n as BrainAdmins, o as ProvisionedBrain, p as withRetry, r as BrainInfo, s as formatPluginBundleLoad, t as AgentHalo, u as HttpConfig, v as authenticateViaChallengeEndpoint, w as readAuthChallenge, x as handleAuthChallenge, y as fetchAuthChallenge } from "./chunk-edge-http-client.mjs";
3
3
  import { a as MAX_INBOUND_MESSAGE_BYTES, c as SegmentedMessageLimitError, d as protocol, f as Protocol, i as MAX_INBOUND_CHUNK_COUNT, l as WebSocketClosedError, m as toUint8Array, n as CLOUDFLARE_RPC_MAX_BYTES, o as MAX_INBOUND_TOTAL_BYTES, p as getTypename, r as EDGE_FLOW_CONTROL, s as MessageTooLargeError, t as CLOUDFLARE_MESSAGE_MAX_BYTES, u as WebSocketMuxer } from "./chunk-edge-ws-muxer.mjs";
4
4
  import * as EffectContext from "effect/Context";
5
5
  import * as Effect from "effect/Effect";
@@ -8,9 +8,10 @@ import * as HttpClient from "effect/http/HttpClient";
8
8
  import * as Layer from "effect/Layer";
9
9
  import * as Schema from "effect/Schema";
10
10
  import { invariant } from "@dxos/invariant";
11
+ import { IdentityDid, PublicKey } from "@dxos/keys";
11
12
  import { log, logInfo } from "@dxos/log";
12
13
  import { BYOK_HEADER, EdgeClientTooOldError, EdgeCredentialsHeaderCodec, EdgeWebsocketProtocol, edgeFlowControlWindow } from "@dxos/protocols";
13
- import { createUrl } from "@dxos/util";
14
+ import { createUrl, markMilestone } from "@dxos/util";
14
15
  import { Event, Mutex, PersistentLifecycle, Trigger, TriggerState, scheduleMicroTask, scheduleTask, scheduleTaskInterval } from "@dxos/async";
15
16
  import { Context, Resource, TRACE_SPAN_ATTRIBUTE } from "@dxos/context";
16
17
  import { create } from "@bufbuild/protobuf";
@@ -20,7 +21,6 @@ import { buf, fromPublicKey } from "@dxos/protocols/buf";
20
21
  import { MessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
21
22
  import { createCredential, createDidFromIdentityKey, signPresentation } from "@dxos/credentials";
22
23
  import { Keyring } from "@dxos/keyring";
23
- import { IdentityDid, PublicKey } from "@dxos/keys";
24
24
  import { EdgeStatusSchema, EdgeStatus_ConnectionState } from "@dxos/protocols/buf/dxos/client/services_pb";
25
25
  import { trace } from "@dxos/tracing";
26
26
  import WebSocket from "isomorphic-ws";
@@ -832,7 +832,7 @@ var EdgeClient = class extends Resource {
832
832
  }, {
833
833
  "~LogMeta": "~LogMeta",
834
834
  F: __dxlog_file$1,
835
- L: 208,
835
+ L: 209,
836
836
  S: this
837
837
  });
838
838
  this._identity = identity;
@@ -857,7 +857,7 @@ var EdgeClient = class extends Resource {
857
857
  log("waiting for websocket", void 0, {
858
858
  "~LogMeta": "~LogMeta",
859
859
  F: __dxlog_file$1,
860
- L: 233,
860
+ L: 234,
861
861
  S: this
862
862
  });
863
863
  await this._ready.wait({ timeout: this._config.timeout ?? DEFAULT_TIMEOUT });
@@ -888,7 +888,7 @@ var EdgeClient = class extends Resource {
888
888
  const sent = this.sendAndWait(Context.default(void 0, {
889
889
  "~LogMeta": "~LogMeta",
890
890
  F: __dxlog_file$1,
891
- L: 278
891
+ L: 279
892
892
  }), message);
893
893
  if (!signal) return sent;
894
894
  return new Promise((resolve, reject) => {
@@ -914,7 +914,7 @@ var EdgeClient = class extends Resource {
914
914
  log.catch(error, void 0, {
915
915
  "~LogMeta": "~LogMeta",
916
916
  F: __dxlog_file$1,
917
- L: 315,
917
+ L: 316,
918
918
  S: this
919
919
  });
920
920
  }
@@ -928,11 +928,12 @@ var EdgeClient = class extends Resource {
928
928
  startNetworking() {
929
929
  if (this._networkingStarted) return;
930
930
  this._networkingStarted = true;
931
+ markMilestone("network.started");
931
932
  this._persistentLifecycle.open().catch((err) => {
932
933
  log.warn("Error while opening connection", { err }, {
933
934
  "~LogMeta": "~LogMeta",
934
935
  F: __dxlog_file$1,
935
- L: 334,
936
+ L: 336,
936
937
  S: this
937
938
  });
938
939
  });
@@ -944,14 +945,14 @@ var EdgeClient = class extends Resource {
944
945
  log("opening...", { info: this.info }, {
945
946
  "~LogMeta": "~LogMeta",
946
947
  F: __dxlog_file$1,
947
- L: 342,
948
+ L: 344,
948
949
  S: this
949
950
  });
950
951
  this.#registerMetrics();
951
952
  if (this._config.deferConnect) log("deferring connection until startNetworking", void 0, {
952
953
  "~LogMeta": "~LogMeta",
953
954
  F: __dxlog_file$1,
954
- L: 345,
955
+ L: 347,
955
956
  S: this
956
957
  });
957
958
  else this.startNetworking();
@@ -967,7 +968,7 @@ var EdgeClient = class extends Resource {
967
968
  log("closing...", { peerKey: this._identity.peerKey }, {
968
969
  "~LogMeta": "~LogMeta",
969
970
  F: __dxlog_file$1,
970
- L: 367,
971
+ L: 369,
971
972
  S: this
972
973
  });
973
974
  for (const cleanup of this.#metricsCleanup) cleanup();
@@ -988,7 +989,7 @@ var EdgeClient = class extends Resource {
988
989
  log.warn("EDGE refused this SDK as outdated; not reconnecting until the app is updated", { data: err.data }, {
989
990
  "~LogMeta": "~LogMeta",
990
991
  F: __dxlog_file$1,
991
- L: 392,
992
+ L: 394,
992
993
  S: this
993
994
  });
994
995
  this.#refusal = err;
@@ -1001,7 +1002,7 @@ var EdgeClient = class extends Resource {
1001
1002
  log("identity changed during auth header request", void 0, {
1002
1003
  "~LogMeta": "~LogMeta",
1003
1004
  F: __dxlog_file$1,
1004
- L: 400,
1005
+ L: 402,
1005
1006
  S: this
1006
1007
  });
1007
1008
  return;
@@ -1014,7 +1015,7 @@ var EdgeClient = class extends Resource {
1014
1015
  }, {
1015
1016
  "~LogMeta": "~LogMeta",
1016
1017
  F: __dxlog_file$1,
1017
- L: 406,
1018
+ L: 408,
1018
1019
  S: this
1019
1020
  });
1020
1021
  const connection = new EdgeWsConnection(identity, {
@@ -1024,19 +1025,20 @@ var EdgeClient = class extends Resource {
1024
1025
  }, {
1025
1026
  onConnected: () => {
1026
1027
  if (this._isActive(connection)) {
1028
+ markMilestone("network.connected");
1027
1029
  this._ready.wake();
1028
1030
  this._notifyReconnected();
1029
1031
  } else {
1030
1032
  log.verbose("closing a connection that connected after it was replaced", void 0, {
1031
1033
  "~LogMeta": "~LogMeta",
1032
1034
  F: __dxlog_file$1,
1033
- L: 421,
1035
+ L: 424,
1034
1036
  S: this
1035
1037
  });
1036
1038
  connection.close().catch((err) => log.catch(err, void 0, {
1037
1039
  "~LogMeta": "~LogMeta",
1038
1040
  F: __dxlog_file$1,
1039
- L: 422,
1041
+ L: 425,
1040
1042
  S: this
1041
1043
  }));
1042
1044
  }
@@ -1049,7 +1051,7 @@ var EdgeClient = class extends Resource {
1049
1051
  } else log.verbose("restart requested by inactive connection", void 0, {
1050
1052
  "~LogMeta": "~LogMeta",
1051
1053
  F: __dxlog_file$1,
1052
- L: 431,
1054
+ L: 434,
1053
1055
  S: this
1054
1056
  });
1055
1057
  restartRequired.wake();
@@ -1063,13 +1065,13 @@ var EdgeClient = class extends Resource {
1063
1065
  }, {
1064
1066
  "~LogMeta": "~LogMeta",
1065
1067
  F: __dxlog_file$1,
1066
- L: 439,
1068
+ L: 442,
1067
1069
  S: this
1068
1070
  });
1069
1071
  connection.close().catch((err) => log.catch(err, void 0, {
1070
1072
  "~LogMeta": "~LogMeta",
1071
1073
  F: __dxlog_file$1,
1072
- L: 443,
1074
+ L: 446,
1073
1075
  S: this
1074
1076
  }));
1075
1077
  }
@@ -1112,7 +1114,7 @@ var EdgeClient = class extends Resource {
1112
1114
  }, {
1113
1115
  "~LogMeta": "~LogMeta",
1114
1116
  F: __dxlog_file$1,
1115
- L: 509,
1117
+ L: 512,
1116
1118
  S: this
1117
1119
  });
1118
1120
  trace.metrics.increment("dxos.edge.ws.reconnect.count", 1, {
@@ -1128,7 +1130,7 @@ var EdgeClient = class extends Resource {
1128
1130
  log.error("ws reconnect listener failed", { err }, {
1129
1131
  "~LogMeta": "~LogMeta",
1130
1132
  F: __dxlog_file$1,
1131
- L: 522,
1133
+ L: 525,
1132
1134
  S: this
1133
1135
  });
1134
1136
  }
@@ -1143,7 +1145,7 @@ var EdgeClient = class extends Resource {
1143
1145
  }, {
1144
1146
  "~LogMeta": "~LogMeta",
1145
1147
  F: __dxlog_file$1,
1146
- L: 532,
1148
+ L: 535,
1147
1149
  S: this
1148
1150
  });
1149
1151
  }
@@ -1176,7 +1178,7 @@ var EdgeClient = class extends Resource {
1176
1178
  }, {
1177
1179
  "~LogMeta": "~LogMeta",
1178
1180
  F: __dxlog_file$1,
1179
- L: 564,
1181
+ L: 567,
1180
1182
  S: this
1181
1183
  });
1182
1184
  }
@@ -1434,6 +1436,6 @@ var MarkdownResponse = Schema.Struct({
1434
1436
  result: Schema.String
1435
1437
  });
1436
1438
  //#endregion
1437
- export { BaseHttpClient, BrainFactFeeds, ByokError, CLOUDFLARE_MESSAGE_MAX_BYTES, CLOUDFLARE_RPC_MAX_BYTES, EDGE_FLOW_CONTROL, EdgeAiHttpClient, EdgeClient, EdgeClientError, EdgeConnectionClosedError, EdgeConnectionService, EdgeHttpClient, EdgeHttpClientService, EdgeIdentityChangedError, HttpConfig, HubHttpClient, MAX_INBOUND_CHUNK_COUNT, MAX_INBOUND_MESSAGE_BYTES, MAX_INBOUND_TOTAL_BYTES, MarkdownRequest, MarkdownResponse, MessageTooLargeError, Protocol, SegmentedMessageLimitError, UsageQuotaExceededError, WebSocketClosedError, WebSocketMuxer, authenticateViaChallengeEndpoint, createChainEdgeIdentity, createDeviceEdgeIdentity, createEphemeralEdgeIdentity, createStubEdgeIdentity, createTestHaloEdgeIdentity, encodeAuthHeader, fetchAuthChallenge, fetchAuthChallengeInfo, getEdgeUrlWithProtocol, getTypename, handleAuthChallenge, parseChallengeHeader, patchAnthropicMessagesRequestBody, presentCredentialsForChallenge, protocol, proxyFetchLegacy, readAuthChallenge, toUint8Array, withLogging, withRetry, withRetryConfig };
1439
+ export { AgentHalo, BaseHttpClient, BrainAdmins, BrainInfo, ByokError, CLOUDFLARE_MESSAGE_MAX_BYTES, CLOUDFLARE_RPC_MAX_BYTES, EDGE_FLOW_CONTROL, EdgeAiHttpClient, EdgeClient, EdgeClientError, EdgeConnectionClosedError, EdgeConnectionService, EdgeHttpClient, EdgeHttpClientService, EdgeIdentityChangedError, HttpConfig, HubHttpClient, MAX_INBOUND_CHUNK_COUNT, MAX_INBOUND_MESSAGE_BYTES, MAX_INBOUND_TOTAL_BYTES, MarkdownRequest, MarkdownResponse, MessageTooLargeError, Protocol, ProvisionedBrain, SegmentedMessageLimitError, UsageQuotaExceededError, WebSocketClosedError, WebSocketMuxer, authenticateViaChallengeEndpoint, createChainEdgeIdentity, createDeviceEdgeIdentity, createEphemeralEdgeIdentity, createStubEdgeIdentity, createTestHaloEdgeIdentity, encodeAuthHeader, fetchAuthChallenge, fetchAuthChallengeInfo, formatPluginBundleLoad, getEdgeUrlWithProtocol, getTypename, handleAuthChallenge, parseChallengeHeader, patchAnthropicMessagesRequestBody, presentCredentialsForChallenge, protocol, proxyFetchLegacy, readAuthChallenge, toUint8Array, withLogging, withRetry, withRetryConfig };
1438
1440
 
1439
1441
  //# sourceMappingURL=index.mjs.map