@zerogpu/browser-extension-sdk 0.1.4 → 0.1.7
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/bin/zerogpu.mjs +7 -13
- package/dist/assets/zerogpu-assets.json +2 -2
- package/dist/extension/zerogpu-offscreen.js +786 -22
- package/dist/extension/zerogpu-offscreen.js.map +1 -1
- package/dist/manifest.json +5 -5
- package/dist/types/config/defaults.d.ts +1 -0
- package/dist/types/config/types.d.ts +7 -0
- package/dist/types/runtime/init-guard.d.ts +36 -0
- package/dist/types/runtime/sdk-state.d.ts +5 -1
- package/dist/types/telemetry/event-buffer.d.ts +5 -0
- package/dist/types/telemetry/event-reporter.d.ts +42 -0
- package/dist/types/telemetry/event-types.d.ts +5 -0
- package/dist/types/telemetry/types.d.ts +26 -0
- package/dist/types/transport/http.d.ts +2 -1
- package/dist/types/transport/websocket.d.ts +2 -0
- package/dist/v/{zerogpu-browser-sdk.beabe7d5083c.umd.js → zerogpu-browser-sdk.eb450ff5aa47.umd.js} +800 -31
- package/dist/v/zerogpu-browser-sdk.eb450ff5aa47.umd.js.map +1 -0
- package/dist/zerogpu-browser-sdk.cjs +799 -30
- package/dist/zerogpu-browser-sdk.cjs.map +1 -1
- package/dist/zerogpu-browser-sdk.esm.js +799 -30
- package/dist/zerogpu-browser-sdk.esm.js.map +1 -1
- package/dist/zerogpu-browser-sdk.umd.js +799 -30
- package/dist/zerogpu-browser-sdk.umd.js.map +1 -1
- package/package.json +5 -3
- package/dist/v/zerogpu-browser-sdk.beabe7d5083c.umd.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RequiredFileSpec, SdkConfig, TaskType } from '../config/types';
|
|
1
|
+
import { RegistrationSettings, RequiredFileSpec, SdkConfig, TaskType } from '../config/types';
|
|
2
2
|
import { DeviceInfo } from '../device/types';
|
|
3
3
|
import { ModelAdapter, TaskSample } from '../adapters/types';
|
|
4
4
|
import { ConnectionStatus } from '../transport/status';
|
|
@@ -40,6 +40,7 @@ export interface SdkState {
|
|
|
40
40
|
modelInfo?: AssignedModelInfo;
|
|
41
41
|
status: ConnectionStatus;
|
|
42
42
|
ws?: WebSocketClient;
|
|
43
|
+
registrationSettings?: RegistrationSettings | null;
|
|
43
44
|
}
|
|
44
45
|
export declare const setConfig: (config: SdkConfig) => void;
|
|
45
46
|
export declare const setDeviceContext: (deviceId: string, deviceInfo: DeviceInfo) => void;
|
|
@@ -52,5 +53,8 @@ export declare const setSample: (sample?: TaskSample) => void;
|
|
|
52
53
|
export declare const setCachedModelId: (cachedModelId?: string | null) => void;
|
|
53
54
|
export declare const setSessionKey: (sessionKey?: string) => void;
|
|
54
55
|
export declare const setWebSocket: (ws?: WebSocketClient) => void;
|
|
56
|
+
export declare const getWebSocket: () => WebSocketClient | undefined;
|
|
57
|
+
export declare const setRegistrationSettings: (settings?: RegistrationSettings | null) => void;
|
|
58
|
+
export declare const getRegistrationSettings: () => RegistrationSettings | null;
|
|
55
59
|
export declare const setStatus: (status: ConnectionStatus) => void;
|
|
56
60
|
export declare const getState: () => SdkState;
|
|
@@ -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
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RequiredFileSpec, SdkConfig } from '../config/types';
|
|
1
|
+
import { RegistrationSettings, RequiredFileSpec, SdkConfig } from '../config/types';
|
|
2
2
|
import { DeviceInfo } from '../device/types';
|
|
3
3
|
export interface RegisterRequest {
|
|
4
4
|
deviceId: string;
|
|
@@ -15,6 +15,7 @@ export interface RegisterResponse {
|
|
|
15
15
|
wsUrl: string;
|
|
16
16
|
active: boolean;
|
|
17
17
|
ttlSeconds: number;
|
|
18
|
+
configSettings?: Record<string, RegistrationSettings>;
|
|
18
19
|
slmConfig?: {
|
|
19
20
|
modelId: string;
|
|
20
21
|
modelType?: string;
|
|
@@ -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;
|
|
@@ -20,6 +21,7 @@ export declare class WebSocketClient {
|
|
|
20
21
|
private handleMessage;
|
|
21
22
|
private handleError;
|
|
22
23
|
private handleClose;
|
|
24
|
+
isActive(): boolean;
|
|
23
25
|
send(payload: Record<string, unknown>): void;
|
|
24
26
|
close(): void;
|
|
25
27
|
}
|