@agent-wechat/agent-wechat 1.0.0-beta.13 → 1.0.0-beta.14
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/index.js +16 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -192,7 +192,7 @@ var NativeWeChatClient = class {
|
|
|
192
192
|
if (typeof options.token !== "string" || !options.token || /[\r\n]/.test(options.token))
|
|
193
193
|
throw new Error("Native API bearer token is required");
|
|
194
194
|
this.token = options.token;
|
|
195
|
-
this.fetchImpl = options.fetch ?? fetch;
|
|
195
|
+
this.fetchImpl = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
196
196
|
this.timeoutMs = options.timeoutMs ?? 3e4;
|
|
197
197
|
this.mediaTimeoutMs = options.mediaTimeoutMs ?? 60 * 6e4;
|
|
198
198
|
if (!Number.isInteger(this.mediaTimeoutMs) || this.mediaTimeoutMs < 1 || this.mediaTimeoutMs > 60 * 6e4)
|
|
@@ -279,9 +279,22 @@ var NativeWeChatClient = class {
|
|
|
279
279
|
throw new Error("Account ID or alias is required");
|
|
280
280
|
return this.request("v1/accounts", { method: "POST", body: JSON.stringify(body) });
|
|
281
281
|
}
|
|
282
|
+
removeAccount(accountId, confirmAccountId) {
|
|
283
|
+
if (accountId !== confirmAccountId)
|
|
284
|
+
throw new Error("Account confirmation does not match");
|
|
285
|
+
return this.request(`v1/accounts/${id(accountId)}`, { method: "DELETE", body: JSON.stringify({ confirmAccountId }) });
|
|
286
|
+
}
|
|
282
287
|
updateAccount(accountId, options) {
|
|
283
288
|
return this.request(`v1/accounts/${id(accountId)}`, { method: "PATCH", body: JSON.stringify(options) });
|
|
284
289
|
}
|
|
290
|
+
accountSettings(accountId, signal) {
|
|
291
|
+
return this.request(`v1/accounts/${id(accountId)}/settings`, { signal });
|
|
292
|
+
}
|
|
293
|
+
updateAccountSettings(accountId, settings, signal) {
|
|
294
|
+
if (!Number.isSafeInteger(settings.autoDownloadMaxBytes) || settings.autoDownloadMaxBytes < 0 || settings.autoDownloadMaxBytes > NATIVE_MAX_SOURCE_BYTES)
|
|
295
|
+
throw new Error("Invalid automatic download limit");
|
|
296
|
+
return this.request(`v1/accounts/${id(accountId)}/settings`, { method: "PATCH", body: JSON.stringify(settings), signal });
|
|
297
|
+
}
|
|
285
298
|
capabilities(accountId) {
|
|
286
299
|
return this.request(`v1/accounts/${id(accountId)}/capabilities`);
|
|
287
300
|
}
|
|
@@ -629,7 +642,7 @@ var NativeWeChatClient = class {
|
|
|
629
642
|
ack(accountId, consumerId, cursor) {
|
|
630
643
|
return this.request(`v1/accounts/${id(accountId)}/consumers/${id(consumerId)}/ack`, { method: "POST", body: JSON.stringify({ cursor: decimal(cursor) }) });
|
|
631
644
|
}
|
|
632
|
-
async *watch(accountId, after = "0", signal) {
|
|
645
|
+
async *watch(accountId, after = "0", signal, options = {}) {
|
|
633
646
|
const connection = new AbortController();
|
|
634
647
|
const streamSignal = signal ? AbortSignal.any([signal, connection.signal]) : connection.signal;
|
|
635
648
|
const bounded = async (work, milliseconds, reason) => {
|
|
@@ -671,6 +684,7 @@ var NativeWeChatClient = class {
|
|
|
671
684
|
const { value, done } = await bounded(() => activeReader.read(), this.streamIdleTimeoutMs, "Native SSE idle timeout");
|
|
672
685
|
if (done)
|
|
673
686
|
break;
|
|
687
|
+
options.onActivity?.();
|
|
674
688
|
buffer += decoder.decode(value, { stream: true });
|
|
675
689
|
if (buffer.length > 1024 * 1024)
|
|
676
690
|
throw new Error("Native SSE frame exceeds its bound");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-wechat/agent-wechat",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"esbuild": "^0.25.0",
|
|
12
12
|
"openclaw": "2026.10.2",
|
|
13
13
|
"typescript": "^5.4.5",
|
|
14
|
-
"@agent-wechat/shared": "1.0.0-beta.
|
|
14
|
+
"@agent-wechat/shared": "1.0.0-beta.3"
|
|
15
15
|
},
|
|
16
16
|
"openclaw": {
|
|
17
17
|
"extensions": [
|