@zerogpu/browser-extension-sdk 0.1.6 → 0.2.0-dev.202607211328.gc9a2a62

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 (33) hide show
  1. package/README.md +7 -0
  2. package/bin/zerogpu.mjs +7 -13
  3. package/dist/assets/zerogpu-assets.json +3 -2
  4. package/dist/extension/zerogpu-offscreen.js +1420 -178
  5. package/dist/extension/zerogpu-offscreen.js.map +1 -1
  6. package/dist/manifest.json +6 -5
  7. package/dist/types/config/types.d.ts +20 -0
  8. package/dist/types/public-api.d.ts +29 -1
  9. package/dist/types/runtime/guardrails.d.ts +36 -0
  10. package/dist/types/runtime/host-api.d.ts +22 -0
  11. package/dist/types/runtime/init-guard.d.ts +38 -15
  12. package/dist/types/runtime/reregister.d.ts +10 -0
  13. package/dist/types/runtime/resource-gate.d.ts +23 -0
  14. package/dist/types/runtime/shutdown.d.ts +22 -0
  15. package/dist/types/runtime/watchdog.d.ts +35 -0
  16. package/dist/types/telemetry/event-buffer.d.ts +5 -0
  17. package/dist/types/telemetry/event-reporter.d.ts +42 -0
  18. package/dist/types/telemetry/event-types.d.ts +5 -0
  19. package/dist/types/telemetry/types.d.ts +26 -0
  20. package/dist/types/transport/http.d.ts +13 -0
  21. package/dist/types/transport/websocket.d.ts +2 -1
  22. package/dist/v/{zerogpu-browser-sdk.8729e27b5aa1.umd.js → zerogpu-browser-sdk.de2e6d71813f.umd.js} +1416 -169
  23. package/dist/v/zerogpu-browser-sdk.de2e6d71813f.umd.js.map +1 -0
  24. package/dist/zerogpu-browser-sdk.cjs +1415 -168
  25. package/dist/zerogpu-browser-sdk.cjs.map +1 -1
  26. package/dist/zerogpu-browser-sdk.esm.js +1415 -168
  27. package/dist/zerogpu-browser-sdk.esm.js.map +1 -1
  28. package/dist/zerogpu-browser-sdk.umd.js +1415 -168
  29. package/dist/zerogpu-browser-sdk.umd.js.map +1 -1
  30. package/docs/auto-update-loader.md +6 -0
  31. package/docs/extension-developer-guide.md +7 -0
  32. package/package.json +7 -4
  33. package/dist/v/zerogpu-browser-sdk.8729e27b5aa1.umd.js.map +0 -1
@@ -18,19 +18,39 @@ export interface SlmConfig {
18
18
  taskType: TaskType;
19
19
  maxInputTokens?: number;
20
20
  }
21
+ export interface WatchdogSettings {
22
+ warnPct?: number;
23
+ degradePct?: number;
24
+ shutdownPct?: number;
25
+ sampleMs?: number;
26
+ recoverPct?: number;
27
+ recoverHoldMs?: number;
28
+ }
29
+ export interface GuardrailSettings {
30
+ memoryBudgetFraction?: number;
31
+ frameworkMultipliers?: Record<string, number>;
32
+ watchdog?: WatchdogSettings;
33
+ minBatteryLevel?: number;
34
+ storageHeadroom?: number;
35
+ unknownMemoryGb?: number;
36
+ [key: string]: unknown;
37
+ }
21
38
  export interface RegistrationSettings {
22
39
  websocket_timeout_seconds?: number;
23
40
  device_timeout_interval_seconds?: number;
41
+ guardrails?: GuardrailSettings;
24
42
  [key: string]: unknown;
25
43
  }
26
44
  export interface OrchestratorConfig {
27
45
  baseUrl: string;
28
46
  registerPath: string;
47
+ eventsPath: string;
29
48
  }
30
49
  export interface TelemetryConfig {
31
50
  enableConsoleLogs: boolean;
32
51
  locationData: boolean;
33
52
  cameraData: boolean;
53
+ events: boolean;
34
54
  }
