@qwen-code/channel-qqbot 0.28.1-preview.0 → 0.28.3
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/QQChannel.d.ts +27 -9
- package/dist/QQChannel.d.ts.map +1 -1
- package/dist/QQChannel.js +246 -11
- package/dist/QQChannel.js.map +1 -1
- package/dist/api.d.ts +50 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +187 -0
- package/dist/api.js.map +1 -1
- package/dist/file-tools.d.ts +89 -0
- package/dist/file-tools.d.ts.map +1 -0
- package/dist/file-tools.js +425 -0
- package/dist/file-tools.js.map +1 -0
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +6 -1
- package/dist/media.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/api.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* - WebSocket Gateway URL resolution
|
|
7
7
|
* - Message sending (text / markdown)
|
|
8
8
|
* - Message recall
|
|
9
|
+
* - Rich-media (image / video / voice / file) upload
|
|
9
10
|
*/
|
|
10
11
|
export interface TokenResponse {
|
|
11
12
|
accessToken: string;
|
|
@@ -48,4 +49,53 @@ export type QQApiMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
|
48
49
|
* path and interpret the status code and error body themselves.
|
|
49
50
|
*/
|
|
50
51
|
export declare function requestQQApi(base: string, method: QQApiMethod, path: string, accessToken: string, body?: Record<string, unknown>): Promise<Response>;
|
|
52
|
+
/** Platform rich-media types. An image, video, or voice file is rendered by the
|
|
53
|
+
* client; a file (`4`) is a downloadable card and the only type that accepts
|
|
54
|
+
* any format. */
|
|
55
|
+
export declare const QQ_FILE_TYPE: {
|
|
56
|
+
readonly image: 1;
|
|
57
|
+
readonly video: 2;
|
|
58
|
+
readonly voice: 3;
|
|
59
|
+
readonly file: 4;
|
|
60
|
+
};
|
|
61
|
+
export type QQFileType = (typeof QQ_FILE_TYPE)[keyof typeof QQ_FILE_TYPE];
|
|
62
|
+
export type QQRichMediaScope = 'users' | 'groups';
|
|
63
|
+
export interface QQRichMediaUploadInput {
|
|
64
|
+
base: string;
|
|
65
|
+
accessToken: string;
|
|
66
|
+
scope: QQRichMediaScope;
|
|
67
|
+
chatId: string;
|
|
68
|
+
fileName: string;
|
|
69
|
+
bytes: Buffer;
|
|
70
|
+
/** `file_type` sent with both the prepare and the merge call. */
|
|
71
|
+
fileType: QQFileType;
|
|
72
|
+
}
|
|
73
|
+
export interface QQRichMediaUploadResult {
|
|
74
|
+
/** Opaque handle for the send call's `media.file_info`; the platform says
|
|
75
|
+
* callers never need to parse it. */
|
|
76
|
+
fileInfo: string;
|
|
77
|
+
/** Seconds the handle stays valid; 0 means it does not expire. */
|
|
78
|
+
ttl: number;
|
|
79
|
+
}
|
|
80
|
+
export type QQRichMediaStage = 'prepare' | 'part' | 'finish' | 'merge';
|
|
81
|
+
/** A failed rich-media call, carrying the platform's `err_code` when the body
|
|
82
|
+
* has one so the caller can decide whether a retry could help. */
|
|
83
|
+
export declare class QQRichMediaError extends Error {
|
|
84
|
+
readonly stage: QQRichMediaStage;
|
|
85
|
+
readonly status: number;
|
|
86
|
+
readonly code: number | undefined;
|
|
87
|
+
constructor(stage: QQRichMediaStage, status: number, code: number | undefined, message: string);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Upload local bytes to a QQ chat as rich media and return the `file_info`
|
|
91
|
+
* handle the send call needs.
|
|
92
|
+
*
|
|
93
|
+
* The platform's chunked path is the only one that fits local files (the URL
|
|
94
|
+
* path needs a public origin; the ≤5 MiB binary path cannot carry a larger
|
|
95
|
+
* file), so this always goes: upload_prepare → PUT each part → part_finish →
|
|
96
|
+
* merge with srv_send_msg=false. Nothing is delivered to the user here.
|
|
97
|
+
*/
|
|
98
|
+
export declare function uploadQQRichMedia(input: QQRichMediaUploadInput): Promise<QQRichMediaUploadResult>;
|
|
99
|
+
/** The platform's error code from a JSON error body, when it carries one. */
|
|
100
|
+
export declare function parseQQErrorCode(text: string): number | undefined;
|
|
51
101
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,CAAC,CAyBxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAwBtD;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAED,wDAAwD;AACxD,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAEnD;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,QAAQ,CAAC,CAEnB;AAED,kEAAkE;AAClE,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtE;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MA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AC7E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQjE"}
|
package/dist/api.js
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* - WebSocket Gateway URL resolution
|
|
7
7
|
* - Message sending (text / markdown)
|
|
8
8
|
* - Message recall
|
|
9
|
+
* - Rich-media (image / video / voice / file) upload
|
|
9
10
|
*/
|
|
11
|
+
import { createHash } from 'node:crypto';
|
|
10
12
|
const TOKEN_URL = 'https://bots.qq.com/app/getAppAccessToken';
|
|
11
13
|
const API_HOST = 'https://api.sgroup.qq.com';
|
|
12
14
|
const SANDBOX_HOST = 'https://sandbox.api.sgroup.qq.com';
|
|
@@ -117,4 +119,189 @@ export async function requestQQApi(base, method, path, accessToken, body) {
|
|
|
117
119
|
signal: AbortSignal.timeout(FETCH_TIMEOUT),
|
|
118
120
|
});
|
|
119
121
|
}
|
|
122
|
+
/** A presigned part carries up to `block_size` (10 MiB in practice) and the
|
|
123
|
+
* platform asks callers to allow at least 5s, so FETCH_TIMEOUT is too tight. */
|
|
124
|
+
const UPLOAD_TIMEOUT = 120_000;
|
|
125
|
+
/** The platform's retryable upload failure (40093001) is real, not theoretical:
|
|
126
|
+
* a live probe hit it once on an otherwise identical request and the retry
|
|
127
|
+
* succeeded. */
|
|
128
|
+
const UPLOAD_ATTEMPTS = 3;
|
|
129
|
+
/** `md5_10m` covers only the first 10002432 bytes, not the whole file. */
|
|
130
|
+
const MD5_10M_BYTES = 10002432;
|
|
131
|
+
/** Backoff for the retryable failures reported before the response can name a
|
|
132
|
+
* delay of its own (upload_prepare). */
|
|
133
|
+
const RETRY_DELAY_FALLBACK_MS = 1000;
|
|
134
|
+
/** Platform rich-media types. An image, video, or voice file is rendered by the
|
|
135
|
+
* client; a file (`4`) is a downloadable card and the only type that accepts
|
|
136
|
+
* any format. */
|
|
137
|
+
export const QQ_FILE_TYPE = {
|
|
138
|
+
image: 1,
|
|
139
|
+
video: 2,
|
|
140
|
+
voice: 3,
|
|
141
|
+
file: 4,
|
|
142
|
+
};
|
|
143
|
+
/** A failed rich-media call, carrying the platform's `err_code` when the body
|
|
144
|
+
* has one so the caller can decide whether a retry could help. */
|
|
145
|
+
export class QQRichMediaError extends Error {
|
|
146
|
+
stage;
|
|
147
|
+
status;
|
|
148
|
+
code;
|
|
149
|
+
constructor(stage, status, code, message) {
|
|
150
|
+
super(message);
|
|
151
|
+
this.name = 'QQRichMediaError';
|
|
152
|
+
this.stage = stage;
|
|
153
|
+
this.status = status;
|
|
154
|
+
this.code = code;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Upload local bytes to a QQ chat as rich media and return the `file_info`
|
|
159
|
+
* handle the send call needs.
|
|
160
|
+
*
|
|
161
|
+
* The platform's chunked path is the only one that fits local files (the URL
|
|
162
|
+
* path needs a public origin; the ≤5 MiB binary path cannot carry a larger
|
|
163
|
+
* file), so this always goes: upload_prepare → PUT each part → part_finish →
|
|
164
|
+
* merge with srv_send_msg=false. Nothing is delivered to the user here.
|
|
165
|
+
*/
|
|
166
|
+
export async function uploadQQRichMedia(input) {
|
|
167
|
+
const { base, accessToken, scope, chatId, fileName, bytes, fileType } = input;
|
|
168
|
+
const scopePath = `/v2/${scope}/${encodeURIComponent(chatId)}`;
|
|
169
|
+
// prepare is retried too: the platform marks 40093001 and 850027 ("try again
|
|
170
|
+
// later") as retryable on this endpoint, and the delay is not known until the
|
|
171
|
+
// response arrives, so it uses the same bounded backoff.
|
|
172
|
+
const prepared = await retrying(() => uploadJson(base, accessToken, `${scopePath}/upload_prepare`, {
|
|
173
|
+
file_type: fileType,
|
|
174
|
+
file_size: String(bytes.length),
|
|
175
|
+
file_name: fileName,
|
|
176
|
+
md5: digest('md5', bytes),
|
|
177
|
+
sha1: digest('sha1', bytes),
|
|
178
|
+
md5_10m: digest('md5', bytes.subarray(0, MD5_10M_BYTES)),
|
|
179
|
+
}, 'prepare'), RETRY_DELAY_FALLBACK_MS);
|
|
180
|
+
const uploadId = stringField(prepared, 'upload_id');
|
|
181
|
+
const blockSize = numberField(prepared, 'block_size');
|
|
182
|
+
const parts = (Array.isArray(prepared['parts']) ? prepared['parts'] : []).filter((part) => typeof part === 'object' && part !== null);
|
|
183
|
+
if (!uploadId || blockSize <= 0 || parts.length === 0) {
|
|
184
|
+
throw new QQRichMediaError('prepare', 200, undefined, 'upload_prepare returned no upload_id, block_size or parts');
|
|
185
|
+
}
|
|
186
|
+
const retryDelayMs = Math.max(1, numberField(prepared['upload_config'], 'retry_delay') || 1) *
|
|
187
|
+
1000;
|
|
188
|
+
// Cumulative offsets rather than `index * block_size`: the parts array is the
|
|
189
|
+
// authority on the split, and the last part may be short.
|
|
190
|
+
const ordered = [...parts].sort((a, b) => numberField(a, 'index') - numberField(b, 'index'));
|
|
191
|
+
let offset = 0;
|
|
192
|
+
for (const part of ordered) {
|
|
193
|
+
const url = stringField(part, 'url') || stringField(part, 'presigned_url');
|
|
194
|
+
const length = numberField(part, 'block_size') || blockSize;
|
|
195
|
+
const slice = bytes.subarray(offset, offset + length);
|
|
196
|
+
offset += length;
|
|
197
|
+
if (!url || slice.length === 0) {
|
|
198
|
+
throw new QQRichMediaError('prepare', 200, undefined, 'upload_prepare returned a part without a URL or payload');
|
|
199
|
+
}
|
|
200
|
+
await retrying(async () => {
|
|
201
|
+
// Presigned URLs carry their own signature — the bot token must not be
|
|
202
|
+
// attached here.
|
|
203
|
+
const resp = await fetch(url, {
|
|
204
|
+
method: 'PUT',
|
|
205
|
+
body: new Uint8Array(slice),
|
|
206
|
+
signal: AbortSignal.timeout(UPLOAD_TIMEOUT),
|
|
207
|
+
});
|
|
208
|
+
await resp.text().catch(() => '');
|
|
209
|
+
if (!resp.ok) {
|
|
210
|
+
throw new QQRichMediaError('part', resp.status, undefined, `part upload failed (HTTP ${resp.status})`);
|
|
211
|
+
}
|
|
212
|
+
}, retryDelayMs);
|
|
213
|
+
await retrying(() => uploadJson(base, accessToken, `${scopePath}/upload_part_finish`, {
|
|
214
|
+
upload_id: uploadId,
|
|
215
|
+
part_index: numberField(part, 'index'),
|
|
216
|
+
block_size: length,
|
|
217
|
+
md5: digest('md5', slice),
|
|
218
|
+
}, 'finish'), retryDelayMs);
|
|
219
|
+
}
|
|
220
|
+
if (offset !== bytes.length) {
|
|
221
|
+
throw new QQRichMediaError('prepare', 200, undefined, `upload_prepare parts cover ${offset} of ${bytes.length} bytes`);
|
|
222
|
+
}
|
|
223
|
+
const merged = await retrying(() => uploadJson(base, accessToken, `${scopePath}/files`, {
|
|
224
|
+
upload_id: uploadId,
|
|
225
|
+
file_type: fileType,
|
|
226
|
+
file_name: fileName,
|
|
227
|
+
srv_send_msg: false,
|
|
228
|
+
}, 'merge'), retryDelayMs);
|
|
229
|
+
const fileInfo = stringField(merged, 'file_info');
|
|
230
|
+
if (!fileInfo) {
|
|
231
|
+
throw new QQRichMediaError('merge', 200, undefined, 'file upload returned no file_info');
|
|
232
|
+
}
|
|
233
|
+
return { fileInfo, ttl: numberField(merged, 'ttl') };
|
|
234
|
+
}
|
|
235
|
+
/** POST a JSON body and return the parsed response, or a typed failure. */
|
|
236
|
+
async function uploadJson(base, accessToken, path, body, stage) {
|
|
237
|
+
const resp = await fetch(`${base}${path}`, {
|
|
238
|
+
method: 'POST',
|
|
239
|
+
headers: {
|
|
240
|
+
'Content-Type': 'application/json',
|
|
241
|
+
Authorization: `QQBot ${accessToken}`,
|
|
242
|
+
},
|
|
243
|
+
body: JSON.stringify(body),
|
|
244
|
+
signal: AbortSignal.timeout(FETCH_TIMEOUT),
|
|
245
|
+
});
|
|
246
|
+
const text = await resp.text().catch(() => '');
|
|
247
|
+
if (!resp.ok) {
|
|
248
|
+
throw new QQRichMediaError(stage, resp.status, parseQQErrorCode(text), text.slice(0, 200) || `HTTP ${resp.status}`);
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
return JSON.parse(text);
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
throw new QQRichMediaError(stage, resp.status, undefined, 'response was not JSON');
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/** Retry the failures the platform marks retryable, plus transport errors. */
|
|
258
|
+
async function retrying(fn, delayMs) {
|
|
259
|
+
for (let attempt = 1;; attempt++) {
|
|
260
|
+
try {
|
|
261
|
+
return await fn();
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
const retryable = !(error instanceof QQRichMediaError) ||
|
|
265
|
+
error.code === 40093001 ||
|
|
266
|
+
error.code === 850027 ||
|
|
267
|
+
error.status === 429 ||
|
|
268
|
+
error.status >= 500;
|
|
269
|
+
if (!retryable || attempt >= UPLOAD_ATTEMPTS)
|
|
270
|
+
throw error;
|
|
271
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function digest(algorithm, data) {
|
|
276
|
+
return createHash(algorithm).update(data).digest('hex');
|
|
277
|
+
}
|
|
278
|
+
/** The platform's error code from a JSON error body, when it carries one. */
|
|
279
|
+
export function parseQQErrorCode(text) {
|
|
280
|
+
try {
|
|
281
|
+
const body = JSON.parse(text);
|
|
282
|
+
const code = body.code ?? body.err_code;
|
|
283
|
+
return typeof code === 'number' ? code : undefined;
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
return undefined;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function stringField(source, key) {
|
|
290
|
+
if (typeof source !== 'object' || source === null)
|
|
291
|
+
return '';
|
|
292
|
+
const value = source[key];
|
|
293
|
+
return typeof value === 'string' ? value : '';
|
|
294
|
+
}
|
|
295
|
+
function numberField(source, key) {
|
|
296
|
+
if (typeof source !== 'object' || source === null)
|
|
297
|
+
return 0;
|
|
298
|
+
const value = source[key];
|
|
299
|
+
if (typeof value === 'number')
|
|
300
|
+
return value;
|
|
301
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
302
|
+
const parsed = Number(value);
|
|
303
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
304
|
+
}
|
|
305
|
+
return 0;
|
|
306
|
+
}
|
|
120
307
|
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,SAAS,GAAG,2CAA2C,CAAC;AAC9D,MAAM,QAAQ,GAAG,2BAA2B,CAAC;AAC7C,MAAM,YAAY,GAAG,mCAAmC,CAAC;AAEzD,mEAAmE;AACnE,MAAM,aAAa,GAAG,MAAM,CAAC;AAO7B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAa,EACb,SAAiB;IAEjB,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,SAAS,EAAE;QAClC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;QACxD,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC;KAC3C,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC1C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC;QAC1E,MAAM,IAAI,KAAK,CAAC,qCAAqC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAG9B,CAAC;IACF,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAA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AM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC;QACxC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,MAAe,EAAE,GAAW;IAC/C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAC7D,MAAM,KAAK,GAAI,MAAkC,CAAC,GAAG,CAAC,CAAC;IACvD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,WAAW,CAAC,MAAe,EAAE,GAAW;IAC/C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAI,MAAkC,CAAC,GAAG,CAAC,CAAC;IACvD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACrD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QQ outbound media tools exposed to the agent as client MCP tools.
|
|
3
|
+
*
|
|
4
|
+
* The model calls one with a local path; the adapter owns the chat binding, the
|
|
5
|
+
* credentials and the platform upload. This module owns the schemas, the
|
|
6
|
+
* workspace path boundary, the format and size validation, and the text the
|
|
7
|
+
* model sees.
|
|
8
|
+
*
|
|
9
|
+
* The boundary is deliberately narrow: a path is only readable when it is an
|
|
10
|
+
* absolute path that resolves inside the session's workspace or the system
|
|
11
|
+
* temporary directory. Sending media is an outbound action with the bot's own
|
|
12
|
+
* identity, so it stays opt-in and its failures are reported, never silently
|
|
13
|
+
* downgraded to a text message or to a different message kind.
|
|
14
|
+
*
|
|
15
|
+
* @see https://bot.q.qq.com/wiki/develop/api-v2/server-inter/message/rich-media.html
|
|
16
|
+
*/
|
|
17
|
+
import type { ChannelToolDefinition } from '@qwen-code/channel-base';
|
|
18
|
+
/** Platform hard limit is 200 MB; the repository's outbound-file convention is
|
|
19
|
+
* 20 MiB, which keeps the file in memory and the exposure bounded. */
|
|
20
|
+
export declare const QQ_OUTBOUND_FILE_MAX_BYTES: number;
|
|
21
|
+
/** The media caps are the platform's decimal soft limits: a larger image, video,
|
|
22
|
+
* or voice upload is quietly downgraded by the platform to a file card, so the
|
|
23
|
+
* tool refuses it locally instead of reporting a different visible outcome. */
|
|
24
|
+
export declare const QQ_OUTBOUND_IMAGE_MAX_BYTES = 20000000;
|
|
25
|
+
export declare const QQ_OUTBOUND_VIDEO_MAX_BYTES = 30000000;
|
|
26
|
+
export declare const QQ_OUTBOUND_VOICE_MAX_BYTES = 20000000;
|
|
27
|
+
export type QQMediaKind = 'file' | 'image' | 'video' | 'voice';
|
|
28
|
+
/** Tool names, also used by the adapter to prefix failures. */
|
|
29
|
+
export declare const QQ_MEDIA_TOOL_NAMES: Record<QQMediaKind, string>;
|
|
30
|
+
export interface QQOutboundFile {
|
|
31
|
+
bytes: Buffer;
|
|
32
|
+
fileName: string;
|
|
33
|
+
}
|
|
34
|
+
/** A rejected path or file; the message is safe to show the model. */
|
|
35
|
+
export declare class QQOutboundFileError extends Error {
|
|
36
|
+
}
|
|
37
|
+
export interface QQFileToolDeps {
|
|
38
|
+
/** Chat bound to the agent session that invoked the tool. */
|
|
39
|
+
resolveChat(sessionId: string): {
|
|
40
|
+
chatId: string;
|
|
41
|
+
} | undefined;
|
|
42
|
+
/** Workspace the session runs in; the path boundary's first root. */
|
|
43
|
+
sessionCwd(sessionId: string): string | undefined;
|
|
44
|
+
/** Upload and send; the adapter owns route, reply anchor and msg_seq. */
|
|
45
|
+
sendMedia(input: {
|
|
46
|
+
sessionId: string;
|
|
47
|
+
chatId: string;
|
|
48
|
+
kind: QQMediaKind;
|
|
49
|
+
fileName: string;
|
|
50
|
+
bytes: Buffer;
|
|
51
|
+
}): Promise<{
|
|
52
|
+
ok: true;
|
|
53
|
+
} | {
|
|
54
|
+
ok: false;
|
|
55
|
+
message: string;
|
|
56
|
+
}>;
|
|
57
|
+
log(message: string): void;
|
|
58
|
+
}
|
|
59
|
+
export declare function buildFileTools(deps: QQFileToolDeps): ChannelToolDefinition[];
|
|
60
|
+
/**
|
|
61
|
+
* Read a file the model asked to send, refusing anything outside the session
|
|
62
|
+
* workspace or the temporary directory.
|
|
63
|
+
*
|
|
64
|
+
* `realpathSync` resolves symlinks before the root check, so a link inside the
|
|
65
|
+
* workspace cannot smuggle an outside file. The read-only open refuses a final
|
|
66
|
+
* component swapped to a symlink: `O_NOFOLLOW` where the platform exposes it,
|
|
67
|
+
* plus the `lstat` → `open` → `fstat` identity proof wherever no post-open
|
|
68
|
+
* descriptor path is available (macOS, Windows) — the same compensation
|
|
69
|
+
* `packages/core/src/utils/no-follow-open.ts` applies. Two further guards close
|
|
70
|
+
* the ways a path check alone is blind: a file with more than one hard link is
|
|
71
|
+
* refused (a hard link has no target to resolve, so the check would otherwise
|
|
72
|
+
* read the linked contents), and where the platform exposes `/proc/self/fd`
|
|
73
|
+
* (Linux) the path the kernel records for the descriptor is compared after
|
|
74
|
+
* opening, which catches a directory component swapped between the check and
|
|
75
|
+
* the open; a descriptor whose path cannot be read there is refused rather than
|
|
76
|
+
* trusted. Without procfs the requested path is resolved again after the open
|
|
77
|
+
* and re-checked against the roots, which narrows the same window. The identity
|
|
78
|
+
* proof and that re-resolution are best-effort against a same-user racer: a
|
|
79
|
+
* swap landing before the identity probe cannot be fully excluded with the
|
|
80
|
+
* primitives Node exposes (there is no `openat`-style descriptor-relative
|
|
81
|
+
* walk). The read is re-checked against `fstat` so a file rewritten mid-read is
|
|
82
|
+
* reported instead of sent truncated.
|
|
83
|
+
*
|
|
84
|
+
* `kind` picks the byte cap and the format the bytes must match. The sniff runs
|
|
85
|
+
* on the same descriptor that was already validated, so the bytes that were
|
|
86
|
+
* checked are the bytes that are uploaded.
|
|
87
|
+
*/
|
|
88
|
+
export declare function readOutboundFile(filePath: string, workspaceDir: string | undefined, kind?: QQMediaKind): QQOutboundFile;
|
|
89
|
+
//# sourceMappingURL=file-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-tools.d.ts","sourceRoot":"","sources":["../src/file-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAeH,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AAEjC;uEACuE;AACvE,eAAO,MAAM,0BAA0B,QAAmB,CAAC;AAE3D;;gFAEgF;AAChF,eAAO,MAAM,2BAA2B,WAAa,CAAC;AACtD,eAAO,MAAM,2BAA2B,WAAa,CAAC;AACtD,eAAO,MAAM,2BAA2B,WAAa,CAAC;AAMtD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAE/D,+DAA+D;AAC/D,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAK3D,CAAC;AASF,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,sEAAsE;AACtE,qBAAa,mBAAoB,SAAQ,KAAK;CAAG;AAEjD,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7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