@dvina/sdk 4.1.58 → 4.1.64

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 (86) hide show
  1. package/dist/_generated_documents-XONZIXZ4.js +1 -0
  2. package/dist/adapters/angular/index.d.ts +1 -1
  3. package/dist/adapters/angular/index.js +1 -159
  4. package/dist/adapters/react/index.js +1 -49
  5. package/dist/billing/index.js +1 -5
  6. package/dist/chunk-5E7LX4YQ.js +1 -0
  7. package/dist/chunk-EK7ODJWE.js +1 -0
  8. package/dist/chunk-EOIDWBEZ.js +1 -0
  9. package/dist/chunk-G34ETQUN.js +1 -0
  10. package/dist/chunk-H3TI6B7T.js +1 -0
  11. package/dist/chunk-IIQ3WGOJ.js +1 -0
  12. package/dist/chunk-JQL7QV2D.js +5 -0
  13. package/dist/chunk-SJ6Q5IDB.js +31 -0
  14. package/dist/{client-K9LxSCVw.d.ts → client-D309vpHA.d.ts} +206 -1
  15. package/dist/index.d.ts +110 -3
  16. package/dist/index.js +1 -10
  17. package/dist/inference/index.js +1 -5
  18. package/dist/package.json +12 -48
  19. package/dist/pagination/index.js +1 -5
  20. package/package.json +13 -49
  21. package/dist/_generated_documents-2RBYHBRH.js +0 -4
  22. package/dist/_generated_documents-2RBYHBRH.js.map +0 -1
  23. package/dist/_generated_documents-3OGB3BZM.cjs +0 -2545
  24. package/dist/_generated_documents-3OGB3BZM.cjs.map +0 -1
  25. package/dist/adapters/angular/index.cjs +0 -163
  26. package/dist/adapters/angular/index.cjs.map +0 -1
  27. package/dist/adapters/angular/index.d.cts +0 -254
  28. package/dist/adapters/angular/index.js.map +0 -1
  29. package/dist/adapters/react/index.cjs +0 -51
  30. package/dist/adapters/react/index.cjs.map +0 -1
  31. package/dist/adapters/react/index.d.cts +0 -62
  32. package/dist/adapters/react/index.js.map +0 -1
  33. package/dist/billing/index.cjs +0 -26
  34. package/dist/billing/index.cjs.map +0 -1
  35. package/dist/billing/index.d.cts +0 -328
  36. package/dist/billing/index.js.map +0 -1
  37. package/dist/chunk-2J5WONKO.cjs +0 -1608
  38. package/dist/chunk-2J5WONKO.cjs.map +0 -1
  39. package/dist/chunk-342BFYZZ.cjs +0 -98
  40. package/dist/chunk-342BFYZZ.cjs.map +0 -1
  41. package/dist/chunk-5WRI5ZAA.js +0 -29
  42. package/dist/chunk-5WRI5ZAA.js.map +0 -1
  43. package/dist/chunk-7XBJ77RJ.js +0 -103
  44. package/dist/chunk-7XBJ77RJ.js.map +0 -1
  45. package/dist/chunk-AE5KAIKK.js +0 -24
  46. package/dist/chunk-AE5KAIKK.js.map +0 -1
  47. package/dist/chunk-AQ45E6MZ.cjs +0 -23951
  48. package/dist/chunk-AQ45E6MZ.cjs.map +0 -1
  49. package/dist/chunk-DLCUHX6I.js +0 -1064
  50. package/dist/chunk-DLCUHX6I.js.map +0 -1
  51. package/dist/chunk-DZUJEN5N.cjs +0 -32
  52. package/dist/chunk-DZUJEN5N.cjs.map +0 -1
  53. package/dist/chunk-FOKGSMXS.cjs +0 -27
  54. package/dist/chunk-FOKGSMXS.cjs.map +0 -1
  55. package/dist/chunk-IWQGSVFY.js +0 -23541
  56. package/dist/chunk-IWQGSVFY.js.map +0 -1
  57. package/dist/chunk-KEM6SUTS.js +0 -92
  58. package/dist/chunk-KEM6SUTS.js.map +0 -1
  59. package/dist/chunk-KV5SP7RP.cjs +0 -114
  60. package/dist/chunk-KV5SP7RP.cjs.map +0 -1
  61. package/dist/chunk-PDM2KR7T.js +0 -392
  62. package/dist/chunk-PDM2KR7T.js.map +0 -1
  63. package/dist/chunk-UELAE75E.cjs +0 -408
  64. package/dist/chunk-UELAE75E.cjs.map +0 -1
  65. package/dist/chunk-USR4MXFW.cjs +0 -1699
  66. package/dist/chunk-USR4MXFW.cjs.map +0 -1
  67. package/dist/chunk-WX7EFPHT.js +0 -1600
  68. package/dist/chunk-WX7EFPHT.js.map +0 -1
  69. package/dist/client-Bb2gD6Iz.d.cts +0 -488
  70. package/dist/client-X8guW4nw.d.cts +0 -7954
  71. package/dist/error-CsVoUTY8.d.cts +0 -95
  72. package/dist/index-D_Z25Pa1.d.cts +0 -79
  73. package/dist/index.cjs +0 -1979
  74. package/dist/index.cjs.map +0 -1
  75. package/dist/index.d.cts +0 -3716
  76. package/dist/index.js.map +0 -1
  77. package/dist/inference/index.cjs +0 -70
  78. package/dist/inference/index.cjs.map +0 -1
  79. package/dist/inference/index.d.cts +0 -80
  80. package/dist/inference/index.js.map +0 -1
  81. package/dist/pagination/index.cjs +0 -34
  82. package/dist/pagination/index.cjs.map +0 -1
  83. package/dist/pagination/index.d.cts +0 -6
  84. package/dist/pagination/index.js.map +0 -1
  85. package/dist/sync-engine-gpxyhQBl.d.cts +0 -478
  86. package/dist/types-Chg8ASmf.d.cts +0 -116
