orchestrix-yuri 4.5.2 → 4.5.4
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.
|
@@ -3,6 +3,40 @@
|
|
|
3
3
|
const { Bot } = require('grammy');
|
|
4
4
|
const { log } = require('../log');
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Detect proxy from environment variables and return grammy-compatible config.
|
|
8
|
+
* Node.js native https does NOT respect http_proxy/https_proxy env vars,
|
|
9
|
+
* so we must explicitly configure a proxy agent for grammy.
|
|
10
|
+
*/
|
|
11
|
+
function getProxyConfig() {
|
|
12
|
+
const proxyUrl = process.env.https_proxy || process.env.HTTPS_PROXY
|
|
13
|
+
|| process.env.http_proxy || process.env.HTTP_PROXY;
|
|
14
|
+
if (!proxyUrl) return {};
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
// Try multiple resolve paths (global npm may have flat or nested node_modules)
|
|
18
|
+
let HttpsProxyAgent;
|
|
19
|
+
try {
|
|
20
|
+
({ HttpsProxyAgent } = require('https-proxy-agent'));
|
|
21
|
+
} catch {
|
|
22
|
+
// Fallback: resolve from package root
|
|
23
|
+
const pkgRoot = require('path').join(__dirname, '..', '..', '..');
|
|
24
|
+
({ HttpsProxyAgent } = require(require('path').join(pkgRoot, 'node_modules', 'https-proxy-agent')));
|
|
25
|
+
}
|
|
26
|
+
const agent = new HttpsProxyAgent(proxyUrl);
|
|
27
|
+
log.telegram(`Using proxy: ${proxyUrl}`);
|
|
28
|
+
return {
|
|
29
|
+
baseFetchConfig: {
|
|
30
|
+
agent,
|
|
31
|
+
compress: true,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
} catch (err) {
|
|
35
|
+
log.warn(`Proxy configured but https-proxy-agent unavailable: ${err.message}`);
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
6
40
|
/**
|
|
7
41
|
* Telegram channel adapter using grammy (polling mode).
|
|
8
42
|
*/
|
|
@@ -23,7 +57,7 @@ class TelegramAdapter {
|
|
|
23
57
|
throw new Error('Telegram bot token is required. Run: orchestrix-yuri start --token YOUR_TOKEN');
|
|
24
58
|
}
|
|
25
59
|
|
|
26
|
-
this.bot = new Bot(this.token);
|
|
60
|
+
this.bot = new Bot(this.token, { client: getProxyConfig() });
|
|
27
61
|
|
|
28
62
|
// Handle text messages
|
|
29
63
|
this.bot.on('message:text', async (ctx) => {
|
|
@@ -200,6 +234,23 @@ function splitMessage(text, maxLength) {
|
|
|
200
234
|
function forceDisconnectPolling(token) {
|
|
201
235
|
const https = require('https');
|
|
202
236
|
|
|
237
|
+
// Use proxy agent if available
|
|
238
|
+
let agent = undefined;
|
|
239
|
+
const proxyUrl = process.env.https_proxy || process.env.HTTPS_PROXY
|
|
240
|
+
|| process.env.http_proxy || process.env.HTTP_PROXY;
|
|
241
|
+
if (proxyUrl) {
|
|
242
|
+
try {
|
|
243
|
+
let HttpsProxyAgent;
|
|
244
|
+
try {
|
|
245
|
+
({ HttpsProxyAgent } = require('https-proxy-agent'));
|
|
246
|
+
} catch {
|
|
247
|
+
const pkgRoot = require('path').join(__dirname, '..', '..', '..');
|
|
248
|
+
({ HttpsProxyAgent } = require(require('path').join(pkgRoot, 'node_modules', 'https-proxy-agent')));
|
|
249
|
+
}
|
|
250
|
+
agent = new HttpsProxyAgent(proxyUrl);
|
|
251
|
+
} catch { /* ok */ }
|
|
252
|
+
}
|
|
253
|
+
|
|
203
254
|
const call = (method, body) => new Promise((resolve) => {
|
|
204
255
|
const data = JSON.stringify(body);
|
|
205
256
|
const req = https.request({
|
|
@@ -208,6 +259,7 @@ function forceDisconnectPolling(token) {
|
|
|
208
259
|
method: 'POST',
|
|
209
260
|
headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(data) },
|
|
210
261
|
timeout: 10000,
|
|
262
|
+
agent,
|
|
211
263
|
}, (res) => {
|
|
212
264
|
let buf = '';
|
|
213
265
|
res.on('data', (d) => { buf += d; });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orchestrix-yuri",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.4",
|
|
4
4
|
"description": "Yuri — Meta-Orchestrator for Orchestrix. Drive your entire project lifecycle with natural language.",
|
|
5
5
|
"main": "lib/installer.js",
|
|
6
6
|
"bin": {
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@larksuiteoapi/node-sdk": "^1.60.0",
|
|
36
36
|
"grammy": "^1.41.1",
|
|
37
|
+
"https-proxy-agent": "^8.0.0",
|
|
37
38
|
"js-yaml": "^4.1.1"
|
|
38
39
|
}
|
|
39
40
|
}
|