@overshoot/sdk 0.1.0-alpha.0

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.
@@ -0,0 +1,302 @@
1
+ type StreamSource = {
2
+ type: "camera";
3
+ cameraFacing: "user" | "environment";
4
+ } | {
5
+ type: "video";
6
+ file: File;
7
+ };
8
+ type WebRtcOffer = {
9
+ type: "offer";
10
+ sdp: string;
11
+ };
12
+ type WebRtcAnswer = {
13
+ type: "answer";
14
+ sdp: string;
15
+ };
16
+ type StreamProcessingConfig = {
17
+ sampling_ratio: number;
18
+ fps: number;
19
+ clip_length_seconds?: number;
20
+ delay_seconds?: number;
21
+ };
22
+ type StreamInferenceConfig = {
23
+ prompt: string;
24
+ backend: "gemini" | "overshoot";
25
+ model: string;
26
+ output_schema_json?: Record<string, any>;
27
+ };
28
+ type StreamClientMeta = {
29
+ request_id?: string;
30
+ };
31
+ type StreamCreateRequest = {
32
+ webrtc: WebRtcOffer;
33
+ processing: StreamProcessingConfig;
34
+ inference: StreamInferenceConfig;
35
+ client?: StreamClientMeta;
36
+ };
37
+ type StreamCreateResponse = {
38
+ stream_id: string;
39
+ webrtc: WebRtcAnswer;
40
+ lease?: {
41
+ ttl_seconds: number;
42
+ };
43
+ turn_servers?: RTCIceServer[];
44
+ };
45
+ type StreamInferenceResult = {
46
+ id: string;
47
+ stream_id: string;
48
+ model_backend: "gemini" | "overshoot";
49
+ model_name: string;
50
+ prompt: string;
51
+ result: string;
52
+ inference_latency_ms: number;
53
+ total_latency_ms: number;
54
+ ok: boolean;
55
+ error: string | null;
56
+ };
57
+ type StreamConfigResponse = {
58
+ id: string;
59
+ stream_id: string;
60
+ prompt: string;
61
+ backend: "gemini" | "overshoot";
62
+ model: string;
63
+ output_schema_json?: Record<string, any>;
64
+ created_at?: string;
65
+ updated_at?: string;
66
+ };
67
+ type FeedbackCreateRequest = {
68
+ rating: number;
69
+ category: string;
70
+ feedback?: string;
71
+ };
72
+ type FeedbackResponse = {
73
+ id: string;
74
+ stream_id: string;
75
+ rating: number;
76
+ category: string;
77
+ feedback: string;
78
+ created_at?: string;
79
+ updated_at?: string;
80
+ };
81
+ type KeepaliveResponse = {
82
+ status: "ok";
83
+ stream_id: string;
84
+ ttl_seconds: number;
85
+ };
86
+ type StatusResponse = {
87
+ status: "ok";
88
+ };
89
+ type ErrorResponse = {
90
+ error: string;
91
+ message?: string;
92
+ request_id?: string;
93
+ details?: any;
94
+ };
95
+
96
+ type ClientConfig = {
97
+ baseUrl: string;
98
+ apiKey: string;
99
+ };
100
+ declare class StreamClient {
101
+ private baseUrl;
102
+ private apiKey;
103
+ constructor(config: ClientConfig);
104
+ private request;
105
+ createStream(request: StreamCreateRequest): Promise<StreamCreateResponse>;
106
+ renewLease(streamId: string): Promise<KeepaliveResponse>;
107
+ updatePrompt(streamId: string, prompt: string): Promise<StreamConfigResponse>;
108
+ submitFeedback(streamId: string, feedback: FeedbackCreateRequest): Promise<StatusResponse>;
109
+ getAllFeedback(): Promise<FeedbackResponse[]>;
110
+ connectWebSocket(streamId: string): WebSocket;
111
+ /**
112
+ * Health check endpoint (for testing, uses internal port if available)
113
+ * Note: This endpoint may not be available via the main API
114
+ */
115
+ healthCheck(): Promise<string>;
116
+ }
117
+
118
+ interface RealtimeVisionConfig {
119
+ /**
120
+ * Base URL for the API (e.g., "https://api.example.com")
121
+ */
122
+ apiUrl: string;
123
+ /**
124
+ * API key for authentication
125
+ * Required for all API requests
126
+ */
127
+ apiKey: string;
128
+ /**
129
+ * The prompt/task to run on window segments of the stream.
130
+ * This runs continuously (at a defined window interval).
131
+ *
132
+ * Examples:
133
+ * - "Read any visible text"
134
+ * - "Detect objects and return as JSON array"
135
+ * - "Describe facial expression"
136
+ */
137
+ prompt: string;
138
+ /**
139
+ * Video source configuration
140
+ * Defaults to camera with environment facing if not specified
141
+ */
142
+ source?: StreamSource;
143
+ /**
144
+ * Model backend to use
145
+ */
146
+ backend?: "gemini" | "overshoot";
147
+ /**
148
+ * Model name to use for inference
149
+ */
150
+ model?: string;
151
+ /**
152
+ * Optional JSON schema for structured output
153
+ */
154
+ outputSchema?: Record<string, any>;
155
+ /**
156
+ * Called when a new inference result arrives (~1 per second)
157
+ */
158
+ onResult: (result: StreamInferenceResult) => void;
159
+ /**
160
+ * Called when an error occurs
161
+ */
162
+ onError?: (error: Error) => void;
163
+ /**
164
+ * Custom processing configuration
165
+ * All fields are optional and will use defaults if not provided
166
+ */
167
+ processing?: {
168
+ /**
169
+ * Sampling ratio (0-1). Controls what fraction of frames are processed.
170
+ */
171
+ sampling_ratio?: number;
172
+ /**
173
+ * Frames per second (1-120)
174
+ */
175
+ fps?: number;
176
+ /**
177
+ * Clip length in seconds (0.1-60)
178
+ */
179
+ clip_length_seconds?: number;
180
+ /**
181
+ * Delay in seconds (0-60)
182
+ */
183
+ delay_seconds?: number;
184
+ };
185
+ /**
186
+ * ICE servers for WebRTC connection
187
+ * If not provided, uses default TURN servers
188
+ */
189
+ iceServers?: RTCIceServer[];
190
+ /**
191
+ * Enable debug logging
192
+ * @default false
193
+ */
194
+ debug?: boolean;
195
+ }
196
+ declare class RealtimeVision {
197
+ private config;
198
+ private client;
199
+ private logger;
200
+ private mediaStream;
201
+ private peerConnection;
202
+ private webSocket;
203
+ private streamId;
204
+ private keepaliveInterval;
205
+ private videoElement;
206
+ private isRunning;
207
+ constructor(config: RealtimeVisionConfig);
208
+ /**
209
+ * Validate configuration values
210
+ */
211
+ private validateConfig;
212
+ /**
213
+ * Create media stream from the configured source
214
+ */
215
+ private createMediaStream;
216
+ /**
217
+ * Get FPS from media stream
218
+ */
219
+ private getStreamFps;
220
+ /**
221
+ * Get processing configuration with defaults applied
222
+ */
223
+ private getProcessingConfig;
224
+ /**
225
+ * Get the effective source configuration
226
+ */
227
+ private getSource;
228
+ /**
229
+ * Start the vision stream
230
+ */
231
+ start(): Promise<void>;
232
+ /**
233
+ * Set up keepalive interval with error handling
234
+ */
235
+ private setupKeepalive;
236
+ /**
237
+ * Set up WebSocket connection with error handling
238
+ */
239
+ private setupWebSocket;
240
+ /**
241
+ * Handle non-fatal errors (report but don't stop stream)
242
+ */
243
+ private handleNonFatalError;
244
+ /**
245
+ * Handle fatal errors (stop stream and report)
246
+ */
247
+ private handleFatalError;
248
+ /**
249
+ * Update the prompt/task while stream is running
250
+ */
251
+ updatePrompt(prompt: string): Promise<void>;
252
+ /**
253
+ * Stop the vision stream and clean up resources
254
+ */
255
+ stop(): Promise<void>;
256
+ /**
257
+ * Submit feedback for the stream
258
+ */
259
+ submitFeedback(feedback: {
260
+ rating: number;
261
+ category: string;
262
+ feedback?: string;
263
+ }): Promise<void>;
264
+ /**
265
+ * Get the current stream ID
266
+ */
267
+ getStreamId(): string | null;
268
+ /**
269
+ * Get the media stream (for displaying video preview)
270
+ */
271
+ getMediaStream(): MediaStream | null;
272
+ /**
273
+ * Check if the stream is running
274
+ */
275
+ isActive(): boolean;
276
+ private cleanup;
277
+ }
278
+
279
+ declare class ApiError extends Error {
280
+ readonly statusCode?: number;
281
+ readonly requestId?: string;
282
+ readonly details?: any;
283
+ constructor(message: string, statusCode?: number, requestId?: string, details?: any);
284
+ }
285
+ declare class UnauthorizedError extends ApiError {
286
+ constructor(message: string, requestId?: string);
287
+ }
288
+ declare class ValidationError extends ApiError {
289
+ constructor(message: string, requestId?: string, details?: any);
290
+ }
291
+ declare class NotFoundError extends ApiError {
292
+ constructor(message: string, requestId?: string);
293
+ }
294
+ declare class NetworkError extends ApiError {
295
+ readonly cause?: Error;
296
+ constructor(message: string, cause?: Error);
297
+ }
298
+ declare class ServerError extends ApiError {
299
+ constructor(message: string, requestId?: string, details?: any);
300
+ }
301
+
302
+ export { ApiError, type ErrorResponse, type FeedbackCreateRequest, type FeedbackResponse, type KeepaliveResponse, NetworkError, NotFoundError, RealtimeVision, type RealtimeVisionConfig, ServerError, type StatusResponse, StreamClient, type StreamClientMeta, type StreamConfigResponse, type StreamCreateRequest, type StreamCreateResponse, type StreamInferenceConfig, type StreamInferenceResult, type StreamProcessingConfig, type StreamSource, UnauthorizedError, ValidationError, type WebRtcAnswer, type WebRtcOffer };