openrtc 0.2.1 → 1.0.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 (36) hide show
  1. package/README.md +49 -0
  2. package/dist/{DelegatingRuntimeAdapter-BxOcVIx_.d.ts → DelegatingRuntimeAdapter-By7pziBs.d.ts} +15 -15
  3. package/dist/IEngineBridge-C7OT2CRv.d.ts +10 -0
  4. package/dist/{IpcRuntimeAdapter-U5AEH0jn.d.ts → IpcRuntimeAdapter-DymXAsNU.d.ts} +2 -2
  5. package/dist/auth/index.js +1 -1
  6. package/dist/auth/internal.js +1 -1
  7. package/dist/chunk-A2ENDDFR.js +2 -0
  8. package/dist/chunk-CK6WQV7J.js +1 -0
  9. package/dist/{chunk-7DN33VUQ.js → chunk-EGEA3GU2.js} +1 -1
  10. package/dist/chunk-KZ3KWQTO.js +1 -0
  11. package/dist/chunk-MA2JFAV7.js +2 -0
  12. package/dist/chunk-OCNLQID3.js +1 -0
  13. package/dist/chunk-VIPNH2BE.js +3 -0
  14. package/dist/device-status-nkXepu97.d.ts +560 -0
  15. package/dist/{framing-lxzHEuSr.d.ts → framing-BUtu0oZK.d.ts} +19 -559
  16. package/dist/index.d.ts +11 -7
  17. package/dist/index.js +2 -2
  18. package/dist/openrtc_bg.wasm +0 -0
  19. package/dist/runtime/WasmRuntimeAdapter.d.ts +3 -2
  20. package/dist/runtime/WasmRuntimeAdapter.js +1 -1
  21. package/dist/runtime/device-status.d.ts +3 -0
  22. package/dist/runtime/device-status.js +1 -0
  23. package/dist/runtime/index.d.ts +86 -83
  24. package/dist/runtime/index.js +1 -1
  25. package/dist/runtime/tauri.d.ts +4 -3
  26. package/dist/runtime/tauri.js +1 -1
  27. package/dist/transport/index.d.ts +1 -1
  28. package/dist/{types-D0fRvUbN.d.ts → types-CzIpGV9x.d.ts} +87 -5
  29. package/package.json +11 -8
  30. package/dist/chunk-FQETZQPW.js +0 -2
  31. package/dist/chunk-IUHUYHNZ.js +0 -1
  32. package/dist/chunk-UBEE42VU.js +0 -2
  33. package/dist/chunk-UPO23UMZ.js +0 -3
  34. package/dist/chunk-WNJE3MJF.js +0 -1
  35. package/env/index.d.ts +0 -64
  36. package/env/index.mjs +0 -230
@@ -1,338 +1,10 @@
1
- import { A as AuthContext, R as RuntimeCapabilities, a as RuntimeCapabilityProfile } from './DelegatingRuntimeAdapter-BxOcVIx_.js';
2
- import { a2 as ConnectionOptions, q as ApplicationPayloadCrypto, v as ApplicationPayloadReadinessOptions, w as ApplicationPayloadRouteOptions, n as ProtocolName, x as ApplicationPayloadSendOptions, a0 as ChannelDescriptor$1, L as LocalDeviceInfo, T as IncomingStreamChannelMetadata, C as ClientOptions, a as Device, f as SignalingSession, R as RuntimeIdentity, b as DeviceStatusSnapshot, a3 as ManagedDeviceConnectOptions, Z as PeerState, $ as PeerHealth, O as JoinRoomOptions, Q as RoomMember, _ as PeerScope, j as BackendConnectionState, y as DevicePresenceStatus, a4 as PeerLifecycleStatus, P as PeerSessionSnapshot, G as GrantScope, I as ISignalingBackend, l as ConnectDeviceHooks, m as ConnectDeviceOptions, k as ConnectDeviceResult, M as ManagedConnectionRecord, c as ResolvedPeerIdentity, t as AppLimits, i as NativeConnectResult, E as ExplicitFileDataSendParams } from './types-D0fRvUbN.js';
3
- import { P as PlutoIpcBridge, I as IpcRuntimeAdapter } from './IpcRuntimeAdapter-U5AEH0jn.js';
1
+ import { A as AuthContext } from './IEngineBridge-C7OT2CRv.js';
2
+ import { G as GrantScope, I as ISignalingBackend, m as ConnectDeviceHooks, n as ConnectDeviceOptions, l as ConnectDeviceResult, M as ManagedConnectionRecord, P as PeerSessionSnapshot, c as ResolvedPeerIdentity, u as AppLimits, i as NativeConnectParams, j as NativeConnectResult, E as ExplicitFileDataSendParams } from './types-CzIpGV9x.js';
3
+ import { h as RuntimePeerState, s as RuntimeConnectionStateSnapshot, j as RuntimePeerReadinessSnapshot, i as RuntimePeerConnectOptions, C as Connection, n as RuntimeIncomingStream, R as RuntimeClientOptions, H as RuntimeAuthIdentity, f as RuntimeLocalDeviceInfo, g as RuntimeLocalDeviceProfile, c as RuntimeDevice, a as RuntimeManagedSessionOptions, b as RuntimeManagedSession, d as RuntimeDeviceStatusSnapshot, e as RuntimeDeviceConnectOptions, X as RuntimeSession, q as RuntimeJoinRoomOptions, r as RuntimeRoomMember, K as RuntimeConnectionTarget, o as RuntimeScopedChannelOptions, p as RuntimeScopedLogicalChannel, m as RuntimePeerStreamOptions, v as RuntimeRawConnection, l as RuntimeChannelDescriptor, V as RuntimePresenceLoopOptions, k as RuntimePeerHealth, t as RuntimeApplicationPayloadReadinessOptions, u as RuntimeConnectionEvent } from './device-status-nkXepu97.js';
4
+ import { R as RuntimeCapabilities, a as RuntimeCapabilityProfile } from './DelegatingRuntimeAdapter-By7pziBs.js';
5
+ import { P as PlutoIpcBridge, I as IpcRuntimeAdapter } from './IpcRuntimeAdapter-DymXAsNU.js';
4
6
  import { WasmRuntimeAdapter } from './runtime/WasmRuntimeAdapter.js';
