veryfront 0.1.286 → 0.1.287

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
@@ -44,6 +44,7 @@ declare namespace _default {
44
44
  "./extensions": string;
45
45
  "./extensions/interfaces": string;
46
46
  "./cli": string;
47
+ "./chat/conversation": string;
47
48
  };
48
49
  let imports: {
49
50
  "veryfront/head": string;
@@ -254,6 +255,7 @@ declare namespace _default {
254
255
  vfile: string;
255
256
  "class-variance-authority": string;
256
257
  "tailwind-merge": string;
258
+ "veryfront/chat/conversation": string;
257
259
  };
258
260
  namespace compilerOptions {
259
261
  let jsx: string;
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.286",
3
+ "version": "0.1.287",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "workspace": [
@@ -63,7 +63,8 @@ export default {
63
63
  "./embedding": "./src/embedding/index.ts",
64
64
  "./extensions": "./src/extensions/index.ts",
65
65
  "./extensions/interfaces": "./src/extensions/interfaces/index.ts",
66
- "./cli": "./cli/main.ts"
66
+ "./cli": "./cli/main.ts",
67
+ "./chat/conversation": "./src/chat/conversation.ts"
67
68
  },
68
69
  "imports": {
69
70
  "veryfront/head": "./src/react/runtime/core.ts",
@@ -273,7 +274,8 @@ export default {
273
274
  "unified": "npm:unified@11.0.5",
274
275
  "vfile": "npm:vfile@6.0.3",
275
276
  "class-variance-authority": "npm:class-variance-authority@0.7.1",
276
- "tailwind-merge": "npm:tailwind-merge@3.5.0"
277
+ "tailwind-merge": "npm:tailwind-merge@3.5.0",
278
+ "veryfront/chat/conversation": "./src/chat/conversation.ts"
277
279
  },
278
280
  "compilerOptions": {
279
281
  "jsx": "react-jsx",
@@ -0,0 +1,236 @@
1
+ import { z } from "zod";
2
+ import type { ChatModelMessage, ChatUiMessage, ChatUiMessagePart } from "./types.js";
3
+ export declare const messagePartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
4
+ type: z.ZodLiteral<"text">;
5
+ text: z.ZodString;
6
+ }, z.core.$strip>, z.ZodObject<{
7
+ type: z.ZodLiteral<"image">;
8
+ upload_id: z.ZodString;
9
+ media_type: z.ZodString;
10
+ url: z.ZodOptional<z.ZodString>;
11
+ }, z.core.$strip>, z.ZodObject<{
12
+ type: z.ZodLiteral<"file">;
13
+ upload_id: z.ZodString;
14
+ media_type: z.ZodString;
15
+ filename: z.ZodOptional<z.ZodString>;
16
+ url: z.ZodOptional<z.ZodString>;
17
+ }, z.core.$strip>, z.ZodObject<{
18
+ type: z.ZodLiteral<"tool_call">;
19
+ id: z.ZodString;
20
+ name: z.ZodString;
21
+ input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
22
+ state: z.ZodEnum<{
23
+ error: "error";
24
+ pending: "pending";
25
+ completed: "completed";
26
+ streaming: "streaming";
27
+ }>;
28
+ }, z.core.$strip>, z.ZodObject<{
29
+ type: z.ZodLiteral<"tool_result">;
30
+ tool_call_id: z.ZodString;
31
+ output: z.ZodUnknown;
32
+ is_error: z.ZodOptional<z.ZodBoolean>;
33
+ }, z.core.$strip>, z.ZodObject<{
34
+ type: z.ZodLiteral<"reasoning">;
35
+ text: z.ZodString;
36
+ signature: z.ZodOptional<z.ZodString>;
37
+ }, z.core.$strip>, z.ZodObject<{
38
+ type: z.ZodLiteral<"citation">;
39
+ source_id: z.ZodString;
40
+ url: z.ZodOptional<z.ZodString>;
41
+ title: z.ZodOptional<z.ZodString>;
42
+ quote: z.ZodOptional<z.ZodString>;
43
+ }, z.core.$strip>, z.ZodObject<{
44
+ type: z.ZodLiteral<"step_start">;
45
+ }, z.core.$strip>, z.ZodObject<{
46
+ type: z.ZodLiteral<"error">;
47
+ code: z.ZodString;
48
+ message: z.ZodString;
49
+ }, z.core.$strip>, z.ZodObject<{
50
+ type: z.ZodLiteral<"data">;
51
+ name: z.ZodString;
52
+ value: z.ZodUnknown;
53
+ }, z.core.$strip>], "type">;
54
+ export type MessagePart = z.infer<typeof messagePartSchema>;
55
+ export declare const conversationTypeSchema: z.ZodEnum<{
56
+ project_agent: "project_agent";
57
+ chat: "chat";
58
+ support: "support";
59
+ channel: "channel";
60
+ agent_task: "agent_task";
61
+ }>;
62
+ export type ConversationType = z.infer<typeof conversationTypeSchema>;
63
+ export declare const messageStatusSchema: z.ZodEnum<{
64
+ error: "error";
65
+ failed: "failed";
66
+ pending: "pending";
67
+ completed: "completed";
68
+ streaming: "streaming";
69
+ cancelled: "cancelled";
70
+ stopped: "stopped";
71
+ }>;
72
+ export type MessageStatus = z.infer<typeof messageStatusSchema>;
73
+ export declare const apiConversationSchema: z.ZodObject<{
74
+ id: z.ZodString;
75
+ projectId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
76
+ type: z.ZodEnum<{
77
+ project_agent: "project_agent";
78
+ chat: "chat";
79
+ support: "support";
80
+ channel: "channel";
81
+ agent_task: "agent_task";
82
+ }>;
83
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
84
+ status: z.ZodEnum<{
85
+ active: "active";
86
+ deleted: "deleted";
87
+ archived: "archived";
88
+ }>;
89
+ summary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
90
+ currentNode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
91
+ messageCount: z.ZodNumber;
92
+ lastMessageAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
93
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
94
+ createdBy: z.ZodString;
95
+ archivedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
96
+ createdAt: z.ZodString;
97
+ updatedAt: z.ZodString;
98
+ }, z.core.$strip>;
99
+ export type ApiConversation = z.infer<typeof apiConversationSchema>;
100
+ export declare const apiMessageSchema: z.ZodObject<{
101
+ id: z.ZodString;
102
+ conversationId: z.ZodString;
103
+ parentId: z.ZodNullable<z.ZodString>;
104
+ seq: z.ZodNumber;
105
+ role: z.ZodEnum<{
106
+ tool: "tool";
107
+ user: "user";
108
+ assistant: "assistant";
109
+ }>;
110
+ parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
111
+ type: z.ZodLiteral<"text">;
112
+ text: z.ZodString;
113
+ }, z.core.$strip>, z.ZodObject<{
114
+ type: z.ZodLiteral<"image">;
115
+ upload_id: z.ZodString;
116
+ media_type: z.ZodString;
117
+ url: z.ZodOptional<z.ZodString>;
118
+ }, z.core.$strip>, z.ZodObject<{
119
+ type: z.ZodLiteral<"file">;
120
+ upload_id: z.ZodString;
121
+ media_type: z.ZodString;
122
+ filename: z.ZodOptional<z.ZodString>;
123
+ url: z.ZodOptional<z.ZodString>;
124
+ }, z.core.$strip>, z.ZodObject<{
125
+ type: z.ZodLiteral<"tool_call">;
126
+ id: z.ZodString;
127
+ name: z.ZodString;
128
+ input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
129
+ state: z.ZodEnum<{
130
+ error: "error";
131
+ pending: "pending";
132
+ completed: "completed";
133
+ streaming: "streaming";
134
+ }>;
135
+ }, z.core.$strip>, z.ZodObject<{
136
+ type: z.ZodLiteral<"tool_result">;
137
+ tool_call_id: z.ZodString;
138
+ output: z.ZodUnknown;
139
+ is_error: z.ZodOptional<z.ZodBoolean>;
140
+ }, z.core.$strip>, z.ZodObject<{
141
+ type: z.ZodLiteral<"reasoning">;
142
+ text: z.ZodString;
143
+ signature: z.ZodOptional<z.ZodString>;
144
+ }, z.core.$strip>, z.ZodObject<{
145
+ type: z.ZodLiteral<"citation">;
146
+ source_id: z.ZodString;
147
+ url: z.ZodOptional<z.ZodString>;
148
+ title: z.ZodOptional<z.ZodString>;
149
+ quote: z.ZodOptional<z.ZodString>;
150
+ }, z.core.$strip>, z.ZodObject<{
151
+ type: z.ZodLiteral<"step_start">;
152
+ }, z.core.$strip>, z.ZodObject<{
153
+ type: z.ZodLiteral<"error">;
154
+ code: z.ZodString;
155
+ message: z.ZodString;
156
+ }, z.core.$strip>, z.ZodObject<{
157
+ type: z.ZodLiteral<"data">;
158
+ name: z.ZodString;
159
+ value: z.ZodUnknown;
160
+ }, z.core.$strip>], "type">>;
161
+ status: z.ZodEnum<{
162
+ error: "error";
163
+ failed: "failed";
164
+ pending: "pending";
165
+ completed: "completed";
166
+ streaming: "streaming";
167
+ cancelled: "cancelled";
168
+ stopped: "stopped";
169
+ }>;
170
+ model: z.ZodNullable<z.ZodString>;
171
+ tokenUsage: z.ZodNullable<z.ZodObject<{
172
+ input: z.ZodNumber;
173
+ output: z.ZodNumber;
174
+ }, z.core.$strip>>;
175
+ finishReason: z.ZodNullable<z.ZodString>;
176
+ costCredits: z.ZodOptional<z.ZodNullable<z.ZodString>>;
177
+ createdBy: z.ZodNullable<z.ZodString>;
178
+ editedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
179
+ idempotencyKey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
180
+ metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
181
+ createdAt: z.ZodString;
182
+ updatedAt: z.ZodNullable<z.ZodString>;
183
+ }, z.core.$strip>;
184
+ export type ApiMessage = z.infer<typeof apiMessageSchema>;
185
+ export interface ToolCallLike {
186
+ type: "tool-call";
187
+ toolCallId: string;
188
+ toolName: string;
189
+ input: unknown;
190
+ providerExecuted?: boolean;
191
+ }
192
+ export interface ToolResultLike {
193
+ type: "tool-result";
194
+ toolCallId: string;
195
+ toolName: string;
196
+ output: unknown;
197
+ providerOptions?: unknown;
198
+ }
199
+ export interface TextPartLike {
200
+ type: "text";
201
+ text: string;
202
+ }
203
+ export interface ReasoningPartLike {
204
+ type: "reasoning";
205
+ text: string;
206
+ }
207
+ type ToolUiPart = Extract<ChatUiMessagePart, {
208
+ toolCallId: string;
209
+ state: string;
210
+ }>;
211
+ export declare const UUID_PATTERN: RegExp;
212
+ export declare function isUuid(value: string | null | undefined): value is string;
213
+ export declare function extractUploadId(url: string): string | null;
214
+ export declare function mapToolState(sdkState: string): "streaming" | "pending" | "completed" | "error";
215
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
216
+ export declare function getStringField(value: unknown, field: string, fallback: string): string;
217
+ export declare function stringifyUnknown(value: unknown): string;
218
+ export declare function isDataUiPart(part: ChatUiMessagePart): part is ChatUiMessagePart & {
219
+ type: `data-${string}`;
220
+ data: unknown;
221
+ };
222
+ export declare function isToolUiPart(part: ChatUiMessagePart): part is ToolUiPart;
223
+ export declare function getUiToolName(part: ToolUiPart): string | undefined;
224
+ export declare function pushToolParts(parts: MessagePart[], toolName: string, toolCallId: string, state: string, part: {
225
+ input?: unknown;
226
+ output?: unknown;
227
+ errorText?: unknown;
228
+ }): void;
229
+ export declare function isToolCallPart(value: unknown): value is ToolCallLike;
230
+ export declare function isToolResultPart(value: unknown): value is ToolResultLike;
231
+ export declare function isTextPart(value: unknown): value is TextPartLike;
232
+ export declare function isReasoningPart(value: unknown): value is ReasoningPartLike;
233
+ export declare function extractTextFromMessage(message: ChatModelMessage): string;
234
+ export declare function convertUiMessagesToModelMessages(messages: ChatUiMessage[]): ChatModelMessage[];
235
+ export {};
236
+ //# sourceMappingURL=conversation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/src/chat/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAiDrF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAW5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,sBAAsB;;;;;;EAMjC,CAAC;AACH,MAAM,MAAM,g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