@dvina/sdk 3.3.124
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/LICENSE +21 -0
- package/README.md +449 -0
- package/dist/_generated_documents-DF34ZUJ3.js +4 -0
- package/dist/_generated_documents-DF34ZUJ3.js.map +1 -0
- package/dist/_generated_documents-W4RHWJ4B.cjs +2041 -0
- package/dist/_generated_documents-W4RHWJ4B.cjs.map +1 -0
- package/dist/adapters/angular/index.cjs +163 -0
- package/dist/adapters/angular/index.cjs.map +1 -0
- package/dist/adapters/angular/index.d.cts +254 -0
- package/dist/adapters/angular/index.d.ts +254 -0
- package/dist/adapters/angular/index.js +159 -0
- package/dist/adapters/angular/index.js.map +1 -0
- package/dist/adapters/react/index.cjs +51 -0
- package/dist/adapters/react/index.cjs.map +1 -0
- package/dist/adapters/react/index.d.cts +62 -0
- package/dist/adapters/react/index.d.ts +62 -0
- package/dist/adapters/react/index.js +49 -0
- package/dist/adapters/react/index.js.map +1 -0
- package/dist/billing/index.cjs +26 -0
- package/dist/billing/index.cjs.map +1 -0
- package/dist/billing/index.d.cts +338 -0
- package/dist/billing/index.d.ts +338 -0
- package/dist/billing/index.js +5 -0
- package/dist/billing/index.js.map +1 -0
- package/dist/chunk-4QKWHQT2.cjs +104 -0
- package/dist/chunk-4QKWHQT2.cjs.map +1 -0
- package/dist/chunk-5WRI5ZAA.js +29 -0
- package/dist/chunk-5WRI5ZAA.js.map +1 -0
- package/dist/chunk-7JUBGIQ2.js +1008 -0
- package/dist/chunk-7JUBGIQ2.js.map +1 -0
- package/dist/chunk-7XBJ77RJ.js +103 -0
- package/dist/chunk-7XBJ77RJ.js.map +1 -0
- package/dist/chunk-DHUFVGJR.cjs +20389 -0
- package/dist/chunk-DHUFVGJR.cjs.map +1 -0
- package/dist/chunk-DZUJEN5N.cjs +32 -0
- package/dist/chunk-DZUJEN5N.cjs.map +1 -0
- package/dist/chunk-GDK2HJTF.cjs +1346 -0
- package/dist/chunk-GDK2HJTF.cjs.map +1 -0
- package/dist/chunk-KG3GNTYI.js +1339 -0
- package/dist/chunk-KG3GNTYI.js.map +1 -0
- package/dist/chunk-KV5SP7RP.cjs +114 -0
- package/dist/chunk-KV5SP7RP.cjs.map +1 -0
- package/dist/chunk-NPIKZKLU.cjs +27 -0
- package/dist/chunk-NPIKZKLU.cjs.map +1 -0
- package/dist/chunk-OAAZZUYL.cjs +1517 -0
- package/dist/chunk-OAAZZUYL.cjs.map +1 -0
- package/dist/chunk-P4BYTXZ7.js +98 -0
- package/dist/chunk-P4BYTXZ7.js.map +1 -0
- package/dist/chunk-PDM2KR7T.js +392 -0
- package/dist/chunk-PDM2KR7T.js.map +1 -0
- package/dist/chunk-QOZI2HY5.js +24 -0
- package/dist/chunk-QOZI2HY5.js.map +1 -0
- package/dist/chunk-RFBLNKW6.js +20035 -0
- package/dist/chunk-RFBLNKW6.js.map +1 -0
- package/dist/chunk-UELAE75E.cjs +408 -0
- package/dist/chunk-UELAE75E.cjs.map +1 -0
- package/dist/client-9Rwj21T9.d.cts +77 -0
- package/dist/client-Bskq7sc_.d.ts +77 -0
- package/dist/client-CLhQragb.d.cts +446 -0
- package/dist/client-CLhQragb.d.ts +446 -0
- package/dist/error-CsVoUTY8.d.cts +95 -0
- package/dist/error-CsVoUTY8.d.ts +95 -0
- package/dist/index-BrGSfyXq.d.cts +79 -0
- package/dist/index-zPcVLagO.d.ts +79 -0
- package/dist/index.cjs +1675 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +9943 -0
- package/dist/index.d.ts +9943 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/inference/index.cjs +70 -0
- package/dist/inference/index.cjs.map +1 -0
- package/dist/inference/index.d.cts +80 -0
- package/dist/inference/index.d.ts +80 -0
- package/dist/inference/index.js +5 -0
- package/dist/inference/index.js.map +1 -0
- package/dist/pagination/index.cjs +34 -0
- package/dist/pagination/index.cjs.map +1 -0
- package/dist/pagination/index.d.cts +6 -0
- package/dist/pagination/index.d.ts +6 -0
- package/dist/pagination/index.js +5 -0
- package/dist/pagination/index.js.map +1 -0
- package/dist/sync-engine-DVKQO-1-.d.cts +423 -0
- package/dist/sync-engine-cLwTqdjv.d.ts +423 -0
- package/dist/types-2RotD0Ab.d.cts +102 -0
- package/dist/types-2RotD0Ab.d.ts +102 -0
- package/package.json +143 -0
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single part of a multi-modal message content array.
|
|
3
|
+
*/
|
|
4
|
+
interface ContentPart {
|
|
5
|
+
type: 'text' | 'image_url';
|
|
6
|
+
text?: string;
|
|
7
|
+
image_url?: {
|
|
8
|
+
url: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A tool call requested by the assistant.
|
|
13
|
+
*/
|
|
14
|
+
interface ToolCall {
|
|
15
|
+
id: string;
|
|
16
|
+
type: 'function';
|
|
17
|
+
function: {
|
|
18
|
+
name: string;
|
|
19
|
+
arguments: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A tool definition that can be passed to the model.
|
|
24
|
+
*/
|
|
25
|
+
interface Tool {
|
|
26
|
+
type: 'function';
|
|
27
|
+
function: {
|
|
28
|
+
name: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
parameters?: Record<string, unknown>;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Tool choice configuration.
|
|
35
|
+
* - `'auto'`: model decides whether to call a tool
|
|
36
|
+
* - `'none'`: model never calls a tool
|
|
37
|
+
* - `'required'`: model must call a tool
|
|
38
|
+
* - `{ type: 'function'; function: { name } }`: model must call the specified tool
|
|
39
|
+
*/
|
|
40
|
+
type ToolChoice = 'auto' | 'none' | 'required' | {
|
|
41
|
+
type: 'function';
|
|
42
|
+
function: {
|
|
43
|
+
name: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* A single message in a chat conversation.
|
|
48
|
+
*/
|
|
49
|
+
interface ChatMessage {
|
|
50
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
51
|
+
content: string | ContentPart[];
|
|
52
|
+
name?: string;
|
|
53
|
+
tool_calls?: ToolCall[];
|
|
54
|
+
tool_call_id?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Request body for POST /chat/completions (non-streaming).
|
|
58
|
+
*/
|
|
59
|
+
interface ChatCompletionRequest {
|
|
60
|
+
model: string;
|
|
61
|
+
messages: ChatMessage[];
|
|
62
|
+
temperature?: number;
|
|
63
|
+
max_completion_tokens?: number;
|
|
64
|
+
stream?: false;
|
|
65
|
+
tools?: Tool[];
|
|
66
|
+
tool_choice?: ToolChoice;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Request body for POST /chat/completions (streaming).
|
|
70
|
+
*/
|
|
71
|
+
interface ChatCompletionStreamRequest {
|
|
72
|
+
model: string;
|
|
73
|
+
messages: ChatMessage[];
|
|
74
|
+
temperature?: number;
|
|
75
|
+
max_completion_tokens?: number;
|
|
76
|
+
stream: true;
|
|
77
|
+
tools?: Tool[];
|
|
78
|
+
tool_choice?: ToolChoice;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Request body for POST /responses (non-streaming).
|
|
82
|
+
*/
|
|
83
|
+
interface ResponsesRequest {
|
|
84
|
+
model: string;
|
|
85
|
+
input: string | unknown[];
|
|
86
|
+
stream?: false;
|
|
87
|
+
instructions?: string;
|
|
88
|
+
temperature?: number;
|
|
89
|
+
max_output_tokens?: number;
|
|
90
|
+
tools?: unknown[];
|
|
91
|
+
tool_choice?: unknown;
|
|
92
|
+
reasoning?: {
|
|
93
|
+
effort?: string;
|
|
94
|
+
summary?: string;
|
|
95
|
+
};
|
|
96
|
+
text?: {
|
|
97
|
+
format?: unknown;
|
|
98
|
+
};
|
|
99
|
+
include?: string[];
|
|
100
|
+
[key: string]: unknown;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Request body for POST /responses (streaming).
|
|
104
|
+
*/
|
|
105
|
+
interface ResponsesStreamRequest {
|
|
106
|
+
model: string;
|
|
107
|
+
input: string | unknown[];
|
|
108
|
+
stream: true;
|
|
109
|
+
instructions?: string;
|
|
110
|
+
temperature?: number;
|
|
111
|
+
max_output_tokens?: number;
|
|
112
|
+
tools?: unknown[];
|
|
113
|
+
tool_choice?: unknown;
|
|
114
|
+
reasoning?: {
|
|
115
|
+
effort?: string;
|
|
116
|
+
summary?: string;
|
|
117
|
+
};
|
|
118
|
+
text?: {
|
|
119
|
+
format?: unknown;
|
|
120
|
+
};
|
|
121
|
+
include?: string[];
|
|
122
|
+
[key: string]: unknown;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Token usage statistics returned by the API.
|
|
126
|
+
*/
|
|
127
|
+
interface Usage {
|
|
128
|
+
prompt_tokens: number;
|
|
129
|
+
completion_tokens: number;
|
|
130
|
+
total_tokens: number;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* A single choice in a non-streaming chat completion response.
|
|
134
|
+
*/
|
|
135
|
+
interface ChatCompletionChoice {
|
|
136
|
+
index: number;
|
|
137
|
+
message: {
|
|
138
|
+
role: string;
|
|
139
|
+
content: string | null;
|
|
140
|
+
tool_calls?: ToolCall[];
|
|
141
|
+
};
|
|
142
|
+
finish_reason: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Non-streaming chat completion response (OpenAI-compatible).
|
|
146
|
+
*/
|
|
147
|
+
interface ChatCompletionResponse {
|
|
148
|
+
id: string;
|
|
149
|
+
object: 'chat.completion';
|
|
150
|
+
created: number;
|
|
151
|
+
model: string;
|
|
152
|
+
choices: ChatCompletionChoice[];
|
|
153
|
+
usage: Usage;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* A delta object within a streaming chunk.
|
|
157
|
+
*/
|
|
158
|
+
interface StreamDelta {
|
|
159
|
+
role?: string;
|
|
160
|
+
content?: string;
|
|
161
|
+
tool_calls?: unknown[];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* A single choice in a streaming chat completion chunk.
|
|
165
|
+
*/
|
|
166
|
+
interface StreamChunkChoice {
|
|
167
|
+
index: number;
|
|
168
|
+
delta: StreamDelta;
|
|
169
|
+
finish_reason: string | null;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* A single SSE chunk during streaming chat completion.
|
|
173
|
+
*/
|
|
174
|
+
interface ChatCompletionChunk {
|
|
175
|
+
id: string;
|
|
176
|
+
object: 'chat.completion.chunk';
|
|
177
|
+
created: number;
|
|
178
|
+
model: string;
|
|
179
|
+
choices: StreamChunkChoice[];
|
|
180
|
+
usage?: Usage;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* A model object returned by the models endpoint.
|
|
184
|
+
*/
|
|
185
|
+
interface Model {
|
|
186
|
+
id: string;
|
|
187
|
+
object: 'model';
|
|
188
|
+
created: number;
|
|
189
|
+
owned_by: string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Response from GET /models.
|
|
193
|
+
*/
|
|
194
|
+
interface ModelListResponse {
|
|
195
|
+
object: 'list';
|
|
196
|
+
data: Model[];
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* OpenAI-compatible error response body from the inference API.
|
|
200
|
+
*/
|
|
201
|
+
interface InferenceErrorResponse {
|
|
202
|
+
error: {
|
|
203
|
+
message: string;
|
|
204
|
+
type: string;
|
|
205
|
+
code: string;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Response from GET /health.
|
|
210
|
+
*/
|
|
211
|
+
interface HealthResponse {
|
|
212
|
+
status: 'ok';
|
|
213
|
+
models: number;
|
|
214
|
+
openaiHost: string;
|
|
215
|
+
anthropicHost: string;
|
|
216
|
+
apiVersion: string;
|
|
217
|
+
timestamp: number;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Options for creating an inference client.
|
|
221
|
+
*/
|
|
222
|
+
interface InferenceClientOptions {
|
|
223
|
+
/** Base URL for the inference API (e.g. 'https://api.dvina.ai/inference/v1'). */
|
|
224
|
+
baseUrl: string;
|
|
225
|
+
/**
|
|
226
|
+
* Static auth token. Use for scripts, CLI tools, and tests.
|
|
227
|
+
* Mutually exclusive with `getToken`.
|
|
228
|
+
*/
|
|
229
|
+
token?: string;
|
|
230
|
+
/**
|
|
231
|
+
* Async callback that returns an auth token.
|
|
232
|
+
* When called with `{ forceRefresh: true }`, the callback must bypass any
|
|
233
|
+
* cache and obtain a brand-new token.
|
|
234
|
+
* Mutually exclusive with `token`.
|
|
235
|
+
*/
|
|
236
|
+
getToken?: (options?: {
|
|
237
|
+
forceRefresh?: boolean;
|
|
238
|
+
}) => Promise<string>;
|
|
239
|
+
/** Custom headers to include in every request. */
|
|
240
|
+
headers?: Record<string, string>;
|
|
241
|
+
/**
|
|
242
|
+
* Request timeout in milliseconds. Default: 120000 (2 minutes).
|
|
243
|
+
*/
|
|
244
|
+
timeout?: number;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Parse a Server-Sent Events response body into an async iterable of typed chunks.
|
|
249
|
+
*
|
|
250
|
+
* Handles:
|
|
251
|
+
* - Chunked network reads (buffer splitting across `data:` boundaries)
|
|
252
|
+
* - `\r\n` and `\n` line endings
|
|
253
|
+
* - `data: [DONE]` termination signal
|
|
254
|
+
* - Mid-stream errors (yields what it can, then throws)
|
|
255
|
+
*
|
|
256
|
+
* @param body - A ReadableStream<Uint8Array> from a fetch response
|
|
257
|
+
* @returns An async iterable of parsed SSE data objects
|
|
258
|
+
*/
|
|
259
|
+
declare function parseSSEStream<T = ChatCompletionChunk>(body: ReadableStream<Uint8Array>): AsyncGenerator<T, void, undefined>;
|
|
260
|
+
/**
|
|
261
|
+
* A chat completion stream that also aggregates the full response for convenience.
|
|
262
|
+
*
|
|
263
|
+
* Implements `AsyncIterable<ChatCompletionChunk>` for chunk-by-chunk processing,
|
|
264
|
+
* and provides helper methods to extract the final assembled text and usage.
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```typescript
|
|
268
|
+
* const stream = await client.chat.completions.stream({ ... });
|
|
269
|
+
*
|
|
270
|
+
* // Option 1: Iterate chunk by chunk
|
|
271
|
+
* for await (const chunk of stream) {
|
|
272
|
+
* process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
|
|
273
|
+
* }
|
|
274
|
+
*
|
|
275
|
+
* // Option 2: Get aggregated result after iteration
|
|
276
|
+
* const text = stream.getText();
|
|
277
|
+
* const usage = stream.getUsage();
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
declare class ChatCompletionStream implements AsyncIterable<ChatCompletionChunk> {
|
|
281
|
+
private readonly _chunks;
|
|
282
|
+
private readonly _source;
|
|
283
|
+
private _consumed;
|
|
284
|
+
constructor(source: AsyncGenerator<ChatCompletionChunk, void, undefined>);
|
|
285
|
+
[Symbol.asyncIterator](): AsyncIterator<ChatCompletionChunk>;
|
|
286
|
+
/**
|
|
287
|
+
* Concatenate all content deltas into a single string.
|
|
288
|
+
* Must be called after the stream has been fully consumed.
|
|
289
|
+
*/
|
|
290
|
+
getText(): string;
|
|
291
|
+
/**
|
|
292
|
+
* Get the token usage from the final chunk (if the server included it).
|
|
293
|
+
* Must be called after the stream has been fully consumed.
|
|
294
|
+
*/
|
|
295
|
+
getUsage(): {
|
|
296
|
+
prompt_tokens: number;
|
|
297
|
+
completion_tokens: number;
|
|
298
|
+
total_tokens: number;
|
|
299
|
+
} | undefined;
|
|
300
|
+
/**
|
|
301
|
+
* Get the collected chunks array.
|
|
302
|
+
* Must be called after the stream has been fully consumed.
|
|
303
|
+
*/
|
|
304
|
+
getChunks(): readonly ChatCompletionChunk[];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Namespaced chat completions API.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```typescript
|
|
312
|
+
* // Non-streaming
|
|
313
|
+
* const response = await sdk.inference.chat.completions.create({
|
|
314
|
+
* model: 'claude-sonnet-4-6',
|
|
315
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
316
|
+
* });
|
|
317
|
+
*
|
|
318
|
+
* // Streaming
|
|
319
|
+
* const stream = await sdk.inference.chat.completions.stream({
|
|
320
|
+
* model: 'claude-sonnet-4-6',
|
|
321
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
322
|
+
* });
|
|
323
|
+
* for await (const chunk of stream) {
|
|
324
|
+
* process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
|
|
325
|
+
* }
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
interface ChatCompletions {
|
|
329
|
+
/** Create a non-streaming chat completion. */
|
|
330
|
+
create(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
|
|
331
|
+
/** Create a streaming chat completion. Returns an async iterable of chunks. */
|
|
332
|
+
stream(request: Omit<ChatCompletionStreamRequest, 'stream'>): Promise<ChatCompletionStream>;
|
|
333
|
+
}
|
|
334
|
+
interface Chat {
|
|
335
|
+
completions: ChatCompletions;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Namespaced responses API.
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
341
|
+
* ```typescript
|
|
342
|
+
* // Non-streaming
|
|
343
|
+
* const response = await sdk.inference.responses.create({
|
|
344
|
+
* model: 'gpt-5.2',
|
|
345
|
+
* input: 'Hello!',
|
|
346
|
+
* });
|
|
347
|
+
*
|
|
348
|
+
* // Streaming
|
|
349
|
+
* const stream = await sdk.inference.responses.stream({
|
|
350
|
+
* model: 'gpt-5.2',
|
|
351
|
+
* input: 'Hello!',
|
|
352
|
+
* });
|
|
353
|
+
* for await (const event of stream) {
|
|
354
|
+
* console.log(event);
|
|
355
|
+
* }
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
interface Responses {
|
|
359
|
+
/** Create a non-streaming response. */
|
|
360
|
+
create(request: ResponsesRequest): Promise<unknown>;
|
|
361
|
+
/** Create a streaming response. Returns a raw async iterable of SSE events. */
|
|
362
|
+
stream(request: Omit<ResponsesStreamRequest, 'stream'>): Promise<AsyncIterable<unknown>>;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Namespaced models API.
|
|
366
|
+
*/
|
|
367
|
+
interface Models {
|
|
368
|
+
/** List all available models. */
|
|
369
|
+
list(): Promise<ModelListResponse>;
|
|
370
|
+
/** Get a single model by ID. */
|
|
371
|
+
get(modelId: string): Promise<Model>;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* The Dvina Inference client.
|
|
375
|
+
*
|
|
376
|
+
* Provides a typed interface to the `/inference/v1` REST API with full
|
|
377
|
+
* SSE streaming support. Follows the OpenAI client naming conventions
|
|
378
|
+
* (`sdk.inference.chat.completions`, `sdk.inference.responses`, `sdk.inference.models`).
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```typescript
|
|
382
|
+
* const sdk = new DvinaSdk({ token: 'your-jwt-token' });
|
|
383
|
+
*
|
|
384
|
+
* // Chat completion
|
|
385
|
+
* const response = await sdk.inference.chat.completions.create({
|
|
386
|
+
* model: 'claude-sonnet-4-6',
|
|
387
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
388
|
+
* });
|
|
389
|
+
*
|
|
390
|
+
* // Streaming
|
|
391
|
+
* const stream = await sdk.inference.chat.completions.stream({
|
|
392
|
+
* model: 'claude-sonnet-4-6',
|
|
393
|
+
* messages: [{ role: 'user', content: 'Tell me a story' }],
|
|
394
|
+
* });
|
|
395
|
+
* for await (const chunk of stream) {
|
|
396
|
+
* process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
|
|
397
|
+
* }
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
interface InferenceClient {
|
|
401
|
+
chat: Chat;
|
|
402
|
+
responses: Responses;
|
|
403
|
+
models: Models;
|
|
404
|
+
/** Check the health of the inference API. */
|
|
405
|
+
health(): Promise<HealthResponse>;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Create an inference client using pre-resolved baseUrl and getToken from the SDK.
|
|
409
|
+
* This is the internal factory called by `createDvinaClient` — it does NOT resolve
|
|
410
|
+
* token/options itself, it receives them from the parent SDK client.
|
|
411
|
+
*
|
|
412
|
+
* @internal
|
|
413
|
+
*/
|
|
414
|
+
declare function createInferenceClientInternal(baseUrl: string, getToken: (options?: {
|
|
415
|
+
forceRefresh?: boolean;
|
|
416
|
+
}) => Promise<string>, options?: {
|
|
417
|
+
headers?: Record<string, string>;
|
|
418
|
+
timeout?: number;
|
|
419
|
+
}): InferenceClient;
|
|
420
|
+
/**
|
|
421
|
+
* Create a standalone Dvina Inference client.
|
|
422
|
+
*
|
|
423
|
+
* Use this when you need inference without the full GraphQL SDK.
|
|
424
|
+
* For most cases, prefer `sdk.inference` which shares auth with the SDK.
|
|
425
|
+
*
|
|
426
|
+
* @param options - Client configuration (base URL, auth, headers, timeout)
|
|
427
|
+
* @returns A fully configured inference client
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```typescript
|
|
431
|
+
* import { createInferenceClient } from '@dvina/sdk/inference';
|
|
432
|
+
*
|
|
433
|
+
* const client = createInferenceClient({
|
|
434
|
+
* baseUrl: 'https://api.dvina.ai/inference/v1',
|
|
435
|
+
* token: 'your-jwt-token',
|
|
436
|
+
* });
|
|
437
|
+
*
|
|
438
|
+
* const response = await client.chat.completions.create({
|
|
439
|
+
* model: 'claude-sonnet-4-6',
|
|
440
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
441
|
+
* });
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
declare function createInferenceClient(options: InferenceClientOptions): InferenceClient;
|
|
445
|
+
|
|
446
|
+
export { type Chat as C, type HealthResponse as H, type InferenceClient as I, type Model as M, type Responses as R, type StreamChunkChoice as S, type Tool as T, type Usage as U, type ChatCompletionChoice as a, type ChatCompletionChunk as b, type ChatCompletionRequest as c, type ChatCompletionResponse as d, ChatCompletionStream as e, type ChatCompletionStreamRequest as f, type ChatCompletions as g, type ChatMessage as h, type ContentPart as i, type InferenceClientOptions as j, type InferenceErrorResponse as k, type ModelListResponse as l, type Models as m, type ResponsesRequest as n, type ResponsesStreamRequest as o, type StreamDelta as p, type ToolCall as q, type ToolChoice as r, createInferenceClient as s, createInferenceClientInternal as t, parseSSEStream as u };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all Dvina SDK errors.
|
|
3
|
+
*/
|
|
4
|
+
declare class DvinaError extends Error {
|
|
5
|
+
/** The original error, if any */
|
|
6
|
+
readonly cause?: Error;
|
|
7
|
+
constructor(message: string, cause?: Error);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Error thrown when the GraphQL response contains errors.
|
|
11
|
+
*/
|
|
12
|
+
declare class DvinaGraphQLError extends DvinaError {
|
|
13
|
+
/** The raw GraphQL errors array */
|
|
14
|
+
readonly errors: readonly GraphQLErrorEntry[];
|
|
15
|
+
/** The query that caused the error (for debugging) */
|
|
16
|
+
readonly query?: string;
|
|
17
|
+
/** The variables that were passed */
|
|
18
|
+
readonly variables?: Record<string, unknown>;
|
|
19
|
+
constructor(errors: readonly GraphQLErrorEntry[], query?: string, variables?: Record<string, unknown>);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Error thrown on network failures (connection refused, timeout, etc.)
|
|
23
|
+
*/
|
|
24
|
+
declare class DvinaNetworkError extends DvinaError {
|
|
25
|
+
/** HTTP status code, if available */
|
|
26
|
+
readonly status?: number;
|
|
27
|
+
constructor(message: string, status?: number, cause?: Error);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Error thrown when authentication fails (401/403).
|
|
31
|
+
*/
|
|
32
|
+
declare class DvinaAuthenticationError extends DvinaError {
|
|
33
|
+
/** The token that was used when the auth error occurred (for stale-token detection). */
|
|
34
|
+
readonly failedToken?: string;
|
|
35
|
+
constructor(message?: string, failedTokenOrCause?: string | Error, cause?: Error);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Known GraphQL error codes returned by the Dvina API in `extensions.code`.
|
|
39
|
+
* Used for programmatic matching in SDK error detection.
|
|
40
|
+
*/
|
|
41
|
+
declare const GRAPHQL_ERROR_CODES: {
|
|
42
|
+
readonly SESSION_TOKEN_LIMIT_REACHED: "SESSION_TOKEN_LIMIT_REACHED";
|
|
43
|
+
readonly STORAGE_LIMIT_REACHED: "STORAGE_LIMIT_REACHED";
|
|
44
|
+
readonly DEEP_ANALYSIS_LIMIT_EXCEEDED: "DEEP_ANALYSIS_LIMIT_EXCEEDED";
|
|
45
|
+
readonly PLAN_DETAIL_RESTRICTION: "PLAN_DETAIL_RESTRICTION";
|
|
46
|
+
readonly RESOURCE_NOT_FOUND: "RESOURCE_NOT_FOUND";
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Base class for plan/billing restriction errors.
|
|
50
|
+
* Thrown when the workspace exceeds a plan limit (storage, capabilities, deep analysis).
|
|
51
|
+
*
|
|
52
|
+
* Consumers can `catch (e) { if (e instanceof DvinaPlanRestrictionError) showUpgradeDialog(); }`
|
|
53
|
+
*/
|
|
54
|
+
declare class DvinaPlanRestrictionError extends DvinaGraphQLError {
|
|
55
|
+
/** The specific restriction code (e.g. 'PLAN_DETAIL_RESTRICTION') */
|
|
56
|
+
readonly restrictionCode: string;
|
|
57
|
+
constructor(errors: readonly GraphQLErrorEntry[], restrictionCode: string, query?: string, variables?: Record<string, unknown>);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Error thrown when the chat session token limit is reached (SESSION_TOKEN_LIMIT_REACHED).
|
|
61
|
+
* Distinct from inference quota — this is a per-session GraphQL limit.
|
|
62
|
+
*/
|
|
63
|
+
declare class DvinaTokenLimitError extends DvinaGraphQLError {
|
|
64
|
+
constructor(errors: readonly GraphQLErrorEntry[], query?: string, variables?: Record<string, unknown>);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Error thrown when a requested resource is not found (RESOURCE_NOT_FOUND).
|
|
68
|
+
*/
|
|
69
|
+
declare class DvinaNotFoundError extends DvinaGraphQLError {
|
|
70
|
+
constructor(errors: readonly GraphQLErrorEntry[], query?: string, variables?: Record<string, unknown>);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Extract the first extension code from a list of GraphQL errors (normalized to uppercase).
|
|
74
|
+
* Returns `undefined` if no code is present.
|
|
75
|
+
*/
|
|
76
|
+
declare function extractErrorCode(errors: readonly GraphQLErrorEntry[]): string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Create the appropriate `DvinaGraphQLError` subclass for the given errors,
|
|
79
|
+
* or return a generic `DvinaGraphQLError` if no specific match is found.
|
|
80
|
+
*/
|
|
81
|
+
declare function createGraphQLError(errors: readonly GraphQLErrorEntry[], query?: string, variables?: Record<string, unknown>): DvinaGraphQLError;
|
|
82
|
+
/**
|
|
83
|
+
* Shape of a single GraphQL error in the response.
|
|
84
|
+
*/
|
|
85
|
+
interface GraphQLErrorEntry {
|
|
86
|
+
message: string;
|
|
87
|
+
locations?: readonly {
|
|
88
|
+
line: number;
|
|
89
|
+
column: number;
|
|
90
|
+
}[];
|
|
91
|
+
path?: readonly (string | number)[];
|
|
92
|
+
extensions?: Record<string, unknown>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { DvinaError as D, GRAPHQL_ERROR_CODES as G, DvinaAuthenticationError as a, DvinaGraphQLError as b, DvinaNetworkError as c, DvinaNotFoundError as d, DvinaPlanRestrictionError as e, DvinaTokenLimitError as f, type GraphQLErrorEntry as g, createGraphQLError as h, extractErrorCode as i };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all Dvina SDK errors.
|
|
3
|
+
*/
|
|
4
|
+
declare class DvinaError extends Error {
|
|
5
|
+
/** The original error, if any */
|
|
6
|
+
readonly cause?: Error;
|
|
7
|
+
constructor(message: string, cause?: Error);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Error thrown when the GraphQL response contains errors.
|
|
11
|
+
*/
|
|
12
|
+
declare class DvinaGraphQLError extends DvinaError {
|
|
13
|
+
/** The raw GraphQL errors array */
|
|
14
|
+
readonly errors: readonly GraphQLErrorEntry[];
|
|
15
|
+
/** The query that caused the error (for debugging) */
|
|
16
|
+
readonly query?: string;
|
|
17
|
+
/** The variables that were passed */
|
|
18
|
+
readonly variables?: Record<string, unknown>;
|
|
19
|
+
constructor(errors: readonly GraphQLErrorEntry[], query?: string, variables?: Record<string, unknown>);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Error thrown on network failures (connection refused, timeout, etc.)
|
|
23
|
+
*/
|
|
24
|
+
declare class DvinaNetworkError extends DvinaError {
|
|
25
|
+
/** HTTP status code, if available */
|
|
26
|
+
readonly status?: number;
|
|
27
|
+
constructor(message: string, status?: number, cause?: Error);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Error thrown when authentication fails (401/403).
|
|
31
|
+
*/
|
|
32
|
+
declare class DvinaAuthenticationError extends DvinaError {
|
|
33
|
+
/** The token that was used when the auth error occurred (for stale-token detection). */
|
|
34
|
+
readonly failedToken?: string;
|
|
35
|
+
constructor(message?: string, failedTokenOrCause?: string | Error, cause?: Error);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Known GraphQL error codes returned by the Dvina API in `extensions.code`.
|
|
39
|
+
* Used for programmatic matching in SDK error detection.
|
|
40
|
+
*/
|
|
41
|
+
declare const GRAPHQL_ERROR_CODES: {
|
|
42
|
+
readonly SESSION_TOKEN_LIMIT_REACHED: "SESSION_TOKEN_LIMIT_REACHED";
|
|
43
|
+
readonly STORAGE_LIMIT_REACHED: "STORAGE_LIMIT_REACHED";
|
|
44
|
+
readonly DEEP_ANALYSIS_LIMIT_EXCEEDED: "DEEP_ANALYSIS_LIMIT_EXCEEDED";
|
|
45
|
+
readonly PLAN_DETAIL_RESTRICTION: "PLAN_DETAIL_RESTRICTION";
|
|
46
|
+
readonly RESOURCE_NOT_FOUND: "RESOURCE_NOT_FOUND";
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Base class for plan/billing restriction errors.
|
|
50
|
+
* Thrown when the workspace exceeds a plan limit (storage, capabilities, deep analysis).
|
|
51
|
+
*
|
|
52
|
+
* Consumers can `catch (e) { if (e instanceof DvinaPlanRestrictionError) showUpgradeDialog(); }`
|
|
53
|
+
*/
|
|
54
|
+
declare class DvinaPlanRestrictionError extends DvinaGraphQLError {
|
|
55
|
+
/** The specific restriction code (e.g. 'PLAN_DETAIL_RESTRICTION') */
|
|
56
|
+
readonly restrictionCode: string;
|
|
57
|
+
constructor(errors: readonly GraphQLErrorEntry[], restrictionCode: string, query?: string, variables?: Record<string, unknown>);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Error thrown when the chat session token limit is reached (SESSION_TOKEN_LIMIT_REACHED).
|
|
61
|
+
* Distinct from inference quota — this is a per-session GraphQL limit.
|
|
62
|
+
*/
|
|
63
|
+
declare class DvinaTokenLimitError extends DvinaGraphQLError {
|
|
64
|
+
constructor(errors: readonly GraphQLErrorEntry[], query?: string, variables?: Record<string, unknown>);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Error thrown when a requested resource is not found (RESOURCE_NOT_FOUND).
|
|
68
|
+
*/
|
|
69
|
+
declare class DvinaNotFoundError extends DvinaGraphQLError {
|
|
70
|
+
constructor(errors: readonly GraphQLErrorEntry[], query?: string, variables?: Record<string, unknown>);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Extract the first extension code from a list of GraphQL errors (normalized to uppercase).
|
|
74
|
+
* Returns `undefined` if no code is present.
|
|
75
|
+
*/
|
|
76
|
+
declare function extractErrorCode(errors: readonly GraphQLErrorEntry[]): string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Create the appropriate `DvinaGraphQLError` subclass for the given errors,
|
|
79
|
+
* or return a generic `DvinaGraphQLError` if no specific match is found.
|
|
80
|
+
*/
|
|
81
|
+
declare function createGraphQLError(errors: readonly GraphQLErrorEntry[], query?: string, variables?: Record<string, unknown>): DvinaGraphQLError;
|
|
82
|
+
/**
|
|
83
|
+
* Shape of a single GraphQL error in the response.
|
|
84
|
+
*/
|
|
85
|
+
interface GraphQLErrorEntry {
|
|
86
|
+
message: string;
|
|
87
|
+
locations?: readonly {
|
|
88
|
+
line: number;
|
|
89
|
+
column: number;
|
|
90
|
+
}[];
|
|
91
|
+
path?: readonly (string | number)[];
|
|
92
|
+
extensions?: Record<string, unknown>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { DvinaError as D, GRAPHQL_ERROR_CODES as G, DvinaAuthenticationError as a, DvinaGraphQLError as b, DvinaNetworkError as c, DvinaNotFoundError as d, DvinaPlanRestrictionError as e, DvinaTokenLimitError as f, type GraphQLErrorEntry as g, createGraphQLError as h, extractErrorCode as i };
|