@proagentstore/cli 0.2.8 → 0.2.10
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/browser-runner/server.js +1 -1
- package/dist/index.js +31 -15
- package/package.json +1 -1
|
@@ -161,7 +161,7 @@ async function route(runner, req, res) {
|
|
|
161
161
|
if (req.method === "GET" && path === "/coding/sessions") {
|
|
162
162
|
return json(res, 200, { sessions: runner.coding.list() });
|
|
163
163
|
}
|
|
164
|
-
if (req.method === "GET" && path === "/coding/diagnostics") {
|
|
164
|
+
if ((req.method === "GET" || req.method === "POST") && path === "/coding/diagnostics") {
|
|
165
165
|
const { listSessions: tmuxList } = await import("./coding/tmux.js");
|
|
166
166
|
const allTmux = tmuxList();
|
|
167
167
|
const pagsTmux = allTmux.filter((n) => n.startsWith("pags-"));
|
package/dist/index.js
CHANGED
|
@@ -932,20 +932,16 @@ async function connectViaRelay(instanceIds, localUrl, runnerToken, opts) {
|
|
|
932
932
|
writeLine(` Agents: ${instanceIds.length} instance${instanceIds.length === 1 ? "" : "s"}`);
|
|
933
933
|
writeLine(" No cloudflared needed. Ctrl+C to disconnect.");
|
|
934
934
|
writeLine("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
while (!stopped) {
|
|
938
|
-
await new Promise((r) => setTimeout(r, 3e4));
|
|
939
|
-
if (stopped) break;
|
|
935
|
+
const heartbeat = () => {
|
|
936
|
+
const timer = setTimeout(async () => {
|
|
940
937
|
for (const id of instanceIds) {
|
|
941
938
|
await requestPags("POST", `/v1/instances/${apiPathSegment(id)}/runtime/heartbeat`, opts, {}).catch(() => void 0);
|
|
942
939
|
}
|
|
943
|
-
|
|
940
|
+
heartbeat();
|
|
941
|
+
}, 3e4);
|
|
942
|
+
timer.unref();
|
|
944
943
|
};
|
|
945
|
-
|
|
946
|
-
process.once("beforeExit", () => {
|
|
947
|
-
stopped = true;
|
|
948
|
-
});
|
|
944
|
+
heartbeat();
|
|
949
945
|
}
|
|
950
946
|
function openRelaySocket(instanceId, wsBase, pagsToken, localUrl, runnerToken) {
|
|
951
947
|
let backoffMs = 1e3;
|
|
@@ -959,6 +955,13 @@ function openRelaySocket(instanceId, wsBase, pagsToken, localUrl, runnerToken) {
|
|
|
959
955
|
};
|
|
960
956
|
ws.onmessage = async (event) => {
|
|
961
957
|
const text = typeof event.data === "string" ? event.data : String(event.data);
|
|
958
|
+
if (text === "ping") {
|
|
959
|
+
try {
|
|
960
|
+
ws.send("pong");
|
|
961
|
+
} catch {
|
|
962
|
+
}
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
962
965
|
let cmd;
|
|
963
966
|
try {
|
|
964
967
|
cmd = JSON.parse(text);
|
|
@@ -978,16 +981,29 @@ function openRelaySocket(instanceId, wsBase, pagsToken, localUrl, runnerToken) {
|
|
|
978
981
|
headers,
|
|
979
982
|
body: hasBody ? JSON.stringify(cmd.body) : void 0
|
|
980
983
|
});
|
|
981
|
-
const
|
|
982
|
-
|
|
984
|
+
const text2 = await res.text().catch(() => "");
|
|
985
|
+
let result;
|
|
986
|
+
try {
|
|
987
|
+
result = text2 ? JSON.parse(text2) : {};
|
|
988
|
+
} catch {
|
|
989
|
+
result = { raw: text2.slice(0, 500) };
|
|
990
|
+
}
|
|
991
|
+
try {
|
|
992
|
+
ws.send(JSON.stringify({ id: cmd.id, status: res.status, result }));
|
|
993
|
+
} catch {
|
|
994
|
+
}
|
|
983
995
|
} catch (err) {
|
|
984
|
-
|
|
996
|
+
try {
|
|
997
|
+
ws.send(JSON.stringify({ id: cmd.id, status: 500, error: err instanceof Error ? err.message : String(err) }));
|
|
998
|
+
} catch {
|
|
999
|
+
}
|
|
985
1000
|
}
|
|
986
1001
|
};
|
|
987
|
-
ws.onclose = () => {
|
|
1002
|
+
ws.onclose = (ev) => {
|
|
988
1003
|
if (reconnecting) return;
|
|
989
1004
|
reconnecting = true;
|
|
990
|
-
|
|
1005
|
+
const reason = ev.code === 4401 || ev.code === 1008 ? " (token expired \u2014 run `pags login` then `pags up`)" : "";
|
|
1006
|
+
writeLine(`Relay disconnected: ${instanceId.slice(0, 8)}\u2026${reason} \u2014 reconnecting in ${Math.round(backoffMs / 1e3)}s`);
|
|
991
1007
|
setTimeout(() => {
|
|
992
1008
|
reconnecting = false;
|
|
993
1009
|
connect();
|