@staff0rd/assist 0.761.1 → 0.763.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/README.md +2 -2
- package/dist/commands/sessions/web/bundle.js +427 -427
- package/dist/index.js +24 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.763.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -15033,20 +15033,26 @@ import {
|
|
|
15033
15033
|
} from "http";
|
|
15034
15034
|
import { request as httpsRequest } from "https";
|
|
15035
15035
|
|
|
15036
|
-
// src/commands/sessions/web/peerTimeoutMs.ts
|
|
15037
|
-
var peerTimeoutMs = 2e4;
|
|
15038
|
-
|
|
15039
15036
|
// src/commands/sessions/web/boundUpstream.ts
|
|
15040
|
-
function boundUpstream(upstream, res) {
|
|
15037
|
+
function boundUpstream(upstream, res, timeoutMs) {
|
|
15041
15038
|
upstream.setTimeout(
|
|
15042
|
-
|
|
15043
|
-
() => upstream.destroy(new Error(`no response after ${
|
|
15039
|
+
timeoutMs,
|
|
15040
|
+
() => upstream.destroy(new Error(`no response after ${timeoutMs}ms`))
|
|
15044
15041
|
);
|
|
15045
15042
|
res.on("close", () => {
|
|
15046
15043
|
if (!res.writableFinished) upstream.destroy();
|
|
15047
15044
|
});
|
|
15048
15045
|
}
|
|
15049
15046
|
|
|
15047
|
+
// src/commands/sessions/web/peerTimeoutMs.ts
|
|
15048
|
+
var peerTimeoutMs = 2e4;
|
|
15049
|
+
|
|
15050
|
+
// src/commands/sessions/web/peerTimeoutFor.ts
|
|
15051
|
+
var ASSIST_UPDATE_DURATION_MS = 6e5;
|
|
15052
|
+
function peerTimeoutFor(pathname) {
|
|
15053
|
+
return pathname === "/api/self-update" ? ASSIST_UPDATE_DURATION_MS : peerTimeoutMs;
|
|
15054
|
+
}
|
|
15055
|
+
|
|
15050
15056
|
// src/commands/sessions/web/isQuietPoll.ts
|
|
15051
15057
|
var POLLED_PATHS = /* @__PURE__ */ new Set(["/api/git-status"]);
|
|
15052
15058
|
function isQuietPoll(pathname, status2) {
|
|
@@ -15085,7 +15091,7 @@ function forwardToPeer(req, res, node, url) {
|
|
|
15085
15091
|
},
|
|
15086
15092
|
(peer) => relayPeerResponse(peer, res, url.pathname, log2, resolve26)
|
|
15087
15093
|
);
|
|
15088
|
-
boundUpstream(upstream, res);
|
|
15094
|
+
boundUpstream(upstream, res, peerTimeoutFor(url.pathname));
|
|
15089
15095
|
upstream.on("error", (error) => {
|
|
15090
15096
|
log2(`failed: ${error.message}`);
|
|
15091
15097
|
if (res.headersSent) res.destroy();
|
|
@@ -15697,6 +15703,11 @@ async function restartDaemon() {
|
|
|
15697
15703
|
);
|
|
15698
15704
|
}
|
|
15699
15705
|
|
|
15706
|
+
// src/commands/sessions/web/linkedRequester.ts
|
|
15707
|
+
function linkedRequester(req) {
|
|
15708
|
+
return `from=${req.headers["x-assist-linked-from"] ?? "local"} trace=${req.headers[TRACE_HEADER] ?? "none"}`;
|
|
15709
|
+
}
|
|
15710
|
+
|
|
15700
15711
|
// src/commands/sessions/web/restartMenu/reExecWebServer.ts
|
|
15701
15712
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
15702
15713
|
function resolveExecve() {
|
|
@@ -15735,9 +15746,7 @@ async function restartWeb(req, res, deps2 = {}) {
|
|
|
15735
15746
|
respondJson(res, 400, { error: "Invalid target" });
|
|
15736
15747
|
return;
|
|
15737
15748
|
}
|
|
15738
|
-
console.log(
|
|
15739
|
-
`restart ${target} from=${req.headers["x-assist-linked-from"] ?? "local"} trace=${req.headers[TRACE_HEADER] ?? "none"}`
|
|
15740
|
-
);
|
|
15749
|
+
console.log(`restart ${target} ${linkedRequester(req)}`);
|
|
15741
15750
|
await new Promise((resolve26) => {
|
|
15742
15751
|
res.once("finish", resolve26);
|
|
15743
15752
|
respondJson(res, 200, { ok: true });
|
|
@@ -15861,9 +15870,11 @@ async function runAssistUpdate() {
|
|
|
15861
15870
|
if (result.exitCode !== 0)
|
|
15862
15871
|
throw new Error(`assist update exited with code ${result.exitCode}`);
|
|
15863
15872
|
}
|
|
15864
|
-
async function selfUpdate(
|
|
15873
|
+
async function selfUpdate(req, res, deps2 = {}) {
|
|
15865
15874
|
const { runUpdate = runAssistUpdate, ...restartDeps } = deps2;
|
|
15866
|
-
console.log(
|
|
15875
|
+
console.log(
|
|
15876
|
+
`self-update: requested ${linkedRequester(req)}; running assist update`
|
|
15877
|
+
);
|
|
15867
15878
|
try {
|
|
15868
15879
|
await runUpdate();
|
|
15869
15880
|
} catch (error) {
|