zalo-agent-cli 1.6.1 → 1.6.2
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/package.json +3 -2
- package/src/commands/mcp.js +3 -1
- package/src/core/zalo-client.js +12 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zalo-agent-cli",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "CLI tool for Zalo automation — multi-account, proxy, bank transfers, QR payments, Official Account API v3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -49,7 +49,8 @@
|
|
|
49
49
|
"express": "^5.2.1",
|
|
50
50
|
"https-proxy-agent": "^8.0.0",
|
|
51
51
|
"node-fetch": "^3.3.0",
|
|
52
|
-
"
|
|
52
|
+
"undici": "^7.24.6",
|
|
53
|
+
"zca-js": "^2.1.2",
|
|
53
54
|
"zod": "^4.3.6"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
package/src/commands/mcp.js
CHANGED
|
@@ -204,7 +204,9 @@ export function registerMCPCommands(program) {
|
|
|
204
204
|
|
|
205
205
|
// Graceful shutdown on SIGINT
|
|
206
206
|
process.on("SIGINT", () => {
|
|
207
|
-
try {
|
|
207
|
+
try {
|
|
208
|
+
getApi().listener.stop();
|
|
209
|
+
} catch {}
|
|
208
210
|
notifier?.destroy();
|
|
209
211
|
httpServer?.close();
|
|
210
212
|
process.exit(0);
|
package/src/core/zalo-client.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import fs from "fs";
|
|
7
7
|
import { Zalo, LoginQRCallbackEventType } from "zca-js";
|
|
8
8
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
9
|
-
import
|
|
9
|
+
import { ProxyAgent } from "undici";
|
|
10
10
|
import { getActive } from "./accounts.js";
|
|
11
11
|
import { loadCredentials } from "./credentials.js";
|
|
12
12
|
import { info } from "../utils/output.js";
|
|
@@ -91,6 +91,15 @@ export function isLoggedIn() {
|
|
|
91
91
|
return _api !== null;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Create a proxy-aware fetch that uses undici ProxyAgent dispatcher.
|
|
96
|
+
* Native Node.js fetch ignores the `agent` option — must use `dispatcher`.
|
|
97
|
+
*/
|
|
98
|
+
function createProxyFetch(proxyUrl) {
|
|
99
|
+
const dispatcher = new ProxyAgent(proxyUrl);
|
|
100
|
+
return (url, init = {}) => fetch(url, { ...init, dispatcher });
|
|
101
|
+
}
|
|
102
|
+
|
|
94
103
|
/** Create a Zalo instance with optional proxy. Suppress logs in JSON mode. */
|
|
95
104
|
function createZalo(proxyUrl) {
|
|
96
105
|
const opts = {
|
|
@@ -99,8 +108,9 @@ function createZalo(proxyUrl) {
|
|
|
99
108
|
imageMetadataGetter: readImageMetadata,
|
|
100
109
|
};
|
|
101
110
|
if (proxyUrl) {
|
|
111
|
+
// HttpsProxyAgent for WebSocket (ws lib), ProxyAgent dispatcher for HTTP fetch
|
|
102
112
|
opts.agent = new HttpsProxyAgent(proxyUrl);
|
|
103
|
-
opts.polyfill =
|
|
113
|
+
opts.polyfill = createProxyFetch(proxyUrl);
|
|
104
114
|
}
|
|
105
115
|
return new Zalo(opts);
|
|
106
116
|
}
|