@staff0rd/assist 0.322.2 → 0.323.1
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/commands/sessions/web/bundle.js +57 -57
- package/dist/index.js +39 -17
- 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.323.1",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -21038,7 +21038,18 @@ async function forwardWindowsCreate(conn, state, client, data) {
|
|
|
21038
21038
|
try {
|
|
21039
21039
|
await conn.ensure();
|
|
21040
21040
|
daemonLog("windows proxy: connection ready, forwarding create");
|
|
21041
|
-
|
|
21041
|
+
const timer = setTimeout(() => {
|
|
21042
|
+
const index3 = state.pendingCreators.findIndex((p) => p.timer === timer);
|
|
21043
|
+
if (index3 === -1) return;
|
|
21044
|
+
state.pendingCreators.splice(index3, 1);
|
|
21045
|
+
daemonLog(`windows proxy: create timed out (cwd=${data.cwd})`);
|
|
21046
|
+
sendTo(client, {
|
|
21047
|
+
type: "error",
|
|
21048
|
+
message: "Windows session did not start: the Windows daemon did not respond."
|
|
21049
|
+
});
|
|
21050
|
+
}, state.createTimeoutMs);
|
|
21051
|
+
timer.unref?.();
|
|
21052
|
+
state.pendingCreators.push({ client, timer });
|
|
21042
21053
|
conn.write(stripOutboundSessionId(data));
|
|
21043
21054
|
} catch (error) {
|
|
21044
21055
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -21068,11 +21079,13 @@ function versionsMatch(a, b) {
|
|
|
21068
21079
|
|
|
21069
21080
|
// src/commands/sessions/daemon/WindowsProxyState.ts
|
|
21070
21081
|
var MAX_SCROLLBACK2 = 256 * 1024;
|
|
21071
|
-
|
|
21082
|
+
var DEFAULT_CREATE_TIMEOUT_MS = 15e3;
|
|
21083
|
+
function createState(broadcast2, onSessionsChanged, onVersionMismatch, createTimeoutMs = DEFAULT_CREATE_TIMEOUT_MS) {
|
|
21072
21084
|
return {
|
|
21073
21085
|
windowsSessions: [],
|
|
21074
21086
|
scrollback: /* @__PURE__ */ new Map(),
|
|
21075
21087
|
pendingCreators: [],
|
|
21088
|
+
createTimeoutMs,
|
|
21076
21089
|
broadcast: broadcast2,
|
|
21077
21090
|
onSessionsChanged,
|
|
21078
21091
|
onVersionMismatch
|
|
@@ -21081,6 +21094,20 @@ function createState(broadcast2, onSessionsChanged, onVersionMismatch) {
|
|
|
21081
21094
|
function resetState(state) {
|
|
21082
21095
|
state.windowsSessions = [];
|
|
21083
21096
|
state.scrollback.clear();
|
|
21097
|
+
for (const { timer } of state.pendingCreators) clearTimeout(timer);
|
|
21098
|
+
state.pendingCreators = [];
|
|
21099
|
+
}
|
|
21100
|
+
function takePendingCreator(state) {
|
|
21101
|
+
const pending = state.pendingCreators.shift();
|
|
21102
|
+
if (!pending) return void 0;
|
|
21103
|
+
clearTimeout(pending.timer);
|
|
21104
|
+
return pending.client;
|
|
21105
|
+
}
|
|
21106
|
+
function failPendingCreators(state, message) {
|
|
21107
|
+
for (const { client, timer } of state.pendingCreators) {
|
|
21108
|
+
clearTimeout(timer);
|
|
21109
|
+
sendTo(client, { type: "error", message });
|
|
21110
|
+
}
|
|
21084
21111
|
state.pendingCreators = [];
|
|
21085
21112
|
}
|
|
21086
21113
|
function replayScrollback2(state, client) {
|
|
@@ -21130,7 +21157,7 @@ function handleHello(state, msg) {
|
|
|
21130
21157
|
}
|
|
21131
21158
|
function handleCreated(state, msg) {
|
|
21132
21159
|
daemonLog(`windows daemon: created session ${nsId(msg)}`);
|
|
21133
|
-
const client = state
|
|
21160
|
+
const client = takePendingCreator(state);
|
|
21134
21161
|
if (client)
|
|
21135
21162
|
sendTo(client, {
|
|
21136
21163
|
type: "created",
|
|
@@ -21165,11 +21192,7 @@ function nsId(msg) {
|
|
|
21165
21192
|
// src/commands/sessions/daemon/handleWindowsClose.ts
|
|
21166
21193
|
function handleWindowsClose(state) {
|
|
21167
21194
|
daemonLog("windows proxy: connection to windows daemon closed");
|
|
21168
|
-
|
|
21169
|
-
sendTo(client, {
|
|
21170
|
-
type: "error",
|
|
21171
|
-
message: "Windows daemon connection closed"
|
|
21172
|
-
});
|
|
21195
|
+
failPendingCreators(state, "Windows daemon connection closed");
|
|
21173
21196
|
resetState(state);
|
|
21174
21197
|
state.onSessionsChanged();
|
|
21175
21198
|
}
|
|
@@ -21359,12 +21382,10 @@ async function autoHealWindowsDaemon(conn, state, heal, version2) {
|
|
|
21359
21382
|
}
|
|
21360
21383
|
}
|
|
21361
21384
|
function notifyHealing(state) {
|
|
21362
|
-
|
|
21363
|
-
|
|
21364
|
-
|
|
21365
|
-
|
|
21366
|
-
});
|
|
21367
|
-
state.pendingCreators = [];
|
|
21385
|
+
failPendingCreators(
|
|
21386
|
+
state,
|
|
21387
|
+
"Windows host is out of date; updating it now \u2014 reselect the repo once the update finishes."
|
|
21388
|
+
);
|
|
21368
21389
|
}
|
|
21369
21390
|
|
|
21370
21391
|
// src/commands/sessions/daemon/WindowsVersionHealer.ts
|
|
@@ -21412,11 +21433,12 @@ var WindowsProxy = class {
|
|
|
21412
21433
|
healer;
|
|
21413
21434
|
// why: on the Windows host the proxy would dial its own bridge, self-feeding a log loop and connect churn.
|
|
21414
21435
|
enabled = process.platform !== "win32";
|
|
21415
|
-
constructor(clients, onSessionsChanged, connect4 = defaultConnect, heal = healWindowsDaemon) {
|
|
21436
|
+
constructor(clients, onSessionsChanged, connect4 = defaultConnect, heal = healWindowsDaemon, createTimeoutMs) {
|
|
21416
21437
|
this.state = createState(
|
|
21417
21438
|
(msg) => broadcast(clients, msg),
|
|
21418
21439
|
onSessionsChanged,
|
|
21419
|
-
(version2) => void this.healer.onMismatch(version2)
|
|
21440
|
+
(version2) => void this.healer.onMismatch(version2),
|
|
21441
|
+
createTimeoutMs
|
|
21420
21442
|
);
|
|
21421
21443
|
this.conn = new WindowsConnection({
|
|
21422
21444
|
connect: connect4,
|