@convex-dev/agent 0.2.2 → 0.2.3-alpha.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/definePlaygroundAPI.d.ts +85 -8
- package/dist/client/definePlaygroundAPI.d.ts.map +1 -1
- package/dist/client/index.d.ts +84 -6
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/messages.d.ts +18 -3
- package/dist/client/messages.d.ts.map +1 -1
- package/dist/client/messages.js +7 -4
- package/dist/client/messages.js.map +1 -1
- package/dist/client/search.d.ts +17 -2
- package/dist/client/search.d.ts.map +1 -1
- package/dist/client/streaming.d.ts +195 -21
- package/dist/client/streaming.d.ts.map +1 -1
- package/dist/component/_generated/api.d.ts +112 -15
- package/dist/component/messages.d.ts +187 -21
- package/dist/component/messages.d.ts.map +1 -1
- package/dist/component/schema.d.ts +517 -55
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/mapping.d.ts.map +1 -1
- package/dist/mapping.js +3 -4
- package/dist/mapping.js.map +1 -1
- package/dist/react/deltas.d.ts.map +1 -1
- package/dist/react/deltas.js +25 -4
- package/dist/react/deltas.js.map +1 -1
- package/dist/validators.d.ts +1257 -177
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +2 -3
- package/dist/validators.js.map +1 -1
- package/package.json +1 -1
- package/src/client/index.ts +20 -1
- package/src/client/messages.ts +12 -4
- package/src/component/_generated/api.d.ts +112 -15
- package/src/mapping.ts +8 -7
- package/src/react/deltas.ts +33 -8
- package/src/react/toUIMessages.test.ts +48 -4
- package/src/validators.ts +15 -15
|
@@ -167,14 +167,14 @@ describe("toUIMessages", () => {
|
|
|
167
167
|
expect(uiMessages[0].text).toBe("Here's one idea. Here's another idea.");
|
|
168
168
|
expect(uiMessages[0].parts.filter((p) => p.type === "reasoning")).toEqual([
|
|
169
169
|
{
|
|
170
|
-
|
|
171
|
-
state:
|
|
170
|
+
providerOptions: undefined,
|
|
171
|
+
state: "done",
|
|
172
172
|
text: "I'm thinking...",
|
|
173
173
|
type: "reasoning",
|
|
174
174
|
},
|
|
175
175
|
{
|
|
176
|
-
|
|
177
|
-
state:
|
|
176
|
+
providerOptions: undefined,
|
|
177
|
+
state: "done",
|
|
178
178
|
text: "I'm thinking...",
|
|
179
179
|
type: "reasoning",
|
|
180
180
|
},
|
|
@@ -356,6 +356,50 @@ describe("toUIMessages", () => {
|
|
|
356
356
|
expect(textParts[0].text).toBe("Hello!");
|
|
357
357
|
});
|
|
358
358
|
|
|
359
|
+
it("sets text field correctly when message has many parts with text part as final part", () => {
|
|
360
|
+
const messages = [
|
|
361
|
+
baseMessageDoc({
|
|
362
|
+
message: {
|
|
363
|
+
role: "assistant",
|
|
364
|
+
content: [
|
|
365
|
+
{
|
|
366
|
+
type: "reasoning",
|
|
367
|
+
text: "Let me think about this...",
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
type: "tool-call",
|
|
371
|
+
toolName: "calculator",
|
|
372
|
+
toolCallId: "call1",
|
|
373
|
+
args: { operation: "add", a: 2, b: 3 },
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
type: "file",
|
|
377
|
+
mimeType: "application/json",
|
|
378
|
+
data: "some-file-data",
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
type: "text",
|
|
382
|
+
text: "Here's my final answer.",
|
|
383
|
+
},
|
|
384
|
+
],
|
|
385
|
+
},
|
|
386
|
+
text: "Here's my final answer.",
|
|
387
|
+
reasoning: "Let me think about this...",
|
|
388
|
+
}),
|
|
389
|
+
];
|
|
390
|
+
|
|
391
|
+
const uiMessages = toUIMessages(messages);
|
|
392
|
+
|
|
393
|
+
expect(uiMessages).toHaveLength(1);
|
|
394
|
+
expect(uiMessages[0].role).toBe("assistant");
|
|
395
|
+
expect(uiMessages[0].text).toBe("Here's my final answer.");
|
|
396
|
+
|
|
397
|
+
// Verify that the text part exists in parts
|
|
398
|
+
const textParts = uiMessages[0].parts.filter((p) => p.type === "text");
|
|
399
|
+
expect(textParts).toHaveLength(1);
|
|
400
|
+
expect(textParts[0].text).toBe("Here's my final answer.");
|
|
401
|
+
});
|
|
402
|
+
|
|
359
403
|
// Add more tests for array content, tool calls, etc. as needed
|
|
360
404
|
|
|
361
405
|
it("should update tool call state from input-available to output-available", () => {
|
package/src/validators.ts
CHANGED
|
@@ -63,7 +63,6 @@ export const vReasoningPart = v.object({
|
|
|
63
63
|
text: v.string(),
|
|
64
64
|
signature: v.optional(v.string()),
|
|
65
65
|
providerOptions,
|
|
66
|
-
state: v.optional(v.union(v.literal("streaming"), v.literal("done"))),
|
|
67
66
|
});
|
|
68
67
|
|
|
69
68
|
export const vRedactedReasoningPart = v.object({
|
|
@@ -89,23 +88,10 @@ export const vToolCallPart = v.object({
|
|
|
89
88
|
toolCallId: v.string(),
|
|
90
89
|
toolName: v.string(),
|
|
91
90
|
args: v.any(),
|
|
92
|
-
providerOptions,
|
|
93
91
|
providerExecuted: v.optional(v.boolean()),
|
|
92
|
+
providerOptions,
|
|
94
93
|
});
|
|
95
94
|
|
|
96
|
-
export const vAssistantContent = v.union(
|
|
97
|
-
v.string(),
|
|
98
|
-
v.array(
|
|
99
|
-
v.union(
|
|
100
|
-
vTextPart,
|
|
101
|
-
vFilePart,
|
|
102
|
-
vReasoningPart,
|
|
103
|
-
vRedactedReasoningPart,
|
|
104
|
-
vToolCallPart,
|
|
105
|
-
),
|
|
106
|
-
),
|
|
107
|
-
);
|
|
108
|
-
|
|
109
95
|
const vToolResultContent = v.array(
|
|
110
96
|
v.union(
|
|
111
97
|
v.object({ type: v.literal("text"), text: v.string() }),
|
|
@@ -134,6 +120,20 @@ export const vToolResultPart = v.object({
|
|
|
134
120
|
});
|
|
135
121
|
export const vToolContent = v.array(vToolResultPart);
|
|
136
122
|
|
|
123
|
+
export const vAssistantContent = v.union(
|
|
124
|
+
v.string(),
|
|
125
|
+
v.array(
|
|
126
|
+
v.union(
|
|
127
|
+
vTextPart,
|
|
128
|
+
vFilePart,
|
|
129
|
+
vReasoningPart,
|
|
130
|
+
vRedactedReasoningPart,
|
|
131
|
+
vToolCallPart,
|
|
132
|
+
vToolResultPart,
|
|
133
|
+
),
|
|
134
|
+
),
|
|
135
|
+
);
|
|
136
|
+
|
|
137
137
|
export const vContent = v.union(vUserContent, vAssistantContent, vToolContent);
|
|
138
138
|
export type Content = Infer<typeof vContent>;
|
|
139
139
|
|