@convex-dev/agent 0.1.18 → 0.2.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/dist/client/createTool.d.ts +30 -11
- package/dist/client/createTool.d.ts.map +1 -1
- package/dist/client/createTool.js +24 -10
- package/dist/client/createTool.js.map +1 -1
- package/dist/client/defaultComponent.d.ts +11 -0
- package/dist/client/defaultComponent.d.ts.map +1 -0
- package/dist/client/defaultComponent.js +7 -0
- package/dist/client/defaultComponent.js.map +1 -0
- package/dist/client/definePlaygroundAPI.d.ts +68 -23
- package/dist/client/definePlaygroundAPI.d.ts.map +1 -1
- package/dist/client/definePlaygroundAPI.js +7 -20
- package/dist/client/definePlaygroundAPI.js.map +1 -1
- package/dist/client/files.d.ts +14 -4
- package/dist/client/files.d.ts.map +1 -1
- package/dist/client/files.js +66 -11
- package/dist/client/files.js.map +1 -1
- package/dist/client/index.d.ts +323 -780
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +445 -543
- package/dist/client/index.js.map +1 -1
- package/dist/client/messages.d.ts +256 -0
- package/dist/client/messages.d.ts.map +1 -0
- package/dist/client/messages.js +97 -0
- package/dist/client/messages.js.map +1 -0
- package/dist/client/search.d.ts +35 -12
- package/dist/client/search.d.ts.map +1 -1
- package/dist/client/search.js +21 -4
- package/dist/client/search.js.map +1 -1
- package/dist/client/streaming.d.ts +21 -21
- package/dist/client/streaming.d.ts.map +1 -1
- package/dist/client/streaming.js +35 -40
- package/dist/client/streaming.js.map +1 -1
- package/dist/client/threads.d.ts +46 -0
- package/dist/client/threads.d.ts.map +1 -0
- package/dist/client/threads.js +49 -0
- package/dist/client/threads.js.map +1 -0
- package/dist/client/types.d.ts +159 -75
- package/dist/client/types.d.ts.map +1 -1
- package/dist/component/_generated/api.d.ts +261 -209
- package/dist/component/messages.d.ts +314 -105
- package/dist/component/messages.d.ts.map +1 -1
- package/dist/component/messages.js +141 -83
- package/dist/component/messages.js.map +1 -1
- package/dist/component/schema.d.ts +631 -870
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +11 -16
- package/dist/component/schema.js.map +1 -1
- package/dist/component/streams.d.ts +29 -149
- package/dist/component/streams.d.ts.map +1 -1
- package/dist/component/streams.js +104 -60
- package/dist/component/streams.js.map +1 -1
- package/dist/component/threads.d.ts +4 -4
- package/dist/component/users.d.ts +3 -3
- package/dist/mapping.d.ts +15 -16
- package/dist/mapping.d.ts.map +1 -1
- package/dist/mapping.js +208 -62
- package/dist/mapping.js.map +1 -1
- package/dist/parts.d.ts +3 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +34 -0
- package/dist/parts.js.map +1 -0
- package/dist/react/SmoothText.d.ts +5 -0
- package/dist/react/SmoothText.d.ts.map +1 -0
- package/dist/react/SmoothText.js +6 -0
- package/dist/react/SmoothText.js.map +1 -0
- package/dist/react/deltas.d.ts +3 -5
- package/dist/react/deltas.d.ts.map +1 -1
- package/dist/react/deltas.js +89 -53
- package/dist/react/deltas.js.map +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +31 -11
- package/dist/react/index.js.map +1 -1
- package/dist/react/optimisticallySendMessage.d.ts.map +1 -1
- package/dist/react/optimisticallySendMessage.js +2 -8
- package/dist/react/optimisticallySendMessage.js.map +1 -1
- package/dist/react/toUIMessages.d.ts +5 -4
- package/dist/react/toUIMessages.d.ts.map +1 -1
- package/dist/react/toUIMessages.js +103 -40
- package/dist/react/toUIMessages.js.map +1 -1
- package/dist/react/useSmoothText.d.ts +13 -12
- package/dist/react/useSmoothText.d.ts.map +1 -1
- package/dist/react/useSmoothText.js +1 -1
- package/dist/react/useSmoothText.js.map +1 -1
- package/dist/validators.d.ts +751 -1464
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +39 -80
- package/dist/validators.js.map +1 -1
- package/package.json +34 -30
- package/src/client/createTool.ts +66 -40
- package/src/client/defaultComponent.ts +17 -0
- package/src/client/definePlaygroundAPI.ts +17 -31
- package/src/client/files.ts +94 -17
- package/src/client/index.test.ts +28 -38
- package/src/client/index.ts +785 -977
- package/src/client/messages.ts +205 -0
- package/src/client/search.ts +37 -10
- package/src/client/streaming.ts +53 -56
- package/src/client/threads.ts +78 -0
- package/src/client/types.ts +239 -131
- package/src/component/_generated/api.d.ts +261 -209
- package/src/component/messages.test.ts +182 -40
- package/src/component/messages.ts +165 -108
- package/src/component/schema.ts +11 -17
- package/src/component/streams.ts +180 -69
- package/src/mapping.ts +253 -96
- package/src/parts.ts +39 -0
- package/src/react/SmoothText.tsx +9 -0
- package/src/react/deltas.test.ts +38 -42
- package/src/react/deltas.ts +116 -65
- package/src/react/index.ts +35 -13
- package/src/react/optimisticallySendMessage.ts +2 -8
- package/src/react/toUIMessages.test.ts +154 -36
- package/src/react/toUIMessages.ts +136 -57
- package/src/react/useSmoothText.ts +14 -15
- package/src/validators.test.ts +1 -117
- package/src/validators.ts +57 -107
- package/dist/client/listMessages.d.ts +0 -22
- package/dist/client/listMessages.d.ts.map +0 -1
- package/dist/client/listMessages.js +0 -25
- package/dist/client/listMessages.js.map +0 -1
- package/src/client/listMessages.ts +0 -38
package/src/validators.test.ts
CHANGED
|
@@ -1,108 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
TextStreamPart as AITextStreamPart,
|
|
3
|
-
AssistantContent,
|
|
4
|
-
CoreAssistantMessage,
|
|
5
|
-
CoreMessage,
|
|
6
|
-
CoreSystemMessage,
|
|
7
|
-
CoreToolMessage,
|
|
8
|
-
CoreUserMessage,
|
|
9
|
-
FilePart,
|
|
10
|
-
ImagePart,
|
|
11
|
-
TextPart,
|
|
12
|
-
ToolCallPart,
|
|
13
|
-
ToolContent,
|
|
14
|
-
ToolSet,
|
|
15
|
-
UserContent,
|
|
16
|
-
} from "ai";
|
|
17
1
|
import type { Infer } from "convex/values";
|
|
18
2
|
import { expectTypeOf, test } from "vitest";
|
|
19
3
|
import type { ContextOptions, StorageOptions } from "./client/types.js";
|
|
20
|
-
import
|
|
21
|
-
import type { TextStreamPart } from "./validators.js";
|
|
22
|
-
import {
|
|
23
|
-
vAssistantContent,
|
|
24
|
-
vAssistantMessage,
|
|
25
|
-
vContextOptions,
|
|
26
|
-
vFilePart,
|
|
27
|
-
vImagePart,
|
|
28
|
-
vMessage,
|
|
29
|
-
vReasoningPart,
|
|
30
|
-
vRedactedReasoningPart,
|
|
31
|
-
vStorageOptions,
|
|
32
|
-
vSystemMessage,
|
|
33
|
-
vTextPart,
|
|
34
|
-
vToolCallPart,
|
|
35
|
-
vToolContent,
|
|
36
|
-
vToolMessage,
|
|
37
|
-
vUserContent,
|
|
38
|
-
vUserMessage,
|
|
39
|
-
} from "./validators.js";
|
|
40
|
-
|
|
41
|
-
// type assertion
|
|
42
|
-
type OurUserContent = SerializeUrlsAndUint8Arrays<UserContent>;
|
|
43
|
-
expectTypeOf<OurUserContent>().toExtend<Infer<typeof vUserContent>>();
|
|
44
|
-
expectTypeOf<Infer<typeof vUserContent>>().toExtend<OurUserContent>();
|
|
45
|
-
|
|
46
|
-
type OurAssistantContent = SerializeUrlsAndUint8Arrays<AssistantContent>;
|
|
47
|
-
expectTypeOf<OurAssistantContent>().toExtend<Infer<typeof vAssistantContent>>();
|
|
48
|
-
expectTypeOf<Infer<typeof vAssistantContent>>().toExtend<OurAssistantContent>();
|
|
49
|
-
|
|
50
|
-
type OurToolContent = SerializeUrlsAndUint8Arrays<ToolContent>;
|
|
51
|
-
expectTypeOf<OurToolContent>().toExtend<Infer<typeof vToolContent>>();
|
|
52
|
-
expectTypeOf<Infer<typeof vToolContent>>().toExtend<OurToolContent>();
|
|
53
|
-
|
|
54
|
-
expectTypeOf<Infer<typeof vToolCallPart>>().toExtend<ToolCallPart>();
|
|
55
|
-
expectTypeOf<ToolCallPart>().toExtend<Infer<typeof vToolCallPart>>();
|
|
56
|
-
|
|
57
|
-
type OurTextPart = SerializeUrlsAndUint8Arrays<TextPart>;
|
|
58
|
-
expectTypeOf<OurTextPart>().toExtend<Infer<typeof vTextPart>>();
|
|
59
|
-
expectTypeOf<Infer<typeof vTextPart>>().toExtend<OurTextPart>();
|
|
60
|
-
|
|
61
|
-
type OurImagePart = SerializeUrlsAndUint8Arrays<ImagePart>;
|
|
62
|
-
expectTypeOf<OurImagePart>().toExtend<Infer<typeof vImagePart>>();
|
|
63
|
-
expectTypeOf<Infer<typeof vImagePart>>().toExtend<OurImagePart>();
|
|
64
|
-
|
|
65
|
-
type OurFilePart = SerializeUrlsAndUint8Arrays<FilePart>;
|
|
66
|
-
expectTypeOf<OurFilePart>().toExtend<Infer<typeof vFilePart>>();
|
|
67
|
-
expectTypeOf<Infer<typeof vFilePart>>().toExtend<OurFilePart>();
|
|
68
|
-
|
|
69
|
-
// narrow to the type
|
|
70
|
-
type ReasoningPart = AssistantContent[number] & { type: "reasoning" } & object;
|
|
71
|
-
type OurReasoningPart = SerializeUrlsAndUint8Arrays<ReasoningPart>;
|
|
72
|
-
expectTypeOf<OurReasoningPart>().toExtend<Infer<typeof vReasoningPart>>();
|
|
73
|
-
expectTypeOf<Infer<typeof vReasoningPart>>().toExtend<OurReasoningPart>();
|
|
74
|
-
|
|
75
|
-
// narrow to the type
|
|
76
|
-
type RedactedReasoningPart = AssistantContent[number] & {
|
|
77
|
-
type: "redacted-reasoning";
|
|
78
|
-
} & object;
|
|
79
|
-
type OurRedactedReasoningPart =
|
|
80
|
-
SerializeUrlsAndUint8Arrays<RedactedReasoningPart>;
|
|
81
|
-
expectTypeOf<OurRedactedReasoningPart>().toExtend<
|
|
82
|
-
Infer<typeof vRedactedReasoningPart>
|
|
83
|
-
>();
|
|
84
|
-
expectTypeOf<
|
|
85
|
-
Infer<typeof vRedactedReasoningPart>
|
|
86
|
-
>().toExtend<OurRedactedReasoningPart>();
|
|
87
|
-
|
|
88
|
-
// test("noop", () => {
|
|
89
|
-
type OurUserMessage = SerializeUrlsAndUint8Arrays<CoreUserMessage>;
|
|
90
|
-
expectTypeOf<OurUserMessage>().toExtend<Infer<typeof vUserMessage>>();
|
|
91
|
-
expectTypeOf<Infer<typeof vUserMessage>>().toExtend<OurUserMessage>();
|
|
92
|
-
|
|
93
|
-
type OurAssistantMessage = SerializeUrlsAndUint8Arrays<CoreAssistantMessage>;
|
|
94
|
-
expectTypeOf<OurAssistantMessage>().toExtend<Infer<typeof vAssistantMessage>>();
|
|
95
|
-
expectTypeOf<Infer<typeof vAssistantMessage>>().toExtend<OurAssistantMessage>();
|
|
96
|
-
|
|
97
|
-
expectTypeOf<Infer<typeof vToolMessage>>().toExtend<CoreToolMessage>();
|
|
98
|
-
expectTypeOf<CoreToolMessage>().toExtend<Infer<typeof vToolMessage>>();
|
|
99
|
-
|
|
100
|
-
expectTypeOf<Infer<typeof vSystemMessage>>().toExtend<CoreSystemMessage>();
|
|
101
|
-
expectTypeOf<CoreSystemMessage>().toExtend<Infer<typeof vSystemMessage>>();
|
|
102
|
-
|
|
103
|
-
type OurMessage = SerializeUrlsAndUint8Arrays<CoreMessage>;
|
|
104
|
-
expectTypeOf<OurMessage>().toExtend<Infer<typeof vMessage>>();
|
|
105
|
-
expectTypeOf<Infer<typeof vMessage>>().toExtend<OurMessage>();
|
|
4
|
+
import { vContextOptions, vStorageOptions } from "./validators.js";
|
|
106
5
|
|
|
107
6
|
expectTypeOf<Infer<typeof vContextOptions>>().toExtend<ContextOptions>();
|
|
108
7
|
expectTypeOf<ContextOptions>().toExtend<Infer<typeof vContextOptions>>();
|
|
@@ -110,19 +9,4 @@ expectTypeOf<ContextOptions>().toExtend<Infer<typeof vContextOptions>>();
|
|
|
110
9
|
expectTypeOf<Infer<typeof vStorageOptions>>().toExtend<StorageOptions>();
|
|
111
10
|
expectTypeOf<StorageOptions>().toExtend<Infer<typeof vStorageOptions>>();
|
|
112
11
|
|
|
113
|
-
type StreamPart = Extract<
|
|
114
|
-
AITextStreamPart<ToolSet>,
|
|
115
|
-
{
|
|
116
|
-
type:
|
|
117
|
-
| "text-delta"
|
|
118
|
-
| "reasoning"
|
|
119
|
-
| "source"
|
|
120
|
-
| "tool-call"
|
|
121
|
-
| "tool-call-streaming-start"
|
|
122
|
-
| "tool-call-delta"
|
|
123
|
-
| "tool-result";
|
|
124
|
-
}
|
|
125
|
-
>;
|
|
126
|
-
expectTypeOf<StreamPart>().toExtend<TextStreamPart>();
|
|
127
|
-
|
|
128
12
|
test("noop", () => {});
|
package/src/validators.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
v,
|
|
3
|
-
type Infer,
|
|
4
|
-
type ObjectType,
|
|
5
|
-
type Validator,
|
|
6
|
-
type Value,
|
|
7
|
-
} from "convex/values";
|
|
1
|
+
import { v, type Infer, type Validator, type Value } from "convex/values";
|
|
8
2
|
import { vVectorDimension } from "./component/vector/tables.js";
|
|
9
3
|
|
|
10
4
|
// const deprecated = v.optional(v.any()) as unknown as VNull<unknown, "optional">;
|
|
@@ -69,6 +63,7 @@ export const vReasoningPart = v.object({
|
|
|
69
63
|
text: v.string(),
|
|
70
64
|
signature: v.optional(v.string()),
|
|
71
65
|
providerOptions,
|
|
66
|
+
state: v.optional(v.union(v.literal("streaming"), v.literal("done"))),
|
|
72
67
|
});
|
|
73
68
|
|
|
74
69
|
export const vRedactedReasoningPart = v.object({
|
|
@@ -79,6 +74,7 @@ export const vRedactedReasoningPart = v.object({
|
|
|
79
74
|
|
|
80
75
|
export const vReasoningDetails = v.array(
|
|
81
76
|
v.union(
|
|
77
|
+
vReasoningPart,
|
|
82
78
|
v.object({
|
|
83
79
|
type: v.literal("text"),
|
|
84
80
|
text: v.string(),
|
|
@@ -97,6 +93,7 @@ export const vToolCallPart = v.object({
|
|
|
97
93
|
toolName: v.string(),
|
|
98
94
|
args: v.any(),
|
|
99
95
|
providerOptions,
|
|
96
|
+
providerExecuted: v.optional(v.boolean()),
|
|
100
97
|
});
|
|
101
98
|
|
|
102
99
|
export const vAssistantContent = v.union(
|
|
@@ -126,17 +123,20 @@ const vToolResultContent = v.array(
|
|
|
126
123
|
),
|
|
127
124
|
);
|
|
128
125
|
|
|
129
|
-
const vToolResultPart = v.object({
|
|
126
|
+
export const vToolResultPart = v.object({
|
|
130
127
|
type: v.literal("tool-result"),
|
|
131
128
|
toolCallId: v.string(),
|
|
132
129
|
toolName: v.string(),
|
|
133
130
|
result: v.any(),
|
|
131
|
+
providerOptions,
|
|
132
|
+
providerExecuted: v.optional(v.boolean()),
|
|
133
|
+
|
|
134
|
+
// Deprecated in ai v5
|
|
135
|
+
isError: v.optional(v.boolean()),
|
|
134
136
|
// This is only here b/c steps include it in toolResults
|
|
135
|
-
// Normal
|
|
137
|
+
// Normal ModelMessage doesn't have this
|
|
136
138
|
args: v.optional(v.any()),
|
|
137
139
|
experimental_content: v.optional(vToolResultContent),
|
|
138
|
-
isError: v.optional(v.boolean()),
|
|
139
|
-
providerOptions,
|
|
140
140
|
});
|
|
141
141
|
export const vToolContent = v.array(vToolResultPart);
|
|
142
142
|
|
|
@@ -175,13 +175,25 @@ export const vMessage = v.union(
|
|
|
175
175
|
);
|
|
176
176
|
export type Message = Infer<typeof vMessage>;
|
|
177
177
|
|
|
178
|
-
export const vSource = v.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
178
|
+
export const vSource = v.union(
|
|
179
|
+
v.object({
|
|
180
|
+
type: v.optional(v.literal("source")),
|
|
181
|
+
sourceType: v.literal("url"),
|
|
182
|
+
id: v.string(),
|
|
183
|
+
url: v.string(),
|
|
184
|
+
title: v.optional(v.string()),
|
|
185
|
+
providerOptions,
|
|
186
|
+
}),
|
|
187
|
+
v.object({
|
|
188
|
+
type: v.literal("source"),
|
|
189
|
+
sourceType: v.literal("document"),
|
|
190
|
+
id: v.string(),
|
|
191
|
+
mediaType: v.string(),
|
|
192
|
+
title: v.string(),
|
|
193
|
+
filename: v.optional(v.string()),
|
|
194
|
+
providerMetadata,
|
|
195
|
+
}),
|
|
196
|
+
);
|
|
185
197
|
|
|
186
198
|
export const vRequest = v.object({
|
|
187
199
|
body: v.optional(v.any()),
|
|
@@ -191,29 +203,6 @@ export const vRequest = v.object({
|
|
|
191
203
|
url: v.optional(v.string()),
|
|
192
204
|
});
|
|
193
205
|
|
|
194
|
-
const vMessageWithFileAndId = v.object({
|
|
195
|
-
id: v.optional(v.string()),
|
|
196
|
-
message: vMessage,
|
|
197
|
-
fileId: v.optional(v.id("files")),
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
export const vResponse = v.object({
|
|
201
|
-
id: v.string(),
|
|
202
|
-
timestamp: v.number(),
|
|
203
|
-
modelId: v.string(),
|
|
204
|
-
headers: v.optional(v.record(v.string(), v.string())), // clear these?
|
|
205
|
-
messages: v.array(vMessageWithFileAndId),
|
|
206
|
-
body: v.optional(v.any()),
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
export const vResponseWithoutMessages = v.object({
|
|
210
|
-
id: v.string(),
|
|
211
|
-
timestamp: v.number(),
|
|
212
|
-
modelId: v.string(),
|
|
213
|
-
headers: v.optional(v.record(v.string(), v.string())), // clear these?
|
|
214
|
-
body: v.optional(v.any()),
|
|
215
|
-
});
|
|
216
|
-
|
|
217
206
|
export const vFinishReason = v.union(
|
|
218
207
|
v.literal("stop"),
|
|
219
208
|
v.literal("length"),
|
|
@@ -228,10 +217,12 @@ export const vUsage = v.object({
|
|
|
228
217
|
promptTokens: v.number(),
|
|
229
218
|
completionTokens: v.number(),
|
|
230
219
|
totalTokens: v.number(),
|
|
220
|
+
reasoningTokens: v.optional(v.number()),
|
|
221
|
+
cachedInputTokens: v.optional(v.number()),
|
|
231
222
|
});
|
|
232
223
|
export type Usage = Infer<typeof vUsage>;
|
|
233
224
|
|
|
234
|
-
export const
|
|
225
|
+
export const vLanguageModelCallWarning = v.union(
|
|
235
226
|
v.object({
|
|
236
227
|
type: v.literal("unsupported-setting"),
|
|
237
228
|
setting: v.string(),
|
|
@@ -242,17 +233,14 @@ export const vLanguageModelV1CallWarning = v.union(
|
|
|
242
233
|
tool: v.any(),
|
|
243
234
|
details: v.optional(v.string()),
|
|
244
235
|
}),
|
|
245
|
-
v.object({
|
|
246
|
-
type: v.literal("other"),
|
|
247
|
-
message: v.string(),
|
|
248
|
-
}),
|
|
236
|
+
v.object({ type: v.literal("other"), message: v.string() }),
|
|
249
237
|
);
|
|
250
238
|
|
|
251
239
|
export const vMessageWithMetadataInternal = v.object({
|
|
252
|
-
id: v.optional(v.string()), // external id, e.g. from Vercel AI SDK
|
|
253
240
|
message: vMessage,
|
|
254
241
|
text: v.optional(v.string()),
|
|
255
242
|
fileIds: v.optional(v.array(v.id("files"))),
|
|
243
|
+
status: v.optional(vMessageStatus),
|
|
256
244
|
// metadata
|
|
257
245
|
finishReason: v.optional(vFinishReason),
|
|
258
246
|
model: v.optional(v.string()),
|
|
@@ -262,33 +250,32 @@ export const vMessageWithMetadataInternal = v.object({
|
|
|
262
250
|
reasoning: v.optional(v.string()),
|
|
263
251
|
reasoningDetails: v.optional(vReasoningDetails),
|
|
264
252
|
usage: v.optional(vUsage),
|
|
265
|
-
warnings: v.optional(v.array(
|
|
253
|
+
warnings: v.optional(v.array(vLanguageModelCallWarning)),
|
|
266
254
|
error: v.optional(v.string()),
|
|
267
255
|
});
|
|
256
|
+
export type MessageWithMetadataInternal = Infer<
|
|
257
|
+
typeof vMessageWithMetadataInternal
|
|
258
|
+
>;
|
|
268
259
|
export const vMessageWithMetadata = v.object({
|
|
269
260
|
...vMessageWithMetadataInternal.fields,
|
|
270
261
|
fileIds: v.optional(v.array(v.string())),
|
|
271
262
|
});
|
|
272
263
|
export type MessageWithMetadata = Infer<typeof vMessageWithMetadata>;
|
|
273
264
|
|
|
274
|
-
export const
|
|
265
|
+
export const vMessageEmbeddingsWithDimension = v.object({
|
|
275
266
|
model: v.string(),
|
|
276
267
|
dimension: vVectorDimension,
|
|
277
268
|
vectors: v.array(v.union(v.array(v.number()), v.null())),
|
|
278
269
|
});
|
|
279
|
-
export type
|
|
270
|
+
export type MessageEmbeddingsWithDimension = Infer<
|
|
271
|
+
typeof vMessageEmbeddingsWithDimension
|
|
272
|
+
>;
|
|
280
273
|
|
|
281
|
-
export const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
finishReason: vFinishReason,
|
|
285
|
-
usage: v.optional(v.any()),
|
|
286
|
-
object: v.any(),
|
|
287
|
-
error: v.optional(v.string()),
|
|
288
|
-
warnings: v.optional(v.array(vLanguageModelV1CallWarning)),
|
|
289
|
-
providerMetadata,
|
|
274
|
+
export const vMessageEmbeddings = v.object({
|
|
275
|
+
model: v.string(),
|
|
276
|
+
vectors: v.array(v.union(v.array(v.number()), v.null())),
|
|
290
277
|
});
|
|
291
|
-
export type
|
|
278
|
+
export type MessageEmbeddings = Infer<typeof vMessageEmbeddings>;
|
|
292
279
|
|
|
293
280
|
export const vContextOptionsSearchOptions = v.object({
|
|
294
281
|
limit: v.number(),
|
|
@@ -318,18 +305,19 @@ const vPromptFields = {
|
|
|
318
305
|
promptMessageId: v.optional(v.string()),
|
|
319
306
|
};
|
|
320
307
|
|
|
321
|
-
export const
|
|
322
|
-
|
|
308
|
+
export const vCallSettings = v.object({
|
|
309
|
+
maxOutputTokens: v.optional(v.number()),
|
|
323
310
|
temperature: v.optional(v.number()),
|
|
324
311
|
topP: v.optional(v.number()),
|
|
325
312
|
topK: v.optional(v.number()),
|
|
326
313
|
presencePenalty: v.optional(v.number()),
|
|
327
314
|
frequencyPenalty: v.optional(v.number()),
|
|
315
|
+
stopSequences: v.optional(v.array(v.string())),
|
|
328
316
|
seed: v.optional(v.number()),
|
|
329
317
|
maxRetries: v.optional(v.number()),
|
|
330
318
|
headers: v.optional(v.record(v.string(), v.string())),
|
|
331
|
-
};
|
|
332
|
-
export type CallSettings =
|
|
319
|
+
});
|
|
320
|
+
export type CallSettings = Infer<typeof vCallSettings>;
|
|
333
321
|
|
|
334
322
|
const vCommonArgs = {
|
|
335
323
|
userId: v.optional(v.string()),
|
|
@@ -337,7 +325,7 @@ const vCommonArgs = {
|
|
|
337
325
|
contextOptions: v.optional(vContextOptions),
|
|
338
326
|
storageOptions: v.optional(vStorageOptions),
|
|
339
327
|
providerOptions,
|
|
340
|
-
|
|
328
|
+
callSettings: v.optional(vCallSettings),
|
|
341
329
|
...vPromptFields,
|
|
342
330
|
};
|
|
343
331
|
|
|
@@ -349,10 +337,7 @@ export const vTextArgs = v.object({
|
|
|
349
337
|
v.literal("auto"),
|
|
350
338
|
v.literal("none"),
|
|
351
339
|
v.literal("required"),
|
|
352
|
-
v.object({
|
|
353
|
-
type: v.literal("tool"),
|
|
354
|
-
toolName: v.string(),
|
|
355
|
-
}),
|
|
340
|
+
v.object({ type: v.literal("tool"), toolName: v.string() }),
|
|
356
341
|
),
|
|
357
342
|
),
|
|
358
343
|
maxSteps: v.optional(v.number()),
|
|
@@ -388,35 +373,6 @@ export function vPaginationResult<
|
|
|
388
373
|
});
|
|
389
374
|
}
|
|
390
375
|
|
|
391
|
-
export const vTextStreamPart = v.union(
|
|
392
|
-
v.object({
|
|
393
|
-
type: v.literal("text-delta"),
|
|
394
|
-
textDelta: v.string(),
|
|
395
|
-
}),
|
|
396
|
-
v.object({
|
|
397
|
-
type: v.literal("reasoning"),
|
|
398
|
-
textDelta: v.string(),
|
|
399
|
-
}),
|
|
400
|
-
v.object({
|
|
401
|
-
type: v.literal("source"),
|
|
402
|
-
source: vSource,
|
|
403
|
-
}),
|
|
404
|
-
vToolCallPart,
|
|
405
|
-
v.object({
|
|
406
|
-
type: v.literal("tool-call-streaming-start"),
|
|
407
|
-
toolCallId: v.string(),
|
|
408
|
-
toolName: v.string(),
|
|
409
|
-
}),
|
|
410
|
-
v.object({
|
|
411
|
-
type: v.literal("tool-call-delta"),
|
|
412
|
-
toolCallId: v.string(),
|
|
413
|
-
toolName: v.string(),
|
|
414
|
-
argsTextDelta: v.string(),
|
|
415
|
-
}),
|
|
416
|
-
vToolResultPart,
|
|
417
|
-
);
|
|
418
|
-
export type TextStreamPart = Infer<typeof vTextStreamPart>;
|
|
419
|
-
|
|
420
376
|
export const vStreamCursor = v.object({
|
|
421
377
|
streamId: v.string(),
|
|
422
378
|
cursor: v.number(),
|
|
@@ -425,14 +381,8 @@ export type StreamCursor = Infer<typeof vStreamCursor>;
|
|
|
425
381
|
|
|
426
382
|
export const vStreamArgs = v.optional(
|
|
427
383
|
v.union(
|
|
428
|
-
v.object({
|
|
429
|
-
|
|
430
|
-
startOrder: v.optional(v.number()),
|
|
431
|
-
}),
|
|
432
|
-
v.object({
|
|
433
|
-
kind: v.literal("deltas"),
|
|
434
|
-
cursors: v.array(vStreamCursor),
|
|
435
|
-
}),
|
|
384
|
+
v.object({ kind: v.literal("list"), startOrder: v.optional(v.number()) }),
|
|
385
|
+
v.object({ kind: v.literal("deltas"), cursors: v.array(vStreamCursor) }),
|
|
436
386
|
),
|
|
437
387
|
);
|
|
438
388
|
export type StreamArgs = Infer<typeof vStreamArgs>;
|
|
@@ -459,6 +409,6 @@ export const vStreamDelta = v.object({
|
|
|
459
409
|
streamId: v.string(),
|
|
460
410
|
start: v.number(), // inclusive
|
|
461
411
|
end: v.number(), // exclusive
|
|
462
|
-
parts: v.array(
|
|
412
|
+
parts: v.array(v.any()),
|
|
463
413
|
});
|
|
464
414
|
export type StreamDelta = Infer<typeof vStreamDelta>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { PaginationOptions, PaginationResult } from "convex/server";
|
|
2
|
-
import type { AgentComponent, RunQueryCtx } from "./types.js";
|
|
3
|
-
import type { MessageStatus } from "../validators.js";
|
|
4
|
-
import type { MessageDoc } from "../component/schema.js";
|
|
5
|
-
/**
|
|
6
|
-
* List messages from a thread.
|
|
7
|
-
* @param ctx A ctx object from a query, mutation, or action.
|
|
8
|
-
* @param component The agent component, usually `components.agent`.
|
|
9
|
-
* @param args.threadId The thread to list messages from.
|
|
10
|
-
* @param args.paginationOpts Pagination options (e.g. via usePaginatedQuery).
|
|
11
|
-
* @param args.excludeToolMessages Whether to exclude tool messages.
|
|
12
|
-
* False by default.
|
|
13
|
-
* @param args.statuses What statuses to include. All by default.
|
|
14
|
-
* @returns The MessageDoc's in a format compatible with usePaginatedQuery.
|
|
15
|
-
*/
|
|
16
|
-
export declare function listMessages(ctx: RunQueryCtx, component: AgentComponent, args: {
|
|
17
|
-
threadId: string;
|
|
18
|
-
paginationOpts: PaginationOptions;
|
|
19
|
-
excludeToolMessages?: boolean;
|
|
20
|
-
statuses?: MessageStatus[];
|
|
21
|
-
}): Promise<PaginationResult<MessageDoc>>;
|
|
22
|
-
//# sourceMappingURL=listMessages.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listMessages.d.ts","sourceRoot":"","sources":["../../src/client/listMessages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE;IACJ,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,iBAAiB,CAAC;IAClC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B,GACA,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAYvC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* List messages from a thread.
|
|
3
|
-
* @param ctx A ctx object from a query, mutation, or action.
|
|
4
|
-
* @param component The agent component, usually `components.agent`.
|
|
5
|
-
* @param args.threadId The thread to list messages from.
|
|
6
|
-
* @param args.paginationOpts Pagination options (e.g. via usePaginatedQuery).
|
|
7
|
-
* @param args.excludeToolMessages Whether to exclude tool messages.
|
|
8
|
-
* False by default.
|
|
9
|
-
* @param args.statuses What statuses to include. All by default.
|
|
10
|
-
* @returns The MessageDoc's in a format compatible with usePaginatedQuery.
|
|
11
|
-
*/
|
|
12
|
-
export async function listMessages(ctx, component, args) {
|
|
13
|
-
if (args.paginationOpts.numItems === 0) {
|
|
14
|
-
return {
|
|
15
|
-
page: [],
|
|
16
|
-
isDone: true,
|
|
17
|
-
continueCursor: args.paginationOpts.cursor ?? "",
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
return ctx.runQuery(component.messages.listMessagesByThreadId, {
|
|
21
|
-
order: "desc",
|
|
22
|
-
...args,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=listMessages.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listMessages.js","sourceRoot":"","sources":["../../src/client/listMessages.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAgB,EAChB,SAAyB,EACzB,IAKC;IAED,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QACvC,OAAO;YACL,IAAI,EAAE,EAAE;YACR,MAAM,EAAE,IAAI;YACZ,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,IAAI,EAAE;SACjD,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE;QAC7D,KAAK,EAAE,MAAM;QACb,GAAG,IAAI;KACR,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { PaginationOptions, PaginationResult } from "convex/server";
|
|
2
|
-
import type { AgentComponent, RunQueryCtx } from "./types.js";
|
|
3
|
-
import type { MessageStatus } from "../validators.js";
|
|
4
|
-
import type { MessageDoc } from "../component/schema.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* List messages from a thread.
|
|
8
|
-
* @param ctx A ctx object from a query, mutation, or action.
|
|
9
|
-
* @param component The agent component, usually `components.agent`.
|
|
10
|
-
* @param args.threadId The thread to list messages from.
|
|
11
|
-
* @param args.paginationOpts Pagination options (e.g. via usePaginatedQuery).
|
|
12
|
-
* @param args.excludeToolMessages Whether to exclude tool messages.
|
|
13
|
-
* False by default.
|
|
14
|
-
* @param args.statuses What statuses to include. All by default.
|
|
15
|
-
* @returns The MessageDoc's in a format compatible with usePaginatedQuery.
|
|
16
|
-
*/
|
|
17
|
-
export async function listMessages(
|
|
18
|
-
ctx: RunQueryCtx,
|
|
19
|
-
component: AgentComponent,
|
|
20
|
-
args: {
|
|
21
|
-
threadId: string;
|
|
22
|
-
paginationOpts: PaginationOptions;
|
|
23
|
-
excludeToolMessages?: boolean;
|
|
24
|
-
statuses?: MessageStatus[];
|
|
25
|
-
},
|
|
26
|
-
): Promise<PaginationResult<MessageDoc>> {
|
|
27
|
-
if (args.paginationOpts.numItems === 0) {
|
|
28
|
-
return {
|
|
29
|
-
page: [],
|
|
30
|
-
isDone: true,
|
|
31
|
-
continueCursor: args.paginationOpts.cursor ?? "",
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
return ctx.runQuery(component.messages.listMessagesByThreadId, {
|
|
35
|
-
order: "desc",
|
|
36
|
-
...args,
|
|
37
|
-
});
|
|
38
|
-
}
|