@urun-sh/core 0.3.0 → 0.3.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.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { g as AppOptions, f as App$1, a9 as SessionPhase, af as SessionStatus, ab as SessionPhaseName, A as AccessTokenOptions, X as RuntimeArtifact, Y as RuntimeArtifactDownload, R as Recording, a3 as Session$1, C as ChannelEndpoint, as as TransportSession, h as AttachOptions, a4 as SessionDiagnostic, b as ActivationEvent, ae as SessionStatsSample, T as RecordingsAccessor, Z as RuntimeArtifactsAccessor, a7 as SessionEndResult, ag as SessionStream$1, an as StreamDataTransport, a6 as SessionDocumentImpl, am as StreamChunkOptions, m as ChunkReadable, P as Presence, v as DocConnector, w as DocTokenSupplier, V as RequestOptions, W as RequestStreamOptions, al as StoreOptions, ak as Store, k as ChannelMultiplexer, a8 as SessionFailureKind, B as MediaSession, ar as TransportOfferResponse, az as WtAudioLaneSeam, aA as WtAudioUplinkSeam, aH as WtVideoUplinkSeam, aG as WtDataUplinkSender, aE as WtDataLaneSink, av as TransportState } from './stream-data-ChGPDdoN.mjs';
2
- export { c as ActivationState, i as AudioPlayoutOptions, D as DERIVED_LEG_SEP, n as DGRAM_HEADER_BYTES, r as DerivedLegRole, s as DgramHeader, u as DocConnectionState, I as InboundStatsSample, M as MediaChunkBinding, x as MediaChunkSource, y as MediaChunkSourceFactory, z as MediaRecorderChunkSourceOptions, N as NegotiatorDataLaneSeam, E as NegotiatorOptions, F as PresenceState, G as PrewakeOptions, H as PrewakeResult, J as PrewakeStatus, Q as QuicStreamDataTransport, K as RecordingBucket, O as RecordingLifecycle, S as RecordingStatus, U as ReleaseSessionBeaconOptions, _ as RuntimeAvailability, $ as RuntimeWakeDetail, a0 as RuntimeWakeGolden, a1 as RuntimeWakeReasonCode, a2 as SIGNALING_PROTOCOL_VERSION, a5 as SessionDocument, aa as SessionPhaseError, ad as SessionStatsOptions, ah as SessionText, ai as SignalCarrier, aj as Signaling, ao as TransportEstablishedNotify, ap as TransportNegotiator, aq as TransportOfferRequest, au as TransportSessionSignaling, aw as VideoPlayoutOptions, ax as WT_CONTROL_FRAME_MAX, ay as WT_DATA_STREAM_VERSION, aB as WtControlDecoder, aC as WtControlMessage, aD as WtDataEnvelope, aF as WtDataStreamParser, aJ as consumeWtDataStreams, aN as derivedLegName, aO as derivedLegRole, aP as encodeWtControlFrame, aQ as isPendingRecording, aR as mediaRecorderChunkSource, aS as parseDgramHeader, aT as prewake, aU as releaseSessionBeacon, aX as writeDgramHeader } from './stream-data-ChGPDdoN.mjs';
1
+ import { g as AppOptions, f as App$1, ae as SessionPhase, ak as SessionStatus, ag as SessionPhaseName, A as AccessTokenOptions, $ as RuntimeArtifact, a0 as RuntimeArtifactDownload, T as Recording, aA as TransportState, a8 as Session$1, C as ChannelEndpoint, ax as TransportSession, h as AttachOptions, a9 as SessionDiagnostic, b as ActivationEvent, aj as SessionStatsSample, z as GenerationTick, X as RecordingsAccessor, a1 as RuntimeArtifactsAccessor, ac as SessionEndResult, al as SessionStream$1, as as StreamDataTransport, ab as SessionDocumentImpl, ar as StreamChunkOptions, m as ChunkReadable, P as Presence, v as DocConnector, x as DocTokenSupplier, w as DocServerUrlResolver, Z as RequestOptions, _ as RequestStreamOptions, aq as StoreOptions, ap as Store, k as ChannelMultiplexer, ad as SessionFailureKind, H as MediaSession, aw as TransportOfferResponse, aF as WtAudioLaneSeam, aG as WtAudioUplinkSeam, aN as WtVideoUplinkSeam, aM as WtDataUplinkSender, aK as WtDataLaneSink } from './stream-data-BJoG7tYI.mjs';
2
+ export { c as ActivationState, i as AudioPlayoutOptions, D as DERIVED_LEG_SEP, n as DGRAM_HEADER_BYTES, r as DerivedLegRole, s as DgramHeader, u as DocConnectionState, G as GENERATION_TICK_EMIT_INTERVAL_MS, y as GENERATION_TICK_MAX_EXTRAPOLATION_MS, I as InboundStatsSample, M as MediaChunkBinding, B as MediaChunkSource, E as MediaChunkSourceFactory, F as MediaRecorderChunkSourceOptions, N as NegotiatorDataLaneSeam, J as NegotiatorOptions, K as PresenceState, O as PrewakeOptions, Q as PrewakeResult, R as PrewakeStatus, S as QuicStreamDataTransport, U as RecordingBucket, V as RecordingLifecycle, W as RecordingStatus, Y as ReleaseSessionBeaconOptions, a2 as RuntimeAvailability, a3 as RuntimeWakeDetail, a4 as RuntimeWakeGolden, a5 as RuntimeWakeReasonCode, a6 as SIGNALING_PROTOCOL_VERSION, a7 as STREAM_END, aa as SessionDocument, af as SessionPhaseError, ai as SessionStatsOptions, am as SessionText, an as SignalCarrier, ao as Signaling, at as TransportEstablishedNotify, au as TransportNegotiator, av as TransportOfferRequest, az as TransportSessionSignaling, aB as VideoPlayoutOptions, aC as WT_CONTROL_FRAME_MAX, aD as WT_DATA_STREAM_VERSION, aE as WatchGenerationTickOptions, aH as WtControlDecoder, aI as WtControlMessage, aJ as WtDataEnvelope, aL as WtDataStreamParser, aP as consumeWtDataStreams, aS as decodeStreamEnvelope, aU as derivedLegName, aV as derivedLegRole, aW as encodeStreamEnvelope, aX as encodeWtControlFrame, aY as isPendingRecording, aZ as mediaRecorderChunkSource, a_ as parseDgramHeader, a$ as prewake, b0 as releaseSessionBeacon, b3 as watchGenerationTick, b4 as writeDgramHeader } from './stream-data-BJoG7tYI.mjs';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
5
5
 
