@agentconnect.md/daemon 1.0.0-rc.216 → 1.0.0-rc.217
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/{acp-host-D4Gc3jWq.js → acp-host-CeJJZbtg.js} +2 -2
- package/dist/{acp-host-D4Gc3jWq.js.map → acp-host-CeJJZbtg.js.map} +1 -1
- package/dist/{chat-IAmHAZsX.js → chat-Bcpnzw3h.js} +2 -2
- package/dist/{chat-IAmHAZsX.js.map → chat-Bcpnzw3h.js.map} +1 -1
- package/dist/index.js +3 -3
- package/dist/{login-CfZuYjo1.js → login-CcIkqoAI.js} +3 -3
- package/dist/{login-CfZuYjo1.js.map → login-CcIkqoAI.js.map} +1 -1
- package/dist/{run-foreground-BroK115h.js → run-foreground-CK2rQc1c.js} +455 -39
- package/dist/run-foreground-CK2rQc1c.js.map +1 -0
- package/dist/run-foreground-d54zOw77.js +2 -0
- package/package.json +1 -1
- package/dist/run-foreground-BroK115h.js.map +0 -1
- package/dist/run-foreground-CXY4t5pU.js +0 -2
|
@@ -3,11 +3,16 @@ import { n as require_ms, t as require_src$2 } from "./src-DDtlVutj.js";
|
|
|
3
3
|
import { t as DAEMON_VERSION } from "./version-DGaRXjBK.js";
|
|
4
4
|
import { a as agentChildEnv, i as selectAgent, n as findAgentFiles, o as loadConfig, r as loadAgents, s as persistDaemonId } from "./load-agents-nWFFmN5-.js";
|
|
5
5
|
import { l as resolveRoot, o as mcpSocketPath, u as statePath } from "./paths-DEcUO8lC.js";
|
|
6
|
-
import { _ as resolveRuntimes, a as initGitInjection, c as simpleGit, d as MAX_FRAME_BYTES, f as buildEnvelope, g as cachedRuntimeVersions, h as cachedRuntimeNames, i as prepareWorkspace, m as encode, n as installedRuntimes, o as probeGitVersion, p as decodeEnvelope, r as prefetchWorkspace, s as sessionGitEnv, t as AcpHost, u as normalizeGitUrl } from "./acp-host-
|
|
6
|
+
import { _ as resolveRuntimes, a as initGitInjection, c as simpleGit, d as MAX_FRAME_BYTES, f as buildEnvelope, g as cachedRuntimeVersions, h as cachedRuntimeNames, i as prepareWorkspace, m as encode, n as installedRuntimes, o as probeGitVersion, p as decodeEnvelope, r as prefetchWorkspace, s as sessionGitEnv, t as AcpHost, u as normalizeGitUrl } from "./acp-host-CeJJZbtg.js";
|
|
7
7
|
import { i as GitCredentialCache, n as gitcredSocketPath, r as writeGitcredShim, t as GitCredServer } from "./gitcred-server-Dcsq6QJe.js";
|
|
8
8
|
import { n as encodeFrame, t as decodeFrames } from "./ipc-2Xbxe7uu.js";
|
|
9
|
+
import { URL as URL$1 } from "url";
|
|
10
|
+
import * as tls from "tls";
|
|
11
|
+
import * as net$2 from "net";
|
|
9
12
|
import * as sp from "node:path";
|
|
10
13
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
14
|
+
import * as http$6 from "http";
|
|
15
|
+
import { Agent } from "https";
|
|
11
16
|
import { chmodSync, existsSync, mkdirSync, mkdtempSync, promises, readFileSync, rmSync, stat, unwatchFile, watch, watchFile, writeFileSync } from "node:fs";
|
|
12
17
|
import { EventEmitter } from "node:events";
|
|
13
18
|
import { hostname, tmpdir, type } from "node:os";
|
|
@@ -16,6 +21,7 @@ import { Readable } from "node:stream";
|
|
|
16
21
|
import net from "node:net";
|
|
17
22
|
import { lstat, open, readdir, realpath, stat as stat$1 } from "node:fs/promises";
|
|
18
23
|
import { DatabaseSync } from "node:sqlite";
|
|
24
|
+
import assert from "assert";
|
|
19
25
|
//#region ../../node_modules/.pnpm/ws@8.21.0/node_modules/ws/lib/constants.js
|
|
20
26
|
var require_constants$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
21
27
|
const BINARY_TYPES = [
|
|
@@ -2059,12 +2065,12 @@ var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2059
2065
|
var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2060
2066
|
const EventEmitter$3 = __require("events");
|
|
2061
2067
|
const https$3 = __require("https");
|
|
2062
|
-
const http$
|
|
2063
|
-
const net$
|
|
2064
|
-
const tls = __require("tls");
|
|
2068
|
+
const http$8 = __require("http");
|
|
2069
|
+
const net$3 = __require("net");
|
|
2070
|
+
const tls$1 = __require("tls");
|
|
2065
2071
|
const { randomBytes: randomBytes$1, createHash: createHash$1 } = __require("crypto");
|
|
2066
2072
|
const { Duplex: Duplex$2, Readable: Readable$1 } = __require("stream");
|
|
2067
|
-
const { URL: URL$
|
|
2073
|
+
const { URL: URL$2 } = __require("url");
|
|
2068
2074
|
const PerMessageDeflate = require_permessage_deflate();
|
|
2069
2075
|
const Receiver = require_receiver$1();
|
|
2070
2076
|
const Sender = require_sender();
|
|
@@ -2605,9 +2611,9 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2605
2611
|
websocket._closeTimeout = opts.closeTimeout;
|
|
2606
2612
|
if (!protocolVersions.includes(opts.protocolVersion)) throw new RangeError(`Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(", ")})`);
|
|
2607
2613
|
let parsedUrl;
|
|
2608
|
-
if (address instanceof URL$
|
|
2614
|
+
if (address instanceof URL$2) parsedUrl = address;
|
|
2609
2615
|
else try {
|
|
2610
|
-
parsedUrl = new URL$
|
|
2616
|
+
parsedUrl = new URL$2(address);
|
|
2611
2617
|
} catch {
|
|
2612
2618
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
2613
2619
|
}
|
|
@@ -2630,7 +2636,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2630
2636
|
}
|
|
2631
2637
|
const defaultPort = isSecure ? 443 : 80;
|
|
2632
2638
|
const key = randomBytes$1(16).toString("base64");
|
|
2633
|
-
const request = isSecure ? https$3.request : http$
|
|
2639
|
+
const request = isSecure ? https$3.request : http$8.request;
|
|
2634
2640
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
2635
2641
|
let perMessageDeflate;
|
|
2636
2642
|
opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
|
|
@@ -2713,7 +2719,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2713
2719
|
req.abort();
|
|
2714
2720
|
let addr;
|
|
2715
2721
|
try {
|
|
2716
|
-
addr = new URL$
|
|
2722
|
+
addr = new URL$2(location, address);
|
|
2717
2723
|
} catch (e) {
|
|
2718
2724
|
emitErrorAndClose(websocket, /* @__PURE__ */ new SyntaxError(`Invalid URL: ${location}`));
|
|
2719
2725
|
return;
|
|
@@ -2806,7 +2812,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2806
2812
|
*/
|
|
2807
2813
|
function netConnect(options) {
|
|
2808
2814
|
options.path = options.socketPath;
|
|
2809
|
-
return net$
|
|
2815
|
+
return net$3.connect(options);
|
|
2810
2816
|
}
|
|
2811
2817
|
/**
|
|
2812
2818
|
* Create a `tls.TLSSocket` and initiate a connection.
|
|
@@ -2817,8 +2823,8 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2817
2823
|
*/
|
|
2818
2824
|
function tlsConnect(options) {
|
|
2819
2825
|
options.path = void 0;
|
|
2820
|
-
if (!options.servername && options.servername !== "") options.servername = net$
|
|
2821
|
-
return tls.connect(options);
|
|
2826
|
+
if (!options.servername && options.servername !== "") options.servername = net$3.isIP(options.host) ? "" : options.host;
|
|
2827
|
+
return tls$1.connect(options);
|
|
2822
2828
|
}
|
|
2823
2829
|
/**
|
|
2824
2830
|
* Abort the handshake and emit an error.
|
|
@@ -3202,7 +3208,7 @@ var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3202
3208
|
//#region ../../node_modules/.pnpm/ws@8.21.0/node_modules/ws/lib/websocket-server.js
|
|
3203
3209
|
var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3204
3210
|
const EventEmitter$2 = __require("events");
|
|
3205
|
-
const http$
|
|
3211
|
+
const http$7 = __require("http");
|
|
3206
3212
|
const { Duplex } = __require("stream");
|
|
3207
3213
|
const { createHash } = __require("crypto");
|
|
3208
3214
|
const extension = require_extension();
|
|
@@ -3283,8 +3289,8 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
3283
3289
|
};
|
|
3284
3290
|
if (options.port == null && !options.server && !options.noServer || options.port != null && (options.server || options.noServer) || options.server && options.noServer) throw new TypeError("One and only one of the \"port\", \"server\", or \"noServer\" options must be specified");
|
|
3285
3291
|
if (options.port != null) {
|
|
3286
|
-
this._server = http$
|
|
3287
|
-
const body = http$
|
|
3292
|
+
this._server = http$7.createServer((req, res) => {
|
|
3293
|
+
const body = http$7.STATUS_CODES[426];
|
|
3288
3294
|
res.writeHead(426, {
|
|
3289
3295
|
"Content-Length": body.length,
|
|
3290
3296
|
"Content-Type": "text/plain"
|
|
@@ -3554,7 +3560,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
3554
3560
|
* @private
|
|
3555
3561
|
*/
|
|
3556
3562
|
function abortHandshake(socket, code, message, headers) {
|
|
3557
|
-
message = message || http$
|
|
3563
|
+
message = message || http$7.STATUS_CODES[code];
|
|
3558
3564
|
headers = {
|
|
3559
3565
|
Connection: "close",
|
|
3560
3566
|
"Content-Type": "text/html",
|
|
@@ -3562,7 +3568,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
3562
3568
|
...headers
|
|
3563
3569
|
};
|
|
3564
3570
|
socket.once("finish", socket.destroy);
|
|
3565
|
-
socket.end(`HTTP/1.1 ${code} ${http$
|
|
3571
|
+
socket.end(`HTTP/1.1 ${code} ${http$7.STATUS_CODES[code]}\r\n` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message);
|
|
3566
3572
|
}
|
|
3567
3573
|
/**
|
|
3568
3574
|
* Emit a `'wsClientError'` event on a `WebSocketServer` if there is at least
|
|
@@ -3584,6 +3590,9 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
3584
3590
|
} else abortHandshake(socket, code, message, headers);
|
|
3585
3591
|
}
|
|
3586
3592
|
}));
|
|
3593
|
+
//#endregion
|
|
3594
|
+
//#region ../../node_modules/.pnpm/ws@8.21.0/node_modules/ws/wrapper.mjs
|
|
3595
|
+
var import_src = /* @__PURE__ */ __toESM(require_src$2(), 1);
|
|
3587
3596
|
require_stream();
|
|
3588
3597
|
require_extension();
|
|
3589
3598
|
require_permessage_deflate();
|
|
@@ -6607,6 +6616,342 @@ var CpRoutingLayer = class {
|
|
|
6607
6616
|
}
|
|
6608
6617
|
};
|
|
6609
6618
|
//#endregion
|
|
6619
|
+
//#region ../../node_modules/.pnpm/agent-base@9.0.0/node_modules/agent-base/dist/index.js
|
|
6620
|
+
const INTERNAL = Symbol("AgentBaseInternalState");
|
|
6621
|
+
var Agent$1 = class extends http$6.Agent {
|
|
6622
|
+
constructor(opts) {
|
|
6623
|
+
super(opts);
|
|
6624
|
+
this[INTERNAL] = {};
|
|
6625
|
+
}
|
|
6626
|
+
/**
|
|
6627
|
+
* Determine whether this is an `http` or `https` request.
|
|
6628
|
+
*/
|
|
6629
|
+
isSecureEndpoint(options) {
|
|
6630
|
+
if (options) {
|
|
6631
|
+
if (typeof options.secureEndpoint === "boolean") return options.secureEndpoint;
|
|
6632
|
+
if (typeof options.protocol === "string") return options.protocol === "https:";
|
|
6633
|
+
}
|
|
6634
|
+
const { stack } = /* @__PURE__ */ new Error();
|
|
6635
|
+
if (typeof stack !== "string") return false;
|
|
6636
|
+
return stack.split("\n").some((l) => l.indexOf("(https.js:") !== -1 || l.indexOf("node:https:") !== -1);
|
|
6637
|
+
}
|
|
6638
|
+
incrementSockets(name) {
|
|
6639
|
+
if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) return null;
|
|
6640
|
+
if (!this.sockets[name]) this.sockets[name] = [];
|
|
6641
|
+
const fakeSocket = new net$2.Socket({ writable: false });
|
|
6642
|
+
this.sockets[name].push(fakeSocket);
|
|
6643
|
+
this.totalSocketCount++;
|
|
6644
|
+
return fakeSocket;
|
|
6645
|
+
}
|
|
6646
|
+
decrementSockets(name, socket) {
|
|
6647
|
+
if (!this.sockets[name] || socket === null) return;
|
|
6648
|
+
const sockets = this.sockets[name];
|
|
6649
|
+
const index = sockets.indexOf(socket);
|
|
6650
|
+
if (index !== -1) {
|
|
6651
|
+
sockets.splice(index, 1);
|
|
6652
|
+
this.totalSocketCount--;
|
|
6653
|
+
if (sockets.length === 0) delete this.sockets[name];
|
|
6654
|
+
}
|
|
6655
|
+
}
|
|
6656
|
+
getName(options) {
|
|
6657
|
+
if (this.isSecureEndpoint(options)) return Agent.prototype.getName.call(this, options);
|
|
6658
|
+
return super.getName(options);
|
|
6659
|
+
}
|
|
6660
|
+
createSocket(req, options, cb) {
|
|
6661
|
+
const connectOpts = {
|
|
6662
|
+
...options,
|
|
6663
|
+
secureEndpoint: this.isSecureEndpoint(options)
|
|
6664
|
+
};
|
|
6665
|
+
const name = this.getName(connectOpts);
|
|
6666
|
+
const fakeSocket = this.incrementSockets(name);
|
|
6667
|
+
Promise.resolve().then(() => this.connect(req, connectOpts)).then((socket) => {
|
|
6668
|
+
this.decrementSockets(name, fakeSocket);
|
|
6669
|
+
if (typeof socket.addRequest === "function") try {
|
|
6670
|
+
return socket.addRequest(req, connectOpts);
|
|
6671
|
+
} catch (err) {
|
|
6672
|
+
return cb(err);
|
|
6673
|
+
}
|
|
6674
|
+
this[INTERNAL].currentSocket = socket;
|
|
6675
|
+
super.createSocket(req, options, cb);
|
|
6676
|
+
}, (err) => {
|
|
6677
|
+
this.decrementSockets(name, fakeSocket);
|
|
6678
|
+
cb(err);
|
|
6679
|
+
});
|
|
6680
|
+
}
|
|
6681
|
+
createConnection() {
|
|
6682
|
+
const socket = this[INTERNAL].currentSocket;
|
|
6683
|
+
this[INTERNAL].currentSocket = void 0;
|
|
6684
|
+
if (!socket) throw new Error("No socket was returned in the `connect()` function");
|
|
6685
|
+
return socket;
|
|
6686
|
+
}
|
|
6687
|
+
get defaultPort() {
|
|
6688
|
+
return this[INTERNAL].defaultPort ?? (this.protocol === "https:" ? 443 : 80);
|
|
6689
|
+
}
|
|
6690
|
+
set defaultPort(v) {
|
|
6691
|
+
if (this[INTERNAL]) this[INTERNAL].defaultPort = v;
|
|
6692
|
+
}
|
|
6693
|
+
get protocol() {
|
|
6694
|
+
return this[INTERNAL].protocol ?? (this.isSecureEndpoint() ? "https:" : "http:");
|
|
6695
|
+
}
|
|
6696
|
+
set protocol(v) {
|
|
6697
|
+
if (this[INTERNAL]) this[INTERNAL].protocol = v;
|
|
6698
|
+
}
|
|
6699
|
+
};
|
|
6700
|
+
//#endregion
|
|
6701
|
+
//#region ../../node_modules/.pnpm/https-proxy-agent@9.1.0/node_modules/https-proxy-agent/dist/parse-proxy-response.js
|
|
6702
|
+
const debug$1 = (0, import_src.default)("https-proxy-agent:parse-proxy-response");
|
|
6703
|
+
function parseProxyResponse(socket) {
|
|
6704
|
+
return new Promise((resolve, reject) => {
|
|
6705
|
+
let buffersLength = 0;
|
|
6706
|
+
const buffers = [];
|
|
6707
|
+
function read() {
|
|
6708
|
+
const b = socket.read();
|
|
6709
|
+
if (b) ondata(b);
|
|
6710
|
+
else socket.once("readable", read);
|
|
6711
|
+
}
|
|
6712
|
+
function cleanup() {
|
|
6713
|
+
socket.removeListener("end", onend);
|
|
6714
|
+
socket.removeListener("error", onerror);
|
|
6715
|
+
socket.removeListener("readable", read);
|
|
6716
|
+
}
|
|
6717
|
+
function onend() {
|
|
6718
|
+
cleanup();
|
|
6719
|
+
debug$1("onend");
|
|
6720
|
+
reject(/* @__PURE__ */ new Error("Proxy connection ended before receiving CONNECT response"));
|
|
6721
|
+
}
|
|
6722
|
+
function onerror(err) {
|
|
6723
|
+
cleanup();
|
|
6724
|
+
debug$1("onerror %o", err);
|
|
6725
|
+
reject(err);
|
|
6726
|
+
}
|
|
6727
|
+
function ondata(b) {
|
|
6728
|
+
buffers.push(b);
|
|
6729
|
+
buffersLength += b.length;
|
|
6730
|
+
const buffered = Buffer.concat(buffers, buffersLength);
|
|
6731
|
+
const endOfHeaders = buffered.indexOf("\r\n\r\n");
|
|
6732
|
+
if (endOfHeaders === -1) {
|
|
6733
|
+
debug$1("have not received end of HTTP headers yet...");
|
|
6734
|
+
read();
|
|
6735
|
+
return;
|
|
6736
|
+
}
|
|
6737
|
+
const headerParts = buffered.slice(0, endOfHeaders).toString("ascii").split("\r\n");
|
|
6738
|
+
const firstLine = headerParts.shift();
|
|
6739
|
+
if (!firstLine) {
|
|
6740
|
+
socket.destroy();
|
|
6741
|
+
return reject(/* @__PURE__ */ new Error("No header received from proxy CONNECT response"));
|
|
6742
|
+
}
|
|
6743
|
+
const firstLineParts = firstLine.split(" ");
|
|
6744
|
+
const statusCode = +firstLineParts[1];
|
|
6745
|
+
const statusText = firstLineParts.slice(2).join(" ");
|
|
6746
|
+
const headers = {};
|
|
6747
|
+
for (const header of headerParts) {
|
|
6748
|
+
if (!header) continue;
|
|
6749
|
+
const firstColon = header.indexOf(":");
|
|
6750
|
+
if (firstColon === -1) {
|
|
6751
|
+
socket.destroy();
|
|
6752
|
+
return reject(/* @__PURE__ */ new Error(`Invalid header from proxy CONNECT response: "${header}"`));
|
|
6753
|
+
}
|
|
6754
|
+
const key = header.slice(0, firstColon).toLowerCase();
|
|
6755
|
+
const value = header.slice(firstColon + 1).trimStart();
|
|
6756
|
+
const current = headers[key];
|
|
6757
|
+
if (typeof current === "string") headers[key] = [current, value];
|
|
6758
|
+
else if (Array.isArray(current)) current.push(value);
|
|
6759
|
+
else headers[key] = value;
|
|
6760
|
+
}
|
|
6761
|
+
debug$1("got proxy server response: %o %o", firstLine, headers);
|
|
6762
|
+
cleanup();
|
|
6763
|
+
resolve({
|
|
6764
|
+
connect: {
|
|
6765
|
+
statusCode,
|
|
6766
|
+
statusText,
|
|
6767
|
+
headers
|
|
6768
|
+
},
|
|
6769
|
+
buffered
|
|
6770
|
+
});
|
|
6771
|
+
}
|
|
6772
|
+
socket.on("error", onerror);
|
|
6773
|
+
socket.on("end", onend);
|
|
6774
|
+
read();
|
|
6775
|
+
});
|
|
6776
|
+
}
|
|
6777
|
+
//#endregion
|
|
6778
|
+
//#region ../../node_modules/.pnpm/proxy-agent-negotiate@1.1.0/node_modules/proxy-agent-negotiate/dist/index.js
|
|
6779
|
+
function createNegotiateAuth() {
|
|
6780
|
+
return async ({ response, scheme }) => {
|
|
6781
|
+
if (scheme.toLowerCase() !== "negotiate") throw new Error(`Expected Negotiate scheme but got "${scheme}"`);
|
|
6782
|
+
let kerberos;
|
|
6783
|
+
try {
|
|
6784
|
+
kerberos = await import("kerberos");
|
|
6785
|
+
} catch {
|
|
6786
|
+
throw new Error("The \"kerberos\" package is required for Negotiate proxy authentication. Install it with: npm install kerberos");
|
|
6787
|
+
}
|
|
6788
|
+
const proxyAuthenticate = response.headers["proxy-authenticate"] || "";
|
|
6789
|
+
const challengeHeader = Array.isArray(proxyAuthenticate) ? proxyAuthenticate[0] : proxyAuthenticate;
|
|
6790
|
+
const serverToken = typeof challengeHeader === "string" && challengeHeader.includes(" ") ? challengeHeader.split(" ").slice(1).join(" ") : void 0;
|
|
6791
|
+
const token = await (await kerberos.initializeClient("HTTP@proxy", { mechOID: kerberos.GSS_MECH_OID_SPNEGO })).step(serverToken || "");
|
|
6792
|
+
if (!token) throw new Error("Kerberos client.step() returned no token");
|
|
6793
|
+
return { headers: { "Proxy-Authorization": `Negotiate ${token}` } };
|
|
6794
|
+
};
|
|
6795
|
+
}
|
|
6796
|
+
//#endregion
|
|
6797
|
+
//#region ../../node_modules/.pnpm/https-proxy-agent@9.1.0/node_modules/https-proxy-agent/dist/index.js
|
|
6798
|
+
const debug = (0, import_src.default)("https-proxy-agent");
|
|
6799
|
+
const setServernameFromNonIpHost = (options) => {
|
|
6800
|
+
if (options.servername === void 0 && options.host && !net$2.isIP(options.host)) return {
|
|
6801
|
+
...options,
|
|
6802
|
+
servername: options.host
|
|
6803
|
+
};
|
|
6804
|
+
return options;
|
|
6805
|
+
};
|
|
6806
|
+
/**
|
|
6807
|
+
* The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
|
|
6808
|
+
* the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
|
|
6809
|
+
*
|
|
6810
|
+
* Outgoing HTTP requests are first tunneled through the proxy server using the
|
|
6811
|
+
* `CONNECT` HTTP request method to establish a connection to the proxy server,
|
|
6812
|
+
* and then the proxy server connects to the destination target and issues the
|
|
6813
|
+
* HTTP request from the proxy server.
|
|
6814
|
+
*
|
|
6815
|
+
* `https:` requests have their socket connection upgraded to TLS once
|
|
6816
|
+
* the connection to the proxy server has been established.
|
|
6817
|
+
*/
|
|
6818
|
+
var HttpsProxyAgent = class extends Agent$1 {
|
|
6819
|
+
constructor(proxy, opts) {
|
|
6820
|
+
super(opts);
|
|
6821
|
+
this.options = { path: void 0 };
|
|
6822
|
+
this.proxy = typeof proxy === "string" ? new URL$1(proxy) : proxy;
|
|
6823
|
+
this.proxyHeaders = opts?.headers ?? {};
|
|
6824
|
+
debug("Creating new HttpsProxyAgent instance: %o", this.proxy.href);
|
|
6825
|
+
if (opts?.negotiate) this.onProxyAuth = createNegotiateAuth();
|
|
6826
|
+
else if (opts?.onProxyAuth) this.onProxyAuth = opts.onProxyAuth;
|
|
6827
|
+
const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, "");
|
|
6828
|
+
const port = this.proxy.port ? parseInt(this.proxy.port, 10) : this.proxy.protocol === "https:" ? 443 : 80;
|
|
6829
|
+
this.connectOpts = {
|
|
6830
|
+
ALPNProtocols: ["http/1.1"],
|
|
6831
|
+
...opts ? omit(opts, "headers", "onProxyAuth", "negotiate") : null,
|
|
6832
|
+
host,
|
|
6833
|
+
port
|
|
6834
|
+
};
|
|
6835
|
+
}
|
|
6836
|
+
/**
|
|
6837
|
+
* Called when the node-core HTTP client library is creating a
|
|
6838
|
+
* new HTTP request.
|
|
6839
|
+
*/
|
|
6840
|
+
async connect(req, opts) {
|
|
6841
|
+
const { proxy } = this;
|
|
6842
|
+
if (!opts.host) throw new TypeError("No \"host\" provided");
|
|
6843
|
+
let socket;
|
|
6844
|
+
if (proxy.protocol === "https:") {
|
|
6845
|
+
debug("Creating `tls.Socket`: %o", this.connectOpts);
|
|
6846
|
+
socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
|
|
6847
|
+
} else {
|
|
6848
|
+
debug("Creating `net.Socket`: %o", this.connectOpts);
|
|
6849
|
+
socket = net$2.connect(this.connectOpts);
|
|
6850
|
+
}
|
|
6851
|
+
const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
|
|
6852
|
+
const host = net$2.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
|
|
6853
|
+
let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r\n`;
|
|
6854
|
+
if (proxy.username || proxy.password) {
|
|
6855
|
+
const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
|
|
6856
|
+
headers["Proxy-Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`;
|
|
6857
|
+
}
|
|
6858
|
+
headers.Host = `${host}:${opts.port}`;
|
|
6859
|
+
if (!headers["Proxy-Connection"]) headers["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close";
|
|
6860
|
+
for (const name of Object.keys(headers)) payload += `${name}: ${headers[name]}\r\n`;
|
|
6861
|
+
const proxyResponsePromise = parseProxyResponse(socket);
|
|
6862
|
+
socket.write(`${payload}\r\n`);
|
|
6863
|
+
const { connect, buffered } = await proxyResponsePromise;
|
|
6864
|
+
req.emit("proxyConnect", connect);
|
|
6865
|
+
this.emit("proxyConnect", connect, req);
|
|
6866
|
+
req.emit("proxy", {
|
|
6867
|
+
proxy: this.proxy.href,
|
|
6868
|
+
socket
|
|
6869
|
+
});
|
|
6870
|
+
if (connect.statusCode === 200) {
|
|
6871
|
+
req.once("socket", resume);
|
|
6872
|
+
if (opts.secureEndpoint) {
|
|
6873
|
+
debug("Upgrading socket connection to TLS");
|
|
6874
|
+
return tls.connect({
|
|
6875
|
+
...omit(setServernameFromNonIpHost(opts), "host", "path", "port"),
|
|
6876
|
+
socket
|
|
6877
|
+
});
|
|
6878
|
+
}
|
|
6879
|
+
return socket;
|
|
6880
|
+
}
|
|
6881
|
+
if (connect.statusCode === 407 && this.onProxyAuth) {
|
|
6882
|
+
debug("Got 407 response, invoking onProxyAuth callback");
|
|
6883
|
+
socket.destroy();
|
|
6884
|
+
const proxyAuthenticate = connect.headers["proxy-authenticate"] || "";
|
|
6885
|
+
const scheme = Array.isArray(proxyAuthenticate) ? proxyAuthenticate[0].split(/\s/)[0] : proxyAuthenticate.split(/\s/)[0];
|
|
6886
|
+
const authResponse = await this.onProxyAuth({
|
|
6887
|
+
response: connect,
|
|
6888
|
+
scheme
|
|
6889
|
+
});
|
|
6890
|
+
return this._connectWithAuth(req, opts, authResponse.headers);
|
|
6891
|
+
}
|
|
6892
|
+
socket.destroy();
|
|
6893
|
+
const fakeSocket = new net$2.Socket({ writable: false });
|
|
6894
|
+
fakeSocket.readable = true;
|
|
6895
|
+
req.once("socket", (s) => {
|
|
6896
|
+
debug("Replaying proxy buffer for failed request");
|
|
6897
|
+
assert(s.listenerCount("data") > 0);
|
|
6898
|
+
s.push(buffered);
|
|
6899
|
+
s.push(null);
|
|
6900
|
+
});
|
|
6901
|
+
return fakeSocket;
|
|
6902
|
+
}
|
|
6903
|
+
/**
|
|
6904
|
+
* Retry a CONNECT request with additional auth headers.
|
|
6905
|
+
*/
|
|
6906
|
+
async _connectWithAuth(req, opts, authHeaders) {
|
|
6907
|
+
const { proxy } = this;
|
|
6908
|
+
let socket;
|
|
6909
|
+
if (proxy.protocol === "https:") socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
|
|
6910
|
+
else socket = net$2.connect(this.connectOpts);
|
|
6911
|
+
const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
|
|
6912
|
+
const host = net$2.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
|
|
6913
|
+
let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r\n`;
|
|
6914
|
+
if (proxy.username || proxy.password) {
|
|
6915
|
+
const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
|
|
6916
|
+
headers["Proxy-Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`;
|
|
6917
|
+
}
|
|
6918
|
+
Object.assign(headers, authHeaders);
|
|
6919
|
+
headers.Host = `${host}:${opts.port}`;
|
|
6920
|
+
if (!headers["Proxy-Connection"]) headers["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close";
|
|
6921
|
+
for (const name of Object.keys(headers)) payload += `${name}: ${headers[name]}\r\n`;
|
|
6922
|
+
const proxyResponsePromise = parseProxyResponse(socket);
|
|
6923
|
+
socket.write(`${payload}\r\n`);
|
|
6924
|
+
const { connect } = await proxyResponsePromise;
|
|
6925
|
+
req.emit("proxyConnect", connect);
|
|
6926
|
+
this.emit("proxyConnect", connect, req);
|
|
6927
|
+
if (connect.statusCode === 200) {
|
|
6928
|
+
req.once("socket", resume);
|
|
6929
|
+
if (opts.secureEndpoint) {
|
|
6930
|
+
debug("Upgrading socket connection to TLS");
|
|
6931
|
+
return tls.connect({
|
|
6932
|
+
...omit(setServernameFromNonIpHost(opts), "host", "path", "port"),
|
|
6933
|
+
socket
|
|
6934
|
+
});
|
|
6935
|
+
}
|
|
6936
|
+
return socket;
|
|
6937
|
+
}
|
|
6938
|
+
socket.destroy();
|
|
6939
|
+
throw new Error(`Proxy authentication failed with status ${connect.statusCode} after retry`);
|
|
6940
|
+
}
|
|
6941
|
+
};
|
|
6942
|
+
HttpsProxyAgent.protocols = ["http", "https"];
|
|
6943
|
+
function resume(socket) {
|
|
6944
|
+
setImmediate(() => {
|
|
6945
|
+
socket.resume();
|
|
6946
|
+
});
|
|
6947
|
+
}
|
|
6948
|
+
function omit(obj, ...keys) {
|
|
6949
|
+
const ret = {};
|
|
6950
|
+
let key;
|
|
6951
|
+
for (key in obj) if (!keys.includes(key)) ret[key] = obj[key];
|
|
6952
|
+
return ret;
|
|
6953
|
+
}
|
|
6954
|
+
//#endregion
|
|
6610
6955
|
//#region ../../node_modules/.pnpm/@slack+logger@4.0.1/node_modules/@slack/logger/dist/index.js
|
|
6611
6956
|
var require_dist$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
6612
6957
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -16172,7 +16517,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
16172
16517
|
var http$4 = __require("http");
|
|
16173
16518
|
var https$1 = __require("https");
|
|
16174
16519
|
var Writable$1 = __require("stream").Writable;
|
|
16175
|
-
var assert = __require("assert");
|
|
16520
|
+
var assert$1 = __require("assert");
|
|
16176
16521
|
var debug = require_debug$1();
|
|
16177
16522
|
// istanbul ignore next
|
|
16178
16523
|
(function detectUnsupportedEnvironment() {
|
|
@@ -16183,7 +16528,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
16183
16528
|
})();
|
|
16184
16529
|
var useNativeURL = false;
|
|
16185
16530
|
try {
|
|
16186
|
-
assert(new URL(""));
|
|
16531
|
+
assert$1(new URL(""));
|
|
16187
16532
|
} catch (error) {
|
|
16188
16533
|
useNativeURL = error.code === "ERR_INVALID_URL";
|
|
16189
16534
|
}
|
|
@@ -16492,7 +16837,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
16492
16837
|
}, input, options);
|
|
16493
16838
|
options.nativeProtocols = nativeProtocols;
|
|
16494
16839
|
if (!isString(options.host) && !isString(options.hostname)) options.hostname = "::1";
|
|
16495
|
-
assert.equal(options.protocol, protocol, "protocol mismatch");
|
|
16840
|
+
assert$1.equal(options.protocol, protocol, "protocol mismatch");
|
|
16496
16841
|
debug("options", options);
|
|
16497
16842
|
return new RedirectableRequest(options, callback);
|
|
16498
16843
|
}
|
|
@@ -16581,7 +16926,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
16581
16926
|
request.destroy(error);
|
|
16582
16927
|
}
|
|
16583
16928
|
function isSubdomain(subdomain, domain) {
|
|
16584
|
-
assert(isString(subdomain) && isString(domain));
|
|
16929
|
+
assert$1(isString(subdomain) && isString(domain));
|
|
16585
16930
|
var dot = subdomain.length - domain.length - 1;
|
|
16586
16931
|
return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
|
|
16587
16932
|
}
|
|
@@ -63121,16 +63466,21 @@ var SlackConnection = class {
|
|
|
63121
63466
|
botToken;
|
|
63122
63467
|
botId = "";
|
|
63123
63468
|
workspaceUrl = "";
|
|
63124
|
-
constructor(deps, factory = (o) =>
|
|
63125
|
-
|
|
63126
|
-
|
|
63127
|
-
|
|
63128
|
-
|
|
63129
|
-
|
|
63130
|
-
|
|
63131
|
-
|
|
63132
|
-
|
|
63133
|
-
|
|
63469
|
+
constructor(deps, factory = (o) => {
|
|
63470
|
+
const proxyUrl = process.env.HTTPS_PROXY ?? process.env.HTTP_PROXY;
|
|
63471
|
+
const agent = proxyUrl ? new HttpsProxyAgent(proxyUrl) : void 0;
|
|
63472
|
+
return new App({
|
|
63473
|
+
token: o.token,
|
|
63474
|
+
appToken: o.appToken,
|
|
63475
|
+
socketMode: true,
|
|
63476
|
+
...agent ? { agent } : {},
|
|
63477
|
+
clientOptions: {
|
|
63478
|
+
timeout: 3e4,
|
|
63479
|
+
retryConfig: { retries: 2 }
|
|
63480
|
+
},
|
|
63481
|
+
...deps.boltDebug ? { logLevel: LogLevel.DEBUG } : {}
|
|
63482
|
+
});
|
|
63483
|
+
}) {
|
|
63134
63484
|
this.deps = deps;
|
|
63135
63485
|
this.appToken = deps.group.appToken;
|
|
63136
63486
|
this.botToken = deps.group.botToken;
|
|
@@ -81825,6 +82175,7 @@ var Daemon = class Daemon {
|
|
|
81825
82175
|
hostStopping = /* @__PURE__ */ new Map();
|
|
81826
82176
|
idleSweepTimer;
|
|
81827
82177
|
cancelTimers = /* @__PURE__ */ new Map();
|
|
82178
|
+
slackRetryTimers = /* @__PURE__ */ new Map();
|
|
81828
82179
|
constructor(opts = {}) {
|
|
81829
82180
|
this.opts = opts;
|
|
81830
82181
|
this.clock = opts.clock ?? systemClock;
|
|
@@ -81975,14 +82326,24 @@ var Daemon = class Daemon {
|
|
|
81975
82326
|
boltDebug: cfg.logging.level === "debug" || cfg.logging.level === "trace"
|
|
81976
82327
|
});
|
|
81977
82328
|
this.log.info(`slack: connecting (${group.integrations.length} integration(s): ${group.integrations.map((i) => i.agentId).join(", ")})…`);
|
|
81978
|
-
|
|
81979
|
-
|
|
81980
|
-
|
|
81981
|
-
|
|
81982
|
-
|
|
82329
|
+
try {
|
|
82330
|
+
await conn.start();
|
|
82331
|
+
this.log.info(`slack: socket connected as bot user ${conn.botUserId}`);
|
|
82332
|
+
for (const { integrationId } of group.integrations) {
|
|
82333
|
+
this.botUserIds[integrationId] = conn.botUserId;
|
|
82334
|
+
this.connByIntegration.set(integrationId, conn);
|
|
82335
|
+
}
|
|
82336
|
+
this.connections.push(conn);
|
|
82337
|
+
this.refreshChannels(conn);
|
|
82338
|
+
} catch (err) {
|
|
82339
|
+
await conn.stop().catch(() => {});
|
|
82340
|
+
this.log.warn(`slack: connection failed for appToken — retrying in 60s: ${formatErr(err)}`);
|
|
82341
|
+
const timer = this.clock.setTimeout(() => {
|
|
82342
|
+
if (this.draining) return;
|
|
82343
|
+
this.retrySlackConnection(group).catch((e) => this.log.error(`slack: retry loop error: ${formatErr(e)}`));
|
|
82344
|
+
}, 6e4);
|
|
82345
|
+
this.slackRetryTimers.set(group.appToken, timer);
|
|
81983
82346
|
}
|
|
81984
|
-
this.connections.push(conn);
|
|
81985
|
-
this.refreshChannels(conn);
|
|
81986
82347
|
}
|
|
81987
82348
|
for (const a of agents) this.scheduler.sync(a.id, a.crons);
|
|
81988
82349
|
const cronCount = agents.reduce((n, a) => n + this.scheduler.count(a.id), 0);
|
|
@@ -82162,6 +82523,11 @@ var Daemon = class Daemon {
|
|
|
82162
82523
|
}
|
|
82163
82524
|
this.connections.push(conn);
|
|
82164
82525
|
this.refreshChannels(conn);
|
|
82526
|
+
const pending = this.slackRetryTimers.get(group.appToken);
|
|
82527
|
+
if (pending !== void 0) {
|
|
82528
|
+
this.clock.clearTimeout(pending);
|
|
82529
|
+
this.slackRetryTimers.delete(group.appToken);
|
|
82530
|
+
}
|
|
82165
82531
|
} catch (err) {
|
|
82166
82532
|
this.log.error(`slack: failed to open runtime socket for appToken — leaving existing sockets intact: ${formatErr(err)}`);
|
|
82167
82533
|
}
|
|
@@ -82197,6 +82563,54 @@ var Daemon = class Daemon {
|
|
|
82197
82563
|
this.log.debug(`slack: channel snapshot refresh failed: ${formatErr(err)}`);
|
|
82198
82564
|
}
|
|
82199
82565
|
}
|
|
82566
|
+
/**
|
|
82567
|
+
* Background retry loop for a Slack connection that failed at initial startup.
|
|
82568
|
+
* Creates a fresh SlackConnection (the old one is in an unknown state) and, on
|
|
82569
|
+
* success, wires it into `botUserIds` / `connByIntegration` / `connections` so
|
|
82570
|
+
* the agent can begin processing messages. On failure, schedules another retry
|
|
82571
|
+
* at a slow, fixed interval — never gives up, so a temporary network outage
|
|
82572
|
+
* self-heals without manual daemon restart.
|
|
82573
|
+
*/
|
|
82574
|
+
async retrySlackConnection(group) {
|
|
82575
|
+
if (this.draining) return;
|
|
82576
|
+
if ([...this.connByIntegration.values()].some((c) => c.appToken === group.appToken)) {
|
|
82577
|
+
this.slackRetryTimers.delete(group.appToken);
|
|
82578
|
+
return;
|
|
82579
|
+
}
|
|
82580
|
+
this.log.info(`slack: background retry for appToken (${group.integrations.length} integration(s): ${group.integrations.map((i) => i.agentId).join(", ")})…`);
|
|
82581
|
+
const conn = new SlackConnection({
|
|
82582
|
+
group,
|
|
82583
|
+
newTraceId: () => randomUUID(),
|
|
82584
|
+
onMessage: (msg) => {
|
|
82585
|
+
this.nameResolver?.noteMessage(conn, msg);
|
|
82586
|
+
this.onInbound(msg);
|
|
82587
|
+
},
|
|
82588
|
+
onChannelsChanged: () => void this.refreshChannels(conn),
|
|
82589
|
+
onStatusAction: (a) => this.handleSlackStatusAction(a),
|
|
82590
|
+
onStatusInfo: (key) => this.statusInfoForKey(key),
|
|
82591
|
+
log: this.log,
|
|
82592
|
+
boltDebug: this.cfg.logging.level === "debug" || this.cfg.logging.level === "trace"
|
|
82593
|
+
});
|
|
82594
|
+
try {
|
|
82595
|
+
await conn.start();
|
|
82596
|
+
this.log.info(`slack: background retry succeeded — connected as bot user ${conn.botUserId}`);
|
|
82597
|
+
this.slackRetryTimers.delete(group.appToken);
|
|
82598
|
+
for (const { integrationId } of group.integrations) {
|
|
82599
|
+
this.botUserIds[integrationId] = conn.botUserId;
|
|
82600
|
+
this.connByIntegration.set(integrationId, conn);
|
|
82601
|
+
}
|
|
82602
|
+
this.connections.push(conn);
|
|
82603
|
+
this.refreshChannels(conn);
|
|
82604
|
+
} catch (err) {
|
|
82605
|
+
await conn.stop().catch(() => {});
|
|
82606
|
+
this.log.warn(`slack: background retry failed — scheduling next attempt in 60s: ${formatErr(err)}`);
|
|
82607
|
+
const timer = this.clock.setTimeout(() => {
|
|
82608
|
+
if (this.draining) return;
|
|
82609
|
+
this.retrySlackConnection(group).catch((e) => this.log.error(`slack: retry loop error: ${formatErr(e)}`));
|
|
82610
|
+
}, 6e4);
|
|
82611
|
+
this.slackRetryTimers.set(group.appToken, timer);
|
|
82612
|
+
}
|
|
82613
|
+
}
|
|
82200
82614
|
ensureHost(agentId, cfg) {
|
|
82201
82615
|
let host = this.hosts.get(agentId);
|
|
82202
82616
|
if (host) return host;
|
|
@@ -83655,6 +84069,8 @@ var Daemon = class Daemon {
|
|
|
83655
84069
|
}
|
|
83656
84070
|
for (const t of this.cancelTimers.values()) this.clock.clearTimeout(t);
|
|
83657
84071
|
this.cancelTimers.clear();
|
|
84072
|
+
for (const t of this.slackRetryTimers.values()) this.clock.clearTimeout(t);
|
|
84073
|
+
this.slackRetryTimers.clear();
|
|
83658
84074
|
this.metrics?.stop();
|
|
83659
84075
|
await this.watcher?.close();
|
|
83660
84076
|
await this.drainForShutdown();
|
|
@@ -83697,4 +84113,4 @@ async function runForeground(opts, deps = {}) {
|
|
|
83697
84113
|
//#endregion
|
|
83698
84114
|
export { ClientTransport as n, runForeground as t };
|
|
83699
84115
|
|
|
83700
|
-
//# sourceMappingURL=run-foreground-
|
|
84116
|
+
//# sourceMappingURL=run-foreground-CK2rQc1c.js.map
|