veryfront 0.1.193 → 0.1.195

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/esm/deno.d.ts CHANGED
@@ -11,6 +11,7 @@ declare namespace _default {
11
11
  "./context": string;
12
12
  "./fonts": string;
13
13
  "./chat": string;
14
+ "./chat/ag-ui": string;
14
15
  "./chat/protocol": string;
15
16
  "./markdown": string;
16
17
  "./mdx": string;
@@ -41,6 +42,7 @@ declare namespace _default {
41
42
  "veryfront/context": string;
42
43
  "veryfront/fonts": string;
43
44
  "veryfront/chat": string;
45
+ "veryfront/chat/ag-ui": string;
44
46
  "veryfront/chat/protocol": string;
45
47
  "veryfront/markdown": string;
46
48
  "veryfront/mdx": string;
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.193",
3
+ "version": "0.1.195",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "exclude": [
@@ -21,6 +21,7 @@ export default {
21
21
  "./context": "./src/react/context/index.tsx",
22
22
  "./fonts": "./src/react/fonts/index.ts",
23
23
  "./chat": "./src/chat/index.ts",
24
+ "./chat/ag-ui": "./src/chat/ag-ui.ts",
24
25
  "./chat/protocol": "./src/chat/protocol.ts",
25
26
  "./markdown": "./src/markdown/index.ts",
26
27
  "./mdx": "./src/mdx/index.ts",
@@ -51,6 +52,7 @@ export default {
51
52
  "veryfront/context": "./src/react/runtime/core.ts",
52
53
  "veryfront/fonts": "./src/react/fonts/index.ts",
53
54
  "veryfront/chat": "./src/chat/index.ts",
55
+ "veryfront/chat/ag-ui": "./src/chat/ag-ui.ts",
54
56
  "veryfront/chat/protocol": "./src/chat/protocol.ts",
55
57
  "veryfront/markdown": "./src/markdown/index.ts",
56
58
  "veryfront/mdx": "./src/mdx/index.ts",
@@ -0,0 +1,307 @@
1
+ import "../../_dnt.polyfills.js";
2
+ import type { ChatStreamEvent } from "./protocol.js";
3
+ import { z } from "zod";
4
+ type ToolCallState = {
5
+ toolName: string;
6
+ argsText: string;
7
+ };
8
+ export type ParsedSseEvent = {
9
+ id: number | null;
10
+ event: string | null;
11
+ data: string;
12
+ };
13
+ export type AgUiDecodedEvent = {
14
+ eventId: number | null;
15
+ wireEvent: AgUiWireEvent;
16
+ chatEvents: ChatStreamEvent[];
17
+ };
18
+ export type AgUiDecodedChunk = {
19
+ events: AgUiDecodedEvent[];
20
+ remainder: string;
21
+ };
22
+ export type AgUiChatEventDecoderState = {
23
+ remainder: string;
24
+ lastEventId: number;
25
+ toolCalls: Map<string, ToolCallState>;
26
+ reasoningFallbackIndex: number;
27
+ activeFallbackReasoningPartId: string | null;
28
+ };
29
+ export declare const AgUiRunFinishedMetadataSchema: z.ZodObject<{
30
+ provider: z.ZodOptional<z.ZodString>;
31
+ model: z.ZodOptional<z.ZodString>;
32
+ inputTokens: z.ZodOptional<z.ZodNumber>;
33
+ outputTokens: z.ZodOptional<z.ZodNumber>;
34
+ totalTokens: z.ZodOptional<z.ZodNumber>;
35
+ cachedInputTokens: z.ZodOptional<z.ZodNumber>;
36
+ reasoningTokens: z.ZodOptional<z.ZodNumber>;
37
+ finishReason: z.ZodOptional<z.ZodString>;
38
+ providerRequestId: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strip>;
40
+ export declare const AgUiSnapshotToolCallSchema: z.ZodObject<{
41
+ id: z.ZodString;
42
+ type: z.ZodLiteral<"function">;
43
+ function: z.ZodObject<{
44
+ name: z.ZodString;
45
+ arguments: z.ZodString;
46
+ }, z.core.$strip>;
47
+ encryptedValue: z.ZodOptional<z.ZodString>;
48
+ }, z.core.$strip>;
49
+ export declare const AgUiSnapshotMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
50
+ id: z.ZodString;
51
+ role: z.ZodLiteral<"assistant">;
52
+ content: z.ZodOptional<z.ZodString>;
53
+ name: z.ZodOptional<z.ZodString>;
54
+ encryptedValue: z.ZodOptional<z.ZodString>;
55
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
56
+ id: z.ZodString;
57
+ type: z.ZodLiteral<"function">;
58
+ function: z.ZodObject<{
59
+ name: z.ZodString;
60
+ arguments: z.ZodString;
61
+ }, z.core.$strip>;
62
+ encryptedValue: z.ZodOptional<z.ZodString>;
63
+ }, z.core.$strip>>>;
64
+ }, z.core.$strip>, z.ZodObject<{
65
+ id: z.ZodString;
66
+ role: z.ZodLiteral<"user">;
67
+ content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
68
+ type: z.ZodLiteral<"text">;
69
+ text: z.ZodString;
70
+ }, z.core.$strip>, z.ZodObject<{
71
+ type: z.ZodLiteral<"binary">;
72
+ mimeType: z.ZodString;
73
+ id: z.ZodOptional<z.ZodString>;
74
+ url: z.ZodOptional<z.ZodString>;
75
+ data: z.ZodOptional<z.ZodString>;
76
+ filename: z.ZodOptional<z.ZodString>;
77
+ }, z.core.$strip>], "type">>]>;
78
+ name: z.ZodOptional<z.ZodString>;
79
+ encryptedValue: z.ZodOptional<z.ZodString>;
80
+ }, z.core.$strip>, z.ZodObject<{
81
+ id: z.ZodString;
82
+ role: z.ZodLiteral<"tool">;
83
+ toolCallId: z.ZodString;
84
+ content: z.ZodString;
85
+ error: z.ZodOptional<z.ZodString>;
86
+ encryptedValue: z.ZodOptional<z.ZodString>;
87
+ }, z.core.$strip>, z.ZodObject<{
88
+ id: z.ZodString;
89
+ role: z.ZodLiteral<"reasoning">;
90
+ content: z.ZodString;
91
+ name: z.ZodOptional<z.ZodString>;
92
+ encryptedValue: z.ZodOptional<z.ZodString>;
93
+ }, z.core.$strip>], "role">;
94
+ export declare const AgUiWireEventNameSchema: z.ZodEnum<{
95
+ ToolCallArgs: "ToolCallArgs";
96
+ ToolCallEnd: "ToolCallEnd";
97
+ ToolCallResult: "ToolCallResult";
98
+ Custom: "Custom";
99
+ ReasoningMessageStart: "ReasoningMessageStart";
100
+ ReasoningMessageContent: "ReasoningMessageContent";
101
+ ReasoningMessageEnd: "ReasoningMessageEnd";
102
+ TextMessageStart: "TextMessageStart";
103
+ TextMessageContent: "TextMessageContent";
104
+ TextMessageEnd: "TextMessageEnd";
105
+ ToolCallStart: "ToolCallStart";
106
+ RunError: "RunError";
107
+ RunFinished: "RunFinished";
108
+ RunStarted: "RunStarted";
109
+ StateSnapshot: "StateSnapshot";
110
+ MessagesSnapshot: "MessagesSnapshot";
111
+ ToolCallChunk: "ToolCallChunk";
112
+ StateDelta: "StateDelta";
113
+ }>;
114
+ export declare const AgUiWireEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
115
+ eventName: z.ZodLiteral<"RunStarted">;
116
+ payload: z.ZodObject<{
117
+ runId: z.ZodOptional<z.ZodString>;
118
+ threadId: z.ZodOptional<z.ZodString>;
119
+ agentId: z.ZodOptional<z.ZodString>;
120
+ }, z.core.$strip>;
121
+ }, z.core.$strip>, z.ZodObject<{
122
+ eventName: z.ZodLiteral<"Custom">;
123
+ payload: z.ZodObject<{
124
+ name: z.ZodString;
125
+ value: z.ZodUnknown;
126
+ }, z.core.$strip>;
127
+ }, z.core.$strip>, z.ZodObject<{
128
+ eventName: z.ZodLiteral<"TextMessageStart">;
129
+ payload: z.ZodObject<{
130
+ messageId: z.ZodString;
131
+ id: z.ZodOptional<z.ZodString>;
132
+ contentId: z.ZodOptional<z.ZodString>;
133
+ role: z.ZodOptional<z.ZodString>;
134
+ }, z.core.$strip>;
135
+ }, z.core.$strip>, z.ZodObject<{
136
+ eventName: z.ZodLiteral<"TextMessageContent">;
137
+ payload: z.ZodObject<{
138
+ messageId: z.ZodString;
139
+ id: z.ZodOptional<z.ZodString>;
140
+ contentId: z.ZodOptional<z.ZodString>;
141
+ delta: z.ZodString;
142
+ }, z.core.$strip>;
143
+ }, z.core.$strip>, z.ZodObject<{
144
+ eventName: z.ZodLiteral<"TextMessageEnd">;
145
+ payload: z.ZodObject<{
146
+ messageId: z.ZodString;
147
+ id: z.ZodOptional<z.ZodString>;
148
+ contentId: z.ZodOptional<z.ZodString>;
149
+ }, z.core.$strip>;
150
+ }, z.core.$strip>, z.ZodObject<{
151
+ eventName: z.ZodLiteral<"ToolCallStart">;
152
+ payload: z.ZodObject<{
153
+ toolCallId: z.ZodString;
154
+ toolCallName: z.ZodString;
155
+ }, z.core.$strip>;
156
+ }, z.core.$strip>, z.ZodObject<{
157
+ eventName: z.ZodLiteral<"ToolCallArgs">;
158
+ payload: z.ZodObject<{
159
+ toolCallId: z.ZodString;
160
+ delta: z.ZodString;
161
+ }, z.core.$strip>;
162
+ }, z.core.$strip>, z.ZodObject<{
163
+ eventName: z.ZodLiteral<"ToolCallChunk">;
164
+ payload: z.ZodObject<{
165
+ toolCallId: z.ZodString;
166
+ delta: z.ZodString;
167
+ }, z.core.$strip>;
168
+ }, z.core.$strip>, z.ZodObject<{
169
+ eventName: z.ZodLiteral<"ToolCallEnd">;
170
+ payload: z.ZodObject<{
171
+ toolCallId: z.ZodString;
172
+ }, z.core.$strip>;
173
+ }, z.core.$strip>, z.ZodObject<{
174
+ eventName: z.ZodLiteral<"ToolCallResult">;
175
+ payload: z.ZodObject<{
176
+ messageId: z.ZodOptional<z.ZodString>;
177
+ toolCallId: z.ZodString;
178
+ content: z.ZodOptional<z.ZodUnknown>;
179
+ result: z.ZodOptional<z.ZodUnknown>;
180
+ role: z.ZodOptional<z.ZodLiteral<"tool">>;
181
+ isError: z.ZodOptional<z.ZodBoolean>;
182
+ }, z.core.$strip>;
183
+ }, z.core.$strip>, z.ZodObject<{
184
+ eventName: z.ZodLiteral<"StateSnapshot">;
185
+ payload: z.ZodObject<{
186
+ snapshot: z.ZodRecord<z.ZodString, z.ZodUnknown>;
187
+ }, z.core.$strip>;
188
+ }, z.core.$strip>, z.ZodObject<{
189
+ eventName: z.ZodLiteral<"MessagesSnapshot">;
190
+ payload: z.ZodObject<{
191
+ messages: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
192
+ id: z.ZodString;
193
+ role: z.ZodLiteral<"assistant">;
194
+ content: z.ZodOptional<z.ZodString>;
195
+ name: z.ZodOptional<z.ZodString>;
196
+ encryptedValue: z.ZodOptional<z.ZodString>;
197
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
198
+ id: z.ZodString;
199
+ type: z.ZodLiteral<"function">;
200
+ function: z.ZodObject<{
201
+ name: z.ZodString;
202
+ arguments: z.ZodString;
203
+ }, z.core.$strip>;
204
+ encryptedValue: z.ZodOptional<z.ZodString>;
205
+ }, z.core.$strip>>>;
206
+ }, z.core.$strip>, z.ZodObject<{
207
+ id: z.ZodString;
208
+ role: z.ZodLiteral<"user">;
209
+ content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
210
+ type: z.ZodLiteral<"text">;
211
+ text: z.ZodString;
212
+ }, z.core.$strip>, z.ZodObject<{
213
+ type: z.ZodLiteral<"binary">;
214
+ mimeType: z.ZodString;
215
+ id: z.ZodOptional<z.ZodString>;
216
+ url: z.ZodOptional<z.ZodString>;
217
+ data: z.ZodOptional<z.ZodString>;
218
+ filename: z.ZodOptional<z.ZodString>;
219
+ }, z.core.$strip>], "type">>]>;
220
+ name: z.ZodOptional<z.ZodString>;
221
+ encryptedValue: z.ZodOptional<z.ZodString>;
222
+ }, z.core.$strip>, z.ZodObject<{
223
+ id: z.ZodString;
224
+ role: z.ZodLiteral<"tool">;
225
+ toolCallId: z.ZodString;
226
+ content: z.ZodString;
227
+ error: z.ZodOptional<z.ZodString>;
228
+ encryptedValue: z.ZodOptional<z.ZodString>;
229
+ }, z.core.$strip>, z.ZodObject<{
230
+ id: z.ZodString;
231
+ role: z.ZodLiteral<"reasoning">;
232
+ content: z.ZodString;
233
+ name: z.ZodOptional<z.ZodString>;
234
+ encryptedValue: z.ZodOptional<z.ZodString>;
235
+ }, z.core.$strip>], "role">>;
236
+ }, z.core.$strip>;
237
+ }, z.core.$strip>, z.ZodObject<{
238
+ eventName: z.ZodLiteral<"ReasoningMessageStart">;
239
+ payload: z.ZodObject<{
240
+ id: z.ZodOptional<z.ZodString>;
241
+ messageId: z.ZodOptional<z.ZodString>;
242
+ role: z.ZodOptional<z.ZodString>;
243
+ }, z.core.$strip>;
244
+ }, z.core.$strip>, z.ZodObject<{
245
+ eventName: z.ZodLiteral<"ReasoningMessageContent">;
246
+ payload: z.ZodObject<{
247
+ id: z.ZodOptional<z.ZodString>;
248
+ messageId: z.ZodOptional<z.ZodString>;
249
+ delta: z.ZodString;
250
+ }, z.core.$strip>;
251
+ }, z.core.$strip>, z.ZodObject<{
252
+ eventName: z.ZodLiteral<"ReasoningMessageEnd">;
253
+ payload: z.ZodObject<{
254
+ id: z.ZodOptional<z.ZodString>;
255
+ messageId: z.ZodOptional<z.ZodString>;
256
+ }, z.core.$strip>;
257
+ }, z.core.$strip>, z.ZodObject<{
258
+ eventName: z.ZodLiteral<"StateDelta">;
259
+ payload: z.ZodObject<{
260
+ delta: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodObject<{
261
+ op: z.ZodEnum<{
262
+ copy: "copy";
263
+ test: "test";
264
+ remove: "remove";
265
+ replace: "replace";
266
+ add: "add";
267
+ move: "move";
268
+ }>;
269
+ path: z.ZodString;
270
+ from: z.ZodOptional<z.ZodString>;
271
+ value: z.ZodOptional<z.ZodUnknown>;
272
+ }, z.core.$strip>>]>;
273
+ }, z.core.$strip>;
274
+ }, z.core.$strip>, z.ZodObject<{
275
+ eventName: z.ZodLiteral<"RunFinished">;
276
+ payload: z.ZodObject<{
277
+ metadata: z.ZodOptional<z.ZodObject<{
278
+ provider: z.ZodOptional<z.ZodString>;
279
+ model: z.ZodOptional<z.ZodString>;
280
+ inputTokens: z.ZodOptional<z.ZodNumber>;
281
+ outputTokens: z.ZodOptional<z.ZodNumber>;
282
+ totalTokens: z.ZodOptional<z.ZodNumber>;
283
+ cachedInputTokens: z.ZodOptional<z.ZodNumber>;
284
+ reasoningTokens: z.ZodOptional<z.ZodNumber>;
285
+ finishReason: z.ZodOptional<z.ZodString>;
286
+ providerRequestId: z.ZodOptional<z.ZodString>;
287
+ }, z.core.$strip>>;
288
+ }, z.core.$strip>;
289
+ }, z.core.$strip>, z.ZodObject<{
290
+ eventName: z.ZodLiteral<"RunError">;
291
+ payload: z.ZodObject<{
292
+ code: z.ZodOptional<z.ZodString>;
293
+ message: z.ZodOptional<z.ZodString>;
294
+ }, z.core.$strip>;
295
+ }, z.core.$strip>], "eventName">;
296
+ export type AgUiRunFinishedMetadata = z.infer<typeof AgUiRunFinishedMetadataSchema>;
297
+ export type AgUiSnapshotMessage = z.infer<typeof AgUiSnapshotMessageSchema>;
298
+ export type AgUiWireEventName = z.infer<typeof AgUiWireEventNameSchema>;
299
+ export type AgUiWireEvent = z.infer<typeof AgUiWireEventSchema>;
300
+ export declare function parseSseEvent(raw: string): ParsedSseEvent;
301
+ export declare function createAgUiChatEventDecoderState(input?: {
302
+ lastEventId?: number;
303
+ }): AgUiChatEventDecoderState;
304
+ export declare function decodeAgUiSseChunk(state: AgUiChatEventDecoderState, chunk: string): AgUiDecodedChunk;
305
+ export declare function flushAgUiSseChunk(state: AgUiChatEventDecoderState): AgUiDecodedChunk;
306
+ export {};
307
+ //# sourceMappingURL=ag-ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ag-ui.d.ts","sourceRoot":"","sources":["../../../src/src/chat/ag-ui.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAoB,eAAe,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,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