@@ -195,6 +195,100 @@ declare class RecordingsClient {
195
195
 
196
196
  declare function createRecordingsClient(options: RecordingsClientOptions): RecordingsClient;
197
197
 
198
+ declare const USER_ACTIVITY_FIELD = "user_activity";
199
+
200
+ declare const FOCUS_FIELD = "focus";
201
+
202
+ declare const USER_ACTIVITY_MIN_INTERVAL_MS = 30000;
203
+
204
+ type PresenceConnectivityState = 'idle' | 'connecting' | 'ready' | 'transient_failure';
205
+ type PresenceVisibility = 'visible' | 'hidden';
206
+ type PresenceFocus = 'focused' | 'unfocused';
207
+
208
+ type PresenceInteractionKind = 'typing' | 'pointer' | 'tty';
209
+
210
+ interface UserActivityPayload {
211
+ at: number;
212
+ counts: {
213
+ typing: number;
214
+ pointer: number;
215
+ tty: number;
216
+ consumer_reads: number;
217
+ };
218
+ inflight: number;
219
+ visibility?: PresenceVisibility;
220
+ focus?: PresenceFocus;
221
+ }
222
+
223
+ interface PresenceAwarenessSink {
224
+ setLocalStateField(field: string, value: unknown): void;
225
+ }
226
+
227
+ interface PresenceTransportLike {
228
+ on(event: 'stateChange', handler: (state: TransportState) => void): () => void;
229
+ readonly state: TransportState;
230
+ }
231
+ interface PresenceTrackerOptions {
232
+
233
+ awareness?: PresenceAwarenessSink;
234
+
235
+ now?: () => number;
236
+
237
+ windowTarget?: Pick<Window, 'addEventListener' | 'removeEventListener'> | null;
238
+ documentTarget?: (Pick<Document, 'addEventListener' | 'removeEventListener'> & {
239
+ hasFocus?: () => boolean;
240
+ }) | null;
241
+ }
242
+ declare class PresenceTracker {
243
+ private readonly _awareness;
244
+ private readonly _now;
245
+ private readonly _win;
246
+ private _state;
247
+ private readonly _stateHandlers;
248
+ private readonly _transportUnsubs;
249
+ private _disposed;
250
+ private readonly _counts;
251
+ private _inflight;
252
+ private _visibility;
253
+ private _focus;
254
+ private _lastSignalAt;
255
+ private _lastPublishedAt;
256
+ private _trailing;
257
+ private _onWindowFocus;
258
+ private _onWindowBlur;
259
+ constructor(options?: PresenceTrackerOptions);
260
+
261
+ get state(): PresenceConnectivityState;
262
+
263
+ onState(handler: (state: PresenceConnectivityState) => void): () => void;
264
+
265
+ transportConnecting(): void;
266
+
267
+ transportReady(): void;
268
+
269
+ transportClosed(): void;
270
+
271
+ attachTransport(transport: PresenceTransportLike): () => void;
272
+ private _setState;
273
+
274
+ interaction(kind: PresenceInteractionKind, count?: number): void;
275
+
276
+ consumerRead(count?: number): void;
277
+
278
+ get inflight(): number;
279
+
280
+ workBegin(): () => void;
281
+
282
+ setVisibility(visibility: PresenceVisibility): void;
283
+
284
+ setFocus(focus: PresenceFocus): void;
285
+
286
+ private _signal;
287
+ private _publishNow;
288
+
289
+ dispose(): void;
290
+ }
291
+
198
292
  declare const DEFAULT_DOC_SYNC_TIMEOUT_MS = 30000;
199
293
  declare class SessionStream implements SessionStream$1 {
200
294
  private _name;
@@ -278,6 +372,8 @@ declare class Session implements Session$1 {
278
372
 
279
373
  private _activity;
280
374
 
375
+ private _presenceTracker;
376
+
281
377
  private _activation;
282
378
 
283
379
  private _activeRequests;
@@ -301,6 +397,9 @@ declare class Session implements Session$1 {
301
397
  private _dialNegotiation;
302
398
 
303
399
  private _dialNegotiationStarted;
400
+
401
+ private _generationTickHandlers;
402
+ private _generationTickStop;
304
403
  constructor(sessionId: string, multiplexer: ChannelEndpoint, transport: TransportSession, recordingsAuth?: RecordingsClientOptions, artifactsAuth?: RuntimeArtifactsClientOptions);
305
404
  private _wireControlDocIncarnation;
306
405
 
@@ -323,6 +422,8 @@ declare class Session implements Session$1 {
323
422
 
324
423
  whenLive(options?: WhenLiveOptions): Promise<void>;
325
424
 
425
+ on(event: 'generationTick', handler: (tick: GenerationTick) => void): () => void;
426
+
326
427
  get recordings(): RecordingsAccessor;
327
428
  get artifacts(): RuntimeArtifactsAccessor;
328
429
  setArtifactsAuth(auth: RuntimeArtifactsClientOptions): void;
@@ -338,12 +439,15 @@ declare class Session implements Session$1 {
338
439
 
339
440
  touch(): void;
340
441
 
442
+ get presenceTracker(): PresenceTracker | null;
443
+
341
444
  connectDocs(connector: DocConnector): void;
342
445
 
343
446
  setDocTransport(opts: {
344
447
  wsUrl: string;
345
448
  token?: string | DocTokenSupplier;
346
449
  webSocket?: typeof WebSocket;
450
+ resolveServerUrl?: DocServerUrlResolver;
347
451
  }): void;
348
452
 
349
453
  useStreamDataTransport(transport: StreamDataTransport): void;
@@ -572,12 +676,105 @@ declare class TransportSessionMismatchError extends Error {
572
676
  declare class SessionAllocationError extends Error {
573
677
 
574
678
  readonly httpStatus?: number;
679
+
680
+ readonly code?: string;
681
+
682
+ readonly balanceCredits?: number;
683
+
684
+ readonly platformStatus?: string;
575
685
  constructor(message: string, options?: {
576
686
  httpStatus?: number;
687
+ code?: string;
688
+ balanceCredits?: number;
689
+ platformStatus?: string;
577
690
  cause?: unknown;
578
691
  });
579
692
  }
580
693
 
694
+ interface CreditsClientOptions {
695
+
696
+ functionsUrl: string;
697
+
698
+ orgId: string;
699
+
700
+ apiKey?: string;
701
+
702
+ jwt?: string;
703
+
704
+ getAccessToken?: (options?: AccessTokenOptions) => string | null | undefined | Promise<string | null | undefined>;
705
+
706
+ authProvider?: string;
707
+ }
708
+
709
+ interface CreditBalance {
710
+ org_id: string;
711
+
712
+ balance_credits: number;
713
+
714
+ available_credits: number;
715
+ free_credits: number;
716
+ subscription_credits: number;
717
+ purchased_credits: number;
718
+ overage_credits: number;
719
+
720
+ activated: boolean;
721
+
722
+ exempt: boolean;
723
+ updated_at: string;
724
+ }
725
+
726
+ interface CreditLedgerEntry {
727
+ id: string;
728
+
729
+ delta_credits: number;
730
+
731
+ reason: string;
732
+ note?: string;
733
+
734
+ session_id?: string;
735
+ created_at: string;
736
+ }
737
+
738
+ interface CreditsLedgerOptions {
739
+
740
+ limit?: number;
741
+ }
742
+
743
+ declare class CreditsError extends Error {
744
+
745
+ readonly status: number;
746
+
747
+ readonly code: string;
748
+ constructor(message: string, options: {
749
+ status: number;
750
+ code: string;
751
+ cause?: unknown;
752
+ });
753
+ }
754
+
755
+ declare class CreditsUnauthorizedError extends CreditsError {
756
+ constructor(message?: string, code?: string);
757
+ }
758
+
759
+ declare class CreditsClient {
760
+ private readonly _options;
761
+ private readonly _base;
762
+ constructor(_options: CreditsClientOptions);
763
+
764
+ getBalance(): Promise<CreditBalance>;
765
+
766
+ getLedger(options?: CreditsLedgerOptions): Promise<CreditLedgerEntry[]>;
767
+
768
+ private _request;
769
+ private _buildUrl;
770
+ private _fetch;
771
+ private _resolveToken;
772
+ private _readJson;
773
+ private _readError;
774
+ }
775
+
776
+ declare function createCreditsClient(options: CreditsClientOptions): CreditsClient;
777
+
581
778
  type CaptureKind = 'audio' | 'video';
582
779
  type GetUserMedia = (constraints: MediaStreamConstraints) => Promise<MediaStream>;
583
780
 
@@ -957,4 +1154,4 @@ declare class FrameReassembler {
957
1154
  private requestKeyframe;
958
1155
  }
959
1156
 
960
- export { ACTIVATION_COLD_BOOT_AFTER_MS, ACTIVATION_DEGRADED_AFTER_MS, ACTIVATION_HINT_PATH, ACTIVATION_STILL_AFTER_MS, ACTIVITY_DOM_EVENTS, ACTIVITY_FIELD, ACTIVITY_STAMP_MIN_INTERVAL_MS, ActivationEvent, ActivationMonitor, type ActivationMonitorOptions, type ActivationStreamLike, type ActivityAwareness, type ActivityTracker, type ActivityTrackerOptions, App, App$1 as AppInterface, AppOptions, AttachOptions, BACKOFF_BASE_MS, BACKOFF_MAX_ATTEMPTS, BACKOFF_MAX_MS, type CameraWarp, type CameraWarpOptions, type CameraWarpTransform, type CaptureClaim, CaptureController, type CaptureControllerOptions, type CaptureKind, CaptureUnavailableError, ChunkReadable, type ClientToken, ClientTokenError, type ConsumingTransport, type CreateClientTokenOptions, DATA_CHANNEL_MESSAGE_CEILING, DEFAULT_DOC_SYNC_TIMEOUT_MS, DEFAULT_GATEWAY_URL, DEFAULT_PRODUCE_ACK_TIMEOUT_MS, DEFAULT_REFERENCE_JPEG_QUALITY, DEFAULT_REFERENCE_MAX_SIZE, DEFAULT_WHEN_LIVE_TIMEOUT_MS, DocTokenSupplier, FOREGROUND_COALESCE_MS, FrameReassembler, INPUT_PRESENCE_DEFAULT_HZ, INPUT_PRESENCE_FIELD, type InputPresenceAwareness, type InputPresencePublisher, type InputPresencePublisherOptions, type InputPresenceState, InvalidDurationError, LEGACY_ACTIVATION_HINT_PATH, MediaSession, type NormalizeReferenceImageOptions, PLATFORM_DOC_NAME, PermanentLockedError, type PhaseObservable, PinRequiresActiveTempError, Presence, ProduceAckTimeoutError, type ReassembledFrame, type ReassemblerCallbacks, type ReassemblerOptions, Recording, RecordingNotFoundError, RecordingsAccessor, RecordingsClient, type RecordingsClientOptions, RecordingsError, RecordingsUnauthorizedError, type ReferenceImage, type ReferenceImageSource, type ReferenceImageType, RequestAbortError, RequestCancelledError, RequestDocSyncError, RequestError, RequestOptions, RequestStreamOptions, RequestTimeoutError, RetainNotTempError, type RetentionIntent, RuntimeArtifact, RuntimeArtifactDownload, RuntimeArtifactNotFoundError, RuntimeArtifactsAccessor, RuntimeArtifactsClient, type RuntimeArtifactsClientOptions, RuntimeArtifactsError, RuntimeArtifactsUnauthorizedError, Session, SessionAllocationError, SessionDiagnostic, SessionEndError, SessionEndResult, SessionEndUnavailableError, SessionFailedError, SessionFailureKind, Session$1 as SessionInterface, SessionPhase, SessionPhaseName, SessionStatsSample, SessionStatus, SessionStream$1 as SessionStream, Store, StoreOptions, StreamChunkOptions, StreamDirectionConflict, TransportOfferResponse, TransportSessionMismatchError, TransportState, URUN_DEV_ENV, VISIBILITY_FIELD, type VideoStreamOptions, WIRE_MESSAGE_BUDGET, WebRtcSession, WebTransportSession, type WhenLiveOptions, WtDataLaneSink, activationHintFrom, cameraCaptureAvailable, captureStillFromVideo, computeBackoffDelay, createActivityTracker, createCameraWarp, createClientToken, createInputPresencePublisher, createRecordingsClient, createRuntimeArtifactsClient, createStore, describeSessionFailure, describeSessionPhase, fitWithin, isDurationString, isRetryableSessionError, isServerTerminalPhase, isWakingPhase, normalizeReferenceImage, normalizeRetention, observeLeaveConfirm, observePageLifecycle, observePageTeardown, referenceImageErrorMessage, sessionFailureFromMediaError, sharedCaptureController, videoStream, whenLive };
1157
+ export { ACTIVATION_COLD_BOOT_AFTER_MS, ACTIVATION_DEGRADED_AFTER_MS, ACTIVATION_HINT_PATH, ACTIVATION_STILL_AFTER_MS, ACTIVITY_DOM_EVENTS, ACTIVITY_FIELD, ACTIVITY_STAMP_MIN_INTERVAL_MS, ActivationEvent, ActivationMonitor, type ActivationMonitorOptions, type ActivationStreamLike, type ActivityAwareness, type ActivityTracker, type ActivityTrackerOptions, App, App$1 as AppInterface, AppOptions, AttachOptions, BACKOFF_BASE_MS, BACKOFF_MAX_ATTEMPTS, BACKOFF_MAX_MS, type CameraWarp, type CameraWarpOptions, type CameraWarpTransform, type CaptureClaim, CaptureController, type CaptureControllerOptions, type CaptureKind, CaptureUnavailableError, ChunkReadable, type ClientToken, ClientTokenError, type ConsumingTransport, type CreateClientTokenOptions, type CreditBalance, type CreditLedgerEntry, CreditsClient, type CreditsClientOptions, CreditsError, type CreditsLedgerOptions, CreditsUnauthorizedError, DATA_CHANNEL_MESSAGE_CEILING, DEFAULT_DOC_SYNC_TIMEOUT_MS, DEFAULT_GATEWAY_URL, DEFAULT_PRODUCE_ACK_TIMEOUT_MS, DEFAULT_REFERENCE_JPEG_QUALITY, DEFAULT_REFERENCE_MAX_SIZE, DEFAULT_WHEN_LIVE_TIMEOUT_MS, DocTokenSupplier, FOCUS_FIELD, FOREGROUND_COALESCE_MS, FrameReassembler, GenerationTick, INPUT_PRESENCE_DEFAULT_HZ, INPUT_PRESENCE_FIELD, type InputPresenceAwareness, type InputPresencePublisher, type InputPresencePublisherOptions, type InputPresenceState, InvalidDurationError, LEGACY_ACTIVATION_HINT_PATH, MediaSession, type NormalizeReferenceImageOptions, PLATFORM_DOC_NAME, PermanentLockedError, type PhaseObservable, PinRequiresActiveTempError, Presence, type PresenceAwarenessSink, type PresenceConnectivityState, type PresenceFocus, type PresenceInteractionKind, PresenceTracker, type PresenceTrackerOptions, type PresenceTransportLike, type PresenceVisibility, ProduceAckTimeoutError, type ReassembledFrame, type ReassemblerCallbacks, type ReassemblerOptions, Recording, RecordingNotFoundError, RecordingsAccessor, RecordingsClient, type RecordingsClientOptions, RecordingsError, RecordingsUnauthorizedError, type ReferenceImage, type ReferenceImageSource, type ReferenceImageType, RequestAbortError, RequestCancelledError, RequestDocSyncError, RequestError, RequestOptions, RequestStreamOptions, RequestTimeoutError, RetainNotTempError, type RetentionIntent, RuntimeArtifact, RuntimeArtifactDownload, RuntimeArtifactNotFoundError, RuntimeArtifactsAccessor, RuntimeArtifactsClient, type RuntimeArtifactsClientOptions, RuntimeArtifactsError, RuntimeArtifactsUnauthorizedError, Session, SessionAllocationError, SessionDiagnostic, SessionEndError, SessionEndResult, SessionEndUnavailableError, SessionFailedError, SessionFailureKind, Session$1 as SessionInterface, SessionPhase, SessionPhaseName, SessionStatsSample, SessionStatus, SessionStream$1 as SessionStream, Store, StoreOptions, StreamChunkOptions, StreamDirectionConflict, TransportOfferResponse, TransportSessionMismatchError, TransportState, URUN_DEV_ENV, USER_ACTIVITY_FIELD, USER_ACTIVITY_MIN_INTERVAL_MS, type UserActivityPayload, VISIBILITY_FIELD, type VideoStreamOptions, WIRE_MESSAGE_BUDGET, WebRtcSession, WebTransportSession, type WhenLiveOptions, WtDataLaneSink, activationHintFrom, cameraCaptureAvailable, captureStillFromVideo, computeBackoffDelay, createActivityTracker, createCameraWarp, createClientToken, createCreditsClient, createInputPresencePublisher, createRecordingsClient, createRuntimeArtifactsClient, createStore, describeSessionFailure, describeSessionPhase, fitWithin, isDurationString, isRetryableSessionError, isServerTerminalPhase, isWakingPhase, normalizeReferenceImage, normalizeRetention, observeLeaveConfirm, observePageLifecycle, observePageTeardown, referenceImageErrorMessage, sessionFailureFromMediaError, sharedCaptureController, videoStream, whenLive };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { g as AppOptions, f as App$1, a9 as SessionPhase, af as SessionStatus, ab as SessionPhaseName, A as AccessTokenOptions, X as RuntimeArtifact, Y as RuntimeArtifactDownload, R as Recording, a3 as Session$1, C as ChannelEndpoint, as as TransportSession, h as AttachOptions, a4 as SessionDiagnostic, b as ActivationEvent, ae as SessionStatsSample, T as RecordingsAccessor, Z as RuntimeArtifactsAccessor, a7 as SessionEndResult, ag as SessionStream$1, an as StreamDataTransport, a6 as SessionDocumentImpl, am as StreamChunkOptions, m as ChunkReadable, P as Presence, v as DocConnector, w as DocTokenSupplier, V as RequestOptions, W as RequestStreamOptions, al as StoreOptions, ak as Store, k as ChannelMultiplexer, a8 as SessionFailureKind, B as MediaSession, ar as TransportOfferResponse, az as WtAudioLaneSeam, aA as WtAudioUplinkSeam, aH as WtVideoUplinkSeam, aG as WtDataUplinkSender, aE as WtDataLaneSink, av as TransportState } from './stream-data-ChGPDdoN.js';
2
- export { c as ActivationState, i as AudioPlayoutOptions, D as DERIVED_LEG_SEP, n as DGRAM_HEADER_BYTES, r as DerivedLegRole, s as DgramHeader, u as DocConnectionState, I as InboundStatsSample, M as MediaChunkBinding, x as MediaChunkSource, y as MediaChunkSourceFactory, z as MediaRecorderChunkSourceOptions, N as NegotiatorDataLaneSeam, E as NegotiatorOptions, F as PresenceState, G as PrewakeOptions, H as PrewakeResult, J as PrewakeStatus, Q as QuicStreamDataTransport, K as RecordingBucket, O as RecordingLifecycle, S as RecordingStatus, U as ReleaseSessionBeaconOptions, _ as RuntimeAvailability, $ as RuntimeWakeDetail, a0 as RuntimeWakeGolden, a1 as RuntimeWakeReasonCode, a2 as SIGNALING_PROTOCOL_VERSION, a5 as SessionDocument, aa as SessionPhaseError, ad as SessionStatsOptions, ah as SessionText, ai as SignalCarrier, aj as Signaling, ao as TransportEstablishedNotify, ap as TransportNegotiator, aq as TransportOfferRequest, au as TransportSessionSignaling, aw as VideoPlayoutOptions, ax as WT_CONTROL_FRAME_MAX, ay as WT_DATA_STREAM_VERSION, aB as WtControlDecoder, aC as WtControlMessage, aD as WtDataEnvelope, aF as WtDataStreamParser, aJ as consumeWtDataStreams, aN as derivedLegName, aO as derivedLegRole, aP as encodeWtControlFrame, aQ as isPendingRecording, aR as mediaRecorderChunkSource, aS as parseDgramHeader, aT as prewake, aU as releaseSessionBeacon, aX as writeDgramHeader } from './stream-data-ChGPDdoN.js';
1
+ import { g as AppOptions, f as App$1, ae as SessionPhase, ak as SessionStatus, ag as SessionPhaseName, A as AccessTokenOptions, $ as RuntimeArtifact, a0 as RuntimeArtifactDownload, T as Recording, aA as TransportState, a8 as Session$1, C as ChannelEndpoint, ax as TransportSession, h as AttachOptions, a9 as SessionDiagnostic, b as ActivationEvent, aj as SessionStatsSample, z as GenerationTick, X as RecordingsAccessor, a1 as RuntimeArtifactsAccessor, ac as SessionEndResult, al as SessionStream$1, as as StreamDataTransport, ab as SessionDocumentImpl, ar as StreamChunkOptions, m as ChunkReadable, P as Presence, v as DocConnector, x as DocTokenSupplier, w as DocServerUrlResolver, Z as RequestOptions, _ as RequestStreamOptions, aq as StoreOptions, ap as Store, k as ChannelMultiplexer, ad as SessionFailureKind, H as MediaSession, aw as TransportOfferResponse, aF as WtAudioLaneSeam, aG as WtAudioUplinkSeam, aN as WtVideoUplinkSeam, aM as WtDataUplinkSender, aK as WtDataLaneSink } from './stream-data-BJoG7tYI.js';
2
+ export { c as ActivationState, i as AudioPlayoutOptions, D as DERIVED_LEG_SEP, n as DGRAM_HEADER_BYTES, r as DerivedLegRole, s as DgramHeader, u as DocConnectionState, G as GENERATION_TICK_EMIT_INTERVAL_MS, y as GENERATION_TICK_MAX_EXTRAPOLATION_MS, I as InboundStatsSample, M as MediaChunkBinding, B as MediaChunkSource, E as MediaChunkSourceFactory, F as MediaRecorderChunkSourceOptions, N as NegotiatorDataLaneSeam, J as NegotiatorOptions, K as PresenceState, O as PrewakeOptions, Q as PrewakeResult, R as PrewakeStatus, S as QuicStreamDataTransport, U as RecordingBucket, V as RecordingLifecycle, W as RecordingStatus, Y as ReleaseSessionBeaconOptions, a2 as RuntimeAvailability, a3 as RuntimeWakeDetail, a4 as RuntimeWakeGolden, a5 as RuntimeWakeReasonCode, a6 as SIGNALING_PROTOCOL_VERSION, a7 as STREAM_END, aa as SessionDocument, af as SessionPhaseError, ai as SessionStatsOptions, am as SessionText, an as SignalCarrier, ao as Signaling, at as TransportEstablishedNotify, au as TransportNegotiator, av as TransportOfferRequest, az as TransportSessionSignaling, aB as VideoPlayoutOptions, aC as WT_CONTROL_FRAME_MAX, aD as WT_DATA_STREAM_VERSION, aE as WatchGenerationTickOptions, aH as WtControlDecoder, aI as WtControlMessage, aJ as WtDataEnvelope, aL as WtDataStreamParser, aP as consumeWtDataStreams, aS as decodeStreamEnvelope, aU as derivedLegName, aV as derivedLegRole, aW as encodeStreamEnvelope, aX as encodeWtControlFrame, aY as isPendingRecording, aZ as mediaRecorderChunkSource, a_ as parseDgramHeader, a$ as prewake, b0 as releaseSessionBeacon, b3 as watchGenerationTick, b4 as writeDgramHeader } from './stream-data-BJoG7tYI.js';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
5
5
 
@@ -195,6 +195,100 @@ declare class RecordingsClient {
195
195
 
196
196
  declare function createRecordingsClient(options: RecordingsClientOptions): RecordingsClient;
197
197
 
198
+ declare const USER_ACTIVITY_FIELD = "user_activity";
199
+
200
+ declare const FOCUS_FIELD = "focus";
201
+
202
+ declare const USER_ACTIVITY_MIN_INTERVAL_MS = 30000;
203
+
204
+ type PresenceConnectivityState = 'idle' | 'connecting' | 'ready' | 'transient_failure';
205
+ type PresenceVisibility = 'visible' | 'hidden';
206
+ type PresenceFocus = 'focused' | 'unfocused';
207
+
208
+ type PresenceInteractionKind = 'typing' | 'pointer' | 'tty';
209
+
210
+ interface UserActivityPayload {
211
+ at: number;
212
+ counts: {
213
+ typing: number;
214
+ pointer: number;
215
+ tty: number;
216
+ consumer_reads: number;
217
+ };
218
+ inflight: number;
219
+ visibility?: PresenceVisibility;
220
+ focus?: PresenceFocus;
221
+ }
222
+
223
+ interface PresenceAwarenessSink {
224
+ setLocalStateField(field: string, value: unknown): void;
225
+ }
226
+
227
+ interface PresenceTransportLike {
228
+ on(event: 'stateChange', handler: (state: TransportState) => void): () => void;
229
+ readonly state: TransportState;
230
+ }
231
+ interface PresenceTrackerOptions {
232
+
233
+ awareness?: PresenceAwarenessSink;
234
+
235
+ now?: () => number;
236
+
237
+ windowTarget?: Pick<Window, 'addEventListener' | 'removeEventListener'> | null;
238
+ documentTarget?: (Pick<Document, 'addEventListener' | 'removeEventListener'> & {
239
+ hasFocus?: () => boolean;
240
+ }) | null;
241
+ }
242
+ declare class PresenceTracker {
243
+ private readonly _awareness;
244
+ private readonly _now;
245
+ private readonly _win;
246
+ private _state;
247
+ private readonly _stateHandlers;
248
+ private readonly _transportUnsubs;
249
+ private _disposed;
250
+ private readonly _counts;
251
+ private _inflight;
252
+ private _visibility;
253
+ private _focus;
254
+ private _lastSignalAt;
255
+ private _lastPublishedAt;
256
+ private _trailing;
257
+ private _onWindowFocus;
258
+ private _onWindowBlur;
259
+ constructor(options?: PresenceTrackerOptions);
260
+
261
+ get state(): PresenceConnectivityState;
262
+
263
+ onState(handler: (state: PresenceConnectivityState) => void): () => void;
264
+
265
+ transportConnecting(): void;
266
+
267
+ transportReady(): void;
268
+
269
+ transportClosed(): void;
270
+
271
+ attachTransport(transport: PresenceTransportLike): () => void;
272
+ private _setState;
273
+
274
+ interaction(kind: PresenceInteractionKind, count?: number): void;
275
+
276
+ consumerRead(count?: number): void;
277
+
278
+ get inflight(): number;
279
+
280
+ workBegin(): () => void;
281
+
282
+ setVisibility(visibility: PresenceVisibility): void;
283
+
284
+ setFocus(focus: PresenceFocus): void;
285
+
286
+ private _signal;
287
+ private _publishNow;
288
+
289
+ dispose(): void;
290
+ }
291
+
198
292
  declare const DEFAULT_DOC_SYNC_TIMEOUT_MS = 30000;
199
293
  declare class SessionStream implements SessionStream$1 {
200
294
  private _name;
@@ -278,6 +372,8 @@ declare class Session implements Session$1 {
278
372
 
279
373
  private _activity;
280
374
 
375
+ private _presenceTracker;
376
+
281
377
  private _activation;
282
378
 
283
379
  private _activeRequests;
@@ -301,6 +397,9 @@ declare class Session implements Session$1 {
301
397
  private _dialNegotiation;
302
398
 
303
399
  private _dialNegotiationStarted;
400
+
401
+ private _generationTickHandlers;
402
+ private _generationTickStop;
304
403
  constructor(sessionId: string, multiplexer: ChannelEndpoint, transport: TransportSession, recordingsAuth?: RecordingsClientOptions, artifactsAuth?: RuntimeArtifactsClientOptions);
305
404
  private _wireControlDocIncarnation;
306
405
 
@@ -323,6 +422,8 @@ declare class Session implements Session$1 {
323
422
 
324
423
  whenLive(options?: WhenLiveOptions): Promise<void>;
325
424
 
425
+ on(event: 'generationTick', handler: (tick: GenerationTick) => void): () => void;
426
+
326
427
  get recordings(): RecordingsAccessor;
327
428
  get artifacts(): RuntimeArtifactsAccessor;
328
429
  setArtifactsAuth(auth: RuntimeArtifactsClientOptions): void;
@@ -338,12 +439,15 @@ declare class Session implements Session$1 {
338
439
 
339
440
  touch(): void;
340
441
 
442
+ get presenceTracker(): PresenceTracker | null;
443
+
341
444
  connectDocs(connector: DocConnector): void;
342
445
 
343
446
  setDocTransport(opts: {
344
447
  wsUrl: string;
345
448
  token?: string | DocTokenSupplier;
346
449
  webSocket?: typeof WebSocket;
450
+ resolveServerUrl?: DocServerUrlResolver;
347
451
  }): void;
348
452
 
349
453
  useStreamDataTransport(transport: StreamDataTransport): void;
@@ -572,12 +676,105 @@ declare class TransportSessionMismatchError extends Error {
572
676
  declare class SessionAllocationError extends Error {
573
677
 
574
678
  readonly httpStatus?: number;
679
+
680
+ readonly code?: string;
681
+
682
+ readonly balanceCredits?: number;
683
+
684
+ readonly platformStatus?: string;
575
685
  constructor(message: string, options?: {
576
686
  httpStatus?: number;
687
+ code?: string;
688
+ balanceCredits?: number;
689
+ platformStatus?: string;
577
690
  cause?: unknown;
578
691
  });
579
692
  }
580
693
 
694
+ interface CreditsClientOptions {
695
+
696
+ functionsUrl: string;
697
+
698
+ orgId: string;
699
+
700
+ apiKey?: string;
701
+
702
+ jwt?: string;
703
+
704
+ getAccessToken?: (options?: AccessTokenOptions) => string | null | undefined | Promise<string | null | undefined>;
705
+
706
+ authProvider?: string;
707
+ }
708
+
709
+ interface CreditBalance {
710
+ org_id: string;
711
+
712
+ balance_credits: number;
713
+
714
+ available_credits: number;
715
+ free_credits: number;
716
+ subscription_credits: number;
717
+ purchased_credits: number;
718
+ overage_credits: number;
719
+
720
+ activated: boolean;
721
+
722
+ exempt: boolean;
723
+ updated_at: string;
724
+ }
725
+
726
+ interface CreditLedgerEntry {
727
+ id: string;
728
+
729
+ delta_credits: number;
730
+
731
+ reason: string;
732
+ note?: string;
733
+
734
+ session_id?: string;
735
+ created_at: string;
736
+ }
737
+
738
+ interface CreditsLedgerOptions {
739
+
740
+ limit?: number;
741
+ }
742
+
743
+ declare class CreditsError extends Error {
744
+
745
+ readonly status: number;
746
+
747
+ readonly code: string;
748
+ constructor(message: string, options: {
749
+ status: number;
750
+ code: string;
751
+ cause?: unknown;
752
+ });
753
+ }
754
+
755
+ declare class CreditsUnauthorizedError extends CreditsError {
756
+ constructor(message?: string, code?: string);
757
+ }
758
+
759
+ declare class CreditsClient {
760
+ private readonly _options;
761
+ private readonly _base;
762
+ constructor(_options: CreditsClientOptions);
763
+
764
+ getBalance(): Promise<CreditBalance>;
765
+
766
+ getLedger(options?: CreditsLedgerOptions): Promise<CreditLedgerEntry[]>;
767
+
768
+ private _request;
769
+ private _buildUrl;
770
+ private _fetch;
771
+ private _resolveToken;
772
+ private _readJson;
773
+ private _readError;
774
+ }
775
+
776
+ declare function createCreditsClient(options: CreditsClientOptions): CreditsClient;
777
+
581
778
  type CaptureKind = 'audio' | 'video';
582
779
  type GetUserMedia = (constraints: MediaStreamConstraints) => Promise<MediaStream>;
583
780
 
@@ -957,4 +1154,4 @@ declare class FrameReassembler {
957
1154
  private requestKeyframe;
958
1155
  }
959
1156
 
960
- export { ACTIVATION_COLD_BOOT_AFTER_MS, ACTIVATION_DEGRADED_AFTER_MS, ACTIVATION_HINT_PATH, ACTIVATION_STILL_AFTER_MS, ACTIVITY_DOM_EVENTS, ACTIVITY_FIELD, ACTIVITY_STAMP_MIN_INTERVAL_MS, ActivationEvent, ActivationMonitor, type ActivationMonitorOptions, type ActivationStreamLike, type ActivityAwareness, type ActivityTracker, type ActivityTrackerOptions, App, App$1 as AppInterface, AppOptions, AttachOptions, BACKOFF_BASE_MS, BACKOFF_MAX_ATTEMPTS, BACKOFF_MAX_MS, type CameraWarp, type CameraWarpOptions, type CameraWarpTransform, type CaptureClaim, CaptureController, type CaptureControllerOptions, type CaptureKind, CaptureUnavailableError, ChunkReadable, type ClientToken, ClientTokenError, type ConsumingTransport, type CreateClientTokenOptions, DATA_CHANNEL_MESSAGE_CEILING, DEFAULT_DOC_SYNC_TIMEOUT_MS, DEFAULT_GATEWAY_URL, DEFAULT_PRODUCE_ACK_TIMEOUT_MS, DEFAULT_REFERENCE_JPEG_QUALITY, DEFAULT_REFERENCE_MAX_SIZE, DEFAULT_WHEN_LIVE_TIMEOUT_MS, DocTokenSupplier, FOREGROUND_COALESCE_MS, FrameReassembler, INPUT_PRESENCE_DEFAULT_HZ, INPUT_PRESENCE_FIELD, type InputPresenceAwareness, type InputPresencePublisher, type InputPresencePublisherOptions, type InputPresenceState, InvalidDurationError, LEGACY_ACTIVATION_HINT_PATH, MediaSession, type NormalizeReferenceImageOptions, PLATFORM_DOC_NAME, PermanentLockedError, type PhaseObservable, PinRequiresActiveTempError, Presence, ProduceAckTimeoutError, type ReassembledFrame, type ReassemblerCallbacks, type ReassemblerOptions, Recording, RecordingNotFoundError, RecordingsAccessor, RecordingsClient, type RecordingsClientOptions, RecordingsError, RecordingsUnauthorizedError, type ReferenceImage, type ReferenceImageSource, type ReferenceImageType, RequestAbortError, RequestCancelledError, RequestDocSyncError, RequestError, RequestOptions, RequestStreamOptions, RequestTimeoutError, RetainNotTempError, type RetentionIntent, RuntimeArtifact, RuntimeArtifactDownload, RuntimeArtifactNotFoundError, RuntimeArtifactsAccessor, RuntimeArtifactsClient, type RuntimeArtifactsClientOptions, RuntimeArtifactsError, RuntimeArtifactsUnauthorizedError, Session, SessionAllocationError, SessionDiagnostic, SessionEndError, SessionEndResult, SessionEndUnavailableError, SessionFailedError, SessionFailureKind, Session$1 as SessionInterface, SessionPhase, SessionPhaseName, SessionStatsSample, SessionStatus, SessionStream$1 as SessionStream, Store, StoreOptions, StreamChunkOptions, StreamDirectionConflict, TransportOfferResponse, TransportSessionMismatchError, TransportState, URUN_DEV_ENV, VISIBILITY_FIELD, type VideoStreamOptions, WIRE_MESSAGE_BUDGET, WebRtcSession, WebTransportSession, type WhenLiveOptions, WtDataLaneSink, activationHintFrom, cameraCaptureAvailable, captureStillFromVideo, computeBackoffDelay, createActivityTracker, createCameraWarp, createClientToken, createInputPresencePublisher, createRecordingsClient, createRuntimeArtifactsClient, createStore, describeSessionFailure, describeSessionPhase, fitWithin, isDurationString, isRetryableSessionError, isServerTerminalPhase, isWakingPhase, normalizeReferenceImage, normalizeRetention, observeLeaveConfirm, observePageLifecycle, observePageTeardown, referenceImageErrorMessage, sessionFailureFromMediaError, sharedCaptureController, videoStream, whenLive };
1157
+ export { ACTIVATION_COLD_BOOT_AFTER_MS, ACTIVATION_DEGRADED_AFTER_MS, ACTIVATION_HINT_PATH, ACTIVATION_STILL_AFTER_MS, ACTIVITY_DOM_EVENTS, ACTIVITY_FIELD, ACTIVITY_STAMP_MIN_INTERVAL_MS, ActivationEvent, ActivationMonitor, type ActivationMonitorOptions, type ActivationStreamLike, type ActivityAwareness, type ActivityTracker, type ActivityTrackerOptions, App, App$1 as AppInterface, AppOptions, AttachOptions, BACKOFF_BASE_MS, BACKOFF_MAX_ATTEMPTS, BACKOFF_MAX_MS, type CameraWarp, type CameraWarpOptions, type CameraWarpTransform, type CaptureClaim, CaptureController, type CaptureControllerOptions, type CaptureKind, CaptureUnavailableError, ChunkReadable, type ClientToken, ClientTokenError, type ConsumingTransport, type CreateClientTokenOptions, type CreditBalance, type CreditLedgerEntry, CreditsClient, type CreditsClientOptions, CreditsError, type CreditsLedgerOptions, CreditsUnauthorizedError, DATA_CHANNEL_MESSAGE_CEILING, DEFAULT_DOC_SYNC_TIMEOUT_MS, DEFAULT_GATEWAY_URL, DEFAULT_PRODUCE_ACK_TIMEOUT_MS, DEFAULT_REFERENCE_JPEG_QUALITY, DEFAULT_REFERENCE_MAX_SIZE, DEFAULT_WHEN_LIVE_TIMEOUT_MS, DocTokenSupplier, FOCUS_FIELD, FOREGROUND_COALESCE_MS, FrameReassembler, GenerationTick, INPUT_PRESENCE_DEFAULT_HZ, INPUT_PRESENCE_FIELD, type InputPresenceAwareness, type InputPresencePublisher, type InputPresencePublisherOptions, type InputPresenceState, InvalidDurationError, LEGACY_ACTIVATION_HINT_PATH, MediaSession, type NormalizeReferenceImageOptions, PLATFORM_DOC_NAME, PermanentLockedError, type PhaseObservable, PinRequiresActiveTempError, Presence, type PresenceAwarenessSink, type PresenceConnectivityState, type PresenceFocus, type PresenceInteractionKind, PresenceTracker, type PresenceTrackerOptions, type PresenceTransportLike, type PresenceVisibility, ProduceAckTimeoutError, type ReassembledFrame, type ReassemblerCallbacks, type ReassemblerOptions, Recording, RecordingNotFoundError, RecordingsAccessor, RecordingsClient, type RecordingsClientOptions, RecordingsError, RecordingsUnauthorizedError, type ReferenceImage, type ReferenceImageSource, type ReferenceImageType, RequestAbortError, RequestCancelledError, RequestDocSyncError, RequestError, RequestOptions, RequestStreamOptions, RequestTimeoutError, RetainNotTempError, type RetentionIntent, RuntimeArtifact, RuntimeArtifactDownload, RuntimeArtifactNotFoundError, RuntimeArtifactsAccessor, RuntimeArtifactsClient, type RuntimeArtifactsClientOptions, RuntimeArtifactsError, RuntimeArtifactsUnauthorizedError, Session, SessionAllocationError, SessionDiagnostic, SessionEndError, SessionEndResult, SessionEndUnavailableError, SessionFailedError, SessionFailureKind, Session$1 as SessionInterface, SessionPhase, SessionPhaseName, SessionStatsSample, SessionStatus, SessionStream$1 as SessionStream, Store, StoreOptions, StreamChunkOptions, StreamDirectionConflict, TransportOfferResponse, TransportSessionMismatchError, TransportState, URUN_DEV_ENV, USER_ACTIVITY_FIELD, USER_ACTIVITY_MIN_INTERVAL_MS, type UserActivityPayload, VISIBILITY_FIELD, type VideoStreamOptions, WIRE_MESSAGE_BUDGET, WebRtcSession, WebTransportSession, type WhenLiveOptions, WtDataLaneSink, activationHintFrom, cameraCaptureAvailable, captureStillFromVideo, computeBackoffDelay, createActivityTracker, createCameraWarp, createClientToken, createCreditsClient, createInputPresencePublisher, createRecordingsClient, createRuntimeArtifactsClient, createStore, describeSessionFailure, describeSessionPhase, fitWithin, isDurationString, isRetryableSessionError, isServerTerminalPhase, isWakingPhase, normalizeReferenceImage, normalizeRetention, observeLeaveConfirm, observePageLifecycle, observePageTeardown, referenceImageErrorMessage, sessionFailureFromMediaError, sharedCaptureController, videoStream, whenLive };