import { a as PeerReconciliationStats } from '../assembly-BTzwQuwI.js'; export { D as ConnectionActor, d as ConnectionActorError, e as ConnectionActorErrorKind, f as ConnectionActorKey, g as ConnectionActorOptions, h as ConnectionActorState, i as ConnectionActors, j as ConnectionClose, k as ConnectionDial, l as LogicalChannel, P as PolicySnapshot, m as PreferredTransport, n as RUNTIME_POLICY, R as RuntimeClient, o as connectionActorKey, p as connectionActorKeyString, q as getRuntimePolicy } from '../assembly-BTzwQuwI.js'; import { Client as Client$1 } from '../coreClient.js'; import { b as Avenue } from '../types-C4TIUgOJ.js'; import * as Draft14 from '@moq/net'; import { a7 as SignalingOptions, I as ISignalingBackend, m as RuntimeIdentity, l as RoomMember, n as SignalingEnvelope, u as SignalingSession, D as Device, r as DesiredPeerProjection, w as BackendConnectionState, a6 as AppLimits, G as GrantScope, Y as JoinRoomOptions, W as ChannelMetadata, a2 as CryptoStreams, a8 as RoomCreationMode, h as ClientOptions, z as PayloadCrypto, k as DiscoveryMode, a1 as ProtocolCapabilityMap, a9 as ScanningLoopOptions, aa as ScanningLoopHandle, ab as RuntimeBootstrapOptions, ac as RuntimeBootstrapResult, F as ApplicationPayloadReadinessOptions, ad as ManagedApplicationRouteOptions, Q as PeerState, T as PeerScope, U as PeerHealth, V as ChannelDescriptor, ae as JoinRequest, N as NativeConnectParams, t as NativeConnectResult } from '../ITransport-yaruAmx3.js'; import { a as Connection, t as ConnectionTarget, m as RawConnection } from '../types-D67HlF0p.js'; export { v as AutoConnectPolicy, B as BrowserProtocolStore, C as ChannelDescriptor, w as ChannelFraming, i as ConnectionEvent, g as ConnectionState, x as ConnectionStatus, k as DeviceConnectOptions, y as DevicePresence, l as DeviceProfile, D as DeviceStatus, I as IncomingStream, q as IrohDocEntry, p as IrohMutationReceipt, J as JoinRoomOptions, L as LocalDeviceInfo, M as ManagedOptions, j as ManagedSession, N as NamespaceDescriptor, z as PayloadRouteOptions, P as PeerConnectOptions, E as PeerLifecycleStatus, b as PeerReadiness, F as PeerSessionSnapshot, d as PeerStreamOptions, u as PresenceLoopOptions, G as PresencePolicy, h as ReadinessOptions, H as RuntimeAuthContext, r as RuntimeAuthIdentity, o as RuntimeClientOptions, e as RuntimeDevice, c as RuntimePeerHealth, K as RuntimePeerScope, R as RuntimePeerState, n as RuntimeRoomMember, s as RuntimeSession, S as ScopedChannelOptions, f as ScopedLogicalChannel, O as SessionKind, Q as SessionPlatform } from '../types-D67HlF0p.js'; import { R as RuntimeCapabilities } from '../capabilities-BwzPe51I.js'; export { B as BROWSER_CAPABILITIES, a as CapabilityHost, C as CapabilityProfile, N as NATIVE_CAPABILITIES, b as NativeRuntimeStatus, c as RuntimeAdapterKind, T as TransportStatus, d as browserCapabilities, e as capabilityProfile, f as cloneCapabilities, s as statusCapabilities } from '../capabilities-BwzPe51I.js'; export { DeviceActiveOptions, isDeviceActive, isDeviceConnectable, isDeviceRoutable } from './device-status.js'; export { a as IpcAdapterOptions, I as IpcRuntimeAdapter } from '../IpcRuntimeAdapter-DDKeQ6UC.js'; export { P as NativeBridge, N as NativeIpcFailureKind, P as PlutoIpcBridge, a as PlutoIpcUnlisten, c as classifyIpcFailure, i as isIpcUnavailable } from '../ipc-CPnNwv6f.js'; import '../DelegatingRuntimeAdapter-BkLR3TNN.js'; declare class Signaling { private readonly appTag; private backend; constructor(options: SignalingOptions, backend: ISignalingBackend); get tag(): string; waitForAuth(): Promise; get currentUser(): RuntimeIdentity | null; usesCoordinationGateway(): boolean; joinCoordinationRoom(roomId: string, nodeId: string, ticket: string): Promise; leaveCoordinationRoom(roomId: string): Promise; getCoordinationRoomMembers(roomId: string): Promise; watchCoordinationRoomMembers(roomId: string, callback: (members: RoomMember[]) => void): () => void; onAuthChange(callback: (user: RuntimeIdentity | null) => void): () => void; signInAnonymously(): Promise; signInWithPluto(): Promise; signOut(): Promise; stopAuthActivity(): Promise; setCoordinationHostAvailability(input: { available: boolean; reason: string; }): void; capabilities(): RuntimeCapabilities | undefined; getTurnCredentials(): Promise; updatePresence(localNodeId: string, ticketStr: string, isOnline?: boolean, ttlMs?: number, metadata?: string): Promise; setOffline(localNodeId: string): Promise; cleanupStaleDevices(): Promise; sendMessage(targetId: string, payload: string, state?: string, replyPayload?: string): Promise; pollMessages(targetId: string): Promise; subscribeSessions(localDeviceId: string, callback: (session: SignalingSession) => void | Promise): Promise<() => void>; getLocalDeviceId(): Promise; searchDevices(excludeNodeId?: string): Promise; updateDevice(deviceId: string, updates: { deviceName?: string; capabilities?: Device['capabilities']; metadata?: string; }): Promise; deleteDevice(deviceId: string): Promise; onDevicesChange(callback: (devices: Device[]) => void, excludeNodeId?: string): () => void; startAutoConnect(userId: string, localDeviceId: string): void; submitDesiredPeerProjection(revision: number, peers: DesiredPeerProjection[]): Promise; notifyDisconnectRequested(remoteNodeId: string): void; startPresenceLoop(userId: string, localNodeId: string, deviceName: string, ticket: string, metadata?: string): void; forceReconnect(): void; isConnected(nodeId: string): Promise; getConnectionStates(): Promise; onStateChange(callback: (state: BackendConnectionState) => void): (() => void) | Promise<() => void>; supportsRustPeerLifecycleProjection(): boolean; setWasmClient(client: any): void; } type CapabilityRuntime = Client$1; /** * Low-level escape hatch used only by `openrtc/runtime`. Product code should * prefer the capability namespaces. Keeping this registry here prevents a * runtime pointer from leaking onto the provider-neutral root surface. */ declare function runtimeForCapability(handle: Avenue): CapabilityRuntime; interface MoQSubscriberOptions { maxPendingSubscriptions?: number; maxSubscribeRetries?: number; subscribeRetryDelayMs?: number; maxBufferedGroupsPerTrack?: number; maxBufferedFramesPerGroup?: number; maxBufferedBytesPerTrack?: number; maxObjectPayloadBytes?: number; onSubscriptionTerminated?: (namespace: string, name: string, error: unknown) => void; } /** Draft-14 subscriber facade; session reconnect remains owned by MoQController. */ declare class MoQSubscriber { private readonly session; private readonly onObject; private readonly subscriptions; private readonly maxSubscriptions; private readonly maxSubscribeRetries; private readonly subscribeRetryDelayMs; private readonly maxObjectPayloadBytes; private readonly onSubscriptionTerminated?; private closed; constructor(session: MoQSession, onObject: (trackNamespace: string, trackName: string, object: Uint8Array, metadata: unknown) => void, options?: MoQSubscriberOptions); subscribe(namespace: string, name: string): Promise; close(): void; private consume; } interface TransportInterface { createBidirectionalStream(): Promise<{ readable: ReadableStream; writable: WritableStream; }>; createUnidirectionalStream(): Promise>; incomingBidirectionalStreams: ReadableStream; incomingUnidirectionalStreams: ReadableStream>; close(): void; ready: Promise; } interface MoQSessionOptions { onSubscriptionTerminated?: (namespace: string, name: string, error: unknown) => void; } interface MoQDatagramDuplex { readonly maxDatagramSize?: number; readonly readable: ReadableStream; readonly writable: WritableStream; close(): void; } /** * Draft-14 MoQT adapter. The OpenRTC controller owns reconnect and lifecycle; * this class owns only one negotiated relay session and its protocol handles. */ declare class MoQSession { readonly transport: TransportInterface; private readonly relayUrl; readonly publisher: MoQPublisher; readonly subscriber: MoQSubscriber; setupComplete: boolean; private connection; private closeListeners; private closed; private closeEmitted; private setupResolve; private readonly setupPromise; constructor(transport: TransportInterface, onObject?: (ns: string, name: string, obj: Uint8Array, meta: unknown) => void, role?: number, relayUrl?: URL, options?: MoQSessionOptions); requireConnection(): Draft14.Connection.Established; /** * Open the patched Draft 14 object-datagram surface used only by the Iroh * packet carrier. Existing application-data publishing remains on subgroup * streams and never shares readiness with this duplex. */ openDatagramDuplex(publishNamespace: string, subscribeNamespace: string, trackName: string): Promise; init(): Promise; waitForSetup(): Promise; onClose(callback: (reason?: unknown) => void): () => void; close(): void; private emitClose; } interface MoQPublisherOptions { maxPendingAnnounces?: number; announceTimeoutMs?: number; maxSubscribedTracks?: number; maxActivePublishers?: number; maxTrackIdChars?: number; /** * Reject an application object before it reaches a relay track. This must * match the receiver-side default so browser and native clients apply the * same hard egress boundary. */ maxObjectPayloadBytes?: number; } interface TrackPublisher { close(): void; push(data: Uint8Array, init: { isKey: boolean; timestamp: number; closeAfterPush?: boolean; }): Promise; } /** Draft-14 publisher facade preserving OpenRTC's existing data-track API. */ declare class MoQPublisher { private readonly session; private readonly namespaces; private readonly activePublishers; private readonly maxNamespaces; private readonly maxSubscribedTracks; private readonly maxActivePublishers; private readonly maxTrackIdChars; private readonly maxObjectPayloadBytes; private closed; constructor(session: MoQSession, options?: MoQPublisherOptions); announce(namespace: string): Promise; hasNamespace(namespace: string): boolean; hasTrackSubscriber(namespace: string, name: string): boolean; createTrack(namespace: string, name: string): Promise; close(): void; private acceptTrackRequests; private totalSubscriberCount; private resolveTrackId; } /** * Browser MoQ session controller. * * Owns the WebTransport-backed MoQ relay session, reconnect state, peer * subscriptions, and direct MoQ data helpers. `Client` remains the facade so * existing SDK calls and test spies keep working while MoQ stops contributing * more lifecycle state to the god object. */ type MoQBundle = { session: MoQSession; publisher: MoQPublisher; subscriber: MoQSubscriber; }; interface RoomClientHost { wasmClient: any; roomCreationMode: 'client-open' | 'client-auth' | 'server-only'; appLimits: AppLimits; ensureAuthenticated(reason: 'room-op'): Promise; getTicketWithToken(grantScope: GrantScope, maxConnections?: number): Promise; getNodeId(): Promise; connect(ticket: string, timeoutMs?: number): Promise; refreshHostedAppSettings(force?: boolean): Promise; getRoomBackendTag(): string; } declare class RoomManager { private signaling; private client; constructor(client: RoomClientHost, signaling: Signaling); private usesCoordinationGateway; private requireCoordinationGateway; private get roomBackendTag(); private resolveRoomUserId; private resolveControlPlaneAppTag; private invokeRoomCallable; private isAlreadyExistsError; private normalizeRoomId; private getMembersInternal; /** * Creates a new room. When `requestedRoomId` is provided, the backend will * try to create that exact room ID instead of generating a random one. */ createRoom(requestedRoomId?: string): Promise; /** * Joins a room by ID. */ joinRoom(roomId: string, options?: JoinRoomOptions): Promise; leaveRoom(roomId: string): Promise; getRoomMembers(roomId: string): Promise; watchRoom(roomId: string, callback: (members: RoomMember[]) => void): () => void; /** Gateway room leases and socket cleanup are owned by the coordination provider. */ stopHeartbeat(_roomId?: string): void; } type ProtocolHint = 'control' | 'explicit' | 'native-main' | 'unknown'; type IncomingStreamEvent = { type: 'bi' | 'uni'; stream: any; remoteNodeId: string; transportStableId?: number; traceId?: string; protocolHint?: ProtocolHint; channel?: ChannelMetadata | null; applicationCrypto?: CryptoStreams; invalid?: boolean; }; declare class Client { signaling: Signaling; rooms: RoomManager; private _services?; private options; private readonly runtimeSafetyProfile; appLimits: AppLimits; private effectiveRoomBackendTag; roomCreationMode: RoomCreationMode; constructor(options: ClientOptions); private get services(); private createServiceGraph; get wasmClient(): any; set wasmClient(client: any); get node(): any; set node(node: any); attachIncomingStreamSource(source: unknown, localNodeId: string): void; getApplicationCrypto(connection?: Connection): PayloadCrypto | undefined; resolveApplicationCryptoForPeer(peerId?: string, connection?: Connection): PayloadCrypto | undefined; releaseApplicationKeyAgreementReply(connectionId: string, action: 'response' | 'ack', claimId: string): void; waitForApplicationCryptoForPeer(peerId?: string, timeoutMs?: number): Promise; destroy(): void; dispose(): void; get apiKey(): string | undefined; get discoveryMode(): DiscoveryMode; getRoomBackendTag(): string; refreshHostedAppSettings(force?: boolean): Promise; setSignalingBackend(backend: ISignalingBackend): void; get currentUser(): any; onAuthChange(callback: (user: any) => void): () => void; signInAnonymously(): Promise; signInWithPluto(): Promise; signOut(): Promise; getSignalingTelemetry(): { transport: string; wasmLoaded: boolean; peerReconciliation: Readonly; }; reconciliationStats(): Readonly; getProtocolCapabilities(): ProtocolCapabilityMap; getRuntimeStatus(): Promise<{ runtime: 'tauri' | 'browser' | 'unknown'; wasmLoaded: boolean; localNodeId?: string; userId?: string; }>; searchDevices(): Promise; updateDevice(deviceId: string, updates: { deviceName?: string; capabilities?: Device['capabilities']; metadata?: string; }): Promise; deleteDevice(deviceId: string): Promise; cleanupStaleDevices(): Promise; onDevicesChange(callback: (devices: Device[]) => void): () => void; subscribeSessions(localDeviceId: string, callback: (session: SignalingSession) => void | Promise): Promise<() => void>; startScanningLoop(options: ScanningLoopOptions): Promise; bootstrapRuntime(options: RuntimeBootstrapOptions): Promise; updateTransportConfig(transports: ClientOptions['transports']): void; init(): Promise; ensureAuthenticated(reason: 'init' | 'room-op' | 'discovery'): Promise; refreshRuntimeAuthToken(reason?: 'runtime-start' | 'managed-session'): Promise; get moqState(): string; get moq(): MoQBundle | null; onMoQReady(cb: () => void): () => void; onMoQFailed(cb: () => void): () => void; refreshTransportCapabilities(reason?: string): Promise; onMoQObject(callback: (ns: string, name: string, obj: Uint8Array, meta: any) => void): () => void; subscribeMoQPeer(connection: Connection): void; subscribeMoQPeerNode(peerId: string, subscriptionKey?: string): void; connect(ticket: string, timeoutMs?: number, expectedDeviceId?: string | null, channelId?: string, options?: { admissionAlreadyPresented?: boolean; approvedScope?: string | null; }): Promise; connectRaw(ticket: string, timeoutMs?: number): Promise<{ connectionId: string; localNodeId: string; remoteNodeId: string; }>; startAutoConnect(localDeviceId?: string): Promise; openBi(peerId: string): Promise<{ readable: ReadableStream; writable: WritableStream; }>; openUni(peerId: string): Promise>; getConnections(): Connection[]; readyConnections(options?: ApplicationPayloadReadinessOptions): Connection[]; getConnectionForPeer(connectionId?: string, remoteNodeId?: string): Connection | null; hasApplicationRouteForPeer(connectionId?: string, remoteNodeId?: string): boolean; ensureManagedApplicationRoute(options: ManagedApplicationRouteOptions): Promise; watchPeerStates(callback: (peers: PeerState[]) => void): () => void; getPeerState(id: string): PeerState | undefined; listConnectedPeers(): PeerState[]; isPeerPromotionEligible(identifiers: { connectionId?: string | null; deviceId?: string | null; deviceIdHint?: string | null; nodeId?: string | null; }): boolean; addPeerScope(id: string, scope?: PeerScope): PeerState | undefined; releasePeerScope(id: string, scope?: PeerScope): PeerState | undefined; getPeerScopes(id: string): PeerScope[]; isSamePeer(a: string, b: string): boolean; refreshPeerSnapshot(): Promise; connectPeer(options: { deviceId?: string; ticket?: string; scope?: PeerScope; channelId?: string; timeoutMs?: number; keepManualDisconnect?: boolean; }): Promise; clearManualDisconnectProjection(id: string): void; disconnectPeer(id: string, scope?: PeerScope): Promise; forceDisconnectPeer(id: string): Promise; getPeerHealth(id: string): Promise; getTicket(): Promise; getNodeId(): Promise; getNodeIdFromTicket(ticket: string): Promise; getTicketWithToken(grantScope: GrantScope, maxConnections?: number): Promise; buildCompoundTicketWithToken(irohTicket: string, grantScope: GrantScope, maxConnections?: number): string; setManagedPresenceTicket(ticket: string | null): void; clearManagedPresenceTicket(): void; registerSessionToken(token: string, grantScope: GrantScope, maxConnections: number, expiresAtMs?: number): void; revokeSessionToken(token: string): void; revokeTokensByScope(grantScope: GrantScope): Promise; clearSessionTokens(): Promise; startPresenceLoop(options?: { deviceName?: string; ticket?: string; metadata?: string; }): Promise; setOffline(): Promise; isConnected(nodeId: string): Promise; disconnectNode(nodeId: string): Promise; getLocalDeviceId(): Promise; acceptNativeMessage(connectionId: string | null, remoteNodeId: string | null, msg: any): Promise; startListening(options?: { startPresence?: boolean; }): Promise; stopListening(): void; forceReconnect(): void; wrapChannelWritable(writable: WritableStream, channelId: string, metadata?: Record | null): WritableStream; updatePresence(isOnline?: boolean, ttlMs?: number, metadata?: string, ticketOverride?: string): Promise; onConnection(callback: (conn: Connection) => void): () => void; onDisconnection(callback: (conn: Connection) => void): () => void; onMessage(callback: (conn: Connection, msg: any) => void): () => void; onIncomingStream(callback: (stream: IncomingStreamEvent) => boolean | void): () => void; registerChannel(descriptor: ChannelDescriptor): void; unregisterChannel(channelId: string): void; listChannels(): ChannelDescriptor[]; onChannelStream(channelId: string, callback: (stream: IncomingStreamEvent) => boolean | void): () => void; onRoomJoinRequest(callback: (request: JoinRequest) => void): () => void; isMoQDataReady(peerId: string | null): boolean; sendMoQData(peerId: string | null, data: Uint8Array, options?: { alreadyProtected?: boolean; }): Promise; } /** * Owns low-level transport commands for RuntimeClient. * * This intentionally stays narrow: managed sessions, device discovery, peer * readiness, and channel orchestration remain in their existing managers until * those boundaries can be tightened independently. */ declare class ConnectionController { private readonly client; private readonly backend; private readonly onLifecycleMutation; constructor(client: Client, backend: ISignalingBackend | null, onLifecycleMutation?: () => void); connectToDevice(params: NativeConnectParams): Promise; connectRaw(target: ConnectionTarget): Promise; openBi(nodeId: string): Promise<{ readable: ReadableStream; writable: WritableStream; }>; openUni(nodeId: string): Promise>; isConnected(nodeId: string): Promise; disconnectNode(nodeId: string): Promise; disconnectDevice(deviceId: string): Promise; excludeAutoConnect(deviceId: string, excluded: boolean): Promise; disconnectPeer(id: string, scope?: string): Promise; forceDisconnectPeer(id: string): Promise; private clearManualDisconnectProjection; } /** * Phase 7 TS-side correlation logger. Mirror of * `openrtc/crates/openrtc/src/client/correlation.rs`. Emits `console.log` lines in * the exact `key=value` shape the Phase 0 parser * (`tests/helpers/correlationLog.ts`) recognises. * * The TS half exists so observer-side state transitions (scoped-actor * coalescing, upgrade observation, channel opens, shutdown) emit the same * correlation chain the Rust core does — making cross-language log scans * grep-friendly. * * ## Usage * * ```ts * import { clog } from '@/openrtc/packages/openrtc/src/runtime/correlationLog'; * clog('[scoped-actor][dial]', * { sessionKind: 'scoped-guest', scope: 'scoped:abc', peerNodeId: 'node-A' }, * 'ready_first'); * ``` * * Empty/undefined fields are omitted so log lines stay short. */ interface CorrelationFields { sessionKind?: string; grantId?: string; scope?: string; peerNodeId?: string; connectionId?: string; transportEpoch?: string | number; channel?: string; tokenFp?: string; } /** * Renders `fields` to `key=value key=value` (snake_case keys to match * the Phase 0 parser's primary regex set). Empty fields are dropped. * Exposed for tests. */ declare function renderCorrelation(fields: CorrelationFields): string; /** @deprecated Use correlationForScope() */ declare function grantCorrelation(scope: string, extra?: CorrelationFields): CorrelationFields; /** * Phase 7 structured-log call. Emits a single `console.log` line of the * form ` ` — the exact shape the Phase 0 * `correlationLog.ts` parser already understands. * * Tag is typically a bracket-prefix like `[drive-grant-actor][dial]`. * Fields are rendered as `snake_case=value`. Pass an empty object for * the fields if a context isn't applicable yet. */ declare function clog(tag: string, fields: CorrelationFields, message?: string, ...extra: unknown[]): void; /** * Consistent logging for session teardown / revoke paths (user-device, share, etc.). * * Browser: set `localStorage.setItem('OPENRTC_TEARDOWN_TRACE', '1')`, reload, reproduce. * Stack lines are tagged `[OpenRTC][teardown-trace:stack]`. * Native / Tauri: run with `PLUTO_RTC_TEARDOWN_TRACE=1` to log matching Rust iroh disconnect lines to stderr. */ declare function logTeardownTrace(kind: string, details?: Record): void; declare function openRtcDebugEnabled(): boolean; declare function openRtcDebug(message: string, data?: unknown): void; declare function openRtcDebugInfo(message: string, data?: unknown): void; declare function openRtcDebugLog(message: string, data?: unknown): void; /** * Pure byte / stream / timing helpers. * * Extracted from the `Client` god object (see * `docs/plans/client-ts-decomposition.md` Phase 1). These functions are * deliberately pure — no `Client` state, no `this`, no logging side effects — so * the same helper is reused everywhere instead of being re-implemented inline * (e.g. `concatBytes` previously existed both here and in `applicationCrypto.ts`, * and three near-identical exponential-backoff helpers existed across the class). */ type ByteArray = Uint8Array; type ByteArrayLike = Uint8Array; type U32FrameHandler = (payload: ByteArray) => void; type JsonFrameHandler = (value: T, payload: ByteArray) => void; interface JsonDecoderOptions { onInvalidJson?: (error: unknown, payload: ByteArray) => void; } declare function encodeU32Frame(payload: ByteArrayLike): ByteArray; declare function createU32Decoder(onFrame: U32FrameHandler): (chunk: ByteArrayLike) => void; declare function encodeJsonPayload(value: unknown): ByteArray; declare function decodeJsonPayload(payload: ByteArrayLike): T; declare function encodeJsonFrame(value: unknown): ByteArray; declare function createJsonDecoder(onValue: JsonFrameHandler, options?: JsonDecoderOptions): (chunk: ByteArrayLike) => void; declare function concatRuntimeBytes(a: ByteArrayLike, b: ByteArrayLike): ByteArray; declare function readRuntimeU32BE(bytes: ByteArrayLike, offset: number): number; export { type CapabilityRuntime, ConnectionController, ConnectionTarget, type CorrelationFields, type JsonDecoderOptions, type JsonFrameHandler, RawConnection, RuntimeCapabilities, type U32FrameHandler, clog, concatRuntimeBytes, createJsonDecoder, createU32Decoder, decodeJsonPayload, encodeJsonFrame, encodeJsonPayload, encodeU32Frame, grantCorrelation, logTeardownTrace, openRtcDebug, openRtcDebugEnabled, openRtcDebugInfo, openRtcDebugLog, readRuntimeU32BE, renderCorrelation, runtimeForCapability as runtimeFromCapability };