@attrove/sdk 0.1.2 → 0.1.4
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/cjs/README.md +247 -0
- package/cjs/package.json +56 -0
- package/cjs/src/__mocks__/version.js +17 -0
- package/cjs/src/__mocks__/version.js.map +1 -0
- package/cjs/src/admin-client.js +221 -0
- package/cjs/src/admin-client.js.map +1 -0
- package/cjs/src/client.js +312 -0
- package/cjs/src/client.js.map +1 -0
- package/cjs/src/constants.js +69 -0
- package/cjs/src/constants.js.map +1 -0
- package/cjs/src/errors/index.js +307 -0
- package/cjs/src/errors/index.js.map +1 -0
- package/cjs/src/index.js +98 -0
- package/cjs/src/index.js.map +1 -0
- package/cjs/src/resources/conversations.js +95 -0
- package/cjs/src/resources/conversations.js.map +1 -0
- package/cjs/src/resources/index.js +17 -0
- package/cjs/src/resources/index.js.map +1 -0
- package/cjs/src/resources/integrations.js +69 -0
- package/cjs/src/resources/integrations.js.map +1 -0
- package/cjs/src/resources/messages.js +98 -0
- package/cjs/src/resources/messages.js.map +1 -0
- package/cjs/src/resources/query.js +143 -0
- package/cjs/src/resources/query.js.map +1 -0
- package/cjs/src/resources/users.js +91 -0
- package/cjs/src/resources/users.js.map +1 -0
- package/cjs/src/types/index.js +292 -0
- package/cjs/src/types/index.js.map +1 -0
- package/cjs/src/utils/fetch.js +417 -0
- package/cjs/src/utils/fetch.js.map +1 -0
- package/cjs/src/utils/index.js +12 -0
- package/cjs/src/utils/index.js.map +1 -0
- package/cjs/src/utils/streaming.js +368 -0
- package/cjs/src/utils/streaming.js.map +1 -0
- package/cjs/src/version.js +31 -0
- package/cjs/src/version.js.map +1 -0
- package/esm/README.md +247 -0
- package/esm/package.json +56 -0
- package/esm/src/__mocks__/version.js +12 -0
- package/esm/src/__mocks__/version.js.map +1 -0
- package/esm/src/admin-client.js +216 -0
- package/esm/src/admin-client.js.map +1 -0
- package/esm/src/client.js +308 -0
- package/esm/src/client.js.map +1 -0
- package/esm/src/constants.js +65 -0
- package/esm/src/constants.js.map +1 -0
- package/esm/src/errors/index.js +285 -0
- package/esm/src/errors/index.js.map +1 -0
- package/esm/src/index.js +68 -0
- package/esm/src/index.js.map +1 -0
- package/esm/src/resources/conversations.js +91 -0
- package/esm/src/resources/conversations.js.map +1 -0
- package/esm/src/resources/index.js +9 -0
- package/esm/src/resources/index.js.map +1 -0
- package/esm/src/resources/integrations.js +65 -0
- package/esm/src/resources/integrations.js.map +1 -0
- package/esm/src/resources/messages.js +94 -0
- package/esm/src/resources/messages.js.map +1 -0
- package/esm/src/resources/query.js +139 -0
- package/esm/src/resources/query.js.map +1 -0
- package/esm/src/resources/users.js +87 -0
- package/esm/src/resources/users.js.map +1 -0
- package/esm/src/types/index.js +277 -0
- package/esm/src/types/index.js.map +1 -0
- package/esm/src/utils/fetch.js +413 -0
- package/esm/src/utils/fetch.js.map +1 -0
- package/esm/src/utils/index.js +6 -0
- package/esm/src/utils/index.js.map +1 -0
- package/esm/src/utils/streaming.js +363 -0
- package/esm/src/utils/streaming.js.map +1 -0
- package/esm/src/version.js +26 -0
- package/esm/src/version.js.map +1 -0
- package/package.json +16 -9
- package/types/src/__mocks__/version.d.ts +8 -0
- package/types/src/__mocks__/version.d.ts.map +1 -0
- package/types/src/admin-client.d.ts +144 -0
- package/types/src/admin-client.d.ts.map +1 -0
- package/types/src/client.d.ts +233 -0
- package/types/src/client.d.ts.map +1 -0
- package/types/src/constants.d.ts +47 -0
- package/types/src/constants.d.ts.map +1 -0
- package/types/src/errors/index.d.ts +206 -0
- package/types/src/errors/index.d.ts.map +1 -0
- package/types/src/index.d.ts +65 -0
- package/types/src/index.d.ts.map +1 -0
- package/types/src/resources/conversations.d.ts +81 -0
- package/types/src/resources/conversations.d.ts.map +1 -0
- package/types/src/resources/index.d.ts +12 -0
- package/types/src/resources/index.d.ts.map +1 -0
- package/types/src/resources/integrations.d.ts +63 -0
- package/types/src/resources/integrations.d.ts.map +1 -0
- package/types/src/resources/messages.d.ts +69 -0
- package/types/src/resources/messages.d.ts.map +1 -0
- package/types/src/resources/query.d.ts +86 -0
- package/types/src/resources/query.d.ts.map +1 -0
- package/types/src/resources/users.d.ts +88 -0
- package/types/src/resources/users.d.ts.map +1 -0
- package/types/src/types/index.d.ts +807 -0
- package/types/src/types/index.d.ts.map +1 -0
- package/types/src/utils/fetch.d.ts +161 -0
- package/types/src/utils/fetch.d.ts.map +1 -0
- package/types/src/utils/index.d.ts +8 -0
- package/types/src/utils/index.d.ts.map +1 -0
- package/types/src/utils/streaming.d.ts +210 -0
- package/types/src/utils/streaming.d.ts.map +1 -0
- package/types/src/version.d.ts +21 -0
- package/types/src/version.d.ts.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC;AAEnE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAE7E;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,MAAM,EAAE,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG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|
+
* HTTP Client with Retries
|
|
3
|
+
*
|
|
4
|
+
* Provides a robust fetch wrapper with automatic retries, timeout handling,
|
|
5
|
+
* and proper error mapping.
|
|
6
|
+
*/
|
|
7
|
+
import { RetryInfo } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* HTTP methods supported by the client.
|
|
10
|
+
*/
|
|
11
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
12
|
+
/**
|
|
13
|
+
* Configuration for HTTP requests.
|
|
14
|
+
*/
|
|
15
|
+
export interface RequestConfig {
|
|
16
|
+
method?: HttpMethod;
|
|
17
|
+
headers?: Record<string, string>;
|
|
18
|
+
body?: unknown;
|
|
19
|
+
timeout?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Authentication mode for the HTTP client.
|
|
23
|
+
* Uses a discriminated union to prevent impossible auth states.
|
|
24
|
+
*/
|
|
25
|
+
export type HttpClientAuth = {
|
|
26
|
+
type: 'apiKey';
|
|
27
|
+
apiKey: string;
|
|
28
|
+
userId: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'partner';
|
|
31
|
+
clientId: string;
|
|
32
|
+
clientSecret: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'none';
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Configuration for the HTTP client.
|
|
38
|
+
*/
|
|
39
|
+
export interface HttpClientConfig {
|
|
40
|
+
baseUrl: string;
|
|
41
|
+
auth: HttpClientAuth;
|
|
42
|
+
timeout: number;
|
|
43
|
+
maxRetries: number;
|
|
44
|
+
onRetry?: (info: RetryInfo) => void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Legacy configuration interface for backward compatibility.
|
|
48
|
+
* Use HttpClientConfig with auth discriminated union for new code.
|
|
49
|
+
*/
|
|
50
|
+
export interface LegacyHttpClientConfig {
|
|
51
|
+
baseUrl: string;
|
|
52
|
+
apiKey?: string;
|
|
53
|
+
clientId?: string;
|
|
54
|
+
clientSecret?: string;
|
|
55
|
+
userId?: string;
|
|
56
|
+
timeout?: number;
|
|
57
|
+
maxRetries?: number;
|
|
58
|
+
onRetry?: (info: RetryInfo) => void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* HTTP client with automatic retries and error handling.
|
|
62
|
+
*
|
|
63
|
+
* Features:
|
|
64
|
+
* - Automatic retries with exponential backoff
|
|
65
|
+
* - Respects Retry-After headers
|
|
66
|
+
* - Proper error mapping to SDK error types
|
|
67
|
+
* - Support for API key and partner authentication
|
|
68
|
+
* - Optional retry callbacks for monitoring
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const client = new HttpClient({
|
|
73
|
+
* baseUrl: 'https://api.attrove.com',
|
|
74
|
+
* apiKey: 'sk_...',
|
|
75
|
+
* userId: 'user-uuid',
|
|
76
|
+
* onRetry: (info) => console.log(`Retrying (${info.attempt}/${info.maxRetries})...`)
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare class HttpClient {
|
|
81
|
+
private readonly config;
|
|
82
|
+
constructor(config: LegacyHttpClientConfig);
|
|
83
|
+
/**
|
|
84
|
+
* Build the full URL for a request.
|
|
85
|
+
*/
|
|
86
|
+
private buildUrl;
|
|
87
|
+
/**
|
|
88
|
+
* Build headers for a request.
|
|
89
|
+
*/
|
|
90
|
+
private buildHeaders;
|
|
91
|
+
/**
|
|
92
|
+
* Parse error from API response.
|
|
93
|
+
* Normalizes string errors to ApiError format.
|
|
94
|
+
*/
|
|
95
|
+
private parseApiError;
|
|
96
|
+
/**
|
|
97
|
+
* Make a request with automatic retries.
|
|
98
|
+
*
|
|
99
|
+
* @param path - API path (relative to base URL)
|
|
100
|
+
* @param config - Request configuration
|
|
101
|
+
* @param queryParams - Optional query parameters
|
|
102
|
+
* @returns Parsed response data
|
|
103
|
+
*
|
|
104
|
+
* @throws {AuthenticationError} When authentication fails (401)
|
|
105
|
+
* @throws {AuthorizationError} When authorization fails (403)
|
|
106
|
+
* @throws {NotFoundError} When resource is not found (404)
|
|
107
|
+
* @throws {ValidationError} When request validation fails (400)
|
|
108
|
+
* @throws {RateLimitError} When rate limits are exceeded (429)
|
|
109
|
+
* @throws {TimeoutError} When request times out
|
|
110
|
+
* @throws {NetworkError} When network errors occur
|
|
111
|
+
* @throws {ServerError} When server errors occur (5xx)
|
|
112
|
+
*/
|
|
113
|
+
request<T>(path: string, config?: RequestConfig, queryParams?: Record<string, string | string[] | undefined>): Promise<T>;
|
|
114
|
+
/**
|
|
115
|
+
* Make a GET request.
|
|
116
|
+
*
|
|
117
|
+
* @throws {AuthenticationError} When authentication fails (401)
|
|
118
|
+
* @throws {AuthorizationError} When authorization fails (403)
|
|
119
|
+
* @throws {NotFoundError} When resource is not found (404)
|
|
120
|
+
* @throws {RateLimitError} When rate limits are exceeded (429)
|
|
121
|
+
* @throws {NetworkError} When network errors occur
|
|
122
|
+
*/
|
|
123
|
+
get<T>(path: string, params?: Record<string, string | string[] | undefined>, config?: Omit<RequestConfig, 'method' | 'body'>): Promise<T>;
|
|
124
|
+
/**
|
|
125
|
+
* Make a POST request.
|
|
126
|
+
*
|
|
127
|
+
* @throws {AuthenticationError} When authentication fails (401)
|
|
128
|
+
* @throws {ValidationError} When request validation fails (400)
|
|
129
|
+
* @throws {RateLimitError} When rate limits are exceeded (429)
|
|
130
|
+
* @throws {NetworkError} When network errors occur
|
|
131
|
+
*/
|
|
132
|
+
post<T>(path: string, body?: unknown, config?: Omit<RequestConfig, 'method'>): Promise<T>;
|
|
133
|
+
/**
|
|
134
|
+
* Make a PUT request.
|
|
135
|
+
*
|
|
136
|
+
* @throws {AuthenticationError} When authentication fails (401)
|
|
137
|
+
* @throws {ValidationError} When request validation fails (400)
|
|
138
|
+
* @throws {NotFoundError} When resource is not found (404)
|
|
139
|
+
* @throws {NetworkError} When network errors occur
|
|
140
|
+
*/
|
|
141
|
+
put<T>(path: string, body?: unknown, config?: Omit<RequestConfig, 'method'>): Promise<T>;
|
|
142
|
+
/**
|
|
143
|
+
* Make a PATCH request.
|
|
144
|
+
*
|
|
145
|
+
* @throws {AuthenticationError} When authentication fails (401)
|
|
146
|
+
* @throws {ValidationError} When request validation fails (400)
|
|
147
|
+
* @throws {NotFoundError} When resource is not found (404)
|
|
148
|
+
* @throws {NetworkError} When network errors occur
|
|
149
|
+
*/
|
|
150
|
+
patch<T>(path: string, body?: unknown, config?: Omit<RequestConfig, 'method'>): Promise<T>;
|
|
151
|
+
/**
|
|
152
|
+
* Make a DELETE request.
|
|
153
|
+
*
|
|
154
|
+
* @throws {AuthenticationError} When authentication fails (401)
|
|
155
|
+
* @throws {AuthorizationError} When authorization fails (403)
|
|
156
|
+
* @throws {NotFoundError} When resource is not found (404)
|
|
157
|
+
* @throws {NetworkError} When network errors occur
|
|
158
|
+
*/
|
|
159
|
+
delete<T>(path: string, config?: Omit<RequestConfig, 'method' | 'body'>): Promise<T>;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/src/utils/fetch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,EAAqC,SAAS,EAAE,MAAM,UAAU,CAAC;AASxE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,QA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{ StreamingClient, generateMessageId } from './streaming';
|
|
7
|
+
export type { StreamOptions, StreamResult } from './streaming';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACjE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket Streaming Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides WebSocket connection management for streaming LLM responses.
|
|
5
|
+
*
|
|
6
|
+
* Security Note: The WebSocket connection passes the authentication token
|
|
7
|
+
* as a query parameter. While this is a common pattern for WebSocket auth
|
|
8
|
+
* (since WebSocket doesn't support custom headers in browsers), be aware that:
|
|
9
|
+
* - Tokens may appear in server access logs
|
|
10
|
+
* - Tokens may be visible in network inspection tools
|
|
11
|
+
* - Using short-lived tokens is recommended for production use
|
|
12
|
+
*/
|
|
13
|
+
import { ConversationMessage, QueryOptions, StreamState, StreamEndReason } from '../types';
|
|
14
|
+
/**
|
|
15
|
+
* Options for streaming queries.
|
|
16
|
+
*
|
|
17
|
+
* Streaming is useful when displaying results progressively to end users.
|
|
18
|
+
* The callbacks allow real-time updates as the LLM generates the response.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const result = await attrove.stream('What happened?', {
|
|
23
|
+
* onChunk: (chunk) => process.stdout.write(chunk),
|
|
24
|
+
* onState: (state) => console.log('State:', state),
|
|
25
|
+
* signal: abortController.signal
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export interface StreamOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Callback for each content chunk received.
|
|
32
|
+
* Called multiple times as the LLM generates the response.
|
|
33
|
+
*/
|
|
34
|
+
onChunk?: (content: string) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Callback for state changes during streaming.
|
|
37
|
+
* States include: 'selecting_messages', 'streaming', 'completed', 'cancelled', 'error'
|
|
38
|
+
*/
|
|
39
|
+
onState?: (state: StreamState) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Callback when streaming starts.
|
|
42
|
+
*/
|
|
43
|
+
onStart?: () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Callback when an error occurs.
|
|
46
|
+
* Note: The error is also thrown/rejected from the stream() method.
|
|
47
|
+
*/
|
|
48
|
+
onError?: (error: Error) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Callback when streaming ends.
|
|
51
|
+
* The reason indicates how the stream ended: 'completed', 'cancelled', or 'error'.
|
|
52
|
+
*/
|
|
53
|
+
onEnd?: (reason: StreamEndReason) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Optional callback for non-fatal warnings during streaming.
|
|
56
|
+
* Called when best-effort operations fail (e.g., cancel message send failure,
|
|
57
|
+
* WebSocket close failure). If not provided, warnings are logged to console.
|
|
58
|
+
*/
|
|
59
|
+
onWarning?: (message: string, context?: Record<string, unknown>) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Signal to abort the stream.
|
|
62
|
+
* When aborted, the stream will be cancelled and the promise will resolve
|
|
63
|
+
* with cancelled: true.
|
|
64
|
+
*/
|
|
65
|
+
signal?: AbortSignal;
|
|
66
|
+
/**
|
|
67
|
+
* Connection timeout in milliseconds. Defaults to 30000 (30 seconds).
|
|
68
|
+
*/
|
|
69
|
+
timeout?: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Result from attempting to cancel a stream.
|
|
73
|
+
* Discriminated union where `error` is only present when `reason` is 'send_failed'.
|
|
74
|
+
*/
|
|
75
|
+
export type CancelResult = {
|
|
76
|
+
/** Cancel message was sent successfully. */
|
|
77
|
+
success: true;
|
|
78
|
+
reason: 'sent';
|
|
79
|
+
} | {
|
|
80
|
+
/** No stream is currently active to cancel. */
|
|
81
|
+
success: false;
|
|
82
|
+
reason: 'no_active_stream';
|
|
83
|
+
} | {
|
|
84
|
+
/** Failed to send the cancel message (connection may be closed). */
|
|
85
|
+
success: false;
|
|
86
|
+
reason: 'send_failed';
|
|
87
|
+
/** Error message describing the failure. */
|
|
88
|
+
error: string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Result from a streaming query.
|
|
92
|
+
*/
|
|
93
|
+
export interface StreamResult {
|
|
94
|
+
/**
|
|
95
|
+
* The full answer text accumulated from all chunks.
|
|
96
|
+
*/
|
|
97
|
+
answer: string;
|
|
98
|
+
/**
|
|
99
|
+
* Updated conversation history including the assistant's response.
|
|
100
|
+
*/
|
|
101
|
+
history: ConversationMessage[];
|
|
102
|
+
/**
|
|
103
|
+
* Message IDs that were used to generate the answer.
|
|
104
|
+
*/
|
|
105
|
+
usedMessageIds: string[];
|
|
106
|
+
/**
|
|
107
|
+
* Whether the stream was cancelled (via AbortSignal or server).
|
|
108
|
+
*/
|
|
109
|
+
cancelled: boolean;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Streaming query client for WebSocket-based LLM responses.
|
|
113
|
+
*
|
|
114
|
+
* Provides real-time streaming of AI-generated answers with support for:
|
|
115
|
+
* - Progress callbacks for each chunk
|
|
116
|
+
* - State change notifications
|
|
117
|
+
* - Cancellation via AbortSignal
|
|
118
|
+
* - Automatic cleanup on completion or error
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* const streaming = new StreamingClient(baseUrl, apiKey);
|
|
123
|
+
* try {
|
|
124
|
+
* const result = await streaming.stream(query, messageId, history, options, {
|
|
125
|
+
* onChunk: (chunk) => console.log(chunk),
|
|
126
|
+
* });
|
|
127
|
+
* console.log('Answer:', result.answer);
|
|
128
|
+
* } finally {
|
|
129
|
+
* streaming.close();
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare class StreamingClient {
|
|
134
|
+
private readonly wsUrl;
|
|
135
|
+
private readonly token;
|
|
136
|
+
private ws;
|
|
137
|
+
private currentMessageId;
|
|
138
|
+
private onWarning?;
|
|
139
|
+
constructor(baseUrl: string, token: string);
|
|
140
|
+
/**
|
|
141
|
+
* Connect to the WebSocket server.
|
|
142
|
+
*
|
|
143
|
+
* @throws {TimeoutError} If connection times out
|
|
144
|
+
* @throws {NetworkError} If connection fails
|
|
145
|
+
*/
|
|
146
|
+
private connect;
|
|
147
|
+
/**
|
|
148
|
+
* Stream a query response.
|
|
149
|
+
*
|
|
150
|
+
* @param query - The natural language question to answer
|
|
151
|
+
* @param messageId - Unique message ID for tracking this stream
|
|
152
|
+
* @param history - Conversation history for context
|
|
153
|
+
* @param queryOptions - Query options (filters, timezone, etc.)
|
|
154
|
+
* @param streamOptions - Streaming options (callbacks, timeout, etc.)
|
|
155
|
+
* @returns Stream result with full answer and metadata
|
|
156
|
+
*
|
|
157
|
+
* @throws {NetworkError} If WebSocket connection fails or errors during streaming
|
|
158
|
+
* @throws {TimeoutError} If connection times out
|
|
159
|
+
* @throws {AttroveError} If the server returns an error
|
|
160
|
+
*/
|
|
161
|
+
stream(query: string, messageId: string, history: ConversationMessage[], queryOptions?: Omit<QueryOptions, 'history'>, streamOptions?: StreamOptions): Promise<StreamResult>;
|
|
162
|
+
/**
|
|
163
|
+
* Cancel the current stream.
|
|
164
|
+
*
|
|
165
|
+
* Sends a stop message to the server to cancel the ongoing query.
|
|
166
|
+
* This is a best-effort operation - if the connection is already
|
|
167
|
+
* closed or in an invalid state, the cancellation will return
|
|
168
|
+
* a result indicating the failure reason but won't throw an error.
|
|
169
|
+
*
|
|
170
|
+
* @returns Result object with success status and reason
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* const result = streaming.cancel();
|
|
175
|
+
* if (!result.success) {
|
|
176
|
+
* if (result.reason === 'no_active_stream') {
|
|
177
|
+
* console.log('No stream to cancel');
|
|
178
|
+
* } else if (result.reason === 'send_failed') {
|
|
179
|
+
* console.error('Failed to send cancel:', result.error);
|
|
180
|
+
* }
|
|
181
|
+
* }
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
cancel(): CancelResult;
|
|
185
|
+
/**
|
|
186
|
+
* Clean up resources.
|
|
187
|
+
*
|
|
188
|
+
* Closes the WebSocket connection and resets internal state.
|
|
189
|
+
* This is called automatically when a stream completes, errors,
|
|
190
|
+
* or is cancelled.
|
|
191
|
+
*/
|
|
192
|
+
private cleanup;
|
|
193
|
+
/**
|
|
194
|
+
* Close the connection.
|
|
195
|
+
*
|
|
196
|
+
* Call this when you're done with the streaming client to ensure
|
|
197
|
+
* all resources are properly cleaned up.
|
|
198
|
+
*/
|
|
199
|
+
close(): void;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Generate a unique message ID for streaming.
|
|
203
|
+
*
|
|
204
|
+
* Creates a message ID in the format `msg_{timestamp}_{random}` that is
|
|
205
|
+
* sufficiently unique for tracking individual stream requests.
|
|
206
|
+
*
|
|
207
|
+
* @returns A unique message ID string
|
|
208
|
+
*/
|
|
209
|
+
export declare function generateMessageId(): string;
|
|
210
|
+
//# sourceMappingURL=streaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/src/utils/streaming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAA8B,mBAAmB,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAsB,MAAM,UAAU,CAAC;AAoB3I;;;;;;;;;;;;;;GAcG;AACH,MAAM,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;;;;GAqBG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,SAAS,CAAC,CAA+D;gBAErE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAO1C;;;;;OAKG;YACW,OAAO;IA6CrB;;;;;;;;;;;;;OAaG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,mBAAmB,EAAE,EAC9B,YAAY,GAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAM,EAChD,aAAa,GAAE,aAAkB,GAChC,OAAO,CAAC,YAAY,CAAC;IA8MxB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,IAAI,YAAY;IAyBtB;;;;;;OAMG;IACH,OAAO,CAAC,OAAO;IAoBf;;;;;OAKG;IACH,KAAK,IAAI,IAAI;CAGd;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Version Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides version information for the SDK using a static constant.
|
|
5
|
+
* This ensures browser compatibility while keeping the API consistent.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Get the SDK version.
|
|
9
|
+
*
|
|
10
|
+
* Returns the SDK version string from the hardcoded constant.
|
|
11
|
+
* This value should be kept in sync with package.json during releases.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getVersion(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Reset the cached version.
|
|
16
|
+
*
|
|
17
|
+
* @deprecated This function has no effect. Version is now a static constant.
|
|
18
|
+
* Kept for API compatibility with existing tests.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resetVersionCache(): void;
|
|
21
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../../../packages/sdk/src/version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC"}
|