@slock-ai/daemon 0.31.3-alpha.8 → 0.32.1
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/chat-bridge.js +0 -0
- package/dist/index.js +64 -6
- package/package.json +15 -15
package/dist/chat-bridge.js
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { fileURLToPath } from "url";
|
|
|
10
10
|
|
|
11
11
|
// src/connection.ts
|
|
12
12
|
import WebSocket from "ws";
|
|
13
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
13
14
|
|
|
14
15
|
// src/logger.ts
|
|
15
16
|
function timestamp() {
|
|
@@ -43,6 +44,52 @@ var systemClock = {
|
|
|
43
44
|
clearTimeout: (timer) => clearTimeout(timer)
|
|
44
45
|
};
|
|
45
46
|
var INBOUND_WATCHDOG_MS = 7e4;
|
|
47
|
+
function getProxyUrlForWebSocket(wsUrl, env) {
|
|
48
|
+
const protocol = new URL(wsUrl).protocol;
|
|
49
|
+
if (protocol === "wss:") {
|
|
50
|
+
return env.WSS_PROXY || env.wss_proxy || env.HTTPS_PROXY || env.https_proxy || env.ALL_PROXY || env.all_proxy;
|
|
51
|
+
}
|
|
52
|
+
return env.WS_PROXY || env.ws_proxy || env.HTTP_PROXY || env.http_proxy || env.ALL_PROXY || env.all_proxy;
|
|
53
|
+
}
|
|
54
|
+
function getDefaultPort(protocol) {
|
|
55
|
+
switch (protocol) {
|
|
56
|
+
case "https:":
|
|
57
|
+
case "wss:":
|
|
58
|
+
return "443";
|
|
59
|
+
case "http:":
|
|
60
|
+
case "ws:":
|
|
61
|
+
return "80";
|
|
62
|
+
default:
|
|
63
|
+
return "";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function hostMatchesNoProxyEntry(hostname, ruleHost) {
|
|
67
|
+
if (!ruleHost) return false;
|
|
68
|
+
const normalizedRule = ruleHost.replace(/^\*\./, ".").replace(/^\./, "").toLowerCase();
|
|
69
|
+
const normalizedHost = hostname.toLowerCase();
|
|
70
|
+
return normalizedHost === normalizedRule || normalizedHost.endsWith(`.${normalizedRule}`);
|
|
71
|
+
}
|
|
72
|
+
function shouldBypassProxy(wsUrl, env) {
|
|
73
|
+
const rawNoProxy = env.NO_PROXY || env.no_proxy;
|
|
74
|
+
if (!rawNoProxy) return false;
|
|
75
|
+
const url = new URL(wsUrl);
|
|
76
|
+
const hostname = url.hostname.toLowerCase();
|
|
77
|
+
const port = url.port || getDefaultPort(url.protocol);
|
|
78
|
+
return rawNoProxy.split(",").map((entry) => entry.trim()).filter(Boolean).some((entry) => {
|
|
79
|
+
if (entry === "*") return true;
|
|
80
|
+
const [ruleHost, rulePort] = entry.split(":", 2);
|
|
81
|
+
if (rulePort && rulePort !== port) return false;
|
|
82
|
+
return hostMatchesNoProxyEntry(hostname, ruleHost);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function buildWebSocketOptions(wsUrl, env) {
|
|
86
|
+
const proxyUrl = getProxyUrlForWebSocket(wsUrl, env);
|
|
87
|
+
if (!proxyUrl) return void 0;
|
|
88
|
+
if (shouldBypassProxy(wsUrl, env)) return void 0;
|
|
89
|
+
return {
|
|
90
|
+
agent: new HttpsProxyAgent(proxyUrl)
|
|
91
|
+
};
|
|
92
|
+
}
|
|
46
93
|
var DaemonConnection = class {
|
|
47
94
|
ws = null;
|
|
48
95
|
options;
|
|
@@ -96,8 +143,12 @@ var DaemonConnection = class {
|
|
|
96
143
|
if (!this.shouldConnect) return;
|
|
97
144
|
if (this.ws && this.ws.readyState !== WebSocket.CLOSED) return;
|
|
98
145
|
const wsUrl = this.options.serverUrl.replace(/^http/, "ws") + `/daemon/connect?key=${this.options.apiKey}`;
|
|
146
|
+
const wsOptions = buildWebSocketOptions(wsUrl, this.options.proxyEnv ?? process.env);
|
|
99
147
|
logger.info(`[Daemon] Connecting to ${this.options.serverUrl}...`);
|
|
100
|
-
|
|
148
|
+
if (wsOptions?.agent) {
|
|
149
|
+
logger.info("[Daemon] Using configured proxy for WebSocket connection");
|
|
150
|
+
}
|
|
151
|
+
const ws = this.options.wsFactory ? this.options.wsFactory(wsUrl, wsOptions) : new WebSocket(wsUrl, wsOptions);
|
|
101
152
|
this.ws = ws;
|
|
102
153
|
ws.on("open", () => {
|
|
103
154
|
if (this.ws !== ws) return;
|
|
@@ -2178,16 +2229,22 @@ function summarizeIncomingMessage(msg) {
|
|
|
2178
2229
|
}
|
|
2179
2230
|
}
|
|
2180
2231
|
function detectRuntimes() {
|
|
2181
|
-
const
|
|
2232
|
+
const ids = [];
|
|
2233
|
+
const versions = {};
|
|
2182
2234
|
const cmd = process.platform === "win32" ? "where" : "which";
|
|
2183
2235
|
for (const rt of RUNTIMES) {
|
|
2184
2236
|
try {
|
|
2185
2237
|
execSync2(`${cmd} ${rt.binary}`, { stdio: "pipe" });
|
|
2186
|
-
|
|
2238
|
+
ids.push(rt.id);
|
|
2239
|
+
try {
|
|
2240
|
+
const ver = execSync2(`${rt.binary} --version`, { stdio: "pipe", timeout: 5e3 }).toString().trim().split("\n")[0];
|
|
2241
|
+
versions[rt.id] = ver;
|
|
2242
|
+
} catch {
|
|
2243
|
+
}
|
|
2187
2244
|
} catch {
|
|
2188
2245
|
}
|
|
2189
2246
|
}
|
|
2190
|
-
return
|
|
2247
|
+
return { ids, versions };
|
|
2191
2248
|
}
|
|
2192
2249
|
var args = process.argv.slice(2);
|
|
2193
2250
|
var serverUrl = "";
|
|
@@ -2290,8 +2347,9 @@ connection = new DaemonConnection({
|
|
|
2290
2347
|
}
|
|
2291
2348
|
},
|
|
2292
2349
|
onConnect: () => {
|
|
2293
|
-
const runtimes = detectRuntimes();
|
|
2294
|
-
|
|
2350
|
+
const { ids: runtimes, versions: runtimeVersions } = detectRuntimes();
|
|
2351
|
+
const runtimeInfo = runtimes.map((id) => runtimeVersions[id] ? `${id} (${runtimeVersions[id]})` : id);
|
|
2352
|
+
logger.info(`[Daemon] Detected runtimes: ${runtimeInfo.join(", ") || "none"}`);
|
|
2295
2353
|
connection.send({
|
|
2296
2354
|
type: "ready",
|
|
2297
2355
|
capabilities: ["agent:start", "agent:stop", "agent:deliver", "workspace:files"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slock-ai/daemon",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"slock-daemon": "dist/index.js"
|
|
@@ -16,28 +16,28 @@
|
|
|
16
16
|
"publishConfig": {
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
21
|
+
"https-proxy-agent": "^7.0.6",
|
|
22
|
+
"ws": "^8.20.0",
|
|
23
|
+
"zod": "^4.3.6"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^25.5.0",
|
|
27
|
+
"@types/ws": "^8.18.1",
|
|
28
|
+
"tsup": "^8.5.1",
|
|
29
|
+
"typescript": "^5.9.3",
|
|
30
|
+
"@slock-ai/shared": "0.1.0"
|
|
31
|
+
},
|
|
19
32
|
"scripts": {
|
|
20
33
|
"dev": "tsx watch src/index.ts",
|
|
21
34
|
"start": "tsx src/index.ts",
|
|
22
35
|
"build": "tsup",
|
|
23
36
|
"test": "node --import tsx --test --test-force-exit 'src/**/*.test.ts'",
|
|
24
|
-
"prepublishOnly": "pnpm run build",
|
|
25
37
|
"typecheck": "tsc --noEmit",
|
|
26
38
|
"release:patch": "npm version patch --no-git-tag-version && cd ../.. && pnpm install --lockfile-only && git add packages/daemon/package.json pnpm-lock.yaml && git commit -m \"chore: bump @slock-ai/daemon to v$(node -p \"require('./packages/daemon/package.json').version\")\" && git tag daemon-v$(node -p \"require('./packages/daemon/package.json').version\") && git push && git push --tags",
|
|
27
39
|
"release:minor": "npm version minor --no-git-tag-version && cd ../.. && pnpm install --lockfile-only && git add packages/daemon/package.json pnpm-lock.yaml && git commit -m \"chore: bump @slock-ai/daemon to v$(node -p \"require('./packages/daemon/package.json').version\")\" && git tag daemon-v$(node -p \"require('./packages/daemon/package.json').version\") && git push && git push --tags",
|
|
28
40
|
"release:major": "npm version major --no-git-tag-version && cd ../.. && pnpm install --lockfile-only && git add packages/daemon/package.json pnpm-lock.yaml && git commit -m \"chore: bump @slock-ai/daemon to v$(node -p \"require('./packages/daemon/package.json').version\")\" && git tag daemon-v$(node -p \"require('./packages/daemon/package.json').version\") && git push && git push --tags",
|
|
29
41
|
"release:alpha": "npm version prerelease --preid=alpha --no-git-tag-version && cd ../.. && pnpm install --lockfile-only && git add packages/daemon/package.json pnpm-lock.yaml && git commit -m \"chore: bump @slock-ai/daemon to v$(node -p \"require('./packages/daemon/package.json').version\")\" && git tag daemon-v$(node -p \"require('./packages/daemon/package.json').version\") && git push && git push --tags"
|
|
30
|
-
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
33
|
-
"ws": "^8.20.0",
|
|
34
|
-
"zod": "^4.3.6"
|
|
35
|
-
},
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"@slock-ai/shared": "workspace:*",
|
|
38
|
-
"@types/node": "^25.5.0",
|
|
39
|
-
"@types/ws": "^8.18.1",
|
|
40
|
-
"tsup": "^8.5.1",
|
|
41
|
-
"typescript": "^5.9.3"
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
}
|