@anvia/client 1.5.0 → 1.7.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/README.md +28 -0
- package/dist/durable-chat.d.ts +51 -0
- package/dist/durable-chat.d.ts.map +1 -0
- package/dist/durable-chat.js +933 -0
- package/dist/durable-chat.js.map +1 -0
- package/dist/durable.d.ts +71 -65
- package/dist/durable.d.ts.map +1 -0
- package/dist/durable.js +213 -253
- package/dist/durable.js.map +1 -1
- package/dist/event-transport-CcP1zaST.js +103 -0
- package/dist/event-transport-CcP1zaST.js.map +1 -0
- package/dist/event-transport-rXxwo4BK.d.ts +88 -0
- package/dist/event-transport-rXxwo4BK.d.ts.map +1 -0
- package/dist/index.d.ts +62 -415
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1968 -2382
- package/dist/index.js.map +1 -1
- package/dist/streams-BXxF27Hp.js +156 -0
- package/dist/streams-BXxF27Hp.js.map +1 -0
- package/dist/transport/index.d.ts +2 -91
- package/dist/transport/index.js +3 -23
- package/dist/types-Bt4tUcST.d.ts +348 -0
- package/dist/types-Bt4tUcST.d.ts.map +1 -0
- package/dist/types-CqJxMo_1.js +466 -0
- package/dist/types-CqJxMo_1.js.map +1 -0
- package/package.json +11 -7
- package/dist/chunk-PD72KNCV.js +0 -150
- package/dist/chunk-PD72KNCV.js.map +0 -1
- package/dist/chunk-RK5U6WVJ.js +0 -127
- package/dist/chunk-RK5U6WVJ.js.map +0 -1
- package/dist/transport/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,434 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import { GuardrailDecisionRecord } from '@anvia/core/guardrails';
|
|
6
|
-
import { MemoryCompactionInfo } from '@anvia/core/memory';
|
|
7
|
-
import { CreateFetchEventTransportOptions } from './transport/index.js';
|
|
8
|
-
|
|
9
|
-
declare const CLIENT_STREAM_PROTOCOL: "anvia.client.v3";
|
|
10
|
-
type ClientDataMap = Record<string, JsonValue>;
|
|
11
|
-
type ClientMetadata = JsonObject;
|
|
12
|
-
type ClientDataSchema<T extends JsonValue = JsonValue> = {
|
|
13
|
-
safeParse(value: unknown): {
|
|
14
|
-
success: true;
|
|
15
|
-
data: T;
|
|
16
|
-
} | {
|
|
17
|
-
success: false;
|
|
18
|
-
error?: unknown;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
type ClientDataSchemas<TData extends ClientDataMap> = {
|
|
22
|
-
[Name in keyof TData]: ClientDataSchema<TData[Name]>;
|
|
23
|
-
};
|
|
24
|
-
type ClientMetadataSchema<TMetadata extends JsonObject = JsonObject> = ClientDataSchema<TMetadata>;
|
|
25
|
-
type UIMessageRole = "system" | "user" | "assistant" | "tool";
|
|
26
|
-
type ClientStreamError = {
|
|
27
|
-
name?: string;
|
|
28
|
-
message: string;
|
|
29
|
-
code?: string;
|
|
30
|
-
retryable?: boolean;
|
|
31
|
-
details?: JsonValue;
|
|
32
|
-
};
|
|
33
|
-
type UIError = ClientStreamError;
|
|
34
|
-
type UIMessageGeneration = {
|
|
35
|
-
runId?: string;
|
|
36
|
-
status?: "completed" | "blocked" | "suspended" | "cancelled" | "error";
|
|
37
|
-
usage?: Usage;
|
|
38
|
-
contextUsage?: ContextUsage;
|
|
39
|
-
trace?: {
|
|
40
|
-
observer: string;
|
|
41
|
-
traceId?: string;
|
|
42
|
-
observationId?: string;
|
|
43
|
-
};
|
|
44
|
-
memoryCompaction?: MemoryCompactionInfo;
|
|
45
|
-
};
|
|
46
|
-
type UIMessage<Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap> = Readonly<{
|
|
47
|
-
id: string;
|
|
48
|
-
role: UIMessageRole;
|
|
49
|
-
parts: readonly UIMessagePart<Data>[];
|
|
50
|
-
modelMessageId?: string;
|
|
51
|
-
metadata?: Metadata;
|
|
52
|
-
generation?: UIMessageGeneration;
|
|
53
|
-
}>;
|
|
54
|
-
type UIAttachment = {
|
|
55
|
-
id: string;
|
|
56
|
-
type: "image" | "document" | "file";
|
|
57
|
-
name?: string;
|
|
58
|
-
mediaType?: string;
|
|
59
|
-
url?: string;
|
|
60
|
-
data?: string;
|
|
61
|
-
text?: string;
|
|
62
|
-
detail?: ImageDetail;
|
|
63
|
-
metadata?: JsonValue;
|
|
64
|
-
};
|
|
65
|
-
type CreateUIAttachment = Omit<UIAttachment, "id"> & {
|
|
66
|
-
id?: string;
|
|
67
|
-
};
|
|
68
|
-
type UIDataPart<Data extends ClientDataMap> = {
|
|
69
|
-
[Name in keyof Data & string]: {
|
|
70
|
-
id: string;
|
|
71
|
-
type: "data";
|
|
72
|
-
name: Name;
|
|
73
|
-
data: Data[Name];
|
|
74
|
-
};
|
|
75
|
-
}[keyof Data & string];
|
|
76
|
-
type UIToolMessagePartBase = {
|
|
77
|
-
id: string;
|
|
78
|
-
type: "tool";
|
|
79
|
-
toolName: string;
|
|
80
|
-
toolCallId: string;
|
|
81
|
-
callId?: string;
|
|
82
|
-
internalCallId?: string;
|
|
83
|
-
turn?: number;
|
|
84
|
-
signature?: string;
|
|
85
|
-
};
|
|
86
|
-
type UIToolMessagePart = (UIToolMessagePartBase & {
|
|
87
|
-
state: "input-streaming";
|
|
88
|
-
input: string;
|
|
89
|
-
}) | (UIToolMessagePartBase & {
|
|
90
|
-
state: "input-available";
|
|
91
|
-
input: JsonValue;
|
|
92
|
-
}) | (UIToolMessagePartBase & {
|
|
93
|
-
state: "output-available";
|
|
94
|
-
input: JsonValue;
|
|
95
|
-
output: JsonValue;
|
|
96
|
-
resultContent?: readonly ToolResultContentPart[];
|
|
97
|
-
}) | (UIToolMessagePartBase & {
|
|
98
|
-
state: "error";
|
|
99
|
-
input: JsonValue;
|
|
100
|
-
error: UIError;
|
|
101
|
-
});
|
|
102
|
-
type UIMessagePart<Data extends ClientDataMap = ClientDataMap> = {
|
|
103
|
-
id: string;
|
|
104
|
-
type: "text";
|
|
105
|
-
text: string;
|
|
106
|
-
signature?: string;
|
|
107
|
-
} | {
|
|
108
|
-
id: string;
|
|
109
|
-
type: "reasoning";
|
|
110
|
-
text: string;
|
|
111
|
-
reasoningId?: string;
|
|
112
|
-
content?: readonly ReasoningDetail[];
|
|
113
|
-
} | UIToolMessagePart | {
|
|
114
|
-
id: string;
|
|
115
|
-
type: "source";
|
|
116
|
-
source: CompletionSource;
|
|
117
|
-
} | UIDataPart<Data> | {
|
|
118
|
-
id: string;
|
|
119
|
-
type: "attachment";
|
|
120
|
-
attachment: UIAttachment;
|
|
121
|
-
} | {
|
|
122
|
-
id: string;
|
|
123
|
-
type: "error";
|
|
124
|
-
error: UIError;
|
|
125
|
-
};
|
|
126
|
-
type ClientStreamCursor = {
|
|
127
|
-
streamId: string;
|
|
128
|
-
after: number;
|
|
129
|
-
};
|
|
130
|
-
type ClientStreamRequest<Metadata extends JsonObject = JsonObject> = {
|
|
131
|
-
type: "messages";
|
|
132
|
-
messages: readonly Message[];
|
|
133
|
-
metadata?: Metadata;
|
|
134
|
-
resume?: ClientStreamCursor;
|
|
135
|
-
} | {
|
|
136
|
-
type: "interaction_response";
|
|
137
|
-
interactionId: string;
|
|
138
|
-
response: AgentInteractionResponse;
|
|
139
|
-
metadata?: Metadata;
|
|
140
|
-
resume?: ClientStreamCursor;
|
|
141
|
-
};
|
|
142
|
-
type ClientCompletionRequest<Metadata extends JsonObject = JsonObject> = {
|
|
143
|
-
prompt: string;
|
|
144
|
-
metadata?: Metadata;
|
|
145
|
-
};
|
|
146
|
-
type ClientStreamScope = {
|
|
147
|
-
agentId?: string;
|
|
148
|
-
agentName?: string;
|
|
149
|
-
parentRunId?: string;
|
|
150
|
-
parentToolName?: string;
|
|
151
|
-
parentToolCallId?: string;
|
|
152
|
-
parentInternalToolCallId?: string;
|
|
153
|
-
};
|
|
154
|
-
type ClientInteraction = Readonly<{
|
|
155
|
-
request: AgentInteractionRequest;
|
|
156
|
-
runId: string;
|
|
157
|
-
status: "pending" | "responded" | "cancelled";
|
|
158
|
-
}>;
|
|
159
|
-
type ClientStreamEventBase = {
|
|
160
|
-
runId: string;
|
|
161
|
-
turn?: number;
|
|
162
|
-
scope?: ClientStreamScope;
|
|
163
|
-
};
|
|
164
|
-
type ClientDataEvent<TData extends ClientDataMap> = {
|
|
165
|
-
[Name in keyof TData & string]: {
|
|
166
|
-
type: "data";
|
|
167
|
-
name: Name;
|
|
168
|
-
data: TData[Name];
|
|
169
|
-
transient?: boolean;
|
|
170
|
-
};
|
|
171
|
-
}[keyof TData & string];
|
|
172
|
-
type ClientStandardStreamEvent<Metadata extends JsonObject, Data extends ClientDataMap> = {
|
|
173
|
-
type: "run_start";
|
|
174
|
-
source: "completion" | "agent";
|
|
175
|
-
metadata?: Metadata;
|
|
176
|
-
} | {
|
|
177
|
-
type: "turn_start";
|
|
178
|
-
} | {
|
|
179
|
-
type: "generation_start";
|
|
180
|
-
model?: {
|
|
181
|
-
provider: string;
|
|
182
|
-
modelId: string;
|
|
183
|
-
};
|
|
184
|
-
} | {
|
|
185
|
-
type: "message_start";
|
|
186
|
-
messageId: string;
|
|
187
|
-
role: "assistant";
|
|
188
|
-
metadata?: Metadata;
|
|
189
|
-
} | {
|
|
190
|
-
type: "text_start";
|
|
191
|
-
messageId: string;
|
|
192
|
-
partId: string;
|
|
193
|
-
} | {
|
|
194
|
-
type: "text_delta";
|
|
195
|
-
messageId: string;
|
|
196
|
-
partId: string;
|
|
197
|
-
delta: string;
|
|
198
|
-
} | {
|
|
199
|
-
type: "text_end";
|
|
200
|
-
messageId: string;
|
|
201
|
-
partId: string;
|
|
202
|
-
text?: string;
|
|
203
|
-
signature?: string;
|
|
204
|
-
} | {
|
|
205
|
-
type: "reasoning_start";
|
|
206
|
-
messageId: string;
|
|
207
|
-
partId: string;
|
|
208
|
-
reasoningId?: string;
|
|
209
|
-
} | {
|
|
210
|
-
type: "reasoning_delta";
|
|
211
|
-
messageId: string;
|
|
212
|
-
partId: string;
|
|
213
|
-
delta: string;
|
|
214
|
-
contentType?: ReasoningContentType;
|
|
215
|
-
signature?: string;
|
|
216
|
-
} | {
|
|
217
|
-
type: "reasoning_end";
|
|
218
|
-
messageId: string;
|
|
219
|
-
partId: string;
|
|
220
|
-
text?: string;
|
|
221
|
-
content?: readonly ReasoningDetail[];
|
|
222
|
-
} | {
|
|
223
|
-
type: "tool_call_start";
|
|
224
|
-
messageId: string;
|
|
225
|
-
partId: string;
|
|
226
|
-
toolCallId: string;
|
|
227
|
-
callId?: string;
|
|
228
|
-
toolName?: string;
|
|
229
|
-
} | {
|
|
230
|
-
type: "tool_call_delta";
|
|
231
|
-
messageId: string;
|
|
232
|
-
partId: string;
|
|
233
|
-
toolCallId: string;
|
|
234
|
-
callId?: string;
|
|
235
|
-
toolName?: string;
|
|
236
|
-
delta: string;
|
|
237
|
-
mode: "append" | "replace";
|
|
238
|
-
signature?: string;
|
|
239
|
-
} | {
|
|
240
|
-
type: "tool_call_end";
|
|
241
|
-
messageId: string;
|
|
242
|
-
partId: string;
|
|
243
|
-
toolCallId: string;
|
|
244
|
-
callId?: string;
|
|
245
|
-
toolName: string;
|
|
246
|
-
input: JsonValue;
|
|
247
|
-
signature?: string;
|
|
248
|
-
} | {
|
|
249
|
-
type: "tool_result";
|
|
250
|
-
messageId: string;
|
|
251
|
-
partId: string;
|
|
252
|
-
toolCallId: string;
|
|
253
|
-
callId?: string;
|
|
254
|
-
internalCallId?: string;
|
|
255
|
-
toolName: string;
|
|
256
|
-
input: JsonValue;
|
|
257
|
-
result: {
|
|
258
|
-
status: "success";
|
|
259
|
-
output: JsonValue;
|
|
260
|
-
content?: readonly ToolResultContentPart[];
|
|
261
|
-
} | {
|
|
262
|
-
status: "error";
|
|
263
|
-
error: ClientStreamError;
|
|
264
|
-
};
|
|
265
|
-
} | {
|
|
266
|
-
type: "source";
|
|
267
|
-
messageId: string;
|
|
268
|
-
partId: string;
|
|
269
|
-
source: CompletionSource;
|
|
270
|
-
} | {
|
|
271
|
-
type: "attachment";
|
|
272
|
-
messageId: string;
|
|
273
|
-
partId: string;
|
|
274
|
-
attachment: UIAttachment;
|
|
275
|
-
} | {
|
|
276
|
-
type: "provider_tool_call";
|
|
277
|
-
toolCall: ProviderToolCall;
|
|
278
|
-
} | {
|
|
279
|
-
type: "interaction";
|
|
280
|
-
interaction: AgentInteractionRequest;
|
|
281
|
-
} | {
|
|
282
|
-
type: "guardrail_decision";
|
|
283
|
-
decision: GuardrailDecisionRecord;
|
|
284
|
-
} | ({
|
|
285
|
-
type: "memory_compaction";
|
|
286
|
-
} & MemoryCompactionInfo) | {
|
|
287
|
-
type: "message_end";
|
|
288
|
-
messageId: string;
|
|
289
|
-
modelMessageId?: string;
|
|
290
|
-
/** Authoritative model-authored parts after provider normalization and guardrails. */
|
|
291
|
-
parts?: readonly UIMessagePart<Data>[];
|
|
292
|
-
usage?: Usage;
|
|
293
|
-
contextUsage?: ContextUsage;
|
|
294
|
-
metadata?: Metadata;
|
|
295
|
-
} | {
|
|
296
|
-
type: "turn_end";
|
|
297
|
-
usage?: Usage;
|
|
298
|
-
contextUsage?: ContextUsage;
|
|
299
|
-
firstDeltaMs?: number;
|
|
300
|
-
} | {
|
|
301
|
-
type: "run_end";
|
|
302
|
-
status: "completed" | "blocked" | "suspended" | "cancelled" | "error";
|
|
303
|
-
text?: string;
|
|
304
|
-
output?: JsonValue;
|
|
305
|
-
usage?: Usage;
|
|
306
|
-
contextUsage?: ContextUsage;
|
|
307
|
-
trace?: {
|
|
308
|
-
observer: string;
|
|
309
|
-
traceId?: string;
|
|
310
|
-
observationId?: string;
|
|
311
|
-
};
|
|
312
|
-
memoryCompaction?: MemoryCompactionInfo;
|
|
313
|
-
metadata?: Metadata;
|
|
314
|
-
} | {
|
|
315
|
-
type: "error";
|
|
316
|
-
error: ClientStreamError;
|
|
317
|
-
usage?: Usage;
|
|
318
|
-
};
|
|
319
|
-
type ClientStreamEvent<Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap> = ClientStreamEventBase & (ClientStandardStreamEvent<Metadata, Data> | ClientDataEvent<Data>);
|
|
320
|
-
type ClientStream<Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap> = AsyncIterable<ClientStreamEvent<Metadata, Data>>;
|
|
321
|
-
type ClientStreamFrame<Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap> = {
|
|
322
|
-
type: "stream_start";
|
|
323
|
-
protocol: typeof CLIENT_STREAM_PROTOCOL;
|
|
324
|
-
streamId: string;
|
|
325
|
-
eventId: 0;
|
|
326
|
-
resumable: boolean;
|
|
327
|
-
} | {
|
|
328
|
-
type: "stream_event";
|
|
329
|
-
streamId: string;
|
|
330
|
-
eventId: number;
|
|
331
|
-
event: ClientStreamEvent<Metadata, Data>;
|
|
332
|
-
} | {
|
|
333
|
-
type: "stream_end";
|
|
334
|
-
streamId: string;
|
|
335
|
-
eventId: number;
|
|
336
|
-
status: "completed" | "error" | "missing";
|
|
337
|
-
};
|
|
338
|
-
type ClientTransportSendOptions<TRequest> = {
|
|
339
|
-
request: TRequest;
|
|
340
|
-
abortSignal?: AbortSignal;
|
|
341
|
-
headers?: HeadersInit;
|
|
342
|
-
resume?: ClientStreamCursor;
|
|
343
|
-
};
|
|
344
|
-
type ClientTransport<TRequest = ClientStreamRequest, Data extends ClientDataMap = ClientDataMap, Metadata extends JsonObject = JsonObject> = {
|
|
345
|
-
readonly _types?: {
|
|
346
|
-
metadata: Metadata;
|
|
347
|
-
data: Data;
|
|
348
|
-
};
|
|
349
|
-
send(options: ClientTransportSendOptions<TRequest>): AsyncIterable<ClientStreamFrame<Metadata, Data>>;
|
|
350
|
-
};
|
|
351
|
-
type ClientErrorMapper = (error: unknown) => ClientStreamError;
|
|
352
|
-
type ClientOutputMapper = (output: unknown) => JsonValue | undefined;
|
|
353
|
-
|
|
1
|
+
import { C as UIMessage, D as UIToolMessagePart, E as UIMessageRole, S as UIError, T as UIMessagePart, _ as ClientStreamScope, a as ClientDataSchemas, b as CreateUIAttachment, c as ClientMetadata, d as ClientStream, f as ClientStreamCursor, g as ClientStreamRequest, h as ClientStreamFrame, i as ClientDataSchema, l as ClientMetadataSchema, m as ClientStreamEvent, n as ClientCompletionRequest, o as ClientErrorMapper, p as ClientStreamError, r as ClientDataMap, s as ClientInteraction, t as CLIENT_STREAM_PROTOCOL, u as ClientOutputMapper, v as ClientTransport, w as UIMessageGeneration, x as UIAttachment, y as ClientTransportSendOptions } from "./types-Bt4tUcST.js";
|
|
2
|
+
import { t as CreateFetchEventTransportOptions } from "./event-transport-rXxwo4BK.js";
|
|
3
|
+
import { CompletionStreamEvent, JsonObject, Message, isJsonValue } from "@anvia/core/completion";
|
|
4
|
+
import { AgentStreamEvent } from "@anvia/core/agent";
|
|
354
5
|
type ClientStreamAdapterOptions<Metadata extends JsonObject = JsonObject> = {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
6
|
+
/** Stable correlation ID for this client-visible run. */
|
|
7
|
+
runId?: string;
|
|
8
|
+
metadata?: Metadata;
|
|
9
|
+
mapError?: ClientErrorMapper;
|
|
10
|
+
mapOutput?: ClientOutputMapper;
|
|
360
11
|
};
|
|
361
12
|
type CompletionClientStreamOptions<Metadata extends JsonObject = JsonObject> = ClientStreamAdapterOptions<Metadata> & {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
13
|
+
model?: {
|
|
14
|
+
provider: string;
|
|
15
|
+
modelId: string;
|
|
16
|
+
};
|
|
366
17
|
};
|
|
367
18
|
type AgentClientStreamContext = {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
19
|
+
runId: string;
|
|
20
|
+
turn?: number;
|
|
21
|
+
scope?: ClientStreamScope;
|
|
371
22
|
};
|
|
372
23
|
type AgentClientStreamOptions<CustomEvent = unknown, Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap> = ClientStreamAdapterOptions<Metadata> & {
|
|
373
|
-
|
|
24
|
+
mapCustomEvent?: (event: CustomEvent, context: AgentClientStreamContext) => ClientStreamEvent<Metadata, Data> | readonly ClientStreamEvent<Metadata, Data>[] | undefined;
|
|
374
25
|
};
|
|
375
|
-
declare function completionToClientStream<Output = string, RawResponse = unknown, Metadata extends JsonObject = JsonObject>(options: CompletionClientStreamOptions<Metadata> & {
|
|
376
|
-
|
|
26
|
+
export declare function completionToClientStream<Output = string, RawResponse = unknown, Metadata extends JsonObject = JsonObject>(options: CompletionClientStreamOptions<Metadata> & {
|
|
27
|
+
events: AsyncIterable<CompletionStreamEvent<Output, RawResponse>>;
|
|
377
28
|
}): ClientStream<Metadata>;
|
|
378
|
-
declare function agentToClientStream<Output = string, RawResponse = unknown, Metadata extends JsonObject = JsonObject>(options: AgentClientStreamOptions<unknown, Metadata> & {
|
|
379
|
-
|
|
29
|
+
export declare function agentToClientStream<Output = string, RawResponse = unknown, Metadata extends JsonObject = JsonObject>(options: AgentClientStreamOptions<unknown, Metadata> & {
|
|
30
|
+
events: AsyncIterable<AgentStreamEvent<Output, RawResponse>>;
|
|
380
31
|
}): ClientStream<Metadata>;
|
|
381
|
-
declare function customAgentEventsToClientStream<CustomEvent, Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap>(options: AgentClientStreamOptions<CustomEvent, Metadata, Data> & {
|
|
382
|
-
|
|
383
|
-
|
|
32
|
+
export declare function customAgentEventsToClientStream<CustomEvent, Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap>(options: AgentClientStreamOptions<CustomEvent, Metadata, Data> & {
|
|
33
|
+
events: AsyncIterable<AgentStreamEvent<unknown, unknown> | CustomEvent>;
|
|
34
|
+
mapCustomEvent: NonNullable<AgentClientStreamOptions<CustomEvent, Metadata, Data>["mapCustomEvent"]>;
|
|
384
35
|
}): ClientStream<Metadata, Data>;
|
|
385
|
-
|
|
386
36
|
type CreateHttpClientTransportOptions<TRequest = ClientStreamRequest, Data extends ClientDataMap = ClientDataMap, Metadata extends JsonObject = JsonObject> = Omit<CreateFetchEventTransportOptions<TRequest, ClientStreamFrame<Metadata, Data>>, "mapEvent" | "validateResponse"> & {
|
|
387
|
-
|
|
388
|
-
|
|
37
|
+
metadataSchema?: ClientMetadataSchema<Metadata>;
|
|
38
|
+
dataSchemas?: ClientDataSchemas<Data>;
|
|
389
39
|
};
|
|
390
|
-
declare function createHttpClientTransport<TRequest = ClientStreamRequest, Data extends ClientDataMap = ClientDataMap, Metadata extends JsonObject = JsonObject>(options: CreateHttpClientTransportOptions<TRequest, Data, Metadata>): ClientTransport<TRequest, Data, Metadata>;
|
|
40
|
+
export declare function createHttpClientTransport<TRequest = ClientStreamRequest, Data extends ClientDataMap = ClientDataMap, Metadata extends JsonObject = JsonObject>(options: CreateHttpClientTransportOptions<TRequest, Data, Metadata>): ClientTransport<TRequest, Data, Metadata>;
|
|
391
41
|
type CreateDirectClientTransportOptions<TRequest, Data extends ClientDataMap, Metadata extends JsonObject> = {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
};
|
|
400
|
-
declare function createDirectClientTransport<TRequest = ClientStreamRequest, Data extends ClientDataMap = ClientDataMap, Metadata extends JsonObject = JsonObject>(options: CreateDirectClientTransportOptions<TRequest, Data, Metadata>): ClientTransport<TRequest, Data, Metadata>;
|
|
401
|
-
|
|
402
|
-
declare function
|
|
403
|
-
declare function
|
|
404
|
-
declare
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
readonly value?: unknown | undefined;
|
|
408
|
-
constructor(message: string, value?: unknown | undefined);
|
|
42
|
+
handler(options: {
|
|
43
|
+
request: TRequest;
|
|
44
|
+
abortSignal?: AbortSignal;
|
|
45
|
+
headers?: HeadersInit;
|
|
46
|
+
}): ClientStream<Metadata, Data> | Promise<ClientStream<Metadata, Data>>;
|
|
47
|
+
metadataSchema?: ClientMetadataSchema<Metadata>;
|
|
48
|
+
dataSchemas?: ClientDataSchemas<Data>;
|
|
49
|
+
};
|
|
50
|
+
export declare function createDirectClientTransport<TRequest = ClientStreamRequest, Data extends ClientDataMap = ClientDataMap, Metadata extends JsonObject = JsonObject>(options: CreateDirectClientTransportOptions<TRequest, Data, Metadata>): ClientTransport<TRequest, Data, Metadata>;
|
|
51
|
+
export declare function uiMessagesToMessages<Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap>(messages: readonly UIMessage<Metadata, Data>[]): Message<Metadata>[];
|
|
52
|
+
export declare function messagesToUIMessages<Metadata extends JsonObject = JsonObject>(messages: readonly Message<Metadata>[]): UIMessage<Metadata>[];
|
|
53
|
+
export declare function createClientId(prefix: string): string;
|
|
54
|
+
export declare class ClientProtocolError extends Error {
|
|
55
|
+
readonly value?: unknown | undefined;
|
|
56
|
+
constructor(message: string, value?: unknown | undefined);
|
|
409
57
|
}
|
|
410
|
-
declare function parseUIMessage<Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap>(value: unknown, options?: {
|
|
411
|
-
|
|
412
|
-
|
|
58
|
+
export declare function parseUIMessage<Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap>(value: unknown, options?: {
|
|
59
|
+
metadataSchema?: ClientMetadataSchema<Metadata>;
|
|
60
|
+
dataSchemas?: ClientDataSchemas<Data>;
|
|
413
61
|
}): UIMessage<Metadata, Data>;
|
|
414
|
-
declare function parseUIMessages<Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap>(value: unknown, options?: {
|
|
415
|
-
|
|
416
|
-
|
|
62
|
+
export declare function parseUIMessages<Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap>(value: unknown, options?: {
|
|
63
|
+
metadataSchema?: ClientMetadataSchema<Metadata>;
|
|
64
|
+
dataSchemas?: ClientDataSchemas<Data>;
|
|
417
65
|
}): UIMessage<Metadata, Data>[];
|
|
418
|
-
declare function parseClientStreamRequest(value: unknown): ClientStreamRequest;
|
|
419
|
-
declare function parseClientStreamEvent<Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap>(value: unknown, options?: {
|
|
420
|
-
|
|
421
|
-
|
|
66
|
+
export declare function parseClientStreamRequest(value: unknown): ClientStreamRequest;
|
|
67
|
+
export declare function parseClientStreamEvent<Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap>(value: unknown, options?: {
|
|
68
|
+
metadataSchema?: ClientMetadataSchema<Metadata>;
|
|
69
|
+
dataSchemas?: ClientDataSchemas<Data>;
|
|
422
70
|
}): ClientStreamEvent<Metadata, Data>;
|
|
423
|
-
declare function parseClientStreamFrame<Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap>(value: unknown, options?: {
|
|
424
|
-
|
|
425
|
-
|
|
71
|
+
export declare function parseClientStreamFrame<Metadata extends JsonObject = JsonObject, Data extends ClientDataMap = ClientDataMap>(value: unknown, options?: {
|
|
72
|
+
metadataSchema?: ClientMetadataSchema<Metadata>;
|
|
73
|
+
dataSchemas?: ClientDataSchemas<Data>;
|
|
426
74
|
}): ClientStreamFrame<Metadata, Data>;
|
|
427
|
-
declare function maskedClientError(): ClientStreamError;
|
|
428
|
-
declare function normalizeClientError(value: unknown): Error;
|
|
429
|
-
|
|
430
|
-
declare function
|
|
431
|
-
declare function
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
export { type AgentClientStreamContext, type AgentClientStreamOptions, CLIENT_STREAM_PROTOCOL, type ClientCompletionRequest, type ClientDataMap, type ClientDataSchema, type ClientDataSchemas, type ClientErrorMapper, type ClientInteraction, type ClientMetadata, type ClientMetadataSchema, type ClientOutputMapper, ClientProtocolError, type ClientStream, type ClientStreamAdapterOptions, type ClientStreamCursor, type ClientStreamError, type ClientStreamEvent, type ClientStreamFrame, type ClientStreamRequest, type ClientStreamScope, type ClientTransport, type ClientTransportSendOptions, type CompletionClientStreamOptions, type CreateDirectClientTransportOptions, type CreateHttpClientTransportOptions, type CreateUIAttachment, type UIAttachment, type UIError, type UIMessage, type UIMessageGeneration, type UIMessagePart, type UIMessageRole, type UIToolMessagePart, agentToClientStream, applyClientStreamEvent, assistantText, completionToClientStream, createClientId, createDirectClientTransport, createHttpClientTransport, customAgentEventsToClientStream, maskedClientError, messageText, messagesToUIMessages, normalizeClientError, parseClientStreamEvent, parseClientStreamFrame, parseClientStreamRequest, parseUIMessage, parseUIMessages, uiMessagesToMessages };
|
|
75
|
+
export declare function maskedClientError(): ClientStreamError;
|
|
76
|
+
export declare function normalizeClientError(value: unknown): Error;
|
|
77
|
+
export declare function applyClientStreamEvent<Metadata extends JsonObject, Data extends ClientDataMap>(messages: readonly UIMessage<Metadata, Data>[], event: ClientStreamEvent<Metadata, Data>): readonly UIMessage<Metadata, Data>[];
|
|
78
|
+
export declare function messageText<Metadata extends JsonObject, Data extends ClientDataMap>(message: UIMessage<Metadata, Data>): string;
|
|
79
|
+
export declare function assistantText<Metadata extends JsonObject, Data extends ClientDataMap>(messages: readonly UIMessage<Metadata, Data>[]): string;
|
|
80
|
+
export { type AgentClientStreamContext, type AgentClientStreamOptions, CLIENT_STREAM_PROTOCOL, type ClientCompletionRequest, type ClientDataMap, type ClientDataSchema, type ClientDataSchemas, type ClientErrorMapper, type ClientInteraction, type ClientMetadata, type ClientMetadataSchema, type ClientOutputMapper, type ClientStream, type ClientStreamAdapterOptions, type ClientStreamCursor, type ClientStreamError, type ClientStreamEvent, type ClientStreamFrame, type ClientStreamRequest, type ClientStreamScope, type ClientTransport, type ClientTransportSendOptions, type CompletionClientStreamOptions, type CreateDirectClientTransportOptions, type CreateHttpClientTransportOptions, type CreateUIAttachment, type UIAttachment, type UIError, type UIMessage, type UIMessageGeneration, type UIMessagePart, type UIMessageRole, type UIToolMessagePart, isJsonValue };
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/adapters.ts","../src/client-transport.ts","../src/messages.ts","../src/protocol.ts","../src/reducer.ts"],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