veryfront 0.1.193 → 0.1.196

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