@slock-ai/daemon 0.55.0 → 0.55.1-play.20260530150714
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 +1 -1
- package/dist/{chunk-VOZJ2ELH.js → chunk-M2KQBJR3.js} +37 -4
- package/dist/{chunk-6Q3U5STT.js → chunk-XRE6235X.js} +922 -176
- package/dist/cli/index.js +1299 -507
- package/dist/core.js +7 -3
- package/dist/drivers/piSdkRunner.js +96 -0
- package/dist/index.js +6 -4
- package/package.json +2 -1
package/dist/chat-bridge.js
CHANGED
|
@@ -142,6 +142,10 @@ async function executeResponseRequest(url, init, {
|
|
|
142
142
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
143
143
|
import { ProxyAgent } from "undici";
|
|
144
144
|
var fetchDispatcherCache = /* @__PURE__ */ new Map();
|
|
145
|
+
function getFetchPreResponseTimeoutMs(env) {
|
|
146
|
+
const parsed = Number.parseInt(env.SLOCK_DAEMON_FETCH_PRE_RESPONSE_TIMEOUT_MS || "", 10);
|
|
147
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : 3e4;
|
|
148
|
+
}
|
|
145
149
|
function getDefaultPort(protocol) {
|
|
146
150
|
switch (protocol) {
|
|
147
151
|
case "https:":
|
|
@@ -196,24 +200,53 @@ function buildWebSocketOptions(wsUrl, env) {
|
|
|
196
200
|
agent: new HttpsProxyAgent(proxyUrl)
|
|
197
201
|
};
|
|
198
202
|
}
|
|
199
|
-
function
|
|
203
|
+
function resolveProxyUrl(targetUrl, env) {
|
|
200
204
|
const proxyUrl = getProxyUrlForTarget(targetUrl, env);
|
|
201
205
|
if (!proxyUrl) return void 0;
|
|
202
206
|
if (shouldBypassProxy(targetUrl, env)) return void 0;
|
|
207
|
+
return proxyUrl;
|
|
208
|
+
}
|
|
209
|
+
function buildFetchDispatcher(targetUrl, env) {
|
|
210
|
+
const proxyUrl = resolveProxyUrl(targetUrl, env);
|
|
211
|
+
if (!proxyUrl) return void 0;
|
|
203
212
|
const cached = fetchDispatcherCache.get(proxyUrl);
|
|
204
213
|
if (cached) return cached;
|
|
205
|
-
const
|
|
214
|
+
const timeoutMs = getFetchPreResponseTimeoutMs(env);
|
|
215
|
+
const dispatcher = new ProxyAgent({
|
|
216
|
+
uri: proxyUrl,
|
|
217
|
+
// All three are pre-response and body-agnostic (see getFetchPreResponseTimeoutMs):
|
|
218
|
+
// headersTimeout = headers-hang leg; requestTls.timeout = CONNECT-tunnel
|
|
219
|
+
// establish leg; connect.timeout = socket to the proxy itself (defensive).
|
|
220
|
+
connect: { timeout: timeoutMs },
|
|
221
|
+
requestTls: { timeout: timeoutMs },
|
|
222
|
+
headersTimeout: timeoutMs
|
|
223
|
+
});
|
|
206
224
|
fetchDispatcherCache.set(proxyUrl, dispatcher);
|
|
207
225
|
return dispatcher;
|
|
208
226
|
}
|
|
227
|
+
function evictFetchDispatcher(targetUrl, env) {
|
|
228
|
+
const proxyUrl = resolveProxyUrl(targetUrl, env);
|
|
229
|
+
if (!proxyUrl) return false;
|
|
230
|
+
const cached = fetchDispatcherCache.get(proxyUrl);
|
|
231
|
+
if (!cached) return false;
|
|
232
|
+
fetchDispatcherCache.delete(proxyUrl);
|
|
233
|
+
void Promise.resolve().then(() => cached.close()).catch(() => cached.destroy?.(new Error("evicted"))).catch(() => {
|
|
234
|
+
});
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
209
237
|
|
|
210
238
|
// src/daemonFetch.ts
|
|
211
239
|
function withDaemonFetchProxy(input, init = {}, env = process.env) {
|
|
212
240
|
const dispatcher = buildFetchDispatcher(input.toString(), env);
|
|
213
241
|
return dispatcher ? { ...init, dispatcher } : init;
|
|
214
242
|
}
|
|
215
|
-
function daemonFetch(input, init, env = process.env) {
|
|
216
|
-
|
|
243
|
+
async function daemonFetch(input, init, env = process.env) {
|
|
244
|
+
try {
|
|
245
|
+
return await fetch(input, withDaemonFetchProxy(input, init, env));
|
|
246
|
+
} catch (err) {
|
|
247
|
+
evictFetchDispatcher(input.toString(), env);
|
|
248
|
+
throw err;
|
|
249
|
+
}
|
|
217
250
|
}
|
|
218
251
|
|
|
219
252
|
export {
|