@vrs-soft/wecom-aibot-mcp 3.3.0 → 3.3.1
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/channel-server.js +10 -7
- package/package.json +1 -1
package/dist/channel-server.js
CHANGED
|
@@ -89,18 +89,20 @@ async function sendWecomMediaFromFile(args) {
|
|
|
89
89
|
}
|
|
90
90
|
const filename = args.filename || path.basename(abs);
|
|
91
91
|
const buf = fs.readFileSync(abs);
|
|
92
|
+
// v3.3.1: 所有可能包含 CJK 的 header 值必须 encodeURIComponent —— HTTP header 值受 ISO-8859-1 限制,
|
|
93
|
+
// node fetch 见到 char > 255 直接抛 ByteString TypeError。daemon 端 getHeaderStr 会 decodeURIComponent。
|
|
92
94
|
const headers = {
|
|
93
95
|
'Content-Type': 'application/octet-stream',
|
|
94
96
|
'Content-Length': String(buf.length),
|
|
95
|
-
'X-Target-User': args.target_user,
|
|
97
|
+
'X-Target-User': encodeURIComponent(args.target_user),
|
|
96
98
|
'X-Media-Type': args.media_type,
|
|
97
99
|
'X-Filename': encodeURIComponent(filename),
|
|
98
|
-
'X-Cc-Id': args.cc_id,
|
|
100
|
+
'X-Cc-Id': encodeURIComponent(args.cc_id),
|
|
99
101
|
};
|
|
100
102
|
if (MCP_AUTH_TOKEN)
|
|
101
103
|
headers['Authorization'] = `Bearer ${MCP_AUTH_TOKEN}`;
|
|
102
104
|
if (args.robot_name)
|
|
103
|
-
headers['X-Robot'] = args.robot_name;
|
|
105
|
+
headers['X-Robot'] = encodeURIComponent(args.robot_name);
|
|
104
106
|
if (args.video_title)
|
|
105
107
|
headers['X-Video-Title'] = encodeURIComponent(args.video_title);
|
|
106
108
|
if (args.video_description)
|
|
@@ -146,14 +148,15 @@ async function uploadFileToHttp(args) {
|
|
|
146
148
|
headers['Authorization'] = `Bearer ${MCP_AUTH_TOKEN}`;
|
|
147
149
|
if (args.ttl_seconds)
|
|
148
150
|
headers['X-TTL'] = String(args.ttl_seconds);
|
|
151
|
+
// v3.3.1: 同上,CJK ccId / tags 必须 URL 编码
|
|
149
152
|
if (args.kind === 'document') {
|
|
150
|
-
headers['X-From-CC'] = args.cc_id;
|
|
151
|
-
headers['X-To-CC'] = args.to_cc || '';
|
|
153
|
+
headers['X-From-CC'] = encodeURIComponent(args.cc_id);
|
|
154
|
+
headers['X-To-CC'] = encodeURIComponent(args.to_cc || '');
|
|
152
155
|
}
|
|
153
156
|
else {
|
|
154
|
-
headers['X-Owner-CC'] = args.cc_id;
|
|
157
|
+
headers['X-Owner-CC'] = encodeURIComponent(args.cc_id);
|
|
155
158
|
if (args.tags && args.tags.length > 0)
|
|
156
|
-
headers['X-Tags'] = args.tags.join(',');
|
|
159
|
+
headers['X-Tags'] = encodeURIComponent(args.tags.join(','));
|
|
157
160
|
}
|
|
158
161
|
try {
|
|
159
162
|
const res = await fetch(`${MCP_URL}${endpoint}`, { method: 'POST', headers, body: buf });
|