@ag-ui/proto 0.0.48 → 0.0.49
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/README.md +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +517 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +517 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -410,6 +410,405 @@ const ToolCall_Function = {
|
|
|
410
410
|
return message;
|
|
411
411
|
}
|
|
412
412
|
};
|
|
413
|
+
function createBaseInputContentDataSource() {
|
|
414
|
+
return {
|
|
415
|
+
value: "",
|
|
416
|
+
mimeType: ""
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
const InputContentDataSource = {
|
|
420
|
+
encode(message, writer = new BinaryWriter()) {
|
|
421
|
+
if (message.value !== "") writer.uint32(10).string(message.value);
|
|
422
|
+
if (message.mimeType !== "") writer.uint32(18).string(message.mimeType);
|
|
423
|
+
return writer;
|
|
424
|
+
},
|
|
425
|
+
decode(input, length) {
|
|
426
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
427
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
428
|
+
const message = createBaseInputContentDataSource();
|
|
429
|
+
while (reader.pos < end) {
|
|
430
|
+
const tag = reader.uint32();
|
|
431
|
+
switch (tag >>> 3) {
|
|
432
|
+
case 1:
|
|
433
|
+
if (tag !== 10) break;
|
|
434
|
+
message.value = reader.string();
|
|
435
|
+
continue;
|
|
436
|
+
case 2:
|
|
437
|
+
if (tag !== 18) break;
|
|
438
|
+
message.mimeType = reader.string();
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
442
|
+
reader.skip(tag & 7);
|
|
443
|
+
}
|
|
444
|
+
return message;
|
|
445
|
+
},
|
|
446
|
+
create(base) {
|
|
447
|
+
return InputContentDataSource.fromPartial(base ?? {});
|
|
448
|
+
},
|
|
449
|
+
fromPartial(object) {
|
|
450
|
+
const message = createBaseInputContentDataSource();
|
|
451
|
+
message.value = object.value ?? "";
|
|
452
|
+
message.mimeType = object.mimeType ?? "";
|
|
453
|
+
return message;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
function createBaseInputContentUrlSource() {
|
|
457
|
+
return {
|
|
458
|
+
value: "",
|
|
459
|
+
mimeType: void 0
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
const InputContentUrlSource = {
|
|
463
|
+
encode(message, writer = new BinaryWriter()) {
|
|
464
|
+
if (message.value !== "") writer.uint32(10).string(message.value);
|
|
465
|
+
if (message.mimeType !== void 0) writer.uint32(18).string(message.mimeType);
|
|
466
|
+
return writer;
|
|
467
|
+
},
|
|
468
|
+
decode(input, length) {
|
|
469
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
470
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
471
|
+
const message = createBaseInputContentUrlSource();
|
|
472
|
+
while (reader.pos < end) {
|
|
473
|
+
const tag = reader.uint32();
|
|
474
|
+
switch (tag >>> 3) {
|
|
475
|
+
case 1:
|
|
476
|
+
if (tag !== 10) break;
|
|
477
|
+
message.value = reader.string();
|
|
478
|
+
continue;
|
|
479
|
+
case 2:
|
|
480
|
+
if (tag !== 18) break;
|
|
481
|
+
message.mimeType = reader.string();
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
485
|
+
reader.skip(tag & 7);
|
|
486
|
+
}
|
|
487
|
+
return message;
|
|
488
|
+
},
|
|
489
|
+
create(base) {
|
|
490
|
+
return InputContentUrlSource.fromPartial(base ?? {});
|
|
491
|
+
},
|
|
492
|
+
fromPartial(object) {
|
|
493
|
+
const message = createBaseInputContentUrlSource();
|
|
494
|
+
message.value = object.value ?? "";
|
|
495
|
+
message.mimeType = object.mimeType ?? void 0;
|
|
496
|
+
return message;
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
function createBaseInputContentSource() {
|
|
500
|
+
return {
|
|
501
|
+
data: void 0,
|
|
502
|
+
url: void 0
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
const InputContentSource = {
|
|
506
|
+
encode(message, writer = new BinaryWriter()) {
|
|
507
|
+
if (message.data !== void 0) InputContentDataSource.encode(message.data, writer.uint32(10).fork()).join();
|
|
508
|
+
if (message.url !== void 0) InputContentUrlSource.encode(message.url, writer.uint32(18).fork()).join();
|
|
509
|
+
return writer;
|
|
510
|
+
},
|
|
511
|
+
decode(input, length) {
|
|
512
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
513
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
514
|
+
const message = createBaseInputContentSource();
|
|
515
|
+
while (reader.pos < end) {
|
|
516
|
+
const tag = reader.uint32();
|
|
517
|
+
switch (tag >>> 3) {
|
|
518
|
+
case 1:
|
|
519
|
+
if (tag !== 10) break;
|
|
520
|
+
message.data = InputContentDataSource.decode(reader, reader.uint32());
|
|
521
|
+
continue;
|
|
522
|
+
case 2:
|
|
523
|
+
if (tag !== 18) break;
|
|
524
|
+
message.url = InputContentUrlSource.decode(reader, reader.uint32());
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
528
|
+
reader.skip(tag & 7);
|
|
529
|
+
}
|
|
530
|
+
return message;
|
|
531
|
+
},
|
|
532
|
+
create(base) {
|
|
533
|
+
return InputContentSource.fromPartial(base ?? {});
|
|
534
|
+
},
|
|
535
|
+
fromPartial(object) {
|
|
536
|
+
const message = createBaseInputContentSource();
|
|
537
|
+
message.data = object.data !== void 0 && object.data !== null ? InputContentDataSource.fromPartial(object.data) : void 0;
|
|
538
|
+
message.url = object.url !== void 0 && object.url !== null ? InputContentUrlSource.fromPartial(object.url) : void 0;
|
|
539
|
+
return message;
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
function createBaseTextInputPart() {
|
|
543
|
+
return { text: "" };
|
|
544
|
+
}
|
|
545
|
+
const TextInputPart = {
|
|
546
|
+
encode(message, writer = new BinaryWriter()) {
|
|
547
|
+
if (message.text !== "") writer.uint32(10).string(message.text);
|
|
548
|
+
return writer;
|
|
549
|
+
},
|
|
550
|
+
decode(input, length) {
|
|
551
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
552
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
553
|
+
const message = createBaseTextInputPart();
|
|
554
|
+
while (reader.pos < end) {
|
|
555
|
+
const tag = reader.uint32();
|
|
556
|
+
switch (tag >>> 3) {
|
|
557
|
+
case 1:
|
|
558
|
+
if (tag !== 10) break;
|
|
559
|
+
message.text = reader.string();
|
|
560
|
+
continue;
|
|
561
|
+
}
|
|
562
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
563
|
+
reader.skip(tag & 7);
|
|
564
|
+
}
|
|
565
|
+
return message;
|
|
566
|
+
},
|
|
567
|
+
create(base) {
|
|
568
|
+
return TextInputPart.fromPartial(base ?? {});
|
|
569
|
+
},
|
|
570
|
+
fromPartial(object) {
|
|
571
|
+
const message = createBaseTextInputPart();
|
|
572
|
+
message.text = object.text ?? "";
|
|
573
|
+
return message;
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
function createBaseImageInputPart() {
|
|
577
|
+
return {
|
|
578
|
+
source: void 0,
|
|
579
|
+
metadata: void 0
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
const ImageInputPart = {
|
|
583
|
+
encode(message, writer = new BinaryWriter()) {
|
|
584
|
+
if (message.source !== void 0) InputContentSource.encode(message.source, writer.uint32(10).fork()).join();
|
|
585
|
+
if (message.metadata !== void 0) Value.encode(Value.wrap(message.metadata), writer.uint32(18).fork()).join();
|
|
586
|
+
return writer;
|
|
587
|
+
},
|
|
588
|
+
decode(input, length) {
|
|
589
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
590
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
591
|
+
const message = createBaseImageInputPart();
|
|
592
|
+
while (reader.pos < end) {
|
|
593
|
+
const tag = reader.uint32();
|
|
594
|
+
switch (tag >>> 3) {
|
|
595
|
+
case 1:
|
|
596
|
+
if (tag !== 10) break;
|
|
597
|
+
message.source = InputContentSource.decode(reader, reader.uint32());
|
|
598
|
+
continue;
|
|
599
|
+
case 2:
|
|
600
|
+
if (tag !== 18) break;
|
|
601
|
+
message.metadata = Value.unwrap(Value.decode(reader, reader.uint32()));
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
605
|
+
reader.skip(tag & 7);
|
|
606
|
+
}
|
|
607
|
+
return message;
|
|
608
|
+
},
|
|
609
|
+
create(base) {
|
|
610
|
+
return ImageInputPart.fromPartial(base ?? {});
|
|
611
|
+
},
|
|
612
|
+
fromPartial(object) {
|
|
613
|
+
const message = createBaseImageInputPart();
|
|
614
|
+
message.source = object.source !== void 0 && object.source !== null ? InputContentSource.fromPartial(object.source) : void 0;
|
|
615
|
+
message.metadata = object.metadata ?? void 0;
|
|
616
|
+
return message;
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
function createBaseAudioInputPart() {
|
|
620
|
+
return {
|
|
621
|
+
source: void 0,
|
|
622
|
+
metadata: void 0
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
const AudioInputPart = {
|
|
626
|
+
encode(message, writer = new BinaryWriter()) {
|
|
627
|
+
if (message.source !== void 0) InputContentSource.encode(message.source, writer.uint32(10).fork()).join();
|
|
628
|
+
if (message.metadata !== void 0) Value.encode(Value.wrap(message.metadata), writer.uint32(18).fork()).join();
|
|
629
|
+
return writer;
|
|
630
|
+
},
|
|
631
|
+
decode(input, length) {
|
|
632
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
633
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
634
|
+
const message = createBaseAudioInputPart();
|
|
635
|
+
while (reader.pos < end) {
|
|
636
|
+
const tag = reader.uint32();
|
|
637
|
+
switch (tag >>> 3) {
|
|
638
|
+
case 1:
|
|
639
|
+
if (tag !== 10) break;
|
|
640
|
+
message.source = InputContentSource.decode(reader, reader.uint32());
|
|
641
|
+
continue;
|
|
642
|
+
case 2:
|
|
643
|
+
if (tag !== 18) break;
|
|
644
|
+
message.metadata = Value.unwrap(Value.decode(reader, reader.uint32()));
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
648
|
+
reader.skip(tag & 7);
|
|
649
|
+
}
|
|
650
|
+
return message;
|
|
651
|
+
},
|
|
652
|
+
create(base) {
|
|
653
|
+
return AudioInputPart.fromPartial(base ?? {});
|
|
654
|
+
},
|
|
655
|
+
fromPartial(object) {
|
|
656
|
+
const message = createBaseAudioInputPart();
|
|
657
|
+
message.source = object.source !== void 0 && object.source !== null ? InputContentSource.fromPartial(object.source) : void 0;
|
|
658
|
+
message.metadata = object.metadata ?? void 0;
|
|
659
|
+
return message;
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
function createBaseVideoInputPart() {
|
|
663
|
+
return {
|
|
664
|
+
source: void 0,
|
|
665
|
+
metadata: void 0
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
const VideoInputPart = {
|
|
669
|
+
encode(message, writer = new BinaryWriter()) {
|
|
670
|
+
if (message.source !== void 0) InputContentSource.encode(message.source, writer.uint32(10).fork()).join();
|
|
671
|
+
if (message.metadata !== void 0) Value.encode(Value.wrap(message.metadata), writer.uint32(18).fork()).join();
|
|
672
|
+
return writer;
|
|
673
|
+
},
|
|
674
|
+
decode(input, length) {
|
|
675
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
676
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
677
|
+
const message = createBaseVideoInputPart();
|
|
678
|
+
while (reader.pos < end) {
|
|
679
|
+
const tag = reader.uint32();
|
|
680
|
+
switch (tag >>> 3) {
|
|
681
|
+
case 1:
|
|
682
|
+
if (tag !== 10) break;
|
|
683
|
+
message.source = InputContentSource.decode(reader, reader.uint32());
|
|
684
|
+
continue;
|
|
685
|
+
case 2:
|
|
686
|
+
if (tag !== 18) break;
|
|
687
|
+
message.metadata = Value.unwrap(Value.decode(reader, reader.uint32()));
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
691
|
+
reader.skip(tag & 7);
|
|
692
|
+
}
|
|
693
|
+
return message;
|
|
694
|
+
},
|
|
695
|
+
create(base) {
|
|
696
|
+
return VideoInputPart.fromPartial(base ?? {});
|
|
697
|
+
},
|
|
698
|
+
fromPartial(object) {
|
|
699
|
+
const message = createBaseVideoInputPart();
|
|
700
|
+
message.source = object.source !== void 0 && object.source !== null ? InputContentSource.fromPartial(object.source) : void 0;
|
|
701
|
+
message.metadata = object.metadata ?? void 0;
|
|
702
|
+
return message;
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
function createBaseDocumentInputPart() {
|
|
706
|
+
return {
|
|
707
|
+
source: void 0,
|
|
708
|
+
metadata: void 0
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
const DocumentInputPart = {
|
|
712
|
+
encode(message, writer = new BinaryWriter()) {
|
|
713
|
+
if (message.source !== void 0) InputContentSource.encode(message.source, writer.uint32(10).fork()).join();
|
|
714
|
+
if (message.metadata !== void 0) Value.encode(Value.wrap(message.metadata), writer.uint32(18).fork()).join();
|
|
715
|
+
return writer;
|
|
716
|
+
},
|
|
717
|
+
decode(input, length) {
|
|
718
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
719
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
720
|
+
const message = createBaseDocumentInputPart();
|
|
721
|
+
while (reader.pos < end) {
|
|
722
|
+
const tag = reader.uint32();
|
|
723
|
+
switch (tag >>> 3) {
|
|
724
|
+
case 1:
|
|
725
|
+
if (tag !== 10) break;
|
|
726
|
+
message.source = InputContentSource.decode(reader, reader.uint32());
|
|
727
|
+
continue;
|
|
728
|
+
case 2:
|
|
729
|
+
if (tag !== 18) break;
|
|
730
|
+
message.metadata = Value.unwrap(Value.decode(reader, reader.uint32()));
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
733
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
734
|
+
reader.skip(tag & 7);
|
|
735
|
+
}
|
|
736
|
+
return message;
|
|
737
|
+
},
|
|
738
|
+
create(base) {
|
|
739
|
+
return DocumentInputPart.fromPartial(base ?? {});
|
|
740
|
+
},
|
|
741
|
+
fromPartial(object) {
|
|
742
|
+
const message = createBaseDocumentInputPart();
|
|
743
|
+
message.source = object.source !== void 0 && object.source !== null ? InputContentSource.fromPartial(object.source) : void 0;
|
|
744
|
+
message.metadata = object.metadata ?? void 0;
|
|
745
|
+
return message;
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
function createBaseInputContent() {
|
|
749
|
+
return {
|
|
750
|
+
text: void 0,
|
|
751
|
+
image: void 0,
|
|
752
|
+
audio: void 0,
|
|
753
|
+
video: void 0,
|
|
754
|
+
document: void 0
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
const InputContent = {
|
|
758
|
+
encode(message, writer = new BinaryWriter()) {
|
|
759
|
+
if (message.text !== void 0) TextInputPart.encode(message.text, writer.uint32(10).fork()).join();
|
|
760
|
+
if (message.image !== void 0) ImageInputPart.encode(message.image, writer.uint32(18).fork()).join();
|
|
761
|
+
if (message.audio !== void 0) AudioInputPart.encode(message.audio, writer.uint32(26).fork()).join();
|
|
762
|
+
if (message.video !== void 0) VideoInputPart.encode(message.video, writer.uint32(34).fork()).join();
|
|
763
|
+
if (message.document !== void 0) DocumentInputPart.encode(message.document, writer.uint32(42).fork()).join();
|
|
764
|
+
return writer;
|
|
765
|
+
},
|
|
766
|
+
decode(input, length) {
|
|
767
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
768
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
769
|
+
const message = createBaseInputContent();
|
|
770
|
+
while (reader.pos < end) {
|
|
771
|
+
const tag = reader.uint32();
|
|
772
|
+
switch (tag >>> 3) {
|
|
773
|
+
case 1:
|
|
774
|
+
if (tag !== 10) break;
|
|
775
|
+
message.text = TextInputPart.decode(reader, reader.uint32());
|
|
776
|
+
continue;
|
|
777
|
+
case 2:
|
|
778
|
+
if (tag !== 18) break;
|
|
779
|
+
message.image = ImageInputPart.decode(reader, reader.uint32());
|
|
780
|
+
continue;
|
|
781
|
+
case 3:
|
|
782
|
+
if (tag !== 26) break;
|
|
783
|
+
message.audio = AudioInputPart.decode(reader, reader.uint32());
|
|
784
|
+
continue;
|
|
785
|
+
case 4:
|
|
786
|
+
if (tag !== 34) break;
|
|
787
|
+
message.video = VideoInputPart.decode(reader, reader.uint32());
|
|
788
|
+
continue;
|
|
789
|
+
case 5:
|
|
790
|
+
if (tag !== 42) break;
|
|
791
|
+
message.document = DocumentInputPart.decode(reader, reader.uint32());
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
794
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
795
|
+
reader.skip(tag & 7);
|
|
796
|
+
}
|
|
797
|
+
return message;
|
|
798
|
+
},
|
|
799
|
+
create(base) {
|
|
800
|
+
return InputContent.fromPartial(base ?? {});
|
|
801
|
+
},
|
|
802
|
+
fromPartial(object) {
|
|
803
|
+
const message = createBaseInputContent();
|
|
804
|
+
message.text = object.text !== void 0 && object.text !== null ? TextInputPart.fromPartial(object.text) : void 0;
|
|
805
|
+
message.image = object.image !== void 0 && object.image !== null ? ImageInputPart.fromPartial(object.image) : void 0;
|
|
806
|
+
message.audio = object.audio !== void 0 && object.audio !== null ? AudioInputPart.fromPartial(object.audio) : void 0;
|
|
807
|
+
message.video = object.video !== void 0 && object.video !== null ? VideoInputPart.fromPartial(object.video) : void 0;
|
|
808
|
+
message.document = object.document !== void 0 && object.document !== null ? DocumentInputPart.fromPartial(object.document) : void 0;
|
|
809
|
+
return message;
|
|
810
|
+
}
|
|
811
|
+
};
|
|
413
812
|
function createBaseMessage() {
|
|
414
813
|
return {
|
|
415
814
|
id: "",
|
|
@@ -418,7 +817,8 @@ function createBaseMessage() {
|
|
|
418
817
|
name: void 0,
|
|
419
818
|
toolCalls: [],
|
|
420
819
|
toolCallId: void 0,
|
|
421
|
-
error: void 0
|
|
820
|
+
error: void 0,
|
|
821
|
+
contentParts: []
|
|
422
822
|
};
|
|
423
823
|
}
|
|
424
824
|
const Message = {
|
|
@@ -430,6 +830,7 @@ const Message = {
|
|
|
430
830
|
for (const v of message.toolCalls) ToolCall.encode(v, writer.uint32(42).fork()).join();
|
|
431
831
|
if (message.toolCallId !== void 0) writer.uint32(50).string(message.toolCallId);
|
|
432
832
|
if (message.error !== void 0) writer.uint32(58).string(message.error);
|
|
833
|
+
for (const v of message.contentParts) InputContent.encode(v, writer.uint32(66).fork()).join();
|
|
433
834
|
return writer;
|
|
434
835
|
},
|
|
435
836
|
decode(input, length) {
|
|
@@ -467,6 +868,10 @@ const Message = {
|
|
|
467
868
|
if (tag !== 58) break;
|
|
468
869
|
message.error = reader.string();
|
|
469
870
|
continue;
|
|
871
|
+
case 8:
|
|
872
|
+
if (tag !== 66) break;
|
|
873
|
+
message.contentParts.push(InputContent.decode(reader, reader.uint32()));
|
|
874
|
+
continue;
|
|
470
875
|
}
|
|
471
876
|
if ((tag & 7) === 4 || tag === 0) break;
|
|
472
877
|
reader.skip(tag & 7);
|
|
@@ -485,6 +890,7 @@ const Message = {
|
|
|
485
890
|
message.toolCalls = object.toolCalls?.map((e) => ToolCall.fromPartial(e)) || [];
|
|
486
891
|
message.toolCallId = object.toolCallId ?? void 0;
|
|
487
892
|
message.error = object.error ?? void 0;
|
|
893
|
+
message.contentParts = object.contentParts?.map((e) => InputContent.fromPartial(e)) || [];
|
|
488
894
|
return message;
|
|
489
895
|
}
|
|
490
896
|
};
|
|
@@ -1625,6 +2031,101 @@ function longToNumber(int64) {
|
|
|
1625
2031
|
|
|
1626
2032
|
//#endregion
|
|
1627
2033
|
//#region src/proto.ts
|
|
2034
|
+
const toProtoSource = (source) => {
|
|
2035
|
+
if (!source || typeof source !== "object") return;
|
|
2036
|
+
if (source.type === "data") return { data: {
|
|
2037
|
+
value: source.value,
|
|
2038
|
+
mimeType: source.mimeType
|
|
2039
|
+
} };
|
|
2040
|
+
if (source.type === "url") return { url: {
|
|
2041
|
+
value: source.value,
|
|
2042
|
+
mimeType: source.mimeType
|
|
2043
|
+
} };
|
|
2044
|
+
};
|
|
2045
|
+
const toProtoContentPart = (part) => {
|
|
2046
|
+
if (!part || typeof part !== "object") return;
|
|
2047
|
+
switch (part.type) {
|
|
2048
|
+
case "text": return { text: { text: part.text } };
|
|
2049
|
+
case "image": return { image: {
|
|
2050
|
+
source: toProtoSource(part.source),
|
|
2051
|
+
metadata: part.metadata
|
|
2052
|
+
} };
|
|
2053
|
+
case "audio": return { audio: {
|
|
2054
|
+
source: toProtoSource(part.source),
|
|
2055
|
+
metadata: part.metadata
|
|
2056
|
+
} };
|
|
2057
|
+
case "video": return { video: {
|
|
2058
|
+
source: toProtoSource(part.source),
|
|
2059
|
+
metadata: part.metadata
|
|
2060
|
+
} };
|
|
2061
|
+
case "document": return { document: {
|
|
2062
|
+
source: toProtoSource(part.source),
|
|
2063
|
+
metadata: part.metadata
|
|
2064
|
+
} };
|
|
2065
|
+
case "binary": {
|
|
2066
|
+
const source = part.data ? { data: {
|
|
2067
|
+
value: part.data,
|
|
2068
|
+
mimeType: part.mimeType
|
|
2069
|
+
} } : part.url ? { url: {
|
|
2070
|
+
value: part.url,
|
|
2071
|
+
mimeType: part.mimeType
|
|
2072
|
+
} } : part.id ? { url: {
|
|
2073
|
+
value: part.id,
|
|
2074
|
+
mimeType: part.mimeType
|
|
2075
|
+
} } : void 0;
|
|
2076
|
+
if (!source) return;
|
|
2077
|
+
return { document: {
|
|
2078
|
+
source,
|
|
2079
|
+
metadata: {
|
|
2080
|
+
legacyBinary: true,
|
|
2081
|
+
filename: part.filename,
|
|
2082
|
+
id: part.id
|
|
2083
|
+
}
|
|
2084
|
+
} };
|
|
2085
|
+
}
|
|
2086
|
+
default: return;
|
|
2087
|
+
}
|
|
2088
|
+
};
|
|
2089
|
+
const fromProtoSource = (source) => {
|
|
2090
|
+
if (!source || typeof source !== "object") return;
|
|
2091
|
+
if (source.data) return {
|
|
2092
|
+
type: "data",
|
|
2093
|
+
value: source.data.value,
|
|
2094
|
+
mimeType: source.data.mimeType
|
|
2095
|
+
};
|
|
2096
|
+
if (source.url) return {
|
|
2097
|
+
type: "url",
|
|
2098
|
+
value: source.url.value,
|
|
2099
|
+
mimeType: source.url.mimeType
|
|
2100
|
+
};
|
|
2101
|
+
};
|
|
2102
|
+
const fromProtoContentPart = (part) => {
|
|
2103
|
+
if (!part || typeof part !== "object") return;
|
|
2104
|
+
if (part.text) return {
|
|
2105
|
+
type: "text",
|
|
2106
|
+
text: part.text.text
|
|
2107
|
+
};
|
|
2108
|
+
if (part.image) return {
|
|
2109
|
+
type: "image",
|
|
2110
|
+
source: fromProtoSource(part.image.source),
|
|
2111
|
+
metadata: part.image.metadata
|
|
2112
|
+
};
|
|
2113
|
+
if (part.audio) return {
|
|
2114
|
+
type: "audio",
|
|
2115
|
+
source: fromProtoSource(part.audio.source),
|
|
2116
|
+
metadata: part.audio.metadata
|
|
2117
|
+
};
|
|
2118
|
+
if (part.video) return {
|
|
2119
|
+
type: "video",
|
|
2120
|
+
source: fromProtoSource(part.video.source),
|
|
2121
|
+
metadata: part.video.metadata
|
|
2122
|
+
};
|
|
2123
|
+
if (part.document) return {
|
|
2124
|
+
type: "document",
|
|
2125
|
+
source: fromProtoSource(part.document.source),
|
|
2126
|
+
metadata: part.document.metadata
|
|
2127
|
+
};
|
|
2128
|
+
};
|
|
1628
2129
|
function toCamelCase(str) {
|
|
1629
2130
|
return str.toLowerCase().replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
1630
2131
|
}
|
|
@@ -1653,11 +2154,17 @@ function encode(event) {
|
|
|
1653
2154
|
const oneofField = toCamelCase(validatedEvent.type);
|
|
1654
2155
|
const { type, timestamp, rawEvent, ...rest } = validatedEvent;
|
|
1655
2156
|
if (type === EventType.MESSAGES_SNAPSHOT && Array.isArray(rest.messages)) rest.messages = rest.messages.map((message) => {
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
2157
|
+
const untypedMessage = message;
|
|
2158
|
+
const normalizedMessage = {
|
|
2159
|
+
...untypedMessage,
|
|
2160
|
+
contentParts: []
|
|
1659
2161
|
};
|
|
1660
|
-
|
|
2162
|
+
if (Array.isArray(untypedMessage.content)) {
|
|
2163
|
+
normalizedMessage.contentParts = untypedMessage.content.map((part) => toProtoContentPart(part)).filter((part) => part !== void 0);
|
|
2164
|
+
normalizedMessage.content = void 0;
|
|
2165
|
+
}
|
|
2166
|
+
if (untypedMessage.toolCalls === void 0) normalizedMessage.toolCalls = [];
|
|
2167
|
+
return normalizedMessage;
|
|
1661
2168
|
});
|
|
1662
2169
|
if (type === EventType.STATE_DELTA && Array.isArray(rest.delta)) rest.delta = rest.delta.map((operation) => ({
|
|
1663
2170
|
...operation,
|
|
@@ -1686,6 +2193,11 @@ function decode(data) {
|
|
|
1686
2193
|
decoded.rawEvent = decoded.baseEvent.rawEvent;
|
|
1687
2194
|
if (decoded.type === EventType.MESSAGES_SNAPSHOT) for (const message of decoded.messages) {
|
|
1688
2195
|
const untypedMessage = message;
|
|
2196
|
+
if (untypedMessage.role === "user" && Array.isArray(untypedMessage.contentParts)) {
|
|
2197
|
+
const contentParts = untypedMessage.contentParts.map((part) => fromProtoContentPart(part)).filter((part) => part !== void 0);
|
|
2198
|
+
if (contentParts.length > 0) untypedMessage.content = contentParts;
|
|
2199
|
+
}
|
|
2200
|
+
if (Array.isArray(untypedMessage.contentParts) && untypedMessage.contentParts.length === 0) untypedMessage.contentParts = void 0;
|
|
1689
2201
|
if (untypedMessage.toolCalls?.length === 0) untypedMessage.toolCalls = void 0;
|
|
1690
2202
|
}
|
|
1691
2203
|
if (decoded.type === EventType.STATE_DELTA) for (const operation of decoded.delta) {
|