@convex-dev/agent 0.2.3-alpha.0 → 0.2.4-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 +59 -5
- package/dist/client/definePlaygroundAPI.d.ts.map +1 -1
- package/dist/client/files.d.ts +1 -1
- package/dist/client/files.d.ts.map +1 -1
- package/dist/client/files.js.map +1 -1
- package/dist/client/index.d.ts +46 -4
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +14 -13
- package/dist/client/index.js.map +1 -1
- package/dist/client/messages.d.ts +14 -2
- package/dist/client/messages.d.ts.map +1 -1
- package/dist/client/search.d.ts +14 -2
- package/dist/client/search.d.ts.map +1 -1
- package/dist/client/search.js +2 -4
- package/dist/client/search.js.map +1 -1
- package/dist/client/streaming.d.ts +132 -23
- package/dist/client/streaming.d.ts.map +1 -1
- package/dist/component/_generated/api.d.ts +189 -0
- package/dist/component/messages.d.ts +149 -20
- package/dist/component/messages.d.ts.map +1 -1
- package/dist/component/messages.js +4 -4
- package/dist/component/messages.js.map +1 -1
- package/dist/component/schema.d.ts +342 -63
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/mapping.d.ts +4 -4
- package/dist/mapping.d.ts.map +1 -1
- package/dist/mapping.js +67 -36
- package/dist/mapping.js.map +1 -1
- package/dist/react/deltas.d.ts +3 -3
- package/dist/react/deltas.d.ts.map +1 -1
- package/dist/react/deltas.js +302 -30
- package/dist/react/deltas.js.map +1 -1
- package/dist/react/toUIMessages.d.ts.map +1 -1
- package/dist/react/toUIMessages.js +289 -180
- package/dist/react/toUIMessages.js.map +1 -1
- package/dist/react/useSmoothText.d.ts.map +1 -1
- package/dist/react/useSmoothText.js +15 -6
- package/dist/react/useSmoothText.js.map +1 -1
- package/dist/shared.d.ts +4 -0
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +8 -0
- package/dist/shared.js.map +1 -1
- package/dist/validators.d.ts +662 -104
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +8 -0
- package/dist/validators.js.map +1 -1
- package/package.json +1 -1
- package/src/client/files.ts +4 -4
- package/src/client/index.ts +21 -20
- package/src/client/search.ts +2 -6
- package/src/component/_generated/api.d.ts +189 -0
- package/src/component/messages.ts +4 -3
- package/src/mapping.ts +99 -51
- package/src/react/deltas.ts +368 -48
- package/src/react/toUIMessages.test.ts +186 -0
- package/src/react/toUIMessages.ts +366 -192
- package/src/react/useSmoothText.ts +25 -13
- package/src/shared.ts +14 -0
- package/src/validators.ts +8 -0
|
@@ -461,4 +461,190 @@ describe("toUIMessages", () => {
|
|
|
461
461
|
);
|
|
462
462
|
expect(toolCallParts).toHaveLength(0);
|
|
463
463
|
});
|
|
464
|
+
it("sets text field correctly when message has many parts with text part as final part", () => {
|
|
465
|
+
const messages = [
|
|
466
|
+
baseMessageDoc({
|
|
467
|
+
text: "what time is it in paris?",
|
|
468
|
+
message: {
|
|
469
|
+
role: "user",
|
|
470
|
+
content: "what time is it in paris?",
|
|
471
|
+
},
|
|
472
|
+
}),
|
|
473
|
+
baseMessageDoc({
|
|
474
|
+
tool: true,
|
|
475
|
+
finishReason: "tool-calls",
|
|
476
|
+
text: "",
|
|
477
|
+
stepOrder: 1,
|
|
478
|
+
message: {
|
|
479
|
+
role: "assistant",
|
|
480
|
+
content: [
|
|
481
|
+
{
|
|
482
|
+
type: "reasoning",
|
|
483
|
+
text: "**Finding the Time**\n\nI've pinpointed the core task: obtaining the current time in Paris. It involves using the `dateTime` tool. I've identified \"Europe/Paris\" as the necessary timezone identifier to provide to the tool. My next step is to test the tool.\n\n\n",
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
args: {
|
|
487
|
+
timezone: "Europe/Paris",
|
|
488
|
+
},
|
|
489
|
+
type: "tool-call",
|
|
490
|
+
toolName: "dateTime",
|
|
491
|
+
toolCallId: "tool_0_dateTime",
|
|
492
|
+
},
|
|
493
|
+
],
|
|
494
|
+
},
|
|
495
|
+
reasoning:
|
|
496
|
+
"**Finding the Time**\n\nI've pinpointed the core task: obtaining the current time in Paris. It involves using the `dateTime` tool. I've identified \"Europe/Paris\" as the necessary timezone identifier to provide to the tool. My next step is to test the tool.\n\n\n",
|
|
497
|
+
reasoningDetails: [
|
|
498
|
+
{
|
|
499
|
+
text: "**Finding the Time**\n\nI've pinpointed the core task: obtaining the current time in Paris. It involves using the `dateTime` tool. I've identified \"Europe/Paris\" as the necessary timezone identifier to provide to the tool. My next step is to test the tool.\n\n\n",
|
|
500
|
+
type: "reasoning",
|
|
501
|
+
},
|
|
502
|
+
],
|
|
503
|
+
warnings: [],
|
|
504
|
+
}),
|
|
505
|
+
baseMessageDoc({
|
|
506
|
+
tool: true,
|
|
507
|
+
stepOrder: 2,
|
|
508
|
+
message: {
|
|
509
|
+
role: "tool",
|
|
510
|
+
content: [
|
|
511
|
+
{
|
|
512
|
+
type: "tool-result",
|
|
513
|
+
toolCallId: "tool_0_dateTime",
|
|
514
|
+
toolName: "dateTime",
|
|
515
|
+
result: {
|
|
516
|
+
type: "json",
|
|
517
|
+
value: {
|
|
518
|
+
day: "20",
|
|
519
|
+
hours: 16,
|
|
520
|
+
minutes: 3,
|
|
521
|
+
month: "August",
|
|
522
|
+
year: "2025",
|
|
523
|
+
},
|
|
524
|
+
},
|
|
525
|
+
},
|
|
526
|
+
],
|
|
527
|
+
},
|
|
528
|
+
sources: [],
|
|
529
|
+
}),
|
|
530
|
+
baseMessageDoc({
|
|
531
|
+
finishReason: "stop",
|
|
532
|
+
text: "The time in Paris, France is 4:03 PM on August 20, 2025.",
|
|
533
|
+
stepOrder: 3,
|
|
534
|
+
message: {
|
|
535
|
+
role: "assistant",
|
|
536
|
+
content: [
|
|
537
|
+
{
|
|
538
|
+
type: "text",
|
|
539
|
+
text: "The time in Paris, France is 4:03 PM on August 20, 2025.",
|
|
540
|
+
},
|
|
541
|
+
],
|
|
542
|
+
},
|
|
543
|
+
reasoningDetails: [],
|
|
544
|
+
sources: [],
|
|
545
|
+
warnings: [],
|
|
546
|
+
}),
|
|
547
|
+
];
|
|
548
|
+
|
|
549
|
+
const uiMessages = toUIMessages(messages);
|
|
550
|
+
|
|
551
|
+
expect(uiMessages).toHaveLength(2);
|
|
552
|
+
expect(uiMessages[0].role).toBe("user");
|
|
553
|
+
expect(uiMessages[0].text).toBe("what time is it in paris?");
|
|
554
|
+
expect(uiMessages[1].role).toBe("assistant");
|
|
555
|
+
expect(uiMessages[1].text).toBe(
|
|
556
|
+
"The time in Paris, France is 4:03 PM on August 20, 2025.",
|
|
557
|
+
);
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
it("handles messages in reverse order (assistant response, then tool response, then tool call)", () => {
|
|
561
|
+
const messages = [
|
|
562
|
+
// Final assistant response comes first (stepOrder 3) - no tool flag since it's the final message
|
|
563
|
+
baseMessageDoc({
|
|
564
|
+
_id: "msg3",
|
|
565
|
+
order: 1,
|
|
566
|
+
stepOrder: 3,
|
|
567
|
+
finishReason: "stop",
|
|
568
|
+
text: "The result is 42.",
|
|
569
|
+
tool: false, // This is the final message without tool calls
|
|
570
|
+
message: {
|
|
571
|
+
role: "assistant",
|
|
572
|
+
content: [
|
|
573
|
+
{
|
|
574
|
+
type: "text",
|
|
575
|
+
text: "The result is 42.",
|
|
576
|
+
},
|
|
577
|
+
],
|
|
578
|
+
},
|
|
579
|
+
}),
|
|
580
|
+
// Tool result comes second (stepOrder 2)
|
|
581
|
+
baseMessageDoc({
|
|
582
|
+
_id: "msg2",
|
|
583
|
+
order: 1,
|
|
584
|
+
stepOrder: 2,
|
|
585
|
+
tool: true,
|
|
586
|
+
message: {
|
|
587
|
+
role: "tool",
|
|
588
|
+
content: [
|
|
589
|
+
{
|
|
590
|
+
type: "tool-result",
|
|
591
|
+
toolCallId: "call1",
|
|
592
|
+
toolName: "calculator",
|
|
593
|
+
result: "42",
|
|
594
|
+
},
|
|
595
|
+
],
|
|
596
|
+
},
|
|
597
|
+
}),
|
|
598
|
+
// Tool call comes last (stepOrder 1)
|
|
599
|
+
baseMessageDoc({
|
|
600
|
+
_id: "msg1",
|
|
601
|
+
order: 1,
|
|
602
|
+
stepOrder: 1,
|
|
603
|
+
tool: true,
|
|
604
|
+
text: "",
|
|
605
|
+
message: {
|
|
606
|
+
role: "assistant",
|
|
607
|
+
content: [
|
|
608
|
+
{
|
|
609
|
+
type: "tool-call",
|
|
610
|
+
toolName: "calculator",
|
|
611
|
+
toolCallId: "call1",
|
|
612
|
+
args: { operation: "add", a: 40, b: 2 },
|
|
613
|
+
},
|
|
614
|
+
],
|
|
615
|
+
},
|
|
616
|
+
}),
|
|
617
|
+
];
|
|
618
|
+
|
|
619
|
+
const uiMessages = toUIMessages(messages);
|
|
620
|
+
|
|
621
|
+
expect(uiMessages).toHaveLength(1);
|
|
622
|
+
expect(uiMessages[0].role).toBe("assistant");
|
|
623
|
+
|
|
624
|
+
// Should concatenate text from all messages (only the final response has text)
|
|
625
|
+
expect(uiMessages[0].text).toBe("The result is 42.");
|
|
626
|
+
|
|
627
|
+
// Should use first message's fields (msg1 with stepOrder 1)
|
|
628
|
+
expect(uiMessages[0].id).toBe("msg1");
|
|
629
|
+
expect(uiMessages[0].order).toBe(1);
|
|
630
|
+
expect(uiMessages[0].stepOrder).toBe(1);
|
|
631
|
+
|
|
632
|
+
// Should have both tool call and result parts
|
|
633
|
+
const toolParts = uiMessages[0].parts.filter(
|
|
634
|
+
(p) => p.type === "tool-calculator",
|
|
635
|
+
);
|
|
636
|
+
expect(toolParts).toHaveLength(1);
|
|
637
|
+
expect(toolParts[0]).toMatchObject({
|
|
638
|
+
type: "tool-calculator",
|
|
639
|
+
toolCallId: "call1",
|
|
640
|
+
state: "output-available",
|
|
641
|
+
input: { operation: "add", a: 40, b: 2 },
|
|
642
|
+
output: "42",
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
// Should also have text part
|
|
646
|
+
const textParts = uiMessages[0].parts.filter((p) => p.type === "text");
|
|
647
|
+
expect(textParts).toHaveLength(1);
|
|
648
|
+
expect(textParts[0].text).toBe("The result is 42.");
|
|
649
|
+
});
|
|
464
650
|
});
|