5
7
 
6
- interface ITransport {
7
- readonly name: string;
8
- readonly isReady: boolean;
9
- init(localNodeId: string, remoteNodeId: string, options: any): Promise<void>;
10
- send(data: Uint8Array): Promise<void>;
11
- close(): void;
12
- onMessage(callback: (data: Uint8Array) => void): void;
13
- onStateChange(callback: (state: 'connecting' | 'connected' | 'failed' | 'disconnected') => void): void;
14
- handleSignalingMessage?(msg: any): void;
15
- getSignalingHandler?(): (msg: any) => Promise<void>;
16
- getNativeTransport?(): any;
17
- getNegotiationId?(): string | null;
18
- getDataChannelReadyState?(): string | null;
19
- }
20
-
21
- type ConnectionHealth = 'unknown' | 'healthy' | 'suspect' | 'stale';
22
-
23
- type UpgradeState = 'none' | 'upgrading' | 'upgraded' | 'failed';
24
- declare class Connection {
25
- private static readonly textDecoder;
26
- private static readonly textEncoder;
27
- private static readonly UPGRADE_RETRY_DELAY_MS;
28
- private static readonly MAX_UPGRADE_RETRIES;
29
- private static readonly MAX_UPGRADE_REDRIVES;
30
- private static readonly UPGRADE_REDRIVE_DELAY_MS;
31
- private static readonly WEBRTC_DISCONNECTED_GRACE_MS;
32
- private static readonly MAX_PENDING_MESSAGES;
33
- private static readonly DEFAULT_APPLICATION_CRYPTO_WAIT_MS;
34
- /**
35
- * Must exceed `WEBRTC_ICE_CONNECT_TIMEOUT_MS` in `WebRTCTransport`: the transport
36
- * waits that long for ICE + DataChannel before `failed`. A shorter watchdog here
37
- * tears the PC down early, burns `MAX_UPGRADE_RETRIES`, and stretches upgrades to ~60s+ under load.
38
- */
39
- private static readonly WEBRTC_UPGRADE_ATTEMPT_TIMEOUT_MS;
40
- private static readonly MAX_PENDING_ENCRYPTED_APPLICATION_PAYLOADS;
41
- private listeners;
42
- private pendingMessages;
43
- private pendingEncryptedApplicationPayloads;
44
- private webrtcBinaryHandlers;
45
- private closeListeners;
46
- private upgradeStateListeners;
47
- private writer;
48
- private reader;
49
- private _isClosed;
50
- get isClosed(): boolean;
51
- private receiveBuffer;
52
- readonly id: string;
53
- readonly remoteNodeId: string;
54
- /** @deprecated Compatibility alias for legacy consumers. This is the remote node id, not a device id. */
55
- readonly deviceId: string;
56
- readonly localNodeId: string;
57
- private options;
58
- private writeMutex;
59
- private applicationCryptoWaiters;
60
- private nativeSignalSender;
61
- private webrtcTransport;
62
- private webRtcApplicationRouteReadyTransport;
63
- private webRtcApplicationRouteReadyNegotiationId;
64
- private upgradeState;
65
- private upgradeRequested;
66
- private negotiationSwitchCount;
67
- private upgradeAttemptActive;
68
- private upgradeRetryCount;
69
- private upgradeReDriveCount;
70
- private upgradeReDriveTimer;
71
- private upgradeRetryTimer;
72
- private upgradeAttemptTimeoutTimer;
73
- private lastReportedTransportStatus;
74
- private applicationRouteMissingNotified;
75
- private upgradeTerminalFailure;
76
- private pendingSignals;
77
- private activeNegotiationId;
78
- private webrtcHeartbeat;
79
- private webRtcHeartbeatProbeInFlight;
80
- private webRtcApplicationRouteProbeInFlight;
81
- private webRtcHeartbeatConsecutiveProbeFailures;
82
- private irohHealthListeners;
83
- private webrtcHealthListeners;
84
- private lastWebRtcHeartbeatOkAt;
85
- private lastWebRtcDataChannelOpenAt;
86
- private static readonly WEBRTC_RENEGOTIATE_LIVENESS_WINDOW_MS;
87
- private static readonly MAX_NEGOTIATION_SWITCHES;
88
- private lastForegroundAt;
89
- private webRtcDisconnectedGraceTimer;
90
- private preferredWebRtcRole;
91
- constructor(id: string, localNodeId: string, remoteNodeId: string, writer: WritableStreamDefaultWriter<Uint8Array>, reader: ReadableStreamDefaultReader<Uint8Array>, options?: ConnectionOptions);
92
- setApplicationCrypto(applicationCrypto: ApplicationPayloadCrypto | undefined): void;
93
- requireApplicationCrypto(): void;
94
- isApplicationCryptoRequired(): boolean;
95
- isReadyForApplicationPayload(options?: ApplicationPayloadReadinessOptions): boolean;
96
- getApplicationPayloadTransports(options?: ApplicationPayloadRouteOptions): ProtocolName[];
97
- private isTransportAvailableForApplicationPayload;
98
- private resolveApplicationCryptoWaiters;
99
- private rejectApplicationCryptoWaiters;
100
- private waitForRequiredApplicationCrypto;
101
- /**
102
- * Starts WebRTC upgrade only when peer capability negotiation allows it.
103
- * No-op when WebRTC is not configured or an upgrade already started.
104
- */
105
- requestWebRTCUpgrade(reason?: string): void;
106
- /**
107
- * Whether the current WebRTC route is provably alive: an open data channel
108
- * plus either a recent heartbeat round trip or a freshly opened channel. An
109
- * `open` readyState alone is not proof — it lingers for many seconds after the
110
- * remote vanishes (e.g. a page reload), so a dead-but-`open` channel reports
111
- * not-live and can be replaced rather than trusted.
112
- */
113
- private isWebRtcRouteHeartbeatLive;
114
- requestTransportRecovery(reason: string, options?: {
115
- forceRenegotiate?: boolean;
116
- replaceExisting?: boolean;
117
- }): void;
118
- private static readonly FOREGROUND_PROBE_TIMEOUT_MS;
119
- handleAppForeground(): void;
120
- private beginWebRtcRecovery;
121
- getUpgradeState(): UpgradeState;
122
- updateRTCConfig(rtcConfig: ConnectionOptions['rtcConfig']): void;
123
- onUpgradeStateChange(callback: (state: UpgradeState) => void): void;
124
- /**
125
- * Best-effort transport diagnostics for developer tooling.
126
- *
127
- * - `usesRelay=true` means the selected WebRTC candidate pair includes a relay candidate.
128
- * - `usesRelay=false` means we found a selected pair and it is direct.
129
- * - `usesRelay=null` means there is not enough data yet.
130
- */
131
- getTransportDiagnostics(): Promise<{
132
- activeTransport: ProtocolName;
133
- parallelTransport: ProtocolName | null;
134
- usesRelay: boolean | null;
135
- relaySource: string | null;
136
- webrtc: {
137
- iceConnectionState: string | null;
138
- iceGatheringState: string | null;
139
- localCandidateType: string | null;
140
- remoteCandidateType: string | null;
141
- localProtocol: string | null;
142
- remoteProtocol: string | null;
143
- candidateTypeSummary: string | null;
144
- } | null;
145
- }>;
146
- private lastWebRtcLocalCandidateType;
147
- private lastWebRtcRemoteCandidateType;
148
- get transportType(): ProtocolName;
149
- private _peerMoQReady;
150
- get peerMoQReady(): boolean;
151
- set peerMoQReady(value: boolean);
152
- private _remoteSupportsWebRTC;
153
- get remoteSupportsWebRTC(): boolean;
154
- set remoteSupportsWebRTC(value: boolean);
155
- private mediaListeners;
156
- /**
157
- * Send a message to the other peer.
158
- * Messages can be strings or objects (JSON stringified).
159
- */
160
- send(message: string | object | ArrayBuffer | Uint8Array, options?: ApplicationPayloadSendOptions): Promise<void>;
161
- /**
162
- * Send media data (video/audio header + payload)
163
- * Internal use for now.
164
- */
165
- sendMedia(type: 'audio' | 'video', data: Uint8Array): Promise<void>;
166
- /**
167
- * Send a data message on a specific transport without fallback.
168
- * Throws when the requested transport is unavailable.
169
- */
170
- sendOnTransport(transport: ProtocolName, message: string | object | ArrayBuffer | Uint8Array): Promise<void>;
171
- /**
172
- * Send plaintext control traffic that is required to bootstrap application
173
- * key agreement. This is intentionally separate from public app-data sends.
174
- */
175
- sendControl(message: string | object | ArrayBuffer | Uint8Array): Promise<void>;
176
- /**
177
- * Write an already-framed payload directly on the underlying iroh control stream.
178
- * Used by native-main signaling paths that must preserve protocol framing.
179
- */
180
- sendRawIrohFrame(frame: Uint8Array): Promise<void>;
181
- /**
182
- * Compatibility/diagnostic view of currently usable transports.
183
- *
184
- * Lifecycle projection and route selection must use getTransportStatus().
185
- * This legacy list intentionally remains for older callers and tests that
186
- * need a human-readable inventory, but it is not an authority for active
187
- * versus fallback transport state.
188
- */
189
- getAvailableTransports(): ProtocolName[];
190
- onWebRTCBinaryMessage(handler: (data: Uint8Array) => boolean): void;
191
- private dispatchWebRtcBinaryHandlers;
192
- getWebRTCTransport(): ITransport | null;
193
- sendOnWebRTC(data: Uint8Array): Promise<void>;
194
- private encodePayload;
195
- private protectApplicationPayload;
196
- private openApplicationPayload;
197
- private openUntypedApplicationPayload;
198
- private queueEncryptedApplicationPayload;
199
- private flushPendingEncryptedApplicationPayloads;
200
- private buildFrame;
201
- private sendOverIroh;
202
- private sendUsingTransport;
203
- private sendTypedOnTransport;
204
- private sendTyped;
205
- private getSendTransportPriorities;
206
- /**
207
- * Disconnect the connection
208
- */
209
- disconnect(): Promise<void>;
210
- /**
211
- * Listen for incoming messages
212
- */
213
- onMessage(callback: (message: any) => void): void;
214
- /**
215
- * Listen for incoming media
216
- */
217
- onMedia(callback: (type: 'audio' | 'video', data: Uint8Array) => void): void;
218
- /**
219
- * Listen for disconnection
220
- */
221
- onDisconnect(callback: () => void): void;
222
- private close;
223
- private preserveWebRtcConnectionAfterBaseTransportLoss;
224
- private readLoop;
225
- injectData(chunk: Uint8Array): void;
226
- private handleData;
227
- private tryHandlePlaintextNativeSignal;
228
- private static isUntypedDataFrame;
229
- private processDataPayload;
230
- private isLikelyTextPayload;
231
- private emitMedia;
232
- private emitMessage;
233
- receiveMessage(msg: any): void;
234
- receiveDataPayload(messageData: Uint8Array): void;
235
- private trackListeners;
236
- private warnedSrtpApplicationCryptoBoundary;
237
- private warnSrtpApplicationCryptoBoundary;
238
- addTrack(track: MediaStreamTrack): RTCRtpSender | null;
239
- addTransceiver(trackOrKind: MediaStreamTrack | string, init?: RTCRtpTransceiverInit): RTCRtpTransceiver | null;
240
- onTrack(callback: (event: RTCTrackEvent) => void): void;
241
- private hasRecoverableBasePath;
242
- private isWebRtcDataChannelOpen;
243
- private clearWebRtcDisconnectedGraceTimer;
244
- private transportStillLikelyAlive;
245
- private handleUnhealthyWebRtcTransportStateWithGrace;
246
- private attemptUpgrade;
247
- private setUpgradeState;
248
- private handleUpgradeFailure;
249
- private scheduleUpgradeReDrive;
250
- private clearUpgradeReDriveTimer;
251
- private shouldRetryUpgrade;
252
- private scheduleUpgradeRetry;
253
- private clearUpgradeRetryTimer;
254
- private startUpgradeAttemptTimeout;
255
- private clearUpgradeAttemptTimeoutTimer;
256
- private teardownWebRTCTransport;
257
- private startWebRtcHeartbeat;
258
- private stopWebRtcHeartbeat;
259
- private notifyWebRtcApplicationRouteMissing;
260
- private startWebRtcApplicationRouteProbe;
261
- private sendIrohHeartbeatPong;
262
- /** Register a listener for WebRTC heartbeat health changes. */
263
- onWebRtcHeartbeatHealth(cb: (health: ConnectionHealth) => void): void;
264
- /** Register a listener for iroh heartbeat health changes (WASM path). */
265
- onIrohHeartbeatHealth(cb: (health: ConnectionHealth) => void): void;
266
- reportTransportStatusIfChanged(): void;
267
- /**
268
- * Single connection-owned transport snapshot for status reporting,
269
- * lifecycle projection, and diagnostics. The active route is application
270
- * ready; the parallel route is its usable fallback or candidate.
271
- */
272
- getTransportStatus(): {
273
- activeTransport: ProtocolName;
274
- parallelTransport: ProtocolName | null;
275
- };
276
- private resolveParallelTransport;
277
- setNativeSignalSender(sender: (envelope: any) => Promise<void>): void;
278
- /**
279
- * Structured connection-lifecycle log. One event per meaningful transition
280
- * (upgrade requested/started/failed, route promoted, app route ready, …) with
281
- * the connection's current lifecycle snapshot, so the whole connection flow
282
- * can be reconstructed from logs. Emits both a human line and a JSON line.
283
- */
284
- private traceLifecycle;
285
- getControlFrameMode(): NonNullable<ConnectionOptions['controlFrameMode']>;
286
- /**
287
- * Send a control envelope over the native-main signal route. Returns false
288
- * (without sending) unless this connection is in `native-main` control-frame
289
- * mode and has a native signal sender, so a typed connection never
290
- * accidentally routes control through the native sender.
291
- */
292
- sendNativeControlEnvelope(envelope: any): Promise<boolean>;
293
- /**
294
- * Promote a connection to the native-main control plane: switch its
295
- * control-frame mode to `native-main` and attach the native signal sender.
296
- * Used when native-main evidence arrives for a connection that bootstrapped
297
- * on a typed stream, so subsequent control traffic flows over the durable
298
- * native-main route even if the bootstrap stream later closes.
299
- */
300
- promoteToNativeMainControlRoute(sender: (envelope: any) => Promise<void>): void;
301
- private hasRequiredApplicationCrypto;
302
- private clearWebRtcApplicationRouteReady;
303
- private isCurrentWebRtcTransportApplicationRouteReady;
304
- private isWebRtcApplicationRouteReadyForTransport;
305
- /**
306
- * Mark the upgraded WebRTC data plane as carrying a proven application route
307
- * (data channel open + required crypto present). Idempotent. Promotes the
308
- * active transport projection to `webrtc` via reportTransportStatusIfChanged.
309
- */
310
- private markWebRtcApplicationRouteReady;
311
- /**
312
- * True only when the WebRTC transport is upgraded AND its application route
313
- * is proven (crypto present). The active route must not advertise `webrtc`
314
- * until this holds, so a half-open data channel never looks routable.
315
- */
316
- isWebRtcApplicationRouteReady(): boolean;
317
- /**
318
- * MoQ has a different data-plane shape than WebRTC: it is a shared relay
319
- * session on the Client plus a peer capability/subscription bit on this
320
- * Connection. Even so, it follows the same lifecycle invariant as every
321
- * custom transport: do not advertise it as the active application route until
322
- * the local transport is ready, the peer route is enabled, and the required
323
- * application crypto is available. Future MoQ route probes should tighten
324
- * this predicate, not bypass it.
325
- */
326
- isMoQApplicationRouteReady(): boolean;
327
- private isMoQDataRouteReady;
328
- private sendInternalSignal;
329
- receiveInternalSignal(content: any): void;
330
- private handleInternalSignal;
331
- private createNegotiationId;
332
- private getDeterministicWebRtcRole;
333
- private normalizeNegotiationId;
334
- }
335
-
336
8
  /**
337
9
  * Coalesced peer reconciliation scheduler and full reconcile orchestration.
338
10
  *
@@ -349,187 +21,6 @@ type PeerReconciliationStats = {
349
21
  orphanTsConnectionHealed: number;
350
22
  };
351
23
 
352
- /**
353
- * App-facing options intentionally hide transport node identifiers from callbacks.
354
- */
355
- type RuntimeClientOptions = Omit<ClientOptions, 'onDevices' | 'onAutoConnect' | 'onIncomingSession'> & {
356
- onDevices?: (devices: RuntimeDevice[]) => void;
357
- onAutoConnect?: (devices: RuntimeDevice[]) => void;
358
- onIncomingSession?: (session: RuntimeSession) => Promise<void>;
359
- };
360
- /**
361
- * App-facing device model. Runtime transport identifiers stay internal.
362
- */
363
- type RuntimeDevice = Omit<Device, 'nodeId'>;
364
- /**
365
- * App-facing session model. Node identifiers are runtime-internal metadata.
366
- */
367
- type RuntimeSession = Omit<SignalingSession, 'initiatorNodeId' | 'targetNodeId' | 'appTag'>;
368
- type RuntimeAuthIdentity = RuntimeIdentity;
369
- type RuntimeAuthContext = AuthContext;
370
- /**
371
- * App-facing peer state model. Runtime transport identifiers stay internal.
372
- */
373
- type RuntimePeerState = Omit<PeerState, 'nodeId'>;
374
- type RuntimePeerHealth = PeerHealth;
375
- type RuntimePeerLifecycleStatus = PeerLifecycleStatus;
376
- type RuntimePeerScope = PeerScope;
377
- /**
378
- * App-facing peer session snapshot model. Runtime transport identifiers stay internal.
379
- */
380
- type RuntimePeerSessionSnapshot = Omit<PeerSessionSnapshot, 'nodeId'>;
381
- type RuntimeLocalDeviceInfo = LocalDeviceInfo;
382
- type RuntimeRoomMember = RoomMember;
383
- type RuntimeDeviceConnectOptions = ManagedDeviceConnectOptions;
384
- type RuntimeJoinRoomOptions = JoinRoomOptions;
385
- type RuntimeChannelDescriptor = ChannelDescriptor$1;
386
- interface RuntimeConnectionTarget {
387
- ticket: string;
388
- timeoutMs?: number;
389
- }
390
- interface RuntimePeerConnectOptions {
391
- deviceId?: string;
392
- ticket?: string;
393
- scope?: RuntimePeerScope;
394
- channelId?: string;
395
- /**
396
- * When true, automatic/observer dials fail fast if the peer has a sticky
397
- * manual-disconnect projection for this app session. User-initiated manual
398
- * reconnects should leave this unset and clear the exclusion explicitly.
399
- */
400
- respectManualDisconnect?: boolean;
401
- }
402
- interface RuntimePeerStreamOptions {
403
- ticket?: string;
404
- scope?: RuntimePeerScope;
405
- channelId?: string;
406
- timeoutMs?: number;
407
- }
408
- type RuntimeLogicalChannelFraming = 'raw' | 'u32be';
409
- interface RuntimeScopedChannelOptions {
410
- peerId?: string;
411
- peerNodeId?: string;
412
- deviceId?: string | null;
413
- ticket?: string;
414
- scope: RuntimePeerScope;
415
- channelId: string;
416
- timeoutMs?: number;
417
- respectManualDisconnect?: boolean;
418
- /**
419
- * Native product protocols such as Plutonium drive-view expect a plaintext
420
- * stream label before payload frames. OpenRTC owns that handshake here so
421
- * apps do not need to choose raw transport APIs.
422
- */
423
- nativeLabel?: boolean;
424
- framing?: RuntimeLogicalChannelFraming;
425
- }
426
- interface RuntimeScopedLogicalChannel {
427
- channelId: string;
428
- peerId: string;
429
- connection: Connection;
430
- send(payload: Uint8Array): Promise<void>;
431
- onMessage(callback: (payload: Uint8Array) => void): () => void;
432
- close(): Promise<void>;
433
- diagnostics(): {
434
- connectionId: string | null;
435
- remoteNodeId: string | null;
436
- transports: string[];
437
- framing: RuntimeLogicalChannelFraming;
438
- nativeLabel: boolean;
439
- };
440
- }
441
- /**
442
- * App-facing device status snapshot model. Runtime transport identifiers stay internal.
443
- */
444
- type RuntimeDeviceStatusSnapshot = Omit<DeviceStatusSnapshot, 'nodeId'>;
445
- type RuntimeDeviceStatus = RuntimeDeviceStatusSnapshot;
446
- type RuntimeDevicePresenceStatus$1 = DevicePresenceStatus;
447
- type RuntimeIncomingStream = {
448
- type: 'bi' | 'uni';
449
- stream: any;
450
- remoteNodeId: string;
451
- protocolHint?: 'control' | 'explicit' | 'native-main' | 'unknown';
452
- channel?: IncomingStreamChannelMetadata | null;
453
- };
454
- type RuntimeConnectionEvent = {
455
- type: 'connected' | 'disconnected';
456
- connectionId: string;
457
- localNodeId: string;
458
- remoteNodeId: string;
459
- transport: ProtocolName;
460
- };
461
- type RuntimeRawConnection = {
462
- connectionId: string;
463
- localNodeId: string;
464
- remoteNodeId: string;
465
- };
466
- type RuntimePresenceLoopOptions = {
467
- deviceName?: string;
468
- ticket?: string;
469
- metadata?: string;
470
- };
471
- type RuntimeManagedSessionPlatform = 'native' | 'web';
472
- type RuntimeManagedSessionKind = 'app-user-device' | 'share-anonymous' | 'drive-grant-guest' | 'scoped-guest' | (string & {});
473
- type RuntimeAutoConnectPolicy = 'enabled' | 'disabled' | 'scoped-only';
474
- type RuntimePresencePolicy = 'online' | 'disabled';
475
- type RuntimeConnectionStateSnapshot = BackendConnectionState;
476
- type RuntimeApplicationPayloadReadinessOptions = ApplicationPayloadReadinessOptions;
477
- type RuntimeUiConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'failed';
478
- interface RuntimePeerReadinessSnapshot {
479
- requestedId: string;
480
- connected: boolean;
481
- settledReady: boolean;
482
- status: RuntimeUiConnectionStatus;
483
- health: RuntimePeerHealth | 'unknown';
484
- deviceId?: string | null;
485
- deviceIdHint?: string | null;
486
- activeConnectionId?: string | null;
487
- readinessState?: string;
488
- readinessReason?: string;
489
- scopes: string[];
490
- }
491
- interface RuntimeLocalDeviceProfile {
492
- deviceId: string | null;
493
- deviceName: string;
494
- platformType: string;
495
- userId: string | null;
496
- capabilities: NonNullable<RuntimeLocalDeviceInfo['capabilities']>;
497
- lastSeenAt: string;
498
- localNodeId?: string | null;
499
- }
500
- interface RuntimeManagedSessionOptions {
501
- platform: RuntimeManagedSessionPlatform;
502
- sessionKind?: RuntimeManagedSessionKind;
503
- scope?: string | null;
504
- autoConnectPolicy?: RuntimeAutoConnectPolicy;
505
- presencePolicy?: RuntimePresencePolicy;
506
- userId?: string | null;
507
- deviceName?: string;
508
- localDeviceId?: string | null;
509
- metadata?: string;
510
- autoConnect?: boolean;
511
- presence?: boolean;
512
- }
513
- interface RuntimeManagedSession {
514
- mode: RuntimeManagedSessionPlatform;
515
- device: RuntimeLocalDeviceProfile;
516
- stop: () => Promise<void>;
517
- }
518
- type ConnectionTarget = RuntimeConnectionTarget;
519
- type PeerConnectOptions = RuntimePeerConnectOptions;
520
- type PeerStreamOptions = RuntimePeerStreamOptions;
521
- type ScopedChannelOptions = RuntimeScopedChannelOptions;
522
- type ScopedLogicalChannel = RuntimeScopedLogicalChannel;
523
- type IncomingStream = RuntimeIncomingStream;
524
- type ConnectionEvent = RuntimeConnectionEvent;
525
- type RawConnection = RuntimeRawConnection;
526
- type PresenceLoopOptions = RuntimePresenceLoopOptions;
527
- type PeerReadiness = RuntimePeerReadinessSnapshot;
528
- type DeviceProfile = RuntimeLocalDeviceProfile;
529
- type SessionOptions$1 = RuntimeManagedSessionOptions;
530
- type Session$1 = RuntimeManagedSession;
531
- type ChannelDescriptor = RuntimeChannelDescriptor;
532
-
533
24
  interface SessionOptions {
534
25
  /**
535
26
  * Logical purpose of this session. Used as a peer-scope tag on all
@@ -778,8 +269,7 @@ interface RuntimePolicySnapshot {
778
269
  };
779
270
  nativeIpc: {
780
271
  authRequiredWaitMs: number;
781
- managedSessionIpcTimeoutMs: number;
782
- managedSessionIpcMaxAttempts: number;
272
+ defaultBoundedCommandTimeoutMs: number;
783
273
  connectionEventSubscribeWindowMs: number;
784
274
  connectionEventRetryMinDelayMs: number;
785
275
  connectionEventRetryMaxDelayMs: number;
@@ -834,7 +324,6 @@ declare class RuntimeClient {
834
324
  private readonly managedReconciliationTasks;
835
325
  private managedReconciliationTimer;
836
326
  private readonly managedReconciliationFollowupTimers;
837
- private nativeIncomingMessageSubscriptionAttached;
838
327
  /**
839
328
  * The one per-`{scope, peerNodeId}` observer-side dial coalescer. It is
840
329
  * intentionally separate from the peer lifecycle read model: it requests a
@@ -855,6 +344,7 @@ declare class RuntimeClient {
855
344
  private fetchAndApplyAppLimits;
856
345
  private resolvePeerStreamTarget;
857
346
  private compatPeerConnectionFromTarget;
347
+ private isTransportOnlyStreamChannel;
858
348
  private nextNativeStartRetryDelayMs;
859
349
  private hasManagedSession;
860
350
  private usesNativeIpcBackend;
@@ -863,10 +353,10 @@ declare class RuntimeClient {
863
353
  private stopManagedReconciliation;
864
354
  private notifyManagedReconciliation;
865
355
  reconcileNativeManagedSession(reason?: string): Promise<void>;
356
+ notifyNetworkChange(reason?: string): Promise<void>;
866
357
  private connectionStateSnapshotKey;
867
358
  private runNativeStartLoop;
868
359
  private isUnsupportedRuntimeAdapterError;
869
- private isRecoverableNativeManagedSessionStartError;
870
360
  onIdentityChange(callback: (identity: RuntimeAuthIdentity | null) => void): () => void;
871
361
  signInAnonymously(): Promise<void>;
872
362
  signInWithPluto(): Promise<void>;
@@ -883,9 +373,6 @@ declare class RuntimeClient {
883
373
  getRuntimePolicy(): RuntimePolicySnapshot;
884
374
  getRuntimeCapabilities(): RuntimeCapabilities;
885
375
  getCapabilityProfile(): RuntimeCapabilityProfile;
886
- private attachNativeIncomingMessageSubscription;
887
- private attachNativeIncomingStreamSource;
888
- private resolveNativeIncomingStreamSource;
889
376
  start(options?: {
890
377
  clearSessionTokens?: boolean;
891
378
  }): Promise<void>;
@@ -1066,10 +553,8 @@ declare class RuntimeClient {
1066
553
  connection: Connection;
1067
554
  writable: WritableStream<Uint8Array>;
1068
555
  }>;
1069
- connectToDevice(params: {
1070
- deviceId?: string | null;
1071
- endpointTicket: string;
1072
- }): Promise<NativeConnectResult>;
556
+ private waitForBrowserApplicationCrypto;
557
+ connectToDevice(params: NativeConnectParams): Promise<NativeConnectResult>;
1073
558
  connectRaw(target: RuntimeConnectionTarget): Promise<RuntimeRawConnection>;
1074
559
  openBi(nodeId: string): Promise<{
1075
560
  readable: ReadableStream<Uint8Array>;
@@ -1081,9 +566,13 @@ declare class RuntimeClient {
1081
566
  unregisterChannel(channelId: string): void;
1082
567
  listChannels(): RuntimeChannelDescriptor[];
1083
568
  onIncomingChannelStream(channelId: string, callback: (stream: RuntimeIncomingStream) => boolean | void): () => void;
569
+ /** @deprecated Use named channels or the optional `openrtc-file-transfer` package. */
1084
570
  sendExplicitFilePath(connectionId: string, filePath: string, transferId?: string): Promise<string>;
571
+ /** @deprecated Use named channels or the optional `openrtc-file-transfer` package. */
1085
572
  sendExplicitFileData(params: ExplicitFileDataSendParams): Promise<void>;
573
+ /** @deprecated Transfer history belongs to the consumer application. */
1086
574
  getTransferHistory(limit?: number): Promise<Array<[string, unknown]>>;
575
+ /** @deprecated Transfer history belongs to the consumer application. */
1087
576
  deleteTransferJob(jobId: string): Promise<void>;
1088
577
  startPresenceLoop(options?: RuntimePresenceLoopOptions): Promise<void>;
1089
578
  updatePresence(options?: {
@@ -1092,6 +581,10 @@ declare class RuntimeClient {
1092
581
  metadata?: string;
1093
582
  ticket?: string;
1094
583
  }): Promise<void>;
584
+ refreshLivePresence(options?: {
585
+ metadata?: string;
586
+ ticket?: string;
587
+ }): Promise<void>;
1095
588
  setOffline(): Promise<void>;
1096
589
  cleanupStaleDevices(): Promise<void>;
1097
590
  startAutoConnect(localDeviceId?: string): Promise<void>;
@@ -1230,39 +723,6 @@ declare function createWasmClient(options: RuntimeFactoryOptions): PlutoRuntimeA
1230
723
  */
1231
724
  declare function createIpcClient(options: RuntimeFactoryOptions, bridge: PlutoIpcBridge): PlutoRuntimeAssembly<IpcRuntimeAdapter>;
1232
725
 
1233
- interface RuntimeDeviceActiveOptions {
1234
- now?: number;
1235
- /**
1236
- * Optional local freshness window for durable roster rows. Leave undefined
1237
- * when the caller only wants to honor explicit online/expiresAt state.
1238
- */
1239
- staleAfterMs?: number;
1240
- }
1241
- type RuntimeDeviceActivityStatus = Pick<Partial<RuntimeDevice>, 'online' | 'lastSeenAt' | 'updatedAt' | 'createdAt' | 'expiresAt'>;
1242
- type RuntimeDeviceRouteStatus = Pick<Partial<RuntimeDeviceStatusSnapshot>, 'settledReady' | 'readinessState' | 'connectionStatus'>;
1243
- type RuntimeDevicePresenceStatus = Pick<RuntimeDevice, 'online' | 'ticket'> & Pick<Partial<RuntimeDeviceStatusSnapshot>, 'connectable' | 'presenceStatus' | 'online' | 'ticket'>;
1244
- /**
1245
- * True when a runtime device row is currently live enough to display or
1246
- * consider for app-level routing. This is deliberately separate from
1247
- * `isRuntimeDeviceConnectable`: a peer can be active/present before it has a
1248
- * usable ticket, and a stale durable row should not keep app UIs alive.
1249
- */
1250
- declare function isRuntimeDeviceActive(device: RuntimeDeviceActivityStatus, options?: RuntimeDeviceActiveOptions): boolean;
1251
- /**
1252
- * True once OpenRTC has a routable peer projection for normal app payloads.
1253
- *
1254
- * This intentionally does not inspect discovery metadata or device
1255
- * capabilities. Those fields describe the remote endpoint roster entry; they
1256
- * are not proof that an application-level protocol has exchanged its own
1257
- * ready/capability message over the mesh.
1258
- */
1259
- declare function isRuntimeDeviceRoutable(device: RuntimeDeviceRouteStatus): boolean;
1260
- /**
1261
- * True when the discovery row currently has enough fresh presence to attempt
1262
- * a dial. This is a discovery gate, not a connected/readiness gate.
1263
- */
1264
- declare function isRuntimeDeviceConnectable(device: RuntimeDevicePresenceStatus): boolean;
1265
-
1266
726
  /**
1267
727
  * Pure byte / stream / timing helpers.
1268
728
  *
@@ -1291,4 +751,4 @@ declare function createRuntimeJsonFrameDecoder<T = unknown>(onValue: RuntimeJson
1291
751
  declare function concatRuntimeBytes(a: ByteArrayLike, b: ByteArrayLike): ByteArray;
1292
752
  declare function readRuntimeU32BE(bytes: ByteArrayLike, offset: number): number;
1293
753
 
1294
- export { type RuntimePresenceLoopOptions as $, type ConnectionEvent as A, type ConnectionTarget as B, Connection as C, type DeviceProfile as D, type IncomingStream as E, type PeerConnectOptions as F, type PeerReadiness as G, type PeerStreamOptions as H, type ITransport as I, type PresenceLoopOptions as J, type RawConnection as K, type RuntimeAuthContext as L, type RuntimeAuthIdentity as M, type RuntimeAutoConnectPolicy as N, OPENRTC_RUNTIME_POLICY as O, type PeerReconciliationStats as P, type RuntimeConnectionTarget as Q, type RuntimeClientOptions as R, type RuntimeDevicePresenceStatus$1 as S, type RuntimeDeviceStatus as T, type RuntimeJsonFrameHandler as U, type RuntimeLogicalChannelFraming as V, type RuntimeManagedSessionKind as W, type RuntimeManagedSessionPlatform as X, type RuntimePeerLifecycleStatus as Y, type RuntimePeerScope as Z, type RuntimePeerSessionSnapshot as _, RuntimeClient as a, type RuntimePresencePolicy as a0, type RuntimeSession as a1, type RuntimeU32BEFrameHandler as a2, type RuntimeUiConnectionStatus as a3, type ScopedChannelOptions as a4, type ScopedLogicalChannel as a5, ScopedSession as a6, type Session as a7, type SessionOptions as a8, createRuntimeJsonFrameDecoder as a9, createIpcClient as aA, createWasmClient as aB, readRuntimeU32BE as aC, driveGrantConnectionKey as aD, driveGrantConnectionKeyToString as aE, createRuntimeU32BEFrameDecoder as aa, decodeRuntimeJsonPayload as ab, encodeRuntimeJsonFrame as ac, encodeRuntimeJsonPayload as ad, encodeRuntimeU32BEFrame as ae, getRuntimePolicy as af, isRuntimeDeviceActive as ag, isRuntimeDeviceConnectable as ah, isRuntimeDeviceRoutable as ai, type RuntimeDeviceActiveOptions as aj, type RuntimeFactoryOptions as ak, type RuntimeJsonFrameDecoderOptions as al, DriveGrantActorError as am, type DriveGrantActorErrorKind as an, DriveGrantActorHandle as ao, type DriveGrantActorHandleOptions as ap, DriveGrantActorRegistry as aq, type DriveGrantActorState as ar, type DriveGrantClose as as, type DriveGrantDial as at, type DriveGrantConnectionKey as au, type DriveGrantLogicalChannelHandle as av, type DriveGrantPreferredTransport as aw, type Session$1 as ax, type SessionOptions$1 as ay, concatRuntimeBytes as az, type RuntimeManagedSessionOptions as b, type RuntimeManagedSession as c, type RuntimeDevice as d, type RuntimeDeviceStatusSnapshot as e, type RuntimeDeviceConnectOptions as f, type RuntimeLocalDeviceInfo as g, type RuntimeLocalDeviceProfile as h, type RuntimePeerState as i, type RuntimePeerConnectOptions as j, type RuntimePeerReadinessSnapshot as k, type RuntimePeerHealth as l, type RuntimeChannelDescriptor as m, type RuntimePeerStreamOptions as n, type RuntimeIncomingStream as o, type RuntimeScopedChannelOptions as p, type RuntimeScopedLogicalChannel as q, type RuntimeJoinRoomOptions as r, type RuntimeRoomMember as s, type RuntimePolicySnapshot as t, type RuntimeConnectionStateSnapshot as u, type RuntimeApplicationPayloadReadinessOptions as v, type RuntimeConnectionEvent as w, type PlutoRuntimeAssembly as x, type RuntimeRawConnection as y, type ChannelDescriptor as z };
754
+ export { createIpcClient as A, createWasmClient as B, readRuntimeU32BE as C, DriveGrantActorError as D, driveGrantConnectionKey as E, driveGrantConnectionKeyToString as F, OPENRTC_RUNTIME_POLICY as O, type PeerReconciliationStats as P, RuntimeClient as R, ScopedSession as S, type RuntimePolicySnapshot as a, type PlutoRuntimeAssembly as b, type RuntimeJsonFrameHandler as c, type RuntimeU32BEFrameHandler as d, type Session as e, type SessionOptions as f, createRuntimeJsonFrameDecoder as g, createRuntimeU32BEFrameDecoder as h, decodeRuntimeJsonPayload as i, encodeRuntimeJsonFrame as j, encodeRuntimeJsonPayload as k, encodeRuntimeU32BEFrame as l, getRuntimePolicy as m, type RuntimeFactoryOptions as n, type RuntimeJsonFrameDecoderOptions as o, type DriveGrantActorErrorKind as p, DriveGrantActorHandle as q, type DriveGrantActorHandleOptions as r, DriveGrantActorRegistry as s, type DriveGrantActorState as t, type DriveGrantClose as u, type DriveGrantDial as v, type DriveGrantConnectionKey as w, type DriveGrantLogicalChannelHandle as x, type DriveGrantPreferredTransport as y, concatRuntimeBytes as z };