memeloop 0.2.0 → 0.2.2

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 (42) hide show
  1. package/dist/browser.cjs +1 -1
  2. package/dist/browser.cjs.map +1 -1
  3. package/dist/browser.d.cts +5 -5
  4. package/dist/browser.d.ts +5 -5
  5. package/dist/browser.js +1 -1
  6. package/dist/chunk-JRCEXHTP.js +1 -0
  7. package/dist/{chunk-ECNKBH5A.js → chunk-KXVZQLJL.js} +127 -21
  8. package/dist/chunk-KXVZQLJL.js.map +1 -0
  9. package/dist/{chunk-CCEFAOSH.js → chunk-WHXFUMDE.js} +2 -2
  10. package/dist/{chunk-CCEFAOSH.js.map → chunk-WHXFUMDE.js.map} +1 -1
  11. package/dist/device-network-portable.cjs +132 -20
  12. package/dist/device-network-portable.cjs.map +1 -1
  13. package/dist/device-network-portable.d.cts +3 -3
  14. package/dist/device-network-portable.d.ts +3 -3
  15. package/dist/device-network-portable.js +14 -2
  16. package/dist/device-network.cjs +132 -20
  17. package/dist/device-network.cjs.map +1 -1
  18. package/dist/device-network.d.cts +2 -2
  19. package/dist/device-network.d.ts +2 -2
  20. package/dist/device-network.js +14 -2
  21. package/dist/index.cjs +134 -22
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +4 -4
  24. package/dist/index.d.ts +4 -4
  25. package/dist/index.js +15 -3
  26. package/dist/index.js.map +1 -1
  27. package/dist/loop-api.cjs.map +1 -1
  28. package/dist/{orchestration-portable-BbkwLbC9.d.ts → orchestration-portable-B4udCSVd.d.ts} +1 -1
  29. package/dist/{orchestration-portable-DNKzAtNq.d.cts → orchestration-portable-BWaCsCGK.d.cts} +1 -1
  30. package/dist/orchestration-portable.cjs +1 -1
  31. package/dist/orchestration-portable.cjs.map +1 -1
  32. package/dist/orchestration-portable.d.cts +2 -2
  33. package/dist/orchestration-portable.d.ts +2 -2
  34. package/dist/orchestration-portable.js +1 -1
  35. package/dist/{pairingInvite-DDx_-IAp.d.cts → pairingInvite-C12n-7Ak.d.cts} +15 -3
  36. package/dist/{pairingInvite-Dkz8CLsb.d.ts → pairingInvite-CPQkuhLQ.d.ts} +15 -3
  37. package/dist/{remoteClient-BKmQEQY9.d.cts → remoteClient-DFIyCZEv.d.cts} +1 -1
  38. package/dist/{remoteClient-D5hco6cS.d.ts → remoteClient-DwBCoHpc.d.ts} +1 -1
  39. package/package.json +1 -1
  40. package/dist/chunk-ECNKBH5A.js.map +0 -1
  41. package/dist/chunk-MXRXYGWW.js +0 -1
  42. /package/dist/{chunk-MXRXYGWW.js.map → chunk-JRCEXHTP.js.map} +0 -0