@@ -1,488 +0,0 @@
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 ModelCost {
186
- input: number;
187
- output: number;
188
- cache_read?: number;
189
- cache_write?: number;
190
- context_over_200k?: {
191
- input: number;
192
- output: number;
193
- cache_read?: number;
194
- cache_write?: number;
195
- };
196
- }
197
- interface ModelLimit {
198
- context: number;
199
- input?: number;
200
- output: number;
201
- }
202
- interface ModelModalities {
203
- input: Array<'text' | 'audio' | 'image' | 'video' | 'pdf'>;
204
- output: Array<'text' | 'audio' | 'image' | 'video' | 'pdf'>;
205
- }
206
- interface Model {
207
- id: string;
208
- object: 'model';
209
- created: number;
210
- owned_by: string;
211
- name?: string;
212
- family?: string;
213
- release_date?: string;
214
- attachment?: boolean;
215
- reasoning?: boolean;
216
- temperature?: boolean;
217
- tool_call?: boolean;
218
- interleaved?: true | {
219
- field: 'reasoning_content' | 'reasoning_details';
220
- };
221
- cost?: ModelCost;
222
- limit?: ModelLimit;
223
- modalities?: ModelModalities;
224
- experimental?: boolean;
225
- status?: 'alpha' | 'beta' | 'deprecated';
226
- options?: Record<string, unknown>;
227
- headers?: Record<string, string>;
228
- provider?: {
229
- npm: string;
230
- };
231
- variants?: Record<string, Record<string, unknown>>;
232
- }
233
- /**
234
- * Response from GET /models.
235
- */
236
- interface ModelListResponse {
237
- object: 'list';
238
- data: Model[];
239
- }
240
- /**
241
- * OpenAI-compatible error response body from the inference API.
242
- */
243
- interface InferenceErrorResponse {
244
- error: {
245
- message: string;
246
- type: string;
247
- code: string;
248
- };
249
- }
250
- /**
251
- * Response from GET /health.
252
- */
253
- interface HealthResponse {
254
- status: 'ok';
255
- models: number;
256
- openaiHost: string;
257
- anthropicHost: string;
258
- apiVersion: string;
259
- timestamp: number;
260
- }
261
- /**
262
- * Options for creating an inference client.
263
- */
264
- interface InferenceClientOptions {
265
- /** Base URL for the inference API (e.g. 'https://api.dvina.ai/inference/v1'). */
266
- baseUrl: string;
267
- /**
268
- * Static auth token. Use for scripts, CLI tools, and tests.
269
- * Mutually exclusive with `getToken`.
270
- */
271
- token?: string;
272
- /**
273
- * Async callback that returns an auth token.
274
- * When called with `{ forceRefresh: true }`, the callback must bypass any
275
- * cache and obtain a brand-new token.
276
- * Mutually exclusive with `token`.
277
- */
278
- getToken?: (options?: {
279
- forceRefresh?: boolean;
280
- }) => Promise<string>;
281
- /** Custom headers to include in every request. */
282
- headers?: Record<string, string>;
283
- /**
284
- * Request timeout in milliseconds. Default: 120000 (2 minutes).
285
- */
286
- timeout?: number;
287
- }
288
-
289
- /**
290
- * Parse a Server-Sent Events response body into an async iterable of typed chunks.
291
- *
292
- * Handles:
293
- * - Chunked network reads (buffer splitting across `data:` boundaries)
294
- * - `\r\n` and `\n` line endings
295
- * - `data: [DONE]` termination signal
296
- * - Mid-stream errors (yields what it can, then throws)
297
- *
298
- * @param body - A ReadableStream<Uint8Array> from a fetch response
299
- * @returns An async iterable of parsed SSE data objects
300
- */
301
- declare function parseSSEStream<T = ChatCompletionChunk>(body: ReadableStream<Uint8Array>): AsyncGenerator<T, void, undefined>;
302
- /**
303
- * A chat completion stream that also aggregates the full response for convenience.
304
- *
305
- * Implements `AsyncIterable<ChatCompletionChunk>` for chunk-by-chunk processing,
306
- * and provides helper methods to extract the final assembled text and usage.
307
- *
308
- * @example
309
- * ```typescript
310
- * const stream = await client.chat.completions.stream({ ... });
311
- *
312
- * // Option 1: Iterate chunk by chunk
313
- * for await (const chunk of stream) {
314
- * process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
315
- * }
316
- *
317
- * // Option 2: Get aggregated result after iteration
318
- * const text = stream.getText();
319
- * const usage = stream.getUsage();
320
- * ```
321
- */
322
- declare class ChatCompletionStream implements AsyncIterable<ChatCompletionChunk> {
323
- private readonly _chunks;
324
- private readonly _source;
325
- private _consumed;
326
- constructor(source: AsyncGenerator<ChatCompletionChunk, void, undefined>);
327
- [Symbol.asyncIterator](): AsyncIterator<ChatCompletionChunk>;
328
- /**
329
- * Concatenate all content deltas into a single string.
330
- * Must be called after the stream has been fully consumed.
331
- */
332
- getText(): string;
333
- /**
334
- * Get the token usage from the final chunk (if the server included it).
335
- * Must be called after the stream has been fully consumed.
336
- */
337
- getUsage(): {
338
- prompt_tokens: number;
339
- completion_tokens: number;
340
- total_tokens: number;
341
- } | undefined;
342
- /**
343
- * Get the collected chunks array.
344
- * Must be called after the stream has been fully consumed.
345
- */
346
- getChunks(): readonly ChatCompletionChunk[];
347
- }
348
-
349
- /**
350
- * Namespaced chat completions API.
351
- *
352
- * @example
353
- * ```typescript
354
- * // Non-streaming
355
- * const response = await sdk.inference.chat.completions.create({
356
- * model: 'claude-sonnet-4-6',
357
- * messages: [{ role: 'user', content: 'Hello!' }],
358
- * });
359
- *
360
- * // Streaming
361
- * const stream = await sdk.inference.chat.completions.stream({
362
- * model: 'claude-sonnet-4-6',
363
- * messages: [{ role: 'user', content: 'Hello!' }],
364
- * });
365
- * for await (const chunk of stream) {
366
- * process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
367
- * }
368
- * ```
369
- */
370
- interface ChatCompletions {
371
- /** Create a non-streaming chat completion. */
372
- create(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
373
- /** Create a streaming chat completion. Returns an async iterable of chunks. */
374
- stream(request: Omit<ChatCompletionStreamRequest, 'stream'>): Promise<ChatCompletionStream>;
375
- }
376
- interface Chat {
377
- completions: ChatCompletions;
378
- }
379
- /**
380
- * Namespaced responses API.
381
- *
382
- * @example
383
- * ```typescript
384
- * // Non-streaming
385
- * const response = await sdk.inference.responses.create({
386
- * model: 'gpt-5.2',
387
- * input: 'Hello!',
388
- * });
389
- *
390
- * // Streaming
391
- * const stream = await sdk.inference.responses.stream({
392
- * model: 'gpt-5.2',
393
- * input: 'Hello!',
394
- * });
395
- * for await (const event of stream) {
396
- * console.log(event);
397
- * }
398
- * ```
399
- */
400
- interface Responses {
401
- /** Create a non-streaming response. */
402
- create(request: ResponsesRequest): Promise<unknown>;
403
- /** Create a streaming response. Returns a raw async iterable of SSE events. */
404
- stream(request: Omit<ResponsesStreamRequest, 'stream'>): Promise<AsyncIterable<unknown>>;
405
- }
406
- /**
407
- * Namespaced models API.
408
- */
409
- interface Models {
410
- /** List all available models. */
411
- list(): Promise<ModelListResponse>;
412
- /** Get a single model by ID. */
413
- get(modelId: string): Promise<Model>;
414
- }
415
- /**
416
- * The Dvina Inference client.
417
- *
418
- * Provides a typed interface to the `/inference/v1` REST API with full
419
- * SSE streaming support. Follows the OpenAI client naming conventions
420
- * (`sdk.inference.chat.completions`, `sdk.inference.responses`, `sdk.inference.models`).
421
- *
422
- * @example
423
- * ```typescript
424
- * const sdk = new DvinaSdk({ token: 'your-jwt-token' });
425
- *
426
- * // Chat completion
427
- * const response = await sdk.inference.chat.completions.create({
428
- * model: 'claude-sonnet-4-6',
429
- * messages: [{ role: 'user', content: 'Hello!' }],
430
- * });
431
- *
432
- * // Streaming
433
- * const stream = await sdk.inference.chat.completions.stream({
434
- * model: 'claude-sonnet-4-6',
435
- * messages: [{ role: 'user', content: 'Tell me a story' }],
436
- * });
437
- * for await (const chunk of stream) {
438
- * process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
439
- * }
440
- * ```
441
- */
442
- interface InferenceClient {
443
- chat: Chat;
444
- responses: Responses;
445
- models: Models;
446
- /** Check the health of the inference API. */
447
- health(): Promise<HealthResponse>;
448
- }
449
- /**
450
- * Create an inference client using pre-resolved baseUrl and getToken from the SDK.
451
- * This is the internal factory called by `createDvinaClient` — it does NOT resolve
452
- * token/options itself, it receives them from the parent SDK client.
453
- *
454
- * @internal
455
- */
456
- declare function createInferenceClientInternal(baseUrl: string, getToken: (options?: {
457
- forceRefresh?: boolean;
458
- }) => Promise<string>, options?: {
459
- headers?: Record<string, string>;
460
- timeout?: number;
461
- }): InferenceClient;
462
- /**
463
- * Create a standalone Dvina Inference client.
464
- *
465
- * Use this when you need inference without the full GraphQL SDK.
466
- * For most cases, prefer `sdk.inference` which shares auth with the SDK.
467
- *
468
- * @param options - Client configuration (base URL, auth, headers, timeout)
469
- * @returns A fully configured inference client
470
- *
471
- * @example
472
- * ```typescript
473
- * import { createInferenceClient } from '@dvina/sdk/inference';
474
- *
475
- * const client = createInferenceClient({
476
- * baseUrl: 'https://api.dvina.ai/inference/v1',
477
- * token: 'your-jwt-token',
478
- * });
479
- *
480
- * const response = await client.chat.completions.create({
481
- * model: 'claude-sonnet-4-6',
482
- * messages: [{ role: 'user', content: 'Hello!' }],
483
- * });
484
- * ```
485
- */
486
- declare function createInferenceClient(options: InferenceClientOptions): InferenceClient;
487
-
488
- 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 };