35
55
  export interface SdkConfig {
36
56
  sdkVersion: string;
@@ -1,4 +1,6 @@
1
1
  import { ConfigOverrides } from './config/env';
2
+ import { HostEventName, SdkLifecycleStatus } from './runtime/host-api';
3
+ import { ResourcePolicy } from './runtime/guardrails';
2
4
  import './adapters';
3
5
  export interface InitOptions {
4
6
  overrides?: ConfigOverrides;
@@ -9,5 +11,31 @@ export interface InitOptions {
9
11
  * If omitted, the SDK generates and stores a per-browser UUID.
10
12
  */
11
13
  deviceId?: string;
14
+ /**
15
+ * Host hints for the resource guardrails (max model size, memory budget).
16
+ * `disableGuardrails` is for lab use only and is logged loudly.
17
+ */
18
+ resourcePolicy?: ResourcePolicy;
19
+ }
20
+ /**
21
+ * Host-facing handle. `status` reflects the guardrail lifecycle
22
+ * (starting → running ⇄ degraded → shutdown, or error); `on` subscribes to
23
+ * `degraded` / `recovered` / `shutdown`; `shutdown()` runs the ordered
24
+ * graceful shutdown (terminal until the page restarts the SDK).
25
+ */
26
+ export interface ZeroGpuSdkHandle {
27
+ readonly status: SdkLifecycleStatus;
28
+ on(event: HostEventName, listener: (detail: {
29
+ code?: string;
30
+ message?: string;
31
+ }) => void): () => void;
32
+ shutdown(): Promise<void>;
12
33
  }
13
- export declare const initZeroGpuSdk: (options?: InitOptions) => Promise<void>;
34
+ /**
35
+ * Never rejects: the SDK is a guest in someone else's app, and a failed init
36
+ * must degrade to "SDK not running" — observable via `handle.status` and the
37
+ * reported `sdk.init_failed` events — never to an unhandled rejection in the
38
+ * host. Existing `await initZeroGpuSdk(...)` callers are unaffected (the
39
+ * returned handle is additive).
40
+ */
41
+ export declare const initZeroGpuSdk: (options?: InitOptions) => Promise<ZeroGpuSdkHandle>;
@@ -0,0 +1,36 @@
1
+ import { RegistrationSettings, WatchdogSettings } from '../config/types';
2
+ /**
3
+ * Guardrail tunables. The registry serves the same numbers it enforces in its
4
+ * registration admission guard (`configSettings.<sdkType>.guardrails`), so the
5
+ * client ResourceGate and the server memory-fit check can never disagree. The
6
+ * hardcoded defaults below match the server's fallbacks and apply when the
7
+ * block is absent — the guardrails work before the registry ever serves them.
8
+ */
9
+ export interface ResourcePolicy {
10
+ maxModelBytes?: number;
11
+ memoryBudgetFraction?: number;
12
+ /** Lab use only; logged loudly. Turns off preflight + watchdog entirely. */
13
+ disableGuardrails?: boolean;
14
+ }
15
+ export interface ResolvedGuardrails {
16
+ memoryBudgetFraction: number;
17
+ frameworkMultipliers: Record<string, number>;
18
+ minBatteryLevel: number;
19
+ storageHeadroom: number;
20
+ unknownMemoryGb: number;
21
+ watchdog: Required<WatchdogSettings>;
22
+ }
23
+ /** Devices that report no memory are treated as modest 2 GB devices (same as the server). */
24
+ export declare const UNKNOWN_DEVICE_MEMORY_GB = 2;
25
+ export declare const setResourcePolicy: (next: ResourcePolicy | undefined) => void;
26
+ export declare const getResourcePolicy: () => ResourcePolicy;
27
+ /** Called after every register with the server-tuned block (or null). */
28
+ export declare const applyRegistrationGuardrails: (settings: RegistrationSettings | null) => void;
29
+ export declare const getGuardrails: () => ResolvedGuardrails;
30
+ export declare const multiplierFor: (framework: string | undefined) => number;
31
+ /**
32
+ * The catalog's size column is megabytes but travels as `sizeBytes` unchanged
33
+ * (deberta-v3-small -> 184). Values below 1e6 cannot be real byte counts for
34
+ * an on-device model — interpret them as MB, identically to the registry.
35
+ */
36
+ export declare const normalizeModelSizeBytes: (raw: number | undefined) => number;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Host-facing lifecycle status and events. The SDK is a guest in someone
3
+ * else's app: this module is how the host observes guardrail state (degraded /
4
+ * recovered / shutdown) without the SDK ever throwing into it. Script-tag
5
+ * consumers get the same signals as `zerogpu:*` window events, matching the
6
+ * existing `zerogpu:cameraPreview` pattern.
7
+ */
8
+ export type SdkLifecycleStatus = 'starting' | 'running' | 'degraded' | 'shutdown' | 'error';
9
+ export type HostEventName = 'degraded' | 'recovered' | 'shutdown';
10
+ export interface HostEventDetail {
11
+ code?: string;
12
+ message?: string;
13
+ }
14
+ type HostEventListener = (detail: HostEventDetail) => void;
15
+ export declare const getLifecycleStatus: () => SdkLifecycleStatus;
16
+ export declare const setLifecycleStatus: (status: SdkLifecycleStatus) => void;
17
+ export declare const isShutdown: () => boolean;
18
+ /** Degraded and shutting-down SDKs finish in-flight work but accept nothing new. */
19
+ export declare const isTaskGateActive: () => boolean;
20
+ export declare const onHostEvent: (name: HostEventName, listener: HostEventListener) => (() => void);
21
+ export declare const emitHostEvent: (name: HostEventName, detail?: HostEventDetail) => void;
22
+ export {};
@@ -1,21 +1,34 @@
1
1
  /**
2
- * Crash-loop guard for SDK initialization.
2
+ * Crash-loop guard for SDK initialization, extended into the Layer 4 crash
3
+ * marker + per-model breaker.
3
4
  *
4
- * On a brand-new device the lifecycle synchronously downloads and instantiates a
5
- * full model (and runs a sample inference) before connecting the WebSocket. In a
6
- * memory-constrained host such as a Telegram mini-app WebView this burst can
7
- * crash/OOM the view. The host then reloads the mini-app, the SDK runs the same
8
- * heavy first-run path again, crashes again, and the app appears to "refresh
9
- * continuously".
5
+ * On a brand-new device the lifecycle synchronously downloads and instantiates
6
+ * a full model (and runs a sample inference) before connecting the WebSocket.
7
+ * In a memory-constrained host such as a Telegram mini-app WebView this burst
8
+ * can crash/OOM the view; the host reloads, the SDK repeats the same heavy
9
+ * path, and the app "refreshes continuously".
10
10
  *
11
- * Nothing in the previous flow recorded a *failed* attempt: the cache pointer is
12
- * only written after a fully successful load, so every reload looked like a fresh
13
- * first run. This guard persists a small attempt counter *before* the heavy work
14
- * and clears it only once init reaches a stable point. If we see several attempts
15
- * in a short window that never completed, we assume a crash loop and skip the
16
- * heavy init for a cool-down period, which breaks the refresh cycle and lets the
17
- * host app stay up.
11
+ * Two mechanisms share one persisted state (`zerogpu_init_state`):
12
+ *
13
+ * - the original attempt counter: several uncompleted attempts in a short
14
+ * window trip a cool-down that skips heavy init entirely;
15
+ * - the crash marker: a `phase` written before each dangerous step
16
+ * (load/sample) and cleared on graceful shutdown. A phase surviving to the
17
+ * next boot means the process died mid-step — that boot reports
18
+ * `sdk.crash_detected`, and two deaths during one model's risky phases in
19
+ * 24 h blocklist that model for 24 h so a single oversized model can't take
20
+ * the host down repeatedly.
18
21
  */
22
+ export type InitPhase = 'boot' | 'downloading' | 'loading' | 'sampling' | 'running';
23
+ export interface CrashInfo {
24
+ /** `oom_suspected` when the death happened mid download/load/sample, else `unknown`. */
25
+ code: 'oom_suspected' | 'unknown';
26
+ phase: InitPhase;
27
+ modelId?: string;
28
+ modelVersion?: string;
29
+ /** Set when this crash pushed the model over the breaker threshold. */
30
+ blocklistedModel?: string;
31
+ }
19
32
  export interface InitGuardDecision {
20
33
  /** False when we should skip heavy init because a crash loop was detected. */
21
34
  allowed: boolean;
@@ -23,6 +36,8 @@ export interface InitGuardDecision {
23
36
  cooldownRemainingMs?: number;
24
37
  /** Uncompleted attempts counted so far in the current window. */
25
38
  attempts: number;
39
+ /** Present when the previous process died mid-phase (emit sdk.crash_detected). */
40
+ crash?: CrashInfo;
26
41
  }
27
42
  /**
28
43
  * Records the start of an init attempt and decides whether heavy init may
@@ -30,7 +45,15 @@ export interface InitGuardDecision {
30
45
  */
31
46
  export declare const beginInitAttempt: (now?: number) => InitGuardDecision;
32
47
  /**
33
- * Clears crash tracking. Call once init reaches a stable point (e.g. the
48
+ * Clears crash-loop tracking. Call once init reaches a stable point (e.g. the
34
49
  * WebSocket is connected), so successful loads never accumulate toward a trip.
50
+ * Breaker history and the current phase survive — only the attempt counter
51
+ * resets.
35
52
  */
36
53
  export declare const markInitSuccess: () => void;
54
+ /** Written before every dangerous step so an unclean death is attributable. */
55
+ export declare const setInitPhase: (phase: InitPhase, modelId?: string, modelVersion?: string) => void;
56
+ /** The graceful shutdown sequence ran — the next boot must not count a crash. */
57
+ export declare const markCleanShutdown: (code: string) => void;
58
+ /** Blocklisted models are refused before any I/O (breaker, Layer 4). */
59
+ export declare const isModelBlocklisted: (modelId: string, modelVersion?: string) => boolean;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The single pending re-registration timer, isolated so both the lifecycle
3
+ * (which schedules it) and the shutdown sequence (which must kill it — §4.7:
4
+ * a guardrail shutdown closes the socket, and without this the re-register
5
+ * loop would resurrect the SDK into the same memory conditions) can reach it
6
+ * without importing each other.
7
+ */
8
+ export declare const hasReregisterTimer: () => boolean;
9
+ export declare const setReregisterTimer: (callback: () => void, delayMs: number) => void;
10
+ export declare const clearReregisterTimer: () => void;
@@ -0,0 +1,23 @@
1
+ import { DeviceInfo } from '../device/types';
2
+ /**
3
+ * Layer 2 admission control: consulted before model download/load. Until the
4
+ * server-side guard refuses the assignment outright, this gate is the last
5
+ * line between an oversized model and the OOM that kills the host app — it
6
+ * must assume a hostile assignment. Same arithmetic as the registry's
7
+ * admission guard (shared numbers via configSettings.guardrails).
8
+ *
9
+ * Every probe is individually guarded: a guardrail bug degrades to "no
10
+ * guardrails", never to a host crash.
11
+ */
12
+ export interface PreflightBlock {
13
+ /** `model_too_large_for_memory` | `storage_quota_exceeded` | `low_battery` | `model_blocklisted` */
14
+ code: string;
15
+ message: string;
16
+ }
17
+ export interface GateModel {
18
+ modelId: string;
19
+ modelVersion?: string;
20
+ sizeBytes?: number;
21
+ inferenceFramework?: string;
22
+ }
23
+ export declare const evaluateResourceGate: (model: GateModel, stage: "download" | "load", deviceInfo?: Pick<DeviceInfo, "memoryGb" | "battery">) => Promise<PreflightBlock | null>;
@@ -0,0 +1,22 @@
1
+ /** Guardrail shutdown close code; the registry records it as `close_4002`. */
2
+ export declare const CLOSE_GUARDRAIL = 4002;
3
+ /**
4
+ * Client→server status update on the live session. The registry's
5
+ * DeviceSession accepts a hello_ack-shaped message from an authenticated
6
+ * socket and flips the device `idle`/`error` — the degrade/recover wire
7
+ * contract, no new message type needed.
8
+ */
9
+ export declare const sendStatusUpdate: (status: "idle" | "error") => void;
10
+ export interface ShutdownOptions {
11
+ reason: string;
12
+ /** True for guardrail-triggered shutdowns: close 4002 + guardrail.shutdown. */
13
+ guardrail?: boolean;
14
+ }
15
+ /**
16
+ * The ordered shutdown sequence (GRACEFUL_SHUTDOWN_IMPLEMENTATION.md §5):
17
+ * mark terminal + kill the re-register loop → gate input → tell the server →
18
+ * report + beacon-flush → free memory largest-first → mark the exit clean →
19
+ * notify the host. Every step individually guarded; target ≤ 1 s. Terminal:
20
+ * `startLifecycle` refuses to run again until the page restarts the SDK.
21
+ */
22
+ export declare const runShutdownSequence: ({ reason, guardrail }: ShutdownOptions) => Promise<void>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Layer 3 runtime watchdog: a periodic sampler over `performance.memory`
3
+ * (Chromium only — on Telegram iOS / non-Chromium webviews there is no polling
4
+ * signal, and the ladder consists of preflight + allocation-failure boundaries
5
+ * only; this watchdog is best-effort by design). Ladder + hysteresis are the
6
+ * pure [WatchdogLadder] so thresholds are unit-testable.
7
+ */
8
+ export type WatchdogAction = 'warn' | 'degrade' | 'recover' | 'shutdown';
9
+ type LadderState = 'normal' | 'warn' | 'degraded' | 'shutdown';
10
+ export declare class WatchdogLadder {
11
+ private readonly thresholds;
12
+ private readonly budgetBytes;
13
+ private belowRecoverSince;
14
+ state: LadderState;
15
+ constructor(thresholds: {
16
+ warnPct: number;
17
+ degradePct: number;
18
+ shutdownPct: number;
19
+ recoverPct: number;
20
+ recoverHoldMs: number;
21
+ }, budgetBytes: number);
22
+ /** Maps a memory sample to the raw action the ladder calls for, if any. */
23
+ onSample(usedBytes: number, now: number): WatchdogAction | null;
24
+ /** Applies an action; returns it only when it is a real state transition. */
25
+ transition(action: WatchdogAction): WatchdogAction | null;
26
+ }
27
+ export declare const startWatchdog: () => void;
28
+ export declare const stopWatchdog: () => void;
29
+ /**
30
+ * Allocation-failure boundary (Layer 5): adapters that catch a RangeError /
31
+ * wasm abort route here instead of propagating — we may be one allocation from
32
+ * the OOM kill, so run the emergency variant immediately.
33
+ */
34
+ export declare const onAllocationFailure: (message?: string) => void;
35
+ export {};
@@ -0,0 +1,5 @@
1
+ import { QueuedEvent } from './types';
2
+ export declare const loadBufferedEvents: () => QueuedEvent[];
3
+ export declare const saveBufferedEvents: (events: QueuedEvent[]) => void;
4
+ export declare const appendBufferedEvents: (events: QueuedEvent[]) => void;
5
+ export declare const clearBufferedEvents: () => void;
@@ -0,0 +1,42 @@
1
+ import { DeviceEventType } from './event-types';
2
+ import { saveBufferedEvents } from './event-buffer';
3
+ import { ReportFields } from './types';
4
+ export interface EventReporterOptions {
5
+ enabled: boolean;
6
+ endpointUrl: string;
7
+ operatorKey: string;
8
+ deviceId: string;
9
+ sdkVersion: string;
10
+ platform: string;
11
+ edgeSdkType?: string;
12
+ }
13
+ declare class EventReporter {
14
+ private readonly options;
15
+ private queue;
16
+ private seq;
17
+ private emittedCount;
18
+ private capped;
19
+ private sessionKey;
20
+ private timer;
21
+ private lastByTypeCode;
22
+ private listenersBound;
23
+ private boundPageHide;
24
+ private boundVisibilityChange;
25
+ constructor(options: EventReporterOptions);
26
+ setSessionKey(key: string | undefined): void;
27
+ matches(deviceId: string, enabled: boolean): boolean;
28
+ dispose(): void;
29
+ report(type: DeviceEventType, fields?: ReportFields): void;
30
+ flush(opts?: {
31
+ beacon?: boolean;
32
+ }): void;
33
+ private enqueue;
34
+ private sendBeacon;
35
+ private sendFetch;
36
+ private bindTerminalFlush;
37
+ }
38
+ export declare const initEventReporter: (options: EventReporterOptions) => void;
39
+ export declare const getEventReporter: () => EventReporter;
40
+ export declare const __getSessionId: () => string;
41
+ export declare const __disposeEventReporter: () => void;
42
+ export { saveBufferedEvents };
@@ -0,0 +1,5 @@
1
+ export declare const DEVICE_EVENT_TYPES: readonly ["sdk.init_started", "sdk.init_succeeded", "sdk.init_failed", "sdk.shutdown", "sdk.crash_detected", "host.foreground", "host.background", "register.started", "register.succeeded", "register.failed", "register.rejected", "model.assigned", "model.cache_hit", "model.cache_invalid", "model.cache_purged", "model.download_started", "model.download_succeeded", "model.download_failed", "model.load_started", "model.load_succeeded", "model.load_failed", "model.sample_succeeded", "model.sample_failed", "model.evicted", "ws.connect_started", "ws.connected", "ws.hello_ack", "ws.closed", "ws.error", "ws.reconnect_scheduled", "ws.init_failure_reported", "task.failed", "task.rejected", "task.slow", "guardrail.preflight_blocked", "guardrail.pressure_warning", "guardrail.degraded", "guardrail.shutdown", "guardrail.model_blocklisted", "ws.session_opened", "ws.session_authenticated", "ws.session_rejected", "ws.session_superseded", "ws.session_closed", "dispatch.sent", "dispatch.completed", "dispatch.timeout", "dispatch.failed_offline", "registry.status_changed"];
2
+ export type DeviceEventType = (typeof DEVICE_EVENT_TYPES)[number];
3
+ export type DeviceEventSeverity = 'info' | 'warning' | 'error' | 'fatal';
4
+ export declare const DEVICE_EVENT_SEVERITY: Record<DeviceEventType, DeviceEventSeverity>;
5
+ export declare const getDeviceEventSeverity: (type: DeviceEventType, code?: string) => DeviceEventSeverity;
@@ -0,0 +1,26 @@
1
+ import { DeviceEventSeverity, DeviceEventType } from './event-types';
2
+ export interface QueuedEvent {
3
+ eventId: string;
4
+ type: DeviceEventType;
5
+ ts: string;
6
+ seq: number;
7
+ severity: DeviceEventSeverity;
8
+ code?: string;
9
+ message?: string;
10
+ modelId?: string;
11
+ modelVersion?: string;
12
+ taskType?: string;
13
+ durationMs?: number;
14
+ bytes?: number;
15
+ data?: Record<string, unknown>;
16
+ }
17
+ export interface ReportFields {
18
+ code?: string;
19
+ message?: string;
20
+ modelId?: string;
21
+ modelVersion?: string;
22
+ taskType?: string;
23
+ durationMs?: number;
24
+ bytes?: number;
25
+ data?: Record<string, unknown>;
26
+ }
@@ -15,6 +15,12 @@ export interface RegisterResponse {
15
15
  wsUrl: string;
16
16
  active: boolean;
17
17
  ttlSeconds: number;
18
+ /**
19
+ * Set when the server politely declined this registration (200 envelope,
20
+ * no wsUrl) — e.g. `model_too_large_for_memory` from the admission guard.
21
+ * A refusal is a deliberate server decision, not a failure: no retry loop.
22
+ */
23
+ refusalReason?: string;
18
24
  configSettings?: Record<string, RegistrationSettings>;
19
25
  slmConfig?: {
20
26
  modelId: string;
@@ -51,5 +57,12 @@ export declare class RegisterError extends Error {
51
57
  body?: string;
52
58
  constructor(status: number, body?: string);
53
59
  }
60
+ /**
61
+ * Detects the server's "polite refusal" envelope: HTTP 200, `status: 'ok'`,
62
+ * and a reason/code — used for `edge_sdk_type_not_allowed` and for every
63
+ * admission-guard refusal (`model_too_large_for_memory`, `low_battery`,
64
+ * `guardrail_blocked`, …). Returns the reason code, or null.
65
+ */
66
+ export declare const detectSoftRefusal: (payload: unknown) => string | null;
54
67
  export declare const isEdgeSdkTypeNotAllowedResponse: (payload: unknown) => boolean;
55
68
  export declare const registerDevice: (config: SdkConfig, payload: RegisterRequest, auth?: RegisterAuthHeaders) => Promise<RegisterResponse>;
@@ -6,6 +6,7 @@ export interface WebSocketClientOptions {
6
6
  closeAfterAck?: boolean;
7
7
  closeCode?: number;
8
8
  closeReason?: string;
9
+ onOpen?: () => void;
9
10
  onMessage: (message: IncomingMessage) => void;
10
11
  onClose: (event: CloseEvent) => void;
11
12
  onError: (event: Event) => void;
@@ -22,5 +23,5 @@ export declare class WebSocketClient {
22
23
  private handleClose;
23
24
  isActive(): boolean;
24
25
  send(payload: Record<string, unknown>): void;
25
- close(): void;
26
+ close(code?: number, reason?: string): void;
26
27
  }