Commit ac6c6f4
feat(teams): deliver outbound files via data-URI activity attachments (#125)
* feat(teams): deliver outbound files via data-URI activity attachments
Port upstream filesToAttachments (packages/adapter-teams/src/index.ts
~1006-1035) to Python. The Teams adapter previously dropped a Postable's
.files entirely -- post_message/edit_message never called extract_files,
so execution artifacts silently vanished.
Adds TeamsAdapter._files_to_attachments: resolves each FileUpload's bytes
via to_buffer(..., throw_on_unsupported=False), base64-encodes them, and
builds a Bot Framework attachment {contentType, contentUrl:
data:<mime>;base64,<b64>, name}. mime defaults to
application/octet-stream; files whose data can't be resolved to bytes are
skipped with a debug log (mirrors upstream's `if (!buffer) continue`).
post_message and edit_message now call extract_files and attach the
results: the adaptive-card branch appends file attachments after the card
attachment; the text branch sets attachments to the file attachments when
present.
Adds TestFileAttachments (5 tests): text+file, card+file (both
attachments present), edit_message+file, octet-stream default, and the
skip-unresolvable-bytes branch.
* fix(teams): scope file delivery to post_message only (upstream fidelity)
The initial port wired filesToAttachments into both post_message AND
edit_message. Upstream vercel/chat wires it into postMessage +
postChannelMessage only — editMessage never carries files. And chinchill
delivers execution artifacts via a fresh post(), never by editing files
into an existing message. Carrying files in edit_message was an
unrequested divergence (and an edit_message+files test has no upstream
counterpart, which the repo's verify_test_fidelity gate would flag).
Revert edit_message to file-free, mirroring upstream. Replace the
edit_message+file test with a fidelity guard asserting edit_message
carries no file attachments. post_message file delivery (the actual
parity fix) is unchanged.
* test(teams): cover multi-file delivery + tighten skip-log
Self-review (two adversarial reviewers) found:
- MEDIUM: multi-file handling untested — mutation showed return attachments[:1]
(drop all but first) and reversed() both passed green, so a regression that
drops/reorders artifacts would merge undetected, defeating the parity goal.
Added test_multiple_files_attached_in_order (N files -> N attachments, input
order) + test_partial_skip_preserves_surviving_files (good/bad/good -> survivors
in order). Mutation-verified: [:1] now FAILS the multi-file test.
- LOW: the skip test's log assertion was hollow (post_message emits an
unconditional 'send (message)' debug, so it passed even if the skip branch
logged nothing). Now asserts the SPECIFIC 'unsupported data' skip log.
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 09a47bc commit ac6c6f4
2 files changed
Lines changed: 253 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
1038 | 1040 | | |
1039 | 1041 | | |
1040 | 1042 | | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
1041 | 1077 | | |
1042 | 1078 | | |
1043 | 1079 | | |
| |||
1046 | 1082 | | |
1047 | 1083 | | |
1048 | 1084 | | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
1049 | 1088 | | |
1050 | 1089 | | |
1051 | 1090 | | |
| |||
1055 | 1094 | | |
1056 | 1095 | | |
1057 | 1096 | | |
1058 | | - | |
| 1097 | + | |
| 1098 | + | |
1059 | 1099 | | |
1060 | 1100 | | |
1061 | 1101 | | |
1062 | 1102 | | |
1063 | 1103 | | |
1064 | 1104 | | |
1065 | 1105 | | |
| 1106 | + | |
1066 | 1107 | | |
1067 | 1108 | | |
1068 | 1109 | | |
| |||
1089 | 1130 | | |
1090 | 1131 | | |
1091 | 1132 | | |
1092 | | - | |
| 1133 | + | |
1093 | 1134 | | |
1094 | 1135 | | |
1095 | 1136 | | |
1096 | 1137 | | |
| 1138 | + | |
| 1139 | + | |
1097 | 1140 | | |
1098 | 1141 | | |
1099 | 1142 | | |
1100 | 1143 | | |
1101 | 1144 | | |
1102 | 1145 | | |
| 1146 | + | |
1103 | 1147 | | |
1104 | 1148 | | |
1105 | 1149 | | |
| |||
1127 | 1171 | | |
1128 | 1172 | | |
1129 | 1173 | | |
1130 | | - | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
1131 | 1183 | | |
1132 | 1184 | | |
1133 | 1185 | | |
| |||
1139 | 1191 | | |
1140 | 1192 | | |
1141 | 1193 | | |
1142 | | - | |
| 1194 | + | |
1143 | 1195 | | |
1144 | 1196 | | |
1145 | 1197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
694 | 694 | | |
695 | 695 | | |
696 | 696 | | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
697 | 893 | | |
698 | 894 | | |
699 | 895 | | |
| |||
0 commit comments