@@ -1,6 +1,6 @@
1
- export { A as AttachmentBlobWire, C as CreateDevicePairingInviteOptions, D as DEVICE_ORCHESTRATION_PROTOCOL, a as DEVICE_PAIRING_INVITE_PROTOCOL, b as DEVICE_PAIRING_INVITE_TTL_MS, c as DeviceCloudComponentStatus, d as DeviceCloudConnectionAdapter, e as DeviceCloudConnectionComponent, f as DeviceCloudConnectionCoordinator, g as DeviceCloudConnectionCoordinatorOptions, h as DeviceCloudConnectionSnapshot, i as DeviceCloudConnectionStatus, j as DeviceCloudStepResult, k as DeviceOrchestrationStreamHandler, l as DeviceOrchestrationStreamHandlerInput, m as DeviceOrchestrationStreamHandlerOptions, n as DeviceOrchestrationTransportOptions, o as DevicePairingInvite, p as DevicePairingInviteIdentityVerifier, q as DevicePairingInviteIdentityVerifierInput, r as DevicePairingInviteUnsignedPayload, s as DeviceSyncStateStore, J as JsonFrameError, t as JsonFrameErrorCode, u as JsonFrameReaderOptions, L as LIBP2P_RPC_REQUEST_TYPE, v as LIBP2P_RPC_RESPONSE_TYPE, w as LIBP2P_SYNC_REQUEST_TYPE, x as LIBP2P_SYNC_RESPONSE_TYPE, y as Libp2pDeviceSyncTransport, z as Libp2pDeviceSyncTransportOptions, B as Libp2pRpcRequest, E as Libp2pRpcResponse, F as Libp2pSyncMethod, G as Libp2pSyncRequest, H as Libp2pSyncResponse, I as LocalTrustDeviceAuthorizer, K as LocalTrustDeviceAuthorizerOptions, M as MemoryDeviceSyncStateStore, P as ParseDevicePairingInviteOptions, R as RemoteOrchestrationHandler, N as attachmentBlobFromWire, O as canonicalDevicePairingInviteBytes, Q as createDeviceOrchestrationStreamHandler, S as createDeviceOrchestrationTransport, T as createDevicePairingInvite, U as createJsonFrameReader, V as encodeDevicePairingInvite, W as encodeJsonFrame, X as encodeJsonFrames, Y as isLibp2pRpcRequest, Z as isLibp2pRpcResponse, _ as isLibp2pSyncRequest, $ as isLibp2pSyncResponse, a0 as parseDevicePairingInvite } from './pairingInvite-Dkz8CLsb.js';
1
+ export { A as AttachmentBlobWire, C as CreateDevicePairingInviteOptions, D as DEVICE_BINDING_SIGNATURE_DOMAIN, a as DEVICE_CONNECTION_GRANT_SIGNATURE_DOMAIN, b as DEVICE_ORCHESTRATION_PROTOCOL, c as DEVICE_PAIRING_INVITE_PROTOCOL, d as DEVICE_PAIRING_INVITE_TTL_MS, e as DEVICE_RELAY_ADMISSION_SIGNATURE_DOMAIN, f as DeviceCloudComponentStatus, g as DeviceCloudConnectionAdapter, h as DeviceCloudConnectionComponent, i as DeviceCloudConnectionCoordinator, j as DeviceCloudConnectionCoordinatorOptions, k as DeviceCloudConnectionSnapshot, l as DeviceCloudConnectionStatus, m as DeviceCloudStepResult, n as DeviceOrchestrationStreamHandler, o as DeviceOrchestrationStreamHandlerInput, p as DeviceOrchestrationStreamHandlerOptions, q as DeviceOrchestrationTransportOptions, r as DevicePairingInvite, s as DevicePairingInviteIdentityVerifier, t as DevicePairingInviteIdentityVerifierInput, u as DevicePairingInviteUnsignedPayload, v as DeviceSyncStateStore, J as JsonFrameError, w as JsonFrameErrorCode, x as JsonFrameReaderOptions, L as LIBP2P_RPC_REQUEST_TYPE, y as LIBP2P_RPC_RESPONSE_TYPE, z as LIBP2P_SYNC_REQUEST_TYPE, B as LIBP2P_SYNC_RESPONSE_TYPE, E as Libp2pDeviceSyncTransport, F as Libp2pDeviceSyncTransportOptions, G as Libp2pRpcRequest, H as Libp2pRpcResponse, I as Libp2pSyncMethod, K as Libp2pSyncRequest, M as Libp2pSyncResponse, N as LocalTrustDeviceAuthorizer, O as LocalTrustDeviceAuthorizerOptions, P as MemoryDeviceSyncStateStore, Q as ParseDevicePairingInviteOptions, R as RemoteOrchestrationHandler, S as attachmentBlobFromWire, T as buildDeviceBindingMessage, U as buildDeviceConnectionGrantMessage, V as buildDeviceRelayReservationTokenMessage, W as canonicalDevicePairingInviteBytes, X as createDeviceOrchestrationStreamHandler, Y as createDeviceOrchestrationTransport, Z as createDevicePairingInvite, _ as createJsonFrameReader, $ as encodeDevicePairingInvite, a0 as encodeJsonFrame, a1 as encodeJsonFrames, a2 as isLibp2pRpcRequest, a3 as isLibp2pRpcResponse, a4 as isLibp2pSyncRequest, a5 as isLibp2pSyncResponse, a6 as parseDevicePairingInvite } from './pairingInvite-CPQkuhLQ.js';
2
2
  export { A as AgentExecutionLocation, a as AgentExecutionState, b as AttachmentBlob, C as CloudDeviceClient, c as CloudDeviceRecord, d as ConversationExecutionPlacement, D as Device, e as DeviceAccountBindingRequest, f as DeviceAuthorizer, g as DeviceCapabilities, h as DeviceConnectionGrant, i as DeviceConnectionGrantVerificationInput, j as DeviceNetworkListenOptions, k as DeviceNetworkPath, l as DeviceNetworkService, m as DevicePlatform, n as DeviceProtocolDirection, o as DeviceReachability, p as DeviceReachabilityState, q as DeviceRelayReservationToken, r as DeviceRelayReservationTokenVerificationInput, s as DeviceRpcHandler, t as DeviceRpcHandlerInput, u as DeviceSyncTransport, v as DeviceTrustMode, w as DeviceTrustStore, E as ExchangeVersionVectorResult, L as LocalDeviceIdentity, x as LocalPairingRequestOptions, M as MemeLoopDuplexStream, y as MemeLoopProtocol, P as PairingSession, z as PairingSessionDirection, B as PairingSessionStatus, S as SyncResult, T as TrustedDeviceRecord } from './types-CcFFIk8W.js';
