@slock-ai/daemon 0.48.1 → 0.49.0
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 +3 -1451
- package/dist/{chunk-B7XIMLOT.js → chunk-KNMCE6WB.js} +66 -109
- package/dist/{chunk-RDRY2MW2.js → chunk-M4A5QPUN.js} +452 -270
- package/dist/cli/index.js +287 -53
- package/dist/core.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -41,75 +41,6 @@ var logger = {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
// src/proxy.ts
|
|
45
|
-
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
46
|
-
import { ProxyAgent } from "undici";
|
|
47
|
-
var fetchDispatcherCache = /* @__PURE__ */ new Map();
|
|
48
|
-
function getDefaultPort(protocol) {
|
|
49
|
-
switch (protocol) {
|
|
50
|
-
case "https:":
|
|
51
|
-
case "wss:":
|
|
52
|
-
return "443";
|
|
53
|
-
case "http:":
|
|
54
|
-
case "ws:":
|
|
55
|
-
return "80";
|
|
56
|
-
default:
|
|
57
|
-
return "";
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function hostMatchesNoProxyEntry(hostname, ruleHost) {
|
|
61
|
-
if (!ruleHost) return false;
|
|
62
|
-
const normalizedRule = ruleHost.replace(/^\*\./, ".").replace(/^\./, "").toLowerCase();
|
|
63
|
-
const normalizedHost = hostname.toLowerCase();
|
|
64
|
-
return normalizedHost === normalizedRule || normalizedHost.endsWith(`.${normalizedRule}`);
|
|
65
|
-
}
|
|
66
|
-
function getProxyUrlForTarget(targetUrl, env) {
|
|
67
|
-
const protocol = new URL(targetUrl).protocol;
|
|
68
|
-
switch (protocol) {
|
|
69
|
-
case "wss:":
|
|
70
|
-
return env.WSS_PROXY || env.wss_proxy || env.HTTPS_PROXY || env.https_proxy || env.ALL_PROXY || env.all_proxy;
|
|
71
|
-
case "ws:":
|
|
72
|
-
return env.WS_PROXY || env.ws_proxy || env.HTTP_PROXY || env.http_proxy || env.ALL_PROXY || env.all_proxy;
|
|
73
|
-
case "https:":
|
|
74
|
-
return env.HTTPS_PROXY || env.https_proxy || env.ALL_PROXY || env.all_proxy;
|
|
75
|
-
case "http:":
|
|
76
|
-
return env.HTTP_PROXY || env.http_proxy || env.ALL_PROXY || env.all_proxy;
|
|
77
|
-
default:
|
|
78
|
-
return env.ALL_PROXY || env.all_proxy;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function shouldBypassProxy(targetUrl, env) {
|
|
82
|
-
const rawNoProxy = env.NO_PROXY || env.no_proxy;
|
|
83
|
-
if (!rawNoProxy) return false;
|
|
84
|
-
const url = new URL(targetUrl);
|
|
85
|
-
const hostname = url.hostname.toLowerCase();
|
|
86
|
-
const port = url.port || getDefaultPort(url.protocol);
|
|
87
|
-
return rawNoProxy.split(",").map((entry) => entry.trim()).filter(Boolean).some((entry) => {
|
|
88
|
-
if (entry === "*") return true;
|
|
89
|
-
const [ruleHost, rulePort] = entry.split(":", 2);
|
|
90
|
-
if (rulePort && rulePort !== port) return false;
|
|
91
|
-
return hostMatchesNoProxyEntry(hostname, ruleHost);
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
function buildWebSocketOptions(wsUrl, env) {
|
|
95
|
-
const proxyUrl = getProxyUrlForTarget(wsUrl, env);
|
|
96
|
-
if (!proxyUrl) return void 0;
|
|
97
|
-
if (shouldBypassProxy(wsUrl, env)) return void 0;
|
|
98
|
-
return {
|
|
99
|
-
agent: new HttpsProxyAgent(proxyUrl)
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function buildFetchDispatcher(targetUrl, env) {
|
|
103
|
-
const proxyUrl = getProxyUrlForTarget(targetUrl, env);
|
|
104
|
-
if (!proxyUrl) return void 0;
|
|
105
|
-
if (shouldBypassProxy(targetUrl, env)) return void 0;
|
|
106
|
-
const cached = fetchDispatcherCache.get(proxyUrl);
|
|
107
|
-
if (cached) return cached;
|
|
108
|
-
const dispatcher = new ProxyAgent(proxyUrl);
|
|
109
|
-
fetchDispatcherCache.set(proxyUrl, dispatcher);
|
|
110
|
-
return dispatcher;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
44
|
// src/chatBridgeRequest.ts
|
|
114
45
|
var DEFAULT_CHAT_BRIDGE_TOOL_TIMEOUT_MS = Number.parseInt(
|
|
115
46
|
process.env.SLOCK_CHAT_BRIDGE_TOOL_TIMEOUT_MS || "",
|
|
@@ -207,55 +138,81 @@ async function executeResponseRequest(url, init, {
|
|
|
207
138
|
}
|
|
208
139
|
}
|
|
209
140
|
|
|
210
|
-
// src/
|
|
211
|
-
import
|
|
212
|
-
import
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
141
|
+
// src/proxy.ts
|
|
142
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
143
|
+
import { ProxyAgent } from "undici";
|
|
144
|
+
var fetchDispatcherCache = /* @__PURE__ */ new Map();
|
|
145
|
+
function getDefaultPort(protocol) {
|
|
146
|
+
switch (protocol) {
|
|
147
|
+
case "https:":
|
|
148
|
+
case "wss:":
|
|
149
|
+
return "443";
|
|
150
|
+
case "http:":
|
|
151
|
+
case "ws:":
|
|
152
|
+
return "80";
|
|
153
|
+
default:
|
|
154
|
+
return "";
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function hostMatchesNoProxyEntry(hostname, ruleHost) {
|
|
158
|
+
if (!ruleHost) return false;
|
|
159
|
+
const normalizedRule = ruleHost.replace(/^\*\./, ".").replace(/^\./, "").toLowerCase();
|
|
160
|
+
const normalizedHost = hostname.toLowerCase();
|
|
161
|
+
return normalizedHost === normalizedRule || normalizedHost.endsWith(`.${normalizedRule}`);
|
|
162
|
+
}
|
|
163
|
+
function getProxyUrlForTarget(targetUrl, env) {
|
|
164
|
+
const protocol = new URL(targetUrl).protocol;
|
|
165
|
+
switch (protocol) {
|
|
166
|
+
case "wss:":
|
|
167
|
+
return env.WSS_PROXY || env.wss_proxy || env.HTTPS_PROXY || env.https_proxy || env.ALL_PROXY || env.all_proxy;
|
|
168
|
+
case "ws:":
|
|
169
|
+
return env.WS_PROXY || env.ws_proxy || env.HTTP_PROXY || env.http_proxy || env.ALL_PROXY || env.all_proxy;
|
|
170
|
+
case "https:":
|
|
171
|
+
return env.HTTPS_PROXY || env.https_proxy || env.ALL_PROXY || env.all_proxy;
|
|
172
|
+
case "http:":
|
|
173
|
+
return env.HTTP_PROXY || env.http_proxy || env.ALL_PROXY || env.all_proxy;
|
|
174
|
+
default:
|
|
175
|
+
return env.ALL_PROXY || env.all_proxy;
|
|
176
|
+
}
|
|
217
177
|
}
|
|
218
|
-
function
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
178
|
+
function shouldBypassProxy(targetUrl, env) {
|
|
179
|
+
const rawNoProxy = env.NO_PROXY || env.no_proxy;
|
|
180
|
+
if (!rawNoProxy) return false;
|
|
181
|
+
const url = new URL(targetUrl);
|
|
182
|
+
const hostname = url.hostname.toLowerCase();
|
|
183
|
+
const port = url.port || getDefaultPort(url.protocol);
|
|
184
|
+
return rawNoProxy.split(",").map((entry) => entry.trim()).filter(Boolean).some((entry) => {
|
|
185
|
+
if (entry === "*") return true;
|
|
186
|
+
const [ruleHost, rulePort] = entry.split(":", 2);
|
|
187
|
+
if (rulePort && rulePort !== port) return false;
|
|
188
|
+
return hostMatchesNoProxyEntry(hostname, ruleHost);
|
|
189
|
+
});
|
|
222
190
|
}
|
|
223
|
-
function
|
|
224
|
-
|
|
191
|
+
function buildWebSocketOptions(wsUrl, env) {
|
|
192
|
+
const proxyUrl = getProxyUrlForTarget(wsUrl, env);
|
|
193
|
+
if (!proxyUrl) return void 0;
|
|
194
|
+
if (shouldBypassProxy(wsUrl, env)) return void 0;
|
|
195
|
+
return {
|
|
196
|
+
agent: new HttpsProxyAgent(proxyUrl)
|
|
197
|
+
};
|
|
225
198
|
}
|
|
226
|
-
function
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
{
|
|
236
|
-
path: path.join(defaultHome, "machines"),
|
|
237
|
-
destination: path.join(slockHome, "machines"),
|
|
238
|
-
description: "daemon machine locks, local traces, and machine-scoped state"
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
path: path.join(defaultHome, "attachments"),
|
|
242
|
-
destination: path.join(slockHome, "attachments"),
|
|
243
|
-
description: "chat bridge attachment download cache"
|
|
244
|
-
}
|
|
245
|
-
];
|
|
246
|
-
return candidates.filter((candidate) => existsSync(candidate.path));
|
|
199
|
+
function buildFetchDispatcher(targetUrl, env) {
|
|
200
|
+
const proxyUrl = getProxyUrlForTarget(targetUrl, env);
|
|
201
|
+
if (!proxyUrl) return void 0;
|
|
202
|
+
if (shouldBypassProxy(targetUrl, env)) return void 0;
|
|
203
|
+
const cached = fetchDispatcherCache.get(proxyUrl);
|
|
204
|
+
if (cached) return cached;
|
|
205
|
+
const dispatcher = new ProxyAgent(proxyUrl);
|
|
206
|
+
fetchDispatcherCache.set(proxyUrl, dispatcher);
|
|
207
|
+
return dispatcher;
|
|
247
208
|
}
|
|
248
209
|
|
|
249
210
|
export {
|
|
250
211
|
subscribeDaemonLogs,
|
|
251
212
|
logger,
|
|
252
|
-
buildWebSocketOptions,
|
|
253
|
-
buildFetchDispatcher,
|
|
254
213
|
DEFAULT_CHAT_BRIDGE_TOOL_TIMEOUT_MS,
|
|
255
214
|
executeJsonRequest,
|
|
256
215
|
executeResponseRequest,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
resolveSlockHomePath,
|
|
260
|
-
listLegacySlockStatePaths
|
|
216
|
+
buildWebSocketOptions,
|
|
217
|
+
buildFetchDispatcher
|
|
261
218
|
};
|