@slock-ai/daemon 0.53.1-alpha.1 → 0.53.1-alpha.3
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/{chunk-LKHS6SRG.js → chunk-QVULOADZ.js} +54 -11
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1376,7 +1376,14 @@ function allocatePort() {
|
|
|
1376
1376
|
function ensureServer(port) {
|
|
1377
1377
|
if (servers.has(port)) return;
|
|
1378
1378
|
const server = http.createServer((req, res) => {
|
|
1379
|
-
void handleProxyRequest(req, res)
|
|
1379
|
+
void handleProxyRequest(req, res).catch((err) => {
|
|
1380
|
+
logger.error(`[Agent Credential Proxy] unhandled local proxy error: ${err.message}`);
|
|
1381
|
+
writeProxyFailureResponse(res, {
|
|
1382
|
+
error: "failed to proxy local agent request",
|
|
1383
|
+
code: "agent_proxy_failed",
|
|
1384
|
+
detail: truncateProxyErrorMessage(err.message)
|
|
1385
|
+
});
|
|
1386
|
+
});
|
|
1380
1387
|
});
|
|
1381
1388
|
server.on("error", (err) => {
|
|
1382
1389
|
logger.warn(`[Agent Credential Proxy] local proxy on port ${port} failed: ${err.message}`);
|
|
@@ -1404,6 +1411,7 @@ async function handleProxyRequest(req, res) {
|
|
|
1404
1411
|
}
|
|
1405
1412
|
const method = req.method ?? "GET";
|
|
1406
1413
|
let target;
|
|
1414
|
+
let upstreamStatus = null;
|
|
1407
1415
|
try {
|
|
1408
1416
|
target = new URL2(req.url ?? "/", registration.serverUrl);
|
|
1409
1417
|
const headers = new Headers();
|
|
@@ -1453,6 +1461,7 @@ async function handleProxyRequest(req, res) {
|
|
|
1453
1461
|
// Required by undici when forwarding a Node stream.
|
|
1454
1462
|
duplex: body ? "half" : void 0
|
|
1455
1463
|
});
|
|
1464
|
+
upstreamStatus = upstream.status;
|
|
1456
1465
|
if (shouldBufferJsonResponse(upstream, target.pathname, registration)) {
|
|
1457
1466
|
const responseText = await upstream.text();
|
|
1458
1467
|
consumeVisibleResponse(registration, target, sendTarget, responseText);
|
|
@@ -1476,26 +1485,45 @@ async function handleProxyRequest(req, res) {
|
|
|
1476
1485
|
res.end();
|
|
1477
1486
|
}
|
|
1478
1487
|
} catch (err) {
|
|
1479
|
-
const failure = proxyFailureForError(method, target, err);
|
|
1488
|
+
const failure = proxyFailureForError(method, target, res, upstreamStatus, err);
|
|
1480
1489
|
logger.warn(
|
|
1481
|
-
`[Agent Credential Proxy] request failed (agent=${registration.agentId}, launch=${registration.launchId ?? "none"}, method=${failure.method}, path=${failure.pathname}, query_keys=${failure.queryKeys.join(",") || "none"}): ${failure.
|
|
1490
|
+
`[Agent Credential Proxy] request failed (agent=${registration.agentId}, launch=${registration.launchId ?? "none"}, method=${failure.method}, path=${failure.pathname}, query_keys=${failure.queryKeys.join(",") || "none"}): ${failure.errorClass}: ${failure.errorMessage}`
|
|
1482
1491
|
);
|
|
1483
1492
|
registration.inboxCoordinator?.recordProxyFailure?.(failure);
|
|
1484
|
-
res
|
|
1485
|
-
res.end(JSON.stringify({
|
|
1493
|
+
writeProxyFailureResponse(res, {
|
|
1486
1494
|
error: "failed to proxy local agent request",
|
|
1487
1495
|
code: "agent_proxy_failed",
|
|
1488
1496
|
detail: failure.errorMessage
|
|
1489
|
-
})
|
|
1497
|
+
});
|
|
1490
1498
|
}
|
|
1491
1499
|
}
|
|
1492
|
-
function
|
|
1500
|
+
function writeProxyFailureResponse(res, body) {
|
|
1501
|
+
if (res.destroyed || res.writableEnded) return;
|
|
1502
|
+
if (proxyResponseStarted(res)) {
|
|
1503
|
+
try {
|
|
1504
|
+
res.end();
|
|
1505
|
+
} catch {
|
|
1506
|
+
}
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1509
|
+
try {
|
|
1510
|
+
res.writeHead(502, { "content-type": "application/json" });
|
|
1511
|
+
res.end(JSON.stringify(body));
|
|
1512
|
+
} catch {
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
function proxyResponseStarted(res) {
|
|
1516
|
+
return res.headersSent || res.writableEnded;
|
|
1517
|
+
}
|
|
1518
|
+
function proxyFailureForError(method, target, res, upstreamStatus, err) {
|
|
1493
1519
|
const queryKeys = target ? [.../* @__PURE__ */ new Set([...target.searchParams.keys()])].sort() : [];
|
|
1494
1520
|
return {
|
|
1495
1521
|
method,
|
|
1496
1522
|
pathname: target?.pathname ?? "unknown",
|
|
1497
1523
|
queryKeys,
|
|
1498
|
-
|
|
1524
|
+
responseStarted: proxyResponseStarted(res),
|
|
1525
|
+
upstreamStatus,
|
|
1526
|
+
errorClass: err instanceof Error ? err.name : typeof err,
|
|
1499
1527
|
errorMessage: truncateProxyErrorMessage(err instanceof Error ? err.message : String(err))
|
|
1500
1528
|
};
|
|
1501
1529
|
}
|
|
@@ -5522,8 +5550,18 @@ function isMissingResumeSession(ap) {
|
|
|
5522
5550
|
(text) => /Session not found/i.test(text) && text.includes(ap.sessionId)
|
|
5523
5551
|
);
|
|
5524
5552
|
}
|
|
5553
|
+
if (ap.driver.id === "gemini") {
|
|
5554
|
+
return candidates.some(
|
|
5555
|
+
(text) => /Error resuming session:\s*Invalid session identifier/i.test(text) && text.includes(ap.sessionId)
|
|
5556
|
+
);
|
|
5557
|
+
}
|
|
5525
5558
|
return false;
|
|
5526
5559
|
}
|
|
5560
|
+
function resumeSessionRuntimeLabel(runtimeId) {
|
|
5561
|
+
if (runtimeId === "opencode") return "OpenCode";
|
|
5562
|
+
if (runtimeId === "gemini") return "Gemini";
|
|
5563
|
+
return "Claude";
|
|
5564
|
+
}
|
|
5527
5565
|
function classifyActivityDetailForTrace(detail) {
|
|
5528
5566
|
if (!detail) return void 0;
|
|
5529
5567
|
if (detail === "Message received") return "message_received";
|
|
@@ -5889,7 +5927,9 @@ var AgentProcessManager = class _AgentProcessManager {
|
|
|
5889
5927
|
method: input.method,
|
|
5890
5928
|
path: input.pathname,
|
|
5891
5929
|
query_keys: input.queryKeys,
|
|
5892
|
-
|
|
5930
|
+
response_started: input.responseStarted,
|
|
5931
|
+
upstream_status: input.upstreamStatus,
|
|
5932
|
+
error_class: input.errorClass,
|
|
5893
5933
|
error_message: input.errorMessage
|
|
5894
5934
|
}, "error");
|
|
5895
5935
|
}
|
|
@@ -6441,7 +6481,7 @@ Use ${communicationCommand(driver, "read_history")} to catch up on the channels
|
|
|
6441
6481
|
this.agents.delete(agentId);
|
|
6442
6482
|
if (missingResumeSession) {
|
|
6443
6483
|
const staleSessionId = ap.sessionId;
|
|
6444
|
-
const runtimeLabel = ap.driver.id
|
|
6484
|
+
const runtimeLabel = resumeSessionRuntimeLabel(ap.driver.id);
|
|
6445
6485
|
const restartConfig = { ...stripManagedRunnerCredential(ap.config), sessionId: null };
|
|
6446
6486
|
logger.warn(
|
|
6447
6487
|
`[Agent ${agentId}] Stored ${runtimeLabel} session ${staleSessionId} is unavailable locally; falling back to cold start`
|
|
@@ -6450,7 +6490,10 @@ Use ${communicationCommand(driver, "read_history")} to catch up on the channels
|
|
|
6450
6490
|
agentId,
|
|
6451
6491
|
"working",
|
|
6452
6492
|
`Stored ${runtimeLabel} session missing; cold-starting a new session\u2026`,
|
|
6453
|
-
[{
|
|
6493
|
+
[{
|
|
6494
|
+
kind: "text",
|
|
6495
|
+
text: `Stored ${runtimeLabel} session ${staleSessionId} was not found locally. Falling back to a cold start; earlier runtime context may not be restored.`
|
|
6496
|
+
}]
|
|
6454
6497
|
);
|
|
6455
6498
|
this.startAgent(
|
|
6456
6499
|
agentId,
|
package/dist/core.js
CHANGED
package/dist/index.js
CHANGED