3
3
  export { ChatSyncEngine, ChatSyncEngineOptions, ChatSyncPeer, PeerNodeSyncAdapter, PeerNodeTransport, decodeAttachmentBlobRpc } from './device-network-portable.js';
4
4
  export { C as ConversationMeta, a as ConversationMetadataPage, I as IAgentStorage, V as VersionRange, b as VersionVector, c as computeMissingVersionRanges, i as isConversationMeta } from './interface-3C3eG8Hn.js';
5
5
  export { M as MemoryDeviceNetworkService, a as MemoryDeviceNetworkServiceOptions, s as syncCloudDevices } from './syncCloudDevices-C8fCUhnX.js';
6
- import './remoteClient-D5hco6cS.js';
6
+ import './remoteClient-DwBCoHpc.js';
@@ -2,12 +2,15 @@ import {
2
2
  MemoryDeviceNetworkService,
3
3
  syncCloudDevices
4
4
  } from "./chunk-EPHRIRAL.js";
5
- import "./chunk-MXRXYGWW.js";
5
+ import "./chunk-JRCEXHTP.js";
6
6
  import {
7
7
  ChatSyncEngine,
8
+ DEVICE_BINDING_SIGNATURE_DOMAIN,
9
+ DEVICE_CONNECTION_GRANT_SIGNATURE_DOMAIN,
8
10
  DEVICE_ORCHESTRATION_PROTOCOL,
9
11
  DEVICE_PAIRING_INVITE_PROTOCOL,
10
12
  DEVICE_PAIRING_INVITE_TTL_MS,
13
+ DEVICE_RELAY_ADMISSION_SIGNATURE_DOMAIN,
11
14
  DeviceCloudConnectionCoordinator,
12
15
  JsonFrameError,
13
16
  LIBP2P_RPC_REQUEST_TYPE,
@@ -19,6 +22,9 @@ import {
19
22
  MemoryDeviceSyncStateStore,
20
23
  PeerNodeSyncAdapter,
21
24
  attachmentBlobFromWire,
25
+ buildDeviceBindingMessage,
26
+ buildDeviceConnectionGrantMessage,
27
+ buildDeviceRelayReservationTokenMessage,
22
28
  canonicalDevicePairingInviteBytes,
23
29
  computeMissingVersionRanges,
24
30
  createDeviceOrchestrationStreamHandler,
@@ -35,13 +41,16 @@ import {
35
41
  isLibp2pSyncRequest,
36
42
  isLibp2pSyncResponse,
37
43
  parseDevicePairingInvite
38
- } from "./chunk-ECNKBH5A.js";
44
+ } from "./chunk-KXVZQLJL.js";
39
45
  import "./chunk-FWSY5HOA.js";
40
46
  export {
41
47
  ChatSyncEngine,
48
+ DEVICE_BINDING_SIGNATURE_DOMAIN,
49
+ DEVICE_CONNECTION_GRANT_SIGNATURE_DOMAIN,
42
50
  DEVICE_ORCHESTRATION_PROTOCOL,
43
51
  DEVICE_PAIRING_INVITE_PROTOCOL,
44
52
  DEVICE_PAIRING_INVITE_TTL_MS,
53
+ DEVICE_RELAY_ADMISSION_SIGNATURE_DOMAIN,
45
54
  DeviceCloudConnectionCoordinator,
46
55
  JsonFrameError,
47
56
  LIBP2P_RPC_REQUEST_TYPE,
@@ -54,6 +63,9 @@ export {
54
63
  MemoryDeviceSyncStateStore,
55
64
  PeerNodeSyncAdapter,
56
65
  attachmentBlobFromWire,
66
+ buildDeviceBindingMessage,
67
+ buildDeviceConnectionGrantMessage,
68
+ buildDeviceRelayReservationTokenMessage,
57
69
  canonicalDevicePairingInviteBytes,
58
70
  computeMissingVersionRanges,
59
71
  createDeviceOrchestrationStreamHandler,
package/dist/index.cjs CHANGED
@@ -22323,7 +22323,7 @@ var init_remoteClient = __esm({
22323
22323
  "src/orchestration/remoteClient.ts"() {
22324
22324
  "use strict";
22325
22325
  init_errors();
22326
- REMOTE_ORCHESTRATION_PROTOCOL = "memeloop.resource.v1";
22326
+ REMOTE_ORCHESTRATION_PROTOCOL = "memeloop.resource.v2";
22327
22327
  REMOTE_OPERATIONS = /* @__PURE__ */ new Set([
22328
22328
  "capabilities",
22329
22329
  "apply",
@@ -26457,9 +26457,12 @@ __export(src_exports, {
26457
26457
  CREDENTIAL_GRANT_KIND: () => CREDENTIAL_GRANT_KIND,
26458
26458
  ChatSyncEngine: () => ChatSyncEngine,
26459
26459
  DEFAULT_DESTINATION_POLICIES: () => DEFAULT_DESTINATION_POLICIES,
26460
+ DEVICE_BINDING_SIGNATURE_DOMAIN: () => DEVICE_BINDING_SIGNATURE_DOMAIN,
26461
+ DEVICE_CONNECTION_GRANT_SIGNATURE_DOMAIN: () => DEVICE_CONNECTION_GRANT_SIGNATURE_DOMAIN,
26460
26462
  DEVICE_ORCHESTRATION_PROTOCOL: () => DEVICE_ORCHESTRATION_PROTOCOL,
26461
26463
  DEVICE_PAIRING_INVITE_PROTOCOL: () => DEVICE_PAIRING_INVITE_PROTOCOL,
26462
26464
  DEVICE_PAIRING_INVITE_TTL_MS: () => DEVICE_PAIRING_INVITE_TTL_MS,
26465
+ DEVICE_RELAY_ADMISSION_SIGNATURE_DOMAIN: () => DEVICE_RELAY_ADMISSION_SIGNATURE_DOMAIN,
26463
26466
  DRIVER_MANIFEST_API_VERSION: () => DRIVER_MANIFEST_API_VERSION,
26464
26467
  DRIVER_MANIFEST_KIND: () => DRIVER_MANIFEST_KIND,
26465
26468
  DRIVER_REQUEST_API_VERSION: () => DRIVER_REQUEST_API_VERSION,
@@ -26576,6 +26579,9 @@ __export(src_exports, {
26576
26579
  base64UrlEncode: () => base64UrlEncode,
26577
26580
  bindWorkerSession: () => bindWorkerSession,
26578
26581
  buildAgent: () => buildAgent,
26582
+ buildDeviceBindingMessage: () => buildDeviceBindingMessage,
26583
+ buildDeviceConnectionGrantMessage: () => buildDeviceConnectionGrantMessage,
26584
+ buildDeviceRelayReservationTokenMessage: () => buildDeviceRelayReservationTokenMessage,
26579
26585
  buildLegacyChatMessageParts: () => buildLegacyChatMessageParts,
26580
26586
  buildMemeloopFileUri: () => buildMemeloopFileUri,
26581
26587
  buildMemeloopUri: () => buildMemeloopUri,
@@ -28888,8 +28894,12 @@ var DeviceCloudConnectionCoordinator = class {
28888
28894
  async stop() {
28889
28895
  this.started = false;
28890
28896
  this.clearTimer();
28891
- this.controller.abort(new Error("device cloud coordinator stopped"));
28897
+ const stoppedController = this.controller;
28898
+ stoppedController.abort(new Error("device cloud coordinator stopped"));
28892
28899
  await this.inFlight?.catch(() => void 0);
28900
+ if (this.controller === stoppedController) {
28901
+ this.controller = new AbortController();
28902
+ }
28893
28903
  }
28894
28904
  async setConfiguration(configuration) {
28895
28905
  this.configuration = configuration;
@@ -29038,6 +29048,43 @@ var DeviceCloudConnectionCoordinator = class {
29038
29048
  }
29039
29049
  };
29040
29050
 
29051
+ // src/device-network/deviceGrantMessages.ts
29052
+ var DEVICE_BINDING_SIGNATURE_DOMAIN = "memeloop-device-binding-v2";
29053
+ var DEVICE_CONNECTION_GRANT_SIGNATURE_DOMAIN = "memeloop-device-connection-grant-v2";
29054
+ var DEVICE_RELAY_ADMISSION_SIGNATURE_DOMAIN = "memeloop-device-relay-admission-v2";
29055
+ function buildDeviceBindingMessage(input) {
29056
+ return new TextEncoder().encode([
29057
+ DEVICE_BINDING_SIGNATURE_DOMAIN,
29058
+ `accountId=${input.accountId}`,
29059
+ `peerId=${input.peerId}`,
29060
+ `publicKey=${input.publicKeyMultibase}`,
29061
+ `nonce=${input.nonce}`
29062
+ ].join("\n"));
29063
+ }
29064
+ function buildDeviceConnectionGrantMessage(grant) {
29065
+ return new TextEncoder().encode([
29066
+ DEVICE_CONNECTION_GRANT_SIGNATURE_DOMAIN,
29067
+ `issuer=${grant.issuer}`,
29068
+ `accountId=${grant.accountId}`,
29069
+ `subjectPeerId=${grant.subjectPeerId}`,
29070
+ `allowedPeerIds=${grant.allowedPeerIds.join(",")}`,
29071
+ `issuedAt=${grant.issuedAt}`,
29072
+ `expiresAt=${grant.expiresAt}`
29073
+ ].join("\n"));
29074
+ }
29075
+ function buildDeviceRelayReservationTokenMessage(token) {
29076
+ return new TextEncoder().encode([
29077
+ DEVICE_RELAY_ADMISSION_SIGNATURE_DOMAIN,
29078
+ `issuer=${token.issuer}`,
29079
+ `accountId=${token.accountId}`,
29080
+ `peerId=${token.peerId}`,
29081
+ `relayMultiaddrs=${token.relayMultiaddrs.join(",")}`,
29082
+ `bootstrapMultiaddrs=${token.bootstrapMultiaddrs.join(",")}`,
29083
+ `issuedAt=${token.issuedAt}`,
29084
+ `expiresAt=${token.expiresAt}`
29085
+ ].join("\n"));
29086
+ }
29087
+
29041
29088
  // src/device-network/deviceOrchestrationTransport.ts
29042
29089
  init_errors();
29043
29090
 
@@ -29435,39 +29482,92 @@ async function readSingleRequest(stream, maxFrameBytes) {
29435
29482
  }
29436
29483
  async function* withWatchBookmarks(source, request, signal) {
29437
29484
  const iterator = source[Symbol.asyncIterator]();
29438
- let pending2 = iterator.next();
29485
+ let activity;
29486
+ let activityWaiter;
29487
+ let bookmarkTimer;
29488
+ let readInFlight = false;
29489
+ let lastResourceVersion = watchResourceVersion(request.payload.options) ?? "0";
29490
+ const clearBookmarkTimer = () => {
29491
+ if (bookmarkTimer !== void 0) clearTimeout(bookmarkTimer);
29492
+ bookmarkTimer = void 0;
29493
+ };
29494
+ const publishActivity = (value) => {
29495
+ if (activityWaiter) {
29496
+ const resolve = activityWaiter;
29497
+ activityWaiter = void 0;
29498
+ clearBookmarkTimer();
29499
+ resolve(value);
29500
+ return;
29501
+ }
29502
+ activity = value;
29503
+ };
29504
+ const readNext = () => {
29505
+ if (readInFlight) return;
29506
+ readInFlight = true;
29507
+ void iterator.next().then(
29508
+ (value) => {
29509
+ readInFlight = false;
29510
+ publishActivity({ kind: "value", value });
29511
+ },
29512
+ (error2) => {
29513
+ readInFlight = false;
29514
+ publishActivity({ kind: "error", error: error2 });
29515
+ }
29516
+ );
29517
+ };
29518
+ const waitForActivity = () => {
29519
+ if (activity) {
29520
+ const value = activity;
29521
+ activity = void 0;
29522
+ return Promise.resolve(value);
29523
+ }
29524
+ if (signal.aborted) return Promise.resolve({ kind: "aborted" });
29525
+ return new Promise((resolve) => {
29526
+ activityWaiter = resolve;
29527
+ bookmarkTimer = setTimeout(() => {
29528
+ bookmarkTimer = void 0;
29529
+ activityWaiter = void 0;
29530
+ resolve({ kind: "bookmark" });
29531
+ }, WATCH_BOOKMARK_INTERVAL_MS);
29532
+ });
29533
+ };
29534
+ const onAbort = () => {
29535
+ publishActivity({ kind: "aborted" });
29536
+ };
29537
+ signal.addEventListener("abort", onAbort, { once: true });
29538
+ readNext();
29439
29539
  try {
29440
29540
  for (; ; ) {
29441
- const result = await Promise.race([
29442
- pending2.then((value) => ({ kind: "value", value })),
29443
- new Promise((resolve) => {
29444
- const timer = setTimeout(() => {
29445
- resolve({ kind: "bookmark" });
29446
- }, WATCH_BOOKMARK_INTERVAL_MS);
29447
- signal.addEventListener("abort", () => {
29448
- clearTimeout(timer);
29449
- resolve({ kind: "bookmark" });
29450
- }, { once: true });
29451
- })
29452
- ]);
29453
- if (signal.aborted) return;
29541
+ const result = await waitForActivity();
29542
+ if (result.kind === "aborted") return;
29454
29543
  if (result.kind === "bookmark") {
29455
29544
  yield {
29456
29545
  protocol: request.protocol,
29457
29546
  requestId: request.requestId,
29458
29547
  ok: true,
29459
- result: { type: "BOOKMARK", resourceVersion: String(Date.now()) }
29548
+ result: { type: "BOOKMARK", resourceVersion: lastResourceVersion }
29460
29549
  };
29461
29550
  continue;
29462
29551
  }
29552
+ if (result.kind === "error") throw result.error;
29463
29553
  if (result.value.done) return;
29464
- yield result.value.value;
29465
- pending2 = iterator.next();
29554
+ const response = result.value.value;
29555
+ lastResourceVersion = response.ok ? watchResourceVersion(response.result) ?? lastResourceVersion : lastResourceVersion;
29556
+ yield response;
29557
+ readNext();
29466
29558
  }
29467
29559
  } finally {
29560
+ clearBookmarkTimer();
29561
+ activityWaiter = void 0;
29562
+ signal.removeEventListener("abort", onAbort);
29468
29563
  void iterator.return?.();
29469
29564
  }
29470
29565
  }
29566
+ function watchResourceVersion(value) {
29567
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return void 0;
29568
+ const resourceVersion = value.resourceVersion;
29569
+ return typeof resourceVersion === "string" && resourceVersion.length > 0 ? resourceVersion : void 0;
29570
+ }
29471
29571
  function createDeviceOrchestrationStreamHandler(options) {
29472
29572
  const maxFrameBytes = options.maxFrameBytes ?? DEFAULT_MAX_FRAME_BYTES;
29473
29573
  assertFrameLimit(maxFrameBytes);
@@ -29575,6 +29675,12 @@ var Libp2pDeviceSyncTransport = class {
29575
29675
  async request(peerId, method, parameters) {
29576
29676
  const grant = await this.grantProvider?.(peerId);
29577
29677
  const stream = await this.deviceNetwork.openStream(peerId, "/memeloop/sync/2.0.0", grant);
29678
+ let aborted = false;
29679
+ const abort = async (error2) => {
29680
+ if (aborted) return;
29681
+ aborted = true;
29682
+ await stream.abort(error2);
29683
+ };
29578
29684
  const request = {
29579
29685
  type: LIBP2P_SYNC_REQUEST_TYPE,
29580
29686
  id: crypto.randomUUID(),
@@ -29589,7 +29695,7 @@ var Libp2pDeviceSyncTransport = class {
29589
29695
  maxPayloadBytes: 16 * 1024 * 1024,
29590
29696
  idleTimeoutMs: 15e3,
29591
29697
  totalTimeoutMs: 12e4,
29592
- abort: async (error2) => stream.abort(error2)
29698
+ abort
29593
29699
  })) {
29594
29700
  if (response !== void 0) throw new Error("sync_response_multiple");
29595
29701
  response = value;
@@ -29599,7 +29705,7 @@ var Libp2pDeviceSyncTransport = class {
29599
29705
  if (!response.ok) throw new Error(response.error);
29600
29706
  return response.result;
29601
29707
  } catch (error2) {
29602
- if (error2 instanceof JsonFrameError) await stream.abort(error2);
29708
+ if (error2 instanceof JsonFrameError) await abort(error2);
29603
29709
  throw error2;
29604
29710
  } finally {
29605
29711
  await stream.close().catch(() => void 0);
@@ -29947,7 +30053,7 @@ async function parseDevicePairingInvite(serialized, options) {
29947
30053
  }
29948
30054
 
29949
30055
  // src/device-network/peerDriverTransport.ts
29950
- var PEER_DRIVER_PROTOCOL_VERSION = "memeloop-peer-driver/v1";
30056
+ var PEER_DRIVER_PROTOCOL_VERSION = "memeloop-peer-driver/v2";
29951
30057
  var IDENTIFIER_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:/-]*$/;
29952
30058
  var MAX_ASSIGNMENT_ID_LENGTH = 256;
29953
30059
  var MAX_OPERATION_LENGTH = 128;
@@ -31624,9 +31730,12 @@ function getToolDefinition(toolId) {
31624
31730
  CREDENTIAL_GRANT_KIND,
31625
31731
  ChatSyncEngine,
31626
31732
  DEFAULT_DESTINATION_POLICIES,
31733
+ DEVICE_BINDING_SIGNATURE_DOMAIN,
31734
+ DEVICE_CONNECTION_GRANT_SIGNATURE_DOMAIN,
31627
31735
  DEVICE_ORCHESTRATION_PROTOCOL,
31628
31736
  DEVICE_PAIRING_INVITE_PROTOCOL,
31629
31737
  DEVICE_PAIRING_INVITE_TTL_MS,
31738
+ DEVICE_RELAY_ADMISSION_SIGNATURE_DOMAIN,
31630
31739
  DRIVER_MANIFEST_API_VERSION,
31631
31740
  DRIVER_MANIFEST_KIND,
31632
31741
  DRIVER_REQUEST_API_VERSION,
@@ -31743,6 +31852,9 @@ function getToolDefinition(toolId) {
31743
31852
  base64UrlEncode,
31744
31853
  bindWorkerSession,
31745
31854
  buildAgent,
31855
+ buildDeviceBindingMessage,
31856
+ buildDeviceConnectionGrantMessage,
31857
+ buildDeviceRelayReservationTokenMessage,
31746
31858
  buildLegacyChatMessageParts,
31747
31859
  buildMemeloopFileUri,
31748
31860
  buildMemeloopUri,