@hanzo/ai 0.1.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.
- package/LICENSE +201 -0
- package/README.md +151 -0
- package/dist/index.cjs +464 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +486 -0
- package/dist/index.d.ts +486 -0
- package/dist/index.js +446 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
type TokenProvider = string | (() => string | Promise<string>);
|
|
2
|
+
interface ClientConfig {
|
|
3
|
+
/** Defaults to https://api.hanzo.ai (the Hanzo gateway). */
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
/** Static IAM access token (from @hanzo/iam). */
|
|
6
|
+
token?: string;
|
|
7
|
+
/** Lazy token source — preferred when tokens rotate/refresh. */
|
|
8
|
+
getToken?: () => string | Promise<string>;
|
|
9
|
+
/** Custom fetch (e.g. for tests or non-global-fetch runtimes). */
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
/** Extra headers sent on every request. */
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
/** Joins the base URL with a `/v1/...` path. Never adds an `/api/` prefix. */
|
|
15
|
+
declare function joinUrl(baseUrl: string, path: string): string;
|
|
16
|
+
interface RequestOptions {
|
|
17
|
+
method?: string;
|
|
18
|
+
path: string;
|
|
19
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
20
|
+
body?: unknown;
|
|
21
|
+
/** When true, the request is sent without an Authorization header. */
|
|
22
|
+
anonymous?: boolean;
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
/** Force a streaming (raw Response) result; skips body parsing. */
|
|
25
|
+
stream?: boolean;
|
|
26
|
+
headers?: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Transport shared by every resource. Owns base-URL joining, lazy bearer-token
|
|
30
|
+
* injection, JSON encoding, and error normalization. Knows nothing about any
|
|
31
|
+
* specific endpoint.
|
|
32
|
+
*/
|
|
33
|
+
declare class HttpClient {
|
|
34
|
+
readonly baseUrl: string;
|
|
35
|
+
private readonly token?;
|
|
36
|
+
private readonly getToken?;
|
|
37
|
+
private readonly fetchImpl;
|
|
38
|
+
private readonly extraHeaders;
|
|
39
|
+
constructor(config: ClientConfig);
|
|
40
|
+
private resolveToken;
|
|
41
|
+
private buildHeaders;
|
|
42
|
+
/** Issues a request and returns the raw Response (used for streaming). */
|
|
43
|
+
raw(opts: RequestOptions): Promise<Response>;
|
|
44
|
+
/** Issues a request and parses a JSON body (no envelope unwrapping). */
|
|
45
|
+
json<T>(opts: RequestOptions): Promise<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Issues a request to a Casdoor/Casibase CRUD endpoint and unwraps the
|
|
48
|
+
* { status, msg, data } envelope, throwing on status "error".
|
|
49
|
+
*/
|
|
50
|
+
enveloped<T>(opts: RequestOptions): Promise<T>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type Role = "system" | "user" | "assistant" | "tool";
|
|
54
|
+
/** Casdoor/Casibase response envelope used by all CRUD endpoints. */
|
|
55
|
+
interface Envelope<T = unknown> {
|
|
56
|
+
status: "ok" | "error";
|
|
57
|
+
msg: string;
|
|
58
|
+
data: T;
|
|
59
|
+
data2?: unknown;
|
|
60
|
+
}
|
|
61
|
+
interface ChatCompletionContentPartText {
|
|
62
|
+
type: "text";
|
|
63
|
+
text: string;
|
|
64
|
+
}
|
|
65
|
+
interface ChatCompletionContentPartImage {
|
|
66
|
+
type: "image_url";
|
|
67
|
+
image_url: {
|
|
68
|
+
url: string;
|
|
69
|
+
detail?: "auto" | "low" | "high";
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
type ChatCompletionContentPart = ChatCompletionContentPartText | ChatCompletionContentPartImage;
|
|
73
|
+
interface ChatCompletionMessage {
|
|
74
|
+
role: Role;
|
|
75
|
+
content?: string | ChatCompletionContentPart[];
|
|
76
|
+
name?: string;
|
|
77
|
+
tool_call_id?: string;
|
|
78
|
+
tool_calls?: ToolCall[];
|
|
79
|
+
}
|
|
80
|
+
interface FunctionDefinition {
|
|
81
|
+
name: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
parameters?: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
interface Tool {
|
|
86
|
+
type: "function";
|
|
87
|
+
function: FunctionDefinition;
|
|
88
|
+
}
|
|
89
|
+
type ToolChoice = "none" | "auto" | "required" | {
|
|
90
|
+
type: "function";
|
|
91
|
+
function: {
|
|
92
|
+
name: string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
interface ToolCall {
|
|
96
|
+
id: string;
|
|
97
|
+
type: "function";
|
|
98
|
+
function: {
|
|
99
|
+
name: string;
|
|
100
|
+
arguments: string;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
interface ChatCompletionCreateParams {
|
|
104
|
+
model: string;
|
|
105
|
+
messages: ChatCompletionMessage[];
|
|
106
|
+
stream?: boolean;
|
|
107
|
+
temperature?: number;
|
|
108
|
+
top_p?: number;
|
|
109
|
+
n?: number;
|
|
110
|
+
stop?: string | string[];
|
|
111
|
+
max_tokens?: number;
|
|
112
|
+
presence_penalty?: number;
|
|
113
|
+
frequency_penalty?: number;
|
|
114
|
+
user?: string;
|
|
115
|
+
tools?: Tool[];
|
|
116
|
+
tool_choice?: ToolChoice;
|
|
117
|
+
response_format?: {
|
|
118
|
+
type: "text" | "json_object";
|
|
119
|
+
};
|
|
120
|
+
seed?: number;
|
|
121
|
+
/** Any extra provider-specific fields are forwarded verbatim. */
|
|
122
|
+
[key: string]: unknown;
|
|
123
|
+
}
|
|
124
|
+
interface CompletionUsage {
|
|
125
|
+
prompt_tokens: number;
|
|
126
|
+
completion_tokens: number;
|
|
127
|
+
total_tokens: number;
|
|
128
|
+
}
|
|
129
|
+
interface ChatCompletionChoice {
|
|
130
|
+
index: number;
|
|
131
|
+
message: ChatCompletionMessage;
|
|
132
|
+
finish_reason: string | null;
|
|
133
|
+
}
|
|
134
|
+
interface ChatCompletion {
|
|
135
|
+
id: string;
|
|
136
|
+
object: "chat.completion";
|
|
137
|
+
created: number;
|
|
138
|
+
model: string;
|
|
139
|
+
choices: ChatCompletionChoice[];
|
|
140
|
+
usage?: CompletionUsage;
|
|
141
|
+
}
|
|
142
|
+
interface ChatCompletionChunkDelta {
|
|
143
|
+
role?: Role;
|
|
144
|
+
content?: string;
|
|
145
|
+
tool_calls?: Array<Partial<ToolCall> & {
|
|
146
|
+
index: number;
|
|
147
|
+
}>;
|
|
148
|
+
}
|
|
149
|
+
interface ChatCompletionChunkChoice {
|
|
150
|
+
index: number;
|
|
151
|
+
delta: ChatCompletionChunkDelta;
|
|
152
|
+
finish_reason: string | null;
|
|
153
|
+
}
|
|
154
|
+
interface ChatCompletionChunk {
|
|
155
|
+
id: string;
|
|
156
|
+
object: "chat.completion.chunk";
|
|
157
|
+
created: number;
|
|
158
|
+
model: string;
|
|
159
|
+
choices: ChatCompletionChunkChoice[];
|
|
160
|
+
}
|
|
161
|
+
interface AnthropicTextBlock {
|
|
162
|
+
type: "text";
|
|
163
|
+
text: string;
|
|
164
|
+
}
|
|
165
|
+
interface AnthropicImageBlock {
|
|
166
|
+
type: "image";
|
|
167
|
+
source: {
|
|
168
|
+
type: "base64";
|
|
169
|
+
media_type: string;
|
|
170
|
+
data: string;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
type AnthropicContentBlock = AnthropicTextBlock | AnthropicImageBlock;
|
|
174
|
+
interface AnthropicMessage {
|
|
175
|
+
role: "user" | "assistant";
|
|
176
|
+
content: string | AnthropicContentBlock[];
|
|
177
|
+
}
|
|
178
|
+
interface MessageCreateParams {
|
|
179
|
+
model: string;
|
|
180
|
+
messages: AnthropicMessage[];
|
|
181
|
+
max_tokens: number;
|
|
182
|
+
system?: string | AnthropicTextBlock[];
|
|
183
|
+
stream?: boolean;
|
|
184
|
+
temperature?: number;
|
|
185
|
+
top_p?: number;
|
|
186
|
+
top_k?: number;
|
|
187
|
+
stop_sequences?: string[];
|
|
188
|
+
metadata?: {
|
|
189
|
+
user_id?: string;
|
|
190
|
+
};
|
|
191
|
+
[key: string]: unknown;
|
|
192
|
+
}
|
|
193
|
+
interface AnthropicUsage {
|
|
194
|
+
input_tokens: number;
|
|
195
|
+
output_tokens: number;
|
|
196
|
+
}
|
|
197
|
+
interface AnthropicMessageResponse {
|
|
198
|
+
id: string;
|
|
199
|
+
type: "message";
|
|
200
|
+
role: "assistant";
|
|
201
|
+
model: string;
|
|
202
|
+
content: AnthropicContentBlock[];
|
|
203
|
+
stop_reason: string | null;
|
|
204
|
+
stop_sequence: string | null;
|
|
205
|
+
usage: AnthropicUsage;
|
|
206
|
+
}
|
|
207
|
+
/** One decoded SSE event from the Anthropic streaming response. */
|
|
208
|
+
interface AnthropicStreamEvent {
|
|
209
|
+
type: string;
|
|
210
|
+
[key: string]: unknown;
|
|
211
|
+
}
|
|
212
|
+
interface Model {
|
|
213
|
+
id: string;
|
|
214
|
+
object: "model";
|
|
215
|
+
created?: number;
|
|
216
|
+
owned_by?: string;
|
|
217
|
+
[key: string]: unknown;
|
|
218
|
+
}
|
|
219
|
+
interface ModelList {
|
|
220
|
+
object: "list";
|
|
221
|
+
data: Model[];
|
|
222
|
+
}
|
|
223
|
+
interface Chat$1 {
|
|
224
|
+
owner: string;
|
|
225
|
+
name: string;
|
|
226
|
+
createdTime?: string;
|
|
227
|
+
updatedTime?: string;
|
|
228
|
+
organization?: string;
|
|
229
|
+
displayName?: string;
|
|
230
|
+
store?: string;
|
|
231
|
+
modelProvider?: string;
|
|
232
|
+
category?: string;
|
|
233
|
+
/** "AI" for assistant threads. */
|
|
234
|
+
type?: string;
|
|
235
|
+
user?: string;
|
|
236
|
+
user1?: string;
|
|
237
|
+
user2?: string;
|
|
238
|
+
users?: string[];
|
|
239
|
+
messageCount?: number;
|
|
240
|
+
tokenCount?: number;
|
|
241
|
+
price?: number;
|
|
242
|
+
currency?: string;
|
|
243
|
+
isHidden?: boolean;
|
|
244
|
+
isDeleted?: boolean;
|
|
245
|
+
needTitle?: boolean;
|
|
246
|
+
}
|
|
247
|
+
interface VectorScore {
|
|
248
|
+
vector: string;
|
|
249
|
+
score: number;
|
|
250
|
+
}
|
|
251
|
+
interface Suggestion {
|
|
252
|
+
text: string;
|
|
253
|
+
isHit: boolean;
|
|
254
|
+
}
|
|
255
|
+
interface Message {
|
|
256
|
+
owner: string;
|
|
257
|
+
name: string;
|
|
258
|
+
createdTime?: string;
|
|
259
|
+
organization?: string;
|
|
260
|
+
store?: string;
|
|
261
|
+
user?: string;
|
|
262
|
+
/** Name of the parent Chat. */
|
|
263
|
+
chat?: string;
|
|
264
|
+
replyTo?: string;
|
|
265
|
+
/** "AI" for assistant messages, otherwise the username. */
|
|
266
|
+
author?: string;
|
|
267
|
+
text?: string;
|
|
268
|
+
reasonText?: string;
|
|
269
|
+
errorText?: string;
|
|
270
|
+
fileName?: string;
|
|
271
|
+
comment?: string;
|
|
272
|
+
tokenCount?: number;
|
|
273
|
+
textTokenCount?: number;
|
|
274
|
+
price?: number;
|
|
275
|
+
currency?: string;
|
|
276
|
+
isHidden?: boolean;
|
|
277
|
+
isDeleted?: boolean;
|
|
278
|
+
isRegenerated?: boolean;
|
|
279
|
+
webSearchEnabled?: boolean;
|
|
280
|
+
modelProvider?: string;
|
|
281
|
+
embeddingProvider?: string;
|
|
282
|
+
vectorScores?: VectorScore[];
|
|
283
|
+
likeUsers?: string[];
|
|
284
|
+
dislikeUsers?: string[];
|
|
285
|
+
suggestions?: Suggestion[];
|
|
286
|
+
toolCalls?: ToolCall[];
|
|
287
|
+
transactionId?: string;
|
|
288
|
+
}
|
|
289
|
+
/** A subset of the IAM user returned by /v1/get-account. */
|
|
290
|
+
interface Account {
|
|
291
|
+
owner: string;
|
|
292
|
+
name: string;
|
|
293
|
+
displayName?: string;
|
|
294
|
+
email?: string;
|
|
295
|
+
avatar?: string;
|
|
296
|
+
type?: string;
|
|
297
|
+
isAdmin?: boolean;
|
|
298
|
+
[key: string]: unknown;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** Current account (/v1/get-account) — resolves the signed-in IAM user. */
|
|
302
|
+
declare class AccountResource {
|
|
303
|
+
private readonly http;
|
|
304
|
+
constructor(http: HttpClient);
|
|
305
|
+
/** Returns the account for the current token's identity. */
|
|
306
|
+
get(options?: {
|
|
307
|
+
signal?: AbortSignal;
|
|
308
|
+
}): Promise<Account>;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
declare class Completions {
|
|
312
|
+
private readonly http;
|
|
313
|
+
constructor(http: HttpClient);
|
|
314
|
+
/** Non-streaming completion. */
|
|
315
|
+
create(params: ChatCompletionCreateParams & {
|
|
316
|
+
stream?: false;
|
|
317
|
+
}, options?: {
|
|
318
|
+
signal?: AbortSignal;
|
|
319
|
+
}): Promise<ChatCompletion>;
|
|
320
|
+
/** Streaming completion — yields OpenAI `chat.completion.chunk`s. */
|
|
321
|
+
create(params: ChatCompletionCreateParams & {
|
|
322
|
+
stream: true;
|
|
323
|
+
}, options?: {
|
|
324
|
+
signal?: AbortSignal;
|
|
325
|
+
}): Promise<AsyncGenerator<ChatCompletionChunk, void, unknown>>;
|
|
326
|
+
}
|
|
327
|
+
declare class Chat {
|
|
328
|
+
readonly completions: Completions;
|
|
329
|
+
constructor(http: HttpClient);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Messages within chat threads. Backed by object.Message on the backend; a
|
|
334
|
+
* message belongs to a Chat via its `chat` field. These are the durable,
|
|
335
|
+
* cross-surface conversation records (distinct from a single completion call).
|
|
336
|
+
*/
|
|
337
|
+
declare class ChatMessages {
|
|
338
|
+
private readonly http;
|
|
339
|
+
constructor(http: HttpClient);
|
|
340
|
+
/** Lists messages, optionally scoped to a single chat thread by name. */
|
|
341
|
+
list(params?: {
|
|
342
|
+
chat?: string;
|
|
343
|
+
user?: string;
|
|
344
|
+
}, options?: {
|
|
345
|
+
signal?: AbortSignal;
|
|
346
|
+
}): Promise<Message[]>;
|
|
347
|
+
/** Fetches a single message by id ("owner/name"). */
|
|
348
|
+
get(id: string, options?: {
|
|
349
|
+
signal?: AbortSignal;
|
|
350
|
+
}): Promise<Message>;
|
|
351
|
+
/** Appends a message to a thread. */
|
|
352
|
+
append(message: Message, options?: {
|
|
353
|
+
signal?: AbortSignal;
|
|
354
|
+
}): Promise<boolean>;
|
|
355
|
+
/** Updates a message in place; `id` is "owner/name". */
|
|
356
|
+
update(id: string, message: Message, options?: {
|
|
357
|
+
signal?: AbortSignal;
|
|
358
|
+
}): Promise<boolean>;
|
|
359
|
+
/** Deletes a message. */
|
|
360
|
+
delete(message: Message, options?: {
|
|
361
|
+
signal?: AbortSignal;
|
|
362
|
+
}): Promise<boolean>;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Portable chat threads — the cross-surface conversation store shared by
|
|
366
|
+
* hanzo.chat, hanzo.app, the desktop app, and hanzo-dev. A Chat is a thread
|
|
367
|
+
* keyed by "owner/name"; its turns are ChatMessages.
|
|
368
|
+
*/
|
|
369
|
+
declare class Chats {
|
|
370
|
+
private readonly http;
|
|
371
|
+
readonly messages: ChatMessages;
|
|
372
|
+
constructor(http: HttpClient);
|
|
373
|
+
/** Lists chat threads for a user, optionally filtered by store. */
|
|
374
|
+
list(params?: {
|
|
375
|
+
user?: string;
|
|
376
|
+
store?: string;
|
|
377
|
+
}, options?: {
|
|
378
|
+
signal?: AbortSignal;
|
|
379
|
+
}): Promise<Chat$1[]>;
|
|
380
|
+
/** Fetches a single chat thread by id ("owner/name"). */
|
|
381
|
+
get(id: string, options?: {
|
|
382
|
+
signal?: AbortSignal;
|
|
383
|
+
}): Promise<Chat$1>;
|
|
384
|
+
/** Creates a chat thread. */
|
|
385
|
+
create(chat: Chat$1, options?: {
|
|
386
|
+
signal?: AbortSignal;
|
|
387
|
+
}): Promise<boolean>;
|
|
388
|
+
/** Updates a chat thread; `id` is "owner/name". */
|
|
389
|
+
update(id: string, chat: Chat$1, options?: {
|
|
390
|
+
signal?: AbortSignal;
|
|
391
|
+
}): Promise<boolean>;
|
|
392
|
+
/** Deletes a chat thread (and its messages, server-side). */
|
|
393
|
+
delete(chat: Chat$1, options?: {
|
|
394
|
+
signal?: AbortSignal;
|
|
395
|
+
}): Promise<boolean>;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** Anthropic Messages API (/v1/messages). */
|
|
399
|
+
declare class Messages {
|
|
400
|
+
private readonly http;
|
|
401
|
+
constructor(http: HttpClient);
|
|
402
|
+
/** Non-streaming message. */
|
|
403
|
+
create(params: MessageCreateParams & {
|
|
404
|
+
stream?: false;
|
|
405
|
+
}, options?: {
|
|
406
|
+
signal?: AbortSignal;
|
|
407
|
+
}): Promise<AnthropicMessageResponse>;
|
|
408
|
+
/** Streaming message — yields Anthropic stream events. */
|
|
409
|
+
create(params: MessageCreateParams & {
|
|
410
|
+
stream: true;
|
|
411
|
+
}, options?: {
|
|
412
|
+
signal?: AbortSignal;
|
|
413
|
+
}): Promise<AsyncGenerator<AnthropicStreamEvent, void, unknown>>;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/** Model catalog (/v1/models, OpenAI-compatible). */
|
|
417
|
+
declare class Models {
|
|
418
|
+
private readonly http;
|
|
419
|
+
constructor(http: HttpClient);
|
|
420
|
+
/** Lists available models. */
|
|
421
|
+
list(options?: {
|
|
422
|
+
signal?: AbortSignal;
|
|
423
|
+
}): Promise<Model[]>;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* The Hanzo AI client. Headless: no UI, no React, no DOM dependency beyond
|
|
428
|
+
* the standard `fetch`/`ReadableStream` web APIs.
|
|
429
|
+
*/
|
|
430
|
+
declare class AiClient {
|
|
431
|
+
/** OpenAI-compatible completions: `chat.completions.create(...)`. */
|
|
432
|
+
readonly chat: Chat;
|
|
433
|
+
/** Anthropic Messages API: `messages.create(...)`. */
|
|
434
|
+
readonly messages: Messages;
|
|
435
|
+
/** Model catalog: `models.list()`. */
|
|
436
|
+
readonly models: Models;
|
|
437
|
+
/** Portable chat threads + their messages (cross-surface store). */
|
|
438
|
+
readonly chats: Chats;
|
|
439
|
+
/** Current signed-in account. */
|
|
440
|
+
readonly account: AccountResource;
|
|
441
|
+
/** Shared transport, exposed for advanced/custom calls. */
|
|
442
|
+
readonly http: HttpClient;
|
|
443
|
+
constructor(config?: ClientConfig);
|
|
444
|
+
}
|
|
445
|
+
/** Creates a typed Hanzo AI client. */
|
|
446
|
+
declare function createAiClient(config?: ClientConfig): AiClient;
|
|
447
|
+
|
|
448
|
+
/** Base error for every failure surfaced by the SDK. */
|
|
449
|
+
declare class HanzoAIError extends Error {
|
|
450
|
+
constructor(message: string);
|
|
451
|
+
}
|
|
452
|
+
/** Non-2xx HTTP response, or a CRUD envelope with status "error". */
|
|
453
|
+
declare class APIError extends HanzoAIError {
|
|
454
|
+
readonly status: number;
|
|
455
|
+
readonly body: unknown;
|
|
456
|
+
constructor(message: string, status: number, body?: unknown);
|
|
457
|
+
}
|
|
458
|
+
/** No token was available when a request required authentication. */
|
|
459
|
+
declare class AuthError extends HanzoAIError {
|
|
460
|
+
constructor(message?: string);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/** A single decoded Server-Sent Event. */
|
|
464
|
+
interface SSEvent {
|
|
465
|
+
event?: string;
|
|
466
|
+
data: string;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Parses a byte stream into SSE events. Handles chunk boundaries that split a
|
|
470
|
+
* single event across reads, CRLF or LF line endings, and multi-line `data:`
|
|
471
|
+
* fields per the SSE spec. Comment lines (starting with ":") are ignored.
|
|
472
|
+
*/
|
|
473
|
+
declare function parseSSE(body: ReadableStream<Uint8Array>): AsyncGenerator<SSEvent, void, unknown>;
|
|
474
|
+
/**
|
|
475
|
+
* Yields OpenAI `chat.completion.chunk` objects from a streaming
|
|
476
|
+
* /v1/chat/completions response, stopping at the `[DONE]` sentinel.
|
|
477
|
+
*/
|
|
478
|
+
declare function streamChatCompletion(res: Response): AsyncGenerator<ChatCompletionChunk, void, unknown>;
|
|
479
|
+
/**
|
|
480
|
+
* Yields Anthropic stream events from a streaming /v1/messages response. The
|
|
481
|
+
* event name is carried on `type` (Anthropic also includes it in the JSON, but
|
|
482
|
+
* the SSE `event:` line is authoritative when present).
|
|
483
|
+
*/
|
|
484
|
+
declare function streamMessage(res: Response): AsyncGenerator<AnthropicStreamEvent, void, unknown>;
|
|
485
|
+
|
|
486
|
+
export { APIError, type Account, AccountResource, AiClient, type AnthropicContentBlock, type AnthropicImageBlock, type AnthropicMessage, type AnthropicMessageResponse, type AnthropicStreamEvent, type AnthropicTextBlock, type AnthropicUsage, AuthError, Chat, type ChatCompletion, type ChatCompletionChoice, type ChatCompletionChunk, type ChatCompletionChunkChoice, type ChatCompletionChunkDelta, type ChatCompletionContentPart, type ChatCompletionContentPartImage, type ChatCompletionContentPartText, type ChatCompletionCreateParams, type ChatCompletionMessage, ChatMessages, Chats, type ClientConfig, type CompletionUsage, Completions, type Envelope, type FunctionDefinition, HanzoAIError, HttpClient, type Message, type MessageCreateParams, Messages, type Model, type ModelList, Models, type Role, type SSEvent, type Suggestion, type TokenProvider, type Tool, type ToolCall, type ToolChoice, type VectorScore, createAiClient, joinUrl, parseSSE, streamChatCompletion, streamMessage };
|